Revision 11613 branches/v10/extensions/extAnnotations/src/com/iver/cit/gvsig/Annotation_Extension.java
Annotation_Extension.java | ||
---|---|---|
59 | 59 |
import com.iver.cit.gvsig.project.documents.gui.Annotation_Open; |
60 | 60 |
import com.iver.cit.gvsig.project.documents.view.IProjectView; |
61 | 61 |
import com.iver.cit.gvsig.project.documents.view.toc.AbstractTocContextMenuAction; |
62 |
import com.iver.cit.gvsig.project.documents.view.toc.actions.FLyrVectEditPropertiesTocMenuEntry; |
|
63 | 62 |
import com.iver.cit.gvsig.project.documents.view.toc.gui.FLyrVectEditPropertiesTocMenuEntry2; |
64 | 63 |
import com.iver.utiles.extensionPoints.ExtensionPoint; |
65 | 64 |
import com.iver.utiles.extensionPoints.ExtensionPoints; |
66 | 65 |
import com.iver.utiles.extensionPoints.ExtensionPointsSingleton; |
67 | 66 |
|
68 |
|
|
69 | 67 |
/** |
70 | 68 |
* Extension to create an annotation layer. |
71 |
* |
|
69 |
*
|
|
72 | 70 |
* @author Vicente Caballero Navarro |
73 | 71 |
*/ |
74 | 72 |
public class Annotation_Extension extends Extension { |
75 |
private MapContext map = null;
|
|
73 |
private MapContext map = null;
|
|
76 | 74 |
|
77 |
/** |
|
78 |
* @see com.iver.andami.plugins.IExtension#initialize() |
|
79 |
*/ |
|
80 |
public void initialize() { |
|
81 |
ExtensionPoints extensionPoints = ExtensionPointsSingleton.getInstance(); |
|
75 |
/** |
|
76 |
* @see com.iver.andami.plugins.IExtension#initialize() |
|
77 |
*/ |
|
78 |
public void initialize() { |
|
79 |
ExtensionPoints extensionPoints = ExtensionPointsSingleton |
|
80 |
.getInstance(); |
|
82 | 81 |
|
83 |
AbstractTocContextMenuAction ma=(AbstractTocContextMenuAction)((ExtensionPoint) extensionPoints.get("View_TocActions")).get("FLyrVectEditProperties"); |
|
84 |
((ExtensionPoint) extensionPoints.get("View_TocActions")).remove("FLyrVectEditProperties"); |
|
85 |
((ExtensionPoint) extensionPoints.get("View_TocActions")).put("FLyrVectEditProperties",new FLyrVectEditPropertiesTocMenuEntry2(ma)); |
|
86 |
//extensionPoints.add("View_TocActions","FLyrVectEditProperties2",new FLyrVectEditPropertiesTocMenuEntry2()); |
|
87 |
System.out.println("A?ado WizardAnnotation."); |
|
88 |
AddLayer.addWizard(Annotation_Open.class); |
|
89 |
} |
|
82 |
AbstractTocContextMenuAction ma = (AbstractTocContextMenuAction) ((ExtensionPoint) extensionPoints |
|
83 |
.get("View_TocActions")).get("FLyrVectEditProperties"); |
|
84 |
((ExtensionPoint) extensionPoints.get("View_TocActions")) |
|
85 |
.remove("FLyrVectEditProperties"); |
|
86 |
((ExtensionPoint) extensionPoints.get("View_TocActions")).put( |
|
87 |
"FLyrVectEditProperties", |
|
88 |
new FLyrVectEditPropertiesTocMenuEntry2(ma)); |
|
89 |
// extensionPoints.add("View_TocActions","FLyrVectEditProperties2",new |
|
90 |
// FLyrVectEditPropertiesTocMenuEntry2()); |
|
91 |
System.out.println("A?ado WizardAnnotation."); |
|
92 |
AddLayer.addWizard(Annotation_Open.class); |
|
93 |
} |
|
90 | 94 |
|
91 |
public void postInitialize() {
|
|
95 |
public void postInitialize() {
|
|
92 | 96 |
// TODO Auto-generated method stub |
93 | 97 |
super.postInitialize(); |
94 |
About about=(About)PluginServices.getExtension(About.class);
|
|
95 |
FPanelAbout panelAbout=about.getAboutPanel();
|
|
96 |
java.net.URL aboutURL = this.getClass().getResource( |
|
97 |
"/about.htm");
|
|
98 |
panelAbout.addAboutUrl(PluginServices.getText(this,"annotations"),aboutURL);
|
|
98 |
About about = (About) PluginServices.getExtension(About.class);
|
|
99 |
FPanelAbout panelAbout = about.getAboutPanel();
|
|
100 |
java.net.URL aboutURL = this.getClass().getResource("/about.htm");
|
|
101 |
panelAbout.addAboutUrl(PluginServices.getText(this, "annotations"),
|
|
102 |
aboutURL);
|
|
99 | 103 |
|
100 | 104 |
} |
101 | 105 |
|
102 | 106 |
/** |
103 |
* @see com.iver.andami.plugins.IExtension#execute(java.lang.String)
|
|
104 |
*/
|
|
105 |
public void execute(String actionCommand) {
|
|
106 |
if ("ANNOTATIONLAYER".equals(actionCommand)) {
|
|
107 |
ImageIcon Logo = new javax.swing.ImageIcon(this.getClass()
|
|
108 |
.getClassLoader()
|
|
109 |
.getResource("images/package_graphics.png"));
|
|
107 |
* @see com.iver.andami.plugins.IExtension#execute(java.lang.String)
|
|
108 |
*/
|
|
109 |
public void execute(String actionCommand) {
|
|
110 |
if ("ANNOTATIONLAYER".equals(actionCommand)) {
|
|
111 |
ImageIcon Logo = new javax.swing.ImageIcon(this.getClass()
|
|
112 |
.getClassLoader()
|
|
113 |
.getResource("images/package_graphics.png"));
|
|
110 | 114 |
|
111 |
SimpleWizard wizard = new SimpleWizard(Logo);
|
|
115 |
SimpleWizard wizard = new SimpleWizard(Logo);
|
|
112 | 116 |
|
113 |
FLyrVect lv = (FLyrVect) map.getLayers().getActives()[0];
|
|
114 |
Annotation_Layer la = new Annotation_Layer();
|
|
115 |
la.setSource(lv.getSource());
|
|
116 |
la.setProjection(lv.getProjection());
|
|
117 |
la.setName(lv.getName());
|
|
117 |
FLyrVect lv = (FLyrVect) map.getLayers().getActives()[0];
|
|
118 |
Annotation_Layer la = new Annotation_Layer();
|
|
119 |
la.setSource(lv.getSource());
|
|
120 |
la.setProjection(lv.getProjection());
|
|
121 |
la.setName(lv.getName());
|
|
118 | 122 |
|
119 |
Annotation_FieldSelect panel1 = new Annotation_FieldSelect(wizard.getWizardComponents(),
|
|
120 |
la);
|
|
121 |
Annotation_ConfigureLabel panel2 = new Annotation_ConfigureLabel(wizard.getWizardComponents(),
|
|
122 |
la);
|
|
123 |
Annotation_FieldSelect panel1 = new Annotation_FieldSelect(wizard
|
|
124 |
.getWizardComponents(), la);
|
|
125 |
Annotation_ConfigureLabel panel2 = new Annotation_ConfigureLabel(
|
|
126 |
wizard.getWizardComponents(), la);
|
|
123 | 127 |
|
124 |
wizard.getWizardComponents().addWizardPanel(panel1);
|
|
125 |
wizard.getWizardComponents().addWizardPanel(panel2);
|
|
128 |
wizard.getWizardComponents().addWizardPanel(panel1);
|
|
129 |
wizard.getWizardComponents().addWizardPanel(panel2);
|
|
126 | 130 |
|
127 |
wizard.getWizardComponents().setFinishAction(new Annotation_Create( |
|
128 |
wizard.getWizardComponents(), map, la)); |
|
131 |
wizard.getWizardComponents() |
|
132 |
.setFinishAction( |
|
133 |
new Annotation_Create(wizard.getWizardComponents(), |
|
134 |
map, la)); |
|
129 | 135 |
|
130 |
wizard.getWindowInfo().setWidth(540);
|
|
131 |
wizard.getWindowInfo().setHeight(380);
|
|
132 |
wizard.getWindowInfo().setTitle(PluginServices.getText(this,
|
|
133 |
"to_annotation"));
|
|
136 |
wizard.getWindowInfo().setWidth(540);
|
|
137 |
wizard.getWindowInfo().setHeight(380);
|
|
138 |
wizard.getWindowInfo().setTitle(
|
|
139 |
PluginServices.getText(this, "to_annotation"));
|
|
134 | 140 |
|
135 |
PluginServices.getMDIManager().addWindow(wizard);
|
|
141 |
PluginServices.getMDIManager().addWindow(wizard);
|
|
136 | 142 |
|
137 |
/* |
|
138 |
FLyrVect lv=(FLyrVect)map.getLayers().getActives()[0]; |
|
139 |
FLyrAnnotation la=new FLyrAnnotation(); |
|
140 |
la.setSource(lv.getSource()); |
|
143 |
/* |
|
144 |
* FLyrVect lv=(FLyrVect)map.getLayers().getActives()[0]; |
|
145 |
* FLyrAnnotation la=new FLyrAnnotation(); |
|
146 |
* la.setSource(lv.getSource()); |
|
147 |
* |
|
148 |
* MappingFieldsToAnotation mfta=new MappingFieldsToAnotation(la); |
|
149 |
* PluginServices.getMDIManager().addView(mfta); |
|
150 |
* |
|
151 |
* if (mfta.isOk()){ map.getLayers().addLayer(la); |
|
152 |
* map.getLayers().removeLayer(lv); } |
|
153 |
*/ |
|
154 |
} |
|
155 |
} |
|
141 | 156 |
|
142 |
MappingFieldsToAnotation mfta=new MappingFieldsToAnotation(la); |
|
143 |
PluginServices.getMDIManager().addView(mfta); |
|
157 |
/** |
|
158 |
* @see com.iver.andami.plugins.IExtension#isEnabled() |
|
159 |
*/ |
|
160 |
public boolean isEnabled() { |
|
161 |
IWindow v = PluginServices.getMDIManager().getActiveWindow(); |
|
144 | 162 |
|
145 |
if (mfta.isOk()){ |
|
146 |
map.getLayers().addLayer(la); |
|
147 |
map.getLayers().removeLayer(lv); |
|
148 |
} |
|
149 |
*/ |
|
150 |
} |
|
151 |
} |
|
163 |
if ((v != null) |
|
164 |
&& v instanceof com.iver.cit.gvsig.project.documents.view.gui.View) { |
|
165 |
com.iver.cit.gvsig.project.documents.view.gui.View vista = (com.iver.cit.gvsig.project.documents.view.gui.View) v; |
|
166 |
IProjectView model = vista.getModel(); |
|
167 |
map = model.getMapContext(); |
|
152 | 168 |
|
153 |
/** |
|
154 |
* @see com.iver.andami.plugins.IExtension#isEnabled() |
|
155 |
*/ |
|
156 |
public boolean isEnabled() { |
|
157 |
IWindow v = PluginServices.getMDIManager().getActiveWindow(); |
|
169 |
FLayer[] layers = map.getLayers().getActives(); |
|
158 | 170 |
|
159 |
if ((v != null) && |
|
160 |
v instanceof com.iver.cit.gvsig.project.documents.view.gui.View) { |
|
161 |
com.iver.cit.gvsig.project.documents.view.gui.View vista = (com.iver.cit.gvsig.project.documents.view.gui.View) v; |
|
162 |
IProjectView model = vista.getModel(); |
|
163 |
map = model.getMapContext(); |
|
171 |
if (layers.length == 1) { |
|
172 |
if (layers[0].isAvailable() && layers[0] instanceof FLyrVect) { |
|
173 |
FLyrVect lv = (FLyrVect) layers[0]; |
|
164 | 174 |
|
165 |
FLayer[] layers = map.getLayers().getActives(); |
|
175 |
// ReadableVectorial src = lv.getSource(); |
|
176 |
try { |
|
177 |
// if (src == null || src.getShapeType()==FShape.POLYGON |
|
178 |
// || src.getShapeType()==FShape.LINE) |
|
179 |
// return false; |
|
180 |
SelectableDataSource sds = lv.getSource() |
|
181 |
.getRecordset(); |
|
166 | 182 |
|
167 |
if (layers.length == 1) { |
|
168 |
if (layers[0].isAvailable() && layers[0] instanceof FLyrVect) { |
|
169 |
FLyrVect lv = (FLyrVect) layers[0]; |
|
183 |
if (sds.getFieldCount() > 0) { |
|
184 |
return true; |
|
185 |
} |
|
186 |
} catch (DriverException e) { |
|
187 |
return false; |
|
188 |
} |
|
189 |
} |
|
190 |
} |
|
191 |
} |
|
170 | 192 |
|
171 |
// ReadableVectorial src = lv.getSource(); |
|
172 |
try { |
|
173 |
// if (src == null || src.getShapeType()==FShape.POLYGON || src.getShapeType()==FShape.LINE) |
|
174 |
// return false; |
|
175 |
SelectableDataSource sds = lv.getSource().getRecordset(); |
|
193 |
return false; |
|
194 |
} |
|
176 | 195 |
|
177 |
if (sds.getFieldCount() > 0) { |
|
178 |
return true; |
|
179 |
} |
|
180 |
} catch (DriverException e) { |
|
181 |
return false; |
|
182 |
} |
|
183 |
} |
|
184 |
} |
|
185 |
} |
|
196 |
/** |
|
197 |
* @see com.iver.andami.plugins.IExtension#isVisible() |
|
198 |
*/ |
|
199 |
public boolean isVisible() { |
|
200 |
IWindow v = PluginServices.getMDIManager().getActiveWindow(); |
|
186 | 201 |
|
187 |
return false; |
|
188 |
} |
|
189 |
|
|
190 |
/** |
|
191 |
* @see com.iver.andami.plugins.IExtension#isVisible() |
|
192 |
*/ |
|
193 |
public boolean isVisible() { |
|
194 |
IWindow v = PluginServices.getMDIManager().getActiveWindow(); |
|
195 |
|
|
196 |
if (v == null) { |
|
197 |
return false; |
|
198 |
} else if (v instanceof com.iver.cit.gvsig.project.documents.view.gui.View) { |
|
199 |
return true; |
|
200 |
} else { |
|
201 |
return false; |
|
202 |
} |
|
203 |
} |
|
202 |
if (v == null) { |
|
203 |
return false; |
|
204 |
} else if (v instanceof com.iver.cit.gvsig.project.documents.view.gui.View) { |
|
205 |
return true; |
|
206 |
} else { |
|
207 |
return false; |
|
208 |
} |
|
209 |
} |
|
204 | 210 |
} |
Also available in: Unified diff