}
return false;
}
public void handleEvent(XPDLElementChangeInfo info) {
XMLElement changedElement = info.getChangedElement();
JaWEManager.getInstance().getLoggingManager().debug("INFO: handleEvenet(): " + info);
int action = info.getAction();
if (action == XPDLElementChangeInfo.SELECTED) {
// should never happen
} else {
if (changedElement instanceof WorkflowProcesses) {
if (action == XMLElementChangeInfo.REMOVED) {
if (info.getChangedSubElements() != null) {
Iterator it = info.getChangedSubElements().iterator();
while (it.hasNext()) {
WorkflowProcess wp = (WorkflowProcess) it.next();
if (wp == selectionMng.getWorkingProcess()) {
// select package
selectionMng.setSelection(wp.getParent().getParent(), true);
break;
}
}
}
}
} else if (changedElement instanceof ActivitySet) {
if (action == XMLElementChangeInfo.REMOVED) {
if (info.getChangedSubElements() != null) {
Iterator it = info.getChangedSubElements().iterator();
while (it.hasNext()) {
ActivitySet as = (ActivitySet) it.next();
if (as == selectionMng.getWorkingActivitySet()) {
// select process
selectionMng.setSelection(as.getParent().getParent(), true);
break;
}
}
}
}
}
}
if (action == XMLElementChangeInfo.INSERTED && (changedElement instanceof WorkflowProcesses || changedElement instanceof ActivitySets)) {
if (info.getChangedSubElements() != null) {
selectionMng.setSelection(info.getChangedSubElements(), true);
}
}
updateTitle();
adjustActions();
if (action == XMLElementChangeInfo.REMOVED || action == XMLElementChangeInfo.INSERTED) {
JaWEManager.getInstance().getLoggingManager().info("JaWEController -> performing appropriate actions on inserting/removing");
if (changedElement instanceof Activities && action == XMLElementChangeInfo.REMOVED) {
// for removing connected Transitions
updateSpecialInProgress = true;
JaWEManager.getInstance().getXPDLUtils().removeTransitionsForActivities(info.getChangedSubElements());
selectionMng.removeFromSelection(info.getChangedSubElements());
updateSpecialInProgress = false;
} else if (changedElement instanceof Transitions) {
Activities acts = (Activities) ((XMLCollectionElement) changedElement.getParent()).get("Activities");
updateSpecialInProgress = true;
JaWEManager.getInstance().getXPDLUtils().correctSplitsAndJoins(acts.toElements());
updateSpecialInProgress = false;
if (action == XMLElementChangeInfo.REMOVED) {
selectionMng.removeFromSelection(info.getChangedSubElements());
}
}
JaWEManager.getInstance().getLoggingManager().info("JaWEController -> finished performing appropriate actions on inserting/removing");
} else if (action == XMLElementChangeInfo.UPDATED) {
XMLElement parent = changedElement.getParent();
if ((changedElement.toName().equals("Id") && (parent instanceof WorkflowProcess || parent instanceof ActivitySet || parent instanceof Application || parent instanceof Participant || parent instanceof DataField || parent instanceof FormalParameter || parent instanceof Activity || parent instanceof Transition || parent instanceof TypeDeclaration)) || ((changedElement.toName().equals("From") || changedElement.toName().equals("To")) && parent instanceof Transition) || ((parent instanceof Split || parent instanceof Join) && changedElement instanceof XMLAttribute)) {
if (parent instanceof Activity || parent instanceof Transition || parent instanceof Split || parent instanceof Join) {
XMLCollectionElement wpOrAs = XMLUtil.getActivitySet(parent);
if (wpOrAs == null) {
wpOrAs = XMLUtil.getWorkflowProcess(parent);
}
if (parent instanceof Activity) {
updateSpecialInProgress = true;
JaWEManager.getInstance().getXPDLUtils().updateTransitionsOnActivityIdChange((Transitions) wpOrAs.get("Transitions"),
(String) info.getOldValue(),
(String) info.getNewValue());
updateSpecialInProgress = false;
} else if (parent instanceof Transition) {
if (changedElement.toName().equals("Id")) {
updateSpecialInProgress = true;
JaWEManager.getInstance().getXPDLUtils().updateActivityOnTransitionIdChange((Activities) wpOrAs.get("Activities"),
((Transition) parent).getFrom(),
(String) info.getOldValue(),
(String) info.getNewValue());
updateSpecialInProgress = false;
} else if (changedElement.toName().equals("From")) {
updateSpecialInProgress = true;
JaWEManager.getInstance().getXPDLUtils().updateActivitiesOnTransitionFromChange((Activities) wpOrAs.get("Activities"),
((Transition) parent).getId(),
(String) info.getOldValue(),
(String) info.getNewValue());
updateSpecialInProgress = false;
} else {
updateSpecialInProgress = true;
JaWEManager.getInstance().getXPDLUtils().updateActivitiesOnTransitionToChange((Activities) wpOrAs.get("Activities"),
((Transition) parent).getId(),
(String) info.getOldValue(),
(String) info.getNewValue());
updateSpecialInProgress = false;
}
} else if (parent instanceof Split || parent instanceof Join) {
updateSpecialInProgress = true;
Activity act = XMLUtil.getActivity(parent);
JaWEManager.getInstance().getXPDLUtils().correctSplitAndJoin(act);
updateSpecialInProgress = false;
}
} else if (parent instanceof TypeDeclaration) {
updateSpecialInProgress = true;
JaWEManager.getInstance().getXPDLUtils().updateTypeDeclarationReferences(JaWEManager.getInstance().getXPDLUtils().getTypeDeclarationReferences(XMLUtil.getPackage(parent),
(String) info.getOldValue()),
(String) info.getNewValue());
updateSpecialInProgress = false;
} else if (parent instanceof WorkflowProcess) {
updateSpecialInProgress = true;
JaWEManager.getInstance().getXPDLUtils().updateWorkflowProcessReferences(JaWEManager.getInstance().getXPDLUtils().getWorkflowProcessReferences(XMLUtil.getPackage(parent),
(String) info.getOldValue()),
(String) info.getNewValue());
updateSpecialInProgress = false;
} else if (parent instanceof ActivitySet) {
updateSpecialInProgress = true;
JaWEManager.getInstance().getXPDLUtils().updateActivitySetReferences(JaWEManager.getInstance().getXPDLUtils().getActivitySetReferences(XMLUtil.getWorkflowProcess(parent),
(String) info.getOldValue()),
(String) info.getNewValue());
updateSpecialInProgress = false;
} else if (parent instanceof Application) {
updateSpecialInProgress = true;
JaWEManager.getInstance().getXPDLUtils().updateApplicationReferences(JaWEManager.getInstance().getXPDLUtils().getApplicationReferences((XMLComplexElement) parent.getParent().getParent(),
(String) info.getOldValue()),
(String) info.getNewValue());
updateSpecialInProgress = false;
} else if (parent instanceof Participant) {
updateSpecialInProgress = true;
JaWEManager.getInstance().getXPDLUtils().updateParticipantReferences(JaWEManager.getInstance().getXPDLUtils().getParticipantReferences((XMLComplexElement) parent.getParent().getParent(),
(String) info.getOldValue()),
(String) info.getNewValue());
updateSpecialInProgress = false;
} else if (parent instanceof DataField || (parent instanceof FormalParameter && parent.getParent().getParent() instanceof WorkflowProcess)) {
updateSpecialInProgress = true;
XMLComplexElement pkgOrWp = (XMLComplexElement) parent.getParent().getParent();
List refs = null;
if (parent instanceof DataField) {
refs = JaWEManager.getInstance().getXPDLUtils().getDataFieldReferences(pkgOrWp, (String) info.getOldValue());
} else {
refs = JaWEManager.getInstance().getXPDLUtils().getFormalParameterReferences((WorkflowProcess) pkgOrWp,