1 11 package org.eclipse.ui.views.properties.tabbed; 12 13 import org.eclipse.swt.SWT; 14 import org.eclipse.swt.custom.CCombo; 15 import org.eclipse.swt.custom.CLabel; 16 import org.eclipse.swt.custom.CTabFolder; 17 import org.eclipse.swt.custom.CTabItem; 18 import org.eclipse.swt.custom.ScrolledComposite; 19 import org.eclipse.swt.layout.FormLayout; 20 import org.eclipse.swt.widgets.Composite; 21 import org.eclipse.swt.widgets.Display; 22 import org.eclipse.swt.widgets.Group; 23 import org.eclipse.swt.widgets.List; 24 import org.eclipse.ui.forms.widgets.FormToolkit; 25 26 31 public class TabbedPropertySheetWidgetFactory 32 extends FormToolkit { 33 34 37 public TabbedPropertySheetWidgetFactory() { 38 super(Display.getCurrent()); 39 } 40 41 50 public CTabFolder createTabFolder(Composite parent, int style) { 51 CTabFolder tabFolder = new CTabFolder(parent, style); 52 return tabFolder; 53 } 54 55 64 public CTabItem createTabItem(CTabFolder tabFolder, int style) { 65 CTabItem tabItem = new CTabItem(tabFolder, style); 66 return tabItem; 67 } 68 69 78 public List createList(Composite parent, int style) { 79 List list = new org.eclipse.swt.widgets.List(parent, style); 80 return list; 81 } 82 83 public Composite createComposite(Composite parent, int style) { 84 Composite c = super.createComposite(parent, style); 85 paintBordersFor(c); 86 return c; 87 } 88 89 public Composite createComposite(Composite parent) { 90 Composite c = createComposite(parent, SWT.NONE); 91 return c; 92 } 93 94 103 public Composite createPlainComposite(Composite parent, int style) { 104 Composite c = super.createComposite(parent, style); 105 c.setBackground(parent.getBackground()); 106 paintBordersFor(c); 107 return c; 108 } 109 110 119 public ScrolledComposite createScrolledComposite(Composite parent, int style) { 120 ScrolledComposite scrolledComposite = new ScrolledComposite(parent, 121 style); 122 return scrolledComposite; 123 } 124 125 134 public CCombo createCCombo(Composite parent, int comboStyle) { 135 CCombo combo = new CCombo(parent, comboStyle); 136 adapt(combo, true, false); 137 if (getBorderStyle() == SWT.BORDER) { 139 combo.setData(FormToolkit.KEY_DRAW_BORDER, FormToolkit.TEXT_BORDER); 140 } 141 return combo; 142 } 143 144 151 public CCombo createCCombo(Composite parent) { 152 return createCCombo(parent, SWT.FLAT | SWT.READ_ONLY); 153 } 154 155 164 public Group createGroup(Composite parent, String text) { 165 Group group = new Group(parent, SWT.SHADOW_NONE); 166 group.setText(text); 167 group.setBackground(getColors().getBackground()); 168 group.setForeground(getColors().getForeground()); 169 return group; 170 } 171 172 179 public Composite createFlatFormComposite(Composite parent) { 180 Composite composite = createComposite(parent); 181 FormLayout layout = new FormLayout(); 182 layout.marginWidth = ITabbedPropertyConstants.HSPACE + 2; 183 layout.marginHeight = ITabbedPropertyConstants.VSPACE; 184 layout.spacing = ITabbedPropertyConstants.VMARGIN + 1; 185 composite.setLayout(layout); 186 return composite; 187 } 188 189 198 public CLabel createCLabel(Composite parent, String text) { 199 return createCLabel(parent, text, SWT.NONE); 200 } 201 202 213 public CLabel createCLabel(Composite parent, String text, int style) { 214 final CLabel label = new CLabel(parent, style); 215 label.setBackground(parent.getBackground()); 216 label.setText(text); 217 return label; 218 } 219 220 public void dispose() { 221 if (getColors() != null) { 222 super.dispose(); 223 } 224 } 225 } 226 | Popular Tags |