Statistics
| Revision:

svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.plugin / org.gvsig.app / org.gvsig.app.mainplugin / src / main / java / org / gvsig / app / project / documents / gui / projectpanel / ProjectDocumentsPanelPageView.java @ 43913

History | View | Annotate | Download (9.53 KB)

1
package org.gvsig.app.project.documents.gui.projectpanel;
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.Color;
9
import java.awt.ComponentOrientation;
10
import java.awt.Container;
11
import java.awt.Dimension;
12
import javax.swing.Box;
13
import javax.swing.ImageIcon;
14
import javax.swing.JButton;
15
import javax.swing.JFrame;
16
import javax.swing.JLabel;
17
import javax.swing.JList;
18
import javax.swing.JPanel;
19
import javax.swing.JScrollPane;
20
import javax.swing.JTextField;
21

    
22

    
23
public class ProjectDocumentsPanelPageView extends JPanel
24
{
25
   TitledSeparator lblDocumentTypes = new TitledSeparator();
26
   TitledSeparator lblDocument = new TitledSeparator();
27
   TitledSeparator lblSessionProperties = new TitledSeparator();
28
   JList lstDocuments = new JList();
29
   JButton btnDocumentNew = new JButton();
30
   JButton btnDocumentOpen = new JButton();
31
   JButton btnDocumentRename = new JButton();
32
   JButton btnDocumentDelete = new JButton();
33
   JButton btnDocumentProperties = new JButton();
34
   JLabel lblSessionName = new JLabel();
35
   JLabel lblSavedIn = new JLabel();
36
   JLabel lblCreationDate = new JLabel();
37
   JTextField txtSessionName = new JTextField();
38
   JTextField txtSavedIn = new JTextField();
39
   JTextField txtCreationDate = new JTextField();
40
   JButton btnProjectProperties = new JButton();
41
   JPanel documentTypesContainer = new JPanel();
42

    
43
   /**
44
    * Default constructor
45
    */
46
   public ProjectDocumentsPanelPageView()
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:GROW(1.0),FILL:4DLU:NONE","CENTER:2DLU:NONE,CENTER:DEFAULT:NONE,CENTER:2DLU:NONE,FILL: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");
134
      CellConstraints cc = new CellConstraints();
135
      jpanel1.setLayout(formlayout1);
136

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

    
141
      lblDocument.setName("lblDocument");
142
      lblDocument.setText("documentos_existentes");
143
      jpanel1.add(lblDocument,cc.xy(2,6));
144

    
145
      lblSessionProperties.setName("lblSessionProperties");
146
      lblSessionProperties.setText("propiedades_sesion");
147
      jpanel1.add(lblSessionProperties,cc.xy(2,10));
148

    
149
      jpanel1.add(createPanel1(),cc.xy(2,8));
150
      jpanel1.add(createPanel3(),cc.xy(2,12));
151
      documentTypesContainer.setName("documentTypesContainer");
152
      jpanel1.add(documentTypesContainer,cc.xy(2,4));
153

    
154
      addFillComponents(jpanel1,new int[]{ 1,2,3 },new int[]{ 1,2,3,4,5,6,7,8,9,10,11,12,13 });
155
      return jpanel1;
156
   }
157

    
158
   public JPanel createPanel1()
159
   {
160
      JPanel jpanel1 = new JPanel();
161
      FormLayout formlayout1 = new FormLayout("FILL:DEFAULT:GROW(1.0),FILL:4DLU:NONE,FILL:DEFAULT:NONE","FILL:DEFAULT:GROW(1.0)");
162
      CellConstraints cc = new CellConstraints();
163
      jpanel1.setLayout(formlayout1);
164

    
165
      lstDocuments.setName("lstDocuments");
166
      JScrollPane jscrollpane1 = new JScrollPane();
167
      jscrollpane1.setViewportView(lstDocuments);
168
      jscrollpane1.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
169
      jscrollpane1.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
170
      jpanel1.add(jscrollpane1,cc.xy(1,1));
171

    
172
      jpanel1.add(createPanel2(),cc.xy(3,1));
173
      addFillComponents(jpanel1,new int[]{ 2,3 },new int[0]);
174
      return jpanel1;
175
   }
176

    
177
   public JPanel createPanel2()
178
   {
179
      JPanel jpanel1 = new JPanel();
180
      FormLayout formlayout1 = new FormLayout("FILL:DEFAULT: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");
181
      CellConstraints cc = new CellConstraints();
182
      jpanel1.setLayout(formlayout1);
183

    
184
      btnDocumentNew.setActionCommand("JButton");
185
      btnDocumentNew.setName("btnDocumentNew");
186
      btnDocumentNew.setText("nuevo");
187
      jpanel1.add(btnDocumentNew,cc.xy(1,1));
188

    
189
      btnDocumentOpen.setActionCommand("JButton");
190
      btnDocumentOpen.setName("btnDocumentOpen");
191
      btnDocumentOpen.setText("abrir");
192
      jpanel1.add(btnDocumentOpen,cc.xy(1,3));
193

    
194
      btnDocumentRename.setActionCommand("JButton");
195
      btnDocumentRename.setName("btnDocumentRename");
196
      btnDocumentRename.setText("renombrar");
197
      jpanel1.add(btnDocumentRename,cc.xy(1,5));
198

    
199
      btnDocumentDelete.setActionCommand("JButton");
200
      btnDocumentDelete.setName("btnDocumentDelete");
201
      btnDocumentDelete.setText("borrar");
202
      jpanel1.add(btnDocumentDelete,cc.xy(1,7));
203

    
204
      btnDocumentProperties.setActionCommand("JButton");
205
      btnDocumentProperties.setName("btnDocumentProperties");
206
      btnDocumentProperties.setText("propiedades");
207
      jpanel1.add(btnDocumentProperties,cc.xy(1,9));
208

    
209
      addFillComponents(jpanel1,new int[0],new int[]{ 2,4,6,8 });
210
      return jpanel1;
211
   }
212

    
213
   public JPanel createPanel3()
214
   {
215
      JPanel jpanel1 = new JPanel();
216
      FormLayout formlayout1 = new FormLayout("FILL:DEFAULT:NONE,FILL:4DLU:NONE,FILL:DEFAULT:GROW(1.0)","CENTER:DEFAULT:NONE,CENTER:2DLU:NONE,CENTER:DEFAULT:NONE,CENTER:2DLU:NONE,CENTER:DEFAULT:NONE,CENTER:2DLU:NONE,CENTER:DEFAULT:NONE");
217
      CellConstraints cc = new CellConstraints();
218
      jpanel1.setLayout(formlayout1);
219

    
220
      lblSessionName.setName("lblSessionName");
221
      lblSessionName.setText("nombre_sesion");
222
      jpanel1.add(lblSessionName,cc.xy(1,1));
223

    
224
      lblSavedIn.setName("lblSavedIn");
225
      lblSavedIn.setText("guardado");
226
      jpanel1.add(lblSavedIn,cc.xy(1,3));
227

    
228
      lblCreationDate.setName("lblCreationDate");
229
      lblCreationDate.setText("creation_date");
230
      jpanel1.add(lblCreationDate,cc.xy(1,5));
231

    
232
      txtSessionName.setBackground(new Color(236,233,216));
233
      txtSessionName.setEditable(false);
234
      txtSessionName.setName("txtSessionName");
235
      jpanel1.add(txtSessionName,cc.xy(3,1));
236

    
237
      txtSavedIn.setBackground(new Color(236,233,216));
238
      txtSavedIn.setEditable(false);
239
      txtSavedIn.setName("txtSavedIn");
240
      jpanel1.add(txtSavedIn,cc.xy(3,3));
241

    
242
      txtCreationDate.setBackground(new Color(236,233,216));
243
      txtCreationDate.setEditable(false);
244
      txtCreationDate.setName("txtCreationDate");
245
      jpanel1.add(txtCreationDate,cc.xy(3,5));
246

    
247
      btnProjectProperties.setActionCommand("JButton");
248
      btnProjectProperties.setName("btnProjectProperties");
249
      btnProjectProperties.setText("propiedades");
250
      jpanel1.add(btnProjectProperties,new CellConstraints(3,7,1,1,CellConstraints.RIGHT,CellConstraints.DEFAULT));
251

    
252
      addFillComponents(jpanel1,new int[]{ 2 },new int[]{ 2,4,6,7 });
253
      return jpanel1;
254
   }
255

    
256
   /**
257
    * Initializer
258
    */
259
   protected void initializePanel()
260
   {
261
      setLayout(new BorderLayout());
262
      add(createPanel(), BorderLayout.CENTER);
263
   }
264

    
265

    
266
}