Revision 48 org.gvsig.vectorediting/trunk/org.gvsig.vectorediting/org.gvsig.vectorediting.swing/org.gvsig.vectorediting.swing.impl/src/main/java/org/gvsig/vectorediting/swing/impl/DefaultEditingSwingManager.java
DefaultEditingSwingManager.java | ||
---|---|---|
6 | 6 |
*/ |
7 | 7 |
package org.gvsig.vectorediting.swing.impl; |
8 | 8 |
|
9 |
import org.gvsig.app.ApplicationLocator; |
|
10 |
import org.gvsig.app.project.documents.view.gui.DefaultViewPanel; |
|
11 | 9 |
import org.gvsig.editing.EditingNotification; |
12 | 10 |
import org.gvsig.editing.EditingNotificationManager; |
13 | 11 |
import org.gvsig.fmap.dal.exception.DataException; |
... | ... | |
19 | 17 |
import org.gvsig.tools.service.AbstractManager; |
20 | 18 |
import org.gvsig.tools.service.Service; |
21 | 19 |
import org.gvsig.tools.service.ServiceException; |
22 |
import org.gvsig.tools.service.spi.ProviderManager; |
|
23 |
import org.gvsig.utils.console.jedit.JEditTextArea; |
|
24 | 20 |
import org.gvsig.vectorediting.lib.api.EditingManager; |
25 | 21 |
import org.gvsig.vectorediting.lib.impl.DefaultEditingProviderManager; |
26 | 22 |
import org.gvsig.vectorediting.swing.api.EditingBehavior; |
... | ... | |
53 | 49 |
} |
54 | 50 |
} |
55 | 51 |
|
56 |
public void beginEdition(FLyrVect layer, DefaultViewPanel view)
|
|
52 |
public void beginEdition(FLyrVect layer, MapControl mapControl)
|
|
57 | 53 |
throws DataException { |
58 | 54 |
|
59 | 55 |
EditingNotificationManager editingNotificationManager = MapControlLocator |
... | ... | |
61 | 57 |
|
62 | 58 |
EditingNotification notification = editingNotificationManager |
63 | 59 |
.notifyObservers(this, EditingNotification.BEFORE_ENTER_EDITING_STORE, |
64 |
view.getDocument(), layer);
|
|
60 |
null, layer);
|
|
65 | 61 |
|
66 | 62 |
if (notification.isCanceled()) { |
67 | 63 |
logger.info("Edit layer '" + layer.getName() |
... | ... | |
70 | 66 |
+ "' canceled."); |
71 | 67 |
} |
72 | 68 |
|
73 |
initFocus(view); |
|
74 |
view.showConsole(); |
|
75 |
setCaretPosition(view); |
|
76 |
|
|
69 |
initFocus(mapControl); |
|
70 |
|
|
77 | 71 |
layer.getFeatureStore().edit(); |
78 |
layer.getFeatureStore().addObserver(view); |
|
79 |
layer.getFeatureStore().addObserver(view.getMapControl());
|
|
72 |
// layer.getFeatureStore().addObserver(view);
|
|
73 |
layer.getFeatureStore().addObserver(mapControl);
|
|
80 | 74 |
|
81 |
ApplicationLocator.getManager().refreshMenusAndToolBars(); |
|
82 |
|
|
83 | 75 |
editingNotificationManager.notifyObservers(this, |
84 |
EditingNotification.AFTER_ENTER_EDITING_STORE, view.getDocument(),
|
|
76 |
EditingNotification.AFTER_ENTER_EDITING_STORE, null,
|
|
85 | 77 |
layer); |
86 | 78 |
} |
87 | 79 |
|
88 |
private void initFocus(DefaultViewPanel view) { |
|
89 |
|
|
90 |
MapControl mapControl = view.getMapControl(); |
|
91 |
|
|
80 |
private void initFocus(MapControl mapControl) { |
|
81 |
|
|
82 |
EditingBehavior editingBehavior; |
|
92 | 83 |
if (!mapControl.hasTool("VectorEditing")) { |
93 |
Behavior vectorEditing = new DefaultEditingBehavior(mapControl); |
|
94 |
mapControl.addBehavior("VectorEditing", vectorEditing); |
|
84 |
editingBehavior = new DefaultEditingBehavior(mapControl); |
|
85 |
mapControl.addBehavior("VectorEditing", (Behavior) editingBehavior); |
|
86 |
|
|
95 | 87 |
} |
96 | 88 |
else { |
97 |
EditingBehavior editingBehavior = (EditingBehavior) mapControl
|
|
89 |
editingBehavior = (EditingBehavior) mapControl |
|
98 | 90 |
.getMapTool("VectorEditing"); |
99 | 91 |
editingBehavior.cleanBehavior(); |
100 | 92 |
} |
101 |
|
|
93 |
|
|
102 | 94 |
mapControl.setTool("VectorEditing"); |
103 |
|
|
95 |
editingBehavior.showConsole(); |
|
104 | 96 |
} |
105 | 97 |
|
106 |
private void setCaretPosition(DefaultViewPanel view) { |
|
107 |
|
|
108 |
JEditTextArea jeta = view.getConsolePanel().getTxt(); |
|
109 |
jeta.requestFocusInWindow(); |
|
110 |
jeta.setCaretPosition(jeta.getText().length()); |
|
111 |
|
|
112 |
} |
|
113 |
|
|
114 | 98 |
} |
Also available in: Unified diff