use of org.talend.core.ui.process.IGEFProcess 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.process.IGEFProcess 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.process.IGEFProcess in project tdi-studio-se by Talend.
the class SubjobContainerFigure method initFigure.
/**
* DOC rdubois Comment method "initFigure".
*/
protected void initFigure() {
outlineFigure = new RoundedRectangle();
rectFig = new RoundedRectangle();
titleFigure = new SimpleHtmlFigure();
titleFigure.setOpaque(true);
collapseFigure = new SubjobCollapseFigure();
collapseFigure.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent event) {
IProcess2 process = subjobContainer.getProcess();
if (!process.isReadOnly()) {
PropertyChangeCommand ppc = new PropertyChangeCommand(subjobContainer, EParameterName.COLLAPSED.getName(), !subjobContainer.isCollapsed());
boolean executed = false;
if (process instanceof IGEFProcess) {
IDesignerCoreUIService designerCoreUIService = CoreUIPlugin.getDefault().getDesignerCoreUIService();
if (designerCoreUIService != null) {
executed = designerCoreUIService.executeCommand((IGEFProcess) process, ppc);
}
}
if (!executed) {
ppc.execute();
}
reSelection();
}
}
});
}
use of org.talend.core.ui.process.IGEFProcess in project tdi-studio-se by Talend.
the class UpdateNodeParameterCommand method execute.
@Override
public void execute() {
if (result == null) {
return;
}
Object updateObject = result.getUpdateObject();
if (updateObject == null || (!(updateObject instanceof Node)) || (!(result.getJob() instanceof IProcess))) {
return;
}
// instance of node before might not be good (loaded while check updates needed)
// so get the instance of the node of the current job in this object.
IProcess process = (IProcess) result.getJob();
for (INode node : process.getGraphicalNodes()) {
if (node.getUniqueName().equals(((Node) updateObject).getUniqueName())) {
updateObject = node;
result.setUpdateObject(updateObject);
break;
}
}
IUpdateItemType updateType = result.getUpdateType();
if (updateType instanceof EUpdateItemType) {
switch((EUpdateItemType) updateType) {
case NODE_PROPERTY:
updateProperty();
break;
case NODE_SCHEMA:
updateSchema();
break;
case NODE_QUERY:
updateQuery();
break;
case NODE_SAP_FUNCTION:
updateSAPParameters();
break;
case NODE_SAP_IDOC:
updateSAPIDocParameters();
break;
case NODE_VALIDATION_RULE:
updateValidationRule();
break;
default:
return;
}
}
// else { // for extension
Node node = (Node) updateObject;
if (node.getProcess() instanceof IProcess2) {
PropertyChangeCommand pcc = new PropertyChangeCommand(node, EParameterName.UPDATE_COMPONENTS.getName(), Boolean.TRUE);
boolean executed = false;
if (process instanceof IGEFProcess) {
IDesignerCoreUIService designerCoreUIService = CoreUIPlugin.getDefault().getDesignerCoreUIService();
if (designerCoreUIService != null) {
executed = designerCoreUIService.executeCommand((IGEFProcess) process, pcc);
}
}
if (!executed) {
pcc.execute();
}
}
}
use of org.talend.core.ui.process.IGEFProcess in project tdi-studio-se by Talend.
the class UpdateManagerUtils method executeUpdate.
private static void executeUpdate(UpdateResult result, IProgressMonitor monitor, boolean updateAllJobs) {
if (result.isReadOnlyProcess()) {
return;
}
// update
Command command = null;
IUpdateItemType updateType = result.getUpdateType();
if (updateType instanceof EUpdateItemType) {
switch((EUpdateItemType) updateType) {
case NODE_PROPERTY:
case NODE_SCHEMA:
case NODE_QUERY:
case NODE_SAP_IDOC:
case NODE_SAP_FUNCTION:
case NODE_VALIDATION_RULE:
command = new UpdateNodeParameterCommand(result);
break;
case JOB_PROPERTY_EXTRA:
case JOB_PROPERTY_STATS_LOGS:
case JOB_PROPERTY_HEADERFOOTER:
case JOB_PROPERTY_STORM:
case JOB_PROPERTY_MAPREDUCE:
command = new UpdateMainParameterCommand(result);
break;
case CONTEXT:
command = executeContextUpdates(result);
break;
case CONTEXT_GROUP:
command = executeContextGroupUpdates(result);
break;
case JOBLET_RENAMED:
case JOBLET_SCHEMA:
case RELOAD:
command = executeJobletNodesUpdates(result);
break;
case JUNIT_RELOAD:
command = executeJunitNodesUpdates(result);
break;
// break;
case MAP_PATH:
command = new UpdateNodePathCommand(result);
break;
default:
break;
}
}
if (command != null) {
SubProgressMonitor subMonitor = new SubProgressMonitor(monitor, 1 * UpdatesConstants.SCALE, SubProgressMonitor.PREPEND_MAIN_LABEL_TO_SUBTASK);
subMonitor.beginTask(UpdatesConstants.EMPTY, 1);
subMonitor.subTask(getResultTaskInfor(result));
//
Object job = result.getJob();
boolean executed = false;
if (job != null && job instanceof IGEFProcess) {
IDesignerCoreUIService designerCoreUIService = CoreUIPlugin.getDefault().getDesignerCoreUIService();
if (designerCoreUIService != null) {
executed = designerCoreUIService.executeCommand((IGEFProcess) job, command);
}
}
if (!executed) {
command.execute();
}
subMonitor.worked(1);
}
// from extension point
UpdateManagerProviderDetector.INSTANCE.doUpdate(monitor, result);
}
Aggregations