Statistics
| Revision:

svn-gvsig-desktop / tags / v1_0_RELEASE / extensions / extWMS / src / com / iver / cit / gvsig / gui / panels / WebMapContextFileChooserAccessory.java @ 9167

History | View | Annotate | Download (6.04 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 9167 2006-12-04 16:01:24Z  $
45
* $Log$
46
* Revision 1.2.6.1  2006-11-15 00:08:21  jjdelcerro
47
* *** empty log message ***
48
*
49
* Revision 1.5  2006/09/20 07:45:21  caballero
50
* constante registerName
51
*
52
* Revision 1.4  2006/09/18 08:28:44  caballero
53
* cambio de nombre
54
*
55
* Revision 1.3  2006/09/15 10:44:24  caballero
56
* extensibilidad de documentos
57
*
58
* Revision 1.2  2006/04/21 11:34:30  jaume
59
* *** empty log message ***
60
*
61
* Revision 1.1  2006/04/19 07:57:29  jaume
62
* *** empty log message ***
63
*
64
* Revision 1.1  2006/04/12 17:10:53  jaume
65
* *** empty log message ***
66
*
67
*
68
*/
69
package com.iver.cit.gvsig.gui.panels;
70

    
71
import java.awt.Dimension;
72
import java.util.ArrayList;
73

    
74
import javax.swing.JComboBox;
75
import javax.swing.JLabel;
76
import javax.swing.JPanel;
77

    
78
import com.iver.andami.PluginServices;
79
import com.iver.cit.gvsig.ProjectExtension;
80
import com.iver.cit.gvsig.project.Project;
81
import com.iver.cit.gvsig.project.documents.view.ProjectView;
82
import com.iver.cit.gvsig.project.documents.view.ProjectViewFactory;
83
import com.iver.cit.gvsig.project.documents.view.gui.View;
84

    
85
public class WebMapContextFileChooserAccessory extends JPanel {
86
        public static int NEW_VIEW = -1;
87
        public static int CURRENT_VIEW = -1;
88
        public static int USERS_VIEW_SELECTION = -1;
89

    
90
        private JComboBox cmbMode = null;
91
        private JComboBox cmbViews = null;
92
        private JLabel lblExplain = null;
93
        private String currentView = null;
94

    
95
        public WebMapContextFileChooserAccessory(String currentViewName) {
96
                super();
97
                currentView = currentViewName;
98
                initialize();
99
        }
100

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

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

    
130
                                        if (cmbMode.getSelectedIndex() == NEW_VIEW) {
131
                                                lblExplain.setText(PluginServices.getText(this, "html_in_a_new_view"));
132
                                        } else if (cmbMode.getSelectedIndex() == CURRENT_VIEW) {
133
                                                lblExplain.setText(PluginServices.getText(this, "html_in_the_current_view"));
134
                                        } else if (cmbMode.getSelectedIndex() == USERS_VIEW_SELECTION) {
135
                                                lblExplain.setText(PluginServices.getText(this, "html_in_other_view"));
136
                                                cmbViews.setVisible(true);
137
                                        }
138
                                }
139
                        });
140
                        cmbMode.removeAllItems();
141
                        cmbMode.addItem(PluginServices.getText(this, "a_new_view"));
142
                        if (currentView!=null) {
143
                                cmbMode.addItem(PluginServices.getText(this, "layers_in_the_current_view")+": "+currentView);
144
                                CURRENT_VIEW = cmbMode.getItemCount()-1;
145
                                cmbMode.setSelectedIndex(CURRENT_VIEW);
146
                        }
147
                        cmbViews.removeAll();
148
                        ProjectExtension pe = (ProjectExtension) PluginServices.getExtension(ProjectExtension.class);
149
                        if (pe.getProject().getDocumentsByType(ProjectViewFactory.registerName).size()>0) {
150
                                cmbMode.addItem(PluginServices.getText(this, "layers_in_other_view"));
151
                                USERS_VIEW_SELECTION = cmbMode.getItemCount() -1;
152
                        }
153
                }
154

    
155
                return cmbMode;
156
        }
157

    
158
        public void setCurrentView(View v) {
159
                currentView = v.getName();
160
        }
161

    
162
        public ProjectView getSelectedView() {
163
                String viewName = null;
164
                if (getCmbMode().getSelectedIndex() == NEW_VIEW)
165
                        return null;
166
                else if (getCmbMode().getSelectedIndex() == CURRENT_VIEW)
167
                        viewName = currentView;
168
                else if (getCmbMode().getSelectedIndex() == USERS_VIEW_SELECTION)
169
                        viewName = (String) getCmbViews().getSelectedItem();
170
                ProjectExtension pe = (ProjectExtension) PluginServices.getExtension(ProjectExtension.class);
171
                return (ProjectView) pe.getProject().getProjectDocumentByName(viewName, ProjectViewFactory.registerName);
172
        }
173

    
174
        public int getOption() {
175
                return cmbMode.getSelectedIndex();
176
        }
177

    
178
        /**
179
         * This method initializes cmbViews
180
         *
181
         * @return javax.swing.JComboBox
182
         */
183
        private JComboBox getCmbViews() {
184
                if (cmbViews == null) {
185
                        cmbViews = new JComboBox();
186
                        cmbViews.setBounds(25, 114, 266, 20);
187
                        ProjectExtension pe = (ProjectExtension) PluginServices.getExtension(ProjectExtension.class);
188
                        ArrayList views = pe.getProject().getDocumentsByType(ProjectViewFactory.registerName);
189
                        for (int i = 0; i < views.size(); i++) {
190
                                ProjectView v = (ProjectView)views.get(i);
191
                                cmbViews.addItem(v.getName());
192
                        }
193
                }
194
                return cmbViews;
195
        }
196
}  //  @jve:decl-index=0:visual-constraint="10,0"