use of org.talend.core.ui.services.IDesignerCoreUIService in project tdi-studio-se by Talend.
the class MultiSchemasManager method executeCommand.
public void executeCommand(Command cmd) {
IProcess process = this.getMultiSchemasComponent().getProcess();
boolean executed = false;
if (process != null && process instanceof IGEFProcess) {
IDesignerCoreUIService designerCoreUIService = CoreUIPlugin.getDefault().getDesignerCoreUIService();
if (designerCoreUIService != null) {
executed = designerCoreUIService.executeCommand((IGEFProcess) process, cmd);
}
}
if (!executed) {
cmd.execute();
}
}
use of org.talend.core.ui.services.IDesignerCoreUIService in project tdi-studio-se by Talend.
the class MavenVersionManagementProjectSettingPage method updateItemsVersion.
protected void updateItemsVersion() {
List<ItemVersionObject> JobsOpenedInEditor = new ArrayList<ItemVersionObject>();
List<ItemVersionObject> closedJobs = new ArrayList<ItemVersionObject>();
boolean hasJobOpenedInEditor = false;
StringBuilder builder = new StringBuilder();
for (ItemVersionObject object : checkedObjects) {
if (RepositoryManager.isOpenedItemInEditor(object.getRepositoryNode().getObject())) {
hasJobOpenedInEditor = true;
JobsOpenedInEditor.add(object);
//$NON-NLS-1$
builder.append(object.getRepositoryNode().getObject().getLabel() + ", ");
} else {
closedJobs.add(object);
}
}
if (builder.length() > 0) {
builder.delete(builder.length() - 2, builder.length());
}
if (hasJobOpenedInEditor) {
MessageDialog.openWarning(Display.getCurrent().getActiveShell(), //$NON-NLS-1$
Messages.getString("VersionManagementDialog.WarningTitle2"), //$NON-NLS-1$
Messages.getString("VersionManagementDialog.openedInEditorMessage", builder.toString()));
IWorkbenchWindow workBench = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
if (workBench != null) {
IWorkbenchPage page = workBench.getActivePage();
IEditorReference[] editorRefs = page.getEditorReferences();
if (GlobalServiceRegister.getDefault().isServiceRegistered(IDesignerCoreUIService.class)) {
IDesignerCoreUIService service = (IDesignerCoreUIService) GlobalServiceRegister.getDefault().getService(IDesignerCoreUIService.class);
if (service != null) {
for (IEditorReference editorRef : editorRefs) {
IEditorPart editor = editorRef.getEditor(false);
if (editor instanceof IMultiPageTalendEditor) {
IProcess2 process = ((IMultiPageTalendEditor) editor).getProcess();
String version = null;
for (ItemVersionObject object : JobsOpenedInEditor) {
if (object.getItem().getProperty().getId().equals(process.getId())) {
version = object.getNewVersion();
break;
}
}
if (version != null) {
String jobDefaultVersion = MavenVersionUtils.getDefaultVersion(process.getProperty().getVersion());
if (version.equals(jobDefaultVersion)) {
// if default, set null to remove key from property.
version = null;
}
Command command = service.crateMavenDeploymentValueChangeCommand(process, MavenConstants.NAME_USER_VERSION, version);
if (process instanceof IGEFProcess) {
service.executeCommand((IGEFProcess) process, command);
}
}
}
}
}
}
}
}
final IWorkspaceRunnable runnable = new IWorkspaceRunnable() {
@Override
public void run(final IProgressMonitor monitor) throws CoreException {
RepositoryWorkUnit<Object> rwu = new //$NON-NLS-1$
RepositoryWorkUnit<Object>(//$NON-NLS-1$
project, //$NON-NLS-1$
"Update items Maven version") {
@Override
protected void run() throws LoginException, PersistenceException {
//$NON-NLS-1$
monitor.beginTask("Update items Maven version", closedJobs.size());
for (ItemVersionObject object : closedJobs) {
final Item item = object.getItem();
Property itemProperty = item.getProperty();
MavenVersionUtils.setItemMavenVersion(itemProperty, object.getNewVersion());
monitor.subTask(itemProperty.getLabel());
FACTORY.save(project, itemProperty);
monitor.worked(1);
}
try {
FACTORY.saveProject(project);
} catch (PersistenceException e) {
ExceptionHandler.process(e);
}
}
};
rwu.setAvoidUnloadResources(true);
rwu.executeRun();
monitor.done();
}
};
IRunnableWithProgress iRunnableWithProgress = new IRunnableWithProgress() {
@Override
public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
IWorkspace workspace = ResourcesPlugin.getWorkspace();
try {
ISchedulingRule schedulingRule = workspace.getRoot();
// the update the project files need to be done in the workspace runnable to avoid all notification
// of changes before the end of the modifications.
workspace.run(runnable, schedulingRule, IWorkspace.AVOID_UPDATE, monitor);
} catch (CoreException e) {
ExceptionHandler.process(e);
}
}
};
final ProgressMonitorDialog dialog = new ProgressMonitorDialog(null);
try {
dialog.run(false, false, iRunnableWithProgress);
} catch (InvocationTargetException | InterruptedException e) {
ExceptionHandler.process(e);
}
}
use of org.talend.core.ui.services.IDesignerCoreUIService in project tdi-studio-se by Talend.
the class ExtraComposite method onReloadPreference.
@Override
protected void onReloadPreference() {
// ExtraComposite.this);
if (elem instanceof Process) {
Process process = (Process) elem;
LoadProjectSettingsCommand command = new LoadProjectSettingsCommand(process, EParameterName.IMPLICITCONTEXT_USE_PROJECT_SETTINGS.getName(), Boolean.TRUE);
boolean executed = false;
IDesignerCoreUIService designerCoreUIService = CoreUIPlugin.getDefault().getDesignerCoreUIService();
if (designerCoreUIService != null) {
executed = designerCoreUIService.executeCommand(process, command);
}
if (!executed) {
command.execute();
}
}
}
use of org.talend.core.ui.services.IDesignerCoreUIService in project tdi-studio-se by Talend.
the class JobJavaScriptsManager method getExportResources.
/*
* (non-Javadoc)
*
* @see
* org.talend.repository.ui.wizards.exportjob.JobScriptsManager#getExportResources(org.talend.core.model.properties
* .ProcessItem[], boolean, boolean, boolean, boolean, boolean, boolean, boolean, java.lang.String)
*/
@Override
public List<ExportFileResource> getExportResources(ExportFileResource[] process, String... codeOptions) throws ProcessorException {
exportFileResource = process;
for (int i = 0; i < process.length; i++) {
ProcessItem processItem = (ProcessItem) process[i].getItem();
String selectedJobVersion = processItem.getProperty().getVersion();
selectedJobVersion = preExportResource(process, i, selectedJobVersion);
IProcess jobProcess = null;
// code is just kept like this to avoid too big changes right now.
if (!isOptionChoosed(ExportChoice.doNotCompileCode)) {
if (contextName != null) {
jobProcess = generateJobFiles(processItem, contextName, selectedJobVersion, statisticPort != IProcessor.NO_STATISTICS || isOptionChoosed(ExportChoice.addStatistics), tracePort != IProcessor.NO_TRACES, isOptionChoosed(ExportChoice.applyToChildren), progressMonitor);
}
analysisModules(processItem.getProperty().getId(), selectedJobVersion);
} else {
LastGenerationInfo.getInstance().setModulesNeededWithSubjobPerJob(processItem.getProperty().getId(), processItem.getProperty().getVersion(), Collections.<ModuleNeeded>emptySet());
LastGenerationInfo.getInstance().setLastMainJob(null);
}
List<URL> resources = new ArrayList<URL>();
List<URL> childrenList = new ArrayList<URL>();
if (CommonsPlugin.isHeadless()) {
childrenList = posExportResource(process, exportChoice, contextName, launcher, statisticPort, tracePort, i, jobProcess, processItem, selectedJobVersion, resources, codeOptions);
} else {
String log4jOption = getLog4jLevel() != null ? TalendProcessArgumentConstant.CMD_ARG_LOG4J_LEVEL + getLog4jLevel().toLowerCase() : null;
String[] newCodeOptions = codeOptions;
if (!ArrayUtils.contains(codeOptions, log4jOption)) {
newCodeOptions = (String[]) ArrayUtils.add(codeOptions, log4jOption);
}
childrenList = posExportResource(process, exportChoice, contextName, launcher, statisticPort, tracePort, i, jobProcess, processItem, selectedJobVersion, resources, newCodeOptions);
}
resources.addAll(childrenList);
process[i].addResources(resources);
// Gets job designer resouce
// List<URL> srcList = getSource(processItem, exportChoice.get(ExportChoice.needSource));
// process[i].addResources(JOB_SOURCE_FOLDER_NAME, srcList);
}
// Exports the system libs
List<ExportFileResource> list = new ArrayList<ExportFileResource>(Arrays.asList(process));
// Add the java system libraries
ExportFileResource libResource = getCompiledLibExportFileResource(process);
list.add(libResource);
// Gets jobInfo.properties
// only addClasspathJar not check in preferences ,then export the jobInfo.properties
boolean addClasspathJar = false;
IDesignerCoreUIService designerCoreUIService = CoreUIPlugin.getDefault().getDesignerCoreUIService();
if (designerCoreUIService != null) {
addClasspathJar = designerCoreUIService.getPreferenceStore().getBoolean(IRepositoryPrefConstants.ADD_CLASSPATH_JAR);
}
if (!addClasspathJar) {
if (!(process.length > 1)) {
for (ExportFileResource pro : process) {
ExportFileResource jobInfoResource = new ExportFileResource(null, PATH_SEPARATOR);
if (CommonsPlugin.isHeadless()) {
jobInfoResource = new ExportFileResource();
}
list.add(jobInfoResource);
List<URL> jobInfoList = getJobInfoFile(pro, contextName);
jobInfoResource.addResources(jobInfoList);
}
}
}
if (PluginChecker.isRulesPluginLoaded()) {
// hywang add for 6484,add final drl files or xls files to exported job script
//$NON-NLS-1$
ExportFileResource ruleFileResource = new ExportFileResource(null, "Rules/rules/final");
list.add(ruleFileResource);
try {
Map<String, List<URL>> map = initUrlForRulesFiles(process);
Object[] keys = map.keySet().toArray();
for (Object key : keys) {
List<URL> talendDrlFiles = map.get(key.toString());
ruleFileResource.addResources(key.toString(), talendDrlFiles);
}
} catch (CoreException e) {
ExceptionHandler.process(e);
} catch (MalformedURLException e) {
ExceptionHandler.process(e);
} catch (PersistenceException e) {
ExceptionHandler.process(e);
}
}
return list;
}
use of org.talend.core.ui.services.IDesignerCoreUIService in project tdi-studio-se by Talend.
the class StatsAndLogsComposite method onReloadPreference.
@Override
protected void onReloadPreference() {
// StatsAndLogsComposite.this);
if (elem instanceof Process) {
Process process = (Process) elem;
LoadProjectSettingsCommand command = new LoadProjectSettingsCommand(process, EParameterName.STATANDLOG_USE_PROJECT_SETTINGS.getName(), Boolean.TRUE);
boolean executed = false;
IDesignerCoreUIService designerCoreUIService = CoreUIPlugin.getDefault().getDesignerCoreUIService();
if (designerCoreUIService != null) {
executed = designerCoreUIService.executeCommand(process, command);
}
if (!executed) {
command.execute();
}
}
}
Aggregations