01: /*******************************************************************************
02: * Copyright (c) 2006, 2007 IBM Corporation and others.
03: * All rights reserved. This program and the accompanying materials
04: * are made available under the terms of the Eclipse Public License v1.0
05: * which accompanies this distribution, and is available at
06: * http://www.eclipse.org/legal/epl-v10.html
07: *
08: * Contributors:
09: * IBM Corporation - initial API and implementation
10: *******************************************************************************/package org.eclipse.ui.internal.quickaccess;
11:
12: import org.eclipse.jface.resource.ImageDescriptor;
13: import org.eclipse.ui.IWorkbenchWindow;
14: import org.eclipse.ui.PlatformUI;
15: import org.eclipse.ui.internal.actions.NewWizardShortcutAction;
16: import org.eclipse.ui.wizards.IWizardDescriptor;
17:
18: /**
19: * @since 3.3
20: *
21: */
22: public class WizardElement extends QuickAccessElement {
23:
24: private static final String separator = " - "; //$NON-NLS-1$
25:
26: private IWizardDescriptor wizardDescriptor;
27:
28: /* package */WizardElement(IWizardDescriptor wizardDescriptor,
29: WizardProvider wizardProvider) {
30: super (wizardProvider);
31: this .wizardDescriptor = wizardDescriptor;
32: }
33:
34: public void execute() {
35: IWorkbenchWindow window = PlatformUI.getWorkbench()
36: .getActiveWorkbenchWindow();
37: if (window != null) {
38: NewWizardShortcutAction wizardAction = new NewWizardShortcutAction(
39: window, wizardDescriptor);
40: wizardAction.run();
41: }
42: }
43:
44: public String getId() {
45: return wizardDescriptor.getId();
46: }
47:
48: public ImageDescriptor getImageDescriptor() {
49: return wizardDescriptor.getImageDescriptor();
50: }
51:
52: public String getLabel() {
53: return wizardDescriptor.getLabel() + separator
54: + wizardDescriptor.getDescription();
55: }
56:
57: public int hashCode() {
58: final int prime = 31;
59: int result = 1;
60: result = prime
61: * result
62: + ((wizardDescriptor == null) ? 0 : wizardDescriptor
63: .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: }
|