Revision 874

View differences:

org.gvsig.proj/branches/refactor2018/org.gvsig.proj/org.gvsig.proj.swing/org.gvsig.proj.swing.api/src/main/java/org/gvsig/proj/swing/CoordinateReferenceSystemAndTransformFieldComponent.java
1
package org.gvsig.proj.swing;
2

  
3
import org.gvsig.proj.CoordinateReferenceSystem;
4
import org.gvsig.proj.CoordinateTransformation;
5
import org.gvsig.tools.swing.api.Component;
6

  
7
/**
8
 * A component  to show and change a {@link CoordinateReferenceSystem}
9
 * and a {@link CoordinateTransformation}.
10
 * @author Cesar Martinez Izquierdo
11
 *
12
 */
13
public interface CoordinateReferenceSystemAndTransformFieldComponent 
14
		extends CoordinateReferenceSystemAndTransformFieldController, Component {
15
	
16
}
org.gvsig.proj/branches/refactor2018/org.gvsig.proj/org.gvsig.proj.swing/org.gvsig.proj.swing.api/src/main/java/org/gvsig/proj/swing/CoordinateReferenceSystemAndTransformFieldController.java
1
package org.gvsig.proj.swing;
2

  
3
import org.gvsig.proj.CoordinateReferenceSystem;
4
import org.gvsig.proj.CoordinateTransformation;
5

  
6
/**
7
 * A controller for a specialized field to show and change a
8
 * {@link CoordinateReferenceSystem} and a {@link CoordinateTransformation}. 
9
 * 
10
 * @author Cesar Martinez Izquierdo
11
 */
12
public interface CoordinateReferenceSystemAndTransformFieldController {
13

  
14
	/**
15
	 * Sets the selected {@link CoordinateReferenceSystem}
16
	 * 
17
	 * @param crs The {@link CoordinateReferenceSystem CRS} to set, or {@code null}
18
	 * to clear the selection. Clearing the CRS will also clear the
19
	 * selected transformation.
20
	 */ 
21
	void setCoordinateReferenceSystem(CoordinateReferenceSystem crs);
22

  
23
	/**
24
	 * Gets the selected {@link CoordinateReferenceSystem} or {@code null} if
25
	 * none has been selected.
26
	 * 
27
	 * @return
28
	 */
29
	CoordinateReferenceSystem getCoordinateReferenceSystem();
30

  
31
	/**
32
	 * Sets the selected {@link CoordinateTransformation}
33
	 * @param ct The {@link CoordinateTransformation} to set, or {@code null}
34
	 * to clear the selection.  
35
	 */
36
	void setCoordinateTransformation(CoordinateTransformation ct);
37

  
38
	/**
39
	 * Gets the selected {@link CoordinateTransformation} or {@code null} if
40
	 * none has been selected.
41
	 * 
42
	 * @return
43
	 */
44
	CoordinateTransformation getCoordinateTransformation();
45
}
org.gvsig.proj/branches/refactor2018/org.gvsig.proj/org.gvsig.proj.swing/org.gvsig.proj.swing.api/src/main/java/org/gvsig/proj/swing/CoordinateReferenceSystemAndTransformationSelectorComponent.java
1
package org.gvsig.proj.swing;
2

  
3
import java.awt.event.ActionListener;
4

  
5
import org.gvsig.proj.CoordinateReferenceSystem;
6
import org.gvsig.proj.CoordinateTransformation;
7
import org.gvsig.tools.swing.api.Component;
8

  
9
/**
10
 * A Component to select a {@link CoordinateReferenceSystem} and a CoordinateTransformation. The selected
11
 * CRS can be the source or the target CRS depending on the assigned {@link #getSelectedCrsRole() role}. 
12
 * Since the transformation requires a source CRS and a target CRS, the component MUST be configured
13
 * using {@link #setFixedCoordinateReferenceSystem(CoordinateReferenceSystem, CrsRole)} to set the
14
 * fixed CRS (the one the user will not be able to change) and the role of this predefined CRS.
15
 * 
16
 * @author Cesar Martinez Izquierdo
17
 */
18
public interface CoordinateReferenceSystemAndTransformationSelectorComponent extends Component {
19
	/**
20
	 * Gets the internal CoordinateReferenceSystemSelectorComponent.
21
	 * 
22
	 * @return
23
	 */
24
	CoordinateReferenceSystemSelectorComponent getCoordinateReferenceSystemSelectorComponent();
25

  
26
	/**
27
	 * Returns the selected {@link CoordinateReferenceSystem}, which can be the source or
28
	 * the target CRS depending on the assigned {@link #getSelectedCrsRole() role}. 
29
	 * 
30
	 * @return the selected {@link CoordinateReferenceSystem}
31
	 */
32
	CoordinateReferenceSystem getCoordinateReferenceSystem();
33

  
34
	/**
35
	 * Returns the selected {@link CoordinateTransformation}.
36
	 * 
37
	 * @return the selected {@link CoordinateTransformation}
38
	 */
39
	CoordinateTransformation getCoordinateTransformation();
40
	
41
	/**
42
	 * Sets the selected {@link CoordinateReferenceSystem}, which can be the source or
43
	 * the target CRS depending on the assigned {@link #getSelectedCrsRole() role}. 
44
	 * 
45
	 * @return the selected {@link CoordinateReferenceSystem}
46
	 */
47
	void setSelectedCoordinateReferenceSystem(CoordinateReferenceSystem selectableCrs);
48
	
49
	/**
50
	 * Sets the fixed {@link CoordinateReferenceSystem}, which can be the source or
51
	 * the target CRS depending on the assigned {@link CrsRole role}
52
	 * 
53
	 * @param fixedCrs the CRS which is predefined, which the user will not be able to change
54
	 * @param role the {@link CrsRole role} of the fixed CRS
55
	 * 
56
	 * @return the selected {@link CoordinateReferenceSystem}
57
	 */
58
	void setFixedCoordinateReferenceSystem(CoordinateReferenceSystem fixedCrs, CrsRole role);
59
	
60
	/**
61
	 * Gets the role of the selected CRS
62
	 * 
63
	 * @see CrsRole
64
	 * @return
65
	 */
66
	CrsRole getSelectedCrsRole();
67
	
68
	/**
69
	 * Gets the role of the fixed CRS
70
	 * 
71
	 * @see CrsRole
72
	 * @return
73
	 */
74
	CrsRole getFixedCrsRole();
75

  
76
	/**
77
	 * Adds a listener to be notified when a CoordinateTransformation is selected
78
	 * 
79
	 * @param listener
80
	 */
81
	void addCoordinateTransformationSelectionListener(ActionListener listener);
82
	
83
    /**
84
     * Adds a listener to be notified when a CRS is selected
85
     * 
86
     * @param listener
87
     */
88
    void addCRSSelectionListener(ActionListener listener);
89

  
90
	/**
91
	 * Enables an alphanumeric filter to refine the list of CoordinateTransformations
92
	 * to those matching the provided search string.
93
	 * 
94
	 * @param searchString
95
	 */
96
	void enableTransformationAlphanumericFilter(String searchString);
97
	
98
	/**
99
	 * The role of the CRS selected by the user
100
	 */
101
	public enum CrsRole {
102
		/**
103
		 * The CRS selected by the user will be the source of the CoordinateTransformation
104
		 */
105
		SOURCE,
106
		/**
107
		 * The CRS selected by the user will be the target of the CoordinateTransformation
108
		 */
109
		TARGET
110
	}
111
}
org.gvsig.proj/branches/refactor2018/org.gvsig.proj/org.gvsig.proj.swing/org.gvsig.proj.swing.api/src/main/java/org/gvsig/proj/swing/CoordinateReferenceSystemSwingManager.java
25 25

  
26 26
import java.util.Set;
27 27

  
28
import javax.swing.JButton;
29
import javax.swing.JLabel;
30

  
28 31
import org.gvsig.proj.CoordinateReferenceSystemManager;
32
import org.gvsig.proj.CoordinateTransformation;
29 33
import org.gvsig.proj.catalog.CRSCatalogManager;
30 34
import org.gvsig.proj.catalog.CRSDefinition;
31 35
import org.gvsig.proj.catalog.TransformationDefinition;
......
48 52
     * @return a {@link CoordinateReferenceSystemSelectorComponent} to select a
49 53
     *         CoordinateReferenceSystem
50 54
     */
51
    CoordinateReferenceSystemSelectorComponent createCoordinateReferenceSystemSelectionComponent();
55
    CoordinateReferenceSystemSelectorComponent createCoordinateReferenceSystemSelectorComponent();
52 56

  
53 57
    /**
54 58
     * Returns the component to select a CoordinateTransformation.
......
56 60
     * @return a {@link CoordinateTransformationSelectorComponent} to select a
57 61
     *         CoordinateTransformation 
58 62
     */
59
    CoordinateTransformationSelectorComponent createCoordinateTransformSelectionComponent();
63
    CoordinateTransformationSelectorComponent createCoordinateTransformSelectorComponent();
60 64
    
61 65
    /**
66
     * Returns the component to select a CoordinateReferenceSystem and a CoordinateTransformation
67
     * from or to this CoordinateReferenceSystem.
68
     * 
69
     * @return a {@link CoordinateReferenceSystemAndTransformationSelectorComponent} to select a
70
     *         CoordinateReferenceSystem and a CoordinateTransformation
71
     */
72
    CoordinateReferenceSystemAndTransformationSelectorComponent createCoordinateReferenceSystemAndTransformationSelectorComponent();
73
    
74
    /**
62 75
     * Gets the list of recently used CoordinateReferenceSystems.
63 76
     * 
64 77
     * @return A <code>RecentHistory</code> object, which can be used to add new
......
152 165
     * documentation to see the expected structure of the DynObject.
153 166
     */
154 167
    public void setPreferences(DynObject preferences);
168

  
169
    /**
170
     * Creates a component to show and change a {@link CoordinateReferenceSystem} and a
171
	 * {@link CoordinateTransformation}. 
172
     * @return
173
     */
174
	CoordinateReferenceSystemAndTransformFieldComponent createCoordinateReferenceSystemAndTransformFieldComponent();
175

  
176
	/**
177
	 * Creates a controller to select a {@link CoordinateReferenceSystem} and a
178
	 * {@link CoordinateTransformation}, based on a custom component created by the
179
	 * user of this method.
180
	 *  
181
	 * @param lblCrsAndTransform The label to show the selected CRS and transformation
182
	 * @param btnSelectCrsAndTransform The button to change the CRS and transformation
183
	 * @return
184
	 */
185
	CoordinateReferenceSystemAndTransformFieldController createCoordinateReferenceSystemAndTransformField(
186
			JLabel lblCrsAndTransform, JButton btnSelectCrsAndTransform);
155 187
}
org.gvsig.proj/branches/refactor2018/org.gvsig.proj/org.gvsig.proj.swing/org.gvsig.proj.swing.impl/src/main/java/org/gvsig/proj/swing/impl/CrsSelectorController.java
390 390
	protected void treeSelectedValueChanged(TreeSelectionEvent e) {
391 391
		TreeNode selection = (TreeNode) this.treeResults.getLastSelectedPathComponent();
392 392
		if (selection==null) {
393
			return;
393
			selectedCrs = null;
394
			String currentCrsLabel = getI18nManager().getTranslation("Selected_CRS_parametrized", new String[]{""});
395
			this.lblCurrentCrs.setText(currentCrsLabel);
396
			this.txtDescription.setText("");
397
			this.txtCrsWkt.setText("");
398
			
394 399
		}
395
		if (selection instanceof CrsTreeNode) {
400
		else if (selection instanceof CrsTreeNode) {
396 401
			CRSDefinition def = ((CrsTreeNode)selection).getCRS();
397 402
			try {
398 403
				selectedCrs = manager.getCRSManager().getCoordinateReferenceSystem(def);
404
				String currentCrsLabel = getI18nManager().getTranslation("Selected_CRS_parametrized", new String[]{selectedCrs.getDefinition().toString()});	
405
				this.lblCurrentCrs.setText(currentCrsLabel);
399 406
				this.txtDescription.setText(def.getDescription());
407
				this.txtDescription.setCaretPosition(0);
400 408
				this.txtCrsWkt.setText(def.toWKT());
409
				this.txtCrsWkt.setCaretPosition(0);
401 410
				listenerSupport.fireActionEvent(new ActionEvent(selection, ActionEvent.ACTION_FIRST, CRS_SELECTED_ACTION_COMMAND));
402 411
			} catch (UnsupportedCoordinateReferenceSystemException | ParseException e1) {
403 412
				logger.debug("CRS not supported", e);
......
418 427
	@Override
419 428
	public void setCoordinateReferenceSystem(CoordinateReferenceSystem crs) {
420 429
		selectedCrs = crs;
421
		// add the provided node to recent nodes and select it
422
		CrsTreeNode node = new CrsTreeNode(crs.getDefinition(), recent);
423
		recent.add(node);
424
		model.reload(recent);
425
		this.treeResults.setSelectionPath(new TreePath(model.getPathToRoot(node)));
426
		
430
		if (crs != null) {
431
			// add the provided node to recent nodes and select it
432
			CrsTreeNode node = new CrsTreeNode(crs.getDefinition(), recent);
433
			recent.add(node);
434
			model.reload(recent);
435
			this.treeResults.setSelectionPath(new TreePath(model.getPathToRoot(node)));
436
		}
437
		else {
438
			this.treeResults.clearSelection();
439
		}
427 440
	}
428 441

  
429 442
	@Override
......
564 577
			}
565 578
			return this;
566 579
		}
567

  
568
		
569 580
	}
570 581
	
571 582
	public DefaultCoordinateReferenceSystemSwingManager getManager() {
......
582 593
				getI18nManager().getTranslation("Loading..."));
583 594
	}
584 595

  
585

  
586 596
	@Override
587 597
	public JTree getTree() {
588 598
		return this.treeResults;
589 599
	}
590 600

  
591

  
592 601
}
org.gvsig.proj/branches/refactor2018/org.gvsig.proj/org.gvsig.proj.swing/org.gvsig.proj.swing.impl/src/main/java/org/gvsig/proj/swing/impl/CrsAndCtSelectorView.java
1
package org.gvsig.proj.swing.impl;
2

  
3
import com.jeta.open.i18n.I18NUtils;
4
import com.jgoodies.forms.layout.CellConstraints;
5
import com.jgoodies.forms.layout.FormLayout;
6
import java.awt.BorderLayout;
7
import java.awt.ComponentOrientation;
8
import java.awt.Container;
9
import java.awt.Dimension;
10
import javax.swing.Box;
11
import javax.swing.ImageIcon;
12
import javax.swing.JFrame;
13
import javax.swing.JPanel;
14
import javax.swing.JTabbedPane;
15

  
16

  
17
public class CrsAndCtSelectorView extends JPanel
18
{
19
   JTabbedPane jtabbedpane1 = new JTabbedPane();
20
   JPanel pnlCrsSelectorContainer = new JPanel();
21
   JPanel pnlCtSelectorContainer = new JPanel();
22

  
23
   /**
24
    * Default constructor
25
    */
26
   public CrsAndCtSelectorView()
27
   {
28
      initializePanel();
29
   }
30

  
31
   /**
32
    * Adds fill components to empty cells in the first row and first column of the grid.
33
    * This ensures that the grid spacing will be the same as shown in the designer.
34
    * @param cols an array of column indices in the first row where fill components should be added.
35
    * @param rows an array of row indices in the first column where fill components should be added.
36
    */
37
   void addFillComponents( Container panel, int[] cols, int[] rows )
38
   {
39
      Dimension filler = new Dimension(10,10);
40

  
41
      boolean filled_cell_11 = false;
42
      CellConstraints cc = new CellConstraints();
43
      if ( cols.length > 0 && rows.length > 0 )
44
      {
45
         if ( cols[0] == 1 && rows[0] == 1 )
46
         {
47
            /** add a rigid area  */
48
            panel.add( Box.createRigidArea( filler ), cc.xy(1,1) );
49
            filled_cell_11 = true;
50
         }
51
      }
52

  
53
      for( int index = 0; index < cols.length; index++ )
54
      {
55
         if ( cols[index] == 1 && filled_cell_11 )
56
         {
57
            continue;
58
         }
59
         panel.add( Box.createRigidArea( filler ), cc.xy(cols[index],1) );
60
      }
61

  
62
      for( int index = 0; index < rows.length; index++ )
63
      {
64
         if ( rows[index] == 1 && filled_cell_11 )
65
         {
66
            continue;
67
         }
68
         panel.add( Box.createRigidArea( filler ), cc.xy(1,rows[index]) );
69
      }
70

  
71
   }
72

  
73
   /**
74
    * Helper method to load an image file from the CLASSPATH
75
    * @param imageName the package and name of the file to load relative to the CLASSPATH
76
    * @return an ImageIcon instance with the specified image file
77
    * @throws IllegalArgumentException if the image resource cannot be loaded.
78
    */
79
   public ImageIcon loadImage( String imageName )
80
   {
81
      try
82
      {
83
         ClassLoader classloader = getClass().getClassLoader();
84
         java.net.URL url = classloader.getResource( imageName );
85
         if ( url != null )
86
         {
87
            ImageIcon icon = new ImageIcon( url );
88
            return icon;
89
         }
90
      }
91
      catch( Exception e )
92
      {
93
         e.printStackTrace();
94
      }
95
      throw new IllegalArgumentException( "Unable to load image: " + imageName );
96
   }
97

  
98
   /**
99
    * Method for recalculating the component orientation for 
100
    * right-to-left Locales.
101
    * @param orientation the component orientation to be applied
102
    */
103
   public void applyComponentOrientation( ComponentOrientation orientation )
104
   {
105
      // Not yet implemented...
106
      // I18NUtils.applyComponentOrientation(this, orientation);
107
      super.applyComponentOrientation(orientation);
108
   }
109

  
110
   public JPanel createPanel()
111
   {
112
      JPanel jpanel1 = new JPanel();
113
      FormLayout formlayout1 = new FormLayout("FILL:DEFAULT:NONE,FILL:DEFAULT:GROW(1.0),FILL:DEFAULT:NONE,FILL:DEFAULT:NONE,FILL:DEFAULT:NONE,FILL:DEFAULT:NONE,FILL:DEFAULT:NONE,FILL:DEFAULT:NONE,FILL:DEFAULT:NONE,FILL:DEFAULT:NONE,FILL:DEFAULT:NONE,FILL:DEFAULT:NONE,FILL:DEFAULT:NONE,FILL:DEFAULT:NONE,FILL:DEFAULT:NONE,FILL:DEFAULT:NONE,FILL:DEFAULT:NONE,FILL:DEFAULT:NONE,FILL:DEFAULT:NONE,FILL:DEFAULT:NONE","CENTER:DEFAULT:NONE,FILL:DEFAULT:GROW(1.0),CENTER:DEFAULT:NONE,CENTER:DEFAULT:NONE,CENTER:DEFAULT:NONE,CENTER:DEFAULT:NONE,CENTER:DEFAULT:NONE,CENTER:DEFAULT:NONE,CENTER:DEFAULT:NONE,CENTER:DEFAULT:NONE,CENTER:DEFAULT:NONE,CENTER:DEFAULT:NONE,CENTER:DEFAULT:NONE,CENTER:DEFAULT:NONE,CENTER:DEFAULT:NONE,CENTER:DEFAULT:NONE,CENTER:DEFAULT:NONE,CENTER:DEFAULT:NONE,CENTER:DEFAULT:NONE,CENTER:DEFAULT:NONE");
114
      CellConstraints cc = new CellConstraints();
115
      jpanel1.setLayout(formlayout1);
116

  
117
      jtabbedpane1.addTab("Coordinate Reference System",null,createPanel1());
118
      jtabbedpane1.addTab("Coordinate Transformation",null,createPanel2());
119
      jpanel1.add(jtabbedpane1,cc.xy(2,2));
120

  
121
      addFillComponents(jpanel1,new int[]{ 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20 },new int[]{ 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20 });
122
      return jpanel1;
123
   }
124

  
125
   public JPanel createPanel1()
126
   {
127
      JPanel jpanel1 = new JPanel();
128
      FormLayout formlayout1 = new FormLayout("FILL:DEFAULT:NONE,FILL:DEFAULT:NONE,FILL:DEFAULT:NONE","CENTER:DEFAULT:NONE,CENTER:DEFAULT:NONE,CENTER:DEFAULT:NONE");
129
      CellConstraints cc = new CellConstraints();
130
      jpanel1.setLayout(formlayout1);
131

  
132
      pnlCrsSelectorContainer.setName("pnlCrsSelectorContainer");
133
      jpanel1.add(pnlCrsSelectorContainer,cc.xy(2,2));
134

  
135
      addFillComponents(jpanel1,new int[]{ 1,2,3 },new int[]{ 1,2,3 });
136
      return jpanel1;
137
   }
138

  
139
   public JPanel createPanel2()
140
   {
141
      JPanel jpanel1 = new JPanel();
142
      FormLayout formlayout1 = new FormLayout("FILL:DEFAULT:NONE,FILL:DEFAULT:NONE,FILL:DEFAULT:NONE","CENTER:DEFAULT:NONE,CENTER:DEFAULT:NONE,CENTER:DEFAULT:NONE");
143
      CellConstraints cc = new CellConstraints();
144
      jpanel1.setLayout(formlayout1);
145

  
146
      pnlCtSelectorContainer.setName("pnlCtSelectorContainer");
147
      jpanel1.add(pnlCtSelectorContainer,cc.xy(2,2));
148

  
149
      addFillComponents(jpanel1,new int[]{ 1,2,3 },new int[]{ 1,2,3 });
150
      return jpanel1;
151
   }
152

  
153
   /**
154
    * Initializer
155
    */
156
   protected void initializePanel()
157
   {
158
      setLayout(new BorderLayout());
159
      add(createPanel(), BorderLayout.CENTER);
160
   }
161

  
162

  
163
}
org.gvsig.proj/branches/refactor2018/org.gvsig.proj/org.gvsig.proj.swing/org.gvsig.proj.swing.impl/src/main/java/org/gvsig/proj/swing/impl/CtSelectorView.java
39 39
   JButton btnFavoritesRemove = new JButton();
40 40
   JButton btnCtAdd = new JButton();
41 41
   JButton btnRecentRemove = new JButton();
42
   JPanel pnlCrsSelectors = new JPanel();
42 43
   JLabel lblSourceCrs = new JLabel();
43 44
   JLabel lblTargetCrs = new JLabel();
44 45
   JTextField txtSourceCRS = new JTextField();
......
166 167

  
167 168
      jpanel1.add(createPanel3(),cc.xy(2,5));
168 169
      jpanel1.add(createPanel4(),cc.xy(2,9));
169
      jpanel1.add(createPanel5(),cc.xy(2,2));
170
      jpanel1.add(createpnlCrsSelectors(),cc.xy(2,2));
170 171
      addFillComponents(jpanel1,new int[]{ 1,2,3 },new int[]{ 1,2,3,4,5,6,7,8,9,10,11,12,13,14 });
171 172
      return jpanel1;
172 173
   }
......
284 285
      return jpanel1;
285 286
   }
286 287

  
287
   public JPanel createPanel5()
288
   public JPanel createpnlCrsSelectors()
288 289
   {
289
      JPanel jpanel1 = new JPanel();
290
      pnlCrsSelectors.setName("pnlCrsSelectors");
290 291
      FormLayout formlayout1 = new FormLayout("FILL:DEFAULT:NONE,FILL:4DLU:NONE,FILL:DEFAULT:GROW(1.0),FILL:4DLU:NONE,FILL:DEFAULT:NONE","CENTER:DEFAULT:NONE,CENTER:2DLU:NONE,CENTER:DEFAULT:NONE");
291 292
      CellConstraints cc = new CellConstraints();
292
      jpanel1.setLayout(formlayout1);
293
      pnlCrsSelectors.setLayout(formlayout1);
293 294

  
294 295
      lblSourceCrs.setName("lblSourceCrs");
295 296
      lblSourceCrs.setText("Source CRS");
296
      jpanel1.add(lblSourceCrs,cc.xy(1,1));
297
      pnlCrsSelectors.add(lblSourceCrs,cc.xy(1,1));
297 298

  
298 299
      lblTargetCrs.setName("lblTargetCrs");
299 300
      lblTargetCrs.setText("Target CRS");
300
      jpanel1.add(lblTargetCrs,cc.xy(1,3));
301
      pnlCrsSelectors.add(lblTargetCrs,cc.xy(1,3));
301 302

  
302 303
      txtSourceCRS.setBackground(new Color(236,233,216));
303 304
      txtSourceCRS.setEditable(false);
304 305
      txtSourceCRS.setName("txtSourceCRS");
305
      jpanel1.add(txtSourceCRS,cc.xy(3,1));
306
      pnlCrsSelectors.add(txtSourceCRS,cc.xy(3,1));
306 307

  
307 308
      btnSelectSoureCRS.setName("btnSelectSoureCRS");
308 309
      btnSelectSoureCRS.setToolTipText("Show selector to choose source CRS");
309 310
      EmptyBorder emptyborder1 = new EmptyBorder(2,2,2,2);
310 311
      btnSelectSoureCRS.setBorder(emptyborder1);
311
      jpanel1.add(btnSelectSoureCRS,cc.xy(5,1));
312
      pnlCrsSelectors.add(btnSelectSoureCRS,cc.xy(5,1));
312 313

  
313 314
      btnSelectTargetCRS.setName("btnSelectTargetCRS");
314 315
      btnSelectTargetCRS.setToolTipText("Show selector to choose target CRS");
315 316
      EmptyBorder emptyborder2 = new EmptyBorder(2,2,2,2);
316 317
      btnSelectTargetCRS.setBorder(emptyborder2);
317
      jpanel1.add(btnSelectTargetCRS,cc.xy(5,3));
318
      pnlCrsSelectors.add(btnSelectTargetCRS,cc.xy(5,3));
318 319

  
319 320
      txtTargetCRS.setBackground(new Color(236,233,216));
320 321
      txtTargetCRS.setEditable(false);
321 322
      txtTargetCRS.setName("txtTargetCRS");
322
      jpanel1.add(txtTargetCRS,cc.xy(3,3));
323
      pnlCrsSelectors.add(txtTargetCRS,cc.xy(3,3));
323 324

  
324
      addFillComponents(jpanel1,new int[]{ 2,4 },new int[]{ 2 });
325
      return jpanel1;
325
      addFillComponents(pnlCrsSelectors,new int[]{ 2,4 },new int[]{ 2 });
326
      return pnlCrsSelectors;
326 327
   }
327 328

  
328 329
   /**
org.gvsig.proj/branches/refactor2018/org.gvsig.proj/org.gvsig.proj.swing/org.gvsig.proj.swing.impl/src/main/java/org/gvsig/proj/swing/impl/CrsAndTransformFieldView.java
1
package org.gvsig.proj.swing.impl;
2

  
3
import com.jeta.open.i18n.I18NUtils;
4
import com.jgoodies.forms.layout.CellConstraints;
5
import com.jgoodies.forms.layout.FormLayout;
6
import java.awt.BorderLayout;
7
import java.awt.ComponentOrientation;
8
import java.awt.Container;
9
import java.awt.Dimension;
10
import javax.swing.Box;
11
import javax.swing.ImageIcon;
12
import javax.swing.JButton;
13
import javax.swing.JFrame;
14
import javax.swing.JLabel;
15
import javax.swing.JPanel;
16

  
17

  
18
public class CrsAndTransformFieldView extends JPanel
19
{
20
   JPanel crsField = new JPanel();
21
   JButton btnChangeCrs = new JButton();
22
   JLabel lblCrsAndTransform = new JLabel();
23

  
24
   /**
25
    * Default constructor
26
    */
27
   public CrsAndTransformFieldView()
28
   {
29
      initializePanel();
30
   }
31

  
32
   /**
33
    * Adds fill components to empty cells in the first row and first column of the grid.
34
    * This ensures that the grid spacing will be the same as shown in the designer.
35
    * @param cols an array of column indices in the first row where fill components should be added.
36
    * @param rows an array of row indices in the first column where fill components should be added.
37
    */
38
   void addFillComponents( Container panel, int[] cols, int[] rows )
39
   {
40
      Dimension filler = new Dimension(10,10);
41

  
42
      boolean filled_cell_11 = false;
43
      CellConstraints cc = new CellConstraints();
44
      if ( cols.length > 0 && rows.length > 0 )
45
      {
46
         if ( cols[0] == 1 && rows[0] == 1 )
47
         {
48
            /** add a rigid area  */
49
            panel.add( Box.createRigidArea( filler ), cc.xy(1,1) );
50
            filled_cell_11 = true;
51
         }
52
      }
53

  
54
      for( int index = 0; index < cols.length; index++ )
55
      {
56
         if ( cols[index] == 1 && filled_cell_11 )
57
         {
58
            continue;
59
         }
60
         panel.add( Box.createRigidArea( filler ), cc.xy(cols[index],1) );
61
      }
62

  
63
      for( int index = 0; index < rows.length; index++ )
64
      {
65
         if ( rows[index] == 1 && filled_cell_11 )
66
         {
67
            continue;
68
         }
69
         panel.add( Box.createRigidArea( filler ), cc.xy(1,rows[index]) );
70
      }
71

  
72
   }
73

  
74
   /**
75
    * Helper method to load an image file from the CLASSPATH
76
    * @param imageName the package and name of the file to load relative to the CLASSPATH
77
    * @return an ImageIcon instance with the specified image file
78
    * @throws IllegalArgumentException if the image resource cannot be loaded.
79
    */
80
   public ImageIcon loadImage( String imageName )
81
   {
82
      try
83
      {
84
         ClassLoader classloader = getClass().getClassLoader();
85
         java.net.URL url = classloader.getResource( imageName );
86
         if ( url != null )
87
         {
88
            ImageIcon icon = new ImageIcon( url );
89
            return icon;
90
         }
91
      }
92
      catch( Exception e )
93
      {
94
         e.printStackTrace();
95
      }
96
      throw new IllegalArgumentException( "Unable to load image: " + imageName );
97
   }
98

  
99
   /**
100
    * Method for recalculating the component orientation for 
101
    * right-to-left Locales.
102
    * @param orientation the component orientation to be applied
103
    */
104
   public void applyComponentOrientation( ComponentOrientation orientation )
105
   {
106
      // Not yet implemented...
107
      // I18NUtils.applyComponentOrientation(this, orientation);
108
      super.applyComponentOrientation(orientation);
109
   }
110

  
111
   public JPanel createcrsField()
112
   {
113
      crsField.setName("crsField");
114
      FormLayout formlayout1 = new FormLayout("FILL:4DLU:NONE,FILL:DEFAULT:GROW(1.0),FILL:4DLU:NONE,FILL:DEFAULT:NONE","CENTER:DEFAULT:NONE");
115
      CellConstraints cc = new CellConstraints();
116
      crsField.setLayout(formlayout1);
117

  
118
      btnChangeCrs.setActionCommand("Change");
119
      btnChangeCrs.setName("btnChangeCrs");
120
      btnChangeCrs.setText("Change");
121
      crsField.add(btnChangeCrs,cc.xy(4,1));
122

  
123
      lblCrsAndTransform.setName("lblCrsAndTransform");
124
      crsField.add(lblCrsAndTransform,cc.xy(2,1));
125

  
126
      addFillComponents(crsField,new int[]{ 1,3 },new int[]{ 1 });
127
      return crsField;
128
   }
129

  
130
   /**
131
    * Initializer
132
    */
133
   protected void initializePanel()
134
   {
135
      setLayout(new BorderLayout());
136
      add(createcrsField(), BorderLayout.CENTER);
137
   }
138

  
139

  
140
}
org.gvsig.proj/branches/refactor2018/org.gvsig.proj/org.gvsig.proj.swing/org.gvsig.proj.swing.impl/src/main/java/org/gvsig/proj/swing/impl/CrsAndCtSelectorController.java
1
package org.gvsig.proj.swing.impl;
2

  
3
import java.awt.BorderLayout;
4
import java.awt.event.ActionEvent;
5
import java.awt.event.ActionListener;
6

  
7
import javax.swing.JComponent;
8

  
9
import org.gvsig.proj.CoordinateReferenceSystem;
10
import org.gvsig.proj.CoordinateTransformation;
11
import org.gvsig.proj.swing.CoordinateReferenceSystemAndTransformationSelectorComponent;
12
import org.gvsig.proj.swing.CoordinateReferenceSystemSelectorComponent;
13

  
14
public class CrsAndCtSelectorController implements CoordinateReferenceSystemAndTransformationSelectorComponent {
15
	private CrsAndCtSelectorView view;
16
	private CrsSelectorController crsSelector;
17
	private CtSelectorController ctSelector;
18
	private DefaultCoordinateReferenceSystemSwingManager manager;
19
	private CrsRole selectedCrsRole = CrsRole.SOURCE;
20
	
21
	public CrsAndCtSelectorController(DefaultCoordinateReferenceSystemSwingManager manager) {
22
		this.view = new CrsAndCtSelectorView();
23
		this.manager = manager;
24
	}
25
	
26
	private void initComponents() {
27
		this.crsSelector = new CrsSelectorController(this.manager);
28
		this.view.jtabbedpane1.setEnabledAt(1, false);
29
		this.view.pnlCrsSelectorContainer.setLayout(new BorderLayout());
30
		this.view.pnlCrsSelectorContainer.add(this.crsSelector.asJComponent(), BorderLayout.CENTER);
31
		this.ctSelector = new CtSelectorController(this.manager);
32
		this.ctSelector.getView().pnlCrsSelectors.setVisible(false);
33
		this.view.pnlCtSelectorContainer.setLayout(new BorderLayout());
34
		this.view.pnlCtSelectorContainer.add(this.ctSelector.asJComponent(), BorderLayout.CENTER);
35
		this.crsSelector.addCRSSelectionListener(new ActionListener() {
36
			
37
			@Override
38
			public void actionPerformed(ActionEvent e) {
39
				// CtSelector tab should be enabled only if a Crs was selected by the user 
40
				CrsAndCtSelectorController.this.setCtTabEnabledStatus();
41
			}
42
		});
43
	}
44

  
45
	@Override
46
	public JComponent asJComponent() {
47
		return this.view;
48
	}
49

  
50
	@Override
51
	public CoordinateReferenceSystemSelectorComponent getCoordinateReferenceSystemSelectorComponent() {
52
		return this.crsSelector;
53
	}
54

  
55
	@Override
56
	public CoordinateReferenceSystem getCoordinateReferenceSystem() {
57
		return this.crsSelector.getCoordinateReferenceSystem();
58
	}
59

  
60
	@Override
61
	public CoordinateTransformation getCoordinateTransformation() {
62
		return this.ctSelector.getCoordinateTransformation();
63
	}
64

  
65
	@Override
66
	public void setSelectedCoordinateReferenceSystem(CoordinateReferenceSystem selectableCrs) {
67
		this.crsSelector.setCoordinateReferenceSystem(selectableCrs);
68
		if (this.selectedCrsRole.equals(CrsRole.SOURCE)) {
69
			this.ctSelector.setSourceCoordinateReferenceSystem(selectableCrs);
70
		}
71
		else {
72
			this.ctSelector.setTargetCoordinateReferenceSystem(selectableCrs);
73
		}
74
		setCtTabEnabledStatus();
75
	}
76

  
77
	@Override
78
	public void setFixedCoordinateReferenceSystem(CoordinateReferenceSystem fixedCrs, CrsRole role) {
79
		if (role.equals(CrsRole.SOURCE)) {
80
			this.ctSelector.setSourceCoordinateReferenceSystem(fixedCrs);
81
			this.selectedCrsRole = CrsRole.TARGET;
82
		}
83
		else {
84
			this.ctSelector.setTargetCoordinateReferenceSystem(fixedCrs);
85
			this.selectedCrsRole = CrsRole.SOURCE;
86
		}
87
		setCtTabEnabledStatus();
88
	}
89
	
90
	/**
91
	 * Enables the CtSelector tab when a source and target CRS are available and are different,
92
	 * and disables the tab otherwise
93
	 */
94
	protected void setCtTabEnabledStatus() {
95
		if (this.ctSelector.getSourceCoordinateReferenceSystem()!=null &&
96
				this.ctSelector.getTargetCoordinateReferenceSystem()!=null
97
				&& !(this.ctSelector.getSourceCoordinateReferenceSystem().equals(this.ctSelector.getTargetCoordinateReferenceSystem()))) {
98
			this.view.jtabbedpane1.setEnabledAt(1, true);	
99
		}
100
		else {
101
			this.view.jtabbedpane1.setEnabledAt(1, true);
102
		}
103
	}
104

  
105
	@Override
106
	public CrsRole getSelectedCrsRole() {
107
		return this.selectedCrsRole;
108
	}
109

  
110
	@Override
111
	public CrsRole getFixedCrsRole() {
112
		if (this.selectedCrsRole.equals(CrsRole.SOURCE)) {
113
			return CrsRole.TARGET;
114
		}
115
		else {
116
			return CrsRole.SOURCE;
117
		}
118
	}
119

  
120
	@Override
121
	public void addCoordinateTransformationSelectionListener(ActionListener listener) {
122
		this.ctSelector.addCoordinateTransformationSelectionListener(listener);
123
	}
124

  
125
	@Override
126
	public void addCRSSelectionListener(ActionListener listener) {
127
		this.crsSelector.addCRSSelectionListener(listener);
128
	}
129

  
130
	@Override
131
	public void enableTransformationAlphanumericFilter(String searchString) {
132
		this.ctSelector.enableAlphanumericFilter(searchString);
133
	}
134

  
135
}
org.gvsig.proj/branches/refactor2018/org.gvsig.proj/org.gvsig.proj.swing/org.gvsig.proj.swing.impl/src/main/java/org/gvsig/proj/swing/impl/CrsAndTransformFieldDirectController.java
1
package org.gvsig.proj.swing.impl;
2

  
3
import java.awt.event.ActionEvent;
4
import java.awt.event.ActionListener;
5

  
6
import javax.swing.JButton;
7
import javax.swing.JLabel;
8

  
9
import org.gvsig.proj.CoordinateReferenceSystem;
10
import org.gvsig.proj.CoordinateTransformation;
11
import org.gvsig.proj.swing.CoordinateReferenceSystemAndTransformFieldController;
12
import org.gvsig.proj.swing.CoordinateReferenceSystemAndTransformationSelectorComponent;
13
import org.gvsig.proj.swing.CoordinateReferenceSystemSwingLocator;
14
import org.gvsig.proj.swing.CoordinateReferenceSystemSwingManager;
15
import org.gvsig.tools.ToolsLocator;
16
import org.gvsig.tools.i18n.I18nManager;
17
import org.gvsig.tools.swing.api.ToolsSwingLocator;
18
import org.gvsig.tools.swing.api.windowmanager.Dialog;
19
import org.gvsig.tools.swing.api.windowmanager.WindowManager;
20
import org.gvsig.tools.swing.api.windowmanager.WindowManager_v2;
21

  
22
public class CrsAndTransformFieldDirectController implements CoordinateReferenceSystemAndTransformFieldController {
23
	private JLabel lblCrsAndTransform;
24
	private JButton btnSelectCrsAndTransform;
25
	protected CoordinateReferenceSystem crs;
26
	protected CoordinateTransformation ct;
27

  
28
	public CrsAndTransformFieldDirectController(JLabel lblCrsAndTransform, JButton btnSelectCrsAndTransform) {
29
		this.lblCrsAndTransform = lblCrsAndTransform;
30
		this.btnSelectCrsAndTransform  = btnSelectCrsAndTransform;
31
	}
32
	
33
	private void initComponents() {
34
		this.btnSelectCrsAndTransform.addActionListener(new ActionListener() {
35
			
36
			@Override
37
			public void actionPerformed(ActionEvent e) {
38
				WindowManager_v2 windowManager = (WindowManager_v2) ToolsSwingLocator.getWindowManager();
39
				CoordinateReferenceSystemSwingManager crsSwingManager = CoordinateReferenceSystemSwingLocator.getSwingManager();
40
				I18nManager i18nManager =  ToolsLocator.getI18nManager();
41
				CoordinateReferenceSystemAndTransformationSelectorComponent c = crsSwingManager.createCoordinateReferenceSystemAndTransformationSelectorComponent();
42
				Dialog d = windowManager.createDialog(c.asJComponent(),
43
						i18nManager.getTranslation("CRS and transformation selection"),
44
						i18nManager.getTranslation("CRS and transformation selection"),
45
						WindowManager_v2.BUTTONS_OK_CANCEL);
46
				d.show(WindowManager.MODE.DIALOG);
47

  
48
				if (d.getAction()==WindowManager_v2.BUTTON_OK) {
49
					setCrsAndCt(c.getCoordinateReferenceSystem(), 
50
							c.getCoordinateTransformation());
51
				}
52
			}
53
		});
54
	}
55
	
56
	protected void setCrsAndCt(CoordinateReferenceSystem crs, CoordinateTransformation ct) {
57
		this.crs = crs;
58
		this.ct = ct;
59
		updateLabel();
60
	}
61
	
62
	/* (non-Javadoc)
63
	 * @see org.gvsig.proj.swing.impl.CoordinateReferenceSystemAndTransformField#setCoordinateReferenceSystem(org.gvsig.proj.CoordinateReferenceSystem)
64
	 */
65
	@Override
66
	public void setCoordinateReferenceSystem(CoordinateReferenceSystem crs) {
67
		this.crs = crs;
68
		if (crs == null) {
69
			this.ct = null;
70
		}
71
		updateLabel();
72
	}
73
	
74
	private void updateLabel() {
75
		String crsName = (this.crs != null)?this.crs.getDefinition().getName():"";
76
		if (this.ct!=null) {
77
			this.lblCrsAndTransform.setText(crsName + " + "+this.ct.getDefinition().getName());	
78
		}
79
		else {
80
			this.lblCrsAndTransform.setText(crsName);
81
		}
82
	}
83
	
84
	/* (non-Javadoc)
85
	 * @see org.gvsig.proj.swing.impl.CoordinateReferenceSystemAndTransformField#getCoordinateReferenceSystem()
86
	 */
87
	@Override
88
	public CoordinateReferenceSystem getCoordinateReferenceSystem() {
89
		return this.crs;
90
	}
91
	
92
	/* (non-Javadoc)
93
	 * @see org.gvsig.proj.swing.impl.CoordinateReferenceSystemAndTransformField#setCoordinateTransformation(org.gvsig.proj.CoordinateTransformation)
94
	 */
95
	@Override
96
	public void setCoordinateTransformation(CoordinateTransformation ct) {
97
		this.ct = ct;
98
		updateLabel();
99
	}
100
	
101
	/* (non-Javadoc)
102
	 * @see org.gvsig.proj.swing.impl.CoordinateReferenceSystemAndTransformField#getCoordinateTransformation()
103
	 */
104
	@Override
105
	public CoordinateTransformation getCoordinateTransformation() {
106
		return this.ct;
107
	}
108
}
org.gvsig.proj/branches/refactor2018/org.gvsig.proj/org.gvsig.proj.swing/org.gvsig.proj.swing.impl/src/main/java/org/gvsig/proj/swing/impl/CtSelectorController.java
50 50
import org.slf4j.Logger;
51 51
import org.slf4j.LoggerFactory;
52 52

  
53
public class CtSelectorController extends CtSelectorView
53
public class CtSelectorController
54 54
	implements CoordinateTransformationSelectorComponent, 
55 55
												Component,
56 56
												TreeContainer {
57 57
	private static final long serialVersionUID = -5281166703625751190L;
58
	private CtSelectorView view;
58 59
	private CoordinateTransformation selectedCt = null;
59 60
	private ActionListenerSupport listenerSupport = ToolsSwingLocator.getToolsSwingManager().createActionListenerSupport();
60 61
	public static final String CT_SELECTED_ACTION_COMMAND = "CtSelected";
......
78 79
	public CtSelectorController(DefaultCoordinateReferenceSystemSwingManager manager) {
79 80
		super();
80 81
		this.manager = manager;
82
		this.view = new CtSelectorView();
81 83
		initIcons();
82 84
		initComponents();
83 85
		initTree();
......
86 88
		resetSearchCombo(null);
87 89
		initSearchActions();
88 90
	}
89
	
90
	@Override
91
	public ImageIcon loadImage( String imageName ) {
92
		return getIconTheme().get(FilenameUtils.getBaseName(imageName));
93
	}
94
	
91

  
95 92
	private IconTheme getIconTheme() {
96 93
		if (iconTheme == null) {
97 94
			iconTheme = ToolsSwingLocator.getIconThemeManager().getCurrent();
......
110 107
	protected void initComponents() {
111 108
		IconTheme theme = getIconTheme();
112 109

  
113
		this.btnSearch.setIcon(theme.get("crs-ctselector-search"));
114
		this.btnSearchRemove.setIcon(theme.get("crs-ctselector-search-remove"));
115
		this.lblFilterAlpha.setIcon(theme.get("crs-ctselector-text-filter"));
116
		this.btnCtAdd.setIcon(theme.get("crs-ctselector-ct-new"));
117
		this.btnRecentRemove.setIcon(theme.get("crs-ctselector-recent-remove"));
118
		this.btnFavoritesAdd.setIcon(theme.get("crs-ctselector-favorite-add"));
119
		this.btnFavoritesRemove.setIcon(theme.get("crs-ctselector-favorite-remove"));
120
		this.btnSelectSoureCRS.setIcon(getIconTheme().get("crs-ctselector-crs"));
121
		this.btnSelectTargetCRS.setIcon(getIconTheme().get("crs-ctselector-crs"));
110
		this.view.btnSearch.setIcon(theme.get("crs-ctselector-search"));
111
		this.view.btnSearchRemove.setIcon(theme.get("crs-ctselector-search-remove"));
112
		this.view.lblFilterAlpha.setIcon(theme.get("crs-ctselector-text-filter"));
113
		this.view.btnCtAdd.setIcon(theme.get("crs-ctselector-ct-new"));
114
		this.view.btnRecentRemove.setIcon(theme.get("crs-ctselector-recent-remove"));
115
		this.view.btnFavoritesAdd.setIcon(theme.get("crs-ctselector-favorite-add"));
116
		this.view.btnFavoritesRemove.setIcon(theme.get("crs-ctselector-favorite-remove"));
117
		this.view.btnSelectSoureCRS.setIcon(getIconTheme().get("crs-ctselector-crs"));
118
		this.view.btnSelectTargetCRS.setIcon(getIconTheme().get("crs-ctselector-crs"));
122 119
		
123 120
		ToolsSwingManager swingManager = ToolsSwingLocator.getToolsSwingManager();
124 121
		// hide recent remove since it is currently not supported
125
		this.btnRecentRemove.setVisible(false);
122
		this.view.btnRecentRemove.setVisible(false);
126 123

  
127
		swingManager.translate(this.btnSearch);
128
		swingManager.translate(this.btnSearchRemove);
129
		swingManager.translate(this.btnCtAdd);
130
		swingManager.translate(this.btnRecentRemove);
131
		swingManager.translate(this.btnFavoritesAdd);
132
		swingManager.translate(this.btnFavoritesRemove);		
133
		swingManager.translate(this.lblCurrentCt);
124
		swingManager.translate(this.view.btnSearch);
125
		swingManager.translate(this.view.btnSearchRemove);
126
		swingManager.translate(this.view.btnCtAdd);
127
		swingManager.translate(this.view.btnRecentRemove);
128
		swingManager.translate(this.view.btnFavoritesAdd);
129
		swingManager.translate(this.view.btnFavoritesRemove);		
130
		swingManager.translate(this.view.lblCurrentCt);
134 131
		
135
	    this.txtDescription.setEditable(false);
136
		this.txtDescription.setText("");
137
		this.txtDescription.setLineWrap(true);
138
		this.txtDescription.setWrapStyleWord(true);
139
		this.txtCtWkt.setEditable(false);
140
		this.txtCtWkt.setText("");
132
	    this.view.txtDescription.setEditable(false);
133
		this.view.txtDescription.setText("");
134
		this.view.txtDescription.setLineWrap(true);
135
		this.view.txtDescription.setWrapStyleWord(true);
136
		this.view.txtCtWkt.setEditable(false);
137
		this.view.txtCtWkt.setText("");
141 138
		
142 139
		/**
143 140
		 * TODO Update strings in CrsPanel and change the name of some components
144 141
		 *
145
		this.btnSearch.setToolTipText(manager.getTranslation("Search"));
146
	    this.btnSearchRemove.setToolTipText(manager.getTranslation("Clear search"));
147
	    this.btnFavoritesAdd.setToolTipText(manager.getTranslation("Add selected CRS to favorites"));
148
	    this.btnFavoritesAdd1.setToolTipText(manager.getTranslation("Remove selected CRS from favorites"));
149
	    this.btnCrsAdd.setToolTipText(manager.getTranslation("Create a new CRS"));
150
	    this.btnFavoritesAdd2.setToolTipText(manager.getTranslation("Remove selected CRS from recents"));
151
	    this.lbl_currentCrs.setText(manager.getTranslation("Current coordinate system:"));
152
	    this.jtxt_description.setEditable(false);
153
		this.jtxt_description.setText("");
154
		this.jtxt_description.setLineWrap(true);
155
		this.jtxt_description.setWrapStyleWord(true);
156
		this.txtCrsWkt.setEditable(false);
157
		this.txtCrsWkt.setText("");
142
		this.view.btnSearch.setToolTipText(manager.getTranslation("Search"));
143
	    this.view.btnSearchRemove.setToolTipText(manager.getTranslation("Clear search"));
144
	    this.view.btnFavoritesAdd.setToolTipText(manager.getTranslation("Add selected CRS to favorites"));
145
	    this.view.btnFavoritesAdd1.setToolTipText(manager.getTranslation("Remove selected CRS from favorites"));
146
	    this.view.btnCrsAdd.setToolTipText(manager.getTranslation("Create a new CRS"));
147
	    this.view.btnFavoritesAdd2.setToolTipText(manager.getTranslation("Remove selected CRS from recents"));
148
	    this.view.lbl_currentCrs.setText(manager.getTranslation("Current coordinate system:"));
149
	    this.view.jtxt_description.setEditable(false);
150
		this.view.jtxt_description.setText("");
151
		this.view.jtxt_description.setLineWrap(true);
152
		this.view.jtxt_description.setWrapStyleWord(true);
153
		this.view.txtCrsWkt.setEditable(false);
154
		this.view.txtCrsWkt.setText("");
158 155
		*/
159 156
		
160 157

  
......
162 159
	}
163 160

  
164 161
	protected void initActionListeners() {
165
		this.btnFavoritesAdd.addActionListener(new ActionListener() {
162
		this.view.btnFavoritesAdd.addActionListener(new ActionListener() {
166 163
			@Override
167 164
			public void actionPerformed(ActionEvent e) {
168 165
				CoordinateTransformation selectedCt = CtSelectorController.this.getCoordinateTransformation();
......
173 170
			}
174 171
		});
175 172
		
176
		this.btnFavoritesRemove.addActionListener(new ActionListener() {
173
		this.view.btnFavoritesRemove.addActionListener(new ActionListener() {
177 174
			@Override
178 175
			public void actionPerformed(ActionEvent e) {
179 176
				CoordinateTransformation selectedCt = CtSelectorController.this.getCoordinateTransformation();
......
184 181
			}
185 182
		});
186 183
		
187
		this.btnSelectSoureCRS.addActionListener(new ActionListener() {
184
		this.view.btnSelectSoureCRS.addActionListener(new ActionListener() {
188 185
			
189 186
			@Override
190 187
			public void actionPerformed(ActionEvent e) {
191 188
				WindowManager_v2 manager = (WindowManager_v2) ToolsSwingLocator.getWindowManager();
192
				CoordinateReferenceSystemSelectorComponent c = getManager().createCoordinateReferenceSystemSelectionComponent();
189
				CoordinateReferenceSystemSelectorComponent c = getManager().createCoordinateReferenceSystemSelectorComponent();
193 190
				Dialog d = manager.createDialog(c.asJComponent(),
194 191
						getI18nManager().getTranslation("Source CRS"),
195 192
						getI18nManager().getTranslation("Source CRS"),
......
201 198
				}
202 199
			}
203 200
		});
204
		this.btnSelectTargetCRS.addActionListener(new ActionListener() {
201
		this.view.btnSelectTargetCRS.addActionListener(new ActionListener() {
205 202
			
206 203
			@Override
207 204
			public void actionPerformed(ActionEvent e) {
208 205
				WindowManager_v2 manager = (WindowManager_v2) ToolsSwingLocator.getWindowManager();
209
				CoordinateReferenceSystemSelectorComponent c = getManager().createCoordinateReferenceSystemSelectionComponent();
206
				CoordinateReferenceSystemSelectorComponent c = getManager().createCoordinateReferenceSystemSelectorComponent();
210 207
				Dialog d = manager.createDialog(c.asJComponent(),
211 208
						getI18nManager().getTranslation("Target CRS"),
212 209
						getI18nManager().getTranslation("Target CRS"),
......
220 217
		});
221 218
		
222 219
		/*
223
		this.btnRecentCrsRemove.addActionListener(new ActionListener() {
220
		this.view.btnRecentCrsRemove.addActionListener(new ActionListener() {
224 221
			@Override
225 222
			public void actionPerformed(ActionEvent e) {
226 223
				CoordinateReferenceSystem selectedCrs = CrsSelectorController.this.getCoordinateReferenceSystem();
......
253 250
			if (node instanceof BranchNode) {
254 251
				TreeNode[] path = this.model.getPathToRoot(node);
255 252
				if (path != null) {
256
					this.treeResults.expandPath(new TreePath(path));
253
					this.view.treeResults.expandPath(new TreePath(path));
257 254
				}
258 255
				expandBranches(node);
259 256
			}
......
261 258
	}
262 259
	
263 260
	protected void resetSearchCombo(String selectedItem) {
264
		this.cboFilterAlpha.removeAllItems();
261
		this.view.cboFilterAlpha.removeAllItems();
265 262
		if ("".equals(selectedItem)) {
266
			this.cboFilterAlpha.insertItemAt(selectedItem, 0);
263
			this.view.cboFilterAlpha.insertItemAt(selectedItem, 0);
267 264
		}
268 265
		for (String filter: manager.getTransformationTextFilterHistory()) {
269
			this.cboFilterAlpha.addItem(filter);	
266
			this.view.cboFilterAlpha.addItem(filter);	
270 267
		}
271
		this.cboFilterAlpha.setSelectedItem(selectedItem);
268
		this.view.cboFilterAlpha.setSelectedItem(selectedItem);
272 269
	}
273 270
	
274 271
	protected void initSearchActions() {
275
		this.cboFilterAlpha.getActionMap().put("enterPressed", new Action() {
272
		this.view.cboFilterAlpha.getActionMap().put("enterPressed", new Action() {
276 273
			
277 274
			@Override
278 275
			public void actionPerformed(ActionEvent e) {
......
315 312
			}
316 313
		});
317 314
		
318
		this.btnSearch.addActionListener(new ActionListener() {
315
		this.view.btnSearch.addActionListener(new ActionListener() {
319 316
			
320 317
			@Override
321 318
			public void actionPerformed(ActionEvent e) {
......
324 321
			}
325 322
		});
326 323
		
327
		this.btnSearchRemove.addActionListener(new ActionListener() {
324
		this.view.btnSearchRemove.addActionListener(new ActionListener() {
328 325
			
329 326
			@Override
330 327
			public void actionPerformed(ActionEvent e) {
......
351 348
		root = new BranchNode(null, this, "root");
352 349
		model = new DefaultTreeModel(root, false);
353 350
		
354
		JTree tree = this.treeResults;
351
		JTree tree = this.view.treeResults;
355 352
		tree.getSelectionModel().setSelectionMode
356 353
        	(TreeSelectionModel.SINGLE_TREE_SELECTION);
357 354
		listenerSupport = ToolsSwingLocator.getToolsSwingManager().createActionListenerSupport();
......
380 377
	}
381 378

  
382 379
	protected void treeSelectedValueChanged(TreeSelectionEvent e) {
383
		TreeNode selection = (TreeNode) this.treeResults.getLastSelectedPathComponent();
380
		TreeNode selection = (TreeNode) this.view.treeResults.getLastSelectedPathComponent();
384 381
		if (selection==null) {
385
			return;
382
			String currentCrsLabel = getI18nManager().getTranslation("Selected_transformation_parametrized", new String[]{""});
383
			this.view.lblCurrentCt.setText(currentCrsLabel);
386 384
		}
387
		if (selection instanceof CtTreeNode) {
385
		else if (selection instanceof CtTreeNode) {
388 386
			TransformationDefinition def = ((CtTreeNode)selection).getCT();
389 387
			if (!compareSourceAndTarget(def)) {
390
				this.txtDescription.setText(getI18nManager().getTranslation("The selected transformation does not match the source and"
388
				this.view.txtDescription.setText(getI18nManager().getTranslation("The selected transformation does not match the source and"
391 389
						+ " target CRSs"));
392
				this.txtCtWkt.setText("");
390
				this.view.txtCtWkt.setText("");
391
				String currentCrsLabel = getI18nManager().getTranslation("Selected_transformation_parametrized", new String[]{""});
392
				this.view.lblCurrentCt.setText(currentCrsLabel);
393 393
				return;
394 394
			}
395 395
			try {
396 396
				selectedCt = manager.getCRSManager().getCoordinateTransformation(def);
397
				this.txtDescription.setText(def.getDescription());
398
				this.txtDescription.setCaretPosition(0);
399
				this.txtCtWkt.setText(def.toWKT());
400
				this.txtCtWkt.setCaretPosition(0);
397
				String currentCrsLabel = getI18nManager().getTranslation("Selected_transformation_parametrized", new String[]{selectedCt.getDefinition().toString()});
398
				this.view.lblCurrentCt.setText(currentCrsLabel);
399
				this.view.txtDescription.setText(def.getDescription());
400
				this.view.txtDescription.setCaretPosition(0);
401
				this.view.txtCtWkt.setText(def.toWKT());
402
				this.view.txtCtWkt.setCaretPosition(0);
401 403
				listenerSupport.fireActionEvent(new ActionEvent(selection, ActionEvent.ACTION_FIRST, CT_SELECTED_ACTION_COMMAND));
402 404
			} catch (UnsupportedTransformationException | ParseException e1) {
403 405
				logger.debug("Coordinate operation not supported", e);
......
407 409
	
408 410
	protected void clearSelection() {
409 411
		this.selectedCt = null;
410
		this.treeResults.clearSelection();
411
		this.txtDescription.setText("");
412
		this.txtCtWkt.setText("");
412
		this.view.treeResults.clearSelection();
413
		this.view.txtDescription.setText("");
414
		this.view.txtCtWkt.setText("");
413 415
	}
414 416
	
415 417
	/**
......
418 420
	 */
419 421
	protected boolean setSearchAvailability() {
420 422
		boolean enabled = (getSourceCoordinateReferenceSystem()!=null && getTargetCoordinateReferenceSystem()!=null);
421
		this.btnSearch.setEnabled(enabled);
422
		this.btnSearchRemove.setEnabled(enabled);
423
		this.treeResults.setEnabled(enabled);
423
		this.view.btnSearch.setEnabled(enabled);
424
		this.view.btnSearchRemove.setEnabled(enabled);
425
		this.view.treeResults.setEnabled(enabled);
424 426
		return enabled;
425 427
	}
426 428
	
......
432 434

  
433 435
	@Override
434 436
	public JComponent asJComponent() {
435
		return this;
437
		return this.view;
436 438
	}
437 439

  
438 440
	@Override
439 441
	public void enableAlphanumericFilter(String searchString) {
440
		cboFilterAlpha.addItem(searchString);
441
		cboFilterAlpha.setSelectedItem(searchString);
442
		this.view.cboFilterAlpha.addItem(searchString);
443
		this.view.cboFilterAlpha.setSelectedItem(searchString);
442 444
	}
443 445
	
444 446
	protected String getAlphanumericFilter() {
445
		return (String) cboFilterAlpha.getSelectedItem();
447
		return (String) this.view.cboFilterAlpha.getSelectedItem();
446 448
	}
447 449
	
448 450
	protected boolean compareSourceAndTarget(TransformationDefinition def) {
......
576 578

  
577 579
	@Override
578 580
	public JTree getTree() {
579
		return this.treeResults;
581
		return this.view.treeResults;
580 582
	}
581 583

  
582 584
	@Override
......
608 610
			CtTreeNode node = new CtTreeNode(transformation.getDefinition(), recent);
609 611
			recent.add(node);
610 612
			model.reload(recent);
611
			this.treeResults.setSelectionPath(new TreePath(model.getPathToRoot(node)));
613
			this.view.treeResults.setSelectionPath(new TreePath(model.getPathToRoot(node)));
612 614
		}
613 615
		else {
614
			this.treeResults.clearSelection();
616
			this.view.treeResults.clearSelection();
615 617
		}
616 618
		if (searchEnabled) {
617 619
			search();
618 620
		}
619
		this.treeResults.repaint();
621
		this.view.treeResults.repaint();
620 622
	}
621 623
	
622 624
	@Override
......
627 629
	@Override
628 630
	public void setSourceCoordinateReferenceSystem(CoordinateReferenceSystem source, boolean editable) {
629 631
		this.sourceCRS = source;
630
		this.btnSelectSoureCRS.setEnabled(editable);
631
		this.txtSourceCRS.setText(source.toString());
632
		this.view.btnSelectSoureCRS.setEnabled(editable);
633
		if (source!=null) {
634
			this.view.txtSourceCRS.setText(source.toString());
635
		}
636
		else {
637
			this.view.txtSourceCRS.setText("");
638
		}
632 639
		ensureCompatibleSelection();
633 640
		resetSearch();
634 641
	}
......
641 648
	@Override
642 649
	public void setTargetCoordinateReferenceSystem(CoordinateReferenceSystem target, boolean editable) {
643 650
		this.targetCRS = target;
644
		this.btnSelectTargetCRS.setEnabled(editable);
645
		this.txtTargetCRS.setText(target.toString());
651
		this.view.btnSelectTargetCRS.setEnabled(editable);
652
		if (target!=null) {
653
			this.view.txtTargetCRS.setText(target.toString());
654
		}
655
		else {
656
			this.view.txtTargetCRS.setText("");
657
		}
646 658
		ensureCompatibleSelection();
647 659
		resetSearch();
648 660
	}
......
658 670

  
659 671
	@Override
660 672
	public boolean isSourceCoordinateReferenceSystemEditable() {
661
		return this.btnSelectSoureCRS.isEnabled();
673
		return this.view.btnSelectSoureCRS.isEnabled();
662 674
	}
663 675

  
664 676
	@Override
665 677
	public boolean isTargetCoordinateReferenceSystemEditable() {
666
		return this.btnSelectTargetCRS.isEnabled();
678
		return this.view.btnSelectTargetCRS.isEnabled();
667 679
	}
668 680

  
669 681
	@Override
......
671 683
		listenerSupport.addActionListener(listener);
672 684
	}
673 685

  
686
	public CtSelectorView getView() {
687
		return this.view;
688
	}
674 689

  
675 690
}
org.gvsig.proj/branches/refactor2018/org.gvsig.proj/org.gvsig.proj.swing/org.gvsig.proj.swing.impl/src/main/java/org/gvsig/proj/swing/impl/CrsAndCtSelectorView.xml
1
<?xml version="1.0" encoding="UTF-8"?>
2

  
3
<object classname="com.jeta.forms.store.memento.FormPackage">
4
 <at name="fileversion">
5
  <object classname="com.jeta.forms.store.memento.FormsVersion2">
6
   <at name="major">2</at>
7
   <at name="minor">0</at>
8
   <at name="sub">0</at>
9
  </object>
10
 </at>
11
 <at name="form">
12
  <object classname="com.jeta.forms.store.memento.FormMemento">
13
   <super classname="com.jeta.forms.store.memento.ComponentMemento">
14
    <at name="cellconstraints">
15
     <object classname="com.jeta.forms.store.memento.CellConstraintsMemento">
16
      <at name="column">1</at>
17
      <at name="row">1</at>
18
      <at name="colspan">1</at>
19
      <at name="rowspan">1</at>
20
      <at name="halign">default</at>
21
      <at name="valign">default</at>
22
      <at name="insets" object="insets">0,0,0,0</at>
23
     </object>
24
    </at>
25
    <at name="componentclass">com.jeta.forms.gui.form.FormComponent</at>
26
   </super>
27
   <at name="id">/home/cesar/projects/gvSIG/workspaces/wslidar-trunk/org.gvsig.proj_refactor2018/org.gvsig.proj/org.gvsig.proj.swing/org.gvsig.proj.swing.impl/src/main/java/org/gvsig/proj/swing/impl/CrsAndCtSelectorView.xml</at>
28
   <at name="path">CrsAndCtSelectorView.xml</at>
29
   <at name="rowspecs">CENTER:DEFAULT:NONE,FILL:DEFAULT:GROW(1.0),CENTER:DEFAULT:NONE,CENTER:DEFAULT:NONE,CENTER:DEFAULT:NONE,CENTER:DEFAULT:NONE,CENTER:DEFAULT:NONE,CENTER:DEFAULT:NONE,CENTER:DEFAULT:NONE,CENTER:DEFAULT:NONE,CENTER:DEFAULT:NONE,CENTER:DEFAULT:NONE,CENTER:DEFAULT:NONE,CENTER:DEFAULT:NONE,CENTER:DEFAULT:NONE,CENTER:DEFAULT:NONE,CENTER:DEFAULT:NONE,CENTER:DEFAULT:NONE,CENTER:DEFAULT:NONE,CENTER:DEFAULT:NONE</at>
30
   <at name="colspecs">FILL:DEFAULT:NONE,FILL:DEFAULT:GROW(1.0),FILL:DEFAULT:NONE,FILL:DEFAULT:NONE,FILL:DEFAULT:NONE,FILL:DEFAULT:NONE,FILL:DEFAULT:NONE,FILL:DEFAULT:NONE,FILL:DEFAULT:NONE,FILL:DEFAULT:NONE,FILL:DEFAULT:NONE,FILL:DEFAULT:NONE,FILL:DEFAULT:NONE,FILL:DEFAULT:NONE,FILL:DEFAULT:NONE,FILL:DEFAULT:NONE,FILL:DEFAULT:NONE,FILL:DEFAULT:NONE,FILL:DEFAULT:NONE,FILL:DEFAULT:NONE</at>
31
   <at name="components">
32
    <object classname="java.util.LinkedList">
33
     <item >
34
      <at name="value">
35
       <object classname="com.jeta.forms.store.memento.BeanMemento">
36
        <super classname="com.jeta.forms.store.memento.ComponentMemento">
37
         <at name="cellconstraints">
38
          <object classname="com.jeta.forms.store.memento.CellConstraintsMemento">
39
           <at name="column">2</at>
40
           <at name="row">2</at>
41
           <at name="colspan">1</at>
42
           <at name="rowspan">1</at>
43
           <at name="halign">default</at>
44
           <at name="valign">default</at>
45
           <at name="insets" object="insets">0,0,0,0</at>
46
          </object>
47
         </at>
48
         <at name="componentclass">com.jeta.forms.gui.form.FormContainerComponent</at>
49
        </super>
50
        <at name="jetabeanclass">com.jeta.forms.gui.beans.JETABean</at>
51
        <at name="beanclass">javax.swing.JTabbedPane</at>
52
        <at name="beanproperties">
53
         <object classname="com.jeta.forms.store.memento.PropertiesMemento">
54
          <at name="classname">javax.swing.JTabbedPane</at>
55
          <at name="properties">
56
           <object classname="com.jeta.forms.store.support.PropertyMap">
57
            <at name="border">
58
             <object classname="com.jeta.forms.store.properties.CompoundBorderProperty">
59
              <super classname="com.jeta.forms.store.properties.BorderProperty">
60
               <at name="name">border</at>
61
              </super>
62
              <at name="borders">
63
               <object classname="java.util.LinkedList">
64
                <item >
65
                 <at name="value">
66
                  <object classname="com.jeta.forms.store.properties.DefaultBorderProperty">
67
                   <super classname="com.jeta.forms.store.properties.BorderProperty">
68
                    <at name="name">border</at>
69
                   </super>
70
                  </object>
71
                 </at>
72
                </item>
73
               </object>
74
              </at>
75
             </object>
76
            </at>
77
            <at name="componentCount">2</at>
78
            <at name="name"></at>
79
            <at name="tabs">
80
             <object classname="com.jeta.forms.store.properties.TabbedPaneProperties">
81
              <at name="name">tabs</at>
82
              <at name="items">
83
               <object classname="java.util.LinkedList">
84
                <item >
85
                 <at name="value">
86
                  <object classname="com.jeta.forms.store.properties.TabProperty">
87
                   <at name="name">tab</at>
88
                   <at name="title">Coordinate Reference System</at>
89
                   <at name="icon">
90
                    <object classname="com.jeta.forms.store.properties.IconProperty">
91
                     <at name="embedded">false</at>
92
                     <at name="description"></at>
93
                     <at name="width">0</at>
94
                     <at name="height">0</at>
95
                    </object>
96
                   </at>
97
                   <at name="form">
98
                    <object classname="com.jeta.forms.store.memento.FormMemento">
99
                     <super classname="com.jeta.forms.store.memento.ComponentMemento">
100
                      <at name="cellconstraints">
101
                       <object classname="com.jeta.forms.store.memento.CellConstraintsMemento">
102
                        <at name="column">1</at>
103
                        <at name="row">1</at>
104
                        <at name="colspan">1</at>
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff