1 11 package org.eclipse.ui.internal.cheatsheets.data; 12 13 import java.util.ArrayList ; 14 import java.util.Iterator ; 15 16 public class Item extends Intro implements IExecutableItem, IPerformWhenItem, ISubItemItem { 17 private String title; 18 private boolean skip; 19 private boolean dialog; 20 private ArrayList itemExtensions; 21 22 private AbstractExecutable executable; 23 private PerformWhen performWhen; 24 25 private ArrayList subItems; 26 private String completionMessage; 27 28 31 public Item() { 32 super(); 33 } 34 35 public Item(String title, String description, String href, String contextId, boolean skip, boolean dialog) { 36 super(description, href, contextId); 37 this.title = title; 38 this.skip = skip; 39 this.dialog = dialog; 40 } 41 42 46 public String getTitle() { 47 return this.title; 48 } 49 50 57 public boolean isDynamic() { 58 if( performWhen != null || hasDynamicSubItems()) { 59 return true; 60 } 61 62 return false; 63 } 64 65 69 public boolean isDialog() { 70 return this.dialog; 71 } 72 73 77 public boolean isSkip() { 78 return this.skip; 79 } 80 81 85 public void setDialog(boolean dialog) { 86 this.dialog = dialog; 87 } 88 89 92 public void setSkip(boolean skip) { 93 this.skip = skip; 94 } 95 96 100 public void setTitle(String title) { 101 this.title = title; 102 } 103 104 108 public void setItemExtensions(ArrayList exts){ 109 this.itemExtensions = exts; 110 } 111 112 116 public ArrayList getItemExtensions(){ 117 return itemExtensions; 118 } 119 120 123 public PerformWhen getPerformWhen() { 124 return performWhen; 125 } 126 127 130 public void setPerformWhen(PerformWhen performWhen) { 131 this.performWhen = performWhen; 132 } 133 134 137 public void addSubItem(AbstractSubItem subItem) { 138 if(subItems == null) { 139 subItems = new ArrayList (); 140 } 141 subItems.add(subItem); 142 } 143 144 147 public ArrayList getSubItems() { 148 return subItems; 149 } 150 151 private boolean hasDynamicSubItems() { 152 if( subItems != null) { 153 for (Iterator iter = subItems.iterator(); iter.hasNext();) { 154 AbstractSubItem subItem = (AbstractSubItem)iter.next(); 155 if( subItem instanceof RepeatedSubItem || 156 subItem instanceof ConditionalSubItem || 157 subItem instanceof SubItem && ((SubItem)subItem).getPerformWhen() != null ) { 158 return true; 159 } 160 } 161 } 162 163 return false; 164 } 165 166 public AbstractExecutable getExecutable() { 167 return executable; 168 } 169 170 public void setExecutable(AbstractExecutable executable) { 171 this.executable = executable; 172 } 173 174 public void setCompletionMessage(String message) { 175 this.completionMessage = message; 176 } 177 178 public String getCompletionMessage() { 179 return completionMessage; 180 } 181 } 182 | Popular Tags |