svn-gvsig-desktop / tags / v1_0_2_Build_898 / libraries / libCorePlugin / src / com / iver / core / preferences / general / DirExtensionsPage.java @ 10513
History | View | Annotate | Download (4.38 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.ActionEvent; |
7 | import java.awt.event.ActionListener; |
||
8 | import java.awt.event.KeyEvent; |
||
9 | import java.awt.event.KeyListener; |
||
10 | 6102 | jaume | |
11 | import javax.swing.BorderFactory; |
||
12 | 5792 | caballero | import javax.swing.ImageIcon; |
13 | 6102 | jaume | import javax.swing.JButton; |
14 | 5792 | caballero | import javax.swing.JFileChooser; |
15 | import javax.swing.JPanel; |
||
16 | 6102 | jaume | import javax.swing.JTextField; |
17 | import javax.swing.border.TitledBorder; |
||
18 | 5792 | caballero | |
19 | 6102 | jaume | import com.iver.andami.Launcher; |
20 | 5792 | caballero | 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 | 6810 | jaume | private boolean changed = false; |
30 | 5792 | caballero | private JPanel jPanel = null; |
31 | private JTextField jTextField = null; |
||
32 | private JButton jButton = null; |
||
33 | 6575 | jaume | private String pluginDirectory; |
34 | 6805 | jaume | |
35 | 5792 | caballero | public DirExtensionsPage() {
|
36 | super();
|
||
37 | initialize(); |
||
38 | id = this.getClass().getName();
|
||
39 | 5804 | fjp | setParentID(GeneralPage.class.getName()); |
40 | 5792 | caballero | } |
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 | 5804 | fjp | |
64 | 5792 | caballero | public void initializeValues() { |
65 | 6575 | jaume | pluginDirectory = Launcher.getAndamiConfig().getPluginsDirectory(); |
66 | getJTextField().setText(pluginDirectory); |
||
67 | 5792 | caballero | } |
68 | |||
69 | 6662 | caballero | public void storeValues() { |
70 | 5792 | caballero | // Se escribe el directorio de los plugins
|
71 | 6575 | jaume | pluginDirectory = getJTextField().getText(); |
72 | Launcher.getAndamiConfig().setPluginsDirectory(pluginDirectory); |
||
73 | 5792 | caballero | } |
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 | 6575 | jaume | jTextField.setText(pluginDirectory); |
133 | 6805 | jaume | 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 | 5792 | caballero | } |
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 | 6805 | jaume | changed = true;
|
164 | 5792 | caballero | } |
165 | } |
||
166 | }); |
||
167 | |||
168 | } |
||
169 | return jButton;
|
||
170 | } |
||
171 | 6575 | jaume | |
172 | 6805 | jaume | public boolean isValueChanged() { |
173 | return changed;
|
||
174 | } |
||
175 | |||
176 | 6810 | jaume | public void setChangesApplied() { |
177 | changed = false;
|
||
178 | } |
||
179 | |||
180 | 5792 | caballero | } // @jve:decl-index=0:visual-constraint="10,10"
|