001: /*
002: * The contents of this file are subject to the
003: * Mozilla Public License Version 1.1 (the "License");
004: * you may not use this file except in compliance with the License.
005: * You may obtain a copy of the License at http://www.mozilla.org/MPL/
006: *
007: * Software distributed under the License is distributed on an "AS IS"
008: * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied.
009: * See the License for the specific language governing rights and
010: * limitations under the License.
011: *
012: * The Initial Developer of the Original Code is Simulacra Media Ltd.
013: * Portions created by Simulacra Media Ltd are Copyright (C) Simulacra Media Ltd, 2004.
014: *
015: * All Rights Reserved.
016: *
017: * Contributor(s):
018: */
019: package org.openharmonise.him.displaycomponents;
020:
021: import org.openharmonise.him.context.StateHandler;
022: import org.openharmonise.him.displaycomponents.table.*;
023: import org.openharmonise.him.window.*;
024: import org.openharmonise.vfs.*;
025: import org.openharmonise.vfs.context.*;
026: import org.openharmonise.vfs.servers.*;
027:
028: /**
029: * Display component for managing content resources.
030: *
031: * @author Matthew Large
032: * @version $Revision: 1.1 $
033: *
034: */
035: public class ContentDisplayComponent extends
036: AbstractTreeTableDisplayComponent implements ContextListener {
037:
038: /**
039: * Virtual file system for the selected file.
040: */
041: private AbstractVirtualFileSystem m_SelectedFileVFS = null;
042:
043: /**
044: * Full path to the selected file.
045: */
046: private String m_sSelectedFilePath = null;
047:
048: /**
049: * Virtual file system for the selected collection.
050: */
051: private AbstractVirtualFileSystem m_SelectedDirVFS = null;
052:
053: /**
054: * Full path to the selected collection.
055: */
056: private String m_sSelectedDirPath = null;
057:
058: /**
059: * Constructs a new content display component.
060: *
061: * @param displayManager Display manager
062: */
063: public ContentDisplayComponent(DisplayManager displayManager) {
064: super (displayManager);
065: ContextHandler.getInstance().addListener(
066: ContextType.CONTEXT_TABS, this );
067: }
068:
069: /**
070: * Constructs a new content display component.
071: *
072: * @param displayManager Display manager
073: * @param server Server
074: * @param sPath Full path to content collection
075: */
076: public ContentDisplayComponent(DisplayManager displayManager,
077: Server server, String sPath) {
078: super (displayManager, server, sPath);
079: ContextHandler.getInstance().addListener(
080: ContextType.CONTEXT_TABS, this );
081: }
082:
083: /* (non-Javadoc)
084: * @see com.simulacramedia.contentmanager.displaycomponents.tree.TreeViewListener#directorySelected(com.simulacramedia.vfs.servers.Server, java.lang.String)
085: */
086: public void virtualFileSelected(AbstractVirtualFileSystem vfs,
087: String sPath) {
088: StateHandler.getInstance().addWait("CONTENT-DIR-SELECTION");
089: try {
090: this .m_SelectedDirVFS = vfs;
091: this .m_sSelectedDirPath = sPath;
092: this .m_SelectedFileVFS = null;
093: this .m_sSelectedFilePath = null;
094: this .m_tableView.setPath(vfs, sPath);
095: this .m_displayManager.hideMetadata();
096: ContextEvent ce = new ContextEvent(
097: ContextType.CONTEXT_DIRS, "", vfs, sPath);
098: ContextHandler.getInstance().fireContextEvent(ce);
099: } catch (Exception e) {
100: e.printStackTrace(System.err);
101: } finally {
102: StateHandler.getInstance().removeWait(
103: "CONTENT-DIR-SELECTION");
104: }
105: }
106:
107: /* (non-Javadoc)
108: * @see com.simulacramedia.contentmanager.displaycomponents.table.TableListener#fileSelection(com.simulacramedia.contentmanager.displaycomponents.table.TableEntry)
109: */
110: public void fileSelection(TableEntry entry) {
111: StateHandler.getInstance().addWait("CONTENT-FILE-SELECTION");
112: try {
113: ContextEvent ce = new ContextEvent(
114: ContextType.CONTEXT_FILES, null, entry.getVFS(),
115: entry.getPath());
116: this .m_SelectedFileVFS = entry.getVFS();
117: this .m_sSelectedFilePath = entry.getPath();
118: ContextHandler.getInstance().fireContextEvent(ce);
119: this .m_displayManager.openMetadata();
120: this .m_displayManager.scrollTableTo(entry.getLocation().x);
121: } catch (Exception e) {
122: e.printStackTrace(System.err);
123: } finally {
124: StateHandler.getInstance().removeWait(
125: "CONTENT-FILE-SELECTION");
126: }
127: }
128:
129: /* (non-Javadoc)
130: * @see com.simulacramedia.contentmanager.displaycomponents.table.TableListener#fileSelection(com.simulacramedia.contentmanager.displaycomponents.table.TableEntry)
131: */
132: public void fileSelection(VersionEntry entry) {
133: StateHandler.getInstance().addWait("CONTENT-FILE-SELECTION");
134: try {
135: ContextEvent ce = new ContextEvent(
136: ContextType.CONTEXT_FILES, null, entry.getVFS(),
137: entry.getPath());
138: ContextHandler.getInstance().fireContextEvent(ce);
139: this .m_SelectedFileVFS = entry.getVFS();
140: this .m_sSelectedFilePath = entry.getPath();
141: this .m_displayManager.openMetadata();
142: this .m_displayManager.scrollTableTo(entry
143: .getParentTableEntry().getLocation().x);
144: } catch (Exception e) {
145: e.printStackTrace(System.err);
146: } finally {
147: StateHandler.getInstance().removeWait(
148: "CONTENT-FILE-SELECTION");
149: }
150: }
151:
152: /* (non-Javadoc)
153: * @see com.simulacramedia.contentmanager.displaycomponents.AbstractTreeTableDisplayComponent#getTitle()
154: */
155: public String getTitle() {
156: return "Content";
157: }
158:
159: /* (non-Javadoc)
160: * @see com.simulacramedia.contentmanager.displaycomponents.AbstractTreeTableDisplayComponent#getIcon()
161: */
162: public String getIcon() {
163: return "16-section.gif";
164: }
165:
166: /* (non-Javadoc)
167: * @see com.simulacramedia.contentmanager.context.ContextListener#contextMessage(com.simulacramedia.contentmanager.context.ContextEvent)
168: */
169: public void contextMessage(ContextEvent ce) {
170: if (ce.CONTEXT_TYPE == ContextType.CONTEXT_TABS
171: && ce.getMessage().equalsIgnoreCase(this .getTitle())) {
172: if (this .m_SelectedDirVFS != null
173: && this .m_sSelectedDirPath != null) {
174: ContextEvent ce2 = new ContextEvent(
175: ContextType.CONTEXT_DIRS, null,
176: this .m_SelectedDirVFS, this .m_sSelectedDirPath);
177: ContextHandler.getInstance().fireContextEvent(ce2);
178: }
179: if (this .m_SelectedFileVFS != null
180: && this .m_sSelectedFilePath != null) {
181: ContextEvent ce2 = new ContextEvent(
182: ContextType.CONTEXT_FILES, null,
183: this.m_SelectedFileVFS,
184: this.m_sSelectedFilePath);
185: ContextHandler.getInstance().fireContextEvent(ce2);
186: this.m_displayManager.openMetadata();
187: } else {
188: this.m_displayManager.hideMetadata();
189: }
190: }
191: }
192:
193: }
|