KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > pde > ui > internal > samples > ReviewPage


1 /*******************************************************************************
2  * Copyright (c) 2000, 2005 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11 package org.eclipse.pde.ui.internal.samples;
12
13 import org.eclipse.core.runtime.IConfigurationElement;
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.*;
20 import org.eclipse.swt.widgets.Composite;
21 import org.eclipse.ui.PlatformUI;
22 import org.eclipse.ui.forms.HyperlinkSettings;
23 import org.eclipse.ui.forms.widgets.ScrolledFormText;
24
25 public class ReviewPage extends WizardPage {
26     private SampleWizard wizard;
27     private ScrolledFormText formText;
28     /**
29      * @param pageName
30      */

31     public ReviewPage(SampleWizard wizard) {
32         super("last"); //$NON-NLS-1$
33
this.wizard = wizard;
34         setTitle(PDEUIMessages.ReviewPage_title); //$NON-NLS-1$
35
setDescription(PDEUIMessages.ReviewPage_desc); //$NON-NLS-1$
36
}
37     public void setVisible(boolean visible) {
38         setPageComplete(wizard.getSelection()!=null);
39         if (formText!=null)
40             updateContent();
41         super.setVisible(visible);
42     }
43     
44     private void updateContent() {
45         StringBuffer JavaDoc buf = new StringBuffer JavaDoc();
46         buf.append("<form>"); //$NON-NLS-1$
47
IConfigurationElement selection = wizard.getSelection();
48         if (selection!=null) {
49             setMessage(null);
50             IConfigurationElement [] desc = selection.getChildren("description"); //$NON-NLS-1$
51
if (desc.length==1)
52                 buf.append(NLS.bind(PDEUIMessages.ReviewPage_descContent, (new String JavaDoc[]{selection.getAttribute("name"), desc[0].getValue()}))); //$NON-NLS-1$ //$NON-NLS-2$
53
else
54                 buf.append(NLS.bind(PDEUIMessages.ReviewPage_content, selection.getAttribute("name"))); //$NON-NLS-1$ //$NON-NLS-2$
55
}
56         else {
57             setMessage(PDEUIMessages.ReviewPage_noSampleFound, WizardPage.WARNING); //$NON-NLS-1$
58
}
59         buf.append("</form>"); //$NON-NLS-1$
60
formText.setText(buf.toString());
61     }
62     /* (non-Javadoc)
63      * @see org.eclipse.jface.dialogs.IDialogPage#createControl(org.eclipse.swt.widgets.Composite)
64      */

65     public void createControl(Composite parent) {
66         Composite container = new Composite(parent, SWT.NULL);
67         GridLayout layout = new GridLayout();
68         container.setLayout(layout);
69         formText = new ScrolledFormText(container, true);
70         formText.setBackground(parent.getBackground());
71         GridData gd = new GridData(GridData.FILL_BOTH);
72         gd.widthHint = 300;
73         gd.heightHint = 300;
74         formText.setLayoutData(gd);
75         HyperlinkSettings settings = new HyperlinkSettings(parent.getDisplay());
76         formText.getFormText().setHyperlinkSettings(settings);
77         setControl(container);
78         updateContent();
79         
80         PlatformUI.getWorkbench().getHelpSystem().setHelp(container, IHelpContextIds.REVIEW);
81     }
82 }
83
Popular Tags