Search in sources :

Example 6 with IDynamicMonitor

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

the class DynamicDistributionOptionForm method initExistingConfigurationInfos.

private void initExistingConfigurationInfos() throws Exception {
    existingConfigurationNames = new HashSet<>();
    existingConfigurationIdMap = new HashMap<>();
    IDynamicMonitor monitor = new DummyDynamicMonitor();
    DynamicDistributionManager dynDistrManager = DynamicDistributionManager.getInstance();
    List<IDynamicPlugin> allDynamicPlugins = new LinkedList<>();
    List<IDynamicPlugin> allBuiltinDynamicPlugins = dynDistrManager.getAllBuiltinDynamicPlugins(monitor);
    if (allBuiltinDynamicPlugins != null && !allBuiltinDynamicPlugins.isEmpty()) {
        allDynamicPlugins.addAll(allBuiltinDynamicPlugins);
    }
    List<IDynamicPlugin> allUsesDynamicPlugins = dynDistrManager.getAllUsersDynamicPlugins(monitor);
    if (allUsesDynamicPlugins != null && !allUsesDynamicPlugins.isEmpty()) {
        allDynamicPlugins.addAll(allUsesDynamicPlugins);
    }
    if (allDynamicPlugins != null && !allDynamicPlugins.isEmpty()) {
        Iterator<IDynamicPlugin> iter = allDynamicPlugins.iterator();
        while (iter.hasNext()) {
            IDynamicPlugin dynPlugin = iter.next();
            IDynamicPluginConfiguration pluginConfiguration = dynPlugin.getPluginConfiguration();
            existingConfigurationNames.add(pluginConfiguration.getName());
            existingConfigurationIdMap.put(pluginConfiguration.getId(), dynPlugin);
        }
    }
}
Also used : DynamicDistributionManager(org.talend.hadoop.distribution.dynamic.DynamicDistributionManager) IDynamicPlugin(org.talend.core.runtime.dynamic.IDynamicPlugin) DummyDynamicMonitor(org.talend.designer.maven.aether.DummyDynamicMonitor) IDynamicPluginConfiguration(org.talend.core.runtime.dynamic.IDynamicPluginConfiguration) IDynamicMonitor(org.talend.designer.maven.aether.IDynamicMonitor) LinkedList(java.util.LinkedList)

Example 7 with IDynamicMonitor

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

the class DynamicDistributionOptionForm method getVersionList.

private List<String> getVersionList() throws Exception {
    final List<List<String>> result = new ArrayList<>();
    try {
        DynamicDistributionSetupData dynConfigData = getDynamicDistributionSetupData();
        IDynamicDistributionsGroup dynDistrGroup = dynConfigData.getDynamicDistributionsGroup();
        final Throwable[] throwable = new Throwable[1];
        final boolean showOnlyCompatibleVersions = showOnlyCompatibleBtn.getSelection();
        run(true, true, new IRunnableWithProgress() {

            @Override
            public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
                try {
                    IDynamicMonitor dMonitor = new AbsDynamicProgressMonitor(monitor) {

                        @Override
                        public void writeMessage(String message) {
                            if (isDebuging()) {
                                System.out.print(message);
                            }
                        }
                    };
                    // $NON-NLS-1$
                    dMonitor.beginTask(// $NON-NLS-1$
                    Messages.getString("DynamicDistributionOptionForm.progress.fetchVersions"), IDynamicMonitor.UNKNOWN);
                    List<String> version = null;
                    if (showOnlyCompatibleVersions) {
                        version = dynDistrGroup.getCompatibleVersions(dMonitor);
                    } else {
                        version = dynDistrGroup.getAllVersions(dMonitor);
                    }
                    result.add(version);
                } catch (Exception e) {
                    throwable[0] = e;
                }
            }
        });
        if (throwable[0] != null) {
            throw throwable[0];
        }
    } catch (Throwable ex) {
        ExceptionHandler.process(ex);
        String message = ex.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, ex);
    }
    if (result.isEmpty()) {
        return null;
    }
    return result.get(0);
}
Also used : ArrayList(java.util.ArrayList) InvocationTargetException(java.lang.reflect.InvocationTargetException) InvocationTargetException(java.lang.reflect.InvocationTargetException) IRunnableWithProgress(org.eclipse.jface.operation.IRunnableWithProgress) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) IDynamicDistributionsGroup(org.talend.hadoop.distribution.dynamic.IDynamicDistributionsGroup) List(java.util.List) ArrayList(java.util.ArrayList) LinkedList(java.util.LinkedList) DynamicDistributionSetupData(org.talend.repository.hadoopcluster.ui.dynamic.DynamicDistributionSetupData) IDynamicMonitor(org.talend.designer.maven.aether.IDynamicMonitor) AbsDynamicProgressMonitor(org.talend.designer.maven.aether.AbsDynamicProgressMonitor)

Example 8 with IDynamicMonitor

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

the class DynamicDistributionOptionForm method createNewDynamicDistribution.

private boolean createNewDynamicDistribution() {
    try {
        final IDynamicPlugin[] result = new IDynamicPlugin[1];
        final Throwable[] throwable = new Throwable[1];
        run(true, true, new IRunnableWithProgress() {

            @Override
            public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
                try {
                    DynamicDistributionSetupData dynConfigData = getDynamicDistributionSetupData();
                    IDynamicDistributionsGroup dynDistrGroup = dynConfigData.getDynamicDistributionsGroup();
                    IDynamicMonitor dMonitor = new AbsDynamicProgressMonitor(monitor) {

                        @Override
                        public void writeMessage(String message) {
                            if (isDebuging()) {
                                System.out.print(message);
                            }
                        }
                    };
                    // step 1. build dynamic plugin basing on template
                    dMonitor.beginTask(// $NON-NLS-1$
                    Messages.getString(// $NON-NLS-1$
                    "DynamicDistributionOptionForm.progress.building", dynamicConfiguration.getName()), IDynamicMonitor.UNKNOWN);
                    IDynamicPlugin dynamicPlugin = dynDistrGroup.buildDynamicPlugin(dMonitor, dynamicConfiguration);
                    result[0] = dynamicPlugin;
                    // step 2. save dynamic plugin and refresh cache
                    if (dynamicPlugin != null) {
                        saveDynamicDistribution(dynamicPlugin, dynDistrGroup, ActionType.NewConfig, dMonitor);
                    }
                } catch (Throwable e) {
                    throwable[0] = e;
                }
            }
        });
        if (throwable[0] != null) {
            throw throwable[0];
        }
        IDynamicPlugin newDynamicPlugin = result[0];
        if (newDynamicPlugin == null) {
            // $NON-NLS-1$
            throw new Exception(Messages.getString("DynamicDistributionOptionForm.newConfig.exception.noPluginGenerated"));
        }
        return true;
    } 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 false;
}
Also used : IDynamicPlugin(org.talend.core.runtime.dynamic.IDynamicPlugin) InvocationTargetException(java.lang.reflect.InvocationTargetException) InvocationTargetException(java.lang.reflect.InvocationTargetException) IRunnableWithProgress(org.eclipse.jface.operation.IRunnableWithProgress) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) IDynamicDistributionsGroup(org.talend.hadoop.distribution.dynamic.IDynamicDistributionsGroup) DynamicDistributionSetupData(org.talend.repository.hadoopcluster.ui.dynamic.DynamicDistributionSetupData) IDynamicMonitor(org.talend.designer.maven.aether.IDynamicMonitor) AbsDynamicProgressMonitor(org.talend.designer.maven.aether.AbsDynamicProgressMonitor)

Example 9 with IDynamicMonitor

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

the class DynamicDistributionDetailsForm method performOk.

@Override
public boolean performOk() {
    try {
        final Throwable[] throwable = new Throwable[1];
        run(true, true, new IRunnableWithProgress() {

            @Override
            public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
                DynamicDistributionSetupData dynamicBuildConfigurationData = getDynamicDistributionSetupData();
                try {
                    IDynamicMonitor dMonitor = new AbsDynamicProgressMonitor(monitor) {

                        @Override
                        public void writeMessage(String message) {
                            if (isDebuging()) {
                                System.out.print(message);
                            }
                        }
                    };
                    saveDynamicDistribution(newDynamicPluginCache, dynamicBuildConfigurationData.getDynamicDistributionsGroup(), dynamicBuildConfigurationData.getActionType(), dMonitor);
                } catch (Exception e) {
                    throwable[0] = e;
                }
            }
        });
        if (throwable[0] != null) {
            throw throwable[0];
        }
        return true;
    } 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 false;
}
Also used : IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) DynamicDistributionSetupData(org.talend.repository.hadoopcluster.ui.dynamic.DynamicDistributionSetupData) InvocationTargetException(java.lang.reflect.InvocationTargetException) IDynamicMonitor(org.talend.designer.maven.aether.IDynamicMonitor) AbsDynamicProgressMonitor(org.talend.designer.maven.aether.AbsDynamicProgressMonitor) InvocationTargetException(java.lang.reflect.InvocationTargetException) IRunnableWithProgress(org.eclipse.jface.operation.IRunnableWithProgress)

Example 10 with IDynamicMonitor

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

the class DynamicDistributionPreferenceForm method doDelete.

private void doDelete(IDynamicPlugin dynamicPlugin) throws Throwable {
    final Throwable[] throwable = new Throwable[1];
    ProgressMonitorDialog progressDialog = new ProgressMonitorDialog(getShell());
    progressDialog.run(true, false, new IRunnableWithProgress() {

        @Override
        public void run(IProgressMonitor pMonitor) throws InvocationTargetException, InterruptedException {
            ProxyRepositoryFactory.getInstance().executeRepositoryWorkUnit(new RepositoryWorkUnit<Boolean>(// $NON-NLS-1$
            Messages.getString("DynamicDistributionPreferenceForm.form.deleteExistingConfig.workunit.title")) {

                @Override
                protected void run() throws LoginException, PersistenceException {
                    IDynamicMonitor monitor = new AbsDynamicProgressMonitor(pMonitor) {

                        @Override
                        public void writeMessage(String message) {
                        // nothing to do
                        }
                    };
                    try {
                        IDynamicPluginConfiguration pluginConfiguration = dynamicPlugin.getPluginConfiguration();
                        monitor.beginTask(// $NON-NLS-1$
                        Messages.getString(// $NON-NLS-1$
                        "DynamicDistributionPreferenceForm.delete.progress.unregist", pluginConfiguration.getName()), IDynamicMonitor.UNKNOWN);
                        String distribution = pluginConfiguration.getDistribution();
                        IDynamicDistributionsGroup dynamicDistributionGroup = DynamicDistributionManager.getInstance().getDynamicDistributionGroup(distribution);
                        dynamicDistributionGroup.unregister(dynamicPlugin, monitor, false);
                        monitor.setTaskName(// $NON-NLS-1$
                        Messages.getString(// $NON-NLS-1$
                        "DynamicDistributionPreferenceForm.delete.progress.deleteFile", pluginConfiguration.getName()));
                        String filePath = (String) pluginConfiguration.getAttribute(DynamicConstants.ATTR_FILE_PATH);
                        File file = new File(filePath);
                        file.delete();
                        monitor.setTaskName(// $NON-NLS-1$
                        Messages.getString("DynamicDistributionPreferenceForm.delete.progress.resetCache"));
                        DynamicDistributionManager.getInstance().resetSystemCache();
                    } catch (Throwable e) {
                        throwable[0] = e;
                    }
                }
            });
        }
    });
    if (throwable[0] != null) {
        throw throwable[0];
    }
}
Also used : ProgressMonitorDialog(org.eclipse.jface.dialogs.ProgressMonitorDialog) RepositoryWorkUnit(org.talend.repository.RepositoryWorkUnit) IDynamicPluginConfiguration(org.talend.core.runtime.dynamic.IDynamicPluginConfiguration) InvocationTargetException(java.lang.reflect.InvocationTargetException) IRunnableWithProgress(org.eclipse.jface.operation.IRunnableWithProgress) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) IDynamicDistributionsGroup(org.talend.hadoop.distribution.dynamic.IDynamicDistributionsGroup) File(java.io.File) IDynamicMonitor(org.talend.designer.maven.aether.IDynamicMonitor) AbsDynamicProgressMonitor(org.talend.designer.maven.aether.AbsDynamicProgressMonitor)

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