Commit 5a82b4f4 authored by Benedikt Engeser's avatar Benedikt Engeser

Overview Templates

parent 0c73e62e
package de.tum.in.www2.cupplugin.views;
import java.sql.Time;
import java.util.EnumSet;
import java.util.HashSet;
import org.eclipse.jface.text.IDocument;
import org.eclipse.swt.SWT;
......@@ -13,6 +15,8 @@ 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.ErrorManager;
import de.in.tum.www2.cup.ast.ParserResult;
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;
......@@ -29,12 +33,27 @@ public class CupOverviewView implements IRegisterForControllerChanges,
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";
private static final String SECTION_CONTENT_DESCRIPTION_TEMPLATE = "start production, package, parser class, terminals, non-terminals";
private static final String SECTION_GRAMMAR = "Grammar";
private static final String SECTION_GRAMMAR_DESCRIPTION_TEMPLATE = "last checked, up2date, syntax correct";
private static final String SECTION_CONFLICTS = "Conflicts";
private static final String SECTION_CONFLICTS_DESCRIPTION_TEMPLATE = "Number of conflicts, etc.";
boolean visible = false;
private IDocument doc;
private FormToolkit toolkit;
private ScrolledForm form;
private CupTextEditor myEditor;
HashSet<Composite> sections = new HashSet<Composite>();
public CupOverviewView(Composite parent, Jumper jumper, IDocument doc,
String title, CupTextEditor editor) {
......@@ -45,20 +64,16 @@ public class CupOverviewView implements IRegisterForControllerChanges,
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);
sections.add(createSection(SECTION_ANALYSIS,
SECTION_ANALYSIS_DESCRIPTION_TEMPLATE, false));
sections.add(createSection(SECTION_PARSE_TABLES,
SECTION_PARSE_TABLES_DESCRIPTION_TEMPLATE, false));
sections.add(createSection(SECTION_CONTENT,
SECTION_CONTENT_DESCRIPTION_TEMPLATE, true));
sections.add(createSection(SECTION_GRAMMAR,
SECTION_GRAMMAR_DESCRIPTION_TEMPLATE, false));
sections.add(createSection(SECTION_CONFLICTS,
SECTION_CONFLICTS_DESCRIPTION_TEMPLATE, false));
}
private Composite createSection(String title, String description,
......@@ -136,10 +151,53 @@ public class CupOverviewView implements IRegisterForControllerChanges,
@Override
public void modelChanged(Model model) {
System.out.println("ModelChangedEvent");
if (model == null) {
return;
}
}
ParserResult astModel = model.getAstModel();
if(astModel == null){
return;
}
ErrorManager eManager = model.getAstModelContext().getErrorManager();
for (Composite e : sections) {
Section section = (Section) e.getParent();
switch (section.getText()) {
case SECTION_ANALYSIS:
int redundantProductions = 0;
int unusedTerminals = 0;
int unusedNonTerminals = 0;
section.setDescription(String.format(SECTION_ANALYSIS_DESCRIPTION_TEMPLATE,redundantProductions,unusedTerminals,unusedNonTerminals));
break;
case SECTION_CONFLICTS:
section.setDescription(String.format(SECTION_CONFLICTS_DESCRIPTION_TEMPLATE));
break;
case SECTION_CONTENT:
section.setDescription(String.format(SECTION_CONTENT_DESCRIPTION_TEMPLATE));
break;
case SECTION_GRAMMAR:
section.setDescription(String.format(SECTION_GRAMMAR_DESCRIPTION_TEMPLATE));
break;
case SECTION_PARSE_TABLES:
section.setDescription(String.format(SECTION_PARSE_TABLES_DESCRIPTION_TEMPLATE));
break;
default:
break;
}
}
}
}
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