Search in sources :

Example 1 with ControlContribution

use of org.eclipse.jface.action.ControlContribution in project cubrid-manager by CUBRID.

the class ApplicationActionBarAdvisor method fillCoolBar.

/**
	 * Fills the cool bar with the main toolbars for the window.
	 *
	 * @param coolBar the cool bar manager
	 */
protected void fillCoolBar(ICoolBarManager coolBarManager) {
    ActionManager manager = ActionManager.getInstance();
    coolBarManager.setLockLayout(true);
    IToolBarManager toolbarManager = new ToolBarManager(SWT.FLAT | SWT.WRAP | SWT.BOTTOM);
    coolBarManager.add(new ToolBarContributionItem(toolbarManager, IActionConstants.TOOL_NEW1));
    Bundle cqbBundle = Platform.getBundle(ApplicationUtil.CQB_PLUGIN_ID);
    /* Active the CQB plugin */
    if (cqbBundle != null) {
        try {
            cqbBundle.start();
        } catch (Exception e) {
            LOGGER.error(e.getMessage());
        }
    }
    Bundle cmBundle = Platform.getBundle(ApplicationUtil.CM_PLUGIN_ID);
    /* Active the CM plugin */
    if (cmBundle != null) {
        try {
            cmBundle.start();
        } catch (Exception e) {
            LOGGER.error(e.getMessage());
        }
    }
    // Change view actions
    if (cqbBundle != null) {
        DropDownAction viewAction = new DropDownAction(Messages.modeActionBig, IAction.AS_DROP_DOWN_MENU, CubridManagerAppPlugin.getImageDescriptor("icons/cubridmanager32.gif"));
        viewAction.setDisabledImageDescriptor(CubridManagerAppPlugin.getImageDescriptor("icons/cubridmanager32.gif"));
        MenuManager viewActionManager = viewAction.getMenuManager();
        viewActionManager.add(manager.getAction(OpenCMPerspectiveAction.ID));
        viewActionManager.add(manager.getAction(OpenCQBPerspectiveAction.ID));
        ActionContributionItem viewItems = new ActionContributionItem(viewAction);
        viewItems.setMode(ActionContributionItem.MODE_FORCE_TEXT);
        viewItems.setId(IPerspectiveConstance.PERSPECTIVE_ACTION_CONTRIBUTION_ID);
        toolbarManager.add(viewItems);
        toolbarManager.add(new Separator());
    }
    /*TOOLS-3988 There still is the install option after installing cmt plugin.*/
    Bundle bundle = Platform.getBundle(ApplicationUtil.CMT_PLUGIN_ID);
    if (bundle == null) {
        toolbarManager.add(new Separator());
        IAction action = ActionManager.getInstance().getAction(InstallMigrationToolkitAction.ID);
        if (action != null) {
            ActionContributionItem item = new ActionContributionItem(action);
            item.setMode(ActionContributionItem.MODE_FORCE_TEXT);
            toolbarManager.add(item);
            item.setId(IPerspectiveConstance.MIGRATION_ACTION_CONTRIBUTION_ID);
        }
    } else {
        /*Active the CMT plugin */
        try {
            bundle.start();
        } catch (Exception e) {
            LOGGER.error(e.getMessage());
        }
    }
    // Help
    toolbarManager.add(new Separator());
    DropDownAction helpDropAction = new DropDownAction(Messages.helpActionNameBig, IAction.AS_DROP_DOWN_MENU, CubridManagerUIPlugin.getImageDescriptor("icons/action/help_big.png"));
    helpDropAction.setDisabledImageDescriptor(CubridManagerUIPlugin.getImageDescriptor("icons/action/help_big.png"));
    MenuManager helpActionManager = helpDropAction.getMenuManager();
    helpActionManager.add(manager.getAction(HelpDocumentAction.ID));
    if ("ko".equals(Messages.language)) {
        helpActionManager.add(newFeatureAction);
    }
    helpActionManager.add(new Separator());
    helpActionManager.add(createItem(ReportBugAction.ID));
    helpActionManager.add(new Separator());
    helpActionManager.add(manager.getAction(ViewServerVersionAction.ID));
    helpActionManager.add(clientVersionAction);
    ActionContributionItem helpItems = new ActionContributionItem(helpDropAction);
    helpItems.setMode(ActionContributionItem.MODE_FORCE_TEXT);
    helpItems.setId(IPerspectiveConstance.HELP_ACTION_CONTRIBUTION_ID);
    toolbarManager.add(helpItems);
    ControlContribution searchContribution = new ControlContribution(SearchContributionComposite.class.getName()) {

        protected Control createControl(Composite parent) {
            return new SearchContributionComposite(parent, SWT.None);
        }
    };
    searchContribution.setId(IPerspectiveConstance.SEARCH_ACTION_CONTRIBUTION_ID);
    toolbarManager.add(new Separator());
    toolbarManager.add(searchContribution);
}
Also used : IAction(org.eclipse.jface.action.IAction) SearchContributionComposite(com.cubrid.common.ui.common.control.SearchContributionComposite) Composite(org.eclipse.swt.widgets.Composite) Bundle(org.osgi.framework.Bundle) ControlContribution(org.eclipse.jface.action.ControlContribution) IToolBarManager(org.eclipse.jface.action.IToolBarManager) ToolBarManager(org.eclipse.jface.action.ToolBarManager) ActionManager(com.cubrid.common.ui.spi.action.ActionManager) ToolBarContributionItem(org.eclipse.jface.action.ToolBarContributionItem) ActionContributionItem(org.eclipse.jface.action.ActionContributionItem) DropDownAction(com.cubrid.common.ui.common.action.DropDownAction) IToolBarManager(org.eclipse.jface.action.IToolBarManager) MenuManager(org.eclipse.jface.action.MenuManager) IMenuManager(org.eclipse.jface.action.IMenuManager) SearchContributionComposite(com.cubrid.common.ui.common.control.SearchContributionComposite) Separator(org.eclipse.jface.action.Separator)

Example 2 with ControlContribution

use of org.eclipse.jface.action.ControlContribution in project dbeaver by dbeaver.

the class OracleObjectDDLEditor method contributeEditorCommands.

@Override
protected void contributeEditorCommands(IContributionManager contributionManager) {
    super.contributeEditorCommands(contributionManager);
    contributionManager.add(new Separator());
    contributionManager.add(new ControlContribution("DDLFormat") {

        @Override
        protected Control createControl(Composite parent) {
            OracleDDLFormat ddlFormat = OracleDDLFormat.getCurrentFormat(getSourceObject().getDataSource());
            final Combo ddlFormatCombo = new Combo(parent, SWT.BORDER | SWT.READ_ONLY | SWT.DROP_DOWN);
            ddlFormatCombo.setToolTipText("DDL Format");
            for (OracleDDLFormat format : OracleDDLFormat.values()) {
                ddlFormatCombo.add(format.getTitle());
                if (format == ddlFormat) {
                    ddlFormatCombo.select(ddlFormatCombo.getItemCount() - 1);
                }
            }
            ddlFormatCombo.addSelectionListener(new SelectionAdapter() {

                @Override
                public void widgetSelected(SelectionEvent e) {
                    for (OracleDDLFormat format : OracleDDLFormat.values()) {
                        if (format.ordinal() == ddlFormatCombo.getSelectionIndex()) {
                            getEditorInput().getDatabaseObject().getDataSource().getContainer().getPreferenceStore().setValue(OracleConstants.PREF_KEY_DDL_FORMAT, format.name());
                            refreshPart(this, true);
                            break;
                        }
                    }
                }
            });
            return ddlFormatCombo;
        }
    });
}
Also used : Control(org.eclipse.swt.widgets.Control) Composite(org.eclipse.swt.widgets.Composite) OracleDDLFormat(org.jkiss.dbeaver.ext.oracle.model.OracleDDLFormat) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) SelectionEvent(org.eclipse.swt.events.SelectionEvent) ControlContribution(org.eclipse.jface.action.ControlContribution) Combo(org.eclipse.swt.widgets.Combo) Separator(org.eclipse.jface.action.Separator)

Example 3 with ControlContribution

use of org.eclipse.jface.action.ControlContribution in project jbosstools-hibernate by jbosstools.

the class AbstractQueryEditor method createToolbar.

protected final void createToolbar(Composite parent) {
    ToolBar bar = new ToolBar(parent, SWT.HORIZONTAL);
    bar.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
    tbm = new ToolBarManager(bar);
    execAction = new ExecuteQueryAction(this);
    clearAction = new ClearAction(this);
    stickResTabAction = new StickResTabAction(this);
    ActionContributionItem item = new ActionContributionItem(execAction);
    tbm.add(item);
    item = new ActionContributionItem(clearAction);
    tbm.add(item);
    // $NON-NLS-1$
    ControlContribution cc = new ConfigurationCombo("hql-target", this);
    tbm.add(cc);
    tbm.add(new Separator());
    cc = new // $NON-NLS-1$
    ComboContribution(// $NON-NLS-1$
    "maxResults") {

        SelectionAdapter selectionAdapter = new SelectionAdapter() {

            public void widgetSelected(SelectionEvent e) {
                Integer maxResults = null;
                try {
                    maxResults = new Integer(getText());
                } catch (NumberFormatException e1) {
                    maxResults = null;
                }
                getQueryInputModel().setMaxResults(maxResults);
            }
        };

        protected Control createControl(Composite parent) {
            Control control = super.createControl(parent);
            comboControl.addModifyListener(new ModifyListener() {

                public void modifyText(ModifyEvent e) {
                    Integer maxResults = null;
                    try {
                        maxResults = new Integer(getText());
                    } catch (NumberFormatException e1) {
                        maxResults = null;
                    }
                    getQueryInputModel().setMaxResults(maxResults);
                }
            });
            return control;
        }

        protected int getComboWidth() {
            return 75;
        }

        protected String getLabelText() {
            return HibernateConsoleMessages.AbstractQueryEditor_max_results;
        }

        protected boolean isReadOnly() {
            return false;
        }

        protected SelectionListener getSelectionAdapter() {
            return selectionAdapter;
        }

        void populateComboBox() {
            comboControl.getDisplay().syncExec(new Runnable() {

                public void run() {
                    // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
                    String[] items = new String[] { "", "10", "20", "30", "50" };
                    comboControl.setItems(items);
                }
            });
        }
    };
    tbm.add(cc);
    tbm.add(new Separator());
    item = new ActionContributionItem(stickResTabAction);
    tbm.add(item);
    tbm.update(true);
}
Also used : ClearAction(org.hibernate.eclipse.console.actions.ClearAction) Composite(org.eclipse.swt.widgets.Composite) ModifyListener(org.eclipse.swt.events.ModifyListener) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) ControlContribution(org.eclipse.jface.action.ControlContribution) ExecuteQueryAction(org.hibernate.eclipse.console.actions.ExecuteQueryAction) ToolBarManager(org.eclipse.jface.action.ToolBarManager) ActionContributionItem(org.eclipse.jface.action.ActionContributionItem) Control(org.eclipse.swt.widgets.Control) ModifyEvent(org.eclipse.swt.events.ModifyEvent) StickResTabAction(org.hibernate.eclipse.console.actions.StickResTabAction) ToolBar(org.eclipse.swt.widgets.ToolBar) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent) Separator(org.eclipse.jface.action.Separator) SelectionListener(org.eclipse.swt.events.SelectionListener)

Example 4 with ControlContribution

use of org.eclipse.jface.action.ControlContribution in project egit by eclipse.

the class CommitEditor method createHeaderContents.

/**
 * @see org.eclipse.ui.forms.editor.SharedHeaderFormEditor#createHeaderContents(org.eclipse.ui.forms.IManagedForm)
 */
@Override
protected void createHeaderContents(IManagedForm headerForm) {
    headerForm.addPart(new FocusManagerFormPart(headerFocusTracker) {

        @Override
        public void setDefaultFocus() {
            headerForm.getForm().getForm().setFocus();
        }
    });
    RepositoryCommit commit = getCommit();
    ScrolledForm form = headerForm.getForm();
    String commitName = commit.getRevCommit().name();
    String title = getFormattedHeaderTitle(commitName);
    HeaderText text = new HeaderText(form.getForm(), title, commitName);
    Control textControl = text.getControl();
    if (textControl != null) {
        headerFocusTracker.addToFocusTracking(textControl);
    }
    form.setToolTipText(commitName);
    getToolkit().decorateFormHeading(form.getForm());
    toolbar = form.getToolBarManager();
    ControlContribution repositoryLabelControl = new ControlContribution(// $NON-NLS-1$
    "repositoryLabel") {

        @Override
        protected Control createControl(Composite parent) {
            FormToolkit toolkit = getHeaderForm().getToolkit();
            String label = getCommit().getRepositoryName();
            ImageHyperlink link = new ImageHyperlink(parent, SWT.NONE);
            // Focus tracking on this link doesn't really work. It's a
            // focusable control inside another focusable control (the
            // toolbar). When focus leaves this control through tabbing
            // or deactivating the editor, the toolbar gets the focus (and
            // possibly loses it right away again). Thus the focus tracker
            // will always see the toolbar as the last focused control.
            // Unfortunately there is no other way to get some text onto
            // the first line of a FormHeading.
            headerFocusTracker.addToFocusTracking(link);
            link.setText(label);
            link.setFont(JFaceResources.getBannerFont());
            link.setForeground(toolkit.getColors().getColor(IFormColors.TITLE));
            link.setToolTipText(UIText.CommitEditor_showGitRepo);
            link.addHyperlinkListener(new HyperlinkAdapter() {

                @Override
                public void linkActivated(HyperlinkEvent event) {
                    RepositoriesView view;
                    try {
                        view = (RepositoriesView) PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().showView(RepositoriesView.VIEW_ID);
                        view.showRepository(getCommit().getRepository());
                    } catch (PartInitException e) {
                        Activator.handleError(UIText.CommitEditor_couldNotShowRepository, e, false);
                    }
                }
            });
            return link;
        }
    };
    toolbar.add(repositoryLabelControl);
    CommonUtils.getService(getSite(), IPartService.class).addPartListener(activationListener);
    if (commit.isStash()) {
        toolbar.add(createActionContributionItem(StashApplyHandler.ID, UIText.CommitEditor_toolbarApplyStash, UIIcons.STASH_APPLY));
        toolbar.add(createActionContributionItem(StashDropHandler.ID, UIText.CommitEditor_toolbarDeleteStash, PlatformUI.getWorkbench().getSharedImages().getImageDescriptor(ISharedImages.IMG_TOOL_DELETE)));
    } else {
        toolbar.add(createActionContributionItem(CreateTagHandler.ID, UIText.CommitEditor_toolbarCreateTag, UIIcons.TAG));
        toolbar.add(createActionContributionItem(CreateBranchHandler.ID, UIText.CommitEditor_toolbarCreateBranch, UIIcons.BRANCH));
        toolbar.add(createActionContributionItem(CheckoutHandler.ID, UIText.CommitEditor_toolbarCheckOut, UIIcons.CHECKOUT));
        toolbar.add(createActionContributionItem(CherryPickHandler.ID, UIText.CommitEditor_toolbarCherryPick, UIIcons.CHERRY_PICK));
        toolbar.add(createActionContributionItem(RevertHandler.ID, UIText.CommitEditor_toolbarRevert, UIIcons.REVERT));
        toolbar.add(createActionContributionItem(ShowInHistoryHandler.ID, UIText.CommitEditor_toolbarShowInHistory, UIIcons.HISTORY));
    }
    addContributions(toolbar);
    toolbar.update(true);
    getSite().setSelectionProvider(new ISelectionProvider() {

        @Override
        public void setSelection(ISelection selection) {
        // Ignored
        }

        @Override
        public void removeSelectionChangedListener(ISelectionChangedListener listener) {
        // Ignored
        }

        @Override
        public ISelection getSelection() {
            return new StructuredSelection(getCommit());
        }

        @Override
        public void addSelectionChangedListener(ISelectionChangedListener listener) {
        // Ignored
        }
    });
    if (toolbar instanceof ToolBarManager) {
        Control control = ((ToolBarManager) toolbar).getControl();
        if (control != null) {
            headerFocusTracker.addToFocusTracking(control);
        }
    }
}
Also used : HyperlinkEvent(org.eclipse.ui.forms.events.HyperlinkEvent) Composite(org.eclipse.swt.widgets.Composite) FormToolkit(org.eclipse.ui.forms.widgets.FormToolkit) ImageHyperlink(org.eclipse.ui.forms.widgets.ImageHyperlink) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) ControlContribution(org.eclipse.jface.action.ControlContribution) IPartService(org.eclipse.ui.IPartService) IToolBarManager(org.eclipse.jface.action.IToolBarManager) ToolBarManager(org.eclipse.jface.action.ToolBarManager) Control(org.eclipse.swt.widgets.Control) ISelectionProvider(org.eclipse.jface.viewers.ISelectionProvider) ScrolledForm(org.eclipse.ui.forms.widgets.ScrolledForm) RepositoriesView(org.eclipse.egit.ui.internal.repository.RepositoriesView) ISelection(org.eclipse.jface.viewers.ISelection) PartInitException(org.eclipse.ui.PartInitException) HyperlinkAdapter(org.eclipse.ui.forms.events.HyperlinkAdapter)

Example 5 with ControlContribution

use of org.eclipse.jface.action.ControlContribution in project dbeaver by serge-rider.

the class OracleEditorUtils method addDDLControl.

public static void addDDLControl(IContributionManager contributionManager, OracleTableBase sourceObject, SQLSourceViewer source) {
    contributionManager.add(new Separator());
    contributionManager.add(new ControlContribution("DDLFormat") {

        @Override
        protected Control createControl(Composite parent) {
            OracleDDLFormat ddlFormat = OracleDDLFormat.getCurrentFormat(sourceObject.getDataSource());
            final Combo ddlFormatCombo = new Combo(parent, SWT.BORDER | SWT.READ_ONLY | SWT.DROP_DOWN);
            ddlFormatCombo.setToolTipText("DDL Format");
            for (OracleDDLFormat format : OracleDDLFormat.values()) {
                ddlFormatCombo.add(format.getTitle());
                if (format == ddlFormat) {
                    ddlFormatCombo.select(ddlFormatCombo.getItemCount() - 1);
                }
            }
            ddlFormatCombo.addSelectionListener(new SelectionAdapter() {

                @Override
                public void widgetSelected(SelectionEvent e) {
                    for (OracleDDLFormat format : OracleDDLFormat.values()) {
                        if (format.ordinal() == ddlFormatCombo.getSelectionIndex()) {
                            if (source instanceof OracleDDLOptions) {
                                ((OracleDDLOptions) source).putDDLOptions(OracleConstants.PREF_KEY_DDL_FORMAT, format);
                            }
                            sourceObject.getDataSource().getContainer().getPreferenceStore().setValue(OracleConstants.PREF_KEY_DDL_FORMAT, format.name());
                            source.refreshPart(this, true);
                            break;
                        }
                    }
                }
            });
            return ddlFormatCombo;
        }
    });
}
Also used : Control(org.eclipse.swt.widgets.Control) Composite(org.eclipse.swt.widgets.Composite) OracleDDLFormat(org.jkiss.dbeaver.ext.oracle.model.OracleDDLFormat) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) SelectionEvent(org.eclipse.swt.events.SelectionEvent) ControlContribution(org.eclipse.jface.action.ControlContribution) Combo(org.eclipse.swt.widgets.Combo) Separator(org.eclipse.jface.action.Separator)

Aggregations

ControlContribution (org.eclipse.jface.action.ControlContribution)16 Composite (org.eclipse.swt.widgets.Composite)16 SelectionEvent (org.eclipse.swt.events.SelectionEvent)13 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)12 Control (org.eclipse.swt.widgets.Control)12 Separator (org.eclipse.jface.action.Separator)11 Combo (org.eclipse.swt.widgets.Combo)7 IToolBarManager (org.eclipse.jface.action.IToolBarManager)5 Button (org.eclipse.swt.widgets.Button)5 IAction (org.eclipse.jface.action.IAction)4 ActionManager (com.cubrid.common.ui.spi.action.ActionManager)3 IContributionItem (org.eclipse.jface.action.IContributionItem)3 ToolBarManager (org.eclipse.jface.action.ToolBarManager)3 IWorkbenchWindow (org.eclipse.ui.IWorkbenchWindow)3 OracleDDLFormat (org.jkiss.dbeaver.ext.oracle.model.OracleDDLFormat)3 RestoreQueryEditorAction (com.cubrid.common.ui.common.action.RestoreQueryEditorAction)2 Action (org.eclipse.jface.action.Action)2 ActionContributionItem (org.eclipse.jface.action.ActionContributionItem)2 StatusLineManager (org.eclipse.jface.action.StatusLineManager)2 Repository (org.eclipse.jgit.lib.Repository)2