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 user resources.
031: *
032: * @author Matthew Large
033: * @version $Revision: 1.1 $
034: *
035: */
036: public class UserDisplayComponent 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 user display component.
061: *
062: * @param displayManager Display manager
063: */
064: public UserDisplayComponent(DisplayManager displayManager) {
065: super (displayManager);
066: ContextHandler.getInstance().addListener(
067: ContextType.CONTEXT_TABS, this );
068: }
069:
070: /**
071: * Constructs a new user display component.
072: *
073: * @param displayManager Display manager
074: * @param server Server
075: * @param sPath Full path to user collection
076: */
077: public UserDisplayComponent(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("USER-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("USER-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("USER-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()
125: .removeWait("USER-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("USER-FILE-SELECTION");
134: try {
135: ContextEvent ce = new ContextEvent(
136: ContextType.CONTEXT_FILES, null, entry.getVFS(),
137: entry.getPath());
138: this .m_SelectedFileVFS = entry.getVFS();
139: this .m_sSelectedFilePath = entry.getPath();
140: ContextHandler.getInstance().fireContextEvent(ce);
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()
148: .removeWait("USER-FILE-SELECTION");
149: }
150: }
151:
152: /* (non-Javadoc)
153: * @see com.simulacramedia.contentmanager.displaycomponents.AbstractTreeTableDisplayComponent#getTitle()
154: */
155: public String getTitle() {
156: return "Users";
157: }
158:
159: /* (non-Javadoc)
160: * @see com.simulacramedia.contentmanager.displaycomponents.AbstractTreeTableDisplayComponent#getIcon()
161: */
162: public String getIcon() {
163: return "16-user-container.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: }
|