Skip to content
项目
群组
代码片段
帮助
正在加载...
帮助
为 GitLab 提交贡献
登录/注册
切换导航
H
h2database
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
分枝图
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
计划
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
分枝图
统计图
创建新议题
作业
提交
议题看板
打开侧边栏
Administrator
h2database
Commits
4653aa5b
提交
4653aa5b
authored
2月 07, 2019
作者:
Evgenij Ryazanov
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add database creation capability to GUIConsole
上级
7adea496
显示空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
209 行增加
和
26 行删除
+209
-26
GUIConsole.java
h2/src/main/org/h2/tools/GUIConsole.java
+208
-25
dictionary.txt
h2/src/tools/org/h2/build/doc/dictionary.txt
+1
-1
没有找到文件。
h2/src/main/org/h2/tools/GUIConsole.java
浏览文件 @
4653aa5b
...
@@ -6,6 +6,7 @@
...
@@ -6,6 +6,7 @@
package
org
.
h2
.
tools
;
package
org
.
h2
.
tools
;
import
java.awt.Button
;
import
java.awt.Button
;
import
java.awt.Color
;
import
java.awt.Dimension
;
import
java.awt.Dimension
;
import
java.awt.Font
;
import
java.awt.Font
;
import
java.awt.Frame
;
import
java.awt.Frame
;
...
@@ -19,8 +20,10 @@ import java.awt.MenuItem;
...
@@ -19,8 +20,10 @@ import java.awt.MenuItem;
import
java.awt.Panel
;
import
java.awt.Panel
;
import
java.awt.PopupMenu
;
import
java.awt.PopupMenu
;
import
java.awt.SystemColor
;
import
java.awt.SystemColor
;
import
java.awt.TextArea
;
import
java.awt.TextField
;
import
java.awt.TextField
;
import
java.awt.Toolkit
;
import
java.awt.Toolkit
;
import
java.awt.Window
;
import
java.awt.event.ActionEvent
;
import
java.awt.event.ActionEvent
;
import
java.awt.event.ActionListener
;
import
java.awt.event.ActionListener
;
import
java.awt.event.MouseEvent
;
import
java.awt.event.MouseEvent
;
...
@@ -28,6 +31,7 @@ import java.awt.event.MouseListener;
...
@@ -28,6 +31,7 @@ import java.awt.event.MouseListener;
import
java.awt.event.WindowEvent
;
import
java.awt.event.WindowEvent
;
import
java.awt.event.WindowListener
;
import
java.awt.event.WindowListener
;
import
java.io.IOException
;
import
java.io.IOException
;
import
java.sql.DriverManager
;
import
java.util.Locale
;
import
java.util.Locale
;
import
java.util.concurrent.TimeUnit
;
import
java.util.concurrent.TimeUnit
;
...
@@ -39,11 +43,18 @@ import org.h2.util.Utils;
...
@@ -39,11 +43,18 @@ import org.h2.util.Utils;
public
class
GUIConsole
extends
Console
implements
ActionListener
,
MouseListener
,
WindowListener
{
public
class
GUIConsole
extends
Console
implements
ActionListener
,
MouseListener
,
WindowListener
{
private
long
lastOpenNs
;
private
long
lastOpenNs
;
private
Frame
frame
;
private
boolean
trayIconUsed
;
private
boolean
trayIconUsed
;
private
Font
font
;
private
Font
font
;
private
Button
startBrowser
;
private
Frame
statusFrame
;
private
TextField
urlText
;
private
TextField
urlText
;
private
Button
startBrowser
;
private
Frame
createFrame
;
private
TextField
pathField
,
userField
,
passwordField
;
private
Button
createButton
;
private
TextArea
errorArea
;
private
Object
tray
;
private
Object
tray
;
private
Object
trayIcon
;
private
Object
trayIcon
;
...
@@ -53,7 +64,7 @@ public class GUIConsole extends Console implements ActionListener, MouseListener
...
@@ -53,7 +64,7 @@ public class GUIConsole extends Console implements ActionListener, MouseListener
loadFont
();
loadFont
();
try
{
try
{
if
(!
createTrayIcon
())
{
if
(!
createTrayIcon
())
{
showWindow
();
show
Status
Window
();
}
}
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
e
.
printStackTrace
();
...
@@ -77,9 +88,9 @@ public class GUIConsole extends Console implements ActionListener, MouseListener
...
@@ -77,9 +88,9 @@ public class GUIConsole extends Console implements ActionListener, MouseListener
@Override
@Override
public
void
shutdown
()
{
public
void
shutdown
()
{
super
.
shutdown
();
super
.
shutdown
();
if
(
f
rame
!=
null
)
{
if
(
statusF
rame
!=
null
)
{
f
rame
.
dispose
();
statusF
rame
.
dispose
();
f
rame
=
null
;
statusF
rame
=
null
;
}
}
if
(
trayIconUsed
)
{
if
(
trayIconUsed
)
{
try
{
try
{
...
@@ -129,6 +140,11 @@ public class GUIConsole extends Console implements ActionListener, MouseListener
...
@@ -129,6 +140,11 @@ public class GUIConsole extends Console implements ActionListener, MouseListener
itemConsole
.
addActionListener
(
this
);
itemConsole
.
addActionListener
(
this
);
itemConsole
.
setFont
(
font
);
itemConsole
.
setFont
(
font
);
menuConsole
.
add
(
itemConsole
);
menuConsole
.
add
(
itemConsole
);
MenuItem
itemCreate
=
new
MenuItem
(
"Create a new database..."
);
itemCreate
.
setActionCommand
(
"showCreate"
);
itemCreate
.
addActionListener
(
this
);
itemCreate
.
setFont
(
font
);
menuConsole
.
add
(
itemCreate
);
MenuItem
itemStatus
=
new
MenuItem
(
"Status"
);
MenuItem
itemStatus
=
new
MenuItem
(
"Status"
);
itemStatus
.
setActionCommand
(
"status"
);
itemStatus
.
setActionCommand
(
"status"
);
itemStatus
.
addActionListener
(
this
);
itemStatus
.
addActionListener
(
this
);
...
@@ -178,21 +194,21 @@ public class GUIConsole extends Console implements ActionListener, MouseListener
...
@@ -178,21 +194,21 @@ public class GUIConsole extends Console implements ActionListener, MouseListener
}
}
}
}
private
void
showWindow
()
{
private
void
show
Status
Window
()
{
if
(
f
rame
!=
null
)
{
if
(
statusF
rame
!=
null
)
{
return
;
return
;
}
}
f
rame
=
new
Frame
(
"H2 Console"
);
statusF
rame
=
new
Frame
(
"H2 Console"
);
f
rame
.
addWindowListener
(
this
);
statusF
rame
.
addWindowListener
(
this
);
Image
image
=
loadImage
(
"/org/h2/res/h2.png"
);
Image
image
=
loadImage
(
"/org/h2/res/h2.png"
);
if
(
image
!=
null
)
{
if
(
image
!=
null
)
{
f
rame
.
setIconImage
(
image
);
statusF
rame
.
setIconImage
(
image
);
}
}
f
rame
.
setResizable
(
false
);
statusF
rame
.
setResizable
(
false
);
f
rame
.
setBackground
(
SystemColor
.
control
);
statusF
rame
.
setBackground
(
SystemColor
.
control
);
GridBagLayout
layout
=
new
GridBagLayout
();
GridBagLayout
layout
=
new
GridBagLayout
();
f
rame
.
setLayout
(
layout
);
statusF
rame
.
setLayout
(
layout
);
// the main panel keeps everything together
// the main panel keeps everything together
Panel
mainPanel
=
new
Panel
(
layout
);
Panel
mainPanel
=
new
Panel
(
layout
);
...
@@ -242,15 +258,15 @@ public class GUIConsole extends Console implements ActionListener, MouseListener
...
@@ -242,15 +258,15 @@ public class GUIConsole extends Console implements ActionListener, MouseListener
startBrowser
.
addActionListener
(
this
);
startBrowser
.
addActionListener
(
this
);
startBrowser
.
setFont
(
font
);
startBrowser
.
setFont
(
font
);
mainPanel
.
add
(
startBrowser
,
constraintsButton
);
mainPanel
.
add
(
startBrowser
,
constraintsButton
);
f
rame
.
add
(
mainPanel
,
constraintsPanel
);
statusF
rame
.
add
(
mainPanel
,
constraintsPanel
);
int
width
=
300
,
height
=
120
;
int
width
=
300
,
height
=
120
;
f
rame
.
setSize
(
width
,
height
);
statusF
rame
.
setSize
(
width
,
height
);
Dimension
screenSize
=
Toolkit
.
getDefaultToolkit
().
getScreenSize
();
Dimension
screenSize
=
Toolkit
.
getDefaultToolkit
().
getScreenSize
();
f
rame
.
setLocation
((
screenSize
.
width
-
width
)
/
2
,
statusF
rame
.
setLocation
((
screenSize
.
width
-
width
)
/
2
,
(
screenSize
.
height
-
height
)
/
2
);
(
screenSize
.
height
-
height
)
/
2
);
try
{
try
{
f
rame
.
setVisible
(
true
);
statusF
rame
.
setVisible
(
true
);
}
catch
(
Throwable
t
)
{
}
catch
(
Throwable
t
)
{
// ignore
// ignore
// some systems don't support this method, for example IKVM
// some systems don't support this method, for example IKVM
...
@@ -258,8 +274,8 @@ public class GUIConsole extends Console implements ActionListener, MouseListener
...
@@ -258,8 +274,8 @@ public class GUIConsole extends Console implements ActionListener, MouseListener
}
}
try
{
try
{
// ensure this window is in front of the browser
// ensure this window is in front of the browser
f
rame
.
setAlwaysOnTop
(
true
);
statusF
rame
.
setAlwaysOnTop
(
true
);
f
rame
.
setAlwaysOnTop
(
false
);
statusF
rame
.
setAlwaysOnTop
(
false
);
}
catch
(
Throwable
t
)
{
}
catch
(
Throwable
t
)
{
// ignore
// ignore
}
}
...
@@ -279,6 +295,161 @@ public class GUIConsole extends Console implements ActionListener, MouseListener
...
@@ -279,6 +295,161 @@ public class GUIConsole extends Console implements ActionListener, MouseListener
}
}
}
}
private
void
showCreateDatabase
()
{
if
(
createFrame
!=
null
)
{
return
;
}
createFrame
=
new
Frame
(
"H2 Console"
);
createFrame
.
addWindowListener
(
this
);
Image
image
=
loadImage
(
"/org/h2/res/h2.png"
);
if
(
image
!=
null
)
{
createFrame
.
setIconImage
(
image
);
}
createFrame
.
setResizable
(
false
);
createFrame
.
setBackground
(
SystemColor
.
control
);
GridBagLayout
layout
=
new
GridBagLayout
();
createFrame
.
setLayout
(
layout
);
// the main panel keeps everything together
Panel
mainPanel
=
new
Panel
(
layout
);
GridBagConstraints
constraints
;
constraints
=
new
GridBagConstraints
();
constraints
.
fill
=
GridBagConstraints
.
HORIZONTAL
;
constraints
.
gridx
=
0
;
constraints
.
gridy
=
0
;
Label
urlLabel
=
new
Label
(
"Database path:"
,
Label
.
LEFT
);
urlLabel
.
setFont
(
font
);
mainPanel
.
add
(
urlLabel
,
constraints
);
constraints
=
new
GridBagConstraints
();
constraints
.
fill
=
GridBagConstraints
.
HORIZONTAL
;
constraints
.
gridy
=
0
;
constraints
.
weightx
=
1
d
;
constraints
.
insets
=
new
Insets
(
0
,
5
,
0
,
0
);
constraints
.
gridx
=
1
;
pathField
=
new
TextField
();
pathField
.
setFont
(
font
);
pathField
.
setText
(
"./test"
);
mainPanel
.
add
(
pathField
,
constraints
);
constraints
=
new
GridBagConstraints
();
constraints
.
fill
=
GridBagConstraints
.
HORIZONTAL
;
constraints
.
gridx
=
0
;
constraints
.
gridy
=
1
;
Label
userLabel
=
new
Label
(
"Username:"
,
Label
.
LEFT
);
userLabel
.
setFont
(
font
);
mainPanel
.
add
(
userLabel
,
constraints
);
constraints
=
new
GridBagConstraints
();
constraints
.
fill
=
GridBagConstraints
.
HORIZONTAL
;
constraints
.
gridy
=
1
;
constraints
.
weightx
=
1
d
;
constraints
.
insets
=
new
Insets
(
0
,
5
,
0
,
0
);
constraints
.
gridx
=
1
;
userField
=
new
TextField
();
userField
.
setFont
(
font
);
userField
.
setText
(
"sa"
);
mainPanel
.
add
(
userField
,
constraints
);
constraints
=
new
GridBagConstraints
();
constraints
.
fill
=
GridBagConstraints
.
HORIZONTAL
;
constraints
.
gridx
=
0
;
constraints
.
gridy
=
2
;
Label
passwordLabel
=
new
Label
(
"Password:"
,
Label
.
LEFT
);
passwordLabel
.
setFont
(
font
);
mainPanel
.
add
(
passwordLabel
,
constraints
);
constraints
=
new
GridBagConstraints
();
constraints
.
fill
=
GridBagConstraints
.
HORIZONTAL
;
constraints
.
gridy
=
2
;
constraints
.
weightx
=
1
d
;
constraints
.
insets
=
new
Insets
(
0
,
5
,
0
,
0
);
constraints
.
gridx
=
1
;
passwordField
=
new
TextField
();
passwordField
.
setFont
(
font
);
mainPanel
.
add
(
passwordField
,
constraints
);
constraints
=
new
GridBagConstraints
();
constraints
.
gridx
=
0
;
constraints
.
gridwidth
=
2
;
constraints
.
insets
=
new
Insets
(
10
,
0
,
0
,
0
);
constraints
.
gridy
=
3
;
constraints
.
anchor
=
GridBagConstraints
.
EAST
;
createButton
=
new
Button
(
"Create"
);
createButton
.
setFocusable
(
false
);
createButton
.
setActionCommand
(
"create"
);
createButton
.
addActionListener
(
this
);
createButton
.
setFont
(
font
);
mainPanel
.
add
(
createButton
,
constraints
);
constraints
=
new
GridBagConstraints
();
constraints
.
fill
=
GridBagConstraints
.
HORIZONTAL
;
constraints
.
gridy
=
4
;
constraints
.
weightx
=
1
d
;
constraints
.
insets
=
new
Insets
(
10
,
0
,
0
,
0
);
constraints
.
gridx
=
0
;
constraints
.
gridwidth
=
2
;
errorArea
=
new
TextArea
();
errorArea
.
setFont
(
font
);
errorArea
.
setEditable
(
false
);
mainPanel
.
add
(
errorArea
,
constraints
);
constraints
=
new
GridBagConstraints
();
constraints
.
gridx
=
0
;
constraints
.
weightx
=
1
d
;
constraints
.
weighty
=
1
d
;
constraints
.
fill
=
GridBagConstraints
.
BOTH
;
constraints
.
insets
=
new
Insets
(
0
,
10
,
0
,
10
);
constraints
.
gridy
=
0
;
createFrame
.
add
(
mainPanel
,
constraints
);
int
width
=
300
,
height
=
300
;
createFrame
.
setSize
(
width
,
height
);
Dimension
screenSize
=
Toolkit
.
getDefaultToolkit
().
getScreenSize
();
createFrame
.
setLocation
((
screenSize
.
width
-
width
)
/
2
,
(
screenSize
.
height
-
height
)
/
2
);
try
{
createFrame
.
setVisible
(
true
);
}
catch
(
Throwable
t
)
{
// ignore
// some systems don't support this method, for example IKVM
// however it still works
}
try
{
// ensure this window is in front of the browser
createFrame
.
setAlwaysOnTop
(
true
);
createFrame
.
setAlwaysOnTop
(
false
);
}
catch
(
Throwable
t
)
{
// ignore
}
}
private
void
createDatabase
()
{
if
(
web
==
null
||
createFrame
==
null
)
{
return
;
}
String
path
=
pathField
.
getText
(),
user
=
userField
.
getText
(),
password
=
passwordField
.
getText
();
if
(
password
.
isEmpty
())
{
errorArea
.
setForeground
(
Color
.
RED
);
errorArea
.
setText
(
"Specify a password"
);
return
;
}
String
url
=
"jdbc:h2:"
+
path
;
try
{
DriverManager
.
getConnection
(
url
,
user
,
password
).
close
();
errorArea
.
setForeground
(
new
Color
(
0
,
0x99
,
0
));
errorArea
.
setText
(
"Database was created successfully.\n\n"
+
"JDBC URL for H2 Console:\n"
+
url
);
}
catch
(
Exception
ex
)
{
errorArea
.
setForeground
(
Color
.
RED
);
errorArea
.
setText
(
ex
.
getMessage
());
}
}
/**
/**
* INTERNAL
* INTERNAL
*/
*/
...
@@ -289,11 +460,17 @@ public class GUIConsole extends Console implements ActionListener, MouseListener
...
@@ -289,11 +460,17 @@ public class GUIConsole extends Console implements ActionListener, MouseListener
shutdown
();
shutdown
();
}
else
if
(
"console"
.
equals
(
command
))
{
}
else
if
(
"console"
.
equals
(
command
))
{
startBrowser
();
startBrowser
();
}
else
if
(
"showCreate"
.
equals
(
command
))
{
showCreateDatabase
();
}
else
if
(
"status"
.
equals
(
command
))
{
}
else
if
(
"status"
.
equals
(
command
))
{
showWindow
();
show
Status
Window
();
}
else
if
(
startBrowser
==
e
.
getSource
())
{
}
else
{
// for some reason, IKVM ignores setActionCommand
// for some reason, IKVM ignores setActionCommand
if
(
startBrowser
==
e
.
getSource
())
{
startBrowser
();
startBrowser
();
}
else
if
(
createButton
==
e
.
getSource
())
{
createDatabase
();
}
}
}
}
}
...
@@ -345,8 +522,14 @@ public class GUIConsole extends Console implements ActionListener, MouseListener
...
@@ -345,8 +522,14 @@ public class GUIConsole extends Console implements ActionListener, MouseListener
@Override
@Override
public
void
windowClosing
(
WindowEvent
e
)
{
public
void
windowClosing
(
WindowEvent
e
)
{
if
(
trayIconUsed
)
{
if
(
trayIconUsed
)
{
frame
.
dispose
();
Window
window
=
e
.
getWindow
();
frame
=
null
;
if
(
window
==
statusFrame
)
{
statusFrame
.
dispose
();
statusFrame
=
null
;
}
else
if
(
window
==
createFrame
)
{
createFrame
.
dispose
();
createFrame
=
null
;
}
}
else
{
}
else
{
shutdown
();
shutdown
();
}
}
...
...
h2/src/tools/org/h2/build/doc/dictionary.txt
浏览文件 @
4653aa5b
...
@@ -806,4 +806,4 @@ econd irst bcef ordinality nord unnest
...
@@ -806,4 +806,4 @@ econd irst bcef ordinality nord unnest
analyst occupation distributive josaph aor engineer sajeewa isuru randil kevin doctor businessman artist ashan
analyst occupation distributive josaph aor engineer sajeewa isuru randil kevin doctor businessman artist ashan
corrupts splitted disruption unintentional octets preconditions predicates subq objectweb insn opcodes
corrupts splitted disruption unintentional octets preconditions predicates subq objectweb insn opcodes
preserves masking holder unboxing avert iae transformed subtle reevaluate exclusions subclause ftbl rgr
preserves masking holder unboxing avert iae transformed subtle reevaluate exclusions subclause ftbl rgr
presorted inclusion contexts aax mwd percentile cont interpolate mwa hypothetical regproc childed listagg
presorted inclusion contexts aax mwd percentile cont interpolate mwa hypothetical regproc childed listagg
foreground
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论