Search in sources :

Example 11 with IEditorSite

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();
}
Also used : IDocumentProvider(org.eclipse.ui.texteditor.IDocumentProvider) EntityEditor(org.jkiss.dbeaver.ui.editors.entity.EntityEditor) MultiPageEditorSite(org.eclipse.ui.part.MultiPageEditorSite) IEditorSite(org.eclipse.ui.IEditorSite)

Example 12 with IEditorSite

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);
    }
}
Also used : IWorkbenchPartSite(org.eclipse.ui.IWorkbenchPartSite) IEditorSite(org.eclipse.ui.IEditorSite)

Example 13 with IEditorSite

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);
    }
}
Also used : MenuManager(org.eclipse.jface.action.MenuManager) IEditorSite(org.eclipse.ui.IEditorSite)

Example 14 with IEditorSite

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();
}
Also used : ScrollingGraphicalViewer(org.eclipse.gef.ui.parts.ScrollingGraphicalViewer) ScalableFreeformRootEditPart(org.eclipse.gef.editparts.ScalableFreeformRootEditPart) GraphicalViewerKeyHandler(org.eclipse.gef.ui.parts.GraphicalViewerKeyHandler) GraphicalViewerKeyHandler(org.eclipse.gef.ui.parts.GraphicalViewerKeyHandler) KeyHandler(org.eclipse.gef.KeyHandler) IEditorSite(org.eclipse.ui.IEditorSite) ContextMenuProvider(org.eclipse.gef.ContextMenuProvider) SchemaContextMenuProvider(com.cubrid.common.ui.er.SchemaContextMenuProvider) SchemaContextMenuProvider(com.cubrid.common.ui.er.SchemaContextMenuProvider)

Example 15 with IEditorSite

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));
    }
}
Also used : Status(org.eclipse.core.runtime.Status) IStatus(org.eclipse.core.runtime.IStatus) IWorkbenchWindow(org.eclipse.ui.IWorkbenchWindow) IStatus(org.eclipse.core.runtime.IStatus) ISelectionProvider(org.eclipse.jface.viewers.ISelectionProvider) EditPosition(org.eclipse.ui.internal.texteditor.EditPosition) EditPosition(org.eclipse.ui.internal.texteditor.EditPosition) Position(org.eclipse.jface.text.Position) TextSelection(org.eclipse.jface.text.TextSelection) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) IEditorPart(org.eclipse.ui.IEditorPart) PartInitException(org.eclipse.ui.PartInitException) IEditorSite(org.eclipse.ui.IEditorSite)

Aggregations

IEditorSite (org.eclipse.ui.IEditorSite)26 IWorkbenchPartSite (org.eclipse.ui.IWorkbenchPartSite)7 List (java.util.List)5 Control (org.eclipse.swt.widgets.Control)5 IEditorPart (org.eclipse.ui.IEditorPart)5 PartInitException (org.eclipse.ui.PartInitException)5 IDocumentProvider (org.eclipse.ui.texteditor.IDocumentProvider)5 ITextEditor (org.eclipse.ui.texteditor.ITextEditor)5 InputStream (java.io.InputStream)4 ArrayList (java.util.ArrayList)4 StyledText (org.eclipse.swt.custom.StyledText)4 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)4 SelectionEvent (org.eclipse.swt.events.SelectionEvent)4 FillLayout (org.eclipse.swt.layout.FillLayout)4 GridData (org.eclipse.swt.layout.GridData)4 Composite (org.eclipse.swt.widgets.Composite)4 IWorkbenchWindow (org.eclipse.ui.IWorkbenchWindow)4 DBPDataSource (org.jkiss.dbeaver.model.DBPDataSource)4 DBPDataSourceContainer (org.jkiss.dbeaver.model.DBPDataSourceContainer)4 DBPIdentifierCase (org.jkiss.dbeaver.model.DBPIdentifierCase)4