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

History | View | Annotate | Download (7.81 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 org.gvsig.installer.swing.api.SwingInstallerLocator;
19
import org.gvsig.installer.swing.api.SwingInstallerManager;
20

    
21
import com.jgoodies.forms.layout.CellConstraints;
22
import com.jgoodies.forms.layout.FormLayout;
23

    
24

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

    
43
   /**
44
    * Default constructor
45
    */
46
   public DefaultOutputPanelLayout()
47
   {
48
          swingInstallerManager = SwingInstallerLocator.getSwingInstallerManager();
49
      initializePanel();
50
   }
51

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

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

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

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

    
92
   }
93

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

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

    
131
   public JPanel createPanel()
132
   {
133
      JPanel jpanel1 = new JPanel();
134
      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");
135
      CellConstraints cc = new CellConstraints();
136
      jpanel1.setLayout(formlayout1);
137

    
138
      fileLabel.setName("fileLabel");
139
      fileLabel.setText(swingInstallerManager.getText("select_package_location")+":");
140
      jpanel1.add(fileLabel,cc.xywh(2,2,5,1));
141

    
142
      fileTextField.setName("fileTextField");
143
      jpanel1.add(fileTextField,cc.xywh(2,3,4,1));
144

    
145
      fileBrowserButton.setActionCommand("Examinar...");
146
      fileBrowserButton.setName("fileBrowserButton");
147
      fileBrowserButton.setText("...");
148
      jpanel1.add(fileBrowserButton,cc.xy(6,3));
149

    
150
      createPackageIndexLabel.setName("createPackageIndexLabel");
151
      createPackageIndexLabel.setText(swingInstallerManager.getText("create_package_index"));
152
      jpanel1.add(createPackageIndexLabel,cc.xywh(2,5,5,1));
153

    
154
      createPackageIndexCheckBox.setActionCommand("Crear indice para el paquete");
155
      createPackageIndexCheckBox.setName("createPackageIndexCheckBox");
156
      createPackageIndexCheckBox.setText(swingInstallerManager.getText("create_index_for_package"));
157
      jpanel1.add(createPackageIndexCheckBox,cc.xywh(2,6,5,1));
158

    
159
      indexFileLabel.setName("indexFileLabel");
160
      indexFileLabel.setText(swingInstallerManager.getText("select_package_index_location"));
161
      jpanel1.add(indexFileLabel,cc.xywh(3,7,4,1));
162

    
163
      indexFileTextField.setName("indexFileTextField");
164
      jpanel1.add(indexFileTextField,cc.xywh(3,8,3,1));
165

    
166
      indexFileBrowserButton.setActionCommand("Examinar ...");
167
      indexFileBrowserButton.setName("indexFileBrowseerButton");
168
      indexFileBrowserButton.setText(" ...");
169
      jpanel1.add(indexFileBrowserButton,cc.xy(6,8));
170

    
171
      packageURLLabel.setName("packageURLLabel");
172
      packageURLLabel.setText(swingInstallerManager.getText("destination_package_url"));
173
      jpanel1.add(packageURLLabel,cc.xywh(3,9,4,1));
174

    
175
      useAbsoluteURLRadioButton.setActionCommand("Indique una url absoluta a donde se encontrara el paquete:");
176
      useAbsoluteURLRadioButton.setName("useAbsoluteURLRadioButton");
177
      useAbsoluteURLRadioButton.setText(swingInstallerManager.getText("absolute_url_package_location")+":");
178
      buttongroup1.add(useAbsoluteURLRadioButton);
179
      jpanel1.add(useAbsoluteURLRadioButton,cc.xywh(3,10,4,1));
180

    
181
      packageURLTextField.setName("packageURLTextField");
182
      jpanel1.add(packageURLTextField,cc.xywh(4,11,3,1));
183

    
184
      usePoolURLRadioButton.setActionCommand("Indique la URL al pool desde el que se podra descargar su paquete (recomendado):");
185
      usePoolURLRadioButton.setName("usePoolURLRadioButton");
186
      usePoolURLRadioButton.setText(swingInstallerManager.getText("pool_url_package_location")+":");
187
      buttongroup1.add(usePoolURLRadioButton);
188
      jpanel1.add(usePoolURLRadioButton,cc.xywh(3,12,4,1));
189

    
190
      packageURLPoolTextField.setName("packageURLPoolTextField");
191
      jpanel1.add(packageURLPoolTextField,cc.xywh(4,13,3,1));
192

    
193
      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 });
194
      return jpanel1;
195
   }
196

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

    
206

    
207
}