Statistics
| Revision:

gvsig-projects-pool / org.gvsig.vcsgis / trunk / org.gvsig.vcsgis / org.gvsig.vcsgis.swing / org.gvsig.vcsgis.swing.impl / src / main / java / org / gvsig / vcsgis / swing / impl / checkoutDataModel / VCSGisJCheckoutDataModelView.java @ 8713

History | View | Annotate | Download (8.79 KB)

1
package org.gvsig.vcsgis.swing.impl.checkoutDataModel;
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.JCheckBox;
14
import javax.swing.JComboBox;
15
import javax.swing.JFrame;
16
import javax.swing.JLabel;
17
import javax.swing.JList;
18
import javax.swing.JPanel;
19
import javax.swing.JProgressBar;
20
import javax.swing.JScrollPane;
21
import javax.swing.JTextField;
22
import javax.swing.border.EmptyBorder;
23

    
24

    
25
public class VCSGisJCheckoutDataModelView extends JPanel
26
{
27
   JLabel lblWorkspace = new JLabel();
28
   JComboBox cboWorkspaces = new JComboBox();
29
   JButton btnInitWorkspace = new JButton();
30
   JList lstTables = new JList();
31
   JLabel lblDataModel = new JLabel();
32
   JComboBox cboDataModels = new JComboBox();
33
   JTextField txtFilter = new JTextField();
34
   JButton btnTable = new JButton();
35
   JLabel lblStatusTitle = new JLabel();
36
   JLabel lblStatusMessages = new JLabel();
37
   JProgressBar pbStatus = new JProgressBar();
38
   JButton btnCheckAllEntities = new JButton();
39
   JButton btnUnCheckAllEntities = new JButton();
40
   JCheckBox chkCloseWindowOnConnect = new JCheckBox();
41
   JButton btnReloadEntities = new JButton();
42

    
43
   /**
44
    * Default constructor
45
    */
46
   public VCSGisJCheckoutDataModelView()
47
   {
48
      initializePanel();
49
   }
50

    
51
   /**
52
    * Adds fill components to empty cells in the first row and first column of the grid.
53
    * This ensures that the grid spacing will be the same as shown in the designer.
54
    * @param cols an array of column indices in the first row where fill components should be added.
55
    * @param rows an array of row indices in the first column where fill components should be added.
56
    */
57
   void addFillComponents( Container panel, int[] cols, int[] rows )
58
   {
59
      Dimension filler = new Dimension(10,10);
60

    
61
      boolean filled_cell_11 = false;
62
      CellConstraints cc = new CellConstraints();
63
      if ( cols.length > 0 && rows.length > 0 )
64
      {
65
         if ( cols[0] == 1 && rows[0] == 1 )
66
         {
67
            /** add a rigid area  */
68
            panel.add( Box.createRigidArea( filler ), cc.xy(1,1) );
69
            filled_cell_11 = true;
70
         }
71
      }
72

    
73
      for( int index = 0; index < cols.length; index++ )
74
      {
75
         if ( cols[index] == 1 && filled_cell_11 )
76
         {
77
            continue;
78
         }
79
         panel.add( Box.createRigidArea( filler ), cc.xy(cols[index],1) );
80
      }
81

    
82
      for( int index = 0; index < rows.length; index++ )
83
      {
84
         if ( rows[index] == 1 && filled_cell_11 )
85
         {
86
            continue;
87
         }
88
         panel.add( Box.createRigidArea( filler ), cc.xy(1,rows[index]) );
89
      }
90

    
91
   }
92

    
93
   /**
94
    * Helper method to load an image file from the CLASSPATH
95
    * @param imageName the package and name of the file to load relative to the CLASSPATH
96
    * @return an ImageIcon instance with the specified image file
97
    * @throws IllegalArgumentException if the image resource cannot be loaded.
98
    */
99
   public ImageIcon loadImage( String imageName )
100
   {
101
      try
102
      {
103
         ClassLoader classloader = getClass().getClassLoader();
104
         java.net.URL url = classloader.getResource( imageName );
105
         if ( url != null )
106
         {
107
            ImageIcon icon = new ImageIcon( url );
108
            return icon;
109
         }
110
      }
111
      catch( Exception e )
112
      {
113
         e.printStackTrace();
114
      }
115
      throw new IllegalArgumentException( "Unable to load image: " + imageName );
116
   }
117

    
118
   /**
119
    * Method for recalculating the component orientation for 
120
    * right-to-left Locales.
121
    * @param orientation the component orientation to be applied
122
    */
123
   public void applyComponentOrientation( ComponentOrientation orientation )
124
   {
125
      // Not yet implemented...
126
      // I18NUtils.applyComponentOrientation(this, orientation);
127
      super.applyComponentOrientation(orientation);
128
   }
129

    
130
   public JPanel createPanel()
131
   {
132
      JPanel jpanel1 = new JPanel();
133
      FormLayout formlayout1 = new FormLayout("FILL:4DLU:NONE,FILL:DEFAULT:NONE,FILL:4DLU:NONE,FILL:DEFAULT:GROW(1.0),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,FILL:DEFAULT:GROW(1.0),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");
134
      CellConstraints cc = new CellConstraints();
135
      jpanel1.setLayout(formlayout1);
136

    
137
      lblWorkspace.setName("lblWorkspace");
138
      lblWorkspace.setText("_Workingcopy");
139
      jpanel1.add(lblWorkspace,cc.xy(2,2));
140

    
141
      cboWorkspaces.setName("cboWorkspaces");
142
      jpanel1.add(cboWorkspaces,cc.xy(4,2));
143

    
144
      btnInitWorkspace.setActionCommand("...");
145
      btnInitWorkspace.setName("btnInitWorkspace");
146
      btnInitWorkspace.setText("...");
147
      EmptyBorder emptyborder1 = new EmptyBorder(2,2,2,2);
148
      btnInitWorkspace.setBorder(emptyborder1);
149
      jpanel1.add(btnInitWorkspace,cc.xy(6,2));
150

    
151
      lstTables.setName("lstTables");
152
      JScrollPane jscrollpane1 = new JScrollPane();
153
      jscrollpane1.setViewportView(lstTables);
154
      jscrollpane1.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
155
      jscrollpane1.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
156
      jpanel1.add(jscrollpane1,cc.xywh(2,8,5,1));
157

    
158
      lblDataModel.setName("lblDataModel");
159
      lblDataModel.setText("_Data_models");
160
      jpanel1.add(lblDataModel,cc.xy(2,4));
161

    
162
      cboDataModels.setName("cboDataModels");
163
      jpanel1.add(cboDataModels,cc.xy(4,4));
164

    
165
      txtFilter.setName("txtFilter");
166
      jpanel1.add(txtFilter,cc.xywh(2,6,3,1));
167

    
168
      btnTable.setActionCommand("...");
169
      btnTable.setName("btnTable");
170
      btnTable.setText("...");
171
      EmptyBorder emptyborder2 = new EmptyBorder(2,2,2,2);
172
      btnTable.setBorder(emptyborder2);
173
      jpanel1.add(btnTable,cc.xy(6,6));
174

    
175
      lblStatusTitle.setName("lblStatusTitle");
176
      jpanel1.add(lblStatusTitle,cc.xywh(2,12,4,1));
177

    
178
      lblStatusMessages.setName("lblStatusMessages");
179
      jpanel1.add(lblStatusMessages,cc.xywh(2,16,4,1));
180

    
181
      pbStatus.setName("pbStatus");
182
      pbStatus.setValue(25);
183
      jpanel1.add(pbStatus,cc.xywh(2,14,4,1));
184

    
185
      jpanel1.add(createPanel1(),cc.xywh(2,10,5,1));
186
      btnReloadEntities.setActionCommand("...");
187
      btnReloadEntities.setEnabled(false);
188
      btnReloadEntities.setIcon(loadImage("common-refresh.png"));
189
      btnReloadEntities.setName("btnReloadEntities");
190
      btnReloadEntities.setToolTipText("_Refresh");
191
      EmptyBorder emptyborder3 = new EmptyBorder(2,2,2,2);
192
      btnReloadEntities.setBorder(emptyborder3);
193
      jpanel1.add(btnReloadEntities,cc.xy(6,4));
194

    
195
      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 });
196
      return jpanel1;
197
   }
198

    
199
   public JPanel createPanel1()
200
   {
201
      JPanel jpanel1 = new JPanel();
202
      FormLayout formlayout1 = new FormLayout("FILL:DEFAULT:NONE,FILL:DEFAULT:NONE,FILL:DEFAULT:GROW(1.0)","CENTER:DEFAULT:NONE");
203
      CellConstraints cc = new CellConstraints();
204
      jpanel1.setLayout(formlayout1);
205

    
206
      btnCheckAllEntities.setActionCommand("...");
207
      btnCheckAllEntities.setIcon(loadImage("src/main/resources/org/gvsig/vcsgis/swing/impl/images/common-check-on.png"));
208
      btnCheckAllEntities.setName("btnCheckAllEntities");
209
      btnCheckAllEntities.setToolTipText("_Select_all");
210
      EmptyBorder emptyborder1 = new EmptyBorder(1,1,1,1);
211
      btnCheckAllEntities.setBorder(emptyborder1);
212
      jpanel1.add(btnCheckAllEntities,cc.xy(1,1));
213

    
214
      btnUnCheckAllEntities.setActionCommand("...");
215
      btnUnCheckAllEntities.setIcon(loadImage("src/main/resources/org/gvsig/vcsgis/swing/impl/images/common-check-off.png"));
216
      btnUnCheckAllEntities.setName("btnUnCheckAllEntities");
217
      btnUnCheckAllEntities.setToolTipText("_Unselect_all");
218
      EmptyBorder emptyborder2 = new EmptyBorder(1,1,1,1);
219
      btnUnCheckAllEntities.setBorder(emptyborder2);
220
      jpanel1.add(btnUnCheckAllEntities,cc.xy(2,1));
221

    
222
      chkCloseWindowOnConnect.setActionCommand("_Close_window_on_connect");
223
      chkCloseWindowOnConnect.setName("chkCloseWindowOnConnect");
224
      chkCloseWindowOnConnect.setSelected(true);
225
      chkCloseWindowOnConnect.setText("_Close_window_on_connect");
226
      jpanel1.add(chkCloseWindowOnConnect,new CellConstraints(3,1,1,1,CellConstraints.RIGHT,CellConstraints.DEFAULT));
227

    
228
      addFillComponents(jpanel1,new int[0],new int[0]);
229
      return jpanel1;
230
   }
231

    
232
   /**
233
    * Initializer
234
    */
235
   protected void initializePanel()
236
   {
237
      setLayout(new BorderLayout());
238
      add(createPanel(), BorderLayout.CENTER);
239
   }
240

    
241

    
242
}