01: /*******************************************************************************
02: * Copyright (c) 2002, 2007 IBM Corporation and others.
03: * All rights reserved. This program and the accompanying materials
04: * are made available under the terms of the Eclipse Public License v1.0
05: * which accompanies this distribution, and is available at
06: * http://www.eclipse.org/legal/epl-v10.html
07: *
08: * Contributors:
09: * IBM Corporation - initial API and implementation
10: *******************************************************************************/package org.eclipse.ui.internal.cheatsheets.views;
11:
12: import org.eclipse.swt.graphics.Color;
13: import org.eclipse.swt.layout.GridData;
14: import org.eclipse.swt.widgets.Composite;
15: import org.eclipse.swt.widgets.Control;
16: import org.eclipse.swt.widgets.Display;
17: import org.eclipse.ui.forms.widgets.FormToolkit;
18: import org.eclipse.ui.forms.widgets.ScrolledForm;
19: import org.eclipse.ui.forms.widgets.TableWrapLayout;
20: import org.eclipse.ui.internal.cheatsheets.CheatSheetStopWatch;
21:
22: public abstract class Page {
23: protected final static int HORZ_SCROLL_INCREMENT = 20;
24:
25: protected final static int VERT_SCROLL_INCREMENT = 20;
26:
27: // Colors
28: protected Color backgroundColor;
29:
30: protected FormToolkit toolkit;
31:
32: protected ScrolledForm form;
33:
34: public Page() {
35: }
36:
37: public Control getControl() {
38: return form;
39: }
40:
41: public void createPart(Composite parent) {
42: init(parent.getDisplay());
43: CheatSheetStopWatch.startStopWatch("Page.createInfoArea()"); //$NON-NLS-1$
44: CheatSheetStopWatch
45: .printLapTime(
46: "Page.createInfoArea()", "Time in Page.createInfoArea() after new FormToolkit(): "); //$NON-NLS-1$ //$NON-NLS-2$
47: form = toolkit.createScrolledForm(parent);
48: form.setData("novarrows", Boolean.TRUE); //$NON-NLS-1$
49: form.setText(ViewUtilities.escapeForLabel(getTitle()));
50: form.setDelayedReflow(true);
51: CheatSheetStopWatch
52: .printLapTime(
53: "Page.createInfoArea()", "Time in Page.createInfoArea() after createScrolledForm(): "); //$NON-NLS-1$ //$NON-NLS-2$
54: GridData gd = new GridData(GridData.FILL_BOTH);
55: gd.widthHint = 10;
56: form.setLayoutData(gd);
57: CheatSheetStopWatch
58: .printLapTime(
59: "Page.createInfoArea()", "Time in Page.createInfoArea() after setLayoutData(): "); //$NON-NLS-1$ //$NON-NLS-2$
60: TableWrapLayout layout = new TableWrapLayout();
61: CheatSheetStopWatch
62: .printLapTime(
63: "Page.createInfoArea()", "Time in Page.createInfoArea() after new FormTableWrapLayout(): "); //$NON-NLS-1$ //$NON-NLS-2$
64: layout.numColumns = 2;
65: // DG - added changes to make the check icon use less space
66: // and to compensate for the fix in section layout
67: // computation that makes it shorter for 3 pixels.
68: layout.leftMargin = 0;
69: layout.horizontalSpacing = 0;
70: layout.verticalSpacing = 3;
71: form.getBody().setLayout(layout);
72:
73: CheatSheetStopWatch
74: .printLapTime(
75: "Page.createInfoArea()", "Time in Page.createInfoArea() end of method: "); //$NON-NLS-1$ //$NON-NLS-2$
76: }
77:
78: public void dispose() {
79: if (form != null) {
80: form.dispose();
81: }
82:
83: if (toolkit != null) {
84: toolkit.dispose();
85: }
86: form = null;
87: toolkit = null;
88: }
89:
90: protected void init(Display display) {
91: toolkit = new FormToolkit(display);
92: backgroundColor = toolkit.getColors().getBackground();
93: }
94:
95: protected abstract String getTitle();
96:
97: public abstract void initialized();
98:
99: }
|