KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > openharmonise > him > window > menus > FileContextMenu


1 /*
2  * The contents of this file are subject to the
3  * Mozilla Public License Version 1.1 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at http://www.mozilla.org/MPL/
6  *
7  * Software distributed under the License is distributed on an "AS IS"
8  * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied.
9  * See the License for the specific language governing rights and
10  * limitations under the License.
11  *
12  * The Initial Developer of the Original Code is Simulacra Media Ltd.
13  * Portions created by Simulacra Media Ltd are Copyright (C) Simulacra Media Ltd, 2004.
14  *
15  * All Rights Reserved.
16  *
17  * Contributor(s):
18  */

19 package org.openharmonise.him.window.menus;
20
21 import java.awt.Font JavaDoc;
22
23 import javax.swing.JPopupMenu JavaDoc;
24
25 import org.openharmonise.him.actions.*;
26 import org.openharmonise.him.actions.file.*;
27 import org.openharmonise.him.actions.publish.*;
28 import org.openharmonise.vfs.*;
29 import org.openharmonise.vfs.context.*;
30
31
32 /**
33  * Context menu for right clicks in the table view on a specific resource.
34  *
35  * @author Matthew Large
36  * @version $Revision: 1.2 $
37  *
38  */

39 public class FileContextMenu extends JPopupMenu JavaDoc {
40
41     /**
42      * Constructs a new file context menu.
43      *
44      * @param sPath full path to the file.
45      * @param vfs virtual file system of the file.
46      */

47     public FileContextMenu(String JavaDoc sPath, AbstractVirtualFileSystem vfs) {
48         super();
49         this.setup(sPath, vfs);
50     }
51     
52     /**
53      * Initialises this component.
54      *
55      * @param sPath full path to the file.
56      * @param vfs virtual file system of the file.
57      */

58     private void setup(String JavaDoc sPath, AbstractVirtualFileSystem vfs) {
59         String JavaDoc fontName = "Dialog";
60         int fontSize = 11;
61         Font JavaDoc font = new Font JavaDoc(fontName, Font.PLAIN, fontSize);
62         this.setFont(font);
63         
64         ContextEvent ce = new ContextEvent(ContextType.CONTEXT_FILES, "", vfs, sPath);
65         
66         HIMAction action = new ActionOpen();
67         this.add(action.getMenuItem());
68         action.isEnabled(ce);
69         
70         this.addSeparator();
71         
72         action = new ActionPreview();
73         this.add(action.getMenuItem());
74         action.isEnabled(ce);
75         
76         action = new ActionPublishToInternet();
77         this.add(action.getMenuItem());
78         action.isEnabled(ce);
79         
80         action = new ActionExport();
81         this.add(action.getMenuItem());
82         action.isEnabled(ce);
83         
84         this.addSeparator();
85         
86         action = new ActionArchive();
87         this.add(action.getMenuItem());
88         action.isEnabled(ce);
89
90         action = new ActionRetrieve();
91         this.add(action.getMenuItem());
92         action.isEnabled(ce);
93         
94         this.addSeparator();
95         
96         //commenting out as renaming a resource changes the path
97
//which then can mess up property domain references
98
//will be fixed in later releases
99

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 JavaDoc arg0) {
132         super(arg0);
133     }
134
135 }
136
Popular Tags