use of org.eclipse.ui.IEditorSite in project dbeaver by dbeaver.
the class SQLEditorNested method refreshPart.
@Override
public void refreshPart(Object source, boolean force) {
// Check if we are in saving process
// If so then no refresh needed (source text was updated during save)
IEditorSite editorSite = getEditorSite();
if (editorSite instanceof MultiPageEditorSite && ((MultiPageEditorSite) editorSite).getMultiPageEditor() instanceof EntityEditor && ((EntityEditor) ((MultiPageEditorSite) editorSite).getMultiPageEditor()).isSaveInProgress()) {
return;
}
final IDocumentProvider documentProvider = getDocumentProvider();
if (documentProvider instanceof SQLEditorNested.ObjectDocumentProvider) {
((SQLEditorNested.ObjectDocumentProvider) documentProvider).sourceText = null;
}
if (force) {
int caretOffset = getEditorControl().getCaretOffset();
super.setInput(getEditorInput());
// Try to keep cursor position
if (caretOffset < getEditorControl().getCharCount()) {
getEditorControl().setCaretOffset(caretOffset);
}
}
reloadSyntaxRules();
}
use of org.eclipse.ui.IEditorSite in project dbeaver by dbeaver.
the class ResultSetStatListener method handleResultSetSelectionChange.
@Override
public void handleResultSetSelectionChange(SelectionChangedEvent event) {
IResultSetSelection selection = viewer.getSelection();
IWorkbenchPartSite site = viewer.getSite();
if (site instanceof IEditorSite) {
// Use job with 100ms delay to avoid event spam
if (this.updateJob == null) {
this.updateJob = new SLUpdateJob();
}
this.updateJob.schedule(100);
}
}
use of org.eclipse.ui.IEditorSite in project dbeaver by dbeaver.
the class Spreadsheet method hookContextMenu.
private void hookContextMenu() {
MenuManager menuMgr = new MenuManager(null, AbstractPresentation.RESULT_SET_PRESENTATION_CONTEXT_MENU);
Menu menu = menuMgr.createContextMenu(this);
menuMgr.addMenuListener(manager -> {
// Let controller to provide it's own menu items
GridPos focusPos = getFocusPos();
presentation.fillContextMenu(manager, isHoveringOnRowHeader() ? null : focusPos.col >= 0 && focusPos.col < columnElements.length ? columnElements[focusPos.col] : null, isHoveringOnHeader() ? null : (focusPos.row >= 0 && focusPos.row < rowElements.length ? rowElements[focusPos.row] : null));
});
menuMgr.setRemoveAllWhenShown(true);
super.setMenu(menu);
if (site instanceof IEditorSite) {
// Exclude editor input contributions from context menu
((IEditorSite) site).registerContextMenu("spreadsheet_menu", menuMgr, presentation, false);
} else {
site.registerContextMenu(menuMgr, presentation);
}
}
use of org.eclipse.ui.IEditorSite in project cubrid-manager by CUBRID.
the class ERSchemaEditor method createGraphicalViewer.
/**
* Creates a new <code>GraphicalViewer</code>, configures, registers and
* initializes it.
*
* @param parent the parent composite
* @return a new <code>GraphicalViewer</code>
*/
protected void createGraphicalViewer(Composite parent) {
IEditorSite editorSite = getEditorSite();
ScrollingGraphicalViewer viewer = createGraphicalViewer(editorSite, parent);
ScalableFreeformRootEditPart rootEditPart = (ScalableFreeformRootEditPart) viewer.getRootEditPart();
zoomManager = rootEditPart.getZoomManager();
zoomManager.setZoomLevels(ZOOM_LEVELS);
// hook the viewer into the EditDomain
getEditDomain().addViewer(viewer);
// acticate the viewer as selection provider for Eclipse
getSite().setSelectionProvider(viewer);
viewer.setContents(erSchema);
ContextMenuProvider provider = new SchemaContextMenuProvider(viewer, getActionRegistry());
viewer.setContextMenu(provider);
getSite().registerContextMenu(provider.getId(), provider, viewer);
graphicalViewer = viewer;
// key handler
GraphicalViewerKeyHandler graphicalViewerKeyHandler = new GraphicalViewerKeyHandler(viewer);
KeyHandler parentKeyHandler = graphicalViewerKeyHandler.setParent(getCommonKeyHandler());
viewer.setKeyHandler(parentKeyHandler);
registDropTarget();
}
use of org.eclipse.ui.IEditorSite in project eclipse.platform.text by eclipse.
the class GotoLastEditPositionAction method run.
@Override
public void run() {
EditPosition editPosition = TextEditorPlugin.getDefault().getLastEditPosition();
if (editPosition == null)
return;
final Position pos = editPosition.getPosition();
if (pos == null || pos.isDeleted)
return;
IWorkbenchWindow window = getWindow();
if (window == null)
return;
IWorkbenchPage page = window.getActivePage();
IEditorPart editor;
try {
editor = page.openEditor(editPosition.getEditorInput(), editPosition.getEditorId());
} catch (PartInitException ex) {
// $NON-NLS-1$
IStatus status = new Status(IStatus.ERROR, TextEditorPlugin.PLUGIN_ID, IStatus.OK, "Go to Last Edit Location failed", ex);
TextEditorPlugin.getDefault().getLog().log(status);
return;
}
// Optimization - could also use else branch
if (editor instanceof ITextEditor) {
ITextEditor textEditor = (ITextEditor) editor;
textEditor.selectAndReveal(pos.offset, pos.length);
return;
}
/*
* Workaround: send out a text selection
* XXX: Needs to be improved, see https://bugs.eclipse.org/bugs/show_bug.cgi?id=32214
*/
if (editor != null) {
IEditorSite site = editor.getEditorSite();
if (site == null)
return;
ISelectionProvider provider = editor.getEditorSite().getSelectionProvider();
if (provider == null)
return;
provider.setSelection(new TextSelection(pos.offset, pos.length));
}
}
Aggregations