Revision 38324
tags/v2_0_0_Build_2047/extensions/extEditing/extEditing/src/org/gvsig/editing/EditionChangeManager.java | ||
---|---|---|
1 |
package org.gvsig.editing; |
|
2 |
|
|
3 |
import org.gvsig.andami.PluginServices; |
|
4 |
import org.gvsig.andami.messages.NotificationManager; |
|
5 |
import org.gvsig.andami.ui.mdiManager.IWindow; |
|
6 |
import org.gvsig.editing.layers.VectorialLayerEdited; |
|
7 |
import org.gvsig.fmap.dal.exception.DataException; |
|
8 |
import org.gvsig.fmap.dal.feature.impl.DefaultFeatureStoreNotification; |
|
9 |
import org.gvsig.fmap.mapcontext.layers.FLayer; |
|
10 |
import org.gvsig.tools.observer.Observable; |
|
11 |
import org.gvsig.tools.observer.Observer; |
|
12 |
|
|
13 |
|
|
14 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
|
15 |
* |
|
16 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana. |
|
17 |
* |
|
18 |
* This program is free software; you can redistribute it and/or |
|
19 |
* modify it under the terms of the GNU General Public License |
|
20 |
* as published by the Free Software Foundation; either version 2 |
|
21 |
* of the License, or (at your option) any later version. |
|
22 |
* |
|
23 |
* This program is distributed in the hope that it will be useful, |
|
24 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
25 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
26 |
* GNU General Public License for more details. |
|
27 |
* |
|
28 |
* You should have received a copy of the GNU General Public License |
|
29 |
* along with this program; if not, write to the Free Software |
|
30 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA. |
|
31 |
* |
|
32 |
* For more information, contact: |
|
33 |
* |
|
34 |
* Generalitat Valenciana |
|
35 |
* Conselleria d'Infraestructures i Transport |
|
36 |
* Av. Blasco Ib??ez, 50 |
|
37 |
* 46010 VALENCIA |
|
38 |
* SPAIN |
|
39 |
* |
|
40 |
* +34 963862235 |
|
41 |
* gvsig@gva.es |
|
42 |
* www.gvsig.gva.es |
|
43 |
* |
|
44 |
* or |
|
45 |
* |
|
46 |
* IVER T.I. S.A |
|
47 |
* Salamanca 50 |
|
48 |
* 46005 Valencia |
|
49 |
* Spain |
|
50 |
* |
|
51 |
* +34 963163400 |
|
52 |
* dac@iver.es |
|
53 |
*/ |
|
54 |
/* CVS MESSAGES: |
|
55 |
* |
|
56 |
* $Id$ |
|
57 |
* $Log$ |
|
58 |
* Revision 1.16 2007-09-19 15:55:42 jaume |
|
59 |
* removed unnecessary imports |
|
60 |
* |
|
61 |
* Revision 1.15 2007/06/22 10:48:00 caballero |
|
62 |
* borrar selecci?n |
|
63 |
* |
|
64 |
* Revision 1.14 2007/03/21 12:25:41 caballero |
|
65 |
* zoom remove cacheDrawing |
|
66 |
* |
|
67 |
* Revision 1.13 2007/02/13 17:10:06 caballero |
|
68 |
* expresion |
|
69 |
* |
|
70 |
* Revision 1.12 2006/11/28 13:18:32 fjp |
|
71 |
* No redibujar cuando se a?ade algo. |
|
72 |
* Para que se dibuje con el s?mbolo por defecto del layer, habr? que tocar |
|
73 |
* en los CADTool |
|
74 |
* |
|
75 |
* Revision 1.11 2006/09/15 10:42:17 caballero |
|
76 |
* extensibilidad de documentos |
|
77 |
* |
|
78 |
* Revision 1.10 2006/08/29 07:56:33 cesar |
|
79 |
* Rename the *View* family of classes to *Window* (ie: SingletonView to SingletonWindow, ViewInfo to WindowInfo, etc) |
|
80 |
* |
|
81 |
* Revision 1.9 2006/08/29 07:13:57 cesar |
|
82 |
* Rename class com.iver.andami.ui.mdiManager.View to com.iver.andami.ui.mdiManager.IWindow |
|
83 |
* |
|
84 |
* Revision 1.8 2006/08/08 07:19:05 caballero |
|
85 |
* afterRowEditEvent con IRow |
|
86 |
* |
|
87 |
* Revision 1.7 2006/07/20 11:03:27 fjp |
|
88 |
* *** empty log message *** |
|
89 |
* |
|
90 |
* Revision 1.6 2006/07/13 12:36:01 fjp |
|
91 |
* Revisar bien lo de a?adir campos y gestionar un campo gris |
|
92 |
* |
|
93 |
* Revision 1.5 2006/06/21 07:22:48 fjp |
|
94 |
* Posibilidad de marcar capas como "dirty" y tener una que guarde lo que se ha dibujado antes que ella. Al hacer un MapControl.rePaintDirtyLayers(), eso se tiene en cuenta en el redibujado. |
|
95 |
* |
|
96 |
* Revision 1.4 2006/05/16 07:06:02 caballero |
|
97 |
* Saber si se realiza una operaci?n desde la vista o desde la tabla. |
|
98 |
* |
|
99 |
* Revision 1.3 2006/05/10 06:26:24 caballero |
|
100 |
* comprobar si tiene capa asociada |
|
101 |
* |
|
102 |
* Revision 1.2 2006/05/09 09:26:04 caballero |
|
103 |
* refrescar las vistas y tablas |
|
104 |
* |
|
105 |
* Revision 1.1 2006/05/05 09:06:09 jorpiell |
|
106 |
* Se a a?adido la clase EditionChangeManager, que no es m?s que un listener que se ejecuta cuando se produce un evento de edici?n. |
|
107 |
* |
|
108 |
* |
|
109 |
*/ |
|
110 |
/** |
|
111 |
* Cuando un tema se pone en edici?n se le debe asociar |
|
112 |
* un listener de este tipo, que se dispar? cuando se produzca |
|
113 |
* un evento de edici?n (borrado, modificaci?n,... sobre la capa. |
|
114 |
* |
|
115 |
* @author Jorge Piera Llodr? (piera_jor@gva.es) |
|
116 |
*/ |
|
117 |
public class EditionChangeManager implements Observer{ |
|
118 |
private FLayer fLayer = null; |
|
119 |
|
|
120 |
/** |
|
121 |
* Constructor |
|
122 |
* @param fLayer |
|
123 |
* Tema que se est? editando |
|
124 |
*/ |
|
125 |
public EditionChangeManager(FLayer fLayer){ |
|
126 |
this.fLayer = fLayer; |
|
127 |
} |
|
128 |
/* |
|
129 |
* (non-Javadoc) |
|
130 |
* @see com.iver.cit.gvsig.fmap.edition.IEditionListener#afterRowEditEvent(com.iver.cit.gvsig.fmap.edition.AfterRowEditEvent) |
|
131 |
*/ |
|
132 |
// public void afterRowEditEvent(IRow feat, AfterRowEditEvent e) { |
|
133 |
// IWindow[] views = PluginServices.getMDIManager().getAllWindows(); |
|
134 |
// |
|
135 |
// for (int i=0 ; i<views.length ; i++){ |
|
136 |
// if (views[i] instanceof Table){ |
|
137 |
//// Table table=(Table)views[i]; |
|
138 |
// ///VCN Creo que no hace falta refrescar la tabla aqu? |
|
139 |
//// if (table.getModel().getAssociatedTable()!=null && table.getModel().getAssociatedTable().equals(fLayer)) |
|
140 |
//// table.refresh(); |
|
141 |
// }else if (views[i] instanceof com.iver.cit.gvsig.project.documents.view.gui.View){ |
|
142 |
// com.iver.cit.gvsig.project.documents.view.gui.View view=(com.iver.cit.gvsig.project.documents.view.gui.View)views[i]; |
|
143 |
// |
|
144 |
// if (e.getChangeType() == EditionEvent.CHANGE_TYPE_ADD) { |
|
145 |
// // No redraw, just image paint |
|
146 |
// view.getMapControl().repaint(); |
|
147 |
// }else if (e.getChangeType() == EditionEvent.CHANGE_TYPE_DELETE){ |
|
148 |
// EditionManager em=CADExtension.getEditionManager(); |
|
149 |
// if (em.getActiveLayerEdited()!=null){ |
|
150 |
// VectorialLayerEdited vle=(VectorialLayerEdited)em.getActiveLayerEdited(); |
|
151 |
// try { |
|
152 |
// vle.clearSelection(false); |
|
153 |
// } catch (ReadException e1) { |
|
154 |
// NotificationManager.addError(e1); |
|
155 |
// } |
|
156 |
// } |
|
157 |
// }else{ |
|
158 |
// fLayer.setDirty(true); |
|
159 |
// view.getMapControl().rePaintDirtyLayers(); |
|
160 |
// } |
|
161 |
// |
|
162 |
// /* FLayers layers=view.getMapControl().getMapContext().getLayers(); |
|
163 |
// for (int j=0;j<layers.getLayersCount();j++){ |
|
164 |
// if (layers.getLayer(j).equals(fLayer)){ |
|
165 |
// view.repaintMap(); |
|
166 |
// } |
|
167 |
// } */ |
|
168 |
// } |
|
169 |
// } |
|
170 |
// |
|
171 |
// } |
|
172 |
public void update(Observable observable, Object notification) { |
|
173 |
DefaultFeatureStoreNotification dfsn=(DefaultFeatureStoreNotification)notification; |
|
174 |
String type=dfsn.getType(); |
|
175 |
IWindow[] views = PluginServices.getMDIManager().getAllWindows(); |
|
176 |
|
|
177 |
for (int i=0 ; i<views.length ; i++){ |
|
178 |
if (views[i] instanceof org.gvsig.app.project.documents.view.gui.DefaultViewPanel){ |
|
179 |
org.gvsig.app.project.documents.view.gui.DefaultViewPanel view=(org.gvsig.app.project.documents.view.gui.DefaultViewPanel)views[i]; |
|
180 |
if (type.equals(DefaultFeatureStoreNotification.AFTER_DELETE)){ |
|
181 |
EditionManager em=CADExtension.getEditionManager(); |
|
182 |
if (em.getActiveLayerEdited()!=null){ |
|
183 |
VectorialLayerEdited vle=(VectorialLayerEdited)em.getActiveLayerEdited(); |
|
184 |
try { |
|
185 |
vle.clearSelection(); |
|
186 |
} catch (DataException e1) { |
|
187 |
NotificationManager.addError(e1); |
|
188 |
} |
|
189 |
} |
|
190 |
} |
|
191 |
if (type.equals(DefaultFeatureStoreNotification.AFTER_INSERT)){ |
|
192 |
view.getMapControl().repaint(); |
|
193 |
} |
|
194 |
if (type.equals(DefaultFeatureStoreNotification.AFTER_UPDATE)){ |
|
195 |
view.getMapControl().rePaintDirtyLayers(); |
|
196 |
} |
|
197 |
} |
|
198 |
} |
|
199 |
} |
|
200 |
|
|
201 |
} |
|
0 | 202 |
tags/v2_0_0_Build_2047/extensions/extEditing/extEditing/src/org/gvsig/editing/ViewCommandStackExtension.java | ||
---|---|---|
1 |
package org.gvsig.editing; |
|
2 |
|
|
3 |
import org.gvsig.andami.PluginServices; |
|
4 |
import org.gvsig.andami.plugins.Extension; |
|
5 |
import org.gvsig.app.gui.command.CommandStackDialog; |
|
6 |
import org.gvsig.app.project.documents.view.ViewDocument; |
|
7 |
import org.gvsig.app.project.documents.view.gui.DefaultViewPanel; |
|
8 |
import org.gvsig.fmap.dal.exception.DataException; |
|
9 |
import org.gvsig.fmap.dal.feature.FeatureStore; |
|
10 |
import org.gvsig.fmap.mapcontext.MapContext; |
|
11 |
import org.gvsig.fmap.mapcontext.layers.FLayers; |
|
12 |
import org.gvsig.fmap.mapcontext.layers.vectorial.FLyrVect; |
|
13 |
|
|
14 |
|
|
15 |
/** |
|
16 |
* DOCUMENT ME! |
|
17 |
* |
|
18 |
* @author Vicente Caballero Navarro |
|
19 |
*/ |
|
20 |
public class ViewCommandStackExtension extends Extension { |
|
21 |
|
|
22 |
public static CommandStackDialog csd=null; |
|
23 |
/** |
|
24 |
* @see org.gvsig.andami.plugins.IExtension#initialize() |
|
25 |
*/ |
|
26 |
public void initialize() { |
|
27 |
PluginServices.getIconTheme().registerDefault( |
|
28 |
"commands-stack", |
|
29 |
this.getClass().getClassLoader().getResource("images/commandstack.png") |
|
30 |
); |
|
31 |
} |
|
32 |
|
|
33 |
/** |
|
34 |
* @see org.gvsig.andami.plugins.IExtension#execute(java.lang.String) |
|
35 |
*/ |
|
36 |
public void execute(String s) { |
|
37 |
org.gvsig.andami.ui.mdiManager.IWindow f = PluginServices.getMDIManager() |
|
38 |
.getActiveWindow(); |
|
39 |
|
|
40 |
DefaultViewPanel vista = (DefaultViewPanel) f; |
|
41 |
ViewDocument model = vista.getModel(); |
|
42 |
MapContext mapa = model.getMapContext(); |
|
43 |
FLayers layers = mapa.getLayers(); |
|
44 |
if (s.equals("COMMANDSTACK")) { |
|
45 |
for (int i =0;i<layers.getLayersCount();i++){ |
|
46 |
if (layers.getLayer(i) instanceof FLyrVect){ |
|
47 |
FLyrVect lyrVect=(FLyrVect)layers.getLayer(i); |
|
48 |
if (lyrVect.isEditing() && lyrVect.isActive()){ |
|
49 |
// try{ |
|
50 |
FeatureStore featureStore=lyrVect.getFeatureStore(); |
|
51 |
// CommandsRecord commandsRecord=null; |
|
52 |
// try { |
|
53 |
// commandsRecord = lyrVect.getFeatureStore().getCommandsRecord(); |
|
54 |
// } catch (ReadException e) { |
|
55 |
// // TODO Auto-generated catch block |
|
56 |
// e.printStackTrace(); |
|
57 |
// } catch (DataException e) { |
|
58 |
// // TODO Auto-generated catch block |
|
59 |
// e.printStackTrace(); |
|
60 |
// } |
|
61 |
// commandsRecord.addObserver(this); |
|
62 |
csd=new CommandStackDialog(); |
|
63 |
csd.setModel(featureStore); |
|
64 |
PluginServices.getMDIManager().addWindow(csd); |
|
65 |
// } catch (DataException e) { |
|
66 |
// e.printStackTrace(); |
|
67 |
// } |
|
68 |
return; |
|
69 |
} |
|
70 |
} |
|
71 |
} |
|
72 |
} |
|
73 |
|
|
74 |
//PluginServices.getMainFrame().enableControls(); |
|
75 |
|
|
76 |
} |
|
77 |
|
|
78 |
/** |
|
79 |
* @see org.gvsig.andami.plugins.IExtension#isEnabled() |
|
80 |
*/ |
|
81 |
public boolean isEnabled() { |
|
82 |
|
|
83 |
return true; |
|
84 |
} |
|
85 |
|
|
86 |
/** |
|
87 |
* @see org.gvsig.andami.plugins.IExtension#isVisible() |
|
88 |
*/ |
|
89 |
public boolean isVisible() { |
|
90 |
if (EditionUtilities.getEditionStatus() == EditionUtilities.EDITION_STATUS_ONE_VECTORIAL_LAYER_ACTIVE_AND_EDITABLE) |
|
91 |
return true; |
|
92 |
return false; |
|
93 |
|
|
94 |
} |
|
95 |
|
|
96 |
// public void commandRepaint() { |
|
97 |
// try { |
|
98 |
// CADExtension.getCADTool().clearSelection(); |
|
99 |
// } catch (ReadException e) { |
|
100 |
// NotificationManager.addError(e.getMessage(),e); |
|
101 |
// } |
|
102 |
// |
|
103 |
// } |
|
104 |
// |
|
105 |
// public void commandRefresh() { |
|
106 |
// try { |
|
107 |
// CADExtension.getCADTool().clearSelection(); |
|
108 |
// } catch (ReadException e) { |
|
109 |
// NotificationManager.addError(e.getMessage(),e); |
|
110 |
// } |
|
111 |
// } |
|
112 |
|
|
113 |
} |
|
0 | 114 |
tags/v2_0_0_Build_2047/extensions/extEditing/extEditing/src/org/gvsig/editing/JoinExtension.java | ||
---|---|---|
1 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
|
2 |
* |
|
3 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana. |
|
4 |
* |
|
5 |
* This program is free software; you can redistribute it and/or |
|
6 |
* modify it under the terms of the GNU General Public License |
|
7 |
* as published by the Free Software Foundation; either version 2 |
|
8 |
* of the License, or (at your option) any later version. |
|
9 |
* |
|
10 |
* This program is distributed in the hope that it will be useful, |
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
13 |
* GNU General Public License for more details. |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License |
|
16 |
* along with this program; if not, write to the Free Software |
|
17 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA. |
|
18 |
* |
|
19 |
* For more information, contact: |
|
20 |
* |
|
21 |
* Generalitat Valenciana |
|
22 |
* Conselleria d'Infraestructures i Transport |
|
23 |
* Av. Blasco Ib??ez, 50 |
|
24 |
* 46010 VALENCIA |
|
25 |
* SPAIN |
|
26 |
* |
|
27 |
* +34 963862235 |
|
28 |
* gvsig@gva.es |
|
29 |
* www.gvsig.gva.es |
|
30 |
* |
|
31 |
* or |
|
32 |
* |
|
33 |
* IVER T.I. S.A |
|
34 |
* Salamanca 50 |
|
35 |
* 46005 Valencia |
|
36 |
* Spain |
|
37 |
* |
|
38 |
* +34 963163400 |
|
39 |
* dac@iver.es |
|
40 |
*/ |
|
41 |
package org.gvsig.editing; |
|
42 |
|
|
43 |
import org.gvsig.andami.PluginServices; |
|
44 |
import org.gvsig.andami.messages.NotificationManager; |
|
45 |
import org.gvsig.andami.plugins.Extension; |
|
46 |
import org.gvsig.app.project.documents.view.gui.DefaultViewPanel; |
|
47 |
import org.gvsig.editing.gui.cad.tools.JoinCADTool; |
|
48 |
import org.gvsig.fmap.dal.exception.DataException; |
|
49 |
import org.gvsig.fmap.dal.feature.FeatureSelection; |
|
50 |
import org.gvsig.fmap.mapcontext.layers.vectorial.FLyrVect; |
|
51 |
import org.gvsig.fmap.mapcontrol.MapControl; |
|
52 |
|
|
53 |
|
|
54 |
/** |
|
55 |
* Extensi?n que gestiona la uni?n de geometr?as en edici?n. |
|
56 |
* |
|
57 |
* @author Vicente Caballero Navarro |
|
58 |
*/ |
|
59 |
public class JoinExtension extends Extension { |
|
60 |
private DefaultViewPanel view; |
|
61 |
|
|
62 |
private MapControl mapControl; |
|
63 |
private JoinCADTool joinCADTool; |
|
64 |
|
|
65 |
/** |
|
66 |
* @see org.gvsig.andami.plugins.IExtension#initialize() |
|
67 |
*/ |
|
68 |
public void initialize() { |
|
69 |
joinCADTool=new JoinCADTool(); |
|
70 |
CADExtension.addCADTool("_join",joinCADTool); |
|
71 |
|
|
72 |
registerIcons(); |
|
73 |
} |
|
74 |
|
|
75 |
private void registerIcons(){ |
|
76 |
PluginServices.getIconTheme().registerDefault( |
|
77 |
"edition-geometry-Join", |
|
78 |
this.getClass().getClassLoader().getResource("images/Join.png") |
|
79 |
); |
|
80 |
|
|
81 |
} |
|
82 |
/** |
|
83 |
* @see org.gvsig.andami.plugins.IExtension#execute(java.lang.String) |
|
84 |
*/ |
|
85 |
public void execute(String s) { |
|
86 |
CADExtension.initFocus(); |
|
87 |
if (s.equals("_join")) { |
|
88 |
CADExtension.setCADTool(s,true); |
|
89 |
} |
|
90 |
CADExtension.getEditionManager().setMapControl(mapControl); |
|
91 |
CADExtension.getCADToolAdapter().configureMenu(); |
|
92 |
} |
|
93 |
|
|
94 |
/** |
|
95 |
* @see org.gvsig.andami.plugins.IExtension#isEnabled() |
|
96 |
*/ |
|
97 |
public boolean isEnabled() { |
|
98 |
|
|
99 |
try { |
|
100 |
if (EditionUtilities.getEditionStatus() == EditionUtilities.EDITION_STATUS_ONE_VECTORIAL_LAYER_ACTIVE_AND_EDITABLE) { |
|
101 |
view = (DefaultViewPanel) PluginServices.getMDIManager().getActiveWindow(); |
|
102 |
mapControl = view.getMapControl(); |
|
103 |
if (CADExtension.getEditionManager().getActiveLayerEdited()==null) |
|
104 |
return false; |
|
105 |
FLyrVect lv=(FLyrVect)CADExtension.getEditionManager().getActiveLayerEdited().getLayer(); |
|
106 |
if (joinCADTool.isApplicable(lv.getShapeType()) && ((FeatureSelection)lv.getFeatureStore().getSelection()).getSize()>1){ |
|
107 |
return true; |
|
108 |
} |
|
109 |
} |
|
110 |
} catch (DataException e) { |
|
111 |
NotificationManager.addError(e.getMessage(),e); |
|
112 |
} |
|
113 |
return false; |
|
114 |
} |
|
115 |
|
|
116 |
/** |
|
117 |
* @see org.gvsig.andami.plugins.IExtension#isVisible() |
|
118 |
*/ |
|
119 |
public boolean isVisible() { |
|
120 |
if (EditionUtilities.getEditionStatus() == EditionUtilities.EDITION_STATUS_ONE_VECTORIAL_LAYER_ACTIVE_AND_EDITABLE) |
|
121 |
return true; |
|
122 |
return false; |
|
123 |
} |
|
124 |
} |
tags/v2_0_0_Build_2047/extensions/extEditing/extEditing/src/org/gvsig/editing/UndoViewExtension.java | ||
---|---|---|
1 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
|
2 |
* |
|
3 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana. |
|
4 |
* |
|
5 |
* This program is free software; you can redistribute it and/or |
|
6 |
* modify it under the terms of the GNU General Public License |
|
7 |
* as published by the Free Software Foundation; either version 2 |
|
8 |
* of the License, or (at your option) any later version. |
|
9 |
* |
|
10 |
* This program is distributed in the hope that it will be useful, |
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
13 |
* GNU General Public License for more details. |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License |
|
16 |
* along with this program; if not, write to the Free Software |
|
17 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA. |
|
18 |
* |
|
19 |
* For more information, contact: |
|
20 |
* |
|
21 |
* Generalitat Valenciana |
|
22 |
* Conselleria d'Infraestructures i Transport |
|
23 |
* Av. Blasco Ib??ez, 50 |
|
24 |
* 46010 VALENCIA |
|
25 |
* SPAIN |
|
26 |
* |
|
27 |
* +34 963862235 |
|
28 |
* gvsig@gva.es |
|
29 |
* www.gvsig.gva.es |
|
30 |
* |
|
31 |
* or |
|
32 |
* |
|
33 |
* IVER T.I. S.A |
|
34 |
* Salamanca 50 |
|
35 |
* 46005 Valencia |
|
36 |
* Spain |
|
37 |
* |
|
38 |
* +34 963163400 |
|
39 |
* dac@iver.es |
|
40 |
*/ |
|
41 |
package org.gvsig.editing; |
|
42 |
|
|
43 |
import org.gvsig.andami.PluginServices; |
|
44 |
import org.gvsig.andami.messages.NotificationManager; |
|
45 |
import org.gvsig.andami.plugins.Extension; |
|
46 |
import org.gvsig.app.project.documents.view.gui.DefaultViewPanel; |
|
47 |
import org.gvsig.fmap.dal.exception.DataException; |
|
48 |
import org.gvsig.fmap.dal.exception.ReadException; |
|
49 |
import org.gvsig.fmap.mapcontext.layers.FLayer; |
|
50 |
import org.gvsig.fmap.mapcontext.layers.FLayers; |
|
51 |
import org.gvsig.fmap.mapcontext.layers.vectorial.FLyrVect; |
|
52 |
import org.gvsig.fmap.mapcontrol.MapControl; |
|
53 |
import org.gvsig.tools.undo.UndoException; |
|
54 |
|
|
55 |
|
|
56 |
|
|
57 |
/** |
|
58 |
* Extensi?n encargada de gestionar el deshacer los comandos anteriormente |
|
59 |
* aplicados. |
|
60 |
* |
|
61 |
* @author Vicente Caballero Navarro |
|
62 |
*/ |
|
63 |
public class UndoViewExtension extends Extension { |
|
64 |
/** |
|
65 |
* @see org.gvsig.andami.plugins.IExtension#initialize() |
|
66 |
*/ |
|
67 |
public void initialize() { |
|
68 |
PluginServices.getIconTheme().registerDefault( |
|
69 |
"view-undo", |
|
70 |
this.getClass().getClassLoader().getResource("images/Undo.png") |
|
71 |
); |
|
72 |
} |
|
73 |
|
|
74 |
/** |
|
75 |
* @see org.gvsig.andami.plugins.IExtension#execute(java.lang.String) |
|
76 |
*/ |
|
77 |
public void execute(String s) { |
|
78 |
DefaultViewPanel vista = (DefaultViewPanel) PluginServices.getMDIManager().getActiveWindow(); |
|
79 |
|
|
80 |
|
|
81 |
if (s.compareTo("UNDO") == 0) { |
|
82 |
undo(vista); |
|
83 |
|
|
84 |
} |
|
85 |
} |
|
86 |
|
|
87 |
private void undo(DefaultViewPanel vista) { |
|
88 |
MapControl mapControl = vista.getMapControl(); |
|
89 |
try { |
|
90 |
FLayers layers=mapControl.getMapContext().getLayers(); |
|
91 |
for (int i=0;i<layers.getLayersCount();i++){ |
|
92 |
if (layers.getLayer(i) instanceof FLyrVect && layers.getLayer(i).isEditing() && layers.getLayer(i).isActive()){ |
|
93 |
((FLyrVect)layers.getLayer(i)).getFeatureStore().undo(); |
|
94 |
// CommandsRecord commandsRecord=((FLyrVect)layers.getLayer(i)).getFeatureStore().getCommandsRecord(); |
|
95 |
// commandsRecord.undo(); |
|
96 |
mapControl.drawMap(false); |
|
97 |
// VectorialEditableAdapter vea=(VectorialEditableAdapter)((FLyrVect)layers.getLayer(i)).getSource(); |
|
98 |
// vea.undo(); |
|
99 |
// vea.getCommandRecord().fireCommandsRepaint(null); |
|
100 |
// CADExtension.getCADTool().clearSelection(); |
|
101 |
} |
|
102 |
} |
|
103 |
// } catch (ReadException e) { |
|
104 |
// NotificationManager.addError(e.getMessage(),e); |
|
105 |
// } catch (DataException e) { |
|
106 |
// NotificationManager.addError(e.getMessage(),e); |
|
107 |
} catch (UndoException e) { |
|
108 |
NotificationManager.addError(e.getMessage(),e); |
|
109 |
} |
|
110 |
|
|
111 |
} |
|
112 |
|
|
113 |
/** |
|
114 |
* @see org.gvsig.andami.plugins.IExtension#isEnabled() |
|
115 |
*/ |
|
116 |
public boolean isEnabled() { |
|
117 |
DefaultViewPanel vista = (DefaultViewPanel) PluginServices.getMDIManager().getActiveWindow(); |
|
118 |
MapControl mapControl = vista.getMapControl(); |
|
119 |
FLayers layers=mapControl.getMapContext().getLayers(); |
|
120 |
for (int i=0;i<layers.getLayersCount();i++){ |
|
121 |
// try { |
|
122 |
if (layers.getLayer(i) instanceof FLyrVect && ((FLyrVect)layers.getLayer(i)).getFeatureStore().isEditing() && layers.getLayer(i).isActive()){ |
|
123 |
return ((FLyrVect)layers.getLayer(i)).getFeatureStore().canUndo(); |
|
124 |
// VectorialEditableAdapter vea=(VectorialEditableAdapter)((FLyrVect)layers.getLayer(i)).getSource(); |
|
125 |
// if (vea==null)return false; |
|
126 |
// return vea.getCommandRecord().moreUndoCommands(); |
|
127 |
} |
|
128 |
// } catch (ReadException e) { |
|
129 |
// // TODO Auto-generated catch block |
|
130 |
// e.printStackTrace(); |
|
131 |
// } catch (DataException e) { |
|
132 |
// // TODO Auto-generated catch block |
|
133 |
// e.printStackTrace(); |
|
134 |
// } |
|
135 |
|
|
136 |
} |
|
137 |
return false; |
|
138 |
} |
|
139 |
|
|
140 |
/** |
|
141 |
* @see org.gvsig.andami.plugins.IExtension#isVisible() |
|
142 |
*/ |
|
143 |
public boolean isVisible() { |
|
144 |
org.gvsig.andami.ui.mdiManager.IWindow f = PluginServices.getMDIManager() |
|
145 |
.getActiveWindow(); |
|
146 |
|
|
147 |
if (f == null) { |
|
148 |
return false; |
|
149 |
} |
|
150 |
|
|
151 |
if (f instanceof DefaultViewPanel) { |
|
152 |
MapControl mapControl = ((DefaultViewPanel)f).getMapControl(); |
|
153 |
FLayer[] layers=mapControl.getMapContext().getLayers().getActives(); |
|
154 |
FLayer layer; |
|
155 |
for (int i=0;i<layers.length;i++){ |
|
156 |
layer = layers[i]; |
|
157 |
if (!layer.isAvailable()){ |
|
158 |
continue; |
|
159 |
} |
|
160 |
// try { |
|
161 |
if (layer instanceof FLyrVect && ((FLyrVect)layer).getFeatureStore().isEditing()){ |
|
162 |
return true; |
|
163 |
} |
|
164 |
// } catch (ReadException e) { |
|
165 |
// // TODO Auto-generated catch block |
|
166 |
// e.printStackTrace(); |
|
167 |
// } |
|
168 |
} |
|
169 |
} |
|
170 |
return false; |
|
171 |
} |
|
172 |
} |
|
0 | 173 |
tags/v2_0_0_Build_2047/extensions/extEditing/extEditing/src/org/gvsig/editing/StartEditing.java | ||
---|---|---|
1 |
package org.gvsig.editing; |
|
2 |
|
|
3 |
import java.awt.Component; |
|
4 |
|
|
5 |
import javax.swing.JOptionPane; |
|
6 |
|
|
7 |
import org.gvsig.andami.PluginServices; |
|
8 |
import org.gvsig.andami.messages.NotificationManager; |
|
9 |
import org.gvsig.andami.plugins.Extension; |
|
10 |
import org.gvsig.app.extension.ProjectExtension; |
|
11 |
import org.gvsig.app.project.documents.view.ViewDocument; |
|
12 |
import org.gvsig.app.project.documents.view.gui.DefaultViewPanel; |
|
13 |
import org.gvsig.editing.gui.cad.CADTool; |
|
14 |
import org.gvsig.editing.gui.tokenmarker.ConsoleToken; |
|
15 |
import org.gvsig.fmap.dal.exception.ReadException; |
|
16 |
import org.gvsig.fmap.mapcontext.exceptions.StartEditionLayerException; |
|
17 |
import org.gvsig.fmap.mapcontext.layers.FLayer; |
|
18 |
import org.gvsig.fmap.mapcontext.layers.vectorial.FLyrVect; |
|
19 |
import org.gvsig.fmap.mapcontext.rendering.legend.ILegend; |
|
20 |
import org.gvsig.fmap.mapcontrol.MapControl; |
|
21 |
import org.gvsig.utils.console.jedit.KeywordMap; |
|
22 |
import org.gvsig.utils.console.jedit.Token; |
|
23 |
|
|
24 |
|
|
25 |
/** |
|
26 |
* DOCUMENT ME! |
|
27 |
* |
|
28 |
* @author Vicente Caballero Navarro |
|
29 |
*/ |
|
30 |
public class StartEditing extends Extension { |
|
31 |
|
|
32 |
// private class MyAction extends AbstractAction |
|
33 |
// { |
|
34 |
// |
|
35 |
// public void actionPerformed(ActionEvent e) { |
|
36 |
// System.err.println("F3"); |
|
37 |
// } |
|
38 |
// |
|
39 |
// } |
|
40 |
|
|
41 |
//View vista; |
|
42 |
/** |
|
43 |
* @see org.gvsig.andami.plugins.IExtension#initialize() |
|
44 |
*/ |
|
45 |
public void initialize() { |
|
46 |
} |
|
47 |
|
|
48 |
/** |
|
49 |
* @see org.gvsig.andami.plugins.IExtension#execute(java.lang.String) |
|
50 |
*/ |
|
51 |
public void execute(String actionCommand) { |
|
52 |
CADExtension.initFocus(); |
|
53 |
org.gvsig.andami.ui.mdiManager.IWindow f = PluginServices.getMDIManager() |
|
54 |
.getActiveWindow(); |
|
55 |
|
|
56 |
if (f instanceof DefaultViewPanel) { |
|
57 |
DefaultViewPanel vista = (DefaultViewPanel) f; |
|
58 |
|
|
59 |
MapControl mapControl = vista.getMapControl(); |
|
60 |
ViewDocument model = vista.getModel(); |
|
61 |
FLayer[] actives = model.getMapContext().getLayers().getActives(); |
|
62 |
|
|
63 |
boolean bEditingStarted = false; |
|
64 |
if (actives.length == 1 && actives[0] instanceof FLyrVect) { |
|
65 |
|
|
66 |
vista.showConsole(); |
|
67 |
EditionManager editionManager=CADExtension.getEditionManager(); |
|
68 |
editionManager.setMapControl(mapControl); |
|
69 |
/* |
|
70 |
* for (int j = 0; j < i; j++) { |
|
71 |
* layers.getLayer(j).setVisible(false); } |
|
72 |
*/ |
|
73 |
|
|
74 |
FLyrVect lv = (FLyrVect) actives[0]; |
|
75 |
// lv.setVisible(true); |
|
76 |
lv.addLayerListener(editionManager); |
|
77 |
try { |
|
78 |
ILegend legendOriginal=lv.getLegend().cloneLegend(); |
|
79 |
|
|
80 |
if (!lv.isWritable()) |
|
81 |
{ |
|
82 |
JOptionPane.showMessageDialog( |
|
83 |
(Component) PluginServices.getMDIManager().getActiveWindow(), |
|
84 |
PluginServices.getText(this, "this_layer_is_not_self_editable"), |
|
85 |
PluginServices.getText(this, "warning_title"), |
|
86 |
JOptionPane.WARNING_MESSAGE); |
|
87 |
} |
|
88 |
|
|
89 |
lv.setEditing(true); |
|
90 |
// FeatureType featureType=lv.getFeatureStore().getDefaultFeatureType(); |
|
91 |
// featureType.getRules().clear(); |
|
92 |
// if (lv.getShapeType()==Geometry.TYPES.SURFACE){ |
|
93 |
// FeatureRule rulePol = new FeatureRulePolygon("PolygonRule", "Sentido correcto de un pol?gono"); |
|
94 |
// featureType.addRule(rulePol); |
|
95 |
// } |
|
96 |
|
|
97 |
// if (!(lv.getSource().getDriver() instanceof IndexedShpDriver)){ |
|
98 |
// VectorialLayerEdited vle=(VectorialLayerEdited)editionManager.getLayerEdited(lv); |
|
99 |
// vle.setLegend(legendOriginal); |
|
100 |
// } |
|
101 |
lv.getFeatureStore().addObserver(mapControl); |
|
102 |
// vea.getCommandRecord().addCommandListener(mapControl); |
|
103 |
// Si existe una tabla asociada a esta capa se cambia su |
|
104 |
// modelo por el VectorialEditableAdapter. |
|
105 |
ProjectExtension pe = (ProjectExtension) PluginServices |
|
106 |
.getExtension(ProjectExtension.class); |
|
107 |
|
|
108 |
startCommandsApplicable(vista,lv); |
|
109 |
vista.repaintMap(); |
|
110 |
|
|
111 |
} catch (StartEditionLayerException e) { |
|
112 |
NotificationManager.addError(e.getMessage(),e); |
|
113 |
// } catch (ReadException e) { |
|
114 |
// NotificationManager.addError(e.getMessage(),e); |
|
115 |
// } catch (DataException e) { |
|
116 |
// NotificationManager.addError(e.getMessage(),e); |
|
117 |
} |
|
118 |
|
|
119 |
// return; |
|
120 |
} |
|
121 |
} |
|
122 |
|
|
123 |
/* |
|
124 |
* PluginServices.getMDIManager().setWaitCursor(); try { if |
|
125 |
* (((FLyrVect) capa).getSource().getDriver().getClass() == |
|
126 |
* DXFCadDriver.class) { if (JOptionPane.showConfirmDialog( |
|
127 |
* (Component) PluginServices.getMainFrame(), "Todas las geometr?as |
|
128 |
* del formato DXF no se pueden editar, de momento podemos editar: |
|
129 |
* Line, Point, Polyline, Arc, Circle y Ellipse. \n El resto de |
|
130 |
* geometr?as se perder?n con la edici?n. \n ?Desea continuar?") == |
|
131 |
* JOptionPane.YES_OPTION) { capa.startEdition(); |
|
132 |
* vista.getMapControl().setCadTool("selection"); } else { } } else { |
|
133 |
* capa.startEdition(); |
|
134 |
* vista.getMapControl().setCadTool("selection"); } } catch |
|
135 |
* (EditionException e) { // TODO Auto-generated catch block |
|
136 |
* e.printStackTrace(); } |
|
137 |
* PluginServices.getMDIManager().restoreCursor(); |
|
138 |
*/ |
|
139 |
// vista.getMapControl().drawMap(false); |
|
140 |
} |
|
141 |
|
|
142 |
// private void registerKeyStrokes() { |
|
143 |
// JComponent theComponent = vista.getConsolePanel().getTxt(); |
|
144 |
// |
|
145 |
// // The actions |
|
146 |
// Action F3Action = new AbstractAction("REFENT") { |
|
147 |
// public void actionPerformed(ActionEvent evt) { |
|
148 |
// System.err.println("SOY F3"); |
|
149 |
// } |
|
150 |
// }; |
|
151 |
// |
|
152 |
// InputMap inputMap = theComponent.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW); |
|
153 |
// inputMap.put(KeyStroke.getKeyStroke(KeyEvent.VK_F3, 0), F3Action.getValue(Action.NAME)); |
|
154 |
// |
|
155 |
// ActionMap actionMap = theComponent.getActionMap(); |
|
156 |
// // actionMap.put("REFENT", new MyAction()); |
|
157 |
// actionMap.put(F3Action.getValue(Action.NAME), F3Action); |
|
158 |
// |
|
159 |
// } |
|
160 |
|
|
161 |
public static void startCommandsApplicable(DefaultViewPanel vista,FLyrVect lv) { |
|
162 |
if (vista==null) |
|
163 |
vista=(DefaultViewPanel)PluginServices.getMDIManager().getActiveWindow(); |
|
164 |
|
|
165 |
CADTool[] cadtools = CADExtension.getCADTools(); |
|
166 |
KeywordMap keywordMap = new KeywordMap(true); |
|
167 |
for (int i = 0; i < cadtools.length; i++) { |
|
168 |
try { |
|
169 |
if (cadtools[i].isApplicable(lv.getShapeType())){ |
|
170 |
keywordMap.add(cadtools[i].getName(), Token.KEYWORD2); |
|
171 |
keywordMap.add(cadtools[i].toString(), Token.KEYWORD3); |
|
172 |
} |
|
173 |
} catch (ReadException e) { |
|
174 |
NotificationManager.addError(e.getMessage(),e); |
|
175 |
} |
|
176 |
|
|
177 |
} |
|
178 |
ConsoleToken consoletoken = new ConsoleToken(keywordMap); |
|
179 |
vista.getConsolePanel().setTokenMarker(consoletoken); |
|
180 |
|
|
181 |
} |
|
182 |
|
|
183 |
// private void changeModelTable(ProjectTable pt, VectorialEditableAdapter vea){ |
|
184 |
// com.iver.andami.ui.mdiManager.IWindow[] views = PluginServices.getMDIManager().getAllWindows(); |
|
185 |
// |
|
186 |
// for (int i=0 ; i<views.length ; i++){ |
|
187 |
// if (views[i] instanceof Table){ |
|
188 |
// Table table=(Table)views[i]; |
|
189 |
// ProjectTable model =table.getModel(); |
|
190 |
// if (model.equals(pt)){ |
|
191 |
// table.setModel(pt); |
|
192 |
// vea.getCommandRecord().addCommandListener(table); |
|
193 |
// } |
|
194 |
// } |
|
195 |
// } |
|
196 |
// } |
|
197 |
/** |
|
198 |
* @see org.gvsig.andami.plugins.IExtension#isEnabled() |
|
199 |
*/ |
|
200 |
public boolean isEnabled() { |
|
201 |
return true; |
|
202 |
} |
|
203 |
|
|
204 |
/** |
|
205 |
* @see org.gvsig.andami.plugins.IExtension#isVisible() |
|
206 |
*/ |
|
207 |
public boolean isVisible() { |
|
208 |
org.gvsig.andami.ui.mdiManager.IWindow f = PluginServices.getMDIManager() |
|
209 |
.getActiveWindow(); |
|
210 |
|
|
211 |
if (f == null) { |
|
212 |
return false; |
|
213 |
} |
|
214 |
if (f instanceof DefaultViewPanel){ |
|
215 |
DefaultViewPanel view=(DefaultViewPanel)f; |
|
216 |
FLayer[] selected = view.getModel().getMapContext().getLayers() |
|
217 |
.getActives(); |
|
218 |
if (selected.length == 1 && selected[0].isAvailable() && selected[0] instanceof FLyrVect) { |
|
219 |
if (selected[0].isEditing()) |
|
220 |
return false; |
|
221 |
return true; |
|
222 |
} |
|
223 |
} |
|
224 |
return false; |
|
225 |
} |
|
226 |
} |
|
0 | 227 |
tags/v2_0_0_Build_2047/extensions/extEditing/extEditing/src/org/gvsig/editing/MatrixExtension.java | ||
---|---|---|
1 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
|
2 |
* |
|
3 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana. |
|
4 |
* |
|
5 |
* This program is free software; you can redistribute it and/or |
|
6 |
* modify it under the terms of the GNU General Public License |
|
7 |
* as published by the Free Software Foundation; either version 2 |
|
8 |
* of the License, or (at your option) any later version. |
|
9 |
* |
|
10 |
* This program is distributed in the hope that it will be useful, |
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
13 |
* GNU General Public License for more details. |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License |
|
16 |
* along with this program; if not, write to the Free Software |
|
17 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA. |
|
18 |
* |
|
19 |
* For more information, contact: |
|
20 |
* |
|
21 |
* Generalitat Valenciana |
|
22 |
* Conselleria d'Infraestructures i Transport |
|
23 |
* Av. Blasco Ib??ez, 50 |
|
24 |
* 46010 VALENCIA |
|
25 |
* SPAIN |
|
26 |
* |
|
27 |
* +34 963862235 |
|
28 |
* gvsig@gva.es |
|
29 |
* www.gvsig.gva.es |
|
30 |
* |
|
31 |
* or |
|
32 |
* |
|
33 |
* IVER T.I. S.A |
|
34 |
* Salamanca 50 |
|
35 |
* 46005 Valencia |
|
36 |
* Spain |
|
37 |
* |
|
38 |
* +34 963163400 |
|
39 |
* dac@iver.es |
|
40 |
*/ |
|
41 |
package org.gvsig.editing; |
|
42 |
|
|
43 |
import org.gvsig.andami.PluginServices; |
|
44 |
import org.gvsig.andami.messages.NotificationManager; |
|
45 |
import org.gvsig.andami.plugins.Extension; |
|
46 |
import org.gvsig.app.project.documents.view.gui.DefaultViewPanel; |
|
47 |
import org.gvsig.editing.gui.cad.tools.MatrixCADTool; |
|
48 |
import org.gvsig.fmap.dal.exception.ReadException; |
|
49 |
import org.gvsig.fmap.mapcontext.layers.vectorial.FLyrVect; |
|
50 |
import org.gvsig.fmap.mapcontrol.MapControl; |
|
51 |
|
|
52 |
|
|
53 |
/** |
|
54 |
* Extensi?n que gestiona la creaci?n de una matriz a partir de la geometr?a seleccionada. |
|
55 |
* |
|
56 |
* @author Vicente Caballero Navarro |
|
57 |
*/ |
|
58 |
public class MatrixExtension extends Extension { |
|
59 |
private DefaultViewPanel view; |
|
60 |
|
|
61 |
private MapControl mapControl; |
|
62 |
private MatrixCADTool matrixCADTool; |
|
63 |
|
|
64 |
/** |
|
65 |
* @see org.gvsig.andami.plugins.IExtension#initialize() |
|
66 |
*/ |
|
67 |
public void initialize() { |
|
68 |
registerIcons(); |
|
69 |
matrixCADTool=new MatrixCADTool(); |
|
70 |
CADExtension.addCADTool("_matrix",matrixCADTool); |
|
71 |
|
|
72 |
|
|
73 |
} |
|
74 |
|
|
75 |
private void registerIcons(){ |
|
76 |
PluginServices.getIconTheme().registerDefault( |
|
77 |
"edition-geometry-matrix", |
|
78 |
this.getClass().getClassLoader().getResource("images/Matriz.png") |
|
79 |
); |
|
80 |
PluginServices.getIconTheme().registerDefault( |
|
81 |
"edition-geometrymatrix-lagxy", |
|
82 |
this.getClass().getClassLoader().getResource("images/lagxy.png") |
|
83 |
); |
|
84 |
PluginServices.getIconTheme().registerDefault( |
|
85 |
"edition-geometrymatrix-addpoint", |
|
86 |
this.getClass().getClassLoader().getResource("images/addpoint.png") |
|
87 |
); |
|
88 |
} |
|
89 |
|
|
90 |
/** |
|
91 |
* @see org.gvsig.andami.plugins.IExtension#execute(java.lang.String) |
|
92 |
*/ |
|
93 |
public void execute(String s) { |
|
94 |
CADExtension.initFocus(); |
|
95 |
if (s.equals("_matrix")) { |
|
96 |
|
|
97 |
|
|
98 |
CADExtension.setCADTool(s,true); |
|
99 |
} |
|
100 |
CADExtension.getEditionManager().setMapControl(mapControl); |
|
101 |
CADExtension.getCADToolAdapter().configureMenu(); |
|
102 |
} |
|
103 |
|
|
104 |
/** |
|
105 |
* @see org.gvsig.andami.plugins.IExtension#isEnabled() |
|
106 |
*/ |
|
107 |
public boolean isEnabled() { |
|
108 |
|
|
109 |
try { |
|
110 |
if (EditionUtilities.getEditionStatus() == EditionUtilities.EDITION_STATUS_ONE_VECTORIAL_LAYER_ACTIVE_AND_EDITABLE) { |
|
111 |
view = (DefaultViewPanel) PluginServices.getMDIManager().getActiveWindow(); |
|
112 |
mapControl = view.getMapControl(); |
|
113 |
if (CADExtension.getEditionManager().getActiveLayerEdited()==null) |
|
114 |
return false; |
|
115 |
FLyrVect lv=(FLyrVect)CADExtension.getEditionManager().getActiveLayerEdited().getLayer(); |
|
116 |
if (matrixCADTool.isApplicable(lv.getShapeType())){ |
|
117 |
return true; |
|
118 |
} |
|
119 |
} |
|
120 |
} catch (ReadException e) { |
|
121 |
NotificationManager.addError(e.getMessage(),e); |
|
122 |
} |
|
123 |
return false; |
|
124 |
} |
|
125 |
|
|
126 |
/** |
|
127 |
* @see org.gvsig.andami.plugins.IExtension#isVisible() |
|
128 |
*/ |
|
129 |
public boolean isVisible() { |
|
130 |
if (EditionUtilities.getEditionStatus() == EditionUtilities.EDITION_STATUS_ONE_VECTORIAL_LAYER_ACTIVE_AND_EDITABLE) |
|
131 |
return true; |
|
132 |
return false; |
|
133 |
} |
|
134 |
} |
|
0 | 135 |
tags/v2_0_0_Build_2047/extensions/extEditing/extEditing/src/org/gvsig/editing/fmap/rendering/EditionManagerLegend.java | ||
---|---|---|
1 |
package org.gvsig.editing.fmap.rendering; |
|
2 |
|
|
3 |
import java.util.ArrayList; |
|
4 |
|
|
5 |
import org.gvsig.andami.PluginServices; |
|
6 |
import org.gvsig.fmap.geom.Geometry; |
|
7 |
import org.gvsig.fmap.mapcontext.rendering.legend.IClassifiedLegend; |
|
8 |
import org.gvsig.fmap.mapcontext.rendering.legend.IVectorLegend; |
|
9 |
import org.gvsig.fmap.mapcontext.rendering.legend.IVectorialUniqueValueLegend; |
|
10 |
import org.gvsig.fmap.mapcontext.rendering.symbols.ISymbol; |
|
11 |
|
|
12 |
public class EditionManagerLegend implements EditionLegend{ |
|
13 |
private ArrayList rules=new ArrayList(); |
|
14 |
private IVectorLegend vectorialLegend; |
|
15 |
private IVectorLegend originalVectorialLegend; |
|
16 |
private LegendControl lc = new LegendControl(Geometry.TYPES.GEOMETRY); |
|
17 |
|
|
18 |
public EditionManagerLegend(IVectorLegend vl) { |
|
19 |
originalVectorialLegend=vl; |
|
20 |
vectorialLegend=vl;//(VectorialLegend)vl.cloneLegend(); |
|
21 |
} |
|
22 |
public Object getValue(int i) { |
|
23 |
Object value=null; |
|
24 |
if (vectorialLegend instanceof IClassifiedLegend) { |
|
25 |
value = ((IClassifiedLegend) vectorialLegend).getValues()[i]; |
|
26 |
}else { |
|
27 |
value=new String(PluginServices.getText(this,"todos_los_valores")); |
|
28 |
} |
|
29 |
return value; |
|
30 |
} |
|
31 |
public ISymbol getSymbol(int i) { |
|
32 |
ISymbol symbol=null; |
|
33 |
symbol=((IVectorialUniqueValueLegend)vectorialLegend).getSymbolByValue(getValue(i)); |
|
34 |
return symbol; |
|
35 |
} |
|
36 |
public boolean isActived(int i) { |
|
37 |
return lc.isActivated(i); |
|
38 |
} |
|
39 |
public boolean isBlocked(int i) { |
|
40 |
return lc.isBlocked(i); |
|
41 |
} |
|
42 |
public boolean isDisable(int i) { |
|
43 |
return lc.isDisabled(i); |
|
44 |
} |
|
45 |
public boolean isFilled(int i) { |
|
46 |
return lc.isFilled(i); |
|
47 |
} |
|
48 |
public boolean isPresent(int i) { |
|
49 |
return (i==getPresent()); |
|
50 |
} |
|
51 |
private int getPresent() { |
|
52 |
return lc.getPresent(); |
|
53 |
} |
|
54 |
public void setActived(int i,boolean b) { |
|
55 |
lc.setActivated(i,b); |
|
56 |
} |
|
57 |
public void setBlocked(int i,boolean b) { |
|
58 |
lc.setBlocked(i,b); |
|
59 |
} |
|
60 |
public void setDisable(int i, boolean b) { |
|
61 |
lc.setDisabled(i,b); |
|
62 |
} |
|
63 |
public void setFilled(int i,boolean b) { |
|
64 |
lc.setFilled(i,b); |
|
65 |
} |
|
66 |
public void setPresent(int i) { |
|
67 |
lc.setPresent(i); |
|
68 |
} |
|
69 |
public int getRowCount() { |
|
70 |
if (vectorialLegend instanceof IClassifiedLegend) { |
|
71 |
IClassifiedLegend classifiedLegend = |
|
72 |
(IClassifiedLegend) vectorialLegend; |
|
73 |
return classifiedLegend.getValues().length; |
|
74 |
} |
|
75 |
return 1; |
|
76 |
} |
|
77 |
public void setValue(int i, Object value) { |
|
78 |
Object previousValue=getValue(i); |
|
79 |
ISymbol previousSymbol=getSymbol(i); |
|
80 |
Object clave; |
|
81 |
ISymbol theSymbol=null; |
|
82 |
int numRow=getRowCount(); |
|
83 |
// Borramos las anteriores listas: |
|
84 |
//((UniqueValueLegend)vectorialLegend).clear(); |
|
85 |
|
|
86 |
boolean bRestoValores = false; // PONERLO EN UN CHECKBOX |
|
87 |
int hasta; |
|
88 |
hasta = getRowCount(); |
|
89 |
// for (int row = 0; row < numRow; row++) { |
|
90 |
// clave = getValue(row); |
|
91 |
// if (row==i) |
|
92 |
if (!value.equals(previousValue)) { |
|
93 |
((IVectorialUniqueValueLegend)vectorialLegend).delSymbol(previousValue); |
|
94 |
clave=value; |
|
95 |
((IVectorialUniqueValueLegend)vectorialLegend).addSymbol(value, previousSymbol); |
|
96 |
System.out.println(value); |
|
97 |
// } |
|
98 |
} |
|
99 |
if (bRestoValores) { |
|
100 |
theSymbol = getSymbol(hasta); |
|
101 |
vectorialLegend.setDefaultSymbol(theSymbol); |
|
102 |
} |
|
103 |
} |
|
104 |
public void setSymbol(int row, Object value) { |
|
105 |
} |
|
106 |
public String getPresentSubLayer() { |
|
107 |
return getValue(getPresent()).toString(); |
|
108 |
} |
|
109 |
} |
|
0 | 110 |
tags/v2_0_0_Build_2047/extensions/extEditing/extEditing/src/org/gvsig/editing/fmap/rendering/EditionLegend.java | ||
---|---|---|
1 |
package org.gvsig.editing.fmap.rendering; |
|
2 |
|
|
3 |
public interface EditionLegend { |
|
4 |
|
|
5 |
} |
|
0 | 6 |
tags/v2_0_0_Build_2047/extensions/extEditing/extEditing/src/org/gvsig/editing/fmap/rendering/LegendControl.java | ||
---|---|---|
1 |
package org.gvsig.editing.fmap.rendering; |
|
2 |
|
|
3 |
import java.util.BitSet; |
|
4 |
|
|
5 |
import org.gvsig.symbology.fmap.mapcontext.rendering.legend.impl.VectorialUniqueValueLegend; |
|
6 |
|
|
7 |
public class LegendControl extends VectorialUniqueValueLegend{ |
|
8 |
|
|
9 |
private BitSet isBlocked=new BitSet(); |
|
10 |
private BitSet isActivated=new BitSet(); |
|
11 |
private BitSet isDisabled=new BitSet(); |
|
12 |
private BitSet isFilled=new BitSet(); |
|
13 |
private int present=0; |
|
14 |
|
|
15 |
public LegendControl(int shapeType) { |
|
16 |
super(shapeType); |
|
17 |
} |
|
18 |
public boolean isBlocked(int i) { |
|
19 |
return isBlocked.get(i); |
|
20 |
} |
|
21 |
public boolean isActivated(int i) { |
|
22 |
return isActivated.get(i); |
|
23 |
} |
|
24 |
public boolean isDisabled(int i) { |
|
25 |
return isDisabled.get(i); |
|
26 |
} |
|
27 |
public boolean isFilled(int i) { |
|
28 |
return isFilled.get(i); |
|
29 |
} |
|
30 |
public void setBlocked(int i,boolean b) { |
|
31 |
isBlocked.set(i,b); |
|
32 |
} |
|
33 |
public void setActivated(int i,boolean b) { |
|
34 |
isActivated.set(i,b); |
|
35 |
} |
|
36 |
public void setDisabled(int i,boolean b) { |
|
37 |
isDisabled.set(i,b); |
|
38 |
} |
|
39 |
public void setFilled(int i,boolean b) { |
|
40 |
isFilled.set(i,b); |
|
41 |
} |
|
42 |
public void setPresent(int i) { |
|
43 |
present=i; |
|
44 |
} |
|
45 |
public int getPresent() { |
|
46 |
return present; |
|
47 |
} |
|
48 |
} |
|
0 | 49 |
tags/v2_0_0_Build_2047/extensions/extEditing/extEditing/src/org/gvsig/editing/gui/graphictools/ToolSelectGraphic.java | ||
---|---|---|
1 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
|
2 |
* |
|
3 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana. |
|
4 |
* |
|
5 |
* This program is free software; you can redistribute it and/or |
|
6 |
* modify it under the terms of the GNU General Public License |
|
7 |
* as published by the Free Software Foundation; either version 2 |
|
8 |
* of the License, or (at your option) any later version. |
|
9 |
* |
|
10 |
* This program is distributed in the hope that it will be useful, |
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
13 |
* GNU General Public License for more details. |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License |
|
16 |
* along with this program; if not, write to the Free Software |
|
17 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA. |
|
18 |
* |
|
19 |
* For more information, contact: |
|
20 |
* |
|
21 |
* Generalitat Valenciana |
|
22 |
* Conselleria d'Infraestructures i Transport |
|
23 |
* Av. Blasco Ib??ez, 50 |
|
24 |
* 46010 VALENCIA |
|
25 |
* SPAIN |
|
26 |
* |
|
27 |
* +34 963862235 |
|
28 |
* gvsig@gva.es |
|
29 |
* www.gvsig.gva.es |
|
30 |
* |
|
31 |
* or |
|
32 |
* |
|
33 |
* IVER T.I. S.A |
|
34 |
* Salamanca 50 |
|
35 |
* 46005 Valencia |
|
36 |
* Spain |
|
37 |
* |
|
38 |
* +34 963163400 |
|
39 |
* dac@iver.es |
|
40 |
*/ |
|
41 |
package org.gvsig.editing.gui.graphictools; |
|
42 |
|
|
43 |
import java.awt.Image; |
|
44 |
import java.awt.geom.Point2D; |
|
45 |
import java.awt.geom.Rectangle2D; |
|
46 |
|
|
47 |
import org.gvsig.andami.PluginServices; |
|
48 |
//import org.gvsig.fmap.mapcontext.layers.FBitSet; |
|
49 |
import org.gvsig.fmap.mapcontext.layers.vectorial.GraphicLayer; |
|
50 |
import org.gvsig.fmap.mapcontrol.MapControl; |
|
51 |
import org.gvsig.fmap.mapcontrol.tools.BehaviorException; |
|
52 |
import org.gvsig.fmap.mapcontrol.tools.Events.PointEvent; |
|
53 |
import org.gvsig.fmap.mapcontrol.tools.Listeners.PointListener; |
|
54 |
|
|
55 |
|
|
56 |
|
|
57 |
/** |
|
58 |
* <p>Listener that selects the items of a {@link GraphicLayer GraphicLayer} that their area |
|
59 |
* intersects with the point selected on the associated <code>MapControl</code>.</p> |
|
60 |
* |
|
61 |
* <p>Listens a single click of any mouse's button.</p> |
|
62 |
*/ |
|
63 |
public class ToolSelectGraphic implements PointListener{ |
|
64 |
|
|
65 |
// private final Image img = new ImageIcon(MapControl.class.getResource( |
|
66 |
// "images/PointSelectCursor.gif")).getImage(); |
|
67 |
/** |
|
68 |
* The image to display when the cursor is active. |
|
69 |
*/ |
|
70 |
private final Image img = PluginServices.getIconTheme().get("rect-select-cursor").getImage(); |
|
71 |
|
|
72 |
/** |
|
73 |
* The cursor used to work with this tool listener. |
|
74 |
* |
|
75 |
* @see #getCursor() |
|
76 |
*/ |
|
77 |
// private Cursor cur = Toolkit.getDefaultToolkit().createCustomCursor(img, |
|
78 |
// new Point(16, 16), ""); |
|
79 |
|
|
80 |
/** |
|
81 |
* Reference to the <code>MapControl</code> object that uses. |
|
82 |
*/ |
|
83 |
protected MapControl mapCtrl; |
|
84 |
|
|
85 |
/** |
|
86 |
* <p>Creates a new <code>ToolSelectGraphic</code> object.</p> |
|
87 |
* |
|
88 |
* @param mc the <code>MapControl</code> where will be applied the changes |
|
89 |
*/ |
|
90 |
public ToolSelectGraphic(MapControl mc) { |
|
91 |
this.mapCtrl = mc; |
|
92 |
} |
|
93 |
|
|
94 |
/* |
|
95 |
* (non-Javadoc) |
|
96 |
* @see com.iver.cit.gvsig.fmap.tools.Listeners.PointListener#point(com.iver.cit.gvsig.fmap.tools.Events.PointEvent) |
|
97 |
*/ |
|
98 |
public void point(PointEvent event) throws BehaviorException { |
|
99 |
// Point2D p = event.getPoint(); |
|
100 |
// Point2D mapPoint = mapCtrl.getViewPort().toMapPoint((int) p.getX(), (int) p.getY()); |
|
101 |
// |
|
102 |
// // Tolerancia de 3 pixels |
|
103 |
// double tol = mapCtrl.getViewPort().toMapDistance(3); |
|
104 |
// GraphicLayer gLyr = mapCtrl.getMapContext().getGraphicsLayer(); |
|
105 |
// Rectangle2D recPoint = new Rectangle2D.Double(mapPoint.getX() - (tol / 2), |
|
106 |
// mapPoint.getY() - (tol / 2), tol, tol); |
|
107 |
// |
|
108 |
// FBitSet oldBitSet = gLyr.getSelection(); |
|
109 |
// |
|
110 |
// FBitSet newBitSet = gLyr.queryByRect(recPoint); |
|
111 |
// if (event.getEvent().isControlDown()) |
|
112 |
// newBitSet.xor(oldBitSet); |
|
113 |
// gLyr.setSelection(newBitSet); |
|
114 |
// |
|
115 |
// mapCtrl.drawGraphics(); |
|
116 |
} |
|
117 |
|
|
118 |
/* |
|
119 |
* (non-Javadoc) |
|
120 |
* @see com.iver.cit.gvsig.fmap.tools.Listeners.PointListener#pointDoubleClick(com.iver.cit.gvsig.fmap.tools.Events.PointEvent) |
|
121 |
*/ |
|
122 |
public void pointDoubleClick(PointEvent event) throws BehaviorException { |
|
123 |
// TODO Auto-generated method stub |
|
124 |
|
|
125 |
} |
|
126 |
|
|
127 |
/* |
|
128 |
* (non-Javadoc) |
|
129 |
* @see com.iver.cit.gvsig.fmap.tools.Listeners.ToolListener#getCursor() |
|
130 |
*/ |
|
131 |
public Image getImageCursor() { |
|
132 |
return img; |
|
133 |
} |
|
134 |
|
|
135 |
/* |
|
136 |
* (non-Javadoc) |
|
137 |
* @see com.iver.cit.gvsig.fmap.tools.Listeners.ToolListener#cancelDrawing() |
|
138 |
*/ |
|
139 |
public boolean cancelDrawing() { |
|
140 |
return false; |
|
141 |
} |
|
142 |
} |
|
143 |
|
|
144 |
|
|
0 | 145 |
tags/v2_0_0_Build_2047/extensions/extEditing/extEditing/src/org/gvsig/editing/gui/graphictools/VisitorSelectGraphicByPoint.java | ||
---|---|---|
1 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana |
|
2 |
* |
|
3 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana. |
|
4 |
* |
|
5 |
* This program is free software; you can redistribute it and/or |
|
6 |
* modify it under the terms of the GNU General Public License |
|
7 |
* as published by the Free Software Foundation; either version 2 |
|
8 |
* of the License, or (at your option) any later version. |
|
9 |
* |
|
10 |
* This program is distributed in the hope that it will be useful, |
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
13 |
* GNU General Public License for more details. |
|
14 |
* |
|
15 |
* You should have received a copy of the GNU General Public License |
|
16 |
* along with this program; if not, write to the Free Software |
|
17 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA. |
|
18 |
* |
|
19 |
* For more information, contact: |
|
20 |
* |
|
21 |
* Generalitat Valenciana |
|
22 |
* Conselleria d'Infraestructures i Transport |
|
23 |
* Av. Blasco Ib??ez, 50 |
|
24 |
* 46010 VALENCIA |
|
25 |
* SPAIN |
|
26 |
* |
|
27 |
* +34 963862235 |
|
28 |
* gvsig@gva.es |
|
29 |
* www.gvsig.gva.es |
|
30 |
* |
|
31 |
* or |
|
32 |
* |
|
33 |
* IVER T.I. S.A |
|
34 |
* Salamanca 50 |
|
35 |
* 46005 Valencia |
|
36 |
* Spain |
|
37 |
* |
|
38 |
* +34 963163400 |
|
39 |
* dac@iver.es |
|
40 |
*/ |
|
41 |
package org.gvsig.editing.gui.graphictools; |
|
42 |
|
|
43 |
import java.awt.geom.Point2D; |
|
44 |
import java.awt.geom.Rectangle2D; |
|
45 |
|
|
46 |
import org.gvsig.fmap.geom.Geometry; |
|
47 |
//import org.gvsig.fmap.mapcontext.layers.FBitSet; |
|
48 |
|
|
49 |
import com.vividsolutions.jts.index.ItemVisitor; |
|
50 |
|
|
51 |
/** |
|
52 |
* @author fjp |
|
53 |
* |
|
54 |
* @deprecated Use queryByRect |
|
55 |
*/ |
|
56 |
public class VisitorSelectGraphicByPoint implements ItemVisitor{ |
|
57 |
|
|
58 |
private Point2D mapPoint; |
|
59 |
private double tol; |
|
60 |
// private FBitSet selection = new FBitSet(); |
|
61 |
private int numReg; |
|
62 |
Rectangle2D recPoint; |
|
63 |
|
|
64 |
public VisitorSelectGraphicByPoint(Point2D mapPoint, double tolerance) |
|
65 |
{ |
|
66 |
this.mapPoint = mapPoint; |
|
67 |
this.tol = tolerance; |
|
68 |
this.numReg = 0; |
|
69 |
|
|
70 |
recPoint = new Rectangle2D.Double(mapPoint.getX() - (tolerance / 2), |
|
71 |
mapPoint.getY() - (tolerance / 2), tolerance, tolerance); |
|
72 |
|
|
73 |
} |
|
74 |
|
|
75 |
/* (non-Javadoc) |
|
76 |
* @see com.vividsolutions.jts.index.ItemVisitor#visitItem(java.lang.Object) |
|
77 |
* TODO: VENDRIA BIEN SABER EL NUMERO DE REGISTRO PARA PODER MARCARLO COMO SELECCIONADO |
|
78 |
*/ |
|
79 |
public void visitItem(Object item) { |
|
80 |
// FGraphic graf = (FGraphic) item; |
|
81 |
// Geometry geom = graf.getGeom(); |
|
82 |
// if (geom.intersects(recPoint)) |
|
83 |
// { |
|
84 |
// selection.set(numReg); |
|
85 |
// } |
|
86 |
// numReg++; |
|
87 |
|
|
88 |
} |
|
89 |
|
|
90 |
// public FBitSet getSelection() { |
|
91 |
// return selection; |
|
92 |
// } |
|
93 |
|
|
94 |
} |
|
95 |
|
|
96 |
|
|
0 | 97 |
Also available in: Unified diff