Revision 37657

View differences:

tags/v_2_0_0_Build_2043/extensions/org.gvsig.app.document.table.app/buildNumber.properties
1
#maven.buildNumber.plugin properties file
2
#Thu Jan 12 18:41:15 CET 2012
3
buildNumber=9
tags/v_2_0_0_Build_2043/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/v_2_0_0_Build_2043/extensions/org.gvsig.app.document.table.app/org.gvsig.app.document.table.app.mainplugin/src/test/resources/README.txt
1
Put into this folder the resources needed by your test classes.
2

  
3
This folder is added to the Tests classpath, so you can load any resources 
4
through the ClassLoader.
5

  
6
By default, in this folder you can find an example of log4j configuration,
7
prepared to log messages through the console, so logging works when you
8
run your tests classes.
tags/v_2_0_0_Build_2043/extensions/org.gvsig.app.document.table.app/org.gvsig.app.document.table.app.mainplugin/src/test/resources/log4j.xml
1
<?xml version="1.0" encoding="ISO-8859-1" ?>
2
<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd">
3

  
4
<!-- 
5
Log4J configuration file for unit tests execution.
6
 -->
7
<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">
8

  
9
	<!-- Appender configuration to show logging messages through the console -->
10
	<appender name="CONSOLE" class="org.apache.log4j.ConsoleAppender">
11
		<layout class="org.apache.log4j.PatternLayout">
12
			<param name="ConversionPattern" value="%d{HH:mm:ss,SSS} %-5p [%c{2}.%M()]\n  %m%n" />
13
		</layout>
14
	</appender>
15

  
16
	<!-- 
17
	Activate logging messages of DEBUG level of higher only for the
18
	org.gvsig.tools packages.
19
	You can put full classes names or packages instead, to configure
20
	logging for all the classes and subpackages of the package.
21
	-->
22
	<category name="org.gvsig.tools">
23
		<priority value="DEBUG" />
24
	</category>
25
	<category name="org.gvsig.app.document.table">
26
		<priority value="DEBUG" />
27
	</category>
28

  
29
	<!-- 
30
	By default, show only logging messages of INFO level or higher, 
31
	through the previously configured CONSOLE appender. 
32
	-->
33
	<root>
34
		<priority value="INFO" />
35
		<appender-ref ref="CONSOLE" />
36
	</root>
37
</log4j:configuration>
tags/v_2_0_0_Build_2043/extensions/org.gvsig.app.document.table.app/org.gvsig.app.document.table.app.mainplugin/src/main/resources/config.xml
1
<?xml version="1.0" encoding="ISO-8859-1"?>
2
<plugin-config>
3
	<libraries library-dir="lib"/>
4
    <depends plugin-name="org.gvsig.app" />
5
	<resourceBundle name="text"/>
6
    <extensions>
7
		<extension class-name="org.gvsig.app.extension.TableExtension"
8
			description="Extensi?n encargada de a?adir soporte a documentos tabla."
9
			active="true"
10
			priority="10">
11

  
12
			<menu text="Tabla"
13
				position="400"
14
				is_separator="true"/>
15
				
16
		</extension>
17

  
18
		<extension class-name="org.gvsig.app.extension.ClearSelectionExtension"
19
			description="Extensi?n encargada de limpiar la selecci?n."
20
			active="true">
21
			<menu text="Capa/clear_selection" position="35010" action-command="DEL_SELECTION" icon="view-clear-selection"/>
22
			<tool-bar name="Tools_Select" position="6">
23
				<action-tool icon="view-clear-selection" action-command="DEL_SELECTION"  tooltip="clear_selection" position="4"/>
24
			</tool-bar>
25
		</extension>
26

  
27
		<extension class-name="org.gvsig.app.extension.ShowTable"
28
			description="Extensi?n encargada de abrir la tabla asociada a la capa seleccionado."
29
			active="true">
30
			<menu text="Capa/ver_tabla_atributos" position="35020" icon="layer-show-attribute-table"/>
31
			<tool-bar name="Acciones" position="13">
32
				<action-tool icon="layer-show-attribute-table"
33
					enableText="Un_Layer"
34
					tooltip="Muestra_atributos" position="1"/>
35
			</tool-bar>
36
		</extension>
37

  
38
		<extension class-name="org.gvsig.app.extension.TableOperations"
39
			description="Extensi?n encargada de gestionar las operaciones sobre las tablas."
40
			active="true">
41
			<menu text="Tabla/link" position="40010" icon="table-link" action-command="LINK"/>
42
			<tool-bar name="Herramientas" position="12">
43
				<action-tool icon="table-link" action-command="LINK" tooltip="link" position="2"/>
44
			</tool-bar>
45
		</extension>
46

  
47
		<extension class-name="org.gvsig.app.extension.RedoTableExtension"
48
			description="Extensi?n encargada de rehacer la edici?n sobre la capa activa."
49
			active="true">
50
			<menu text="Tabla/rehacer" position="40014" action-command="REDO" icon="table-redo"/>
51
			<tool-bar name="modificar" position="12">
52
				<action-tool name="rehacer" icon="table-redo" action-command="REDO" tooltip="rehacer" group="tabla" position="2"/>
53
			</tool-bar>
54
		</extension>
55

  
56
		<extension class-name="org.gvsig.app.extension.UndoTableExtension"
57
			description="Extensi?n encargada de dehacer la edici?n sobre la capa activa."
58
			active="true">
59
			<menu text="Tabla/deshacer" position="40016" action-command="UNDO" icon="table-undo"/>
60
			<tool-bar name="modificar" position="12">
61
				<action-tool name="deshacer" icon="table-undo" action-command="UNDO" tooltip="deshacer" group="tabla" position="1"/>
62
			</tool-bar>
63
		</extension>
64

  
65
		<extension class-name="org.gvsig.app.extension.TableEditStopExtension"
66
			description="Extensi?n encargada de gestionar las operaciones de edici?n sobre las tablas."
67
			active="true">
68
			<menu text="Tabla/stop_edition" position="40020" action-command="STOPEDITING"/>
69
		</extension>
70
		<extension class-name="org.gvsig.app.extension.TableEditStartExtension"
71
			description="Extensi?n encargada de gestionar las operaciones de edici?n sobre las tablas."
72
			active="true">
73
			<menu text="Tabla/start_edition" position="40024" action-command="STARTEDIT"/>
74
		</extension>
75
		<extension class-name="org.gvsig.app.extension.TableEditInsertExtension"
76
			description="Extensi?n encargada de gestionar las operaciones de edici?n sobre las tablas."
77
			active="true">
78
			<menu text="Tabla/insert_row" position="40026" action-command="INSERTROW"/>
79
		</extension>
80
		<extension class-name="org.gvsig.app.extension.TableEditRemoveRowExtension"
81
			description="Extensi?n encargada de gestionar las operaciones de edici?n sobre las tablas."
82
			active="true">
83
			<menu text="Tabla/remove_row" position="40030" action-command="REMOVEROW"/>
84
		</extension>
85
		<extension class-name="org.gvsig.app.extension.TableEditChangeColumnsExtension"
86
			description="Extensi?n encargada de gestionar las operaciones de edici?n de columnas sobre las tablas."
87
			active="true">
88
			<menu text="Tabla/add_column" position="40034" action-command="ADDCOLUMN"/>
89
			<menu text="Tabla/rename_column" position="40036" action-command="RENAMECOLUMN"/>
90
			<menu text="Tabla/remove_column" position="40040" action-command="REMOVECOLUMN"/>
91
		</extension>
92
		<extension class-name="org.gvsig.app.extension.TableEditAttributes"
93
			description="Extensi?n encargada de gestionar los campos de las tablas."
94
			active="true">
95
			<menu text="Tabla/manage_fields" position="40044" action-command="MANAGE_FIELDS"/>
96
		</extension>
97

  
98
		<extension class-name="org.gvsig.app.extension.TableEditCopyExtension"
99
			description="Extensi?n encargada de gestionar las operaciones de edici?n sobre las tablas."
100
			active="true">
101
			<menu text="Tabla/copy" position="40046" icon="edit-copy" action-command="COPY"/>
102
		</extension>
103

  
104
		<extension class-name="org.gvsig.app.extension.TableEditCutExtension"
105
			description="Extensi?n encargada de gestionar las operaciones de edici?n sobre las tablas."
106
			active="true">
107
			<menu text="Tabla/cut" position="40050" icon="edit-cut" action-command="CUT"/>
108
		</extension>
109

  
110
		<extension class-name="org.gvsig.app.extension.TableEditPasteExtension"
111
			description="Extensi?n encargada de gestionar las operaciones de edici?n sobre las tablas."
112
			active="true">
113
			<menu text="Tabla/paste" position="40054" icon="edit-paste" action-command="PASTE"/>
114
		</extension>
115

  
116
		<extension active="true" class-name="org.gvsig.app.extension.TableFieldOperations"
117
			description="Operaciones sobre los campos de las tablas">
118
			<menu text="Tabla/ascending_order" position="40056" icon="table-order-asc" action-command="ORDERASC"/>
119
			<menu text="Tabla/descending_order" position="40060" icon="table-order-desc" action-command="ORDERDESC"/>
120
			<tool-bar name="Herramientas" position="12">
121
				<action-tool icon="table-order-asc" tooltip="ascending_order_tooltip" action-command="ORDERASC" position="3"/>
122
				<action-tool icon="table-order-desc" tooltip="descending_order_tooltip" action-command="ORDERDESC" position="4"/>
123
			</tool-bar>
124
		</extension>
125

  
126
		<extension class-name="org.gvsig.app.extension.TableNumericFieldOperations"
127
			description="Extensi?n encargada de gestionar las operaciones sobre los campos num?ricos."
128
			active="true">
129
			<menu text="Tabla/statistics" position="40064" icon="table-statistics"/>
130
			<tool-bar name="Herramientas" position="12">
131
				<action-tool icon="table-statistics" tooltip="statistics" position="5"/>
132
			</tool-bar>
133
		</extension>
134

  
135
		<extension class-name="org.gvsig.app.extension.TableRowsOperations"
136
			description="Extensi?n encargada de gestionar la selecci?n en la tabla."
137
			active="true">
138
			<menu text="Tabla/selection_up" position="40066" action-command="SELECTIONUP" icon="table-selection-up"/>
139
			<menu text="Tabla/invert_selection" position="40070" action-command="INVERTSELECTION" icon="table-invert"/>
140
			<tool-bar name="Herramientas" position="12">
141
				<action-tool icon="table-selection-up" action-command="SELECTIONUP" tooltip="selection_up" position="6"/>
142
				<action-tool icon="table-invert" action-command="INVERTSELECTION" tooltip="invert_selection" position="7"/>
143
			</tool-bar>
144
		</extension>
145

  
146
		<extension class-name="org.gvsig.app.extension.RemoveTableLink"
147
			description="Extensi?n encargada de quitar los enlaces de las tablas."
148
			active="true">
149
			<menu text="Tabla/quitar_enlaces" position="40076" />
150
		</extension>
151

  
152
		<extension class-name="org.gvsig.app.extension.PrintTable"
153
			description="Extensi?n encargada de la impresi?n de las tablas."
154
			active="true">
155
			<menu text="Tabla/Imprimir" position="40080" icon="document-print" action-command="PRINTTABLE" tooltip="Imprimir"/>
156
			<tool-bar name="Tabla" position="10">
157
				<action-tool icon="document-print" action-command="PRINTTABLE" tooltip="Imprimir"/>
158
			</tool-bar>
159
		</extension>
160
        
161
        <extension class-name="org.gvsig.app.extension.ZoomToSelectExtension"
162
            description="Extensi?n encargada de gestionar los eventos realizados sobre una capa."
163
            active="true">
164
            <menu text="Vista/navegacion/Zoom_Select" position="3002090" action-command="ZOOM_SELECT" icon="view-zoom-to-seleccion"/>
165
            <tool-bar name="View_Tools_Zooms" position="3">
166
                <action-tool icon="view-zoom-to-seleccion" action-command="ZOOM_SELECT"  tooltip="Zoom_Select" position="7"/>
167
            </tool-bar>
168
        </extension>
169

  
170
        <extension class-name="org.gvsig.app.extension.FiltroExtension"
171
            description="Extensi?n encargada de abrir el di?logo para filtrar una tabla."
172
            active="true">
173
            <menu text="Tabla/filtro" position="40074" icon="table-filter" action-command="FILTRO"/>
174
            <tool-bar name="Herramientas" position="12">
175
                <action-tool icon="table-filter" action-command="FILTRO" tooltip="filtro" position="7"/>
176
            </tool-bar>
177
        </extension>
178

  
179
	</extensions>
180
	<icon src="gvsig-logo-icon" text="gvSIG"/>
181
</plugin-config>
tags/v_2_0_0_Build_2043/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/v_2_0_0_Build_2043/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/v_2_0_0_Build_2043/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/v_2_0_0_Build_2043/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/v_2_0_0_Build_2043/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/v_2_0_0_Build_2043/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/v_2_0_0_Build_2043/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/v_2_0_0_Build_2043/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/v_2_0_0_Build_2043/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);
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff