use of org.talend.designer.core.ui.editor.process.Process in project tdi-studio-se by Talend.
the class OpenRepositoryJobHierarchyAction method doRun.
/*
* (non-Javadoc)
*
* @see org.eclipse.jface.action.Action#run()
*/
protected void doRun() {
ISelection selection = getSelection();
Object obj = ((IStructuredSelection) selection).getFirstElement();
RepositoryNode node = (RepositoryNode) obj;
Property property = (Property) node.getObject().getProperty();
Property updatedProperty = null;
try {
updatedProperty = ProxyRepositoryFactory.getInstance().getLastVersion(new Project(ProjectManager.getInstance().getProject(property.getItem())), property.getId()).getProperty();
} catch (PersistenceException e) {
ExceptionHandler.process(e);
}
// update the property of the node repository object
if (node.getObject() instanceof IRepositoryObject) {
IRepositoryObject iobject = (IRepositoryObject) node.getObject();
iobject.setProperty(updatedProperty);
}
Assert.isTrue(property.getItem() instanceof ProcessItem);
// TODO should use a fake Process here to replace the real Process.
// Process loadedProcess = new Process(property);
// loadedProcess.loadXmlFile();
IDesignerCoreService designerCoreService = CorePlugin.getDefault().getDesignerCoreService();
Process loadedProcess = (Process) designerCoreService.getProcessFromProcessItem((ProcessItem) updatedProperty.getItem());
OpenJobHierarchyAction openAction = new OpenJobHierarchyAction(this.getViewPart());
openAction.run(loadedProcess);
}
use of org.talend.designer.core.ui.editor.process.Process in project tdi-studio-se by Talend.
the class JobHierarchyTransferDropAdapter method drop.
public void drop(DropTargetEvent event) {
IStructuredSelection selection = getSelection();
if (selection.size() == 1) {
if (selection.getFirstElement() instanceof RepositoryNode) {
RepositoryNode sourceNode = (RepositoryNode) selection.getFirstElement();
Item item = sourceNode.getObject().getProperty().getItem();
if (item instanceof ProcessItem) {
// Process loadedProcess = new Process(((ProcessItem) item).getProperty());
// loadedProcess.loadXmlFile();
IDesignerCoreService designerCoreService = CorePlugin.getDefault().getDesignerCoreService();
Process loadedProcess = (Process) designerCoreService.getProcessFromProcessItem((ProcessItem) item);
part.setInputProcess(loadedProcess);
}
}
}
}
use of org.talend.designer.core.ui.editor.process.Process in project tdi-studio-se by Talend.
the class ChangeActivateStatusElementCommand method undo.
@Override
public void undo() {
Process process;
if (nodeList.size() > 0) {
process = (Process) nodeList.get(0).getProcess();
} else {
process = (Process) connectionList.get(0).getSource().getProcess();
}
process.setActivate(false);
dummyMiddleElement(true);
for (Node node : nodeList) {
if (isSameSchemaInputOutput(node)) {
node.setPropertyValue(EParameterName.DUMMY.getName(), value);
}
node.setPropertyValue(EParameterName.ACTIVATE.getName(), !value);
}
for (Connection connection : connectionList) {
connection.setPropertyValue(EParameterName.ACTIVATE.getName(), !value);
}
if (connectionList != null && connectionList.size() != 0) {
if (connIndex < outputs.size()) {
outputs.remove(this.curConn);
outputs.add(outputs.size() - deactiveNum, (Connection) object);
}
if (connIndex >= outputs.size()) {
outputs.add(curConn);
}
curConn.updateAllId();
}
process.setActivate(true);
process.checkStartNodes();
process.checkProcess();
refreshPropertyView();
refreshMRStatus();
}
use of org.talend.designer.core.ui.editor.process.Process in project tdi-studio-se by Talend.
the class ChangeActivateStatusElementCommand method getAllMiddleConnections.
private Map<List<INode>, List<IConnection>> getAllMiddleConnections() {
Map<List<INode>, List<IConnection>> middConnMap = new HashMap<List<INode>, List<IConnection>>();
Process process;
if (nodeList.size() > 0) {
process = (Process) nodeList.get(0).getProcess();
} else {
process = (Process) connectionList.get(0).getSource().getProcess();
}
List<? extends INode> nodes = process.getGraphicalNodes();
List<INode> jobletandnodeList = new ArrayList<INode>();
for (INode node : nodes) {
if (((Node) node).isJoblet() && !((Node) node).getNodeContainer().isCollapsed() && (((Node) node).getNodeContainer() instanceof AbstractJobletContainer)) {
for (NodeContainer nc : ((AbstractJobletContainer) ((Node) node).getNodeContainer()).getNodeContainers()) {
jobletandnodeList.add(nc.getNode());
}
} else {
jobletandnodeList.add(node);
}
}
for (INode node : jobletandnodeList) {
if (node.isActivate()) {
Map<IConnection, Node> outMiddleNodes = getAllOutMiddleNodes(node);
Map<IConnection, Node> inMiddleNodes = getAllInMiddleNodes(node);
Set<Entry<IConnection, Node>> outSet = outMiddleNodes.entrySet();
Iterator<Entry<IConnection, Node>> outIte = outSet.iterator();
boolean haveActivateTarget = false;
List<INode> nodeList = new ArrayList<INode>();
List<IConnection> connList = new ArrayList<IConnection>();
while (outIte.hasNext()) {
Entry<IConnection, Node> en = outIte.next();
Node enNode = en.getValue();
IConnection enConn = en.getKey();
if (enNode != null) {
haveActivateTarget = true;
if (!nodeList.contains(node)) {
nodeList.add(node);
}
if (!nodeList.contains(enNode)) {
nodeList.add(enNode);
}
}
if (enConn != null && !connList.contains(enConn)) {
connList.add(enConn);
}
}
if (!haveActivateTarget) {
outMiddleNodes.clear();
}
if (!nodeList.isEmpty() && !connList.isEmpty()) {
Set<Entry<List<INode>, List<IConnection>>> middSet = middConnMap.entrySet();
Iterator<Entry<List<INode>, List<IConnection>>> middIte = middSet.iterator();
boolean exist = false;
while (middIte.hasNext()) {
Entry<List<INode>, List<IConnection>> entry = middIte.next();
List<INode> enNodeList = entry.getKey();
if (enNodeList.size() == 2 && nodeList.size() == 2) {
if (enNodeList.get(0).getUniqueName().equals(nodeList.get(1).getUniqueName()) && enNodeList.get(1).getUniqueName().equals(nodeList.get(0).getUniqueName())) {
exist = true;
} else if (enNodeList.get(0).getUniqueName().equals(nodeList.get(0).getUniqueName()) && enNodeList.get(1).getUniqueName().equals(nodeList.get(1).getUniqueName())) {
exist = true;
}
}
}
if (!exist) {
middConnMap.put(nodeList, connList);
}
}
Set<Entry<IConnection, Node>> inSet = inMiddleNodes.entrySet();
Iterator<Entry<IConnection, Node>> inIte = inSet.iterator();
boolean haveActivateSource = false;
nodeList = new ArrayList<INode>();
connList = new ArrayList<IConnection>();
while (inIte.hasNext()) {
Entry<IConnection, Node> en = inIte.next();
Node enNode = en.getValue();
IConnection enConn = en.getKey();
if (enNode != null) {
haveActivateSource = true;
if (!nodeList.contains(node)) {
nodeList.add(node);
}
if (!nodeList.contains(enNode)) {
nodeList.add(enNode);
}
}
if (enConn != null && !connList.contains(enConn)) {
connList.add(enConn);
}
}
if (!haveActivateSource) {
inMiddleNodes.clear();
}
if (!nodeList.isEmpty() && !connList.isEmpty()) {
Set<Entry<List<INode>, List<IConnection>>> middSet = middConnMap.entrySet();
Iterator<Entry<List<INode>, List<IConnection>>> middIte = middSet.iterator();
boolean exist = false;
while (middIte.hasNext()) {
Entry<List<INode>, List<IConnection>> entry = middIte.next();
List<INode> enNodeList = entry.getKey();
if (enNodeList.size() == 2 && nodeList.size() == 2) {
if (enNodeList.get(0).getUniqueName().equals(nodeList.get(1).getUniqueName()) && enNodeList.get(1).getUniqueName().equals(nodeList.get(0).getUniqueName())) {
exist = true;
} else if (enNodeList.get(0).getUniqueName().equals(nodeList.get(0).getUniqueName()) && enNodeList.get(1).getUniqueName().equals(nodeList.get(1).getUniqueName())) {
exist = true;
}
}
}
if (!exist) {
middConnMap.put(nodeList, connList);
}
}
}
}
return middConnMap;
}
use of org.talend.designer.core.ui.editor.process.Process in project tdi-studio-se by Talend.
the class ChangeConnectionStatusCommand method execute.
public void execute() {
INode target = connection.getTarget();
if (connection.getLineStyle().equals(EConnectionType.FLOW_MAIN)) {
connection.setLineStyle(EConnectionType.FLOW_REF);
} else {
boolean found = false;
for (int i = 0; i < target.getIncomingConnections().size() && !found; i++) {
Connection currentConnection = (Connection) target.getIncomingConnections().get(i);
if (currentConnection.getLineStyle().equals(EConnectionType.FLOW_MAIN)) {
oldMainConnection = currentConnection;
oldMainConnection.setLineStyle(EConnectionType.FLOW_REF);
}
}
connection.setLineStyle(EConnectionType.FLOW_MAIN);
}
if (target.getExternalNode() != null) {
target.getExternalNode().connectionStatusChanged(connection.getLineStyle(), connection.getUniqueName());
}
((Process) connection.getSource().getProcess()).checkStartNodes();
((Process) connection.getSource().getProcess()).checkProcess();
}
Aggregations