commonsrc.ingenias.editor.persistence.RelationshipSaveAbs Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of core Show documentation
Show all versions of core Show documentation
The INGENIAS Meta-Editor core. It is a set of facilities to generate an editor from a detailed xml description
/**
* Copyright (C) 2010 Jorge J. Gomez-Sanz sobre código original de Rubén Fuentes
*
* This file is part of the INGENME tool. INGENME is an open source meta-editor
* which produces customized editors for user-defined modeling languages
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation version 3 of the License
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program. If not, see
**/
package ingenias.editor.persistence;
import java.lang.reflect.*;
import javax.swing.tree.*;
import org.apache.xerces.parsers.DOMParser;
import org.xml.sax.InputSource;
import java.awt.Color;
import java.awt.Point;
import java.awt.Rectangle;
import java.io.OutputStreamWriter;
import java.io.*;
import javax.swing.tree.DefaultMutableTreeNode;
import java.util.*;
import java.util.Map;
import java.util.Hashtable;
import java.util.ArrayList;
import javax.xml.parsers.*;
import org.jgraph.JGraph;
import org.jgraph.graph.*;
import org.w3c.dom.*;
import org.w3c.dom.Document;
import org.w3c.dom.DOMImplementation;
import ingenias.editor.entities.*;
import ingenias.exception.*;
import ingenias.editor.cell.*;
import ingenias.editor.*;
public abstract class RelationshipSaveAbs {
public RelationshipSaveAbs() {
}
public void saveRelationships(RelationshipManager rm, GraphManager gm,
OutputStreamWriter fos) throws IOException {
Enumeration enumeration = rm.getRelationships(gm);
fos.write("\n");
OutputStreamWriter tempOutput = null;
ObjectSave objsave=new ObjectSave();
while (enumeration.hasMoreElements()) {
java.io.ByteArrayOutputStream byteStore=new java.io.ByteArrayOutputStream();
tempOutput = new OutputStreamWriter(byteStore);
ingenias.editor.entities.NAryEdgeEntity en = (NAryEdgeEntity) enumeration.
nextElement();
try {
tempOutput.write( "\n");
objsave.saveObject(en, tempOutput);
String[] idEnt = en.getIds();
for (int k = 0; k < idEnt.length; k++) {
RoleEntity re = en.getRoleEntity(idEnt[k]);
if (re != null) {
tempOutput.write( ("\n"));
try {
saveRole(re, tempOutput);
}
catch (Exception e2) {
e2.printStackTrace();
}
tempOutput.write(" ");
} else {
System.err.println("WARNING!!!!!!!!!!!!! role for "+idEnt[k]+" is missing in "+en.getId());
Log.getInstance().log("WARNING!!!!!!!!!!!!! role for "+idEnt[k]+" is missing in "+en.getId());
}
}
tempOutput.write( (" \n"));
tempOutput.flush();
fos.write(byteStore.toString());
}
catch (Exception e1) {
e1.printStackTrace();
}
}
fos.write(" \n");
}
abstract protected void saveRole(ingenias.editor.entities.RoleEntity en,
OutputStreamWriter tempOutput) throws
IOException ;
}