1 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 31 public ReviewPage(SampleWizard wizard) { 32 super("last"); this.wizard = wizard; 34 setTitle(PDEUIMessages.ReviewPage_title); setDescription(PDEUIMessages.ReviewPage_desc); } 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 buf = new StringBuffer (); 46 buf.append("<form>"); IConfigurationElement selection = wizard.getSelection(); 48 if (selection!=null) { 49 setMessage(null); 50 IConfigurationElement [] desc = selection.getChildren("description"); if (desc.length==1) 52 buf.append(NLS.bind(PDEUIMessages.ReviewPage_descContent, (new String []{selection.getAttribute("name"), desc[0].getValue()}))); else 54 buf.append(NLS.bind(PDEUIMessages.ReviewPage_content, selection.getAttribute("name"))); } 56 else { 57 setMessage(PDEUIMessages.ReviewPage_noSampleFound, WizardPage.WARNING); } 59 buf.append("</form>"); formText.setText(buf.toString()); 61 } 62 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 |