01: /*******************************************************************************
02: * Copyright (c) 2000, 2006 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.pde.internal.ui.samples;
11:
12: import org.eclipse.core.runtime.IConfigurationElement;
13: import org.eclipse.jface.dialogs.IMessageProvider;
14: import org.eclipse.jface.wizard.WizardPage;
15: import org.eclipse.osgi.util.NLS;
16: import org.eclipse.pde.internal.ui.IHelpContextIds;
17: import org.eclipse.pde.internal.ui.PDEUIMessages;
18: import org.eclipse.swt.SWT;
19: import org.eclipse.swt.layout.GridData;
20: import org.eclipse.swt.layout.GridLayout;
21: import org.eclipse.swt.widgets.Composite;
22: import org.eclipse.ui.PlatformUI;
23: import org.eclipse.ui.forms.HyperlinkSettings;
24: import org.eclipse.ui.forms.widgets.ScrolledFormText;
25:
26: public class ReviewPage extends WizardPage {
27: private SampleWizard wizard;
28: private ScrolledFormText formText;
29:
30: /**
31: * @param pageName
32: */
33: public ReviewPage(SampleWizard wizard) {
34: super ("last"); //$NON-NLS-1$
35: this .wizard = wizard;
36: setTitle(PDEUIMessages.ReviewPage_title);
37: setDescription(PDEUIMessages.ReviewPage_desc);
38: }
39:
40: public void setVisible(boolean visible) {
41: setPageComplete(wizard.getSelection() != null);
42: if (formText != null)
43: updateContent();
44: super .setVisible(visible);
45: }
46:
47: private void updateContent() {
48: StringBuffer buf = new StringBuffer();
49: buf.append("<form>"); //$NON-NLS-1$
50: IConfigurationElement selection = wizard.getSelection();
51: if (selection != null) {
52: setMessage(null);
53: IConfigurationElement[] desc = selection
54: .getChildren("description"); //$NON-NLS-1$
55: if (desc.length == 1)
56: buf
57: .append(NLS
58: .bind(
59: PDEUIMessages.ReviewPage_descContent,
60: (new String[] {
61: selection
62: .getAttribute("name"), desc[0].getValue() }))); //$NON-NLS-1$
63: else
64: buf.append(NLS.bind(PDEUIMessages.ReviewPage_content,
65: selection.getAttribute("name"))); //$NON-NLS-1$
66: } else {
67: setMessage(PDEUIMessages.ReviewPage_noSampleFound,
68: IMessageProvider.WARNING);
69: }
70: buf.append("</form>"); //$NON-NLS-1$
71: formText.setText(buf.toString());
72: }
73:
74: /* (non-Javadoc)
75: * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
76: */
77: public void createControl(Composite parent) {
78: Composite container = new Composite(parent, SWT.NULL);
79: GridLayout layout = new GridLayout();
80: container.setLayout(layout);
81: formText = new ScrolledFormText(container, true);
82: formText.setBackground(parent.getBackground());
83: GridData gd = new GridData(GridData.FILL_BOTH);
84: gd.widthHint = 300;
85: gd.heightHint = 300;
86: formText.setLayoutData(gd);
87: HyperlinkSettings settings = new HyperlinkSettings(parent
88: .getDisplay());
89: formText.getFormText().setHyperlinkSettings(settings);
90: setControl(container);
91: updateContent();
92:
93: PlatformUI.getWorkbench().getHelpSystem().setHelp(container,
94: IHelpContextIds.REVIEW);
95: }
96: }
|