Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
suliangchun
dbeaver
提交
b1000586
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,发现更多精彩内容 >>
提交
b1000586
编写于
5月 16, 2019
作者:
S
Serge Rider
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
GIS value editor: SRID editor
Former-commit-id:
25d6bf2e
上级
09483e68
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
294 addition
and
110 deletion
+294
-110
plugins/org.jkiss.dbeaver.data.gis.view/src/org/jkiss/dbeaver/ui/gis/IGeometryValueEditor.java
...ew/src/org/jkiss/dbeaver/ui/gis/IGeometryValueEditor.java
+6
-0
plugins/org.jkiss.dbeaver.data.gis.view/src/org/jkiss/dbeaver/ui/gis/panel/GISEditorUtils.java
...ew/src/org/jkiss/dbeaver/ui/gis/panel/GISEditorUtils.java
+47
-0
plugins/org.jkiss.dbeaver.data.gis.view/src/org/jkiss/dbeaver/ui/gis/panel/GISLeafletViewer.java
.../src/org/jkiss/dbeaver/ui/gis/panel/GISLeafletViewer.java
+15
-103
plugins/org.jkiss.dbeaver.data.gis.view/src/org/jkiss/dbeaver/ui/gis/panel/GISTextViewer.java
...iew/src/org/jkiss/dbeaver/ui/gis/panel/GISTextViewer.java
+77
-5
plugins/org.jkiss.dbeaver.data.gis.view/src/org/jkiss/dbeaver/ui/gis/panel/SelectCRSAction.java
...w/src/org/jkiss/dbeaver/ui/gis/panel/SelectCRSAction.java
+106
-0
plugins/org.jkiss.dbeaver.data.gis.view/src/org/jkiss/dbeaver/ui/gis/panel/SetCRSAction.java
...view/src/org/jkiss/dbeaver/ui/gis/panel/SetCRSAction.java
+41
-0
plugins/org.jkiss.dbeaver.ui.editors.data/src/org/jkiss/dbeaver/ui/data/editors/StringInlineEditor.java
...org/jkiss/dbeaver/ui/data/editors/StringInlineEditor.java
+2
-2
未找到文件。
plugins/org.jkiss.dbeaver.data.gis.view/src/org/jkiss/dbeaver/ui/gis/IGeometryValueEditor.java
浏览文件 @
b1000586
...
@@ -16,11 +16,17 @@
...
@@ -16,11 +16,17 @@
*/
*/
package
org.jkiss.dbeaver.ui.gis
;
package
org.jkiss.dbeaver.ui.gis
;
import
org.eclipse.swt.widgets.Control
;
import
java.util.List
;
/**
/**
* Geometry value editor
* Geometry value editor
*/
*/
public
interface
IGeometryValueEditor
{
public
interface
IGeometryValueEditor
{
Control
getEditorControl
();
int
getValueSRID
();
int
getValueSRID
();
void
setValueSRID
(
int
srid
);
void
setValueSRID
(
int
srid
);
...
...
plugins/org.jkiss.dbeaver.data.gis.view/src/org/jkiss/dbeaver/ui/gis/panel/GISEditorUtils.java
0 → 100644
浏览文件 @
b1000586
/*
* DBeaver - Universal Database Manager
* Copyright (C) 2010-2019 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.gis.panel
;
import
java.util.ArrayList
;
import
java.util.List
;
/**
* Database select dialog
*/
public
class
GISEditorUtils
{
private
static
final
int
MAX_RECENT_SRID_SIZE
=
10
;
private
static
final
List
<
Integer
>
recentSRIDs
=
new
ArrayList
<>();
public
static
List
<
Integer
>
getRecentSRIDs
()
{
return
recentSRIDs
;
}
public
static
void
addRecentSRID
(
int
srid
)
{
if
(!
recentSRIDs
.
contains
(
srid
))
{
recentSRIDs
.
add
(
srid
);
}
}
public
static
void
curRecentSRIDs
()
{
if
(
recentSRIDs
.
size
()
>
MAX_RECENT_SRID_SIZE
)
{
recentSRIDs
.
remove
(
0
);
}
}
}
\ No newline at end of file
plugins/org.jkiss.dbeaver.data.gis.view/src/org/jkiss/dbeaver/ui/gis/panel/GISLeafletViewer.java
浏览文件 @
b1000586
...
@@ -17,7 +17,6 @@
...
@@ -17,7 +17,6 @@
package
org.jkiss.dbeaver.ui.gis.panel
;
package
org.jkiss.dbeaver.ui.gis.panel
;
import
org.eclipse.jface.action.*
;
import
org.eclipse.jface.action.*
;
import
org.eclipse.jface.dialogs.IDialogConstants
;
import
org.eclipse.swt.SWT
;
import
org.eclipse.swt.SWT
;
import
org.eclipse.swt.browser.Browser
;
import
org.eclipse.swt.browser.Browser
;
import
org.eclipse.swt.dnd.Clipboard
;
import
org.eclipse.swt.dnd.Clipboard
;
...
@@ -39,7 +38,10 @@ import org.jkiss.dbeaver.model.exec.DBCException;
...
@@ -39,7 +38,10 @@ import org.jkiss.dbeaver.model.exec.DBCException;
import
org.jkiss.dbeaver.model.gis.*
;
import
org.jkiss.dbeaver.model.gis.*
;
import
org.jkiss.dbeaver.model.runtime.VoidProgressMonitor
;
import
org.jkiss.dbeaver.model.runtime.VoidProgressMonitor
;
import
org.jkiss.dbeaver.runtime.DBWorkbench
;
import
org.jkiss.dbeaver.runtime.DBWorkbench
;
import
org.jkiss.dbeaver.ui.*
;
import
org.jkiss.dbeaver.ui.ActionUtils
;
import
org.jkiss.dbeaver.ui.DBeaverIcons
;
import
org.jkiss.dbeaver.ui.UIIcon
;
import
org.jkiss.dbeaver.ui.UIUtils
;
import
org.jkiss.dbeaver.ui.css.CSSUtils
;
import
org.jkiss.dbeaver.ui.css.CSSUtils
;
import
org.jkiss.dbeaver.ui.css.DBStyles
;
import
org.jkiss.dbeaver.ui.css.DBStyles
;
import
org.jkiss.dbeaver.ui.data.IValueController
;
import
org.jkiss.dbeaver.ui.data.IValueController
;
...
@@ -65,7 +67,6 @@ public class GISLeafletViewer implements IGeometryValueEditor {
...
@@ -65,7 +67,6 @@ public class GISLeafletViewer implements IGeometryValueEditor {
private
static
final
Log
log
=
Log
.
getLog
(
GISLeafletViewer
.
class
);
private
static
final
Log
log
=
Log
.
getLog
(
GISLeafletViewer
.
class
);
private
static
final
String
PREF_RECENT_SRID_LIST
=
"srid.list.recent"
;
private
static
final
String
PREF_RECENT_SRID_LIST
=
"srid.list.recent"
;
private
static
final
int
MAX_RECENT_SRID_SIZE
=
10
;
private
static
final
String
[]
SUPPORTED_FORMATS
=
new
String
[]
{
"png"
,
"gif"
,
"bmp"
};
private
static
final
String
[]
SUPPORTED_FORMATS
=
new
String
[]
{
"png"
,
"gif"
,
"bmp"
};
...
@@ -77,7 +78,6 @@ public class GISLeafletViewer implements IGeometryValueEditor {
...
@@ -77,7 +78,6 @@ public class GISLeafletViewer implements IGeometryValueEditor {
private
File
scriptFile
;
private
File
scriptFile
;
private
final
ToolBarManager
toolBarManager
;
private
final
ToolBarManager
toolBarManager
;
private
int
defaultSRID
;
// Target SRID used to render map
private
int
defaultSRID
;
// Target SRID used to render map
private
List
<
Integer
>
recentSRIDs
=
new
ArrayList
<>();
private
boolean
toolsVisible
=
true
;
private
boolean
toolsVisible
=
true
;
private
boolean
flipCoordinates
=
false
;
private
boolean
flipCoordinates
=
false
;
...
@@ -115,15 +115,18 @@ public class GISLeafletViewer implements IGeometryValueEditor {
...
@@ -115,15 +115,18 @@ public class GISLeafletViewer implements IGeometryValueEditor {
if
(
recentSRID
==
0
||
recentSRID
==
GeometryDataUtils
.
getDefaultSRID
()
||
recentSRID
==
GisConstants
.
DEFAULT_OSM_SRID
)
{
if
(
recentSRID
==
0
||
recentSRID
==
GeometryDataUtils
.
getDefaultSRID
()
||
recentSRID
==
GisConstants
.
DEFAULT_OSM_SRID
)
{
continue
;
continue
;
}
}
if
(!
recentSRIDs
.
contains
(
recentSRID
))
{
GISEditorUtils
.
addRecentSRID
(
recentSRID
);
recentSRIDs
.
add
(
recentSRID
);
}
}
}
}
}
//recentSRIDs.sort(Integer::compareTo);
//recentSRIDs.sort(Integer::compareTo);
}
}
}
}
@Override
public
Control
getEditorControl
()
{
return
composite
;
}
@Override
@Override
public
int
getValueSRID
()
{
public
int
getValueSRID
()
{
return
actualSourceSRID
!=
0
?
actualSourceSRID
:
return
actualSourceSRID
!=
0
?
actualSourceSRID
:
...
@@ -145,14 +148,12 @@ public class GISLeafletViewer implements IGeometryValueEditor {
...
@@ -145,14 +148,12 @@ public class GISLeafletViewer implements IGeometryValueEditor {
}
}
{
{
// Save SRID to the list of recently used SRIDs
// Save SRID to the list of recently used SRIDs
if
(
srid
!=
GeometryDataUtils
.
getDefaultSRID
()
&&
srid
!=
GisConstants
.
DEFAULT_OSM_SRID
&&
!
recentSRIDs
.
contains
(
srid
))
{
if
(
srid
!=
GeometryDataUtils
.
getDefaultSRID
()
&&
srid
!=
GisConstants
.
DEFAULT_OSM_SRID
)
{
recentSRIDs
.
add
(
srid
);
GISEditorUtils
.
addRecentSRID
(
srid
);
}
if
(
recentSRIDs
.
size
()
>
MAX_RECENT_SRID_SIZE
)
{
recentSRIDs
.
remove
(
0
);
}
}
GISEditorUtils
.
curRecentSRIDs
();
StringBuilder
sridListStr
=
new
StringBuilder
();
StringBuilder
sridListStr
=
new
StringBuilder
();
for
(
Integer
sridInt
:
recentSRIDs
)
{
for
(
Integer
sridInt
:
GISEditorUtils
.
getRecentSRIDs
()
)
{
if
(
sridListStr
.
length
()
>
0
)
sridListStr
.
append
(
","
);
if
(
sridListStr
.
length
()
>
0
)
sridListStr
.
append
(
","
);
sridListStr
.
append
(
sridInt
);
sridListStr
.
append
(
sridInt
);
}
}
...
@@ -444,7 +445,7 @@ public class GISLeafletViewer implements IGeometryValueEditor {
...
@@ -444,7 +445,7 @@ public class GISLeafletViewer implements IGeometryValueEditor {
toolBarManager
.
add
(
new
Separator
());
toolBarManager
.
add
(
new
Separator
());
Action
crsSelectorAction
=
new
ChangeCRSAction
(
);
Action
crsSelectorAction
=
new
SelectCRSAction
(
this
);
toolBarManager
.
add
(
ActionUtils
.
makeActionContribution
(
crsSelectorAction
,
true
));
toolBarManager
.
add
(
ActionUtils
.
makeActionContribution
(
crsSelectorAction
,
true
));
toolBarManager
.
add
(
new
Action
(
"Flip coordinates"
,
Action
.
AS_CHECK_BOX
)
{
toolBarManager
.
add
(
new
Action
(
"Flip coordinates"
,
Action
.
AS_CHECK_BOX
)
{
...
@@ -502,93 +503,4 @@ public class GISLeafletViewer implements IGeometryValueEditor {
...
@@ -502,93 +503,4 @@ public class GISLeafletViewer implements IGeometryValueEditor {
}
}
}
}
private
class
ChangeCRSAction
extends
Action
implements
IMenuCreator
{
private
MenuManager
menuManager
;
public
ChangeCRSAction
()
{
super
(
"EPSG:"
+
getValueSRID
(),
Action
.
AS_DROP_DOWN_MENU
);
setImageDescriptor
(
DBeaverIcons
.
getImageDescriptor
(
UIIcon
.
CHART_LINE
));
}
@Override
public
void
run
()
{
SelectSRIDDialog
manageCRSDialog
=
new
SelectSRIDDialog
(
UIUtils
.
getActiveWorkbenchShell
(),
getValueSRID
());
if
(
manageCRSDialog
.
open
()
==
IDialogConstants
.
OK_ID
)
{
setValueSRID
(
manageCRSDialog
.
getSelectedSRID
());
}
}
@Override
public
IMenuCreator
getMenuCreator
()
{
return
this
;
}
@Override
public
void
dispose
()
{
if
(
menuManager
!=
null
)
{
menuManager
.
dispose
();
menuManager
=
null
;
}
}
@Override
public
Menu
getMenu
(
Control
parent
)
{
if
(
menuManager
==
null
)
{
menuManager
=
new
MenuManager
();
menuManager
.
setRemoveAllWhenShown
(
true
);
menuManager
.
addMenuListener
(
manager
->
{
menuManager
.
add
(
new
SetCRSAction
(
GeometryDataUtils
.
getDefaultSRID
()));
menuManager
.
add
(
new
SetCRSAction
(
GisConstants
.
DEFAULT_OSM_SRID
));
menuManager
.
add
(
new
Separator
());
if
(!
recentSRIDs
.
isEmpty
())
{
for
(
Integer
recentSRID
:
recentSRIDs
)
{
menuManager
.
add
(
new
SetCRSAction
(
recentSRID
));
}
menuManager
.
add
(
new
Separator
());
}
menuManager
.
add
(
new
Action
(
"Other ..."
)
{
@Override
public
void
run
()
{
ChangeCRSAction
.
this
.
run
();
}
});
menuManager
.
add
(
new
Action
(
"Configuration ..."
)
{
@Override
public
void
run
()
{
new
GISViewerConfigurationDialog
(
composite
.
getShell
()).
open
();
}
});
});
}
return
menuManager
.
createContextMenu
(
parent
);
}
@Override
public
Menu
getMenu
(
Menu
parent
)
{
return
null
;
}
}
private
class
SetCRSAction
extends
Action
{
private
final
int
srid
;
public
SetCRSAction
(
int
srid
)
{
super
(
"EPSG:"
+
srid
,
AS_CHECK_BOX
);
this
.
srid
=
srid
;
}
@Override
public
boolean
isChecked
()
{
return
srid
==
getValueSRID
();
}
@Override
public
void
run
()
{
setValueSRID
(
srid
);
}
}
}
}
\ No newline at end of file
plugins/org.jkiss.dbeaver.data.gis.view/src/org/jkiss/dbeaver/ui/gis/panel/GISTextViewer.java
浏览文件 @
b1000586
...
@@ -16,12 +16,28 @@
...
@@ -16,12 +16,28 @@
*/
*/
package
org.jkiss.dbeaver.ui.gis.panel
;
package
org.jkiss.dbeaver.ui.gis.panel
;
import
org.eclipse.jface.action.IContributionManager
;
import
org.eclipse.jface.action.ToolBarManager
;
import
org.eclipse.swt.SWT
;
import
org.eclipse.swt.layout.FillLayout
;
import
org.eclipse.swt.layout.GridData
;
import
org.eclipse.swt.widgets.Composite
;
import
org.eclipse.swt.widgets.Control
;
import
org.eclipse.swt.widgets.ToolBar
;
import
org.jkiss.code.NotNull
;
import
org.jkiss.dbeaver.DBException
;
import
org.jkiss.dbeaver.DBException
;
import
org.jkiss.dbeaver.Log
;
import
org.jkiss.dbeaver.model.exec.DBCException
;
import
org.jkiss.dbeaver.model.exec.DBCException
;
import
org.jkiss.dbeaver.model.gis.DBGeometry
;
import
org.jkiss.dbeaver.model.gis.GisAttribute
;
import
org.jkiss.dbeaver.model.gis.GisAttribute
;
import
org.jkiss.dbeaver.model.runtime.VoidProgressMonitor
;
import
org.jkiss.dbeaver.model.runtime.VoidProgressMonitor
;
import
org.jkiss.dbeaver.model.struct.DBSTypedObject
;
import
org.jkiss.dbeaver.model.struct.DBSTypedObject
;
import
org.jkiss.dbeaver.ui.ActionUtils
;
import
org.jkiss.dbeaver.ui.UIUtils
;
import
org.jkiss.dbeaver.ui.css.CSSUtils
;
import
org.jkiss.dbeaver.ui.css.DBStyles
;
import
org.jkiss.dbeaver.ui.data.IValueController
;
import
org.jkiss.dbeaver.ui.data.IValueController
;
import
org.jkiss.dbeaver.ui.data.editors.BaseValueEditor
;
import
org.jkiss.dbeaver.ui.data.editors.StringInlineEditor
;
import
org.jkiss.dbeaver.ui.data.editors.StringInlineEditor
;
import
org.jkiss.dbeaver.ui.gis.IGeometryValueEditor
;
import
org.jkiss.dbeaver.ui.gis.IGeometryValueEditor
;
import
org.jkiss.dbeaver.ui.gis.IGeometryViewer
;
import
org.jkiss.dbeaver.ui.gis.IGeometryViewer
;
...
@@ -33,17 +49,45 @@ import org.locationtech.jts.geom.Geometry;
...
@@ -33,17 +49,45 @@ import org.locationtech.jts.geom.Geometry;
*/
*/
public
class
GISTextViewer
extends
StringInlineEditor
implements
IGeometryViewer
,
IGeometryValueEditor
{
public
class
GISTextViewer
extends
StringInlineEditor
implements
IGeometryViewer
,
IGeometryValueEditor
{
private
static
final
Log
log
=
Log
.
getLog
(
GISTextViewer
.
class
);
private
int
valueSRID
;
private
int
valueSRID
;
private
ToolBarManager
toolBarManager
;
public
GISTextViewer
(
IValueController
controller
)
{
public
GISTextViewer
(
IValueController
controller
)
{
super
(
controller
);
super
(
controller
);
}
}
@Override
protected
Control
createControl
(
Composite
editPlaceholder
)
{
Composite
composite
=
UIUtils
.
createPlaceholder
(
editPlaceholder
,
1
);
CSSUtils
.
setCSSClass
(
composite
,
DBStyles
.
COLORED_BY_CONNECTION_TYPE
);
Composite
controlPanel
=
UIUtils
.
createPlaceholder
(
composite
,
1
);
controlPanel
.
setLayoutData
(
new
GridData
(
GridData
.
FILL_BOTH
));
controlPanel
.
setLayout
(
new
FillLayout
());
Control
textControl
=
super
.
createControl
(
controlPanel
);
Composite
bottomPanel
=
UIUtils
.
createPlaceholder
(
composite
,
1
);
//new Composite(composite, SWT.NONE);
bottomPanel
.
setLayoutData
(
new
GridData
(
GridData
.
FILL_HORIZONTAL
));
CSSUtils
.
setCSSClass
(
bottomPanel
,
DBStyles
.
COLORED_BY_CONNECTION_TYPE
);
ToolBar
bottomToolbar
=
new
ToolBar
(
bottomPanel
,
SWT
.
FLAT
|
SWT
.
HORIZONTAL
|
SWT
.
RIGHT
);
toolBarManager
=
new
ToolBarManager
(
bottomToolbar
);
return
textControl
;
}
@Override
@Override
public
void
primeEditorValue
(
Object
value
)
throws
DBException
{
public
void
primeEditorValue
(
Object
value
)
throws
DBException
{
super
.
primeEditorValue
(
value
);
super
.
primeEditorValue
(
value
);
valueSRID
=
0
;
if
(
value
instanceof
Geometry
)
{
if
(
value
instanceof
Geometry
)
{
this
.
valueSRID
=
((
Geometry
)
value
).
getSRID
();
this
.
valueSRID
=
((
Geometry
)
value
).
getSRID
();
}
else
if
(
value
instanceof
DBGeometry
)
{
this
.
valueSRID
=
((
DBGeometry
)
value
).
getSRID
();
}
}
if
(
valueSRID
==
0
)
{
if
(
valueSRID
==
0
)
{
DBSTypedObject
column
=
valueController
.
getValueType
();
DBSTypedObject
column
=
valueController
.
getValueType
();
...
@@ -51,19 +95,33 @@ public class GISTextViewer extends StringInlineEditor implements IGeometryViewer
...
@@ -51,19 +95,33 @@ public class GISTextViewer extends StringInlineEditor implements IGeometryViewer
valueSRID
=
((
GisAttribute
)
column
).
getAttributeGeometrySRID
(
new
VoidProgressMonitor
());
valueSRID
=
((
GisAttribute
)
column
).
getAttributeGeometrySRID
(
new
VoidProgressMonitor
());
}
}
}
}
updateToolBar
();
}
private
void
updateToolBar
()
{
toolBarManager
.
removeAll
();
toolBarManager
.
add
(
ActionUtils
.
makeActionContribution
(
new
SelectCRSAction
(
this
),
true
));
toolBarManager
.
update
(
true
);
}
}
@Override
@Override
public
Object
extractEditorValue
()
throws
DBCException
{
public
Object
extractEditorValue
()
throws
DBCException
{
Object
geometry
=
super
.
extractEditorValue
();
Object
geometry
=
super
.
extractEditorValue
();
if
(
geometry
instanceof
Geometry
)
{
if
(
valueSRID
!=
0
)
{
((
Geometry
)
geometry
).
setSRID
(
valueSRID
);
}
}
return
geometry
;
return
geometry
;
}
}
@Override
public
void
contributeActions
(
@NotNull
IContributionManager
manager
,
@NotNull
IValueController
controller
)
throws
DBCException
{
super
.
contributeActions
(
manager
,
controller
);
}
@Override
public
Control
getEditorControl
()
{
return
getControl
();
}
@Override
@Override
public
int
getValueSRID
()
{
public
int
getValueSRID
()
{
return
valueSRID
;
return
valueSRID
;
...
@@ -72,6 +130,20 @@ public class GISTextViewer extends StringInlineEditor implements IGeometryViewer
...
@@ -72,6 +130,20 @@ public class GISTextViewer extends StringInlineEditor implements IGeometryViewer
@Override
@Override
public
void
setValueSRID
(
int
srid
)
{
public
void
setValueSRID
(
int
srid
)
{
this
.
valueSRID
=
srid
;
this
.
valueSRID
=
srid
;
try
{
Object
geometry
=
extractEditorValue
();
if
(
geometry
instanceof
DBGeometry
)
{
((
DBGeometry
)
geometry
).
setSRID
(
valueSRID
);
}
else
if
(
geometry
instanceof
Geometry
)
{
((
Geometry
)
geometry
).
setSRID
(
valueSRID
);
}
valueController
.
updateValue
(
geometry
,
false
);
}
catch
(
DBCException
e
)
{
log
.
error
(
e
);
}
updateToolBar
();
}
}
}
}
plugins/org.jkiss.dbeaver.data.gis.view/src/org/jkiss/dbeaver/ui/gis/panel/SelectCRSAction.java
0 → 100644
浏览文件 @
b1000586
/*
* DBeaver - Universal Database Manager
* Copyright (C) 2010-2019 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.gis.panel
;
import
org.eclipse.jface.action.Action
;
import
org.eclipse.jface.action.IMenuCreator
;
import
org.eclipse.jface.action.MenuManager
;
import
org.eclipse.jface.action.Separator
;
import
org.eclipse.jface.dialogs.IDialogConstants
;
import
org.eclipse.swt.widgets.Control
;
import
org.eclipse.swt.widgets.Menu
;
import
org.jkiss.dbeaver.model.gis.GisConstants
;
import
org.jkiss.dbeaver.ui.DBeaverIcons
;
import
org.jkiss.dbeaver.ui.UIIcon
;
import
org.jkiss.dbeaver.ui.UIUtils
;
import
org.jkiss.dbeaver.ui.gis.GeometryDataUtils
;
import
org.jkiss.dbeaver.ui.gis.IGeometryValueEditor
;
import
java.util.List
;
class
SelectCRSAction
extends
Action
implements
IMenuCreator
{
private
MenuManager
menuManager
;
private
IGeometryValueEditor
valueEditor
;
public
SelectCRSAction
(
IGeometryValueEditor
valueEditor
)
{
super
(
"EPSG:"
+
valueEditor
.
getValueSRID
(),
Action
.
AS_DROP_DOWN_MENU
);
setImageDescriptor
(
DBeaverIcons
.
getImageDescriptor
(
UIIcon
.
CHART_LINE
));
this
.
valueEditor
=
valueEditor
;
}
@Override
public
void
run
()
{
SelectSRIDDialog
manageCRSDialog
=
new
SelectSRIDDialog
(
UIUtils
.
getActiveWorkbenchShell
(),
valueEditor
.
getValueSRID
());
if
(
manageCRSDialog
.
open
()
==
IDialogConstants
.
OK_ID
)
{
valueEditor
.
setValueSRID
(
manageCRSDialog
.
getSelectedSRID
());
}
}
@Override
public
IMenuCreator
getMenuCreator
()
{
return
this
;
}
@Override
public
void
dispose
()
{
if
(
menuManager
!=
null
)
{
menuManager
.
dispose
();
menuManager
=
null
;
}
}
@Override
public
Menu
getMenu
(
Control
parent
)
{
if
(
menuManager
==
null
)
{
menuManager
=
new
MenuManager
();
menuManager
.
setRemoveAllWhenShown
(
true
);
menuManager
.
addMenuListener
(
manager
->
{
menuManager
.
add
(
new
SetCRSAction
(
valueEditor
,
GeometryDataUtils
.
getDefaultSRID
()));
menuManager
.
add
(
new
SetCRSAction
(
valueEditor
,
GisConstants
.
DEFAULT_OSM_SRID
));
menuManager
.
add
(
new
Separator
());
List
<
Integer
>
recentSRIDs
=
GISEditorUtils
.
getRecentSRIDs
();
if
(!
recentSRIDs
.
isEmpty
())
{
for
(
Integer
recentSRID
:
recentSRIDs
)
{
menuManager
.
add
(
new
SetCRSAction
(
valueEditor
,
recentSRID
));
}
menuManager
.
add
(
new
Separator
());
}
menuManager
.
add
(
new
Action
(
"Other ..."
)
{
@Override
public
void
run
()
{
SelectCRSAction
.
this
.
run
();
}
});
menuManager
.
add
(
new
Action
(
"Configuration ..."
)
{
@Override
public
void
run
()
{
new
GISViewerConfigurationDialog
(
valueEditor
.
getEditorControl
().
getShell
()).
open
();
}
});
});
}
return
menuManager
.
createContextMenu
(
parent
);
}
@Override
public
Menu
getMenu
(
Menu
parent
)
{
return
null
;
}
}
plugins/org.jkiss.dbeaver.data.gis.view/src/org/jkiss/dbeaver/ui/gis/panel/SetCRSAction.java
0 → 100644
浏览文件 @
b1000586
/*
* DBeaver - Universal Database Manager
* Copyright (C) 2010-2019 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.gis.panel
;
import
org.eclipse.jface.action.Action
;
import
org.jkiss.dbeaver.ui.gis.IGeometryValueEditor
;
class
SetCRSAction
extends
Action
{
private
final
IGeometryValueEditor
valueEditor
;
private
final
int
srid
;
public
SetCRSAction
(
IGeometryValueEditor
valueEditor
,
int
srid
)
{
super
(
"EPSG:"
+
srid
,
AS_CHECK_BOX
);
this
.
valueEditor
=
valueEditor
;
this
.
srid
=
srid
;
}
@Override
public
boolean
isChecked
()
{
return
srid
==
valueEditor
.
getValueSRID
();
}
@Override
public
void
run
()
{
valueEditor
.
setValueSRID
(
srid
);
}
}
plugins/org.jkiss.dbeaver.ui.editors.data/src/org/jkiss/dbeaver/ui/data/editors/StringInlineEditor.java
浏览文件 @
b1000586
...
@@ -50,13 +50,13 @@ public class StringInlineEditor extends BaseValueEditor<Control> {
...
@@ -50,13 +50,13 @@ public class StringInlineEditor extends BaseValueEditor<Control> {
{
{
final
boolean
inline
=
valueController
.
getEditType
()
==
IValueController
.
EditType
.
INLINE
;
final
boolean
inline
=
valueController
.
getEditType
()
==
IValueController
.
EditType
.
INLINE
;
if
(
inline
)
{
if
(
inline
)
{
final
Text
editor
=
new
Text
(
valueController
.
getEditPlaceholder
()
,
SWT
.
BORDER
);
final
Text
editor
=
new
Text
(
editPlaceholder
,
SWT
.
BORDER
);
//editor.setTextLimit(MAX_STRING_LENGTH);
//editor.setTextLimit(MAX_STRING_LENGTH);
//editor.setFont(JFaceResources.getFont(JFaceResources.TEXT_FONT));
//editor.setFont(JFaceResources.getFont(JFaceResources.TEXT_FONT));
editor
.
setEditable
(!
valueController
.
isReadOnly
());
editor
.
setEditable
(!
valueController
.
isReadOnly
());
return
editor
;
return
editor
;
}
else
{
}
else
{
final
StyledText
editor
=
new
StyledText
(
valueController
.
getEditPlaceholder
()
,
final
StyledText
editor
=
new
StyledText
(
editPlaceholder
,
SWT
.
MULTI
|
SWT
.
WRAP
|
SWT
.
V_SCROLL
);
SWT
.
MULTI
|
SWT
.
WRAP
|
SWT
.
V_SCROLL
);
//editor.setTextLimit(MAX_STRING_LENGTH);
//editor.setTextLimit(MAX_STRING_LENGTH);
editor
.
setEditable
(!
valueController
.
isReadOnly
());
editor
.
setEditable
(!
valueController
.
isReadOnly
());
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录