Commit 6c69f21c authored by Johannes Roith's avatar Johannes Roith

show state index.

parent 9cbcef27
......@@ -7,6 +7,10 @@ public abstract class Conflict
{
private lalr_state state;
public lalr_state getState() {
return state;
}
public Conflict(lalr_state state) {
this.state = state;
}
......
......@@ -45,6 +45,7 @@ ICupParserLaLrChangeObserver, IRegisterForControllerChanges {
static class ConflictPanel extends Composite {
private Label conflictTypeLabel;
private Label stateLabel;
public ConflictPanel(Composite parent, int style) {
super(parent, style);
......@@ -60,6 +61,7 @@ ICupParserLaLrChangeObserver, IRegisterForControllerChanges {
setLayout(layout);
this.conflictTypeLabel = new Label(this, SWT.NONE);
this.stateLabel = new Label(this, SWT.NONE);
}
......@@ -71,6 +73,8 @@ ICupParserLaLrChangeObserver, IRegisterForControllerChanges {
} else {
throw new RuntimeException("unexpected conflict type.");
}
stateLabel.setText("State: " + conflict.getState().index());
}
}
......@@ -92,7 +96,7 @@ ICupParserLaLrChangeObserver, IRegisterForControllerChanges {
this.scrolled = new ScrolledComposite(parent, SWT.V_SCROLL);
this.scrolled.setExpandHorizontal(true);
this.scrolled.setExpandVertical(true);
list = new Composite(scrolled, SWT.NONE);
list.setBackground(new Color(Display.getCurrent(), Colors.white));
scrolled.setContent(list);
......@@ -115,13 +119,12 @@ ICupParserLaLrChangeObserver, IRegisterForControllerChanges {
}
refreshScrolledLayout ();
}
private void matchPanelNumber(int number) {
int excessPanels = this.conflictPanels.size() - number;
if (excessPanels > 0) {
// TODO!
// for (int i=0; i < excessPanels; i++)
// this.conflictPanels.remove(0);
for (int i=0; i < excessPanels; i++)
this.conflictPanels.remove(0);
} else {
while (this.conflictPanels.size() < number) {
conflictPanels.add (new ConflictPanel(list, SWT.NONE));
......@@ -131,7 +134,7 @@ ICupParserLaLrChangeObserver, IRegisterForControllerChanges {
System.out.println("conflictPanels size: " + this.conflictPanels.size());
}
private void refreshScrolledLayout() {
scrolled.layout(true, true);
scrolled.setMinSize(list.computeSize(SWT.DEFAULT, SWT.DEFAULT));
......@@ -140,21 +143,17 @@ ICupParserLaLrChangeObserver, IRegisterForControllerChanges {
public void dispose() {
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!!!");
System.out.println("NO RERUN!!!"); // TODO
Model model = Model.getInstanceForDocument(editor.getDocument());
LALRResult result = model.getLaLrResult();
if (result != null) {
ConflictManager cm = result.getContext().getConflictManager();
updateConflicts(cm.getConflicts());
// TODO: update conflicts
}
}
}
......@@ -162,34 +161,23 @@ ICupParserLaLrChangeObserver, IRegisterForControllerChanges {
@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) {
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) {
System.out.println("IF CASE!!!"); // TODO
ConflictManager cm = result.getContext().getConflictManager();
System.out.println("MANAGER: " + cm + " SIZE: " + cm.getConflicts().size());
updateConflicts(cm.getConflicts());
// TODO: update conflicts
} else {
System.out.println("ELSE CASE!!!"); // TODO
matchPanelNumber(0);
}
}
......
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