svn-gvsig-desktop / 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 @ 40558
History | View | Annotate | Download (3.84 KB)
1 |
/**
|
---|---|
2 |
* gvSIG. Desktop Geographic Information System.
|
3 |
*
|
4 |
* Copyright (C) 2007-2013 gvSIG Association.
|
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 3
|
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 |
* For any additional information, do not hesitate to contact us
|
22 |
* at info AT gvsig.com, or visit our website www.gvsig.com.
|
23 |
*/
|
24 |
package org.gvsig.app.extension; |
25 |
|
26 |
import java.util.List; |
27 |
|
28 |
import org.gvsig.andami.IconThemeHelper; |
29 |
import org.gvsig.andami.PluginServices; |
30 |
import org.gvsig.andami.ui.mdiManager.IWindow; |
31 |
import org.gvsig.app.ApplicationLocator; |
32 |
import org.gvsig.app.project.documents.table.TableDocument.TableLink; |
33 |
import org.gvsig.app.project.documents.table.gui.FeatureTableDocumentPanel; |
34 |
import org.gvsig.fmap.dal.exception.DataException; |
35 |
import org.gvsig.fmap.dal.feature.FeatureStore; |
36 |
|
37 |
/**
|
38 |
* DOCUMENT ME!
|
39 |
*
|
40 |
* @author Vicente Caballero Navarro
|
41 |
*/
|
42 |
public class TableEditStartExtension extends AbstractTableEditExtension { |
43 |
|
44 |
|
45 |
public void initialize() { |
46 |
super.initialize();
|
47 |
IconThemeHelper.registerIcon("action", "table-start-editing", this); |
48 |
} |
49 |
/**
|
50 |
* @see org.gvsig.andami.plugins.IExtension#execute(java.lang.String)
|
51 |
*/
|
52 |
public void execute(String actionCommand) { |
53 |
if ("table-start-editing".equals(actionCommand)) { |
54 |
try {
|
55 |
table.getModel().getStore().edit(FeatureStore.MODE_FULLEDIT); |
56 |
ApplicationLocator.getManager().refreshMenusAndToolBars(); |
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 |
IWindow v = PluginServices.getMDIManager().getActiveWindow(); |
68 |
|
69 |
if (v == null) { |
70 |
return false; |
71 |
} |
72 |
if (v instanceof FeatureTableDocumentPanel) { |
73 |
FeatureTableDocumentPanel t = (FeatureTableDocumentPanel) v; |
74 |
FeatureStore fs = t.getModel().getStore(); |
75 |
// FJP:
|
76 |
// Si est? linkada, por ahora no dejamos editar
|
77 |
// TODO: Esto evita la edici?n en un sentido, pero no en el otro
|
78 |
// Hay que permitir la edici?n, pero evitar que toquen el/los
|
79 |
// campos de uni?n. Para eso tendremos que a?adir alguna funci?n
|
80 |
// que indique si un campo est? involucrado en alguna uni?n, o
|
81 |
// quiz?s algo m?s gen?rico, algo que permita bloquear campos
|
82 |
// para que no se puedan editar.
|
83 |
List<TableLink> links = t.getModel().getLinks();
|
84 |
if (links != null && links.size() > 0) { |
85 |
return false; |
86 |
} |
87 |
return fs.allowWrite();
|
88 |
} |
89 |
return false; |
90 |
} |
91 |
|
92 |
/**
|
93 |
* @see org.gvsig.andami.plugins.IExtension#isVisible()
|
94 |
*/
|
95 |
public boolean isVisible() { |
96 |
IWindow v = PluginServices.getMDIManager().getActiveWindow(); |
97 |
|
98 |
if (v == null) { |
99 |
return false; |
100 |
} |
101 |
|
102 |
if (v instanceof FeatureTableDocumentPanel |
103 |
&& !((FeatureTableDocumentPanel) v).getModel().getStore() |
104 |
.isEditing() |
105 |
&& ((FeatureTableDocumentPanel) v).getModel().getAssociatedLayer() == null) {
|
106 |
table = (FeatureTableDocumentPanel) v; |
107 |
return true; |
108 |
} |
109 |
|
110 |
return false; |
111 |
} |
112 |
} |