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