KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > rero > dialogs > ThemeDialog


1 package rero.dialogs;
2
3 import java.awt.*;
4 import java.awt.event.*;
5
6 import javax.swing.*;
7 import javax.swing.table.*;
8 import javax.swing.event.*;
9
10 import java.util.*;
11 import rero.config.*;
12
13 import java.io.*;
14 import rero.util.*;
15
16 import rero.dck.items.*;
17 import rero.dck.*;
18
19 import rero.gui.*;
20
21 public class ThemeDialog extends DMain implements ActionListener
22 {
23    private JLabel label;
24    private JButton importt, exportt;
25
26    public String JavaDoc getTitle()
27    {
28       return "Theme Manager";
29    }
30
31    public String JavaDoc getDescription()
32    {
33       return "Theme Manager";
34    }
35
36    public void actionPerformed(ActionEvent ev)
37    {
38       File file = null;
39
40       if (ev.getSource() == importt)
41       {
42          file = DialogUtilities.showFileDialog("Import Theme File", null, null);
43          if (file != null)
44          {
45             SessionManager.getGlobalCapabilities().getActiveSession().executeCommand("/theme " + file.getAbsolutePath());
46          }
47       }
48       else if (ev.getSource() == exportt)
49       {
50          String JavaDoc name = ClientUtils.generateThemeScript(null);
51
52          if (name != null)
53          {
54             ClientState.getClientState().setString("current.theme", name);
55          }
56       }
57    }
58
59    public void setupDialog()
60    {
61       label = new JLabel();
62       refresh();
63
64       importt = new JButton("Import Theme");
65       importt.setMnemonic('I');
66       importt.setToolTipText("Import colormap settings from a jIRCii theme script");
67       importt.addActionListener(this);
68
69       exportt = new JButton("Export Theme");
70       exportt.setMnemonic('E');
71       exportt.setToolTipText("Export colormap settings to a jIRCii theme script");
72       exportt.addActionListener(this);
73
74       JPanel a = new JPanel();
75       a.setLayout(new FlowLayout(FlowLayout.LEFT));
76       a.add(importt);
77
78       JPanel b = new JPanel();
79       b.setLayout(new FlowLayout(FlowLayout.LEFT));
80       b.add(exportt);
81  
82       addBlankSpace();
83       addBlankSpace();
84       addBlankSpace();
85       addBlankSpace();
86       addComponent(label);
87       addBlankSpace();
88       addComponent(a);
89       addComponent(b);
90       addBlankSpace();
91       addLabel("jIRCii themes consist of colormap and background color settings. To edit the current colormap simply hold down shift and click on text within the client.", 30);
92       addBlankSpace();
93       addBlankSpace();
94    }
95  
96    public void refresh()
97    {
98       label.setText("Current Theme: " + ClientState.getClientState().getString("current.theme", ClientDefaults.current_theme));
99    }
100 }
101
102
103
104
Popular Tags