Revision 303
org.gvsig.vectorediting/trunk/org.gvsig.vectorediting/org.gvsig.vectorediting.swing/org.gvsig.vectorediting.swing.api/src/main/java/org/gvsig/vectorediting/swing/api/EditingContext.java | ||
---|---|---|
39 | 39 |
static final int SAVE_CHANGES = 3; |
40 | 40 |
static final String DEFAULT_TOOL = "default_tool"; |
41 | 41 |
|
42 |
static final String CHANGE_SELECTED_TOOL_NOTIFICATION = "EditingContext.changeSelectedTool"; |
|
43 |
static final String REFRESH_TOOLS_NOTIFICATION = "EditingContext.refreshTools"; |
|
42 | 44 |
/** |
43 | 45 |
* Activates service as of name and {@link MapControl} |
44 | 46 |
* |
org.gvsig.vectorediting/trunk/org.gvsig.vectorediting/org.gvsig.vectorediting.swing/org.gvsig.vectorediting.swing.impl/src/main/java/org/gvsig/vectorediting/swing/impl/DefaultEditingContext.java | ||
---|---|---|
58 | 58 |
import org.gvsig.fmap.mapcontrol.tools.Behavior.Behavior; |
59 | 59 |
import org.gvsig.tools.ToolsLocator; |
60 | 60 |
import org.gvsig.tools.i18n.I18nManager; |
61 |
import org.gvsig.tools.observer.BaseNotification; |
|
62 |
import org.gvsig.tools.observer.Notification; |
|
61 | 63 |
import org.gvsig.tools.observer.ObservableHelper; |
62 | 64 |
import org.gvsig.tools.observer.Observer; |
63 | 65 |
import org.gvsig.utils.console.JConsole; |
... | ... | |
376 | 378 |
} |
377 | 379 |
|
378 | 380 |
private void changeSelectedTool(String name) { |
379 |
this.observableHelper.notifyObservers(this, name); |
|
381 |
if (name.equalsIgnoreCase(DEFAULT_TOOL)){ |
|
382 |
name = "selection-simple-select-view"; |
|
383 |
this.getMapControl().setTool("pointSelection"); |
|
384 |
// } else { |
|
385 |
// this.getMapControl().setTool(name); |
|
386 |
} |
|
387 |
Notification notification = new BaseNotification(EditingContext.CHANGE_SELECTED_TOOL_NOTIFICATION, new Object[]{name}); |
|
388 |
this.observableHelper.notifyObservers(this, notification); |
|
380 | 389 |
} |
381 | 390 |
|
382 | 391 |
private void cleanEditingContext() { |
... | ... | |
770 | 779 |
} |
771 | 780 |
|
772 | 781 |
protected void refreshMenusAndToolBars() { |
773 |
this.observableHelper.notifyObservers(this, null); |
|
782 |
Notification notification = new BaseNotification(EditingContext.REFRESH_TOOLS_NOTIFICATION, null); |
|
783 |
this.observableHelper.notifyObservers(this, notification); |
|
774 | 784 |
} |
775 | 785 |
|
776 | 786 |
private void saveChanges(FLyrVect layer) throws EndEditingException { |
org.gvsig.vectorediting/trunk/org.gvsig.vectorediting/org.gvsig.vectorediting.app/org.gvsig.vectorediting.app.mainplugin/src/main/java/org/gvsig/vectorediting/app/mainplugin/EditingExtension.java | ||
---|---|---|
37 | 37 |
import org.gvsig.fmap.mapcontrol.MapControl; |
38 | 38 |
import org.gvsig.fmap.mapcontrol.tools.Behavior.Behavior; |
39 | 39 |
import org.gvsig.fmap.mapcontrol.tools.Behavior.MouseMovementBehavior; |
40 |
import org.gvsig.tools.observer.BaseNotification; |
|
41 |
import org.gvsig.tools.observer.Notification; |
|
40 | 42 |
import org.gvsig.tools.observer.Observable; |
41 | 43 |
import org.gvsig.tools.observer.Observer; |
42 | 44 |
import org.gvsig.vectorediting.swing.api.EditingContext; |
... | ... | |
169 | 171 |
return null; |
170 | 172 |
} |
171 | 173 |
|
172 |
//FIXME: Revisar implementaci?n. ?Implementar sistema de notificaciones? |
|
173 | 174 |
public void update(Observable observable, Object notification) { |
174 | 175 |
|
175 |
if (observable instanceof EditingContext) { |
|
176 |
if (notification != null) { |
|
177 |
if (notification instanceof String) { |
|
178 |
String name = (String) notification; |
|
179 |
if (name.equalsIgnoreCase(EditingContext.DEFAULT_TOOL)){ |
|
180 |
PluginServices.getMainFrame().setSelectedTool("selection-simple-select-view"); |
|
181 |
IView view = getActiveView(); |
|
182 |
view.getMapControl().setTool("pointSelection"); |
|
183 |
} |
|
184 |
PluginServices.getMainFrame().setSelectedTool(name); |
|
185 |
} |
|
186 |
} |
|
176 |
if (notification instanceof Notification){ |
|
187 | 177 |
ApplicationManager appManager = |
188 | 178 |
ApplicationLocator.getManager(); |
189 |
appManager.refreshMenusAndToolBars(); |
|
179 |
Notification n = (Notification)notification; |
|
180 |
if (n.getType().equalsIgnoreCase(EditingContext.CHANGE_SELECTED_TOOL_NOTIFICATION)){ |
|
181 |
String name = (String)n.getValue(); |
|
182 |
PluginServices.getMainFrame().setSelectedTool(name); |
|
183 |
appManager.refreshMenusAndToolBars(); |
|
184 |
|
|
185 |
} else if (n.getType().equalsIgnoreCase(EditingContext.REFRESH_TOOLS_NOTIFICATION)){ |
|
186 |
appManager.refreshMenusAndToolBars(); |
|
187 |
} |
|
190 | 188 |
} |
191 | 189 |
} |
192 | 190 |
} |
Also available in: Unified diff