return editor;
}
private void importNets(PnmlType pnml, boolean showUI) throws Exception {
editor = new IEditor[pnml.getNetArray().length];
NetType currentNet;
Dimension dim;
Point location;
PetriNetModelProcessor currentPetrinet;
SimulationType[] simulations;
for (int i = 0; i < pnml.getNetArray().length; i++) {
simulations = null;
boolean savedFlag = true;
currentNet = pnml.getNetArray(i);
editor[i] = mediator.createEditor(true, showUI);
if(showUI){
if (((WoPeDUndoManager) editor[i].getGraph().getUndoManager()) != null) {
((WoPeDUndoManager) editor[i].getGraph().getUndoManager())
.setEnabled(false);
}
}
currentPetrinet = ((PetriNetModelProcessor) editor[i]
.getModelProcessor());
// attr. id
currentPetrinet.setId(currentNet.getId());
// attr. type
// Type no other types
// name
if (currentNet.isSetName()) {
currentPetrinet.setName(currentNet.getName().getText());
}
if(showUI) if (ConfigurationManager.getConfiguration().isImportToolspecific()) {
// toolspecific
for (int j = 0; j < currentNet.getToolspecificArray().length; j++) {
if (currentNet.getToolspecificArray(j).getTool().equals(
"WoPeD")) {
if (currentNet.getToolspecificArray(j).isSetBounds()) {
dim = new Dimension(currentNet
.getToolspecificArray(j).getBounds()
.getDimension().getX().intValue(),
currentNet.getToolspecificArray(j)
.getBounds().getDimension().getY()
.intValue());
location = new Point(currentNet
.getToolspecificArray(j).getBounds()
.getPosition().getX().intValue(),
currentNet.getToolspecificArray(j)
.getBounds().getPosition().getY()
.intValue());
if (editor[i] instanceof EditorVC) {
// Pass read layout information on to the editor
EditorLayoutInfo layout = new EditorLayoutInfo();
layout.setSavedSize(dim);
layout.setSavedLocation(location);
// try to import the type of Layout (false if vertical)
((EditorVC) editor[i]).setRotateSelected(currentNet
.getToolspecificArray(j)
.getVerticalLayout());
//for importing a vertical net to change the rotate-button
if (currentNet
.getToolspecificArray(j)
.getVerticalLayout()== true){
//EditorVC.setRotateSelected(true);
VisualController.getInstance().propertyChange(new PropertyChangeEvent(this, "Import", null, null));
// Update the UI representation
//EditorVC.getGraph().updateUI();
}
if (currentNet.getToolspecificArray(j).isSetScale()) {
// try to import the saved scale
((EditorVC) editor[i]).getGraph().setScale(currentNet
.getToolspecificArray(j).getScale()/100.0);
}
// Only if also the remaining information is
// available,
// try to import the width of the tree view and the height of the overview panel
if (currentNet.getToolspecificArray(j).isSetTreeWidth()){
GraphicsSimpleType bounds = currentNet.getToolspecificArray(j).getBounds();
DimensionType dimension = bounds.getDimension();
int x =(int) (dimension.getX()).doubleValue();
x = x - currentNet.getToolspecificArray(j).getTreeWidth();
layout.setTreeViewWidthRight(x);
} else if (currentNet.getToolspecificArray(j).isSetTreeWidthRight()){
layout.setTreeViewWidthRight(currentNet.getToolspecificArray(j).getTreeWidthRight());
}
else {
layout.setTreeViewWidthRight(currentNet
.getToolspecificArray(j).getBounds()
.getDimension().getX().intValue() - 100);
}
if(currentNet.getToolspecificArray(j).isSetOverviewPanelVisible()){
layout.setOverviewPanelVisible(currentNet.getToolspecificArray(j).getOverviewPanelVisible());
}else{
layout.setOverviewPanelVisible(true);
}
if (currentNet.getToolspecificArray(j).isSetTreeHeightOverview()){
if(currentNet.getToolspecificArray(j).getTreeHeightOverview() < 1){
layout.setTreeHeightOverview(100);
}else{
layout.setTreeHeightOverview(currentNet.getToolspecificArray(j).getTreeHeightOverview());
}
}else{
layout.setTreeHeightOverview(100);
}
if(currentNet.getToolspecificArray(j).isSetTreePanelVisible()){
layout.setTreePanelVisible(currentNet.getToolspecificArray(j).getTreePanelVisible());
}else{
layout.setTreePanelVisible(true);
}
((EditorVC) editor[i]).getEditorPanel().setSavedLayoutInfo(layout);
}
}
if (currentNet.getToolspecificArray(j).isSetResources()) {
// ResourceMapType resourceMap =
// currentNet.getToolspecificArray(j).getResources().getResourceMap();
ResourceMappingType[] resourceMaps = currentNet
.getToolspecificArray(j).getResources()
.getResourceMappingArray();
RoleType[] roles = currentNet.getToolspecificArray(
j).getResources().getRoleArray();
ResourceClassModel roleModelTemp;
for (int k = 0; k < roles.length; k++) {
roleModelTemp = new ResourceClassModel(roles[k]
.getName(),
ResourceClassModel.TYPE_ROLE);
currentPetrinet.addRole(roleModelTemp);
SuperModelType[] supermodels = roles[k].getSuperModelArray();
ResourceClassModel superModelTemp;
for( int l=0;l<supermodels.length;l++){
superModelTemp = new ResourceClassModel(supermodels[l]
.getName(),ResourceClassModel.TYPE_ROLE);
roleModelTemp.addSuperModel(superModelTemp);
}
}
OrganizationUnitType[] units = currentNet
.getToolspecificArray(j).getResources()
.getOrganizationUnitArray();
ResourceClassModel orgUnitTemp;
for (int l = 0; l < units.length; l++) {
orgUnitTemp = new ResourceClassModel(units[l]
.getName(),
ResourceClassModel.TYPE_ORGUNIT);
currentPetrinet.addOrgUnit(orgUnitTemp);
SuperModelType[] supermodels = units[l].getSuperModelArray();
ResourceClassModel superModelTemp;
for( int m=0;m<supermodels.length;m++){
superModelTemp = new ResourceClassModel(supermodels[m]
.getName(),ResourceClassModel.TYPE_ORGUNIT);
orgUnitTemp.addSuperModel(superModelTemp);
}
}
ResourceType[] resources = currentNet
.getToolspecificArray(j).getResources()
.getResourceArray();
ResourceModel resourceModelTemp;
for (int m = 0; m < resources.length; m++) {
resourceModelTemp = new ResourceModel(
resources[m].getName());
currentPetrinet.addResource(resourceModelTemp);
}
for (int n = 0; n < resourceMaps.length; n++) {
currentPetrinet.addResourceMapping(
resourceMaps[n].getResourceClass(),
resourceMaps[n].getResourceID());
}
}
if (currentNet.getToolspecificArray(j)
.isSetSimulations()) {
// only save the simulationsarray to local variable
// here - the import itself
// has to be done after import of the transitions
// because the simulation
// references transitions (which otherwise result in
// 'null')
// see "importSimulations([...])" below
simulations = currentNet.getToolspecificArray(j)
.getSimulations().getSimulationArray();
}
if (currentNet.getToolspecificArray(j)
.isSetPartnerLinks()) {
TPartnerLinks plist = currentNet
.getToolspecificArray(j).getPartnerLinks();
for (int x = 0; x < plist.sizeOfPartnerLinkArray(); x++) {
TPartnerLink link = plist
.getPartnerLinkArray(x);
if (link.isSetMyRole()
&& link.isSetPartnerRole()) {
currentPetrinet.getElementContainer()
.addPartnerLink(
link.getName(),
link.getPartnerLinkType()
.getNamespaceURI(),
link.getPartnerLinkType()
.getLocalPart(),
link.getPartnerRole(),
link.getMyRole(),
link.getWSDL());
} else if (link.isSetMyRole()) {
currentPetrinet.getElementContainer()
.addPartnerLinkWithoutPartnerRole(
link.getName(),
link.getPartnerLinkType()
.getNamespaceURI(),
link.getPartnerLinkType()
.getLocalPart(),
link.getMyRole(),
link.getWSDL());
} else if (link.isSetPartnerRole()) {
currentPetrinet.getElementContainer()
.addPartnerLinkWithoutMyRole(
link.getName(),
link.getPartnerLinkType()
.getNamespaceURI(),
link.getPartnerLinkType()
.getLocalPart(),
link.getPartnerRole(),
link.getWSDL());
}
}
}
if (currentNet.getToolspecificArray(j).isSetVariables()) {
TVariables vlist = currentNet.getToolspecificArray(
j).getVariables();
for (int x = 0; x < vlist.sizeOfVariableArray(); x++) {
TVariable var = vlist.getVariableArray(x);
currentPetrinet.getElementContainer()
.addVariable(var.getName(),
var.getType().getLocalPart());
}
}
} else {
currentPetrinet.addUnknownToolSpecs(currentNet
.getToolspecificArray(j));
}
}
}