1 11 package org.eclipse.ui.internal.cheatsheets.views; 12 13 import org.eclipse.swt.graphics.Color; 14 import org.eclipse.swt.layout.GridData; 15 import org.eclipse.swt.widgets.Composite; 16 import org.eclipse.swt.widgets.Control; 17 import org.eclipse.swt.widgets.Display; 18 import org.eclipse.ui.forms.widgets.FormToolkit; 19 import org.eclipse.ui.forms.widgets.ScrolledForm; 20 import org.eclipse.ui.forms.widgets.TableWrapLayout; 21 import org.eclipse.ui.internal.cheatsheets.CheatSheetStopWatch; 22 23 public abstract class Page { 24 protected final static int HORZ_SCROLL_INCREMENT = 20; 25 26 protected final static int VERT_SCROLL_INCREMENT = 20; 27 28 protected Color backgroundColor; 30 31 protected FormToolkit toolkit; 32 33 protected ScrolledForm form; 34 35 public Page() { 36 } 37 38 public Control getControl() { 39 return form; 40 } 41 42 public void createPart(Composite parent) { 43 init(parent.getDisplay()); 44 CheatSheetStopWatch.startStopWatch("Page.createInfoArea()"); CheatSheetStopWatch 46 .printLapTime( 47 "Page.createInfoArea()", "Time in Page.createInfoArea() after new FormToolkit(): "); form = toolkit.createScrolledForm(parent); 49 form.setData("novarrows", Boolean.TRUE); form.setText(ViewUtilities.escapeForLabel(getTitle())); 51 form.setDelayedReflow(true); 52 CheatSheetStopWatch 53 .printLapTime( 54 "Page.createInfoArea()", "Time in Page.createInfoArea() after createScrolledForm(): "); GridData gd = new GridData(GridData.FILL_BOTH); 56 gd.widthHint = 10; 57 form.setLayoutData(gd); 58 CheatSheetStopWatch 59 .printLapTime( 60 "Page.createInfoArea()", "Time in Page.createInfoArea() after setLayoutData(): "); TableWrapLayout layout = new TableWrapLayout(); 62 CheatSheetStopWatch 63 .printLapTime( 64 "Page.createInfoArea()", "Time in Page.createInfoArea() after new FormTableWrapLayout(): "); layout.numColumns = 2; 66 layout.leftMargin = 0; 70 layout.horizontalSpacing = 0; 71 layout.verticalSpacing = 3; 72 form.getBody().setLayout(layout); 73 74 CheatSheetStopWatch 75 .printLapTime( 76 "Page.createInfoArea()", "Time in Page.createInfoArea() end of method: "); } 78 79 public void dispose() { 80 if (form != null) { 81 form.dispose(); 82 } 83 84 if (toolkit != null) { 85 toolkit.dispose(); 86 } 87 form = null; 88 toolkit = null; 89 } 90 91 protected void init(Display display) { 92 toolkit = new FormToolkit(display); 93 backgroundColor = toolkit.getColors().getBackground(); 94 } 95 96 protected abstract String getTitle(); 97 98 public abstract void initialized(); 99 100 } 101 | Popular Tags |