Revision 44437

View differences:

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/project/documents/table/TableManager.java
30 30
import java.util.function.Function;
31 31

  
32 32
import javax.swing.ImageIcon;
33
import javax.swing.JOptionPane;
33 34

  
34 35
import org.gvsig.andami.IconThemeHelper;
35 36
import org.gvsig.andami.PluginServices;
......
58 59
import org.gvsig.fmap.dal.feature.FeatureQuery;
59 60
import org.gvsig.fmap.dal.feature.FeatureQueryOrder;
60 61
import org.gvsig.fmap.dal.feature.FeatureStore;
62
import org.gvsig.fmap.dal.feature.FeatureType;
61 63
import org.gvsig.fmap.dal.serverexplorer.filesystem.swing.FilesystemExplorerWizardPanel;
62 64
import org.gvsig.fmap.mapcontext.layers.vectorial.FLyrVect;
63 65
import org.gvsig.fmap.mapcontext.layers.vectorial.VectorLayer;
......
65 67
import org.gvsig.tools.dynobject.DynObjectManager;
66 68
import org.gvsig.tools.dynobject.DynStruct;
67 69
import org.gvsig.tools.evaluator.Evaluator;
70
import org.gvsig.tools.i18n.I18nManager;
68 71
import org.gvsig.tools.persistence.PersistenceManager;
72
import org.gvsig.tools.swing.api.ToolsSwingLocator;
73
import org.gvsig.tools.swing.api.threadsafedialogs.ThreadSafeDialogsManager;
69 74
import org.gvsig.tools.util.MappedIterator;
70 75
import org.gvsig.tools.util.UnmodifiableBasicSet;
71 76

  
......
206 211
                @SuppressWarnings("unchecked")
207 212
                List<TableDocument> docs =
208 213
                    (List<TableDocument>) panel.executeWizard();
214
                for (TableDocument doc : docs) {
215
                    try {
216
                        FeatureStore store = ((TableDocument)doc).getDataStore();
217
                        FeatureType type = store.getDefaultFeatureType();
218
                        if( ! type.supportReferences() ) {
219
                            I18nManager i18n = ToolsLocator.getI18nManager();
220
                            ThreadSafeDialogsManager dialogs = ToolsSwingLocator.getThreadSafeDialogsManager();
221
                            dialogs.messageDialog(
222
                                    "\""+ doc.getName() + "\"\n"+
223
                                    i18n.getTranslation("_The_table_has_no_primary_key_or_OID") +"\n" +
224
                                           i18n.getTranslation("_Many_features_selection_deletion_modification_will_not_be_available_as_they_require_it_for_proper_operation"),
225
                                    null, 
226
                                    i18n.getTranslation("_Warning"),
227
                                    JOptionPane.WARNING_MESSAGE, 
228
                                    "TableDoNotSupportReferences"
229
                           );
230
                        }
231
                    } catch (Exception ex) {
232

  
233
                    }
234
                }
209 235
                return docs.iterator();
210 236
            }
211 237
        } catch (Exception e) {
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/SelectByAttributesInTableExtension.java
32 32
import org.gvsig.andami.plugins.Extension;
33 33
import org.gvsig.andami.ui.mdiManager.IWindow;
34 34
import org.gvsig.app.ApplicationLocator;
35
import org.gvsig.app.ApplicationManager;
35 36
import org.gvsig.app.gui.filter.ExpressionListener;
36 37
import org.gvsig.app.gui.filter.FilterDialog;
38
import org.gvsig.app.project.documents.table.TableDocument;
39
import org.gvsig.app.project.documents.table.TableManager;
37 40
import org.gvsig.app.project.documents.table.gui.FeatureTableDocumentPanel;
38 41
import org.gvsig.fmap.dal.DALLocator;
39 42
import org.gvsig.fmap.dal.DataManager;
......
43 46
import org.gvsig.fmap.dal.feature.FeatureSelection;
44 47
import org.gvsig.fmap.dal.feature.FeatureSet;
45 48
import org.gvsig.fmap.dal.feature.FeatureStore;
49
import org.gvsig.fmap.dal.feature.FeatureType;
46 50
import org.gvsig.i18n.Messages;
47 51
import org.gvsig.tools.dispose.DisposeUtils;
48 52
import org.gvsig.tools.swing.api.windowmanager.WindowManager;
......
113 117

  
114 118
    @Override
115 119
    public boolean isEnabled() {
116
        return isVisible();
120
        ApplicationManager application = ApplicationLocator.getManager();
121
        TableDocument doc = (TableDocument) application.getActiveDocument(TableManager.TYPENAME);
122
        if (doc == null) {
123
            return false;
124
        }
125
        FeatureTableDocumentPanel tablePanel = (FeatureTableDocumentPanel) doc.getMainComponent();
126
        if( tablePanel == null ) {
127
            return false;
128
        }
129
        FeatureStore store = tablePanel.getFeatureStore();
130
        try {
131
            if( ! store.getFeatureSelection().isAvailable() ) {
132
                return false;
133
            }
134
        } catch (Exception ex) {
135
        }                        
136
        
137
        return  true;
117 138
    }
118 139

  
119 140
    @Override
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/ShowTable.java
22 22
 */
23 23
package org.gvsig.app.extension;
24 24

  
25
import javax.swing.JOptionPane;
25 26
import org.gvsig.andami.IconThemeHelper;
26
import org.gvsig.andami.PluginServices;
27 27
import org.gvsig.andami.plugins.Extension;
28 28
import org.gvsig.andami.ui.mdiManager.IWindow;
29 29
import org.gvsig.app.ApplicationLocator;
......
34 34
import org.gvsig.app.project.documents.table.TableManager;
35 35
import org.gvsig.app.project.documents.view.ViewDocument;
36 36
import org.gvsig.app.project.documents.view.ViewManager;
37
import org.gvsig.fmap.dal.feature.FeatureStore;
38
import org.gvsig.fmap.dal.feature.FeatureType;
37 39
import org.gvsig.fmap.mapcontext.MapContext;
38 40
import org.gvsig.fmap.mapcontext.layers.CancelationException;
39 41
import org.gvsig.fmap.mapcontext.layers.FLayer;
......
42 44
import org.gvsig.fmap.mapcontext.layers.LayerCollectionListener;
43 45
import org.gvsig.fmap.mapcontext.layers.LayerPositionEvent;
44 46
import org.gvsig.fmap.mapcontext.layers.vectorial.FLyrVect;
47
import org.gvsig.tools.ToolsLocator;
48
import org.gvsig.tools.i18n.I18nManager;
49
import org.gvsig.tools.swing.api.ToolsSwingLocator;
50
import org.gvsig.tools.swing.api.threadsafedialogs.ThreadSafeDialogsManager;
45 51
import org.gvsig.tools.util.ArrayUtils;
46 52

  
47 53
/**
......
95 101

  
96 102
            for (FLayer layer : layers) {
97 103
                if (layer instanceof FLyrVect) {
98
                    FLyrVect layerVect = (FLyrVect) layer;
104
                    FLyrVect layerVect = (FLyrVect) layer;                    
99 105
                    TableDocument tableDoc = tableManager.getTableDocument(layerVect);
100 106
                    if (tableDoc == null) {
101 107
                        tableDoc = (TableDocument) tableManager.createDocument();
......
105 111
                        layerVect.getParentLayer().addLayerCollectionListener(this);
106 112
                        project.addDocument(tableDoc);
107 113
                    }
114
                    try {
115
                        FeatureStore store = tableDoc.getDataStore();
116
                        FeatureType type = store.getDefaultFeatureType();
117
                        if( ! type.supportReferences() ) {
118
                            I18nManager i18n = ToolsLocator.getI18nManager();
119
                            ThreadSafeDialogsManager dialogs = ToolsSwingLocator.getThreadSafeDialogsManager();
120
                            dialogs.messageDialog(
121
                                    "\""+ store.getName() + "\"\n"+
122
                                    i18n.getTranslation("_The_table_has_no_primary_key_or_OID") +"\n" +
123
                                           i18n.getTranslation("_Many_features_selection_deletion_modification_will_not_be_available_as_they_require_it_for_proper_operation"),
124
                                    null, 
125
                                    i18n.getTranslation("_Warning"),
126
                                    JOptionPane.WARNING_MESSAGE, 
127
                                    "TableDoNotSupportReferences"
128
                           );
129
                        }
130
                    } catch (Exception ex) {
131

  
132
                    }
133
                    
108 134
                    IWindow tablePanel = tableManager.getMainWindow(tableDoc);
109 135
                    tableDoc.setModified(true);
110 136
                    application.getUIManager().addWindow(tablePanel);
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/TableOperations.java
23 23
 */
24 24
package org.gvsig.app.extension;
25 25

  
26
import java.awt.Component;
27 26
import java.awt.Dimension;
28 27
import java.util.List;
29 28

  
......
73 72

  
74 73
    private FeatureStore featureStore = null;
75 74

  
75
    @Override
76 76
    public void execute(String actionCommand) {
77 77
        
78 78
        I18nManager i18n = ToolsLocator.getI18nManager();
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/ShowTableAsForm.java
1 1
package org.gvsig.app.extension;
2 2

  
3 3
import java.awt.Dimension;
4
import javax.swing.JComponent;
5 4
import javax.swing.JOptionPane;
6 5
import org.gvsig.andami.plugins.Extension;
7 6
import org.gvsig.app.ApplicationLocator;
......
14 13
import org.gvsig.featureform.swing.JFeaturesForm;
15 14
import org.gvsig.fmap.dal.exception.DataException;
16 15
import org.gvsig.fmap.dal.feature.FeatureStore;
16
import org.gvsig.fmap.dal.feature.FeatureType;
17 17
import org.gvsig.fmap.dal.swing.DALSwingLocator;
18 18
import org.gvsig.fmap.dal.swing.DataSwingManager;
19 19
import org.gvsig.tools.service.ServiceException;
......
23 23

  
24 24
public class ShowTableAsForm extends Extension {
25 25

  
26
    private static final Logger logger = LoggerFactory.getLogger(ShowTableAsForm.class);
27

  
28 26
    @Override
29 27
    public void initialize() {
30 28
    }
......
62 60

  
63 61
    @Override
64 62
    public boolean isEnabled() {
65
        return true;
63
        ApplicationManager application = ApplicationLocator.getManager();
64
        TableDocument doc = (TableDocument) application.getActiveDocument(TableManager.TYPENAME);
65
        return doc != null;
66 66
    }
67 67

  
68 68
    @Override
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/TableRowsOperations.java
23 23
 */
24 24
package org.gvsig.app.extension;
25 25

  
26
import javax.swing.JOptionPane;
27 26

  
28 27
import org.gvsig.andami.IconThemeHelper;
29 28
import org.gvsig.andami.PluginServices;
30
import org.gvsig.andami.messages.NotificationManager;
31 29
import org.gvsig.andami.plugins.Extension;
32 30
import org.gvsig.andami.ui.mdiManager.IWindow;
33
import org.gvsig.app.ApplicationLocator;
34 31
import org.gvsig.app.project.documents.table.gui.FeatureTableDocumentPanel;
35 32
import org.gvsig.fmap.dal.exception.DataException;
36 33
import org.gvsig.fmap.dal.feature.FeatureStore;
37
import org.gvsig.i18n.Messages;
34
import org.gvsig.fmap.dal.feature.FeatureType;
38 35

  
39 36
public class TableRowsOperations extends Extension {
40 37

  
38
    @Override
41 39
    public void initialize() {
42 40
        registerIcons();
43 41
    }
......
48 46
    	IconThemeHelper.registerIcon("action", "selection-reverse", this);    
49 47
    }
50 48

  
49
    @Override
51 50
    public void execute(String actionCommand) {
52 51
        FeatureTableDocumentPanel tableDocument = getTableDocument();
53 52
        if (actionCommand.equalsIgnoreCase("selection-disable-move-up") ) {
......
83 82
            FeatureStore fs = getTableDocument().getModel().getStore();
84 83
            fs.getFeatureSelection().reverse();
85 84
        } catch (DataException e) {
86
            e.printStackTrace();
87
            NotificationManager.addError(e);
85
            logger.warn("Can't invert selecction", e);
88 86
        }
89 87
    }
90 88

  
91
//    private void showsSelectedRows(FeatureTableDocumentPanel table) {
92
//        table.setSelectionUp(true);
93
//    }
94

  
89
    @Override
95 90
    public boolean isEnabled() {
96
        return getTableDocument() != null;
91
        FeatureTableDocumentPanel panel = getTableDocument();
92
        if( panel == null ) {
93
            return false;
94
        }
95
        FeatureStore store = panel.getFeatureStore();
96
        try {
97
            if( !store.getFeatureSelection().isAvailable() ) {
98
                return false;
99
            }
100
        } catch (Exception ex) {
101
        }                        
102
        
103
        return  true;
97 104
    }
98 105

  
106
    @Override
99 107
    public boolean isVisible() {
100 108
        return getTableDocument() != null;
101 109
    }
......
114 122
            try {
115 123
                return !tabledoc.getModel().getStore()
116 124
                    .getFeatureSelection().isEmpty();
117
            } catch (DataException e) {
118
                NotificationManager.addError(e);
125
            } catch (Exception e) {
126
                logger.warn("Can't check if table has a selecction", e);
119 127
            }
120 128
        }
121 129
        return false;
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/TableEditStartExtension.java
32 32
import org.gvsig.fmap.dal.EditingNotificationManager;
33 33
import org.gvsig.fmap.dal.exception.DataException;
34 34
import org.gvsig.fmap.dal.feature.FeatureStore;
35
import org.gvsig.fmap.dal.feature.FeatureType;
35 36
import org.gvsig.fmap.dal.swing.DALSwingLocator;
36 37
import org.gvsig.tools.util.ArrayUtils;
37
import org.slf4j.Logger;
38
import org.slf4j.LoggerFactory;
39 38

  
40 39
public class TableEditStartExtension extends AbstractTableEditExtension {
41 40

  
42
    private static final Logger logger = LoggerFactory.getLogger(TableEditStartExtension.class);
43

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

  
47
    @Override
50 48
    public void execute(String actionCommand) {
51 49
        this.execute(actionCommand,null);
52 50
    }
......
81 79
        }
82 80
    }
83 81

  
82
    @Override
84 83
    public boolean isEnabled() {
85 84
        IWindow v = PluginServices.getMDIManager().getActiveWindow();
86 85

  
......
88 87
            return false;
89 88
        }
90 89
        if (v instanceof FeatureTableDocumentPanel) {
91
            FeatureTableDocumentPanel t = (FeatureTableDocumentPanel) v;
92
            FeatureStore fs = t.getModel().getStore();
93
            return fs.allowWrite();
90
            try {
91
                FeatureTableDocumentPanel t = (FeatureTableDocumentPanel) v;
92
                FeatureStore fs = t.getModel().getStore();
93
                if( ! fs.allowWrite() || !fs.supportReferences() ) {
94
                    return false;
95
                }
96
                return true;
97
            } catch (Exception ex) {
98
                return false;
99
            }
94 100
        }
95 101
        return false;
96 102
    }
97 103

  
104
    @Override
98 105
    public boolean isVisible() {
99 106
        IWindow v = PluginServices.getMDIManager().getActiveWindow();
100 107

  
trunk/org.gvsig.desktop/org.gvsig.desktop.plugin/org.gvsig.app.document.table.app/org.gvsig.app.document.table.app.mainplugin/src/main/resources-plugin/i18n/text.properties
59 59
_Select_table_duplicates=Seleccionar duplicados tabla
60 60
_Select_all_duplicates=Seleccionar todos los duplicados
61 61
_Select_all_duplicates_in_the_table=Seleccionar todos los duplicados de la tabla
62

  
trunk/org.gvsig.desktop/org.gvsig.desktop.plugin/org.gvsig.app.document.table.app/org.gvsig.app.document.table.app.mainplugin/src/main/resources-plugin/i18n/text_en.properties
58 58
_Column_information_XcolonX=Column information\:
59 59
_Select_table_duplicates=Select table duplicates
60 60
_Select_all_duplicates=Select all duplicates
61
_Select_all_duplicates_in_the_table=Select all duplicates in the table
61
_Select_all_duplicates_in_the_table=Select all duplicates in the table
trunk/org.gvsig.desktop/org.gvsig.desktop.plugin/org.gvsig.app/org.gvsig.app.mainplugin/src/main/java/org/gvsig/app/extension/ViewSelectionByTheme.java
31 31
import org.gvsig.app.gui.selectionByTheme.SelectionByTheme;
32 32
import org.gvsig.app.project.documents.view.ViewDocument;
33 33
import org.gvsig.app.project.documents.view.gui.IView;
34
import org.gvsig.fmap.dal.feature.FeatureStore;
35
import org.gvsig.fmap.dal.feature.FeatureType;
36
import org.gvsig.fmap.mapcontext.layers.FLayer;
37
import org.gvsig.fmap.mapcontext.layers.vectorial.FLyrVect;
34 38
import org.gvsig.tools.ToolsLocator;
35 39
import org.gvsig.tools.i18n.I18nManager;
36 40
import org.gvsig.tools.swing.api.ToolsSwingLocator;
......
80 84
        }
81 85
    }
82 86

  
87
    @Override
83 88
    public boolean isEnabled() {
84 89
        ApplicationManager application = ApplicationLocator.getManager();
85 90

  
......
88 93
            return false;
89 94
        }
90 95
        ViewDocument document = view.getViewDocument();
91

  
92
        return document.getMapContext().hasActiveVectorLayers();
96
        if( document == null ) {
97
            return false;
98
        }
99
        boolean hasActiveVectorLayers = false;
100
        for (FLayer layer : document.getMapContext().getLayers()) {
101
            if( layer.isActive() && layer.isAvailable() && layer instanceof FLyrVect ) {
102
                try {
103
                    hasActiveVectorLayers = true;
104
                    FeatureStore store = ((FLyrVect)layer).getFeatureStore();
105
                    if( !store.getFeatureSelection().isAvailable() ) {
106
                        return false;
107
                    }
108
                } catch (Exception ex) {
109
                }
110
            }
111
        }
112
        return hasActiveVectorLayers;
93 113
    }
94 114

  
95 115
    public boolean isVisible() {
trunk/org.gvsig.desktop/org.gvsig.desktop.plugin/org.gvsig.app/org.gvsig.app.mainplugin/src/main/java/org/gvsig/app/extension/SearchByAttributesExtension.java
1 1
package org.gvsig.app.extension;
2 2

  
3
import javax.swing.JOptionPane;
3 4
import org.gvsig.andami.plugins.Extension;
4 5
import org.gvsig.app.ApplicationLocator;
5 6
import org.gvsig.app.ApplicationManager;
6 7
import org.gvsig.app.project.documents.view.ViewDocument;
7 8
import org.gvsig.app.project.documents.view.gui.IView;
8 9
import org.gvsig.fmap.dal.feature.FeatureStore;
10
import org.gvsig.fmap.dal.feature.FeatureType;
9 11
import org.gvsig.fmap.dal.swing.DALSwingLocator;
10 12
import org.gvsig.fmap.dal.swing.DataSwingManager;
11 13
import org.gvsig.fmap.dal.swing.searchpanel.FeatureStoreSearchPanel;
12 14
import org.gvsig.fmap.mapcontext.layers.FLayer;
13 15
import org.gvsig.fmap.mapcontext.layers.vectorial.FLyrVect;
16
import org.gvsig.tools.ToolsLocator;
17
import org.gvsig.tools.i18n.I18nManager;
14 18
import org.gvsig.tools.swing.api.ToolsSwingLocator;
19
import org.gvsig.tools.swing.api.threadsafedialogs.ThreadSafeDialogsManager;
15 20
import org.gvsig.tools.swing.api.windowmanager.WindowManager;
16 21

  
17 22
/**
......
42 47
            String title = "Search: " + layer.getName();
43 48
            FeatureStore featureStore = ((FLyrVect) layer).getFeatureStore();
44 49
            
50
            try {
51
                FeatureType type = featureStore.getDefaultFeatureType();
52
                if( ! type.supportReferences() ) {
53
                    I18nManager i18n = ToolsLocator.getI18nManager();
54
                    ThreadSafeDialogsManager dialogs = ToolsSwingLocator.getThreadSafeDialogsManager();
55
                    dialogs.messageDialog(
56
                           i18n.getTranslation("_The_table_has_no_primary_key_or_OID") +"\n" +
57
                                   i18n.getTranslation("_Many_features_selection_deletion_modification_will_not_be_available_as_they_require_it_for_proper_operation"),
58
                           null, 
59
                           i18n.getTranslation("_Warning"),
60
                            JOptionPane.WARNING_MESSAGE, 
61
                           "TableDoNotSupportReferences"
62
                   );
63
                }
64
            } catch (Exception ex) {
65
            }
66
            
45 67
            FeatureStoreSearchPanel panel = dataSwingManager.createFeatureStoreSearchPanel(featureStore);
46 68
            winManager.showWindow(
47 69
                    panel.asJComponent(), 
trunk/org.gvsig.desktop/org.gvsig.desktop.plugin/org.gvsig.app/org.gvsig.app.mainplugin/src/main/java/org/gvsig/app/extension/ViewInvertSelection.java
33 33
import org.gvsig.fmap.dal.DataStore;
34 34
import org.gvsig.fmap.dal.exception.DataException;
35 35
import org.gvsig.fmap.dal.feature.FeatureStore;
36
import org.gvsig.fmap.dal.feature.FeatureType;
36 37
import org.gvsig.fmap.mapcontext.MapContext;
37 38
import org.gvsig.fmap.mapcontext.layers.FLayer;
38 39
import org.gvsig.fmap.mapcontext.layers.operations.SingleLayer;
40
import org.gvsig.fmap.mapcontext.layers.vectorial.FLyrVect;
39 41
import org.slf4j.Logger;
40 42
import org.slf4j.LoggerFactory;
41 43

  
......
87 89
        }
88 90
    }
89 91

  
92
    @Override
90 93
    public boolean isEnabled() {
91 94
        ApplicationManager application = ApplicationLocator.getManager();
92 95

  
......
95 98
            return false;
96 99
        }
97 100
        ViewDocument document = view.getViewDocument();
98
        return document.getMapContext().hasActiveVectorLayers();
101
        if( document == null ) {
102
            return false;
103
        }
104
        boolean hasActiveVectorLayers = false;
105
        for (FLayer layer : document.getMapContext().getLayers()) {
106
            if( layer.isActive() && layer.isAvailable() && layer instanceof FLyrVect ) {
107
                try {
108
                    hasActiveVectorLayers = true;
109
                    FeatureStore store = ((FLyrVect)layer).getFeatureStore();
110
                    if( !store.getFeatureSelection().isAvailable() ) {
111
                        return false;
112
                    }
113
                } catch (Exception ex) {
114
                }
115
            }
116
        }
117
        return hasActiveVectorLayers;
99 118
    }
100 119

  
101 120
    public boolean isVisible() {
trunk/org.gvsig.desktop/org.gvsig.desktop.plugin/org.gvsig.app/org.gvsig.app.mainplugin/src/main/java/org/gvsig/app/extension/ZoomToSelectExtension.java
29 29
import org.gvsig.app.ApplicationManager;
30 30
import org.gvsig.app.project.documents.view.ViewDocument;
31 31
import org.gvsig.app.project.documents.view.gui.IView;
32
import org.gvsig.fmap.dal.feature.FeatureSelection;
33
import org.gvsig.fmap.dal.feature.FeatureStore;
34
import org.gvsig.fmap.dal.feature.FeatureType;
32 35
import org.gvsig.fmap.geom.primitive.Envelope;
33 36
import org.gvsig.fmap.mapcontext.MapContext;
34 37
import org.gvsig.fmap.mapcontext.layers.FLayer;
......
81 84
        return document.getMapContext().getLayers().getLayersCount() > 0;
82 85
    }
83 86

  
87
    @Override
84 88
    public boolean isEnabled() {
85 89
        ApplicationManager application = ApplicationLocator.getManager();
86 90

  
......
89 93
            return false;
90 94
        }
91 95
        ViewDocument document = view.getViewDocument();
92
        FLayer[] selected = document.getMapContext().getLayers().getActives();
93
        if (selected.length == 1 && selected[0] instanceof FLyrVect && selected[0].isAvailable()) {
94
            FLyrVect layer = (FLyrVect) selected[0];
95
            try {
96
                if (!layer.getFeatureStore().getFeatureSelection().isEmpty()) {
97
                    return true;
96
        if( document == null ) {
97
            return false;
98
        }
99
        boolean hasActiveVectorLayers = false;
100
        boolean hasSelection = false;
101
        for (FLayer layer : document.getMapContext().getLayers()) {
102
            if( layer.isActive() && layer.isAvailable() && layer instanceof FLyrVect ) {
103
                try {
104
                    hasActiveVectorLayers = true;
105
                    FeatureStore store = ((FLyrVect)layer).getFeatureStore();
106
                    FeatureSelection selection = store.getFeatureSelection();
107
                    if( !selection.isAvailable() ) {
108
                        return false;
109
                    }
110
                    if( !selection.isEmpty() ) {
111
                        hasSelection = true;
112
                    }
113
                } catch (Exception ex) {
98 114
                }
99
            } catch (Exception e) {
100
                String msg = "Can't check if selection if empty in layer '" + layer.getName() + "'.";
101
                logger.warn(msg, e);
102
                application.message(msg, JOptionPane.WARNING_MESSAGE);
103 115
            }
104 116
        }
105
        return false;
117
        return hasActiveVectorLayers && hasSelection;
106 118
    }
107 119

  
108 120
}
trunk/org.gvsig.desktop/org.gvsig.desktop.plugin/org.gvsig.app/org.gvsig.app.mainplugin/src/main/java/org/gvsig/app/extension/ShowLayerAsForm.java
68 68
                if (layer.isAvailable() && layer instanceof FLyrVect) {
69 69
                    try {
70 70
                        FLyrVect vectLayer = (FLyrVect) layer;
71
                        JFeaturesForm form = this.createform(vectLayer.getFeatureStore());
72
                        form.addAction(new SelectFeatureInTheViewAction(doc, form, layer));
73
                        form.showForm(WindowManager.MODE.WINDOW);
71
                        FeatureStore featureStore = vectLayer.getFeatureStore();
72
                        FeatureType type = featureStore.getDefaultFeatureType();
73
                        if( type.supportReferences() ) {
74
                            JFeaturesForm form = this.createform(featureStore);
75
                            form.addAction(new SelectFeatureInTheViewAction(doc, form, layer));
76
                            form.showForm(WindowManager.MODE.WINDOW);
77
                        }
74 78
                    } catch (Exception ex) {
75 79
                        String msg = "Can't show form for layer '" + layer.getName() + "'.";
76 80
                        logger.warn(msg, ex);
trunk/org.gvsig.desktop/org.gvsig.desktop.plugin/org.gvsig.app/org.gvsig.app.mainplugin/src/main/java/org/gvsig/app/extension/ClearSelectionExtension.java
31 31
import org.gvsig.app.project.documents.view.gui.IView;
32 32
import org.gvsig.fmap.dal.exception.DataException;
33 33
import org.gvsig.fmap.dal.exception.ReadException;
34
import org.gvsig.fmap.dal.feature.FeatureSelection;
34 35
import org.gvsig.fmap.dal.feature.FeatureStore;
36
import org.gvsig.fmap.dal.feature.FeatureType;
35 37
import org.gvsig.fmap.mapcontext.MapContext;
36 38
import org.gvsig.fmap.mapcontext.layers.FLayer;
37 39
import org.gvsig.fmap.mapcontext.layers.FLayers;
......
114 116
            return false;
115 117
        }
116 118
        ViewDocument document = view.getViewDocument();
117
        MapContext mapa = document.getMapContext();
118
        return hasVectorLayersWithSelection(mapa.getLayers());
119
        if( document == null ) {
120
            return false;
121
        }
122
        boolean hasActiveVectorLayers = false;
123
        boolean hasSelection = false;
124
        for (FLayer layer : document.getMapContext().getLayers()) {
125
            if( layer.isActive() && layer.isAvailable() && layer instanceof FLyrVect ) {
126
                try {
127
                    hasActiveVectorLayers = true;
128
                    FeatureStore store = ((FLyrVect)layer).getFeatureStore();
129
                    FeatureSelection selection = store.getFeatureSelection();
130
                    if( !selection.isAvailable() || selection.isEmpty() ) {
131
                        return false;
132
                    }
133
                } catch (Exception ex) {
134
                }
135
            }
136
        }
137
        return hasActiveVectorLayers && hasSelection;
119 138
    }
120 139

  
121 140
    private boolean hasVectorLayersWithSelection(FLayers layers) {
trunk/org.gvsig.desktop/org.gvsig.desktop.plugin/org.gvsig.app/org.gvsig.app.mainplugin/src/main/java/org/gvsig/app/extension/ViewSelectionControls.java
28 28
import org.gvsig.app.ApplicationManager;
29 29
import org.gvsig.app.project.documents.view.ViewDocument;
30 30
import org.gvsig.app.project.documents.view.gui.IView;
31
import org.gvsig.fmap.dal.feature.FeatureStore;
32
import org.gvsig.fmap.dal.feature.FeatureType;
33
import org.gvsig.fmap.mapcontext.layers.FLayer;
34
import org.gvsig.fmap.mapcontext.layers.vectorial.FLyrVect;
31 35
import org.gvsig.fmap.mapcontrol.MapControl;
32 36
import org.slf4j.Logger;
33 37
import org.slf4j.LoggerFactory;
......
52 56
        IconThemeHelper.registerIcon("action", "selection-clear", this);
53 57
    }
54 58

  
59
    @Override
55 60
    public void execute(String actionCommand) {
56 61
        ApplicationManager application = ApplicationLocator.getManager();
57 62

  
......
73 78
        }
74 79
    }
75 80

  
81
    @Override
76 82
    public boolean isEnabled() {
77 83
        ApplicationManager application = ApplicationLocator.getManager();
78 84

  
......
81 87
            return false;
82 88
        }
83 89
        ViewDocument document = view.getViewDocument();
84
        return document.getMapContext().hasActiveVectorLayers();
90
        if( document == null ) {
91
            return false;
92
        }
93
        boolean hasActiveVectorLayers = false;
94
        for (FLayer layer : document.getMapContext().getLayers()) {
95
            if( layer.isActive() && layer.isAvailable() && layer instanceof FLyrVect ) {
96
                try {
97
                    hasActiveVectorLayers = true;
98
                    FeatureStore store = ((FLyrVect)layer).getFeatureStore();
99
                    if( !store.getFeatureSelection().isAvailable() ) {
100
                        return false;
101
                    }
102
                } catch (Exception ex) {
103
                }
104
            }
105
        }
106
        return hasActiveVectorLayers ;
85 107
    }
86 108

  
109
    @Override
87 110
    public boolean isVisible() {
88 111
        ApplicationManager application = ApplicationLocator.getManager();
89 112

  
trunk/org.gvsig.desktop/org.gvsig.desktop.plugin/org.gvsig.app/org.gvsig.app.mainplugin/src/main/java/org/gvsig/app/extension/SelectByAttributesExtension.java
44 44
import org.gvsig.fmap.dal.feature.FeatureSelection;
45 45
import org.gvsig.fmap.dal.feature.FeatureSet;
46 46
import org.gvsig.fmap.dal.feature.FeatureStore;
47
import org.gvsig.fmap.dal.feature.FeatureType;
47 48
import org.gvsig.fmap.mapcontext.layers.FLayer;
48 49
import org.gvsig.fmap.mapcontext.layers.vectorial.FLyrVect;
49 50
import org.gvsig.i18n.Messages;
......
116 117

  
117 118
    @Override
118 119
    public boolean isEnabled() {
119
        return true;
120
        ApplicationManager application = ApplicationLocator.getManager();
121

  
122
        IView view = (IView) application.getActiveComponent(ViewDocument.class);
123
        if (view == null) {
124
            return false;
125
        }
126
        ViewDocument document = view.getViewDocument();
127
        if( document == null ) {
128
            return false;
129
        }
130
        boolean hasActiveVectorLayers = false;
131
        for (FLayer layer : document.getMapContext().getLayers()) {
132
            if( layer.isActive() && layer.isAvailable() && layer instanceof FLyrVect ) {
133
                try {
134
                    hasActiveVectorLayers = true;
135
                    FeatureStore store = ((FLyrVect)layer).getFeatureStore();
136
                    if( !store.getFeatureSelection().isAvailable() ) {
137
                        return false;
138
                    }
139
                } catch (Exception ex) {
140
                }
141
            }
142
        }
143
        return hasActiveVectorLayers;
120 144
    }
121 145

  
122 146
    @Override
trunk/org.gvsig.desktop/org.gvsig.desktop.plugin/org.gvsig.app/org.gvsig.app.mainplugin/src/main/resources-plugin/i18n/text_en.properties
1296 1296
_Add=Add
1297 1297
_Update=Update
1298 1298
_Remove=Remove
1299
_The_table_has_no_primary_key_or_OID=The table has no primary key or OID.
1300
_Many_features_selection_deletion_modification_will_not_be_available_as_they_require_it_for_proper_operation=Many features (selection, deletion, modification ...) will not be available as they require it for proper operation.
trunk/org.gvsig.desktop/org.gvsig.desktop.plugin/org.gvsig.app/org.gvsig.app.mainplugin/src/main/resources-plugin/i18n/text.properties
1377 1377
_Add=A\u00f1adir
1378 1378
_Update=Actualizar
1379 1379
_Remove=Eliminar
1380
_The_table_has_no_primary_key_or_OID=La tabla no tiene clave primario ni OID.
1381
_Many_features_selection_deletion_modification_will_not_be_available_as_they_require_it_for_proper_operation=Muchas funcionalidades (selecci\u00f3n, borrado, modificaci\u00f3n...) no estar\u00e1n disponibles ya que lo requieren para su correcto funcionamiento.
1380 1382

  

Also available in: Unified diff