blob: 6fa2f1db7ed0398c5afe9a5b232cd870630adf13 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
|
/*
* SIP Communicator, the OpenSource Java VoIP and Instant Messaging client.
*
* Distributable under LGPL license.
* See terms of license at gnu.org.
*/
package net.java.sip.communicator.plugin.skinmanager;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import net.java.sip.communicator.util.swing.*;
import org.osgi.framework.*;
/**
* @author Adam Netocny
*/
public class SkinManagerPanel
extends TransparentPanel
{
/**
* Remove button.
*/
private final JButton rmButton = new JButton("Remove selected skin");
/**
* <tt>SkinSelector</tt> component.
*/
private final SkinSelector skinSelector = new SkinSelector();
/**
* Creates an instance of <tt>SkinManagerPanel</tt>.
*/
public SkinManagerPanel()
{
super(new FlowLayout(FlowLayout.CENTER));
JPanel selectorPanel = new TransparentPanel();
selectorPanel.setLayout(new BoxLayout(selectorPanel, BoxLayout.Y_AXIS));
skinSelector.setAlignmentX(Component.CENTER_ALIGNMENT);
skinSelector.addItemListener(new EnableDisableListener());
selectorPanel.add(skinSelector);
rmButton.setAlignmentX(Component.CENTER_ALIGNMENT);
rmButton.addActionListener(new RemoveListener());
selectorPanel.add(rmButton);
enableDisableButton();
add(selectorPanel, BorderLayout.NORTH);
}
/**
* Enables(if a skin <tt>Bundle</tt> is selected) or disables the remove
* button.
*/
private void enableDisableButton()
{
Object tmp = skinSelector.getSelectedItem();
if(tmp != null)
{
if(tmp instanceof Bundle)
{
rmButton.setEnabled(true);
return;
}
}
rmButton.setEnabled(false);
}
/**
* Listener for the remove button events.
*/
private class RemoveListener implements ActionListener
{
/**
* Invoked when an action occurs.
* @param e <tt>ActionEvent</tt>.
*/
public void actionPerformed(ActionEvent e)
{
Object tmp = skinSelector.getSelectedItem();
if(tmp != null)
{
if(tmp instanceof Bundle)
{
try
{
((Bundle) tmp).uninstall();
}
catch (BundleException ex)
{
}
}
}
}
}
/**
* Selection listener for enabling/disabling of remove button.
*/
private class EnableDisableListener
implements ItemListener
{
public void itemStateChanged(ItemEvent e)
{
SwingUtilities.invokeLater(new Runnable()
{
public void run()
{
enableDisableButton();
}
});
}
}
}
|