1 11 12 package org.eclipse.ui.internal.quickaccess; 13 14 import org.eclipse.jface.resource.ImageDescriptor; 15 import org.eclipse.ui.IWorkbenchWindow; 16 import org.eclipse.ui.PlatformUI; 17 import org.eclipse.ui.internal.actions.NewWizardShortcutAction; 18 import org.eclipse.ui.wizards.IWizardDescriptor; 19 20 24 public class WizardElement extends QuickAccessElement { 25 26 private static final String separator = " - "; 28 private IWizardDescriptor wizardDescriptor; 29 30 WizardElement(IWizardDescriptor wizardDescriptor, WizardProvider wizardProvider) { 31 super(wizardProvider); 32 this.wizardDescriptor = wizardDescriptor; 33 } 34 35 public void execute() { 36 IWorkbenchWindow window = PlatformUI.getWorkbench() 37 .getActiveWorkbenchWindow(); 38 if (window != null) { 39 NewWizardShortcutAction wizardAction = new NewWizardShortcutAction( 40 window, wizardDescriptor); 41 wizardAction.run(); 42 } 43 } 44 45 public String getId() { 46 return wizardDescriptor.getId(); 47 } 48 49 public ImageDescriptor getImageDescriptor() { 50 return wizardDescriptor.getImageDescriptor(); 51 } 52 53 public String getLabel() { 54 return wizardDescriptor.getLabel() + separator 55 + wizardDescriptor.getDescription(); 56 } 57 58 public int hashCode() { 59 final int prime = 31; 60 int result = 1; 61 result = prime 62 * result 63 + ((wizardDescriptor == null) ? 0 : wizardDescriptor.hashCode()); 64 return result; 65 } 66 67 public boolean equals(Object obj) { 68 if (this == obj) 69 return true; 70 if (obj == null) 71 return false; 72 if (getClass() != obj.getClass()) 73 return false; 74 final WizardElement other = (WizardElement) obj; 75 if (wizardDescriptor == null) { 76 if (other.wizardDescriptor != null) 77 return false; 78 } else if (!wizardDescriptor.equals(other.wizardDescriptor)) 79 return false; 80 return true; 81 } 82 } 83 | Popular Tags |