Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
suliangchun
dbeaver
提交
bef602e3
D
dbeaver
项目概览
suliangchun
/
dbeaver
与 Fork 源项目一致
从无法访问的项目Fork
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
D
dbeaver
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
bef602e3
编写于
10月 14, 2017
作者:
A
Alexander Fedorov
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
#2297 add "Link File" action
上级
39b5efb1
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
298 addition
and
90 deletion
+298
-90
plugins/org.jkiss.dbeaver.core/OSGI-INF/l10n/bundle.properties
...ns/org.jkiss.dbeaver.core/OSGI-INF/l10n/bundle.properties
+3
-0
plugins/org.jkiss.dbeaver.core/OSGI-INF/l10n/bundle_ru.properties
...org.jkiss.dbeaver.core/OSGI-INF/l10n/bundle_ru.properties
+4
-1
plugins/org.jkiss.dbeaver.core/plugin.xml
plugins/org.jkiss.dbeaver.core/plugin.xml
+36
-4
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/runtime/ContentTypeParameterValues.java
...org/jkiss/dbeaver/runtime/ContentTypeParameterValues.java
+24
-0
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/actions/navigator/NavigatorHandlerCreateLink.java
...aver/ui/actions/navigator/NavigatorHandlerCreateLink.java
+103
-85
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/actions/navigator/NavigatorHandlerLinkFile.java
...beaver/ui/actions/navigator/NavigatorHandlerLinkFile.java
+77
-0
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/actions/navigator/NavigatorHandlerLinkFolder.java
...aver/ui/actions/navigator/NavigatorHandlerLinkFolder.java
+51
-0
未找到文件。
plugins/org.jkiss.dbeaver.core/OSGI-INF/l10n/bundle.properties
浏览文件 @
bef602e3
...
...
@@ -68,6 +68,9 @@ command.org.jkiss.dbeaver.core.project.select.name=Select Active Project
command.org.jkiss.dbeaver.core.project.select.description
=
Select active project
command.org.jkiss.dbeaver.core.resource.create.folder.name
=
Create New Folder
command.org.jkiss.dbeaver.core.resource.create.folder.description
=
Create new folder
command.org.jkiss.dbeaver.core.resource.link.file.name
=
Link File
command.org.jkiss.dbeaver.core.resource.link.file.description
=
Create link to some file on file system
commandParameter.org.jkiss.dbeaver.core.resource.link.file.contenttype.name
=
Linked file content type
command.org.jkiss.dbeaver.core.resource.link.folder.name
=
Link Folder
command.org.jkiss.dbeaver.core.resource.link.folder.description
=
Create link to some folder on file system
command.org.jkiss.dbeaver.core.sql.script.associate.name
=
Associate with data source
...
...
plugins/org.jkiss.dbeaver.core/OSGI-INF/l10n/bundle_ru.properties
浏览文件 @
bef602e3
...
...
@@ -36,7 +36,10 @@ command.org.jkiss.dbeaver.core.project.select.name=\u0412\u044B\u0431\u0440\u043
command.org.jkiss.dbeaver.core.project.select.description
=
\u0412\u
044B
\u0431\u0440\u0430\u0442\u
044C
\u0430\u
043A
\u0442\u0438\u0432\u
043D
\u
044B
\u0439
\u
043F
\u0440\u
043E
\u0435\u
043A
\u0442
command.org.jkiss.dbeaver.core.resource.create.folder.name
=
\u
041D
\u
043E
\u0432\u0430\u
044F
\u
043F
\u0430\u
043F
\u
043A
\u0430
command.org.jkiss.dbeaver.core.resource.create.folder.description
=
\u0421\u
043E
\u0437\u0434\u0430\u0442\u
044C
\u
043D
\u
043E
\u0432\u0443\u
044E
\u
043F
\u0430\u
043F
\u
043A
\u0443
command.org.jkiss.dbeaver.core.resource.link.folder.name
=
\u0421\u
043E
\u0437\u0434\u0430\u0442\u
044C
\u0441\u0441\u
044B
\u
043B
\u
043A
\u0443
command.org.jkiss.dbeaver.core.resource.link.file.name
=
\u0421\u
043E
\u0437\u0434\u0430\u0442\u
044C
\u0441\u0441\u
044B
\u
043B
\u
043A
\u0443
\u
043D
\u0430
\u0444\u0430\u0439\u
043B
command.org.jkiss.dbeaver.core.resource.link.file.description
=
\u0421\u
043E
\u0437\u0434\u0430\u0442\u
044C
\u0441\u0441\u
044B
\u
043B
\u
043A
\u0443
\u
043D
\u0430
\u0444\u0430\u0439\u
043B
\u0432
\u0444\u0430\u0439\u
043B
\u
043E
\u0432\u
043E
\u0439
\u0441\u0438\u0441\u0442\u0435\u
043C
\u0435
commandParameter.org.jkiss.dbeaver.core.resource.link.file.contenttype.name
=
Linked file content type
command.org.jkiss.dbeaver.core.resource.link.folder.name
=
\u0421\u
043E
\u0437\u0434\u0430\u0442\u
044C
\u0441\u0441\u
044B
\u
043B
\u
043A
\u0443
\u
043D
\u0430
\u
043F
\u0430\u
043F
\u
043A
\u0443
command.org.jkiss.dbeaver.core.resource.link.folder.description
=
\u0421\u
043E
\u0437\u0434\u0430\u0442\u
044C
\u0441\u0441\u
044B
\u
043B
\u
043A
\u0443
\u
043D
\u0430
\u
043F
\u0430\u
043F
\u
043A
\u0443
\u0432
\u0444\u0430\u0439\u
043B
\u
043E
\u0432\u
043E
\u0439
\u0441\u0438\u0441\u0442\u0435\u
043C
\u0435
command.org.jkiss.dbeaver.core.sql.script.associate.name
=
\u0421\u0432\u
044F
\u0437\u0430\u0442\u
044C
\u0441
\u0431\u0430\u0437\u
043E
\u0439
\u0434\u0430\u
043D
\u
043D
\u
044B
\u0445
command.org.jkiss.dbeaver.core.sql.script.associate.description
=
\u0421\u0432\u
044F
\u0437\u0430\u0442\u
044C
\u0441\u
043A
\u0440\u0438\u
043F(
\u
044B)
\u0441
\u0431\u0430\u0437\u
043E
\u0439
\u0434\u0430\u
043D
\u
043D
\u
044B
\u0445
...
...
plugins/org.jkiss.dbeaver.core/plugin.xml
浏览文件 @
bef602e3
...
...
@@ -217,7 +217,19 @@
<command
id=
"org.jkiss.dbeaver.core.project.active"
name=
"%command.org.jkiss.dbeaver.core.project.active.name"
description=
"%command.org.jkiss.dbeaver.core.project.active.description"
categoryId=
"org.jkiss.dbeaver.core.navigator"
/>
<command
id=
"org.jkiss.dbeaver.core.project.select"
name=
"%command.org.jkiss.dbeaver.core.project.select.name"
description=
"%command.org.jkiss.dbeaver.core.project.select.description"
categoryId=
"org.jkiss.dbeaver.core.navigator"
/>
<command
id=
"org.jkiss.dbeaver.core.resource.create.folder"
name=
"%command.org.jkiss.dbeaver.core.resource.create.folder.name"
description=
"%command.org.jkiss.dbeaver.core.resource.create.folder.description"
categoryId=
"org.jkiss.dbeaver.core.navigator"
/>
<command
id=
"org.jkiss.dbeaver.core.resource.create.link"
name=
"%command.org.jkiss.dbeaver.core.resource.link.folder.name"
description=
"%command.org.jkiss.dbeaver.core.resource.link.folder.description"
categoryId=
"org.jkiss.dbeaver.core.navigator"
/>
<command
categoryId=
"org.jkiss.dbeaver.core.navigator"
description=
"%command.org.jkiss.dbeaver.core.resource.link.file.description"
id=
"org.jkiss.dbeaver.core.resource.link.file"
name=
"%command.org.jkiss.dbeaver.core.resource.link.file.name"
>
<commandParameter
id=
"org.jkiss.dbeaver.core.resource.link.file.contenttype"
name=
"%commandParameter.org.jkiss.dbeaver.core.resource.link.file.contenttype.name"
optional=
"true"
values=
"org.jkiss.dbeaver.runtime.ContentTypeParameterValues"
>
</commandParameter>
</command>
<command
id=
"org.jkiss.dbeaver.core.resource.link.folder"
name=
"%command.org.jkiss.dbeaver.core.resource.link.folder.name"
description=
"%command.org.jkiss.dbeaver.core.resource.link.folder.description"
categoryId=
"org.jkiss.dbeaver.core.navigator"
/>
<command
id=
"org.jkiss.dbeaver.core.sql.script.associate"
name=
"%command.org.jkiss.dbeaver.core.sql.script.associate.name"
description=
"%command.org.jkiss.dbeaver.core.sql.script.associate.description"
categoryId=
"org.jkiss.dbeaver.core.navigator"
/>
<command
id=
"org.jkiss.dbeaver.core.connect"
name=
"%command.org.jkiss.dbeaver.core.connect.name"
description=
"%command.org.jkiss.dbeaver.core.connect.description"
categoryId=
"org.jkiss.dbeaver.core.database"
/>
...
...
@@ -343,7 +355,8 @@
<image
commandId=
"org.jkiss.dbeaver.core.project.refresh"
icon=
"icons/refresh.png"
/>
<image
commandId=
"org.jkiss.dbeaver.core.project.select"
icon=
"icons/project.png"
/>
<image
commandId=
"org.jkiss.dbeaver.core.resource.create.folder"
icon=
"IMG_TOOL_NEW_WIZARD"
/>
<image
commandId=
"org.jkiss.dbeaver.core.resource.create.link"
icon=
"icons/file/link.png"
/>
<image
commandId=
"org.jkiss.dbeaver.core.resource.link.file"
icon=
"icons/file/link.png"
/>
<image
commandId=
"org.jkiss.dbeaver.core.resource.link.folder"
icon=
"icons/file/link.png"
/>
<image
commandId=
"org.jkiss.dbeaver.core.sql.editor.open"
icon=
"icons/sql/sql_script.png"
/>
<image
commandId=
"org.jkiss.dbeaver.core.sql.editor.recent"
icon=
"icons/sql/sql_script_recent.png"
/>
...
...
@@ -574,7 +587,19 @@
</with>
</enabledWhen>
</handler>
<handler
commandId=
"org.jkiss.dbeaver.core.resource.create.link"
class=
"org.jkiss.dbeaver.ui.actions.navigator.NavigatorHandlerCreateLink"
>
<handler
commandId=
"org.jkiss.dbeaver.core.resource.link.file"
class=
"org.jkiss.dbeaver.ui.actions.navigator.NavigatorHandlerLinkFile"
>
<enabledWhen>
<with
variable=
"selection"
>
<count
value=
"1"
/>
<iterate
operator=
"and"
>
<adapt
type=
"org.eclipse.core.resources.IResource"
>
<test
property=
"org.jkiss.dbeaver.core.resource.canCreateLink"
/>
</adapt>
</iterate>
</with>
</enabledWhen>
</handler>
<handler
commandId=
"org.jkiss.dbeaver.core.resource.link.folder"
class=
"org.jkiss.dbeaver.ui.actions.navigator.NavigatorHandlerLinkFolder"
>
<enabledWhen>
<with
variable=
"selection"
>
<count
value=
"1"
/>
...
...
@@ -1827,7 +1852,14 @@
<command
commandId=
"org.jkiss.dbeaver.core.resource.create.folder"
>
<visibleWhen
checkEnabled=
"true"
/>
</command>
<command
commandId=
"org.jkiss.dbeaver.core.resource.create.link"
>
<command
commandId=
"org.jkiss.dbeaver.core.resource.link.file"
>
<parameter
name=
"org.jkiss.dbeaver.core.resource.link.file.contenttype"
value=
"org.jkiss.dbeaver.sql"
>
</parameter>
<visibleWhen
checkEnabled=
"true"
/>
</command>
<command
commandId=
"org.jkiss.dbeaver.core.resource.link.folder"
>
<visibleWhen
checkEnabled=
"true"
/>
</command>
...
...
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/runtime/ContentTypeParameterValues.java
0 → 100644
浏览文件 @
bef602e3
package
org.jkiss.dbeaver.runtime
;
import
java.util.HashMap
;
import
java.util.Map
;
import
org.eclipse.core.commands.IParameterValues
;
import
org.eclipse.core.runtime.Platform
;
import
org.eclipse.core.runtime.content.IContentType
;
public
class
ContentTypeParameterValues
implements
IParameterValues
{
@SuppressWarnings
({
"rawtypes"
,
"unchecked"
})
@Override
public
Map
getParameterValues
()
{
final
Map
values
=
new
HashMap
();
IContentType
[]
allContentTypes
=
Platform
.
getContentTypeManager
().
getAllContentTypes
();
for
(
IContentType
contentType
:
allContentTypes
)
{
values
.
put
(
contentType
.
getName
(),
contentType
.
getId
());
}
return
values
;
}
}
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/actions/navigator/NavigatorHandlerCreateLink.java
浏览文件 @
bef602e3
/*
* DBeaver - Universal Database Manager
* Copyright (C) 2010-2017 Serge Rider (serge@jkiss.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
org.jkiss.dbeaver.ui.actions.navigator
;
import
org.eclipse.core.commands.ExecutionEvent
;
import
org.eclipse.core.commands.ExecutionException
;
import
org.eclipse.core.resources.IFolder
;
import
org.eclipse.core.resources.IResource
;
import
org.eclipse.core.runtime.CoreException
;
import
org.eclipse.core.runtime.IProgressMonitor
;
import
org.eclipse.jface.operation.IRunnableWithProgress
;
import
org.eclipse.jface.viewers.ISelection
;
import
org.eclipse.jface.viewers.IStructuredSelection
;
import
org.eclipse.swt.SWT
;
import
org.eclipse.swt.widgets.DirectoryDialog
;
import
org.eclipse.ui.IWorkbenchWindow
;
import
org.eclipse.ui.handlers.HandlerUtil
;
import
org.jkiss.dbeaver.model.navigator.DBNResource
;
import
org.jkiss.dbeaver.runtime.ui.DBUserInterface
;
import
java.io.File
;
import
java.lang.reflect.InvocationTargetException
;
public
class
NavigatorHandlerCreateLink
extends
NavigatorHandlerObjectBase
{
@Override
public
Object
execute
(
ExecutionEvent
event
)
throws
ExecutionException
{
final
ISelection
selection
=
HandlerUtil
.
getCurrentSelection
(
event
);
if
(
selection
instanceof
IStructuredSelection
)
{
final
IStructuredSelection
structSelection
=
(
IStructuredSelection
)
selection
;
Object
element
=
structSelection
.
getFirstElement
();
if
(!(
element
instanceof
DBNResource
))
{
return
null
;
}
final
IResource
resource
=
((
DBNResource
)
element
).
getResource
();
if
(
resource
instanceof
IFolder
)
{
final
IWorkbenchWindow
workbenchWindow
=
HandlerUtil
.
getActiveWorkbenchWindow
(
event
);
DirectoryDialog
dialog
=
new
DirectoryDialog
(
workbenchWindow
.
getShell
(),
SWT
.
NONE
);
String
folder
=
dialog
.
open
();
if
(
folder
!=
null
)
{
createLink
(
workbenchWindow
,
(
IFolder
)
resource
,
folder
);
}
}
}
return
null
;
}
private
void
createLink
(
IWorkbenchWindow
workbenchWindow
,
IFolder
folder
,
String
fsFolder
)
{
final
File
externalFolder
=
new
File
(
fsFolder
);
try
{
final
IFolder
linkedFolder
=
folder
.
getFolder
(
externalFolder
.
getName
());
workbenchWindow
.
run
(
true
,
true
,
new
IRunnableWithProgress
()
{
@Override
public
void
run
(
IProgressMonitor
monitor
)
throws
InvocationTargetException
,
InterruptedException
{
try
{
linkedFolder
.
createLink
(
externalFolder
.
toURI
(),
IResource
.
NONE
,
monitor
);
}
catch
(
CoreException
e
)
{
throw
new
InvocationTargetException
(
e
);
}
}
});
}
catch
(
InvocationTargetException
e
)
{
DBUserInterface
.
getInstance
().
showError
(
"Create link"
,
"Can't create link"
,
e
);
}
catch
(
InterruptedException
e
)
{
// skip
}
}
/*
* DBeaver - Universal Database Manager
* Copyright (C) 2010-2017 Serge Rider (serge@jkiss.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
org.jkiss.dbeaver.ui.actions.navigator
;
import
java.lang.reflect.InvocationTargetException
;
import
org.eclipse.core.commands.AbstractHandler
;
import
org.eclipse.core.commands.ExecutionEvent
;
import
org.eclipse.core.commands.ExecutionException
;
import
org.eclipse.core.resources.IContainer
;
import
org.eclipse.core.resources.IResource
;
import
org.eclipse.core.runtime.Adapters
;
import
org.eclipse.core.runtime.CoreException
;
import
org.eclipse.core.runtime.IProgressMonitor
;
import
org.eclipse.core.runtime.IStatus
;
import
org.eclipse.core.runtime.Status
;
import
org.eclipse.jface.operation.IRunnableContext
;
import
org.eclipse.jface.viewers.IStructuredSelection
;
import
org.eclipse.osgi.util.NLS
;
import
org.eclipse.ui.IWorkbenchWindow
;
import
org.eclipse.ui.PlatformUI
;
import
org.eclipse.ui.actions.WorkspaceModifyOperation
;
import
org.eclipse.ui.handlers.HandlerUtil
;
import
org.jkiss.dbeaver.core.DBeaverCore
;
import
org.jkiss.dbeaver.runtime.ui.DBUserInterface
;
public
abstract
class
NavigatorHandlerCreateLink
extends
AbstractHandler
{
@Override
public
Object
execute
(
ExecutionEvent
event
)
throws
ExecutionException
{
IStructuredSelection
structured
=
HandlerUtil
.
getCurrentStructuredSelection
(
event
);
if
(
structured
.
isEmpty
())
{
return
null
;
}
Object
first
=
structured
.
getFirstElement
();
IResource
resource
=
Adapters
.
adapt
(
first
,
IResource
.
class
);
IStatus
validation
=
validateSelected
(
resource
);
if
(!
validation
.
isOK
())
{
DBUserInterface
.
getInstance
().
showError
(
"Create link"
,
validation
.
getMessage
());
return
null
;
}
String
path
=
selectTarget
(
event
);
if
(
path
==
null
)
{
return
null
;
}
WorkspaceModifyOperation
operation
=
new
WorkspaceModifyOperation
()
{
@Override
protected
void
execute
(
IProgressMonitor
monitor
)
throws
CoreException
,
InvocationTargetException
,
InterruptedException
{
createLink
(
resource
,
path
,
monitor
);
}
};
IRunnableContext
context
=
getRunnableContext
(
event
);
try
{
context
.
run
(
true
,
true
,
operation
);
}
catch
(
InvocationTargetException
e
)
{
DBUserInterface
.
getInstance
().
showError
(
"Create link"
,
"Unable to create link"
,
e
);
}
catch
(
InterruptedException
e
)
{
// skip
}
return
null
;
}
protected
IStatus
validateSelected
(
IResource
resource
)
{
if
(
resource
instanceof
IContainer
)
{
return
Status
.
OK_STATUS
;
}
String
message
=
NLS
.
bind
(
"Unable to create link inside {0}"
,
resource
);
return
new
Status
(
IStatus
.
ERROR
,
DBeaverCore
.
getCorePluginID
(),
message
);
}
protected
abstract
String
selectTarget
(
ExecutionEvent
event
);
protected
IRunnableContext
getRunnableContext
(
ExecutionEvent
event
)
{
final
IWorkbenchWindow
activeWindow
=
HandlerUtil
.
getActiveWorkbenchWindow
(
event
);
if
(
activeWindow
!=
null
)
{
return
activeWindow
;
}
return
PlatformUI
.
getWorkbench
().
getProgressService
();
}
protected
abstract
void
createLink
(
IResource
resource
,
String
path
,
IProgressMonitor
monitor
)
throws
CoreException
;
}
\ No newline at end of file
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/actions/navigator/NavigatorHandlerLinkFile.java
0 → 100644
浏览文件 @
bef602e3
/*
* DBeaver - Universal Database Manager
* Copyright (C) 2010-2017 Serge Rider (serge@jkiss.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
org.jkiss.dbeaver.ui.actions.navigator
;
import
java.io.File
;
import
org.eclipse.core.commands.ExecutionEvent
;
import
org.eclipse.core.resources.IFile
;
import
org.eclipse.core.resources.IFolder
;
import
org.eclipse.core.resources.IResource
;
import
org.eclipse.core.runtime.CoreException
;
import
org.eclipse.core.runtime.IProgressMonitor
;
import
org.eclipse.core.runtime.Platform
;
import
org.eclipse.core.runtime.content.IContentType
;
import
org.eclipse.swt.SWT
;
import
org.eclipse.swt.widgets.FileDialog
;
import
org.eclipse.swt.widgets.Shell
;
import
org.eclipse.ui.handlers.HandlerUtil
;
public
class
NavigatorHandlerLinkFile
extends
NavigatorHandlerCreateLink
{
private
static
final
String
COMMAND_PARAMETER_LINK_FILE_CONTENTTYPE
=
"org.jkiss.dbeaver.core.resource.link.file.contenttype"
;
//$NON-NLS-1$
@Override
protected
String
selectTarget
(
ExecutionEvent
event
)
{
Shell
shell
=
HandlerUtil
.
getActiveShell
(
event
);
FileDialog
dialog
=
new
FileDialog
(
shell
,
SWT
.
NONE
);
String
contentTypeId
=
event
.
getParameter
(
COMMAND_PARAMETER_LINK_FILE_CONTENTTYPE
);
if
(
contentTypeId
!=
null
)
{
IContentType
contentType
=
Platform
.
getContentTypeManager
().
getContentType
(
contentTypeId
);
if
(
contentType
!=
null
)
{
StringBuilder
sb
=
new
StringBuilder
();
String
[]
fileSpecs
=
contentType
.
getFileSpecs
(
IContentType
.
FILE_EXTENSION_SPEC
);
for
(
String
extension
:
fileSpecs
)
{
if
(
sb
.
length
()
>
0
)
{
sb
.
append
(
';'
);
}
sb
.
append
(
'*'
).
append
(
'.'
).
append
(
extension
);
}
if
(
sb
.
length
()
>
0
)
{
String
[]
names
=
new
String
[]
{
contentType
.
getName
()};
String
[]
extensions
=
new
String
[]
{
sb
.
toString
()};
dialog
.
setFilterNames
(
names
);
dialog
.
setFilterExtensions
(
extensions
);
}
}
}
String
file
=
dialog
.
open
();
return
file
;
}
@Override
protected
void
createLink
(
IResource
resource
,
String
path
,
IProgressMonitor
monitor
)
throws
CoreException
{
IFolder
container
=
(
IFolder
)
resource
;
final
File
externalFolder
=
new
File
(
path
);
final
IFile
linked
=
container
.
getFile
(
externalFolder
.
getName
());
linked
.
createLink
(
externalFolder
.
toURI
(),
IResource
.
NONE
,
monitor
);
}
}
\ No newline at end of file
plugins/org.jkiss.dbeaver.core/src/org/jkiss/dbeaver/ui/actions/navigator/NavigatorHandlerLinkFolder.java
0 → 100644
浏览文件 @
bef602e3
/*
* DBeaver - Universal Database Manager
* Copyright (C) 2010-2017 Serge Rider (serge@jkiss.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package
org.jkiss.dbeaver.ui.actions.navigator
;
import
java.io.File
;
import
org.eclipse.core.commands.ExecutionEvent
;
import
org.eclipse.core.resources.IFolder
;
import
org.eclipse.core.resources.IResource
;
import
org.eclipse.core.runtime.CoreException
;
import
org.eclipse.core.runtime.IProgressMonitor
;
import
org.eclipse.swt.SWT
;
import
org.eclipse.swt.widgets.DirectoryDialog
;
import
org.eclipse.swt.widgets.Shell
;
import
org.eclipse.ui.handlers.HandlerUtil
;
public
class
NavigatorHandlerLinkFolder
extends
NavigatorHandlerCreateLink
{
@Override
protected
String
selectTarget
(
ExecutionEvent
event
)
{
Shell
shell
=
HandlerUtil
.
getActiveShell
(
event
);
DirectoryDialog
dialog
=
new
DirectoryDialog
(
shell
,
SWT
.
NONE
);
String
folder
=
dialog
.
open
();
return
folder
;
}
@Override
protected
void
createLink
(
IResource
resource
,
String
path
,
IProgressMonitor
monitor
)
throws
CoreException
{
IFolder
container
=
(
IFolder
)
resource
;
final
File
externalFolder
=
new
File
(
path
);
final
IFolder
linkedFolder
=
container
.
getFolder
(
externalFolder
.
getName
());
linkedFolder
.
createLink
(
externalFolder
.
toURI
(),
IResource
.
NONE
,
monitor
);
}
}
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录