1 11 package org.eclipse.ui.internal.ide.dialogs; 12 13 import org.eclipse.core.resources.IProject; 14 import org.eclipse.jface.viewers.StructuredSelection; 15 import org.eclipse.jface.wizard.IWizard; 16 import org.eclipse.osgi.util.NLS; 17 import org.eclipse.ui.ICapabilityUninstallWizard; 18 import org.eclipse.ui.PlatformUI; 19 import org.eclipse.ui.internal.ide.IDEWorkbenchMessages; 20 import org.eclipse.ui.internal.ide.IDEWorkbenchPlugin; 21 import org.eclipse.ui.internal.ide.registry.Capability; 22 import org.eclipse.ui.internal.ide.registry.CapabilityRegistry; 23 24 28 public class RemoveCapabilityStep extends WizardStep { 29 private Capability capability; 30 31 private String [] natureIds; 32 33 private IProject project; 34 35 private ICapabilityUninstallWizard wizard; 36 37 45 public RemoveCapabilityStep(int number, Capability capability, 46 String [] natureIds, IProject project) { 47 super(number); 48 this.capability = capability; 49 this.natureIds = natureIds; 50 this.project = project; 51 } 52 53 56 public String getLabel() { 57 return NLS.bind(IDEWorkbenchMessages.RemoveCapabilityStep_label, capability.getName()); 58 } 59 60 63 public String getDetails() { 64 String details = capability.getUninstallDetails(); 65 if (details == null) { 66 if (natureIds.length == 1) { 67 details = NLS.bind(IDEWorkbenchMessages.RemoveCapabilityStep_defaultDescription0, capability.getName()); 68 } else if (natureIds.length == 2) { 69 CapabilityRegistry reg = IDEWorkbenchPlugin.getDefault() 70 .getCapabilityRegistry(); 71 Capability otherCapability = reg 72 .getCapabilityForNature(natureIds[1]); 73 if (otherCapability == capability) 74 otherCapability = reg.getCapabilityForNature(natureIds[0]); 75 details = NLS.bind(IDEWorkbenchMessages.RemoveCapabilityStep_defaultDescription1, capability.getName(), otherCapability.getName()); 76 } else { 77 StringBuffer msg = new StringBuffer (); 78 CapabilityRegistry reg = IDEWorkbenchPlugin.getDefault() 79 .getCapabilityRegistry(); 80 for (int i = 0; i < natureIds.length; i++) { 81 Capability cap = reg.getCapabilityForNature(natureIds[i]); 82 if (cap != capability) { 83 msg.append("\n "); msg.append(cap.getName()); 85 } 86 } 87 details = NLS.bind(IDEWorkbenchMessages.RemoveCapabilityStep_defaultDescription2, capability.getName(), msg); 88 } 89 } 90 91 return details; 92 } 93 94 97 public IWizard getWizard() { 98 if (wizard == null) { 99 wizard = capability.getUninstallWizard(); 100 if (wizard == null) 101 wizard = new RemoveCapabilityWizard(); 102 if (wizard != null) { 103 wizard.init(PlatformUI.getWorkbench(), 104 StructuredSelection.EMPTY, project, natureIds); 105 wizard.addPages(); 106 } 107 } 108 109 return wizard; 110 } 111 112 } 113 | Popular Tags |