package org.simantics.interop.update.editor;
+import org.eclipse.ui.PartInitException;
import org.simantics.db.Resource;
import org.simantics.db.layer0.variable.RVI;
import org.simantics.ui.workbench.ResourceEditorInput2;
+import org.simantics.utils.ui.workbench.WorkbenchUtils;
/**
* Editor input for ModelUpdateEditor
*/
public class UpdateEditorInput extends ResourceEditorInput2{
+ private String editorID;
private Resource r1;
private Resource r2;
super(editorID, r1, model, rvi);
this.r1 = r1;
this.r2 = r2;
+ this.editorID = editorID;
}
public Resource getR1() {
}
+ public void openEditor() throws PartInitException {
+ WorkbenchUtils.openEditor(editorID, this);
+ }
+
}
return node;
}
+ protected UpdateNode getNode(Resource r) {
+ return nodes.get(r);
+ }
+
protected boolean connectParent(ReadGraph g, UpdateNode node) throws DatabaseException {
UpdateNode parent = null;
while (true) {
Resource parentResource = node.getParentResource(g);
parent = nodes.get(parentResource);
if (parent == null) {
- if (changes.getComparable().containsLeft(parentResource)) {
- parent = createNode(parentResource, changes.getComparable().getRight(parentResource));
- } else if (changes.getComparable().containsRight(parentResource)) {
- parent = createNode(changes.getComparable().getLeft(parentResource) ,parentResource);
- } else {
+ parent = getOrCreate(g, parentResource);
+ if (parent == null)
return false;
- }
//parent.setStatus(Status.CONTAINS);
parent.addChild(node);
node = parent;
}
}
+ protected UpdateNode getOrCreate(ReadGraph g, Resource parentResource) throws DatabaseException {
+ UpdateNode parent = nodes.get(parentResource);
+ if (parent == null) {
+ if (changes.getComparable().containsLeft(parentResource)) {
+ parent = createNode(parentResource, changes.getComparable().getRight(parentResource));
+ } else if (changes.getComparable().containsRight(parentResource)) {
+ parent = createNode(changes.getComparable().getLeft(parentResource) ,parentResource);
+ } else {
+ return null;
+ }
+ //parent.setStatus(Status.CONTAINS
+ }
+ return parent;
+ }
+
+
+
protected boolean handleCustom(ReadGraph g, UpdateOp op) throws DatabaseException {
return false;
}