Revision 8700

View differences:

org.gvsig.raster/branches/org.gvsig.raster.2.4/org.gvsig.wmts/org.gvsig.wmts.swing/org.gvsig.wmts.swing.impl/pom.xml
1
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
2
 xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
3
  <modelVersion>4.0.0</modelVersion>
4
  <parent>
5
    <groupId>org.gvsig</groupId>
6
    <artifactId>org.gvsig.wmts.swing</artifactId>
7
    <version>1.0.0-SNAPSHOT</version>
8
  </parent>
9
  <artifactId>org.gvsig.wmts.swing.impl</artifactId>
10
  <name>org.gvsig.wmts.swing.impl</name>
11
  <description>Implementation for the UI of WMTS</description>
12
  <dependencies>
13
    <dependency>
14
      <groupId>com.jgoodies</groupId>
15
      <artifactId>jgoodies-forms</artifactId>
16
    </dependency>
17
    <dependency>
18
      <groupId>org.gvsig</groupId>
19
      <artifactId>org.gvsig.wmts.swing.api</artifactId>
20
     <scope>compile</scope>
21
    </dependency>
22
    <dependency>
23
     <groupId>org.gvsig</groupId>
24
     <artifactId>org.gvsig.tools.lib</artifactId>
25
     <scope>compile</scope>
26
    </dependency>
27
    <dependency>
28
      <groupId>org.gvsig</groupId>
29
      <artifactId>org.gvsig.wmts.provider</artifactId>
30
     <scope>compile</scope>
31
    </dependency>
32
    <dependency>
33
      <groupId>org.gvsig</groupId>
34
      <artifactId>org.gvsig.fmap.mapcontext.api</artifactId>
35
     <scope>compile</scope>
36
    </dependency>
37
  </dependencies>
38
</project>
org.gvsig.raster/branches/org.gvsig.raster.2.4/org.gvsig.wmts/org.gvsig.wmts.swing/org.gvsig.wmts.swing.impl/src/main/resources/META-INF/services/org.gvsig.tools.library.Library
1
org.gvsig.wmts.swing.impl.WMTSSwingImplLibrary
org.gvsig.raster/branches/org.gvsig.raster.2.4/org.gvsig.wmts/org.gvsig.wmts.swing/org.gvsig.wmts.swing.impl/src/main/java/org/gvsig/wmts/swing/impl/DefaultWMTSParametersPanelView.java
1
package org.gvsig.wmts.swing.impl;
2

  
3
import java.awt.BorderLayout;
4
import java.awt.Color;
5
import java.awt.ComponentOrientation;
6
import java.awt.Container;
7
import java.awt.Dimension;
8

  
9
import javax.swing.Box;
10
import javax.swing.ButtonGroup;
11
import javax.swing.ImageIcon;
12
import javax.swing.JButton;
13
import javax.swing.JCheckBox;
14
import javax.swing.JComboBox;
15
import javax.swing.JEditorPane;
16
import javax.swing.JLabel;
17
import javax.swing.JList;
18
import javax.swing.JPanel;
19
import javax.swing.JRadioButton;
20
import javax.swing.JScrollPane;
21
import javax.swing.JSlider;
22
import javax.swing.JTabbedPane;
23
import javax.swing.JTextField;
24
import javax.swing.JTree;
25

  
26
import com.jgoodies.forms.layout.CellConstraints;
27
import com.jgoodies.forms.layout.FormLayout;
28

  
29

  
30
public class DefaultWMTSParametersPanelView extends JPanel
31
{
32
   JTabbedPane tabWMTS = new JTabbedPane();
33
   JLabel lblInformation = new JLabel();
34
   JCheckBox chkInvertAxisOrder = new JCheckBox();
35
   JButton btnConnect = new JButton();
36
   JButton btnCancel = new JButton();
37
   JComboBox cboServerList = new JComboBox();
38
   JLabel lblServer = new JLabel();
39
   JCheckBox chkRefreshCache = new JCheckBox();
40
   JCheckBox chkRefreshLocalCache = new JCheckBox();
41
   JEditorPane txtInformation = new JEditorPane();
42
   JLabel lblUser = new JLabel();
43
   JLabel lblPassword = new JLabel();
44
   JTextField txtUser = new JTextField();
45
   JTextField txtPassword = new JTextField();
46
   JLabel lblSelectLayers = new JLabel();
47
   JTree treeLayersSelector = new JTree();
48
   JTextField txtSelectedLayer = new JTextField();
49
   JButton btnAddLayer = new JButton();
50
   JButton btnRemoveLayer = new JButton();
51
   JLabel lblSelectedLayer = new JLabel();
52
   JTree treeStyles = new JTree();
53
   JLabel lblSettings = new JLabel();
54
   JLabel lblSettingsEditor = new JLabel();
55
   JLabel lblValue = new JLabel();
56
   JSlider sldValues = new JSlider();
57
   JButton btnFirst = new JButton();
58
   JButton btnPrevious = new JButton();
59
   JTextField txtDimensionNumber = new JTextField();
60
   JButton btnNext = new JButton();
61
   JButton btnLast = new JButton();
62
   JRadioButton rdbSimpleValue = new JRadioButton();
63
   ButtonGroup buttongroup1 = new ButtonGroup();
64
   JRadioButton rdbMultipleValue = new JRadioButton();
65
   JRadioButton rdbInterval = new JRadioButton();
66
   JTextField txtSetting = new JTextField();
67
   JButton btnSet = new JButton();
68
   JLabel lblFieldValue = new JLabel();
69
   JButton btnAddSetting = new JButton();
70
   JButton btnClearSetting = new JButton();
71
   JList lstDimensions = new JList();
72
   JList lstDimensionsSettings = new JList();
73
   JLabel lblFormats = new JLabel();
74
   JLabel lblProjection = new JLabel();
75
   JLabel lblInfoFormat = new JLabel();
76
   JList lstInfoFormats = new JList();
77
   JList lstProjections = new JList();
78
   JList lstFormats = new JList();
79

  
80
   /**
81
    * Default constructor
82
    */
83
   public DefaultWMTSParametersPanelView()
84
   {
85
      initializePanel();
86
   }
87

  
88
   /**
89
    * Adds fill components to empty cells in the first row and first column of the grid.
90
    * This ensures that the grid spacing will be the same as shown in the designer.
91
    * @param cols an array of column indices in the first row where fill components should be added.
92
    * @param rows an array of row indices in the first column where fill components should be added.
93
    */
94
   void addFillComponents( Container panel, int[] cols, int[] rows )
95
   {
96
      Dimension filler = new Dimension(10,10);
97

  
98
      boolean filled_cell_11 = false;
99
      CellConstraints cc = new CellConstraints();
100
      if ( cols.length > 0 && rows.length > 0 )
101
      {
102
         if ( cols[0] == 1 && rows[0] == 1 )
103
         {
104
            /** add a rigid area  */
105
            panel.add( Box.createRigidArea( filler ), cc.xy(1,1) );
106
            filled_cell_11 = true;
107
         }
108
      }
109

  
110
      for( int index = 0; index < cols.length; index++ )
111
      {
112
         if ( cols[index] == 1 && filled_cell_11 )
113
         {
114
            continue;
115
         }
116
         panel.add( Box.createRigidArea( filler ), cc.xy(cols[index],1) );
117
      }
118

  
119
      for( int index = 0; index < rows.length; index++ )
120
      {
121
         if ( rows[index] == 1 && filled_cell_11 )
122
         {
123
            continue;
124
         }
125
         panel.add( Box.createRigidArea( filler ), cc.xy(1,rows[index]) );
126
      }
127

  
128
   }
129

  
130
   /**
131
    * Helper method to load an image file from the CLASSPATH
132
    * @param imageName the package and name of the file to load relative to the CLASSPATH
133
    * @return an ImageIcon instance with the specified image file
134
    * @throws IllegalArgumentException if the image resource cannot be loaded.
135
    */
136
   public ImageIcon loadImage( String imageName )
137
   {
138
      try
139
      {
140
         ClassLoader classloader = getClass().getClassLoader();
141
         java.net.URL url = classloader.getResource( imageName );
142
         if ( url != null )
143
         {
144
            ImageIcon icon = new ImageIcon( url );
145
            return icon;
146
         }
147
      }
148
      catch( Exception e )
149
      {
150
         e.printStackTrace();
151
      }
152
      throw new IllegalArgumentException( "Unable to load image: " + imageName );
153
   }
154

  
155
   /**
156
    * Method for recalculating the component orientation for
157
    * right-to-left Locales.
158
    * @param orientation the component orientation to be applied
159
    */
160
   public void applyComponentOrientation( ComponentOrientation orientation )
161
   {
162
      // Not yet implemented...
163
      // I18NUtils.applyComponentOrientation(this, orientation);
164
      super.applyComponentOrientation(orientation);
165
   }
166

  
167
   public JPanel createPanel()
168
   {
169
      JPanel jpanel1 = new JPanel();
170
      FormLayout formlayout1 = new FormLayout("FILL:4DLU:NONE,FILL:DEFAULT:GROW(1.0),FILL:4DLU:NONE","CENTER:2DLU:NONE,CENTER:DEFAULT:GROW(1.0),CENTER:2DLU:NONE");
171
      CellConstraints cc = new CellConstraints();
172
      jpanel1.setLayout(formlayout1);
173

  
174
      tabWMTS.setName("tabWMTS");
175
      tabWMTS.addTab("_connection",null,createPanel1());
176
      tabWMTS.addTab("_layers",null,createPanel3());
177
      tabWMTS.addTab("_styles",null,createPanel4());
178
      tabWMTS.addTab("_dimensions",null,createPanel5());
179
      tabWMTS.addTab("_formats",null,createPanel7());
180
      jpanel1.add(tabWMTS,new CellConstraints(2,2,1,1,CellConstraints.FILL,CellConstraints.FILL));
181

  
182
      addFillComponents(jpanel1,new int[]{ 1,2,3 },new int[]{ 1,2,3 });
183
      return jpanel1;
184
   }
185

  
186
   public JPanel createPanel1()
187
   {
188
      JPanel jpanel1 = new JPanel();
189
      FormLayout formlayout1 = new FormLayout("FILL:4DLU:NONE,FILL:DEFAULT:GROW(1.0),FILL:4DLU:NONE,FILL:DEFAULT:NONE,FILL:4DLU:NONE,FILL:DEFAULT:NONE,FILL:4DLU:NONE","CENTER:2DLU:NONE,CENTER:DEFAULT:NONE,CENTER:2DLU:NONE,CENTER:DEFAULT:NONE,CENTER:2DLU:NONE,CENTER:DEFAULT:NONE,CENTER:2DLU:NONE,CENTER:DEFAULT:NONE,CENTER:2DLU:NONE,CENTER:DEFAULT:NONE,CENTER:2DLU:NONE,CENTER:DEFAULT:NONE,CENTER:2DLU:NONE,CENTER:DEFAULT:NONE,CENTER:2DLU:NONE,CENTER:DEFAULT:NONE,CENTER:2DLU:NONE,CENTER:DEFAULT:GROW(1.0),CENTER:2DLU:NONE");
190
      CellConstraints cc = new CellConstraints();
191
      jpanel1.setLayout(formlayout1);
192

  
193
      lblInformation.setName("lblInformation");
194
      lblInformation.setText("_information");
195
      lblInformation.setToolTipText("_information");
196
      jpanel1.add(lblInformation,cc.xywh(2,16,5,1));
197

  
198
      chkInvertAxisOrder.setActionCommand("_assumption_axis_order_xy");
199
      chkInvertAxisOrder.setName("chkInvertAxisOrder");
200
      chkInvertAxisOrder.setText("_invert_axis_order");
201
      chkInvertAxisOrder.setToolTipText("_invert_axis_order");
202
      jpanel1.add(chkInvertAxisOrder,cc.xywh(2,14,5,1));
203

  
204
      btnConnect.setActionCommand("_connect");
205
      btnConnect.setName("btnConnect");
206
      btnConnect.setText("_connect");
207
      btnConnect.setToolTipText("_try_connect_to_the_server");
208
      jpanel1.add(btnConnect,cc.xy(4,10));
209

  
210
      btnCancel.setActionCommand("_cancel");
211
      btnCancel.setName("btnCancel");
212
      btnCancel.setText("_cancel");
213
      btnCancel.setToolTipText("_cancel_connection");
214
      jpanel1.add(btnCancel,cc.xy(6,10));
215

  
216
      cboServerList.setEditable(true);
217
      cboServerList.setName("cboServerList");
218
      cboServerList.setRequestFocusEnabled(false);
219
      cboServerList.setToolTipText("_server_connection_string");
220
      jpanel1.add(cboServerList,cc.xywh(2,4,5,1));
221

  
222
      lblServer.setName("lblServer");
223
      lblServer.setText("_server");
224
      lblServer.setToolTipText("_server_conexion_string");
225
      jpanel1.add(lblServer,cc.xywh(2,2,5,1));
226

  
227
      chkRefreshCache.setActionCommand("JCheckBox");
228
      chkRefreshCache.setName("chkRefreshCache");
229
      chkRefreshCache.setText("_refresh_service_cache");
230
      chkRefreshCache.setToolTipText("_refresh_service_cache");
231
      jpanel1.add(chkRefreshCache,cc.xywh(2,8,5,1));
232

  
233
      chkRefreshLocalCache.setActionCommand("JCheckBox");
234
      chkRefreshLocalCache.setName("chkRefreshLocalCache");
235
      chkRefreshLocalCache.setText("_refresh_local_tile_cache");
236
      chkRefreshLocalCache.setToolTipText("_refresh_local_tile_cache");
237
      jpanel1.add(chkRefreshLocalCache,cc.xywh(2,12,5,1));
238

  
239
      txtInformation.setContentType("text/html");
240
      txtInformation.setName("txtInformation");
241
      txtInformation.setSelectionEnd(1);
242
      txtInformation.setSelectionStart(1);
243
      txtInformation.setText("<html>\n  <head>\n    \n  </head>\n  <body>\n  </body>\n</html>\n");
244
      JScrollPane jscrollpane1 = new JScrollPane();
245
      jscrollpane1.setViewportView(txtInformation);
246
      jscrollpane1.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
247
      jscrollpane1.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
248
      jpanel1.add(jscrollpane1,new CellConstraints(2,18,5,1,CellConstraints.FILL,CellConstraints.FILL));
249

  
250
      jpanel1.add(createPanel2(),cc.xywh(2,6,5,1));
251
      addFillComponents(jpanel1,new int[]{ 1,2,3,4,5,6,7 },new int[]{ 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19 });
252
      return jpanel1;
253
   }
254

  
255
   public JPanel createPanel2()
256
   {
257
      JPanel jpanel1 = new JPanel();
258
      FormLayout formlayout1 = new FormLayout("FILL:DEFAULT:NONE,FILL:4DLU:NONE,FILL:DEFAULT:GROW(1.0)","CENTER:DEFAULT:NONE,CENTER:2DLU:NONE,CENTER:DEFAULT:NONE");
259
      CellConstraints cc = new CellConstraints();
260
      jpanel1.setLayout(formlayout1);
261

  
262
      lblUser.setName("lblUser");
263
      lblUser.setText("_user");
264
      lblUser.setToolTipText("_user");
265
      jpanel1.add(lblUser,cc.xy(1,1));
266

  
267
      lblPassword.setName("lblPassword");
268
      lblPassword.setText("_password");
269
      lblPassword.setToolTipText("_password");
270
      jpanel1.add(lblPassword,cc.xy(1,3));
271

  
272
      txtUser.setName("txtUser");
273
      txtUser.setToolTipText("_user");
274
      jpanel1.add(txtUser,cc.xy(3,1));
275

  
276
      txtPassword.setName("txtPassword");
277
      txtPassword.setToolTipText("_password");
278
      jpanel1.add(txtPassword,cc.xy(3,3));
279

  
280
      addFillComponents(jpanel1,new int[]{ 2 },new int[]{ 2 });
281
      return jpanel1;
282
   }
283

  
284
   public JPanel createPanel3()
285
   {
286
      JPanel jpanel1 = new JPanel();
287
      FormLayout formlayout1 = new FormLayout("FILL:4DLU:NONE,FILL:DEFAULT:GROW(1.0),FILL:4DLU:NONE,FILL:DEFAULT:NONE,FILL:4DLU:NONE,FILL:DEFAULT:NONE,FILL:4DLU:NONE","CENTER:2DLU:NONE,CENTER:2DLU:NONE,CENTER:DEFAULT:NONE,CENTER:2DLU:NONE,FILL:DEFAULT:GROW(1.0),CENTER:2DLU:NONE,CENTER:DEFAULT:NONE,CENTER:2DLU:NONE,CENTER:DEFAULT:NONE,CENTER:2DLU:NONE");
288
      CellConstraints cc = new CellConstraints();
289
      jpanel1.setLayout(formlayout1);
290

  
291
      lblSelectLayers.setName("lblSelectLayers");
292
      lblSelectLayers.setText("_select_layer");
293
      lblSelectLayers.setToolTipText("_select_layer");
294
      jpanel1.add(lblSelectLayers,cc.xy(2,3));
295

  
296
      treeLayersSelector.setName("treeLayersSelector");
297
      treeLayersSelector.setToolTipText("_select_layers");
298
      JScrollPane jscrollpane1 = new JScrollPane();
299
      jscrollpane1.setViewportView(treeLayersSelector);
300
      jscrollpane1.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
301
      jscrollpane1.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
302
      jpanel1.add(jscrollpane1,new CellConstraints(2,5,5,1,CellConstraints.FILL,CellConstraints.FILL));
303

  
304
      txtSelectedLayer.setBackground(new Color(236,233,216));
305
      txtSelectedLayer.setEditable(false);
306
      txtSelectedLayer.setName("txtSelectedLayer");
307
      txtSelectedLayer.setToolTipText("_selected_layer");
308
      jpanel1.add(txtSelectedLayer,cc.xy(2,9));
309

  
310
      btnAddLayer.setActionCommand("JButton");
311
      btnAddLayer.setName("btnAddLayer");
312
      btnAddLayer.setText("_add_layer");
313
      btnAddLayer.setToolTipText("_add_layer");
314
      jpanel1.add(btnAddLayer,cc.xy(4,9));
315

  
316
      btnRemoveLayer.setActionCommand("JButton");
317
      btnRemoveLayer.setName("btnRemoveLayer");
318
      btnRemoveLayer.setText("_remove_layer");
319
      btnRemoveLayer.setToolTipText("_remove_layer");
320
      jpanel1.add(btnRemoveLayer,cc.xy(6,9));
321

  
322
      lblSelectedLayer.setName("lblSelectedLayer");
323
      lblSelectedLayer.setText("_selected_layer");
324
      lblSelectedLayer.setToolTipText("_selected_layer");
325
      jpanel1.add(lblSelectedLayer,cc.xy(2,7));
326

  
327
      addFillComponents(jpanel1,new int[]{ 1,2,3,4,5,6,7 },new int[]{ 1,2,3,4,5,6,7,8,9,10 });
328
      return jpanel1;
329
   }
330

  
331
   public JPanel createPanel4()
332
   {
333
      JPanel jpanel1 = new JPanel();
334
      FormLayout formlayout1 = new FormLayout("FILL:4DLU:NONE,FILL:DEFAULT:GROW(1.0),FILL:4DLU:NONE","CENTER:2DLU:NONE,CENTER:DEFAULT:GROW(1.0),CENTER:2DLU:NONE");
335
      CellConstraints cc = new CellConstraints();
336
      jpanel1.setLayout(formlayout1);
337

  
338
      treeStyles.setName("treeStyles");
339
      JScrollPane jscrollpane1 = new JScrollPane();
340
      jscrollpane1.setViewportView(treeStyles);
341
      jscrollpane1.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
342
      jscrollpane1.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
343
      jpanel1.add(jscrollpane1,new CellConstraints(2,2,1,1,CellConstraints.FILL,CellConstraints.FILL));
344

  
345
      addFillComponents(jpanel1,new int[]{ 1,2,3 },new int[]{ 1,2,3 });
346
      return jpanel1;
347
   }
348

  
349
   public JPanel createPanel5()
350
   {
351
      JPanel jpanel1 = new JPanel();
352
      FormLayout formlayout1 = new FormLayout("FILL:4DLU:NONE,FILL:DEFAULT:GROW(1.0),FILL:4DLU:NONE,FILL:DEFAULT:GROW(1.0),FILL:4DLU:NONE","CENTER:2DLU:NONE,CENTER:DEFAULT:NONE,CENTER:2DLU:NONE,FILL:DEFAULT:GROW(1.0),CENTER:2DLU:NONE,CENTER:DEFAULT:NONE,CENTER:2DLU:NONE,FILL:DEFAULT:NONE,CENTER:2DLU:NONE");
353
      CellConstraints cc = new CellConstraints();
354
      jpanel1.setLayout(formlayout1);
355

  
356
      lblSettings.setName("lblSettings");
357
      lblSettings.setText("_settings");
358
      lblSettings.setToolTipText("_settings");
359
      jpanel1.add(lblSettings,cc.xy(2,2));
360

  
361
      lblSettingsEditor.setName("lblSettingsEditor");
362
      lblSettingsEditor.setText("_settings_editor");
363
      lblSettingsEditor.setToolTipText("_settings_editor");
364
      jpanel1.add(lblSettingsEditor,cc.xy(2,6));
365

  
366
      jpanel1.add(createPanel6(),cc.xy(4,8));
367
      lstDimensions.setName("lstDimensions");
368
      JScrollPane jscrollpane1 = new JScrollPane();
369
      jscrollpane1.setViewportView(lstDimensions);
370
      jscrollpane1.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
371
      jscrollpane1.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
372
      jpanel1.add(jscrollpane1,cc.xy(2,8));
373

  
374
      lstDimensionsSettings.setName("lstDimensionsSettings");
375
      JScrollPane jscrollpane2 = new JScrollPane();
376
      jscrollpane2.setViewportView(lstDimensionsSettings);
377
      jscrollpane2.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
378
      jscrollpane2.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
379
      jpanel1.add(jscrollpane2,cc.xywh(2,4,3,1));
380

  
381
      addFillComponents(jpanel1,new int[]{ 1,2,3,4,5 },new int[]{ 1,2,3,4,5,6,7,8,9 });
382
      return jpanel1;
383
   }
384

  
385
   public JPanel createPanel6()
386
   {
387
      JPanel jpanel1 = new JPanel();
388
      FormLayout formlayout1 = new FormLayout("FILL:DEFAULT:NONE,FILL:4DLU:NONE,FILL:DEFAULT:NONE,FILL:4DLU:NONE,FILL:DEFAULT:GROW(1.0),FILL:4DLU:NONE,FILL:DEFAULT:GROW(1.0),FILL:4DLU:NONE,FILL:DEFAULT:NONE,FILL:4DLU:NONE,FILL:DEFAULT:NONE","CENTER:DEFAULT:NONE,CENTER:2DLU:NONE,CENTER:DEFAULT:NONE,CENTER:2DLU:NONE,CENTER:DEFAULT:NONE,CENTER:2DLU:NONE,CENTER:DEFAULT:NONE,CENTER:2DLU:NONE,CENTER:DEFAULT:NONE,CENTER:2DLU:NONE,CENTER:DEFAULT:NONE,CENTER:2DLU:NONE,CENTER:DEFAULT:NONE,CENTER:2DLU:NONE,CENTER:DEFAULT:NONE,CENTER:2DLU:NONE,CENTER:DEFAULT:NONE");
389
      CellConstraints cc = new CellConstraints();
390
      jpanel1.setLayout(formlayout1);
391

  
392
      lblValue.setName("lblValue");
393
      lblValue.setText("_value");
394
      lblValue.setToolTipText("_value");
395
      jpanel1.add(lblValue,cc.xywh(1,1,3,1));
396

  
397
      sldValues.setMajorTickSpacing(20);
398
      sldValues.setName("sldValues");
399
      sldValues.setPaintLabels(true);
400
      sldValues.setPaintTicks(true);
401
      jpanel1.add(sldValues,cc.xywh(1,3,11,1));
402

  
403
      btnFirst.setActionCommand("_first");
404
      btnFirst.setName("btnFirst");
405
      btnFirst.setText("_first");
406
      btnFirst.setToolTipText("_first");
407
      jpanel1.add(btnFirst,cc.xy(1,5));
408

  
409
      btnPrevious.setActionCommand("_previous");
410
      btnPrevious.setName("btnPrevious");
411
      btnPrevious.setText("_previous");
412
      btnPrevious.setToolTipText("_previous");
413
      jpanel1.add(btnPrevious,cc.xy(3,5));
414

  
415
      txtDimensionNumber.setName("txtDimensionNumber");
416
      jpanel1.add(txtDimensionNumber,cc.xywh(5,5,3,1));
417

  
418
      btnNext.setActionCommand("_next");
419
      btnNext.setName("btnNext");
420
      btnNext.setText("_next");
421
      btnNext.setToolTipText("_next");
422
      jpanel1.add(btnNext,cc.xy(9,5));
423

  
424
      btnLast.setActionCommand("_last");
425
      btnLast.setName("btnLast");
426
      btnLast.setText("_last");
427
      btnLast.setToolTipText("_last");
428
      jpanel1.add(btnLast,cc.xy(11,5));
429

  
430
      rdbSimpleValue.setActionCommand("_simple_value");
431
      rdbSimpleValue.setName("rdbSimpleValue");
432
      rdbSimpleValue.setText("_simple_value");
433
      rdbSimpleValue.setToolTipText("_simple_value");
434
      buttongroup1.add(rdbSimpleValue);
435
      jpanel1.add(rdbSimpleValue,cc.xywh(1,7,11,1));
436

  
437
      rdbMultipleValue.setActionCommand("_multiple_value");
438
      rdbMultipleValue.setName("rdbMultipleValue");
439
      rdbMultipleValue.setText("_multiple_value");
440
      rdbMultipleValue.setToolTipText("_multiple_value");
441
      buttongroup1.add(rdbMultipleValue);
442
      jpanel1.add(rdbMultipleValue,cc.xywh(1,9,11,1));
443

  
444
      rdbInterval.setActionCommand("_interval");
445
      rdbInterval.setName("rdbInterval");
446
      rdbInterval.setText("_interval");
447
      rdbInterval.setToolTipText("_interval");
448
      buttongroup1.add(rdbInterval);
449
      jpanel1.add(rdbInterval,cc.xywh(1,11,11,1));
450

  
451
      txtSetting.setName("txtSetting");
452
      txtSetting.setToolTipText("_setting");
453
      jpanel1.add(txtSetting,cc.xywh(1,15,11,1));
454

  
455
      btnSet.setActionCommand("_set");
456
      btnSet.setName("btnSet");
457
      btnSet.setText("_set");
458
      btnSet.setToolTipText("_set");
459
      jpanel1.add(btnSet,cc.xywh(1,17,5,1));
460

  
461
      lblFieldValue.setName("lblFieldValue");
462
      lblFieldValue.setToolTipText("_value");
463
      jpanel1.add(lblFieldValue,cc.xywh(5,1,7,1));
464

  
465
      btnAddSetting.setActionCommand("_add");
466
      btnAddSetting.setName("btnAddSetting");
467
      btnAddSetting.setText("_add");
468
      btnAddSetting.setToolTipText("_add_setting");
469
      jpanel1.add(btnAddSetting,cc.xywh(1,13,5,1));
470

  
471
      btnClearSetting.setActionCommand("_clear");
472
      btnClearSetting.setName("btnClearSetting");
473
      btnClearSetting.setText("_clear");
474
      btnClearSetting.setToolTipText("_clear_setting");
475
      jpanel1.add(btnClearSetting,cc.xywh(7,13,5,1));
476

  
477
      addFillComponents(jpanel1,new int[]{ 2,3,4,6,7,8,9,10,11 },new int[]{ 2,4,6,8,10,12,14,16 });
478
      return jpanel1;
479
   }
480

  
481
   public JPanel createPanel7()
482
   {
483
      JPanel jpanel1 = new JPanel();
484
      FormLayout formlayout1 = new FormLayout("FILL:4DLU:NONE,FILL:DEFAULT:GROW(1.0),FILL:4DLU:NONE","CENTER:2DLU:NONE,CENTER:DEFAULT:NONE,CENTER:2DLU:NONE,CENTER:DEFAULT:GROW(1.0),CENTER:2DLU:NONE,CENTER:DEFAULT:NONE,CENTER:2DLU:NONE,CENTER:DEFAULT:GROW(1.0),CENTER:2DLU:NONE,CENTER:DEFAULT:NONE,CENTER:2DLU:NONE,CENTER:DEFAULT:GROW(1.0),CENTER:2DLU:NONE");
485
      CellConstraints cc = new CellConstraints();
486
      jpanel1.setLayout(formlayout1);
487

  
488
      lblFormats.setName("lblFormats");
489
      lblFormats.setText("_select_format");
490
      lblFormats.setToolTipText("_select_format");
491
      jpanel1.add(lblFormats,cc.xy(2,2));
492

  
493
      lblProjection.setName("lblProjection");
494
      lblProjection.setText("_select_crs");
495
      lblProjection.setToolTipText("_select_crs");
496
      jpanel1.add(lblProjection,cc.xy(2,6));
497

  
498
      lblInfoFormat.setName("lblInfoFormat");
499
      lblInfoFormat.setText("_select_info_format");
500
      lblInfoFormat.setToolTipText("_select_info_format");
501
      jpanel1.add(lblInfoFormat,cc.xy(2,10));
502

  
503
      lstInfoFormats.setName("lstInfoFormats");
504
      JScrollPane jscrollpane1 = new JScrollPane();
505
      jscrollpane1.setViewportView(lstInfoFormats);
506
      jscrollpane1.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
507
      jscrollpane1.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
508
      jpanel1.add(jscrollpane1,new CellConstraints(2,12,1,1,CellConstraints.FILL,CellConstraints.FILL));
509

  
510
      lstProjections.setName("lstProjections");
511
      JScrollPane jscrollpane2 = new JScrollPane();
512
      jscrollpane2.setViewportView(lstProjections);
513
      jscrollpane2.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
514
      jscrollpane2.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
515
      jpanel1.add(jscrollpane2,new CellConstraints(2,8,1,1,CellConstraints.FILL,CellConstraints.FILL));
516

  
517
      lstFormats.setName("lstFormats");
518
      JScrollPane jscrollpane3 = new JScrollPane();
519
      jscrollpane3.setViewportView(lstFormats);
520
      jscrollpane3.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
521
      jscrollpane3.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
522
      jpanel1.add(jscrollpane3,new CellConstraints(2,4,1,1,CellConstraints.FILL,CellConstraints.FILL));
523

  
524
      addFillComponents(jpanel1,new int[]{ 1,2,3 },new int[]{ 1,2,3,4,5,6,7,8,9,10,11,12,13 });
525
      return jpanel1;
526
   }
527

  
528
   /**
529
    * Initializer
530
    */
531
   protected void initializePanel()
532
   {
533
      setLayout(new BorderLayout());
534
      add(createPanel(), BorderLayout.CENTER);
535
   }
536

  
537

  
538
}
org.gvsig.raster/branches/org.gvsig.raster.2.4/org.gvsig.wmts/org.gvsig.wmts.swing/org.gvsig.wmts.swing.impl/src/main/java/org/gvsig/wmts/swing/impl/DefaultWMTSSwingManager.java
1
package org.gvsig.wmts.swing.impl;
2
/* gvSIG. Desktop Geographic Information System.
3
 *
4
 * Copyright ? 2007-2018 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 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
 * 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

  
25

  
26
import org.gvsig.wmts.swing.api.WMTSParametersPanel;
27
import org.gvsig.wmts.swing.api.WMTSSwingManager;
28

  
29

  
30
/**
31
 * @author fdiaz
32
 *
33
 */
34
public class DefaultWMTSSwingManager implements WMTSSwingManager {
35

  
36
    /**
37
     *
38
     */
39
    public DefaultWMTSSwingManager() {
40
        // TODO Auto-generated constructor stub
41
    }
42

  
43
    /* (non-Javadoc)
44
     * @see org.gvsig.wms.swing.api.WMSSwingManager#createWMSParametersPanel(org.gvsig.fmap.dal.DataParameters)
45
     */
46
    @Override
47
    public WMTSParametersPanel createWMTSParametersPanel() {
48
        return new DefaultWMTSParametersPanelController();
49
    }
50

  
51
}
org.gvsig.raster/branches/org.gvsig.raster.2.4/org.gvsig.wmts/org.gvsig.wmts.swing/org.gvsig.wmts.swing.impl/src/main/java/org/gvsig/wmts/swing/impl/DefaultWMTSParametersPanelController.java
1
/* gvSIG. Desktop Geographic Information System.
2
 *
3
 * Copyright ? 2007-2018 gvSIG Association
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., 51 Franklin Street, Fifth Floor, Boston,
18
 * MA  02110-1301, USA.
19
 *
20
 * For any additional information, do not hesitate to contact us
21
 * at info AT gvsig.com, or visit our website www.gvsig.com.
22
 */
23
package org.gvsig.wmts.swing.impl;
24

  
25
import java.awt.Color;
26
import java.awt.Component;
27
import java.awt.event.ActionEvent;
28
import java.awt.event.ActionListener;
29
import java.awt.event.MouseAdapter;
30
import java.awt.event.MouseEvent;
31
import java.net.URL;
32
import java.util.Iterator;
33
import java.util.List;
34

  
35
import javax.swing.DefaultComboBoxModel;
36
import javax.swing.DefaultListModel;
37
import javax.swing.JComponent;
38
import javax.swing.JLabel;
39
import javax.swing.JPanel;
40
import javax.swing.JRadioButton;
41
import javax.swing.JTree;
42
import javax.swing.ListSelectionModel;
43
import javax.swing.SwingUtilities;
44
import javax.swing.event.ListSelectionEvent;
45
import javax.swing.event.ListSelectionListener;
46
import javax.swing.event.TreeModelListener;
47
import javax.swing.tree.DefaultTreeCellRenderer;
48
import javax.swing.tree.DefaultTreeModel;
49
import javax.swing.tree.TreeModel;
50
import javax.swing.tree.TreeNode;
51
import javax.swing.tree.TreePath;
52

  
53
import org.apache.commons.lang3.StringUtils;
54
import org.cresques.cts.IProjection;
55
import org.slf4j.Logger;
56
import org.slf4j.LoggerFactory;
57

  
58
import org.gvsig.fmap.crs.CRSFactory;
59
import org.gvsig.fmap.dal.DALLocator;
60
import org.gvsig.fmap.dal.DataManager;
61
import org.gvsig.fmap.dal.DataServerExplorerParameters;
62
import org.gvsig.fmap.dal.DataServerExplorerPool;
63
import org.gvsig.fmap.dal.DataServerExplorerPoolEntry;
64
import org.gvsig.tools.ToolsLocator;
65
import org.gvsig.tools.dispose.DisposeUtils;
66
import org.gvsig.tools.dynobject.DynObject;
67
import org.gvsig.tools.i18n.I18nManager;
68
import org.gvsig.tools.swing.api.ToolsSwingLocator;
69
import org.gvsig.tools.swing.icontheme.IconTheme;
70
import org.gvsig.wmts.provider.WMTSRasterProviderParameters;
71
import org.gvsig.wmts.provider.WMTSRasterServerExplorer;
72
import org.gvsig.wmts.provider.WMTSRasterServerExplorerParameters;
73
import org.gvsig.wmts.provider.tree.WMTSLayerNode;
74
import org.gvsig.wmts.provider.tree.WMTSNode;
75
import org.gvsig.wmts.provider.tree.WMTSStyleData;
76
import org.gvsig.wmts.swing.api.WMTSParametersPanel;
77

  
78
/**
79
 * @author fdiaz
80
 *
81
 */
82
public class DefaultWMTSParametersPanelController extends DefaultWMTSParametersPanelView implements WMTSParametersPanel {
83

  
84
    private static final String NAME = "DefaultGoogleMapsParametersPanelController";
85
    private static final Logger logger = LoggerFactory.getLogger(DefaultWMTSParametersPanelController.class);
86
    private static final int TAB_CONNECTION_INDEX = 0;
87
    private static final int TAB_LAYERS_INDEX = 1;
88
    private static final int TAB_STYLES_INDEX = 2;
89
    private static final int TAB_DIMENSIONS_INDEX = 3;
90
    private static final int TAB_FORMATS_INDEX = 4;
91
    // List<WMSParametersEntry> parameterList;
92
    WMTSRasterServerExplorer explorer;
93
    private WMTSRasterServerExplorer serverExplorer;
94
    private String format = null;
95
    private String infoFormat = null;
96
    private String projection = "";
97
    private IProjection mapCtxProj = null;
98

  
99
    private Thread connectionThread;
100
    private WMTSLayerNode selectedLayer;
101
    protected String selectedStyle;
102

  
103
    /**
104
     *
105
     */
106
    public DefaultWMTSParametersPanelController() {
107
        super();
108
        initComponents();
109
        translate();
110
    }
111

  
112
    @Override
113
    public void setPreferredProjection(IProjection proj) {
114
        mapCtxProj = proj;
115
    }
116

  
117
    private void translate() {
118
        I18nManager i18nManager = ToolsLocator.getI18nManager();
119
        // Title tab translate
120
        for (int i = 0; i < tabWMTS.getTabCount(); i++) {
121
            tabWMTS.setTitleAt(i, i18nManager.getTranslation(tabWMTS.getTitleAt(i)));
122
        }
123

  
124
        // Tab connection
125
        lblServer.setText(i18nManager.getTranslation(lblServer.getText()));
126
        lblServer.setToolTipText(i18nManager.getTranslation(lblServer.getToolTipText()));
127

  
128
        cboServerList.setToolTipText(i18nManager.getTranslation(cboServerList.getToolTipText()));
129

  
130
        lblUser.setText(i18nManager.getTranslation(lblUser.getText()));
131
        lblUser.setToolTipText(i18nManager.getTranslation(lblUser.getToolTipText()));
132

  
133
        txtUser.setToolTipText(i18nManager.getTranslation(txtUser.getToolTipText()));
134

  
135
        lblPassword.setText(i18nManager.getTranslation(lblPassword.getText()));
136
        lblPassword.setToolTipText(i18nManager.getTranslation(lblPassword.getToolTipText()));
137

  
138
        txtPassword.setToolTipText(i18nManager.getTranslation(txtPassword.getToolTipText()));
139

  
140
        chkRefreshCache.setText(i18nManager.getTranslation(chkRefreshCache.getText()));
141
        chkRefreshCache.setToolTipText(i18nManager.getTranslation(chkRefreshCache.getToolTipText()));
142

  
143
        btnConnect.setText(i18nManager.getTranslation(btnConnect.getText()));
144
        btnConnect.setToolTipText(i18nManager.getTranslation(btnConnect.getToolTipText()));
145

  
146
        btnCancel.setText(i18nManager.getTranslation(btnCancel.getText()));
147
        btnCancel.setToolTipText(i18nManager.getTranslation(btnCancel.getToolTipText()));
148

  
149
        chkRefreshLocalCache.setText(i18nManager.getTranslation(chkRefreshLocalCache.getText()));
150
        chkRefreshLocalCache.setToolTipText(i18nManager.getTranslation(chkRefreshLocalCache.getToolTipText()));
151

  
152
        chkInvertAxisOrder.setText(i18nManager.getTranslation(chkInvertAxisOrder.getText()));
153
        chkInvertAxisOrder.setToolTipText(i18nManager.getTranslation(chkInvertAxisOrder.getToolTipText()));
154

  
155
        lblInformation.setText(i18nManager.getTranslation(lblInformation.getText()));
156
        lblInformation.setToolTipText(i18nManager.getTranslation(lblInformation.getToolTipText()));
157

  
158
        lblSelectLayers.setText(i18nManager.getTranslation(lblSelectLayers.getText()));
159
        lblSelectLayers.setToolTipText(i18nManager.getTranslation(lblSelectLayers.getToolTipText()));
160

  
161
        treeLayersSelector.setToolTipText(i18nManager.getTranslation(treeLayersSelector.getToolTipText()));
162

  
163
        lblSelectedLayer.setText(i18nManager.getTranslation(lblSelectedLayer.getText()));
164
        lblSelectedLayer.setToolTipText(i18nManager.getTranslation(lblSelectedLayer.getToolTipText()));
165

  
166
        txtSelectedLayer.setToolTipText(i18nManager.getTranslation(txtSelectedLayer.getToolTipText()));
167

  
168
        btnAddLayer.setText(""); // btnAddLayer.getText()));
169
        btnAddLayer.setToolTipText(i18nManager.getTranslation(btnAddLayer.getToolTipText()));
170

  
171
        btnRemoveLayer.setText(""); // btnRemoveLayer.getText()));
172
        btnRemoveLayer.setToolTipText(i18nManager.getTranslation(btnRemoveLayer.getToolTipText()));
173

  
174
        // Tab styles
175
        treeStyles.setToolTipText(i18nManager.getTranslation(treeStyles.getToolTipText()));
176

  
177
        // Tab dimensions
178
        lblSettings.setText(i18nManager.getTranslation(lblSettings.getText()));
179
        lblSettings.setToolTipText(i18nManager.getTranslation(lblSettings.getToolTipText()));
180

  
181
        lstDimensionsSettings.setToolTipText(i18nManager.getTranslation(lstDimensionsSettings.getToolTipText()));
182

  
183
        lblSettingsEditor.setText(i18nManager.getTranslation(lblSettingsEditor.getText()));
184
        lblSettingsEditor.setToolTipText(i18nManager.getTranslation(lblSettingsEditor.getToolTipText()));
185

  
186
        lstDimensions.setToolTipText(i18nManager.getTranslation(lstDimensions.getToolTipText()));
187

  
188
        lblValue.setText(i18nManager.getTranslation(lblValue.getText()));
189
        lblValue.setToolTipText(i18nManager.getTranslation(lblValue.getToolTipText()));
190

  
191
        lblFieldValue.setText("");
192
        lblFieldValue.setToolTipText(i18nManager.getTranslation(lblFieldValue.getToolTipText()));
193

  
194
        sldValues.setToolTipText(i18nManager.getTranslation(sldValues.getToolTipText()));
195

  
196
        btnFirst.setText(""); // btnFirst.getText()));
197
        btnFirst.setToolTipText(i18nManager.getTranslation(btnFirst.getToolTipText()));
198

  
199
        btnPrevious.setText(""); // btnPrevious.getText()));
200
        btnPrevious.setToolTipText(i18nManager.getTranslation(btnPrevious.getToolTipText()));
201

  
202
        txtDimensionNumber.setToolTipText(i18nManager.getTranslation(txtDimensionNumber.getToolTipText()));
203

  
204
        btnNext.setText(""); // btnNext.getText()));
205
        btnNext.setToolTipText(i18nManager.getTranslation(btnNext.getToolTipText()));
206

  
207
        btnLast.setText(""); // btnLast.getText()));
208
        btnLast.setToolTipText(i18nManager.getTranslation(btnLast.getToolTipText()));
209

  
210
        rdbSimpleValue.setText(i18nManager.getTranslation(rdbSimpleValue.getText()));
211
        rdbSimpleValue.setToolTipText(i18nManager.getTranslation(rdbSimpleValue.getToolTipText()));
212

  
213
        rdbMultipleValue.setText(i18nManager.getTranslation(rdbMultipleValue.getText()));
214
        rdbMultipleValue.setToolTipText(i18nManager.getTranslation(rdbMultipleValue.getToolTipText()));
215

  
216
        rdbInterval.setText(i18nManager.getTranslation(rdbInterval.getText()));
217
        rdbInterval.setToolTipText(i18nManager.getTranslation(rdbInterval.getToolTipText()));
218

  
219
        btnAddSetting.setText(i18nManager.getTranslation(btnAddSetting.getText()));
220
        btnAddSetting.setToolTipText(i18nManager.getTranslation(btnAddSetting.getToolTipText()));
221

  
222
        btnClearSetting.setText(i18nManager.getTranslation(btnClearSetting.getText()));
223
        btnClearSetting.setToolTipText(i18nManager.getTranslation(btnClearSetting.getToolTipText()));
224

  
225
        txtSetting.setToolTipText(i18nManager.getTranslation(txtSetting.getToolTipText()));
226

  
227
        btnSet.setText(i18nManager.getTranslation(btnSet.getText()));
228
        btnSet.setToolTipText(i18nManager.getTranslation(btnSet.getToolTipText()));
229

  
230
        // Tab formats
231
        lblFormats.setText(i18nManager.getTranslation(lblFormats.getText()));
232
        lblFormats.setToolTipText(i18nManager.getTranslation(lblFormats.getToolTipText()));
233

  
234
        lstFormats.setToolTipText(i18nManager.getTranslation(lstFormats.getToolTipText()));
235

  
236
        lblProjection.setText(i18nManager.getTranslation(lblProjection.getText()));
237
        lblProjection.setToolTipText(i18nManager.getTranslation(lblProjection.getToolTipText()));
238

  
239
        lstProjections.setToolTipText(i18nManager.getTranslation(lstProjections.getToolTipText()));
240

  
241
        lblInfoFormat.setText(i18nManager.getTranslation(lblInfoFormat.getText()));
242
        lblInfoFormat.setToolTipText(i18nManager.getTranslation(lblInfoFormat.getToolTipText()));
243

  
244
        lstInfoFormats.setToolTipText(i18nManager.getTranslation(lstInfoFormats.getToolTipText()));
245

  
246
    }
247

  
248
    private void initComponents() {
249
        fillConnections();
250

  
251
        IconTheme iconTheme = ToolsSwingLocator.getIconThemeManager().getCurrent();
252

  
253
        this.btnAddLayer.setIcon(iconTheme.get("add-layer-icon"));
254
        this.btnRemoveLayer.setIcon(iconTheme.get("remove-layer-icon"));
255

  
256
        this.btnFirst.setIcon(iconTheme.get("first-value-icon"));
257
        this.btnPrevious.setIcon(iconTheme.get("previous-value-icon"));
258
        this.btnNext.setIcon(iconTheme.get("next-value-icon"));
259
        this.btnLast.setIcon(iconTheme.get("last-value-icon"));
260

  
261
        this.btnConnect.addActionListener(new ActionListener() {
262

  
263
            @Override
264
            public void actionPerformed(ActionEvent e) {
265
                doConnect();
266
            }
267
        });
268

  
269
        this.btnCancel.addActionListener(new ActionListener() {
270

  
271
            @Override
272
            public void actionPerformed(ActionEvent e) {
273
                doCancelConnection();
274
            }
275
        });
276

  
277
        initializeTreeLayerSelector();
278
        initializeLstProjections();
279
        initializeTreeStyles();
280
        initializeLstFormats();
281
        initializeLstInfoFormats();
282
        // initializeTblDimensions();
283

  
284
        this.btnAddLayer.setEnabled(false);
285
        this.btnAddLayer.addActionListener(new ActionListener() {
286

  
287
            @Override
288
            public void actionPerformed(ActionEvent e) {
289
                WMTSNode node = (WMTSNode) treeLayersSelector.getLastSelectedPathComponent();
290
                if (node == null) {
291
                    return;
292
                }
293
                if (node instanceof WMTSLayerNode && node.isLeaf()) {
294
                    doSelectLayer(node);
295
                }
296
            }
297
        });
298

  
299
        this.btnRemoveLayer.setEnabled(false);
300
        this.btnRemoveLayer.addActionListener(new ActionListener() {
301

  
302
            @Override
303
            public void actionPerformed(ActionEvent e) {
304
                selectedLayer = null;
305
                updateTxtSelectedLayer();
306
            }
307
        });
308

  
309
        updateComponents();
310
    }
311

  
312
    protected void updateTxtSelectedLayer() {
313
        if (selectedLayer != null) {
314
            txtSelectedLayer.setText(selectedLayer.getTitle());
315
        } else {
316
            txtSelectedLayer.setText("");
317
        }
318
    }
319

  
320
    @Override
321
    public JComponent asJComponent() {
322
        return this;
323
    }
324

  
325
    @Override
326
    public void dispose() {
327
        DisposeUtils.disposeQuietly(explorer);
328
    }
329

  
330
    public void putParameters(DynObject parameters) {
331
        // TODO:
332
    }
333

  
334
    public void fetchParameters(DynObject parameters) {
335

  
336
    }
337

  
338
    private void doConnect() {
339
        final String selectedItem = (String) cboServerList.getSelectedItem();
340
        if (StringUtils.isEmpty(selectedItem)) {
341
            return;
342
        }
343

  
344
        btnConnect.setEnabled(false);
345
        btnCancel.setEnabled(true);
346

  
347
        connectionThread = new Thread(new Runnable() {
348

  
349
            @Override
350
            public void run() {
351
                DataManager manager = DALLocator.getDataManager();
352
                final DataServerExplorerParameters parameters;
353
                try {
354
                    parameters = manager.createServerExplorerParameters("WMTS");
355
                    parameters.setDynValue(WMTSRasterServerExplorerParameters.WMTS_SERVICE_PARAMETER_NAME, new URL(
356
                        selectedItem)); // "service"
357
                    // parameters.setDynValue(WMTSRasterServerExplorerParameters.WMTS_OVERRIDE_CAPABILITIES_PARAMETER_NAME,
358
                    // chkRefreshCache.isSelected()); // "override_capabilities"
359

  
360
                    final WMTSRasterServerExplorer serverExplorer =
361
                        (WMTSRasterServerExplorer) manager.openServerExplorer("WMTS", parameters);
362

  
363
                    // List layers = serverExplorer.list();
364

  
365
                    SwingUtilities.invokeLater(new Runnable() {
366

  
367
                        @Override
368
                        public void run() {
369
                            // if(Thread.interrupted()){
370
                            // return;
371
                            // }
372
                            setServerExplorer(serverExplorer);
373
                            DataServerExplorerPool pool = DALLocator.getDataManager().getDataServerExplorerPool();
374

  
375
                            pool.add(((URL) parameters
376
                                .getDynValue(WMTSRasterServerExplorerParameters.WMTS_SERVICE_PARAMETER_NAME))
377
                                .toString(), serverExplorer.getParameters());
378

  
379
                        }
380
                    });
381
                } catch (Exception e) {
382
                    // FIXME: ?Mostrar di?logo para preguntar si se desea
383
                    // eliminar el servidor del pool de servidores en caso de
384
                    // existir ah??
385
                    setServerExplorer(null);
386
                }
387

  
388
            }
389
        }, "WMSConnection");
390
        connectionThread.start();
391
        try {
392
            Thread.sleep(2);
393
        } catch (InterruptedException e) {
394
        }
395
    }
396

  
397
    protected void doCancelConnection() {
398
        // if(connectionThread != null && connectionThread.isAlive()){
399
        // connectionThread.interrupt();
400
        // }
401
    }
402

  
403
    private void setServerExplorer(WMTSRasterServerExplorer serverExplorer) {
404
        this.serverExplorer = serverExplorer;
405

  
406
        this.updateComponents();
407

  
408
        WMTSNode node = (WMTSNode) this.serverExplorer.getListAsTree();
409
        fillLayers(node);
410

  
411
        txtInformation.setText(serverExplorer.getInfoString());
412

  
413
        tabWMTS.setEnabledAt(4, true);
414
    }
415

  
416
    private void updateComponents() {
417

  
418
        if (serverExplorer == null) {
419
            cboServerList.setEnabled(true);
420
            // Authentication of WMS servers is not yet implemented, when
421
            // implemented, enabling the following two controls.
422
            txtUser.setEnabled(false);
423
            txtPassword.setEnabled(false);
424

  
425
            chkRefreshCache.setEnabled(true);
426
            btnConnect.setEnabled(true);
427
            btnCancel.setEnabled(false);
428

  
429
            chkRefreshLocalCache.setEnabled(false);
430
            chkInvertAxisOrder.setEnabled(false);
431
            txtInformation.setEnabled(false);
432

  
433
            tabWMTS.setEnabledAt(TAB_LAYERS_INDEX, false);
434
            tabWMTS.setEnabledAt(TAB_STYLES_INDEX, false);
435
            tabWMTS.setEnabledAt(TAB_DIMENSIONS_INDEX, false);
436
            tabWMTS.setEnabledAt(TAB_FORMATS_INDEX, false);
437
        } else {
438
            cboServerList.setEnabled(false);
439
            txtUser.setEnabled(false);
440
            txtPassword.setEnabled(false);
441
            chkRefreshCache.setEnabled(false);
442
            btnConnect.setEnabled(false);
443
            btnCancel.setEnabled(false);
444

  
445
            chkRefreshLocalCache.setEnabled(true);
446
            chkInvertAxisOrder.setEnabled(true);
447
            txtInformation.setEnabled(true);
448

  
449
            tabWMTS.setEnabledAt(TAB_LAYERS_INDEX, true);
450
        }
451

  
452
    }
453

  
454
    private void fillConnections() {
455
        DefaultComboBoxModel<String> model = new DefaultComboBoxModel<>();
456

  
457
        DataServerExplorerPool pool = DALLocator.getDataManager().getDataServerExplorerPool();
458
        Iterator it = pool.iterator();
459
        while (it.hasNext()) {
460
            DataServerExplorerPoolEntry entry = (DataServerExplorerPoolEntry) it.next();
461
            DataServerExplorerParameters parameters = entry.getExplorerParameters();
462
            if (parameters instanceof WMTSRasterServerExplorerParameters) {
463
                model.addElement(((URL) parameters
464
                    .getDynValue(WMTSRasterServerExplorerParameters.WMTS_SERVICE_PARAMETER_NAME)).toString());
465
            }
466
        }
467

  
468
        this.cboServerList.setModel(model);
469
    }
470

  
471
    private void initializeLstFormats() {
472
        final DefaultListModel<String> model = new DefaultListModel<>();
473
        lstFormats.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
474
        lstFormats.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
475

  
476
            @Override
477
            public void valueChanged(ListSelectionEvent e) {
478
                int index = lstFormats.getSelectedIndex();
479
                if (index >= 0) {
480
                    format = model.getElementAt(index);
481
                } else {
482
                    format = "";
483
                }
484
            }
485
        });
486
        lstFormats.setModel(model);
487
    }
488

  
489
    private void updateLstFormats(List<String> formats) {
490
        final DefaultListModel<String> model = (DefaultListModel<String>) (lstFormats.getModel());
491
        model.clear();
492
        if (formats != null) {
493
            for (Iterator<String> iterator = formats.iterator(); iterator.hasNext();) {
494
                model.addElement(iterator.next());
495
            }
496
        }
497
        selectFormat();
498
    }
499

  
500
    private void initializeLstInfoFormats() {
501

  
502
        final DefaultListModel<String> model = new DefaultListModel<>();
503
        lstInfoFormats.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
504
        lstInfoFormats.getSelectionModel().addListSelectionListener(new ListSelectionListener() {
505

  
506
            @Override
507
            public void valueChanged(ListSelectionEvent e) {
508
                int index = lstInfoFormats.getSelectedIndex();
509
                if (index >= 0) {
510
                    infoFormat = model.getElementAt(index);
511
                } else {
512
                    infoFormat = "";
513
                }
514
            }
515
        });
516
        lstInfoFormats.setModel(model);
517
    }
518

  
519
    private void updateLstInfoFormats(List<String> infoFormats) {
520

  
521
        final DefaultListModel<String> model = (DefaultListModel<String>) (lstInfoFormats.getModel());
522
        model.clear();
523
        if (infoFormats != null) {
524
            for (Iterator<String> iterator = infoFormats.iterator(); iterator.hasNext();) {
525
                model.addElement(iterator.next());
526
            }
527
        }
528
        selectInfoFormat();
529
    }
530

  
531
    private void fillLayers(TreeNode node) {
532
        TreeModel treeModel = new DefaultTreeModel(node, true);
533
        treeLayersSelector.setModel(treeModel);
534
    }
535

  
536
    /**
537
     *
538
     */
539
    private void initializeTreeLayerSelector() {
540
        treeLayersSelector.setCellRenderer(new DefaultTreeCellRenderer() {
541

  
542
            /**
543
             *
544
             */
545
            private static final long serialVersionUID = -6800758982020754819L;
546

  
547
            @Override
548
            public Component getTreeCellRendererComponent(JTree tree, Object value, boolean selected, boolean expanded,
549
                boolean leaf, int row, boolean hasFocus) {
550
                Component comp =
551
                    super.getTreeCellRendererComponent(tree, value, selected, expanded, leaf, row, hasFocus);
552
                String text;
553
                if (value instanceof WMTSNode) {
554
                    WMTSNode node = (WMTSNode) value;
555
                    text = node.getTitle();
556
                    setText(text);
557
                }
558
                return comp;
559
            }
560
        });
561

  
562
        treeLayersSelector.addMouseListener(new MouseAdapter() {
563

  
564
            @Override
565
            public void mouseClicked(MouseEvent e) {
566
                if (e.getClickCount() == 1) {
567
                    WMTSNode node = (WMTSNode) treeLayersSelector.getLastSelectedPathComponent();
568
                    btnAddLayer.setEnabled(node != null && node.isLeaf() && node instanceof WMTSLayerNode);
569
                } else if (e.getClickCount() == 2) {
570
                    WMTSNode node = (WMTSNode) treeLayersSelector.getLastSelectedPathComponent();
571
                    if (node == null)
572
                        return;
573
                    if (node.isLeaf() && node instanceof WMTSLayerNode) {
574
                        doSelectLayer((WMTSLayerNode) node);
575
                    }
576
                }
577
            }
578
        });
579
    }
580

  
581
    protected void doSelectLayer(Object selected) {
582
        if (selected instanceof WMTSLayerNode) {
583
            WMTSLayerNode node = (WMTSLayerNode) selected;
584
            this.selectedLayer = node;
585
            updateTxtSelectedLayer();
586

  
587
            List<String> formats = null;
588
            if (selectedLayer != null) {
589
                formats = this.selectedLayer.getFormats();
590
            }
591

  
592
            updateLstFormats(formats);
593
            int formatIndex = -1;
594
            if (!StringUtils.isEmpty(format)) {
595
                if (formats.contains(format)) {
596
                    formatIndex = formats.indexOf(format);
597
                }
598
            } else {
599
                if (formats.size() > 0) {
600
                    formatIndex = 0;
601
                    format = formats.get(formatIndex);
602
                }
603
            }
604
            lstFormats.getSelectionModel().setSelectionInterval(formatIndex, formatIndex);
605

  
606
            List<String> infoFormats = null;
607
            if (selectedLayer != null) {
608
                infoFormats = this.selectedLayer.getInfoFormats();
609
            }
610
            updateLstInfoFormats(infoFormats);
611
            int formatInfoIndex = -1;
612
            if (infoFormats != null) {
613
                if (!StringUtils.isEmpty(infoFormat)) {
614
                    if (infoFormats.contains(infoFormat)) {
615
                        formatInfoIndex = infoFormats.indexOf(infoFormat);
616
                    }
617
                } else {
618
                    if (infoFormats.size() > 0) {
619
                        formatInfoIndex = 0;
620
                        infoFormat = infoFormats.get(formatInfoIndex);
621
                    }
622
                }
623
                lstInfoFormats.getSelectionModel().setSelectionInterval(formatInfoIndex, formatInfoIndex);
624
            }
625
            updateLstProjections();
626
            updateTreeStyles();
627
        }
628
    }
629

  
630
    @SuppressWarnings("unchecked")
631
    private void initializeLstProjections() {
632

  
633
        final DefaultListModel<String> model = new DefaultListModel<>();
634

  
635
        lstProjections.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
636

  
637
        ListSelectionModel selectionModel = lstProjections.getSelectionModel();
638
        selectionModel.addListSelectionListener(new ListSelectionListener() {
639

  
640
            @Override
641
            public void valueChanged(ListSelectionEvent e) {
642
                int selectedRow = lstProjections.getSelectedIndex();
643
                if (selectedRow >= 0 && selectedRow < model.getSize()) {
644
                    projection = model.getElementAt(selectedRow);
645
                }
646
            }
647
        });
648

  
649
        lstProjections.setModel(model);
650
    }
651

  
652
    private void updateLstProjections() {
653
        @SuppressWarnings("unchecked")
654
        DefaultListModel<String> model = (DefaultListModel<String>) lstProjections.getModel();
655
        model.clear();
656
        if (selectedLayer != null) {
657
            List<String> srss = selectedLayer.getSrsList();
658
            for (Iterator<String> iterator = srss.iterator(); iterator.hasNext();) {
659
                model.addElement(iterator.next());
660
            }
661
            selectProjection();
662
        } else {
663
            this.projection = null;
664
        }
665
    }
666

  
667
    @SuppressWarnings("unchecked")
668
    private void selectProjection() {
669
        if (!StringUtils.isEmpty(projection)) {
670
            DefaultListModel<String> model = (DefaultListModel<String>) lstProjections.getModel();
671
            for (int i = 0; i < model.size(); i++) {
672
                if (projection.equals(model.elementAt(i))) {
673
                    lstProjections.setSelectedIndex(i);
674
                    return;
675
                }
676
            }
677
        } else if (mapCtxProj != null) {
678
            DefaultListModel<String> model = (DefaultListModel<String>) lstProjections.getModel();
679
            for (int i = 0; i < model.size(); i++) {
680

  
681
                String srs = model.elementAt(i);
682
                try {
683
                    IProjection crs = CRSFactory.getCRS(model.elementAt(i));
684
                    if (crs != null && crs.equals(mapCtxProj)) {
685
                        lstProjections.setSelectedIndex(i);
686
                        return;
687
                    }
688
                } catch (Exception e) {
689
                    logger.info("Can't get crs from: '" + srs + "' code", e);
690
                }
691
            }
692
        }
693
        ;
694
        if (lstProjections.getModel().getSize() > 0) {
695
            lstProjections.setSelectedIndex(0);
696
        }
697
    }
698

  
699
    @SuppressWarnings("unchecked")
700
    private void selectFormat() {
701
        DefaultListModel<String> model = (DefaultListModel<String>) lstFormats.getModel();
702
        if (!StringUtils.isEmpty(format)) {
703
            for (int i = 0; i < model.size(); i++) {
704
                if (format.equals(model.elementAt(i))) {
705
                    lstFormats.setSelectedIndex(i);
706
                    return;
707
                }
708
            }
709
        }
710
        if (model.getSize() > 0) {
711
            lstFormats.setSelectedIndex(0);
712
        }
713
    }
714

  
715
    @SuppressWarnings("unchecked")
716
    private void selectInfoFormat() {
717
        DefaultListModel<String> model = (DefaultListModel<String>) lstInfoFormats.getModel();
718
        if (!StringUtils.isEmpty(infoFormat)) {
719
            for (int i = 0; i < model.size(); i++) {
720
                if (format.equals(model.elementAt(i))) {
721
                    lstInfoFormats.setSelectedIndex(i);
722
                    return;
723
                }
724
            }
725
        }
726
        if (model.getSize() > 0) {
727
            lstInfoFormats.setSelectedIndex(0);
728
        }
729
    }
730

  
731
    /**
732
    *
733
    */
734
    private void initializeTreeStyles() {
735
        treeStyles.setToggleClickCount(1);
736
        treeStyles.setRowHeight(22);
737

  
738
        treeStyles.setCellRenderer(new DefaultTreeCellRenderer() {
739

  
740
            /**
741
             *
742
             */
743
            private static final long serialVersionUID = 4821777811489883864L;
744

  
745
            @Override
746
            public java.awt.Component getTreeCellRendererComponent(JTree tree, Object value, boolean selected,
747
                boolean expanded, boolean leaf, int row, boolean hasFocus) {
748
                if (leaf) {
749
                    JPanel leafComponent = new JPanel();
750
                    leafComponent.setBackground(Color.WHITE);
751
                    JRadioButton leafRadioButton =
752
                        new JRadioButton("", ((StyleTreeModel) treeStyles.getModel()).isSelected((WMTSStyleData) value));
753

  
754
                    leafRadioButton.setBackground(Color.WHITE);
755
                    leafComponent.add(leafRadioButton);
756
                    String text = ((WMTSStyleData) value).getTitle();
757
                    if (StringUtils.isEmpty(text)) {
758
                        text = ((WMTSStyleData) value).getIdentifier();
759
                    }
760
                    leafComponent.add(new JLabel(((WMTSStyleData) value).getIdentifier()));
761
                    return leafComponent;
762
                } else {
763
                    super.getTreeCellRendererComponent(tree, value, selected, expanded, leaf, row, hasFocus);
764
                    if (value instanceof WMTSLayerNode) {
765
                        WMTSLayerNode layerNode = (WMTSLayerNode) value;
766
                        String text = "";
767
                        if (layerNode != null) {
768
                            text = layerNode.getTitle();
769
                        }
770
                        setText(text);
771
                    } else if (value instanceof String) {
772
                        setText((String) value);
773
                    }
774
                    return this;
775
                }
776
            }
777
        });
778

  
779
        treeStyles.addMouseListener(new java.awt.event.MouseAdapter() {
780

  
781
            @Override
782
            public void mouseClicked(java.awt.event.MouseEvent e) {
783
                ((StyleTreeModel) treeStyles.getModel()).setSelectedLeaf(treeStyles.getSelectionPath());
784
                selectedStyle = ((WMTSNode) treeStyles.getSelectionPath().getLastPathComponent()).getIdentifier();
785
                treeStyles.clearSelection();
786
                repaint();
787
            }
788
        });
789
    }
790

  
791
    private void updateTreeStyles() {
792

  
793
        tabWMTS.setEnabledAt(TAB_STYLES_INDEX, selectedLayer != null);
794

  
795
        StyleTreeModel model = new StyleTreeModel(selectedLayer);
796

  
797
        treeStyles.setModel(model);
798
        expandAllNodes(treeStyles);
799
    }
800

  
801
    private void expandAllNodes(JTree tree) {
802
        int j = tree.getRowCount();
803
        int i = 0;
804
        while (i < j) {
805
            tree.expandRow(i);
806
            i += 1;
807
            j = tree.getRowCount();
808
        }
809
    }
810

  
811
    class StyleTreeModel implements TreeModel {
812

  
813
        WMTSLayerNode layerNode;
814

  
815
        public StyleTreeModel(WMTSLayerNode layerNode) {
816
            this.layerNode = layerNode;
817
        }
818

  
819
        /**
820
         * Will return true if this style is selected.
821
         *
822
         * @param WMSStyle
823
         * @return true if this style is selected.
824
         */
825
        public boolean isSelected(WMTSStyleData style) {
826
            if (layerNode.getSelectedStyle().equals(style)) {
827
                return true;
828
            }
829
            return false;
830
        }
831

  
832
        /**
833
         * Gets the name of the selected style.
834
         *
835
         * @return the names of the selected styles into a List using the same
836
         *         order as they was represented in the StylesTree.
837
         */
838
        public String getStyleSelectionTitles() {
839
            WMTSStyleData sty = layerNode.getSelectedStyle();
840
            if (sty == null) {
841
                return "";
842
            } else {
843
                return sty.getTitle();
844
            }
845
        }
846

  
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff