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 / TableRefresh.java @ 42641

History | View | Annotate | Download (3.69 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.IconThemeHelper;
27
import org.gvsig.andami.PluginServices;
28
import org.gvsig.andami.plugins.Extension;
29
import org.gvsig.app.ApplicationLocator;
30
import org.gvsig.app.ApplicationManager;
31
import org.gvsig.app.project.ProjectManager;
32
import org.gvsig.app.project.documents.Document;
33
import org.gvsig.app.project.documents.table.TableDocument;
34
import org.gvsig.app.project.documents.table.TableManager;
35
import org.gvsig.app.project.documents.table.gui.FeatureTableDocumentPanel;
36
import org.gvsig.app.project.documents.table.gui.GeneralTablePropertiesPageFactory;
37
import org.gvsig.app.project.documents.view.ViewDocument;
38
import org.gvsig.app.project.documents.view.ViewManager;
39
import org.gvsig.app.project.documents.view.gui.AbstractViewPanel;
40
import org.gvsig.fmap.dal.exception.DataException;
41
import org.gvsig.fmap.dal.feature.FeatureStore;
42
import org.gvsig.fmap.mapcontext.layers.CancelationException;
43
import org.gvsig.fmap.mapcontext.layers.FLayer;
44
import org.gvsig.fmap.mapcontext.layers.FLayers;
45
import org.gvsig.fmap.mapcontext.layers.LayerCollectionEvent;
46
import org.gvsig.fmap.mapcontext.layers.LayerCollectionListener;
47
import org.gvsig.fmap.mapcontext.layers.LayerPositionEvent;
48
import org.gvsig.fmap.mapcontext.layers.vectorial.FLyrVect;
49
import org.gvsig.fmap.mapcontrol.MapControlLocator;
50
import org.gvsig.propertypage.PropertiesPageManager;
51
import org.slf4j.Logger;
52
import org.slf4j.LoggerFactory;
53

    
54
/**
55
 * Extensi?n que refresca los datos de la tabla.
56
 *
57
 * @author dmartinez
58
 */
59
public class TableRefresh extends Extension  {
60
    private static final Logger LOG = LoggerFactory
61
        .getLogger(TableRefresh.class);
62

    
63
    public void initialize() {
64

    
65
    }
66

    
67
    /**
68
     * @see org.gvsig.andami.plugins.IExtension#isEnabled()
69
     */
70
    public boolean isEnabled() {
71
        return true;
72
    }
73

    
74
    /**
75
     * @see org.gvsig.andami.plugins.IExtension#isVisible()
76
     */
77
    public boolean isVisible() {
78
        ApplicationManager application = ApplicationLocator.getManager();
79
        Document doc = application.getActiveDocument(TableManager.TYPENAME);
80
        return doc != null;
81
    }
82

    
83
    /**
84
     * @see com.iver.mdiApp.plugins.IExtension#updateUI(java.lang.String)
85
     */
86
    public void execute(String s) {
87
        if ("table-refresh".equalsIgnoreCase(s)) {
88
            ApplicationManager application = ApplicationLocator.getManager();
89
            Document doc = application.getActiveDocument(TableManager.TYPENAME);
90
            if (doc instanceof TableDocument){
91
                TableDocument docTable=(TableDocument)doc;
92
                try {
93
                    docTable.getStore().refresh();
94
                } catch (DataException e) {
95
                    LOG.warn("Error refreshing table", e);
96
                }
97
            }
98
        }
99
        }
100
}