1 11 package org.eclipse.ui.internal.dialogs; 12 13 import org.eclipse.jface.dialogs.IDialogSettings; 14 import org.eclipse.jface.viewers.IStructuredSelection; 15 import org.eclipse.jface.wizard.WizardDialog; 16 import org.eclipse.swt.widgets.Composite; 17 import org.eclipse.swt.widgets.Control; 18 import org.eclipse.ui.IWorkbench; 19 import org.eclipse.ui.internal.IWorkbenchHelpContextIds; 20 import org.eclipse.ui.internal.WorkbenchMessages; 21 import org.eclipse.ui.internal.activities.ws.WorkbenchTriggerPoints; 22 import org.eclipse.ui.wizards.IWizardCategory; 23 import org.eclipse.ui.wizards.IWizardDescriptor; 24 25 34 class NewWizardSelectionPage extends WorkbenchWizardSelectionPage { 35 private IWizardCategory wizardCategories; 36 37 private NewWizardNewPage newResourcePage; 39 40 private IWizardDescriptor [] primaryWizards; 41 42 private boolean projectsOnly; 43 44 private boolean canFinishEarly = false, hasPages = true; 45 46 55 public NewWizardSelectionPage(IWorkbench workbench, 56 IStructuredSelection selection, IWizardCategory root, 57 IWizardDescriptor[] primary, boolean projectsOnly) { 58 super("newWizardSelectionPage", workbench, selection, null, WorkbenchTriggerPoints.NEW_WIZARDS); 60 setTitle(WorkbenchMessages.NewWizardSelectionPage_description); 61 wizardCategories = root; 62 primaryWizards = primary; 63 this.projectsOnly = projectsOnly; 64 } 65 66 69 public void advanceToNextPageOrFinish() { 70 if (canFlipToNextPage()) { 71 getContainer().showPage(getNextPage()); 72 } else if (canFinishEarly()) { 73 if (getWizard().performFinish()) { 74 ((WizardDialog)getContainer()).close(); 75 } 76 } 77 } 78 79 82 public void createControl(Composite parent) { 83 IDialogSettings settings = getDialogSettings(); 84 newResourcePage = new NewWizardNewPage(this, wizardCategories, 85 primaryWizards, projectsOnly); 86 newResourcePage.setDialogSettings(settings); 87 88 Control control = newResourcePage.createControl(parent); 89 getWorkbench().getHelpSystem().setHelp(control, 90 IWorkbenchHelpContextIds.NEW_WIZARD_SELECTION_WIZARD_PAGE); 91 setControl(control); 92 } 93 94 98 protected void saveWidgetValues() { 99 newResourcePage.saveWidgetValues(); 100 } 101 102 105 public boolean canFlipToNextPage() { 106 if (hasPages) { 108 return super.canFlipToNextPage(); 109 } 110 return false; 111 } 112 113 119 public void setHasPages(boolean newValue) { 120 hasPages = newValue; 121 } 122 123 129 public void setCanFinishEarly(boolean newValue) { 130 canFinishEarly = newValue; 131 } 132 133 139 public boolean canFinishEarly() { 140 return canFinishEarly; 141 } 142 } 143 | Popular Tags |