Commit aadaf51b authored by Johannes Roith's avatar Johannes Roith

Layout now works.

parent 10e8154b
......@@ -34,7 +34,8 @@ import de.tum.in.www2.cupplugin.model.ICupStatisticsChangeObserver;
import de.tum.in.www2.cupplugin.model.Model;
public class CupOverviewView extends FailableView
implements IRegisterForControllerChanges,
implements
//IRegisterForControllerChanges,
ICupEditorPageVisibility,
ICupParserLaLrChangeObserver,
ICupParserASTChangeObserver,
......@@ -67,16 +68,11 @@ public class CupOverviewView extends FailableView
}
}
private static final int ERROR_ROW = 2;
private static final int ERROR_ROW = 0;
private static final int OUTER_MARGIN = 10;
private static final int INNER_MARGIN = 10;
private static final String SECTION_ANALYSIS = "Analysis";
private static final String SECTION_ANALYSIS_DESCRIPTION_TEMPLATE =
"Redundant Productions\t\t%5d\n"
+ "Unused terminals\t\t%5d\n"
+ "Unused non terminals:\t\t%d";
private static final String SECTION_PARSE_TABLES = "Parse Tables";
private static final String SECTION_PARSE_TABLES_DESCRIPTION_TEMPLATE = "last created, up2date, number of states, number of entries";
private static final String SECTION_CONTENT = "Content";
......@@ -103,11 +99,10 @@ public class CupOverviewView extends FailableView
setupForm(parent, title);
this.editor = editor;
Controller.getInstance(editor).registerObserver(this);
// Controller.getInstance(editor).registerObserver(this);
Model.getInstanceForDocument(doc).registerModelObserver(this);
analysisSection = createTableSection(SECTION_ANALYSIS,
SECTION_ANALYSIS_DESCRIPTION_TEMPLATE, false, 10);
analysisSection = createTableSection("Analysis", "", false, 3);
analysisSection.getSecond().setRowLabel(ERROR_ROW, "Errors:");
......@@ -122,26 +117,31 @@ public class CupOverviewView extends FailableView
}
private Pair<Composite,SimpleTable> createTableSection(String title, String description, boolean doSpan, int rowCount) {
Composite section = createSection(title, description, doSpan);
Pair<Composite,Section> pair = createSection(title, description, doSpan);
Composite sectionComp = pair.getFirst();
Section section = pair.getSecond();
SimpleTable tbl = new SimpleTable();
GridLayout gl = new GridLayout();
gl.numColumns = 2;
section.setLayout(gl);
sectionComp.setLayout(gl);
for (int i=0; i < rowCount; i++) {
Label label = new Label(section, SWT.NONE);
Label label = new Label(sectionComp, SWT.NONE);
label.setText("TODO");
Label val = new Label(section, SWT.NONE);
Label val = new Label(sectionComp, SWT.NONE);
val.setText("TODO");
tbl.addRow(label, val);
}
return new Pair<Composite,SimpleTable>(section, tbl);
// section.layout(); // TODO: required!
return new Pair<Composite,SimpleTable>(sectionComp, tbl);
}
private Composite createSection(String title, String description,
private Pair<Composite,Section> createSection(String title, String description,
boolean doSpan) {
Section section = toolkit.createSection(form.getBody(),
Section.DESCRIPTION | Section.TITLE_BAR);
......@@ -150,7 +150,6 @@ public class CupOverviewView extends FailableView
GridData data = new GridData(GridData.FILL_BOTH);
data.widthHint = 200;
data.heightHint = 100;
if (doSpan)
data.horizontalSpan = 2;
section.setLayoutData(data);
......@@ -162,7 +161,7 @@ public class CupOverviewView extends FailableView
layout.marginHeight = INNER_MARGIN;
client.setLayout(layout);
section.setClient(client);
return client;
return new Pair<Composite, Section>(client, section);
}
private void setupForm(Composite parent, String title) {
......@@ -191,21 +190,13 @@ public class CupOverviewView extends FailableView
public void willBecomeVisible() {
System.out.println("CupOverviewView will become visible.");
visible = true;
if (!Controller.getInstance(editor).requestJobRun()) {
// TODO: Handle no rerun!!
}
// 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() {
// we never request jobs ourselves.
......@@ -214,9 +205,9 @@ public class CupOverviewView extends FailableView
@Override
public void jobStatusChanged(JobStatus status) {
// TODO Auto-generated method stub
// do nothing
}
*/
private void updateStatistics(Statistics statistics) {
if (statistics == null)
return;
......@@ -227,15 +218,7 @@ public class CupOverviewView extends FailableView
public void modelChanged(Model model) {
if (model == null)
return;
updateStatistics(model.getStatistics());
ParserResult astModel = model.getAstModel();
if(astModel == null){
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