Source code: com/arranger/jarl/ui/ConfigButtonListener.java
1 package com.arranger.jarl.ui;
2
3 import com.arranger.jarl.util.StringTools;
4
5 import javax.swing.*;
6 import java.awt.event.ActionListener;
7 import java.awt.event.ActionEvent;
8 import java.io.File;
9
10 /**
11 * ConfigButtonListener created on Apr 15, 2003
12 */
13 class ConfigButtonListener implements ActionListener {
14 protected File m_currentDir;
15 private MainPanel m_mainPanel;
16
17 public ConfigButtonListener(MainPanel mainPanel) {
18 m_mainPanel = mainPanel;
19 }
20
21 public void actionPerformed(ActionEvent e) {
22 JFileChooser jFileChooser = new JFileChooser();
23 ExampleFileFilter filter = new ExampleFileFilter();
24 filter.addExtension("xml");
25 filter.addExtension("jarlml");
26 filter.setDescription("XML & JARLML configFiles");
27 jFileChooser.setFileFilter(filter);
28
29 if (m_currentDir != null) {
30 jFileChooser.setCurrentDirectory(m_currentDir);
31 } else {
32 String configDir = m_mainPanel.m_preferences.getProperty("config.dir");
33 if (!StringTools.isEmpty(configDir)) {
34 m_currentDir = new File(configDir);
35 jFileChooser.setCurrentDirectory(m_currentDir);
36 }
37 }
38
39 if (jFileChooser.showOpenDialog(m_mainPanel) == JFileChooser.APPROVE_OPTION) {
40 m_currentDir = jFileChooser.getCurrentDirectory();
41 m_mainPanel.m_preferences.setProperty("config.dir", m_currentDir.getAbsolutePath());
42 m_mainPanel.m_prefManager.storePreferences(m_mainPanel.m_preferences);
43 m_mainPanel.m_compConfigFile.setText(jFileChooser.getSelectedFile().getAbsolutePath());
44 }
45 }
46
47 }