1 11 package org.eclipse.ui.internal.cheatsheets.data; 12 13 import java.util.ArrayList ; 14 import java.util.Iterator ; 15 import org.eclipse.ui.internal.cheatsheets.views.CheatSheetManager; 16 17 public class PerformWhen implements IExecutableItem { 18 private String condition; 19 private ArrayList executables; 20 private AbstractExecutable selectedExecutable; 21 22 25 public PerformWhen() { 26 super(); 27 } 28 29 public PerformWhen(String condition) { 30 super(); 31 this.condition = condition; 32 } 33 34 38 public String getCondition() { 39 return condition; 40 } 41 42 46 public void setCondition(String newCondition) { 47 this.condition = newCondition; 48 } 49 50 53 public ArrayList getExecutables() { 54 return executables; 55 } 56 57 60 public void addExecutable(AbstractExecutable executable) { 61 if(executables == null) { 62 executables = new ArrayList (); 63 } 64 executables.add(executable); 65 } 66 67 68 72 public AbstractExecutable getExecutable() { 73 return null; 74 } 75 76 80 public void setExecutable(AbstractExecutable executable) { 81 addExecutable(executable); 82 } 83 84 public AbstractExecutable getSelectedExecutable() { 85 return selectedExecutable; 86 } 87 88 public void setSelectedExecutable(CheatSheetManager csm) { 89 String conditionValue = csm.getVariableData(condition); 90 91 for (Iterator iter = executables.iterator(); iter.hasNext();) { 92 AbstractExecutable executable = (AbstractExecutable) iter.next(); 93 if(executable.getWhen() != null && executable.getWhen().equals(conditionValue)) { 94 selectedExecutable = executable; 95 break; 96 } 97 } 98 } 99 100 } 101 | Popular Tags |