Revision 6575

View differences:

trunk/libraries/libCorePlugin/src/com/iver/core/preferences/general/ExtensionPage.java
2 2

  
3 3
import javax.swing.ImageIcon;
4 4
import javax.swing.JCheckBox;
5
import javax.swing.JOptionPane;
5 6
import javax.swing.JPanel;
6 7

  
7 8
import com.iver.andami.plugins.config.generate.Extension;
8 9
import com.iver.andami.plugins.config.generate.PluginConfig;
9 10
import com.iver.andami.preferences.AbstractPreferencePage;
10 11
import java.awt.BorderLayout;
12
import java.awt.Component;
13

  
11 14
import javax.swing.JScrollPane;
12 15
import javax.swing.JTextArea;
13 16
import java.awt.Dimension;
......
40 43
	private JLabel jLabel = null;
41 44
	private JCheckBox chbActivar = null;
42 45
	private ImageIcon icon;
46
	private boolean chkSelected;
47
	private int txtPriority;
43 48

  
44 49
	/**
45 50
	 * This is the default constructor
......
62 67
		this.setSize(451, 234);
63 68
		this.add(getJPanel(), java.awt.BorderLayout.CENTER);
64 69
		this.add(getJPanel1(), java.awt.BorderLayout.SOUTH);
70
		getChbActivar().setSelected(((Extension) Launcher.getExtension(extension.getClassName())).getActive());
71
		getJTextField().setText(String.valueOf(extension.getPriority()));
72
		getJTextArea().setText(format(((Extension) Launcher.getExtension(extension.getClassName())).getDescription(),40));
73
		chkSelected = getChbActivar().isSelected();
74
		txtPriority = extension.getPriority();
75

  
65 76
	}
66 77

  
67 78
	public String getID() {
......
73 84
	}
74 85

  
75 86
	public JPanel getPanel() {
76
		getChbActivar().setSelected(((Extension) Launcher.getExtension(extension.getClassName())).getActive());
77
		getJTextField().setText(String.valueOf(extension.getPriority()));
78
		getJTextArea().setText(format(((Extension) Launcher.getExtension(extension.getClassName())).getDescription(),40));
79 87
		return this;
80 88
	}
81 89

  
82 90

  
83 91

  
84 92
	public void initializeValues() {
85
		// TODO Auto-generated method stub
86 93

  
87 94
	}
88 95

  
89 96
	public boolean storeValues() {
90
//		Se escribe el config de los plugins
97
		int pri;
98
		try {
99
			pri = Integer.parseInt(getJTextField().getText());
100
		} catch (Exception e){
101
			JOptionPane.showMessageDialog((Component)PluginServices.getMainFrame(), PluginServices.getText(this, "invalid_priority_value"));
102
			return false;
103
		}
104
		extension.setActive(chbActivar.isSelected());
105
		extension.setPriority(pri);
106
		// Se escribe el config de los plugins
91 107
		marshalPlugins();
92 108

  
93 109
		return true;
......
160 176
		return icon;
161 177
	}
162 178

  
179
	public void cancelAction() {
180
		getChbActivar().setSelected(chkSelected);
181
		getJTextField().setText(String.valueOf(txtPriority));
182

  
183
	}
184

  
163 185
	/**
164 186
	 * This method initializes jPanel
165 187
	 *
......
217 239
			chbActivar = new JCheckBox();
218 240
			chbActivar.setSelected(true);
219 241
			chbActivar.setText(PluginServices.getText(this, "extension_activada"));
220
			chbActivar.addActionListener(new java.awt.event.ActionListener() {
221
					public void actionPerformed(java.awt.event.ActionEvent e) {
222
						extension.setActive(chbActivar.isSelected());
223
					}
224
				});
225 242
		}
226 243

  
227 244
		return chbActivar;
......
279 296
        return theMessage;
280 297
    }
281 298

  
299

  
300

  
282 301
}  //  @jve:decl-index=0:visual-constraint="10,10"
trunk/libraries/libCorePlugin/src/com/iver/core/preferences/general/GeneralPage.java
105 105
	}
106 106

  
107 107
	public void initializeValues() {
108

  
108
		// TODO
109 109
	}
110 110

  
111 111
	public boolean storeValues() {
......
113 113
	}
114 114

  
115 115
	public void initializeDefaults() {
116
		// TODO
117
	}
116 118

  
119
	public void cancelAction() {
120
		// TODO
117 121
	}
118 122

  
119 123
	public ImageIcon getIcon() {
trunk/libraries/libCorePlugin/src/com/iver/core/preferences/general/DirExtensionsPage.java
25 25
	private JPanel jPanel = null;
26 26
	private JTextField jTextField = null;
27 27
	private JButton jButton = null;
28
	private String pluginDirectory;
28 29
	public DirExtensionsPage() {
29 30
		super();
30 31
		initialize();
......
55 56

  
56 57

  
57 58
	public void initializeValues() {
58

  
59
		pluginDirectory = Launcher.getAndamiConfig().getPluginsDirectory();
60
		getJTextField().setText(pluginDirectory);
59 61
	}
60 62

  
61 63
	public boolean storeValues() {
62 64
//		Se escribe el directorio de los plugins
63
		Launcher.getAndamiConfig().setPluginsDirectory(getJTextField().getText());
65
		pluginDirectory = getJTextField().getText();
64 66

  
67
		Launcher.getAndamiConfig().setPluginsDirectory(pluginDirectory);
65 68
		return true;
66 69
	}
67 70

  
......
69 72

  
70 73
	}
71 74

  
75
	public void cancelAction() {
76
		getJTextField().setText(pluginDirectory);
77
	}
78

  
72 79
	public ImageIcon getIcon() {
73 80
		return icon;
74 81
	}
......
122 129
		if (jTextField == null) {
123 130
			jTextField = new JTextField();
124 131
			jTextField.setPreferredSize(new Dimension(200, 20));
125
			jTextField.setText(Launcher.getAndamiConfig().getPluginsDirectory());
132
			jTextField.setText(pluginDirectory);
126 133
		}
127 134
		return jTextField;
128 135
	}
......
155 162
		}
156 163
		return jButton;
157 164
	}
165

  
158 166
}  //  @jve:decl-index=0:visual-constraint="10,10"
159 167

  
trunk/libraries/libCorePlugin/src/com/iver/core/preferences/general/AppearancePage.java
43 43
*
44 44
* $Id$
45 45
* $Log$
46
* Revision 1.1  2006-06-29 16:15:06  jaume
46
* Revision 1.2  2006-07-31 10:02:31  jaume
47
* *** empty log message ***
48
*
49
* Revision 1.1  2006/06/29 16:15:06  jaume
47 50
* Appearance now configurable
48 51
*
49 52
*
......
69 72
    private String id;
70 73
    private ImageIcon icon;
71 74
    private String lookAndFeel;
75
	private int lookAndFeelIndex;
72 76

  
73 77
    public AppearancePage() {
74 78
        super();
75 79
        id = this.getClass().getName();
76 80
        icon = new ImageIcon(this.getClass().getClassLoader().getResource("images/gnome-settings-theme.png"));
77 81
        setParentID(GeneralPage.id);
82
        addComponent(PluginServices.getText(this, "options.general.select_theme"), getLookAndFeelComboBox());
78 83
    }
79 84

  
80 85
    public String getID() {
......
96 101
    	if (lookAndFeel == null) {
97 102
    		lookAndFeel = Launcher.getDefaultLookAndFeel();
98 103
    	}
99
    	addComponent(PluginServices.getText(this, "options.general.select_theme"), getLookAndFeelComboBox());
104

  
100 105
    }
101 106

  
102 107

  
......
117 122
        }
118 123
    }
119 124

  
125
    public void cancelAction() {
126
    	getLookAndFeelComboBox().setSelectedIndex(lookAndFeelIndex);
127
    }
128

  
120 129
    public ImageIcon getIcon() {
121 130
        return icon;
122 131
    }
......
134 143
            }
135 144
            lookAndFeelCombo = new JComboBox((LF[]) a.toArray(new LF[a.size()]));
136 145

  
137
            if (selectedLookAndFeel!=null)
146
            if (selectedLookAndFeel!=null) {
138 147
                lookAndFeelCombo.setSelectedItem(selectedLookAndFeel);
148
                lookAndFeelIndex = lookAndFeelCombo.getSelectedIndex();
149
            }
139 150

  
140 151
            lookAndFeelCombo.addActionListener(new ActionListener() {
141

  
142 152
                public void actionPerformed(ActionEvent e) {
143 153
                    lookAndFeel = ((LF) lookAndFeelCombo.getSelectedItem()).getClassName();
144 154
                }
145

  
146 155
            });
147 156
        }
148 157
        return lookAndFeelCombo;
trunk/libraries/libCorePlugin/src/com/iver/core/preferences/general/ExtensionsPage.java
69 69
		return icon;
70 70
	}
71 71

  
72
	public void cancelAction() {
73
		// TODO Auto-generated method stub
74

  
75
	}
76

  
72 77
}
trunk/libraries/libCorePlugin/src/com/iver/core/preferences/general/LanguagePage.java
66 66

  
67 67
	private JComboBox cmbIdioma = null;
68 68

  
69
	private int langIndex;
70

  
69 71
	public LanguagePage() {
70 72
		super();
71 73
		initialize();
......
80 82
		this.setSize(new java.awt.Dimension(386, 177));
81 83
		this.add(getPN(), java.awt.BorderLayout.NORTH);
82 84
		this.add(getPC(), java.awt.BorderLayout.CENTER);
85
		langIndex = getJComboBox().getSelectedIndex();
83 86
	}
84 87

  
85 88
	public String getID() {
......
118 121
		Launcher.getAndamiConfig().setLocaleLanguage(sel.locale.getLanguage());
119 122
		Launcher.getAndamiConfig().setLocaleCountry(sel.locale.getCountry());
120 123
		Launcher.getAndamiConfig().setLocaleVariant(sel.locale.getVariant());
121

  
124
		langIndex = getJComboBox().getSelectedIndex();
122 125
		return true;
123 126
	}
124 127

  
......
130 133
		return icon;
131 134
	}
132 135

  
136
	public void cancelAction() {
137
		getJComboBox().setSelectedIndex(langIndex);
138
		storeValues();
139
	}
140

  
133 141
	/**
134 142
	 * This method initializes pN
135 143
	 *
trunk/libraries/libCorePlugin/src/com/iver/core/preferences/network/FirewallPage.java
43 43
*
44 44
* $Id$
45 45
* $Log$
46
* Revision 1.2  2006-06-13 07:43:08  fjp
46
* Revision 1.3  2006-07-31 10:02:31  jaume
47
* *** empty log message ***
48
*
49
* Revision 1.2  2006/06/13 07:43:08  fjp
47 50
* Ajustes sobre los cuadros de dialogos de preferencias
48 51
*
49 52
* Revision 1.1  2006/06/12 16:04:28  caballero
......
126 129
		id = this.getClass().getName();
127 130
		icon = new ImageIcon(this.getClass().getClassLoader().getResource("images/shield.png"));
128 131
		setParentID(NetworkPage.id);
129
	}
130

  
131
	public void initializeValues() {
132
		// checkbox
132
//		 checkbox
133 133
		addComponent(httpEnabled = new JCheckBox(PluginServices.getText(this,
134 134
			"options.firewall.http.enabled")));
135 135
		// proxy host
......
148 148
		addComponent(PluginServices.getText(this, "options.firewall.http.nonProxy") + ":",
149 149
			httpNonProxy = new JTextField("", 15));
150 150

  
151
//		 checkbox
152
		addComponent(socksEnabled = new JCheckBox(PluginServices.getText(this,
153
			"options.firewall.socks.enabled")));
154
		// proxy host
155
		addComponent(PluginServices.getText(this, "options.firewall.socks.host") + ":",
156
			socksHost = new JTextField("", 15));
157
		// proxy port
158
		addComponent(PluginServices.getText(this, "options.firewall.socks.port") + ":",
159
			socksPort = new JTextField("", 15));
160

  
161
	}
162

  
163
	public void initializeValues() {
164

  
151 165
		boolean enabled = prefs.getBoolean("firewall.http.enabled", false);
152 166
		httpEnabled.setSelected(enabled);
153 167
		httpHost.setEnabled(enabled);
......
164 178

  
165 179
		httpEnabled.addActionListener(new ActionHandler());
166 180

  
167
		// checkbox
168
		addComponent(socksEnabled = new JCheckBox(PluginServices.getText(this,
169
			"options.firewall.socks.enabled")));
170
		// proxy host
171
		addComponent(PluginServices.getText(this, "options.firewall.socks.host") + ":",
172
			socksHost = new JTextField("", 15));
173
		// proxy port
174
		addComponent(PluginServices.getText(this, "options.firewall.socks.port") + ":",
175
			socksPort = new JTextField("", 15));
176 181

  
177 182
		enabled = prefs.getBoolean("firewall.socks.enabled", false);
178 183
		socksEnabled.setSelected(enabled);
......
266 271
		return true;
267 272
	}
268 273

  
274
	public void cancelAction() {
275
		initializeValues();
276
	}
277

  
269 278
	public void initializeDefaults() {
270 279
		httpEnabled.setSelected(false);
271 280
		httpHost.setText("");
......
279 288

  
280 289
	}
281 290

  
282
	class ActionHandler implements ActionListener {
291
	private class ActionHandler implements ActionListener {
283 292
		public void actionPerformed(ActionEvent evt) {
284 293
			httpHost.setEnabled(httpEnabled.isSelected());
285 294
			httpPort.setEnabled(httpEnabled.isSelected());
......
294 303
	public ImageIcon getIcon() {
295 304
		return icon;
296 305
	}
306

  
307

  
297 308
}
trunk/libraries/libCorePlugin/src/com/iver/core/preferences/network/NetworkPage.java
43 43
*
44 44
* $Id$
45 45
* $Log$
46
* Revision 1.3  2006-07-03 10:46:01  jaume
46
* Revision 1.4  2006-07-31 10:02:31  jaume
47 47
* *** empty log message ***
48 48
*
49
* Revision 1.3  2006/07/03 10:46:01  jaume
50
* *** empty log message ***
51
*
49 52
* Revision 1.2  2006/06/13 07:43:08  fjp
50 53
* Ajustes sobre los cuadros de dialogos de preferencias
51 54
*
......
107 110
		super();
108 111
		id = this.getClass().getName();
109 112
		icon = new ImageIcon(this.getClass().getClassLoader().getResource("images/network.png"));
113
		lblNetworkStatus = new JLabel();
114
		lblNetworkStatus.setFont(new java.awt.Font("Arial", java.awt.Font.BOLD, 12));
115
		lblNetworkStatus.setText(PluginServices.getText(this, "optinos.network.click_to_test_connection"));
116

  
117
		JPanel aux = new JPanel();
118
		aux.add(lblNetworkStatus);
119
		aux.add(getBtnCheckConnection());
120
		addComponent(PluginServices.getText(this, "options.network.status") + ":", aux	);
110 121
	}
111 122

  
112 123
	private JToolBarButton getBtnCheckConnection() {
......
163 174

  
164 175

  
165 176
	public void initializeValues() {
166
		lblNetworkStatus = new JLabel();
167
		lblNetworkStatus.setFont(new java.awt.Font("Arial", java.awt.Font.BOLD, 12));
168
		lblNetworkStatus.setText(PluginServices.getText(this, "optinos.network.click_to_test_connection"));
169
		JPanel aux = new JPanel();
170
		aux.add(lblNetworkStatus);
171
		aux.add(getBtnCheckConnection());
172
		addComponent(PluginServices.getText(this, "options.network.status") + ":", aux	);
177

  
178

  
173 179
	}
174 180

  
175 181
	public boolean storeValues() {
......
177 183
	}
178 184

  
179 185
	public void initializeDefaults() {
186
		// nothing
187
	}
180 188

  
189
	public void cancelAction() {
190
		// nothing
181 191
	}
182 192

  
183 193
	class ActionHandler implements ActionListener {
......
190 200
		return icon;
191 201
	}
192 202

  
203

  
193 204
}
trunk/frameworks/_fwAndami/src/com/iver/andami/preferences/GenericDlgPreferences.java
151 151

  
152 152

  
153 153
		treeModel = new DefaultTreeModel(root);
154
		
154

  
155 155
		refreshTree();
156 156

  
157 157
	}
158
	
158

  
159 159
	private void refreshTree() {
160
		ExtensionPoints extensionPoints = 
160
		ExtensionPoints extensionPoints =
161 161
			ExtensionPointsSingleton.getInstance();
162
		
162

  
163 163
		ExtensionPoint extensionPoint =(ExtensionPoint)extensionPoints.get("AplicationPreferences");
164
		
164

  
165 165
		Iterator iterator = extensionPoint.keySet().iterator();
166 166
		while (iterator.hasNext()) {
167 167
			try {
......
179 179
			}
180 180
		}
181 181
	}
182
	
183
	
182

  
183

  
184 184
	/**
185 185
	 * It is very common to be confused with this method. But
186 186
	 * the one you are looking for is addPreferencePage(IPreference)
......
395 395
			jButtonCancel = new JButton();
396 396
			jButtonCancel.setText(PluginServices.getText(this, "cancelar"));
397 397
			jButtonCancel.addActionListener(new java.awt.event.ActionListener() {
398
				public void actionPerformed(java.awt.event.ActionEvent e) {					
398
				public void actionPerformed(java.awt.event.ActionEvent e) {
399
					if (activePreference!=null)
400
						activePreference.cancelAction();
399 401
					closeView();
400 402
				}
401 403
			});
trunk/frameworks/_fwAndami/src/com/iver/andami/preferences/IPreference.java
47 47
 * In addition to this interface, an abstract class is supplied to ease the addition
48 48
 * of new pages
49 49
 * @see com.iver.andami.preferences.AbstractPreferencePage
50
 * 
50
 *
51 51
 * @author jaume dominguez faus - jaume.dominguez@iver.es
52 52
 *
53 53
 */
54 54
public interface IPreference {
55
	
55

  
56 56
	/**
57 57
	 * Returns an identifier for this preferences page that is used to reference
58 58
	 * it inside the Map.
59 59
	 * @return String, you'd typically use any kind of <code>this.getClass().getName();</code>
60 60
	 */
61 61
	String getID();
62
	
62

  
63 63
	/**
64 64
	 * Returns an string containing the title of the preferences page. This string
65 65
	 * will be shown whether in the tree entry or in the page header.
66 66
	 * @return String, the title of the page
67 67
	 */
68 68
	String getTitle();
69
	
69

  
70 70
	/**
71 71
	 * The page must be contained in a JPanel and whatever to be shown will be returned
72 72
	 * by this function.<br>
......
79 79
	 * @return JPanel holding the contents to be shown in the page.
80 80
	 */
81 81
	JPanel getPanel();
82
	
82

  
83 83
	/**
84 84
	 * Returns the ID of the parent of this layer. If this method returns null, which means
85 85
	 * that this preferences page has no parent, this is new entry in the preferences
86 86
	 * tree, otherwise this preferences page will be hanging on the page with the ID
87 87
	 * returned by this.
88
	 * @return 
88
	 * @return
89 89
	 */
90 90
	String getParentID();
91
	
91

  
92 92
	/**
93 93
	 * Initializes the components of this preferences page to the last settings.
94 94
	 */
95 95
	void initializeValues();
96
	
96

  
97 97
	/**
98 98
	 * Saves the new settings
99 99
	 * @return <b>true</b> if the values were correctly stored, <b>false</b> otherwise.
100 100
	 */
101 101
	boolean storeValues();
102
	
102

  
103 103
	/**
104 104
	 * Restores the default values of this preferences page's settings.
105 105
	 */
106 106
	void initializeDefaults();
107
	
107

  
108 108
	/**
109 109
	 * Returns the image that will be shown in the header of this preferences page
110 110
	 * @return
111 111
	 */
112 112
	ImageIcon getIcon();
113 113

  
114
	/**
115
	 * invoked when cancel button is clicked.
116
	 */
117
	void cancelAction();
114 118
}
115 119

  
116 120

  
trunk/frameworks/_fwAndami/src/com/iver/andami/preferences/DlgPreferences.java
47 47

  
48 48
	public static DlgPreferences getInstance() {
49 49
		/*
50
		if (singletonInstance == null)
51
			singletonInstance = new DlgPreferences();
52
		return singletonInstance;
53
		*/
50
		 * if (singletonInstance == null) singletonInstance = new
51
		 * DlgPreferences(); return singletonInstance;
52
		 */
54 53
		return new DlgPreferences();
55 54
	}
56 55

  
......
58 57
		super();
59 58
	}
60 59

  
61

  
62 60
	public Object getViewModel() {
63 61
		return this.getClass();
64 62
	}
65 63

  
66
}  //  @jve:decl-index=0:visual-constraint="10,10"
64
} // @jve:decl-index=0:visual-constraint="10,10"

Also available in: Unified diff