Commit b771524c authored by Johannes Roith's avatar Johannes Roith

Rename interface.

parent 94502fbd
......@@ -80,7 +80,7 @@ public class CupContext
public ErrorManager getErrorManager() {
return errorManager;
}
public ConflictManager getConflictManager() {
return conflictManager;
}
......
......@@ -30,13 +30,12 @@ public class LALRResult {
public parse_reduce_table getReduceTable() {
return reduce_table;
}
private LALRResult(CupContext context) {
this.context = context;
}
public static LALRResult Compute (CupContext context, production start_production) throws internal_error {
LALRResult result = new LALRResult(context);
non_terminal.compute_nullability(context);
......
......@@ -103,8 +103,7 @@ public class MultiPageEditor extends MultiPageEditorPart implements
void createConflictsPage(Jumper jumper) {
Composite composite = new Composite(getContainer(), SWT.NONE);
IDocument doc = editor.getDocument();
conflictsView = new CupConflictsView(composite, jumper, doc);
conflictsView = new CupConflictsView(composite, jumper, editor);
addPage(CONFLICTS_PAGE_INDEX, composite);
setPageText(CONFLICTS_PAGE_INDEX, "Conflicts");
}
......
......@@ -2,6 +2,6 @@ package de.tum.in.www2.cupplugin.model;
public interface ICupParserLaLrChangeObserver {
public void ModelChange(Model model);
public void modelChanged(Model model);
}
......@@ -123,7 +123,7 @@ public class Model {
this.lalrContext = lalrContext;
for(Object observer : modelObservers) {
if (observer instanceof ICupParserLaLrChangeObserver) {
((ICupParserLaLrChangeObserver)observer).ModelChange(this);
((ICupParserLaLrChangeObserver)observer).modelChanged(this);
}
}
//System.out.println(lalrModel.getReduceTable().toString());
......
......@@ -86,7 +86,7 @@ public class CupActionTableView implements ICupEditorPageVisibility,
System.out.println("CupActionTableView will become visible.");
isVisible = true;
if (!Controller.getInstance(editor).requestJobRun()) {
ModelChange(Model.getInstanceForDocument(doc));
modelChanged(Model.getInstanceForDocument(doc));
}
}
......@@ -106,7 +106,7 @@ public class CupActionTableView implements ICupEditorPageVisibility,
}
@Override
public void ModelChange(Model model) {
public void modelChanged(Model model) {
if (!isVisible) {
return;
}
......
......@@ -267,7 +267,7 @@ public class CupConflictGraphView implements ICupParserLaLrChangeObserver,
}
@Override
public void ModelChange(Model model) {
public void modelChanged(Model model) {
if (!isVisible) {
return;
}
......@@ -421,7 +421,7 @@ public class CupConflictGraphView implements ICupParserLaLrChangeObserver,
// TODO: Handle no rerun!!
IDocument doc = editor.getDocumentProvider().getDocument(
editor.getEditorInput());
ModelChange(Model.getInstanceForDocument(doc));
modelChanged(Model.getInstanceForDocument(doc));
}
}
......
package de.tum.in.www2.cupplugin.views;
import java.util.ArrayList;
import java.util.EnumSet;
import java.util.List;
import org.eclipse.jface.text.IDocument;
......@@ -13,17 +14,30 @@ import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Display;
import de.in.tum.www2.cup.ConflictManager;
import de.in.tum.www2.cup.LALRResult;
import de.in.tum.www2.cup.ast.ParserResult;
import de.tum.in.www2.cupplugin.Colors;
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.ICupParserLaLrChangeObserver;
import de.tum.in.www2.cupplugin.model.Model;
public class CupConflictsView {
public class CupConflictsView implements ICupEditorPageVisibility,
ICupParserLaLrChangeObserver, IRegisterForControllerChanges {
private static final int OUTER_MARGIN = 10; // TODO: share between panels.
private Jumper jumper;
private CupTextEditor editor;
private boolean isVisible;
private List<ConflictPanel> conflictPanels;
private ScrolledComposite scrolled;
private Composite list;
static class ConflictPanel extends Composite {
public ConflictPanel(Composite parent, int style) {
......@@ -36,10 +50,14 @@ public class CupConflictsView {
}
}
public CupConflictsView(Composite parent, Jumper jumper, IDocument doc) {
public CupConflictsView(Composite parent, Jumper jumper, CupTextEditor editor) {
this.editor = editor;
this.jumper = jumper;
this.conflictPanels = new ArrayList<ConflictPanel> ();
Controller.getInstance(editor).registerObserver(this);
Model.getInstanceForDocument(editor.getDocument()).registerModelObserver(this);
parent.setBackground(new Color(parent.getDisplay(), Colors.white));
FillLayout fillLayout = new FillLayout();
fillLayout.marginWidth = OUTER_MARGIN;
......@@ -59,11 +77,23 @@ public class CupConflictsView {
gl.makeColumnsEqualWidth = true;
list.setLayout(gl);
for (int i=0; i < 100; i++) {
conflictPanels.add (new ConflictPanel(list, SWT.NONE));
refreshScrolledLayout ();
}
private void matchPanelNumber(int number) {
int excessPanels = number - this.conflictPanels.size();
if (excessPanels > 0) {
// TODO!
// for (int i=0; i < excessPanels; i++)
// this.conflictPanels.remove(0);
} else {
while (this.conflictPanels.size() < number) {
conflictPanels.add (new ConflictPanel(list, SWT.NONE));
}
}
refreshScrolledLayout ();
System.out.println("conflictPanels size: " + this.conflictPanels.size());
}
private void refreshScrolledLayout() {
......@@ -75,15 +105,52 @@ public class CupConflictsView {
System.out.println("CupConflictsView disposed!");
}
@Override
public void willBecomeVisible() {
System.out.println("CupConflictsView will become visible.");
this.isVisible = true;
if (!Controller.getInstance(editor).requestJobRun()) {
// TODO: Handle no rerun!!
System.out.println("NO RERUN!!!");
Model model = Model.getInstanceForDocument(editor.getDocument());
LALRResult result = model.getLaLrResult();
ConflictManager cm = result.getContext().getConflictManager();
matchPanelNumber(cm.getConflicts().size());
}
}
@Override
public void becameHidden() {
this.isVisible = false;
System.out.println("CupConflictsView became hidden.");
}
@Override
public EnumSet<JobsToDo> getRequiredJobs() {
EnumSet<JobsToDo> requestedJobs = EnumSet.noneOf(JobsToDo.class);
if (isVisible) {
requestedJobs = EnumSet.of(JobsToDo.buildTable);
}
return requestedJobs;
}
@Override
public void modelChanged(Model model) {
System.out.println("MODEL CHANGED !!!!!!!!!!!");
LALRResult result = model.getLaLrResult();
if (result != null) {
ConflictManager cm = result.getContext().getConflictManager();
matchPanelNumber(cm.getConflicts().size());
} else {
matchPanelNumber(0);
}
refreshScrolledLayout ();
}
}
......@@ -261,7 +261,7 @@ public class CupReduceGraphView implements ICupParserLaLrChangeObserver,
// TODO: Handle no rerun!!
IDocument doc = editor.getDocumentProvider().getDocument(
editor.getEditorInput());
ModelChange(Model.getInstanceForDocument(doc));
modelChanged(Model.getInstanceForDocument(doc));
}
}
......@@ -289,7 +289,7 @@ public class CupReduceGraphView implements ICupParserLaLrChangeObserver,
}
@Override
public void ModelChange(Model model) {
public void modelChanged(Model model) {
if (!isVisible) {
return;
}
......
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