KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > enhydra > jawe > misc > ShowHideButtonsPanel


1 /* ShowHideButtonsPanel.java
2  *
3  * Authors:
4  * Stefanovic Nenad chupo@iis.ns.ac.yu
5  * Bojanic Sasa sasaboy@neobee.net
6  * Puskas Vladimir vpuskas@eunet.yu
7  * Pilipovic Goran zboniek@uns.ac.yu
8  *
9  */

10
11
12 package org.enhydra.jawe.misc;
13
14 import org.enhydra.jawe.*;
15 import org.enhydra.jawe.xml.*;
16 import org.enhydra.jawe.xml.elements.*;
17 import org.enhydra.jawe.xml.panels.*;
18
19
20 import javax.swing.*;
21 import javax.swing.tree.*;
22 import java.awt.*;
23 import java.awt.event.*;
24
25 public class ShowHideButtonsPanel extends XMLControlPanel {
26    private WorkflowManager workflowManager;
27
28    public ShowHideButtonsPanel (Participants myOwner,WorkflowManager wm,
29          boolean isVertical) {
30
31       super(myOwner,"",isVertical,false);
32
33       this.workflowManager=wm;
34
35       String JavaDoc s=XMLUtil.getLanguageDependentString("ShowKey");
36       String JavaDoc h=XMLUtil.getLanguageDependentString("HideKey");
37
38       Dimension dim=getPreferredDimension(new String JavaDoc[]{s,h});
39
40       XMLButton buttonShow=new XMLButton(s,"Show",dim);
41       XMLButton buttonHide=new XMLButton(h,"Hide",dim);
42
43       buttonShow.setEnabled(!myOwner.isReadOnly());
44       buttonHide.setEnabled(!myOwner.isReadOnly());
45
46       if (isVertical) {
47          add(Box.createVerticalGlue());
48       } else {
49          add(Box.createHorizontalGlue());
50       }
51       add(buttonShow);
52       if (isVertical) {
53          add(Box.createRigidArea(new Dimension(0,5)));
54       } else {
55          add(Box.createRigidArea(new Dimension(5,0)));
56       }
57       add(buttonHide);
58       if (isVertical) {
59          add(Box.createVerticalGlue());
60       } else {
61          add(Box.createHorizontalGlue());
62          add(Box.createRigidArea(new Dimension(0,15)));
63       }
64
65       buttonShow.addActionListener(new ActionListener() {
66          public void actionPerformed(ActionEvent ae) {
67             Participants pOwner=(Participants)getOwner();
68             XMLTableControlPanel tcp=(XMLTableControlPanel)pOwner.getControlPanel();
69             Participant selectedParticipant=(Participant)tcp.getSelectedElement();
70             if (selectedParticipant!=null) {
71                Participants pps = (Participants)pOwner.getPackage().get("Participants");
72                if ((!pOwner.isMine(selectedParticipant) &&
73                      pOwner.getCollectionElement(selectedParticipant.getID())!=null) ||
74                      (pOwner.isExternal(selectedParticipant) &&
75                      pps.getCollectionElement(selectedParticipant.getID())!=null)) {
76                   JaWE.getInstance().message(ResourceManager.
77                         getLanguageDependentString("WarningCannotShowRedefinedParticipant"),
78                         JOptionPane.WARNING_MESSAGE);
79                } else {
80                   workflowManager.showNode(selectedParticipant);
81                }
82             }
83          }
84       });
85
86       buttonHide.addActionListener(new ActionListener() {
87          public void actionPerformed(ActionEvent ae) {
88             Participants pOwner=(Participants)getOwner();
89             XMLTableControlPanel tcp=(XMLTableControlPanel)pOwner.getControlPanel();
90             Participant selectedParticipant=(Participant)tcp.getSelectedElement();
91             if (selectedParticipant!=null) {
92                workflowManager.hideNode(selectedParticipant);
93             }
94          }
95       });
96
97    }
98
99 }
100
Popular Tags