Revision 36923
tags/v2_0_0_Build_2038/extensions/org.gvsig.app.document.table.app/buildNumber.properties | ||
---|---|---|
1 |
#maven.buildNumber.plugin properties file |
|
2 |
#Mon Oct 24 14:20:37 CEST 2011 |
|
3 |
buildNumber=4 |
tags/v2_0_0_Build_2038/extensions/org.gvsig.app.document.table.app/.project | ||
---|---|---|
1 |
<?xml version="1.0" encoding="UTF-8"?> |
|
2 |
<projectDescription> |
|
3 |
<name>org.gvsig.app.document.table.app</name> |
|
4 |
<comment></comment> |
|
5 |
<projects> |
|
6 |
</projects> |
|
7 |
<buildSpec> |
|
8 |
</buildSpec> |
|
9 |
<natures> |
|
10 |
</natures> |
|
11 |
</projectDescription> |
tags/v2_0_0_Build_2038/extensions/org.gvsig.app.document.table.app/org.gvsig.app.document.table.app.mainplugin/buildNumber.properties | ||
---|---|---|
1 |
#maven.buildNumber.plugin properties file |
|
2 |
#Mon Oct 24 14:20:38 CEST 2011 |
|
3 |
buildNumber=4 |
tags/v2_0_0_Build_2038/extensions/org.gvsig.app.document.table.app/org.gvsig.app.document.table.app.mainplugin/src/main/java/org/gvsig/app/extension/package.html | ||
---|---|---|
1 |
<?xml version="1.0" encoding="UTF-8" ?> |
|
2 |
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> |
|
3 |
<html xmlns="http://www.w3.org/1999/xhtml"> |
|
4 |
<head> |
|
5 |
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> |
|
6 |
<title>org.gvsig.landregistryviewer package documentation</title> |
|
7 |
</head> |
|
8 |
<body> |
|
9 |
|
|
10 |
<p> |
|
11 |
Table document extensions for gvSIG. |
|
12 |
</p> |
|
13 |
|
|
14 |
</body> |
|
15 |
</html> |
tags/v2_0_0_Build_2038/extensions/org.gvsig.app.document.table.app/org.gvsig.app.document.table.app.mainplugin/src/main/java/org/gvsig/app/extension/AbstractTableEditExtension.java | ||
---|---|---|
1 |
/* gvSIG. Geographic Information System of the Valencian Government |
|
2 |
* |
|
3 |
* Copyright (C) 2007-2008 Infrastructures and Transports Department |
|
4 |
* of the Valencian Government (CIT) |
|
5 |
* |
|
6 |
* This program is free software; you can redistribute it and/or |
|
7 |
* modify it under the terms of the GNU General Public License |
|
8 |
* as published by the Free Software Foundation; either version 2 |
|
9 |
* of the License, or (at your option) any later version. |
|
10 |
* |
|
11 |
* This program is distributed in the hope that it will be useful, |
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
14 |
* GNU General Public License for more details. |
|
15 |
* |
|
16 |
* You should have received a copy of the GNU General Public License |
|
17 |
* along with this program; if not, write to the Free Software |
|
18 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
19 |
* MA 02110-1301, USA. |
|
20 |
* |
|
21 |
*/ |
|
22 |
package org.gvsig.app.extension; |
|
23 |
|
|
24 |
import org.gvsig.andami.PluginServices; |
|
25 |
import org.gvsig.andami.plugins.Extension; |
|
26 |
import org.gvsig.andami.ui.mdiManager.IWindow; |
|
27 |
import org.gvsig.app.project.documents.table.TableOperations; |
|
28 |
import org.gvsig.app.project.documents.table.gui.FeatureTableDocumentPanel; |
|
29 |
|
|
30 |
public abstract class AbstractTableEditExtension extends Extension { |
|
31 |
|
|
32 |
protected FeatureTableDocumentPanel table = null; |
|
33 |
protected TableOperations featureTableOperations = null; |
|
34 |
|
|
35 |
/** |
|
36 |
* @see org.gvsig.andami.plugins.IExtension#initialize() |
|
37 |
*/ |
|
38 |
public void initialize() { |
|
39 |
featureTableOperations = TableOperations.getInstance(); |
|
40 |
} |
|
41 |
|
|
42 |
/** |
|
43 |
* @see org.gvsig.andami.plugins.IExtension#isVisible() |
|
44 |
*/ |
|
45 |
public boolean isVisible() { |
|
46 |
IWindow v = PluginServices.getMDIManager().getActiveWindow(); |
|
47 |
if (v != null |
|
48 |
&& v instanceof FeatureTableDocumentPanel |
|
49 |
&& ((FeatureTableDocumentPanel) v).getModel().getStore() |
|
50 |
.isEditing()) { |
|
51 |
table = (FeatureTableDocumentPanel) v; |
|
52 |
return true; |
|
53 |
} |
|
54 |
return false; |
|
55 |
} |
|
56 |
|
|
57 |
} |
tags/v2_0_0_Build_2038/extensions/org.gvsig.app.document.table.app/org.gvsig.app.document.table.app.mainplugin/src/main/java/org/gvsig/app/extension/TableEditInsertExtension.java | ||
---|---|---|
1 |
/* gvSIG. Geographic Information System of the Valencian Government |
|
2 |
* |
|
3 |
* Copyright (C) 2007-2008 Infrastructures and Transports Department |
|
4 |
* of the Valencian Government (CIT) |
|
5 |
* |
|
6 |
* This program is free software; you can redistribute it and/or |
|
7 |
* modify it under the terms of the GNU General Public License |
|
8 |
* as published by the Free Software Foundation; either version 2 |
|
9 |
* of the License, or (at your option) any later version. |
|
10 |
* |
|
11 |
* This program is distributed in the hope that it will be useful, |
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
14 |
* GNU General Public License for more details. |
|
15 |
* |
|
16 |
* You should have received a copy of the GNU General Public License |
|
17 |
* along with this program; if not, write to the Free Software |
|
18 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
19 |
* MA 02110-1301, USA. |
|
20 |
* |
|
21 |
*/ |
|
22 |
package org.gvsig.app.extension; |
|
23 |
|
|
24 |
import org.gvsig.fmap.dal.exception.DataException; |
|
25 |
|
|
26 |
/** |
|
27 |
* DOCUMENT ME! |
|
28 |
* |
|
29 |
* @author Vicente Caballero Navarro |
|
30 |
*/ |
|
31 |
public class TableEditInsertExtension extends AbstractTableEditExtension { |
|
32 |
|
|
33 |
/** |
|
34 |
* @see org.gvsig.andami.plugins.IExtension#execute(java.lang.String) |
|
35 |
*/ |
|
36 |
public void execute(String actionCommand) { |
|
37 |
if ("INSERTROW".equals(actionCommand)) { |
|
38 |
try { |
|
39 |
featureTableOperations.setStore(table.getModel().getStore()); |
|
40 |
featureTableOperations.insertNewFeature(); |
|
41 |
} catch (DataException e) { |
|
42 |
e.printStackTrace(); |
|
43 |
} |
|
44 |
} |
|
45 |
|
|
46 |
} |
|
47 |
|
|
48 |
/** |
|
49 |
* @see org.gvsig.andami.plugins.IExtension#isEnabled() |
|
50 |
*/ |
|
51 |
public boolean isEnabled() { |
|
52 |
return (table.getModel().getAssociatedLayer() == null); |
|
53 |
} |
|
54 |
|
|
55 |
} |
tags/v2_0_0_Build_2038/extensions/org.gvsig.app.document.table.app/org.gvsig.app.document.table.app.mainplugin/src/main/java/org/gvsig/app/extension/TableNumericFieldOperations.java | ||
---|---|---|
1 |
/* gvSIG. Geographic Information System of the Valencian Government |
|
2 |
* |
|
3 |
* Copyright (C) 2007-2008 Infrastructures and Transports Department |
|
4 |
* of the Valencian Government (CIT) |
|
5 |
* |
|
6 |
* This program is free software; you can redistribute it and/or |
|
7 |
* modify it under the terms of the GNU General Public License |
|
8 |
* as published by the Free Software Foundation; either version 2 |
|
9 |
* of the License, or (at your option) any later version. |
|
10 |
* |
|
11 |
* This program is distributed in the hope that it will be useful, |
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
14 |
* GNU General Public License for more details. |
|
15 |
* |
|
16 |
* You should have received a copy of the GNU General Public License |
|
17 |
* along with this program; if not, write to the Free Software |
|
18 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
19 |
* MA 02110-1301, USA. |
|
20 |
* |
|
21 |
*/ |
|
22 |
package org.gvsig.app.extension; |
|
23 |
|
|
24 |
import java.math.BigDecimal; |
|
25 |
|
|
26 |
import org.gvsig.andami.PluginServices; |
|
27 |
import org.gvsig.andami.messages.NotificationManager; |
|
28 |
import org.gvsig.andami.plugins.Extension; |
|
29 |
import org.gvsig.andami.ui.mdiManager.IWindow; |
|
30 |
import org.gvsig.app.project.documents.table.gui.FeatureTableDocumentPanel; |
|
31 |
import org.gvsig.app.project.documents.table.gui.Statistics; |
|
32 |
import org.gvsig.fmap.dal.DataTypes; |
|
33 |
import org.gvsig.fmap.dal.exception.DataException; |
|
34 |
import org.gvsig.fmap.dal.feature.Feature; |
|
35 |
import org.gvsig.fmap.dal.feature.FeatureAttributeDescriptor; |
|
36 |
import org.gvsig.fmap.dal.feature.FeatureQuery; |
|
37 |
import org.gvsig.fmap.dal.feature.FeatureSelection; |
|
38 |
import org.gvsig.fmap.dal.feature.FeatureSet; |
|
39 |
import org.gvsig.fmap.dal.feature.FeatureStore; |
|
40 |
import org.gvsig.tools.dispose.DisposableIterator; |
|
41 |
|
|
42 |
/** |
|
43 |
* @author 2004-2005 Fernando Gonz?lez Cort?s |
|
44 |
* @author 2005- Vicente Caballero |
|
45 |
* @author 2009- <a href="cordinyana@gvsig.org">C?sar Ordi?ana</a> - gvSIG team |
|
46 |
*/ |
|
47 |
public class TableNumericFieldOperations extends Extension { |
|
48 |
|
|
49 |
private FeatureTableDocumentPanel table; |
|
50 |
|
|
51 |
/** |
|
52 |
* @see org.gvsig.andami.plugins.IExtension#initialize() |
|
53 |
*/ |
|
54 |
public void initialize() { |
|
55 |
registerIcons(); |
|
56 |
} |
|
57 |
|
|
58 |
private void registerIcons() { |
|
59 |
PluginServices.getIconTheme().registerDefault( |
|
60 |
"table-statistics", |
|
61 |
this.getClass().getClassLoader() |
|
62 |
.getResource("images/statistics.png")); |
|
63 |
} |
|
64 |
|
|
65 |
/** |
|
66 |
* @see org.gvsig.andami.plugins.IExtension#execute(java.lang.String) |
|
67 |
*/ |
|
68 |
public void execute(String actionCommand) { |
|
69 |
IWindow v = PluginServices.getMDIManager().getActiveWindow(); |
|
70 |
|
|
71 |
if (v != null) { |
|
72 |
if (v.getClass() == FeatureTableDocumentPanel.class) { |
|
73 |
|
|
74 |
FeatureTableDocumentPanel table = (FeatureTableDocumentPanel) v; |
|
75 |
|
|
76 |
doExecute(table); |
|
77 |
} |
|
78 |
} |
|
79 |
} |
|
80 |
|
|
81 |
/** |
|
82 |
* "execute" method acction |
|
83 |
* |
|
84 |
* @param actionCommand |
|
85 |
* The acction command that executes this method |
|
86 |
* @param table |
|
87 |
* Table to operate |
|
88 |
*/ |
|
89 |
protected void doExecute(FeatureTableDocumentPanel table) { |
|
90 |
FeatureSet featureSet = null; |
|
91 |
DisposableIterator iterator = null; |
|
92 |
try { |
|
93 |
FeatureAttributeDescriptor fad = |
|
94 |
table.getTablePanel().getTable() |
|
95 |
.getSelectedColumnsAttributeDescriptor()[0]; |
|
96 |
long numRows = 0; |
|
97 |
FeatureStore fs = table.getModel().getStore(); |
|
98 |
|
|
99 |
// Get the iterator from the selection or all the data |
|
100 |
FeatureSelection selection = fs.getFeatureSelection(); |
|
101 |
if (selection.isEmpty()) { |
|
102 |
FeatureQuery fq = fs.createFeatureQuery(); |
|
103 |
fq.setAttributeNames(new String[] { fad.getName() }); |
|
104 |
featureSet = fs.getFeatureSet(); |
|
105 |
numRows = featureSet.getSize(); |
|
106 |
iterator = featureSet.fastIterator(); |
|
107 |
} else { |
|
108 |
numRows = selection.getSize(); |
|
109 |
iterator = selection.fastIterator(); |
|
110 |
} |
|
111 |
|
|
112 |
// Read all values and calculate the min, max and the sum. |
|
113 |
// Also, calculate what we can for the variance |
|
114 |
BigDecimal sum = BigDecimal.ZERO; |
|
115 |
double min = Double.MAX_VALUE; |
|
116 |
double max = -Double.MAX_VALUE; |
|
117 |
BigDecimal variance = BigDecimal.ZERO; |
|
118 |
while (iterator.hasNext()) { |
|
119 |
Feature feature = (Feature) iterator.next(); |
|
120 |
Number valueNumber = (Number) feature.get(fad.getName()); |
|
121 |
if (valueNumber == null) { |
|
122 |
continue; |
|
123 |
} |
|
124 |
double value = valueNumber.doubleValue(); |
|
125 |
BigDecimal valueBig = BigDecimal.valueOf(value); |
|
126 |
sum = sum.add(valueBig); |
|
127 |
if (value < min) { |
|
128 |
min = value; |
|
129 |
} |
|
130 |
if (value > max) { |
|
131 |
max = value; |
|
132 |
} |
|
133 |
variance = variance.add(valueBig.pow(2)); |
|
134 |
} |
|
135 |
|
|
136 |
// Calculate the average, the variance final value and the standard |
|
137 |
// desviation |
|
138 |
BigDecimal average; |
|
139 |
double desviation = 0.0d; |
|
140 |
if (numRows < 1l) { |
|
141 |
average = BigDecimal.ZERO; |
|
142 |
} else { |
|
143 |
BigDecimal numRowsBig = BigDecimal.valueOf(numRows); |
|
144 |
average = sum.divide(numRowsBig, BigDecimal.ROUND_HALF_DOWN); |
|
145 |
variance = |
|
146 |
variance.divide(numRowsBig, BigDecimal.ROUND_HALF_DOWN) |
|
147 |
.subtract(average.pow(2)); |
|
148 |
desviation = Math.sqrt(variance.doubleValue()); |
|
149 |
} |
|
150 |
|
|
151 |
// Create and shot the statistics window |
|
152 |
Statistics st = new Statistics(); |
|
153 |
st.setStatistics(average.doubleValue(), max, min, |
|
154 |
variance.doubleValue(), desviation, numRows, max - min, |
|
155 |
sum.doubleValue()); |
|
156 |
PluginServices.getMDIManager().addWindow(st); |
|
157 |
} catch (DataException e) { |
|
158 |
NotificationManager.addError(e); |
|
159 |
} finally { |
|
160 |
if (iterator != null) { |
|
161 |
iterator.dispose(); |
|
162 |
} |
|
163 |
if (featureSet != null) { |
|
164 |
featureSet.dispose(); |
|
165 |
} |
|
166 |
} |
|
167 |
} |
|
168 |
|
|
169 |
/** |
|
170 |
* @see org.gvsig.andami.plugins.IExtension#isEnabled() |
|
171 |
*/ |
|
172 |
public boolean isEnabled() { |
|
173 |
return doIsEnabled(table); |
|
174 |
} |
|
175 |
|
|
176 |
protected boolean doIsEnabled(FeatureTableDocumentPanel table) { |
|
177 |
// FIXME |
|
178 |
FeatureAttributeDescriptor[] fads = null; |
|
179 |
try { |
|
180 |
fads = |
|
181 |
table.getTablePanel().getTable() |
|
182 |
.getSelectedColumnsAttributeDescriptor(); |
|
183 |
} catch (DataException e) { |
|
184 |
e.printStackTrace(); |
|
185 |
} |
|
186 |
|
|
187 |
if (fads.length == 1) { |
|
188 |
// int index=indices.nextSetBit(0); |
|
189 |
// if |
|
190 |
// (table.getModel().getStore().getDefaultFeatureType().size()<index+1) |
|
191 |
// { |
|
192 |
// return false; |
|
193 |
// } |
|
194 |
int type = fads[0].getType(); |
|
195 |
if ((type == DataTypes.LONG) || (type == DataTypes.DOUBLE) |
|
196 |
|| (type == DataTypes.FLOAT) || (type == DataTypes.INT)) { |
|
197 |
return true; |
|
198 |
} |
|
199 |
} |
|
200 |
return false; |
|
201 |
} |
|
202 |
|
|
203 |
/** |
|
204 |
* @see org.gvsig.andami.plugins.IExtension#isVisible() |
|
205 |
*/ |
|
206 |
public boolean isVisible() { |
|
207 |
IWindow v = PluginServices.getMDIManager().getActiveWindow(); |
|
208 |
if (v != null && v instanceof FeatureTableDocumentPanel) { |
|
209 |
table = (FeatureTableDocumentPanel) v; |
|
210 |
return true; |
|
211 |
} |
|
212 |
return false; |
|
213 |
} |
|
214 |
|
|
215 |
} |
tags/v2_0_0_Build_2038/extensions/org.gvsig.app.document.table.app/org.gvsig.app.document.table.app.mainplugin/src/main/java/org/gvsig/app/extension/RemoveTableLink.java | ||
---|---|---|
1 |
/* gvSIG. Geographic Information System of the Valencian Government |
|
2 |
* |
|
3 |
* Copyright (C) 2007-2008 Infrastructures and Transports Department |
|
4 |
* of the Valencian Government (CIT) |
|
5 |
* |
|
6 |
* This program is free software; you can redistribute it and/or |
|
7 |
* modify it under the terms of the GNU General Public License |
|
8 |
* as published by the Free Software Foundation; either version 2 |
|
9 |
* of the License, or (at your option) any later version. |
|
10 |
* |
|
11 |
* This program is distributed in the hope that it will be useful, |
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
14 |
* GNU General Public License for more details. |
|
15 |
* |
|
16 |
* You should have received a copy of the GNU General Public License |
|
17 |
* along with this program; if not, write to the Free Software |
|
18 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
19 |
* MA 02110-1301, USA. |
|
20 |
* |
|
21 |
*/ |
|
22 |
package org.gvsig.app.extension; |
|
23 |
|
|
24 |
import org.gvsig.andami.PluginServices; |
|
25 |
import org.gvsig.andami.plugins.Extension; |
|
26 |
import org.gvsig.andami.ui.mdiManager.IWindow; |
|
27 |
import org.gvsig.app.project.documents.table.TableDocument; |
|
28 |
import org.gvsig.app.project.documents.table.gui.FeatureTableDocumentPanel; |
|
29 |
|
|
30 |
/** |
|
31 |
* Extensi?n para borrar los link existentes entre tablas. |
|
32 |
* |
|
33 |
* @author Vicente Caballero Navarro |
|
34 |
*/ |
|
35 |
public class RemoveTableLink extends Extension { |
|
36 |
|
|
37 |
/** |
|
38 |
* @see org.gvsig.andami.plugins.IExtension#initialize() |
|
39 |
*/ |
|
40 |
public void initialize() { |
|
41 |
// TODO Auto-generated method stub |
|
42 |
} |
|
43 |
|
|
44 |
/** |
|
45 |
* @see org.gvsig.andami.plugins.IExtension#execute(java.lang.String) |
|
46 |
*/ |
|
47 |
public void execute(String actionCommand) { |
|
48 |
FeatureTableDocumentPanel t = |
|
49 |
(FeatureTableDocumentPanel) PluginServices.getMDIManager() |
|
50 |
.getActiveWindow(); |
|
51 |
TableDocument pt = t.getModel(); |
|
52 |
pt.removeLinkTable();// restoreDataSource(); |
|
53 |
t.getModel().setModified(true); |
|
54 |
} |
|
55 |
|
|
56 |
/** |
|
57 |
* @see org.gvsig.andami.plugins.IExtension#isEnabled() |
|
58 |
*/ |
|
59 |
public boolean isEnabled() { |
|
60 |
IWindow v = PluginServices.getMDIManager().getActiveWindow(); |
|
61 |
|
|
62 |
if (v == null) { |
|
63 |
return false; |
|
64 |
} |
|
65 |
|
|
66 |
if (v.getClass() == FeatureTableDocumentPanel.class) { |
|
67 |
FeatureTableDocumentPanel t = (FeatureTableDocumentPanel) v; |
|
68 |
|
|
69 |
if (t.getModel().hasLinks()) { |
|
70 |
return true; |
|
71 |
} |
|
72 |
} |
|
73 |
|
|
74 |
return false; |
|
75 |
} |
|
76 |
|
|
77 |
/** |
|
78 |
* @see org.gvsig.andami.plugins.IExtension#isVisible() |
|
79 |
*/ |
|
80 |
public boolean isVisible() { |
|
81 |
IWindow v = PluginServices.getMDIManager().getActiveWindow(); |
|
82 |
|
|
83 |
if (v == null) { |
|
84 |
return false; |
|
85 |
} |
|
86 |
|
|
87 |
if (v instanceof FeatureTableDocumentPanel) { |
|
88 |
return true; |
|
89 |
} else { |
|
90 |
return false; |
|
91 |
} |
|
92 |
} |
|
93 |
} |
tags/v2_0_0_Build_2038/extensions/org.gvsig.app.document.table.app/org.gvsig.app.document.table.app.mainplugin/src/main/java/org/gvsig/app/extension/TableExtension.java | ||
---|---|---|
1 |
/* gvSIG. Geographic Information System of the Valencian Government |
|
2 |
* |
|
3 |
* Copyright (C) 2007-2008 Infrastructures and Transports Department |
|
4 |
* of the Valencian Government (CIT) |
|
5 |
* |
|
6 |
* This program is free software; you can redistribute it and/or |
|
7 |
* modify it under the terms of the GNU General Public License |
|
8 |
* as published by the Free Software Foundation; either version 2 |
|
9 |
* of the License, or (at your option) any later version. |
|
10 |
* |
|
11 |
* This program is distributed in the hope that it will be useful, |
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
14 |
* GNU General Public License for more details. |
|
15 |
* |
|
16 |
* You should have received a copy of the GNU General Public License |
|
17 |
* along with this program; if not, write to the Free Software |
|
18 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
19 |
* MA 02110-1301, USA. |
|
20 |
* |
|
21 |
*/ |
|
22 |
package org.gvsig.app.extension; |
|
23 |
|
|
24 |
import org.gvsig.andami.plugins.Extension; |
|
25 |
import org.gvsig.app.ApplicationLocator; |
|
26 |
import org.gvsig.app.project.documents.table.TableManager; |
|
27 |
import org.gvsig.fmap.dal.serverexplorer.filesystem.swing.FilesystemExplorerTableWizardPanel; |
|
28 |
import org.gvsig.tools.ToolsLocator; |
|
29 |
import org.gvsig.tools.extensionpoint.ExtensionPointManager; |
|
30 |
|
|
31 |
/** |
|
32 |
* A gvSIG {@link Extension} to register the Table document type. |
|
33 |
* |
|
34 |
* @author gvSIG Team |
|
35 |
* @version $Id$ |
|
36 |
*/ |
|
37 |
public class TableExtension extends Extension { |
|
38 |
|
|
39 |
public void initialize() { |
|
40 |
ExtensionPointManager epMan = ToolsLocator.getExtensionPointManager(); |
|
41 |
epMan.add("DocumentActions_Table", |
|
42 |
"Context menu options of the table document list" |
|
43 |
+ " in the project window " + "(register instances of " |
|
44 |
+ "org.gvsig.app.project.AbstractDocumentContextMenuAction)"); |
|
45 |
} |
|
46 |
|
|
47 |
public void postInitialize() { |
|
48 |
TableManager.register(); |
|
49 |
ApplicationLocator.getManager().registerAddTableWizard("File", |
|
50 |
"File Table", FilesystemExplorerTableWizardPanel.class); |
|
51 |
} |
|
52 |
|
|
53 |
public boolean isEnabled() { |
|
54 |
return true; |
|
55 |
} |
|
56 |
|
|
57 |
public boolean isVisible() { |
|
58 |
return true; |
|
59 |
} |
|
60 |
|
|
61 |
public void execute(String actionCommand) { |
|
62 |
// Nothing to do |
|
63 |
} |
|
64 |
|
|
65 |
} |
tags/v2_0_0_Build_2038/extensions/org.gvsig.app.document.table.app/org.gvsig.app.document.table.app.mainplugin/src/main/java/org/gvsig/app/extension/ZoomToSelectExtension.java | ||
---|---|---|
1 |
/* gvSIG. Geographic Information System of the Valencian Government |
|
2 |
* |
|
3 |
* Copyright (C) 2007-2008 Infrastructures and Transports Department |
|
4 |
* of the Valencian Government (CIT) |
|
5 |
* |
|
6 |
* This program is free software; you can redistribute it and/or |
|
7 |
* modify it under the terms of the GNU General Public License |
|
8 |
* as published by the Free Software Foundation; either version 2 |
|
9 |
* of the License, or (at your option) any later version. |
|
10 |
* |
|
11 |
* This program is distributed in the hope that it will be useful, |
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
14 |
* GNU General Public License for more details. |
|
15 |
* |
|
16 |
* You should have received a copy of the GNU General Public License |
|
17 |
* along with this program; if not, write to the Free Software |
|
18 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
19 |
* MA 02110-1301, USA. |
|
20 |
* |
|
21 |
*/ |
|
22 |
package org.gvsig.app.extension; |
|
23 |
|
|
24 |
import org.gvsig.andami.PluginServices; |
|
25 |
import org.gvsig.andami.messages.NotificationManager; |
|
26 |
import org.gvsig.andami.plugins.Extension; |
|
27 |
import org.gvsig.andami.ui.mdiManager.IWindow; |
|
28 |
import org.gvsig.app.project.documents.table.gui.FeatureTableDocumentPanel; |
|
29 |
import org.gvsig.app.project.documents.view.gui.DefaultViewPanel; |
|
30 |
import org.gvsig.fmap.dal.exception.DataException; |
|
31 |
import org.gvsig.fmap.geom.primitive.Envelope; |
|
32 |
import org.gvsig.fmap.mapcontext.MapContext; |
|
33 |
import org.gvsig.tools.exception.BaseException; |
|
34 |
|
|
35 |
/** |
|
36 |
* Extensi?n de zoom a lo seleccionado teniendo como ventana activa una tabla. |
|
37 |
* |
|
38 |
* @author Vicente Caballero Navarro |
|
39 |
*/ |
|
40 |
public class ZoomToSelectExtension extends Extension { |
|
41 |
|
|
42 |
public void execute(String s) { |
|
43 |
org.gvsig.andami.ui.mdiManager.IWindow f = |
|
44 |
PluginServices.getMDIManager().getActiveWindow(); |
|
45 |
MapContext mapa = null; |
|
46 |
Envelope selectedExtent = null; |
|
47 |
if (f instanceof FeatureTableDocumentPanel) { |
|
48 |
FeatureTableDocumentPanel table = (FeatureTableDocumentPanel) f; |
|
49 |
mapa = (table.getModel().getAssociatedLayer()).getMapContext(); |
|
50 |
} |
|
51 |
|
|
52 |
try { |
|
53 |
selectedExtent = mapa.getSelectionBounds(); |
|
54 |
mapa.getViewPort().setEnvelope(selectedExtent); |
|
55 |
} catch (BaseException e) { |
|
56 |
NotificationManager.addError(e); |
|
57 |
} |
|
58 |
|
|
59 |
} |
|
60 |
|
|
61 |
public boolean isVisible() { |
|
62 |
org.gvsig.andami.ui.mdiManager.IWindow window = |
|
63 |
PluginServices.getMDIManager().getActiveWindow(); |
|
64 |
if (window instanceof FeatureTableDocumentPanel) { |
|
65 |
FeatureTableDocumentPanel featureTableDocumentPanel = |
|
66 |
(FeatureTableDocumentPanel) window; |
|
67 |
IWindow[] windows = PluginServices.getMDIManager().getAllWindows(); |
|
68 |
for (int i = 0; i < windows.length; i++) { |
|
69 |
if (windows[i] instanceof DefaultViewPanel) { |
|
70 |
if (featureTableDocumentPanel.getModel() |
|
71 |
.getAssociatedLayer() != null) { |
|
72 |
if (((DefaultViewPanel) windows[i]) |
|
73 |
.getMapControl() |
|
74 |
.getMapContext() |
|
75 |
.equals( |
|
76 |
(featureTableDocumentPanel.getModel() |
|
77 |
.getAssociatedLayer()).getMapContext())) { |
|
78 |
return true; |
|
79 |
} |
|
80 |
} |
|
81 |
} |
|
82 |
} |
|
83 |
} |
|
84 |
return false; |
|
85 |
} |
|
86 |
|
|
87 |
public boolean isEnabled() { |
|
88 |
org.gvsig.andami.ui.mdiManager.IWindow f = |
|
89 |
PluginServices.getMDIManager().getActiveWindow(); |
|
90 |
if (f == null) { |
|
91 |
return false; |
|
92 |
} |
|
93 |
if (f instanceof FeatureTableDocumentPanel) { |
|
94 |
FeatureTableDocumentPanel t = (FeatureTableDocumentPanel) f; |
|
95 |
IWindow[] windows = PluginServices.getMDIManager().getAllWindows(); |
|
96 |
for (int i = 0; i < windows.length; i++) { |
|
97 |
if (windows[i] instanceof DefaultViewPanel) { |
|
98 |
if (((DefaultViewPanel) windows[i]) |
|
99 |
.getMapControl() |
|
100 |
.getMapContext() |
|
101 |
.equals( |
|
102 |
(t.getModel().getAssociatedLayer()).getMapContext())) { |
|
103 |
try { |
|
104 |
if (!t.getModel().getStore().getFeatureSelection() |
|
105 |
.isEmpty()) { |
|
106 |
return true; |
|
107 |
} |
|
108 |
} catch (DataException e) { |
|
109 |
NotificationManager.addError(e); |
|
110 |
return false; |
|
111 |
} |
|
112 |
} |
|
113 |
} |
|
114 |
} |
|
115 |
|
|
116 |
} |
|
117 |
return false; |
|
118 |
} |
|
119 |
|
|
120 |
public void initialize() { |
|
121 |
registerIcons(); |
|
122 |
} |
|
123 |
|
|
124 |
private void registerIcons() { |
|
125 |
PluginServices.getIconTheme().registerDefault( |
|
126 |
"table-zoom-to-seleccion", |
|
127 |
this.getClass().getClassLoader() |
|
128 |
.getResource("images/ZoomSeleccion.png")); |
|
129 |
} |
|
130 |
} |
tags/v2_0_0_Build_2038/extensions/org.gvsig.app.document.table.app/org.gvsig.app.document.table.app.mainplugin/src/main/java/org/gvsig/app/extension/TableEditCopyExtension.java | ||
---|---|---|
1 |
/* gvSIG. Geographic Information System of the Valencian Government |
|
2 |
* |
|
3 |
* Copyright (C) 2007-2008 Infrastructures and Transports Department |
|
4 |
* of the Valencian Government (CIT) |
|
5 |
* |
|
6 |
* This program is free software; you can redistribute it and/or |
|
7 |
* modify it under the terms of the GNU General Public License |
|
8 |
* as published by the Free Software Foundation; either version 2 |
|
9 |
* of the License, or (at your option) any later version. |
|
10 |
* |
|
11 |
* This program is distributed in the hope that it will be useful, |
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
14 |
* GNU General Public License for more details. |
|
15 |
* |
|
16 |
* You should have received a copy of the GNU General Public License |
|
17 |
* along with this program; if not, write to the Free Software |
|
18 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
19 |
* MA 02110-1301, USA. |
|
20 |
* |
|
21 |
*/ |
|
22 |
package org.gvsig.app.extension; |
|
23 |
|
|
24 |
import org.gvsig.andami.PluginServices; |
|
25 |
import org.gvsig.fmap.dal.exception.DataException; |
|
26 |
|
|
27 |
/** |
|
28 |
* DOCUMENT ME! |
|
29 |
* |
|
30 |
* @author Vicente Caballero Navarro |
|
31 |
*/ |
|
32 |
public class TableEditCopyExtension extends AbstractTableEditExtension { |
|
33 |
|
|
34 |
/** |
|
35 |
* @see org.gvsig.andami.plugins.IExtension#initialize() |
|
36 |
*/ |
|
37 |
public void initialize() { |
|
38 |
super.initialize(); |
|
39 |
registerIcons(); |
|
40 |
} |
|
41 |
|
|
42 |
private void registerIcons() { |
|
43 |
PluginServices.getIconTheme() |
|
44 |
.registerDefault( |
|
45 |
"edit-copy", |
|
46 |
this.getClass().getClassLoader() |
|
47 |
.getResource("images/editcopy.png")); |
|
48 |
} |
|
49 |
|
|
50 |
/** |
|
51 |
* @see org.gvsig.andami.plugins.IExtension#execute(java.lang.String) |
|
52 |
*/ |
|
53 |
public void execute(String actionCommand) { |
|
54 |
if ("COPY".equals(actionCommand)) { |
|
55 |
try { |
|
56 |
featureTableOperations.setStore(table.getModel().getStore()); |
|
57 |
featureTableOperations.copyFeatures(); |
|
58 |
} catch (DataException e) { |
|
59 |
e.printStackTrace(); |
|
60 |
} |
|
61 |
} |
|
62 |
} |
|
63 |
|
|
64 |
/** |
|
65 |
* @see org.gvsig.andami.plugins.IExtension#isEnabled() |
|
66 |
*/ |
|
67 |
public boolean isEnabled() { |
|
68 |
try { |
|
69 |
if (table.getTablePanel().getTable().getSelectedRowCount() > 0) |
|
70 |
return true; |
|
71 |
} catch (DataException e) { |
|
72 |
e.printStackTrace(); |
|
73 |
} |
|
74 |
return false; |
|
75 |
} |
|
76 |
} |
tags/v2_0_0_Build_2038/extensions/org.gvsig.app.document.table.app/org.gvsig.app.document.table.app.mainplugin/src/main/java/org/gvsig/app/extension/TableEditPasteExtension.java | ||
---|---|---|
1 |
/* gvSIG. Geographic Information System of the Valencian Government |
|
2 |
* |
|
3 |
* Copyright (C) 2007-2008 Infrastructures and Transports Department |
|
4 |
* of the Valencian Government (CIT) |
|
5 |
* |
|
6 |
* This program is free software; you can redistribute it and/or |
|
7 |
* modify it under the terms of the GNU General Public License |
|
8 |
* as published by the Free Software Foundation; either version 2 |
|
9 |
* of the License, or (at your option) any later version. |
|
10 |
* |
|
11 |
* This program is distributed in the hope that it will be useful, |
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
14 |
* GNU General Public License for more details. |
|
15 |
* |
|
16 |
* You should have received a copy of the GNU General Public License |
|
17 |
* along with this program; if not, write to the Free Software |
|
18 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
19 |
* MA 02110-1301, USA. |
|
20 |
* |
|
21 |
*/ |
|
22 |
package org.gvsig.app.extension; |
|
23 |
|
|
24 |
import org.gvsig.andami.PluginServices; |
|
25 |
import org.gvsig.fmap.dal.exception.DataException; |
|
26 |
|
|
27 |
/** |
|
28 |
* DOCUMENT ME! |
|
29 |
* |
|
30 |
* @author Vicente Caballero Navarro |
|
31 |
*/ |
|
32 |
public class TableEditPasteExtension extends AbstractTableEditExtension { |
|
33 |
|
|
34 |
/** |
|
35 |
* @see org.gvsig.andami.plugins.IExtension#initialize() |
|
36 |
*/ |
|
37 |
public void initialize() { |
|
38 |
super.initialize(); |
|
39 |
registerIcons(); |
|
40 |
} |
|
41 |
|
|
42 |
private void registerIcons() { |
|
43 |
PluginServices.getIconTheme().registerDefault( |
|
44 |
"edit-paste", |
|
45 |
this.getClass().getClassLoader() |
|
46 |
.getResource("images/editpaste.png")); |
|
47 |
} |
|
48 |
|
|
49 |
/** |
|
50 |
* @see org.gvsig.andami.plugins.IExtension#execute(java.lang.String) |
|
51 |
*/ |
|
52 |
public void execute(String actionCommand) { |
|
53 |
if ("PASTE".equals(actionCommand)) { |
|
54 |
try { |
|
55 |
featureTableOperations.setStore(table.getModel().getStore()); |
|
56 |
featureTableOperations.pasteFeatures(); |
|
57 |
} catch (DataException e) { |
|
58 |
e.printStackTrace(); |
|
59 |
} |
|
60 |
} |
|
61 |
} |
|
62 |
|
|
63 |
/** |
|
64 |
* @see org.gvsig.andami.plugins.IExtension#isEnabled() |
|
65 |
*/ |
|
66 |
public boolean isEnabled() { |
|
67 |
return featureTableOperations.hasSelection(); |
|
68 |
} |
|
69 |
|
|
70 |
} |
tags/v2_0_0_Build_2038/extensions/org.gvsig.app.document.table.app/org.gvsig.app.document.table.app.mainplugin/src/main/java/org/gvsig/app/extension/ShowTable.java | ||
---|---|---|
1 |
/* gvSIG. Geographic Information System of the Valencian Government |
|
2 |
* |
|
3 |
* Copyright (C) 2007-2008 Infrastructures and Transports Department |
|
4 |
* of the Valencian Government (CIT) |
|
5 |
* |
|
6 |
* This program is free software; you can redistribute it and/or |
|
7 |
* modify it under the terms of the GNU General Public License |
|
8 |
* as published by the Free Software Foundation; either version 2 |
|
9 |
* of the License, or (at your option) any later version. |
|
10 |
* |
|
11 |
* This program is distributed in the hope that it will be useful, |
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
14 |
* GNU General Public License for more details. |
|
15 |
* |
|
16 |
* You should have received a copy of the GNU General Public License |
|
17 |
* along with this program; if not, write to the Free Software |
|
18 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
19 |
* MA 02110-1301, USA. |
|
20 |
* |
|
21 |
*/ |
|
22 |
package org.gvsig.app.extension; |
|
23 |
|
|
24 |
import org.gvsig.andami.PluginServices; |
|
25 |
import org.gvsig.andami.plugins.Extension; |
|
26 |
import org.gvsig.app.project.ProjectManager; |
|
27 |
import org.gvsig.app.project.documents.table.TableDocument; |
|
28 |
import org.gvsig.app.project.documents.table.TableManager; |
|
29 |
import org.gvsig.app.project.documents.table.gui.FeatureTableDocumentPanel; |
|
30 |
import org.gvsig.app.project.documents.view.gui.AbstractViewPanel; |
|
31 |
import org.gvsig.fmap.dal.feature.FeatureStore; |
|
32 |
import org.gvsig.fmap.mapcontext.layers.CancelationException; |
|
33 |
import org.gvsig.fmap.mapcontext.layers.FLayer; |
|
34 |
import org.gvsig.fmap.mapcontext.layers.FLayers; |
|
35 |
import org.gvsig.fmap.mapcontext.layers.LayerCollectionEvent; |
|
36 |
import org.gvsig.fmap.mapcontext.layers.LayerCollectionListener; |
|
37 |
import org.gvsig.fmap.mapcontext.layers.LayerPositionEvent; |
|
38 |
import org.gvsig.fmap.mapcontext.layers.vectorial.FLyrVect; |
|
39 |
|
|
40 |
/** |
|
41 |
* Extensi?n que abre las tablas asociadas a las vistas. |
|
42 |
* |
|
43 |
* @author Vicente Caballero Navarro |
|
44 |
*/ |
|
45 |
public class ShowTable extends Extension implements LayerCollectionListener { |
|
46 |
|
|
47 |
/** |
|
48 |
* @see org.gvsig.andami.plugins.IExtension#isEnabled() |
|
49 |
*/ |
|
50 |
public boolean isEnabled() { |
|
51 |
AbstractViewPanel f = |
|
52 |
(AbstractViewPanel) PluginServices.getMDIManager() |
|
53 |
.getActiveWindow(); |
|
54 |
|
|
55 |
if (f == null) { |
|
56 |
return false; |
|
57 |
} |
|
58 |
|
|
59 |
FLayer[] selected = |
|
60 |
f.getViewDocument().getMapContext().getLayers().getActives(); |
|
61 |
|
|
62 |
boolean algunaTabla = false; |
|
63 |
|
|
64 |
for (int i = 0; i < selected.length; i++) { |
|
65 |
if (selected[i].isAvailable() && selected[i] instanceof FLyrVect) { |
|
66 |
FLyrVect co = (FLyrVect) selected[i]; |
|
67 |
|
|
68 |
try { |
|
69 |
if (co.getFeatureStore() != null) { |
|
70 |
algunaTabla = true; |
|
71 |
} |
|
72 |
// } catch (ReadException e) { |
|
73 |
// return false; |
|
74 |
} catch (NullPointerException e) { |
|
75 |
return false; |
|
76 |
} |
|
77 |
} |
|
78 |
} |
|
79 |
|
|
80 |
return algunaTabla; |
|
81 |
} |
|
82 |
|
|
83 |
/** |
|
84 |
* @see org.gvsig.andami.plugins.IExtension#isVisible() |
|
85 |
*/ |
|
86 |
public boolean isVisible() { |
|
87 |
org.gvsig.andami.ui.mdiManager.IWindow f = |
|
88 |
PluginServices.getMDIManager().getActiveWindow(); |
|
89 |
|
|
90 |
if (f == null) { |
|
91 |
return false; |
|
92 |
} |
|
93 |
|
|
94 |
return (f instanceof AbstractViewPanel); |
|
95 |
} |
|
96 |
|
|
97 |
/** |
|
98 |
* @see com.iver.mdiApp.plugins.IExtension#updateUI(java.lang.String) |
|
99 |
*/ |
|
100 |
public void execute(String s) { |
|
101 |
AbstractViewPanel vista = |
|
102 |
(AbstractViewPanel) PluginServices.getMDIManager() |
|
103 |
.getActiveWindow(); |
|
104 |
FLayer[] actives = |
|
105 |
vista.getViewDocument().getMapContext().getLayers().getActives(); |
|
106 |
|
|
107 |
for (int i = 0; i < actives.length; i++) { |
|
108 |
if (actives[i] instanceof FLyrVect) { |
|
109 |
FLyrVect co = (FLyrVect) actives[i]; |
|
110 |
|
|
111 |
ProjectManager projectManager = getProjectManager(); |
|
112 |
TableManager tableManager = getTableManager(); |
|
113 |
|
|
114 |
TableDocument projectTable = tableManager.getTableDocument(co); |
|
115 |
FeatureStore fs = ((FLyrVect) actives[i]).getFeatureStore(); |
|
116 |
|
|
117 |
if (projectTable == null) { |
|
118 |
projectTable = |
|
119 |
(TableDocument) projectManager.createDocument( |
|
120 |
TableManager.TYPENAME, |
|
121 |
PluginServices.getText(this, "Tabla_de_Atributos") |
|
122 |
+ ": " + actives[i].getName()); |
|
123 |
projectTable.setStore(fs); |
|
124 |
projectTable.setAssociatedLayer(co); |
|
125 |
co.getParentLayer().addLayerCollectionListener(this); |
|
126 |
projectManager.getCurrentProject().add(projectTable); |
|
127 |
} |
|
128 |
|
|
129 |
FeatureTableDocumentPanel featureTableDocumentPanel = |
|
130 |
(FeatureTableDocumentPanel) projectTable.getFactory() |
|
131 |
.getMainWindow(projectTable); |
|
132 |
|
|
133 |
featureTableDocumentPanel.getModel().setModified(true); |
|
134 |
PluginServices.getMDIManager().addWindow( |
|
135 |
featureTableDocumentPanel); |
|
136 |
} |
|
137 |
} |
|
138 |
|
|
139 |
} |
|
140 |
|
|
141 |
private ProjectManager getProjectManager() { |
|
142 |
return ProjectManager.getInstance(); |
|
143 |
} |
|
144 |
|
|
145 |
private TableManager getTableManager() { |
|
146 |
TableManager tableManager = |
|
147 |
(TableManager) getProjectManager().getDocumentManager( |
|
148 |
TableManager.TYPENAME); |
|
149 |
return tableManager; |
|
150 |
} |
|
151 |
|
|
152 |
/** |
|
153 |
* @see org.gvsig.andami.plugins.IExtension#initialize() |
|
154 |
*/ |
|
155 |
public void initialize() { |
|
156 |
registerIcons(); |
|
157 |
} |
|
158 |
|
|
159 |
private void registerIcons() { |
|
160 |
PluginServices.getIconTheme().registerDefault( |
|
161 |
"layer-show-attribute-table", |
|
162 |
this.getClass().getClassLoader() |
|
163 |
.getResource("images/ResultConsulta.png")); |
|
164 |
} |
|
165 |
|
|
166 |
public void layerAdded(LayerCollectionEvent e) { |
|
167 |
// Nothing to do |
|
168 |
} |
|
169 |
|
|
170 |
public void layerMoved(LayerPositionEvent e) { |
|
171 |
// Nothing to do |
|
172 |
} |
|
173 |
|
|
174 |
public void layerRemoved(LayerCollectionEvent e) { |
|
175 |
FLayer layer = e.getAffectedLayer(); |
|
176 |
// Just in case we where listening to a group of layers being removed |
|
177 |
// remove us from there |
|
178 |
if (layer instanceof FLayers) { |
|
179 |
((FLayers) layer).removeLayerCollectionListener(this); |
|
180 |
} |
|
181 |
// Remove the related table document, if any |
|
182 |
if (layer instanceof FLyrVect) { |
|
183 |
getTableManager().removeTableDocument((FLyrVect) layer); |
|
184 |
// If the parent layers has not other child layers, for sure there |
|
185 |
// are not related tables opened, don't need to listen |
|
186 |
// LayerCollectionEvents anymore. |
|
187 |
// TODO: remove us also when there are not any child layers with |
|
188 |
// related table documents |
|
189 |
FLayers layers = layer.getParentLayer(); |
|
190 |
if (layers != null && layers.getLayersCount() == 0) { |
|
191 |
layers.removeLayerCollectionListener(this); |
|
192 |
} |
|
193 |
} |
|
194 |
} |
|
195 |
|
|
196 |
public void layerAdding(LayerCollectionEvent e) throws CancelationException { |
|
197 |
// Nothing to do |
|
198 |
} |
|
199 |
|
|
200 |
public void layerMoving(LayerPositionEvent e) throws CancelationException { |
|
201 |
// Nothing to do |
|
202 |
} |
|
203 |
|
|
204 |
public void layerRemoving(LayerCollectionEvent e) |
|
205 |
throws CancelationException { |
|
206 |
// Nothing to do |
|
207 |
} |
|
208 |
|
|
209 |
public void visibilityChanged(LayerCollectionEvent e) |
|
210 |
throws CancelationException { |
|
211 |
// Nothing to do |
|
212 |
} |
|
213 |
} |
tags/v2_0_0_Build_2038/extensions/org.gvsig.app.document.table.app/org.gvsig.app.document.table.app.mainplugin/src/main/java/org/gvsig/app/extension/ClearSelectionExtension.java | ||
---|---|---|
1 |
/* gvSIG. Geographic Information System of the Valencian Government |
|
2 |
* |
|
3 |
* Copyright (C) 2007-2008 Infrastructures and Transports Department |
|
4 |
* of the Valencian Government (CIT) |
|
5 |
* |
|
6 |
* This program is free software; you can redistribute it and/or |
|
7 |
* modify it under the terms of the GNU General Public License |
|
8 |
* as published by the Free Software Foundation; either version 2 |
|
9 |
* of the License, or (at your option) any later version. |
|
10 |
* |
|
11 |
* This program is distributed in the hope that it will be useful, |
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
14 |
* GNU General Public License for more details. |
|
15 |
* |
|
16 |
* You should have received a copy of the GNU General Public License |
|
17 |
* along with this program; if not, write to the Free Software |
|
18 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
19 |
* MA 02110-1301, USA. |
|
20 |
* |
|
21 |
*/ |
|
22 |
package org.gvsig.app.extension; |
|
23 |
|
|
24 |
import org.gvsig.andami.PluginServices; |
|
25 |
import org.gvsig.andami.messages.NotificationManager; |
|
26 |
import org.gvsig.andami.plugins.Extension; |
|
27 |
import org.gvsig.andami.ui.mdiManager.IWindow; |
|
28 |
import org.gvsig.app.project.documents.table.gui.FeatureTableDocumentPanel; |
|
29 |
import org.gvsig.fmap.dal.exception.DataException; |
|
30 |
import org.gvsig.fmap.dal.feature.FeatureSelection; |
|
31 |
|
|
32 |
/** |
|
33 |
* Extensi?n encargada de limpiar la selecci?n. |
|
34 |
* |
|
35 |
* @author Vicente Caballero Navarro |
|
36 |
*/ |
|
37 |
public class ClearSelectionExtension extends Extension { |
|
38 |
|
|
39 |
public void execute(String s) { |
|
40 |
if (s.compareTo("DEL_SELECTION") == 0) { |
|
41 |
IWindow activeWindow = |
|
42 |
PluginServices.getMDIManager().getActiveWindow(); |
|
43 |
|
|
44 |
if (isFeatureTableDocumentPanel(activeWindow)) { |
|
45 |
try { |
|
46 |
FeatureSelection selection = getSelection(activeWindow); |
|
47 |
selection.deselectAll(); |
|
48 |
} catch (DataException e) { |
|
49 |
NotificationManager.addError(e); |
|
50 |
} |
|
51 |
} |
|
52 |
} |
|
53 |
} |
|
54 |
|
|
55 |
public boolean isVisible() { |
|
56 |
IWindow activeWindow = PluginServices.getMDIManager().getActiveWindow(); |
|
57 |
return isFeatureTableDocumentPanel(activeWindow); |
|
58 |
} |
|
59 |
|
|
60 |
private boolean isFeatureTableDocumentPanel(IWindow activeWindow) { |
|
61 |
return activeWindow instanceof FeatureTableDocumentPanel; |
|
62 |
} |
|
63 |
|
|
64 |
public boolean isEnabled() { |
|
65 |
IWindow activeWindow = PluginServices.getMDIManager().getActiveWindow(); |
|
66 |
|
|
67 |
if (isFeatureTableDocumentPanel(activeWindow)) { |
|
68 |
try { |
|
69 |
return !getSelection(activeWindow).isEmpty(); |
|
70 |
} catch (DataException e) { |
|
71 |
throw new RuntimeException( |
|
72 |
"Error getting the selection to check if it is empty", e); |
|
73 |
} |
|
74 |
} |
|
75 |
|
|
76 |
return false; |
|
77 |
} |
|
78 |
|
|
79 |
private FeatureSelection getSelection(IWindow activeWindow) |
|
80 |
throws DataException { |
|
81 |
return (FeatureSelection) ((FeatureTableDocumentPanel) activeWindow) |
|
82 |
.getModel().getStore().getSelection(); |
|
83 |
} |
|
84 |
|
|
85 |
public void initialize() { |
|
86 |
registerIcons(); |
|
87 |
} |
|
88 |
|
|
89 |
private void registerIcons() { |
|
90 |
PluginServices.getIconTheme().registerDefault( |
|
91 |
"table-clear-selection", |
|
92 |
this.getClass().getClassLoader() |
|
93 |
.getResource("images/delselection.png")); |
|
94 |
} |
|
95 |
} |
tags/v2_0_0_Build_2038/extensions/org.gvsig.app.document.table.app/org.gvsig.app.document.table.app.mainplugin/src/main/java/org/gvsig/app/extension/TableOperations.java | ||
---|---|---|
1 |
/* gvSIG. Geographic Information System of the Valencian Government |
|
2 |
* |
|
3 |
* Copyright (C) 2007-2008 Infrastructures and Transports Department |
|
4 |
* of the Valencian Government (CIT) |
|
5 |
* |
|
6 |
* This program is free software; you can redistribute it and/or |
|
7 |
* modify it under the terms of the GNU General Public License |
|
8 |
* as published by the Free Software Foundation; either version 2 |
|
9 |
* of the License, or (at your option) any later version. |
|
10 |
* |
|
11 |
* This program is distributed in the hope that it will be useful, |
|
12 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
14 |
* GNU General Public License for more details. |
|
15 |
* |
|
16 |
* You should have received a copy of the GNU General Public License |
|
17 |
* along with this program; if not, write to the Free Software |
|
18 |
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, |
|
19 |
* MA 02110-1301, USA. |
|
20 |
* |
|
21 |
*/ |
|
22 |
package org.gvsig.app.extension; |
|
23 |
|
|
24 |
import java.awt.Component; |
|
25 |
import java.awt.Dimension; |
|
26 |
import java.util.List; |
|
27 |
|
|
28 |
import javax.swing.JOptionPane; |
|
29 |
|
|
30 |
import org.gvsig.andami.PluginServices; |
|
31 |
import org.gvsig.andami.messages.NotificationManager; |
|
32 |
import org.gvsig.andami.plugins.Extension; |
|
33 |
import org.gvsig.andami.ui.mdiManager.IWindow; |
|
34 |
import org.gvsig.app.gui.filter.ExpressionListener; |
|
35 |
import org.gvsig.app.project.Project; |
|
36 |
import org.gvsig.app.project.ProjectManager; |
|
37 |
import org.gvsig.app.project.documents.Document; |
|
38 |
import org.gvsig.app.project.documents.gui.AndamiWizard; |
|
39 |
import org.gvsig.app.project.documents.gui.ObjectSelectionStep; |
|
40 |
import org.gvsig.app.project.documents.table.FieldSelectionModel; |
|
41 |
import org.gvsig.app.project.documents.table.TableDocument; |
|
42 |
import org.gvsig.app.project.documents.table.TableManager; |
|
43 |
import org.gvsig.app.project.documents.table.TableSelectionModel; |
|
44 |
import org.gvsig.app.project.documents.table.gui.FeatureTableDocumentPanel; |
|
45 |
import org.gvsig.fmap.dal.DALLocator; |
|
46 |
import org.gvsig.fmap.dal.exception.DataException; |
|
47 |
import org.gvsig.fmap.dal.feature.Feature; |
|
48 |
import org.gvsig.fmap.dal.feature.FeatureAttributeDescriptor; |
|
49 |
import org.gvsig.fmap.dal.feature.FeatureQuery; |
|
50 |
import org.gvsig.fmap.dal.feature.FeatureSelection; |
|
51 |
import org.gvsig.fmap.dal.feature.FeatureSet; |
|
52 |
import org.gvsig.fmap.dal.feature.FeatureStore; |
|
53 |
import org.gvsig.tools.dispose.DisposableIterator; |
|
54 |
import org.gvsig.tools.dispose.DisposeUtils; |
|
55 |
import org.gvsig.utils.swing.objectSelection.SelectionException; |
|
56 |
import org.gvsig.utils.swing.wizard.WizardControl; |
|
57 |
import org.gvsig.utils.swing.wizard.WizardEvent; |
|
58 |
import org.gvsig.utils.swing.wizard.WizardListener; |
|
59 |
|
|
60 |
/** |
|
61 |
* Extensi?n que controla las operaciones realizadas sobre las tablas. |
|
62 |
* |
|
63 |
* @author Fernando Gonz?lez Cort?s |
|
64 |
*/ |
|
65 |
public class TableOperations extends Extension implements ExpressionListener { |
|
66 |
|
|
67 |
private FeatureStore featureStore = null; |
|
68 |
|
|
69 |
public void execute(String actionCommand) { |
|
70 |
final Project project = |
|
71 |
ProjectManager.getInstance().getCurrentProject(); |
|
72 |
List<Document> tableDcouments = |
|
73 |
project.getDocuments(TableManager.TYPENAME); |
|
74 |
TableDocument[] pts = |
|
75 |
tableDcouments |
|
76 |
.toArray(new TableDocument[tableDcouments.size()]); |
|
77 |
|
|
78 |
if ("LINK".equals(actionCommand)) { |
|
79 |
try { |
|
80 |
final ObjectSelectionStep sourceTable = |
|
81 |
new ObjectSelectionStep(); |
|
82 |
sourceTable.setModel(new TableSelectionModel(pts, |
|
83 |
PluginServices.getText(this, "seleccione_tabla_origen"))); |
|
84 |
|
|
85 |
final ObjectSelectionStep targetTable = |
|
86 |
new ObjectSelectionStep(); |
|
87 |
targetTable |
|
88 |
.setModel(new TableSelectionModel(pts, PluginServices |
|
89 |
.getText(this, "seleccione_tabla_a_enlazar"))); |
|
90 |
|
|
91 |
final ObjectSelectionStep firstTableField = |
|
92 |
new ObjectSelectionStep(); |
|
93 |
final ObjectSelectionStep secondTableField = |
|
94 |
new ObjectSelectionStep(); |
|
95 |
final AndamiWizard wiz = |
|
96 |
new AndamiWizard(PluginServices.getText(this, "back"), |
|
97 |
PluginServices.getText(this, "next"), |
|
98 |
PluginServices.getText(this, "finish"), |
|
99 |
PluginServices.getText(this, "cancel")); |
|
100 |
wiz.setSize(new Dimension(450, 200)); |
|
101 |
wiz.addStep(sourceTable); |
|
102 |
wiz.addStep(firstTableField); |
|
103 |
wiz.addStep(targetTable); |
|
104 |
wiz.addStep(secondTableField); |
|
105 |
|
|
106 |
wiz.addWizardListener(new WizardListener() { |
|
107 |
|
|
108 |
public void cancel(WizardEvent w) { |
|
109 |
PluginServices.getMDIManager().closeWindow(wiz); |
|
110 |
} |
|
111 |
|
|
112 |
public void finished(WizardEvent w) { |
|
113 |
PluginServices.getMDIManager().closeWindow(wiz); |
|
114 |
|
|
115 |
TableDocument sourceProjectTable = |
|
116 |
(TableDocument) sourceTable.getSelected(); |
|
117 |
|
|
118 |
TableDocument targetProjectTable = |
|
119 |
(TableDocument) targetTable.getSelected(); |
|
120 |
FeatureStore sds2 = targetProjectTable.getStore(); |
|
121 |
|
|
122 |
String field1 = (String) firstTableField.getSelected(); |
|
123 |
String field2 = (String) secondTableField.getSelected(); |
|
124 |
sourceProjectTable.addLinkTable(sds2.getName(), field1, |
|
125 |
field2); |
|
126 |
|
|
127 |
} |
|
128 |
|
|
129 |
public void next(WizardEvent w) { |
|
130 |
WizardControl wiz = w.wizard; |
|
131 |
wiz.enableBack(true); |
|
132 |
wiz.enableNext(((ObjectSelectionStep) wiz |
|
133 |
.getCurrentStep()).getSelectedItem() != null); |
|
134 |
|
|
135 |
if (w.currentStep == 1) { |
|
136 |
TableDocument pt = |
|
137 |
(TableDocument) sourceTable.getSelected(); |
|
138 |
|
|
139 |
try { |
|
140 |
firstTableField |
|
141 |
.setModel(new FieldSelectionModel(pt |
|
142 |
.getStore(), PluginServices.getText( |
|
143 |
this, "seleccione_campo_enlace"))); |
|
144 |
} catch (SelectionException e) { |
|
145 |
NotificationManager.addError( |
|
146 |
"Error obteniendo los campos de la tabla", |
|
147 |
e); |
|
148 |
} |
|
149 |
} else |
|
150 |
if (w.currentStep == 3) { |
|
151 |
try { |
|
152 |
// tabla |
|
153 |
TableDocument pt = |
|
154 |
(TableDocument) sourceTable |
|
155 |
.getSelected(); |
|
156 |
|
|
157 |
// ?ndice del campo |
|
158 |
FeatureStore fs = pt.getStore(); |
|
159 |
String fieldName = |
|
160 |
(String) firstTableField.getSelected(); |
|
161 |
int type = |
|
162 |
((FeatureAttributeDescriptor) fs |
|
163 |
.getDefaultFeatureType().get( |
|
164 |
fieldName)).getType(); |
|
165 |
|
|
166 |
secondTableField |
|
167 |
.setModel(new FieldSelectionModel( |
|
168 |
((TableDocument) targetTable |
|
169 |
.getSelected()).getStore(), |
|
170 |
PluginServices.getText(this, |
|
171 |
"seleccione_campo_enlace"), |
|
172 |
type)); |
|
173 |
} catch (SelectionException e) { |
|
174 |
NotificationManager |
|
175 |
.addError( |
|
176 |
"Error obteniendo los campos de la tabla", |
|
177 |
e); |
|
178 |
} catch (DataException e) { |
|
179 |
NotificationManager |
|
180 |
.addError( |
|
181 |
"Error obteniendo los campos de la tabla", |
|
182 |
e); |
|
183 |
} |
|
184 |
} |
|
185 |
} |
|
186 |
|
|
187 |
public void back(WizardEvent w) { |
|
188 |
WizardControl wiz = w.wizard; |
|
189 |
wiz.enableBack(true); |
|
190 |
wiz.enableNext(((ObjectSelectionStep) wiz |
|
191 |
.getCurrentStep()).getSelectedItem() != null); |
|
192 |
} |
|
193 |
}); |
|
194 |
project.setModified(true); |
|
195 |
PluginServices.getMDIManager().addWindow(wiz); |
|
196 |
} catch (SelectionException e) { |
|
197 |
NotificationManager.addError("Error abriendo el asistente", e); |
|
198 |
} |
|
199 |
} |
|
200 |
} |
|
201 |
|
|
202 |
/** |
|
203 |
* @see org.gvsig.app.gui.filter.ExpressionListener#newSet(java.lang.String) |
|
204 |
*/ |
|
205 |
public void newSet(String expression) throws DataException { |
|
206 |
// By Pablo: if no filter expression -> no element selected |
|
207 |
if (!this.filterExpressionFromWhereIsEmpty(expression)) { |
|
208 |
FeatureSet set = null; |
|
209 |
try { |
|
210 |
set = doSet(expression); |
|
211 |
|
|
212 |
if (set == null) { |
|
213 |
throw new RuntimeException("Not a 'where' clause?"); |
|
214 |
} |
|
215 |
FeatureSelection newSel = featureStore.createFeatureSelection(); |
|
216 |
newSel.select(set); |
|
217 |
featureStore.setSelection(newSel); |
|
218 |
} catch (Exception e) { |
|
219 |
JOptionPane.showMessageDialog( |
|
220 |
(Component) PluginServices.getMainFrame(), |
|
221 |
"Asegurate de que la consulta es correcta."); |
|
222 |
} finally { |
|
223 |
if (set != null) { |
|
224 |
set.dispose(); |
|
225 |
} |
|
226 |
} |
|
227 |
} else { |
|
228 |
// By Pablo: if no expression -> no element selected |
|
229 |
featureStore.getFeatureSelection().deselectAll(); |
|
230 |
} |
|
231 |
} |
|
232 |
|
|
233 |
/** |
|
234 |
* @see org.gvsig.app.gui.filter.ExpressionListener#newSet(java.lang.String) |
|
235 |
*/ |
|
236 |
private FeatureSet doSet(String expression) throws DataException { |
|
237 |
FeatureQuery query = featureStore.createFeatureQuery(); |
|
238 |
query |
|
239 |
.setFilter(DALLocator.getDataManager().createExpresion(expression)); |
|
240 |
return featureStore.getFeatureSet(query); |
|
241 |
} |
|
242 |
|
|
243 |
/** |
|
244 |
* @see org.gvsig.app.gui.filter.ExpressionListener#addToSet(java.lang.String) |
|
245 |
*/ |
|
246 |
public void addToSet(String expression) throws DataException { |
|
247 |
// By Pablo: if no filter expression -> don't add more elements to set |
|
248 |
if (!this.filterExpressionFromWhereIsEmpty(expression)) { |
|
249 |
FeatureSet set = null; |
|
250 |
try { |
|
251 |
set = doSet(expression); |
|
252 |
|
|
253 |
featureStore.getFeatureSelection().select(set); |
|
254 |
} finally { |
|
255 |
if (set != null) { |
|
256 |
set.dispose(); |
|
257 |
} |
|
258 |
} |
|
259 |
} |
|
260 |
} |
|
261 |
|
|
262 |
/** |
|
263 |
* @see org.gvsig.app.gui.filter.ExpressionListener#fromSet(java.lang.String) |
|
264 |
*/ |
|
265 |
public void fromSet(String expression) throws DataException { |
|
266 |
// By Pablo: if no filter expression -> no element selected |
|
267 |
if (!this.filterExpressionFromWhereIsEmpty(expression)) { |
|
268 |
|
|
269 |
FeatureSet set = null; |
|
270 |
DisposableIterator iterator = null; |
|
271 |
try { |
|
272 |
set = doSet(expression); |
|
273 |
|
|
274 |
if (set == null) { |
|
275 |
throw new RuntimeException("Not a 'where' clause?"); |
|
276 |
} |
|
277 |
FeatureSelection oldSelection = |
|
278 |
featureStore.getFeatureSelection(); |
|
279 |
|
|
280 |
FeatureSelection newSelection = |
|
281 |
featureStore.createFeatureSelection(); |
|
282 |
iterator = set.fastIterator(); |
|
283 |
while (iterator.hasNext()) { |
|
284 |
Feature feature = (Feature) iterator.next(); |
|
285 |
if (oldSelection.isSelected(feature)) { |
|
286 |
newSelection.select(feature); |
|
287 |
} |
|
288 |
} |
|
289 |
featureStore.setSelection(newSelection); |
|
290 |
} finally { |
|
291 |
DisposeUtils.dispose(iterator); |
|
292 |
DisposeUtils.dispose(set); |
|
293 |
} |
|
294 |
} else { |
|
295 |
// By Pablo: if no expression -> no element selected |
|
296 |
// featureStore.setSelection(featureStore.createSelection()); |
|
297 |
featureStore.getFeatureSelection().deselectAll(); |
|
298 |
} |
|
299 |
} |
|
300 |
|
|
301 |
/** |
|
302 |
* Returns true if the WHERE subconsultation of the filterExpression is |
|
303 |
* empty ("") |
|
304 |
* |
|
305 |
* @author Pablo Piqueras Bartolom? (p_queras@hotmail.com) |
|
306 |
* @param expression |
|
307 |
* An string |
|
308 |
* @return A boolean value |
|
309 |
*/ |
|
310 |
private boolean filterExpressionFromWhereIsEmpty(String expression) { |
|
311 |
String subExpression = expression.trim(); |
|
312 |
int pos; |
|
313 |
|
|
314 |
// Remove last ';' if exists |
|
315 |
if (subExpression.charAt(subExpression.length() - 1) == ';') { |
|
316 |
subExpression = |
|
317 |
subExpression.substring(0, subExpression.length() - 1).trim(); |
|
318 |
} |
|
319 |
|
|
320 |
// If there is no 'where' clause |
|
321 |
if ((pos = subExpression.indexOf("where")) == -1) { |
|
322 |
return false; |
|
323 |
} |
|
324 |
|
Also available in: Unified diff