use of org.talend.designer.core.ui.editor.process.Process in project tdi-studio-se by Talend.
the class JobletConnectionReconnectCommand method undo.
@Override
public void undo() {
if (newSource != null) {
INodeConnector connector = oldSource.getConnectorFromName(connectorName);
connector.setCurLinkNbOutput(connector.getCurLinkNbOutput() + 1);
connector = newSource.getConnectorFromName(connectorName);
connector.setCurLinkNbOutput(connector.getCurLinkNbOutput() - 1);
if (connection.getLineStyle().hasConnectionCategory(IConnectionCategory.FLOW)) {
boolean builtInNewSource = newSource.getConnectorFromName(connectorName).isMultiSchema();
boolean builtInOldSource = oldSource.getConnectorFromName(connectorName).isMultiSchema();
if ((!builtInNewSource) && (!builtInOldSource)) {
setSchemaToNotBuiltInNode(newSource, oldSource, oldMetadataTable);
if (oldSource.getJobletNode() != null) {
connection.setMetaName(oldSource.getJobletNode().getUniqueName());
} else
connection.setMetaName(oldSource.getUniqueName());
} else {
if (!builtInNewSource) {
oldSource.getMetadataList().add(oldMetadataTable);
connection.setMetaName(oldMetadataTable.getTableName());
}
if (!builtInOldSource) {
int num = 0;
for (int i = 0; i < newSource.getMetadataList().size(); i++) {
IMetadataTable meta = newSource.getMetadataList().get(i);
if (meta.getTableName().equals(connection.getUniqueName())) {
num = i;
}
}
newSource.getMetadataList().remove(num);
setSchemaToNotBuiltInNode(newSource, oldSource, oldMetadataTable);
if (oldSource.getJobletNode() != null) {
connection.setMetaName(oldSource.getJobletNode().getUniqueName());
} else
connection.setMetaName(oldSource.getUniqueName());
}
if ((builtInOldSource) && (builtInNewSource)) {
int num = 0;
for (int i = 0; i < newSource.getMetadataList().size(); i++) {
IMetadataTable meta = newSource.getMetadataList().get(i);
if (meta.getTableName().equals(oldMetadataTable.getTableName())) {
num = i;
}
}
newSource.getMetadataList().remove(num);
oldSource.getMetadataList().add(oldMetadataTable);
}
}
if (newSourceSchemaType != null) {
for (ChangeMetadataCommand cmd : metadataChanges) {
cmd.undo();
}
newSource.setPropertyValue(EParameterName.SCHEMA_TYPE.getName(), newSourceSchemaType);
}
if (oldSourceSchemaType != null) {
oldSource.setPropertyValue(EParameterName.SCHEMA_TYPE.getName(), oldSourceSchemaType);
}
} else {
if (oldSource.getJobletNode() != null) {
connection.setMetaName(oldSource.getJobletNode().getUniqueName());
} else
connection.setMetaName(oldSource.getUniqueName());
}
} else if (newTarget != null) {
INodeConnector connector = oldTarget.getConnectorFromType(oldLineStyle);
connector.setCurLinkNbInput(connector.getCurLinkNbInput() + 1);
connector = newTarget.getConnectorFromType(newLineStyle);
connector.setCurLinkNbInput(connector.getCurLinkNbInput() - 1);
if (newTargetSchemaType != null) {
for (ChangeMetadataCommand cmd : metadataChanges) {
cmd.undo();
}
newTarget.setPropertyValue(EParameterName.SCHEMA_TYPE.getName(), newTargetSchemaType);
}
}
connection.reconnect(oldSource, oldTarget, oldLineStyle);
connection.updateName();
((Process) oldSource.getProcess()).checkStartNodes();
((Process) oldSource.getProcess()).checkProcess();
}
use of org.talend.designer.core.ui.editor.process.Process in project tdi-studio-se by Talend.
the class NodesMoveCommond method undo.
@SuppressWarnings("unchecked")
@Override
public void undo() {
// remove the current selection
AbstractMultiPageTalendEditor multiPageTalendEditor = (AbstractMultiPageTalendEditor) PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getActiveEditor();
GraphicalViewer viewer = multiPageTalendEditor.getTalendEditor().getViewer();
if (!multipleCommand) {
viewer.deselectAll();
}
for (NodeContainer nodeContainer : nodeContainerList) {
// remove the connections name from the list
for (Connection connection : (List<Connection>) nodeContainer.getNode().getOutgoingConnections()) {
process.removeUniqueConnectionName(connection.getName());
}
((Process) process).removeNodeContainer(nodeContainer);
}
// check that the created connections are removed, remove them if not
for (String newConnectionName : createdNames) {
if (!process.checkValidConnectionName(newConnectionName, true)) {
process.removeUniqueConnectionName(newConnectionName);
}
}
process.checkStartNodes();
process.checkProcess();
// set the old selection active
if (!multipleCommand) {
StructuredSelection s = new StructuredSelection(oldSelection);
viewer.setSelection(s);
}
}
use of org.talend.designer.core.ui.editor.process.Process in project tdi-studio-se by Talend.
the class StatsAndLogsTabPropertySection method setInput.
public void setInput(final IWorkbenchPart workbenchPart, final ISelection selection) {
Object input = ((IStructuredSelection) selection).getFirstElement();
if (input instanceof RepositoryNode) {
// This is the only RepositoryNode that displays the Job.
Process process = StatsAndLogsSectionFilter.getProcessPartByRepositoryNode((RepositoryNode) input);
if (process == null) {
return;
}
// make a mock processPart here for super.setInput();
ProcessPart part = new ProcessPart();
part.setModel(process);
StructuredSelection sel = new StructuredSelection(part);
super.setInput(workbenchPart, sel);
} else {
super.setInput(workbenchPart, selection);
}
}
use of org.talend.designer.core.ui.editor.process.Process in project tdi-studio-se by Talend.
the class SubjobContainerLayoutEditPolicy method getCreateCommand.
// ------------------------------------------------------------------------
// Abstract methods from LayoutEditPolicy
/*
* (non-Javadoc)
*
* @see org.eclipse.gef.editpolicies.LayoutEditPolicy#getCreateCommand(org.eclipse.gef.requests.CreateRequest)
*/
protected Command getCreateCommand(final CreateRequest request) {
if (((SubjobContainer) getHost().getModel()).isReadOnly()) {
return null;
}
Rectangle constraint = (Rectangle) getConstraintFor(request);
Process linkedProcess = (Process) ((SubjobContainer) getHost().getModel()).getProcess();
Command command = null;
if (Note.class.equals(request.getNewObjectType())) {
command = new CreateNoteCommand(linkedProcess, (Note) request.getNewObject(), constraint.getLocation());
} else if (request.getNewObject() instanceof Node) {
Node node = (Node) request.getNewObject();
NodeContainer nodeContainer = ((Process) node.getProcess()).loadNodeContainer(node, false);
command = new CreateNodeContainerCommand(linkedProcess, nodeContainer, constraint.getLocation());
}
return command;
}
use of org.talend.designer.core.ui.editor.process.Process in project tdi-studio-se by Talend.
the class AbstractTalendEditor method getCommonKeyHandler.
/**
* DOC qzhang Comment method "getCommonKeyHandler".
*
* @return
*/
public KeyHandler getCommonKeyHandler() {
if (sharedKeyHandler == null) {
sharedKeyHandler = new KeyHandler();
sharedKeyHandler.put(KeyStroke.getPressed(SWT.F1, 0), new Action() {
@Override
public void run() {
ISelection selection = getGraphicalViewer().getSelection();
if (selection != null) {
if (selection instanceof IStructuredSelection) {
Object input = ((IStructuredSelection) selection).getFirstElement();
Node node = null;
if (input instanceof NodeTreeEditPart) {
NodeTreeEditPart nTreePart = (NodeTreeEditPart) input;
node = (Node) nTreePart.getModel();
} else {
if (input instanceof NodePart) {
EditPart editPart = (EditPart) input;
node = (Node) editPart.getModel();
}
}
if (node != null) {
String helpLink = (String) node.getPropertyValue(EParameterName.HELP.getName());
String requiredHelpLink = ((Process) node.getProcess()).getBaseHelpLink() + node.getComponent().getName();
if (helpLink == null || "".equals(helpLink) || !requiredHelpLink.equals(helpLink)) {
helpLink = ((Process) node.getProcess()).getBaseHelpLink() + node.getComponent().getName();
}
PlatformUI.getWorkbench().getHelpSystem().displayHelp(helpLink);
}
}
}
}
});
sharedKeyHandler.put(KeyStroke.getPressed(SWT.DEL, 0), getActionRegistry().getAction(ActionFactory.DELETE.getId()));
// deactivate the F2 shortcut as it's not used anymore
// sharedKeyHandler.put(KeyStroke.getPressed(SWT.F2, 0),
// getActionRegistry().getAction(GEFActionConstants.DIRECT_EDIT));
}
return sharedKeyHandler;
}
Aggregations