Statistics
| Revision:

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 / UndoTableExtension.java @ 40558

History | View | Annotate | Download (2.81 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 org.gvsig.andami.PluginServices;
27
import org.gvsig.andami.messages.NotificationManager;
28
import org.gvsig.andami.plugins.Extension;
29
import org.gvsig.app.project.documents.table.gui.FeatureTableDocumentPanel;
30
import org.gvsig.fmap.dal.feature.FeatureStore;
31
import org.gvsig.tools.undo.UndoException;
32

    
33
/**
34
 * Extensi?n encargada de gestionar el rehacer un comando anteriormente
35
 * deshecho.
36
 * 
37
 * @author Vicente Caballero Navarro
38
 */
39
public class UndoTableExtension extends Extension {
40

    
41
    private FeatureTableDocumentPanel table;
42

    
43
    /**
44
     * @see org.gvsig.andami.plugins.IExtension#initialize()
45
     */
46
    public void initialize() {
47
    }
48

    
49
    /**
50
     * @see org.gvsig.andami.plugins.IExtension#execute(java.lang.String)
51
     */
52
    public void execute(String s) {
53
            if( "edit-undo-table".equalsIgnoreCase(s)) {
54
            if (table.getModel().getStore().isEditing()) {
55
                FeatureStore fs = table.getModel().getStore();
56
                try {
57
                    fs.undo();
58
                } catch (UndoException e) {
59
                    NotificationManager.addError(e);
60
                }
61
            }
62
            table.getModel().setModified(true);
63
        }
64
    }
65

    
66
    /**
67
     * @see org.gvsig.andami.plugins.IExtension#isEnabled()
68
     */
69
    public boolean isEnabled() {
70
        FeatureStore fs = table.getModel().getStore();
71
        if (fs != null && fs.isEditing()) {
72
            return fs.canUndo();
73
        }
74

    
75
        return false;
76
    }
77

    
78
    /**
79
     * @see org.gvsig.andami.plugins.IExtension#isVisible()
80
     */
81
    public boolean isVisible() {
82
        org.gvsig.andami.ui.mdiManager.IWindow f =
83
            PluginServices.getMDIManager().getActiveWindow();
84
        if (f != null && f instanceof FeatureTableDocumentPanel) {
85
            table = (FeatureTableDocumentPanel) f;
86
            return true;
87
        }
88
        return false;
89
    }
90
}