Commit f1e29d25 authored by Benedikt Engeser's avatar Benedikt Engeser

...

parent b170f2b5
package de.tum.in.www2.cupplugin.controller;
import java.awt.Event;
import java.io.ByteArrayInputStream;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.EnumSet;
import java.util.List;
......@@ -12,10 +10,8 @@ import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.DocumentEvent;
import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.ITypedRegion;
import org.eclipse.ui.part.FileEditorInput;
import org.eclipse.ui.progress.UIJob;
import org.eclipse.ui.texteditor.IDocumentProvider;
......@@ -23,14 +19,10 @@ import org.eclipse.ui.texteditor.IDocumentProvider;
import de.in.tum.www2.cup.CupContext;
import de.in.tum.www2.cup.CupParser;
import de.in.tum.www2.cup.LALRResult;
import de.in.tum.www2.cup.NoopErrorReporter;
import de.in.tum.www2.cup.Position;
import de.in.tum.www2.cup.analysis.LocationPatchVisitor;
import de.in.tum.www2.cup.ast.ParserResult;
import de.in.tum.www2.cup.internal.internal_error;
import de.tum.in.www2.cupplugin.controller.Controller.JobsToDo;
import de.tum.in.www2.cupplugin.editors.CupEditorErrorReporter;
import de.tum.in.www2.cupplugin.editors.CupPartionScanner;
import de.tum.in.www2.cupplugin.editors.CupTextEditor;
import de.tum.in.www2.cupplugin.editors.RevisionManager;
import de.tum.in.www2.cupplugin.model.Model;
......@@ -149,7 +141,7 @@ public class DocumentDidChangeJob extends Job {
context.start_production);
} else {
System.out.println("LALRResult.Compute was not called, "
+ "because the parser has reported errors.");
+ "because the parser has reported errors.");//TODO: REMOVE
}
} catch (internal_error e) {
e.printStackTrace();
......
......@@ -72,7 +72,7 @@ public class MultiPageEditor extends MultiPageEditorPart implements
addHooksToMainTextEditor(editor);
editor.addActions();
IDocument doc = editor.getDocument();
editor.getDocument();
// we need to call init _after_ the editor has a document.
editor.init();
......@@ -96,7 +96,7 @@ public class MultiPageEditor extends MultiPageEditorPart implements
void createOverviewPage(Jumper jumper) {
Composite composite = new Composite(getContainer(), SWT.NONE);
IDocument doc = editor.getDocument();
overviewView = new CupOverviewView(composite, jumper, doc, editor.getTitle());
overviewView = new CupOverviewView(composite, jumper, doc, editor.getTitle(),editor);
addPage(OVERVIEW_PAGE_INDEX, composite);
setPageText(OVERVIEW_PAGE_INDEX, "Overview");
}
......@@ -111,7 +111,7 @@ public class MultiPageEditor extends MultiPageEditorPart implements
void createActionTablePage(Jumper jumper) {
Composite composite = new Composite(getContainer(), SWT.NONE);
IDocument doc = editor.getDocument();
editor.getDocument();
actionTableView = new CupActionTableView(composite, jumper, editor);
addPage(ACTION_TABLE_PAGE_INDEX, composite);
setPageText(ACTION_TABLE_PAGE_INDEX, "Action Table");
......@@ -127,7 +127,7 @@ public class MultiPageEditor extends MultiPageEditorPart implements
void createConflictGraphPage(Jumper jumper) {
Composite composite = new Composite(getContainer(), SWT.NONE);
IDocument doc = editor.getDocument();
editor.getDocument();
conflictGraphView = new CupConflictGraphView(composite, jumper, editor);
addPage(CONFLICT_GRAPH_PAGE_INDEX, composite);
setPageText(CONFLICT_GRAPH_PAGE_INDEX, "Conflict Graph");
......
package de.tum.in.www2.cupplugin.views;
import java.util.EnumSet;
import org.eclipse.jface.text.IDocument;
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Color;
......@@ -7,69 +9,90 @@ import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.ui.forms.widgets.Form;
import org.eclipse.ui.forms.widgets.FormToolkit;
import org.eclipse.ui.forms.widgets.ScrolledForm;
import org.eclipse.ui.forms.widgets.Section;
import de.in.tum.www2.cup.LALRResult;
import de.in.tum.www2.cup.ast.ParserResult;
import de.in.tum.www2.cup.internal.lalr_state;
import de.tum.in.www2.cupplugin.controller.Controller.JobsToDo;
import de.tum.in.www2.cupplugin.controller.Controller;
import de.tum.in.www2.cupplugin.controller.IRegisterForControllerChanges;
import de.tum.in.www2.cupplugin.editors.CupTextEditor;
import de.tum.in.www2.cupplugin.editors.ICupEditorPageVisibility;
import de.tum.in.www2.cupplugin.editors.Jumper;
import de.tum.in.www2.cupplugin.model.ICupParserASTChangeObserver;
import de.tum.in.www2.cupplugin.model.ICupParserLaLrChangeObserver;
import de.tum.in.www2.cupplugin.model.Model;
public class CupOverviewView {
public class CupOverviewView implements IRegisterForControllerChanges,
ICupEditorPageVisibility, ICupParserLaLrChangeObserver,
ICupParserASTChangeObserver {
private static final int OUTER_MARGIN = 10;
private static final int INNER_MARGIN = 10;
boolean visible = false;
private IDocument doc;
private FormToolkit toolkit;
private ScrolledForm form;
private CupTextEditor myEditor;
public CupOverviewView(Composite parent, Jumper jumper, IDocument doc, String title) {
public CupOverviewView(Composite parent, Jumper jumper, IDocument doc,
String title, CupTextEditor editor) {
this.doc = doc;
setupForm(parent, title);
myEditor = editor;
Controller.getInstance(editor).registerObserver(this);
Model.getInstanceForDocument(doc).registerModelObserver(this);
Composite section0 = createSection("Analysis", "double productions, unused terminals, unused non terminals", false);
Composite section1 = createSection("Parse Tables",
"last created, up2date, number of states, number of entries", false);
Composite section2 = createSection("Content", "start production, package, parser class, terminals, non-terminals", true);
Composite section3 = createSection("Grammar", "last checked, up2date, syntax correct", false);
Composite section4 = createSection("Conflicts", "Number of conflicts, etc.", false);
Composite section0 = createSection("Analysis",
"double productions, unused terminals, unused non terminals",
false);
Composite section1 = createSection("Parse Tables",
"last created, up2date, number of states, number of entries",
false);
Composite section2 = createSection(
"Content",
"start production, package, parser class, terminals, non-terminals",
true);
Composite section3 = createSection("Grammar",
"last checked, up2date, syntax correct", false);
Composite section4 = createSection("Conflicts",
"Number of conflicts, etc.", false);
}
private Composite createSection(String title, String description, boolean doSpan) {
Section section = toolkit.createSection(form.getBody(),
Section.DESCRIPTION | Section.TITLE_BAR);
section.setText(title);
section.setDescription(description);
GridData data = new GridData(GridData.FILL_BOTH);
data.widthHint = 200;
data.heightHint = 100;
if (doSpan)
data.horizontalSpan = 2;
section.setLayoutData(data);
// Composite for storing the data
Composite client = toolkit.createComposite(section, SWT.WRAP);
FillLayout layout = new FillLayout();
layout.marginWidth = INNER_MARGIN;
layout.marginHeight = INNER_MARGIN;
client.setLayout(layout);
section.setClient(client);
return client;
private Composite createSection(String title, String description,
boolean doSpan) {
Section section = toolkit.createSection(form.getBody(),
Section.DESCRIPTION | Section.TITLE_BAR);
section.setText(title);
section.setDescription(description);
GridData data = new GridData(GridData.FILL_BOTH);
data.widthHint = 200;
data.heightHint = 100;
if (doSpan)
data.horizontalSpan = 2;
section.setLayoutData(data);
// Composite for storing the data
Composite client = toolkit.createComposite(section, SWT.WRAP);
FillLayout layout = new FillLayout();
layout.marginWidth = INNER_MARGIN;
layout.marginHeight = INNER_MARGIN;
client.setLayout(layout);
section.setClient(client);
return client;
}
private void setupForm(Composite parent, String title) {
parent.setBackground(new Color(parent.getDisplay(), 255, 255, 255));
FillLayout fillLayout = new FillLayout();
fillLayout.marginWidth = OUTER_MARGIN;
fillLayout.marginHeight = OUTER_MARGIN;
fillLayout.marginWidth = OUTER_MARGIN;
fillLayout.marginHeight = OUTER_MARGIN;
parent.setLayout(fillLayout);
toolkit = new FormToolkit(parent.getDisplay());
form = toolkit.createScrolledForm(parent);
form.setText("CUP Parser Generator : " + title);
......@@ -77,25 +100,46 @@ public class CupOverviewView {
bodyLayout.numColumns = 2;
bodyLayout.marginTop = 20;
bodyLayout.makeColumnsEqualWidth = true;
form.getBody().setLayout(bodyLayout);
// form.getBody().setBackground(new Color(parent.getDisplay(), 255, 0, 0));
form.getBody().setLayout(bodyLayout);
// form.getBody().setBackground(new Color(parent.getDisplay(), 255, 0,
// 0));
}
public void dispose() {
toolkit.dispose();
}
public void willBecomeVisible() {
System.out.println("CupOverviewView will become visible.");
visible = true;
if (!Controller.getInstance(myEditor).requestJobRun()) {
// TODO: Handle no rerun!!
// Model model = Model.getInstanceForDocument(doc);
// LALRResult result = model.getLaLrResult();
// int numberOfStates = lalr_state.number(result.getContext());
}
// Model model = Model.getInstanceForDocument(doc);
// LALRResult result = model.getLaLrResult();
// int numberOfStates = lalr_state.number(result.getContext());
}
public void becameHidden() {
visible = false;
System.out.println("CupOverviewView became hidden.");
}
@Override
public EnumSet<JobsToDo> getRequiredJobs() {
return visible ? EnumSet.of(JobsToDo.buildTable, JobsToDo.parseCode)
: EnumSet.noneOf(JobsToDo.class);
}
@Override
public void modelChanged(Model model) {
System.out.println("ModelChangedEvent");
}
}
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