Statistics
| Revision:

gvsig-projects-pool / org.gvsig.online / trunk / org.gvsig.online / org.gvsig.online.app / org.gvsig.online.app.mainplugin / src / main / java / org / gvsig / online / app / mainplugin / preferencespages / OnlinePageView.java @ 9515

History | View | Annotate | Download (7.76 KB)

1
package org.gvsig.online.app.mainplugin.preferencespages;
2

    
3
import com.jeta.forms.components.separator.TitledSeparator;
4
import com.jeta.open.i18n.I18NUtils;
5
import com.jgoodies.forms.layout.CellConstraints;
6
import com.jgoodies.forms.layout.FormLayout;
7
import java.awt.BorderLayout;
8
import java.awt.ComponentOrientation;
9
import java.awt.Container;
10
import java.awt.Dimension;
11
import javax.swing.Box;
12
import javax.swing.ImageIcon;
13
import javax.swing.JCheckBox;
14
import javax.swing.JComboBox;
15
import javax.swing.JFrame;
16
import javax.swing.JLabel;
17
import javax.swing.JPanel;
18
import javax.swing.JTabbedPane;
19
import org.gvsig.andami.preferences.AbstractPreferencePage;
20

    
21

    
22
public abstract class OnlinePageView extends AbstractPreferencePage
23
{
24
   JTabbedPane tabPreferences = new JTabbedPane();
25
   JPanel tabPreferences1 = new JPanel();
26
   JCheckBox chkEmptyEffectiveDateAllowedInCommitPanel = new JCheckBox();
27
   JCheckBox chkCurrentDateAsEffectiveDateByDefaultInCommitPanel = new JCheckBox();
28
   TitledSeparator lblChangesPanel = new TitledSeparator();
29
   TitledSeparator lblAdvanced = new TitledSeparator();
30
   JLabel lblRepositoryEntityFeatureTypeEditorMode = new JLabel();
31
   JComboBox cboRepositoryEntityFeatureTypeEditorMode = new JComboBox();
32
   JPanel gridWorkspaces = new JPanel();
33

    
34
   /**
35
    * Default constructor
36
    */
37
   public OnlinePageView()
38
   {
39
      initializePanel();
40
   }
41

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

    
52
      boolean filled_cell_11 = false;
53
      CellConstraints cc = new CellConstraints();
54
      if ( cols.length > 0 && rows.length > 0 )
55
      {
56
         if ( cols[0] == 1 && rows[0] == 1 )
57
         {
58
            /** add a rigid area  */
59
            panel.add( Box.createRigidArea( filler ), cc.xy(1,1) );
60
            filled_cell_11 = true;
61
         }
62
      }
63

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

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

    
82
   }
83

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

    
109
   /**
110
    * Method for recalculating the component orientation for 
111
    * right-to-left Locales.
112
    * @param orientation the component orientation to be applied
113
    */
114
   public void applyComponentOrientation( ComponentOrientation orientation )
115
   {
116
      // Not yet implemented...
117
      // I18NUtils.applyComponentOrientation(this, orientation);
118
      super.applyComponentOrientation(orientation);
119
   }
120

    
121
   public JPanel createPanel()
122
   {
123
      JPanel jpanel1 = new JPanel();
124
      FormLayout formlayout1 = new FormLayout("FILL:4DLU:NONE,FILL:DEFAULT:GROW(1.0),FILL:4DLU:NONE","CENTER:2DLU:NONE,FILL:DEFAULT:GROW(1.0),CENTER:2DLU:NONE");
125
      CellConstraints cc = new CellConstraints();
126
      jpanel1.setLayout(formlayout1);
127

    
128
      tabPreferences.setName("tabPreferences");
129
      tabPreferences.addTab("_General",null,createtabPreferences());
130
      tabPreferences.addTab("_Working_copies",null,createPanel1());
131
      jpanel1.add(tabPreferences,cc.xy(2,2));
132

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

    
137
   public JPanel createtabPreferences()
138
   {
139
      tabPreferences1.setName("tabPreferences");
140
      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:NONE,CENTER:4DLU: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");
141
      CellConstraints cc = new CellConstraints();
142
      tabPreferences1.setLayout(formlayout1);
143

    
144
      chkEmptyEffectiveDateAllowedInCommitPanel.setActionCommand("_Use_of_empty_effective_date_is_allowed");
145
      chkEmptyEffectiveDateAllowedInCommitPanel.setName("chkEmptyEffectiveDateAllowedInCommitPanel");
146
      chkEmptyEffectiveDateAllowedInCommitPanel.setText("_Use_of_empty_effective_date_is_allowed");
147
      tabPreferences1.add(chkEmptyEffectiveDateAllowedInCommitPanel,cc.xy(2,4));
148

    
149
      chkCurrentDateAsEffectiveDateByDefaultInCommitPanel.setActionCommand("_Use_current_date_as_effective_date_by_default");
150
      chkCurrentDateAsEffectiveDateByDefaultInCommitPanel.setName("chkCurrentDateAsEffectiveDateByDefaultInCommitPanel");
151
      chkCurrentDateAsEffectiveDateByDefaultInCommitPanel.setText("_Use_current_date_as_effective_date_by_default");
152
      tabPreferences1.add(chkCurrentDateAsEffectiveDateByDefaultInCommitPanel,cc.xy(2,6));
153

    
154
      lblChangesPanel.setName("lblChangesPanel");
155
      lblChangesPanel.setText("_Changes_panel");
156
      tabPreferences1.add(lblChangesPanel,cc.xy(2,2));
157

    
158
      lblAdvanced.setName("lblAdvanced");
159
      lblAdvanced.setText("_Advanced");
160
      tabPreferences1.add(lblAdvanced,cc.xy(2,8));
161

    
162
      lblRepositoryEntityFeatureTypeEditorMode.setName("lblRepositoryEntityFeatureTypeEditorMode");
163
      lblRepositoryEntityFeatureTypeEditorMode.setText("_VCS_Repository_entity_feature_type_editor_mode");
164
      tabPreferences1.add(lblRepositoryEntityFeatureTypeEditorMode,cc.xy(2,10));
165

    
166
      cboRepositoryEntityFeatureTypeEditorMode.setName("cboRepositoryEntityFeatureTypeEditorMode");
167
      tabPreferences1.add(cboRepositoryEntityFeatureTypeEditorMode,cc.xy(2,12));
168

    
169
      addFillComponents(tabPreferences1,new int[]{ 1,2,3 },new int[]{ 1,2,3,4,5,6,7,8,9,10,11,12,13 });
170
      return tabPreferences1;
171
   }
172

    
173
   public JPanel createPanel1()
174
   {
175
      JPanel jpanel1 = new JPanel();
176
      FormLayout formlayout1 = new FormLayout("FILL:4DLU:NONE,FILL:DEFAULT:GROW(1.0),FILL:4DLU:NONE","CENTER:2DLU:NONE,FILL:DEFAULT:GROW(1.0),CENTER:2DLU:NONE");
177
      CellConstraints cc = new CellConstraints();
178
      jpanel1.setLayout(formlayout1);
179

    
180
      jpanel1.add(creategridWorkspaces(),cc.xy(2,2));
181
      addFillComponents(jpanel1,new int[]{ 1,2,3 },new int[]{ 1,2,3 });
182
      return jpanel1;
183
   }
184

    
185
   public JPanel creategridWorkspaces()
186
   {
187
      gridWorkspaces.setName("gridWorkspaces");
188
      FormLayout formlayout1 = new FormLayout("FILL:DEFAULT:GROW(1.0)","FILL:DEFAULT:GROW(1.0)");
189
      CellConstraints cc = new CellConstraints();
190
      gridWorkspaces.setLayout(formlayout1);
191

    
192
      addFillComponents(gridWorkspaces,new int[]{ 1 },new int[]{ 1 });
193
      return gridWorkspaces;
194
   }
195

    
196
   /**
197
    * Initializer
198
    */
199
   protected void initializePanel()
200
   {
201
      setLayout(new BorderLayout());
202
      add(createPanel(), BorderLayout.CENTER);
203
   }
204

    
205

    
206
}