@Override public void shellDeactivated(ShellEvent e) { if (iSMenuUp) return; final Shell editorShell = editor.getSite().getShell(); display.asyncExec(new Runnable() { // post to UI thread since editor shell only gets activated after popup has lost focus public void run() { Shell activeShell = display.getActiveShell(); if (activeShell != editorShell) { controller.cancelLinkedMode(); } } }); } });
protected void activateEditor() { editor.getSite().getShell().setActive(); }
public boolean ownsFocusShell() { if (popup == null) return false; if (popup.ownsFocusShell()) { return true; } Shell editorShell = editor.getSite().getShell(); Shell activeShell = editorShell.getDisplay().getActiveShell(); if (editorShell == activeShell) return true; return false; }
private Display getDisplay() { XtextEditor editor = this.editor; if (editor == null){ if(sourceViewer != null) return sourceViewer.getControl().getDisplay(); return null; } IWorkbenchPartSite site = editor.getSite(); if (site == null) return null; Shell shell = site.getShell(); if (shell == null || shell.isDisposed()) return null; Display display = shell.getDisplay(); if (display == null || display.isDisposed()) return null; return display; }
public void undoDocumentChanges() { final ISourceViewer viewer = editor.getInternalSourceViewer(); try { editor.getSite().getWorkbenchWindow().run(false, true, new IRunnableWithProgress() { public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { if (viewer instanceof ITextViewerExtension6) { IUndoManager undoManager = ((ITextViewerExtension6) viewer).getUndoManager(); if (undoManager instanceof IUndoManagerExtension) { IUndoManagerExtension undoManagerExtension = (IUndoManagerExtension) undoManager; IUndoContext undoContext = undoManagerExtension.getUndoContext(); IOperationHistory operationHistory = OperationHistoryFactory.getOperationHistory(); while (undoManager.undoable()) { if (startingUndoOperation != null && startingUndoOperation.equals(operationHistory.getUndoOperation(undoContext))) return; undoManager.undo(); } } } } }); syncUtil.waitForReconciler(editor); } catch (Exception e) { LOG.error(e.getMessage(), e); } } }
@Override public Image getDefaultImage() { IEditorRegistry editorRegistry = PlatformUI.getWorkbench().getEditorRegistry(); IEditorDescriptor editorDesc = editorRegistry.findEditor(getSite().getId()); ImageDescriptor imageDesc = editorDesc != null ? editorDesc.getImageDescriptor() : null; return imageDesc != null ? imageHelper.getImage(imageDesc) : super.getDefaultImage(); }
public void widgetDisposed(DisposeEvent e) { editor.getSite().getWorkbenchWindow().getPartService() .removePartListener(PopupVisibilityManager.this); if (!textWidget.isDisposed()) { textWidget.removeControlListener(PopupVisibilityManager.this); textWidget.removeMouseListener(PopupVisibilityManager.this); textWidget.removeKeyListener(PopupVisibilityManager.this); } editor.getSite().getShell().removeControlListener(PopupVisibilityManager.this); viewer.removeViewportListener(PopupVisibilityManager.this); if (menuImage != null) { menuImage.dispose(); menuImage = null; } if (menuManager != null) { menuManager.dispose(); menuManager = null; } } });
protected void start() { editor.getSite().getWorkbenchWindow().getPartService().addPartListener(this); final ISourceViewer viewer = editor.getInternalSourceViewer(); final StyledText textWidget = viewer.getTextWidget(); textWidget.addMouseListener(this); textWidget.addKeyListener(this); editor.getSite().getShell().addControlListener(this); viewer.addViewportListener(this); popup.addDisposeListener(new DisposeListener() {
Shell workbenchShell = editor.getSite().getShell(); final Display display = workbenchShell.getDisplay(); popup = new Shell(workbenchShell, SWT.ON_TOP | SWT.NO_TRIM | SWT.TOOL);