Search in sources :

Example 1 with EntityEditor

use of org.jkiss.dbeaver.ui.editors.entity.EntityEditor in project dbeaver by serge-rider.

the class PackageNavigateHandler method execute.

@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
    final OracleProcedurePackaged procedure = getSelectedProcedure(event);
    if (procedure != null) {
        OraclePackage procPackage = procedure.getParentObject();
        IEditorPart entityEditor = NavigatorHandlerObjectOpen.openEntityEditor(procPackage);
        if (entityEditor instanceof EntityEditor) {
            ((EntityEditor) entityEditor).switchFolder("source.definition");
            SQLEditorBase sqlEditor = entityEditor.getAdapter(SQLEditorBase.class);
            if (sqlEditor != null) {
                new NavigateJob(procedure, sqlEditor).schedule();
            }
        }
    }
    return null;
}
Also used : OracleProcedurePackaged(org.jkiss.dbeaver.ext.oracle.model.OracleProcedurePackaged) OraclePackage(org.jkiss.dbeaver.ext.oracle.model.OraclePackage) SQLEditorBase(org.jkiss.dbeaver.ui.editors.sql.SQLEditorBase) EntityEditor(org.jkiss.dbeaver.ui.editors.entity.EntityEditor) IEditorPart(org.eclipse.ui.IEditorPart)

Example 2 with EntityEditor

use of org.jkiss.dbeaver.ui.editors.entity.EntityEditor 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) {
        try {
            super.init(editorSite, getEditorInput());
        // setFocus();
        } catch (PartInitException e) {
            log.error(e);
        }
    }
    reloadSyntaxRules();
}
Also used : IDocumentProvider(org.eclipse.ui.texteditor.IDocumentProvider) EntityEditor(org.jkiss.dbeaver.ui.editors.entity.EntityEditor) PartInitException(org.eclipse.ui.PartInitException) MultiPageEditorSite(org.eclipse.ui.part.MultiPageEditorSite) IEditorSite(org.eclipse.ui.IEditorSite)

Example 3 with EntityEditor

use of org.jkiss.dbeaver.ui.editors.entity.EntityEditor in project dbeaver by dbeaver.

the class ItemListControl method fillCustomActions.

@Override
protected void fillCustomActions(IContributionManager contributionManager) {
    super.fillCustomActions(contributionManager);
    final DBNNode rootNode = getRootNode();
    if (rootNode instanceof DBNDatabaseFolder && ((DBNDatabaseFolder) rootNode).getItemsMeta() != null) {
        contributionManager.add(new Action(CoreMessages.obj_editor_properties_control_action_filter_setting, DBeaverIcons.getImageDescriptor(UIIcon.FILTER)) {

            @Override
            public void run() {
                NavigatorHandlerFilterConfig.configureFilters(getShell(), rootNode);
            }
        });
    }
    addColumnConfigAction(contributionManager);
    IWorkbenchSite workbenchSite = getWorkbenchSite();
    if (workbenchSite != null) {
        contributionManager.add(ActionUtils.makeCommandContribution(workbenchSite, IWorkbenchCommandConstants.FILE_REFRESH));
    }
    if (rootNode instanceof DBNDatabaseNode) {
        contributionManager.add(new Separator());
        contributionManager.add(ActionUtils.makeCommandContribution(workbenchSite, CoreCommands.CMD_OBJECT_OPEN));
        contributionManager.add(ActionUtils.makeCommandContribution(workbenchSite, CoreCommands.CMD_OBJECT_CREATE));
        contributionManager.add(ActionUtils.makeCommandContribution(workbenchSite, CoreCommands.CMD_OBJECT_DELETE));
    }
    if (rootNode instanceof DBNDatabaseNode && rootNode.isPersisted()) {
        boolean hasReorder = false;
        List<Class<?>> childrenTypes = ((DBNDatabaseNode) rootNode).getChildrenTypes(null);
        for (Class<?> chilType : childrenTypes) {
            if (EntityEditorsRegistry.getInstance().getObjectManager(chilType, DBEObjectReorderer.class) != null) {
                hasReorder = true;
                break;
            }
        }
        if (hasReorder) {
            contributionManager.add(new Separator());
            contributionManager.add(ActionUtils.makeCommandContribution(workbenchSite, CoreCommands.CMD_OBJECT_MOVE_UP));
            contributionManager.add(ActionUtils.makeCommandContribution(workbenchSite, CoreCommands.CMD_OBJECT_MOVE_DOWN));
        }
    }
    if (workbenchSite instanceof MultiPageEditorSite) {
        final MultiPageEditorPart editor = ((MultiPageEditorSite) workbenchSite).getMultiPageEditor();
        if (editor instanceof EntityEditor) {
            contributionManager.add(new Separator());
            DatabaseEditorUtils.contributeStandardEditorActions(workbenchSite, contributionManager);
        }
    }
}
Also used : IWorkbenchSite(org.eclipse.ui.IWorkbenchSite) Action(org.eclipse.jface.action.Action) DBNNode(org.jkiss.dbeaver.model.navigator.DBNNode) MultiPageEditorPart(org.eclipse.ui.part.MultiPageEditorPart) DBNDatabaseFolder(org.jkiss.dbeaver.model.navigator.DBNDatabaseFolder) DBEObjectReorderer(org.jkiss.dbeaver.model.edit.DBEObjectReorderer) EntityEditor(org.jkiss.dbeaver.ui.editors.entity.EntityEditor) DBNDatabaseNode(org.jkiss.dbeaver.model.navigator.DBNDatabaseNode) MultiPageEditorSite(org.eclipse.ui.part.MultiPageEditorSite) Separator(org.eclipse.jface.action.Separator)

Example 4 with EntityEditor

use of org.jkiss.dbeaver.ui.editors.entity.EntityEditor in project dbeaver by serge-rider.

the class WorkbenchContextListener method activatePartContexts.

void activatePartContexts(IWorkbenchPart part) {
    IContextService contextService = PlatformUI.getWorkbench().getService(IContextService.class);
    if (contextService == null) {
        return;
    }
    try {
        contextService.deferUpdates(true);
        if (part instanceof INavigatorModelView) {
        // We check for instanceof (do not use adapter) because otherwise it become active
        // for all entity editor and clashes with SQL editor and other complex stuff.
        // if (activationNavigator != null) {
        // //log.debug("Double activation of navigator context");
        // contextService.deactivateContext(activationNavigator);
        // }
        // activationNavigator = contextService.activateContext(INavigatorModelView.NAVIGATOR_CONTEXT_ID);
        }
        if (part instanceof SQLEditorBase || part.getAdapter(SQLEditorBase.class) != null) {
            if (activationSQL != null) {
                // log.debug("Double activation of SQL context");
                contextService.deactivateContext(activationSQL);
            }
            activationSQL = contextService.activateContext(SQLEditorContributions.SQL_EDITOR_CONTEXT);
        }
        if (part.getAdapter(ResultSetViewer.class) != null || (part instanceof SQLEditor) || (part instanceof EntityEditor && ((EntityEditor) part).getDatabaseObject() instanceof DBSDataContainer)) {
            if (activationResults != null) {
                contextService.deactivateContext(activationResults);
            }
            activationResults = contextService.activateContext(RESULTS_CONTEXT_ID);
        }
        // Refresh auto-commit element state (#3315)
        // Refresh OpenSeparateConnection
        ActionUtils.fireCommandRefresh(ConnectionCommands.CMD_TOGGLE_AUTOCOMMIT, SQLEditorCommands.CMD_TOGGLE_SEPARATE_CONNECTION);
    } finally {
        contextService.deferUpdates(false);
    }
}
Also used : SQLEditor(org.jkiss.dbeaver.ui.editors.sql.SQLEditor) SQLEditorBase(org.jkiss.dbeaver.ui.editors.sql.SQLEditorBase) IContextService(org.eclipse.ui.contexts.IContextService) INavigatorModelView(org.jkiss.dbeaver.ui.navigator.INavigatorModelView) EntityEditor(org.jkiss.dbeaver.ui.editors.entity.EntityEditor) DBSDataContainer(org.jkiss.dbeaver.model.struct.DBSDataContainer) ResultSetViewer(org.jkiss.dbeaver.ui.controls.resultset.ResultSetViewer)

Example 5 with EntityEditor

use of org.jkiss.dbeaver.ui.editors.entity.EntityEditor in project dbeaver by serge-rider.

the class PackageNavigateHandler method execute.

@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
    final OracleProcedurePackaged procedure = getSelectedProcedure(event);
    if (procedure != null) {
        OraclePackage procPackage = procedure.getParentObject();
        IEditorPart entityEditor = NavigatorHandlerObjectOpen.openEntityEditor(procPackage);
        if (entityEditor instanceof EntityEditor) {
            ((EntityEditor) entityEditor).switchFolder("source.definition");
            SQLEditorBase sqlEditor = entityEditor.getAdapter(SQLEditorBase.class);
            if (sqlEditor != null) {
                new NavigateJob(procedure, sqlEditor).schedule();
            }
        }
    }
    return null;
}
Also used : OracleProcedurePackaged(org.jkiss.dbeaver.ext.oracle.model.OracleProcedurePackaged) OraclePackage(org.jkiss.dbeaver.ext.oracle.model.OraclePackage) SQLEditorBase(org.jkiss.dbeaver.ui.editors.sql.SQLEditorBase) EntityEditor(org.jkiss.dbeaver.ui.editors.entity.EntityEditor) IEditorPart(org.eclipse.ui.IEditorPart)

Aggregations

EntityEditor (org.jkiss.dbeaver.ui.editors.entity.EntityEditor)17 IEditorPart (org.eclipse.ui.IEditorPart)8 MultiPageEditorSite (org.eclipse.ui.part.MultiPageEditorSite)6 InvocationTargetException (java.lang.reflect.InvocationTargetException)5 IWorkbenchWindow (org.eclipse.ui.IWorkbenchWindow)4 IWorkbenchSite (org.eclipse.ui.IWorkbenchSite)3 MultiPageEditorPart (org.eclipse.ui.part.MultiPageEditorPart)3 OraclePackage (org.jkiss.dbeaver.ext.oracle.model.OraclePackage)3 OracleProcedurePackaged (org.jkiss.dbeaver.ext.oracle.model.OracleProcedurePackaged)3 DBECommandContext (org.jkiss.dbeaver.model.edit.DBECommandContext)3 DBEObjectReorderer (org.jkiss.dbeaver.model.edit.DBEObjectReorderer)3 DBCException (org.jkiss.dbeaver.model.exec.DBCException)3 DBNDatabaseFolder (org.jkiss.dbeaver.model.navigator.DBNDatabaseFolder)3 DBNDatabaseNode (org.jkiss.dbeaver.model.navigator.DBNDatabaseNode)3 DBNNode (org.jkiss.dbeaver.model.navigator.DBNNode)3 SQLEditorBase (org.jkiss.dbeaver.ui.editors.sql.SQLEditorBase)3 ArrayList (java.util.ArrayList)2 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)2 Action (org.eclipse.jface.action.Action)2 Separator (org.eclipse.jface.action.Separator)2