1 11 package org.eclipse.pde.ui.templates; 12 13 import org.eclipse.swt.SWT; 14 import org.eclipse.swt.layout.GridData; 15 import org.eclipse.swt.widgets.Composite; 16 import org.eclipse.swt.widgets.Control; 17 18 24 public abstract class AbstractChoiceOption extends TemplateOption { 25 protected String [][] fChoices; 26 private boolean fBlockListener; 27 28 43 public AbstractChoiceOption(BaseOptionTemplateSection section, String name, 44 String label, String [][] choices) { 45 super(section, name, label); 46 this.fChoices = choices; 47 } 48 49 50 55 public String getChoice() { 56 return getValue() != null ? getValue().toString() : null; 57 } 58 59 66 public void setValue(Object value) { 67 super.setValue(value); 68 setOptionValue(value); 69 } 70 71 protected abstract void setOptionValue(Object value); 72 73 77 public void setEnabled(boolean enabled) { 78 super.setEnabled(enabled); 79 setOptionEnabled(enabled); 80 } 81 82 protected abstract void setOptionEnabled(boolean enabled); 83 84 protected GridData fill(Control control, int span) { 85 GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_FILL); 86 gd.horizontalSpan = span; 87 control.setLayoutData(gd); 88 return gd; 89 } 90 91 protected Composite createComposite(Composite parent, int span) { 92 Composite composite = new Composite(parent, SWT.NULL); 93 fill(composite, span); 94 return composite; 95 } 96 97 protected void selectChoice(String choice) { 98 fBlockListener = true; 99 selectOptionChoice(choice); 100 fBlockListener = false; 101 } 102 103 protected abstract void selectOptionChoice(String choice); 104 105 protected boolean isBlocked() { 106 return fBlockListener; 107 } 108 } 109 | Popular Tags |