Commit 06efb9ec authored by Johannes Roith's avatar Johannes Roith

Fix bug.

parent b08d42d6
......@@ -46,6 +46,7 @@ import de.tum.in.www2.cupplugin.model.Model;
public class CupConflictsView implements ICupEditorPageVisibility,
ICupParserLaLrChangeObserver, IRegisterForControllerChanges {
private static final int OUTER_MARGIN = 10; // TODO: share between panels.
private static final int INNER_MARGIN = 5;
private Jumper jumper;
private CupTextEditor editor;
......@@ -56,6 +57,7 @@ public class CupConflictsView implements ICupEditorPageVisibility,
class ConflictPanel extends Composite {
private static final int BASE_HEIGHT = 90;
private static final int COLUMNS = 3;
private static final int HEADING_FONT_SIZE = 14;
private static final int SIZE_INCREASE_PER_LINE = 8;
......@@ -66,6 +68,7 @@ public class CupConflictsView implements ICupEditorPageVisibility,
private Link stateLabel;
private Label symbolLabel;
private Composite detailWrapper;
private Link detailText;
private Label resolutionHint;
private List<Range> links = new ArrayList<Range>();
......@@ -88,7 +91,7 @@ public class CupConflictsView implements ICupEditorPageVisibility,
gridData = new GridData(SWT.FILL, SWT.FILL, true, false);
gridData.grabExcessHorizontalSpace = true;
gridData.widthHint = 100; // Do not remove. This is a bugfix. :-)
gridData.heightHint = 80;
gridData.heightHint = BASE_HEIGHT;
setLayoutData(gridData);
GridLayout gl = new GridLayout();
......@@ -120,7 +123,7 @@ public class CupConflictsView implements ICupEditorPageVisibility,
}
});
Composite detailWrapper = makeDetailWrapper(COLUMNS);
detailWrapper = makeDetailWrapper(COLUMNS);
this.detailText = new Link(detailWrapper, SWT.WRAP);
detailText.addSelectionListener(new SelectionAdapter() {
@Override
......@@ -132,6 +135,10 @@ public class CupConflictsView implements ICupEditorPageVisibility,
});
this.resolutionHint = new Label(this, SWT.NONE);
GridData resolutionHintData = new GridData();
resolutionHintData.grabExcessHorizontalSpace = true;
resolutionHintData.horizontalSpan = COLUMNS;
resolutionHint.setLayoutData(resolutionHintData);
}
private Composite makeDetailWrapper(int columns) {
......@@ -143,8 +150,8 @@ public class CupConflictsView implements ICupEditorPageVisibility,
detailWrapper.setLayoutData(detailTextData);
TableWrapLayout layout = new TableWrapLayout();
layout.bottomMargin = 0;
layout.topMargin = 0;
layout.bottomMargin = INNER_MARGIN;
layout.topMargin = INNER_MARGIN;
layout.leftMargin = 0;
layout.rightMargin = 0;
layout.makeColumnsEqualWidth = false;
......@@ -162,6 +169,7 @@ public class CupConflictsView implements ICupEditorPageVisibility,
stateLabel.setBackground(background);
symbolLabel.setBackground(background);
detailText.setBackground(background);
detailWrapper.setBackground(background);
}
private Pair<String,Integer> makeConflictResolutionHint(ConflictResolutionManager crm, lalr_state state) {
......@@ -186,14 +194,14 @@ public class CupConflictsView implements ICupEditorPageVisibility,
public void update(ConflictResolutionManager crm, Conflict conflict) {
this.conflict = conflict;
links.clear();
int linkCounter = 0;
lalr_state state = conflict.getState();
Pair<String,Integer> hint = makeConflictResolutionHint(crm, state);
resolutionHint.setText(hint.getFirst());
gridData.heightHint += hint.getSecond() * SIZE_INCREASE_PER_LINE;
gridData.heightHint = BASE_HEIGHT + hint.getSecond() * SIZE_INCREASE_PER_LINE;
int cindex = state.index();
stateLabel.setText("<a href=\"" + cindex + "\">State: " + cindex + "</a>");
......@@ -355,8 +363,11 @@ public class CupConflictsView implements ICupEditorPageVisibility,
private void matchPanelNumber(int number) {
int excessPanels = this.conflictPanels.size() - number;
if (excessPanels > 0) {
for (int i = 0; i < excessPanels; i++)
for (int i = 0; i < excessPanels; i++) {
this.conflictPanels.get(0).dispose();
this.conflictPanels.remove(0);
}
} else {
while (this.conflictPanels.size() < number) {
conflictPanels.add(new ConflictPanel(list, SWT.NONE));
......
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