Revision 44616

View differences:

trunk/org.gvsig.desktop/org.gvsig.desktop.plugin/org.gvsig.geometrymeasurement.app/org.gvsig.geometrymeasurement.app.mainplugin/src/main/java/org/gvsig/geometrymeasurement/app/extension/AddXYPointThemeExtension.java
24 24
package org.gvsig.geometrymeasurement.app.extension;
25 25

  
26 26
import org.gvsig.andami.IconThemeHelper;
27
import org.gvsig.andami.PluginServices;
28 27
import org.gvsig.app.project.documents.table.TableDocument;
28
import org.gvsig.fmap.dal.DataStoreProviderFactory;
29 29
import org.gvsig.fmap.dal.feature.FeatureStore;
30
import org.gvsig.fmap.dal.feature.FeatureStoreProviderFactory;
30 31
import org.gvsig.fmap.geom.Geometry;
31 32
import org.gvsig.geometrymeasurement.app.extension.utils.Operations;
32 33

  
33 34
/**
34 35
 * Andami extension to show PerimeterMeasurementExtension in the application.
35
 * 
36
 *
36 37
 * @author gvSIG Team
37 38
 * @version $Id$
38 39
 */
39 40
public class AddXYPointThemeExtension extends
40
    AbstractGeometryMeasurementExtension {
41
        AbstractGeometryMeasurementExtension {
41 42

  
43
    @Override
42 44
    public void initialize() {
43 45
        super.initialize();
44 46
        IconThemeHelper.registerIcon("action", "table-add-xy", this);
45 47
    }
46 48

  
49
    @Override
47 50
    protected void execute(String actionCommand, FeatureStore featureStore)
48
        throws Exception {
51
            throws Exception {
49 52
        new Operations().addXYPoints(featureStore, "X", "Y");
50 53
    }
51 54

  
55
    @Override
52 56
    protected boolean isVisibleForTable(TableDocument tableDocument) {
53
        return isStoreOfAnyType(tableDocument, new int[] { Geometry.TYPES.POINT });
57
        DataStoreProviderFactory factory = tableDocument.getFeatureStore().getProviderFactory();
58
        if (factory instanceof FeatureStoreProviderFactory) {
59
            FeatureStoreProviderFactory ffactory = (FeatureStoreProviderFactory) factory;
60
            if (ffactory.allowEditableFeatureType() == FeatureStoreProviderFactory.NO) {
61
                return false;
62
            }
63
        }
64
        return isStoreOfAnyType(tableDocument, new int[]{Geometry.TYPES.POINT});
54 65
    }
55 66
}
trunk/org.gvsig.desktop/org.gvsig.desktop.plugin/org.gvsig.geometrymeasurement.app/org.gvsig.geometrymeasurement.app.mainplugin/src/main/java/org/gvsig/geometrymeasurement/app/extension/AreaMeasurementExtension.java
25 25

  
26 26
import org.gvsig.andami.IconThemeHelper;
27 27
import org.gvsig.app.project.documents.table.TableDocument;
28
import org.gvsig.fmap.dal.DataStoreProviderFactory;
28 29
import org.gvsig.fmap.dal.feature.FeatureStore;
30
import org.gvsig.fmap.dal.feature.FeatureStoreProviderFactory;
29 31
import org.gvsig.fmap.geom.Geometry;
30 32
import org.gvsig.geometrymeasurement.app.extension.utils.Operations;
31 33

  
32 34
/**
33 35
 * Andami extension to show AreaMeasurementExtension in the application.
34
 * 
36
 *
35 37
 * @author gvSIG Team
36 38
 * @version $Id$
37 39
 */
38 40
public class AreaMeasurementExtension extends
39
    AbstractGeometryMeasurementExtension {
41
        AbstractGeometryMeasurementExtension {
40 42

  
43
    @Override
41 44
    public void initialize() {
42
    super.initialize();
45
        super.initialize();
43 46
        IconThemeHelper.registerIcon("action", "table-add-area", this);
44 47
    }
45 48

  
46 49
    @Override
47 50
    protected void execute(String actionCommand, FeatureStore featureStore)
48
        throws Exception {
51
            throws Exception {
49 52
        new Operations().addDoubleFieldFromOperation(featureStore, "AREA",
50
            "area");
53
                "area");
51 54
    }
52 55

  
53 56
    @Override
54 57
    protected boolean isVisibleForTable(TableDocument tableDocument) {
55
        return isStoreOfAnyType(tableDocument, new int[] { Geometry.TYPES.SURFACE,
56
            Geometry.TYPES.MULTISURFACE });
58
        DataStoreProviderFactory factory = tableDocument.getFeatureStore().getProviderFactory();
59
        if (factory instanceof FeatureStoreProviderFactory) {
60
            FeatureStoreProviderFactory ffactory = (FeatureStoreProviderFactory) factory;
61
            if (ffactory.allowEditableFeatureType() == FeatureStoreProviderFactory.NO) {
62
                return false;
63
            }
64
        }
65
        return isStoreOfAnyType(tableDocument, new int[]{Geometry.TYPES.SURFACE,
66
            Geometry.TYPES.MULTISURFACE});
57 67
    }
58 68
}
trunk/org.gvsig.desktop/org.gvsig.desktop.plugin/org.gvsig.geometrymeasurement.app/org.gvsig.geometrymeasurement.app.mainplugin/src/main/java/org/gvsig/geometrymeasurement/app/extension/PerimeterMeasurementExtension.java
24 24
package org.gvsig.geometrymeasurement.app.extension;
25 25

  
26 26
import org.gvsig.andami.IconThemeHelper;
27
import org.gvsig.andami.PluginServices;
28 27
import org.gvsig.app.project.documents.table.TableDocument;
28
import org.gvsig.fmap.dal.DataStoreProviderFactory;
29 29
import org.gvsig.fmap.dal.feature.FeatureStore;
30
import org.gvsig.fmap.dal.feature.FeatureStoreProviderFactory;
30 31
import org.gvsig.fmap.geom.Geometry;
31 32
import org.gvsig.geometrymeasurement.app.extension.utils.Operations;
32 33

  
33 34
/**
34 35
 * Andami extension to show PerimeterMeasurementExtension in the application.
35
 * 
36
 *
36 37
 * @author gvSIG Team
37 38
 * @version $Id$
38 39
 */
39 40
public class PerimeterMeasurementExtension extends
40
    AbstractGeometryMeasurementExtension {
41
        AbstractGeometryMeasurementExtension {
41 42

  
43
    @Override
42 44
    public void initialize() {
43
    	super.initialize();
45
        super.initialize();
44 46
        IconThemeHelper.registerIcon("action", "table-add-perimeter", this);
45 47
    }
46 48

  
47 49
    @Override
48 50
    protected void execute(String actionCommand, FeatureStore featureStore)
49
        throws Exception {
51
            throws Exception {
50 52
        new Operations().addDoubleFieldFromOperation(featureStore, "PERIMETER",
51
            "perimeter");
53
                "perimeter");
52 54
    }
53 55

  
54 56
    @Override
55 57
    protected boolean isVisibleForTable(TableDocument tableDocument) {
56
        return !isStoreOfAnyType(tableDocument, new int[] { Geometry.TYPES.POINT,
58
        DataStoreProviderFactory factory = tableDocument.getFeatureStore().getProviderFactory();
59
        if (factory instanceof FeatureStoreProviderFactory) {
60
            FeatureStoreProviderFactory ffactory = (FeatureStoreProviderFactory) factory;
61
            if (ffactory.allowEditableFeatureType() == FeatureStoreProviderFactory.NO) {
62
                return false;
63
            }
64
        }
65
        return !isStoreOfAnyType(tableDocument, new int[]{Geometry.TYPES.POINT,
57 66
            Geometry.TYPES.MULTIPOINT});
58 67
    }
59 68

  
trunk/org.gvsig.desktop/org.gvsig.desktop.plugin/org.gvsig.geometrymeasurement.app/org.gvsig.geometrymeasurement.app.mainplugin/src/main/java/org/gvsig/geometrymeasurement/app/extension/AbstractGeometryMeasurementExtension.java
24 24
package org.gvsig.geometrymeasurement.app.extension;
25 25

  
26 26
import java.awt.Component;
27
import java.util.Locale;
28 27

  
29 28
import javax.swing.JOptionPane;
30 29

  
......
59 58
    //Just to know if the resources has been initialized
60 59
    private static boolean isInitialized = false;
61 60
       
61
    @Override
62 62
    public void initialize() {
63 63
        if (!isInitialized){
64 64
            isInitialized = true;
65 65
        }        
66 66
    }
67 67

  
68
    @Override
68 69
    public boolean isEnabled() {
69 70
        TableDocument tableDocument;
70 71
        String name = "unknow";
......
80 81
        return false;
81 82
    }
82 83

  
84
    @Override
83 85
    public final boolean isVisible() {
84 86
        TableDocument tableDocument;
85 87
        String name = "unknow";
......
148 150
        return false;
149 151
    }
150 152

  
153
    @Override
151 154
    public void execute(String actionCommand) {
152 155
        try {
153 156
            TableDocument tableDocument = getActiveTableDocument();
trunk/org.gvsig.desktop/org.gvsig.desktop.plugin/org.gvsig.app.document.table.app/org.gvsig.app.document.table.app.mainplugin/src/main/java/org/gvsig/app/extension/TableEditChangeColumnsExtension.java
31 31
import org.gvsig.app.project.documents.table.TableDocument;
32 32
import org.gvsig.app.project.documents.table.TableManager;
33 33
import org.gvsig.app.project.documents.table.gui.FeatureTableDocumentPanel;
34
import org.gvsig.fmap.dal.DataStoreProviderFactory;
34 35
import org.gvsig.fmap.dal.exception.DataException;
36
import org.gvsig.fmap.dal.feature.FeatureStore;
37
import org.gvsig.fmap.dal.feature.FeatureStoreProviderFactory;
35 38

  
36 39
/**
37 40
 * DOCUMENT ME!
38
 * 
41
 *
39 42
 * @author Vicente Caballero Navarro
40 43
 */
41 44
public class TableEditChangeColumnsExtension extends AbstractTableEditExtension {
42 45

  
43
	public void initialize() {
44
		super.initialize();
45
		IconThemeHelper.registerIcon("action", "table-rename-column", this);
46
		IconThemeHelper.registerIcon("action", "table-remove-column", this);
47
	}
46
    public void initialize() {
47
        super.initialize();
48
        IconThemeHelper.registerIcon("action", "table-rename-column", this);
49
        IconThemeHelper.registerIcon("action", "table-remove-column", this);
50
    }
51

  
48 52
    /**
49 53
     * @see org.gvsig.andami.plugins.IExtension#execute(java.lang.String)
50 54
     */
......
53 57
            featureTableOperations.setTablePanel(table);
54 58
            if ("table-remove-column".equals(actionCommand)) {
55 59
                featureTableOperations.deleteAttributes(table.getTablePanel()
56
                    .getTable());
57
            } else
58
                    if ("table-rename-column".equals(actionCommand)) {
59
                        featureTableOperations.renameAttributes(table
60
                            .getTablePanel().getTable());
61
                    }
60
                        .getTable());
61
            } else if ("table-rename-column".equals(actionCommand)) {
62
                featureTableOperations.renameAttributes(table
63
                        .getTablePanel().getTable());
64
            }
62 65
        } catch (DataException e) {
63 66
            NotificationManager.showMessageError(
64
                PluginServices.getText(this, "update_featuretype_error"), null);
67
                    PluginServices.getText(this, "update_featuretype_error"), null);
65 68
        }
66 69

  
67 70
    }
68 71

  
69
        @Override
72
    @Override
70 73
    public boolean isEnabled() {
71 74
        try {
75
            FeatureStore store = table.getFeatureStore();
76

  
77
            DataStoreProviderFactory factory = store.getProviderFactory();
78
            if (factory instanceof FeatureStoreProviderFactory) {
79
                FeatureStoreProviderFactory ffactory = (FeatureStoreProviderFactory) factory;
80
                if (ffactory.allowEditableFeatureType() == FeatureStoreProviderFactory.NO) {
81
                    return false;
82
                }
83
            }
72 84
            if (table.getTablePanel().getTable().getSelectedColumnCount() > 0) {
73 85
                return true;
74 86
            }
......
82 94
    public boolean isVisible() {
83 95
        ApplicationManager application = ApplicationLocator.getManager();
84 96
        TableDocument tableDoc = (TableDocument) application.getActiveDocument(TableManager.TYPENAME);
85
        if( tableDoc == null ) {
97
        if (tableDoc == null) {
86 98
            return false;
87 99
        }
88 100
        this.table = (FeatureTableDocumentPanel) tableDoc.getMainComponent();
89 101
        return true;
90 102
    }
91
    
92
    
103

  
93 104
}
trunk/org.gvsig.desktop/org.gvsig.desktop.plugin/org.gvsig.app.document.table.app/org.gvsig.app.document.table.app.mainplugin/src/main/java/org/gvsig/app/extension/TableEditAttributes.java
41 41
import org.gvsig.app.project.documents.table.TableManager;
42 42
import org.gvsig.app.project.documents.table.gui.FeatureTableDocumentPanel;
43 43
import org.gvsig.configurableactions.ConfigurableActionsMamager;
44
import org.gvsig.fmap.dal.DataStoreProviderFactory;
44 45
import org.gvsig.fmap.dal.DataTypes;
45 46
import org.gvsig.fmap.dal.feature.EditableFeatureAttributeDescriptor;
46 47
import org.gvsig.fmap.dal.feature.EditableFeatureType;
47 48
import org.gvsig.fmap.dal.feature.FeatureStore;
49
import org.gvsig.fmap.dal.feature.FeatureStoreProviderFactory;
48 50
import org.gvsig.fmap.dal.feature.FeatureType;
49 51
import org.gvsig.fmap.dal.swing.DALSwingLocator;
50 52
import org.gvsig.fmap.dal.swing.DataSwingManager;
......
61 63
/**
62 64
 * Extensi?n que abre la ventana para cambiar la configuraci?n de la estructura
63 65
 * de la tabla.
64
 * 
66
 *
65 67
 */
66 68
@SuppressWarnings("UseSpecificCatch")
67 69
public class TableEditAttributes extends Extension {
......
91 93
        final ApplicationManager application = ApplicationLocator.getManager();
92 94

  
93 95
        TableDocument tabledoc = (TableDocument) application.getActiveDocument(TableManager.TYPENAME);
94
        if( tabledoc == null ) {
96
        if (tabledoc == null) {
95 97
            return;
96 98
        }
97 99
//        final FeatureStore featureStore = tabledoc.getStore();
98 100
        final FeatureTableDocumentPanel tablePanel = (FeatureTableDocumentPanel) tabledoc.getMainComponent();
99 101
        final FeatureStore featureStore = tablePanel.getFeatureStore();
100 102

  
101
    	if( "table-column-manager".equalsIgnoreCase(s)) {
103
        if ("table-column-manager".equalsIgnoreCase(s)) {
102 104
            try {
103 105
                final FeatureType featureType = featureStore.getDefaultFeatureType();
104 106
                final EditableFeatureType editableFeatureType = featureType.getEditable();
105 107
                final FeatureTypePanel panel = dataSwingManager.createFeatureTypePanel();
106 108
                panel.put(editableFeatureType);
109
                FeatureStore store = tabledoc.getStore();
110

  
107 111
                panel.setMode(
108
                        featureStore.isEditing()? 
109
                                FeatureTypePanel.MODE_EDIT_ALL:
110
                                FeatureTypePanel.MODE_EDIT_ONLY_METADATA
112
                        featureStore.isEditing()
113
                        ? FeatureTypePanel.MODE_EDIT_ALL
114
                        : FeatureTypePanel.MODE_EDIT_ONLY_METADATA
111 115
                );
116
                DataStoreProviderFactory factory = store.getProviderFactory();
117
                if (factory instanceof FeatureStoreProviderFactory) {
118
                    FeatureStoreProviderFactory ffactory = (FeatureStoreProviderFactory) factory;
119
                    if (ffactory.allowEditableFeatureType() == FeatureStoreProviderFactory.NO) {
120
                        panel.setMode(FeatureTypePanel.MODE_SHOW_ONLY);
121
                    }
122
                }
123

  
112 124
                final Dialog dialog = winManager.createDialog(
113 125
                        panel.asJComponent(),
114 126
                        i18n.getTranslation("_Column_manager") + " - " + tabledoc.getName(),
115 127
                        null,
116
                       WindowManager_v2.BUTTONS_OK_CANCEL
128
                        WindowManager_v2.BUTTONS_OK_CANCEL
117 129
                );
118 130
                panel.addChangeListener(new ChangeListener() {
119 131
                    @Override
120 132
                    public void stateChanged(ChangeEvent e) {
121
                        if( panel.isModifyingAField() ) {
133
                        if (panel.isModifyingAField()) {
122 134
                            dialog.setButtonEnabled(WindowManager_v2.BUTTON_OK, false);
123 135
                        } else {
124 136
                            dialog.setButtonEnabled(WindowManager_v2.BUTTON_OK, true);
......
128 140
                dialog.addActionListener(new ActionListener() {
129 141
                    @Override
130 142
                    public void actionPerformed(ActionEvent e) {
131
                        if( dialog.getAction()!= WindowManager_v2.BUTTON_OK ) {
143
                        if (dialog.getAction() != WindowManager_v2.BUTTON_OK) {
132 144
                            return;
133 145
                        }
134 146
                        try {
......
160 172
                dialog.addActionListener(new ActionListener() {
161 173
                    @Override
162 174
                    public void actionPerformed(ActionEvent e) {
163
                        if( dialog.getAction()!=WindowManager_v2.BUTTONS_OK ) {
175
                        if (dialog.getAction() != WindowManager_v2.BUTTONS_OK) {
164 176
                            return;
165 177
                        }
166
                        if( !featureStore.isEditing() ) {
178
                        if (!featureStore.isEditing()) {
167 179
                            return;
168 180
                        }
169 181
                        try {
......
183 195
            } catch (Exception ex) {
184 196
                logger.warn("Problems show FeatureTypeAttributePanel.", ex);
185 197
            }
186
    		
187
    	}
198

  
199
        }
188 200
    }
189 201

  
190 202
    public static class ShowAsTableAction extends AbstractAction {
......
195 207

  
196 208
            this.putValue(NAME, i18n.getTranslation("_Show_as_table"));
197 209
            this.putValue(ACTION_COMMAND_KEY, "ShowAsTable");
198
        this.putValue(
199
                Action.SMALL_ICON, 
200
                ToolsSwingLocator.getIconThemeManager().getCurrent().get("layer-show-attributes-table")
201
        );
210
            this.putValue(
211
                    Action.SMALL_ICON,
212
                    ToolsSwingLocator.getIconThemeManager().getCurrent().get("layer-show-attributes-table")
213
            );
202 214
        }
203 215

  
204 216
        @Override
......
209 221

  
210 222
            ProjectManager projectManager = ApplicationLocator.getManager().getProjectManager();
211 223
            Project project = projectManager.getCurrentProject();
212
            TableDocument tableDoc = (TableDocument) project.getDocument(store.getName(),TableManager.TYPENAME);
213
            if( tableDoc == null ) {
224
            TableDocument tableDoc = (TableDocument) project.getDocument(store.getName(), TableManager.TYPENAME);
225
            if (tableDoc == null) {
214 226
                tableDoc = (TableDocument) projectManager.createDocument(TableManager.TYPENAME);
215 227
                tableDoc.setStore(store);
216 228
                tableDoc.setName(store.getName());
217 229
                project.addDocument(tableDoc);
218 230
            }
219 231
            ApplicationLocator.getManager().getUIManager().addWindow(tableDoc.getMainWindow());
220
            }
232
        }
221 233
    }
222 234

  
223 235
    @Override
......
225 237
        ApplicationManager application = ApplicationLocator.getManager();
226 238

  
227 239
        TableDocument tabledoc = (TableDocument) application.getActiveDocument(TableManager.TYPENAME);
228
        if( tabledoc == null ) {
240
        if (tabledoc == null) {
229 241
            return false;
230 242
        }
231 243
        return tabledoc.getStore().isEditing();
......
236 248
        ApplicationManager application = ApplicationLocator.getManager();
237 249

  
238 250
        TableDocument tabledoc = (TableDocument) application.getActiveDocument(TableManager.TYPENAME);
239
        return tabledoc!=null;
251
        return tabledoc != null;
240 252
    }
241 253

  
242 254
    @Override
......
249 261
        ApplicationManager application = ApplicationLocator.getManager();
250 262

  
251 263
        TableDocument tabledoc = (TableDocument) application.getActiveDocument(TableManager.TYPENAME);
252
        if( tabledoc == null ) {
264
        if (tabledoc == null) {
253 265
            return false;
254 266
        }
255
    	if( "table-column-manager".equalsIgnoreCase(action)) {
267
        if ("table-column-manager".equalsIgnoreCase(action)) {
256 268
            return true;
257
            
269

  
258 270
        } else if ("table-add-column".equals(action)) {
259
            return tabledoc.getStore().isEditing();
260
            
271
            FeatureStore store = tabledoc.getStore();
272

  
273
            DataStoreProviderFactory factory = store.getProviderFactory();
274
            if (factory instanceof FeatureStoreProviderFactory) {
275
                FeatureStoreProviderFactory ffactory = (FeatureStoreProviderFactory) factory;
276
                if (ffactory.allowEditableFeatureType() == FeatureStoreProviderFactory.NO) {
277
                    return false;
278
                } else {
279
                    return tabledoc.getStore().isEditing();
280
                }
281
            } else {
282
                return tabledoc.getStore().isEditing();
283
            }
284

  
261 285
        }
262 286
        return false;
263 287
    }
264
    
288

  
265 289
}

Also available in: Unified diff