Revision 44616 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
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