01: package org.osbl.client.wings.devtools;
02:
03: import org.wings.*;
04: import org.wings.border.SEmptyBorder;
05: import org.wingx.XDivision;
06: import org.osbl.client.wings.shell.AbstractTool;
07: import org.osbl.client.wings.shell.Client;
08:
09: import javax.swing.*;
10: import java.util.List;
11: import java.util.Collections;
12:
13: public class DevelopmentTool extends AbstractTool {
14: protected static final List<Action> NO_ACTIONS = Collections.EMPTY_LIST;
15:
16: private SPanel panel;
17: private XDivision globalDivision = new XDivision(new SGridLayout());
18: private XDivision specificDivision = new XDivision(
19: new SGridLayout());
20:
21: private List<Action> specificActions;
22: private Action[] globalActions;
23:
24: public DevelopmentTool() {
25: putValue(Action.NAME, "Development");
26: }
27:
28: public void setGlobalActions(Action[] globalActions) {
29: this .globalActions = globalActions;
30: }
31:
32: private void initGlobalDevelopmentTools() {
33: addActions(globalDivision, globalActions);
34: }
35:
36: public void setSpecificActions(List<Action> specificActions) {
37: if (this .specificActions != specificActions) {
38: this .specificActions = specificActions != null ? specificActions
39: : NO_ACTIONS;
40: specificDivision.removeAll();
41: addActions(specificDivision, this .specificActions
42: .toArray(new Action[this .specificActions.size()]));
43: System.out.println("replace development actions = "
44: + this .specificActions);
45: }
46: }
47:
48: private void addActions(SContainer division, Action[] actions) {
49: for (Action action : actions) {
50: SButton button = new SButton(Client.getInstance()
51: .getActionProvider().configure(action));
52: button.setPreferredSize(SDimension.FULLWIDTH);
53: button.setHorizontalAlignment(SConstants.LEFT_ALIGN);
54: division.add(button);
55: }
56: }
57:
58: public SComponent getComponent() {
59: if (panel == null) {
60: panel = new SPanel(new SGridLayout());
61: panel.setBorder(new SEmptyBorder(8, 8, 8, 8));
62: panel.setPreferredSize(SDimension.FULLWIDTH);
63:
64: globalDivision.setTitle("Global Tools");
65: globalDivision.setPreferredSize(SDimension.FULLWIDTH);
66: specificDivision.setTitle("Specific Tools");
67: specificDivision.setPreferredSize(SDimension.FULLWIDTH);
68:
69: panel.add(globalDivision);
70: panel.add(specificDivision);
71:
72: initGlobalDevelopmentTools();
73: }
74: return panel;
75: }
76: }
|