Statistics
| Revision:

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

History | View | Annotate | Download (6.07 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 10724 2007-03-13 09:15:05Z  $
45
* $Log$
46
* Revision 1.2.6.2  2007-01-04 10:08:42  jcampos
47
* Upgrade new version
48
*
49
* Revision 1.2.6.1  2006/11/15 00:08:21  jjdelcerro
50
* *** empty log message ***
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 com.iver.cit.gvsig.gui.panels;
73

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

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

    
81
import com.iver.andami.PluginServices;
82
import com.iver.cit.gvsig.ProjectExtension;
83
import com.iver.cit.gvsig.project.documents.view.ProjectView;
84
import com.iver.cit.gvsig.project.documents.view.ProjectViewFactory;
85
import com.iver.cit.gvsig.project.documents.view.gui.BaseView;
86

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

    
92
        private JComboBox cmbMode = null;
93
        private JComboBox cmbViews = null;
94
        private JLabel lblExplain = null;
95
        private String currentView = null;
96

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

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

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

    
132
                                        if (cmbMode.getSelectedIndex() == NEW_VIEW) {
133
                                                lblExplain.setText(PluginServices.getText(this, "html_in_a_new_view"));
134
                                        } else if (cmbMode.getSelectedIndex() == CURRENT_VIEW) {
135
                                                lblExplain.setText(PluginServices.getText(this, "html_in_the_current_view"));
136
                                        } else if (cmbMode.getSelectedIndex() == USERS_VIEW_SELECTION) {
137
                                                lblExplain.setText(PluginServices.getText(this, "html_in_other_view"));
138
                                                cmbViews.setVisible(true);
139
                                        }
140
                                }
141
                        });
142
                        cmbMode.removeAllItems();
143
                        cmbMode.addItem(PluginServices.getText(this, "a_new_view"));
144
                        if (currentView!=null) {
145
                                cmbMode.addItem(PluginServices.getText(this, "layers_in_the_current_view")+": "+currentView);
146
                                CURRENT_VIEW = cmbMode.getItemCount()-1;
147
                                cmbMode.setSelectedIndex(CURRENT_VIEW);
148
                        }
149
                        cmbViews.removeAll();
150
                        ProjectExtension pe = (ProjectExtension) PluginServices.getExtension(ProjectExtension.class);
151
                        if (pe.getProject().getDocumentsByType(ProjectViewFactory.registerName).size()>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(BaseView v) {
161
                currentView = v.getName();
162
        }
163

    
164
        public ProjectView 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
                ProjectExtension pe = (ProjectExtension) PluginServices.getExtension(ProjectExtension.class);
173
                return (ProjectView) pe.getProject().getProjectDocumentByName(viewName, ProjectViewFactory.registerName);
174
        }
175

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

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