diff --git a/TaskAndTimeTimJahn.txt b/TaskAndTimeTimJahn.txt index 5fe6e63a423937569a5ed317fc34121db5423701..e71b7e943d4824dd6f6ceaec86073cc2267a3ee1 100644 --- a/TaskAndTimeTimJahn.txt +++ b/TaskAndTimeTimJahn.txt @@ -16,6 +16,9 @@ Nachfolgend die Informationen die du brauchst. Für weiterführende Konzepte ist meist leider nur die API Doku https://eclipse.dev/glsp/documentation/ oder der Code da Diese solltest du dir bei Bedarf, wenn du am Issues fixen bist anschauen + + example: + https://github.com/eclipse-glsp/glsp-examples/tree/master/project-templates/java-emf-theia Der Editor selbst ist in https://git-st.inf.tu-dresden.de/dineros/framework/pnml-petri-net-editor @@ -45,6 +48,7 @@ hours: 01.12.24 8h 08.12.24 8h 16.12.24 12h +22.12.24 12h //------------------------------------------------------------------------------------------------------ see https://github.com/eclipse-theia/theia/blob/master/doc/Developing.md#prerequisite_native_keymap @@ -59,6 +63,13 @@ sudo npm install -g n node --version sudo n 20.18.0 //theia needs version < 21 +=============================================================== +alt. if sudo n does not work (check with node --version): + +curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.40.1/install.sh | bash +nvm install 20 +=============================================================== + curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add - echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list sudo apt update && sudo apt install yarn diff --git a/glsp-server/.classpath b/glsp-server/.classpath index 423f07cfeee193c42f622df865c062d97a5ace04..0e68107da9d6ee7e87290f01f95a94ab53c982e0 100644 --- a/glsp-server/.classpath +++ b/glsp-server/.classpath @@ -1,6 +1,6 @@ <?xml version="1.0" encoding="UTF-8"?> <classpath> - <classpathentry kind="src" output="target_classes" path="src-gen"> + <classpathentry kind="src" output="target/classes" path="src-gen"> <attributes> <attribute name="optional" value="true"/> <attribute name="maven.pomderived" value="true"/> @@ -12,19 +12,19 @@ </attributes> </classpathentry> <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/> - <classpathentry kind="src" output="target_classes" path="src/main/java"> + <classpathentry kind="src" output="target/classes" path="src/main/java"> <attributes> <attribute name="optional" value="true"/> <attribute name="maven.pomderived" value="true"/> </attributes> </classpathentry> - <classpathentry excluding="**" kind="src" output="target_classes" path="src/main/resources"> + <classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources"> <attributes> <attribute name="maven.pomderived" value="true"/> <attribute name="optional" value="true"/> </attributes> </classpathentry> - <classpathentry excluding="**" kind="src" output="target_classes" path="model"> + <classpathentry excluding="**" kind="src" output="target/classes" path="model"> <attributes> <attribute name="maven.pomderived" value="true"/> <attribute name="optional" value="true"/> @@ -66,5 +66,5 @@ <attribute name="test" value="true"/> </attributes> </classpathentry> - <classpathentry kind="output" path="target_classes"/> + <classpathentry kind="output" path="target/classes"/> </classpath> diff --git a/glsp-server/src/main/java/org/eclipse/glsp/example/javaemf/model/TaskListSourceModelStorage.java b/glsp-server/src/main/java/org/eclipse/glsp/example/javaemf/model/TaskListSourceModelStorage.java index 9b68a3eb7e51cb3274b632bffe7531c78dc7186a..04b5012d6e65aff8d764513344d2225653fb9909 100644 --- a/glsp-server/src/main/java/org/eclipse/glsp/example/javaemf/model/TaskListSourceModelStorage.java +++ b/glsp-server/src/main/java/org/eclipse/glsp/example/javaemf/model/TaskListSourceModelStorage.java @@ -39,6 +39,7 @@ import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import java.io.File; +import java.io.FileWriter; import java.io.IOException; import java.util.Collections; @@ -74,7 +75,6 @@ public class TaskListSourceModelStorage extends EMFNotationSourceModelStorage { * not in the source model */ - private final URI baseModel = URI.createFileURI(new File("BaseModel.pnml").getAbsolutePath()); @Override public void loadSourceModel(final RequestModelAction action) { @@ -84,20 +84,71 @@ public class TaskListSourceModelStorage extends EMFNotationSourceModelStorage { ResourceSet resourceSet = getOrCreateEditingDomain().getResourceSet(); - System.err.println("1"); - System.err.println("\nERROR: URI "+ sourceURI + " empty. \n\t at "+ resourceURI +")\n"); + try{ + // check how many bytes the inputstream from the url yields before hitting some interrupt + if(0 == resourceSet.getURIConverter().createInputStream(resourceURI).available()) + setupAndLoadNewModel(resourceSet, resourceURI, action); - if(!resourceSet.getURIConverter().exists(resourceURI, null)) + else + doLoadSourceModel(resourceSet, resourceURI, action); + } + catch(IOException e) { - System.err.println("2"); - System.err.println("\nERROR: URI "+ sourceURI + " empty. \n\t at "+ resourceURI +")\n"); + System.err.println("\nIO Exception trying to access uri: "+ resourceURI +"\n"); } - else { - System.err.println("3"); - doLoadSourceModel(resourceSet, resourceURI, action); - System.err.println("4"); + } + + + private void setupAndLoadNewModel(final ResourceSet resourceSet, final URI sourceURI, + final RequestModelAction action) + { + /* + * this function creates a local file from which to load a default model, + * then deletes that file after loading is finished + * + * the added model will not be saved and the file will be gone, so there will in fact not be a file source + * + * to actually create the file save it once + * + * possibly the same could be achived by manually building a graphical model and translating it into an empty sorce model + * this would avoid the need for additional files + */ + String fileName = sourceURI.lastSegment(); + int dotIndex = fileName.lastIndexOf("."); + if(dotIndex >= 0) + fileName = fileName.substring(0,dotIndex); + + String baseModel = + "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\r\n" + // + "<pnml xmi:version=\"2.0\" xmlns:xmi=\"http://www.omg.org/XMI\" xmlns=\"http://www.pnml.org/version-2009/grammar/pnml\">\r\n" + // + " <net id=\""+ fileName +"\"/>\r\n" + // + //" </net>\r\n" + // + "</pnml>"; + + + // create a server local tempfile for the model to load from + URI modelURI = null; + File modelFile = null; + try{ + modelFile = new File("model.tmp"); + FileWriter modelInput = new FileWriter(modelFile); + modelInput.write(baseModel); + modelInput.close(); + + modelURI = URI.createFileURI(modelFile.getAbsolutePath()); } - System.err.println("5"); + catch(IOException e) + { + LOGGER.error("Could not create new resource: " + modelURI, e); + throw new GLSPServerException("Could not save model to file: " + modelURI, e); + } + + // load the file and set the uri to the intended source + doLoadSourceModel(resourceSet, modelURI, action); + Resource resource = resourceSet.getResource(modelURI, false); + resource.setURI(sourceURI); + // cleanup temp file + modelFile.delete(); } /*