Search in sources :

Example 1 with AbsDynamicProgressMonitor

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

the class DynamicDistributionManager method load.

@Override
public void load(IProgressMonitor monitor, boolean resetModulesCache) throws Exception {
    if (isLoaded()) {
        return;
    }
    synchronized (this) {
        if (isLoaded()) {
            return;
        }
        IDynamicMonitor dynMonitor = new AbsDynamicProgressMonitor(monitor) {

            @Override
            public void writeMessage(String message) {
            // nothing to do
            }
        };
        registerAll(dynMonitor, resetModulesCache);
        setLoaded(true);
    }
}
Also used : IDynamicMonitor(org.talend.designer.maven.aether.IDynamicMonitor) AbsDynamicProgressMonitor(org.talend.designer.maven.aether.AbsDynamicProgressMonitor)

Example 2 with AbsDynamicProgressMonitor

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

the class DynamicDistributionManager method reset.

@Override
public void reset(IProgressMonitor monitor) {
    if (!isLoaded) {
        return;
    }
    if (monitor == null) {
        monitor = new NullProgressMonitor();
    }
    IDynamicMonitor dynamicMonitor = new AbsDynamicProgressMonitor(monitor) {

        @Override
        public void writeMessage(String message) {
        // nothing to do
        }
    };
    try {
        unregisterAll(dynamicMonitor, false);
        usersPluginsCache = null;
        resetSystemCache();
        isLoaded = false;
    } catch (Exception e) {
        ExceptionHandler.process(e);
    }
}
Also used : NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) IDynamicMonitor(org.talend.designer.maven.aether.IDynamicMonitor) AbsDynamicProgressMonitor(org.talend.designer.maven.aether.AbsDynamicProgressMonitor)

Example 3 with AbsDynamicProgressMonitor

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

the class DynamicDistributionManager method reloadAllDynamicDistributions.

@Override
public void reloadAllDynamicDistributions(IProgressMonitor monitor) throws Exception {
    if (monitor == null) {
        monitor = new NullProgressMonitor();
    }
    IDynamicMonitor dynamicMonitor = new AbsDynamicProgressMonitor(monitor) {

        @Override
        public void writeMessage(String message) {
        // nothing to do
        }
    };
    unregisterAll(dynamicMonitor, false);
    usersPluginsCache = null;
    registerAll(dynamicMonitor, false);
    resetSystemCache();
}
Also used : NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) IDynamicMonitor(org.talend.designer.maven.aether.IDynamicMonitor) AbsDynamicProgressMonitor(org.talend.designer.maven.aether.AbsDynamicProgressMonitor)

Example 4 with AbsDynamicProgressMonitor

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

use of org.talend.designer.maven.aether.AbsDynamicProgressMonitor 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)

Aggregations

AbsDynamicProgressMonitor (org.talend.designer.maven.aether.AbsDynamicProgressMonitor)7 IDynamicMonitor (org.talend.designer.maven.aether.IDynamicMonitor)7 InvocationTargetException (java.lang.reflect.InvocationTargetException)4 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)4 IRunnableWithProgress (org.eclipse.jface.operation.IRunnableWithProgress)4 IDynamicDistributionsGroup (org.talend.hadoop.distribution.dynamic.IDynamicDistributionsGroup)3 DynamicDistributionSetupData (org.talend.repository.hadoopcluster.ui.dynamic.DynamicDistributionSetupData)3 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)2 File (java.io.File)1 ArrayList (java.util.ArrayList)1 LinkedList (java.util.LinkedList)1 List (java.util.List)1 ProgressMonitorDialog (org.eclipse.jface.dialogs.ProgressMonitorDialog)1 IDynamicPlugin (org.talend.core.runtime.dynamic.IDynamicPlugin)1 IDynamicPluginConfiguration (org.talend.core.runtime.dynamic.IDynamicPluginConfiguration)1 RepositoryWorkUnit (org.talend.repository.RepositoryWorkUnit)1