@Override public Control getControl() { return part == null ? null : (Control) part.getWidget(); } };
/** * Create a new instance of this class based on the provided part. * * @param partSite the part to test */ public WorkbenchPartTestable(PartSite partSite) { Composite paneComposite = (Composite) partSite.getModel().getWidget(); Control [] paneChildren = paneComposite.getChildren(); this.composite = ((Composite) paneChildren[0]); }
private Object getCookieForTab(IEditorPart part) { if (part != null) { IWorkbenchPartSite site = part.getSite(); if (site instanceof PartSite) { PartSite partSite = (PartSite) site; WorkbenchPartReference ref = (WorkbenchPartReference) partSite.getPartReference(); if (!ref.isDisposed()) { return partSite.getModel().getWidget(); } } } return null; }
@Override public void partClosed(IWorkbenchPartReference partRef) { if (isPerTabHistoryEnabled() && partRef instanceof EditorReference) { if (!((EditorReference)partRef).isDisposed()) { Object editorTabCookie = ((EditorReference) partRef).getModel().getWidget(); disposeHistoryForTab(editorTabCookie); updateActions(); } } updateNavigationHistory(partRef, true); }
void close() { // 3.x implementation closes the editor when the ISL is disposed PartSite partSite = (PartSite) getSite(); MPart model = partSite.getModel(); Widget widget = (Widget) model.getWidget(); if (widget != null && !widget.isDisposed()) { getSite().getPage().closeEditor(MultiPageEditorPart.this, true); } }
void callingAllParts(Class<? extends Annotation> clz) { List<MPart> parts = ms.findElements(myPart, null, MPart.class); for (MPart part : parts) { if (part == myPart) { continue; } Control ctrl = (Control) part.getWidget(); if (part.getObject() != null && ctrl != null && !ctrl.isDisposed()) { ContextInjectionFactory.invoke(part.getObject(), clz, part.getContext(), null); } } }
@Focus void setFocus() { MPart ap = findInnerActive(myPart); if (ap == null) { if (Policy.DEBUG_FOCUS) { WorkbenchSWTActivator.trace(Policy.DEBUG_FOCUS_FLAG, "Focus not set, no selected element in: " + myPart, //$NON-NLS-1$ new IllegalStateException()); } return; } Control ctrl = (Control) ap.getWidget(); Object object = ap.getObject(); if (object != null && ctrl != null && !ctrl.isDisposed()) { ContextInjectionFactory.invoke(object, Focus.class, ap.getContext(), null); } else { if (Policy.DEBUG_FOCUS) { WorkbenchSWTActivator.trace(Policy.DEBUG_FOCUS_FLAG, "Focus not set, object is null or widget is disposed: " + object, new IllegalStateException()); //$NON-NLS-1$ } } }
/** * Enables the UI of the given parts containing this saveable after a * background save operation has finished. This method is not intended to be * called by clients. * <p> * The default implementation calls setEnabled(true) on the given parts' * composites. * </p> * * @param parts * the workbench parts containing this saveable * * @since 3.3 */ public void enableUI(IWorkbenchPart[] parts) { for (IWorkbenchPart workbenchPart : parts) { Composite paneComposite = (Composite) ((PartSite) workbenchPart.getSite()).getModel().getWidget(); Control[] paneChildren = paneComposite.getChildren(); Composite toEnable = ((Composite) paneChildren[0]); paneComposite.setCursor(originalCursor); if (waitCursor != null) { /* * waitCursor is always the System SWT.CURSOR_WAIT instance and * should never be disposed */ waitCursor = null; } toEnable.setEnabled(true); } }
@Override public final IWorkbenchPart getPart(boolean restore) { if (isDisposed()) { return null; } if (legacyPart == null) { if (restore && part.getWidget() == null) { // create the underlying client object backed by the part model // with the rendering engine EPartService partService = windowContext.get(EPartService.class); partService.showPart(part, PartState.CREATE); } // check if we were actually created, it is insufficient to check // whether the 'object' feature is valid or not because it is one of // the last things to be unset during the teardown process, this // means we may return a valid workbench part even if it is actually // in the process of being destroyed, see bug 328944 if (part.getObject() instanceof CompatibilityPart) { CompatibilityPart compatibilityPart = (CompatibilityPart) part.getObject(); if (compatibilityPart != null) { legacyPart = compatibilityPart.getPart(); } } else if (part.getObject() != null) { if (part.getTransientData().get(E4PartWrapper.E4_WRAPPER_KEY) instanceof E4PartWrapper) { return (IWorkbenchPart) part.getTransientData().get(E4PartWrapper.E4_WRAPPER_KEY); } } } return legacyPart; }
/** * Sets the dialog's location on the screen. * * @param dialog */ protected void setDialogLocation(final Shell dialog, IWorkbenchPart activePart) { Display display = dialog.getDisplay(); Rectangle dialogBounds = dialog.getBounds(); Rectangle parentBounds = dialog.getParent().getBounds(); // the bounds of the monitor that contains the currently active part. Rectangle monitorBounds = activePart == null ? display.getPrimaryMonitor().getBounds() : ((Control) ((PartSite) activePart.getSite()).getModel().getWidget()).getMonitor().getBounds(); // Place it in the center of its parent; dialogBounds.x = parentBounds.x + ((parentBounds.width - dialogBounds.width) / 2); dialogBounds.y = parentBounds.y + ((parentBounds.height - dialogBounds.height) / 2); if (!monitorBounds.contains(dialogBounds.x, dialogBounds.y) || !monitorBounds.contains(dialogBounds.x + dialogBounds.width, dialogBounds.y + dialogBounds.height)) { // Place it in the center of the monitor if it is not visible // when placed in the center of its parent. // Ensure the origin is visible on the screen. dialogBounds.x = Math.max(0, monitorBounds.x + (monitorBounds.width - dialogBounds.width) / 2); dialogBounds.y = Math.max(0, monitorBounds.y + (monitorBounds.height - dialogBounds.height) / 2); } dialog.setLocation(dialogBounds.x, dialogBounds.y); }
: ((Control) ((PartSite) activePart.getSite()).getModel().getWidget()).getMonitor() .getBounds();
public void markEditor(final IEditorPart part) { if (ignoreEntries > 0 || part == null) { return; } /* Ignore all entries until the async exec runs. Workaround to avoid * extra entry when using Open Declaration (F3) that opens another editor. */ ignoreEntries++; getDisplay().asyncExec(() -> { if (--ignoreEntries == 0) { if (part.getEditorSite() instanceof EditorSite) { EditorSite site = (EditorSite) part.getEditorSite(); Control c = (Control) site.getModel().getWidget(); if (c == null || c.isDisposed()) { return; } NavigationHistoryEntry e = getEntry(activeEntry); if (e != null && part.getEditorInput() != e.editorInfo.editorInput) { updateEntry(e); } addEntry(part); } } }); }
@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); }
/** * Forces the standby state of the intro part. * * @param standby update the standby state */ public void setStandby(final boolean standby) { final Control control = (Control) ((PartSite) getSite()).getModel().getWidget(); BusyIndicator.showWhile(control.getDisplay(), () -> { try { control.setRedraw(false); introPart.standbyStateChanged(standby); } finally { control.setRedraw(true); } setBarVisibility(standby); }); }
@Override public IStatus runInUIThread(IProgressMonitor monitor) { Control control = (Control) site.getModel().getWidget(); if (control == null || control.isDisposed()) { return Status.CANCEL_STATUS; } synchronized (lock) { //Update cursors if we are doing that Cursor cursor = null; if (waitCursorJobCount !=0) { // at least one job which is running has requested for wait cursor cursor = control.getDisplay().getSystemCursor(SWT.CURSOR_APPSTARTING); } control.setCursor(cursor); showBusy(busy); IWorkbenchPart part = site.getPart(); if (part instanceof WorkbenchPart) { ((WorkbenchPart) part).showBusy(busy); } } return Status.OK_STATUS; }
Control control = (Control) model.getWidget(); if (control != null && !control.isDisposed()) { return control.getShell();
if (site instanceof PartSite) { final MPart model = ((PartSite) site).getModel(); Composite partContainer = (Composite) model.getWidget(); if (partContainer != null) { Composite parent = partContainer.getParent();
if (site instanceof PartSite) { final MPart model = ((PartSite) site).getModel(); Composite partContainer = (Composite) model.getWidget(); if (partContainer != null) { Composite parent = partContainer.getParent();
Control ctrl = (Control) part.getWidget(); final Menu tmpMenu = (Menu) renderer.createGui(menuModel, ctrl.getShell(), part.getContext());