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 / extension / evalexpression / EvaluateExpressionPanelView.java @ 46049

History | View | Annotate | Download (7.94 KB)

1
package org.gvsig.app.extension.evalexpression;
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.ImageIcon;
12
import javax.swing.JButton;
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.JScrollPane;
19
import javax.swing.JTextArea;
20
import javax.swing.JTextField;
21
import javax.swing.border.EmptyBorder;
22

    
23

    
24
public class EvaluateExpressionPanelView extends JPanel
25
{
26
   JButton btnExpression = new JButton();
27
   JButton btnExpressionHistory = new JButton();
28
   JButton btnExpressionBookmarks = new JButton();
29
   JLabel lblLaunchOnChangeBBox = new JLabel();
30
   JCheckBox chkLaunchOnChangeBBox = new JCheckBox();
31
   JLabel lblTitle = new JLabel();
32
   JLabel lblWindowType = new JLabel();
33
   JComboBox cboWindowType = new JComboBox();
34
   JTextField txtTitle = new JTextField();
35
   JLabel lblContentType = new JLabel();
36
   JComboBox cboContentType = new JComboBox();
37
   JButton btnExecute = new JButton();
38
   JTextArea txtExpression = new JTextArea();
39

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

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

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

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

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

    
88
   }
89

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

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

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

    
134
      btnExpression.setActionCommand("...");
135
      btnExpression.setName("btnExpression");
136
      btnExpression.setText("...");
137
      EmptyBorder emptyborder1 = new EmptyBorder(2,2,2,2);
138
      btnExpression.setBorder(emptyborder1);
139
      jpanel1.add(btnExpression,cc.xy(4,2));
140

    
141
      btnExpressionHistory.setActionCommand("...");
142
      btnExpressionHistory.setName("btnExpressionHistory");
143
      btnExpressionHistory.setText("...");
144
      EmptyBorder emptyborder2 = new EmptyBorder(2,2,2,2);
145
      btnExpressionHistory.setBorder(emptyborder2);
146
      jpanel1.add(btnExpressionHistory,cc.xy(4,4));
147

    
148
      btnExpressionBookmarks.setActionCommand("...");
149
      btnExpressionBookmarks.setName("btnExpressionBookmarks");
150
      btnExpressionBookmarks.setText("...");
151
      EmptyBorder emptyborder3 = new EmptyBorder(2,2,2,2);
152
      btnExpressionBookmarks.setBorder(emptyborder3);
153
      jpanel1.add(btnExpressionBookmarks,cc.xy(4,6));
154

    
155
      jpanel1.add(createPanel1(),cc.xy(2,8));
156
      btnExecute.setActionCommand("Ejecutar");
157
      btnExecute.setName("btnExecute");
158
      btnExecute.setText("Ejecutar");
159
      jpanel1.add(btnExecute,new CellConstraints(2,10,1,1,CellConstraints.RIGHT,CellConstraints.DEFAULT));
160

    
161
      txtExpression.setName("txtExpression");
162
      JScrollPane jscrollpane1 = new JScrollPane();
163
      jscrollpane1.setViewportView(txtExpression);
164
      jscrollpane1.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
165
      jscrollpane1.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
166
      jpanel1.add(jscrollpane1,cc.xywh(2,2,1,5));
167

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

    
172
   public JPanel createPanel1()
173
   {
174
      JPanel jpanel1 = new JPanel();
175
      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");
176
      CellConstraints cc = new CellConstraints();
177
      jpanel1.setLayout(formlayout1);
178

    
179
      lblLaunchOnChangeBBox.setName("lblLaunchOnChangeBBox");
180
      lblLaunchOnChangeBBox.setText("Ejecutar cuando cambie el encuadre de la vista activa");
181
      jpanel1.add(lblLaunchOnChangeBBox,cc.xy(1,1));
182

    
183
      chkLaunchOnChangeBBox.setName("chkLaunchOnChangeBBox");
184
      jpanel1.add(chkLaunchOnChangeBBox,cc.xy(3,1));
185

    
186
      lblTitle.setName("lblTitle");
187
      lblTitle.setText("Titulo de la ventana");
188
      jpanel1.add(lblTitle,cc.xy(1,3));
189

    
190
      lblWindowType.setName("lblWindowType");
191
      lblWindowType.setText("Tipo de ventana");
192
      jpanel1.add(lblWindowType,cc.xy(1,5));
193

    
194
      cboWindowType.setName("cboWindowType");
195
      cboWindowType.addItem("Ventana");
196
      cboWindowType.addItem("Modal");
197
      cboWindowType.addItem("Semimodal");
198
      jpanel1.add(cboWindowType,cc.xy(3,5));
199

    
200
      txtTitle.setName("txtTitle");
201
      jpanel1.add(txtTitle,cc.xy(3,3));
202

    
203
      lblContentType.setName("lblContentType");
204
      lblContentType.setText("Tipo de contenido");
205
      jpanel1.add(lblContentType,cc.xy(1,7));
206

    
207
      cboContentType.setName("cboContentType");
208
      cboContentType.addItem("text/plain");
209
      cboContentType.addItem("text/html");
210
      cboContentType.addItem("image/png");
211
      jpanel1.add(cboContentType,cc.xy(3,7));
212

    
213
      addFillComponents(jpanel1,new int[]{ 2 },new int[]{ 2,4,6 });
214
      return jpanel1;
215
   }
216

    
217
   /**
218
    * Initializer
219
    */
220
   protected void initializePanel()
221
   {
222
      setLayout(new BorderLayout());
223
      add(createPanel(), BorderLayout.CENTER);
224
   }
225

    
226

    
227
}