Revision 783
trunk/applications/appgvSIG/src/com/iver/cit/gvsig/gui/toolListeners/InfoListener.java | ||
---|---|---|
20 | 20 |
|
21 | 21 |
import com.hardcode.gdbms.engine.data.DataSource; |
22 | 22 |
import com.iver.andami.PluginServices; |
23 |
import com.iver.andami.messages.NotificationManager; |
|
23 | 24 |
import com.iver.cit.gvsig.fmap.DriverException; |
24 | 25 |
import com.iver.cit.gvsig.fmap.NewMapControl; |
25 | 26 |
import com.iver.cit.gvsig.fmap.drivers.DriverIOException; |
... | ... | |
28 | 29 |
import com.iver.cit.gvsig.fmap.layers.layerOperations.VectorialData; |
29 | 30 |
import com.iver.cit.gvsig.fmap.operations.QueriedPoint; |
30 | 31 |
import com.iver.cit.gvsig.fmap.operations.strategies.QueryByPointVisitor; |
32 |
import com.iver.cit.gvsig.fmap.tools.BehaviorException; |
|
31 | 33 |
import com.iver.cit.gvsig.fmap.tools.Events.PointEvent; |
32 | 34 |
import com.iver.cit.gvsig.fmap.tools.Listeners.PointListener; |
33 | 35 |
import com.iver.cit.gvsig.gui.Dialogs.FInfoDialogXML; |
... | ... | |
69 | 71 |
* |
70 | 72 |
* @see com.iver.cit.gvsig.fmap.tools.Listeners.PointListener#point(com.iver.cit.gvsig.fmap.tools.Events.PointEvent) |
71 | 73 |
*/ |
72 |
public void point(PointEvent event) throws DriverException {
|
|
74 |
public void point(PointEvent event) throws BehaviorException {
|
|
73 | 75 |
Point2D pReal = mapCtrl.getMapContext().getViewPort().toMapPoint(event.getPoint()); |
74 | 76 |
|
75 | 77 |
// Dentro de queryByPoint tenemos que separar los registros que vienen asociados a una |
... | ... | |
98 | 100 |
visitor.setQueriedPoint(new QueriedPoint( |
99 | 101 |
pReal.getX(), pReal.getY())); |
100 | 102 |
visitor.setTolerance(mapCtrl.getMapContext().getViewPort().toMapDistance(3)); |
101 |
((VectorialData) laCapa).process(visitor); |
|
103 |
try { |
|
104 |
((VectorialData) laCapa).process(visitor); |
|
105 |
} catch (DriverException e) { |
|
106 |
throw new BehaviorException("No se pudo procesar la capa", e); |
|
107 |
} |
|
102 | 108 |
bitset[i] = visitor.getBitSet(); |
103 | 109 |
layers[i] = laCapa; |
104 | 110 |
} |
... | ... | |
106 | 112 |
|
107 | 113 |
if (bitset != null) { |
108 | 114 |
try { |
115 |
if (PluginServices.getMainFrame() == null) |
|
116 |
{ |
|
117 |
JDialog dialog = new JDialog(); |
|
118 |
dlgXML.setPreferredSize(dlgXML.getSize()); |
|
119 |
dialog.getContentPane().add(dlgXML); |
|
120 |
dialog.setModal(false); |
|
121 |
dialog.pack(); |
|
122 |
dialog.show(); |
|
123 |
|
|
124 |
} |
|
125 |
else |
|
126 |
dlgXML = (FInfoDialogXML) PluginServices.getMDIManager().addView(dlgXML); |
|
127 |
|
|
109 | 128 |
dlgXML.setModel(new XMLContent() { |
110 |
private ContentHandler handler;
|
|
129 |
private ContentHandler handler; |
|
111 | 130 |
|
112 |
public void setContentHandler(ContentHandler arg0) {
|
|
113 |
handler = arg0;
|
|
114 |
}
|
|
131 |
public void setContentHandler(ContentHandler arg0) { |
|
132 |
handler = arg0; |
|
133 |
} |
|
115 | 134 |
|
116 |
public void parse() throws SAXException {
|
|
117 |
handler.startDocument();
|
|
135 |
public void parse() throws SAXException { |
|
136 |
handler.startDocument(); |
|
118 | 137 |
|
119 |
for (int i = 0; i < bitset.length; i++) {
|
|
120 |
AttributesImpl aii = new AttributesImpl();
|
|
121 |
handler.startElement("", "",
|
|
122 |
((FLayer) layers[i]).getName(), aii);
|
|
138 |
for (int i = 0; i < bitset.length; i++) { |
|
139 |
AttributesImpl aii = new AttributesImpl(); |
|
140 |
handler.startElement("", "", |
|
141 |
((FLayer) layers[i]).getName(), aii); |
|
123 | 142 |
|
124 |
try {
|
|
125 |
DataSource ds = ((AlphanumericData) layers[i]).getRecordset();
|
|
126 |
ds.start();
|
|
143 |
try { |
|
144 |
DataSource ds = ((AlphanumericData) layers[i]).getRecordset(); |
|
145 |
ds.start(); |
|
127 | 146 |
|
128 |
for (int j = bitset[i].nextSetBit(0);
|
|
129 |
j >= 0;
|
|
130 |
j = bitset[i].nextSetBit(j + 1)) {
|
|
131 |
// for (int j = 0; j < bitset[i].length();
|
|
132 |
// j++) {
|
|
133 |
//if (bitset[i].get(j)) {
|
|
134 |
AttributesImpl ai = new AttributesImpl();
|
|
147 |
for (int j = bitset[i].nextSetBit(0); |
|
148 |
j >= 0; |
|
149 |
j = bitset[i].nextSetBit(j + 1)) { |
|
150 |
// for (int j = 0; j < bitset[i].length(); |
|
151 |
// j++) { |
|
152 |
//if (bitset[i].get(j)) { |
|
153 |
AttributesImpl ai = new AttributesImpl(); |
|
135 | 154 |
|
136 |
for (int k = 0; k < ds.getFieldCount();
|
|
137 |
k++) {
|
|
138 |
ai.addAttribute("",
|
|
139 |
ds.getFieldName(k), "",
|
|
140 |
"xs:string",
|
|
141 |
ds.getFieldValue(j, k).toString());
|
|
142 |
}
|
|
155 |
for (int k = 0; k < ds.getFieldCount(); |
|
156 |
k++) { |
|
157 |
ai.addAttribute("", |
|
158 |
ds.getFieldName(k), "", |
|
159 |
"xs:string", |
|
160 |
ds.getFieldValue(j, k).toString()); |
|
161 |
} |
|
143 | 162 |
|
144 |
handler.startElement("", "",
|
|
145 |
String.valueOf(j), ai);
|
|
163 |
handler.startElement("", "", |
|
164 |
String.valueOf(j), ai); |
|
146 | 165 |
|
147 |
handler.endElement("", "",
|
|
148 |
String.valueOf(j));
|
|
166 |
handler.endElement("", "", |
|
167 |
String.valueOf(j)); |
|
149 | 168 |
|
150 |
} |
|
151 |
|
|
152 |
logger.debug("ds.stop()"); |
|
153 |
ds.stop(); |
|
154 |
} catch (com.hardcode.gdbms.engine.data.DriverException e) { |
|
155 |
throw new SAXException(e); |
|
156 |
} catch (DriverException e) { |
|
157 |
throw new SAXException(e); |
|
158 | 169 |
} |
159 | 170 |
|
160 |
handler.endElement("", "", |
|
161 |
((FLayer) layers[i]).getName()); |
|
171 |
logger.debug("ds.stop()"); |
|
172 |
ds.stop(); |
|
173 |
} catch (com.hardcode.gdbms.engine.data.DriverException e) { |
|
174 |
throw new SAXException(e); |
|
175 |
} catch (DriverException e) { |
|
176 |
throw new SAXException(e); |
|
162 | 177 |
} |
163 | 178 |
|
164 |
handler.endDocument(); |
|
179 |
handler.endElement("", "", |
|
180 |
((FLayer) layers[i]).getName()); |
|
165 | 181 |
} |
166 |
}); |
|
182 |
|
|
183 |
handler.endDocument(); |
|
184 |
} |
|
185 |
}); |
|
186 |
dlgXML.getXmlTree().setRootVisible(false); |
|
187 |
DefaultTreeModel treeModel = (DefaultTreeModel) dlgXML.getXmlTree().getModel(); |
|
188 |
DefaultMutableTreeNode n; |
|
189 |
DefaultMutableTreeNode root = (DefaultMutableTreeNode) dlgXML.getXmlTree().getModel().getRoot(); |
|
190 |
n = root.getFirstLeaf(); |
|
191 |
TreePath path = new TreePath(treeModel.getPathToRoot(n)); |
|
192 |
dlgXML.getXmlTree().expandPath(path); |
|
193 |
|
|
194 |
dlgXML.getXmlTree().setSelectionPath(path); |
|
195 |
|
|
167 | 196 |
} catch (SAXException e) { |
168 |
e.printStackTrace();
|
|
197 |
NotificationManager.addError("Error formateando los resultados", e);
|
|
169 | 198 |
} |
170 | 199 |
} |
171 | 200 |
|
172 |
/* if (algunNoWMS) { |
|
173 |
dlg = (FInfoDialog) App.instance.getMDIContext().addView(dlg); |
|
174 |
} |
|
175 |
if (algunWMS) { |
|
176 |
try { |
|
177 |
dlgXML.setModel(xmlModel); |
|
178 |
dlgXML = (FInfoDialogXML) App.instance.getMDIContext().addView(dlgXML); |
|
179 |
} catch (SAXException e) { |
|
180 |
if (App.instance != null) { |
|
181 |
App.instance.getNm().addError("No se reconoce el formato", e); |
|
182 |
} else { |
|
183 |
} |
|
184 |
} |
|
185 |
}*/ |
|
186 |
dlgXML.getXmlTree().setRootVisible(false); |
|
187 |
DefaultTreeModel treeModel = (DefaultTreeModel) dlgXML.getXmlTree().getModel(); |
|
188 |
DefaultMutableTreeNode n; |
|
189 |
DefaultMutableTreeNode root = (DefaultMutableTreeNode) dlgXML.getXmlTree().getModel().getRoot(); |
|
190 |
n = root.getFirstLeaf(); |
|
191 |
TreePath path = new TreePath(treeModel.getPathToRoot(n)); |
|
192 |
dlgXML.getXmlTree().expandPath(path); |
|
193 |
|
|
194 |
|
|
195 |
if (PluginServices.getMainFrame() == null) |
|
196 |
{ |
|
197 |
JDialog dialog = new JDialog(); |
|
198 |
dlgXML.setPreferredSize(dlgXML.getSize()); |
|
199 |
dialog.getContentPane().add(dlgXML); |
|
200 |
dialog.setModal(false); |
|
201 |
dialog.pack(); |
|
202 |
dialog.show(); |
|
203 |
|
|
204 |
} |
|
205 |
else |
|
206 |
dlgXML = (FInfoDialogXML) PluginServices.getMDIManager().addView(dlgXML); |
|
207 |
|
|
208 |
dlgXML.getXmlTree().setSelectionPath(path); |
|
209 | 201 |
} |
210 | 202 |
|
211 | 203 |
/** |
Also available in: Unified diff