KickJava   Java API By Example, From Geeks To Geeks.

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


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 package org.openharmonise.him.displaycomponents;
20
21 import org.openharmonise.him.context.StateHandler;
22 import org.openharmonise.him.displaycomponents.table.*;
23 import org.openharmonise.him.window.*;
24 import org.openharmonise.vfs.*;
25 import org.openharmonise.vfs.context.*;
26 import org.openharmonise.vfs.servers.*;
27
28
29 /**
30  * Display component for managing content resources.
31  *
32  * @author Matthew Large
33  * @version $Revision: 1.1 $
34  *
35  */

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

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

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

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

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

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

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

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

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

123     public void fileSelection(VersionEntry entry) {
124         StateHandler.getInstance().addWait("CONTENT-FILE-SELECTION");
125         try {
126             ContextEvent ce = new ContextEvent(ContextType.CONTEXT_FILES, null, entry.getVFS(), entry.getPath());
127             ContextHandler.getInstance().fireContextEvent(ce);
128             this.m_SelectedFileVFS = entry.getVFS();
129             this.m_sSelectedFilePath = entry.getPath();
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("CONTENT-FILE-SELECTION");
136         }
137     }
138     
139     /* (non-Javadoc)
140      * @see com.simulacramedia.contentmanager.displaycomponents.AbstractTreeTableDisplayComponent#getTitle()
141      */

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

149     public String JavaDoc getIcon() {
150         return "16-section.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