/*
* The contents of this file are subject to the
* Mozilla Public License Version 1.1 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS"
* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied.
* See the License for the specific language governing rights and
* limitations under the License.
*
* The Initial Developer of the Original Code is Simulacra Media Ltd.
* Portions created by Simulacra Media Ltd are Copyright (C) Simulacra Media Ltd, 2004.
*
* All Rights Reserved.
*
* Contributor(s):
*/
package org.openharmonise.him.actions.xslt;
import java.awt.event.ActionEvent;
import javax.swing.Icon;
import org.openharmonise.him.actions.*;
import org.openharmonise.him.actions.rules.*;
import org.openharmonise.him.editors.*;
import org.openharmonise.him.harmonise.*;
import org.openharmonise.vfs.*;
import org.openharmonise.vfs.context.*;
import org.openharmonise.vfs.gui.*;
/**
* Action to download the import hierarchy for a XSLT.
*
* @author Matthew Large
* @version $Revision: 1.1 $
*
*/
public class ActionDownloadImports
extends AbstractHIMAction
implements HIMAction {
/**
*
*/
public ActionDownloadImports() {
super();
this.setup();
}
/**
* @param vfFile
*/
public ActionDownloadImports(VirtualFile vfFile) {
super(vfFile);
this.setup();
}
/**
* Configures this action.
*
*/
public void setup() {
RuleGroup andGroup = new RuleGroup();
andGroup.setGroupType(RuleGroup.GROUPTYPE_AND);
RuleGroup orGroup = new RuleGroup();
orGroup.setGroupType(RuleGroup.GROUPTYPE_OR);
orGroup.addEnableRule( new PathRule( HarmonisePaths.PATH_XSLT ) );
orGroup.addEnableRule(new PathRule("/webdav/XSLResource"));
andGroup.addEnableRule(orGroup);
IsDirectoryRule dirRule = new IsDirectoryRule();
dirRule.setResultComparator(false);
andGroup.addEnableRule( dirRule );
super.addEnableRule(andGroup);
this.getButton().setVisible(false);
this.getMenuItem().setVisible(false);
}
/* (non-Javadoc)
* @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
*/
public void actionPerformed(ActionEvent arg0) {
XSLTEditor editor = new XSLTEditor();
editor.downloadImports(this.getLastContextFile());
}
/* (non-Javadoc)
* @see com.simulacramedia.contentmanager.actions.AbstractCMAction#getText()
*/
public String getText() {
return "Download imports";
}
/* (non-Javadoc)
* @see com.simulacramedia.contentmanager.actions.AbstractCMAction#getToolTip()
*/
public String getToolTip() {
return "Downloads all the imports required to be able to run an XSLT locally.";
}
/* (non-Javadoc)
* @see com.simulacramedia.contentmanager.actions.AbstractCMAction#getIcon()
*/
public Icon getIcon() {
return IconManager.getInstance().getIcon("16-blank.gif");
}
/* (non-Javadoc)
* @see com.simulacramedia.contentmanager.actions.AbstractCMAction#getMnemonic()
*/
public String getMnemonic() {
return "D";
}
/* (non-Javadoc)
* @see com.simulacramedia.contentmanager.actions.CMAction#getDescription()
*/
public String getDescription() {
return this.getToolTip();
}
/* (non-Javadoc)
* @see com.simulacramedia.contentmanager.actions.CMAction#getAcceleratorKeycode()
*/
public int getAcceleratorKeycode() {
return 0;
}
/* (non-Javadoc)
* @see com.simulacramedia.contentmanager.actions.CMAction#getAcceleratorMask()
*/
public int getAcceleratorMask() {
return 0;
}
/* (non-Javadoc)
* @see com.simulacramedia.contentmanager.actions.AbstractCMAction#isEnabled(com.simulacramedia.contentmanager.context.ContextEvent)
*/
public boolean isEnabled(ContextEvent ce) {
if(ce.CONTEXT_TYPE==ContextType.CONTEXT_FILES && super.isEnabled(ce)) {
this.getButton().setVisible(true);
this.getMenuItem().setVisible(true);
return true;
} else {
this.getButton().setVisible(false);
this.getMenuItem().setVisible(false);
return false;
}
}
}
|