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