1 11 package org.eclipse.ui.internal.dialogs; 12 13 import org.eclipse.core.runtime.CoreException; 14 import org.eclipse.core.runtime.IStatus; 15 import org.eclipse.jface.resource.ImageDescriptor; 16 import org.eclipse.swt.graphics.Image; 17 import org.eclipse.ui.IWorkbenchPropertyPage; 18 import org.eclipse.ui.internal.WorkbenchMessages; 19 import org.eclipse.ui.internal.misc.StatusUtil; 20 import org.eclipse.ui.internal.preferences.WorkbenchPreferenceExtensionNode; 21 import org.eclipse.ui.statushandlers.StatusManager; 22 23 28 public class PropertyPageNode extends WorkbenchPreferenceExtensionNode { 29 private RegistryPageContributor contributor; 30 31 private IWorkbenchPropertyPage page; 32 33 private Image icon; 34 35 private Object element; 36 37 42 public PropertyPageNode(RegistryPageContributor contributor, 43 Object element) { 44 super(contributor.getPageId(), contributor.getConfigurationElement()); 45 this.contributor = contributor; 46 this.element = element; 47 } 48 49 54 public void createPage() { 55 try { 56 page = contributor.createPage(element); 57 } catch (CoreException e) { 58 IStatus errStatus = StatusUtil.newStatus(e.getStatus(), WorkbenchMessages.PropertyPageNode_errorMessage); 61 StatusManager.getManager().handle(errStatus, StatusManager.SHOW); 62 page = new EmptyPropertyPage(); 63 } 64 setPage(page); 65 } 66 67 70 public void disposeResources() { 71 72 if (page != null) { 73 page.dispose(); 74 page = null; 75 } 76 if (icon != null) { 77 icon.dispose(); 78 icon = null; 79 } 80 } 81 82 85 public Image getLabelImage() { 86 if (icon == null) { 87 ImageDescriptor desc = contributor.getPageIcon(); 88 if (desc != null) { 89 icon = desc.createImage(); 90 } 91 } 92 return icon; 93 } 94 95 98 public String getLabelText() { 99 return contributor.getPageName(); 100 } 101 } 102 | Popular Tags |