Revision 44704
trunk/org.gvsig.desktop/org.gvsig.desktop.plugin/org.gvsig.app/org.gvsig.app.mainplugin/src/main/java/org/gvsig/app/extension/ViewControls.java | ||
---|---|---|
38 | 38 |
import org.gvsig.app.ApplicationManager; |
39 | 39 |
import org.gvsig.app.gui.preferencespage.ViewPage; |
40 | 40 |
import org.gvsig.app.gui.preferencespage.dal.DALPage; |
41 |
import org.gvsig.app.gui.preferencespage.databaseworkspace.DatabaseWorkspacePage; |
|
41 | 42 |
import org.gvsig.app.gui.preferencespage.dialogreminder.DialogReminderPage; |
42 | 43 |
import org.gvsig.app.project.Project; |
43 | 44 |
import org.gvsig.app.project.ProjectManager; |
... | ... | |
239 | 240 |
|
240 | 241 |
IconThemeHelper.registerIcon("preferences", "dialog-remember-preferences", this); |
241 | 242 |
IconThemeHelper.registerIcon("preferences", "dal-preferences", this); |
243 |
IconThemeHelper.registerIcon("preferences", "databaseworkspace-preferences", this); |
|
242 | 244 |
} |
243 | 245 |
|
244 | 246 |
public boolean isEnabled() { |
... | ... | |
265 | 267 |
prefs.add(getViewPropertiesPage()); |
266 | 268 |
prefs.add(new DialogReminderPage()); |
267 | 269 |
prefs.add(new DALPage()); |
270 |
prefs.add(new DatabaseWorkspacePage()); |
|
268 | 271 |
|
269 | 272 |
return prefs.toArray(new IPreference[prefs.size()]); |
270 | 273 |
} |
trunk/org.gvsig.desktop/org.gvsig.desktop.plugin/org.gvsig.app/org.gvsig.app.mainplugin/src/main/java/org/gvsig/app/extension/InitializeApplicationExtension.java | ||
---|---|---|
33 | 33 |
import java.util.HashMap; |
34 | 34 |
import java.util.List; |
35 | 35 |
import java.util.Map; |
36 |
import java.util.Objects; |
|
36 | 37 |
import java.util.Properties; |
37 | 38 |
import java.util.prefs.Preferences; |
38 | 39 |
import javax.swing.JOptionPane; |
... | ... | |
60 | 61 |
import org.gvsig.expressionevaluator.ExpressionEvaluatorManager; |
61 | 62 |
import org.gvsig.fmap.dal.DALLocator; |
62 | 63 |
import org.gvsig.fmap.dal.DataManager; |
64 |
import org.gvsig.fmap.dal.DataServerExplorerPool; |
|
65 |
import org.gvsig.fmap.dal.DataServerExplorerPoolEntry; |
|
66 |
import org.gvsig.fmap.dal.DatabaseWorkspaceManager; |
|
63 | 67 |
import org.gvsig.fmap.dal.OpenErrorHandler; |
64 | 68 |
import org.gvsig.fmap.dal.feature.AbstractDataProfile; |
65 | 69 |
import org.gvsig.fmap.dal.resource.ResourceManager; |
... | ... | |
85 | 89 |
import org.slf4j.Logger; |
86 | 90 |
import org.slf4j.LoggerFactory; |
87 | 91 |
|
92 |
@SuppressWarnings("UseSpecificCatch") |
|
88 | 93 |
public class InitializeApplicationExtension extends Extension { |
89 | 94 |
|
90 |
private static final Logger logger = LoggerFactory |
|
91 |
.getLogger(InitializeApplicationExtension.class); |
|
95 |
private static final Logger LOGGER = LoggerFactory.getLogger(InitializeApplicationExtension.class); |
|
92 | 96 |
|
93 | 97 |
// Copiadas de org.gvsig.coreplugin.PreferencesExtension |
94 | 98 |
public static final String PROJECTS_FOLDER_PROPERTY_NAME = "ProjectsFolder"; |
... | ... | |
256 | 260 |
} |
257 | 261 |
}, true, -1); |
258 | 262 |
|
263 |
pluginManager.addStartupTask("ConnectoToDefaultWorkspace", () -> { |
|
264 |
connectToDefaultWorkspace(); |
|
265 |
}, false, 500); |
|
259 | 266 |
} |
260 | 267 |
|
268 |
private void connectToDefaultWorkspace() { |
|
269 |
String workspaceName = null; |
|
270 |
try { |
|
271 |
DataManager dataManager = DALLocator.getDataManager(); |
|
272 |
PluginsManager pluginManager = PluginsLocator.getPluginsManager(); |
|
273 |
PluginServices plugin = pluginManager.getPlugin(this); |
|
274 |
DynObject preferences = plugin.getPluginProperties(); |
|
275 |
if ((Boolean) (preferences.getDynValue("connectAutomaticallyToDatabaseWorkspace"))) { |
|
276 |
workspaceName = (String) preferences.getDynValue("databaseWorkspaceToConnect"); |
|
277 |
DataServerExplorerPool pool = dataManager.getDataServerExplorerPool(); |
|
278 |
DataServerExplorerPoolEntry entry = pool.get(workspaceName); |
|
279 |
if (entry != null) { |
|
280 |
DatabaseWorkspaceManager workspace = dataManager.createDatabaseWorkspaceManager( |
|
281 |
entry.getExplorerParameters() |
|
282 |
); |
|
283 |
if (workspace != null) { |
|
284 |
dataManager.addDatabaseWorkspace(workspace); |
|
285 |
} |
|
286 |
} |
|
287 |
} |
|
288 |
} catch (Exception ex) { |
|
289 |
LOGGER.warn("Can't connect to default workspace ("+Objects.toString(workspaceName)+").", ex); |
|
290 |
} |
|
291 |
} |
|
292 |
|
|
261 | 293 |
private void showAddOnManagerOnStartIfNeed() { |
262 | 294 |
PluginsManager pluginManager = PluginsLocator.getManager(); |
263 | 295 |
PluginServices plugin = pluginManager.getPlugin(this); |
... | ... | |
301 | 333 |
try { |
302 | 334 |
application.getUIManager().setMaximum((IWindow) viewWindow, true); |
303 | 335 |
} catch (PropertyVetoException e) { |
304 |
logger.info("Can't maximize view.", e);
|
|
336 |
LOGGER.info("Can't maximize view.", e);
|
|
305 | 337 |
} |
306 | 338 |
} |
307 | 339 |
|
... | ... | |
377 | 409 |
private void addToLogInfo() { |
378 | 410 |
String info[] = this.getStringInfo().split("\n"); |
379 | 411 |
for (String line : info) { |
380 |
logger.info(line);
|
|
412 |
LOGGER.info(line);
|
|
381 | 413 |
} |
382 | 414 |
} |
383 | 415 |
|
... | ... | |
446 | 478 |
try { |
447 | 479 |
resMan.dispose(); |
448 | 480 |
} catch (DisposeResorceManagerException e) { |
449 |
logger.warn(e.getMessageStack());
|
|
481 |
LOGGER.warn(e.getMessageStack());
|
|
450 | 482 |
} |
451 | 483 |
super.terminate(); |
452 | 484 |
} |
trunk/org.gvsig.desktop/org.gvsig.desktop.plugin/org.gvsig.app/org.gvsig.app.mainplugin/src/main/java/org/gvsig/app/gui/preferencespage/databaseworkspace/DatabaseWorkspacePageView.xml | ||
---|---|---|
1 |
<?xml version="1.0" encoding="UTF-8"?> |
|
2 |
|
|
3 |
<object classname="com.jeta.forms.store.memento.FormPackage"> |
|
4 |
<at name="fileversion"> |
|
5 |
<object classname="com.jeta.forms.store.memento.FormsVersion2"> |
|
6 |
<at name="major">2</at> |
|
7 |
<at name="minor">0</at> |
|
8 |
<at name="sub">0</at> |
|
9 |
</object> |
|
10 |
</at> |
|
11 |
<at name="form"> |
|
12 |
<object classname="com.jeta.forms.store.memento.FormMemento"> |
|
13 |
<super classname="com.jeta.forms.store.memento.ComponentMemento"> |
|
14 |
<at name="cellconstraints"> |
|
15 |
<object classname="com.jeta.forms.store.memento.CellConstraintsMemento"> |
|
16 |
<at name="column">1</at> |
|
17 |
<at name="row">1</at> |
|
18 |
<at name="colspan">1</at> |
|
19 |
<at name="rowspan">1</at> |
|
20 |
<at name="halign">default</at> |
|
21 |
<at name="valign">default</at> |
|
22 |
<at name="insets" object="insets">0,0,0,0</at> |
|
23 |
</object> |
|
24 |
</at> |
|
25 |
<at name="componentclass">com.jeta.forms.gui.form.FormComponent</at> |
|
26 |
</super> |
|
27 |
<at name="id">/home/jjdelcerro/datos/devel/org.gvsig.desktop/org.gvsig.desktop.plugin/org.gvsig.app/org.gvsig.app.mainplugin/src/main/java/org/gvsig/app/gui/preferencespage/databaseworkspace/DatabaseWorkspacePageView.xml</at> |
|
28 |
<at name="rowspecs">CENTER:DEFAULT:NONE,CENTER:DEFAULT:NONE,CENTER:DEFAULT:NONE,CENTER:DEFAULT:NONE,CENTER:2DLU:NONE,CENTER:DEFAULT:NONE,CENTER:DEFAULT:NONE,FILL:DEFAULT:GROW(1.0)</at> |
|
29 |
<at name="colspecs">FILL:DEFAULT:NONE,FILL:DEFAULT:GROW(1.0),FILL:DEFAULT:NONE</at> |
|
30 |
<at name="components"> |
|
31 |
<object classname="java.util.LinkedList"> |
|
32 |
<item > |
|
33 |
<at name="value"> |
|
34 |
<object classname="com.jeta.forms.store.memento.BeanMemento"> |
|
35 |
<super classname="com.jeta.forms.store.memento.ComponentMemento"> |
|
36 |
<at name="cellconstraints"> |
|
37 |
<object classname="com.jeta.forms.store.memento.CellConstraintsMemento"> |
|
38 |
<at name="column">2</at> |
|
39 |
<at name="row">2</at> |
|
40 |
<at name="colspan">1</at> |
|
41 |
<at name="rowspan">1</at> |
|
42 |
<at name="halign">default</at> |
|
43 |
<at name="valign">default</at> |
|
44 |
<at name="insets" object="insets">0,0,0,0</at> |
|
45 |
</object> |
|
46 |
</at> |
|
47 |
<at name="componentclass">com.jeta.forms.gui.form.StandardComponent</at> |
|
48 |
</super> |
|
49 |
<at name="jetabeanclass">com.jeta.forms.gui.beans.JETABean</at> |
|
50 |
<at name="beanclass">javax.swing.JCheckBox</at> |
|
51 |
<at name="beanproperties"> |
|
52 |
<object classname="com.jeta.forms.store.memento.PropertiesMemento"> |
|
53 |
<at name="classname">javax.swing.JCheckBox</at> |
|
54 |
<at name="properties"> |
|
55 |
<object classname="com.jeta.forms.store.support.PropertyMap"> |
|
56 |
<at name="border"> |
|
57 |
<object classname="com.jeta.forms.store.properties.CompoundBorderProperty"> |
|
58 |
<super classname="com.jeta.forms.store.properties.BorderProperty"> |
|
59 |
<at name="name">border</at> |
|
60 |
</super> |
|
61 |
<at name="borders"> |
|
62 |
<object classname="java.util.LinkedList"> |
|
63 |
<item > |
|
64 |
<at name="value"> |
|
65 |
<object classname="com.jeta.forms.store.properties.DefaultBorderProperty"> |
|
66 |
<super classname="com.jeta.forms.store.properties.BorderProperty"> |
|
67 |
<at name="name">border</at> |
|
68 |
</super> |
|
69 |
</object> |
|
70 |
</at> |
|
71 |
</item> |
|
72 |
</object> |
|
73 |
</at> |
|
74 |
</object> |
|
75 |
</at> |
|
76 |
<at name="actionCommand">Conectar automaticamente</at> |
|
77 |
<at name="name">chkConnectAutomatically</at> |
|
78 |
<at name="width">796</at> |
|
79 |
<at name="text">_Automatically_connect_to_a_database_workspace</at> |
|
80 |
<at name="height">16</at> |
|
81 |
</object> |
|
82 |
</at> |
|
83 |
</object> |
|
84 |
</at> |
|
85 |
</object> |
|
86 |
</at> |
|
87 |
</item> |
|
88 |
<item > |
|
89 |
<at name="value"> |
|
90 |
<object classname="com.jeta.forms.store.memento.BeanMemento"> |
|
91 |
<super classname="com.jeta.forms.store.memento.ComponentMemento"> |
|
92 |
<at name="cellconstraints"> |
|
93 |
<object classname="com.jeta.forms.store.memento.CellConstraintsMemento"> |
|
94 |
<at name="column">2</at> |
|
95 |
<at name="row">6</at> |
|
96 |
<at name="colspan">1</at> |
|
97 |
<at name="rowspan">1</at> |
|
98 |
<at name="halign">default</at> |
|
99 |
<at name="valign">default</at> |
|
100 |
<at name="insets" object="insets">0,0,0,0</at> |
|
101 |
</object> |
|
102 |
</at> |
|
103 |
<at name="componentclass">com.jeta.forms.gui.form.StandardComponent</at> |
|
104 |
</super> |
|
105 |
<at name="jetabeanclass">com.jeta.forms.gui.beans.JETABean</at> |
|
106 |
<at name="beanclass">javax.swing.JComboBox</at> |
|
107 |
<at name="beanproperties"> |
|
108 |
<object classname="com.jeta.forms.store.memento.PropertiesMemento"> |
|
109 |
<at name="classname">javax.swing.JComboBox</at> |
|
110 |
<at name="properties"> |
|
111 |
<object classname="com.jeta.forms.store.support.PropertyMap"> |
|
112 |
<at name="border"> |
|
113 |
<object classname="com.jeta.forms.store.properties.CompoundBorderProperty"> |
|
114 |
<super classname="com.jeta.forms.store.properties.BorderProperty"> |
|
115 |
<at name="name">border</at> |
|
116 |
</super> |
|
117 |
<at name="borders"> |
|
118 |
<object classname="java.util.LinkedList"> |
|
119 |
<item > |
|
120 |
<at name="value"> |
|
121 |
<object classname="com.jeta.forms.store.properties.DefaultBorderProperty"> |
|
122 |
<super classname="com.jeta.forms.store.properties.BorderProperty"> |
|
123 |
<at name="name">border</at> |
|
124 |
</super> |
|
125 |
</object> |
|
126 |
</at> |
|
127 |
</item> |
|
128 |
</object> |
|
129 |
</at> |
|
130 |
</object> |
|
131 |
</at> |
|
132 |
<at name="name">cboSelectWorkspace</at> |
|
133 |
<at name="width">796</at> |
|
134 |
<at name="items"> |
|
135 |
<object classname="com.jeta.forms.store.properties.ItemsProperty"> |
|
136 |
<at name="name">items</at> |
|
137 |
</object> |
|
138 |
</at> |
|
139 |
<at name="height">20</at> |
|
140 |
</object> |
|
141 |
</at> |
|
142 |
</object> |
|
143 |
</at> |
|
144 |
</object> |
|
145 |
</at> |
|
146 |
</item> |
|
147 |
<item > |
|
148 |
<at name="value"> |
|
149 |
<object classname="com.jeta.forms.store.memento.BeanMemento"> |
|
150 |
<super classname="com.jeta.forms.store.memento.ComponentMemento"> |
|
151 |
<at name="cellconstraints"> |
|
152 |
<object classname="com.jeta.forms.store.memento.CellConstraintsMemento"> |
|
153 |
<at name="column">2</at> |
|
154 |
<at name="row">4</at> |
|
155 |
<at name="colspan">1</at> |
|
156 |
<at name="rowspan">1</at> |
|
157 |
<at name="halign">default</at> |
|
158 |
<at name="valign">default</at> |
|
159 |
<at name="insets" object="insets">0,0,0,0</at> |
|
160 |
</object> |
|
161 |
</at> |
|
162 |
<at name="componentclass">com.jeta.forms.gui.form.StandardComponent</at> |
|
163 |
</super> |
|
164 |
<at name="jetabeanclass">com.jeta.forms.gui.beans.JETABean</at> |
|
165 |
<at name="beanclass">com.jeta.forms.components.label.JETALabel</at> |
|
166 |
<at name="beanproperties"> |
|
167 |
<object classname="com.jeta.forms.store.memento.PropertiesMemento"> |
|
168 |
<at name="classname">com.jeta.forms.components.label.JETALabel</at> |
|
169 |
<at name="properties"> |
|
170 |
<object classname="com.jeta.forms.store.support.PropertyMap"> |
|
171 |
<at name="border"> |
|
172 |
<object classname="com.jeta.forms.store.properties.CompoundBorderProperty"> |
|
173 |
<super classname="com.jeta.forms.store.properties.BorderProperty"> |
|
174 |
<at name="name">border</at> |
|
175 |
</super> |
|
176 |
<at name="borders"> |
|
177 |
<object classname="java.util.LinkedList"> |
|
178 |
<item > |
|
179 |
<at name="value"> |
|
180 |
<object classname="com.jeta.forms.store.properties.DefaultBorderProperty"> |
|
181 |
<super classname="com.jeta.forms.store.properties.BorderProperty"> |
|
182 |
<at name="name">border</at> |
|
183 |
</super> |
|
184 |
</object> |
|
185 |
</at> |
|
186 |
</item> |
|
187 |
</object> |
|
188 |
</at> |
|
189 |
</object> |
|
190 |
</at> |
|
191 |
<at name="name">lblSelectWorkspace</at> |
|
192 |
<at name="width">796</at> |
|
193 |
<at name="text">_Select_the_workspace_you_want_to_connect</at> |
|
194 |
<at name="fill"> |
|
195 |
<object classname="com.jeta.forms.store.properties.effects.PaintProperty"> |
|
196 |
<at name="name">fill</at> |
|
197 |
</object> |
|
198 |
</at> |
|
199 |
<at name="height">14</at> |
|
200 |
</object> |
|
201 |
</at> |
|
202 |
</object> |
|
203 |
</at> |
|
204 |
</object> |
|
205 |
</at> |
|
206 |
</item> |
|
207 |
</object> |
|
208 |
</at> |
|
209 |
<at name="properties"> |
|
210 |
<object classname="com.jeta.forms.store.memento.PropertiesMemento"> |
|
211 |
<at name="classname">com.jeta.forms.gui.form.GridView</at> |
|
212 |
<at name="properties"> |
|
213 |
<object classname="com.jeta.forms.store.support.PropertyMap"> |
|
214 |
<at name="border"> |
|
215 |
<object classname="com.jeta.forms.store.properties.CompoundBorderProperty"> |
|
216 |
<super classname="com.jeta.forms.store.properties.BorderProperty"> |
|
217 |
<at name="name">border</at> |
|
218 |
</super> |
|
219 |
<at name="borders"> |
|
220 |
<object classname="java.util.LinkedList"/> |
|
221 |
</at> |
|
222 |
</object> |
|
223 |
</at> |
|
224 |
<at name="name"></at> |
|
225 |
<at name="fill"> |
|
226 |
<object classname="com.jeta.forms.store.properties.effects.PaintProperty"> |
|
227 |
<at name="name">fill</at> |
|
228 |
</object> |
|
229 |
</at> |
|
230 |
<at name="scollBars"> |
|
231 |
<object classname="com.jeta.forms.store.properties.ScrollBarsProperty"> |
|
232 |
<at name="name">scollBars</at> |
|
233 |
<at name="verticalpolicy">21</at> |
|
234 |
<at name="horizontalpolicy">31</at> |
|
235 |
<at name="border"> |
|
236 |
<object classname="com.jeta.forms.store.properties.CompoundBorderProperty"> |
|
237 |
<super classname="com.jeta.forms.store.properties.BorderProperty"> |
|
238 |
<at name="name">border</at> |
|
239 |
</super> |
|
240 |
<at name="borders"> |
|
241 |
<object classname="java.util.LinkedList"> |
|
242 |
<item > |
|
243 |
<at name="value"> |
|
244 |
<object classname="com.jeta.forms.store.properties.DefaultBorderProperty"> |
|
245 |
<super classname="com.jeta.forms.store.properties.BorderProperty"> |
|
246 |
<at name="name">border</at> |
|
247 |
</super> |
|
248 |
</object> |
|
249 |
</at> |
|
250 |
</item> |
|
251 |
</object> |
|
252 |
</at> |
|
253 |
</object> |
|
254 |
</at> |
|
255 |
</object> |
|
256 |
</at> |
|
257 |
</object> |
|
258 |
</at> |
|
259 |
</object> |
|
260 |
</at> |
|
261 |
<at name="cellpainters"> |
|
262 |
<object classname="com.jeta.forms.store.support.Matrix"> |
|
263 |
<at name="rows"> |
|
264 |
<object classname="[Ljava.lang.Object;" size="8"> |
|
265 |
<at name="item" index="0"> |
|
266 |
<object classname="[Ljava.lang.Object;" size="3"/> |
|
267 |
</at> |
|
268 |
<at name="item" index="1"> |
|
269 |
<object classname="[Ljava.lang.Object;" size="3"/> |
|
270 |
</at> |
|
271 |
<at name="item" index="2"> |
|
272 |
<object classname="[Ljava.lang.Object;" size="3"/> |
|
273 |
</at> |
|
274 |
<at name="item" index="3"> |
|
275 |
<object classname="[Ljava.lang.Object;" size="3"/> |
|
276 |
</at> |
|
277 |
<at name="item" index="4"> |
|
278 |
<object classname="[Ljava.lang.Object;" size="3"/> |
|
279 |
</at> |
|
280 |
<at name="item" index="5"> |
|
281 |
<object classname="[Ljava.lang.Object;" size="3"/> |
|
282 |
</at> |
|
283 |
<at name="item" index="6"> |
|
284 |
<object classname="[Ljava.lang.Object;" size="3"/> |
|
285 |
</at> |
|
286 |
<at name="item" index="7"> |
|
287 |
<object classname="[Ljava.lang.Object;" size="3"/> |
|
288 |
</at> |
|
289 |
</object> |
|
290 |
</at> |
|
291 |
</object> |
|
292 |
</at> |
|
293 |
<at name="rowgroups"> |
|
294 |
<object classname="com.jeta.forms.store.memento.FormGroupSet"> |
|
295 |
<at name="groups"> |
|
296 |
<object classname="java.util.HashMap"/> |
|
297 |
</at> |
|
298 |
</object> |
|
299 |
</at> |
|
300 |
<at name="colgroups"> |
|
301 |
<object classname="com.jeta.forms.store.memento.FormGroupSet"> |
|
302 |
<at name="groups"> |
|
303 |
<object classname="java.util.HashMap"/> |
|
304 |
</at> |
|
305 |
</object> |
|
306 |
</at> |
|
307 |
</object> |
|
308 |
</at> |
|
309 |
</object> |
trunk/org.gvsig.desktop/org.gvsig.desktop.plugin/org.gvsig.app/org.gvsig.app.mainplugin/src/main/java/org/gvsig/app/gui/preferencespage/databaseworkspace/DatabaseWorkspacePageView.java | ||
---|---|---|
1 |
package org.gvsig.app.gui.preferencespage.databaseworkspace; |
|
2 |
|
|
3 |
import com.jeta.open.i18n.I18NUtils; |
|
4 |
import com.jgoodies.forms.layout.CellConstraints; |
|
5 |
import com.jgoodies.forms.layout.FormLayout; |
|
6 |
import java.awt.BorderLayout; |
|
7 |
import java.awt.ComponentOrientation; |
|
8 |
import java.awt.Container; |
|
9 |
import java.awt.Dimension; |
|
10 |
import javax.swing.Box; |
|
11 |
import javax.swing.ImageIcon; |
|
12 |
import javax.swing.JCheckBox; |
|
13 |
import javax.swing.JComboBox; |
|
14 |
import javax.swing.JFrame; |
|
15 |
import javax.swing.JLabel; |
|
16 |
import javax.swing.JPanel; |
|
17 |
import org.gvsig.andami.preferences.AbstractPreferencePage; |
|
18 |
|
|
19 |
|
|
20 |
public abstract class DatabaseWorkspacePageView extends AbstractPreferencePage |
|
21 |
{ |
|
22 |
JCheckBox chkConnectAutomatically = new JCheckBox(); |
|
23 |
JComboBox cboSelectWorkspace = new JComboBox(); |
|
24 |
JLabel lblSelectWorkspace = new JLabel(); |
|
25 |
|
|
26 |
/** |
|
27 |
* Default constructor |
|
28 |
*/ |
|
29 |
public DatabaseWorkspacePageView() |
|
30 |
{ |
|
31 |
initializePanel(); |
|
32 |
} |
|
33 |
|
|
34 |
/** |
|
35 |
* Adds fill components to empty cells in the first row and first column of the grid. |
|
36 |
* This ensures that the grid spacing will be the same as shown in the designer. |
|
37 |
* @param cols an array of column indices in the first row where fill components should be added. |
|
38 |
* @param rows an array of row indices in the first column where fill components should be added. |
|
39 |
*/ |
|
40 |
void addFillComponents( Container panel, int[] cols, int[] rows ) |
|
41 |
{ |
|
42 |
Dimension filler = new Dimension(10,10); |
|
43 |
|
|
44 |
boolean filled_cell_11 = false; |
|
45 |
CellConstraints cc = new CellConstraints(); |
|
46 |
if ( cols.length > 0 && rows.length > 0 ) |
|
47 |
{ |
|
48 |
if ( cols[0] == 1 && rows[0] == 1 ) |
|
49 |
{ |
|
50 |
/** add a rigid area */ |
|
51 |
panel.add( Box.createRigidArea( filler ), cc.xy(1,1) ); |
|
52 |
filled_cell_11 = true; |
|
53 |
} |
|
54 |
} |
|
55 |
|
|
56 |
for( int index = 0; index < cols.length; index++ ) |
|
57 |
{ |
|
58 |
if ( cols[index] == 1 && filled_cell_11 ) |
|
59 |
{ |
|
60 |
continue; |
|
61 |
} |
|
62 |
panel.add( Box.createRigidArea( filler ), cc.xy(cols[index],1) ); |
|
63 |
} |
|
64 |
|
|
65 |
for( int index = 0; index < rows.length; index++ ) |
|
66 |
{ |
|
67 |
if ( rows[index] == 1 && filled_cell_11 ) |
|
68 |
{ |
|
69 |
continue; |
|
70 |
} |
|
71 |
panel.add( Box.createRigidArea( filler ), cc.xy(1,rows[index]) ); |
|
72 |
} |
|
73 |
|
|
74 |
} |
|
75 |
|
|
76 |
/** |
|
77 |
* Helper method to load an image file from the CLASSPATH |
|
78 |
* @param imageName the package and name of the file to load relative to the CLASSPATH |
|
79 |
* @return an ImageIcon instance with the specified image file |
|
80 |
* @throws IllegalArgumentException if the image resource cannot be loaded. |
|
81 |
*/ |
|
82 |
public ImageIcon loadImage( String imageName ) |
|
83 |
{ |
|
84 |
try |
|
85 |
{ |
|
86 |
ClassLoader classloader = getClass().getClassLoader(); |
|
87 |
java.net.URL url = classloader.getResource( imageName ); |
|
88 |
if ( url != null ) |
|
89 |
{ |
|
90 |
ImageIcon icon = new ImageIcon( url ); |
|
91 |
return icon; |
|
92 |
} |
|
93 |
} |
|
94 |
catch( Exception e ) |
|
95 |
{ |
|
96 |
e.printStackTrace(); |
|
97 |
} |
|
98 |
throw new IllegalArgumentException( "Unable to load image: " + imageName ); |
|
99 |
} |
|
100 |
|
|
101 |
/** |
|
102 |
* Method for recalculating the component orientation for |
|
103 |
* right-to-left Locales. |
|
104 |
* @param orientation the component orientation to be applied |
|
105 |
*/ |
|
106 |
public void applyComponentOrientation( ComponentOrientation orientation ) |
|
107 |
{ |
|
108 |
// Not yet implemented... |
|
109 |
// I18NUtils.applyComponentOrientation(this, orientation); |
|
110 |
super.applyComponentOrientation(orientation); |
|
111 |
} |
|
112 |
|
|
113 |
public JPanel createPanel() |
|
114 |
{ |
|
115 |
JPanel jpanel1 = new JPanel(); |
|
116 |
FormLayout formlayout1 = new FormLayout("FILL:DEFAULT:NONE,FILL:DEFAULT:GROW(1.0),FILL:DEFAULT:NONE","CENTER:DEFAULT:NONE,CENTER:DEFAULT:NONE,CENTER:DEFAULT:NONE,CENTER:DEFAULT:NONE,CENTER:2DLU:NONE,CENTER:DEFAULT:NONE,CENTER:DEFAULT:NONE,FILL:DEFAULT:GROW(1.0)"); |
|
117 |
CellConstraints cc = new CellConstraints(); |
|
118 |
jpanel1.setLayout(formlayout1); |
|
119 |
|
|
120 |
chkConnectAutomatically.setActionCommand("Conectar automaticamente"); |
|
121 |
chkConnectAutomatically.setName("chkConnectAutomatically"); |
|
122 |
chkConnectAutomatically.setText("_Automatically_connect_to_a_database_workspace"); |
|
123 |
jpanel1.add(chkConnectAutomatically,cc.xy(2,2)); |
|
124 |
|
|
125 |
cboSelectWorkspace.setName("cboSelectWorkspace"); |
|
126 |
jpanel1.add(cboSelectWorkspace,cc.xy(2,6)); |
|
127 |
|
|
128 |
lblSelectWorkspace.setName("lblSelectWorkspace"); |
|
129 |
lblSelectWorkspace.setText("_Select_the_workspace_you_want_to_connect"); |
|
130 |
jpanel1.add(lblSelectWorkspace,cc.xy(2,4)); |
|
131 |
|
|
132 |
addFillComponents(jpanel1,new int[]{ 1,2,3 },new int[]{ 1,2,3,4,5,6,7,8 }); |
|
133 |
return jpanel1; |
|
134 |
} |
|
135 |
|
|
136 |
/** |
|
137 |
* Initializer |
|
138 |
*/ |
|
139 |
protected void initializePanel() |
|
140 |
{ |
|
141 |
setLayout(new BorderLayout()); |
|
142 |
add(createPanel(), BorderLayout.CENTER); |
|
143 |
} |
|
144 |
|
|
145 |
|
|
146 |
} |
trunk/org.gvsig.desktop/org.gvsig.desktop.plugin/org.gvsig.app/org.gvsig.app.mainplugin/src/main/java/org/gvsig/app/gui/preferencespage/databaseworkspace/DatabaseWorkspacePage.java | ||
---|---|---|
1 |
package org.gvsig.app.gui.preferencespage.databaseworkspace; |
|
2 |
|
|
3 |
import javax.swing.DefaultComboBoxModel; |
|
4 |
import javax.swing.DefaultListModel; |
|
5 |
import javax.swing.ImageIcon; |
|
6 |
import javax.swing.JPanel; |
|
7 |
import org.gvsig.andami.IconThemeHelper; |
|
8 |
import org.gvsig.andami.PluginServices; |
|
9 |
import org.gvsig.andami.PluginsLocator; |
|
10 |
import org.gvsig.andami.PluginsManager; |
|
11 |
import org.gvsig.andami.preferences.IPreference; |
|
12 |
import org.gvsig.andami.preferences.StoreException; |
|
13 |
import org.gvsig.fmap.dal.DALLocator; |
|
14 |
import org.gvsig.fmap.dal.DataManager; |
|
15 |
import org.gvsig.fmap.dal.DataServerExplorerParameters; |
|
16 |
import org.gvsig.fmap.dal.DataServerExplorerPool; |
|
17 |
import org.gvsig.fmap.dal.DataServerExplorerPoolEntry; |
|
18 |
import org.gvsig.fmap.dal.DatabaseWorkspaceManager; |
|
19 |
import org.gvsig.tools.ToolsLocator; |
|
20 |
import org.gvsig.tools.dynobject.DynObject; |
|
21 |
import org.gvsig.tools.i18n.I18nManager; |
|
22 |
import org.gvsig.tools.swing.api.ToolsSwingLocator; |
|
23 |
import org.gvsig.tools.swing.api.ToolsSwingManager; |
|
24 |
|
|
25 |
|
|
26 |
@SuppressWarnings("UseSpecificCatch") |
|
27 |
public class DatabaseWorkspacePage extends DatabaseWorkspacePageView implements IPreference { |
|
28 |
|
|
29 |
// |
|
30 |
// The class DatabaseWorkspacePage can extend from AbstractPreferencePage, not JPanel, |
|
31 |
// if recreate it from the GUI builder change te class declaration to: |
|
32 |
// public abstract class DatabaseWorkspacePageView extends AbstractPreferencePage |
|
33 |
|
|
34 |
private final ImageIcon icon; |
|
35 |
public static String id = DatabaseWorkspacePage.class.getName(); |
|
36 |
|
|
37 |
public DatabaseWorkspacePage() { |
|
38 |
setParentID("org.gvsig.coreplugin.preferences.general.GeneralPage"); |
|
39 |
icon = IconThemeHelper.getImageIcon("databaseworkspace-preferences"); |
|
40 |
initComponents(); |
|
41 |
} |
|
42 |
|
|
43 |
@Override |
|
44 |
public boolean isResizeable() { |
|
45 |
return true; |
|
46 |
} |
|
47 |
|
|
48 |
private void initComponents() { |
|
49 |
this.translateAll(); |
|
50 |
} |
|
51 |
|
|
52 |
private void translateAll() { |
|
53 |
ToolsSwingManager manager = ToolsSwingLocator.getToolsSwingManager(); |
|
54 |
|
|
55 |
manager.translate(this.lblSelectWorkspace); |
|
56 |
manager.translate(this.chkConnectAutomatically); |
|
57 |
} |
|
58 |
|
|
59 |
@Override |
|
60 |
public void storeValues() throws StoreException { |
|
61 |
PluginsManager pluginManager = PluginsLocator.getPluginsManager(); |
|
62 |
PluginServices plugin = pluginManager.getPlugin(this); |
|
63 |
DynObject preferences = plugin.getPluginProperties(); |
|
64 |
|
|
65 |
preferences.setDynValue("connectAutomaticallyToDatabaseWorkspace", this.chkConnectAutomatically.isSelected()); |
|
66 |
preferences.setDynValue("databaseWorkspaceToConnect",this.cboSelectWorkspace.getSelectedItem()); |
|
67 |
} |
|
68 |
|
|
69 |
@Override |
|
70 |
public void setChangesApplied() { |
|
71 |
} |
|
72 |
|
|
73 |
@Override |
|
74 |
public String getID() { |
|
75 |
return id; |
|
76 |
} |
|
77 |
|
|
78 |
@Override |
|
79 |
public String getTitle() { |
|
80 |
I18nManager i18nManager = ToolsLocator.getI18nManager(); |
|
81 |
return i18nManager.getTranslation("_Databaseworkspace"); |
|
82 |
} |
|
83 |
|
|
84 |
@Override |
|
85 |
public JPanel getPanel() { |
|
86 |
return this; |
|
87 |
} |
|
88 |
|
|
89 |
@Override |
|
90 |
public void initializeValues() { |
|
91 |
PluginsManager pluginManager = PluginsLocator.getPluginsManager(); |
|
92 |
DataManager dataManager = DALLocator.getDataManager(); |
|
93 |
|
|
94 |
DefaultComboBoxModel<String> connectionsModel = new DefaultComboBoxModel<>(); |
|
95 |
DataServerExplorerPool connections = dataManager.getDataServerExplorerPool(); |
|
96 |
for (DataServerExplorerPoolEntry connectionEntry : connections) { |
|
97 |
DataServerExplorerParameters connection = connectionEntry.getExplorerParameters(); |
|
98 |
DatabaseWorkspaceManager workspaceManager = dataManager.createDatabaseWorkspaceManager(connection); |
|
99 |
if( workspaceManager.isValid() ) { |
|
100 |
connectionsModel.addElement(connectionEntry.getName()); |
|
101 |
} |
|
102 |
} |
|
103 |
this.cboSelectWorkspace.setModel(connectionsModel); |
|
104 |
|
|
105 |
PluginServices plugin = pluginManager.getPlugin(this); |
|
106 |
DynObject preferences = plugin.getPluginProperties(); |
|
107 |
this.cboSelectWorkspace.setSelectedIndex(-1); |
|
108 |
this.chkConnectAutomatically.setSelected((Boolean)(preferences.getDynValue("connectAutomaticallyToDatabaseWorkspace"))); |
|
109 |
this.cboSelectWorkspace.setSelectedItem(preferences.getDynValue("databaseWorkspaceToConnect")); |
|
110 |
} |
|
111 |
|
|
112 |
@Override |
|
113 |
public void initializeDefaults() { |
|
114 |
this.initializeValues(); |
|
115 |
this.chkConnectAutomatically.setSelected(false); |
|
116 |
} |
|
117 |
|
|
118 |
@Override |
|
119 |
public ImageIcon getIcon() { |
|
120 |
return this.icon; |
|
121 |
} |
|
122 |
|
|
123 |
@Override |
|
124 |
public boolean isValueChanged() { |
|
125 |
return true; |
|
126 |
} |
|
127 |
|
|
128 |
} |
trunk/org.gvsig.desktop/org.gvsig.desktop.plugin/org.gvsig.app/org.gvsig.app.mainplugin/src/main/resources-plugin/plugin-persistence.def | ||
---|---|---|
73 | 73 |
<field name="baseHelpURL" type="String" mandatory="false" defaultValue="http://downloads.gvsig.org/download/web/"> |
74 | 74 |
<description></description> |
75 | 75 |
</field> |
76 |
<field name="connectAutomaticallyToDatabaseWorkspace" type="Boolean" mandatory="false" defaultValue="false"> |
|
77 |
<description></description> |
|
78 |
</field> |
|
79 |
<field name="databaseWorkspaceToConnect" type="String" mandatory="false" defaultValue=""> |
|
80 |
<description></description> |
|
81 |
</field> |
|
82 |
|
|
76 | 83 |
</fields> |
77 | 84 |
</class> |
78 | 85 |
</classes> |
Also available in: Unified diff