Search in sources :

Example 6 with DynamicDistributionSetupData

use of org.talend.repository.hadoopcluster.ui.dynamic.DynamicDistributionSetupData in project tbd-studio-se by Talend.

the class DynamicDistributionPreferenceForm method addListeners.

private void addListeners() {
    if (ITalendCorePrefConstants.DYNAMIC_DISTRIBUTION_SETTING == showPart) {
        distributionCombo.addSelectionChangedListener(new ISelectionChangedListener() {

            @Override
            public void selectionChanged(SelectionChangedEvent event) {
                refreshVersionList(new DummyDynamicMonitor());
                updateButtons();
            }
        });
        versionCombo.addSelectionChangedListener(new ISelectionChangedListener() {

            @Override
            public void selectionChanged(SelectionChangedEvent event) {
                updateButtons();
            }
        });
        buildConfigBtn.addSelectionListener(new SelectionAdapter() {

            @Override
            public void widgetSelected(SelectionEvent e) {
                try {
                    IStructuredSelection selection = (IStructuredSelection) distributionCombo.getSelection();
                    if (selection == null) {
                        ExceptionHandler.process(new Exception(// $NON-NLS-1$
                        Messages.getString("DynamicDistributionPreferenceForm.exception.noDistributionSelected")));
                        return;
                    }
                    String distribution = (String) selection.getFirstElement();
                    if (distribution == null) {
                        ExceptionHandler.process(new Exception(// $NON-NLS-1$
                        Messages.getString("DynamicDistributionPreferenceForm.exception.noDistributionSelected")));
                        return;
                    }
                    IDynamicDistributionsGroup dynamicDistributionsGroup = DynamicDistributionManager.getInstance().getDynamicDistributionGroup(distribution);
                    DynamicDistributionSetupData configData = new DynamicDistributionSetupData();
                    configData.setDynamicDistributionsGroup(dynamicDistributionsGroup);
                    DynamicDistributionSetupWizard wizard = new DynamicDistributionSetupWizard(configData);
                    WizardDialog wizardDialog = new WizardDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), wizard);
                    wizardDialog.setMinimumPageSize(600, 400);
                    wizardDialog.create();
                    if (wizardDialog.open() == IDialogConstants.OK_ID) {
                    // nothing to do
                    }
                    IDynamicMonitor monitor = new DummyDynamicMonitor();
                    refreshVersionList(monitor);
                } catch (Throwable ex) {
                    ExceptionHandler.process(ex);
                }
                updateButtons();
            }
        });
        deleteBtn.addSelectionListener(new SelectionAdapter() {

            @Override
            public void widgetSelected(SelectionEvent e) {
                onDeleteBtnPressed();
                updateButtons();
            }
        });
    } else {
        setupDistriCombo.addSelectionChangedListener(new ISelectionChangedListener() {

            @Override
            public void selectionChanged(SelectionChangedEvent event) {
                try {
                    loadRepositorySetupGroup();
                } catch (Exception e) {
                    ExceptionHandler.process(e);
                }
                updateButtons();
            }
        });
        overrideDefaultSetupBtn.addSelectionListener(new SelectionAdapter() {

            @Override
            public void widgetSelected(SelectionEvent e) {
                updateButtons();
            }
        });
        repositoryText.addModifyListener(new ModifyListener() {

            @Override
            public void modifyText(ModifyEvent e) {
                String newRepositoryText = repositoryText.getText();
                if (StringUtils.equals(newRepositoryText, repositoryUrlCache)) {
                    return;
                }
                repositoryUrlCache = newRepositoryText;
                updateButtons();
            }
        });
        anonymousBtn.addSelectionListener(new SelectionAdapter() {

            @Override
            public void widgetSelected(SelectionEvent e) {
                updateButtons();
            }
        });
        userText.addModifyListener(new ModifyListener() {

            @Override
            public void modifyText(ModifyEvent e) {
                String newUsername = userText.getText();
                if (StringUtils.equals(newUsername, usernameCache)) {
                    return;
                }
                usernameCache = newUsername;
                updateButtons();
            }
        });
        passwordText.addModifyListener(new ModifyListener() {

            @Override
            public void modifyText(ModifyEvent e) {
                String newPassword = passwordText.getText();
                if (StringUtils.equals(newPassword, passwordCache)) {
                    return;
                }
                passwordCache = newPassword;
                updateButtons();
            }
        });
        checkConnectionBtn.addSelectionListener(new SelectionAdapter() {

            @Override
            public void widgetSelected(SelectionEvent e) {
                if (!isComplete()) {
                    return;
                }
                TypedReturnCode tc = new TypedReturnCode();
                try {
                    IDynamicDistributionsGroup distriGroup = getSelectedSetupDynamicDistriGroup();
                    DynamicConfiguration dynamicConfiguration = new DynamicConfiguration();
                    dynamicConfiguration.setDistribution(distriGroup.getDistribution());
                    IDependencyResolver dependencyResolver = distriGroup.getDependencyResolver(dynamicConfiguration);
                    tc = dependencyResolver.checkConnection(repositoryText.getText(), userText.getText(), passwordText.getText());
                } catch (Exception e1) {
                    ExceptionHandler.process(e1);
                    tc.setOk(false);
                    tc.setMessage(e1.getMessage());
                }
                showCheckConnectionInformation(true, tc);
            }
        });
    }
}
Also used : ModifyListener(org.eclipse.swt.events.ModifyListener) ISelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) LoginException(org.talend.commons.exception.LoginException) InvocationTargetException(java.lang.reflect.InvocationTargetException) PersistenceException(org.talend.commons.exception.PersistenceException) IDependencyResolver(org.talend.hadoop.distribution.dynamic.resolver.IDependencyResolver) DynamicDistributionSetupWizard(org.talend.repository.hadoopcluster.ui.dynamic.DynamicDistributionSetupWizard) ModifyEvent(org.eclipse.swt.events.ModifyEvent) IDynamicDistributionsGroup(org.talend.hadoop.distribution.dynamic.IDynamicDistributionsGroup) DynamicConfiguration(org.talend.hadoop.distribution.dynamic.DynamicConfiguration) TypedReturnCode(org.talend.utils.sugars.TypedReturnCode) DummyDynamicMonitor(org.talend.designer.maven.aether.DummyDynamicMonitor) SelectionEvent(org.eclipse.swt.events.SelectionEvent) DynamicDistributionSetupData(org.talend.repository.hadoopcluster.ui.dynamic.DynamicDistributionSetupData) WizardDialog(org.eclipse.jface.wizard.WizardDialog) IDynamicMonitor(org.talend.designer.maven.aether.IDynamicMonitor)

Example 7 with DynamicDistributionSetupData

use of org.talend.repository.hadoopcluster.ui.dynamic.DynamicDistributionSetupData in project tbd-studio-se by Talend.

the class DynamicDistributionOptionForm method initData.

private void initData(IDynamicMonitor monitor) {
    try {
        namePluginMap = getNamePluginMap();
        getDynamicDistributionSetupData().setNamePluginMap(namePluginMap);
    } catch (Exception e) {
        ExceptionHandler.process(e);
    }
    DynamicDistributionSetupData dynConfigData = getDynamicDistributionSetupData();
    IDynamicDistributionsGroup dynamicDistributionsGroup = dynConfigData.getDynamicDistributionsGroup();
    dynamicConfiguration = new DynamicConfiguration();
    dynamicConfiguration.setDistribution(dynamicDistributionsGroup.getDistribution());
    try {
        refreshExistingConfigsCombo(monitor, dynamicDistributionsGroup);
    } catch (Exception e) {
        ExceptionHandler.process(e);
    }
}
Also used : IDynamicDistributionsGroup(org.talend.hadoop.distribution.dynamic.IDynamicDistributionsGroup) DynamicConfiguration(org.talend.hadoop.distribution.dynamic.DynamicConfiguration) DynamicDistributionSetupData(org.talend.repository.hadoopcluster.ui.dynamic.DynamicDistributionSetupData) InvocationTargetException(java.lang.reflect.InvocationTargetException)

Example 8 with DynamicDistributionSetupData

use of org.talend.repository.hadoopcluster.ui.dynamic.DynamicDistributionSetupData 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)

Example 9 with DynamicDistributionSetupData

use of org.talend.repository.hadoopcluster.ui.dynamic.DynamicDistributionSetupData in project tbd-studio-se by Talend.

the class DynamicDistributionOptionForm method getNamePluginMap.

private Map<String, IDynamicPlugin> getNamePluginMap() throws Exception {
    if (namePluginMap == null || namePluginMap.isEmpty()) {
        namePluginMap = new HashMap<>();
        DynamicDistributionSetupData dynamicBuildConfigurationData = getDynamicDistributionSetupData();
        if (allBuiltinDynamicPlugins == null || allBuiltinDynamicPlugins.isEmpty()) {
            copyAllUsersDynamicPlugins(new DummyDynamicMonitor(), dynamicBuildConfigurationData.getDynamicDistributionsGroup());
        }
        if (allBuiltinDynamicPlugins != null) {
            for (IDynamicPlugin plugin : allBuiltinDynamicPlugins) {
                IDynamicPluginConfiguration pluginConfiguration = plugin.getPluginConfiguration();
                String name = pluginConfiguration.getName();
                namePluginMap.put(name, plugin);
            }
        }
        if (allCurrentUsersDynamicPlugins != null) {
            for (IDynamicPlugin plugin : allCurrentUsersDynamicPlugins) {
                IDynamicPluginConfiguration pluginConfiguration = plugin.getPluginConfiguration();
                String name = pluginConfiguration.getName();
                namePluginMap.put(name, plugin);
            }
        }
    }
    return namePluginMap;
}
Also used : IDynamicPlugin(org.talend.core.runtime.dynamic.IDynamicPlugin) DummyDynamicMonitor(org.talend.designer.maven.aether.DummyDynamicMonitor) DynamicDistributionSetupData(org.talend.repository.hadoopcluster.ui.dynamic.DynamicDistributionSetupData) IDynamicPluginConfiguration(org.talend.core.runtime.dynamic.IDynamicPluginConfiguration)

Aggregations

DynamicDistributionSetupData (org.talend.repository.hadoopcluster.ui.dynamic.DynamicDistributionSetupData)9 InvocationTargetException (java.lang.reflect.InvocationTargetException)8 IDynamicDistributionsGroup (org.talend.hadoop.distribution.dynamic.IDynamicDistributionsGroup)6 IDynamicPlugin (org.talend.core.runtime.dynamic.IDynamicPlugin)4 IDynamicMonitor (org.talend.designer.maven.aether.IDynamicMonitor)4 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)3 IRunnableWithProgress (org.eclipse.jface.operation.IRunnableWithProgress)3 IDynamicPluginConfiguration (org.talend.core.runtime.dynamic.IDynamicPluginConfiguration)3 AbsDynamicProgressMonitor (org.talend.designer.maven.aether.AbsDynamicProgressMonitor)3 ArrayList (java.util.ArrayList)2 LinkedList (java.util.LinkedList)2 List (java.util.List)2 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)2 DummyDynamicMonitor (org.talend.designer.maven.aether.DummyDynamicMonitor)2 DynamicConfiguration (org.talend.hadoop.distribution.dynamic.DynamicConfiguration)2 Calendar (java.util.Calendar)1 Date (java.util.Date)1 ISelectionChangedListener (org.eclipse.jface.viewers.ISelectionChangedListener)1 SelectionChangedEvent (org.eclipse.jface.viewers.SelectionChangedEvent)1 WizardDialog (org.eclipse.jface.wizard.WizardDialog)1