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.actions.xslt;
020:
021: import java.awt.event.ActionEvent;
022:
023: import javax.swing.Icon;
024:
025: import org.openharmonise.him.actions.*;
026: import org.openharmonise.him.actions.rules.*;
027: import org.openharmonise.him.editors.*;
028: import org.openharmonise.him.harmonise.*;
029: import org.openharmonise.vfs.*;
030: import org.openharmonise.vfs.context.*;
031: import org.openharmonise.vfs.gui.*;
032:
033: /**
034: * Action to download the import hierarchy for a XSLT.
035: *
036: * @author Matthew Large
037: * @version $Revision: 1.1 $
038: *
039: */
040: public class ActionDownloadImports extends AbstractHIMAction implements
041: HIMAction {
042:
043: /**
044: *
045: */
046: public ActionDownloadImports() {
047: super ();
048: this .setup();
049: }
050:
051: /**
052: * @param vfFile
053: */
054: public ActionDownloadImports(VirtualFile vfFile) {
055: super (vfFile);
056: this .setup();
057: }
058:
059: /**
060: * Configures this action.
061: *
062: */
063: public void setup() {
064: RuleGroup andGroup = new RuleGroup();
065: andGroup.setGroupType(RuleGroup.GROUPTYPE_AND);
066: RuleGroup orGroup = new RuleGroup();
067: orGroup.setGroupType(RuleGroup.GROUPTYPE_OR);
068:
069: orGroup.addEnableRule(new PathRule(HarmonisePaths.PATH_XSLT));
070: orGroup.addEnableRule(new PathRule("/webdav/XSLResource"));
071: andGroup.addEnableRule(orGroup);
072: IsDirectoryRule dirRule = new IsDirectoryRule();
073: dirRule.setResultComparator(false);
074: andGroup.addEnableRule(dirRule);
075:
076: super .addEnableRule(andGroup);
077: this .getButton().setVisible(false);
078: this .getMenuItem().setVisible(false);
079: }
080:
081: /* (non-Javadoc)
082: * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
083: */
084: public void actionPerformed(ActionEvent arg0) {
085: XSLTEditor editor = new XSLTEditor();
086: editor.downloadImports(this .getLastContextFile());
087: }
088:
089: /* (non-Javadoc)
090: * @see com.simulacramedia.contentmanager.actions.AbstractCMAction#getText()
091: */
092: public String getText() {
093: return "Download imports";
094: }
095:
096: /* (non-Javadoc)
097: * @see com.simulacramedia.contentmanager.actions.AbstractCMAction#getToolTip()
098: */
099: public String getToolTip() {
100: return "Downloads all the imports required to be able to run an XSLT locally.";
101: }
102:
103: /* (non-Javadoc)
104: * @see com.simulacramedia.contentmanager.actions.AbstractCMAction#getIcon()
105: */
106: public Icon getIcon() {
107: return IconManager.getInstance().getIcon("16-blank.gif");
108: }
109:
110: /* (non-Javadoc)
111: * @see com.simulacramedia.contentmanager.actions.AbstractCMAction#getMnemonic()
112: */
113: public String getMnemonic() {
114: return "D";
115: }
116:
117: /* (non-Javadoc)
118: * @see com.simulacramedia.contentmanager.actions.CMAction#getDescription()
119: */
120: public String getDescription() {
121: return this .getToolTip();
122: }
123:
124: /* (non-Javadoc)
125: * @see com.simulacramedia.contentmanager.actions.CMAction#getAcceleratorKeycode()
126: */
127: public int getAcceleratorKeycode() {
128: return 0;
129: }
130:
131: /* (non-Javadoc)
132: * @see com.simulacramedia.contentmanager.actions.CMAction#getAcceleratorMask()
133: */
134: public int getAcceleratorMask() {
135: return 0;
136: }
137:
138: /* (non-Javadoc)
139: * @see com.simulacramedia.contentmanager.actions.AbstractCMAction#isEnabled(com.simulacramedia.contentmanager.context.ContextEvent)
140: */
141: public boolean isEnabled(ContextEvent ce) {
142: if (ce.CONTEXT_TYPE == ContextType.CONTEXT_FILES
143: && super .isEnabled(ce)) {
144: this .getButton().setVisible(true);
145: this .getMenuItem().setVisible(true);
146: return true;
147: } else {
148: this .getButton().setVisible(false);
149: this .getMenuItem().setVisible(false);
150: return false;
151: }
152: }
153:
154: }
|