Search in sources :

Example 11 with IDynamicMonitor

use of org.talend.designer.maven.aether.IDynamicMonitor 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 12 with IDynamicMonitor

use of org.talend.designer.maven.aether.IDynamicMonitor in project tbd-studio-se by Talend.

the class HadoopUiService method createDynamicDistributionPrefForm.

/* (non-Javadoc)
     * @see org.talend.core.ui.services.IHadoopUiService#createDynamicDistributionPrefForm(org.eclipse.swt.widgets.Composite)
     */
@Override
public IPreferenceForm createDynamicDistributionPrefForm(Composite parent, PreferencePage prefPage) {
    IDynamicMonitor monitor = new DummyDynamicMonitor();
    DynamicDistributionPreferenceForm existingConfigForm = new DynamicDistributionPreferenceForm(parent, SWT.NONE, monitor, ITalendCorePrefConstants.ARTIFACT_PROXY_SETTING);
    AbstractDynamicDistributionForm.ICheckListener checkListener = new ICheckListener() {

        @Override
        public String getMessage() {
            return prefPage.getMessage();
        }

        @Override
        public void showMessage(String message, int level) {
            prefPage.setMessage(message, level);
        }

        @Override
        public void updateButtons() {
            boolean isValid = existingConfigForm.isComplete();
            prefPage.setValid(isValid);
        }

        @Override
        public void run(boolean fork, boolean cancelable, IRunnableWithProgress runnable) throws Exception {
            // $NON-NLS-1$
            throw new Exception("Please implement it if needed");
        }
    };
    existingConfigForm.setCheckListener(checkListener);
    return new IPreferenceForm() {

        @Override
        public void setLayoutData(Object layoutData) {
            existingConfigForm.setLayoutData(layoutData);
        }

        @Override
        public boolean performApply() {
            return existingConfigForm.performApply();
        }

        @Override
        public boolean performDefaults() {
            return existingConfigForm.performDefaults();
        }

        @Override
        public boolean isComplete() {
            return existingConfigForm.isComplete();
        }
    };
}
Also used : ICheckListener(org.talend.repository.hadoopcluster.ui.dynamic.form.AbstractDynamicDistributionForm.ICheckListener) ICheckListener(org.talend.repository.hadoopcluster.ui.dynamic.form.AbstractDynamicDistributionForm.ICheckListener) DummyDynamicMonitor(org.talend.designer.maven.aether.DummyDynamicMonitor) AbstractDynamicDistributionForm(org.talend.repository.hadoopcluster.ui.dynamic.form.AbstractDynamicDistributionForm) DynamicDistributionPreferenceForm(org.talend.repository.hadoopcluster.ui.dynamic.form.DynamicDistributionPreferenceForm) IDynamicMonitor(org.talend.designer.maven.aether.IDynamicMonitor) IPreferenceForm(org.talend.core.ui.services.IPreferenceForm) IRunnableWithProgress(org.eclipse.jface.operation.IRunnableWithProgress)

Example 13 with IDynamicMonitor

use of org.talend.designer.maven.aether.IDynamicMonitor in project tbd-studio-se by Talend.

the class DynamicDistributionDetailsPage method createControl.

@Override
public void createControl(Composite parent) {
    IDynamicMonitor monitor = new DummyDynamicMonitor();
    AbstractDynamicDistributionForm.ICheckListener checkListener = new ICheckListener() {

        @Override
        public void showMessage(String message, int level) {
            setMessage(message, level);
            setErrorMessage(message);
        }

        @Override
        public void updateButtons() {
            getContainer().updateButtons();
        }

        @Override
        public String getMessage() {
            return DynamicDistributionDetailsPage.this.getMessage();
        }

        @Override
        public void run(boolean fork, boolean cancelable, IRunnableWithProgress runnable) throws Exception {
            getContainer().run(fork, cancelable, runnable);
        }
    };
    AbstractDynamicDistributionForm setupForm = new DynamicDistributionDetailsForm(parent, SWT.NONE, getDynamicBuildConfigurationData(), monitor);
    setupForm.setCheckListener(checkListener);
    setControl(setupForm);
    setCurrentForm(setupForm);
    setPageComplete(false);
}
Also used : ICheckListener(org.talend.repository.hadoopcluster.ui.dynamic.form.AbstractDynamicDistributionForm.ICheckListener) ICheckListener(org.talend.repository.hadoopcluster.ui.dynamic.form.AbstractDynamicDistributionForm.ICheckListener) DummyDynamicMonitor(org.talend.designer.maven.aether.DummyDynamicMonitor) AbstractDynamicDistributionForm(org.talend.repository.hadoopcluster.ui.dynamic.form.AbstractDynamicDistributionForm) DynamicDistributionDetailsForm(org.talend.repository.hadoopcluster.ui.dynamic.form.DynamicDistributionDetailsForm) IDynamicMonitor(org.talend.designer.maven.aether.IDynamicMonitor) IRunnableWithProgress(org.eclipse.jface.operation.IRunnableWithProgress)

Example 14 with IDynamicMonitor

use of org.talend.designer.maven.aether.IDynamicMonitor in project tbd-studio-se by Talend.

the class DynamicDistributionPreferencePage method createContents.

@Override
protected Control createContents(Composite parent) {
    AbstractDynamicDistributionForm.ICheckListener checkListener = new ICheckListener() {

        @Override
        public String getMessage() {
            return DynamicDistributionPreferencePage.this.getMessage();
        }

        @Override
        public void showMessage(String message, int level) {
            setMessage(message, level);
        }

        @Override
        public void updateButtons() {
            boolean isValid = getCurrentForm().isComplete();
            setValid(isValid);
        }

        @Override
        public void run(boolean fork, boolean cancelable, IRunnableWithProgress runnable) throws Exception {
            // $NON-NLS-1$
            throw new Exception("Please implement it if needed");
        }
    };
    IDynamicMonitor monitor = new DummyDynamicMonitor();
    DynamicDistributionPreferenceForm existingConfigForm = new DynamicDistributionPreferenceForm(parent, SWT.NONE, monitor, ITalendCorePrefConstants.DYNAMIC_DISTRIBUTION_SETTING);
    existingConfigForm.setCheckListener(checkListener);
    setCurrentForm(existingConfigForm);
    boolean isValid = getCurrentForm().isComplete();
    setValid(isValid);
    return existingConfigForm;
}
Also used : ICheckListener(org.talend.repository.hadoopcluster.ui.dynamic.form.AbstractDynamicDistributionForm.ICheckListener) ICheckListener(org.talend.repository.hadoopcluster.ui.dynamic.form.AbstractDynamicDistributionForm.ICheckListener) DummyDynamicMonitor(org.talend.designer.maven.aether.DummyDynamicMonitor) AbstractDynamicDistributionForm(org.talend.repository.hadoopcluster.ui.dynamic.form.AbstractDynamicDistributionForm) DynamicDistributionPreferenceForm(org.talend.repository.hadoopcluster.ui.dynamic.form.DynamicDistributionPreferenceForm) IDynamicMonitor(org.talend.designer.maven.aether.IDynamicMonitor) IRunnableWithProgress(org.eclipse.jface.operation.IRunnableWithProgress)

Example 15 with IDynamicMonitor

use of org.talend.designer.maven.aether.IDynamicMonitor in project tbd-studio-se by Talend.

the class DynamicDistributionDetailsForm method onExportConfigurationSelected.

private void onExportConfigurationSelected() {
    DirectoryDialog dirDialog = new DirectoryDialog(getShell());
    String folderPath = dirDialog.open();
    if (StringUtils.isNotEmpty(folderPath)) {
        try {
            // IDynamicPlugin dynamicPlugin = getDynamicDistributionSetupData().getDynamicPlugin();
            IDynamicPlugin dynamicPlugin = newDynamicPluginCache;
            IDynamicPluginConfiguration pluginConfiguration = dynamicPlugin.getPluginConfiguration();
            String id = pluginConfiguration.getId();
            // $NON-NLS-1$
            String fileName = id + "." + DynamicDistributionManager.DISTRIBUTION_FILE_EXTENSION;
            // $NON-NLS-1$
            String filePath = folderPath + "/" + fileName;
            File file = new File(filePath);
            if (file.exists()) {
                boolean agree = MessageDialog.openQuestion(getShell(), // $NON-NLS-1$
                Messages.getString("DynamicDistributionDetailsForm.exportConfig.dialog.fileExist.title"), // $NON-NLS-1$
                Messages.getString(// $NON-NLS-1$
                "DynamicDistributionDetailsForm.exportConfig.dialog.fileExist.message", file.getCanonicalPath()));
                if (!agree) {
                    return;
                }
            }
            IDynamicMonitor monitor = new DummyDynamicMonitor();
            DynamicDistributionManager.getInstance().saveUsersDynamicPlugin(dynamicPlugin, filePath, monitor);
            MessageDialog.openInformation(getShell(), // $NON-NLS-1$
            Messages.getString("DynamicDistributionDetailsForm.exportConfig.dialog.title"), // $NON-NLS-1$
            Messages.getString(// $NON-NLS-1$
            "DynamicDistributionDetailsForm.exportConfig.dialog.message", new File(filePath).getCanonicalPath()));
        } catch (Exception e) {
            ExceptionHandler.process(e);
        }
    }
}
Also used : IDynamicPlugin(org.talend.core.runtime.dynamic.IDynamicPlugin) DummyDynamicMonitor(org.talend.designer.maven.aether.DummyDynamicMonitor) IDynamicPluginConfiguration(org.talend.core.runtime.dynamic.IDynamicPluginConfiguration) File(java.io.File) IDynamicMonitor(org.talend.designer.maven.aether.IDynamicMonitor) InvocationTargetException(java.lang.reflect.InvocationTargetException) DirectoryDialog(org.eclipse.swt.widgets.DirectoryDialog)

Aggregations

IDynamicMonitor (org.talend.designer.maven.aether.IDynamicMonitor)17 DummyDynamicMonitor (org.talend.designer.maven.aether.DummyDynamicMonitor)10 IRunnableWithProgress (org.eclipse.jface.operation.IRunnableWithProgress)8 AbsDynamicProgressMonitor (org.talend.designer.maven.aether.AbsDynamicProgressMonitor)7 InvocationTargetException (java.lang.reflect.InvocationTargetException)6 IDynamicPlugin (org.talend.core.runtime.dynamic.IDynamicPlugin)6 IDynamicPluginConfiguration (org.talend.core.runtime.dynamic.IDynamicPluginConfiguration)5 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)4 IDynamicDistributionsGroup (org.talend.hadoop.distribution.dynamic.IDynamicDistributionsGroup)4 DynamicDistributionSetupData (org.talend.repository.hadoopcluster.ui.dynamic.DynamicDistributionSetupData)4 AbstractDynamicDistributionForm (org.talend.repository.hadoopcluster.ui.dynamic.form.AbstractDynamicDistributionForm)4 ICheckListener (org.talend.repository.hadoopcluster.ui.dynamic.form.AbstractDynamicDistributionForm.ICheckListener)4 File (java.io.File)2 LinkedList (java.util.LinkedList)2 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)2 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)2 DynamicDistributionPreferenceForm (org.talend.repository.hadoopcluster.ui.dynamic.form.DynamicDistributionPreferenceForm)2 ArrayList (java.util.ArrayList)1 List (java.util.List)1 ProgressMonitorDialog (org.eclipse.jface.dialogs.ProgressMonitorDialog)1