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