Statistics
| Revision:

svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.library / org.gvsig.fmap.control / src / main / java / org / gvsig / fmap / mapcontrol / tools / PointSelectionListenerUniqueSelect.java @ 45947

History | View | Annotate | Download (5.49 KB)

1
package org.gvsig.fmap.mapcontrol.tools;
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.JList;
15
import javax.swing.JPanel;
16
import javax.swing.JScrollPane;
17
import javax.swing.JTable;
18

    
19

    
20
public class PointSelectionListenerUniqueSelect extends JPanel
21
{
22
   JTable tblSelection = new JTable();
23
   JList lstLayers = new JList();
24
   JButton btnPrevious = new JButton();
25
   JButton btnNext = new JButton();
26

    
27
   /**
28
    * Default constructor
29
    */
30
   public PointSelectionListenerUniqueSelect()
31
   {
32
      initializePanel();
33
   }
34

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

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

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

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

    
75
   }
76

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

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

    
114
   public JPanel createPanel()
115
   {
116
      JPanel jpanel1 = new JPanel();
117
      FormLayout formlayout1 = new FormLayout("FILL:5PX:NONE,FILL:MAX(200DLU;DEFAULT):NONE,FILL:4DLU:NONE,FILL:DEFAULT:GROW(1.0),FILL:4PX:NONE","CENTER:4PX:NONE,FILL:133PX:GROW(1.0),CENTER:2DLU:NONE,CENTER:DEFAULT:NONE,CENTER:5PX:NONE");
118
      CellConstraints cc = new CellConstraints();
119
      jpanel1.setLayout(formlayout1);
120

    
121
      tblSelection.setName("tblSelection");
122
      JScrollPane jscrollpane1 = new JScrollPane();
123
      jscrollpane1.setViewportView(tblSelection);
124
      jscrollpane1.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
125
      jscrollpane1.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
126
      jpanel1.add(jscrollpane1,cc.xy(4,2));
127

    
128
      lstLayers.setName("lstLayers");
129
      JScrollPane jscrollpane2 = new JScrollPane();
130
      jscrollpane2.setViewportView(lstLayers);
131
      jscrollpane2.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
132
      jscrollpane2.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
133
      jpanel1.add(jscrollpane2,cc.xy(2,2));
134

    
135
      jpanel1.add(createPanel1(),cc.xywh(2,4,3,1));
136
      addFillComponents(jpanel1,new int[]{ 1,2,3,4,5 },new int[]{ 1,2,3,4,5 });
137
      return jpanel1;
138
   }
139

    
140
   public JPanel createPanel1()
141
   {
142
      JPanel jpanel1 = new JPanel();
143
      FormLayout formlayout1 = new FormLayout("FILL:DEFAULT:GROW(1.0),FILL:DEFAULT:NONE,FILL:4DLU:NONE,FILL:DEFAULT:NONE","CENTER:DEFAULT:NONE");
144
      CellConstraints cc = new CellConstraints();
145
      jpanel1.setLayout(formlayout1);
146

    
147
      btnPrevious.setActionCommand("_Previous");
148
      btnPrevious.setName("btnPrevious");
149
      btnPrevious.setText("_Previous");
150
      jpanel1.add(btnPrevious,cc.xy(2,1));
151

    
152
      btnNext.setActionCommand("_Next");
153
      btnNext.setName("btnNext");
154
      btnNext.setText("_Next");
155
      jpanel1.add(btnNext,cc.xy(4,1));
156

    
157
      addFillComponents(jpanel1,new int[]{ 1,3 },new int[]{ 1 });
158
      return jpanel1;
159
   }
160

    
161
   /**
162
    * Initializer
163
    */
164
   protected void initializePanel()
165
   {
166
      setLayout(new BorderLayout());
167
      add(createPanel(), BorderLayout.CENTER);
168
   }
169

    
170

    
171
}