Statistics
| Revision:

root / branches / v2_0_0_prep / extensions / extGeocoding / src / org / gvsig / geocoding / extension / RelateGeocodingResultsExtension.java @ 27756

History | View | Annotate | Download (4.15 KB)

1
/* gvSIG. Geographic Information System of the Valencian Government
2
 *
3
 * Copyright (C) 2007-2008 Infrastructures and Transports Department
4
 * of the Valencian Government (CIT)
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 2
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
 */
22

    
23
/*
24
 * AUTHORS (In addition to CIT):
25
 * 2008 Prodevelop S.L. main development
26
 */
27

    
28
package org.gvsig.geocoding.extension;
29

    
30
import java.util.List;
31

    
32
import org.gvsig.fmap.mapcontext.layers.FLayer;
33
import org.gvsig.fmap.mapcontext.layers.FLayers;
34
import org.gvsig.fmap.mapcontext.layers.vectorial.FLyrVect;
35
import org.gvsig.geocoding.gui.relation.RelatePanel;
36
import org.gvsig.project.document.table.FeatureTableDocument;
37
import org.slf4j.Logger;
38
import org.slf4j.LoggerFactory;
39

    
40
import com.iver.andami.PluginServices;
41
import com.iver.andami.plugins.Extension;
42
import com.iver.andami.preferences.IPreference;
43
import com.iver.andami.preferences.IPreferenceExtension;
44
import com.iver.andami.ui.mdiManager.IWindow;
45
import com.iver.cit.gvsig.project.documents.view.gui.View;
46

    
47
/**
48
 * Geocoding Extension. This extension geoposition in the map one postal
49
 * address.
50
 * 
51
 * @author <a href="mailto:jsanz@prodevelop.es"> Jorge Gaspar Sanz Salinas</a>
52
 * @author <a href="mailto:vsanjaime@prodevelop.es"> Vicente Sanjaime Calvet</a>
53
 */
54

    
55
public class RelateGeocodingResultsExtension extends Extension implements
56
                IPreferenceExtension {
57

    
58
        private static final String RELATEGEOCODING = "RELATEGEOCODING";
59

    
60
        private static final String GEOCODINGRESULTS = "GEOCODINGRESULTS";
61

    
62
        private static final Logger log = LoggerFactory
63
                        .getLogger(RelateGeocodingResultsExtension.class);
64

    
65
        private GeocoController control = null;
66

    
67
        /**
68
         * execute
69
         */
70
        public void execute(String actionCommand) {
71

    
72
                if (actionCommand.equalsIgnoreCase(RELATEGEOCODING)) {
73

    
74
                        GeocodingExtension mainExt = (GeocodingExtension) PluginServices
75
                                        .getExtension(GeocodingExtension.class);
76
                        control = mainExt.getControl();
77
                        // ahow panel extension
78
                        RelatePanel repanel = new RelatePanel();
79
                        PluginServices.getMDIManager().addWindow(repanel);
80
                        repanel.setVisible(true);
81
                }
82
        }
83

    
84
        /**
85
         * This method initializes some parameters of the extension
86
         */
87
        public void initialize() {
88

    
89
        }
90

    
91
        /**
92
         * This method puts available the extension
93
         * 
94
         * @return true or false
95
         */
96
        public boolean isEnabled() {
97

    
98
//                IWindow window = PluginServices.getMDIManager().getActiveWindow();
99
//                if (window instanceof View) {
100
//                        View vi = (View) window;
101
//                        FLayers lyrs = vi.getMapControl().getMapContext().getLayers();
102
//                        int cant = lyrs.getLayersCount();
103
//                        if (lyrs != null && lyrs.getLayersCount() > 0) {
104
//                                if (lyrs.getActives().length > 0) {
105
//                                        FLayer lyr = lyrs.getActives()[0];
106
//                                        if (lyr instanceof FLyrVect) {
107
//                                                FLyrVect ly = (FLyrVect) lyr;
108
//                                                List<FeatureTableDocument> tables = control
109
//                                                                .getListgvSIGTables();
110
//                                                Object obj = ly.getProperty(GEOCODINGRESULTS);
111
//                                                if (obj instanceof FeatureTableDocument
112
//                                                                && tables.size() > 0) {
113
//                                                        return true;
114
//                                                }
115
//                                        }
116
//                                }
117
//                        }
118
//                }
119
                return false;
120
        }
121

    
122
        /**
123
         * This method puts visible the extension
124
         * 
125
         * @return true or false
126
         */
127
        public boolean isVisible() {
128
                IWindow window = PluginServices.getMDIManager().getActiveWindow();
129
                // Visible when there are views in the window
130
                if (window instanceof View) {
131
                        return true;
132
                }
133
                return false;
134
        }
135

    
136
        public IPreference[] getPreferencesPages() {
137

    
138
                return null;
139
        }
140

    
141
}