1 13 package org.eclipse.ui.internal.ide.dialogs; 14 15 import org.eclipse.jface.viewers.ISelectionChangedListener; 16 import org.eclipse.jface.viewers.IStructuredSelection; 17 import org.eclipse.jface.viewers.SelectionChangedEvent; 18 import org.eclipse.jface.wizard.WizardPage; 19 import org.eclipse.swt.SWT; 20 import org.eclipse.swt.graphics.Font; 21 import org.eclipse.swt.layout.GridData; 22 import org.eclipse.swt.layout.GridLayout; 23 import org.eclipse.swt.widgets.Composite; 24 import org.eclipse.swt.widgets.Label; 25 import org.eclipse.swt.widgets.Text; 26 import org.eclipse.ui.PlatformUI; 27 import org.eclipse.ui.internal.ide.IDEWorkbenchMessages; 28 import org.eclipse.ui.internal.ide.IIDEHelpContextIds; 29 import org.eclipse.ui.internal.ide.misc.WizardStepGroup; 30 31 42 public class MultiStepReviewWizardPage extends WizardPage { 43 private Text detailsField; 44 45 private Label instructionLabel; 46 47 private WizardStepGroup stepGroup; 48 49 private MultiStepWizard stepWizard; 50 51 57 public MultiStepReviewWizardPage(String pageName, MultiStepWizard stepWizard) { 58 super(pageName); 59 this.stepWizard = stepWizard; 60 } 61 62 65 public boolean canFlipToNextPage() { 66 return isPageComplete() && !stepWizard.canFinishOnReviewPage(); 68 } 69 70 73 public void createControl(Composite parent) { 74 Composite composite = new Composite(parent, SWT.NULL); 75 GridLayout layout = new GridLayout(); 76 layout.numColumns = 2; 77 composite.setLayout(layout); 78 composite.setLayoutData(new GridData(GridData.FILL_BOTH)); 79 80 PlatformUI.getWorkbench().getHelpSystem().setHelp(composite, 81 IIDEHelpContextIds.NEW_PROJECT_REVIEW_WIZARD_PAGE); 82 83 createStepGroup(composite); 84 createDetailsGroup(composite); 85 createInstructionsGroup(composite); 86 87 setControl(composite); 88 } 89 90 93 private void createDetailsGroup(Composite parent) { 94 Font font = parent.getFont(); 95 Composite composite = new Composite(parent, SWT.NULL); 97 composite.setLayout(new GridLayout()); 98 composite.setLayoutData(new GridData(GridData.FILL_BOTH)); 99 100 Label label = new Label(composite, SWT.LEFT); 102 label.setText(IDEWorkbenchMessages.MultiStepReviewWizardPage_detailsLabel); 103 GridData data = new GridData(); 104 data.verticalAlignment = SWT.TOP; 105 label.setLayoutData(data); 106 label.setFont(font); 107 108 detailsField = new Text(composite, SWT.WRAP | SWT.MULTI | SWT.V_SCROLL 110 | SWT.BORDER); 111 detailsField.setText("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"); detailsField.setEditable(false); 113 detailsField.setLayoutData(new GridData(GridData.FILL_BOTH)); 114 detailsField.setFont(font); 115 } 116 117 120 private void createInstructionsGroup(Composite parent) { 121 instructionLabel = new Label(parent, SWT.LEFT); 122 instructionLabel.setText(IDEWorkbenchMessages.MultiStepReviewWizardPage_instructionFinishLabel); 123 GridData data = new GridData(); 124 data.verticalAlignment = SWT.TOP; 125 data.horizontalSpan = 2; 126 instructionLabel.setLayoutData(data); 127 instructionLabel.setFont(parent.getFont()); 128 } 129 130 133 private void createStepGroup(Composite parent) { 134 stepGroup = new WizardStepGroup(); 135 stepGroup.createContents(parent); 136 stepGroup.setSelectionListener(new ISelectionChangedListener() { 137 public void selectionChanged(SelectionChangedEvent event) { 138 if (event.getSelection() instanceof IStructuredSelection) { 139 IStructuredSelection sel = (IStructuredSelection) event 140 .getSelection(); 141 WizardStep step = (WizardStep) sel.getFirstElement(); 142 if (step != null) { 143 detailsField.setText(step.getDetails()); 144 } 145 } 146 } 147 }); 148 } 149 150 153 WizardStep[] getSteps() { 154 if (stepGroup != null) { 155 return stepGroup.getSteps(); 156 } 157 158 return new WizardStep[0]; 159 } 160 161 167 void setSteps(WizardStep[] steps) { 168 if (stepGroup != null) { 169 stepGroup.setSteps(steps); 170 } 171 } 172 173 176 public void setVisible(boolean visible) { 177 super.setVisible(visible); 178 if (visible) { 179 if (stepWizard.canFinishOnReviewPage()) { 180 instructionLabel.setText(IDEWorkbenchMessages.MultiStepReviewWizardPage_instructionFinishLabel); 181 } else { 182 instructionLabel.setText(IDEWorkbenchMessages.MultiStepReviewWizardPage_instructionNextLabel); 183 } 184 ((Composite) getControl()).layout(true); 185 } 186 } 187 } 188 | Popular Tags |