Search in sources :

Example 21 with IWorkbenchPartSite

use of org.eclipse.ui.IWorkbenchPartSite in project dbeaver by dbeaver.

the class ResultSetHandlerToggleMode method updateElement.

@Override
public void updateElement(UIElement element, Map parameters) {
    if (element.getServiceLocator() instanceof IWorkbenchPartSite) {
        IWorkbenchPartSite partSite = (IWorkbenchPartSite) element.getServiceLocator();
        if (partSite.getPart() instanceof IResultSetContainer) {
            IResultSetController rsv = ((IResultSetContainer) partSite.getPart()).getResultSetController();
            if (rsv != null) {
                if (!rsv.isRecordMode()) {
                    element.setText("Switch to record mode");
                    element.setChecked(true);
                } else {
                    element.setText("Switch to grid mode");
                    element.setChecked(false);
                }
            }
        }
    }
}
Also used : IWorkbenchPartSite(org.eclipse.ui.IWorkbenchPartSite) IResultSetContainer(org.jkiss.dbeaver.ui.controls.resultset.IResultSetContainer) IResultSetController(org.jkiss.dbeaver.ui.controls.resultset.IResultSetController)

Example 22 with IWorkbenchPartSite

use of org.eclipse.ui.IWorkbenchPartSite in project dbeaver by dbeaver.

the class ItemListControl method fillCustomActions.

@Override
public void fillCustomActions(IContributionManager contributionManager) {
    super.fillCustomActions(contributionManager);
    final DBNNode rootNode = getRootNode();
    if (rootNode instanceof DBNDatabaseFolder && ((DBNDatabaseFolder) rootNode).getItemsMeta() != null) {
        contributionManager.add(new Action(UINavigatorMessages.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 (rootNode instanceof DBNDatabaseFolder) {
        contributionManager.add(new Separator());
        contributionManager.add(ActionUtils.makeCommandContribution(workbenchSite, NavigatorCommands.CMD_OBJECT_OPEN));
        {
            if (ObjectPropertyTester.canCreateObject(rootNode, true)) {
                contributionManager.add(ActionUtils.makeCommandContribution(workbenchSite, NavigatorCommands.CMD_OBJECT_CREATE));
            } else if (ObjectPropertyTester.canCreateObject(rootNode, false)) {
                contributionManager.add(new Action(null, Action.AS_DROP_DOWN_MENU) {

                    {
                        setActionDefinitionId(NavigatorCommands.CMD_OBJECT_CREATE);
                    }

                    @Override
                    public void run() {
                        super.run();
                    }

                    @Override
                    public IMenuCreator getMenuCreator() {
                        return new MenuCreator(control -> {
                            List<IContributionItem> items = NavigatorHandlerObjectCreateNew.fillCreateMenuItems((IWorkbenchPartSite) workbenchSite, rootNode);
                            MenuManager menuManager = new MenuManager();
                            for (IContributionItem cc : items) {
                                menuManager.add(cc);
                            }
                            return menuManager;
                        });
                    }
                });
            }
        }
        contributionManager.add(ActionUtils.makeCommandContribution(workbenchSite, NavigatorCommands.CMD_OBJECT_DELETE));
    }
    if (rootNode instanceof DBNDatabaseNode && rootNode.isPersisted()) {
        boolean hasReorder = false;
        List<Class<?>> childrenTypes = ((DBNDatabaseNode) rootNode).getChildrenTypes(null);
        for (Class<?> chilType : childrenTypes) {
            if (DBWorkbench.getPlatform().getEditorsRegistry().getObjectManager(chilType, DBEObjectReorderer.class) != null) {
                hasReorder = true;
                break;
            }
        }
        if (hasReorder) {
            contributionManager.add(new Separator());
            contributionManager.add(ActionUtils.makeCommandContribution(workbenchSite, NavigatorCommands.CMD_OBJECT_MOVE_UP));
            contributionManager.add(ActionUtils.makeCommandContribution(workbenchSite, NavigatorCommands.CMD_OBJECT_MOVE_DOWN));
        }
    }
    if (rootNode instanceof DBNDatabaseNode) {
        // Expand/collapse
        final List<DBXTreeNode> inlineMetas = collectInlineMetas((DBNDatabaseNode) rootNode, ((DBNDatabaseNode) rootNode).getMeta());
        if (!inlineMetas.isEmpty()) {
            contributionManager.add(new Separator());
            contributionManager.add(ActionUtils.makeCommandContribution(workbenchSite, IWorkbenchCommandConstants.NAVIGATE_COLLAPSE_ALL, null, UIIcon.TREE_COLLAPSE_ALL));
            contributionManager.add(ActionUtils.makeCommandContribution(workbenchSite, IWorkbenchCommandConstants.NAVIGATE_EXPAND_ALL, null, UIIcon.TREE_EXPAND_ALL));
        }
    }
    // Save/revert
    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) MultiPageEditorPart(org.eclipse.ui.part.MultiPageEditorPart) DBWorkbench(org.jkiss.dbeaver.runtime.DBWorkbench) DatabaseLoadService(org.jkiss.dbeaver.model.runtime.load.DatabaseLoadService) ObjectPropertyTester(org.jkiss.dbeaver.ui.actions.ObjectPropertyTester) Arrays(java.util.Arrays) org.eclipse.jface.action(org.eclipse.jface.action) DBNNode(org.jkiss.dbeaver.model.navigator.DBNNode) org.jkiss.dbeaver.ui(org.jkiss.dbeaver.ui) IWorkbenchPartSite(org.eclipse.ui.IWorkbenchPartSite) IWorkbenchCommandConstants(org.eclipse.ui.IWorkbenchCommandConstants) NavigatorCommands(org.jkiss.dbeaver.ui.navigator.NavigatorCommands) PropertyEditorUtils(org.jkiss.dbeaver.ui.properties.PropertyEditorUtils) ArrayList(java.util.ArrayList) EntityEditor(org.jkiss.dbeaver.ui.editors.entity.EntityEditor) DBNUtils(org.jkiss.dbeaver.model.navigator.DBNUtils) Composite(org.eclipse.swt.widgets.Composite) NavigatorHandlerFilterConfig(org.jkiss.dbeaver.ui.navigator.actions.NavigatorHandlerFilterConfig) Log(org.jkiss.dbeaver.Log) DBRProgressMonitor(org.jkiss.dbeaver.model.runtime.DBRProgressMonitor) ObjectPropertyDescriptor(org.jkiss.dbeaver.runtime.properties.ObjectPropertyDescriptor) Font(org.eclipse.swt.graphics.Font) DBPObjectStatisticsCollector(org.jkiss.dbeaver.model.DBPObjectStatisticsCollector) DBUtils(org.jkiss.dbeaver.model.DBUtils) IWorkbenchSite(org.eclipse.ui.IWorkbenchSite) Collection(java.util.Collection) DBSObject(org.jkiss.dbeaver.model.struct.DBSObject) DBNDatabaseNode(org.jkiss.dbeaver.model.navigator.DBNDatabaseNode) DBSWrapper(org.jkiss.dbeaver.model.struct.DBSWrapper) ArrayUtils(org.jkiss.utils.ArrayUtils) org.eclipse.jface.viewers(org.eclipse.jface.viewers) DBPDataSourceContainer(org.jkiss.dbeaver.model.DBPDataSourceContainer) UINavigatorMessages(org.jkiss.dbeaver.ui.internal.UINavigatorMessages) InvocationTargetException(java.lang.reflect.InvocationTargetException) MultiPageEditorSite(org.eclipse.ui.part.MultiPageEditorSite) List(java.util.List) Color(org.eclipse.swt.graphics.Color) SWT(org.eclipse.swt.SWT) DatabaseEditorUtils(org.jkiss.dbeaver.ui.editors.DatabaseEditorUtils) DBXTreeNode(org.jkiss.dbeaver.model.navigator.meta.DBXTreeNode) NavigatorHandlerObjectCreateNew(org.jkiss.dbeaver.ui.navigator.actions.NavigatorHandlerObjectCreateNew) DBEObjectReorderer(org.jkiss.dbeaver.model.edit.DBEObjectReorderer) DBNDatabaseFolder(org.jkiss.dbeaver.model.navigator.DBNDatabaseFolder) DBNNode(org.jkiss.dbeaver.model.navigator.DBNNode) MultiPageEditorPart(org.eclipse.ui.part.MultiPageEditorPart) DBNDatabaseFolder(org.jkiss.dbeaver.model.navigator.DBNDatabaseFolder) IWorkbenchPartSite(org.eclipse.ui.IWorkbenchPartSite) DBXTreeNode(org.jkiss.dbeaver.model.navigator.meta.DBXTreeNode) DBEObjectReorderer(org.jkiss.dbeaver.model.edit.DBEObjectReorderer) ArrayList(java.util.ArrayList) List(java.util.List) EntityEditor(org.jkiss.dbeaver.ui.editors.entity.EntityEditor) DBNDatabaseNode(org.jkiss.dbeaver.model.navigator.DBNDatabaseNode) MultiPageEditorSite(org.eclipse.ui.part.MultiPageEditorSite)

Example 23 with IWorkbenchPartSite

use of org.eclipse.ui.IWorkbenchPartSite in project xtext-xtend by eclipse.

the class OpenEditorAction method run.

@Override
public void run() {
    if (inputFile == null) {
        return;
    }
    IWorkbenchPartSite workbenchPartSite = derivedSourceView.getSite();
    IWorkbenchPage workbenchPage = workbenchPartSite.getPage();
    try {
        IEditorPart editorPart = workbenchPage.openEditor(new FileEditorInput(inputFile), COMPILATION_UNIT_EDITOR_ID, true, IWorkbenchPage.MATCH_ID | IWorkbenchPage.MATCH_INPUT);
        if (selectedRegion != null) {
            ((ITextEditor) editorPart).selectAndReveal(selectedRegion.getOffset(), selectedRegion.getLength());
        }
    } catch (PartInitException partInitException) {
        throw new WrappedRuntimeException(partInitException);
    }
}
Also used : IWorkbenchPartSite(org.eclipse.ui.IWorkbenchPartSite) ITextEditor(org.eclipse.ui.texteditor.ITextEditor) FileEditorInput(org.eclipse.ui.part.FileEditorInput) IWorkbenchPage(org.eclipse.ui.IWorkbenchPage) IEditorPart(org.eclipse.ui.IEditorPart) PartInitException(org.eclipse.ui.PartInitException) WrappedRuntimeException(org.eclipse.core.internal.utils.WrappedRuntimeException)

Example 24 with IWorkbenchPartSite

use of org.eclipse.ui.IWorkbenchPartSite in project tmdm-studio-se by Talend.

the class TestTriggerAction method doRun.

@Override
protected void doRun() {
    com.amalto.workbench.utils.MDMServerDef serverDef = getServerDef();
    if (serverDef == null) {
        return;
    }
    boolean canConnect = checkConnection(serverDef.getUrl(), serverDef.getUser(), serverDef.getPasswd());
    if (!canConnect) {
        MessageDialog.openError(getShell(), Messages.RoutingRuleMainPage2_CheckConnection, Messages.RoutingRuleMainPage2_UnableToConnect);
        return;
    }
    try {
        service = Util.getMDMService(new URL(serverDef.getUrl()), serverDef.getUser(), serverDef.getPasswd());
        IWorkbenchPartSite site = commonViewer.getCommonNavigator().getSite();
        dialog = new DataClusterDialog(getShell(), new TreeObject(), site);
        dialog.setDefaultServerDef(serverDef);
        dialog.setOkLabel(Messages.TestTriggerAction_Test);
        dialog.setCancelLabel(Messages.TestTriggerAction_Close);
        dialog.setSelectionListener(this);
        dialog.open();
    } catch (Exception e) {
        log.error(e.getMessage(), e);
    }
}
Also used : IWorkbenchPartSite(org.eclipse.ui.IWorkbenchPartSite) TreeObject(com.amalto.workbench.models.TreeObject) URL(java.net.URL) DataClusterDialog(com.amalto.workbench.editors.DataClusterDialog)

Example 25 with IWorkbenchPartSite

use of org.eclipse.ui.IWorkbenchPartSite in project tmdm-studio-se by Talend.

the class NewProcessAction method doRun.

@Override
protected void doRun() {
    parentItem = null;
    selectObj = getSelectedObject().get(0);
    int type = getType();
    if (selectObj instanceof IRepositoryViewObject) {
        Item pItem = ((IRepositoryViewObject) selectObj).getProperty().getItem();
        if (pItem instanceof ContainerItem) {
            parentItem = (ContainerItem) pItem;
        }
    }
    IWorkbenchPartSite site = commonViewer.getCommonNavigator().getSite();
    // wizard
    NewProcessWizard newProcessWizard = new NewProcessWizard(site, type);
    WizardDialog wizardDialog = new WizardDialog(getShell(), newProcessWizard);
    wizardDialog.setPageSize(500, 260);
    if (wizardDialog.open() == IDialogConstants.OK_ID) {
        WSTransformerV2E newProcess = newProcessWizard.getNewProcess();
        final Item item = createServerObject(newProcess);
        commonViewer.refresh(selectObj);
        commonViewer.expandToLevel(selectObj, 1);
        openEditor(item);
        if (newProcessWizard.isCreateJob()) {
            generateJobTemplate(newProcessWizard.getType(), newProcessWizard.getProcessName(), newProcessWizard.getReturnMessages(), newProcessWizard.isEnableRedirect(), newProcessWizard.getRedirectUrl(), newProcessWizard.getJobTemplates());
            refreshJobEditorTitle(item);
        }
    }
}
Also used : IWorkbenchPartSite(org.eclipse.ui.IWorkbenchPartSite) WSTransformerV2Item(org.talend.mdm.repository.model.mdmproperties.WSTransformerV2Item) ProcessItem(org.talend.core.model.properties.ProcessItem) Item(org.talend.core.model.properties.Item) ContainerItem(org.talend.mdm.repository.model.mdmproperties.ContainerItem) ContainerItem(org.talend.mdm.repository.model.mdmproperties.ContainerItem) WSTransformerV2E(org.talend.mdm.repository.model.mdmserverobject.WSTransformerV2E) IRepositoryViewObject(org.talend.core.model.repository.IRepositoryViewObject) NewProcessWizard(org.talend.mdm.repository.ui.wizards.process.NewProcessWizard) WizardDialog(org.eclipse.jface.wizard.WizardDialog)

Aggregations

IWorkbenchPartSite (org.eclipse.ui.IWorkbenchPartSite)73 IWorkbenchPart (org.eclipse.ui.IWorkbenchPart)13 ISelection (org.eclipse.jface.viewers.ISelection)12 IEditorPart (org.eclipse.ui.IEditorPart)12 ArrayList (java.util.ArrayList)10 MenuManager (org.eclipse.jface.action.MenuManager)9 ISelectionProvider (org.eclipse.jface.viewers.ISelectionProvider)9 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)9 Composite (org.eclipse.swt.widgets.Composite)9 Display (org.eclipse.swt.widgets.Display)9 Shell (org.eclipse.swt.widgets.Shell)9 IWorkbenchWindow (org.eclipse.ui.IWorkbenchWindow)9 Menu (org.eclipse.swt.widgets.Menu)7 IEditorSite (org.eclipse.ui.IEditorSite)7 IWorkbenchPage (org.eclipse.ui.IWorkbenchPage)7 SWT (org.eclipse.swt.SWT)6 PartInitException (org.eclipse.ui.PartInitException)6 List (java.util.List)5 IToolBarManager (org.eclipse.jface.action.IToolBarManager)4 Separator (org.eclipse.jface.action.Separator)4