Revision 7143

View differences:

branches/v10/libraries/libCorePlugin/src/com/iver/core/preferences/general/FolderingPage.java
1
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
2
 *
3
 * Copyright (C) 2005 IVER T.I. and Generalitat Valenciana.
4
 *
5
 * This program is free software; you can redistribute it and/or
6
 * modify it under the terms of the GNU General Public License
7
 * as published by the Free Software Foundation; either version 2
8
 * of the License, or (at your option) any later version.
9
 *
10
 * This program is distributed in the hope that it will be useful,
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 * GNU General Public License for more details.
14
 *
15
 * You should have received a copy of the GNU General Public License
16
 * along with this program; if not, write to the Free Software
17
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
18
 *
19
 * For more information, contact:
20
 *
21
 *  Generalitat Valenciana
22
 *   Conselleria d'Infraestructures i Transport
23
 *   Av. Blasco Ib??ez, 50
24
 *   46010 VALENCIA
25
 *   SPAIN
26
 *
27
 *      +34 963862235
28
 *   gvsig@gva.es
29
 *      www.gvsig.gva.es
30
 *
31
 *    or
32
 *
33
 *   IVER T.I. S.A
34
 *   Salamanca 50
35
 *   46005 Valencia
36
 *   Spain
37
 *
38
 *   +34 963163400
39
 *   dac@iver.es
40
 */
41

  
42
/* CVS MESSAGES:
43
*
44
* $Id$
45
* $Log$
46
* Revision 1.1.2.1  2006-09-08 11:56:24  jaume
47
* *** empty log message ***
48
*
49
*
50
*/
51
package com.iver.core.preferences.general;
52

  
53
import java.awt.event.ActionEvent;
54
import java.awt.event.ActionListener;
55
import java.io.File;
56
import java.util.prefs.Preferences;
57

  
58
import javax.swing.ImageIcon;
59
import javax.swing.JFileChooser;
60
import javax.swing.JLabel;
61
import javax.swing.JPanel;
62
import javax.swing.JTextField;
63
import javax.swing.filechooser.FileFilter;
64

  
65
import org.gvsig.gui.beans.swing.JButton;
66

  
67
import com.iver.andami.PluginServices;
68
import com.iver.andami.preferences.AbstractPreferencePage;
69
import com.iver.andami.preferences.StoreException;
70
import com.iver.utiles.XMLEntity;
71
/**
72
 *
73
 * In the FolderingPage the user sets which folder paths should be used by
74
 * default.
75
 *
76
 * @author jaume dominguez faus - jaume.dominguez@iver.es
77
 *
78
 */
79
public class FolderingPage extends AbstractPreferencePage{
80
	private static Preferences prefs = Preferences.userRoot().node( "gvsig.foldering" );
81

  
82
	private static final String DATA_FOLDER_PROPERTY_NAME = "DataFolder";
83
	private static final String TEMPLATES_FOLDER_PROPERTY_NAME = "TemplatesFolder";
84
	private JTextField txtDataFolder;
85
	private JButton btnSelectDataFolder;
86
	private JTextField txtTemplatesFolder;
87
	private JButton btnSelectTemplatesFolder;
88
	private ImageIcon icon;
89
	private ActionListener btnFileChooserAction;
90
	public FolderingPage() {
91
		super();
92

  
93
		icon = new ImageIcon(this.getClass().getClassLoader().getResource("images/folder.png"));
94

  
95
		btnFileChooserAction = new ActionListener() {
96
			public void actionPerformed(ActionEvent e) {
97
				String path;
98
				if (e.getSource().equals(btnSelectDataFolder)) {
99
					path = txtDataFolder.getText();
100
				} else {
101
					path = txtTemplatesFolder.getText();
102
				}
103

  
104
				// The file filter for the JFileChooser
105
				FileFilter def =  new FileFilter(){
106
					public boolean accept(File f) {
107
						return (f.isDirectory());
108
					}
109

  
110
					public String getDescription() {
111
						return null;
112
					}
113
				};
114

  
115
				File file = new File(path);
116
				JFileChooser fc;
117
				if (file.exists()) {
118
					fc = new JFileChooser(file);
119
				} else {
120
					fc = new JFileChooser();
121
				}
122

  
123
				fc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
124
                fc.setMultiSelectionEnabled(false);
125
                fc.setAcceptAllFileFilterUsed(false);
126
                fc.addChoosableFileFilter(def);
127
                int result = fc.showOpenDialog(FolderingPage.this);
128

  
129
                if (result == JFileChooser.APPROVE_OPTION && (file = fc.getSelectedFile()) != null) {
130
                	if (e.getSource().equals(btnSelectDataFolder)) {
131
    					txtDataFolder.setText(file.getAbsolutePath());
132
    				} else {
133
    					txtTemplatesFolder.setText(file.getAbsolutePath());
134
    				}
135
                }
136
			}
137

  
138
		};
139
		btnSelectDataFolder = new JButton(PluginServices.getText(this, "browse"));
140
		btnSelectDataFolder.addActionListener(btnFileChooserAction);
141
		btnSelectTemplatesFolder = new JButton(PluginServices.getText(this, "browse"));
142
		btnSelectTemplatesFolder.addActionListener(btnFileChooserAction);
143

  
144

  
145
		JLabel lblDataFolder = new JLabel("<html><b>" +
146
				PluginServices.
147
				getText(this, "preferences.foldering.data_folder") +
148
		"</b></html>");
149
		addComponent(lblDataFolder);
150
		addComponent(txtDataFolder = new JTextField(40), btnSelectDataFolder);
151
		addComponent(new JLabel(" "));
152
		JLabel lblTemplatesFolder = new JLabel("<html><b>" +
153
				PluginServices.
154
				getText(this, "preferences.foldering.template_folder") +
155
		"</b></html>");
156
		addComponent(lblTemplatesFolder);
157
		addComponent(txtTemplatesFolder = new JTextField(40), btnSelectTemplatesFolder);
158

  
159
		PluginServices ps = PluginServices.getPluginServices(this);
160
		XMLEntity xml = ps.getPersistentXML();
161

  
162
		if (xml.contains(DATA_FOLDER_PROPERTY_NAME)) {
163
			prefs.put(DATA_FOLDER_PROPERTY_NAME, xml.getStringProperty(DATA_FOLDER_PROPERTY_NAME));
164
		}
165

  
166
		if (xml.contains(TEMPLATES_FOLDER_PROPERTY_NAME)) {
167
			prefs.put(TEMPLATES_FOLDER_PROPERTY_NAME, xml.getStringProperty(TEMPLATES_FOLDER_PROPERTY_NAME));
168
		}
169

  
170
	}
171

  
172
	public void storeValues() throws StoreException {
173
		File f;
174
		PluginServices ps = PluginServices.getPluginServices(this);
175
		XMLEntity xml = ps.getPersistentXML();
176

  
177
		// Data folder
178
		f = new File(txtDataFolder.getText());
179
		if (f.exists()) {
180
			final String propertyName = DATA_FOLDER_PROPERTY_NAME;
181
			if (xml.contains(propertyName)) {
182
				xml.remove(propertyName);
183
			}
184
			xml.putProperty(propertyName, f.getAbsolutePath());
185
			prefs.put(DATA_FOLDER_PROPERTY_NAME, f.getAbsolutePath());
186

  
187
		}
188

  
189
		// Data folder
190
		f = new File(txtTemplatesFolder.getText());
191
		if (f.exists()) {
192
			final String propertyName = TEMPLATES_FOLDER_PROPERTY_NAME;
193
			if (xml.contains(propertyName)) {
194
				xml.remove(propertyName);
195
			}
196
			xml.putProperty(propertyName, f.getAbsolutePath());
197
			prefs.put(TEMPLATES_FOLDER_PROPERTY_NAME, f.getAbsolutePath());
198

  
199
		}
200

  
201
	}
202

  
203
	public void setChangesApplied() {
204
		setChanged(false);
205
	}
206

  
207
	public String getID() {
208
		return this.getClass().getName();
209
	}
210

  
211
	public String getTitle() {
212
		return PluginServices.getText(this, "preferences.foldering.title");
213
	}
214

  
215
	public JPanel getPanel() {
216
		return this;
217
	}
218

  
219
	public void initializeValues() {
220
		PluginServices ps = PluginServices.getPluginServices(this);
221
		XMLEntity xml = ps.getPersistentXML();
222
		if (xml.contains(DATA_FOLDER_PROPERTY_NAME)) {
223
			txtDataFolder.setText(xml.getStringProperty(DATA_FOLDER_PROPERTY_NAME));
224
		}
225
		if (xml.contains(TEMPLATES_FOLDER_PROPERTY_NAME)) {
226
			txtTemplatesFolder.setText(xml.getStringProperty(TEMPLATES_FOLDER_PROPERTY_NAME));
227
		}
228

  
229
	}
230

  
231
	public void initializeDefaults() {
232
		txtDataFolder.setText("");
233
		txtTemplatesFolder.setText("");
234
	}
235

  
236
	public ImageIcon getIcon() {
237
		return icon;
238
	}
239

  
240
	public boolean isValueChanged() {
241
		return super.hasChanged();
242
	}
243

  
244
}
0 245

  
branches/v10/libraries/libCorePlugin/src/com/iver/core/preferences/general/AppearancePage.java
43 43
*
44 44
* $Id$
45 45
* $Log$
46
* Revision 1.7  2006-08-22 12:23:05  jaume
46
* Revision 1.7.4.1  2006-09-08 11:56:24  jaume
47
* *** empty log message ***
48
*
49
* Revision 1.7  2006/08/22 12:23:05  jaume
47 50
* improved perfomance when saving changes
48 51
*
49 52
* Revision 1.6  2006/08/22 07:37:17  jaume
......
84 87
import com.iver.andami.Launcher;
85 88
import com.iver.andami.PluginServices;
86 89
import com.iver.andami.preferences.AbstractPreferencePage;
87

  
90
/**
91
 * Appearance page. Where the user can choose Look&Feels and maybe some more stuff.
92
 *
93
 * @author jaume dominguez faus - jaume.dominguez@iver.es
94
 *
95
 */
88 96
public class AppearancePage extends AbstractPreferencePage{
89 97
    private JComboBox lookAndFeelCombo;
90 98
    private String id;
branches/v10/libraries/libCorePlugin/src/com/iver/core/preferences/network/NetworkPage.java
43 43
*
44 44
* $Id$
45 45
* $Log$
46
* Revision 1.7  2006-08-22 12:23:05  jaume
46
* Revision 1.7.4.1  2006-09-08 11:56:24  jaume
47
* *** empty log message ***
48
*
49
* Revision 1.7  2006/08/22 12:23:05  jaume
47 50
* improved perfomance when saving changes
48 51
*
49 52
* Revision 1.6  2006/08/22 07:37:17  jaume
......
123 126
		lblNetworkStatus.setText(PluginServices.getText(this, "optinos.network.click_to_test_connection"));
124 127

  
125 128
		JPanel aux = new JPanel();
126
		aux.add(lblNetworkStatus);
127 129
		aux.add(getBtnCheckConnection());
128
		addComponent(PluginServices.getText(this, "options.network.status") + ":", aux	);
130
		addComponent(PluginServices.getText(this, "options.network.status") + ":", lblNetworkStatus	);
131
		addComponent("", aux);
132

  
129 133
	}
130 134

  
131 135
	private JToolBarButton getBtnCheckConnection() {
branches/v10/libraries/libCorePlugin/src/com/iver/core/PreferencesExtension.java
16 16
import com.iver.core.preferences.general.DirExtensionsPage;
17 17
import com.iver.core.preferences.general.ExtensionPage;
18 18
import com.iver.core.preferences.general.ExtensionsPage;
19
import com.iver.core.preferences.general.FolderingPage;
19 20
import com.iver.core.preferences.general.GeneralPage;
20 21
import com.iver.core.preferences.general.LanguagePage;
21 22
import com.iver.core.preferences.network.FirewallPage;
......
51 52
	}
52 53

  
53 54
	private void initializeCoreExtensions() {
54
		//dlgPrefs.addPreferencePage(new GeneralPage());
55 55
		this.extensionPoints.add("AplicationPreferences","GeneralPage", new GeneralPage());
56

  
57
		//dlgPrefs.addPreferencePage(new NetworkPage());
58 56
		this.extensionPoints.add("AplicationPreferences","NetworkPage", new NetworkPage());
59

  
60
		//dlgPrefs.addPreferencePage(new FirewallPage());
61 57
		this.extensionPoints.add("AplicationPreferences","FirewallPage", new FirewallPage());
62

  
63
		//dlgPrefs.addPreferencePage(new DirExtensionsPage());
64 58
		this.extensionPoints.add("AplicationPreferences","DirExtensionsPage", new DirExtensionsPage());
65

  
66
		//dlgPrefs.addPreferencePage(new LanguagePage());
67 59
		this.extensionPoints.add("AplicationPreferences","LanguagePage", new LanguagePage());
68

  
69
		//dlgPrefs.addPreferencePage(new ExtensionsPage());
70 60
		this.extensionPoints.add("AplicationPreferences","ExtensionsPage", new ExtensionsPage());
71

  
72
		//dlgPrefs.addPreferencePage(new AppearancePage());
73 61
		this.extensionPoints.add("AplicationPreferences","AppearancePage", new AppearancePage());
62
		this.extensionPoints.add("AplicationPreferences","FolderingPage", new FolderingPage());
74 63

  
75 64
		//Falta los plugin
76 65
	}
branches/v10/applications/appgvSIG/src/com/iver/cit/gvsig/gui/FileOpenDialog.java
53 53
import java.util.HashSet;
54 54
import java.util.Iterator;
55 55
import java.util.TreeSet;
56
import java.util.prefs.Preferences;
56 57

  
57 58
import javax.swing.DefaultListModel;
58 59
import javax.swing.JFileChooser;
......
75 76
 * @author Vicente Caballero Navarro
76 77
 */
77 78
public class FileOpenDialog extends JPanel{
78
	// TODO LWS ?los m_Files ... ?tendr?an que ser GeoFiles (Projected y dem?s)?	
79
	// TODO LWS ?los m_Files ... ?tendr?an que ser GeoFiles (Projected y dem?s)?
79 80
	private static String lastPath = null;
80 81
	private static DriverFileFilter lastFileFilter = null;
81 82
    private ArrayList m_Files;
......
86 87
    private String title = PluginServices.getText(this,"Capas");
87 88

  
88 89
	private ProjChooserPanel jPanelProj = null;
89
	//private JLabel jLabel = null;
90
	//private JComboBox jCboProjections = null;
91 90
	private ListManagerSkin listManagerDemoSkin = null;
92 91
    private boolean proj;
92

  
93 93
    public FileOpenDialog(Class[] driverClasses) {
94 94
        init(driverClasses, true);
95 95
    }
......
134 134
        this.setLayout(new BorderLayout());
135 135
        this.setSize(514, 280);
136 136
        this.setLayout(null);
137
//        this.setBorder(javax.swing.BorderFactory.createBevelBorder(
138
  //              javax.swing.border.BevelBorder.RAISED));
139 137
        this.add(getJPanel2(), null);
140 138
    }
141 139

  
......
250 248
			        }
251 249
				}
252 250
			});
253
/*			jPanel = new JLabel();
254
			jPanel.setBounds(11, 214, 448, 37);
255
			jLabel.setText("Seleccione la proyecci?n:");
256
			jPanel.add(jLabel, null);
257
			jPanel.add(getJCboProjections(), null);*/
251

  
258 252
		}
259 253
		return jPanelProj;
260 254
	}
261
	/*
262
	 * This method initializes jComboBox
263
	 *
264
	 * @return javax.swing.JComboBox
265
	 * /
266
	private JComboBox getJCboProjections() {
267
		if (jCboProjections == null) {
268
			Iterator it = ProjectionPool.iterator();
269
			Vector vector = new Vector();
270
			int selected = -1;
271
			int i=0;
272
			while (it.hasNext())
273
			{
274
				IProjection auxP =(IProjection) it.next();
275
				if (auxP == FOpenDialog.getLastProjection())
276
						selected = i;
277
				vector.add(auxP.getAbrev());
278
				i++;
279
			}
280
			DefaultComboBoxModel cModel = new DefaultComboBoxModel(vector);
281
			cModel.setSelectedItem(vector.get(selected));
282
			jCboProjections = new JComboBox(cModel);
283
			jCboProjections.setPreferredSize(new java.awt.Dimension(124,19));
284
			jCboProjections.addActionListener(new java.awt.event.ActionListener() {
285
				public void actionPerformed(java.awt.event.ActionEvent e) {
286
					System.out.println("actionPerformed()"); // TODO Auto-generated Event stub actionPerformed()
287
					String strProj = (String) jCboProjections.getSelectedItem();
288
					FOpenDialog.setLastProjection(ProjectionPool.get(strProj));
289
				}
290
			});
291
		}
292
		return jCboProjections;
293
	}*/
294 255

  
295 256
	public class MyFile {
296 257
		private File f;
......
329 290
                            return dff1.driver.getName().compareTo(dff2.driver.getName());
330 291
                        }
331 292
                    });
293

  
294
				    if (lastPath == null) {
295
				    	Preferences prefs = Preferences.userRoot().node( "gvsig.foldering" );
296
				    	lastPath = prefs.get("DataFolder", null);
297
				    }
332 298
                    fileChooser = new JFileChooser(lastPath);
333 299
                    fileChooser.setMultiSelectionEnabled(true);
334 300
                    fileChooser.setAcceptAllFileFilterUsed(false);
......
408 374
                    }
409 375
                    else
410 376
                    	return new Object[0];
411

  
412
                    // DefaultListModel lstModel = new DefaultListModel();
413
/*
414
                    for (int iFile = 0; iFile < newFiles.length;
415
                            iFile++) {
416
                    	File theFile = newFiles[iFile];
417
                    	String absolutePath = theFile.getAbsolutePath();
418
                    	lastPath = theFile.getParent();
419
                    	// Miramos por si es un ecwp:
420
                    	int test = absolutePath.indexOf("ecwp:");
421
                    	if (test == -1)
422
                    		m_lstModel.addElement(absolutePath);
423
                    	else
424
                    		m_lstModel.addElement(absolutePath.substring(test));
425
                    }
426

  
427
                    getJListLayers().setModel(m_lstModel);*/
428

  
429 377
                }
430 378

  
431 379
				public Object getProperties(Object selected) {

Also available in: Unified diff