1 19 package org.openharmonise.him.actions.xslt; 20 21 import java.awt.event.ActionEvent ; 22 23 import javax.swing.Icon ; 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 41 public class ActionDownloadImports 42 extends AbstractHIMAction 43 implements HIMAction { 44 45 48 public ActionDownloadImports() { 49 super(); 50 this.setup(); 51 } 52 53 56 public ActionDownloadImports(VirtualFile vfFile) { 57 super(vfFile); 58 this.setup(); 59 } 60 61 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 86 public void actionPerformed(ActionEvent arg0) { 87 XSLTEditor editor = new XSLTEditor(); 88 editor.downloadImports(this.getLastContextFile()); 89 } 90 91 94 public String getText() { 95 return "Download imports"; 96 } 97 98 101 public String getToolTip() { 102 return "Downloads all the imports required to be able to run an XSLT locally."; 103 } 104 105 108 public Icon getIcon() { 109 return IconManager.getInstance().getIcon("16-blank.gif"); 110 } 111 112 115 public String getMnemonic() { 116 return "D"; 117 } 118 119 122 public String getDescription() { 123 return this.getToolTip(); 124 } 125 126 129 public int getAcceleratorKeycode() { 130 return 0; 131 } 132 133 136 public int getAcceleratorMask() { 137 return 0; 138 } 139 140 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 |