@Override public void addPropertyListener(IPropertyListener l) { addListenerObject(l); }
/** * Sets the part site. * <p> * Subclasses must invoke this method from <code>IEditorPart.init</code> * and <code>IViewPart.init</code>. * * @param site the workbench part site */ protected void setSite(IWorkbenchPartSite site) { checkSite(site); this.partSite = site; }
@Override public void setPartProperty(String key, String value) { String oldValue = partProperties.get(key); if (value == null) { partProperties.remove(key); } else { partProperties.put(key, value); } firePartPropertyChanged(key, oldValue, value); }
void setDefaultTitle() { String description = getContentDescription(); String name = getPartName(); String newTitle = name; if (!Util.equals(description, "")) { //$NON-NLS-1$ newTitle = MessageFormat .format( WorkbenchMessages.WorkbenchPart_AutoTitleFormat, name, description); } setTitle(newTitle); }
void internalSetPartName(String partName) { partName = Util.safeString(partName); Assert.isNotNull(partName); //Do not send changes if they are the same if (Util.equals(this.partName, partName)) { return; } this.partName = partName; firePropertyChange(IWorkbenchPartConstants.PROP_PART_NAME); }
@Override public Image getTitleImage() { if (titleImage != null) { return titleImage; } return getDefaultImage(); }
@Override protected String getTableHeader(IWorkbenchPart activePart) { if (activePart instanceof WorkbenchPart) { return ((WorkbenchPart) activePart).getPartName(); } return activePart.getTitle(); }
/** * Fires a property changed event. * * @param propertyId the id of the property that changed */ protected void firePropertyChange(final int propertyId) { for (Object listener : getListeners()) { final IPropertyListener propertyListener = (IPropertyListener) listener; try { propertyListener.propertyChanged(WorkbenchPart.this, propertyId); } catch (RuntimeException e) { WorkbenchPlugin.log(e); } } }
/** * The <code>WorkbenchPart</code> implementation of this * <code>IWorkbenchPart</code> method disposes the title image * loaded by <code>setInitializationData</code>. Subclasses may extend. */ @Override public void dispose() { if (imageDescriptor != null) { JFaceResources.getResources().destroyImage(imageDescriptor); } // Clear out the property change listeners as we // should not be notifying anyone after the part // has been disposed. clearListeners(); partChangeListeners.clear(); }
@Override protected void setDialogLocation(final Shell dialog, IWorkbenchPart activePart) { if (dialog == null) return; // Default to center on the display Point dlgAnchor = Geometry.centerPoint(dialog.getDisplay().getBounds()); // Center the dialog within the activePart's pane (if any) if (activePart != null) { WorkbenchPart wbPart = (WorkbenchPart) activePart; PartSite site = (PartSite) wbPart.getSite(); Control paneCtrl = (Control) site.getModel().getWidget(); // Get the center of the view pane's control Rectangle viewBounds = paneCtrl.getBounds(); Point vCenter = Geometry.centerPoint(viewBounds); // Map it to the display dlgAnchor = paneCtrl.getParent().toDisplay(vCenter); } // Offset the point by half the dialog size Rectangle dialogBounds = dialog.getBounds(); dlgAnchor.x -= (dialogBounds.width / 2); dlgAnchor.y -= (dialogBounds.height / 2); dialog.setLocation(dlgAnchor); }
/** * Sets or clears the title tool tip text of this part. Clients should * call this method instead of overriding <code>getTitleToolTip</code> * * @param toolTip the new tool tip text, or <code>null</code> to clear */ protected void setTitleToolTip(String toolTip) { toolTip = Util.safeString(toolTip); //Do not send changes if they are the same if (Util.equals(this.toolTip, toolTip)) { return; } this.toolTip = toolTip; firePropertyChange(IWorkbenchPart.PROP_TITLE); }
void internalSetContentDescription(String description) { Assert.isNotNull(description); //Do not send changes if they are the same if (Util.equals(contentDescription, description)) { return; } this.contentDescription = description; if (partSite instanceof PartSite) { PartSite site = (PartSite) partSite; ContributedPartRenderer.setDescription(site.getModel(), description); } firePropertyChange(IWorkbenchPartConstants.PROP_CONTENT_DESCRIPTION); }
@Override protected final void checkSite(IWorkbenchPartSite site) { super.checkSite(site); Assert.isTrue(site instanceof IViewSite, "The site for a view must be an IViewSite"); //$NON-NLS-1$ } }
/** * Sets or clears the title of this part. Clients should call this method instead * of overriding getTitle. * <p> * This may change a title that was previously set using setPartName or setContentDescription. * </p> * * @deprecated new code should use setPartName and setContentDescription * * @param title the title, or <code>null</code> to clear */ @Deprecated protected void setTitle(String title) { title = Util.safeString(title); //Do not send changes if they are the same if (Util.equals(this.title, title)) { return; } this.title = title; firePropertyChange(IWorkbenchPart.PROP_TITLE); }
/** * Checks that the given site is valid for this type of part. * The site for an editor must be an <code>IEditorSite</code>. * * @param site the site to check * @since 3.1 */ @Override protected final void checkSite(IWorkbenchPartSite site) { super.checkSite(site); Assert.isTrue(site instanceof IEditorSite, "The site for an editor must be an IEditorSite"); //$NON-NLS-1$ }
/** * Sets or clears the title image of this part. * * @param titleImage the title image, or <code>null</code> to clear */ protected void setTitleImage(Image titleImage) { Assert.isTrue(titleImage == null || !titleImage.isDisposed()); //Do not send changes if they are the same if (this.titleImage == titleImage) { return; } this.titleImage = titleImage; firePropertyChange(IWorkbenchPart.PROP_TITLE); if (imageDescriptor != null) { JFaceResources.getResources().destroyImage(imageDescriptor); imageDescriptor = null; } }