1 11 12 package org.eclipse.ui.internal.quickaccess; 13 14 import org.eclipse.jface.preference.IPreferenceNode; 15 import org.eclipse.jface.resource.ImageDescriptor; 16 import org.eclipse.swt.graphics.Image; 17 import org.eclipse.ui.IWorkbenchWindow; 18 import org.eclipse.ui.PlatformUI; 19 import org.eclipse.ui.internal.dialogs.PropertyDialog; 20 21 25 public class PropertiesElement extends QuickAccessElement { 26 27 private Object selectedElement; 28 private IPreferenceNode preferenceNode; 29 30 PropertiesElement(Object selectedElement, IPreferenceNode preferenceNode, PropertiesProvider propertiesProvider) { 31 super(propertiesProvider); 32 this.selectedElement = selectedElement; 33 this.preferenceNode = preferenceNode; 34 } 35 36 public void execute() { 37 IWorkbenchWindow window = PlatformUI.getWorkbench() 38 .getActiveWorkbenchWindow(); 39 if (window != null) { 40 PropertyDialog dialog = PropertyDialog.createDialogOn(window 41 .getShell(), preferenceNode.getId(), selectedElement); 42 dialog.open(); 43 } 44 } 45 46 public String getId() { 47 return preferenceNode.getId(); 48 } 49 50 public ImageDescriptor getImageDescriptor() { 51 Image image = preferenceNode.getLabelImage(); 52 if (image != null) { 53 ImageDescriptor descriptor = ImageDescriptor.createFromImage(image); 54 return descriptor; 55 } 56 return null; 57 } 58 59 public String getLabel() { 60 return preferenceNode.getLabelText(); 61 } 62 63 public int hashCode() { 64 final int prime = 31; 65 int result = 1; 66 result = prime * result 67 + ((preferenceNode == null) ? 0 : preferenceNode.hashCode()); 68 return result; 69 } 70 71 public boolean equals(Object obj) { 72 if (this == obj) 73 return true; 74 if (obj == null) 75 return false; 76 if (getClass() != obj.getClass()) 77 return false; 78 final PropertiesElement other = (PropertiesElement) obj; 79 if (preferenceNode == null) { 80 if (other.preferenceNode != null) 81 return false; 82 } else if (!preferenceNode.equals(other.preferenceNode)) 83 return false; 84 return true; 85 } 86 } 87 | Popular Tags |