NetInfo current = (NetInfo) selection[i].getLastPathComponent();
Object[] sme = current.getReferencedElements();
for (int j = 0; j < sme.length; ++j)
processedSelection.add(sme[j]);
}
AbstractGraph currentGraph = m_currentEditor.getGraph();
// Finally, select all elements selected in the tree view
ArrayList<AbstractPetriNetElementModel> newSelection = new ArrayList<AbstractPetriNetElementModel>();
for (Iterator<Object> i = processedSelection.iterator(); i.hasNext();) {
AbstractPetriNetElementModel currentObject = (AbstractPetriNetElementModel) i.next();
// Comparing only the IDs is too risky because we may crash in this
// case if by
// accident an id name is not unique.
// Rather, look up by ID and see if the references match. This if
// proof
// that we're actually talking about the same element
if (m_currentEditor.getModelProcessor().getElementContainer().getElementById(((currentObject).getId())) == currentObject)
// The selected element is part of the currently edited net
newSelection.add(currentObject);
else {
// The selected element is not part of the currently edited net
// We will try to open a corresponding sub-net and
// see if we can select it there
AbstractPetriNetElementModel parent = currentObject.getRootOwningContainer().getOwningElement();
if (parent instanceof SubProcessModel) {
IEditor newEditor = m_mediator.createSubprocessEditor(true, m_currentEditor, (SubProcessModel) parent);
// Select in the new editor
newEditor.getGraph().addSelectionCell(currentObject);
}
}
}
if (highlightOnly == false) {
valueChangedActive = true;
// Need to have an intermediary for our new selection
// as for some reason addSelection will clear all
// previously selected items
currentGraph.setSelectionCells(newSelection.toArray());
valueChangedActive = false;
} else {
highlightElements(newSelection.iterator());
}
}