Search in sources :

Example 31 with IDynamicPluginConfiguration

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

the class DynamicCDH6xDistribution method initTemplate.

@Override
protected IDynamicDistributionTemplate initTemplate(DynamicPluginAdapter pluginAdapter, IDynamicMonitor monitor) throws Exception {
    IDynamicDistributionTemplate dynamicDistributionTemplate = null;
    IDynamicPluginConfiguration pluginConfiguration = pluginAdapter.getPluginConfiguration();
    String templateId = pluginConfiguration.getTemplateId();
    switch(templateId) {
        case CDH6xDistributionTemplate.TEMPLATE_ID:
            dynamicDistributionTemplate = new CDH6xDistributionTemplate(pluginAdapter);
            break;
        default:
            throw new Exception("Unknown templateId: " + templateId);
    }
    return dynamicDistributionTemplate;
}
Also used : CDH6xDistributionTemplate(org.talend.hadoop.distribution.cdh6x.CDH6xDistributionTemplate) IDynamicDistributionTemplate(org.talend.hadoop.distribution.dynamic.template.IDynamicDistributionTemplate) IDynamicPluginConfiguration(org.talend.core.runtime.dynamic.IDynamicPluginConfiguration)

Example 32 with IDynamicPluginConfiguration

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

the class DynamicDistributionOptionForm method checkSelectExistingConfig.

private boolean checkSelectExistingConfig() {
    if (!editExistingConfigBtn.getSelection()) {
        return true;
    }
    IStructuredSelection selection = (IStructuredSelection) existingConfigsComboViewer.getSelection();
    if (selection == null) {
        // $NON-NLS-1$
        String errorMessage = Messages.getString("DynamicDistributionOptionForm.importConfigText.check.existingConfig.empty");
        showMessage(errorMessage, WizardPage.ERROR);
        return false;
    }
    Object firstElement = selection.getFirstElement();
    if (firstElement == null) {
        // $NON-NLS-1$
        String errorMessage = Messages.getString("DynamicDistributionOptionForm.importConfigText.check.existingConfig.empty");
        showMessage(errorMessage, WizardPage.ERROR);
        return false;
    }
    IDynamicPlugin dynamicPlugin = (IDynamicPlugin) firstElement;
    existingConfigsComboViewer.getControl().setToolTipText(existingConfigsComboViewer.getCombo().getText());
    getDynamicDistributionSetupData().setDynamicPlugin(dynamicPlugin);
    IDynamicPluginConfiguration pluginConfiguration = dynamicPlugin.getPluginConfiguration();
    boolean isBuiltin = isBuiltinDynamicConfiguration(dynamicPlugin);
    boolean isInCurrentProject = isInCurrentProject(dynamicPlugin);
    getDynamicDistributionSetupData().setReadonly(isBuiltin || !isInCurrentProject || isReadonly());
    if (isBuiltin) {
        String warnMessage = // $NON-NLS-1$
        Messages.getString(// $NON-NLS-1$
        "DynamicDistributionOptionForm.editExisting.builtin", pluginConfiguration.getName());
        showMessage(warnMessage, WizardPage.WARNING);
    }
    if (!isInCurrentProject) {
        String warnMessage = // $NON-NLS-1$
        Messages.getString(// $NON-NLS-1$
        "DynamicDistributionOptionForm.editExisting.notInCurrentProject", pluginConfiguration.getName(), pluginConfiguration.getAttribute(DynamicConstants.ATTR_PROJECT_TECHNICAL_NAME));
        showMessage(warnMessage, WizardPage.WARNING);
    }
    return true;
}
Also used : IDynamicPlugin(org.talend.core.runtime.dynamic.IDynamicPlugin) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) IDynamicPluginConfiguration(org.talend.core.runtime.dynamic.IDynamicPluginConfiguration)

Example 33 with IDynamicPluginConfiguration

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

the class AbstractDynamicDistributionSetupForm method saveDynamicDistribution.

protected void saveDynamicDistribution(IDynamicPlugin dynamicPlugin, IDynamicDistributionsGroup dynDistrGroup, ActionType actionType, IDynamicMonitor dMonitor) throws Exception {
    IDynamicPluginConfiguration pluginConfiguration = dynamicPlugin.getPluginConfiguration();
    dMonitor.beginTask(// $NON-NLS-1$
    Messages.getString("AbstractDynamicDistributionSetupForm.progress.saving", pluginConfiguration.getName()), IDynamicMonitor.UNKNOWN);
    // step 1: clean unused modules
    IDynamicDistributionPreference dynamicDistributionPreference = dynDistrGroup.getDynamicDistributionPreference(ProjectManager.getInstance().getCurrentProject());
    DynamicPluginAdapter pluginAdapter = new DynamicPluginAdapter(dynamicPlugin, dynamicDistributionPreference, null);
    pluginAdapter.cleanUnusedAndRefresh();
    // step 2: save
    final IDynamicPlugin fDynPlugin = pluginAdapter.getPlugin();
    ProxyRepositoryFactory.getInstance().executeRepositoryWorkUnit(new RepositoryWorkUnit<Boolean>(Messages.getString("AbstractDynamicDistributionSetupForm.repositoryWorkUnit.title", // $NON-NLS-1$
    pluginConfiguration.getName())) {

        @Override
        protected void run() throws LoginException, PersistenceException {
            result = false;
            try {
                DynamicDistributionManager.getInstance().saveUsersDynamicPlugin(fDynPlugin, dMonitor);
            } catch (Exception e) {
                throw new PersistenceException(e);
            }
            result = true;
        }
    });
    // step 3: regist
    dMonitor.setTaskName(// $NON-NLS-1$
    Messages.getString("AbstractDynamicDistributionSetupForm.progress.registing", pluginConfiguration.getName()));
    if (ActionType.EditExisting.equals(actionType)) {
        dynDistrGroup.unregister(fDynPlugin, dMonitor, false);
    }
    dynDistrGroup.register(fDynPlugin, dMonitor);
    // step 4: reset system cache
    // $NON-NLS-1$
    dMonitor.setTaskName(Messages.getString("AbstractDynamicDistributionSetupForm.progress.resetCache"));
    DynamicDistributionManager.getInstance().resetSystemCache();
}
Also used : IDynamicDistributionPreference(org.talend.hadoop.distribution.dynamic.pref.IDynamicDistributionPreference) DynamicPluginAdapter(org.talend.hadoop.distribution.dynamic.adapter.DynamicPluginAdapter) IDynamicPlugin(org.talend.core.runtime.dynamic.IDynamicPlugin) PersistenceException(org.talend.commons.exception.PersistenceException) LoginException(org.talend.commons.exception.LoginException) IDynamicPluginConfiguration(org.talend.core.runtime.dynamic.IDynamicPluginConfiguration) LoginException(org.talend.commons.exception.LoginException) PersistenceException(org.talend.commons.exception.PersistenceException)

Example 34 with IDynamicPluginConfiguration

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

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

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