KickJava   Java API By Example, From Geeks To Geeks.

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


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 archive resources.
32  *
33  * @author Matthew Large
34  * @version $Revision: 1.1 $
35  *
36  */

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

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

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

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

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

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

77     public ArchiveDisplayComponent(DisplayManager displayManager, Server server, String JavaDoc sPath) {
78         super(displayManager, server, sPath);
79         ContextHandler.getInstance().addListener(ContextType.CONTEXT_TABS, this);
80     }
81     
82     /* (non-Javadoc)
83      * @see com.simulacramedia.contentmanager.displaycomponents.AbstractTreeTableDisplayComponent#directorySelected(com.simulacramedia.vfs.AbstractVirtualFileSystem, java.lang.String)
84      */

85     public void virtualFileSelected(AbstractVirtualFileSystem vfs, String JavaDoc sPath) {
86         StateHandler.getInstance().addWait("ARCHIVE-DIR-SELECTION");
87         try {
88             this.m_SelectedDirVFS = vfs;
89             this.m_sSelectedDirPath = sPath;
90             this.m_tableView.setPath(vfs, sPath);
91             this.m_displayManager.hideMetadata();
92             ContextEvent ce = new ContextEvent(ContextType.CONTEXT_DIRS, "", vfs, sPath);
93             ContextHandler.getInstance().fireContextEvent(ce);
94         } catch (Exception JavaDoc e) {
95             e.printStackTrace(System.err);
96         } finally {
97             StateHandler.getInstance().removeWait("ARCHIVE-DIR-SELECTION");
98         }
99     }
100     
101     /* (non-Javadoc)
102      * @see com.simulacramedia.contentmanager.displaycomponents.AbstractTreeTableDisplayComponent#fileSelection(com.simulacramedia.contentmanager.displaycomponents.table.TableEntry)
103      */

104     public void fileSelection(TableEntry entry) {
105         StateHandler.getInstance().addWait("ARCHIVE-FILE-SELECTION");
106         try {
107             ContextEvent ce = new ContextEvent(ContextType.CONTEXT_FILES, null, entry.getVFS(), entry.getPath());
108             this.m_SelectedFileVFS = entry.getVFS();
109             this.m_sSelectedFilePath = entry.getPath();
110             ContextHandler.getInstance().fireContextEvent(ce);
111             this.m_displayManager.openMetadata();
112             this.m_displayManager.scrollTableTo( entry.getLocation().x );
113         } catch (Exception JavaDoc e) {
114             e.printStackTrace(System.err);
115         } finally {
116             StateHandler.getInstance().removeWait("ARCHIVE-FILE-SELECTION");
117         }
118     }
119     
120     /* (non-Javadoc)
121      * @see com.simulacramedia.contentmanager.displaycomponents.AbstractTreeTableDisplayComponent#fileSelection(com.simulacramedia.contentmanager.displaycomponents.table.VersionEntry)
122      */

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

142     public String JavaDoc getTitle() {
143         return "Archive";
144     }
145     
146     /* (non-Javadoc)
147      * @see com.simulacramedia.contentmanager.displaycomponents.AbstractTreeTableDisplayComponent#getIcon()
148      */

149     public String JavaDoc getIcon() {
150         return "16-archive-container.gif";
151     }
152     
153     /* (non-Javadoc)
154      * @see com.simulacramedia.contentmanager.context.ContextListener#contextMessage(com.simulacramedia.contentmanager.context.ContextEvent)
155      */

156     public void contextMessage(ContextEvent ce) {
157         if(ce.CONTEXT_TYPE==ContextType.CONTEXT_TABS && ce.getMessage().equalsIgnoreCase(this.getTitle())) {
158             if(this.m_SelectedDirVFS!=null && this.m_sSelectedDirPath!=null) {
159                 ContextEvent ce2 = new ContextEvent(ContextType.CONTEXT_DIRS, null, this.m_SelectedDirVFS, this.m_sSelectedDirPath);
160                 ContextHandler.getInstance().fireContextEvent(ce2);
161             }
162             if(this.m_SelectedFileVFS!=null && this.m_sSelectedFilePath!=null) {
163                 ContextEvent ce2 = new ContextEvent(ContextType.CONTEXT_FILES, null, this.m_SelectedFileVFS, this.m_sSelectedFilePath);
164                 ContextHandler.getInstance().fireContextEvent(ce2);
165                 this.m_displayManager.openMetadata();
166             } else {
167                 this.m_displayManager.hideMetadata();
168             }
169         }
170     }
171
172 }
173
Popular Tags