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.window.menus;
020:
021: import java.awt.Font;
022:
023: import javax.swing.JPopupMenu;
024:
025: import org.openharmonise.him.actions.*;
026: import org.openharmonise.him.actions.file.*;
027: import org.openharmonise.him.actions.publish.*;
028: import org.openharmonise.vfs.*;
029: import org.openharmonise.vfs.context.*;
030:
031: /**
032: * Context menu for right clicks in the table view on a specific resource.
033: *
034: * @author Matthew Large
035: * @version $Revision: 1.2 $
036: *
037: */
038: public class FileContextMenu extends JPopupMenu {
039:
040: /**
041: * Constructs a new file context menu.
042: *
043: * @param sPath full path to the file.
044: * @param vfs virtual file system of the file.
045: */
046: public FileContextMenu(String sPath, AbstractVirtualFileSystem vfs) {
047: super ();
048: this .setup(sPath, vfs);
049: }
050:
051: /**
052: * Initialises this component.
053: *
054: * @param sPath full path to the file.
055: * @param vfs virtual file system of the file.
056: */
057: private void setup(String sPath, AbstractVirtualFileSystem vfs) {
058: String fontName = "Dialog";
059: int fontSize = 11;
060: Font font = new Font(fontName, Font.PLAIN, fontSize);
061: this .setFont(font);
062:
063: ContextEvent ce = new ContextEvent(ContextType.CONTEXT_FILES,
064: "", vfs, sPath);
065:
066: HIMAction action = new ActionOpen();
067: this .add(action.getMenuItem());
068: action.isEnabled(ce);
069:
070: this .addSeparator();
071:
072: action = new ActionPreview();
073: this .add(action.getMenuItem());
074: action.isEnabled(ce);
075:
076: action = new ActionPublishToInternet();
077: this .add(action.getMenuItem());
078: action.isEnabled(ce);
079:
080: action = new ActionExport();
081: this .add(action.getMenuItem());
082: action.isEnabled(ce);
083:
084: this .addSeparator();
085:
086: action = new ActionArchive();
087: this .add(action.getMenuItem());
088: action.isEnabled(ce);
089:
090: action = new ActionRetrieve();
091: this .add(action.getMenuItem());
092: action.isEnabled(ce);
093:
094: this .addSeparator();
095:
096: //commenting out as renaming a resource changes the path
097: //which then can mess up property domain references
098: //will be fixed in later releases
099:
100: // action = new ActionRename();
101: // this.add(action.getMenuItem());
102: // action.isEnabled(ce);
103:
104: action = new ActionUpload();
105: this .add(action.getMenuItem());
106: action.isEnabled(ce);
107:
108: action = new ActionCreateCopy();
109: this .add(action.getMenuItem());
110: action.isEnabled(ce);
111:
112: this .addSeparator();
113:
114: action = new ActionSynchronise();
115: this .add(action.getMenuItem());
116: action.isEnabled(ce);
117:
118: action = new ActionLock();
119: this .add(action.getMenuItem());
120: action.isEnabled(ce);
121:
122: action = new ActionUnlock();
123: this .add(action.getMenuItem());
124: action.isEnabled(ce);
125:
126: }
127:
128: /**
129: * @param arg0
130: */
131: private FileContextMenu(String arg0) {
132: super(arg0);
133: }
134:
135: }
|