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