Search in sources :

Example 1 with DBPDataFormatterRegistry

use of org.jkiss.dbeaver.model.app.DBPDataFormatterRegistry in project dbeaver by serge-rider.

the class StreamConsumerPageSettings method getSelectedFormatterProfile.

private Object getSelectedFormatterProfile() {
    DBPDataFormatterRegistry registry = DBWorkbench.getPlatform().getDataFormatterRegistry();
    int selectionIndex = formatProfilesCombo.getSelectionIndex();
    if (selectionIndex < 0) {
        return null;
    } else if (selectionIndex == 0) {
        return registry.getGlobalProfile();
    } else {
        return registry.getCustomProfile(UIUtils.getComboSelection(formatProfilesCombo));
    }
}
Also used : DBPDataFormatterRegistry(org.jkiss.dbeaver.model.app.DBPDataFormatterRegistry)

Example 2 with DBPDataFormatterRegistry

use of org.jkiss.dbeaver.model.app.DBPDataFormatterRegistry in project dbeaver by serge-rider.

the class StreamConsumerPageSettings method createControl.

@Override
public void createControl(Composite parent) {
    DBPDataFormatterRegistry dataFormatterRegistry = DBWorkbench.getPlatform().getDataFormatterRegistry();
    initializeDialogUnits(parent);
    final StreamConsumerSettings settings = getWizard().getPageSettings(this, StreamConsumerSettings.class);
    Composite composite = UIUtils.createComposite(parent, 1);
    {
        Composite generalSettings = UIUtils.createControlGroup(composite, DTMessages.data_transfer_wizard_settings_group_general, 5, GridData.FILL_HORIZONTAL, 0);
        ((GridLayout) generalSettings.getLayout()).verticalSpacing = 0;
        ((GridLayout) generalSettings.getLayout()).marginHeight = 0;
        ((GridLayout) generalSettings.getLayout()).marginWidth = 0;
        {
            formatProfilesCombo = UIUtils.createLabelCombo(generalSettings, DTMessages.data_transfer_wizard_settings_label_formatting, SWT.DROP_DOWN | SWT.READ_ONLY);
            GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING | GridData.FILL_HORIZONTAL);
            gd.horizontalSpan = 3;
            formatProfilesCombo.setLayoutData(gd);
            formatProfilesCombo.addSelectionListener(new SelectionAdapter() {

                @Override
                public void widgetSelected(SelectionEvent e) {
                    if (formatProfilesCombo.getSelectionIndex() > 0) {
                        settings.setFormatterProfile(dataFormatterRegistry.getCustomProfile(UIUtils.getComboSelection(formatProfilesCombo)));
                    } else {
                        settings.setFormatterProfile(null);
                    }
                }
            });
            UIUtils.createDialogButton(generalSettings, DTMessages.data_transfer_wizard_settings_button_edit, new SelectionAdapter() {

                @Override
                public void widgetSelected(SelectionEvent e) {
                    PreferenceDialog propDialog = PreferencesUtil.createPropertyDialogOn(getShell(), dataFormatterRegistry, // TODO: replace this hardcode with some model invocation
                    "org.jkiss.dbeaver.preferences.main.dataformat", null, getSelectedFormatterProfile(), PreferencesUtil.OPTION_NONE);
                    if (propDialog != null) {
                        propDialog.open();
                        reloadFormatProfiles();
                    }
                }
            });
            reloadFormatProfiles();
            UIUtils.createControlLabel(generalSettings, DTMessages.data_transfer_wizard_settings_label_binaries);
            Composite binariesPanel = UIUtils.createComposite(generalSettings, 4);
            gd = new GridData(GridData.FILL_HORIZONTAL);
            gd.horizontalSpan = 4;
            binariesPanel.setLayoutData(gd);
            lobExtractType = new Combo(binariesPanel, SWT.DROP_DOWN | SWT.READ_ONLY);
            lobExtractType.setItems(DTMessages.data_transfer_wizard_settings_binaries_item_set_to_null, DTMessages.data_transfer_wizard_settings_binaries_item_save_to_file, DTMessages.data_transfer_wizard_settings_binaries_item_inline);
            lobExtractType.addSelectionListener(new SelectionAdapter() {

                @Override
                public void widgetSelected(SelectionEvent e) {
                    switch(lobExtractType.getSelectionIndex()) {
                        case EXTRACT_LOB_SKIP:
                            settings.setLobExtractType(StreamConsumerSettings.LobExtractType.SKIP);
                            break;
                        case EXTRACT_LOB_FILES:
                            settings.setLobExtractType(StreamConsumerSettings.LobExtractType.FILES);
                            break;
                        case EXTRACT_LOB_INLINE:
                            settings.setLobExtractType(StreamConsumerSettings.LobExtractType.INLINE);
                            break;
                    }
                    updatePageCompletion();
                }
            });
            lobEncodingLabel = UIUtils.createControlLabel(binariesPanel, DTMessages.data_transfer_wizard_settings_label_encoding);
            lobEncodingCombo = new Combo(binariesPanel, SWT.DROP_DOWN | SWT.READ_ONLY);
            lobEncodingCombo.setItems(// $NON-NLS-1$
            "Base64", // $NON-NLS-1$
            "Hex", // $NON-NLS-1$
            "Binary", // $NON-NLS-1$
            "Native");
            lobEncodingCombo.addSelectionListener(new SelectionAdapter() {

                @Override
                public void widgetSelected(SelectionEvent e) {
                    switch(lobEncodingCombo.getSelectionIndex()) {
                        case LOB_ENCODING_BASE64:
                            settings.setLobEncoding(StreamConsumerSettings.LobEncoding.BASE64);
                            break;
                        case LOB_ENCODING_HEX:
                            settings.setLobEncoding(StreamConsumerSettings.LobEncoding.HEX);
                            break;
                        case LOB_ENCODING_BINARY:
                            settings.setLobEncoding(StreamConsumerSettings.LobEncoding.BINARY);
                            break;
                        case LOB_ENCODING_NATIVE:
                            settings.setLobEncoding(StreamConsumerSettings.LobEncoding.NATIVE);
                            break;
                    }
                }
            });
        }
    }
    {
        Composite exporterSettings = UIUtils.createControlGroup(composite, DTMessages.data_transfer_wizard_settings_group_exporter, 1, GridData.FILL_BOTH, 0);
        propsEditor = new PropertyTreeViewer(exporterSettings, SWT.BORDER);
    }
    setControl(composite);
}
Also used : StreamConsumerSettings(org.jkiss.dbeaver.tools.transfer.stream.StreamConsumerSettings) GridLayout(org.eclipse.swt.layout.GridLayout) Composite(org.eclipse.swt.widgets.Composite) PreferenceDialog(org.eclipse.jface.preference.PreferenceDialog) PropertyTreeViewer(org.jkiss.dbeaver.ui.properties.PropertyTreeViewer) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent) DBPDataFormatterRegistry(org.jkiss.dbeaver.model.app.DBPDataFormatterRegistry) Combo(org.eclipse.swt.widgets.Combo)

Example 3 with DBPDataFormatterRegistry

use of org.jkiss.dbeaver.model.app.DBPDataFormatterRegistry in project dbeaver by dbeaver.

the class StreamConsumerPageSettings method reloadFormatProfiles.

private void reloadFormatProfiles() {
    DBPDataFormatterRegistry registry = DBWorkbench.getPlatform().getDataFormatterRegistry();
    formatProfilesCombo.removeAll();
    formatProfilesCombo.add(DTMessages.data_transfer_wizard_settings_listbox_formatting_item_default);
    for (DBDDataFormatterProfile profile : registry.getCustomProfiles()) {
        formatProfilesCombo.add(profile.getProfileName());
    }
    final StreamConsumerSettings settings = getWizard().getPageSettings(this, StreamConsumerSettings.class);
    DBDDataFormatterProfile formatterProfile = settings.getFormatterProfile();
    if (formatterProfile != null) {
        if (!UIUtils.setComboSelection(formatProfilesCombo, formatterProfile.getProfileName())) {
            formatProfilesCombo.select(0);
        }
    } else {
        formatProfilesCombo.select(0);
    }
}
Also used : StreamConsumerSettings(org.jkiss.dbeaver.tools.transfer.stream.StreamConsumerSettings) DBPDataFormatterRegistry(org.jkiss.dbeaver.model.app.DBPDataFormatterRegistry) DBDDataFormatterProfile(org.jkiss.dbeaver.model.data.DBDDataFormatterProfile)

Example 4 with DBPDataFormatterRegistry

use of org.jkiss.dbeaver.model.app.DBPDataFormatterRegistry in project dbeaver by dbeaver.

the class StreamConsumerPageSettings method getSelectedFormatterProfile.

private Object getSelectedFormatterProfile() {
    DBPDataFormatterRegistry registry = DBWorkbench.getPlatform().getDataFormatterRegistry();
    int selectionIndex = formatProfilesCombo.getSelectionIndex();
    if (selectionIndex < 0) {
        return null;
    } else if (selectionIndex == 0) {
        return registry.getGlobalProfile();
    } else {
        return registry.getCustomProfile(UIUtils.getComboSelection(formatProfilesCombo));
    }
}
Also used : DBPDataFormatterRegistry(org.jkiss.dbeaver.model.app.DBPDataFormatterRegistry)

Example 5 with DBPDataFormatterRegistry

use of org.jkiss.dbeaver.model.app.DBPDataFormatterRegistry in project dbeaver by dbeaver.

the class StreamConsumerPageSettings method createControl.

@Override
public void createControl(Composite parent) {
    DBPDataFormatterRegistry dataFormatterRegistry = DBWorkbench.getPlatform().getDataFormatterRegistry();
    initializeDialogUnits(parent);
    final StreamConsumerSettings settings = getWizard().getPageSettings(this, StreamConsumerSettings.class);
    Composite composite = UIUtils.createComposite(parent, 1);
    {
        Composite generalSettings = UIUtils.createControlGroup(composite, DTMessages.data_transfer_wizard_settings_group_general, 5, GridData.FILL_HORIZONTAL, 0);
        ((GridLayout) generalSettings.getLayout()).verticalSpacing = 0;
        ((GridLayout) generalSettings.getLayout()).marginHeight = 0;
        ((GridLayout) generalSettings.getLayout()).marginWidth = 0;
        {
            formatProfilesCombo = UIUtils.createLabelCombo(generalSettings, DTMessages.data_transfer_wizard_settings_label_formatting, SWT.DROP_DOWN | SWT.READ_ONLY);
            GridData gd = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING | GridData.FILL_HORIZONTAL);
            gd.horizontalSpan = 3;
            formatProfilesCombo.setLayoutData(gd);
            formatProfilesCombo.addSelectionListener(new SelectionAdapter() {

                @Override
                public void widgetSelected(SelectionEvent e) {
                    if (formatProfilesCombo.getSelectionIndex() > 0) {
                        settings.setFormatterProfile(dataFormatterRegistry.getCustomProfile(UIUtils.getComboSelection(formatProfilesCombo)));
                    } else {
                        settings.setFormatterProfile(null);
                    }
                }
            });
            UIUtils.createDialogButton(generalSettings, DTMessages.data_transfer_wizard_settings_button_edit, new SelectionAdapter() {

                @Override
                public void widgetSelected(SelectionEvent e) {
                    PreferenceDialog propDialog = PreferencesUtil.createPropertyDialogOn(getShell(), dataFormatterRegistry, // TODO: replace this hardcode with some model invocation
                    "org.jkiss.dbeaver.preferences.main.dataformat", null, getSelectedFormatterProfile(), PreferencesUtil.OPTION_NONE);
                    if (propDialog != null) {
                        propDialog.open();
                        reloadFormatProfiles();
                    }
                }
            });
            reloadFormatProfiles();
            UIUtils.createControlLabel(generalSettings, DTMessages.data_transfer_wizard_settings_label_binaries);
            Composite binariesPanel = UIUtils.createComposite(generalSettings, 4);
            gd = new GridData(GridData.FILL_HORIZONTAL);
            gd.horizontalSpan = 4;
            binariesPanel.setLayoutData(gd);
            lobExtractType = new Combo(binariesPanel, SWT.DROP_DOWN | SWT.READ_ONLY);
            lobExtractType.setItems(DTMessages.data_transfer_wizard_settings_binaries_item_set_to_null, DTMessages.data_transfer_wizard_settings_binaries_item_save_to_file, DTMessages.data_transfer_wizard_settings_binaries_item_inline);
            lobExtractType.addSelectionListener(new SelectionAdapter() {

                @Override
                public void widgetSelected(SelectionEvent e) {
                    switch(lobExtractType.getSelectionIndex()) {
                        case EXTRACT_LOB_SKIP:
                            settings.setLobExtractType(StreamConsumerSettings.LobExtractType.SKIP);
                            break;
                        case EXTRACT_LOB_FILES:
                            settings.setLobExtractType(StreamConsumerSettings.LobExtractType.FILES);
                            break;
                        case EXTRACT_LOB_INLINE:
                            settings.setLobExtractType(StreamConsumerSettings.LobExtractType.INLINE);
                            break;
                    }
                    updatePageCompletion();
                }
            });
            lobEncodingLabel = UIUtils.createControlLabel(binariesPanel, DTMessages.data_transfer_wizard_settings_label_encoding);
            lobEncodingCombo = new Combo(binariesPanel, SWT.DROP_DOWN | SWT.READ_ONLY);
            lobEncodingCombo.setItems(// $NON-NLS-1$
            "Base64", // $NON-NLS-1$
            "Hex", // $NON-NLS-1$
            "Binary", // $NON-NLS-1$
            "Native");
            lobEncodingCombo.addSelectionListener(new SelectionAdapter() {

                @Override
                public void widgetSelected(SelectionEvent e) {
                    switch(lobEncodingCombo.getSelectionIndex()) {
                        case LOB_ENCODING_BASE64:
                            settings.setLobEncoding(StreamConsumerSettings.LobEncoding.BASE64);
                            break;
                        case LOB_ENCODING_HEX:
                            settings.setLobEncoding(StreamConsumerSettings.LobEncoding.HEX);
                            break;
                        case LOB_ENCODING_BINARY:
                            settings.setLobEncoding(StreamConsumerSettings.LobEncoding.BINARY);
                            break;
                        case LOB_ENCODING_NATIVE:
                            settings.setLobEncoding(StreamConsumerSettings.LobEncoding.NATIVE);
                            break;
                    }
                }
            });
        }
    }
    {
        Composite exporterSettings = UIUtils.createControlGroup(composite, DTMessages.data_transfer_wizard_settings_group_exporter, 1, GridData.FILL_BOTH, 0);
        propsEditor = new PropertyTreeViewer(exporterSettings, SWT.BORDER);
    }
    setControl(composite);
}
Also used : StreamConsumerSettings(org.jkiss.dbeaver.tools.transfer.stream.StreamConsumerSettings) GridLayout(org.eclipse.swt.layout.GridLayout) Composite(org.eclipse.swt.widgets.Composite) PreferenceDialog(org.eclipse.jface.preference.PreferenceDialog) PropertyTreeViewer(org.jkiss.dbeaver.ui.properties.PropertyTreeViewer) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) GridData(org.eclipse.swt.layout.GridData) SelectionEvent(org.eclipse.swt.events.SelectionEvent) DBPDataFormatterRegistry(org.jkiss.dbeaver.model.app.DBPDataFormatterRegistry) Combo(org.eclipse.swt.widgets.Combo)

Aggregations

DBPDataFormatterRegistry (org.jkiss.dbeaver.model.app.DBPDataFormatterRegistry)6 StreamConsumerSettings (org.jkiss.dbeaver.tools.transfer.stream.StreamConsumerSettings)4 PreferenceDialog (org.eclipse.jface.preference.PreferenceDialog)2 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)2 SelectionEvent (org.eclipse.swt.events.SelectionEvent)2 GridData (org.eclipse.swt.layout.GridData)2 GridLayout (org.eclipse.swt.layout.GridLayout)2 Combo (org.eclipse.swt.widgets.Combo)2 Composite (org.eclipse.swt.widgets.Composite)2 DBDDataFormatterProfile (org.jkiss.dbeaver.model.data.DBDDataFormatterProfile)2 PropertyTreeViewer (org.jkiss.dbeaver.ui.properties.PropertyTreeViewer)2