Revision 45049 trunk/org.gvsig.desktop/org.gvsig.desktop.plugin/org.gvsig.h2spatial.app/org.gvsig.h2spatial.app.mainplugin/src/main/java/org/gvsig/h2spatial/H2SpatialExtension.java
H2SpatialExtension.java | ||
---|---|---|
2 | 2 |
package org.gvsig.h2spatial; |
3 | 3 |
|
4 | 4 |
import java.awt.event.ActionEvent; |
5 |
import java.awt.event.ActionListener; |
|
6 | 5 |
import java.io.File; |
7 | 6 |
import java.net.BindException; |
8 | 7 |
import java.sql.SQLException; |
9 | 8 |
import java.text.MessageFormat; |
10 | 9 |
import java.util.ArrayList; |
11 | 10 |
import java.util.List; |
12 |
import java.util.logging.Level; |
|
13 |
import java.util.logging.Logger; |
|
14 | 11 |
import javax.swing.JOptionPane; |
15 | 12 |
import javax.swing.filechooser.FileNameExtensionFilter; |
16 | 13 |
import org.apache.commons.collections.CollectionUtils; |
... | ... | |
27 | 24 |
import org.gvsig.filedialogchooser.FileDialogChooser; |
28 | 25 |
import org.gvsig.fmap.dal.DALLocator; |
29 | 26 |
import org.gvsig.fmap.dal.DataManager; |
30 |
import org.gvsig.fmap.dal.DataServerExplorer; |
|
31 | 27 |
import org.gvsig.fmap.dal.DataServerExplorerParameters; |
32 |
import org.gvsig.fmap.dal.exception.InitializeException; |
|
33 |
import org.gvsig.fmap.dal.exception.ProviderNotRegisteredException; |
|
34 | 28 |
import org.gvsig.fmap.dal.feature.FeatureStore; |
35 | 29 |
import org.gvsig.fmap.dal.serverexplorer.filesystem.FilesystemStoreParameters; |
36 | 30 |
import org.gvsig.fmap.dal.store.jdbc.JDBCServerExplorer; |
... | ... | |
165 | 159 |
@Override |
166 | 160 |
public boolean isEnabled(String action) { |
167 | 161 |
ApplicationManager application = ApplicationLocator.getManager(); |
168 |
|
|
169 |
if( "tools-h2spatial-show-admintool".equalsIgnoreCase(action) ) {
|
|
162 |
switch(action.toLowerCase()) { |
|
163 |
case "tools-h2spatial-show-admintool":
|
|
170 | 164 |
return true; |
171 |
} |
|
172 |
if( "tools-h2spatial-linklayer".equalsIgnoreCase(action) ) {
|
|
165 |
|
|
166 |
case "tools-h2spatial-linklayer":
|
|
173 | 167 |
return ! CollectionUtils.isEmpty(this.getSelectedLayers()); |
174 |
} |
|
175 |
if( "tools-h2spatial-import".equalsIgnoreCase(action) ) {
|
|
168 |
|
|
169 |
case "tools-h2spatial-import":
|
|
176 | 170 |
return true; |
177 |
} |
|
178 |
if( "tools-h2spatial-downloadosm".equalsIgnoreCase(action) ) {
|
|
171 |
|
|
172 |
case "tools-h2spatial-downloadosm":
|
|
179 | 173 |
ViewDocument viewDoc = (ViewDocument) application.getActiveDocument(ViewManager.TYPENAME); |
180 | 174 |
if( viewDoc == null ) { |
181 | 175 |
return false; |
182 | 176 |
} |
183 | 177 |
Envelope env = viewDoc.getMapContext().getViewPort().getEnvelope(); |
184 | 178 |
return !(env != null && env.isEmpty()); |
179 |
|
|
180 |
case "tools-h2spatial-shutdownserver": |
|
181 |
return true; |
|
182 |
|
|
183 |
default: |
|
184 |
return false; |
|
185 | 185 |
} |
186 |
return false; |
|
186 |
|
|
187 | 187 |
} |
188 | 188 |
|
189 | 189 |
@Override |
... | ... | |
213 | 213 |
i18n.getTranslation("_Select_files_to_import_as_tables_in_H2_database"), |
214 | 214 |
WindowManager_v2.BUTTONS_OK_CANCEL |
215 | 215 |
); |
216 |
dlg.addActionListener(new ActionListener() { |
|
217 |
@Override |
|
218 |
public void actionPerformed(ActionEvent e) { |
|
219 |
if( dlg.getAction()==WindowManager_v2.BUTTONS_OK ) { |
|
220 |
doImportTables( |
|
216 |
dlg.addActionListener((ActionEvent e) -> { |
|
217 |
if( dlg.getAction()==WindowManager_v2.BUTTONS_OK ) { |
|
218 |
doImportTables( |
|
221 | 219 |
panel.getExplorerParameters(), |
222 | 220 |
panel.getFileType(), |
223 | 221 |
panel.getFile(), |
224 | 222 |
panel.getTableName(), |
225 | 223 |
panel.getDeleteTables() |
226 |
); |
|
227 |
} |
|
224 |
); |
|
228 | 225 |
} |
229 | 226 |
}); |
230 | 227 |
dlg.show(WindowManager.MODE.WINDOW); |
... | ... | |
288 | 285 |
return; |
289 | 286 |
} |
290 | 287 |
final JDBCConnectionPanel jdbcConnectionPanel = DALSwingLocator.getSwingManager().createJDBCConnectionPanel(); |
291 |
jdbcConnectionPanel.setConnectorFilter(new JDBCConnectionPanel.ConnectorFilter() { |
|
292 |
@Override |
|
293 |
public boolean accept(JDBCServerExplorerParameters parameters) { |
|
294 |
return StringUtils.equalsIgnoreCase(parameters.getExplorerName(), DAL_EXPLORER_NAME); |
|
295 |
} |
|
296 |
}); |
|
288 |
jdbcConnectionPanel.setConnectorFilter((JDBCServerExplorerParameters parameters) -> StringUtils.equalsIgnoreCase(parameters.getExplorerName(), DAL_EXPLORER_NAME)); |
|
297 | 289 |
WindowManager_v2 winmanager = (WindowManager_v2) ToolsSwingLocator.getWindowManager(); |
298 | 290 |
final Dialog dlg = winmanager.createDialog( |
299 | 291 |
jdbcConnectionPanel.asJComponent(), |
... | ... | |
301 | 293 |
null, |
302 | 294 |
WindowManager_v2.BUTTONS_OK_CANCEL |
303 | 295 |
); |
304 |
dlg.addActionListener(new ActionListener() { |
|
305 |
@Override |
|
306 |
public void actionPerformed(ActionEvent e) { |
|
307 |
if( dlg.getAction()==WindowManager_v2.BUTTONS_OK ) { |
|
308 |
JDBCServerExplorerParameters params = jdbcConnectionPanel.getServerExplorerParameters(); |
|
309 |
linkLayers(layers, params); |
|
310 |
} |
|
296 |
dlg.addActionListener((ActionEvent e) -> { |
|
297 |
if( dlg.getAction()==WindowManager_v2.BUTTONS_OK ) { |
|
298 |
JDBCServerExplorerParameters params = jdbcConnectionPanel.getServerExplorerParameters(); |
|
299 |
linkLayers(layers, params); |
|
311 | 300 |
} |
312 | 301 |
}); |
313 | 302 |
dlg.show(WindowManager.MODE.WINDOW); |
... | ... | |
360 | 349 |
|
361 | 350 |
if( !ArrayUtils.isEmpty(files) ) { |
362 | 351 |
final JDBCConnectionPanel jdbcConnectionPanel = DALSwingLocator.getSwingManager().createJDBCConnectionPanel(); |
363 |
jdbcConnectionPanel.setConnectorFilter(new JDBCConnectionPanel.ConnectorFilter() { |
|
364 |
@Override |
|
365 |
public boolean accept(JDBCServerExplorerParameters parameters) { |
|
366 |
return StringUtils.equalsIgnoreCase(parameters.getExplorerName(), DAL_EXPLORER_NAME); |
|
367 |
} |
|
368 |
}); |
|
352 |
jdbcConnectionPanel.setConnectorFilter((JDBCServerExplorerParameters parameters) -> |
|
353 |
StringUtils.equalsIgnoreCase(parameters.getExplorerName(), DAL_EXPLORER_NAME) |
|
354 |
); |
|
369 | 355 |
WindowManager_v2 winmanager = (WindowManager_v2) ToolsSwingLocator.getWindowManager(); |
370 | 356 |
final Dialog dlg = winmanager.createDialog( |
371 | 357 |
jdbcConnectionPanel.asJComponent(), |
... | ... | |
373 | 359 |
null, |
374 | 360 |
WindowManager_v2.BUTTONS_OK_CANCEL |
375 | 361 |
); |
376 |
dlg.addActionListener(new ActionListener() { |
|
377 |
@Override |
|
378 |
public void actionPerformed(ActionEvent e) { |
|
379 |
if( dlg.getAction()==WindowManager_v2.BUTTONS_OK ) { |
|
380 |
doDownloadOSM( |
|
381 |
env, |
|
362 |
dlg.addActionListener((ActionEvent e) -> { |
|
363 |
if( dlg.getAction()==WindowManager_v2.BUTTONS_OK ) { |
|
364 |
doDownloadOSM( |
|
365 |
env, |
|
382 | 366 |
files[0], |
383 | 367 |
jdbcConnectionPanel.getServerExplorerParameters() |
384 |
); |
|
385 |
} |
|
368 |
); |
|
386 | 369 |
} |
387 | 370 |
}); |
388 | 371 |
dlg.show(WindowManager.MODE.WINDOW); |
Also available in: Unified diff