Revision 42146
trunk/org.gvsig.desktop/org.gvsig.desktop.library/org.gvsig.fmap.control/src/main/java/org/gvsig/fmap/mapcontrol/impl/DefaultMapControlManager.java | ||
---|---|---|
32 | 32 |
import java.util.ArrayList; |
33 | 33 |
import java.util.HashSet; |
34 | 34 |
import java.util.Iterator; |
35 |
import java.util.LinkedHashSet; |
|
35 | 36 |
import java.util.List; |
36 | 37 |
import java.util.Map; |
37 | 38 |
import java.util.Set; |
... | ... | |
70 | 71 |
|
71 | 72 |
private ExtensionPointManager extensionPoints = ToolsLocator.getExtensionPointManager(); |
72 | 73 |
private int snappingTolerance = 4; |
73 |
private ISymbol selectionSymbol = null;
|
|
74 |
private ISymbol selectionSymbol = null; |
|
74 | 75 |
private ISymbol axisReferencesSymbol = null; |
75 | 76 |
private ISymbol geometrySelectionSymbol = null; |
76 | 77 |
private ISymbol handlerSymbol = null; |
... | ... | |
79 | 80 |
private Preferences prefs = Preferences.userRoot().node( "cadtooladapter" ); |
80 | 81 |
private static Preferences prefSnappers = Preferences.userRoot().node("snappers"); |
81 | 82 |
private List<ISnapper> snappers = null; |
82 |
private Set<MapControlCreationListener> mapControlCreationListeners = new HashSet<MapControlCreationListener>(); |
|
83 |
|
|
83 |
private Set<MapControlCreationListener> mapControlCreationListeners = new LinkedHashSet<MapControlCreationListener>(); |
|
84 | 84 |
|
85 |
|
|
85 | 86 |
public DefaultMapControlManager() { |
86 | 87 |
super(); |
87 | 88 |
snappers = new ArrayList<ISnapper>(); |
... | ... | |
93 | 94 |
public MapControlDrawer createDefaultMapControlDrawer() throws MapControlCreationException { |
94 | 95 |
ExtensionPoint ep = extensionPoints.add(MAPCONTROL_MANAGER_EXTENSION_POINT); |
95 | 96 |
try { |
96 |
return (MapControlDrawer)ep.create(DEFAULT_MAPCONTROLMANAGER_NAME);
|
|
97 |
return (MapControlDrawer)ep.create(DEFAULT_MAPCONTROLMANAGER_NAME); |
|
97 | 98 |
} catch (Exception e) { |
98 | 99 |
throw new MapControlCreationException(e); |
99 |
}
|
|
100 |
} |
|
100 | 101 |
} |
101 | 102 |
|
102 | 103 |
/* |
... | ... | |
106 | 107 |
public MapControlDrawer createMapControlDrawer(String name) throws MapControlCreationException { |
107 | 108 |
ExtensionPoint ep = extensionPoints.add(MAPCONTROL_MANAGER_EXTENSION_POINT); |
108 | 109 |
try { |
109 |
return (MapControlDrawer)ep.create(name);
|
|
110 |
return (MapControlDrawer)ep.create(name); |
|
110 | 111 |
} catch (Exception e) { |
111 | 112 |
throw new MapControlCreationException(e); |
112 | 113 |
} |
... | ... | |
122 | 123 |
} |
123 | 124 |
|
124 | 125 |
ExtensionPoint extensionPoint = extensionPoints.add(MAPCONTROL_MANAGER_EXTENSION_POINT, ""); |
125 |
extensionPoint.append(DEFAULT_MAPCONTROLMANAGER_NAME, "Default MapControl", mapControlDrawerClass);
|
|
126 |
extensionPoint.append(DEFAULT_MAPCONTROLMANAGER_NAME, "Default MapControl", mapControlDrawerClass); |
|
126 | 127 |
} |
127 | 128 |
|
128 | 129 |
/* (non-Javadoc) |
... | ... | |
137 | 138 |
} |
138 | 139 |
|
139 | 140 |
ExtensionPoint extensionPoint = extensionPoints.add(MAPCONTROL_MANAGER_EXTENSION_POINT, ""); |
140 |
extensionPoint.append(name, "Default MapControl", mapControlDrawerClass);
|
|
141 |
extensionPoint.append(name, "Default MapControl", mapControlDrawerClass); |
|
141 | 142 |
} |
142 | 143 |
|
143 | 144 |
/* (non-Javadoc) |
... | ... | |
151 | 152 |
* @see org.gvsig.fmap.mapcontrol.MapControlManager#setSnappingTolerance(int) |
152 | 153 |
*/ |
153 | 154 |
public void setTolerance(int tolerance) { |
154 |
snappingTolerance = tolerance;
|
|
155 |
snappingTolerance = tolerance; |
|
155 | 156 |
} |
156 | 157 |
|
157 | 158 |
/* (non-Javadoc) |
158 | 159 |
* @see org.gvsig.fmap.mapcontrol.MapControlManager#clearSnappers() |
159 | 160 |
*/ |
160 | 161 |
public void clearSnappers() { |
161 |
snappers.clear();
|
|
162 |
snappers.clear(); |
|
162 | 163 |
} |
163 | 164 |
|
164 | 165 |
/* (non-Javadoc) |
... | ... | |
182 | 183 |
geometrySelectionSymbol = |
183 | 184 |
mapContextManager.getSymbolManager() |
184 | 185 |
.createSymbol(Geometry.TYPES.GEOMETRY, Color.RED); |
185 |
}
|
|
186 |
} |
|
186 | 187 |
return geometrySelectionSymbol; |
187 | 188 |
} |
188 | 189 |
|
... | ... | |
205 | 206 |
if (selectionSymbol == null){ |
206 | 207 |
selectionSymbol = |
207 | 208 |
mapContextManager.getSymbolManager().createSymbol( |
208 |
Geometry.TYPES.GEOMETRY, new Color(255, 0, 0, 100));
|
|
209 |
Geometry.TYPES.GEOMETRY, new Color(255, 0, 0, 100)); |
|
209 | 210 |
} |
210 | 211 |
return selectionSymbol; |
211 | 212 |
} |
... | ... | |
215 | 216 |
* @see org.gvsig.fmap.mapcontrol.MapControlManager#setAxisReferenceSymbol(org.gvsig.fmap.mapcontext.rendering.symbols.ISymbol) |
216 | 217 |
*/ |
217 | 218 |
public void setAxisReferenceSymbol(ISymbol axisReferencesSymbol) { |
218 |
this.axisReferencesSymbol = axisReferencesSymbol;
|
|
219 |
this.axisReferencesSymbol = axisReferencesSymbol; |
|
219 | 220 |
} |
220 | 221 |
|
221 | 222 |
/* |
... | ... | |
223 | 224 |
* @see org.gvsig.fmap.mapcontrol.MapControlManager#setGeometrySelectionSymbol(org.gvsig.fmap.mapcontext.rendering.symbols.ISymbol) |
224 | 225 |
*/ |
225 | 226 |
public void setGeometrySelectionSymbol(ISymbol geometrySelectionSymbol) { |
226 |
this.geometrySelectionSymbol = geometrySelectionSymbol;
|
|
227 |
this.geometrySelectionSymbol = geometrySelectionSymbol; |
|
227 | 228 |
} |
228 | 229 |
|
229 | 230 |
/* |
... | ... | |
231 | 232 |
* @see org.gvsig.fmap.mapcontrol.MapControlManager#setHandlerSymbol(org.gvsig.fmap.mapcontext.rendering.symbols.ISymbol) |
232 | 233 |
*/ |
233 | 234 |
public void setHandlerSymbol(ISymbol handlerSymbol) { |
234 |
this.handlerSymbol = handlerSymbol;
|
|
235 |
this.handlerSymbol = handlerSymbol; |
|
235 | 236 |
} |
236 | 237 |
|
237 | 238 |
/* |
... | ... | |
239 | 240 |
* @see org.gvsig.fmap.mapcontrol.MapControlManager#setSelectionSymbol(org.gvsig.fmap.mapcontext.rendering.symbols.ISymbol) |
240 | 241 |
*/ |
241 | 242 |
public void setSelectionSymbol(ISymbol selectionSymbol) { |
242 |
this.selectionSymbol = selectionSymbol;
|
|
243 |
this.selectionSymbol = selectionSymbol; |
|
243 | 244 |
} |
244 | 245 |
|
245 | 246 |
/* (non-Javadoc) |
... | ... | |
249 | 250 |
if (!ISnapper.class.isAssignableFrom(snapperClass)) { |
250 | 251 |
throw new IllegalArgumentException(snapperClass.getName() |
251 | 252 |
+ " must implement the ISnapper interface"); |
252 |
}
|
|
253 |
} |
|
253 | 254 |
|
254 | 255 |
ExtensionPoint extensionPoint = extensionPoints.add(SNAPPING_EXTENSION_POINT, ""); |
255 | 256 |
Extension extension = extensionPoint.append(name, "", snapperClass); |
... | ... | |
264 | 265 |
int priority = prefs.getInt("snapper_priority" + nameClass,3); |
265 | 266 |
snapper.setPriority(priority); |
266 | 267 |
if (select){ |
267 |
snapper.setEnabled(select);
|
|
268 |
}
|
|
269 |
|
|
268 |
snapper.setEnabled(select); |
|
269 |
} |
|
270 |
|
|
270 | 271 |
} catch (Exception e) { |
271 | 272 |
logger.error("It is not possible to create the snapper"); |
272 |
}
|
|
273 |
} |
|
273 | 274 |
} |
274 | 275 |
|
275 | 276 |
/* (non-Javadoc) |
... | ... | |
290 | 291 |
* @see org.gvsig.fmap.mapcontrol.MapControlManager#disableSnapping() |
291 | 292 |
*/ |
292 | 293 |
public void disableSnapping() { |
293 |
snappers.clear();
|
|
294 |
snappers.clear(); |
|
294 | 295 |
} |
295 | 296 |
|
296 | 297 |
/* (non-Javadoc) |
... | ... | |
317 | 318 |
nameClass = nameClass.substring(nameClass.lastIndexOf('.')); |
318 | 319 |
boolean select = prefs.getBoolean("snapper_activated" + nameClass, false); |
319 | 320 |
if (select) { |
320 |
snp.setEnabled(select);
|
|
321 |
snp.setEnabled(select); |
|
321 | 322 |
} |
322 | 323 |
int priority = prefs.getInt("snapper_priority" + nameClass, 3); |
323 | 324 |
snp.setPriority(priority); |
... | ... | |
346 | 347 |
public void addMapControlCreationListener(MapControlCreationListener listener) { |
347 | 348 |
this.mapControlCreationListeners.add(listener); |
348 | 349 |
} |
349 |
|
|
350 |
|
|
350 | 351 |
public LayersDynObjectSetComponent createLayersDynObjectSetComponent( |
351 | 352 |
Map<String, DynObjectSet> layerName2InfoByPoint) { |
352 | 353 |
return createLayersDynObjectSetComponent(layerName2InfoByPoint, false); |
trunk/org.gvsig.desktop/org.gvsig.desktop.plugin/org.gvsig.app.document.table.app/org.gvsig.app.document.table.app.mainplugin/src/main/java/org/gvsig/app/extension/TableEditStartExtension.java | ||
---|---|---|
42 | 42 |
|
43 | 43 |
/** |
44 | 44 |
* DOCUMENT ME! |
45 |
*
|
|
45 |
* |
|
46 | 46 |
* @author Vicente Caballero Navarro |
47 | 47 |
*/ |
48 | 48 |
public class TableEditStartExtension extends AbstractTableEditExtension { |
49 | 49 |
private static final Logger logger = LoggerFactory.getLogger(TableEditStartExtension.class); |
50 |
|
|
50 |
|
|
51 | 51 |
public void initialize() { |
52 | 52 |
super.initialize(); |
53 | 53 |
IconThemeHelper.registerIcon("action", "table-start-editing", this); |
... | ... | |
61 | 61 |
TableDocument doc = (TableDocument) table.getDocument(); |
62 | 62 |
EditingNotificationManager editingNotification = MapControlLocator.getEditingNotificationManager(); |
63 | 63 |
EditingNotification notification = editingNotification.notifyObservers( |
64 |
this,
|
|
65 |
EditingNotification.BEFORE_ENTER_EDITING_STORE,
|
|
64 |
this, |
|
65 |
EditingNotification.BEFORE_ENTER_EDITING_STORE, |
|
66 | 66 |
doc, |
67 | 67 |
doc.getStore()); |
68 | 68 |
if( notification.isCanceled() ) { |
... | ... | |
71 | 71 |
doc.getStore().edit(FeatureStore.MODE_FULLEDIT); |
72 | 72 |
ApplicationLocator.getManager().refreshMenusAndToolBars(); |
73 | 73 |
editingNotification.notifyObservers( |
74 |
this,
|
|
75 |
EditingNotification.AFTER_ENTER_EDITING_STORE,
|
|
74 |
this, |
|
75 |
EditingNotification.AFTER_ENTER_EDITING_STORE, |
|
76 | 76 |
doc, |
77 | 77 |
doc.getStore()); |
78 | 78 |
} catch (DataException e) { |
... | ... | |
93 | 93 |
if (v instanceof FeatureTableDocumentPanel) { |
94 | 94 |
FeatureTableDocumentPanel t = (FeatureTableDocumentPanel) v; |
95 | 95 |
FeatureStore fs = t.getModel().getStore(); |
96 |
// FJP: |
|
97 |
// Si est? linkada, por ahora no dejamos editar |
|
98 |
// TODO: Esto evita la edici?n en un sentido, pero no en el otro |
|
99 |
// Hay que permitir la edici?n, pero evitar que toquen el/los |
|
100 |
// campos de uni?n. Para eso tendremos que a?adir alguna funci?n |
|
101 |
// que indique si un campo est? involucrado en alguna uni?n, o |
|
102 |
// quiz?s algo m?s gen?rico, algo que permita bloquear campos |
|
103 |
// para que no se puedan editar. |
|
104 |
List<TableLink> links = t.getModel().getLinks(); |
|
105 |
if (links != null && links.size() > 0) { |
|
106 |
return false; |
|
107 |
} |
|
108 | 96 |
return fs.allowWrite(); |
109 | 97 |
} |
110 | 98 |
return false; |
... | ... | |
121 | 109 |
} |
122 | 110 |
|
123 | 111 |
if (v instanceof FeatureTableDocumentPanel |
124 |
&& !((FeatureTableDocumentPanel) v).getModel().getStore() |
|
125 |
.isEditing() |
|
126 |
&& ((FeatureTableDocumentPanel) v).getModel().getAssociatedLayer() == null) { |
|
112 |
&& !((FeatureTableDocumentPanel) v).getModel().getStore().isEditing()) { |
|
127 | 113 |
table = (FeatureTableDocumentPanel) v; |
128 | 114 |
return true; |
129 | 115 |
} |
trunk/org.gvsig.desktop/org.gvsig.desktop.plugin/org.gvsig.app.document.table.app/org.gvsig.app.document.table.app.mainplugin/src/main/java/org/gvsig/app/extension/TableEditStopExtension.java | ||
---|---|---|
65 | 65 |
import org.gvsig.utils.swing.threads.IMonitorableTask; |
66 | 66 |
|
67 | 67 |
public class TableEditStopExtension extends AbstractTableEditExtension { |
68 |
|
|
68 |
|
|
69 | 69 |
private static Logger logger = |
70 | 70 |
LoggerFactory.getLogger(TableEditStopExtension.class); |
71 | 71 |
|
... | ... | |
73 | 73 |
super.initialize(); |
74 | 74 |
IconThemeHelper.registerIcon("action", "table-stop-editing", this); |
75 | 75 |
} |
76 |
|
|
76 |
|
|
77 | 77 |
public void execute(String actionCommand) { |
78 | 78 |
if ("table-stop-editing".equals(actionCommand)) { |
79 | 79 |
TableDocument doc = (TableDocument) table.getDocument(); |
80 | 80 |
EditingNotificationManager editingNotification = MapControlLocator.getEditingNotificationManager(); |
81 | 81 |
EditingNotification notification = editingNotification.notifyObservers( |
82 |
this,
|
|
83 |
EditingNotification.BEFORE_ENTER_EDITING_STORE,
|
|
82 |
this, |
|
83 |
EditingNotification.BEFORE_ENTER_EDITING_STORE, |
|
84 | 84 |
doc, |
85 | 85 |
doc.getStore()); |
86 | 86 |
if( notification.isCanceled() ) { |
... | ... | |
89 | 89 |
stopEditing(table); |
90 | 90 |
ApplicationLocator.getManager().refreshMenusAndToolBars(); |
91 | 91 |
editingNotification.notifyObservers( |
92 |
this,
|
|
93 |
EditingNotification.AFTER_ENTER_EDITING_STORE,
|
|
92 |
this, |
|
93 |
EditingNotification.AFTER_ENTER_EDITING_STORE, |
|
94 | 94 |
doc, |
95 | 95 |
doc.getStore()); |
96 | 96 |
} |
... | ... | |
102 | 102 |
PluginServices.getText(this, "_Guardar"), |
103 | 103 |
" " + PluginServices.getText(this, "_Descartar") + " ", |
104 | 104 |
PluginServices.getText(this, "_Continuar") }; |
105 |
|
|
105 |
|
|
106 | 106 |
JPanel explanation_panel = getExplanationPanel(table.getModel().getName()); |
107 |
|
|
107 |
|
|
108 | 108 |
int resp = JOptionPane |
109 | 109 |
.showOptionDialog( |
110 | 110 |
(Component) PluginServices.getMainFrame(), |
... | ... | |
119 | 119 |
// CANCEL EDITING |
120 | 120 |
table.getModel().getStore().cancelEditing(); |
121 | 121 |
} else { |
122 |
|
|
122 |
|
|
123 | 123 |
if (resp == JOptionPane.YES_OPTION) { |
124 | 124 |
// Save table |
125 | 125 |
table.getModel().getStore().finishEditing(); |
... | ... | |
153 | 153 |
} else |
154 | 154 |
if (v instanceof FeatureTableDocumentPanel |
155 | 155 |
&& ((FeatureTableDocumentPanel) v).getModel().getStore() |
156 |
.isEditing() |
|
157 |
&& ((FeatureTableDocumentPanel) v).getModel() |
|
158 |
.getAssociatedLayer() == null) { |
|
156 |
.isEditing()) { |
|
159 | 157 |
table = (FeatureTableDocumentPanel) v; |
160 | 158 |
return true; |
161 | 159 |
} else { |
... | ... | |
168 | 166 |
* This class provides the status of extensions. If this extension has some |
169 | 167 |
* unsaved editing table (and save them), and methods to check if the |
170 | 168 |
* extension has some associated background tasks. |
171 |
*
|
|
169 |
* |
|
172 | 170 |
* @author Vicente Caballero Navarro |
173 |
*
|
|
171 |
* |
|
174 | 172 |
*/ |
175 | 173 |
private class StopEditingStatus implements IExtensionStatus { |
176 | 174 |
|
177 | 175 |
/** |
178 | 176 |
* This method is used to check if this extension has some unsaved |
179 | 177 |
* editing tables. |
180 |
*
|
|
178 |
* |
|
181 | 179 |
* @return true if the extension has some unsaved editing tables, false |
182 | 180 |
* otherwise. |
183 | 181 |
*/ |
... | ... | |
199 | 197 |
/** |
200 | 198 |
* This method is used to check if the extension has some associated |
201 | 199 |
* background process which is currently running. |
202 |
*
|
|
200 |
* |
|
203 | 201 |
* @return true if the extension has some associated background process, |
204 | 202 |
* false otherwise. |
205 | 203 |
*/ |
... | ... | |
212 | 210 |
* Gets an array of the traceable background tasks associated with this |
213 | 211 |
* extension. These tasks may be tracked, canceled, etc. |
214 | 212 |
* </p> |
215 |
*
|
|
213 |
* |
|
216 | 214 |
* @return An array of the associated background tasks, or null in case |
217 | 215 |
* there is |
218 | 216 |
* no associated background tasks. |
... | ... | |
226 | 224 |
* Gets an array of the UnsavedData objects, which contain information |
227 | 225 |
* about the unsaved editing tables and allows to save it. |
228 | 226 |
* </p> |
229 |
*
|
|
227 |
* |
|
230 | 228 |
* @return An array of the associated unsaved editing layers, or null in |
231 | 229 |
* case the extension |
232 | 230 |
* has not unsaved editing tables. |
... | ... | |
276 | 274 |
public void setTable(TableDocument table) { |
277 | 275 |
this.table = table; |
278 | 276 |
} |
279 |
|
|
277 |
|
|
280 | 278 |
public String getIcon() { |
281 | 279 |
return "document-table-icon-small"; |
282 | 280 |
} |
... | ... | |
329 | 327 |
public IExtensionStatus getStatus() { |
330 | 328 |
return new StopEditingStatus(); |
331 | 329 |
} |
332 |
|
|
333 |
|
|
330 |
|
|
331 |
|
|
334 | 332 |
private JPanel getExplanationPanel(String name) { |
335 |
|
|
333 |
|
|
336 | 334 |
BorderLayout bl = new BorderLayout(10, 10); |
337 | 335 |
JPanel resp = new JPanel(bl); |
338 |
|
|
336 |
|
|
339 | 337 |
String msg = Messages.getText("realmente_desea_guardar"); |
340 | 338 |
JLabel topLabel = new JLabel(msg); |
341 |
|
|
339 |
|
|
342 | 340 |
JPanel mainPanel = new JPanel(new GridBagLayout()); |
343 | 341 |
GridBagConstraints cc = new GridBagConstraints(); |
344 |
|
|
342 |
|
|
345 | 343 |
cc.gridx = 0; |
346 | 344 |
cc.gridy = 0; |
347 | 345 |
cc.anchor = GridBagConstraints.WEST; |
348 |
|
|
346 |
|
|
349 | 347 |
cc.insets = new Insets(3, 6, 3, 6); |
350 |
|
|
348 |
|
|
351 | 349 |
Font boldf = mainPanel.getFont().deriveFont(Font.BOLD); |
352 |
|
|
350 |
|
|
353 | 351 |
JLabel lbl = new JLabel(Messages.getText("_Guardar")); |
354 | 352 |
lbl.setFont(boldf); |
355 | 353 |
mainPanel.add(lbl, cc); |
356 | 354 |
cc.gridx = 1; |
357 | 355 |
mainPanel.add(new JLabel(Messages.getText("_Save_changes_performed")), cc); |
358 |
|
|
356 |
|
|
359 | 357 |
cc.gridx = 0; |
360 | 358 |
cc.gridy = 1; |
361 | 359 |
lbl = new JLabel(Messages.getText("_Descartar")); |
Also available in: Unified diff