Search in sources :

Example 11 with IDynamicDistributionsGroup

use of org.talend.hadoop.distribution.dynamic.IDynamicDistributionsGroup 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)

Example 12 with IDynamicDistributionsGroup

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

the class DynamicDistributionPreferenceForm method loadData.

private void loadData(IDynamicMonitor monitor) {
    try {
        DynamicDistributionManager dynDistriManager = DynamicDistributionManager.getInstance();
        List<IDynamicDistributionsGroup> dynDistriGroups = dynDistriManager.getDynamicDistributionsGroups();
        if (dynDistriGroups != null && !dynDistriGroups.isEmpty()) {
            List<String> distributionDisplayNames = new ArrayList<>();
            for (IDynamicDistributionsGroup dynDistriGroup : dynDistriGroups) {
                String displayName = dynDistriGroup.getDistributionDisplay();
                distributionDisplayNames.add(displayName);
            }
            Collections.sort(distributionDisplayNames);
            if (ITalendCorePrefConstants.DYNAMIC_DISTRIBUTION_SETTING == showPart) {
                distributionCombo.setInput(distributionDisplayNames);
            } else {
                setupDistriCombo.setInput(distributionDisplayNames);
            }
            if (0 < distributionDisplayNames.size()) {
                if (ITalendCorePrefConstants.DYNAMIC_DISTRIBUTION_SETTING == showPart) {
                    distributionCombo.setSelection(new StructuredSelection(distributionDisplayNames.get(0)));
                    refreshVersionList(monitor);
                } else {
                    setupDistriCombo.setSelection(new StructuredSelection(distributionDisplayNames.get(0)));
                }
            }
        }
        if (ITalendCorePrefConstants.DYNAMIC_DISTRIBUTION_SETTING != showPart) {
            loadRepositorySetupGroup();
        }
    } catch (Exception e) {
        ExceptionHandler.process(e);
    }
}
Also used : IDynamicDistributionsGroup(org.talend.hadoop.distribution.dynamic.IDynamicDistributionsGroup) DynamicDistributionManager(org.talend.hadoop.distribution.dynamic.DynamicDistributionManager) ArrayList(java.util.ArrayList) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) StructuredSelection(org.eclipse.jface.viewers.StructuredSelection) LoginException(org.talend.commons.exception.LoginException) InvocationTargetException(java.lang.reflect.InvocationTargetException) PersistenceException(org.talend.commons.exception.PersistenceException)

Example 13 with IDynamicDistributionsGroup

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

the class DynamicDistributionOptionForm method checkNewConfig.

private boolean checkNewConfig() {
    try {
        if (!newConfigBtn.getSelection()) {
            return true;
        }
        versionsComboViewer.getControl().setEnabled(false);
        List<String> versionList = (List<String>) versionsComboViewer.getInput();
        if (versionList == null || versionList.isEmpty()) {
            String errorMessage = // $NON-NLS-1$
            Messages.getString(// $NON-NLS-1$
            "DynamicDistributionOptionForm.newConfig.check.empty", refreshButton.getText());
            showMessage(errorMessage, WizardPage.ERROR);
            return false;
        }
        // $NON-NLS-1$
        String selectedVersion = "";
        IStructuredSelection selection = (IStructuredSelection) versionsComboViewer.getSelection();
        if (selection != null) {
            selectedVersion = (String) selection.getFirstElement();
        }
        if (StringUtils.isEmpty(selectedVersion)) {
            String errorMessage = // $NON-NLS-1$
            Messages.getString(// $NON-NLS-1$
            "DynamicDistributionOptionForm.newConfig.check.empty", refreshButton.getText());
            showMessage(errorMessage, WizardPage.ERROR);
            return false;
        }
        versionsComboViewer.getControl().setEnabled(true);
        DynamicDistributionSetupData dynamicBuildConfigurationData = getDynamicDistributionSetupData();
        IDynamicDistributionsGroup dynamicDistributionsGroup = dynamicBuildConfigurationData.getDynamicDistributionsGroup();
        String versionName = dynamicDistributionsGroup.generateVersionName(selectedVersion);
        if (dynamicBuildConfigurationData.getNamePluginMap().containsKey(versionName)) {
            String errorMessage = // $NON-NLS-1$
            Messages.getString(// $NON-NLS-1$
            "DynamicDistributionOptionForm.newConfig.check.nameExist", // $NON-NLS-1$
            versionName, editExistingConfigBtn.getText());
            showMessage(errorMessage, WizardPage.ERROR);
            return false;
        }
        String versionId = dynamicDistributionsGroup.generateVersionId(selectedVersion);
        versionId = DynamicDistributionUtils.appendTimestamp(versionId);
        dynamicConfiguration.setId(versionId);
        dynamicConfiguration.setName(versionName);
        dynamicConfiguration.setVersion(selectedVersion);
        if (!checkSparkVersonSelection()) {
            return false;
        }
        return true;
    } catch (Exception e) {
        ExceptionHandler.process(e);
        return false;
    }
}
Also used : IDynamicDistributionsGroup(org.talend.hadoop.distribution.dynamic.IDynamicDistributionsGroup) List(java.util.List) ArrayList(java.util.ArrayList) LinkedList(java.util.LinkedList) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) DynamicDistributionSetupData(org.talend.repository.hadoopcluster.ui.dynamic.DynamicDistributionSetupData) InvocationTargetException(java.lang.reflect.InvocationTargetException)

Aggregations

IDynamicDistributionsGroup (org.talend.hadoop.distribution.dynamic.IDynamicDistributionsGroup)13 InvocationTargetException (java.lang.reflect.InvocationTargetException)10 DynamicDistributionSetupData (org.talend.repository.hadoopcluster.ui.dynamic.DynamicDistributionSetupData)6 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)4 LoginException (org.talend.commons.exception.LoginException)4 PersistenceException (org.talend.commons.exception.PersistenceException)4 IDynamicMonitor (org.talend.designer.maven.aether.IDynamicMonitor)4 IDynamicDistributionPreference (org.talend.hadoop.distribution.dynamic.pref.IDynamicDistributionPreference)4 ArrayList (java.util.ArrayList)3 LinkedList (java.util.LinkedList)3 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)3 IRunnableWithProgress (org.eclipse.jface.operation.IRunnableWithProgress)3 IDynamicPlugin (org.talend.core.runtime.dynamic.IDynamicPlugin)3 AbsDynamicProgressMonitor (org.talend.designer.maven.aether.AbsDynamicProgressMonitor)3 List (java.util.List)2 StructuredSelection (org.eclipse.jface.viewers.StructuredSelection)2 IDynamicPluginConfiguration (org.talend.core.runtime.dynamic.IDynamicPluginConfiguration)2 DynamicConfiguration (org.talend.hadoop.distribution.dynamic.DynamicConfiguration)2 File (java.io.File)1 Calendar (java.util.Calendar)1