Revision 47592 trunk/org.gvsig.desktop/org.gvsig.desktop.plugin/org.gvsig.app/org.gvsig.app.mainplugin/src/main/java/org/gvsig/app/extension/geometriespalette/GeometriesPaletteExtension.java
GeometriesPaletteExtension.java | ||
---|---|---|
101 | 101 |
WindowManager.MODE.DIALOG |
102 | 102 |
); |
103 | 103 |
|
104 |
if (addLayerDialog.isAccepted()) { |
|
105 |
if (addLayerDialog.getSelectedTab() instanceof WizardPanel) { |
|
106 |
WizardPanel panel = (WizardPanel) addLayerDialog.getSelectedTab(); |
|
107 |
panel.executeWizard(); |
|
108 |
// Algunas capas se cargan en segundo plano, asi que si tratamos de |
|
109 |
// acceder a ellas ya mismo puede que aun no esten cargadas. |
|
110 |
// No es muy ortodox pero nos esperaremos un poco. |
|
111 |
for (int i = 0; i < 30; i++) { |
|
112 |
try { Thread.sleep(1000); } catch (Exception ex) { } |
|
113 |
if (!mapContext.getLayers().isEmpty()) { |
|
114 |
FLyrVect layer = (FLyrVect) mapContext.getLayers().getFirstActiveVectorLayer(); |
|
115 |
FeatureStore store = layer.getFeatureStore(); |
|
116 |
DisposeUtils.bind(store); |
|
117 |
SwingUtilities.invokeLater(() -> { |
|
118 |
GeometriesPalettePanel.showPalette(store, null, layer.getName(), null); |
|
119 |
}); |
|
120 |
return; |
|
121 |
} |
|
122 |
} |
|
123 |
// TODO: Avisar que no se ha cargado ninguna capa ? |
|
124 |
} |
|
104 |
if (!addLayerDialog.isAccepted()) { |
|
105 |
DisposeUtils.disposeQuietly(mapContext); |
|
106 |
return; |
|
125 | 107 |
} |
108 |
|
|
109 |
if (! (addLayerDialog.getSelectedTab() instanceof WizardPanel) ) { |
|
110 |
DisposeUtils.disposeQuietly(mapContext); |
|
111 |
return; |
|
112 |
} |
|
113 |
|
|
114 |
WizardPanel panel = (WizardPanel) addLayerDialog.getSelectedTab(); |
|
115 |
panel.executeWizard(); |
|
116 |
|
|
126 | 117 |
} catch (Exception ex) { |
127 | 118 |
logger.warn("Can't open palete from layer",ex); |
119 |
DisposeUtils.disposeQuietly(mapContext); |
|
120 |
return; |
|
128 | 121 |
} finally { |
129 | 122 |
DisposeUtils.disposeQuietly(addLayerDialog); |
130 | 123 |
DisposeUtils.disposeQuietly(mapControl); |
131 |
DisposeUtils.disposeQuietly(mapContext); |
|
132 | 124 |
} |
133 |
|
|
125 |
|
|
126 |
// Algunas capas se cargan en segundo plano, asi que si tratamos de |
|
127 |
// acceder a ellas ya mismo puede que aun no esten cargadas. |
|
128 |
// No es muy ortodox pero nos esperaremos un poco. |
|
129 |
// Ademas algunos proveedores pueden acabar cargandolas con un |
|
130 |
// invoke later, con lo que para poder acceder a ellas, nos esperamos |
|
131 |
// en un thread a parte. |
|
132 |
Thread task = new Thread( |
|
133 |
new Runnable() { |
|
134 |
@Override |
|
135 |
public void run() { |
|
136 |
try { |
|
137 |
for (int i = 0; i < 30; i++) { |
|
138 |
try { Thread.sleep(1000); } catch (Exception ex) { } |
|
139 |
if (!mapContext.getLayers().isEmpty()) { |
|
140 |
FLyrVect layer = (FLyrVect) mapContext.getLayers().getFirstActiveVectorLayer(); |
|
141 |
FeatureStore store = layer.getFeatureStore(); |
|
142 |
DisposeUtils.bind(store); |
|
143 |
SwingUtilities.invokeLater(() -> { |
|
144 |
GeometriesPalettePanel.showPalette(store, null, layer.getName(), null); |
|
145 |
}); |
|
146 |
return; |
|
147 |
} |
|
148 |
} |
|
149 |
// TODO: Avisar que no se ha cargado ninguna capa ? |
|
150 |
} finally { |
|
151 |
DisposeUtils.disposeQuietly(mapContext); |
|
152 |
} |
|
153 |
} |
|
154 |
}, |
|
155 |
"GeometriesPaletteLayerLoader" |
|
156 |
); |
|
157 |
task.start(); |
|
134 | 158 |
} |
135 | 159 |
|
136 | 160 |
private void doOpenGeometriesPalette(String tableName, String labelattr, String title, String filter) { |
Also available in: Unified diff