Statistics
| Revision:

svn-gvsig-desktop / branches / v2_0_0_prep / applications / appgvSIG / src / com / iver / cit / gvsig / TableEditStartExtension.java @ 25089

History | View | Annotate | Download (4.82 KB)

1
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
2
 *
3
 * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
4
 *
5
 * This program is free software; you can redistribute it and/or
6
 * modify it under the terms of the GNU General Public License
7
 * as published by the Free Software Foundation; either version 2
8
 * of the License, or (at your option) any later version.
9
 *
10
 * This program is distributed in the hope that it will be useful,
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 * GNU General Public License for more details.
14
 *
15
 * You should have received a copy of the GNU General Public License
16
 * along with this program; if not, write to the Free Software
17
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
18
 *
19
 * For more information, contact:
20
 *
21
 *  Generalitat Valenciana
22
 *   Conselleria d'Infraestructures i Transport
23
 *   Av. Blasco Ib??ez, 50
24
 *   46010 VALENCIA
25
 *   SPAIN
26
 *
27
 *      +34 963862235
28
 *   gvsig@gva.es
29
 *      www.gvsig.gva.es
30
 *
31
 *    or
32
 *
33
 *   IVER T.I. S.A
34
 *   Salamanca 50
35
 *   46005 Valencia
36
 *   Spain
37
 *
38
 *   +34 963163400
39
 *   dac@iver.es
40
 */
41
package com.iver.cit.gvsig;
42

    
43
import org.gvsig.fmap.dal.feature.FeatureStore;
44
import org.gvsig.project.document.table.gui.FeatureTableDocumentPanel;
45

    
46
import com.iver.andami.PluginServices;
47
import com.iver.andami.plugins.Extension;
48
import com.iver.andami.ui.mdiManager.IWindow;
49

    
50

    
51
/**
52
 * DOCUMENT ME!
53
 *
54
 * @author Vicente Caballero Navarro
55
 */
56
public class TableEditStartExtension extends Extension {
57
         /**
58
     * @see com.iver.andami.plugins.IExtension#initialize()
59
     */
60
    public void initialize() {
61
    }
62

    
63
    /**
64
     * @see com.iver.andami.plugins.IExtension#execute(java.lang.String)
65
     */
66
    public void execute(String actionCommand) {
67
            if ("STARTEDIT".equals(actionCommand)) {
68
                    IWindow v = PluginServices.getMDIManager().getActiveWindow();
69
//                        FIXME
70
//                    try {
71
//                            FeatureTableDocumentPanel table = (FeatureTableDocumentPanel) v;
72
////                          Driver drv = table.getModel().getModelo().getOriginalDriver();
73
////                          if (drv instanceof IWriteable)
74
////                          {
75
////                          IWriter writer = ((IWriteable) drv).getWriter();
76
////                          if (!writer.canSaveEdits())
77
////                          {
78
////                          JOptionPane.showMessageDialog(
79
////                          (Component) PluginServices.getMDIManager().getActiveWindow(),
80
////                          PluginServices.getText(this, "this_table_is_not_self_editable"),
81
////                          PluginServices.getText(this, "warning"),
82
////                          JOptionPane.WARNING_MESSAGE);
83
////                          return;
84
////                          }
85
////                          }
86
////                          else
87
////                          {
88
////                          JOptionPane.showMessageDialog(
89
////                          (Component) PluginServices.getMDIManager().getActiveWindow(),
90
////                          PluginServices.getText(this, "this_table_is_not_self_editable"),
91
////                          PluginServices.getText(this, "warning"),
92
////                          JOptionPane.WARNING_MESSAGE);
93
////                          return;
94
////                          }
95
//
96
//                            table.startEditing();
97
//                            /* IEditableSource edTable = (IEditableSource) table.getModel().getAssociatedTable();
98
//                             edTable.getCommandRecord().addCommandListener(table); */
99
//
100
//                    } catch (StartEditingTableException e) {
101
//                            e.printStackTrace();
102
//                    } catch (HeadlessException e) {
103
//                            e.printStackTrace();
104
//                    }
105
            }
106
    }
107

    
108
    /**
109
     * @see com.iver.andami.plugins.IExtension#isEnabled()
110
     */
111
    public boolean isEnabled() {
112
        IWindow v = PluginServices.getMDIManager().getActiveWindow();
113

    
114
        if (v == null) {
115
            return false;
116
        }
117
        if (v instanceof FeatureTableDocumentPanel)
118
        {
119
                FeatureTableDocumentPanel t = (FeatureTableDocumentPanel) v;
120
                    FeatureStore fs = t.getModel().getStore();
121
                    // FJP:
122
                    // Si est? linkada, por ahora no dejamos editar
123
                    // TODO: Esto evita la edici?n en un sentido, pero no en el otro
124
                    // Hay que permitir la edici?n, pero evitar que toquen el/los
125
                    // campos de uni?n. Para eso tendremos que a?adir alguna funci?n
126
                    // que indique si un campo est? involucrado en alguna uni?n, o
127
                    // quiz?s algo m?s gen?rico, algo que permita bloquear campos
128
                    // para que no se puedan editar.
129
                    if (t.getModel().getLinkTable() != null) {
130
                                return false;
131
                        }
132
//                    if (ies.getOriginalDriver() instanceof IWriteable)
133
//                    {
134
//                            return true;
135
//                    }
136
                    return fs.allowWrite();
137
        }
138
            return false;
139
    }
140

    
141
    /**
142
     * @see com.iver.andami.plugins.IExtension#isVisible()
143
     */
144
    public boolean isVisible() {
145
        IWindow v = PluginServices.getMDIManager().getActiveWindow();
146

    
147
        if (v == null) {
148
            return false;
149
        }
150

    
151
        if (v instanceof FeatureTableDocumentPanel && !((FeatureTableDocumentPanel) v).getModel().getStore().isEditing() && ((FeatureTableDocumentPanel)v).getModel().getAssociatedLayer()==null) {
152
                       return true;
153
        }
154

    
155
        return false;
156
    }
157
}