KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > openharmonise > him > actions > xslt > ActionDownloadImports


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.actions.xslt;
20
21 import java.awt.event.ActionEvent JavaDoc;
22
23 import javax.swing.Icon JavaDoc;
24
25 import org.openharmonise.him.actions.*;
26 import org.openharmonise.him.actions.rules.*;
27 import org.openharmonise.him.editors.*;
28 import org.openharmonise.him.harmonise.*;
29 import org.openharmonise.vfs.*;
30 import org.openharmonise.vfs.context.*;
31 import org.openharmonise.vfs.gui.*;
32
33
34 /**
35  * Action to download the import hierarchy for a XSLT.
36  *
37  * @author Matthew Large
38  * @version $Revision: 1.1 $
39  *
40  */

41 public class ActionDownloadImports
42     extends AbstractHIMAction
43     implements HIMAction {
44
45     /**
46      *
47      */

48     public ActionDownloadImports() {
49         super();
50         this.setup();
51     }
52
53     /**
54      * @param vfFile
55      */

56     public ActionDownloadImports(VirtualFile vfFile) {
57         super(vfFile);
58         this.setup();
59     }
60     
61     /**
62      * Configures this action.
63      *
64      */

65     public void setup() {
66         RuleGroup andGroup = new RuleGroup();
67         andGroup.setGroupType(RuleGroup.GROUPTYPE_AND);
68         RuleGroup orGroup = new RuleGroup();
69         orGroup.setGroupType(RuleGroup.GROUPTYPE_OR);
70         
71         orGroup.addEnableRule( new PathRule( HarmonisePaths.PATH_XSLT ) );
72         orGroup.addEnableRule(new PathRule("/webdav/XSLResource"));
73         andGroup.addEnableRule(orGroup);
74         IsDirectoryRule dirRule = new IsDirectoryRule();
75         dirRule.setResultComparator(false);
76         andGroup.addEnableRule( dirRule );
77         
78         super.addEnableRule(andGroup);
79         this.getButton().setVisible(false);
80         this.getMenuItem().setVisible(false);
81     }
82
83     /* (non-Javadoc)
84      * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
85      */

86     public void actionPerformed(ActionEvent JavaDoc arg0) {
87         XSLTEditor editor = new XSLTEditor();
88         editor.downloadImports(this.getLastContextFile());
89     }
90
91     /* (non-Javadoc)
92      * @see com.simulacramedia.contentmanager.actions.AbstractCMAction#getText()
93      */

94     public String JavaDoc getText() {
95         return "Download imports";
96     }
97
98     /* (non-Javadoc)
99      * @see com.simulacramedia.contentmanager.actions.AbstractCMAction#getToolTip()
100      */

101     public String JavaDoc getToolTip() {
102         return "Downloads all the imports required to be able to run an XSLT locally.";
103     }
104
105     /* (non-Javadoc)
106      * @see com.simulacramedia.contentmanager.actions.AbstractCMAction#getIcon()
107      */

108     public Icon JavaDoc getIcon() {
109         return IconManager.getInstance().getIcon("16-blank.gif");
110     }
111
112     /* (non-Javadoc)
113      * @see com.simulacramedia.contentmanager.actions.AbstractCMAction#getMnemonic()
114      */

115     public String JavaDoc getMnemonic() {
116         return "D";
117     }
118
119     /* (non-Javadoc)
120      * @see com.simulacramedia.contentmanager.actions.CMAction#getDescription()
121      */

122     public String JavaDoc getDescription() {
123         return this.getToolTip();
124     }
125
126     /* (non-Javadoc)
127      * @see com.simulacramedia.contentmanager.actions.CMAction#getAcceleratorKeycode()
128      */

129     public int getAcceleratorKeycode() {
130         return 0;
131     }
132
133     /* (non-Javadoc)
134      * @see com.simulacramedia.contentmanager.actions.CMAction#getAcceleratorMask()
135      */

136     public int getAcceleratorMask() {
137         return 0;
138     }
139
140     /* (non-Javadoc)
141      * @see com.simulacramedia.contentmanager.actions.AbstractCMAction#isEnabled(com.simulacramedia.contentmanager.context.ContextEvent)
142      */

143     public boolean isEnabled(ContextEvent ce) {
144         if(ce.CONTEXT_TYPE==ContextType.CONTEXT_FILES && super.isEnabled(ce)) {
145             this.getButton().setVisible(true);
146             this.getMenuItem().setVisible(true);
147             return true;
148         } else {
149             this.getButton().setVisible(false);
150             this.getMenuItem().setVisible(false);
151             return false;
152         }
153     }
154
155 }
156
Popular Tags