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:
020: package org.openharmonise.him.displaycomponents;
021:
022: import org.openharmonise.him.context.StateHandler;
023: import org.openharmonise.him.displaycomponents.table.*;
024: import org.openharmonise.him.window.*;
025: import org.openharmonise.vfs.*;
026: import org.openharmonise.vfs.context.*;
027: import org.openharmonise.vfs.servers.*;
028:
029: /**
030: * Display component for managing archive resources.
031: *
032: * @author Matthew Large
033: * @version $Revision: 1.1 $
034: *
035: */
036: public class ArchiveDisplayComponent extends
037: AbstractTreeTableDisplayComponent implements ContextListener {
038:
039: /**
040: * Virtual file system for the selected file.
041: */
042: private AbstractVirtualFileSystem m_SelectedFileVFS = null;
043:
044: /**
045: * Full path to the selected file.
046: */
047: private String m_sSelectedFilePath = null;
048:
049: /**
050: * Virtual file system for the selected collection.
051: */
052: private AbstractVirtualFileSystem m_SelectedDirVFS = null;
053:
054: /**
055: * Full path to the selected collection.
056: */
057: private String m_sSelectedDirPath = null;
058:
059: /**
060: * Constructs a new archive display component.
061: *
062: * @param displayManager Display manager
063: */
064: public ArchiveDisplayComponent(DisplayManager displayManager) {
065: super (displayManager);
066: ContextHandler.getInstance().addListener(
067: ContextType.CONTEXT_TABS, this );
068: }
069:
070: /**
071: * Constructs a new archive display component.
072: *
073: * @param displayManager Display manager
074: * @param server Server
075: * @param sPath Full path to archive
076: */
077: public ArchiveDisplayComponent(DisplayManager displayManager,
078: Server server, String sPath) {
079: super (displayManager, server, sPath);
080: ContextHandler.getInstance().addListener(
081: ContextType.CONTEXT_TABS, this );
082: }
083:
084: /* (non-Javadoc)
085: * @see com.simulacramedia.contentmanager.displaycomponents.AbstractTreeTableDisplayComponent#directorySelected(com.simulacramedia.vfs.AbstractVirtualFileSystem, java.lang.String)
086: */
087: public void virtualFileSelected(AbstractVirtualFileSystem vfs,
088: String sPath) {
089: StateHandler.getInstance().addWait("ARCHIVE-DIR-SELECTION");
090: try {
091: this .m_SelectedDirVFS = vfs;
092: this .m_sSelectedDirPath = sPath;
093: this .m_tableView.setPath(vfs, sPath);
094: this .m_displayManager.hideMetadata();
095: ContextEvent ce = new ContextEvent(
096: ContextType.CONTEXT_DIRS, "", vfs, sPath);
097: ContextHandler.getInstance().fireContextEvent(ce);
098: } catch (Exception e) {
099: e.printStackTrace(System.err);
100: } finally {
101: StateHandler.getInstance().removeWait(
102: "ARCHIVE-DIR-SELECTION");
103: }
104: }
105:
106: /* (non-Javadoc)
107: * @see com.simulacramedia.contentmanager.displaycomponents.AbstractTreeTableDisplayComponent#fileSelection(com.simulacramedia.contentmanager.displaycomponents.table.TableEntry)
108: */
109: public void fileSelection(TableEntry entry) {
110: StateHandler.getInstance().addWait("ARCHIVE-FILE-SELECTION");
111: try {
112: ContextEvent ce = new ContextEvent(
113: ContextType.CONTEXT_FILES, null, entry.getVFS(),
114: entry.getPath());
115: this .m_SelectedFileVFS = entry.getVFS();
116: this .m_sSelectedFilePath = entry.getPath();
117: ContextHandler.getInstance().fireContextEvent(ce);
118: this .m_displayManager.openMetadata();
119: this .m_displayManager.scrollTableTo(entry.getLocation().x);
120: } catch (Exception e) {
121: e.printStackTrace(System.err);
122: } finally {
123: StateHandler.getInstance().removeWait(
124: "ARCHIVE-FILE-SELECTION");
125: }
126: }
127:
128: /* (non-Javadoc)
129: * @see com.simulacramedia.contentmanager.displaycomponents.AbstractTreeTableDisplayComponent#fileSelection(com.simulacramedia.contentmanager.displaycomponents.table.VersionEntry)
130: */
131: public void fileSelection(VersionEntry entry) {
132: StateHandler.getInstance().addWait("ARCHIVE-FILE-SELECTION");
133: try {
134: ContextEvent ce = new ContextEvent(
135: ContextType.CONTEXT_FILES, null, entry.getVFS(),
136: entry.getPath());
137: this .m_SelectedFileVFS = entry.getVFS();
138: this .m_sSelectedFilePath = entry.getPath();
139: ContextHandler.getInstance().fireContextEvent(ce);
140: this .m_displayManager.openMetadata();
141: this .m_displayManager.scrollTableTo(entry
142: .getParentTableEntry().getLocation().x);
143: } catch (Exception e) {
144: e.printStackTrace(System.err);
145: } finally {
146: StateHandler.getInstance().removeWait(
147: "ARCHIVE-FILE-SELECTION");
148: }
149: }
150:
151: /* (non-Javadoc)
152: * @see com.simulacramedia.contentmanager.displaycomponents.AbstractTreeTableDisplayComponent#getTitle()
153: */
154: public String getTitle() {
155: return "Archive";
156: }
157:
158: /* (non-Javadoc)
159: * @see com.simulacramedia.contentmanager.displaycomponents.AbstractTreeTableDisplayComponent#getIcon()
160: */
161: public String getIcon() {
162: return "16-archive-container.gif";
163: }
164:
165: /* (non-Javadoc)
166: * @see com.simulacramedia.contentmanager.context.ContextListener#contextMessage(com.simulacramedia.contentmanager.context.ContextEvent)
167: */
168: public void contextMessage(ContextEvent ce) {
169: if (ce.CONTEXT_TYPE == ContextType.CONTEXT_TABS
170: && ce.getMessage().equalsIgnoreCase(this .getTitle())) {
171: if (this .m_SelectedDirVFS != null
172: && this .m_sSelectedDirPath != null) {
173: ContextEvent ce2 = new ContextEvent(
174: ContextType.CONTEXT_DIRS, null,
175: this .m_SelectedDirVFS, this .m_sSelectedDirPath);
176: ContextHandler.getInstance().fireContextEvent(ce2);
177: }
178: if (this .m_SelectedFileVFS != null
179: && this .m_sSelectedFilePath != null) {
180: ContextEvent ce2 = new ContextEvent(
181: ContextType.CONTEXT_FILES, null,
182: this.m_SelectedFileVFS,
183: this.m_sSelectedFilePath);
184: ContextHandler.getInstance().fireContextEvent(ce2);
185: this.m_displayManager.openMetadata();
186: } else {
187: this.m_displayManager.hideMetadata();
188: }
189: }
190: }
191:
192: }
|