Revision 25

View differences:

org.gvsig.vectorediting/trunk/org.gvsig.vectorediting/org.gvsig.vectorediting.lib/org.gvsig.vectorediting.lib.api/src/main/java/org/gvsig/vectorediting/lib/api/EditingServiceParameter.java
46 46
   * @return
47 47
   */
48 48
  public boolean equals(EditingServiceParameter param);
49
  
50
  /**
51
   * 
52
   * @return
53
   */
54
  public String getConsoleMessage();
49 55

  
50 56
}
org.gvsig.vectorediting/trunk/org.gvsig.vectorediting/org.gvsig.vectorediting.lib/org.gvsig.vectorediting.lib.spi/src/main/java/org/gvsig/vectorediting/lib/spi/DefaultEditingServiceParameter.java
15 15
  private String description;
16 16

  
17 17
  private int type;
18
  
19
  private String consoleMessage;
18 20

  
19
  public DefaultEditingServiceParameter(String name, String desciption, int type) {
21
  public DefaultEditingServiceParameter(String name, String desciption, int type, String consoleMessage) {
20 22
    this.name = name;
21 23
    this.description = desciption;
22 24
    this.type = type; //TODO Check type
25
    this.consoleMessage = consoleMessage;
23 26
  }
24 27

  
25 28
  public int getType() {
26
    // TODO Auto-generated method stub
27 29
    return type;
28 30
  }
29 31

  
30 32
  public String getName() {
31
    // TODO Auto-generated method stub
32 33
    return name;
33 34
  }
34 35

  
35 36
  public String getDescription() {
36
    // TODO Auto-generated method stub
37 37
    return description;
38 38
  }
39 39

  
......
42 42
    return false;
43 43
  }
44 44

  
45
  public String getConsoleMessage() {
46
    return this.consoleMessage;
47
  }
48

  
45 49
}
org.gvsig.vectorediting/trunk/org.gvsig.vectorediting/org.gvsig.vectorediting.lib/org.gvsig.vectorediting.lib.impl/src/main/java/org/gvsig/vectorediting/lib/impl/DefaultEditingManager.java
117 117
      mapControl.addBehavior("VectorEditing", vectorEditing);
118 118
    }
119 119

  
120
    view.addConsoleListener("cad", new ResponseListener() {
121
      public void acceptResponse(String response) {
122
        System.out.println(response);
123
      }
124
    });
125
    
126 120
    mapControl.setTool("VectorEditing");
127 121
  }
128 122
}
org.gvsig.vectorediting/trunk/org.gvsig.vectorediting/org.gvsig.vectorediting.lib/org.gvsig.vectorediting.lib.impl/src/main/java/org/gvsig/vectorediting/lib/impl/DefaultEditingBehavior.java
13 13
import java.awt.geom.Point2D;
14 14
import java.awt.image.BufferedImage;
15 15

  
16
import org.gvsig.andami.PluginServices;
17
import org.gvsig.app.project.documents.view.gui.DefaultViewPanel;
16 18
import org.gvsig.fmap.mapcontext.MapContext;
17 19
import org.gvsig.fmap.mapcontext.ViewPort;
18 20
import org.gvsig.fmap.mapcontext.layers.CancelationException;
......
28 30
import org.gvsig.fmap.mapcontrol.tools.BehaviorException;
29 31
import org.gvsig.fmap.mapcontrol.tools.Behavior.Behavior;
30 32
import org.gvsig.fmap.mapcontrol.tools.Listeners.ToolListener;
33
import org.gvsig.utils.console.JConsole;
34
import org.gvsig.utils.console.ResponseListener;
31 35
import org.gvsig.vectorediting.lib.api.EditingBehavior;
32 36
import org.gvsig.vectorediting.lib.api.EditingLocator;
33 37
import org.gvsig.vectorediting.lib.api.EditingManager;
34 38
import org.gvsig.vectorediting.lib.api.EditingService;
35 39
import org.gvsig.vectorediting.lib.api.EditingServiceParameter;
36
import org.opengis.spatialschema.geometry.primitive.Point;
37 40

  
38 41
public class DefaultEditingBehavior extends Behavior implements EditingBehavior {
39 42

  
......
66 69
      this.mapControl = mapControl;
67 70
      initMapControlListeners(mapControl);
68 71
      FLayers layers = mapControl.getMapContext().getLayers();
69
      for(int i=0; i< layers.getLayersCount(); i++){
70
        if(layers.getLayer(i) instanceof FLyrVect)
71
        setCurrentLayer((FLyrVect)layers.getLayer(i));
72
      for (int i = 0; i < layers.getLayersCount(); i++) {
73
        if (layers.getLayer(i) instanceof FLyrVect)
74
          setCurrentLayer((FLyrVect) layers.getLayer(i));
72 75
      }
73
      
76

  
74 77
    }
75 78
  }
76 79

  
......
92 95
    }
93 96
  };
94 97

  
95
  private Point2D mapAdjustedPoint;
98
  private void initMapControlListeners(MapControl mapControl) {
99
    DefaultViewPanel view = getActiveView();
100
    view.addConsoleListener("VectorEditingConsole", new ResponseListener() {
96 101

  
97
  private void initMapControlListeners(MapControl mapControl) {
102
      public void acceptResponse(String response) {
103
        textEntered(response);
104
      }
105
    });
98 106
    MapContext context = mapControl.getMapContext();
99 107
    FLayers layers = context.getLayers();
100 108
    layers.addLayerListener(layerListener);
......
138 146
    });
139 147
  }
140 148

  
149
  private void textEntered(String response) {
150
    int type = currentParam.getType();
151
    DefaultViewPanel view = getActiveView();
152
    switch (type) {
153
      case EditingServiceParameter.TYPE_POINT:
154
        try {
155
          String[] numbers = new String[1];
156
          numbers[0] = response;
157
          numbers = response.split(",");
158
          if (numbers.length == 2) {
159
            if(numbers[0].startsWith("(") && numbers[1].endsWith(")\n")){ //CCS format
160
              numbers[0] = numbers[0].replace("(", "");
161
              numbers[1] = numbers[1].replace(")\n", "");
162
            }
163
            double[] values = new double[] { Double.parseDouble(numbers[0]),
164
                Double.parseDouble(numbers[1]) };
165
            Point2D point = new Point2D.Double(values[0], values[1]);
166
            this.activatedTool.setValueParameter(currentParam, point);
167

  
168
          }
169
          else {
170
            view.getConsolePanel().addText("?Datos inv?lidos!", JConsole.ERROR);
171
          }
172
        }
173
        catch (Exception e) {
174
          view.getConsolePanel().addText("?Datos inv?lidos!", JConsole.ERROR);
175
        }
176

  
177
      case EditingServiceParameter.TYPE_LIST_POINTS:
178
      case EditingServiceParameter.TYPE_OPTION:
179
      case EditingServiceParameter.TYPE_SELECTION:
180
      case EditingServiceParameter.TYPE_GEOMETRY:
181
      case EditingServiceParameter.TYPE_VALUE:
182
    }
183
    getNextParameter();
184
  }
185

  
141 186
  public void setCurrentLayer(FLyrVect layer) {
142 187
    this.currentLayer = layer;
143 188
  }
......
166 211
      activatedTool.start();
167 212
      getNextParameter();
168 213
    }
214
    else {
215
      askQuestion(currentParam);
216

  
217
    }
218

  
169 219
  }
170 220

  
221
  private void askQuestion(EditingServiceParameter param) {
222
    DefaultViewPanel viewActive = getActiveView();
223
    if (viewActive != null) {
224
      viewActive.getConsolePanel().addText(
225
          "\n" + "#" + param.getConsoleMessage() + " > ", JConsole.MESSAGE);
226
    }
227
  }
228

  
229
  private DefaultViewPanel getActiveView() {
230
    org.gvsig.andami.ui.mdiManager.IWindow activeWindow = PluginServices
231
        .getMDIManager().getActiveWindow();
232

  
233
    if (activeWindow instanceof DefaultViewPanel) {
234
      return (DefaultViewPanel) activeWindow;
235
    }
236
    return null;
237
  }
238

  
171 239
  @Override
172 240
  public ToolListener getListener() {
173 241
    return new ToolListener() {
org.gvsig.vectorediting/trunk/org.gvsig.vectorediting/org.gvsig.vectorediting.lib/org.gvsig.vectorediting.lib.prov/org.gvsig.vectorediting.lib.prov.insertpoint/src/main/java/org/gvsig/vectorediting/lib/prov/insertpoint/InsertPointEditingProvider.java
31 31
  private final static String PROVIDER_DESCRIPTION = "Inserts points on the view";
32 32

  
33 33
  private EditingServiceParameter point = new DefaultEditingServiceParameter(
34
      PROVIDER_NAME, PROVIDER_DESCRIPTION, EditingServiceParameter.TYPE_POINT);
34
      PROVIDER_NAME, PROVIDER_DESCRIPTION, EditingServiceParameter.TYPE_POINT, "Inserte un punto");
35 35

  
36 36
  private Map<EditingServiceParameter, Object> values;
37 37

  
org.gvsig.vectorediting/trunk/org.gvsig.vectorediting/org.gvsig.vectorediting.app/org.gvsig.vectorediting.app.mainplugin/src/main/resources-plugin/config.xml
1 1
<?xml version="1.0" encoding="ISO-8859-1"?>
2
<!--
2
<!-- gvSIG. Desktop Geographic Information System. Copyright (C) 2007-2013 
3
	gvSIG Association. This program is free software; you can redistribute it 
4
	and/or modify it under the terms of the GNU General Public License as published 
5
	by the Free Software Foundation; either version 3 of the License, or (at 
6
	your option) any later version. This program is distributed in the hope that 
7
	it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty 
8
	of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General 
9
	Public License for more details. You should have received a copy of the GNU 
10
	General Public License along with this program; if not, write to the Free 
11
	Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 
12
	USA. For any additional information, do not hesitate to contact us at info 
13
	AT gvsig.com, or visit our website www.gvsig.com. -->
14
<plugin-config>
15
	<depends plugin-name="org.gvsig.app.mainplugin" />
16
	<resourceBundle name="text" />
17
	<libraries library-dir="lib" />
18
	<extensions>
19
		<extension
20
			class-name="org.gvsig.vectorediting.app.mainplugin.extensions.EditingExtension"
21
			description="" active="true" priority="1">
3 22

  
4
    gvSIG. Desktop Geographic Information System.
23
			<action name="VectorEditing" label="Start_edit" tooltip="Strat_edit"
24
				action-command="start_edit" icon="vector-editing" position="302001000"
25
				accelerator="" />
5 26

  
6
    Copyright (C) 2007-2013 gvSIG Association.
27
			<menu text="tools/start_edit/start_edit" name="start_edit" />
7 28

  
8
    This program is free software; you can redistribute it and/or
9
    modify it under the terms of the GNU General Public License
10
    as published by the Free Software Foundation; either version 3
11
    of the License, or (at your option) any later version.
29
			<tool-bar name="Vector editing" position="1">
30
				<action-tool name="VectorEditing" />
31
			</tool-bar>
12 32

  
13
    This program is distributed in the hope that it will be useful,
14
    but WITHOUT ANY WARRANTY; without even the implied warranty of
15
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
    GNU General Public License for more details.
33
		</extension>
34
		<extension
35
			class-name="org.gvsig.vectorediting.app.mainplugin.extensions.InsertPointExtension"
36
			description="" active="true" priority="1">
17 37

  
18
    You should have received a copy of the GNU General Public License
19
    along with this program; if not, write to the Free Software
20
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
21
    MA  02110-1301, USA.
38
			<action name="InsertPoint" label="Insert_point" tooltip="insert_point"
39
				action-command="insert_point" icon="layer-insert-point" position="302001000"
40
				accelerator="" />
22 41

  
23
    For any additional information, do not hesitate to contact us
24
    at info AT gvsig.com, or visit our website www.gvsig.com.
25
-->
26
<plugin-config>
27
	<depends plugin-name="org.gvsig.app.mainplugin" />
28
	<resourceBundle name="text"/>
29
	<libraries library-dir="lib"/>
30
	<extensions>
31
		<extension class-name="org.gvsig.vectorediting.app.mainplugin.extensions.EditingExtension"
32
			description=""
33
			active="true"
34
			priority="1">
35
			
36
		    <action 
37
		        name= "VectorEditing"
38
		        label="Start_edit"
39
		        tooltip="Strat_edit"
40
		        action-command="start_edit" 
41
		        icon="vector-editing"
42
		        position="302001000"
43
		        accelerator=""
44
		    />
45
        
46
			<menu 
47
				text="tools/start_edit/start_edit"
48
				name="start_edit"
49
			/>
50
			
51
			<tool-bar name="Vector editing" position="1">
52
		        <action-tool name="VectorEditing"/>
53
      		</tool-bar>
54
      		
55
		</extension>
56
		<extension class-name="org.gvsig.vectorediting.app.mainplugin.extensions.InsertPointExtension"
57
			description=""
58
			active="true"
59
			priority="1">
60
			
61
		    <action 
62
		        name= "InsertPoint"
63
		        label="Insert_point"
64
		        tooltip="insert_point"
65
		        action-command="insert_point" 
66
		        icon="layer-insert-point"
67
		        position="302001000"
68
		        accelerator=""
69
		    />
70
        
71
			<menu 
72
				text="tools/insert_point"
73
				name="insert_point"
74
			/>
75
			
42
			<menu text="tools/insert_point" name="insert_point" />
43

  
76 44
			<tool-bar name="Insert Point" position="1">
77
		        <action-tool name="InsertPoint"/>
78
      		</tool-bar>
79
      		
45
				<selectable-tool name="InsertPoint" />
46
			</tool-bar>
47

  
80 48
		</extension>
81
				
49

  
82 50
	</extensions>
83
	
51

  
84 52
</plugin-config>

Also available in: Unified diff