KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > openharmonise > him > displaycomponents > WorkflowDisplayComponent


1 /*
2  * The contents of this file are subject to the
3  * Mozilla Public License Version 1.1 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at http://www.mozilla.org/MPL/
6  *
7  * Software distributed under the License is distributed on an "AS IS"
8  * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied.
9  * See the License for the specific language governing rights and
10  * limitations under the License.
11  *
12  * The Initial Developer of the Original Code is Simulacra Media Ltd.
13  * Portions created by Simulacra Media Ltd are Copyright (C) Simulacra Media Ltd, 2004.
14  *
15  * All Rights Reserved.
16  *
17  * Contributor(s):
18  */

19
20 package org.openharmonise.him.displaycomponents;
21
22 import org.openharmonise.him.context.StateHandler;
23 import org.openharmonise.him.displaycomponents.table.*;
24 import org.openharmonise.him.window.*;
25 import org.openharmonise.vfs.*;
26 import org.openharmonise.vfs.context.*;
27 import org.openharmonise.vfs.servers.*;
28
29
30 /**
31  * Display component for managing workflow resources.
32  *
33  * @author Matthew Large
34  * @version $Revision: 1.1 $
35  *
36  */

37 public class WorkflowDisplayComponent
38     extends AbstractTreeTableDisplayComponent
39     implements ContextListener {
40
41     /**
42      * Virtual file system for the selected file.
43      */

44     private AbstractVirtualFileSystem m_SelectedFileVFS = null;
45     
46     /**
47      * Full path to the selected file.
48      */

49     private String JavaDoc m_sSelectedFilePath = null;
50
51     /**
52      * Virtual file system for the selected collection.
53      */

54     private AbstractVirtualFileSystem m_SelectedDirVFS = null;
55     
56     /**
57      * Full path to the selected collection.
58      */

59     private String JavaDoc m_sSelectedDirPath = null;
60
61     /**
62      * Constructs a new workflow display component.
63      *
64      * @param displayManager Display manager
65      */

66     public WorkflowDisplayComponent(DisplayManager displayManager) {
67         super(displayManager);
68         ContextHandler.getInstance().addListener(
69             ContextType.CONTEXT_TABS,
70             this);
71     }
72     
73     /**
74      * Constructs a new workflow display component.
75      *
76      * @param displayManager Display manager
77      * @param server Server
78      * @param sPath Full path to workflow collection
79      */

80     public WorkflowDisplayComponent(
81         DisplayManager displayManager,
82         Server server,
83         String JavaDoc sPath) {
84         super(displayManager, server, sPath);
85         ContextHandler.getInstance().addListener(
86             ContextType.CONTEXT_TABS,
87             this);
88     }
89
90     /* (non-Javadoc)
91      * @see com.simulacramedia.contentmanager.displaycomponents.tree.TreeViewListener#directorySelected(com.simulacramedia.vfs.servers.Server, java.lang.String)
92      */

93     public void virtualFileSelected(
94         AbstractVirtualFileSystem vfs,
95         String JavaDoc sPath) {
96         StateHandler.getInstance().addWait("WORKFLOW-DIR-SELECTION");
97         try {
98             this.m_SelectedDirVFS = vfs;
99             this.m_sSelectedDirPath = sPath;
100             this.m_SelectedFileVFS = null;
101             this.m_sSelectedFilePath = null;
102             this.m_tableView.setPath(vfs, sPath);
103             this.m_displayManager.hideMetadata();
104             ContextEvent ce = new ContextEvent(ContextType.CONTEXT_DIRS, "", vfs, sPath);
105             ContextHandler.getInstance().fireContextEvent(ce);
106         } catch (Exception JavaDoc e) {
107             e.printStackTrace(System.err);
108         } finally {
109             StateHandler.getInstance().removeWait("WORKFLOW-DIR-SELECTION");
110         }
111     }
112     
113     /* (non-Javadoc)
114      * @see com.simulacramedia.contentmanager.displaycomponents.table.TableListener#fileSelection(com.simulacramedia.contentmanager.displaycomponents.table.TableEntry)
115      */

116     public void fileSelection(TableEntry entry) {
117         StateHandler.getInstance().addWait("WORKFLOW-FILE-SELECTION");
118         try {
119             ContextEvent ce =
120                 new ContextEvent(
121                     ContextType.CONTEXT_FILES,
122                     null,
123                     entry.getVFS(),
124                     entry.getPath());
125             this.m_SelectedFileVFS = entry.getVFS();
126             this.m_sSelectedFilePath = entry.getPath();
127             ContextHandler.getInstance().fireContextEvent(ce);
128             this.m_displayManager.openMetadata();
129             this.m_displayManager.scrollTableTo(entry.getLocation().x);
130         } catch (Exception JavaDoc e) {
131             e.printStackTrace(System.err);
132         } finally {
133             StateHandler.getInstance().removeWait("WORKFLOW-FILE-SELECTION");
134         }
135     }
136     
137     /* (non-Javadoc)
138      * @see com.simulacramedia.contentmanager.displaycomponents.table.TableListener#fileSelection(com.simulacramedia.contentmanager.displaycomponents.table.TableEntry)
139      */

140     public void fileSelection(VersionEntry entry) {
141         StateHandler.getInstance().addWait("WORKFLOW-FILE-SELECTION");
142         try {
143             ContextEvent ce =
144                 new ContextEvent(
145                     ContextType.CONTEXT_FILES,
146                     null,
147                     entry.getVFS(),
148                     entry.getPath());
149             ContextHandler.getInstance().fireContextEvent(ce);
150             this.m_SelectedFileVFS = entry.getVFS();
151             this.m_sSelectedFilePath = entry.getPath();
152             this.m_displayManager.openMetadata();
153             this.m_displayManager.scrollTableTo(
154                 entry.getParentTableEntry().getLocation().x);
155         } catch (Exception JavaDoc e) {
156             e.printStackTrace(System.err);
157         } finally {
158             StateHandler.getInstance().removeWait("WORKFLOW-FILE-SELECTION");
159         }
160     }
161     
162     /* (non-Javadoc)
163      * @see com.simulacramedia.contentmanager.displaycomponents.AbstractTreeTableDisplayComponent#getTitle()
164      */

165     public String JavaDoc getTitle() {
166         return "Workflow";
167     }
168     
169     /* (non-Javadoc)
170      * @see com.simulacramedia.contentmanager.displaycomponents.AbstractTreeTableDisplayComponent#getIcon()
171      */

172     public String JavaDoc getIcon() {
173         return "16-workflow-container.gif";
174     }
175     
176     /* (non-Javadoc)
177      * @see com.simulacramedia.contentmanager.context.ContextListener#contextMessage(com.simulacramedia.contentmanager.context.ContextEvent)
178      */

179     public void contextMessage(ContextEvent ce) {
180         if (ce.CONTEXT_TYPE == ContextType.CONTEXT_TABS
181             && ce.getMessage().equalsIgnoreCase(this.getTitle())) {
182             if (this.m_SelectedDirVFS != null
183                 && this.m_sSelectedDirPath != null) {
184                 ContextEvent ce2 =
185                     new ContextEvent(
186                         ContextType.CONTEXT_DIRS,
187                         null,
188                         this.m_SelectedDirVFS,
189                         this.m_sSelectedDirPath);
190                 ContextHandler.getInstance().fireContextEvent(ce2);
191             }
192             if (this.m_SelectedFileVFS != null
193                 && this.m_sSelectedFilePath != null) {
194                 ContextEvent ce2 =
195                     new ContextEvent(
196                         ContextType.CONTEXT_FILES,
197                         null,
198                         this.m_SelectedFileVFS,
199                         this.m_sSelectedFilePath);
200                 ContextHandler.getInstance().fireContextEvent(ce2);
201                 this.m_displayManager.openMetadata();
202             } else {
203                 this.m_displayManager.hideMetadata();
204             }
205         }
206     }
207
208 }
209
Popular Tags