Commit ea6781c5 authored by Sebastian Pretscher's avatar Sebastian Pretscher

Changes to show a graph

parent 6c57869d
......@@ -11,9 +11,9 @@ Require-Bundle: org.eclipse.ui,
org.eclipse.core.resources,
org.eclipse.ui.editors,
org.eclipse.ui.ide,
CupReferencedLibraries;bundle-version="1.0.0",
org.eclipse.zest.core;bundle-version="1.5.100",
org.eclipse.zest.layouts;bundle-version="1.1.100"
org.eclipse.zest.layouts;bundle-version="1.1.100",
CupReferencedLibraries;bundle-version="1.0.0"
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Bundle-ActivationPolicy: lazy
Bundle-ClassPath: .
package de.tum.in.www2.cupplugin.controller;
import java.io.ByteArrayInputStream;
import java.io.InputStream;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
......@@ -7,6 +10,13 @@ import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.jface.text.IDocument;
import org.eclipse.ui.progress.UIJob;
import de.in.tum.www2.cup.CupContext;
import de.in.tum.www2.cup.CupParser;
import de.in.tum.www2.cup.DefaultErrorReporter;
import de.in.tum.www2.cup.LALRResult;
import de.in.tum.www2.cup.ast.ParserResult;
import de.in.tum.www2.cup.internal.internal_error;
public class DocumentDidChangeJob extends Job {
boolean iAmCurrentlyRunning = false;
......@@ -29,8 +39,37 @@ public class DocumentDidChangeJob extends Job {
* TODO: Job bestücken, vll mit callbacks
*/
String codeText = myDocument.get();
InputStream in = new ByteArrayInputStream(codeText.getBytes());
CupParser p = new CupParser(new DefaultErrorReporter(), in);
ParserResult result = null;
CupContext context = null;
LALRResult lalrResult = null;
try {
result = p.parse();
context = p.getContext();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
if(result != null) {
System.out.println(result.toString());
}
if (context == null) {
} else {
try {
lalrResult = LALRResult.Compute(context, context.start_production);
} catch (internal_error e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
System.out.println(lalrResult.action_table);
System.out.println(lalrResult.reduce_table);
}
//nichts mehr ändern ab hier
iAmCurrentlyRunning = false;
......
package de.tum.in.www2.cupplugin.editors;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.part.ViewPart;
......@@ -17,21 +23,23 @@ public class CupGraphView implements CupGraphModelObserver {
private Model parseModel;
private Composite graphComposite;
private Graph g;
public CupGraphView(Composite parent) {
this.parseModel = Model.getInstance();
this.parseModel.registerModelObserver(this);
this.graphComposite = parent;
}
public void drawGraph() {
//this.graphComposite.
Graph g = new Graph(this.graphComposite, SWT.NONE);
GraphNode hello = new GraphNode(g, SWT.NONE, "Hello");
GraphNode world = new GraphNode(g, SWT.NONE, "World");
new GraphConnection(g, SWT.NONE, hello, world);
g.setLayoutAlgorithm(new SpringLayoutAlgorithm(LayoutStyles.NO_LAYOUT_NODE_RESIZING), true);
org.eclipse.swt.layout.FillLayout layout = new FillLayout();
this.graphComposite.setLayout(layout);
g = new Graph(parent, SWT.NONE);
for (int i = 0; i<500; i++) {
GraphNode hello = new GraphNode(g, SWT.NONE, "Hello");
GraphNode world = new GraphNode(g, SWT.NONE, "World");
new GraphConnection(g, SWT.NONE, hello, world);
}
g.setLayoutAlgorithm(new SpringLayoutAlgorithm(LayoutStyles.NO_LAYOUT_NODE_RESIZING), true);
}
@Override
......@@ -40,6 +48,4 @@ public class CupGraphView implements CupGraphModelObserver {
}
}
......@@ -158,7 +158,6 @@ public class MultiPageEditor extends MultiPageEditorPart implements IResourceCha
super.pageChange(newPageIndex);
if (newPageIndex == 1) {
//TODO: Manage page changes
graphView.drawGraph();
}
}
/**
......
......@@ -59,6 +59,7 @@ Export-Package: EDU.oswego.cs.dl.util.concurrent,
com.ctc.wstx.util,
corejava,
de.in.tum.www2.cup,
de.in.tum.www2.cup.ast,
de.in.tum.www2.cup.internal,
edu.uci.ics.jung.algorithms.blockmodel,
edu.uci.ics.jung.algorithms.cluster,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment