Statistics
| Revision:

svn-gvsig-desktop / tags / v2_0_0_Build_2058 / extensions / extEditing / sm / SelectionCADTool.sm @ 41849

History | View | Annotate | Download (4.55 KB)

1 3828 caballero
// -*- tab-width: 4; -*-
2
3
%{
4
//
5
// Vicente Caballero Navarro
6
%}
7
8 3978 caballero
%start Selection::FirstPoint
9 3828 caballero
%class SelectionCADTool
10
%package com.iver.cit.gvsig.gui.cad.tools.smc
11
%import com.iver.cit.gvsig.gui.cad.tools.SelectionCADTool
12 4324 caballero
%import java.awt.event.InputEvent
13 4583 caballero
%import com.iver.andami.PluginServices
14 3828 caballero
15 4324 caballero
16 3978 caballero
%map Selection
17 3828 caballero
%%
18
// A task begins life in suspended animation.
19
20 3978 caballero
FirstPoint
21 3828 caballero
22 4708 caballero
  Entry {
23 4892 caballero
    setQuestion(
24 5207 caballero
    PluginServices.getText(this,"insert_point_selection"));
25
    setDescription(new String[]{"cancel"});
26 4708 caballero
    }
27
  Exit{
28
    }
29 3828 caballero
30 4708 caballero
  {
31
32
    addPoint( pointX:double,pointY:double,event:InputEvent)
33
      [ctxt.getType().equals(PluginServices.getText(this,"simple")) && ctxt.selectFeatures(pointX,pointY, event) && ctxt.getNextState().equals("Selection.SecondPoint")]
34
      SecondPoint{
35 5207 caballero
        setQuestion(PluginServices.getText(this,"insert_second_point"));
36
        setDescription(new String[]{"cancel"});
37 4708 caballero
        addPoint( pointX,pointY,event);
38
        }
39
    addPoint( pointX:double,pointY:double,event:InputEvent)
40
      [ctxt.getType().equals(PluginServices.getText(this,"simple")) && ctxt.getNextState().equals("Selection.WithSelectedFeatures")]
41
      WithSelectedFeatures {
42
        setQuestion(PluginServices.getText(this,"select_handlers"));
43 5207 caballero
        setDescription(new String[]{"cancel"});
44 4708 caballero
        addPoint( pointX,pointY,event);
45
        end();
46
        }
47 3828 caballero
}
48
49 3978 caballero
SecondPoint{
50 4708 caballero
  // Si hemos conseguido seleccionar algo
51
  addPoint( pointX:double,pointY:double,event:InputEvent)
52
      [ctxt.selectWithSecondPoint(pointX,pointY, event) > 0]
53
      WithSelectedFeatures {
54
        setQuestion(PluginServices.getText(this,"select_handlers"));
55 5207 caballero
        setDescription(new String[]{"cancel"});
56 4708 caballero
        addPoint( pointX,pointY,event);
57
        end();
58
        }
59
  // Si no lo hemos conseguido
60
  addPoint( pointX:double,pointY:double,event:InputEvent)
61
      FirstPoint {
62 5207 caballero
        setQuestion(PluginServices.getText(this,"insert_point_selection"));
63
        setDescription(new String[]{"cancel"});
64 4708 caballero
        addPoint(pointX,pointY,event);
65
        }
66
  addOption(s:String)
67
      FirstPoint{
68 5207 caballero
        setQuestion(PluginServices.getText(this,"insert_point_selection"));
69
        setDescription(new String[]{"cancel"});
70 4708 caballero
        setType(s);
71
        }
72 4448 fjp
73
}
74
WithSelectedFeatures{
75
76 4708 caballero
  // Si hemos pinchado encima de un handler
77
  addPoint( pointX:double,pointY:double,event:InputEvent)
78
  [ctxt.selectHandlers(pointX, pointY, event)>0]
79
      WithHandlers {
80
        setQuestion(PluginServices.getText(this,"insert_destination_point"));
81 5207 caballero
        setDescription(new String[]{"cancel"});
82 4708 caballero
        addPoint( pointX,pointY,event);
83
        // refresh();
84
        }
85 4448 fjp
86 4708 caballero
  // Si no hemos cogido un handler, probamos a seleccionar
87
  // otra entidad
88
  addPoint( pointX:double,pointY:double,event:InputEvent)
89
    [ctxt.selectFeatures(pointX,pointY, event) && ctxt.getNextState().equals("Selection.WithSelectedFeatures")]
90
      WithSelectedFeatures {
91
        setQuestion(PluginServices.getText(this,"select_handlers"));
92 5207 caballero
        setDescription(new String[]{"cancel"});
93 4708 caballero
        addPoint( pointX,pointY,event);
94
        }
95 3844 caballero
96
97 4708 caballero
  // Cualquier otro caso (hemos pinchado en algo vacio), volvemos al estado inicial
98
  addPoint( pointX:double,pointY:double,event:InputEvent)
99
      FirstPoint {
100 5207 caballero
        setQuestion(PluginServices.getText(this,"insert_point_selection"));
101
        setDescription(new String[]{"cancel"});
102 4708 caballero
        addPoint( pointX,pointY,event);
103
        // refresh();
104
        }
105
	 addOption(s:String)
106
      FirstPoint{
107 5207 caballero
        setQuestion(PluginServices.getText(this,"insert_point_selection"));
108
        setDescription(new String[]{"cancel"});
109 4708 caballero
        setType(s);
110
        }
111 3828 caballero
}
112 3978 caballero
113 4445 fjp
WithHandlers{
114 4708 caballero
  addPoint( pointX:double,pointY:double,event:InputEvent)
115
      WithSelectedFeatures {
116
        setQuestion(PluginServices.getText(this,"select_handlers"));
117 5207 caballero
        setDescription(new String[]{"cancel"});
118 4708 caballero
        addPoint( pointX,pointY,event);
119
        refresh();
120
        }
121 4445 fjp
}
122
123 3828 caballero
Default
124
{
125 9052 caballero
	addOption(s:String)
126
      [s.equals("")]
127
      FirstPoint{
128
        restorePreviousTool();
129
        setQuestion(PluginServices.getText(this,"insert_point_selection"));
130
        setDescription(new String[]{"cancel"});
131
        end();
132
        }
133 4708 caballero
  addOption(s:String)
134
    [s.equals(PluginServices.getText(this,"cancel"))]
135
    FirstPoint{
136
      end();
137
      }
138 5730 caballero
    addOption(s:String)
139
		FirstPoint{
140
			throwOptionException(PluginServices.getText(this,"incorrect_option"),s);
141
			}
142
	addValue(d:double)
143
		FirstPoint{
144
			throwValueException(PluginServices.getText(this,"incorrect_value"),d);
145
			}
146
	addPoint(pointX:double,pointY:double,event:InputEvent)
147
		FirstPoint{
148
			throwPointException(PluginServices.getText(this,"incorrect_point"),pointX,pointY);
149
			}
150 3828 caballero
}
151
%%