Search in sources :

Example 16 with IDynamicPluginConfiguration

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

the class DynamicDistributionsLabelProvider method getText.

@Override
public String getText(Object element) {
    if (element instanceof IDynamicPlugin) {
        IDynamicPluginConfiguration pluginConfiguration = ((IDynamicPlugin) element).getPluginConfiguration();
        String name = pluginConfiguration.getName();
        String isBuiltinStr = (String) pluginConfiguration.getAttribute(DynamicConstants.ATTR_IS_BUILTIN);
        boolean isBuiltin = Boolean.valueOf(isBuiltinStr);
        if (isBuiltin) {
            // $NON-NLS-1$
            name = Messages.getString("DynamicDistributionsLabelProvider.label.existing.builtin", name);
        } else {
            Project curProj = ProjectManager.getInstance().getCurrentProject();
            String curProjTechName = curProj.getTechnicalLabel();
            String projTechName = (String) pluginConfiguration.getAttribute(DynamicConstants.ATTR_PROJECT_TECHNICAL_NAME);
            if (StringUtils.equals(curProjTechName, projTechName)) {
                // $NON-NLS-1$
                name = Messages.getString("DynamicDistributionsLabelProvider.label.existing.currentProject", name);
            } else {
                name = // $NON-NLS-1$
                Messages.getString(// $NON-NLS-1$
                "DynamicDistributionsLabelProvider.label.existing.otherProject", // $NON-NLS-1$
                name, projTechName);
            }
        }
        return name;
    } else {
        // $NON-NLS-1$
        return element == null ? "" : element.toString();
    }
}
Also used : Project(org.talend.core.model.general.Project) IDynamicPlugin(org.talend.core.runtime.dynamic.IDynamicPlugin) IDynamicPluginConfiguration(org.talend.core.runtime.dynamic.IDynamicPluginConfiguration)

Example 17 with IDynamicPluginConfiguration

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

the class AbstractDynamicDistributionTemplateTest method beforeTest.

@Before
public void beforeTest() throws Exception {
    DynamicFactory factory = DynamicFactory.getInstance();
    IDynamicPlugin dynamicPlugin = factory.createDynamicPlugin();
    IDynamicPluginConfiguration dynamicPluginConfiguration = DynamicFactory.getInstance().createDynamicPluginConfiguration();
    dynamicPluginConfiguration.setDistribution(DISTRIBUTION);
    // $NON-NLS-1$
    dynamicPluginConfiguration.setVersion("v1");
    dynamicPlugin.setPluginConfiguration(dynamicPluginConfiguration);
    dynamicPluginAdapter = new DynamicPluginAdapter(dynamicPlugin, DynamicCDHDistributionPreferenceFactory.getInstance().getDynamicDistributionPreference(ProjectManager.getInstance().getCurrentProject()), null);
}
Also used : DynamicPluginAdapter(org.talend.hadoop.distribution.dynamic.adapter.DynamicPluginAdapter) IDynamicPlugin(org.talend.core.runtime.dynamic.IDynamicPlugin) DynamicFactory(org.talend.core.runtime.dynamic.DynamicFactory) IDynamicPluginConfiguration(org.talend.core.runtime.dynamic.IDynamicPluginConfiguration) Before(org.junit.Before)

Example 18 with IDynamicPluginConfiguration

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

the class DynamicDistributionDetailsForm method initData.

private void initData() {
    try {
        DynamicDistributionSetupData dynConfigData = getDynamicDistributionSetupData();
        IDynamicPlugin originPlugin = dynConfigData.getDynamicPlugin();
        if (originPlugin == originPluginCache) {
            return;
        }
        originPluginCache = originPlugin;
        newDynamicPluginCache = DynamicFactory.getInstance().createPluginFromJson(originPluginCache.toXmlJson().toString());
        IDynamicPluginConfiguration pluginConfiguration = newDynamicPluginCache.getPluginConfiguration();
        String name = (String) pluginConfiguration.getAttribute(DynamicConstants.ATTR_USER_INPUTED_NAME);
        if (StringUtils.isEmpty(name)) {
            name = pluginConfiguration.getName();
        }
        nameCache = name;
        dynamicConfigNameText.setText(name);
        initTableViewData(newDynamicPluginCache);
    } catch (Exception 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) DynamicDistributionSetupData(org.talend.repository.hadoopcluster.ui.dynamic.DynamicDistributionSetupData) IDynamicPluginConfiguration(org.talend.core.runtime.dynamic.IDynamicPluginConfiguration) InvocationTargetException(java.lang.reflect.InvocationTargetException)

Example 19 with IDynamicPluginConfiguration

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

Example 20 with IDynamicPluginConfiguration

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

the class AbstractDynamicDistribution method getAllBuiltinDynamicPlugins.

@Override
public List<IDynamicPlugin> getAllBuiltinDynamicPlugins(IDynamicMonitor monitor) throws Exception {
    if (builtinPluginsCache != null) {
        return builtinPluginsCache;
    }
    List<IDynamicPlugin> dynamicPlugins = new ArrayList<>();
    Bundle bundle = getBundle();
    Enumeration<URL> entries = bundle.findEntries(getBuiltinFolderPath(), null, true);
    if (entries != null) {
        String curProjTechName = null;
        Project curProject = ProjectManager.getInstance().getCurrentProject();
        if (curProject != null) {
            curProjTechName = curProject.getTechnicalLabel();
        }
        while (entries.hasMoreElements()) {
            try {
                URL curUrl = entries.nextElement();
                if (curUrl != null) {
                    String builtinDistributionPath = FileLocator.toFileURL(curUrl).getPath();
                    String jsonContent = DynamicServiceUtil.readFile(new File(builtinDistributionPath));
                    IDynamicPlugin dynamicPlugin = DynamicFactory.getInstance().createPluginFromJson(jsonContent);
                    IDynamicPluginConfiguration pluginConfiguration = dynamicPlugin.getPluginConfiguration();
                    // pluginConfiguration.setAttribute(DynamicDistriConfigAdapter.ATTR_FILE_PATH,
                    // builtinDistributionPath);
                    pluginConfiguration.setAttribute(DynamicConstants.ATTR_IS_BUILTIN, Boolean.TRUE.toString());
                    pluginConfiguration.setAttribute(DynamicConstants.ATTR_PROJECT_TECHNICAL_NAME, curProjTechName);
                    dynamicPlugins.add(dynamicPlugin);
                }
            } catch (Exception e) {
                ExceptionHandler.process(e);
            }
        }
    }
    builtinPluginsCache = dynamicPlugins;
    return builtinPluginsCache;
}
Also used : Project(org.talend.core.model.general.Project) IDynamicPlugin(org.talend.core.runtime.dynamic.IDynamicPlugin) Bundle(org.osgi.framework.Bundle) ArrayList(java.util.ArrayList) File(java.io.File) IDynamicPluginConfiguration(org.talend.core.runtime.dynamic.IDynamicPluginConfiguration) URL(java.net.URL)

Aggregations

IDynamicPluginConfiguration (org.talend.core.runtime.dynamic.IDynamicPluginConfiguration)38 IDynamicPlugin (org.talend.core.runtime.dynamic.IDynamicPlugin)16 DynamicPluginAdapter (org.talend.hadoop.distribution.dynamic.adapter.DynamicPluginAdapter)10 Set (java.util.Set)6 NodeComponentTypeBean (org.talend.hadoop.distribution.NodeComponentTypeBean)6 File (java.io.File)5 InvocationTargetException (java.lang.reflect.InvocationTargetException)5 DummyDynamicMonitor (org.talend.designer.maven.aether.DummyDynamicMonitor)5 IDynamicMonitor (org.talend.designer.maven.aether.IDynamicMonitor)5 IDynamicDistributionTemplate (org.talend.hadoop.distribution.dynamic.template.IDynamicDistributionTemplate)4 ArrayList (java.util.ArrayList)3 Project (org.talend.core.model.general.Project)3 DynamicConfiguration (org.talend.hadoop.distribution.dynamic.DynamicConfiguration)3 DynamicDistributionSetupData (org.talend.repository.hadoopcluster.ui.dynamic.DynamicDistributionSetupData)3 IFolder (org.eclipse.core.resources.IFolder)2 IProject (org.eclipse.core.resources.IProject)2 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)2 Bundle (org.osgi.framework.Bundle)2 LoginException (org.talend.commons.exception.LoginException)2 PersistenceException (org.talend.commons.exception.PersistenceException)2