Search in sources :

Example 11 with IDynamicDistributionPreference

use of org.talend.hadoop.distribution.dynamic.pref.IDynamicDistributionPreference in project tbd-studio-se by Talend.

the class DynamicDistributionPreferenceForm method performDefaults.

@Override
public boolean performDefaults() {
    boolean isReadonly = isReadonly();
    if (isReadonly) {
        super.performDefaults();
        return false;
    }
    boolean agree = MessageDialog.openConfirm(getShell(), // $NON-NLS-1$
    Messages.getString("DynamicDistributionPreferenceForm.performDefaults.confirm.title"), // $NON-NLS-1$
    Messages.getString("DynamicDistributionPreferenceForm.performDefaults.confirm.message"));
    if (!agree) {
        return false;
    }
    try {
        IDynamicDistributionsGroup selectedSetupDynamicDistriGroup = getSelectedSetupDynamicDistriGroup();
        if (selectedSetupDynamicDistriGroup != null) {
            IDynamicDistributionPreference dynamicDistributionPreference = selectedSetupDynamicDistriGroup.getDynamicDistributionPreference(ProjectManager.getInstance().getCurrentProject());
            if (dynamicDistributionPreference != null) {
                boolean changed = false;
                boolean isAnonymous = dynamicDistributionPreference.getDefaultIsAnonymous();
                changed = changed || dynamicDistributionPreference.isAnonymous() != isAnonymous;
                dynamicDistributionPreference.setAnonymous(isAnonymous);
                boolean overrideDefaultSetup = dynamicDistributionPreference.getDefaultOverrideDefaultSetup();
                changed = changed || dynamicDistributionPreference.overrideDefaultSetup() != overrideDefaultSetup;
                dynamicDistributionPreference.setOverrideDefaultSetup(overrideDefaultSetup);
                String password = dynamicDistributionPreference.getDefaultPassword();
                changed = changed || !StringUtils.equals(dynamicDistributionPreference.getPassword(), password);
                dynamicDistributionPreference.setPassword(password);
                String repository = dynamicDistributionPreference.getDefaultRepository();
                changed = changed || !StringUtils.equals(dynamicDistributionPreference.getRepository(), repository);
                dynamicDistributionPreference.setRepository(repository);
                String username = dynamicDistributionPreference.getDefaultUsername();
                changed = changed || !StringUtils.equals(dynamicDistributionPreference.getUsername(), username);
                dynamicDistributionPreference.setUsername(username);
                dynamicDistributionPreference.save();
                loadRepositorySetupGroup();
                isComplete();
                if (changed) {
                    reloadDynamicDistributions();
                }
            }
        }
    } catch (Throwable e) {
        ExceptionHandler.process(e);
        String message = e.getMessage();
        if (StringUtils.isEmpty(message)) {
            // $NON-NLS-1$
            message = Messages.getString("ExceptionDialog.message.empty");
        }
        // $NON-NLS-1$
        ExceptionMessageDialog.openError(getShell(), Messages.getString("ExceptionDialog.title"), message, e);
    }
    return super.performDefaults();
}
Also used : IDynamicDistributionPreference(org.talend.hadoop.distribution.dynamic.pref.IDynamicDistributionPreference) IDynamicDistributionsGroup(org.talend.hadoop.distribution.dynamic.IDynamicDistributionsGroup)

Example 12 with IDynamicDistributionPreference

use of org.talend.hadoop.distribution.dynamic.pref.IDynamicDistributionPreference in project tbd-studio-se by Talend.

the class DynamicDistributionPreferenceForm method performApply.

@Override
public boolean performApply() {
    boolean isReadonly = isReadonly();
    if (isReadonly) {
        return super.performApply();
    }
    try {
        IDynamicDistributionsGroup selectedSetupDynamicDistriGroup = getSelectedSetupDynamicDistriGroup();
        if (selectedSetupDynamicDistriGroup != null) {
            IDynamicDistributionPreference dynamicDistributionPreference = selectedSetupDynamicDistriGroup.getDynamicDistributionPreference(ProjectManager.getInstance().getCurrentProject());
            if (dynamicDistributionPreference != null) {
                boolean changed = false;
                boolean isAnonymous = anonymousBtn.getSelection();
                changed = changed || dynamicDistributionPreference.isAnonymous() != isAnonymous;
                dynamicDistributionPreference.setAnonymous(isAnonymous);
                boolean overrideDefaultSetup = overrideDefaultSetupBtn.getSelection();
                changed = changed || dynamicDistributionPreference.overrideDefaultSetup() != overrideDefaultSetup;
                dynamicDistributionPreference.setOverrideDefaultSetup(overrideDefaultSetup);
                String password = passwordText.getText();
                changed = changed || !StringUtils.equals(dynamicDistributionPreference.getPassword(), password);
                dynamicDistributionPreference.setPassword(password);
                String repository = repositoryText.getText();
                changed = changed || !StringUtils.equals(dynamicDistributionPreference.getRepository(), repository);
                dynamicDistributionPreference.setRepository(repository);
                String username = userText.getText();
                changed = changed || !StringUtils.equals(dynamicDistributionPreference.getUsername(), username);
                dynamicDistributionPreference.setUsername(username);
                dynamicDistributionPreference.save();
                isComplete();
                if (changed) {
                    reloadDynamicDistributions();
                }
            }
        }
    } catch (Throwable e) {
        ExceptionHandler.process(e);
        String message = e.getMessage();
        if (StringUtils.isEmpty(message)) {
            // $NON-NLS-1$
            message = Messages.getString("ExceptionDialog.message.empty");
        }
        // $NON-NLS-1$
        ExceptionMessageDialog.openError(getShell(), Messages.getString("ExceptionDialog.title"), message, e);
    }
    return super.performApply();
}
Also used : IDynamicDistributionPreference(org.talend.hadoop.distribution.dynamic.pref.IDynamicDistributionPreference) IDynamicDistributionsGroup(org.talend.hadoop.distribution.dynamic.IDynamicDistributionsGroup)

Aggregations

IDynamicDistributionPreference (org.talend.hadoop.distribution.dynamic.pref.IDynamicDistributionPreference)12 IDynamicDistributionsGroup (org.talend.hadoop.distribution.dynamic.IDynamicDistributionsGroup)4 LoginException (org.talend.commons.exception.LoginException)2 PersistenceException (org.talend.commons.exception.PersistenceException)2 Project (org.talend.core.model.general.Project)2 IDynamicPlugin (org.talend.core.runtime.dynamic.IDynamicPlugin)2 IDynamicPluginConfiguration (org.talend.core.runtime.dynamic.IDynamicPluginConfiguration)2 DynamicConfiguration (org.talend.hadoop.distribution.dynamic.DynamicConfiguration)2 DynamicPluginAdapter (org.talend.hadoop.distribution.dynamic.adapter.DynamicPluginAdapter)2 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 ArrayList (java.util.ArrayList)1 IProject (org.eclipse.core.resources.IProject)1 Bundle (org.osgi.framework.Bundle)1 DependencyNode (org.talend.designer.maven.aether.node.DependencyNode)1 VersionNotFoundException (org.talend.hadoop.distribution.dynamic.VersionNotFoundException)1 IDynamicDistributionTemplate (org.talend.hadoop.distribution.dynamic.template.IDynamicDistributionTemplate)1 ProjectManager (org.talend.repository.ProjectManager)1