svn-gvsig-desktop / trunk / org.gvsig.desktop / org.gvsig.desktop.framework / org.gvsig.andami / src / main / java / org / gvsig / andami / ui / DisablePluginsConflictingLayoutPanel.java @ 41312
History | View | Annotate | Download (5.95 KB)
1 | 40821 | jjdelcerro | package org.gvsig.andami.ui; |
---|---|---|---|
2 | import java.awt.BorderLayout; |
||
3 | import java.awt.ComponentOrientation; |
||
4 | import java.awt.Container; |
||
5 | import java.awt.Dimension; |
||
6 | |||
7 | import javax.swing.Box; |
||
8 | import javax.swing.ImageIcon; |
||
9 | import javax.swing.JButton; |
||
10 | import javax.swing.JLabel; |
||
11 | import javax.swing.JList; |
||
12 | import javax.swing.JPanel; |
||
13 | import javax.swing.JScrollPane; |
||
14 | |||
15 | import com.jgoodies.forms.layout.CellConstraints; |
||
16 | import com.jgoodies.forms.layout.FormLayout; |
||
17 | |||
18 | |||
19 | public class DisablePluginsConflictingLayoutPanel extends JPanel |
||
20 | { |
||
21 | /**
|
||
22 | *
|
||
23 | */
|
||
24 | private static final long serialVersionUID = 1L; |
||
25 | |||
26 | @SuppressWarnings("rawtypes") |
||
27 | public JList pluginList = new JList(); |
||
28 | public JButton buttonContinue = new JButton(); |
||
29 | public JButton buttonClose = new JButton(); |
||
30 | public JLabel lblConflict = new JLabel(); |
||
31 | public JLabel lblSelectPluginToDisable = new JLabel(); |
||
32 | public JLabel lblClickContinue = new JLabel(); |
||
33 | public JLabel lblClickClose = new JLabel(); |
||
34 | |||
35 | /**
|
||
36 | * Default constructor
|
||
37 | */
|
||
38 | public DisablePluginsConflictingLayoutPanel()
|
||
39 | { |
||
40 | initializePanel(); |
||
41 | } |
||
42 | |||
43 | /**
|
||
44 | * Adds fill components to empty cells in the first row and first column of the grid.
|
||
45 | * This ensures that the grid spacing will be the same as shown in the designer.
|
||
46 | * @param cols an array of column indices in the first row where fill components should be added.
|
||
47 | * @param rows an array of row indices in the first column where fill components should be added.
|
||
48 | */
|
||
49 | void addFillComponents( Container panel, int[] cols, int[] rows ) |
||
50 | { |
||
51 | Dimension filler = new Dimension(10,10); |
||
52 | |||
53 | boolean filled_cell_11 = false; |
||
54 | CellConstraints cc = new CellConstraints();
|
||
55 | if ( cols.length > 0 && rows.length > 0 ) |
||
56 | { |
||
57 | if ( cols[0] == 1 && rows[0] == 1 ) |
||
58 | { |
||
59 | /** add a rigid area */
|
||
60 | panel.add( Box.createRigidArea( filler ), cc.xy(1,1) ); |
||
61 | filled_cell_11 = true;
|
||
62 | } |
||
63 | } |
||
64 | |||
65 | for( int index = 0; index < cols.length; index++ ) |
||
66 | { |
||
67 | if ( cols[index] == 1 && filled_cell_11 ) |
||
68 | { |
||
69 | continue;
|
||
70 | } |
||
71 | panel.add( Box.createRigidArea( filler ), cc.xy(cols[index],1) ); |
||
72 | } |
||
73 | |||
74 | for( int index = 0; index < rows.length; index++ ) |
||
75 | { |
||
76 | if ( rows[index] == 1 && filled_cell_11 ) |
||
77 | { |
||
78 | continue;
|
||
79 | } |
||
80 | panel.add( Box.createRigidArea( filler ), cc.xy(1,rows[index]) ); |
||
81 | } |
||
82 | |||
83 | } |
||
84 | |||
85 | /**
|
||
86 | * Helper method to load an image file from the CLASSPATH
|
||
87 | * @param imageName the package and name of the file to load relative to the CLASSPATH
|
||
88 | * @return an ImageIcon instance with the specified image file
|
||
89 | * @throws IllegalArgumentException if the image resource cannot be loaded.
|
||
90 | */
|
||
91 | public ImageIcon loadImage( String imageName ) |
||
92 | { |
||
93 | try
|
||
94 | { |
||
95 | ClassLoader classloader = getClass().getClassLoader();
|
||
96 | java.net.URL url = classloader.getResource( imageName ); |
||
97 | if ( url != null ) |
||
98 | { |
||
99 | ImageIcon icon = new ImageIcon( url ); |
||
100 | return icon;
|
||
101 | } |
||
102 | } |
||
103 | catch( Exception e ) |
||
104 | { |
||
105 | e.printStackTrace(); |
||
106 | } |
||
107 | throw new IllegalArgumentException( "Unable to load image: " + imageName ); |
||
108 | } |
||
109 | |||
110 | /**
|
||
111 | * Method for recalculating the component orientation for
|
||
112 | * right-to-left Locales.
|
||
113 | * @param orientation the component orientation to be applied
|
||
114 | */
|
||
115 | public void applyComponentOrientation( ComponentOrientation orientation ) |
||
116 | { |
||
117 | // Not yet implemented...
|
||
118 | // I18NUtils.applyComponentOrientation(this, orientation);
|
||
119 | super.applyComponentOrientation(orientation);
|
||
120 | } |
||
121 | |||
122 | public JPanel createPanel() |
||
123 | { |
||
124 | JPanel jpanel1 = new JPanel(); |
||
125 | FormLayout formlayout1 = new FormLayout("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:GROW(1.0),CENTER:DEFAULT:NONE,CENTER:DEFAULT:NONE,CENTER:DEFAULT:NONE"); |
||
126 | CellConstraints cc = new CellConstraints();
|
||
127 | jpanel1.setLayout(formlayout1); |
||
128 | |||
129 | lblConflict.setName("lblConflict");
|
||
130 | lblConflict.setText("Some of plugins installed conflict with each other.");
|
||
131 | jpanel1.add(lblConflict,new CellConstraints(2,2,4,1,CellConstraints.FILL,CellConstraints.DEFAULT)); |
||
132 | |||
133 | pluginList.setName("PluginList");
|
||
134 | JScrollPane jscrollpane1 = new JScrollPane(); |
||
135 | jscrollpane1.setViewportView(pluginList); |
||
136 | jscrollpane1.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED);
|
||
137 | jscrollpane1.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
|
||
138 | jpanel1.add(jscrollpane1,new CellConstraints(2,7,4,1,CellConstraints.FILL,CellConstraints.FILL)); |
||
139 | |||
140 | buttonContinue.setActionCommand("Continue");
|
||
141 | buttonContinue.setText("Continue");
|
||
142 | jpanel1.add(buttonContinue,cc.xy(5,9)); |
||
143 | |||
144 | buttonClose.setActionCommand("Close");
|
||
145 | buttonClose.setName("buttonClose");
|
||
146 | buttonClose.setText("Close");
|
||
147 | jpanel1.add(buttonClose,cc.xy(3,9)); |
||
148 | |||
149 | lblSelectPluginToDisable.setName("lblSelectPluginToDisable");
|
||
150 | lblSelectPluginToDisable.setText("Select the plugins that you want to disable and click the continue button.");
|
||
151 | jpanel1.add(lblSelectPluginToDisable,cc.xywh(2,3,4,1)); |
||
152 | |||
153 | lblClickContinue.setName("lblClickContinue");
|
||
154 | lblClickContinue.setText("You can click on continue button directly if you want to disable any plugins.");
|
||
155 | jpanel1.add(lblClickContinue,cc.xywh(2,4,4,1)); |
||
156 | |||
157 | lblClickClose.setName("lblClickClose");
|
||
158 | lblClickClose.setText("Or click the close button to close the application.");
|
||
159 | jpanel1.add(lblClickClose,cc.xywh(2,5,4,1)); |
||
160 | |||
161 | addFillComponents(jpanel1,new int[]{ 1,2,3,4,5,6 },new int[]{ 1,2,3,4,5,6,7,8,9,10 }); |
||
162 | return jpanel1;
|
||
163 | } |
||
164 | |||
165 | /**
|
||
166 | * Initializer
|
||
167 | */
|
||
168 | protected void initializePanel() |
||
169 | { |
||
170 | setLayout(new BorderLayout()); |
||
171 | add(createPanel(), BorderLayout.CENTER);
|
||
172 | } |
||
173 | |||
174 | |||
175 | } |