KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > ui > internal > quickaccess > WizardElement


1 /*******************************************************************************
2  * Copyright (c) 2006, 2007 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

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 /**
21  * @since 3.3
22  *
23  */

24 public class WizardElement extends QuickAccessElement {
25
26     private static final String JavaDoc separator = " - "; //$NON-NLS-1$
27

28     private IWizardDescriptor wizardDescriptor;
29
30     /* package */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 JavaDoc getId() {
46         return wizardDescriptor.getId();
47     }
48
49     public ImageDescriptor getImageDescriptor() {
50         return wizardDescriptor.getImageDescriptor();
51     }
52
53     public String JavaDoc 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 JavaDoc 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