Skip to content
Snippets Groups Projects
Commit e91c0d49 authored by StarryScythe's avatar StarryScythe
Browse files

issue #1 fixed

parent 6208818a
No related branches found
No related tags found
No related merge requests found
......@@ -17,6 +17,9 @@ Nachfolgend die Informationen die du brauchst.
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
Tipps zur Installation:
......@@ -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
......
<?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>
......@@ -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");
}
System.err.println("5");
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());
}
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();
}
/*
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment