root / tags / v1_0_2_Build_901 / libraries / libCorePlugin / src / com / iver / core / preferences / general / DirExtensionsPage.java @ 10571
History | View | Annotate | Download (4.38 KB)
1 |
package com.iver.core.preferences.general; |
---|---|
2 |
|
3 |
import java.awt.BorderLayout; |
4 |
import java.awt.Component; |
5 |
import java.awt.Dimension; |
6 |
import java.awt.event.ActionEvent; |
7 |
import java.awt.event.ActionListener; |
8 |
import java.awt.event.KeyEvent; |
9 |
import java.awt.event.KeyListener; |
10 |
|
11 |
import javax.swing.BorderFactory; |
12 |
import javax.swing.ImageIcon; |
13 |
import javax.swing.JButton; |
14 |
import javax.swing.JFileChooser; |
15 |
import javax.swing.JPanel; |
16 |
import javax.swing.JTextField; |
17 |
import javax.swing.border.TitledBorder; |
18 |
|
19 |
import com.iver.andami.Launcher; |
20 |
import com.iver.andami.PluginServices; |
21 |
import com.iver.andami.preferences.AbstractPreferencePage; |
22 |
import com.iver.utiles.GenericFileFilter; |
23 |
|
24 |
public class DirExtensionsPage extends AbstractPreferencePage { |
25 |
private ImageIcon icon; |
26 |
private String id; |
27 |
private JPanel pN = null; |
28 |
private JPanel pC = null; |
29 |
private boolean changed = false; |
30 |
private JPanel jPanel = null; |
31 |
private JTextField jTextField = null; |
32 |
private JButton jButton = null; |
33 |
private String pluginDirectory; |
34 |
|
35 |
public DirExtensionsPage() {
|
36 |
super();
|
37 |
initialize(); |
38 |
id = this.getClass().getName();
|
39 |
setParentID(GeneralPage.class.getName()); |
40 |
} |
41 |
|
42 |
private void initialize() { |
43 |
icon = new ImageIcon(this.getClass().getClassLoader().getResource("images/file-manager.png")); |
44 |
this.setLayout(new BorderLayout()); |
45 |
this.setSize(new java.awt.Dimension(386,177)); |
46 |
this.add(getPN(), java.awt.BorderLayout.NORTH);
|
47 |
this.add(getPC(), java.awt.BorderLayout.CENTER);
|
48 |
} |
49 |
|
50 |
public String getID() { |
51 |
return id;
|
52 |
} |
53 |
|
54 |
public String getTitle() { |
55 |
return PluginServices.getText(this, "directorio_extensiones"); |
56 |
} |
57 |
|
58 |
public JPanel getPanel() { |
59 |
return this; |
60 |
} |
61 |
|
62 |
|
63 |
|
64 |
public void initializeValues() { |
65 |
pluginDirectory = Launcher.getAndamiConfig().getPluginsDirectory(); |
66 |
getJTextField().setText(pluginDirectory); |
67 |
} |
68 |
|
69 |
public void storeValues() { |
70 |
// Se escribe el directorio de los plugins
|
71 |
pluginDirectory = getJTextField().getText(); |
72 |
Launcher.getAndamiConfig().setPluginsDirectory(pluginDirectory); |
73 |
} |
74 |
|
75 |
public void initializeDefaults() { |
76 |
|
77 |
} |
78 |
|
79 |
public ImageIcon getIcon() { |
80 |
return icon;
|
81 |
} |
82 |
|
83 |
/**
|
84 |
* This method initializes pN
|
85 |
*
|
86 |
* @return javax.swing.JPanel
|
87 |
*/
|
88 |
private JPanel getPN() { |
89 |
if (pN == null) { |
90 |
pN = new JPanel(); |
91 |
} |
92 |
return pN;
|
93 |
} |
94 |
|
95 |
/**
|
96 |
* This method initializes pC
|
97 |
*
|
98 |
* @return javax.swing.JPanel
|
99 |
*/
|
100 |
private JPanel getPC() { |
101 |
if (pC == null) { |
102 |
pC = new JPanel(); |
103 |
pC.add(getJPanel(), null);
|
104 |
} |
105 |
return pC;
|
106 |
} |
107 |
|
108 |
/**
|
109 |
* This method initializes jPanel
|
110 |
*
|
111 |
* @return javax.swing.JPanel
|
112 |
*/
|
113 |
private JPanel getJPanel() { |
114 |
if (jPanel == null) { |
115 |
jPanel = new JPanel(); |
116 |
jPanel.setBorder(BorderFactory.createTitledBorder(null, PluginServices.getText(this, "directorio"), TitledBorder.DEFAULT_JUSTIFICATION, TitledBorder.DEFAULT_POSITION, null, null)); |
117 |
jPanel.add(getJTextField(), null);
|
118 |
jPanel.add(getJButton(), null);
|
119 |
} |
120 |
return jPanel;
|
121 |
} |
122 |
|
123 |
/**
|
124 |
* This method initializes jTextField
|
125 |
*
|
126 |
* @return javax.swing.JTextField
|
127 |
*/
|
128 |
private JTextField getJTextField() { |
129 |
if (jTextField == null) { |
130 |
jTextField = new JTextField(); |
131 |
jTextField.setPreferredSize(new Dimension(200, 20)); |
132 |
jTextField.setText(pluginDirectory); |
133 |
jTextField.addKeyListener(new KeyListener() { |
134 |
public void keyPressed(KeyEvent e) { changed = true; } |
135 |
public void keyReleased(KeyEvent e) { changed = true; } |
136 |
public void keyTyped(KeyEvent e){ changed = true; } |
137 |
}); |
138 |
} |
139 |
return jTextField;
|
140 |
} |
141 |
|
142 |
/**
|
143 |
* This method initializes jButton
|
144 |
*
|
145 |
* @return javax.swing.JButton
|
146 |
*/
|
147 |
private JButton getJButton() { |
148 |
if (jButton == null) { |
149 |
jButton = new JButton(); |
150 |
jButton.setText(PluginServices.getText(this, "examinar")); |
151 |
jButton.addActionListener(new java.awt.event.ActionListener() {
|
152 |
public void actionPerformed(java.awt.event.ActionEvent e) { |
153 |
JFileChooser jfc = new JFileChooser(); |
154 |
jfc.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
|
155 |
jfc.addChoosableFileFilter(new GenericFileFilter("", |
156 |
PluginServices.getText(this,
|
157 |
"directorio_extensiones")));
|
158 |
|
159 |
if (jfc.showOpenDialog(
|
160 |
(Component) PluginServices.getMainFrame()) == JFileChooser.APPROVE_OPTION) { |
161 |
getJTextField().setText(jfc.getSelectedFile() |
162 |
.getAbsolutePath()); |
163 |
changed = true;
|
164 |
} |
165 |
} |
166 |
}); |
167 |
|
168 |
} |
169 |
return jButton;
|
170 |
} |
171 |
|
172 |
public boolean isValueChanged() { |
173 |
return changed;
|
174 |
} |
175 |
|
176 |
public void setChangesApplied() { |
177 |
changed = false;
|
178 |
} |
179 |
|
180 |
} // @jve:decl-index=0:visual-constraint="10,10"
|
181 |
|