Search in sources :

Example 21 with CommandContributionItemParameter

use of org.eclipse.ui.menus.CommandContributionItemParameter in project dbeaver by serge-rider.

the class NavigatorHandlerObjectCreateNew method makeCreateContributionItem.

private static IContributionItem makeCreateContributionItem(@Nullable IWorkbenchPartSite site, String objectType, String objectTypeName, DBPImage objectIcon, boolean isFolder) {
    if (site == null) {
        return DUMMY_CONTRIBUTION_ITEM;
    }
    CommandContributionItemParameter params = new CommandContributionItemParameter(site, NavigatorCommands.CMD_OBJECT_CREATE, NavigatorCommands.CMD_OBJECT_CREATE, CommandContributionItem.STYLE_PUSH);
    Map<String, String> parameters = new HashMap<>();
    parameters.put(NavigatorCommands.PARAM_OBJECT_TYPE, objectType);
    parameters.put(NavigatorCommands.PARAM_OBJECT_TYPE_NAME, objectTypeName);
    if (objectIcon != null) {
        parameters.put(NavigatorCommands.PARAM_OBJECT_TYPE_ICON, objectIcon.getLocation());
    }
    if (isFolder) {
        parameters.put(NavigatorCommands.PARAM_OBJECT_TYPE_FOLDER, String.valueOf(true));
    }
    params.parameters = parameters;
    return new CommandContributionItem(params);
}
Also used : HashMap(java.util.HashMap) CommandContributionItemParameter(org.eclipse.ui.menus.CommandContributionItemParameter) CommandContributionItem(org.eclipse.ui.menus.CommandContributionItem)

Example 22 with CommandContributionItemParameter

use of org.eclipse.ui.menus.CommandContributionItemParameter in project dbeaver by dbeaver.

the class NavigatorHandlerObjectCreateNew method makeCreateContributionItem.

private static IContributionItem makeCreateContributionItem(@Nullable IWorkbenchPartSite site, String objectType, String objectTypeName, DBPImage objectIcon, boolean isFolder) {
    if (site == null) {
        return DUMMY_CONTRIBUTION_ITEM;
    }
    CommandContributionItemParameter params = new CommandContributionItemParameter(site, NavigatorCommands.CMD_OBJECT_CREATE, NavigatorCommands.CMD_OBJECT_CREATE, CommandContributionItem.STYLE_PUSH);
    Map<String, String> parameters = new HashMap<>();
    parameters.put(NavigatorCommands.PARAM_OBJECT_TYPE, objectType);
    parameters.put(NavigatorCommands.PARAM_OBJECT_TYPE_NAME, objectTypeName);
    if (objectIcon != null) {
        parameters.put(NavigatorCommands.PARAM_OBJECT_TYPE_ICON, objectIcon.getLocation());
    }
    if (isFolder) {
        parameters.put(NavigatorCommands.PARAM_OBJECT_TYPE_FOLDER, String.valueOf(true));
    }
    params.parameters = parameters;
    return new CommandContributionItem(params);
}
Also used : HashMap(java.util.HashMap) CommandContributionItemParameter(org.eclipse.ui.menus.CommandContributionItemParameter) CommandContributionItem(org.eclipse.ui.menus.CommandContributionItem)

Example 23 with CommandContributionItemParameter

use of org.eclipse.ui.menus.CommandContributionItemParameter in project dbeaver by dbeaver.

the class ActionUtils method makeCommandContribution.

public static CommandContributionItem makeCommandContribution(@NotNull IServiceLocator serviceLocator, @NotNull String commandId, int style, @Nullable DBPImage icon) {
    CommandContributionItemParameter parameters = new CommandContributionItemParameter(serviceLocator, null, commandId, style);
    parameters.icon = DBeaverIcons.getImageDescriptor(icon);
    return new CommandContributionItem(parameters);
}
Also used : CommandContributionItemParameter(org.eclipse.ui.menus.CommandContributionItemParameter) CommandContributionItem(org.eclipse.ui.menus.CommandContributionItem)

Example 24 with CommandContributionItemParameter

use of org.eclipse.ui.menus.CommandContributionItemParameter in project dbeaver by dbeaver.

the class ActionUtils method makeCommandContribution.

public static CommandContributionItem makeCommandContribution(@NotNull IServiceLocator serviceLocator, @NotNull String commandId, int style, @Nullable String name, @Nullable DBPImage image, @Nullable String toolTip, boolean showText, @Nullable Map<String, Object> parameters) {
    final CommandContributionItemParameter contributionParameters = new CommandContributionItemParameter(serviceLocator, null, commandId, null, image == null ? null : DBeaverIcons.getImageDescriptor(image), null, null, name, null, toolTip, style, null, false);
    contributionParameters.parameters = parameters;
    if (showText) {
        contributionParameters.mode = CommandContributionItem.MODE_FORCE_TEXT;
    }
    return new CommandContributionItem(contributionParameters);
}
Also used : CommandContributionItemParameter(org.eclipse.ui.menus.CommandContributionItemParameter) CommandContributionItem(org.eclipse.ui.menus.CommandContributionItem)

Example 25 with CommandContributionItemParameter

use of org.eclipse.ui.menus.CommandContributionItemParameter in project dbeaver by dbeaver.

the class ResultSetHandlerCopyAs method fillCopyAsMenu.

public static void fillCopyAsMenu(ResultSetViewer viewer, IContributionManager copyAsMenu) {
    IWorkbenchPartSite site = viewer.getSite();
    copyAsMenu.add(ActionUtils.makeCommandContribution(site, ResultSetHandlerCopySpecial.CMD_COPY_SPECIAL));
    copyAsMenu.add(ActionUtils.makeCommandContribution(site, ResultSetHandlerCopySpecial.CMD_COPY_COLUMN_NAMES));
    copyAsMenu.add(ActionUtils.makeCommandContribution(site, ResultSetHandlerMain.CMD_COPY_ROW_NAMES));
    // Add copy commands for different formats
    copyAsMenu.add(new Separator());
    ResultSetDataContainerOptions options = new ResultSetDataContainerOptions();
    ResultSetDataContainer dataContainer = new ResultSetDataContainer(viewer, options);
    List<DataTransferProcessorDescriptor> appProcessors = new ArrayList<>();
    for (final DataTransferNodeDescriptor consumerNode : DataTransferRegistry.getInstance().getAvailableConsumers(Collections.singleton(dataContainer))) {
        for (DataTransferProcessorDescriptor processor : consumerNode.getProcessors()) {
            if (processor.isBinaryFormat()) {
                continue;
            }
            appProcessors.add(processor);
        }
    }
    appProcessors.sort(Comparator.comparing(DataTransferProcessorDescriptor::getName));
    for (DataTransferProcessorDescriptor processor : appProcessors) {
        CommandContributionItemParameter params = new CommandContributionItemParameter(site, processor.getId(), ResultSetHandlerCopyAs.CMD_COPY_AS, CommandContributionItem.STYLE_PUSH);
        params.label = processor.getName();
        if (processor.getIcon() != null) {
            params.icon = DBeaverIcons.getImageDescriptor(processor.getIcon());
        }
        Map<String, Object> parameters = new HashMap<>();
        parameters.put(ResultSetHandlerCopyAs.PARAM_PROCESSOR_ID, processor.getFullId());
        params.parameters = parameters;
        copyAsMenu.add(new CommandContributionItem(params));
    }
}
Also used : DataTransferProcessorDescriptor(org.jkiss.dbeaver.tools.transfer.registry.DataTransferProcessorDescriptor) IWorkbenchPartSite(org.eclipse.ui.IWorkbenchPartSite) CommandContributionItemParameter(org.eclipse.ui.menus.CommandContributionItemParameter) DataTransferNodeDescriptor(org.jkiss.dbeaver.tools.transfer.registry.DataTransferNodeDescriptor) CommandContributionItem(org.eclipse.ui.menus.CommandContributionItem)

Aggregations

CommandContributionItemParameter (org.eclipse.ui.menus.CommandContributionItemParameter)31 CommandContributionItem (org.eclipse.ui.menus.CommandContributionItem)30 HashMap (java.util.HashMap)9 IContributionItem (org.eclipse.jface.action.IContributionItem)4 ResultSetPanelDescriptor (org.jkiss.dbeaver.ui.controls.resultset.panel.ResultSetPanelDescriptor)4 DataTransferNodeDescriptor (org.jkiss.dbeaver.tools.transfer.registry.DataTransferNodeDescriptor)3 DataTransferProcessorDescriptor (org.jkiss.dbeaver.tools.transfer.registry.DataTransferProcessorDescriptor)3 InvocationTargetException (java.lang.reflect.InvocationTargetException)2 DecimalFormat (java.text.DecimalFormat)2 java.util (java.util)2 List (java.util.List)2 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)2 IAdaptable (org.eclipse.core.runtime.IAdaptable)2 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)2 IStatus (org.eclipse.core.runtime.IStatus)2 Status (org.eclipse.core.runtime.Status)2 org.eclipse.jface.action (org.eclipse.jface.action)2 IDialogConstants (org.eclipse.jface.dialogs.IDialogConstants)2 IDialogSettings (org.eclipse.jface.dialogs.IDialogSettings)2 IFindReplaceTarget (org.eclipse.jface.text.IFindReplaceTarget)2