root / branches / v10 / extensions / extPublish / src / com / iver / cit / gvsig / publish / PublishExtension.java @ 13570
History | View | Annotate | Download (7.5 KB)
1 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
|
---|---|
2 |
*
|
3 |
* Copyright (C) 2004-2006 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 Iba?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 |
/**
|
42 |
* @author Jos? Vicente Hig?n (josevicente.higon@iver.es)
|
43 |
*/
|
44 |
package com.iver.cit.gvsig.publish; |
45 |
|
46 |
import java.util.Iterator; |
47 |
import java.util.Set; |
48 |
|
49 |
import com.hardcode.gdbms.engine.data.driver.DriverException; |
50 |
import com.iver.andami.PluginServices; |
51 |
import com.iver.andami.plugins.Extension; |
52 |
import com.iver.cit.gvsig.fmap.MapControl; |
53 |
import com.iver.cit.gvsig.fmap.drivers.FieldDescription; |
54 |
import com.iver.cit.gvsig.fmap.drivers.ITableDefinition; |
55 |
import com.iver.cit.gvsig.fmap.drivers.shp.IndexedShpDriver; |
56 |
import com.iver.cit.gvsig.fmap.layers.FLayer; |
57 |
import com.iver.cit.gvsig.fmap.layers.FLayers; |
58 |
import com.iver.cit.gvsig.fmap.layers.FLyrVect; |
59 |
import com.iver.cit.gvsig.fmap.rendering.Legend; |
60 |
import com.iver.cit.gvsig.fmap.rendering.SingleSymbolLegend; |
61 |
import com.iver.cit.gvsig.fmap.rendering.VectorialLegend; |
62 |
import com.iver.cit.gvsig.fmap.rendering.VectorialUniqueValueLegend; |
63 |
import com.iver.cit.gvsig.project.documents.view.IProjectView; |
64 |
import com.iver.cit.gvsig.project.documents.view.ProjectView; |
65 |
import com.iver.cit.gvsig.project.documents.view.gui.View; |
66 |
import com.iver.cit.gvsig.publish.gui.control.MainController; |
67 |
import com.iver.cit.gvsig.publish.infoProject.IViewInfo; |
68 |
import com.iver.cit.gvsig.publish.infoProject.InfoFactory; |
69 |
import com.iver.cit.gvsig.publish.serversModel.PublishException; |
70 |
import com.iver.cit.gvsig.publish.serversModel.Server; |
71 |
import com.iver.utiles.extensionPoints.ExtensionPoint; |
72 |
import com.iver.utiles.extensionPoints.ExtensionPoints; |
73 |
import com.iver.utiles.extensionPoints.ExtensionPointsSingleton; |
74 |
|
75 |
public class PublishExtension extends Extension { |
76 |
/**
|
77 |
* Execution of the application
|
78 |
*/
|
79 |
public void execute(String actionCommand) { |
80 |
// TODO Auto-generated method stub
|
81 |
/* System.err.println("aiba!");
|
82 |
View view = (View) PluginServices.getMDIManager().getActiveWindow();
|
83 |
MapControl mapControl = (MapControl) view.getMapControl();
|
84 |
FLayers layers = (FLayers) mapControl.getMapContext().getLayers();
|
85 |
FLayer layer = layers.getLayer(0);
|
86 |
System.err.println("Layer name: " + layer.getName());
|
87 |
FLyrVect lvect = (FLyrVect)layer;
|
88 |
System.err.println(lvect.getTransparency());
|
89 |
|
90 |
FieldDescription[] fields=null;
|
91 |
try {
|
92 |
fields = lvect.getRecordset().getFieldsDescription();
|
93 |
} catch (DriverException e) {
|
94 |
// TODO Auto-generated catch block
|
95 |
e.printStackTrace();
|
96 |
} catch (com.iver.cit.gvsig.fmap.DriverException e) {
|
97 |
// TODO Auto-generated catch block
|
98 |
e.printStackTrace();
|
99 |
}
|
100 |
for (int i = 0; i< fields.length ; i++){
|
101 |
System.err.println(fields[i].getFieldAlias());
|
102 |
System.err.println(fields[i].getFieldDecimalCount());
|
103 |
System.err.println(fields[i].getFieldLength());
|
104 |
System.err.println(FieldDescription.typeToString(fields[i].getFieldType()));
|
105 |
}*/
|
106 |
|
107 |
/* DA UN PETE DE NULL
|
108 |
IndexedShpDriver driver = (IndexedShpDriver) lvect.getSource().getDriver();
|
109 |
ITableDefinition def = driver.getTableDefinition();
|
110 |
FieldDescription[] fields = def.getFieldsDesc();
|
111 |
for (int i = 0; i< fields.length ; i++){
|
112 |
System.err.println(fields[i].getFieldAlias());
|
113 |
System.err.println(fields[i].getFieldDecimalCount());
|
114 |
System.err.println(fields[i].getFieldLength());
|
115 |
System.err.println(fields[i].getFieldType());
|
116 |
}*/
|
117 |
//LEYENDAS
|
118 |
/*Legend legend = lvect.getLegend();
|
119 |
|
120 |
//SingleSymbolLegend
|
121 |
if (legend instanceof SingleSymbolLegend){
|
122 |
SingleSymbolLegend l = (SingleSymbolLegend) legend;
|
123 |
System.err.println(l.getLabelField());
|
124 |
System.err.println(l.getLabelHeightField());
|
125 |
System.err.println(l.getLabelRotationField());
|
126 |
System.err.println(l.getShapeType());
|
127 |
//defaultsymbol
|
128 |
System.err.println(l.getDefaultSymbol().getDescription());
|
129 |
System.err.println(l.getDefaultSymbol().getSymbolType());
|
130 |
|
131 |
}
|
132 |
//VectorialUniqueValueLegend
|
133 |
if (legend instanceof VectorialUniqueValueLegend){
|
134 |
VectorialUniqueValueLegend l = (VectorialUniqueValueLegend) legend;
|
135 |
System.err.println(l.getLabelField());
|
136 |
|
137 |
}
|
138 |
|
139 |
//VectorialLegend vectlegend = (VectorialLegend) legend;
|
140 |
//String[] fields = vectlegend.getUsedFields();
|
141 |
//for (int i = 0; i < fields.length; i++){
|
142 |
// System.err.println(fields[i]);
|
143 |
//}
|
144 |
*/
|
145 |
|
146 |
//GUI
|
147 |
|
148 |
MainController ctrl = new MainController();
|
149 |
//gets active view
|
150 |
View view = (View) PluginServices.getMDIManager().getActiveWindow(); |
151 |
//TODO: I must check the cast
|
152 |
ProjectView kk = (ProjectView) view.getModel(); |
153 |
IViewInfo infoView = InfoFactory.getViewInfo(kk); |
154 |
//set information to the controller
|
155 |
ctrl.setViewInfo(infoView); |
156 |
ctrl.start(); |
157 |
|
158 |
|
159 |
/*
|
160 |
Set set = Server.register.getServerNames();
|
161 |
|
162 |
//veo los nombre de servidores
|
163 |
Iterator i = set.iterator();
|
164 |
while (i.hasNext()){
|
165 |
System.out.println("Server brand ===== " + i.next());
|
166 |
}
|
167 |
|
168 |
*/
|
169 |
|
170 |
//Comprobando los puntos de extension
|
171 |
/*
|
172 |
ExtensionPoints extensionPoints = ExtensionPointsSingleton.getInstance();
|
173 |
ExtensionPoint extensionPoint = (ExtensionPoint)extensionPoints.get(Server.PUBLISH_SERVERS);
|
174 |
Set set = extensionPoint.keySet();
|
175 |
|
176 |
//veo los nombre de servidores
|
177 |
Iterator i = set.iterator();
|
178 |
while (i.hasNext()){
|
179 |
System.out.println("Server brand = " + i.next());
|
180 |
}
|
181 |
*/
|
182 |
/*
|
183 |
Server s = null;
|
184 |
try {
|
185 |
s = (Server) extensionPoint.create("Mapserver");
|
186 |
} catch (InstantiationException e) {
|
187 |
// TODO Auto-generated catch block
|
188 |
e.printStackTrace();
|
189 |
} catch (IllegalAccessException e) {
|
190 |
// TODO Auto-generated catch block
|
191 |
e.printStackTrace();
|
192 |
}
|
193 |
try {
|
194 |
s.publish();
|
195 |
} catch (PublishException e) {
|
196 |
// TODO Auto-generated catch block
|
197 |
e.printStackTrace();
|
198 |
}
|
199 |
*/
|
200 |
} |
201 |
/**
|
202 |
* Creates a point extension ???
|
203 |
*/
|
204 |
public void initialize() { |
205 |
|
206 |
} |
207 |
/**
|
208 |
* Returns if the extension is enabled
|
209 |
*/
|
210 |
public boolean isEnabled() { |
211 |
return true; |
212 |
} |
213 |
/**
|
214 |
* Only is visible when a view is selected
|
215 |
*/
|
216 |
public boolean isVisible() { |
217 |
com.iver.andami.ui.mdiManager.IWindow f = PluginServices.getMDIManager().getActiveWindow(); |
218 |
if (f == null) { |
219 |
return false; |
220 |
} |
221 |
return (f instanceof View); |
222 |
|
223 |
} |
224 |
|
225 |
} |