Commit 3c807939 authored by Michael Schwarz's avatar Michael Schwarz 🤔
Browse files

resolution of connected conflicts can be aborted

parent dd6a0bab
...@@ -74,6 +74,7 @@ public class CupConflictsView extends FailableView implements ICupEditorPageVisi ...@@ -74,6 +74,7 @@ public class CupConflictsView extends FailableView implements ICupEditorPageVisi
private boolean isVisible; private boolean isVisible;
private List<ConflictPanel> conflictPanels; private List<ConflictPanel> conflictPanels;
private Label countConflictsLabel, connectedResolutionLabel; private Label countConflictsLabel, connectedResolutionLabel;
private Button connectedResolutionAbort;
private ScrolledComposite scrolled; private ScrolledComposite scrolled;
private Composite list; private Composite list;
...@@ -96,6 +97,10 @@ public class CupConflictsView extends FailableView implements ICupEditorPageVisi ...@@ -96,6 +97,10 @@ public class CupConflictsView extends FailableView implements ICupEditorPageVisi
public void add(terminal t){ public void add(terminal t){
terminals.add(t); terminals.add(t);
for(ConflictPanel c : conflictPanels){
c.markIfAffected(this);
}
} }
} }
...@@ -494,15 +499,24 @@ public class CupConflictsView extends FailableView implements ICupEditorPageVisi ...@@ -494,15 +499,24 @@ public class CupConflictsView extends FailableView implements ICupEditorPageVisi
resolutionButton.setEnabled(false); resolutionButton.setEnabled(false);
} }
else { else {
if(conflict instanceof ShiftReduceConflict){
resolutionButton.setEnabled(false); resolutionButton.setEnabled(false);
resolutionOptions.setEnabled(false); resolutionOptions.setEnabled(false);
if(conflict instanceof ShiftReduceConflict){
changeColors(backgroundColorShiftReduceUnrelated,foregroundColorShiftReduceUnrelated); changeColors(backgroundColorShiftReduceUnrelated,foregroundColorShiftReduceUnrelated);
} }
} }
} }
public void connectedEditAborted(){
if(conflict instanceof ShiftReduceConflict){
resolutionButton.setEnabled(true);
resolutionOptions.setEnabled(true);
resolutionOptions.select(0);
changeColors(backgroundColorShiftReduce,foregroundColorShiftReduce);
}
}
// replace (*) generated by CUP with BULLET U+2022 • // replace (*) generated by CUP with BULLET U+2022 •
private String prettyString(lalr_item item) throws internal_error { private String prettyString(lalr_item item) throws internal_error {
return item.toString().replace("(*)", "\u2022"); return item.toString().replace("(*)", "\u2022");
...@@ -530,11 +544,6 @@ public class CupConflictsView extends FailableView implements ICupEditorPageVisi ...@@ -530,11 +544,6 @@ public class CupConflictsView extends FailableView implements ICupEditorPageVisi
if(srdetails.shiftAffectsOthers && resolutionOptions.getSelectionIndex() == 1){ if(srdetails.shiftAffectsOthers && resolutionOptions.getSelectionIndex() == 1){
beginConnectedResolution(); beginConnectedResolution();
currentPrecs.add(srdetails.shift); currentPrecs.add(srdetails.shift);
for(ConflictPanel c : conflictPanels){
c.markIfAffected(currentPrecs);
}
return; return;
} }
...@@ -595,6 +604,22 @@ public class CupConflictsView extends FailableView implements ICupEditorPageVisi ...@@ -595,6 +604,22 @@ public class CupConflictsView extends FailableView implements ICupEditorPageVisi
this.connectedResolutionLabel = new Label(list,SWT.NONE); this.connectedResolutionLabel = new Label(list,SWT.NONE);
this.connectedResolutionLabel.setBackground(new Color(Display.getCurrent(), Colors.white)); this.connectedResolutionLabel.setBackground(new Color(Display.getCurrent(), Colors.white));
this.connectedResolutionAbort = new Button(list,SWT.PUSH);
this.connectedResolutionAbort.setVisible(false);
this.connectedResolutionAbort.setText("Abort");
this.connectedResolutionAbort.addSelectionListener(new SelectionListener() {
@Override
public void widgetSelected(SelectionEvent e) {
abortConnectedResolution();
}
@Override
public void widgetDefaultSelected(SelectionEvent e) {
}
});
refreshScrolledLayout(); refreshScrolledLayout();
} }
...@@ -700,6 +725,7 @@ public class CupConflictsView extends FailableView implements ICupEditorPageVisi ...@@ -700,6 +725,7 @@ public class CupConflictsView extends FailableView implements ICupEditorPageVisi
} }
} }
private void beginConnectedResolution(){ private void beginConnectedResolution(){
Shell shell = new Shell(Display.getCurrent()); Shell shell = new Shell(Display.getCurrent());
MessageBox box = new MessageBox(shell,SWT.ICON_WARNING | SWT.OK); MessageBox box = new MessageBox(shell,SWT.ICON_WARNING | SWT.OK);
...@@ -710,6 +736,19 @@ public class CupConflictsView extends FailableView implements ICupEditorPageVisi ...@@ -710,6 +736,19 @@ public class CupConflictsView extends FailableView implements ICupEditorPageVisi
currentPrecs = new PrecedenceToInsert(); currentPrecs = new PrecedenceToInsert();
this.connectedResolutionLabel.setText("Currently resolving a set of conflicts that are connected."); this.connectedResolutionLabel.setText("Currently resolving a set of conflicts that are connected.");
this.connectedResolutionAbort.setVisible(true);
refreshScrolledLayout();
}
private void abortConnectedResolution(){
currentPrecs = new PrecedenceToInsert();
this.connectedResolutionLabel.setText("");
this.connectedResolutionAbort.setVisible(false);
for(ConflictPanel c : conflictPanels){
c.connectedEditAborted();
}
refreshScrolledLayout(); refreshScrolledLayout();
} }
......
Supports Markdown
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