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 @ 3457

History | View | Annotate | Download (8.52 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.ButtonGroup;
12
import javax.swing.ImageIcon;
13
import javax.swing.JButton;
14
import javax.swing.JCheckBox;
15
import javax.swing.JComboBox;
16
import javax.swing.JFrame;
17
import javax.swing.JLabel;
18
import javax.swing.JList;
19
import javax.swing.JPanel;
20
import javax.swing.JProgressBar;
21
import javax.swing.JRadioButton;
22
import javax.swing.JScrollPane;
23
import javax.swing.JTextField;
24
import javax.swing.border.EmptyBorder;
25

    
26

    
27
public class VCSGisJCheckoutDataModelView extends JPanel
28
{
29
   JLabel lblWorkspace = new JLabel();
30
   JComboBox cboWorkspaces = new JComboBox();
31
   JButton btnInitWorkspace = new JButton();
32
   JList lstTables = new JList();
33
   JCheckBox chkOverwriteExistingTables = new JCheckBox();
34
   JLabel lblDataModel = new JLabel();
35
   JComboBox cboDataModels = new JComboBox();
36
   JTextField txtFilter = new JTextField();
37
   JButton btnTable = new JButton();
38
   JLabel lblStatusTitle = new JLabel();
39
   JLabel lblStatusMessages = new JLabel();
40
   JProgressBar pbStatus = new JProgressBar();
41
   JRadioButton rdbDontAddToProject = new JRadioButton();
42
   ButtonGroup buttongroup2 = new ButtonGroup();
43
   JRadioButton rdbAddLayerToView = new JRadioButton();
44
   JComboBox cboView = new JComboBox();
45
   JRadioButton rdbAddTableToProject = new JRadioButton();
46

    
47
   /**
48
    * Default constructor
49
    */
50
   public VCSGisJCheckoutDataModelView()
51
   {
52
      initializePanel();
53
   }
54

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

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

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

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

    
95
   }
96

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

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

    
134
   public JPanel createPanel()
135
   {
136
      JPanel jpanel1 = new JPanel();
137
      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,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,CENTER:2DLU:NONE");
138
      CellConstraints cc = new CellConstraints();
139
      jpanel1.setLayout(formlayout1);
140

    
141
      lblWorkspace.setName("lblWorkspace");
142
      lblWorkspace.setText("_Workspace");
143
      jpanel1.add(lblWorkspace,cc.xy(2,2));
144

    
145
      cboWorkspaces.setName("cboWorkspaces");
146
      jpanel1.add(cboWorkspaces,cc.xy(4,2));
147

    
148
      btnInitWorkspace.setActionCommand("...");
149
      btnInitWorkspace.setName("btnInitWorkspace");
150
      btnInitWorkspace.setOpaque(false);
151
      btnInitWorkspace.setText("...");
152
      EmptyBorder emptyborder1 = new EmptyBorder(2,2,2,2);
153
      btnInitWorkspace.setBorder(emptyborder1);
154
      jpanel1.add(btnInitWorkspace,cc.xy(6,2));
155

    
156
      lstTables.setName("lstTables");
157
      JScrollPane jscrollpane1 = new JScrollPane();
158
      jscrollpane1.setViewportView(lstTables);
159
      jscrollpane1.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
160
      jscrollpane1.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
161
      jpanel1.add(jscrollpane1,cc.xywh(2,8,5,1));
162

    
163
      chkOverwriteExistingTables.setActionCommand("_Overwrite_table");
164
      chkOverwriteExistingTables.setEnabled(false);
165
      chkOverwriteExistingTables.setName("chkOverwriteExistingTables");
166
      chkOverwriteExistingTables.setText("_Overwrite_existing_tables");
167
      chkOverwriteExistingTables.setToolTipText("_Delete_existing_tables_in_workspace_and_then_checkout_them_from_repository");
168
      jpanel1.add(chkOverwriteExistingTables,cc.xywh(2,10,5,1));
169

    
170
      lblDataModel.setName("lblDataModel");
171
      lblDataModel.setText("_Data_models");
172
      jpanel1.add(lblDataModel,cc.xy(2,4));
173

    
174
      cboDataModels.setName("cboDataModels");
175
      jpanel1.add(cboDataModels,cc.xywh(4,4,3,1));
176

    
177
      txtFilter.setName("txtFilter");
178
      jpanel1.add(txtFilter,cc.xywh(2,6,3,1));
179

    
180
      btnTable.setActionCommand("...");
181
      btnTable.setName("btnTable");
182
      btnTable.setOpaque(false);
183
      btnTable.setText("...");
184
      EmptyBorder emptyborder2 = new EmptyBorder(2,2,2,2);
185
      btnTable.setBorder(emptyborder2);
186
      jpanel1.add(btnTable,cc.xy(6,6));
187

    
188
      lblStatusTitle.setName("lblStatusTitle");
189
      jpanel1.add(lblStatusTitle,cc.xywh(2,20,4,1));
190

    
191
      lblStatusMessages.setName("lblStatusMessages");
192
      jpanel1.add(lblStatusMessages,cc.xywh(2,24,4,1));
193

    
194
      pbStatus.setName("pbStatus");
195
      pbStatus.setValue(25);
196
      jpanel1.add(pbStatus,cc.xywh(2,22,4,1));
197

    
198
      rdbDontAddToProject.setActionCommand("_Dont_add_the_table_or_layer_to_the_project");
199
      rdbDontAddToProject.setName("rdbDontAddToProject");
200
      rdbDontAddToProject.setText("_Dont_add_the_table_or_layer_to_the_project");
201
      buttongroup2.add(rdbDontAddToProject);
202
      jpanel1.add(rdbDontAddToProject,cc.xywh(2,12,5,1));
203

    
204
      rdbAddLayerToView.setActionCommand("_Add_layer_to_view");
205
      rdbAddLayerToView.setName("rdbAddLayerToView");
206
      rdbAddLayerToView.setText("_Add_layer_to_view");
207
      buttongroup2.add(rdbAddLayerToView);
208
      jpanel1.add(rdbAddLayerToView,cc.xywh(2,14,5,1));
209

    
210
      cboView.setName("cboView");
211
      jpanel1.add(cboView,cc.xywh(4,16,3,1));
212

    
213
      rdbAddTableToProject.setActionCommand("_Add_table_to_project");
214
      rdbAddTableToProject.setName("rdbAddTableToProject");
215
      rdbAddTableToProject.setText("_Add_table_to_project");
216
      buttongroup2.add(rdbAddTableToProject);
217
      jpanel1.add(rdbAddTableToProject,cc.xywh(2,18,5,1));
218

    
219
      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,20,21,22,23,24,25 });
220
      return jpanel1;
221
   }
222

    
223
   /**
224
    * Initializer
225
    */
226
   protected void initializePanel()
227
   {
228
      setLayout(new BorderLayout());
229
      add(createPanel(), BorderLayout.CENTER);
230
   }
231

    
232

    
233
}