Statistics
| Revision:

root / branches / v2_0_0_prep / extensions / extWMS / src / org / gvsig / wms / gui / panels / WebMapContextFileChooserAccessory.java @ 31496

History | View | Annotate | Download (6.27 KB)

1
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
2
 *
3
 * Copyright (C) 2005 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

    
42
/* CVS MESSAGES:
43
*
44
* $Id: WebMapContextFileChooserAccessory.java 31496 2009-11-04 12:53:20Z jjdelcerro $
45
* $Log$
46
* Revision 1.7  2007-09-19 16:15:41  jaume
47
* removed unnecessary imports
48
*
49
* Revision 1.6  2007/06/27 06:29:27  jaume
50
* Views jcombobox bug fixed
51
*
52
* Revision 1.5  2006/09/20 07:45:21  caballero
53
* constante registerName
54
*
55
* Revision 1.4  2006/09/18 08:28:44  caballero
56
* cambio de nombre
57
*
58
* Revision 1.3  2006/09/15 10:44:24  caballero
59
* extensibilidad de documentos
60
*
61
* Revision 1.2  2006/04/21 11:34:30  jaume
62
* *** empty log message ***
63
*
64
* Revision 1.1  2006/04/19 07:57:29  jaume
65
* *** empty log message ***
66
*
67
* Revision 1.1  2006/04/12 17:10:53  jaume
68
* *** empty log message ***
69
*
70
*
71
*/
72
package org.gvsig.wms.gui.panels;
73

    
74
import java.awt.Dimension;
75
import java.util.List;
76

    
77
import javax.swing.JComboBox;
78
import javax.swing.JLabel;
79
import javax.swing.JPanel;
80

    
81
import org.gvsig.andami.PluginServices;
82
import org.gvsig.app.project.ProjectManager;
83
import org.gvsig.app.project.documents.Document;
84
import org.gvsig.app.project.documents.view.DefaultViewDocument;
85
import org.gvsig.app.project.documents.view.ViewManager;
86
import org.gvsig.app.project.documents.view.gui.DefaultViewPanel;
87

    
88

    
89
public class WebMapContextFileChooserAccessory extends JPanel {
90
        public static int NEW_VIEW = -1;
91
        public static int CURRENT_VIEW = -1;
92
        public static int USERS_VIEW_SELECTION = -1;
93

    
94
        private JComboBox cmbMode = null;
95
        private JComboBox cmbViews = null;
96
        private JLabel lblExplain = null;
97
        private String currentView = null;
98

    
99
        public WebMapContextFileChooserAccessory(String currentViewName) {
100
                super();
101
                currentView = currentViewName;
102
                initialize();
103
        }
104

    
105
        private void initialize() {
106
                lblExplain = new JLabel();
107
                lblExplain.setBounds(25, 52, 268, 55);
108
                lblExplain.setText(PluginServices.getText(this, "html_in_a_new_view"));
109
                setLayout(null);
110
                setSize(315, 240);
111
                setPreferredSize(new Dimension(315, 72));
112
                this.add(getCmbViews(), null);
113
                this.add(lblExplain, null);
114
                setBorder(javax.swing.BorderFactory.createTitledBorder(
115
                                  null, PluginServices.getText(this, "open_layers_as"),
116
                                  javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION,
117
                                  javax.swing.border.TitledBorder.DEFAULT_POSITION, null, null));
118
                this.add(getCmbMode(), null);
119
        }
120

    
121
        /**
122
         * This method initializes cmbBoxMode
123
         *
124
         * @return javax.swing.JComboBox
125
         */
126
        private JComboBox getCmbMode() {
127
                if (cmbMode == null) {
128
                        cmbMode = new JComboBox();
129
                        cmbMode.setBounds(25, 26, 268, 20);
130
                        cmbMode.removeAllItems();
131
                        cmbMode.addItemListener(new java.awt.event.ItemListener() {
132
                                public void itemStateChanged(java.awt.event.ItemEvent e) {
133
                                        cmbViews.setVisible(false);
134

    
135
                                        if (cmbMode.getSelectedIndex() == NEW_VIEW) {
136
                                                lblExplain.setText(PluginServices.getText(this, "html_in_a_new_view"));
137
                                        } else if (cmbMode.getSelectedIndex() == CURRENT_VIEW) {
138
                                                lblExplain.setText(PluginServices.getText(this, "html_in_the_current_view"));
139
                                        } else if (cmbMode.getSelectedIndex() == USERS_VIEW_SELECTION) {
140
                                                lblExplain.setText(PluginServices.getText(this, "html_in_other_view"));
141
                                                cmbViews.setVisible(true);
142
                                        }
143
                                }
144
                        });
145
                        cmbMode.addItem(PluginServices.getText(this, "a_new_view"));
146
                        if (currentView!=null) {
147
                                cmbMode.addItem(PluginServices.getText(this, "layers_in_the_current_view")+": "+currentView);
148
                                CURRENT_VIEW = cmbMode.getItemCount()-1;
149
                                cmbMode.setSelectedIndex(CURRENT_VIEW);
150
                        }
151
                        if (getCmbViews().getItemCount()>0) {
152
                                cmbMode.addItem(PluginServices.getText(this, "layers_in_other_view"));
153
                                USERS_VIEW_SELECTION = cmbMode.getItemCount() -1;
154
                        }
155
                }
156

    
157
                return cmbMode;
158
        }
159

    
160
        public void setCurrentView(DefaultViewPanel v) {
161
                currentView = v.getName();
162
        }
163

    
164
        public DefaultViewDocument getSelectedView() {
165
                String viewName = null;
166
                if (getCmbMode().getSelectedIndex() == NEW_VIEW)
167
                        return null;
168
                else if (getCmbMode().getSelectedIndex() == CURRENT_VIEW)
169
                        viewName = currentView;
170
                else if (getCmbMode().getSelectedIndex() == USERS_VIEW_SELECTION)
171
                        viewName = (String) getCmbViews().getSelectedItem();
172
                return (DefaultViewDocument) ProjectManager.getInstance().getCurrentProject().getDocument(viewName, ViewManager.TYPENAME);
173
//                ProjectExtension pe = (ProjectExtension) PluginServices.getExtension(ProjectExtension.class);
174
//                return (ProjectView) pe.getProject().getProjectDocumentByName(viewName, ProjectViewFactory.registerName);
175
        }
176

    
177
        public int getOption() {
178
                return cmbMode.getSelectedIndex();
179
        }
180

    
181
        /**
182
         * This method initializes cmbViews
183
         *
184
         * @return javax.swing.JComboBox
185
         */
186
        private JComboBox getCmbViews() {
187
                if (cmbViews == null) {
188
                        cmbViews = new JComboBox();
189
                        cmbViews.setBounds(25, 114, 266, 20);
190
                        List<Document> views = ProjectManager.getInstance().getCurrentProject().getDocuments( ViewManager.TYPENAME);
191
                        for (Document v : views) {
192
                                cmbViews.addItem(v.getName());
193
                        }
194
                        
195
//                        ProjectExtension pe = (ProjectExtension) PluginServices.getExtension(ProjectExtension.class);
196
//                        ArrayList views = pe.getProject().getDocumentsByType(ProjectViewFactory.registerName);
197
//                        for (int i = 0; i < views.size(); i++) {
198
//                                ProjectView v = (ProjectView)views.get(i);
199
//                                cmbViews.addItem(v.getName());
200
//                        }
201
                }
202
                return cmbViews;
203
        }
204
}  //  @jve:decl-index=0:visual-constraint="10,0"