23 |
23 |
*/
|
24 |
24 |
package org.gvsig.app.extension;
|
25 |
25 |
|
|
26 |
import javax.swing.JOptionPane;
|
|
27 |
|
26 |
28 |
import org.gvsig.andami.IconThemeHelper;
|
27 |
29 |
import org.gvsig.andami.PluginServices;
|
28 |
30 |
import org.gvsig.andami.messages.NotificationManager;
|
29 |
31 |
import org.gvsig.andami.plugins.Extension;
|
30 |
32 |
import org.gvsig.andami.ui.mdiManager.IWindow;
|
|
33 |
import org.gvsig.app.ApplicationLocator;
|
31 |
34 |
import org.gvsig.app.project.documents.table.gui.FeatureTableDocumentPanel;
|
32 |
35 |
import org.gvsig.fmap.dal.exception.DataException;
|
33 |
36 |
import org.gvsig.fmap.dal.feature.FeatureStore;
|
|
37 |
import org.gvsig.i18n.Messages;
|
34 |
38 |
|
35 |
39 |
public class TableRowsOperations extends Extension {
|
36 |
40 |
|
... | ... | |
46 |
50 |
public void execute(String actionCommand) {
|
47 |
51 |
FeatureTableDocumentPanel tableDocument = getTableDocument();
|
48 |
52 |
if (actionCommand.equalsIgnoreCase("selection-move-up") ) {
|
49 |
|
showsSelectedRows(tableDocument);
|
|
53 |
if (thereIsSelection(tableDocument)) {
|
|
54 |
showsSelectedRows(tableDocument);
|
|
55 |
tableDocument.getModel().setModified(true);
|
|
56 |
} else {
|
|
57 |
JOptionPane.showMessageDialog(
|
|
58 |
ApplicationLocator.getManager().getRootComponent(),
|
|
59 |
Messages.getText("_There_are_no_selected_rows"),
|
|
60 |
Messages.getText("_Move_up_selection"),
|
|
61 |
JOptionPane.INFORMATION_MESSAGE);
|
|
62 |
}
|
|
63 |
|
50 |
64 |
}
|
51 |
65 |
if (actionCommand.equalsIgnoreCase("selection-reverse") ) {
|
52 |
66 |
invertSelection(tableDocument);
|
|
67 |
tableDocument.getModel().setModified(true);
|
53 |
68 |
}
|
54 |
|
tableDocument.getModel().setModified(true);
|
|
69 |
|
55 |
70 |
}
|
56 |
71 |
|
57 |
72 |
/**
|
... | ... | |
74 |
89 |
}
|
75 |
90 |
|
76 |
91 |
public boolean isEnabled() {
|
77 |
|
FeatureTableDocumentPanel tableDocument = getTableDocument();
|
78 |
|
|
79 |
|
if (tableDocument != null) {
|
80 |
|
try {
|
81 |
|
return !tableDocument.getModel().getStore()
|
82 |
|
.getFeatureSelection().isEmpty();
|
83 |
|
} catch (DataException e) {
|
84 |
|
NotificationManager.addError(e);
|
85 |
|
}
|
86 |
|
}
|
87 |
|
|
88 |
|
return false;
|
|
92 |
return getTableDocument() != null;
|
89 |
93 |
}
|
90 |
94 |
|
91 |
95 |
public boolean isVisible() {
|
... | ... | |
99 |
103 |
}
|
100 |
104 |
return null;
|
101 |
105 |
}
|
|
106 |
|
|
107 |
private boolean thereIsSelection(FeatureTableDocumentPanel tabledoc) {
|
|
108 |
|
|
109 |
if (tabledoc != null) {
|
|
110 |
try {
|
|
111 |
return !tabledoc.getModel().getStore()
|
|
112 |
.getFeatureSelection().isEmpty();
|
|
113 |
} catch (DataException e) {
|
|
114 |
NotificationManager.addError(e);
|
|
115 |
}
|
|
116 |
}
|
|
117 |
return false;
|
|
118 |
|
|
119 |
}
|
102 |
120 |
}
|