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 website resources.
031: *
032: * @author Matthew Large
033: * @version $Revision: 1.1 $
034: *
035: */
036: public class TemplatesDisplayComponent 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 website display component.
061: *
062: * @param displayManager Display manager
063: */
064: public TemplatesDisplayComponent(DisplayManager displayManager) {
065: super (displayManager);
066: ContextHandler.getInstance().addListener(
067: ContextType.CONTEXT_TABS, this );
068: }
069:
070: /**
071: * Constructs a new website display component.
072: *
073: * @param displayManager Display manager
074: * @param server Server
075: * @param sPath Full path to website collection
076: */
077: public TemplatesDisplayComponent(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.tree.TreeViewListener#directorySelected(com.simulacramedia.vfs.servers.Server, java.lang.String)
086: */
087: public void virtualFileSelected(AbstractVirtualFileSystem vfs,
088: String sPath) {
089: StateHandler.getInstance().addWait("TEMPLATES-DIR-SELECTION");
090: try {
091: this .m_SelectedDirVFS = vfs;
092: this .m_sSelectedDirPath = sPath;
093: this .m_SelectedFileVFS = null;
094: this .m_sSelectedFilePath = null;
095: this .m_tableView.setPath(vfs, sPath);
096: this .m_displayManager.hideMetadata();
097: ContextEvent ce = new ContextEvent(
098: ContextType.CONTEXT_DIRS, "", vfs, sPath);
099: ContextHandler.getInstance().fireContextEvent(ce);
100: } catch (Exception e) {
101: e.printStackTrace(System.err);
102: } finally {
103: StateHandler.getInstance().removeWait(
104: "TEMPLATES-DIR-SELECTION");
105: }
106: }
107:
108: /* (non-Javadoc)
109: * @see com.simulacramedia.contentmanager.displaycomponents.table.TableListener#fileSelection(com.simulacramedia.contentmanager.displaycomponents.table.TableEntry)
110: */
111: public void fileSelection(TableEntry entry) {
112: StateHandler.getInstance().addWait("TEMPLATES-FILE-SELECTION");
113: try {
114: ContextEvent ce = new ContextEvent(
115: ContextType.CONTEXT_FILES, null, entry.getVFS(),
116: entry.getPath());
117: this .m_SelectedFileVFS = entry.getVFS();
118: this .m_sSelectedFilePath = entry.getPath();
119: ContextHandler.getInstance().fireContextEvent(ce);
120: this .m_displayManager.openMetadata();
121: this .m_displayManager.scrollTableTo(entry.getLocation().x);
122: } catch (Exception e) {
123: e.printStackTrace(System.err);
124: } finally {
125: StateHandler.getInstance().removeWait(
126: "TEMPLATES-FILE-SELECTION");
127: }
128: }
129:
130: /* (non-Javadoc)
131: * @see com.simulacramedia.contentmanager.displaycomponents.table.TableListener#fileSelection(com.simulacramedia.contentmanager.displaycomponents.table.TableEntry)
132: */
133: public void fileSelection(VersionEntry entry) {
134: StateHandler.getInstance().addWait("TEMPLATES-FILE-SELECTION");
135: try {
136: ContextEvent ce = new ContextEvent(
137: ContextType.CONTEXT_FILES, null, entry.getVFS(),
138: entry.getPath());
139: this .m_SelectedFileVFS = entry.getVFS();
140: this .m_sSelectedFilePath = entry.getPath();
141: ContextHandler.getInstance().fireContextEvent(ce);
142: this .m_displayManager.openMetadata();
143: this .m_displayManager.scrollTableTo(entry
144: .getParentTableEntry().getLocation().x);
145: } catch (Exception e) {
146: e.printStackTrace(System.err);
147: } finally {
148: StateHandler.getInstance().removeWait(
149: "TEMPLATES-FILE-SELECTION");
150: }
151: }
152:
153: /* (non-Javadoc)
154: * @see com.simulacramedia.contentmanager.displaycomponents.AbstractTreeTableDisplayComponent#getTitle()
155: */
156: public String getTitle() {
157: return "Website";
158: }
159:
160: /* (non-Javadoc)
161: * @see com.simulacramedia.contentmanager.displaycomponents.AbstractTreeTableDisplayComponent#getIcon()
162: */
163: public String getIcon() {
164: return "16-website-container.gif";
165: }
166:
167: /* (non-Javadoc)
168: * @see com.simulacramedia.contentmanager.context.ContextListener#contextMessage(com.simulacramedia.contentmanager.context.ContextEvent)
169: */
170: public void contextMessage(ContextEvent ce) {
171: if (ce.CONTEXT_TYPE == ContextType.CONTEXT_TABS
172: && ce.getMessage().equalsIgnoreCase(this .getTitle())) {
173: if (this .m_SelectedDirVFS != null
174: && this .m_sSelectedDirPath != null) {
175: ContextEvent ce2 = new ContextEvent(
176: ContextType.CONTEXT_DIRS, null,
177: this .m_SelectedDirVFS, this .m_sSelectedDirPath);
178: ContextHandler.getInstance().fireContextEvent(ce2);
179: }
180: if (this .m_SelectedFileVFS != null
181: && this .m_sSelectedFilePath != null) {
182: ContextEvent ce2 = new ContextEvent(
183: ContextType.CONTEXT_FILES, null,
184: this.m_SelectedFileVFS,
185: this.m_sSelectedFilePath);
186: ContextHandler.getInstance().fireContextEvent(ce2);
187: this.m_displayManager.openMetadata();
188: } else {
189: this.m_displayManager.hideMetadata();
190: }
191: }
192: }
193:
194: }
|