Commit ae73cb79 authored by Sebastian Pretscher's avatar Sebastian Pretscher

Some fixes for UI etc

parent 8419c9ac
......@@ -26,6 +26,10 @@ import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.ScrolledComposite;
import org.eclipse.swt.events.ControlAdapter;
import org.eclipse.swt.events.ControlEvent;
import org.eclipse.swt.events.MouseAdapter;
import org.eclipse.swt.events.MouseEvent;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.Device;
import org.eclipse.swt.graphics.Font;
......@@ -41,7 +45,9 @@ import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Link;
import org.eclipse.swt.widgets.Listener;
import org.eclipse.swt.widgets.ScrollBar;
import org.eclipse.zest.core.viewers.AbstractZoomableViewer;
import org.eclipse.zest.core.viewers.EntityConnectionData;
import org.eclipse.zest.core.viewers.GraphViewer;
......@@ -51,6 +57,7 @@ import org.eclipse.zest.core.viewers.IGraphEntityContentProvider;
import org.eclipse.zest.core.viewers.ISelfStyleProvider;
import org.eclipse.zest.core.viewers.IZoomableWorkbenchPart;
import org.eclipse.zest.core.viewers.internal.ZoomManager;
import org.eclipse.zest.core.widgets.Graph;
import org.eclipse.zest.core.widgets.GraphConnection;
import org.eclipse.zest.core.widgets.GraphNode;
import org.eclipse.zest.core.widgets.ZestStyles;
......@@ -69,6 +76,7 @@ import de.in.tum.www2.cup.CupContext;
import de.in.tum.www2.cup.LALRResult;
import de.in.tum.www2.cup.ReduceReduceConflict;
import de.in.tum.www2.cup.ShiftReduceConflict;
import de.in.tum.www2.cup.ast.Symbol;
import de.in.tum.www2.cup.internal.lalr_state;
import de.in.tum.www2.cup.internal.lalr_transition;
import de.tum.in.www2.cupplugin.Colors;
......@@ -96,7 +104,7 @@ public class CupConflictGraphView extends FailableView implements
private ParserConflictNodeModelContentProvider nodeModel;
private Composite graphComposite;
private Composite parentComposite;
private Label symbolLabel;
private Link symbolLabel;
private final ScrolledComposite scroll;
// private final Composite scrollSubContent;
......@@ -110,6 +118,7 @@ public class CupConflictGraphView extends FailableView implements
private boolean jumperTriggered = false;
private HashMap<Integer, lalr_state> stateHashMap;
List<CupConflictState> resultList;
private HashSet<lalr_state> visitedStates;
private ConflictResolutionManager conflictResolutionManager;
......@@ -159,14 +168,56 @@ public class CupConflictGraphView extends FailableView implements
scroll = new ScrolledComposite(this.parentComposite, SWT.BORDER
| SWT.V_SCROLL);
GridData data = new GridData(SWT.FILL, SWT.CENTER, true, false, 8, 1);
data.minimumHeight = 60;
data.heightHint = 60;
data.minimumHeight = 100;
data.heightHint = 100;
scroll.setLayoutData(data);
scroll.setLayout(new FillLayout());
scroll.setExpandHorizontal(true);
scroll.setExpandVertical(true);
graphViewer.getGraphControl().addMouseListener(new MouseAdapter() {
symbolLabel = new Label(scroll, SWT.WRAP);
@Override
public void mouseDoubleClick(MouseEvent e) {
Graph g = (Graph) graphViewer.getControl();
List<Object> selection = g.getSelection();
Object o = selection.get(selection.size() - 1);
if (o instanceof GraphConnection) {
GraphConnection con = (GraphConnection) o;
String[] nameComponents = con.getSource().getText()
.split(" ");
Symbol s = null;
int stateNumber = Integer.parseInt(nameComponents[1]);
for (CupConflictState cState : resultList) {
if (cState.getState().index() == stateNumber) {
s = cState.getTransition().on_symbol().getAstNode();
break;
}
}
if (s != null) {
jumper.jumpToEditorSelection(s.getRange());
}
}
}
});
symbolLabel = new Link(scroll, SWT.WRAP);
symbolLabel.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
int stateNumber = Integer.parseInt(e.text);
Symbol s = null;
for (CupConflictState cState : resultList) {
if (cState.getState().index() == stateNumber) {
s = cState.getTransition().on_symbol().getAstNode();
break;
}
}
jumper.jumpToEditorSelection(s.getRange());
}
});
// symbolLabel.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true,
// false, 1, 1));
// symbolLabel.setLayoutData(new GridData(SWT.LEFT, SWT.BOTTOM, true,
......@@ -399,17 +450,27 @@ public class CupConflictGraphView extends FailableView implements
} else {
conflictResolutionManager.setUseDijkstar(true);
}
List<CupConflictState> resultList = conflictResolutionManager
.searchForState(state);
resultList = conflictResolutionManager.searchForState(state);
if (resultList != null) {
String resultString = "";
for (CupConflictState n : resultList) {
if (n.getSuccessor() != null) {
resultString += "From: State " + n.getState().index()
+ " to: State "
+ n.getSuccessor().getState().index()
+ " with Transition: "
+ n.getTransition().on_symbol().toString() + "\n";
if (n.getTransition().on_symbol().getAstNode() != null) {
resultString += "From: State " + n.getState().index()
+ " to: State "
+ n.getSuccessor().getState().index()
+ " with Transition: " + "<a href=\""
+ n.getState().index() + "\">"
+ n.getTransition().on_symbol().toString()
+ "</a>\n";
} else {
resultString += "From: State " + n.getState().index()
+ " to: State "
+ n.getSuccessor().getState().index()
+ " with Transition: "
+ n.getTransition().on_symbol().toString()
+ "\n";
}
}
}
symbolLabel.setText(resultString);
......
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