Revision 43068

View differences:

trunk/org.gvsig.desktop/org.gvsig.desktop.plugin/org.gvsig.coreplugin.app/org.gvsig.coreplugin.app.mainplugin/src/main/java/org/gvsig/coreplugin/preferences/general/IconThemePageLayout.xml
1 1
<?xml version="1.0" encoding="UTF-8"?>
2
<!--
3 2

  
4
    gvSIG. Desktop Geographic Information System.
5

  
6
    Copyright (C) 2007-2013 gvSIG Association.
7

  
8
    This program is free software; you can redistribute it and/or
9
    modify it under the terms of the GNU General Public License
10
    as published by the Free Software Foundation; either version 3
11
    of the License, or (at your option) any later version.
12

  
13
    This program is distributed in the hope that it will be useful,
14
    but WITHOUT ANY WARRANTY; without even the implied warranty of
15
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
    GNU General Public License for more details.
17

  
18
    You should have received a copy of the GNU General Public License
19
    along with this program; if not, write to the Free Software
20
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
21
    MA  02110-1301, USA.
22

  
23
    For any additional information, do not hesitate to contact us
24
    at info AT gvsig.com, or visit our website www.gvsig.com.
25

  
26
-->
27

  
28 3
<object classname="com.jeta.forms.store.memento.FormPackage">
29 4
 <at name="fileversion">
30 5
  <object classname="com.jeta.forms.store.memento.FormsVersion2">
......
49 24
    </at>
50 25
    <at name="componentclass">com.jeta.forms.gui.form.FormComponent</at>
51 26
   </super>
52
   <at name="id">N593826fD13838cef220CB8000</at>
27
   <at name="id">/home/jjdelcerro/datos/devel/org.gvsig.desktop/org.gvsig.desktop.plugin/org.gvsig.coreplugin.app/org.gvsig.coreplugin.app.mainplugin/src/main/java/org/gvsig/coreplugin/preferences/general/IconThemePageLayout.xml</at>
53 28
   <at name="rowspecs">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</at>
54 29
   <at name="colspecs">FILL:DEFAULT:NONE,FILL:DEFAULT:NONE,FILL:DEFAULT:GROW(1.0),FILL:DEFAULT:NONE</at>
55 30
   <at name="components">
......
78 53
          <at name="classname">com.jeta.forms.components.label.JETALabel</at>
79 54
          <at name="properties">
80 55
           <object classname="com.jeta.forms.store.support.PropertyMap">
81
            <at name="text">_Icon_themes_availables</at>
82
            <at name="height">17</at>
83
            <at name="width">878</at>
84
            <at name="name">label_title</at>
85
            <at name="fill">
86
             <object classname="com.jeta.forms.store.properties.effects.PaintProperty">
87
              <at name="name">fill</at>
88
             </object>
89
            </at>
90 56
            <at name="border">
91 57
             <object classname="com.jeta.forms.store.properties.CompoundBorderProperty">
92 58
              <super classname="com.jeta.forms.store.properties.BorderProperty">
......
107 73
              </at>
108 74
             </object>
109 75
            </at>
76
            <at name="name">label_title</at>
77
            <at name="width">933</at>
78
            <at name="text">_Icon_themes_availables</at>
79
            <at name="fill">
80
             <object classname="com.jeta.forms.store.properties.effects.PaintProperty">
81
              <at name="name">fill</at>
82
             </object>
83
            </at>
84
            <at name="height">14</at>
110 85
           </object>
111 86
          </at>
112 87
         </object>
......
138 113
          <at name="classname">com.jeta.forms.components.label.JETALabel</at>
139 114
          <at name="properties">
140 115
           <object classname="com.jeta.forms.store.support.PropertyMap">
141
            <at name="text">_Select_an_icon_theme_as_default_for_use_in_the_application</at>
142
            <at name="height">17</at>
143
            <at name="width">878</at>
144
            <at name="name">label_selection</at>
145
            <at name="fill">
146
             <object classname="com.jeta.forms.store.properties.effects.PaintProperty">
147
              <at name="name">fill</at>
148
             </object>
149
            </at>
150 116
            <at name="border">
151 117
             <object classname="com.jeta.forms.store.properties.CompoundBorderProperty">
152 118
              <super classname="com.jeta.forms.store.properties.BorderProperty">
......
167 133
              </at>
168 134
             </object>
169 135
            </at>
170
           </object>
171
          </at>
172
         </object>
173
        </at>
174
       </object>
175
      </at>
176
     </item>
177
     <item >
178
      <at name="value">
179
       <object classname="com.jeta.forms.store.memento.BeanMemento">
180
        <super classname="com.jeta.forms.store.memento.ComponentMemento">
181
         <at name="cellconstraints">
182
          <object classname="com.jeta.forms.store.memento.CellConstraintsMemento">
183
           <at name="column">2</at>
184
           <at name="row">6</at>
185
           <at name="colspan">3</at>
186
           <at name="rowspan">1</at>
187
           <at name="halign">default</at>
188
           <at name="valign">default</at>
189
           <at name="insets" object="insets">0,0,0,0</at>
190
          </object>
191
         </at>
192
         <at name="componentclass">com.jeta.forms.gui.form.StandardComponent</at>
193
        </super>
194
        <at name="jetabeanclass">com.jeta.forms.gui.beans.JETABean</at>
195
        <at name="beanclass">com.jeta.forms.components.label.JETALabel</at>
196
        <at name="beanproperties">
197
         <object classname="com.jeta.forms.store.memento.PropertiesMemento">
198
          <at name="classname">com.jeta.forms.components.label.JETALabel</at>
199
          <at name="properties">
200
           <object classname="com.jeta.forms.store.support.PropertyMap">
201
            <at name="text">_You_can_export_the_default_icon_theme_to_use_as_base_for_create_a_custom_icon_theme</at>
202
            <at name="height">17</at>
203
            <at name="width">878</at>
204
            <at name="name">label_export</at>
136
            <at name="name">label_selection</at>
137
            <at name="width">933</at>
138
            <at name="text">_Select_an_icon_theme_as_default_for_use_in_the_application</at>
205 139
            <at name="fill">
206 140
             <object classname="com.jeta.forms.store.properties.effects.PaintProperty">
207 141
              <at name="name">fill</at>
208 142
             </object>
209 143
            </at>
210
            <at name="border">
211
             <object classname="com.jeta.forms.store.properties.CompoundBorderProperty">
212
              <super classname="com.jeta.forms.store.properties.BorderProperty">
213
               <at name="name">border</at>
214
              </super>
215
              <at name="borders">
216
               <object classname="java.util.LinkedList">
217
                <item >
218
                 <at name="value">
219
                  <object classname="com.jeta.forms.store.properties.DefaultBorderProperty">
220
                   <super classname="com.jeta.forms.store.properties.BorderProperty">
221
                    <at name="name">border</at>
222
                   </super>
223
                  </object>
224
                 </at>
225
                </item>
226
               </object>
227
              </at>
228
             </object>
229
            </at>
144
            <at name="height">14</at>
230 145
           </object>
231 146
          </at>
232 147
         </object>
......
258 173
          <at name="classname">javax.swing.JComboBox</at>
259 174
          <at name="properties">
260 175
           <object classname="com.jeta.forms.store.support.PropertyMap">
261
            <at name="height">23</at>
262
            <at name="items">
263
             <object classname="com.jeta.forms.store.properties.ItemsProperty">
264
              <at name="name">items</at>
265
             </object>
266
            </at>
267
            <at name="width">846</at>
268
            <at name="name">combo_selection</at>
269 176
            <at name="border">
270 177
             <object classname="com.jeta.forms.store.properties.CompoundBorderProperty">
271 178
              <super classname="com.jeta.forms.store.properties.BorderProperty">
......
286 193
              </at>
287 194
             </object>
288 195
            </at>
289
           </object>
290
          </at>
291
         </object>
292
        </at>
293
       </object>
294
      </at>
295
     </item>
296
     <item >
297
      <at name="value">
298
       <object classname="com.jeta.forms.store.memento.BeanMemento">
299
        <super classname="com.jeta.forms.store.memento.ComponentMemento">
300
         <at name="cellconstraints">
301
          <object classname="com.jeta.forms.store.memento.CellConstraintsMemento">
302
           <at name="column">3</at>
303
           <at name="row">8</at>
304
           <at name="colspan">1</at>
305
           <at name="rowspan">1</at>
306
           <at name="halign">left</at>
307
           <at name="valign">default</at>
308
           <at name="insets" object="insets">0,0,0,0</at>
309
          </object>
310
         </at>
311
         <at name="componentclass">com.jeta.forms.gui.form.StandardComponent</at>
312
        </super>
313
        <at name="jetabeanclass">com.jeta.forms.gui.beans.JETABean</at>
314
        <at name="beanclass">javax.swing.JButton</at>
315
        <at name="beanproperties">
316
         <object classname="com.jeta.forms.store.memento.PropertiesMemento">
317
          <at name="classname">javax.swing.JButton</at>
318
          <at name="properties">
319
           <object classname="com.jeta.forms.store.support.PropertyMap">
320
            <at name="text">_Export_default_icon_theme</at>
321
            <at name="height">22</at>
322
            <at name="width">212</at>
323
            <at name="name">button_export</at>
324
            <at name="actionCommand">_Export_default_icon_theme</at>
325
            <at name="border">
326
             <object classname="com.jeta.forms.store.properties.CompoundBorderProperty">
327
              <super classname="com.jeta.forms.store.properties.BorderProperty">
328
               <at name="name">border</at>
329
              </super>
330
              <at name="borders">
331
               <object classname="java.util.LinkedList">
332
                <item >
333
                 <at name="value">
334
                  <object classname="com.jeta.forms.store.properties.DefaultBorderProperty">
335
                   <super classname="com.jeta.forms.store.properties.BorderProperty">
336
                    <at name="name">border</at>
337
                   </super>
338
                  </object>
339
                 </at>
340
                </item>
341
               </object>
342
              </at>
196
            <at name="name">combo_selection</at>
197
            <at name="width">901</at>
198
            <at name="items">
199
             <object classname="com.jeta.forms.store.properties.ItemsProperty">
200
              <at name="name">items</at>
343 201
             </object>
344 202
            </at>
203
            <at name="height">20</at>
345 204
           </object>
346 205
          </at>
347 206
         </object>
......
356 215
     <at name="classname">com.jeta.forms.gui.form.GridView</at>
357 216
     <at name="properties">
358 217
      <object classname="com.jeta.forms.store.support.PropertyMap">
359
       <at name="name"></at>
218
       <at name="border">
219
        <object classname="com.jeta.forms.store.properties.CompoundBorderProperty">
220
         <super classname="com.jeta.forms.store.properties.BorderProperty">
221
          <at name="name">border</at>
222
         </super>
223
         <at name="borders">
224
          <object classname="java.util.LinkedList"/>
225
         </at>
226
        </object>
227
       </at>
228
       <at name="name"/>
360 229
       <at name="fill">
361 230
        <object classname="com.jeta.forms.store.properties.effects.PaintProperty">
362 231
         <at name="name">fill</at>
......
367 236
         <at name="name">scollBars</at>
368 237
         <at name="verticalpolicy">21</at>
369 238
         <at name="horizontalpolicy">31</at>
370
        </object>
371
       </at>
372
       <at name="border">
373
        <object classname="com.jeta.forms.store.properties.CompoundBorderProperty">
374
         <super classname="com.jeta.forms.store.properties.BorderProperty">
375
          <at name="name">border</at>
376
         </super>
377
         <at name="borders">
378
          <object classname="java.util.LinkedList"/>
239
         <at name="border">
240
          <object classname="com.jeta.forms.store.properties.CompoundBorderProperty">
241
           <super classname="com.jeta.forms.store.properties.BorderProperty">
242
            <at name="name">border</at>
243
           </super>
244
           <at name="borders">
245
            <object classname="java.util.LinkedList">
246
             <item >
247
              <at name="value">
248
               <object classname="com.jeta.forms.store.properties.DefaultBorderProperty">
249
                <super classname="com.jeta.forms.store.properties.BorderProperty">
250
                 <at name="name">border</at>
251
                </super>
252
               </object>
253
              </at>
254
             </item>
255
            </object>
256
           </at>
257
          </object>
379 258
         </at>
380 259
        </object>
381 260
       </at>
trunk/org.gvsig.desktop/org.gvsig.desktop.plugin/org.gvsig.coreplugin.app/org.gvsig.coreplugin.app.mainplugin/src/main/java/org/gvsig/coreplugin/preferences/general/IconThemePageLayout.java
1
/**
2
 * gvSIG. Desktop Geographic Information System.
3
 *
4
 * Copyright (C) 2007-2013 gvSIG Association.
5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 3
9
 * of the License, or (at your option) any later version.
10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
 * MA  02110-1301, USA.
20
 *
21
 * For any additional information, do not hesitate to contact us
22
 * at info AT gvsig.com, or visit our website www.gvsig.com.
23
 */
24 1
package org.gvsig.coreplugin.preferences.general;
25 2

  
26
//import com.jeta.open.i18n.I18NUtils;
3
import com.jeta.open.i18n.I18NUtils;
4
import com.jgoodies.forms.layout.CellConstraints;
5
import com.jgoodies.forms.layout.FormLayout;
27 6
import java.awt.BorderLayout;
28 7
import java.awt.ComponentOrientation;
29 8
import java.awt.Container;
30 9
import java.awt.Dimension;
31
import java.awt.GridBagConstraints;
32
import java.awt.GridBagLayout;
33
import java.awt.Insets;
34

  
35 10
import javax.swing.Box;
36 11
import javax.swing.ImageIcon;
37
import javax.swing.JButton;
38 12
import javax.swing.JComboBox;
13
import javax.swing.JFrame;
39 14
import javax.swing.JLabel;
40 15
import javax.swing.JPanel;
41
import javax.swing.JTextArea;
42 16

  
43
import org.gvsig.i18n.Messages;
44 17

  
45
import com.jgoodies.forms.layout.CellConstraints;
46
import com.jgoodies.forms.layout.FormLayout;
18
public class IconThemePageLayout extends JPanel
19
{
20
   JLabel label_title = new JLabel();
21
   JLabel label_selection = new JLabel();
22
   JComboBox combo_selection = new JComboBox();
47 23

  
48
public class IconThemePageLayout extends JPanel {
49
	/**
50
	 * 
51
	 */
52
	private static final long serialVersionUID = 732724276675072878L;
24
   /**
25
    * Default constructor
26
    */
27
   public IconThemePageLayout()
28
   {
29
      initializePanel();
30
   }
53 31

  
54
	JLabel label_title = new JLabel();
55
	JLabel label_selection = new JLabel();
56
	JTextArea label_export = new JTextArea();
57
	JComboBox combo_selection = new JComboBox();
58
	JButton button_export = new JButton();
32
   /**
33
    * Adds fill components to empty cells in the first row and first column of the grid.
34
    * This ensures that the grid spacing will be the same as shown in the designer.
35
    * @param cols an array of column indices in the first row where fill components should be added.
36
    * @param rows an array of row indices in the first column where fill components should be added.
37
    */
38
   void addFillComponents( Container panel, int[] cols, int[] rows )
39
   {
40
      Dimension filler = new Dimension(10,10);
59 41

  
60
	/**
61
	 * Default constructor
62
	 */
63
	public IconThemePageLayout() {
64
		initializePanel();
65
	}
42
      boolean filled_cell_11 = false;
43
      CellConstraints cc = new CellConstraints();
44
      if ( cols.length > 0 && rows.length > 0 )
45
      {
46
         if ( cols[0] == 1 && rows[0] == 1 )
47
         {
48
            /** add a rigid area  */
49
            panel.add( Box.createRigidArea( filler ), cc.xy(1,1) );
50
            filled_cell_11 = true;
51
         }
52
      }
66 53

  
67
	/**
68
	 * Adds fill components to empty cells in the first row and first column of
69
	 * the grid. This ensures that the grid spacing will be the same as shown in
70
	 * the designer.
71
	 * 
72
	 * @param cols
73
	 *            an array of column indices in the first row where fill
74
	 *            components should be added.
75
	 * @param rows
76
	 *            an array of row indices in the first column where fill
77
	 *            components should be added.
78
	 */
79
	void addFillComponents(Container panel, int[] cols, int[] rows) {
80
		Dimension filler = new Dimension(10, 10);
54
      for( int index = 0; index < cols.length; index++ )
55
      {
56
         if ( cols[index] == 1 && filled_cell_11 )
57
         {
58
            continue;
59
         }
60
         panel.add( Box.createRigidArea( filler ), cc.xy(cols[index],1) );
61
      }
81 62

  
82
		boolean filled_cell_11 = false;
83
		CellConstraints cc = new CellConstraints();
84
		if (cols.length > 0 && rows.length > 0) {
85
			if (cols[0] == 1 && rows[0] == 1) {
86
				/** add a rigid area */
87
				panel.add(Box.createRigidArea(filler), cc.xy(1, 1));
88
				filled_cell_11 = true;
89
			}
90
		}
63
      for( int index = 0; index < rows.length; index++ )
64
      {
65
         if ( rows[index] == 1 && filled_cell_11 )
66
         {
67
            continue;
68
         }
69
         panel.add( Box.createRigidArea( filler ), cc.xy(1,rows[index]) );
70
      }
91 71

  
92
		for (int index = 0; index < cols.length; index++) {
93
			if (cols[index] == 1 && filled_cell_11) {
94
				continue;
95
			}
96
			panel.add(Box.createRigidArea(filler), cc.xy(cols[index], 1));
97
		}
72
   }
98 73

  
99
		for (int index = 0; index < rows.length; index++) {
100
			if (rows[index] == 1 && filled_cell_11) {
101
				continue;
102
			}
103
			panel.add(Box.createRigidArea(filler), cc.xy(1, rows[index]));
104
		}
74
   /**
75
    * Helper method to load an image file from the CLASSPATH
76
    * @param imageName the package and name of the file to load relative to the CLASSPATH
77
    * @return an ImageIcon instance with the specified image file
78
    * @throws IllegalArgumentException if the image resource cannot be loaded.
79
    */
80
   public ImageIcon loadImage( String imageName )
81
   {
82
      try
83
      {
84
         ClassLoader classloader = getClass().getClassLoader();
85
         java.net.URL url = classloader.getResource( imageName );
86
         if ( url != null )
87
         {
88
            ImageIcon icon = new ImageIcon( url );
89
            return icon;
90
         }
91
      }
92
      catch( Exception e )
93
      {
94
         e.printStackTrace();
95
      }
96
      throw new IllegalArgumentException( "Unable to load image: " + imageName );
97
   }
105 98

  
106
	}
99
   /**
100
    * Method for recalculating the component orientation for 
101
    * right-to-left Locales.
102
    * @param orientation the component orientation to be applied
103
    */
104
   public void applyComponentOrientation( ComponentOrientation orientation )
105
   {
106
      // Not yet implemented...
107
      // I18NUtils.applyComponentOrientation(this, orientation);
108
      super.applyComponentOrientation(orientation);
109
   }
107 110

  
108
	/**
109
	 * Helper method to load an image file from the CLASSPATH
110
	 * 
111
	 * @param imageName
112
	 *            the package and name of the file to load relative to the
113
	 *            CLASSPATH
114
	 * @return an ImageIcon instance with the specified image file
115
	 * @throws IllegalArgumentException
116
	 *             if the image resource cannot be loaded.
117
	 */
118
	public ImageIcon loadImage(String imageName) {
119
		try {
120
			ClassLoader classloader = getClass().getClassLoader();
121
			java.net.URL url = classloader.getResource(imageName);
122
			if (url != null) {
123
				ImageIcon icon = new ImageIcon(url);
124
				return icon;
125
			}
126
		} catch (Exception e) {
127
			e.printStackTrace();
128
		}
129
		throw new IllegalArgumentException("Unable to load image: " + imageName);
130
	}
111
   public JPanel createPanel()
112
   {
113
      JPanel jpanel1 = new JPanel();
114
      FormLayout formlayout1 = new FormLayout("FILL:DEFAULT:NONE,FILL:DEFAULT:NONE,FILL:DEFAULT:GROW(1.0),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");
115
      CellConstraints cc = new CellConstraints();
116
      jpanel1.setLayout(formlayout1);
131 117

  
132
	/**
133
	 * Method for recalculating the component orientation for right-to-left
134
	 * Locales.
135
	 * 
136
	 * @param orientation
137
	 *            the component orientation to be applied
138
	 */
139
	public void applyComponentOrientation(ComponentOrientation orientation) {
140
		// Not yet implemented...
141
		// I18NUtils.applyComponentOrientation(this, orientation);
142
		super.applyComponentOrientation(orientation);
143
	}
118
      label_title.setName("label_title");
119
      label_title.setText("_Icon_themes_availables");
120
      jpanel1.add(label_title,cc.xywh(2,2,3,1));
144 121

  
145
	public JPanel createPanel() {
146
		
147
		GridBagLayout gbl = new GridBagLayout();
148
		JPanel resp = new JPanel(gbl);
149
		GridBagConstraints gbc = new GridBagConstraints();
150
		
151
		gbc.insets = new Insets(2, 30, 0, 30);
152
		gbc.anchor = GridBagConstraints.NORTHWEST;
153
		gbc.fill = GridBagConstraints.BOTH;
154
		gbc.gridx = 0;
155
		// ==============================
156
		gbc.gridy = 0;
157
		label_title.setName("label_title");
158
		label_title.setText(Messages.getText("_Icon_themes_availables"));
159
		resp.add(label_title, gbc);
160
		// ==============================
161
		gbc.gridy = 1;
162
		label_selection.setName("label_selection");
163
		label_selection.setText(Messages.getText(
164
				"_Select_an_icon_theme_as_default_for_use_in_the_application"));
165
		resp.add(label_selection, gbc);
166
		// ==============================
167
		gbc.gridy = 2;
168
		combo_selection.setName("combo_selection");
169
		resp.add(combo_selection, gbc);
170
		// ==============================
171
		gbc.gridy = 3;
172
		resp.add(new JLabel(" "), gbc);
173
		// ==============================
174
		gbc.gridy = 4;
175
		label_export.setName("label_export");
176
		label_export.setWrapStyleWord(true);
177
		label_export.setLineWrap(true);
178
		label_export.setFont(new JLabel().getFont());
179
		label_export.setBackground(resp.getBackground());
180
		label_export.setText(Messages.getText(
181
				"_You_can_export_the_default_icon_theme_to_use_as_base_for_create_a_custom_icon_theme"));
182
		resp.add(label_export, gbc);
183
		// ==============================
184
		gbc.gridy = 5;
185
		gbc.fill = GridBagConstraints.NONE;
186
		gbc.anchor = GridBagConstraints.NORTH;
187
		button_export.setActionCommand("_Export_default_icon_theme");
188
		button_export.setName("button_export");
189
		button_export.setText(Messages.getText(
190
				"_Export_default_icon_theme"));
191
		resp.add(button_export, gbc);
192
		// ==============================
193
		return resp;
194
	}
122
      label_selection.setName("label_selection");
123
      label_selection.setText("_Select_an_icon_theme_as_default_for_use_in_the_application");
124
      jpanel1.add(label_selection,cc.xywh(2,3,3,1));
195 125

  
196
	/**
197
	 * Initializer
198
	 */
199
	protected void initializePanel() {
200
		setLayout(new BorderLayout());
201
		add(createPanel(), BorderLayout.CENTER);
202
	}
126
      combo_selection.setName("combo_selection");
127
      jpanel1.add(combo_selection,cc.xy(3,4));
203 128

  
129
      addFillComponents(jpanel1,new int[]{ 1,2,3,4 },new int[]{ 1,2,3,4,5,6,7,8,9 });
130
      return jpanel1;
131
   }
132

  
133
   /**
134
    * Initializer
135
    */
136
   protected void initializePanel()
137
   {
138
      setLayout(new BorderLayout());
139
      add(createPanel(), BorderLayout.CENTER);
140
   }
141

  
142

  
204 143
}
trunk/org.gvsig.desktop/org.gvsig.desktop.plugin/org.gvsig.coreplugin.app/org.gvsig.coreplugin.app.mainplugin/src/main/java/org/gvsig/coreplugin/preferences/general/IconThemePage.java
3 3
 *
4 4
 * Copyright (C) 2007-2013 gvSIG Association.
5 5
 *
6
 * This program is free software; you can redistribute it and/or
7
 * modify it under the terms of the GNU General Public License
8
 * as published by the Free Software Foundation; either version 3
9
 * of the License, or (at your option) any later version.
6
 * This program is free software; you can redistribute it and/or modify it under
7
 * the terms of the GNU General Public License as published by the Free Software
8
 * Foundation; either version 3 of the License, or (at your option) any later
9
 * version.
10 10
 *
11
 * This program is distributed in the hope that it will be useful,
12
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 * GNU General Public License for more details.
11
 * This program is distributed in the hope that it will be useful, but WITHOUT
12
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13
 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
14
 * details.
15 15
 *
16
 * You should have received a copy of the GNU General Public License
17
 * along with this program; if not, write to the Free Software
18
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19
 * MA  02110-1301, USA.
16
 * You should have received a copy of the GNU General Public License along with
17
 * this program; if not, write to the Free Software Foundation, Inc., 51
18
 * Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 19
 *
21
 * For any additional information, do not hesitate to contact us
22
 * at info AT gvsig.com, or visit our website www.gvsig.com.
20
 * For any additional information, do not hesitate to contact us at info AT
21
 * gvsig.com, or visit our website www.gvsig.com.
23 22
 */
24 23
package org.gvsig.coreplugin.preferences.general;
25 24

  
26 25
import java.awt.BorderLayout;
27
import java.awt.event.ActionEvent;
28
import java.awt.event.ActionListener;
29
import java.io.File;
30 26
import java.util.prefs.Preferences;
31 27

  
32 28
import javax.swing.ComboBoxModel;
......
35 31
import javax.swing.event.ListDataListener;
36 32

  
37 33
import org.gvsig.andami.IconThemeHelper;
38
import org.gvsig.andami.PluginsLocator;
39
import org.gvsig.andami.PluginsManager;
40 34
import org.gvsig.andami.preferences.AbstractPreferencePage;
41 35
import org.gvsig.andami.preferences.StoreException;
42 36
import org.gvsig.i18n.Messages;
......
48 42

  
49 43
public class IconThemePage extends AbstractPreferencePage {
50 44

  
51
	/**
52
	 * 
53
	 */
54
	private static final long serialVersionUID = 4369071892027860769L;
45
    /**
46
     *
47
     */
48
    private static final long serialVersionUID = 4369071892027860769L;
55 49

  
56
	private static Logger logger = LoggerFactory.getLogger(IconThemePage.class);
57
	
58
	private String id;
59
	private boolean changed = false;
60
	private IconThemePageLayout panel = null;
50
    private static final Logger logger = LoggerFactory.getLogger(IconThemePage.class);
61 51

  
62
	public IconThemePage() {
63
		super();
64
		initialize();
65
		id = this.getClass().getName();
66
		setParentID(GeneralPage.class.getName());
67
	}
52
    private final String id;
53
    private boolean changed = false;
54
    private IconThemePageLayout panel = null;
55
    private ImageIcon icon = null;
68 56

  
69
	public String getID() {
70
		return id;
71
	}
57
    public IconThemePage() {
58
        super();
59
        initialize();
60
        id = this.getClass().getName();
61
        setParentID(GeneralPage.class.getName());
62
    }
72 63

  
73
	public String getTitle() {
74
		return Messages.getText("_Icon_theme");
75
	}
64
    @Override
65
    public String getID() {
66
        return id;
67
    }
76 68

  
77
	public JPanel getPanel() {
78
		return this;
79
	}
69
    @Override
70
    public String getTitle() {
71
        return Messages.getText("_Icon_theme");
72
    }
80 73

  
81
	public void initializeValues() {
82
	}
74
    @Override
75
    public JPanel getPanel() {
76
        return this;
77
    }
83 78

  
84
	public void storeValues() throws StoreException {
85
		IconTheme iconTheme = (IconTheme) panel.combo_selection.getSelectedItem();
86
		if(iconTheme != null && iconTheme != iconTheme.getDefault() ) {
87
			Preferences prefs = Preferences.userRoot().node("gvsig.icontheme");
88
			prefs.put("default-theme", iconTheme.getID());
89
		}
90
	}
79
    @Override
80
    public void initializeValues() {
81
    }
91 82

  
92
	public void initializeDefaults() {
83
    @Override
84
    public void storeValues() throws StoreException {
85
        IconTheme iconTheme = (IconTheme) panel.combo_selection.getSelectedItem();
86
        if (iconTheme != null && iconTheme != iconTheme.getDefault()) {
87
            Preferences prefs = Preferences.userRoot().node("gvsig.icontheme");
88
            prefs.put("default-theme", iconTheme.getID());
89
        }
90
    }
93 91

  
94
	}
92
    @Override
93
    public void initializeDefaults() {
95 94

  
96
	private ImageIcon icon = null;
97
	public ImageIcon getIcon() {
98
		if (icon == null) {
99
			icon = IconThemeHelper.getImageIcon("edit-setup-icontheme");
100
		}
101
		return icon;
102
	}
95
    }
103 96

  
104
	public boolean isValueChanged() {
105
		if( panel.combo_selection.getSelectedIndex()>=0 ) {
106
			return true;
107
		}
108
		return changed;
109
	}
97
    @Override
98
    public ImageIcon getIcon() {
99
        if (icon == null) {
100
            icon = IconThemeHelper.getImageIcon("edit-setup-icontheme");
101
        }
102
        return icon;
103
    }
110 104

  
111
	public void setChangesApplied() {
112
		changed = false;
113
	}
105
    @Override
106
    public boolean isValueChanged() {
107
        if (panel.combo_selection.getSelectedIndex() >= 0) {
108
            return true;
109
        }
110
        return changed;
111
    }
114 112

  
115
	private void initialize() {
116
		final IconThemeManager iconManager = ToolsSwingLocator.getIconThemeManager();
117
		this.setLayout(new BorderLayout());
118
		
119
		this.panel = new IconThemePageLayout();
113
    @Override
114
    public void setChangesApplied() {
115
        changed = false;
116
    }
120 117

  
121
		panel.combo_selection.setModel(new ComboBoxModel() {
122
			IconTheme selected = null;
123
			public void removeListDataListener(ListDataListener arg0) {
124
				// Do nothing
125
			}
126
			public int getSize() {
127
				return iconManager.getCount();
128
			}
129
			public Object getElementAt(int arg0) {
130
				return iconManager.get(arg0);
131
			}
132
			public void addListDataListener(ListDataListener arg0) {
133
				// Do nothing
134
			}
135
			public void setSelectedItem(Object arg0) {
136
				this.selected = (IconTheme) arg0;
137
			}
138
			public Object getSelectedItem() {
139
				return this.selected;
140
			}
141
		});
142
		
143
		panel.button_export.addActionListener(new ActionListener() {
144
			public void actionPerformed(ActionEvent arg0) {
145
				createDefaultIconTheme();
146
			}
147
		});
148
		
149
		// Traducir las etiquetas del panel
150
		panel.label_title.setText(translate(panel.label_title.getText()));
151
		panel.label_selection.setText(translate(panel.label_selection.getText()));
152
		panel.button_export.setText(translate(panel.button_export.getText()));
153
		
154
		this.add(panel, BorderLayout.CENTER);
155
	}
156
	
157
	private String translate(String s) {
158
		return Messages.getText(s);
159
	}
160
	
161
	private void createDefaultIconTheme() {
162
		PluginsManager pluginsManager = PluginsLocator.getManager();
163
		IconThemeManager iconManager = ToolsSwingLocator.getIconThemeManager();
164
		
165
		File f = new File(pluginsManager.getApplicationHomeFolder(),"icon-theme");
166
		if( !f.exists() ) {
167
			f.mkdir();
168
		}
169
		IconTheme theme = iconManager.getDefault();
170
		File f2 = new File(f,theme.getID()) ;
171
		if( !f2.exists() ) {
172
			logger.info("Creating default icon theme in "+f.getAbsolutePath());
173
			theme.export(f);
174
		}
175
	}
176
} 
118
    private void initialize() {
119
        final IconThemeManager iconManager = ToolsSwingLocator.getIconThemeManager();
120
        this.setLayout(new BorderLayout());
177 121

  
122
        this.panel = new IconThemePageLayout();
123

  
124
        panel.combo_selection.setModel(new ComboBoxModel() {
125
            IconTheme selected = null;
126

  
127
            @Override
128
            public void removeListDataListener(ListDataListener arg0) {
129
                // Do nothing
130
            }
131

  
132
            @Override
133
            public int getSize() {
134
                return iconManager.getCount();
135
            }
136

  
137
            @Override
138
            public Object getElementAt(int arg0) {
139
                return iconManager.get(arg0);
140
            }
141

  
142
            @Override
143
            public void addListDataListener(ListDataListener arg0) {
144
                // Do nothing
145
            }
146

  
147
            @Override
148
            public void setSelectedItem(Object arg0) {
149
                this.selected = (IconTheme) arg0;
150
            }
151

  
152
            @Override
153
            public Object getSelectedItem() {
154
                return this.selected;
155
            }
156
        });
157

  
158
        // Traducir las etiquetas del panel
159
        panel.label_title.setText(translate(panel.label_title.getText()));
160
        panel.label_selection.setText(translate(panel.label_selection.getText()));
161

  
162
        this.add(panel, BorderLayout.CENTER);
163
    }
164

  
165
    private String translate(String s) {
166
        return Messages.getText(s);
167
    }
168

  
169
//    private void createDefaultIconTheme() {
170
//        PluginsManager pluginsManager = PluginsLocator.getManager();
171
//        IconThemeManager iconManager = ToolsSwingLocator.getIconThemeManager();
172
//
173
//        File f = new File(pluginsManager.getApplicationHomeFolder(), "icon-theme");
174
//        if (!f.exists()) {
175
//            f.mkdir();
176
//        }
177
//        IconTheme theme = iconManager.getDefault();
178
//        File f2 = new File(f, theme.getID());
179
//        if (!f2.exists()) {
180
//            logger.info("Creating default icon theme in " + f.getAbsolutePath());
181
//            theme.export(f);
182
//        }
183
//    }
184
}

Also available in: Unified diff