1 11 package org.eclipse.ui.internal.dialogs; 12 13 import org.eclipse.core.runtime.Assert; 14 import org.eclipse.jface.wizard.IWizardPage; 15 import org.eclipse.jface.wizard.Wizard; 16 import org.eclipse.ui.IWorkingSet; 17 import org.eclipse.ui.dialogs.IWorkingSetNewWizard; 18 import org.eclipse.ui.dialogs.IWorkingSetPage; 19 import org.eclipse.ui.internal.WorkbenchMessages; 20 import org.eclipse.ui.internal.WorkbenchPlugin; 21 import org.eclipse.ui.internal.registry.WorkingSetDescriptor; 22 import org.eclipse.ui.internal.registry.WorkingSetRegistry; 23 24 31 public class WorkingSetNewWizard extends Wizard implements IWorkingSetNewWizard { 32 private WorkingSetTypePage workingSetTypePage; 33 34 private IWorkingSetPage workingSetEditPage; 35 36 private String editPageId; 37 38 private IWorkingSet workingSet; 39 40 private WorkingSetDescriptor[] descriptors; 41 42 47 public WorkingSetNewWizard(WorkingSetDescriptor[] descriptors) { 48 super(); 49 Assert.isTrue(descriptors != null && descriptors.length > 0); 50 this.descriptors= descriptors; 51 setWindowTitle(WorkbenchMessages.WorkingSetNewWizard_title); 52 } 53 54 62 public void addPages() { 63 super.addPages(); 64 65 IWizardPage page; 66 WorkingSetRegistry registry = WorkbenchPlugin.getDefault().getWorkingSetRegistry(); 67 68 if (descriptors.length > 1) { 69 page = workingSetTypePage = new WorkingSetTypePage(this.descriptors); 70 } else { 71 editPageId = descriptors[0].getId(); 72 page = workingSetEditPage = registry.getWorkingSetPage(editPageId); 73 } 74 page.setWizard(this); 75 addPage(page); 76 setForcePreviousAndNextButtons(descriptors.length > 1); 77 } 78 79 84 public boolean canFinish() { 85 return (workingSetEditPage != null && workingSetEditPage 86 .isPageComplete()); 87 } 88 89 97 public IWizardPage getNextPage(IWizardPage page) { 98 if (workingSetTypePage != null && page == workingSetTypePage) { 99 String pageId = workingSetTypePage.getSelection(); 100 if (pageId != null) { 101 if (workingSetEditPage == null || pageId != editPageId) { 102 WorkingSetRegistry registry = WorkbenchPlugin.getDefault() 103 .getWorkingSetRegistry(); 104 workingSetEditPage = registry.getWorkingSetPage(pageId); 105 addPage(workingSetEditPage); 106 editPageId = pageId; 107 } 108 return workingSetEditPage; 109 } 110 } 111 return null; 112 } 113 114 121 public IWorkingSet getSelection() { 122 return workingSet; 123 } 124 125 132 public boolean performFinish() { 133 workingSetEditPage.finish(); 134 workingSet = workingSetEditPage.getSelection(); 135 workingSet.setId(editPageId); 136 return true; 137 } 138 } 139 | Popular Tags |