Statistics
| Revision:

svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.plugin / org.gvsig.h2spatial.app / org.gvsig.h2spatial.app.mainplugin / src / main / java / org / gvsig / webbrowser / jfx / JFXWebBrowserPanelView.java @ 43377

History | View | Annotate | Download (7.14 KB)

1
package org.gvsig.webbrowser.jfx;
2

    
3
import com.jeta.forms.components.image.ImageComponent;
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.JPanel;
18
import javax.swing.JTextField;
19
import javax.swing.border.EmptyBorder;
20
import javax.swing.border.LineBorder;
21

    
22

    
23
public class JFXWebBrowserPanelView extends JPanel
24
{
25
   JTextField txtURL = new JTextField();
26
   JPanel containerBrowser = new JPanel();
27
   JTextField txtSearch = new JTextField();
28
   JLabel lblStatus = new JLabel();
29
   ImageComponent imgSearch = new ImageComponent();
30
   JButton btnSearchNext = new JButton();
31
   JButton btnSearchPrevious = new JButton();
32
   JButton btnPrevious = new JButton();
33
   JButton btnNext = new JButton();
34
   JButton btnRefresh = new JButton();
35
   JButton btnConfig = new JButton();
36

    
37
   /**
38
    * Default constructor
39
    */
40
   public JFXWebBrowserPanelView()
41
   {
42
      initializePanel();
43
   }
44

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

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

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

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

    
85
   }
86

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

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

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

    
131
      txtURL.setName("txtURL");
132
      jpanel1.add(txtURL,cc.xy(8,2));
133

    
134
      containerBrowser.setName("containerBrowser");
135
      jpanel1.add(containerBrowser,new CellConstraints(2,4,9,1,CellConstraints.FILL,CellConstraints.FILL));
136

    
137
      jpanel1.add(createPanel1(),cc.xywh(2,6,9,1));
138
      btnPrevious.setName("btnPrevious");
139
      EmptyBorder emptyborder1 = new EmptyBorder(0,0,0,0);
140
      btnPrevious.setBorder(emptyborder1);
141
      jpanel1.add(btnPrevious,new CellConstraints(2,2,1,1,CellConstraints.FILL,CellConstraints.FILL));
142

    
143
      btnNext.setName("btnNext");
144
      EmptyBorder emptyborder2 = new EmptyBorder(0,0,0,0);
145
      btnNext.setBorder(emptyborder2);
146
      jpanel1.add(btnNext,new CellConstraints(4,2,1,1,CellConstraints.FILL,CellConstraints.FILL));
147

    
148
      btnRefresh.setEnabled(false);
149
      btnRefresh.setName("btnRefresh");
150
      EmptyBorder emptyborder3 = new EmptyBorder(0,0,0,0);
151
      btnRefresh.setBorder(emptyborder3);
152
      jpanel1.add(btnRefresh,new CellConstraints(6,2,1,1,CellConstraints.FILL,CellConstraints.FILL));
153

    
154
      btnConfig.setEnabled(false);
155
      btnConfig.setName("btnConfig");
156
      EmptyBorder emptyborder4 = new EmptyBorder(0,0,0,0);
157
      btnConfig.setBorder(emptyborder4);
158
      jpanel1.add(btnConfig,new CellConstraints(10,2,1,1,CellConstraints.FILL,CellConstraints.FILL));
159

    
160
      addFillComponents(jpanel1,new int[]{ 1,2,3,4,5,6,7,8,9,10,11 },new int[]{ 1,2,3,4,5,6,7 });
161
      return jpanel1;
162
   }
163

    
164
   public JPanel createPanel1()
165
   {
166
      JPanel jpanel1 = new JPanel();
167
      FormLayout formlayout1 = new FormLayout("FILL:DEFAULT:NONE,FILL:4DLU:NONE,FILL:MIN(12DLU;DEFAULT):GROW(0.3),FILL:4DLU:NONE,FILL:DEFAULT:NONE,FILL:4DLU:NONE,FILL:DEFAULT:NONE,FILL:4DLU:NONE,FILL:DEFAULT:GROW(0.7)","CENTER:DEFAULT:NONE");
168
      CellConstraints cc = new CellConstraints();
169
      jpanel1.setLayout(formlayout1);
170

    
171
      txtSearch.setName("txtSearch");
172
      jpanel1.add(txtSearch,cc.xy(3,1));
173

    
174
      lblStatus.setName("lblStatus");
175
      LineBorder lineborder1 = new LineBorder(new Color(189,190,176),1,false);
176
      lblStatus.setBorder(lineborder1);
177
      jpanel1.add(lblStatus,new CellConstraints(9,1,1,1,CellConstraints.FILL,CellConstraints.FILL));
178

    
179
      imgSearch.setName("imgSearch");
180
      jpanel1.add(imgSearch,cc.xy(1,1));
181

    
182
      btnSearchNext.setName("btnSearchNext");
183
      EmptyBorder emptyborder1 = new EmptyBorder(0,0,0,0);
184
      btnSearchNext.setBorder(emptyborder1);
185
      jpanel1.add(btnSearchNext,cc.xy(5,1));
186

    
187
      btnSearchPrevious.setName("btnSearchPrevious");
188
      EmptyBorder emptyborder2 = new EmptyBorder(0,0,0,0);
189
      btnSearchPrevious.setBorder(emptyborder2);
190
      jpanel1.add(btnSearchPrevious,cc.xy(7,1));
191

    
192
      addFillComponents(jpanel1,new int[]{ 2,4,6,8 },new int[0]);
193
      return jpanel1;
194
   }
195

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

    
205

    
206
}