1 19 20 package org.netbeans.modules.tasklist.client; 21 22 import java.awt.Image ; 23 import java.beans.PropertyChangeListener ; 24 import java.beans.PropertyChangeSupport ; 25 import org.openide.filesystems.FileObject; 26 27 import org.openide.text.Line; 28 import org.netbeans.modules.tasklist.client.SuggestionPriority; 29 30 109 abstract public class Suggestion { 110 111 112 SuggestionAgent agent; 113 114 private final PropertyChangeSupport supp = new PropertyChangeSupport (this); 115 116 117 public static final String PROP_SUMMARY = "summary"; 118 119 120 public static final String PROP_ICON = "icon"; 121 122 123 public static final String PROP_DETAILS = "details"; 124 125 126 public static final String PROP_PRIORITY = "priority"; 127 128 129 public static final String PROP_VALID = "valid"; 130 131 private boolean valid; 132 133 135 136 private Image icon = null; 137 138 private String summary = null; 139 140 141 private String details = null; 142 143 146 147 149 150 private SuggestionPriority priority = SuggestionPriority.MEDIUM; 151 152 156 private String type = null; 157 158 159 private Line line = null; 160 161 private SuggestionPerformer action = null; 162 163 private FileObject fo; 164 165 167 170 186 protected Suggestion(FileObject fo, final String type, 187 final String summary, final SuggestionPerformer action) { 188 this.fo = fo; 189 this.type = type; 190 this.summary = summary; 191 this.action = action; 192 valid = true; 193 } 194 195 200 public FileObject getFileObject() { 201 return fo; 202 } 203 204 209 protected void setFileObject(FileObject fo) { 210 this.fo = fo; 211 } 212 213 221 protected void setSummary(final String summary) { 222 if (summary == null) { 223 throw new NullPointerException (); 224 } 225 String old = getSummary(); 226 if (old.equals(summary)) return; 227 this.summary = summary; 228 firePropertyChange(PROP_SUMMARY, old, summary); 229 } 230 231 237 public String getSummary() { 238 if (summary == null) { 239 summary = ""; 240 } 241 return summary; 242 } 243 244 252 protected void setDetails(final String details) { 253 String old = getDetails(); 254 if (old.equals(details)) return; 255 this.details = details; 256 firePropertyChange(PROP_DETAILS, old, details); 257 } 258 259 266 public String getDetails() { 267 if (details == null) { 268 details = ""; 269 } 270 return details; 271 } 272 273 296 304 protected void setPriority(final SuggestionPriority priority) { 305 SuggestionPriority old = getPriority(); 306 if (old == priority) return; 307 this.priority = priority; 308 firePropertyChange(PROP_PRIORITY, old, priority); 309 } 310 311 317 public SuggestionPriority getPriority() { 318 return priority; 319 } 320 321 330 protected void setIcon(final Image icon) { 331 Image old = getIcon(); 332 if (old == icon) return; 333 this.icon = icon; 334 firePropertyChange(PROP_ICON, old, icon); 335 } 336 337 344 public Image getIcon() { 345 return icon; 346 } 347 348 356 protected void setLine(final Line line) { 357 this.line = line; 358 } 359 360 366 public Line getLine() { 367 return line; 368 } 369 370 378 protected final void setAction(final SuggestionPerformer action) { 379 this.action = action; 380 } 381 382 389 public SuggestionPerformer getAction() { 390 return action; 391 } 392 393 402 protected void setType(final String type) { 403 this.type = type; 404 } 405 406 412 public String getType() { 413 return type; 414 } 415 416 423 public abstract Object getSeed(); 424 425 431 public boolean isValid() { 432 return valid; 433 } 434 435 void invalidate() { 436 if (valid == false) return; 437 valid = false; 438 supp.firePropertyChange(PROP_VALID, true, false); 439 } 440 441 447 public final void addPropertyChangeListener(PropertyChangeListener l) { 448 supp.removePropertyChangeListener(l); 449 supp.addPropertyChangeListener(l); 450 } 451 452 459 public final void removePropertyChangeListener(PropertyChangeListener l) { 460 supp.removePropertyChangeListener(l); 461 } 462 463 464 473 protected void firePropertyChange(String propertyName, Object oldValue, Object newValue) { 474 supp.firePropertyChange(propertyName, oldValue, newValue); 475 } 476 } 477 | Popular Tags |