Revision 3623
org.gvsig.vcsgis/tags/org.gvsig.vcsgis-1.0.14/org.gvsig.vcsgis.app/org.gvsig.vcsgis.app.mainplugin/buildNumber.properties | ||
---|---|---|
1 |
#Mon Mar 29 19:18:20 CEST 2021 |
|
2 |
buildNumber=21 |
org.gvsig.vcsgis/tags/org.gvsig.vcsgis-1.0.14/org.gvsig.vcsgis.app/org.gvsig.vcsgis.app.mainplugin/src/main/assembly/gvsig-plugin-package.xml | ||
---|---|---|
1 |
<!-- gvSIG. Desktop Geographic Information System. Copyright (C) 2007-2013 gvSIG |
|
2 |
Association. This program is free software; you can redistribute it and/or modify |
|
3 |
it under the terms of the GNU General Public License as published by the Free Software |
|
4 |
Foundation; either version 3 of the License, or (at your option) any later version. |
|
5 |
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; |
|
6 |
without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR |
|
7 |
PURPOSE. See the GNU General Public License for more details. You should have received |
|
8 |
a copy of the GNU General Public License along with this program; if not, write to |
|
9 |
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, |
|
10 |
USA. For any additional information, do not hesitate to contact us at info AT gvsig.com, |
|
11 |
or visit our website www.gvsig.com. --> |
|
12 |
<assembly> |
|
13 |
<id>gvsig-plugin-package</id> |
|
14 |
<formats> |
|
15 |
<format>zip</format> |
|
16 |
</formats> |
|
17 |
<baseDirectory>${project.artifactId}</baseDirectory> |
|
18 |
<includeBaseDirectory>true</includeBaseDirectory> |
|
19 |
<files> |
|
20 |
<file> |
|
21 |
<source>target/${project.artifactId}-${project.version}.jar</source> |
|
22 |
<outputDirectory>lib</outputDirectory> |
|
23 |
</file> |
|
24 |
<file> |
|
25 |
<source>target/package.info</source> |
|
26 |
</file> |
|
27 |
</files> |
|
28 |
|
|
29 |
<fileSets> |
|
30 |
<fileSet> |
|
31 |
<directory>src/main/resources-plugin</directory> |
|
32 |
<outputDirectory>.</outputDirectory> |
|
33 |
</fileSet> |
|
34 |
</fileSets> |
|
35 |
|
|
36 |
|
|
37 |
<dependencySets> |
|
38 |
<dependencySet> |
|
39 |
<useProjectArtifact>false</useProjectArtifact> |
|
40 |
<useTransitiveDependencies>false</useTransitiveDependencies> |
|
41 |
<outputDirectory>lib</outputDirectory> |
|
42 |
<includes> |
|
43 |
<include>org.gvsig:org.gvsig.vcsgis.lib.api</include> |
|
44 |
<include>org.gvsig:org.gvsig.vcsgis.lib.impl</include> |
|
45 |
<include>org.gvsig:org.gvsig.vcsgis.swing.api</include> |
|
46 |
<include>org.gvsig:org.gvsig.vcsgis.swing.impl</include> |
|
47 |
<!--<include>org.apache.httpcomponents:httpclient</include>--> |
|
48 |
|
|
49 |
|
|
50 |
</includes> |
|
51 |
</dependencySet> |
|
52 |
</dependencySets> |
|
53 |
|
|
54 |
</assembly> |
|
55 |
|
org.gvsig.vcsgis/tags/org.gvsig.vcsgis-1.0.14/org.gvsig.vcsgis.app/org.gvsig.vcsgis.app.mainplugin/src/main/java/org/gvsig/vcsgis/app/VCSGisDialogsHelper.java | ||
---|---|---|
1 |
/* |
|
2 |
* gvSIG. Desktop Geographic Information System. |
|
3 |
* |
|
4 |
* Copyright (C) 2007-2020 gvSIG Association. |
|
5 |
* |
|
6 |
* This program is free software; you can redistribute it and/or |
|
7 |
* modify it under the terms of the GNU General Public License |
|
8 |
* as published by the Free Software Foundation; either version 3 |
|
9 |
* of the License, or (at your option) any later version. |
|
10 |
* |
|
11 |
* This program is distributed in the hope that it will be useful, |
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
14 |
* GNU General Public License for more details. |
|
15 |
* |
|
16 |
* You should have received a copy of the GNU General Public License |
|
17 |
* along with this program. If not, see <https://www.gnu.org/licenses/>. |
|
18 |
* |
|
19 |
* For any additional information, do not hesitate to contact us |
|
20 |
* at info AT gvsig.com, or visit our website www.gvsig.com. |
|
21 |
*/ |
|
22 |
|
|
23 |
package org.gvsig.vcsgis.app; |
|
24 |
|
|
25 |
import java.awt.event.ActionEvent; |
|
26 |
import java.awt.event.ComponentAdapter; |
|
27 |
import java.awt.event.ComponentEvent; |
|
28 |
import java.util.HashMap; |
|
29 |
import java.util.Map; |
|
30 |
import org.gvsig.tools.ToolsLocator; |
|
31 |
import org.gvsig.tools.i18n.I18nManager; |
|
32 |
import org.gvsig.tools.swing.api.Component; |
|
33 |
import org.gvsig.tools.swing.api.ToolsSwingLocator; |
|
34 |
import org.gvsig.tools.swing.api.windowmanager.Dialog; |
|
35 |
import org.gvsig.tools.swing.api.windowmanager.WindowManager; |
|
36 |
import org.gvsig.tools.swing.api.windowmanager.WindowManager_v2; |
|
37 |
import org.gvsig.vcsgis.swing.VCSGisPanel; |
|
38 |
import org.slf4j.Logger; |
|
39 |
import org.slf4j.LoggerFactory; |
|
40 |
|
|
41 |
/** |
|
42 |
* |
|
43 |
* @author gvSIG Team |
|
44 |
*/ |
|
45 |
public class VCSGisDialogsHelper { |
|
46 |
private static final Logger LOGGER = LoggerFactory.getLogger(VCSGisDialogsHelper.class); |
|
47 |
|
|
48 |
public static class VCSGisDialogInfo { |
|
49 |
|
|
50 |
private VCSGisPanel panel; |
|
51 |
private final String name; |
|
52 |
private final String title; |
|
53 |
private String header; |
|
54 |
private String okLabel; |
|
55 |
private boolean closed; |
|
56 |
private Runnable action; |
|
57 |
private Dialog dialog; |
|
58 |
private boolean autoclose; |
|
59 |
|
|
60 |
public VCSGisDialogInfo(String name, VCSGisPanel thePanel, String title) { |
|
61 |
this.name = name; |
|
62 |
this.panel = thePanel; |
|
63 |
this.title = title; |
|
64 |
this.closed = true; |
|
65 |
this.autoclose = false; |
|
66 |
|
|
67 |
this.panel.asJComponent().addComponentListener(new ComponentAdapter() { |
|
68 |
@Override |
|
69 |
public void componentHidden(ComponentEvent e) { |
|
70 |
closed = true; |
|
71 |
if (!panel.isProcessing()) { |
|
72 |
panel = null; |
|
73 |
dialog = null; |
|
74 |
} |
|
75 |
} |
|
76 |
}); |
|
77 |
} |
|
78 |
|
|
79 |
public VCSGisDialogInfo(String name, VCSGisPanel thePanel, String title, String header, String okLabel) { |
|
80 |
this(name, thePanel, title); |
|
81 |
this.header = header; |
|
82 |
this.okLabel = okLabel; |
|
83 |
} |
|
84 |
|
|
85 |
private void performDialogAction() { |
|
86 |
action.run(); |
|
87 |
} |
|
88 |
|
|
89 |
public void setAction(Runnable action) { |
|
90 |
this.action = action; |
|
91 |
} |
|
92 |
|
|
93 |
public Component getPanel() { |
|
94 |
return this.panel; |
|
95 |
} |
|
96 |
|
|
97 |
public boolean isClosed() { |
|
98 |
return this.closed; |
|
99 |
} |
|
100 |
|
|
101 |
public String getName() { |
|
102 |
return this.name; |
|
103 |
} |
|
104 |
|
|
105 |
public void setAutoclose(boolean autoclose) { |
|
106 |
if( this.dialog!=null ) { |
|
107 |
this.dialog.setAutoclose(autoclose); |
|
108 |
} |
|
109 |
this.autoclose = autoclose; |
|
110 |
} |
|
111 |
|
|
112 |
private Dialog createDialog() { |
|
113 |
I18nManager i18n = ToolsLocator.getI18nManager(); |
|
114 |
WindowManager_v2 winManager = (WindowManager_v2) ToolsSwingLocator.getWindowManager(); |
|
115 |
|
|
116 |
Dialog theDialog = winManager.createDialog( |
|
117 |
this.panel.asJComponent(), |
|
118 |
i18n.getTranslation(title), |
|
119 |
i18n.getTranslation(header), |
|
120 |
WindowManager_v2.BUTTONS_OK_CANCEL |
|
121 |
); |
|
122 |
theDialog.setAutoclose(this.autoclose); |
|
123 |
|
|
124 |
this.panel.setDialog(theDialog); |
|
125 |
theDialog.setButtonLabel( |
|
126 |
WindowManager_v2.BUTTON_OK, |
|
127 |
i18n.getTranslation(okLabel) |
|
128 |
); |
|
129 |
theDialog.setButtonLabel( |
|
130 |
WindowManager_v2.BUTTON_CANCEL, |
|
131 |
i18n.getTranslation("_Close") |
|
132 |
); |
|
133 |
if (this.panel.isProcessing()) { |
|
134 |
theDialog.setButtonEnabled(WindowManager_v2.BUTTON_OK, false); |
|
135 |
} |
|
136 |
theDialog.addActionListener((ActionEvent e) -> { |
|
137 |
switch (theDialog.getAction()) { |
|
138 |
case WindowManager_v2.BUTTON_OK: |
|
139 |
Thread task = new Thread(() -> { |
|
140 |
performDialogAction(); |
|
141 |
}, "VCSGis" + name); |
|
142 |
task.start(); |
|
143 |
break; |
|
144 |
case WindowManager_v2.BUTTON_CANCEL: |
|
145 |
theDialog.asJComponent().setVisible(false); |
|
146 |
break; |
|
147 |
} |
|
148 |
}); |
|
149 |
return theDialog; |
|
150 |
} |
|
151 |
|
|
152 |
public void show() { |
|
153 |
if (!this.closed) { |
|
154 |
return; |
|
155 |
} |
|
156 |
if( this.action==null ) { |
|
157 |
I18nManager i18n = ToolsLocator.getI18nManager(); |
|
158 |
WindowManager_v2 winManager = (WindowManager_v2) ToolsSwingLocator.getWindowManager(); |
|
159 |
winManager.showWindow( |
|
160 |
this.panel.asJComponent(), |
|
161 |
i18n.getTranslation(this.title), |
|
162 |
WindowManager.MODE.WINDOW |
|
163 |
); |
|
164 |
} else { |
|
165 |
this.dialog = this.createDialog(); |
|
166 |
this.dialog.show(WindowManager.MODE.WINDOW); |
|
167 |
} |
|
168 |
} |
|
169 |
} |
|
170 |
|
|
171 |
private Map<String, VCSGisDialogInfo> dialogsInfo; |
|
172 |
|
|
173 |
public VCSGisDialogInfo getDialog(String name) { |
|
174 |
if (this.dialogsInfo == null) { |
|
175 |
return null; |
|
176 |
} |
|
177 |
VCSGisDialogInfo info = this.dialogsInfo.get(name); |
|
178 |
return info; |
|
179 |
} |
|
180 |
|
|
181 |
public VCSGisDialogInfo getOrCreateDialog(String name, VCSGisPanel panel, String title, String header, String okLabel, Runnable action) { |
|
182 |
if (this.dialogsInfo == null) { |
|
183 |
this.dialogsInfo = new HashMap<>(); |
|
184 |
} |
|
185 |
VCSGisDialogInfo info = this.dialogsInfo.get(name); |
|
186 |
if (info == null || info.isClosed() ) { |
|
187 |
info = new VCSGisDialogInfo(name, panel, title, header, okLabel); |
|
188 |
info.setAction(action); |
|
189 |
this.dialogsInfo.put(name, info); |
|
190 |
} |
|
191 |
return info; |
|
192 |
} |
|
193 |
|
|
194 |
public VCSGisDialogInfo getOrCreateDialog(String name, VCSGisPanel panel, String title) { |
|
195 |
if (this.dialogsInfo == null) { |
|
196 |
this.dialogsInfo = new HashMap<>(); |
|
197 |
} |
|
198 |
VCSGisDialogInfo info = this.dialogsInfo.get(name); |
|
199 |
if (info == null || info.isClosed()) { |
|
200 |
info = new VCSGisDialogInfo(name, panel, title); |
|
201 |
this.dialogsInfo.put(name, info); |
|
202 |
} |
|
203 |
return info; |
|
204 |
} |
|
205 |
|
|
206 |
} |
org.gvsig.vcsgis/tags/org.gvsig.vcsgis-1.0.14/org.gvsig.vcsgis.app/org.gvsig.vcsgis.app.mainplugin/src/main/java/org/gvsig/vcsgis/app/addlayer/AbstractWizardVCSGisView.java | ||
---|---|---|
1 |
package org.gvsig.vcsgis.app.addlayer; |
|
2 |
|
|
3 |
import com.jeta.forms.components.border.TitledBorderLabel; |
|
4 |
import com.jeta.open.i18n.I18NUtils; |
|
5 |
import com.jgoodies.forms.layout.CellConstraints; |
|
6 |
import com.jgoodies.forms.layout.FormLayout; |
|
7 |
import java.awt.BorderLayout; |
|
8 |
import java.awt.Color; |
|
9 |
import java.awt.ComponentOrientation; |
|
10 |
import java.awt.Container; |
|
11 |
import java.awt.Dimension; |
|
12 |
import javax.swing.Box; |
|
13 |
import javax.swing.ImageIcon; |
|
14 |
import javax.swing.JButton; |
|
15 |
import javax.swing.JComboBox; |
|
16 |
import javax.swing.JFrame; |
|
17 |
import javax.swing.JLabel; |
|
18 |
import javax.swing.JList; |
|
19 |
import javax.swing.JPanel; |
|
20 |
import javax.swing.JProgressBar; |
|
21 |
import javax.swing.JScrollPane; |
|
22 |
import javax.swing.JTextField; |
|
23 |
import javax.swing.border.EmptyBorder; |
|
24 |
|
|
25 |
|
|
26 |
public class AbstractWizardVCSGisView extends JPanel |
|
27 |
{ |
|
28 |
TitledBorderLabel lblWorkspace = new TitledBorderLabel(); |
|
29 |
JButton btnAdvancedProperties = new JButton(); |
|
30 |
TitledBorderLabel lblTable = new TitledBorderLabel(); |
|
31 |
TitledBorderLabel lblColumns = new TitledBorderLabel(); |
|
32 |
JList lstColumns = new JList(); |
|
33 |
JList lstTables = new JList(); |
|
34 |
JButton btnDeselectAllColumns = new JButton(); |
|
35 |
JButton btnSelectAllColumns = new JButton(); |
|
36 |
JButton btnTablesFilter = new JButton(); |
|
37 |
JTextField txtTablesFilter = new JTextField(); |
|
38 |
JButton btnCheckout = new JButton(); |
|
39 |
JLabel lblName = new JLabel(); |
|
40 |
JTextField txtName = new JTextField(); |
|
41 |
JLabel lblIdField = new JLabel(); |
|
42 |
JComboBox cboIdField = new JComboBox(); |
|
43 |
JLabel lblGeometryField = new JLabel(); |
|
44 |
JComboBox cboGeometryField = new JComboBox(); |
|
45 |
JLabel lblProjection = new JLabel(); |
|
46 |
JLabel lblFilter = new JLabel(); |
|
47 |
JTextField txtProjection = new JTextField(); |
|
48 |
JButton btnProjection = new JButton(); |
|
49 |
JTextField txtFilter = new JTextField(); |
|
50 |
JButton btnFilter = new JButton(); |
|
51 |
JButton btnFilterBookmarks = new JButton(); |
|
52 |
JButton btnFilterHistory = new JButton(); |
|
53 |
JComboBox cboWorkspaces = new JComboBox(); |
|
54 |
JTextField txtRepositoryInfo = new JTextField(); |
|
55 |
JButton btnInitWorkspace = new JButton(); |
|
56 |
JButton btnAddWorkspace = new JButton(); |
|
57 |
JLabel lblStatusTitle = new JLabel(); |
|
58 |
JProgressBar pbStatus = new JProgressBar(); |
|
59 |
JLabel lblStatusMessages = new JLabel(); |
|
60 |
|
|
61 |
/** |
|
62 |
* Default constructor |
|
63 |
*/ |
|
64 |
public AbstractWizardVCSGisView() |
|
65 |
{ |
|
66 |
initializePanel(); |
|
67 |
} |
|
68 |
|
|
69 |
/** |
|
70 |
* Adds fill components to empty cells in the first row and first column of the grid. |
|
71 |
* This ensures that the grid spacing will be the same as shown in the designer. |
|
72 |
* @param cols an array of column indices in the first row where fill components should be added. |
|
73 |
* @param rows an array of row indices in the first column where fill components should be added. |
|
74 |
*/ |
|
75 |
void addFillComponents( Container panel, int[] cols, int[] rows ) |
|
76 |
{ |
|
77 |
Dimension filler = new Dimension(10,10); |
|
78 |
|
|
79 |
boolean filled_cell_11 = false; |
|
80 |
CellConstraints cc = new CellConstraints(); |
|
81 |
if ( cols.length > 0 && rows.length > 0 ) |
|
82 |
{ |
|
83 |
if ( cols[0] == 1 && rows[0] == 1 ) |
|
84 |
{ |
|
85 |
/** add a rigid area */ |
|
86 |
panel.add( Box.createRigidArea( filler ), cc.xy(1,1) ); |
|
87 |
filled_cell_11 = true; |
|
88 |
} |
|
89 |
} |
|
90 |
|
|
91 |
for( int index = 0; index < cols.length; index++ ) |
|
92 |
{ |
|
93 |
if ( cols[index] == 1 && filled_cell_11 ) |
|
94 |
{ |
|
95 |
continue; |
|
96 |
} |
|
97 |
panel.add( Box.createRigidArea( filler ), cc.xy(cols[index],1) ); |
|
98 |
} |
|
99 |
|
|
100 |
for( int index = 0; index < rows.length; index++ ) |
|
101 |
{ |
|
102 |
if ( rows[index] == 1 && filled_cell_11 ) |
|
103 |
{ |
|
104 |
continue; |
|
105 |
} |
|
106 |
panel.add( Box.createRigidArea( filler ), cc.xy(1,rows[index]) ); |
|
107 |
} |
|
108 |
|
|
109 |
} |
|
110 |
|
|
111 |
/** |
|
112 |
* Helper method to load an image file from the CLASSPATH |
|
113 |
* @param imageName the package and name of the file to load relative to the CLASSPATH |
|
114 |
* @return an ImageIcon instance with the specified image file |
|
115 |
* @throws IllegalArgumentException if the image resource cannot be loaded. |
|
116 |
*/ |
|
117 |
public ImageIcon loadImage( String imageName ) |
|
118 |
{ |
|
119 |
try |
|
120 |
{ |
|
121 |
ClassLoader classloader = getClass().getClassLoader(); |
|
122 |
java.net.URL url = classloader.getResource( imageName ); |
|
123 |
if ( url != null ) |
|
124 |
{ |
|
125 |
ImageIcon icon = new ImageIcon( url ); |
|
126 |
return icon; |
|
127 |
} |
|
128 |
} |
|
129 |
catch( Exception e ) |
|
130 |
{ |
|
131 |
e.printStackTrace(); |
|
132 |
} |
|
133 |
throw new IllegalArgumentException( "Unable to load image: " + imageName ); |
|
134 |
} |
|
135 |
|
|
136 |
/** |
|
137 |
* Method for recalculating the component orientation for |
|
138 |
* right-to-left Locales. |
|
139 |
* @param orientation the component orientation to be applied |
|
140 |
*/ |
|
141 |
public void applyComponentOrientation( ComponentOrientation orientation ) |
|
142 |
{ |
|
143 |
// Not yet implemented... |
|
144 |
// I18NUtils.applyComponentOrientation(this, orientation); |
|
145 |
super.applyComponentOrientation(orientation); |
|
146 |
} |
|
147 |
|
|
148 |
public JPanel createPanel() |
|
149 |
{ |
|
150 |
JPanel jpanel1 = new JPanel(); |
|
151 |
FormLayout formlayout1 = new FormLayout("FILL:4DLU:NONE,FILL:8DLU:GROW(1.0),FILL:4DLU:NONE,FILL:DEFAULT:NONE","CENTER:DEFAULT:NONE,CENTER:2DLU:NONE,CENTER:DEFAULT:NONE,CENTER:2DLU:NONE,CENTER:2DLU:NONE,FILL:DEFAULT:GROW(1.0),CENTER:2DLU:NONE,CENTER:DEFAULT:NONE,CENTER:DEFAULT:NONE,CENTER:2DLU:NONE,CENTER:DEFAULT:NONE,CENTER:DEFAULT:NONE,CENTER:2DLU:NONE"); |
|
152 |
CellConstraints cc = new CellConstraints(); |
|
153 |
jpanel1.setLayout(formlayout1); |
|
154 |
|
|
155 |
lblWorkspace.setName("lblWorkspace"); |
|
156 |
lblWorkspace.setText("_Workspace"); |
|
157 |
jpanel1.add(lblWorkspace,cc.xy(2,1)); |
|
158 |
|
|
159 |
btnAdvancedProperties.setActionCommand("_Advanced_properties"); |
|
160 |
btnAdvancedProperties.setName("btnAdvancedProperties"); |
|
161 |
btnAdvancedProperties.setText("_Advanced_properties"); |
|
162 |
jpanel1.add(btnAdvancedProperties,new CellConstraints(2,11,1,1,CellConstraints.RIGHT,CellConstraints.DEFAULT)); |
|
163 |
|
|
164 |
jpanel1.add(createPanel1(),cc.xy(2,6)); |
|
165 |
jpanel1.add(createPanel5(),cc.xy(2,9)); |
|
166 |
jpanel1.add(createPanel8(),cc.xy(2,3)); |
|
167 |
jpanel1.add(createPanel9(),cc.xy(2,12)); |
|
168 |
addFillComponents(jpanel1,new int[]{ 1,3,4 },new int[]{ 1,2,3,4,5,6,7,8,9,10,11,12,13 }); |
|
169 |
return jpanel1; |
|
170 |
} |
|
171 |
|
|
172 |
public JPanel createPanel1() |
|
173 |
{ |
|
174 |
JPanel jpanel1 = new JPanel(); |
|
175 |
FormLayout formlayout1 = new FormLayout("FILL:DEFAULT:GROW(0.5),FILL:4DLU:NONE,FILL:DEFAULT:GROW(0.5)","CENTER:DEFAULT:NONE,CENTER:2DLU:NONE,CENTER:DEFAULT:NONE,CENTER:2DLU:NONE,FILL:DEFAULT:GROW(1.0),CENTER:2DLU:NONE,CENTER:DEFAULT:NONE"); |
|
176 |
CellConstraints cc = new CellConstraints(); |
|
177 |
jpanel1.setLayout(formlayout1); |
|
178 |
|
|
179 |
lblTable.setName("lblTable"); |
|
180 |
lblTable.setText("choose_table"); |
|
181 |
jpanel1.add(lblTable,cc.xy(1,1)); |
|
182 |
|
|
183 |
lblColumns.setName("lblColumns"); |
|
184 |
lblColumns.setText("table_fields"); |
|
185 |
jpanel1.add(lblColumns,cc.xy(3,1)); |
|
186 |
|
|
187 |
lstColumns.setName("lstColumns"); |
|
188 |
JScrollPane jscrollpane1 = new JScrollPane(); |
|
189 |
jscrollpane1.setViewportView(lstColumns); |
|
190 |
jscrollpane1.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED); |
|
191 |
jscrollpane1.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); |
|
192 |
jpanel1.add(jscrollpane1,cc.xywh(3,3,1,3)); |
|
193 |
|
|
194 |
lstTables.setName("lstTables"); |
|
195 |
JScrollPane jscrollpane2 = new JScrollPane(); |
|
196 |
jscrollpane2.setViewportView(lstTables); |
|
197 |
jscrollpane2.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED); |
|
198 |
jscrollpane2.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED); |
|
199 |
jpanel1.add(jscrollpane2,cc.xy(1,5)); |
|
200 |
|
|
201 |
jpanel1.add(createPanel2(),cc.xy(3,7)); |
|
202 |
jpanel1.add(createPanel3(),cc.xy(1,3)); |
|
203 |
jpanel1.add(createPanel4(),cc.xy(1,7)); |
|
204 |
addFillComponents(jpanel1,new int[]{ 2 },new int[]{ 2,3,4,6,7 }); |
|
205 |
return jpanel1; |
|
206 |
} |
|
207 |
|
|
208 |
public JPanel createPanel2() |
|
209 |
{ |
|
210 |
JPanel jpanel1 = new JPanel(); |
|
211 |
FormLayout formlayout1 = new FormLayout("FILL:DEFAULT:GROW(1.0),FILL:DEFAULT:NONE,FILL:4DLU:NONE,FILL:DEFAULT:NONE","CENTER:DEFAULT:NONE"); |
|
212 |
CellConstraints cc = new CellConstraints(); |
|
213 |
jpanel1.setLayout(formlayout1); |
|
214 |
|
|
215 |
btnDeselectAllColumns.setActionCommand("Ninguno"); |
|
216 |
btnDeselectAllColumns.setName("btnDeselectAllColumns"); |
|
217 |
btnDeselectAllColumns.setOpaque(false); |
|
218 |
btnDeselectAllColumns.setText("_None"); |
|
219 |
EmptyBorder emptyborder1 = new EmptyBorder(2,2,2,2); |
|
220 |
btnDeselectAllColumns.setBorder(emptyborder1); |
|
221 |
jpanel1.add(btnDeselectAllColumns,cc.xy(4,1)); |
|
222 |
|
|
223 |
btnSelectAllColumns.setActionCommand("Todos"); |
|
224 |
btnSelectAllColumns.setName("btnSelectAllColumns"); |
|
225 |
btnSelectAllColumns.setOpaque(false); |
|
226 |
btnSelectAllColumns.setText("_All"); |
|
227 |
EmptyBorder emptyborder2 = new EmptyBorder(2,2,2,2); |
|
228 |
btnSelectAllColumns.setBorder(emptyborder2); |
|
229 |
jpanel1.add(btnSelectAllColumns,cc.xy(2,1)); |
|
230 |
|
|
231 |
addFillComponents(jpanel1,new int[]{ 1,3 },new int[]{ 1 }); |
|
232 |
return jpanel1; |
|
233 |
} |
|
234 |
|
|
235 |
public JPanel createPanel3() |
|
236 |
{ |
|
237 |
JPanel jpanel1 = new JPanel(); |
|
238 |
FormLayout formlayout1 = new FormLayout("FILL:DEFAULT:GROW(1.0),FILL:4DLU:NONE,FILL:DEFAULT:NONE","CENTER:DEFAULT:NONE"); |
|
239 |
CellConstraints cc = new CellConstraints(); |
|
240 |
jpanel1.setLayout(formlayout1); |
|
241 |
|
|
242 |
btnTablesFilter.setActionCommand("..."); |
|
243 |
btnTablesFilter.setName("btnTablesFilter"); |
|
244 |
btnTablesFilter.setText("..."); |
|
245 |
EmptyBorder emptyborder1 = new EmptyBorder(2,2,2,2); |
|
246 |
btnTablesFilter.setBorder(emptyborder1); |
|
247 |
jpanel1.add(btnTablesFilter,cc.xy(3,1)); |
|
248 |
|
|
249 |
txtTablesFilter.setName("txtTablesFilter"); |
|
250 |
jpanel1.add(txtTablesFilter,cc.xy(1,1)); |
|
251 |
|
|
252 |
addFillComponents(jpanel1,new int[]{ 2 },new int[0]); |
|
253 |
return jpanel1; |
|
254 |
} |
|
255 |
|
|
256 |
public JPanel createPanel4() |
|
257 |
{ |
|
258 |
JPanel jpanel1 = new JPanel(); |
|
259 |
FormLayout formlayout1 = new FormLayout("FILL:DEFAULT:GROW(1.0),FILL:DEFAULT:NONE","CENTER:DEFAULT:NONE"); |
|
260 |
CellConstraints cc = new CellConstraints(); |
|
261 |
jpanel1.setLayout(formlayout1); |
|
262 |
|
|
263 |
btnCheckout.setActionCommand("..."); |
|
264 |
btnCheckout.setIcon(loadImage("src/main/resources/org/gvsig/vcsgis/swing/impl/images/vcsgis-checkout.png")); |
|
265 |
btnCheckout.setName("btnCheckout"); |
|
266 |
btnCheckout.setOpaque(false); |
|
267 |
btnCheckout.setToolTipText("_VCS_Checkout"); |
|
268 |
EmptyBorder emptyborder1 = new EmptyBorder(2,2,2,2); |
|
269 |
btnCheckout.setBorder(emptyborder1); |
|
270 |
jpanel1.add(btnCheckout,cc.xy(2,1)); |
|
271 |
|
|
272 |
addFillComponents(jpanel1,new int[]{ 1 },new int[]{ 1 }); |
|
273 |
return jpanel1; |
|
274 |
} |
|
275 |
|
|
276 |
public JPanel createPanel5() |
|
277 |
{ |
|
278 |
JPanel jpanel1 = new JPanel(); |
|
279 |
FormLayout formlayout1 = new FormLayout("FILL:DEFAULT:NONE,FILL:4DLU:NONE,FILL:DEFAULT:GROW(1.0)","CENTER:2DLU:NONE,CENTER:DEFAULT:NONE,CENTER:2DLU:NONE,CENTER:DEFAULT:NONE,CENTER:2DLU:NONE,CENTER:DEFAULT:NONE,CENTER:2DLU:NONE,CENTER:DEFAULT:NONE,CENTER:2DLU:NONE,CENTER:DEFAULT:NONE"); |
|
280 |
CellConstraints cc = new CellConstraints(); |
|
281 |
jpanel1.setLayout(formlayout1); |
|
282 |
|
|
283 |
lblName.setName("lblName"); |
|
284 |
lblName.setText("_Name"); |
|
285 |
jpanel1.add(lblName,cc.xy(1,2)); |
|
286 |
|
|
287 |
txtName.setName("txtName"); |
|
288 |
jpanel1.add(txtName,cc.xy(3,2)); |
|
289 |
|
|
290 |
lblIdField.setName("lblIdField"); |
|
291 |
lblIdField.setText("_Id_field"); |
|
292 |
jpanel1.add(lblIdField,cc.xy(1,4)); |
|
293 |
|
|
294 |
cboIdField.setName("cboIdField"); |
|
295 |
jpanel1.add(cboIdField,cc.xy(3,4)); |
|
296 |
|
|
297 |
lblGeometryField.setName("lblGeometryField"); |
|
298 |
lblGeometryField.setText("_Geo_field"); |
|
299 |
jpanel1.add(lblGeometryField,cc.xy(1,6)); |
|
300 |
|
|
301 |
cboGeometryField.setName("cboGeometryField"); |
|
302 |
jpanel1.add(cboGeometryField,cc.xy(3,6)); |
|
303 |
|
|
304 |
lblProjection.setName("lblProjection"); |
|
305 |
lblProjection.setText("_Projection"); |
|
306 |
jpanel1.add(lblProjection,cc.xy(1,8)); |
|
307 |
|
|
308 |
lblFilter.setName("lblFilter"); |
|
309 |
lblFilter.setText("_Filter"); |
|
310 |
jpanel1.add(lblFilter,cc.xy(1,10)); |
|
311 |
|
|
312 |
jpanel1.add(createPanel6(),cc.xy(3,8)); |
|
313 |
jpanel1.add(createPanel7(),cc.xy(3,10)); |
|
314 |
addFillComponents(jpanel1,new int[]{ 1,2,3 },new int[]{ 1,3,5,7,9 }); |
|
315 |
return jpanel1; |
|
316 |
} |
|
317 |
|
|
318 |
public JPanel createPanel6() |
|
319 |
{ |
|
320 |
JPanel jpanel1 = new JPanel(); |
|
321 |
FormLayout formlayout1 = new FormLayout("FILL:DEFAULT:GROW(1.0),FILL:4DLU:NONE,FILL:DEFAULT:NONE","FILL:DEFAULT:NONE"); |
|
322 |
CellConstraints cc = new CellConstraints(); |
|
323 |
jpanel1.setLayout(formlayout1); |
|
324 |
|
|
325 |
txtProjection.setName("txtProjection"); |
|
326 |
jpanel1.add(txtProjection,cc.xy(1,1)); |
|
327 |
|
|
328 |
btnProjection.setActionCommand("..."); |
|
329 |
btnProjection.setName("btnProjection"); |
|
330 |
btnProjection.setOpaque(false); |
|
331 |
btnProjection.setText("..."); |
|
332 |
EmptyBorder emptyborder1 = new EmptyBorder(2,2,2,2); |
|
333 |
btnProjection.setBorder(emptyborder1); |
|
334 |
jpanel1.add(btnProjection,cc.xy(3,1)); |
|
335 |
|
|
336 |
addFillComponents(jpanel1,new int[]{ 2 },new int[0]); |
|
337 |
return jpanel1; |
|
338 |
} |
|
339 |
|
|
340 |
public JPanel createPanel7() |
|
341 |
{ |
|
342 |
JPanel jpanel1 = new JPanel(); |
|
343 |
FormLayout formlayout1 = new FormLayout("FILL:DEFAULT:GROW(1.0),FILL:4DLU:NONE,FILL:DEFAULT:NONE,FILL:4DLU:NONE,FILL:DEFAULT:NONE,FILL:4DLU:NONE,FILL:DEFAULT:NONE","CENTER:DEFAULT:NONE"); |
|
344 |
CellConstraints cc = new CellConstraints(); |
|
345 |
jpanel1.setLayout(formlayout1); |
|
346 |
|
|
347 |
txtFilter.setName("txtFilter"); |
|
348 |
jpanel1.add(txtFilter,cc.xy(1,1)); |
|
349 |
|
|
350 |
btnFilter.setActionCommand("..."); |
|
351 |
btnFilter.setName("btnFilter"); |
|
352 |
btnFilter.setOpaque(false); |
|
353 |
btnFilter.setText("..."); |
|
354 |
EmptyBorder emptyborder1 = new EmptyBorder(2,2,2,2); |
|
355 |
btnFilter.setBorder(emptyborder1); |
|
356 |
jpanel1.add(btnFilter,cc.xy(3,1)); |
|
357 |
|
|
358 |
btnFilterBookmarks.setActionCommand("..."); |
|
359 |
btnFilterBookmarks.setName("btnFilterBookmarks"); |
|
360 |
btnFilterBookmarks.setOpaque(false); |
|
361 |
btnFilterBookmarks.setText("..."); |
|
362 |
EmptyBorder emptyborder2 = new EmptyBorder(2,2,2,2); |
|
363 |
btnFilterBookmarks.setBorder(emptyborder2); |
|
364 |
jpanel1.add(btnFilterBookmarks,cc.xy(7,1)); |
|
365 |
|
|
366 |
btnFilterHistory.setActionCommand("..."); |
|
367 |
btnFilterHistory.setName("btnFilterHistory"); |
|
368 |
btnFilterHistory.setOpaque(false); |
|
369 |
btnFilterHistory.setText("..."); |
|
370 |
EmptyBorder emptyborder3 = new EmptyBorder(2,2,2,2); |
|
371 |
btnFilterHistory.setBorder(emptyborder3); |
|
372 |
jpanel1.add(btnFilterHistory,cc.xy(5,1)); |
|
373 |
|
|
374 |
addFillComponents(jpanel1,new int[]{ 2,4,6 },new int[0]); |
|
375 |
return jpanel1; |
|
376 |
} |
|
377 |
|
|
378 |
public JPanel createPanel8() |
|
379 |
{ |
|
380 |
JPanel jpanel1 = new JPanel(); |
|
381 |
FormLayout formlayout1 = new FormLayout("FILL:4DLU:NONE,FILL:DEFAULT:GROW(1.0),FILL:4DLU:NONE,FILL:DEFAULT:NONE","CENTER:DEFAULT:NONE,CENTER:2DLU:NONE,CENTER:DEFAULT:NONE,CENTER:2DLU:NONE,CENTER:DEFAULT:NONE"); |
|
382 |
CellConstraints cc = new CellConstraints(); |
|
383 |
jpanel1.setLayout(formlayout1); |
|
384 |
|
|
385 |
cboWorkspaces.setName("cboWorkspaces"); |
|
386 |
jpanel1.add(cboWorkspaces,cc.xy(2,1)); |
|
387 |
|
|
388 |
txtRepositoryInfo.setBackground(new Color(236,233,216)); |
|
389 |
txtRepositoryInfo.setEditable(false); |
|
390 |
txtRepositoryInfo.setName("txtRepositoryInfo"); |
|
391 |
jpanel1.add(txtRepositoryInfo,cc.xy(2,5)); |
|
392 |
|
|
393 |
btnInitWorkspace.setActionCommand("..."); |
|
394 |
btnInitWorkspace.setIcon(loadImage("src/main/resources/org/gvsig/vcsgis/swing/impl/images/vcsgis-init-workspace.png")); |
|
395 |
btnInitWorkspace.setName("btnInitWorkspace"); |
|
396 |
btnInitWorkspace.setOpaque(false); |
|
397 |
btnInitWorkspace.setText("_If_you_cant_find_the_layer_click_here_to_initialize_a_new_workspace"); |
|
398 |
EmptyBorder emptyborder1 = new EmptyBorder(2,2,2,2); |
|
399 |
btnInitWorkspace.setBorder(emptyborder1); |
|
400 |
btnInitWorkspace.setHorizontalTextPosition(JButton.LEFT); |
|
401 |
jpanel1.add(btnInitWorkspace,new CellConstraints(2,3,1,1,CellConstraints.RIGHT,CellConstraints.DEFAULT)); |
|
402 |
|
|
403 |
btnAddWorkspace.setActionCommand("..."); |
|
404 |
btnAddWorkspace.setName("btnAddWorkspace"); |
|
405 |
btnAddWorkspace.setOpaque(false); |
|
406 |
btnAddWorkspace.setText("..."); |
|
407 |
EmptyBorder emptyborder2 = new EmptyBorder(2,2,2,2); |
|
408 |
btnAddWorkspace.setBorder(emptyborder2); |
|
409 |
jpanel1.add(btnAddWorkspace,cc.xy(4,1)); |
|
410 |
|
|
411 |
addFillComponents(jpanel1,new int[]{ 1,3 },new int[]{ 1,2,3,4,5 }); |
|
412 |
return jpanel1; |
|
413 |
} |
|
414 |
|
|
415 |
public JPanel createPanel9() |
|
416 |
{ |
|
417 |
JPanel jpanel1 = new JPanel(); |
|
418 |
FormLayout formlayout1 = new FormLayout("FILL:DEFAULT:GROW(1.0),FILL:DEFAULT:NONE","CENTER:MIN(16PX;DEFAULT):NONE,CENTER:MIN(16PX;DEFAULT):NONE,CENTER:MIN(16PX;DEFAULT):NONE"); |
|
419 |
CellConstraints cc = new CellConstraints(); |
|
420 |
jpanel1.setLayout(formlayout1); |
|
421 |
|
|
422 |
lblStatusTitle.setName("lblStatusTitle"); |
|
423 |
jpanel1.add(lblStatusTitle,cc.xy(1,1)); |
|
424 |
|
|
425 |
pbStatus.setName("pbStatus"); |
|
426 |
pbStatus.setValue(25); |
|
427 |
jpanel1.add(pbStatus,cc.xy(1,2)); |
|
428 |
|
|
429 |
lblStatusMessages.setName("lblStatusMessages"); |
|
430 |
jpanel1.add(lblStatusMessages,cc.xy(1,3)); |
|
431 |
|
|
432 |
JLabel jlabel1 = new JLabel(); |
|
433 |
jlabel1.setText(" "); |
|
434 |
jpanel1.add(jlabel1,cc.xy(2,1)); |
|
435 |
|
|
436 |
JLabel jlabel2 = new JLabel(); |
|
437 |
jlabel2.setText(" "); |
|
438 |
jpanel1.add(jlabel2,cc.xy(2,2)); |
|
439 |
|
|
440 |
JLabel jlabel3 = new JLabel(); |
|
441 |
jlabel3.setText(" "); |
|
442 |
jpanel1.add(jlabel3,cc.xy(2,3)); |
|
443 |
|
|
444 |
addFillComponents(jpanel1,new int[0],new int[0]); |
|
445 |
return jpanel1; |
|
446 |
} |
|
447 |
|
|
448 |
/** |
|
449 |
* Initializer |
|
450 |
*/ |
|
451 |
protected void initializePanel() |
|
452 |
{ |
|
453 |
setLayout(new BorderLayout()); |
|
454 |
add(createPanel(), BorderLayout.CENTER); |
|
455 |
} |
|
456 |
|
|
457 |
|
|
458 |
} |
org.gvsig.vcsgis/tags/org.gvsig.vcsgis-1.0.14/org.gvsig.vcsgis.app/org.gvsig.vcsgis.app.mainplugin/src/main/java/org/gvsig/vcsgis/app/addlayer/AbstractWizardVCSGis.java | ||
---|---|---|
1 |
package org.gvsig.vcsgis.app.addlayer; |
|
2 |
|
|
3 |
import java.awt.BorderLayout; |
|
4 |
import java.awt.Cursor; |
|
5 |
import java.awt.Dimension; |
|
6 |
import java.awt.event.ActionEvent; |
|
7 |
import java.awt.event.ItemEvent; |
|
8 |
import java.net.URL; |
|
9 |
import java.util.ArrayList; |
|
10 |
import java.util.Collection; |
|
11 |
import java.util.HashMap; |
|
12 |
import java.util.List; |
|
13 |
import java.util.Map; |
|
14 |
import javax.swing.ComboBoxModel; |
|
15 |
import javax.swing.DefaultComboBoxModel; |
|
16 |
import javax.swing.DefaultListModel; |
|
17 |
import javax.swing.DefaultListSelectionModel; |
|
18 |
import javax.swing.ImageIcon; |
|
19 |
import javax.swing.JOptionPane; |
|
20 |
import javax.swing.ListModel; |
|
21 |
import javax.swing.ListSelectionModel; |
|
22 |
import javax.swing.SwingUtilities; |
|
23 |
import javax.swing.event.ChangeEvent; |
|
24 |
import javax.swing.event.ListSelectionEvent; |
|
25 |
import org.apache.commons.io.FilenameUtils; |
|
26 |
import org.apache.commons.lang3.StringUtils; |
|
27 |
import org.cresques.cts.IProjection; |
|
28 |
import org.gvsig.app.gui.WizardPanel; |
|
29 |
import org.gvsig.expressionevaluator.Expression; |
|
30 |
import org.gvsig.expressionevaluator.ExpressionUtils; |
|
31 |
import org.gvsig.expressionevaluator.swing.ExpressionEvaluatorSwingLocator; |
|
32 |
import org.gvsig.expressionevaluator.swing.ExpressionEvaluatorSwingManager; |
|
33 |
import org.gvsig.expressionevaluator.swing.ExpressionPickerController; |
|
34 |
import org.gvsig.fmap.dal.DALLocator; |
|
35 |
import org.gvsig.fmap.dal.DataManager; |
|
36 |
import org.gvsig.fmap.dal.DataStoreParameters; |
|
37 |
import org.gvsig.fmap.dal.DataTypes; |
|
38 |
import org.gvsig.fmap.dal.exception.ValidateDataParametersException; |
|
39 |
import org.gvsig.fmap.dal.feature.FeatureAttributeDescriptor; |
|
40 |
import org.gvsig.fmap.dal.feature.FeatureStore; |
|
41 |
import org.gvsig.fmap.dal.feature.FeatureType; |
|
42 |
import org.gvsig.fmap.dal.store.jdbc.JDBCStoreParameters; |
|
43 |
import org.gvsig.fmap.dal.swing.DALSwingLocator; |
|
44 |
import org.gvsig.fmap.dal.swing.DataSwingManager; |
|
45 |
import org.gvsig.fmap.dal.swing.dataStoreParameters.DataStoreParametersPanel; |
|
46 |
import org.gvsig.fmap.dal.swing.dataStoreParameters.DataStoreParametersPanelManager; |
|
47 |
import org.gvsig.tools.ToolsLocator; |
|
48 |
import org.gvsig.tools.i18n.I18nManager; |
|
49 |
import org.gvsig.tools.swing.api.FilteredListController; |
|
50 |
import org.gvsig.tools.swing.api.JListWithCheckbox; |
|
51 |
import org.gvsig.tools.swing.api.ToolsSwingLocator; |
|
52 |
import org.gvsig.tools.swing.api.ToolsSwingManager; |
|
53 |
import org.gvsig.tools.swing.api.pickercontroller.PickerController; |
|
54 |
import org.gvsig.tools.swing.api.task.TaskStatusController; |
|
55 |
import org.gvsig.tools.swing.api.task.TaskStatusSwingManager; |
|
56 |
import org.gvsig.tools.swing.api.threadsafedialogs.ThreadSafeDialogsManager; |
|
57 |
import org.gvsig.tools.swing.api.windowmanager.Dialog; |
|
58 |
import org.gvsig.tools.swing.api.windowmanager.WindowManager; |
|
59 |
import org.gvsig.tools.swing.api.windowmanager.WindowManager_v2; |
|
60 |
import org.gvsig.tools.swing.icontheme.IconTheme; |
|
61 |
import org.gvsig.tools.util.LabeledValue; |
|
62 |
import org.gvsig.tools.util.LabeledValueImpl; |
|
63 |
import org.gvsig.vcsgis.lib.VCSGisEntity; |
|
64 |
import org.gvsig.vcsgis.lib.VCSGisManager; |
|
65 |
import static org.gvsig.vcsgis.lib.VCSGisManager.ERR_OK; |
|
66 |
import static org.gvsig.vcsgis.lib.VCSGisManager.STATE_REPOSITORY_NEW; |
|
67 |
import org.gvsig.vcsgis.lib.workspace.VCSGisWorkspace; |
|
68 |
import org.gvsig.vcsgis.lib.workspace.VCSGisWorkspaceEntity; |
|
69 |
import org.gvsig.vcsgis.swing.VCSGisJInitWorkspace; |
|
70 |
import org.gvsig.vcsgis.swing.VCSGisSwingLocator; |
|
71 |
import org.gvsig.vcsgis.swing.VCSGisSwingManager; |
|
72 |
import org.slf4j.Logger; |
|
73 |
import org.slf4j.LoggerFactory; |
|
74 |
|
|
75 |
/** |
|
76 |
* |
|
77 |
* @author jjdelcerro |
|
78 |
*/ |
|
79 |
@SuppressWarnings("UseSpecificCatch") |
|
80 |
public abstract class AbstractWizardVCSGis extends WizardPanel { |
|
81 |
|
|
82 |
protected static final Logger LOGGER = LoggerFactory.getLogger(AbstractWizardVCSGis.class); |
|
83 |
|
|
84 |
protected class TableInfo extends LabeledValueImpl<JDBCStoreParameters> { |
|
85 |
|
|
86 |
private final ListSelectionModel columnChecksModel; |
|
87 |
private FeatureType featureType; |
|
88 |
private int geomFieldSelected = -1; |
|
89 |
private int idFieldSelected = -1; |
|
90 |
private ComboBoxModel<String> idFieldComboModel; |
|
91 |
private ComboBoxModel<String> geomFieldComboModel; |
|
92 |
private List<FeatureAttributeDescriptor> attributeDescriptors; |
|
93 |
private ListModel<LabeledValue<FeatureAttributeDescriptor>> columnsListModel; |
|
94 |
private Expression filter; |
|
95 |
private IProjection projection; |
|
96 |
private boolean selected; |
|
97 |
private String documentName; |
|
98 |
|
|
99 |
public TableInfo(JDBCStoreParameters parameters) { |
|
100 |
super(getLabelForTable(parameters), parameters); |
|
101 |
this.columnChecksModel = new DefaultListSelectionModel(); |
|
102 |
this.selected = false; |
|
103 |
this.documentName = parameters.getTable(); |
|
104 |
this.projection = parameters.getCRS(); |
|
105 |
} |
|
106 |
|
|
107 |
public String getDocumentName() { |
|
108 |
return this.documentName; |
|
109 |
} |
|
110 |
|
|
111 |
public void setDocumentName(String name) { |
|
112 |
this.documentName = name; |
|
113 |
} |
|
114 |
|
|
115 |
public boolean isSelected() { |
|
116 |
return selected; |
|
117 |
} |
|
118 |
|
|
119 |
public void setSelected(boolean selected) { |
|
120 |
this.selected = selected; |
|
121 |
} |
|
122 |
|
|
123 |
public ListSelectionModel getColumnChecksModel() { |
|
124 |
return this.columnChecksModel; |
|
125 |
} |
|
126 |
|
|
127 |
public JDBCStoreParameters getParameters() { |
|
128 |
JDBCStoreParameters p = this.getValue(); |
|
129 |
StringBuilder fields = new StringBuilder(); |
|
130 |
List<FeatureAttributeDescriptor> attributes = this.getAttributeDescriptors(); |
|
131 |
boolean allSelected = true; |
|
132 |
for (int i = 0; i < attributes.size(); i++) { |
|
133 |
if (this.columnChecksModel.isSelectedIndex(i)) { |
|
134 |
if (fields.length() > 0) { |
|
135 |
fields.append(","); |
|
136 |
} |
|
137 |
fields.append(attributes.get(i).getName()); |
|
138 |
|
|
139 |
} else { |
|
140 |
allSelected = false; |
|
141 |
} |
|
142 |
} |
|
143 |
if( !allSelected ) { |
|
144 |
p.setFields(fields.toString()); |
|
145 |
} |
|
146 |
p.setPkFields(this.getFieldId()); |
|
147 |
p.setCRS(this.getProjection()); |
|
148 |
p.setDefaultGeometryField(this.getGeomField()); |
|
149 |
if (!ExpressionUtils.isEmpty(this.filter)) { |
|
150 |
p.setBaseFilter(this.filter.toString()); |
|
151 |
} else { |
|
152 |
p.setBaseFilter(null); |
|
153 |
} |
|
154 |
return p; |
|
155 |
} |
|
156 |
|
|
157 |
public void setProjection(IProjection projection) { |
|
158 |
this.projection = projection; |
|
159 |
} |
|
160 |
|
|
161 |
public IProjection getProjection() { |
|
162 |
return projection; |
|
163 |
} |
|
164 |
|
|
165 |
public String getFieldId() { |
|
166 |
if (this.idFieldSelected < 0) { |
|
167 |
return null; |
|
168 |
} |
|
169 |
return this.idFieldComboModel.getElementAt(this.idFieldSelected); |
|
170 |
} |
|
171 |
|
|
172 |
public String getGeomField() { |
|
173 |
if (this.geomFieldSelected < 0) { |
|
174 |
return null; |
|
175 |
} |
|
176 |
return this.geomFieldComboModel.getElementAt(this.geomFieldSelected); |
|
177 |
} |
|
178 |
|
|
179 |
public FeatureType getFeatureType() { |
|
180 |
if (this.featureType == null) { |
|
181 |
DataManager dataManager = DALLocator.getDataManager(); |
|
182 |
try { |
|
183 |
JDBCStoreParameters params = this.getValue(); |
|
184 |
FeatureStore store = (FeatureStore) dataManager.openStore( |
|
185 |
params.getDataStoreName(), |
|
186 |
params |
|
187 |
); |
|
188 |
this.featureType = store.getDefaultFeatureType(); |
|
189 |
} catch (Exception ex) { |
|
190 |
LOGGER.trace("Can't get feature type.",ex); // To allow set break points |
|
191 |
} |
|
192 |
} |
|
193 |
return this.featureType; |
|
194 |
} |
|
195 |
|
|
196 |
public ComboBoxModel getGeomFieldComboModel() { |
|
197 |
if (this.geomFieldComboModel == null) { |
|
198 |
DefaultComboBoxModel<String> geomModel = new DefaultComboBoxModel<>(); |
|
199 |
geomModel.addElement(" "); |
|
200 |
int geomIndex = -1; |
|
201 |
int n = 1; |
|
202 |
for (FeatureAttributeDescriptor attr : this.getAttributeDescriptors()) { |
|
203 |
if (geomIndex < 0 && attr.getType() == DataTypes.GEOMETRY) { |
|
204 |
geomIndex = n; |
|
205 |
} |
|
206 |
int dataType = attr.getType(); |
|
207 |
if (dataType == DataTypes.GEOMETRY |
|
208 |
|| dataType == DataTypes.BYTEARRAY |
|
209 |
|| dataType == DataTypes.STRING) { |
|
210 |
geomModel.addElement(attr.getName()); |
|
211 |
n++; |
|
212 |
} |
|
213 |
} |
|
214 |
if (geomIndex < 0) { |
|
215 |
geomIndex = 0; |
|
216 |
} |
|
217 |
this.geomFieldComboModel = geomModel; |
|
218 |
this.geomFieldSelected = geomIndex; |
|
219 |
} |
|
220 |
return this.geomFieldComboModel; |
|
221 |
} |
|
222 |
|
|
223 |
public int getGeomFieldSelected() { |
|
224 |
return this.geomFieldSelected; |
|
225 |
} |
|
226 |
|
|
227 |
public ComboBoxModel getIdFieldComboModel() { |
|
228 |
if (this.idFieldComboModel == null) { |
|
229 |
StringBuilder pkName = new StringBuilder(); |
|
230 |
for (FeatureAttributeDescriptor attr : this.getAttributeDescriptors()) { |
|
231 |
if (attr.isPrimaryKey()) { |
|
232 |
if (!StringUtils.isBlank(pkName)) { |
|
233 |
pkName.append(","); |
|
234 |
} |
|
235 |
pkName.append(attr.getName()); |
|
236 |
} |
|
237 |
} |
|
238 |
DefaultComboBoxModel<String> idsModel = new DefaultComboBoxModel<>(); |
|
239 |
idsModel.addElement(" "); |
|
240 |
int idsIndex = -1; |
|
241 |
int n = 1; |
|
242 |
if (!StringUtils.isBlank(pkName) && StringUtils.contains(pkName, "/")) { |
|
243 |
idsModel.addElement(pkName.toString()); |
|
244 |
idsIndex = n++; |
|
245 |
} |
|
246 |
for (FeatureAttributeDescriptor attr : getAttributeDescriptors()) { |
|
247 |
if (idsIndex < 0 && attr.isPrimaryKey()) { |
|
248 |
idsIndex = n; |
|
249 |
} |
|
250 |
idsModel.addElement(attr.getName()); |
|
251 |
n++; |
|
252 |
} |
|
253 |
if (idsIndex < 0) { |
|
254 |
idsIndex = 0; |
|
255 |
} |
|
256 |
this.idFieldComboModel = idsModel; |
|
257 |
this.idFieldSelected = idsIndex; |
|
258 |
} |
|
259 |
return this.idFieldComboModel; |
|
260 |
} |
|
261 |
|
|
262 |
public List<FeatureAttributeDescriptor> getAttributeDescriptors() { |
|
263 |
if (this.attributeDescriptors == null) { |
|
264 |
List<FeatureAttributeDescriptor> attrs = new ArrayList<>(); |
|
265 |
for (FeatureAttributeDescriptor attr : this.getFeatureType()) { |
|
266 |
attrs.add(attr); |
|
267 |
} |
|
268 |
attrs.sort((FeatureAttributeDescriptor o1, FeatureAttributeDescriptor o2) -> |
|
269 |
o1.getName().compareTo(o2.getName()) |
|
270 |
); |
|
271 |
this.columnChecksModel.setSelectionInterval(0, attrs.size()); |
|
272 |
this.attributeDescriptors = attrs; |
|
273 |
} |
|
274 |
return this.attributeDescriptors; |
|
275 |
} |
|
276 |
|
|
277 |
public ListModel<LabeledValue<FeatureAttributeDescriptor>> getColumnsListModel() { |
|
278 |
if (this.columnsListModel == null) { |
|
279 |
DefaultListModel<LabeledValue<FeatureAttributeDescriptor>> model = new DefaultListModel<>(); |
|
280 |
for (FeatureAttributeDescriptor attr : this.getAttributeDescriptors()) { |
|
281 |
model.addElement(new LabeledValueImpl<>( |
|
282 |
attr.getName() + " [" + attr.getDataTypeName() + "]", |
|
283 |
attr |
|
284 |
) |
|
285 |
); |
|
286 |
} |
|
287 |
this.columnsListModel = model; |
|
288 |
} |
|
289 |
return this.columnsListModel; |
|
290 |
} |
|
291 |
|
|
292 |
public FeatureAttributeDescriptor getAttributeDescriptor(String attrName) { |
|
293 |
return this.getFeatureType().getAttributeDescriptor(attrName); |
|
294 |
} |
|
295 |
|
|
296 |
public int getIdFieldSelected() { |
|
297 |
return this.idFieldSelected; |
|
298 |
} |
|
299 |
|
|
300 |
public Expression getFilter() { |
|
301 |
return this.filter; |
|
302 |
} |
|
303 |
|
|
304 |
public void setFilter(Expression filter) { |
|
305 |
this.filter = filter; |
|
306 |
} |
|
307 |
|
|
308 |
private void setIdFieldSelected(int selectedIndex) { |
|
309 |
this.idFieldSelected = selectedIndex; |
|
310 |
} |
|
311 |
|
|
312 |
private void setGeomFieldSelected(int selectedIndex) { |
|
313 |
this.geomFieldSelected = selectedIndex; |
|
314 |
} |
|
315 |
|
|
316 |
private boolean hasValidValues() { |
|
317 |
if (this.getGeomFieldSelected() < 0 && requireGeometry()) { |
|
318 |
return false; |
|
319 |
} |
|
320 |
JDBCStoreParameters p = this.getParameters(); |
|
321 |
try { |
|
322 |
p.validate(); |
|
323 |
return true; |
|
324 |
} catch (ValidateDataParametersException ex) { |
|
325 |
return false; |
|
326 |
} |
|
327 |
} |
|
328 |
|
|
329 |
} |
|
330 |
|
|
331 |
private WizardVCSGisViewExtended view; |
|
332 |
private PickerController<VCSGisWorkspace> workspacePicker; |
|
333 |
private PickerController<IProjection> pickerProjection; |
|
334 |
private ExpressionPickerController pickerFilter; |
|
335 |
private JListWithCheckbox lwcTables; |
|
336 |
private JListWithCheckbox lwcColumns; |
|
337 |
protected Map<String, TableInfo> tablesInfo = null; |
|
338 |
protected FilteredListController tablesFilterController; |
|
339 |
private boolean processing; |
|
340 |
private TaskStatusController taskStatusController; |
|
341 |
|
|
342 |
public AbstractWizardVCSGis() { |
|
343 |
initComponents(); |
|
344 |
} |
|
345 |
|
|
346 |
private void initComponents() { |
|
347 |
DataSwingManager dataSwingManager = DALSwingLocator.getDataSwingManager(); |
|
348 |
ToolsSwingManager toolsSwingManager = ToolsSwingLocator.getToolsSwingManager(); |
|
349 |
ExpressionEvaluatorSwingManager expressionSwingManager = ExpressionEvaluatorSwingLocator.getManager(); |
|
350 |
VCSGisSwingManager swingManager = VCSGisSwingLocator.getVCSGisSwingManager(); |
|
351 |
|
|
352 |
this.view = new WizardVCSGisViewExtended(); |
|
353 |
|
|
354 |
TaskStatusSwingManager taskStatusManager = ToolsSwingLocator.getTaskStatusSwingManager(); |
|
355 |
|
|
356 |
this.taskStatusController = taskStatusManager.createTaskStatusController( |
|
357 |
this.view.lblStatusTitle, |
|
358 |
this.view.lblStatusMessages, |
|
359 |
this.view.pbStatus |
|
360 |
); |
|
361 |
this.taskStatusController.setShowCancelButton(false); |
|
362 |
this.taskStatusController.setShowRemoveTaskButton(false); |
|
363 |
this.taskStatusController.bind(ToolsLocator.getTaskStatusManager()); |
|
364 |
|
|
365 |
toolsSwingManager.translate(this.view.btnDeselectAllColumns); |
|
366 |
toolsSwingManager.translate(this.view.btnSelectAllColumns); |
|
367 |
toolsSwingManager.translate(this.view.lblColumns); |
|
368 |
toolsSwingManager.translate(this.view.lblWorkspace); |
|
369 |
toolsSwingManager.translate(this.view.lblFilter); |
|
370 |
toolsSwingManager.translate(this.view.lblGeometryField); |
|
371 |
toolsSwingManager.translate(this.view.lblIdField); |
|
372 |
toolsSwingManager.translate(this.view.lblName); |
|
373 |
toolsSwingManager.translate(this.view.lblProjection); |
|
374 |
toolsSwingManager.translate(this.view.lblTable); |
|
375 |
toolsSwingManager.translate(this.view.cboWorkspaces); |
|
376 |
toolsSwingManager.translate(this.view.btnAddWorkspace); |
|
377 |
toolsSwingManager.translate(this.view.btnCheckout); |
|
378 |
toolsSwingManager.translate(this.view.btnAdvancedProperties); |
|
379 |
toolsSwingManager.translate(this.view.btnInitWorkspace); |
|
380 |
this.view.btnInitWorkspace.setText(toHTML(this.view.btnInitWorkspace.getText())); |
|
381 |
toolsSwingManager.translate(this.view.txtRepositoryInfo); |
|
382 |
|
|
383 |
toolsSwingManager.addClearButton(this.view.txtName); |
|
384 |
toolsSwingManager.setDefaultPopupMenu(this.view.txtName); |
|
385 |
|
|
386 |
this.view.btnInitWorkspace.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); |
|
387 |
this.view.btnAddWorkspace.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); |
|
388 |
this.view.btnSelectAllColumns.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); |
|
389 |
this.view.btnDeselectAllColumns.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); |
|
390 |
this.view.btnProjection.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); |
|
391 |
this.view.btnFilter.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); |
|
392 |
this.view.btnFilterBookmarks.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); |
|
393 |
this.view.btnFilterHistory.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); |
|
394 |
this.view.btnAdvancedProperties.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); |
|
395 |
this.view.btnAdvancedProperties.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); |
|
396 |
|
|
397 |
|
|
398 |
|
|
399 |
|
|
400 |
this.lwcTables = toolsSwingManager.createJListWithCheckbox( |
|
401 |
this.view.lstTables |
|
402 |
); |
|
403 |
this.lwcColumns = toolsSwingManager.createJListWithCheckbox( |
|
404 |
this.view.lstColumns |
|
405 |
); |
|
406 |
|
|
407 |
this.workspacePicker = swingManager.createWorkspacePickerController( |
|
408 |
this.view.cboWorkspaces, |
|
409 |
this.view.btnAddWorkspace |
|
410 |
); |
|
411 |
|
|
412 |
this.workspacePicker.addChangeListener((ChangeEvent e) -> { |
|
413 |
doChangeWorkspace(); |
|
414 |
setEditableTables(true); |
|
415 |
}); |
|
416 |
|
|
417 |
|
|
418 |
this.pickerProjection = dataSwingManager.createProjectionPickerController( |
|
419 |
this.view.txtProjection, |
|
420 |
this.view.btnProjection |
|
421 |
); |
|
422 |
|
|
423 |
this.pickerFilter = expressionSwingManager.createExpressionPickerController( |
|
424 |
this.view.txtFilter, |
|
425 |
this.view.btnFilter, |
|
426 |
this.view.btnFilterBookmarks, |
|
427 |
this.view.btnFilterHistory |
|
428 |
); |
|
429 |
this.lwcTables.addListSelectionListener((ListSelectionEvent e) -> { |
|
430 |
doChangeTableSelected(); |
|
431 |
}); |
|
432 |
this.lwcTables.addChecksListener((ListSelectionEvent e) -> { |
|
433 |
doChangeTableSelected(); |
|
434 |
}); |
|
435 |
this.view.cboGeometryField.addItemListener((ItemEvent e) -> { |
|
436 |
if (e.getStateChange() == ItemEvent.SELECTED) { |
|
437 |
doChangeGeometryField(); |
|
438 |
} |
|
439 |
}); |
|
440 |
this.view.btnDeselectAllColumns.addActionListener((ActionEvent e) -> { |
|
441 |
doDeselectAllColumns(); |
|
442 |
}); |
|
443 |
this.view.btnSelectAllColumns.addActionListener((ActionEvent e) -> { |
|
444 |
doSelectAllColumns(); |
|
445 |
}); |
|
446 |
this.view.btnAdvancedProperties.addActionListener((ActionEvent e) -> { |
|
447 |
doShowAdvancedProperties(); |
|
448 |
}); |
|
449 |
this.view.btnInitWorkspace.addActionListener((ActionEvent e) -> { |
|
450 |
doShowInitWorkspace(); |
|
451 |
}); |
|
452 |
|
|
453 |
this.view.btnCheckout.addActionListener((ActionEvent e) -> { |
|
454 |
doCheckout(); |
|
455 |
}); |
|
456 |
|
|
457 |
|
|
458 |
|
|
459 |
this.tablesFilterController = toolsSwingManager.createFilteredListController( |
|
460 |
this.view.lstTables, |
|
461 |
this.view.txtTablesFilter, |
|
462 |
this.view.btnTablesFilter |
|
463 |
); |
|
464 |
|
|
465 |
this.clearTables(); |
|
466 |
this.setEditableTables(false); |
|
467 |
|
|
468 |
this.setLayout(new BorderLayout()); |
|
469 |
this.add(this.view, BorderLayout.CENTER); |
|
470 |
this.setPreferredSize(new Dimension(500, 400)); |
|
471 |
doUpdateComponents(); |
|
472 |
} |
|
473 |
|
|
474 |
protected abstract boolean requireGeometry(); |
|
475 |
|
|
476 |
protected Collection<TableInfo> getTablesInformation() { |
|
477 |
this.updateTableInfoFromUI(); |
|
478 |
if( this.tablesInfo == null ) { |
|
479 |
this.tablesInfo = new HashMap<>(); |
|
480 |
} |
|
481 |
return this.tablesInfo.values(); |
|
482 |
} |
|
483 |
|
|
484 |
private void doDeselectAllColumns() { |
|
485 |
TableInfo info = this.getCurrentTableInfo(); |
|
486 |
if (info == null) { |
|
487 |
return; |
|
488 |
} |
|
489 |
info.getColumnChecksModel().clearSelection(); |
|
490 |
} |
|
491 |
|
|
492 |
private void doSelectAllColumns() { |
|
493 |
TableInfo info = this.getCurrentTableInfo(); |
|
494 |
if (info == null) { |
|
495 |
return; |
|
496 |
} |
|
497 |
info.getColumnChecksModel().setSelectionInterval(0, info.getAttributeDescriptors().size()); |
|
498 |
} |
|
499 |
|
|
500 |
private void doShowAdvancedProperties() { |
|
501 |
final TableInfo info = this.getCurrentTableInfo(); |
|
502 |
if (info == null) { |
|
503 |
return; |
|
504 |
} |
|
505 |
this.fetch(info); |
|
506 |
I18nManager i18n = ToolsLocator.getI18nManager(); |
|
507 |
WindowManager_v2 winmgr = (WindowManager_v2) ToolsSwingLocator.getWindowManager(); |
|
508 |
DataStoreParametersPanelManager paramsPanelManager = DALSwingLocator.getDataStoreParametersPanelManager(); |
|
509 |
|
|
510 |
final DataStoreParametersPanel panel = paramsPanelManager.createDataStoreParametersPanel(info.getParameters()); |
|
511 |
final Dialog dialog = winmgr.createDialog( |
|
512 |
panel.asJComponent(), |
|
513 |
i18n.getTranslation("_Connection_parameters"), |
|
514 |
null, |
|
515 |
WindowManager_v2.BUTTONS_OK_CANCEL |
|
516 |
); |
|
517 |
dialog.addActionListener((ActionEvent e) -> { |
|
518 |
if( dialog.getAction()==WindowManager_v2.BUTTON_OK ) { |
|
519 |
panel.fetchParameters(info.getParameters()); |
|
520 |
} |
|
521 |
}); |
|
522 |
dialog.show(WindowManager.MODE.DIALOG); |
|
523 |
} |
|
524 |
|
|
525 |
private void clearTables() { |
|
526 |
this.lwcTables.setModel(new DefaultListModel()); |
|
527 |
this.lwcTables.getCheckedModel().clearSelection(); |
|
528 |
this.clearTableConfig(); |
|
529 |
} |
|
530 |
|
|
531 |
private void clearTableConfig() { |
|
532 |
this.lwcColumns.setModel(new DefaultListModel()); |
|
533 |
this.lwcColumns.getCheckedModel().clearSelection(); |
|
534 |
this.view.txtName.setText(""); |
|
535 |
this.view.cboGeometryField.setModel(new DefaultComboBoxModel()); |
|
536 |
this.view.cboIdField.setModel(new DefaultComboBoxModel()); |
|
537 |
this.pickerProjection.set(null); |
|
538 |
this.pickerFilter.set(null); |
|
539 |
} |
|
540 |
|
|
541 |
private void setEditableTables(boolean enable) { |
|
542 |
this.view.lstTables.setEnabled(enable); |
|
543 |
this.setEditableTableConfig(enable); |
|
544 |
this.view.btnDeselectAllColumns.setEnabled(enable); |
|
545 |
this.view.btnSelectAllColumns.setEnabled(enable); |
|
546 |
} |
|
547 |
|
|
548 |
private void setEditableTableConfig(boolean enable) { |
|
549 |
this.view.lstColumns.setEnabled(enable); |
|
550 |
this.view.txtName.setEditable(enable); |
|
551 |
this.view.cboGeometryField.setEnabled(enable); |
|
552 |
this.view.cboIdField.setEnabled(enable); |
|
553 |
this.pickerProjection.setEditable(enable); |
|
554 |
this.pickerFilter.setEditable(enable); |
|
555 |
this.view.btnAdvancedProperties.setEnabled(enable); |
|
556 |
} |
|
557 |
|
|
558 |
private TableInfo getCurrentTableInfo() { |
|
559 |
VCSGisEntity rEntity = getRemoteEntity(); |
|
560 |
if(rEntity == null){ |
|
561 |
return null; |
|
562 |
} |
|
563 |
|
|
564 |
TableInfo xx = this.tablesInfo.get(rEntity.getEntityName()); |
|
565 |
return xx; |
|
566 |
} |
|
567 |
|
|
568 |
private void doChangeGeometryField() { |
|
569 |
TableInfo info = this.getCurrentTableInfo(); |
|
570 |
if (info == null) { |
|
571 |
return; |
|
572 |
} |
|
573 |
String attrName = (String) this.view.cboGeometryField.getSelectedItem(); |
|
574 |
if (StringUtils.isBlank(attrName)) { |
|
575 |
return; |
|
576 |
} |
|
577 |
FeatureAttributeDescriptor attr = info.getAttributeDescriptor(attrName); |
|
578 |
IProjection srs = attr.getSRS(); |
|
579 |
if (srs == null) { |
|
580 |
return; |
|
581 |
} |
|
582 |
this.pickerProjection.set(srs); |
|
583 |
} |
|
584 |
|
|
585 |
private void doChangeWorkspace() { |
|
586 |
if (notInSwingThreadInvokeLater(this::doChangeWorkspace)) { |
|
587 |
return; |
|
588 |
} |
|
589 |
|
|
590 |
this.lwcTables.clearSelection(); |
|
591 |
|
|
592 |
I18nManager i18n = ToolsLocator.getI18nManager(); |
|
593 |
VCSGisWorkspace workspace = workspacePicker.get(); |
|
594 |
this.tablesFilterController.getModel().clear(); |
|
595 |
if (workspace == null) { |
|
596 |
return; |
|
597 |
} |
|
598 |
|
|
599 |
this.view.txtRepositoryInfo.setText(workspace.getRepository().getLabel()); |
|
600 |
|
|
601 |
reloadEntities(workspace, i18n); |
|
602 |
} |
|
603 |
|
|
604 |
private void reloadEntities(VCSGisWorkspace workspace, I18nManager i18n) { |
|
605 |
this.tablesInfo = new HashMap<>(); |
|
606 |
|
|
607 |
//Rellenamos la lista de entidades |
|
608 |
Thread task = new Thread(() -> { |
|
609 |
try { |
|
610 |
processing = true; |
|
611 |
doUpdateComponents(); |
|
612 |
List<VCSGisEntity> repoEntities = workspace.getRepositoryEntities(); |
|
613 |
List<VCSGisWorkspaceEntity> wsEntities = workspace.getWorkspaceEntities(); |
|
614 |
doReloadEntitiesList(repoEntities, wsEntities); |
|
615 |
|
|
616 |
|
|
617 |
} catch (Exception e) { |
|
618 |
LOGGER.warn("_Cant_retrieve_entities_from_repository", e); |
|
619 |
ThreadSafeDialogsManager dialogs = ToolsSwingLocator.getThreadSafeDialogsManager(); |
|
620 |
dialogs.messageDialog( |
|
621 |
i18n.getTranslation("_Cant_retrieve_entities_from_repository") + "\n" + e.getMessage(), |
|
622 |
i18n.getTranslation("_Add_table"), |
|
623 |
JOptionPane.WARNING_MESSAGE |
|
624 |
); |
|
625 |
|
|
626 |
} finally { |
|
627 |
processing = false; |
|
628 |
doUpdateComponents(); |
|
629 |
} |
|
630 |
}, "VCSGisAddTable_getRepositoryEntities"); |
|
631 |
|
|
632 |
processing = true; |
|
633 |
doUpdateComponents(); |
|
634 |
task.start(); |
|
635 |
} |
|
636 |
|
|
637 |
|
|
638 |
// private void doUpdateTables() { |
|
639 |
// JDBCServerExplorerParameters connection = this.pickerConnection.get(); |
|
640 |
// if (connection == null) { |
|
641 |
// this.clearTables(); |
|
642 |
// return; |
|
643 |
// } |
|
644 |
// DataManager dataManager = DALLocator.getDataManager(); |
|
645 |
// DataServerExplorer explorer = null; |
|
646 |
// try { |
|
647 |
// explorer = dataManager.openServerExplorer( |
|
648 |
// connection.getDataStoreName(), |
|
649 |
// connection |
|
650 |
// ); |
|
651 |
// List<TableInfo> parameters = new ArrayList<>(); |
|
652 |
// for (DataStoreParameters params : explorer.list()) { |
|
653 |
// parameters.add(new TableInfo((JDBCStoreParameters) params)); |
|
654 |
// } |
|
655 |
// parameters.sort((TableInfo o1, TableInfo o2) -> |
|
656 |
// o1.getLabel().compareTo(o2.getLabel()) |
|
657 |
// ); |
|
658 |
// this.tablesInfo = new HashMap<>(); |
|
659 |
// DefaultListModel<TableInfo> model = new DefaultListModel<>(); |
|
660 |
// for (TableInfo x : parameters) { |
|
661 |
// model.addElement(x); |
|
662 |
// this.tablesInfo.put(x.getDocumentName(), x); |
|
663 |
// } |
|
664 |
// this.lwcTables.setModel(model); |
|
665 |
// this.lwcTables.getCheckedModel().clearSelection(); |
|
666 |
// } catch (Exception ex) { |
|
667 |
// } finally { |
|
668 |
// DisposeUtils.disposeQuietly(explorer); |
|
669 |
// } |
|
670 |
// } |
|
671 |
|
|
672 |
private void doChangeTableSelected() { |
|
673 |
if( notInSwingThreadInvokeLater(() -> {doChangeTableSelected();}) ) { |
|
674 |
return; |
|
675 |
} |
|
676 |
boolean updatedTableInfo = false; |
|
677 |
|
|
678 |
VCSGisEntity rEntity = getRemoteEntity(); |
|
679 |
if(rEntity != null){ |
|
680 |
VCSGisWorkspaceEntity lEntity; |
|
681 |
lEntity = getWorkspace().getWorkspaceEntity(rEntity.getEntityName()); |
|
682 |
if(lEntity != null){ |
|
683 |
TableInfo tableInfo = tablesInfo.get(rEntity.getEntityName()); |
|
684 |
this.updateTableInfoFromUI(); |
|
685 |
this.put(tableInfo); |
|
686 |
updatedTableInfo = true; |
|
687 |
} else { |
|
688 |
int index = this.lwcTables.getSelectedIndex(); |
|
689 |
this.lwcTables.getCheckedModel().removeIndexInterval(index, index); |
|
690 |
} |
|
691 |
} |
|
692 |
|
|
693 |
if(!updatedTableInfo){ |
|
694 |
this.clearTableConfig(); |
|
695 |
} |
|
696 |
|
|
697 |
showMessage(""); |
|
698 |
doUpdateComponents(); |
|
699 |
} |
|
700 |
|
|
701 |
private void updateTableInfoFromUI() { |
|
702 |
String previousTableName = this.view.txtName.getText(); |
|
703 |
if (this.tablesInfo!=null && !this.tablesInfo.isEmpty()) { |
|
704 |
TableInfo previousInfo = this.tablesInfo.get(previousTableName); |
|
705 |
if (previousInfo != null) { |
|
706 |
this.fetch(previousInfo); |
|
707 |
} |
|
708 |
} |
|
709 |
} |
|
710 |
|
|
711 |
private void put(TableInfo tableInfo) { |
|
712 |
this.lwcColumns.setModel(tableInfo.getColumnsListModel()); |
|
713 |
this.lwcColumns.setCheckedModel(tableInfo.getColumnChecksModel()); |
|
714 |
|
|
715 |
this.view.cboGeometryField.setModel(tableInfo.getGeomFieldComboModel()); |
|
716 |
this.view.cboGeometryField.setSelectedIndex(tableInfo.getGeomFieldSelected()); |
|
717 |
|
|
718 |
this.view.cboIdField.setModel(tableInfo.getIdFieldComboModel()); |
|
719 |
this.view.cboIdField.setSelectedIndex(tableInfo.getIdFieldSelected()); |
|
720 |
|
|
721 |
this.pickerProjection.set(tableInfo.getProjection()); |
|
722 |
this.pickerFilter.set(tableInfo.getFilter()); |
|
723 |
this.view.txtName.setText(tableInfo.getDocumentName()); |
|
724 |
} |
|
725 |
|
|
726 |
private void fetch(TableInfo tableInfo) { |
|
727 |
tableInfo.setIdFieldSelected(this.view.cboIdField.getSelectedIndex()); |
|
728 |
tableInfo.setGeomFieldSelected(this.view.cboGeometryField.getSelectedIndex()); |
|
729 |
tableInfo.setFilter(this.pickerFilter.get()); |
|
730 |
tableInfo.setProjection(this.pickerProjection.get()); |
|
731 |
tableInfo.setDocumentName(this.view.txtName.getText()); |
|
732 |
int index = this.lwcTables.getSelectedIndex(); |
|
733 |
tableInfo.setSelected(this.lwcTables.getCheckedModel().isSelectedIndex(index)); |
|
734 |
} |
|
735 |
|
|
736 |
@Override |
|
737 |
public void initWizard() { |
|
738 |
I18nManager i18n = ToolsLocator.getI18nManager(); |
|
739 |
setTabName(i18n.getTranslation("_VCSGis")); |
|
740 |
} |
|
741 |
|
|
742 |
@Override |
|
743 |
public boolean areSettingsValid() { |
|
744 |
if(processing){ |
|
745 |
return false; |
|
746 |
} |
|
747 |
boolean hasInvalidValues = false; |
|
748 |
boolean hasSelectedTables = false; |
|
749 |
for (TableInfo tableInfo : this.getTablesInformation() ) { |
|
750 |
if (tableInfo.isSelected()) { |
|
751 |
hasSelectedTables = true; |
|
752 |
if (!tableInfo.hasValidValues()) { |
|
753 |
hasInvalidValues = true; |
|
754 |
} |
|
755 |
} |
Also available in: Unified diff