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;
}
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;
}
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();
}
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);
}
}
}
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;
}
Aggregations