Search in sources :

Example 31 with DataTransferProcessorDescriptor

use of org.jkiss.dbeaver.tools.transfer.registry.DataTransferProcessorDescriptor in project dbeaver by serge-rider.

the class ResultSetHandlerOpenWith method fillOpenWithMenu.

public static void fillOpenWithMenu(ResultSetViewer viewer, IContributionManager openWithMenu) {
    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.getAppFileExtension() != null) {
                appProcessors.add(processor);
            }
        }
    }
    appProcessors.sort(Comparator.comparingInt(DataTransferProcessorDescriptor::getOrder));
    for (DataTransferProcessorDescriptor processor : appProcessors) {
        CommandContributionItemParameter params = new CommandContributionItemParameter(viewer.getSite(), processor.getId(), ResultSetHandlerOpenWith.CMD_OPEN_WITH, CommandContributionItem.STYLE_RADIO);
        params.label = processor.getAppName();
        if (processor.getIcon() != null) {
            params.icon = DBeaverIcons.getImageDescriptor(processor.getIcon());
        }
        Map<String, Object> parameters = new HashMap<>();
        parameters.put(ResultSetHandlerOpenWith.PARAM_PROCESSOR_ID, processor.getFullId());
        params.parameters = parameters;
        openWithMenu.add(new CommandContributionItem(params));
    }
}
Also used : CommandContributionItemParameter(org.eclipse.ui.menus.CommandContributionItemParameter) DataTransferProcessorDescriptor(org.jkiss.dbeaver.tools.transfer.registry.DataTransferProcessorDescriptor) DataTransferNodeDescriptor(org.jkiss.dbeaver.tools.transfer.registry.DataTransferNodeDescriptor) CommandContributionItem(org.eclipse.ui.menus.CommandContributionItem)

Example 32 with DataTransferProcessorDescriptor

use of org.jkiss.dbeaver.tools.transfer.registry.DataTransferProcessorDescriptor in project dbeaver by dbeaver.

the class ResultSetHandlerCopyAs method execute.

@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
    IResultSetController resultSet = ResultSetHandlerMain.getActiveResultSet(HandlerUtil.getActivePart(event));
    if (resultSet == null) {
        return null;
    }
    DataTransferProcessorDescriptor processor = getActiveProcessor(event.getParameter(PARAM_PROCESSOR_ID));
    if (processor == null) {
        return null;
    }
    switch(event.getCommand().getId()) {
        case CMD_COPY_AS:
            openResultsWith(resultSet, processor);
            break;
    }
    return null;
}
Also used : DataTransferProcessorDescriptor(org.jkiss.dbeaver.tools.transfer.registry.DataTransferProcessorDescriptor)

Example 33 with DataTransferProcessorDescriptor

use of org.jkiss.dbeaver.tools.transfer.registry.DataTransferProcessorDescriptor 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)

Example 34 with DataTransferProcessorDescriptor

use of org.jkiss.dbeaver.tools.transfer.registry.DataTransferProcessorDescriptor in project dbeaver by dbeaver.

the class ResultSetHandlerOpenWith method execute.

@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
    IResultSetController resultSet = ResultSetHandlerMain.getActiveResultSet(HandlerUtil.getActivePart(event));
    if (resultSet == null) {
        return null;
    }
    DataTransferProcessorDescriptor processor = getActiveProcessor(event.getParameter(PARAM_PROCESSOR_ID));
    if (processor == null) {
        return null;
    }
    switch(event.getCommand().getId()) {
        case CMD_OPEN_WITH:
            openResultsWith(resultSet, processor);
            break;
    }
    return null;
}
Also used : DataTransferProcessorDescriptor(org.jkiss.dbeaver.tools.transfer.registry.DataTransferProcessorDescriptor)

Aggregations

DataTransferProcessorDescriptor (org.jkiss.dbeaver.tools.transfer.registry.DataTransferProcessorDescriptor)34 DataTransferNodeDescriptor (org.jkiss.dbeaver.tools.transfer.registry.DataTransferNodeDescriptor)16 DBSObject (org.jkiss.dbeaver.model.struct.DBSObject)10 DBException (org.jkiss.dbeaver.DBException)6 ArrayList (java.util.ArrayList)4 CommandContributionItem (org.eclipse.ui.menus.CommandContributionItem)4 CommandContributionItemParameter (org.eclipse.ui.menus.CommandContributionItemParameter)4 DBPPropertyDescriptor (org.jkiss.dbeaver.model.preferences.DBPPropertyDescriptor)4 PropertySourceCustom (org.jkiss.dbeaver.runtime.properties.PropertySourceCustom)4 DataTransferSettings (org.jkiss.dbeaver.tools.transfer.DataTransferSettings)4 Collection (java.util.Collection)2 Date (java.util.Date)2 Color (org.eclipse.swt.graphics.Color)2 IWorkbenchPartSite (org.eclipse.ui.IWorkbenchPartSite)2 DBPImage (org.jkiss.dbeaver.model.DBPImage)2 DBPObject (org.jkiss.dbeaver.model.DBPObject)2 DBCException (org.jkiss.dbeaver.model.exec.DBCException)2 MonitorRunnableContext (org.jkiss.dbeaver.model.runtime.MonitorRunnableContext)2 DataTransferRegistry (org.jkiss.dbeaver.tools.transfer.registry.DataTransferRegistry)2 StreamConsumerSettings (org.jkiss.dbeaver.tools.transfer.stream.StreamConsumerSettings)2