Example usage for org.eclipse.jface.action IContributionManager add

List of usage examples for org.eclipse.jface.action IContributionManager add

Introduction

In this page you can find the example usage for org.eclipse.jface.action IContributionManager add.

Prototype

void add(IContributionItem item);

Source Link

Document

Adds a contribution item to this manager.

Usage

From source file:org.jkiss.dbeaver.ui.controls.itemlist.ItemListControl.java

License:Open Source License

@Override
protected void fillCustomActions(IContributionManager contributionManager) {
    if (getRootNode() instanceof DBNDatabaseFolder
            && ((DBNDatabaseFolder) getRootNode()).getItemsMeta() != null) {
        contributionManager.add(new Action("Filter", DBeaverIcons.getImageDescriptor(UIIcon.FILTER)) {
            @Override//  www .  j  a  v a  2  s . co  m
            public void run() {
                NavigatorHandlerConfigureFilter.configureFilters(getShell(), getRootNode());
            }
        });
    }
}

From source file:org.jkiss.dbeaver.ui.controls.resultset.panel.aggregate.AggregateColumnsPanel.java

License:Apache License

private void fillToolBar(IContributionManager contributionManager) {
    contributionManager.add(new AddFunctionAction());
    contributionManager.add(new RemoveFunctionAction());
    contributionManager.add(new ResetFunctionsAction());
    contributionManager.add(new Separator());
    contributionManager.add(new GroupByColumnsAction());
}

From source file:org.jkiss.dbeaver.ui.controls.resultset.panel.grouping.GroupingPanel.java

License:Apache License

private void fillToolBar(IContributionManager contributionManager) {
    contributionManager.add(new EditColumnsAction(resultsContainer));
    contributionManager.add(new Separator());
    contributionManager.add(new DeleteColumnAction(resultsContainer));
    contributionManager.add(new ClearGroupingAction(resultsContainer));
}

From source file:org.jkiss.dbeaver.ui.controls.resultset.panel.grouping.GroupingResultsDecorator.java

License:Apache License

@Override
public void fillContributions(IContributionManager contributionManager) {
    contributionManager.add(new GroupingPanel.EditColumnsAction(container));
    contributionManager.add(new GroupingPanel.DeleteColumnAction(container));
    contributionManager.add(new GroupingPanel.ClearGroupingAction(container));
}

From source file:org.jkiss.dbeaver.ui.controls.resultset.panel.valueviewer.ValueViewerPanel.java

License:Apache License

private void fillToolBar(final IContributionManager contributionManager) {
    contributionManager.add(new Separator());
    //contributionManager.add(new Separator());
    if (valueManager != null) {
        try {/*from  w w w .  j a  va 2s  . c o  m*/
            valueManager.contributeActions(contributionManager, previewController, valueEditor);
        } catch (Exception e) {
            log.error("Can't contribute value manager actions", e);
        }
    }

    contributionManager.add(ActionUtils.makeCommandContribution(presentation.getController().getSite(),
            ValueViewCommandHandler.CMD_SAVE_VALUE));

    contributionManager.add(new Action("Auto-apply value", Action.AS_CHECK_BOX) {
        {
            setImageDescriptor(DBeaverIcons.getImageDescriptor(UIIcon.LINK_TO_EDITOR));
        }

        @Override
        public boolean isChecked() {
            return DBeaverCore.getGlobalPreferenceStore()
                    .getBoolean(DBeaverPreferences.RS_EDIT_AUTO_UPDATE_VALUE);
        }

        @Override
        public void run() {
            boolean newValue = !isChecked();
            DBeaverCore.getGlobalPreferenceStore().setValue(DBeaverPreferences.RS_EDIT_AUTO_UPDATE_VALUE,
                    newValue);
            presentation.getController().updatePanelActions();
        }
    });
}

From source file:org.jkiss.dbeaver.ui.controls.resultset.panel.ViewValuePanel.java

License:Apache License

private void fillToolBar(final IContributionManager contributionManager) {
    contributionManager.add(new Separator());
    //contributionManager.add(new Separator());
    if (valueManager != null) {
        try {//from w w  w  .j  av  a  2  s .com
            valueManager.contributeActions(contributionManager, previewController, valueEditor);
        } catch (Exception e) {
            log.error("Can't contribute value manager actions", e);
        }
    }

    contributionManager.add(ActionUtils.makeCommandContribution(presentation.getController().getSite(),
            ValueViewCommandHandler.CMD_SAVE_VALUE));

    contributionManager.add(new Action("Auto-save value", Action.AS_CHECK_BOX) {
        {
            setImageDescriptor(DBeaverIcons.getImageDescriptor(UIIcon.LINK_TO_EDITOR));
        }

        @Override
        public boolean isChecked() {
            return DBeaverCore.getGlobalPreferenceStore()
                    .getBoolean(DBeaverPreferences.RS_EDIT_AUTO_UPDATE_VALUE);
        }

        @Override
        public void run() {
            boolean newValue = !isChecked();
            DBeaverCore.getGlobalPreferenceStore().setValue(DBeaverPreferences.RS_EDIT_AUTO_UPDATE_VALUE,
                    newValue);
            presentation.getController().updatePanelActions();
        }
    });
}

From source file:org.jkiss.dbeaver.ui.data.editors.ContentPanelEditor.java

License:Open Source License

@Override
protected Control createControl(Composite editPlaceholder) {
    DBDContent content = (DBDContent) valueController.getValue();
    if (ContentUtils.isTextContent(content)) {
        Text text = new Text(editPlaceholder, SWT.MULTI | SWT.WRAP | SWT.V_SCROLL | SWT.BORDER);
        text.setEditable(!valueController.isReadOnly());
        text.setFont(JFaceResources.getFont(JFaceResources.TEXT_FONT));
        return text;
    } else {//  w w  w  .ja  v  a  2s . co m
        ImageDetector imageDetector = new ImageDetector(content);
        if (!DBUtils.isNullValue(content)) {
            DBeaverUI.runInUI(valueController.getValueSite().getWorkbenchWindow(), imageDetector);
        }

        IContributionManager editBar = valueController.getEditBar();
        if (imageDetector.isImage()) {
            ImageViewer imageViewer = new ImageViewer(editPlaceholder, SWT.BORDER);
            if (editBar != null) {
                imageViewer.fillToolBar(editBar);
            }
            return imageViewer;
        } else {
            final HexEditControl hexEditor = new HexEditControl(editPlaceholder, SWT.BORDER);
            if (editBar != null) {
                editBar.add(new Action("Switch Insert/Overwrite mode",
                        DBeaverIcons.getImageDescriptor(UIIcon.CURSOR)) {
                    @Override
                    public void run() {
                        hexEditor.redrawCaret(true);
                    }
                });
            }
            return hexEditor;
        }
    }
}

From source file:org.jkiss.dbeaver.ui.data.managers.ContentValueManager.java

License:Open Source License

public static void contributeContentActions(@NotNull IContributionManager manager,
        @NotNull final IValueController controller) throws DBCException {
    if (controller.getValue() instanceof DBDContent && !((DBDContent) controller.getValue()).isNull()) {
        manager.add(new Action(CoreMessages.model_jdbc_save_to_file_,
                DBeaverIcons.getImageDescriptor(UIIcon.SAVE_AS)) {
            @Override//from ww  w.  j av a 2 s.c  o m
            public void run() {
                DialogUtils.saveToFile(controller);
            }
        });
    }
    manager.add(
            new Action(CoreMessages.model_jdbc_load_from_file_, DBeaverIcons.getImageDescriptor(UIIcon.LOAD)) {
                @Override
                public void run() {
                    DialogUtils.loadFromFile(controller);
                }
            });
}

From source file:org.jkiss.dbeaver.ui.data.managers.DateTimeValueManager.java

License:Open Source License

@Override
public void contributeActions(@NotNull IContributionManager manager, @NotNull final IValueController controller,
        @Nullable IValueEditor activeEditor) throws DBCException {
    super.contributeActions(manager, controller, activeEditor);
    manager.add(new Action(CoreMessages.model_jdbc_set_to_current_time,
            DBeaverIcons.getImageDescriptor(DBIcon.TYPE_DATETIME)) {
        @Override//from   ww w . j a v  a  2 s  .  c  om
        public void run() {
            controller.updateValue(new Date());
        }
    });
}

From source file:org.jkiss.dbeaver.ui.data.managers.stream.AbstractTextPanelEditor.java

License:Apache License

@Override
public void contributeSettings(@NotNull IContributionManager manager, @NotNull final StyledText editorControl)
        throws DBCException {
    manager.add(new Separator());
    {/*from  www.  j  av a  2 s. c  o  m*/
        Action wwAction = new Action("Word Wrap", Action.AS_CHECK_BOX) {
            @Override
            public void run() {
                boolean newWW = !editorControl.getWordWrap();
                setChecked(newWW);
                editorControl.setWordWrap(newWW);
                ValueViewerPanel.getPanelSettings().put(PREF_TEXT_EDITOR_WORD_WRAP, newWW);
            }
        };
        wwAction.setChecked(editorControl.getWordWrap());
        manager.add(wwAction);
    }

    BaseTextEditor textEditor = getTextEditor();
    if (textEditor != null) {
        final Action afAction = new Action("Auto Format", Action.AS_CHECK_BOX) {
            @Override
            public void run() {
                boolean newAF = !ValueViewerPanel.getPanelSettings().getBoolean(PREF_TEXT_EDITOR_AUTO_FORMAT);
                setChecked(newAF);
                ValueViewerPanel.getPanelSettings().put(PREF_TEXT_EDITOR_AUTO_FORMAT, newAF);
                applyEditorStyle();
            }
        };
        afAction.setChecked(ValueViewerPanel.getPanelSettings().getBoolean(PREF_TEXT_EDITOR_AUTO_FORMAT));
        manager.add(afAction);
    }
}