Search in sources :

Example 1 with DBDDataFormatterProfile

use of org.jkiss.dbeaver.model.data.DBDDataFormatterProfile in project dbeaver by serge-rider.

the class DataFormatProfilesEditDialog method loadProfiles.

private void loadProfiles() {
    profileList.removeAll();
    List<DBDDataFormatterProfile> profiles = DataFormatterRegistry.getInstance().getCustomProfiles();
    for (DBDDataFormatterProfile profile : profiles) {
        profileList.add(profile.getProfileName());
    }
    Button deleteButton = getButton(DELETE_ID);
    if (deleteButton != null) {
        deleteButton.setEnabled(false);
    }
}
Also used : Button(org.eclipse.swt.widgets.Button) DBDDataFormatterProfile(org.jkiss.dbeaver.model.data.DBDDataFormatterProfile)

Example 2 with DBDDataFormatterProfile

use of org.jkiss.dbeaver.model.data.DBDDataFormatterProfile in project dbeaver by serge-rider.

the class StreamConsumerPageSettings method reloadFormatProfiles.

private void reloadFormatProfiles() {
    DataFormatterRegistry registry = DataFormatterRegistry.getInstance();
    formatProfilesCombo.removeAll();
    formatProfilesCombo.add(CoreMessages.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 : DBDDataFormatterProfile(org.jkiss.dbeaver.model.data.DBDDataFormatterProfile) DataFormatterRegistry(org.jkiss.dbeaver.registry.formatter.DataFormatterRegistry)

Example 3 with DBDDataFormatterProfile

use of org.jkiss.dbeaver.model.data.DBDDataFormatterProfile in project dbeaver by serge-rider.

the class DataFormatterRegistry method saveProfiles.

private void saveProfiles() {
    if (customProfiles == null) {
        return;
    }
    File storeFile = DBeaverActivator.getConfigurationFile(CONFIG_FILE_NAME);
    try (OutputStream os = new FileOutputStream(storeFile)) {
        XMLBuilder xml = new XMLBuilder(os, GeneralUtils.UTF8_ENCODING);
        xml.setButify(true);
        xml.startElement(RegistryConstants.TAG_PROFILES);
        for (DBDDataFormatterProfile profile : customProfiles) {
            xml.startElement(RegistryConstants.TAG_PROFILE);
            xml.addAttribute(RegistryConstants.ATTR_NAME, profile.getProfileName());
            SimplePreferenceStore store = (SimplePreferenceStore) profile.getPreferenceStore();
            Map<String, String> props = store.getProperties();
            if (props != null) {
                for (Map.Entry<String, String> entry : props.entrySet()) {
                    xml.startElement(RegistryConstants.TAG_PROPERTY);
                    xml.addAttribute(RegistryConstants.ATTR_NAME, entry.getKey());
                    xml.addAttribute(RegistryConstants.ATTR_VALUE, entry.getValue());
                    xml.endElement();
                }
            }
            xml.endElement();
        }
        xml.endElement();
        xml.flush();
    } catch (IOException ex) {
        log.warn("IO error", ex);
    }
}
Also used : SimplePreferenceStore(org.jkiss.dbeaver.model.impl.preferences.SimplePreferenceStore) DBDDataFormatterProfile(org.jkiss.dbeaver.model.data.DBDDataFormatterProfile) HashMap(java.util.HashMap) Map(java.util.Map) XMLBuilder(org.jkiss.utils.xml.XMLBuilder)

Example 4 with DBDDataFormatterProfile

use of org.jkiss.dbeaver.model.data.DBDDataFormatterProfile in project dbeaver by serge-rider.

the class PrefPageDataFormat method refreshProfileList.

private void refreshProfileList() {
    if (isDataSourcePreferencePage()) {
        return;
    }
    int selectionIndex = profilesCombo.getSelectionIndex();
    String oldProfile = null;
    if (selectionIndex > 0) {
        oldProfile = profilesCombo.getItem(selectionIndex);
    }
    profilesCombo.removeAll();
    //$NON-NLS-1$ //$NON-NLS-2$
    profilesCombo.add("<" + DataFormatterRegistry.getInstance().getGlobalProfile().getProfileName() + ">");
    for (DBDDataFormatterProfile profile : DataFormatterRegistry.getInstance().getCustomProfiles()) {
        profilesCombo.add(profile.getProfileName());
    }
    if (oldProfile != null) {
        profilesCombo.setText(oldProfile);
    }
    if (profilesCombo.getSelectionIndex() < 0) {
        profilesCombo.select(0);
    }
    profilesCombo.setEnabled(profilesCombo.getItemCount() >= 2);
    changeProfile();
}
Also used : DBDDataFormatterProfile(org.jkiss.dbeaver.model.data.DBDDataFormatterProfile)

Example 5 with DBDDataFormatterProfile

use of org.jkiss.dbeaver.model.data.DBDDataFormatterProfile in project dbeaver by serge-rider.

the class PrefPageDataFormat method changeProfile.

private void changeProfile() {
    int selectionIndex = profilesCombo.getSelectionIndex();
    if (selectionIndex < 0) {
        return;
    }
    DBDDataFormatterProfile newProfile;
    if (selectionIndex == 0) {
        newProfile = getDefaultProfile();
    } else {
        String newProfileName = profilesCombo.getItem(selectionIndex);
        newProfile = DataFormatterRegistry.getInstance().getCustomProfile(newProfileName);
    }
    if (newProfile != formatterProfile) {
        setCurrentProfile(newProfile);
    }
}
Also used : DBDDataFormatterProfile(org.jkiss.dbeaver.model.data.DBDDataFormatterProfile)

Aggregations

DBDDataFormatterProfile (org.jkiss.dbeaver.model.data.DBDDataFormatterProfile)7 DataFormatterRegistry (org.jkiss.dbeaver.registry.formatter.DataFormatterRegistry)2 HashMap (java.util.HashMap)1 Map (java.util.Map)1 Button (org.eclipse.swt.widgets.Button)1 SimplePreferenceStore (org.jkiss.dbeaver.model.impl.preferences.SimplePreferenceStore)1 XMLBuilder (org.jkiss.utils.xml.XMLBuilder)1