Commit 66b17ae3 authored by Johannes Roith's avatar Johannes Roith

Fix link bug, improve colors.

parent 3a681055
......@@ -35,6 +35,11 @@ public class Colors {
public static final RGB stateRed = new RGB (232, 196, 196);
public static final RGB stateYellow = new RGB (218, 214, 155);
public static final RGB stateBrightYellow = new RGB (241, 237, 122);
public static final RGB conflictBgBlue = new RGB (231, 244, 247);
public static final RGB conflictFgBlue = new RGB (17, 62, 91);
public static final RGB conflictBgYellow = new RGB (247, 247, 231);
public static final RGB conflictFgYellow = new RGB (91, 71, 17);
......
......@@ -64,14 +64,24 @@ public class CupConflictsView implements ICupEditorPageVisibility,
private Link detailText;
private List<Range> links = new ArrayList<Range>();
private Color backgroundColorReduce;
private Color foregroundColorReduce;
private Color backgroundColorShift;
private Color foregroundColorShift;
public ConflictPanel(Composite parent, int style) {
super(parent, style);
backgroundColorReduce = new Color(Display.getCurrent(), Colors.conflictBgBlue);
foregroundColorReduce = new Color(Display.getCurrent(), Colors.conflictFgBlue);
backgroundColorShift = new Color(Display.getCurrent(), Colors.conflictBgYellow);
foregroundColorShift = new Color(Display.getCurrent(), Colors.conflictFgYellow);
GridData data = new GridData(SWT.FILL, SWT.FILL, true, false);
data.grabExcessHorizontalSpace = true;
data.widthHint = 100; // Do not remove. This is a bugfix. :-)
data.heightHint = 80;
setLayoutData(data);
setBackground(new Color(Display.getCurrent(), Colors.lightGray));
TableWrapLayout layout = new TableWrapLayout();
layout.numColumns = 3;
......@@ -83,9 +93,8 @@ public class CupConflictsView implements ICupEditorPageVisibility,
fD[0].setHeight(14);
conflictTypeLabel.setFont( new Font(Display.getCurrent(),fD[0]));
this.stateLabel = new Label(this, SWT.NONE);
this.symbolLabel = new Label(this, SWT.NONE);
this.stateLabel = new Label(this, SWT.NONE);
this.detailText = new Link(this, SWT.WRAP);
this.detailText.setBackground(new Color(Display.getCurrent(),
......@@ -94,8 +103,6 @@ public class CupConflictsView implements ICupEditorPageVisibility,
TableWrapData td = new TableWrapData();
td.colspan = 1;
detailText.setLayoutData(td);
detailText.setBackground(new Color(Display.getCurrent(),
Colors.lightGray));
detailText.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
......@@ -106,6 +113,12 @@ public class CupConflictsView implements ICupEditorPageVisibility,
});
}
private void changeColors(Color background, Color foreground) {
setBackground(background);
detailText.setBackground(background);
conflictTypeLabel.setForeground(foreground);
}
public void update(Conflict conflict) {
links.clear();
int linkCounter = 0;
......@@ -114,7 +127,7 @@ public class CupConflictsView implements ICupEditorPageVisibility,
if (conflict instanceof ReduceReduceConflict) {
ReduceReduceConflict rrc = (ReduceReduceConflict) conflict;
changeColors(backgroundColorReduce, foregroundColorReduce);
conflictTypeLabel.setText("Reduce-Reduce conflict");
ProductionRight conflict1Ast = rrc.getConflictItem1()
......@@ -167,7 +180,7 @@ public class CupConflictsView implements ICupEditorPageVisibility,
} else if (conflict instanceof ShiftReduceConflict) {
ShiftReduceConflict src = (ShiftReduceConflict) conflict;
changeColors(backgroundColorShift, foregroundColorShift);
conflictTypeLabel.setText("Shift-Reduce conflict");
symbolLabel.setText("Under symbol: " + src.getTerminal().name());
......@@ -199,7 +212,7 @@ public class CupConflictsView implements ICupEditorPageVisibility,
.getAstNode();
if (conflict2ItemAst != null) {
builder.append("<a href=\"" + linkCounter++ + "\">");
links.add(conflict1Ast.getRange());
links.add(conflict2ItemAst.getRange());
}
try {
builder.append(item.to_simple_string());
......
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