Statistics
| Revision:

svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.library / org.gvsig.installer / org.gvsig.installer.swing / org.gvsig.installer.swing.impl / src / main / java / org / gvsig / installer / swing / impl / creation / panel / DefaultOutputPanelLayout.java @ 40868

History | View | Annotate | Download (7.58 KB)

1
package org.gvsig.installer.swing.impl.creation.panel;
2

    
3
import java.awt.BorderLayout;
4
import java.awt.ComponentOrientation;
5
import java.awt.Container;
6
import java.awt.Dimension;
7

    
8
import javax.swing.Box;
9
import javax.swing.ButtonGroup;
10
import javax.swing.ImageIcon;
11
import javax.swing.JButton;
12
import javax.swing.JCheckBox;
13
import javax.swing.JLabel;
14
import javax.swing.JPanel;
15
import javax.swing.JRadioButton;
16
import javax.swing.JTextField;
17

    
18
import com.jgoodies.forms.layout.CellConstraints;
19
import com.jgoodies.forms.layout.FormLayout;
20

    
21

    
22
public class DefaultOutputPanelLayout extends JPanel
23
{
24
   JLabel fileLabel = new JLabel();
25
   JTextField fileTextField = new JTextField();
26
   JButton fileBrowserButton = new JButton();
27
   JLabel createPackageIndexLabel = new JLabel();
28
   JCheckBox createPackageIndexCheckBox = new JCheckBox();
29
   JLabel indexFileLabel = new JLabel();
30
   JTextField indexFileTextField = new JTextField();
31
   JButton indexFileBrowserButton = new JButton();
32
   JLabel packageURLLabel = new JLabel();
33
   JRadioButton useAbsoluteURLRadioButton = new JRadioButton();
34
   ButtonGroup buttongroup1 = new ButtonGroup();
35
   JTextField packageURLTextField = new JTextField();
36
   JRadioButton usePoolURLRadioButton = new JRadioButton();
37
   JTextField packageURLPoolTextField = new JTextField();
38

    
39
   /**
40
    * Default constructor
41
    */
42
   public DefaultOutputPanelLayout()
43
   {
44
      initializePanel();
45
   }
46

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

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

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

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

    
87
   }
88

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

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

    
126
   public JPanel createPanel()
127
   {
128
      JPanel jpanel1 = new JPanel();
129
      FormLayout formlayout1 = new FormLayout("FILL:DEFAULT:NONE,FILL:DEFAULT:NONE,FILL:DEFAULT:NONE,FILL:DEFAULT:GROW(1.0),FILL:DEFAULT:NONE,FILL:DEFAULT:NONE,FILL:DEFAULT:NONE,FILL: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");
130
      CellConstraints cc = new CellConstraints();
131
      jpanel1.setLayout(formlayout1);
132

    
133
      fileLabel.setName("fileLabel");
134
      fileLabel.setText("Indique la ubicacion en la que se generara el paquete:");
135
      jpanel1.add(fileLabel,cc.xywh(2,2,5,1));
136

    
137
      fileTextField.setName("fileTextField");
138
      jpanel1.add(fileTextField,cc.xywh(2,3,4,1));
139

    
140
      fileBrowserButton.setActionCommand("Examinar...");
141
      fileBrowserButton.setName("fileBrowserButton");
142
      fileBrowserButton.setText("...");
143
      jpanel1.add(fileBrowserButton,cc.xy(6,3));
144

    
145
      createPackageIndexLabel.setName("createPackageIndexLabel");
146
      createPackageIndexLabel.setText("¿ Desea crear el indice para este paquete ?");
147
      jpanel1.add(createPackageIndexLabel,cc.xywh(2,5,5,1));
148

    
149
      createPackageIndexCheckBox.setActionCommand("Crear indice para el paquete");
150
      createPackageIndexCheckBox.setName("createPackageIndexCheckBox");
151
      createPackageIndexCheckBox.setText("Crear indice para el paquete");
152
      jpanel1.add(createPackageIndexCheckBox,cc.xywh(2,6,5,1));
153

    
154
      indexFileLabel.setName("indexFileLabel");
155
      indexFileLabel.setText("Indique la ubicacion en la que se generara el indice");
156
      jpanel1.add(indexFileLabel,cc.xywh(3,7,4,1));
157

    
158
      indexFileTextField.setName("indexFileTextField");
159
      jpanel1.add(indexFileTextField,cc.xywh(3,8,3,1));
160

    
161
      indexFileBrowserButton.setActionCommand("Examinar ...");
162
      indexFileBrowserButton.setName("indexFileBrowseerButton");
163
      indexFileBrowserButton.setText(" ...");
164
      jpanel1.add(indexFileBrowserButton,cc.xy(6,8));
165

    
166
      packageURLLabel.setName("packageURLLabel");
167
      packageURLLabel.setText("Para crear un indice debera indicar la url desde la que se podra descargar su paquete una vez generado.");
168
      jpanel1.add(packageURLLabel,cc.xywh(3,9,4,1));
169

    
170
      useAbsoluteURLRadioButton.setActionCommand("Indique una url absoluta a donde se encontrara el paquete:");
171
      useAbsoluteURLRadioButton.setName("useAbsoluteURLRadioButton");
172
      useAbsoluteURLRadioButton.setText("Indique una url absoluta a donde se encontrara el paquete:");
173
      buttongroup1.add(useAbsoluteURLRadioButton);
174
      jpanel1.add(useAbsoluteURLRadioButton,cc.xywh(3,10,4,1));
175

    
176
      packageURLTextField.setName("packageURLTextField");
177
      jpanel1.add(packageURLTextField,cc.xywh(4,11,3,1));
178

    
179
      usePoolURLRadioButton.setActionCommand("Indique la URL al pool desde el que se podra descargar su paquete (recomendado):");
180
      usePoolURLRadioButton.setName("usePoolURLRadioButton");
181
      usePoolURLRadioButton.setText("Indique la URL al pool desde el que se podra descargar su paquete (recomendado):");
182
      buttongroup1.add(usePoolURLRadioButton);
183
      jpanel1.add(usePoolURLRadioButton,cc.xywh(3,12,4,1));
184

    
185
      packageURLPoolTextField.setName("packageURLPoolTextField");
186
      jpanel1.add(packageURLPoolTextField,cc.xywh(4,13,3,1));
187

    
188
      addFillComponents(jpanel1,new int[]{ 1,2,3,4,5,6,7,8 },new int[]{ 1,2,3,4,5,6,7,8,9,10,11,12,13,14 });
189
      return jpanel1;
190
   }
191

    
192
   /**
193
    * Initializer
194
    */
195
   protected void initializePanel()
196
   {
197
      setLayout(new BorderLayout());
198
      add(createPanel(), BorderLayout.CENTER);
199
   }
200

    
201

    
202
}