Search in sources :

Example 21 with IDynamicPlugin

use of org.talend.core.runtime.dynamic.IDynamicPlugin 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)

Example 22 with IDynamicPlugin

use of org.talend.core.runtime.dynamic.IDynamicPlugin in project tbd-studio-se by Talend.

the class DynamicDistributionPreferenceForm method onDeleteBtnPressed.

private void onDeleteBtnPressed() {
    IStructuredSelection selection = (IStructuredSelection) versionCombo.getSelection();
    final IDynamicPlugin dynamicPlugin = (IDynamicPlugin) selection.getFirstElement();
    boolean agree = MessageDialog.openConfirm(getShell(), // $NON-NLS-1$
    Messages.getString("DynamicDistributionPreferenceForm.form.deleteExistingConfig.confirm.dialog.title"), // $NON-NLS-1$
    Messages.getString(// $NON-NLS-1$
    "DynamicDistributionPreferenceForm.form.deleteExistingConfig.confirm.dialog.message", dynamicPlugin.getPluginConfiguration().getName()));
    if (agree) {
        try {
            doDelete(dynamicPlugin);
            IDynamicMonitor monitor = new DummyDynamicMonitor();
            refreshVersionList(monitor);
        } 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);
        }
    }
}
Also used : IDynamicPlugin(org.talend.core.runtime.dynamic.IDynamicPlugin) DummyDynamicMonitor(org.talend.designer.maven.aether.DummyDynamicMonitor) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) IDynamicMonitor(org.talend.designer.maven.aether.IDynamicMonitor)

Example 23 with IDynamicPlugin

use of org.talend.core.runtime.dynamic.IDynamicPlugin in project tbd-studio-se by Talend.

the class DynamicDistributionPreferenceForm method checkVersionSelection.

private boolean checkVersionSelection() {
    IStructuredSelection selection = (IStructuredSelection) versionCombo.getSelection();
    boolean canDelete = false;
    try {
        if (selection != null) {
            IDynamicPlugin dynamicPlugin = (IDynamicPlugin) selection.getFirstElement();
            if (dynamicPlugin != null) {
                IDynamicPluginConfiguration pluginConfiguration = dynamicPlugin.getPluginConfiguration();
                String isBuiltinStr = (String) pluginConfiguration.getAttribute(DynamicConstants.ATTR_IS_BUILTIN);
                if (!Boolean.valueOf(isBuiltinStr)) {
                    String curProjTechName = ProjectManager.getInstance().getCurrentProject().getTechnicalLabel();
                    String projTechName = (String) pluginConfiguration.getAttribute(DynamicConstants.ATTR_PROJECT_TECHNICAL_NAME);
                    if (StringUtils.equals(curProjTechName, projTechName)) {
                        canDelete = true;
                    }
                }
            }
        }
    } catch (Exception e) {
        ExceptionHandler.process(e);
    } finally {
        boolean isReadonly = isReadonly();
        if (isReadonly) {
            deleteBtn.setEnabled(false);
        } else {
            deleteBtn.setEnabled(canDelete);
        }
    }
    return true;
}
Also used : IDynamicPlugin(org.talend.core.runtime.dynamic.IDynamicPlugin) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) IDynamicPluginConfiguration(org.talend.core.runtime.dynamic.IDynamicPluginConfiguration) LoginException(org.talend.commons.exception.LoginException) InvocationTargetException(java.lang.reflect.InvocationTargetException) PersistenceException(org.talend.commons.exception.PersistenceException)

Example 24 with IDynamicPlugin

use of org.talend.core.runtime.dynamic.IDynamicPlugin in project tbd-studio-se by Talend.

the class DynamicDistributionOptionForm method copyAllUsersDynamicPlugins.

private List<IDynamicPlugin> copyAllUsersDynamicPlugins(IDynamicMonitor monitor, IDynamicDistributionsGroup dynamicDistributionsGroup) throws Exception {
    List<IDynamicPlugin> distriDynamicPlugins = new LinkedList<>();
    /**
     * Can't edit builtin plugins
     */
    allBuiltinDynamicPlugins = dynamicDistributionsGroup.getAllBuiltinDynamicPlugins(monitor);
    if (allBuiltinDynamicPlugins != null && !allBuiltinDynamicPlugins.isEmpty()) {
        distriDynamicPlugins.addAll(allBuiltinDynamicPlugins);
    }
    // List<IDynamicPlugin> allUsersDynamicPlugins = DynamicDistributionManager.getInstance()
    // .getAllUsersDynamicPluginsForProject(ProjectManager.getInstance().getCurrentProject(), monitor);
    List<IDynamicPlugin> allUsersDynamicPlugins = DynamicDistributionManager.getInstance().getAllUsersDynamicPlugins(monitor);
    if (allUsersDynamicPlugins != null && !allUsersDynamicPlugins.isEmpty()) {
        List<IDynamicPlugin> filterDynamicPlugins = dynamicDistributionsGroup.filterDynamicPlugins(allUsersDynamicPlugins, monitor);
        if (filterDynamicPlugins != null && !filterDynamicPlugins.isEmpty()) {
            for (IDynamicPlugin dynPlugin : filterDynamicPlugins) {
                IDynamicPlugin clonedPlugin = DynamicFactory.getInstance().createPluginFromJson(dynPlugin.toXmlJson().toString());
                distriDynamicPlugins.add(clonedPlugin);
            }
        }
    }
    allCurrentUsersDynamicPlugins = allUsersDynamicPlugins;
    Collections.sort(distriDynamicPlugins, Collections.reverseOrder(new DynamicPluginComparator()));
    return distriDynamicPlugins;
}
Also used : IDynamicPlugin(org.talend.core.runtime.dynamic.IDynamicPlugin) DynamicPluginComparator(org.talend.hadoop.distribution.dynamic.comparator.DynamicPluginComparator) LinkedList(java.util.LinkedList)

Example 25 with IDynamicPlugin

use of org.talend.core.runtime.dynamic.IDynamicPlugin 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

IDynamicPlugin (org.talend.core.runtime.dynamic.IDynamicPlugin)25 IDynamicPluginConfiguration (org.talend.core.runtime.dynamic.IDynamicPluginConfiguration)16 InvocationTargetException (java.lang.reflect.InvocationTargetException)6 DummyDynamicMonitor (org.talend.designer.maven.aether.DummyDynamicMonitor)6 IDynamicMonitor (org.talend.designer.maven.aether.IDynamicMonitor)6 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)5 LinkedList (java.util.LinkedList)4 Project (org.talend.core.model.general.Project)4 DynamicPluginAdapter (org.talend.hadoop.distribution.dynamic.adapter.DynamicPluginAdapter)4 DynamicDistributionSetupData (org.talend.repository.hadoopcluster.ui.dynamic.DynamicDistributionSetupData)4 File (java.io.File)3 LoginException (org.talend.commons.exception.LoginException)3 PersistenceException (org.talend.commons.exception.PersistenceException)3 IDynamicDistributionsGroup (org.talend.hadoop.distribution.dynamic.IDynamicDistributionsGroup)3 ArrayList (java.util.ArrayList)2 IProject (org.eclipse.core.resources.IProject)2 StructuredSelection (org.eclipse.jface.viewers.StructuredSelection)2 Bundle (org.osgi.framework.Bundle)2 DynamicPluginComparator (org.talend.hadoop.distribution.dynamic.comparator.DynamicPluginComparator)2 IDynamicDistributionPreference (org.talend.hadoop.distribution.dynamic.pref.IDynamicDistributionPreference)2