svn-gvsig-desktop / branches / gvSIG_GisPlanet / applications / appgvSIG / src / com / iver / cit / gvsig / Tabla.java @ 2174
History | View | Annotate | Download (4.21 KB)
1 |
/*
|
---|---|
2 |
* Created on 02-mar-2004
|
3 |
*
|
4 |
* To change the template for this generated file go to
|
5 |
* Window>Preferences>Java>Code Generation>Code and Comments
|
6 |
*/
|
7 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
|
8 |
*
|
9 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
|
10 |
*
|
11 |
* This program is free software; you can redistribute it and/or
|
12 |
* modify it under the terms of the GNU General Public License
|
13 |
* as published by the Free Software Foundation; either version 2
|
14 |
* of the License, or (at your option) any later version.
|
15 |
*
|
16 |
* This program is distributed in the hope that it will be useful,
|
17 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
18 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
19 |
* GNU General Public License for more details.
|
20 |
*
|
21 |
* You should have received a copy of the GNU General Public License
|
22 |
* along with this program; if not, write to the Free Software
|
23 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA.
|
24 |
*
|
25 |
* For more information, contact:
|
26 |
*
|
27 |
* Generalitat Valenciana
|
28 |
* Conselleria d'Infraestructures i Transport
|
29 |
* Av. Blasco Ib??ez, 50
|
30 |
* 46010 VALENCIA
|
31 |
* SPAIN
|
32 |
*
|
33 |
* +34 963862235
|
34 |
* gvsig@gva.es
|
35 |
* www.gvsig.gva.es
|
36 |
*
|
37 |
* or
|
38 |
*
|
39 |
* IVER T.I. S.A
|
40 |
* Salamanca 50
|
41 |
* 46005 Valencia
|
42 |
* Spain
|
43 |
*
|
44 |
* +34 963163400
|
45 |
* dac@iver.es
|
46 |
*/
|
47 |
package com.iver.cit.gvsig; |
48 |
|
49 |
import com.iver.andami.PluginServices; |
50 |
import com.iver.andami.messages.NotificationManager; |
51 |
import com.iver.andami.plugins.Extension; |
52 |
|
53 |
import com.iver.cit.gvsig.fmap.DriverException; |
54 |
import com.iver.cit.gvsig.fmap.layers.FLayer; |
55 |
import com.iver.cit.gvsig.fmap.layers.SelectableDataSource; |
56 |
import com.iver.cit.gvsig.fmap.layers.layerOperations.AlphanumericData; |
57 |
import com.iver.cit.gvsig.gui.Table; |
58 |
import com.iver.cit.gvsig.gui.View; |
59 |
import com.iver.cit.gvsig.project.ProjectFactory; |
60 |
import com.iver.cit.gvsig.project.ProjectTable; |
61 |
|
62 |
|
63 |
/**
|
64 |
* Extensi?n que abre las tablas asociadas a las vistas.
|
65 |
*
|
66 |
* @author Vicente Caballero Navarro
|
67 |
*/
|
68 |
public class Tabla implements Extension { |
69 |
/**
|
70 |
* @see com.iver.andami.plugins.Extension#isEnabled()
|
71 |
*/
|
72 |
public boolean isEnabled() { |
73 |
View f = (View) PluginServices.getMDIManager().getActiveView(); |
74 |
|
75 |
if (f == null) { |
76 |
return false; |
77 |
} |
78 |
|
79 |
FLayer[] selected = f.getModel().getMapContext().getLayers().getActives();
|
80 |
|
81 |
boolean algunaTabla = false; |
82 |
|
83 |
for (int i = 0; i < selected.length; i++) { |
84 |
if (selected[i] instanceof AlphanumericData) { |
85 |
AlphanumericData co = (AlphanumericData) selected[i]; |
86 |
|
87 |
try {
|
88 |
if (co.getRecordset() != null) { |
89 |
algunaTabla = true;
|
90 |
} |
91 |
} catch (DriverException e) {
|
92 |
} |
93 |
} |
94 |
} |
95 |
|
96 |
return algunaTabla;
|
97 |
} |
98 |
|
99 |
/**
|
100 |
* @see com.iver.andami.plugins.Extension#isVisible()
|
101 |
*/
|
102 |
public boolean isVisible() { |
103 |
com.iver.andami.ui.mdiManager.View f = PluginServices.getMDIManager() |
104 |
.getActiveView(); |
105 |
|
106 |
if (f == null) { |
107 |
return false; |
108 |
} |
109 |
|
110 |
return (f.getClass() == View.class); |
111 |
} |
112 |
|
113 |
/**
|
114 |
* @see com.iver.mdiApp.plugins.Extension#updateUI(java.lang.String)
|
115 |
*/
|
116 |
public void execute(String s) { |
117 |
View vista = (View) PluginServices.getMDIManager().getActiveView(); |
118 |
FLayer[] actives = ((View) vista).getModel().getMapContext().getLayers() |
119 |
.getActives(); |
120 |
|
121 |
try {
|
122 |
for (int i = 0; i < actives.length; i++) { |
123 |
if (actives[i] instanceof AlphanumericData) { |
124 |
AlphanumericData co = (AlphanumericData) actives[i]; |
125 |
|
126 |
SelectableDataSource dataSource; |
127 |
dataSource = co.getRecordset(); |
128 |
|
129 |
ProjectExtension ext = (ProjectExtension) PluginServices.getExtension(ProjectExtension.class); |
130 |
|
131 |
ProjectTable projectTable = ext.getProject().getTable(co); |
132 |
|
133 |
if (projectTable == null) { |
134 |
projectTable = ProjectFactory.createTable(PluginServices.getText(this, "Tabla de Atributos") + ": " + actives[i].getName(), |
135 |
dataSource); |
136 |
projectTable.setAssociatedTable(co); |
137 |
ext.getProject().addTable(projectTable); |
138 |
} |
139 |
|
140 |
Table t = new Table();
|
141 |
t.setModel(projectTable); |
142 |
PluginServices.getMDIManager().addView(t); |
143 |
} |
144 |
} |
145 |
} catch (DriverException e) {
|
146 |
NotificationManager.addError("No se pudo obtener la tabla del tema", e);
|
147 |
} |
148 |
} |
149 |
|
150 |
/**
|
151 |
* @see com.iver.andami.plugins.Extension#inicializar()
|
152 |
*/
|
153 |
public void inicializar() { |
154 |
} |
155 |
} |