Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
suliangchun
dbeaver
提交
997f20aa
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,发现更多精彩内容 >>
提交
997f20aa
编写于
5月 20, 2016
作者:
S
serge-rider
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Command line args processing
Former-commit-id:
5ddfc091
上级
6316f827
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
98 addition
and
5 deletion
+98
-5
plugins/org.jkiss.dbeaver.core.application/META-INF/MANIFEST.MF
...s/org.jkiss.dbeaver.core.application/META-INF/MANIFEST.MF
+2
-1
plugins/org.jkiss.dbeaver.core.application/src/org/jkiss/dbeaver/core/application/DBeaverApplication.java
...rg/jkiss/dbeaver/core/application/DBeaverApplication.java
+57
-4
plugins/org.jkiss.dbeaver.core.application/src/org/jkiss/dbeaver/core/application/DBeaverCommandLine.java
...rg/jkiss/dbeaver/core/application/DBeaverCommandLine.java
+39
-0
未找到文件。
plugins/org.jkiss.dbeaver.core.application/META-INF/MANIFEST.MF
浏览文件 @
997f20aa
...
...
@@ -24,4 +24,5 @@ Require-Bundle: org.jkiss.dbeaver.core,
org.eclipse.e4.ui.css.core,
org.eclipse.e4.ui.css.swt,
org.eclipse.e4.ui.workbench.renderers.swt,
org.w3c.css.sac
org.w3c.css.sac,
org.apache.commons.cli
plugins/org.jkiss.dbeaver.core.application/src/org/jkiss/dbeaver/core/application/DBeaverApplication.java
浏览文件 @
997f20aa
...
...
@@ -17,6 +17,7 @@
*/
package
org.jkiss.dbeaver.core.application
;
import
org.apache.commons.cli.*
;
import
org.eclipse.core.runtime.Platform
;
import
org.eclipse.equinox.app.IApplication
;
import
org.eclipse.equinox.app.IApplicationContext
;
...
...
@@ -28,11 +29,17 @@ import org.eclipse.swt.widgets.Shell;
import
org.eclipse.ui.IWorkbench
;
import
org.eclipse.ui.IWorkbenchPreferenceConstants
;
import
org.eclipse.ui.PlatformUI
;
import
org.jkiss.code.Nullable
;
import
org.jkiss.dbeaver.Log
;
import
org.jkiss.dbeaver.core.DBeaverCore
;
import
org.jkiss.utils.ArrayUtils
;
import
java.io.File
;
import
java.net.URL
;
import
java.util.ArrayList
;
import
java.util.Collections
;
import
java.util.Comparator
;
import
java.util.List
;
/**
* This class controls all aspects of the application's execution
...
...
@@ -42,9 +49,6 @@ public class DBeaverApplication implements IApplication
private
static
final
Log
log
=
Log
.
getLog
(
DBeaverApplication
.
class
);
public
static
final
String
DBEAVER_DEFAULT_DIR
=
".dbeaver"
;
//$NON-NLS-1$
/* (non-Javadoc)
* @see org.eclipse.equinox.app.IApplication#start(org.eclipse.equinox.app.IApplicationContext)
*/
@Override
public
Object
start
(
IApplicationContext
context
)
{
...
...
@@ -53,7 +57,6 @@ public class DBeaverApplication implements IApplication
Location
instanceLoc
=
Platform
.
getInstanceLocation
();
String
defaultHomePath
=
getDefaultWorkspaceLocation
().
getAbsolutePath
();
try
{
URL
defaultHomeURL
=
new
URL
(
"file"
,
//$NON-NLS-1$
null
,
...
...
@@ -62,6 +65,9 @@ public class DBeaverApplication implements IApplication
Shell
shell
=
null
;
while
(
keepTrying
)
{
if
(!
instanceLoc
.
set
(
defaultHomeURL
,
true
))
{
if
(
handleCommandLine
(
instanceLoc
))
{
return
IApplication
.
EXIT_OK
;
}
// Can't lock specified path
if
(
shell
==
null
)
{
shell
=
new
Shell
(
display
,
SWT
.
ON_TOP
);
...
...
@@ -125,6 +131,44 @@ public class DBeaverApplication implements IApplication
}
}
private
boolean
handleCommandLine
(
Location
instanceLoc
)
{
CommandLine
commandLine
=
getCommandLine
();
if
(
commandLine
==
null
)
{
return
false
;
}
String
[]
files
=
commandLine
.
getOptionValues
(
DBeaverCommandLine
.
PARAM_FILE
);
String
[]
fileArgs
=
commandLine
.
getArgs
();
if
(!
ArrayUtils
.
isEmpty
(
files
)
||
!
ArrayUtils
.
isEmpty
(
fileArgs
))
{
List
<
String
>
fileNames
=
new
ArrayList
<>();
if
(!
ArrayUtils
.
isEmpty
(
files
))
{
Collections
.
addAll
(
fileNames
,
files
);
}
if
(!
ArrayUtils
.
isEmpty
(
fileArgs
))
{
Collections
.
addAll
(
fileNames
,
fileArgs
);
}
return
true
;
}
if
(
commandLine
.
hasOption
(
DBeaverCommandLine
.
PARAM_STOP
))
{
return
true
;
}
if
(
commandLine
.
hasOption
(
DBeaverCommandLine
.
PARAM_THREAD_DUMP
))
{
return
true
;
}
if
(
commandLine
.
hasOption
(
DBeaverCommandLine
.
PARAM_HELP
))
{
HelpFormatter
helpFormatter
=
new
HelpFormatter
();
helpFormatter
.
setWidth
(
120
);
helpFormatter
.
setOptionComparator
(
new
Comparator
<
Option
>()
{
@Override
public
int
compare
(
Option
o1
,
Option
o2
)
{
return
0
;
}
});
helpFormatter
.
printHelp
(
"dbeaver"
,
"Universal Database Manager"
,
DBeaverCommandLine
.
ALL_OPTIONS
,
"(C) 2016 Serge Rider"
,
true
);
return
true
;
}
return
false
;
}
private
static
File
getDefaultWorkspaceLocation
()
{
return
new
File
(
System
.
getProperty
(
"user.home"
),
...
...
@@ -153,5 +197,14 @@ public class DBeaverApplication implements IApplication
});
}
@Nullable
public
static
CommandLine
getCommandLine
()
{
try
{
return
new
DefaultParser
().
parse
(
DBeaverCommandLine
.
ALL_OPTIONS
,
Platform
.
getApplicationArgs
(),
false
);
}
catch
(
Exception
e
)
{
log
.
error
(
"Error parsing command line"
,
e
);
return
null
;
}
}
}
plugins/org.jkiss.dbeaver.core.application/src/org/jkiss/dbeaver/core/application/DBeaverCommandLine.java
0 → 100644
浏览文件 @
997f20aa
/*
* DBeaver - Universal Database Manager
* Copyright (C) 2010-2016 Serge Rieder (serge@jkiss.org)
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License (version 2)
* as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program; if not, write to the Free Software Foundation, Inc.,
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
package
org.jkiss.dbeaver.core.application
;
import
org.apache.commons.cli.Options
;
/**
* command line options
*/
public
class
DBeaverCommandLine
{
public
static
final
String
PARAM_HELP
=
"help"
;
public
static
final
String
PARAM_FILE
=
"f"
;
public
static
final
String
PARAM_STOP
=
"stop"
;
public
static
final
String
PARAM_THREAD_DUMP
=
"dump"
;
public
final
static
Options
ALL_OPTIONS
=
new
Options
()
.
addOption
(
PARAM_HELP
,
false
,
"Help"
)
.
addOption
(
PARAM_FILE
,
"file"
,
true
,
"File top open"
)
.
addOption
(
PARAM_STOP
,
"quit"
,
true
,
"Stop DBeaver running instance"
)
.
addOption
(
PARAM_THREAD_DUMP
,
"thread-dump"
,
true
,
"Print instance thread dump"
)
;
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录