1 11 package org.eclipse.ui.internal.cheatsheets.data; 12 13 import java.util.ArrayList ; 14 import java.util.Iterator ; 15 16 import org.eclipse.ui.internal.cheatsheets.views.CheatSheetManager; 17 18 public class ConditionalSubItem extends AbstractSubItem implements ISubItemItem { 19 private String condition; 20 private ArrayList subItems; 21 private SubItem selectedSubItem; 22 23 26 public ConditionalSubItem() { 27 super(); 28 } 29 30 public ConditionalSubItem(String condition) { 31 super(); 32 this.condition = condition; 33 } 34 35 39 public String getCondition() { 40 return condition; 41 } 42 43 47 public void setCondition(String newCondition) { 48 this.condition = newCondition; 49 } 50 51 54 public void addSubItem(AbstractSubItem subItem) { 55 if(subItems == null) { 56 subItems = new ArrayList (); 57 } 58 subItems.add(subItem); 59 } 60 61 64 public ArrayList getSubItems() { 65 return subItems; 66 } 67 68 public SubItem getSelectedSubItem() { 69 return selectedSubItem; 70 } 71 72 public void setSelectedSubItem(CheatSheetManager csm) { 73 String conditionValue = csm.getVariableData(condition); 74 75 for (Iterator iter = subItems.iterator(); iter.hasNext();) { 76 SubItem subItem = (SubItem) iter.next(); 77 if(subItem.getWhen() != null && subItem.getWhen().equals(conditionValue)) { 78 selectedSubItem = subItem; 79 break; 80 } 81 } 82 } 83 } 84 | Popular Tags |