01: package desktop;
02:
03: import org.wings.*;
04: import org.wings.style.CSSProperty;
05:
06: import java.awt.event.ActionEvent;
07: import java.awt.event.ActionListener;
08: import java.beans.PropertyChangeEvent;
09: import java.beans.PropertyChangeListener;
10:
11: public class NewsFeedItem extends AbstractDesktopItem {
12:
13: private NewsFeedPanel panel;
14:
15: public NewsFeedItem() {
16: super ();
17: pref.put(TOOL, "NewsfeedTool");
18:
19: addPropertyChangeListener(new PropertyChangeListener() {
20: public void propertyChange(PropertyChangeEvent e) {
21: if (e.getPropertyName().equals(FEED)) {
22: ((NewsFeedPanel) getComponent()).setFeed((String) e
23: .getNewValue());
24: }
25: }
26: });
27: }
28:
29: public NewsFeedItem(String name) {
30: super (name);
31:
32: addPropertyChangeListener(new PropertyChangeListener() {
33: public void propertyChange(PropertyChangeEvent e) {
34: if (e.getPropertyName().equals(FEED)) {
35: ((NewsFeedPanel) getComponent()).setFeed((String) e
36: .getNewValue());
37: }
38: }
39: });
40: }
41:
42: public SComponent getComponent() {
43: if (panel == null) {
44: panel = new NewsFeedPanel();
45:
46: }
47:
48: return panel;
49: }
50:
51: public void activated() {
52: if (!(attributes.containsKey(NAME) && getValue(NAME) != null
53: && attributes.containsKey(FEED) && getValue(FEED) != null)) {
54:
55: final SPanel inputPanel = new SPanel();
56: final STextField inputElement = new STextField(
57: "file:///home/hengels/IssueNavigator.jspa.xml");
58: final STextField inputTitleElement = new STextField(
59: "custom");
60: inputElement.setAttribute(CSSProperty.WIDTH, "300px");
61: inputTitleElement.setAttribute(CSSProperty.WIDTH, "300px");
62:
63: inputPanel.add(new SLabel("Title "));
64: inputPanel.add(inputTitleElement);
65:
66: inputPanel.setLayout(new SGridLayout(2, 2));
67: inputPanel.add(new SLabel("URL "));
68: inputPanel.add(inputElement);
69: SOptionPane.showInputDialog(panel, "New News-Feed",
70: "News-Feed", inputPanel, new ActionListener() {
71:
72: public void actionPerformed(ActionEvent e) {
73: if (e.getActionCommand().equals(
74: SOptionPane.OK_ACTION)) {
75: putValue(NAME, inputTitleElement
76: .getText());
77: putValue(FEED, inputElement.getText());
78: } else
79: container.destroy();
80: }
81: });
82: }
83:
84: }
85:
86: public void fixContent() {
87: }
88:
89: public void destroyed() {
90: super .destroyed();
91: ((NewsFeedPanel) getComponent()).destroy();
92: }
93:
94: }
|