Commit d79cbbb9 authored by Sebastian Pretscher's avatar Sebastian Pretscher

Some refinements/fixes etc

parent d9735492
......@@ -11,8 +11,6 @@ Require-Bundle: org.eclipse.ui,
org.eclipse.core.resources,
org.eclipse.ui.editors,
org.eclipse.ui.ide,
org.eclipse.zest.core;bundle-version="1.5.100",
org.eclipse.zest.layouts;bundle-version="1.1.100",
CupReferencedLibraries;bundle-version="1.0.0",
org.eclipse.ui.views;bundle-version="3.7.0",
org.eclipse.core.expressions;bundle-version="3.4.600",
......@@ -24,7 +22,9 @@ Require-Bundle: org.eclipse.ui,
org.eclipse.jdt.ui;bundle-version="3.10.1",
org.eclipse.ant.core;bundle-version="3.3.0",
org.eclipse.text,
org.eclipse.ui.forms;bundle-version="3.6.100"
org.eclipse.ui.forms;bundle-version="3.6.100",
org.eclipse.zest.core;bundle-version="1.5.100",
org.eclipse.zest.layouts;bundle-version="1.1.100"
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Bundle-ActivationPolicy: lazy
Bundle-ClassPath: .
......@@ -90,7 +90,7 @@ public class MultiPageEditor extends MultiPageEditorPart implements
Composite composite = new Composite(getContainer(), SWT.NONE);
graphReduceView = new CupReduceGraphView(composite, jumper, getEditor());
int index = addPage(composite);
setPageText(index, "Automaton View (costly)");
setPageText(index, "Automaton View (expensive)");
}
void createOverviewPage(Jumper jumper) {
......
......@@ -53,10 +53,14 @@ import org.eclipse.zest.layouts.algorithms.GridLayoutAlgorithm;
import org.eclipse.zest.layouts.algorithms.HorizontalShift;
import org.eclipse.zest.layouts.algorithms.SpringLayoutAlgorithm;
import de.in.tum.www2.cup.Conflict;
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.internal.lalr_state;
import de.in.tum.www2.cup.internal.lalr_transition;
import de.tum.in.www2.cupplugin.Colors;
import de.tum.in.www2.cupplugin.controller.Controller;
import de.tum.in.www2.cupplugin.controller.Controller.JobsToDo;
import de.tum.in.www2.cupplugin.controller.IRegisterForControllerChanges;
......@@ -126,7 +130,8 @@ public class CupConflictGraphView implements ICupParserLaLrChangeObserver,
ParserConflictLabelProvider labelProvider = new ParserConflictLabelProvider(
nodeModel.getConnections());
graphViewer.setLabelProvider(labelProvider);
//graphViewer.getGraphControl().setNodeStyle(ZestStyles.NODES_NO_ANIMATION);
graphViewer.setNodeStyle(ZestStyles.NODES_NO_ANIMATION);
graphViewer.setInput(nodeModel.getNodes());
// Setup search Result Label
......@@ -305,6 +310,13 @@ public class CupConflictGraphView implements ICupParserLaLrChangeObserver,
CupContext lalrContext = model.getLaLrContext();
lalr_state.lalr_state_shared sharedState = lalr_state
.getShared(lalrContext);
List<Conflict> allInterstingConflicts = new LinkedList<Conflict>();
for (Conflict conf:lalrContext.getConflictManager().getConflicts()) {
if(conf instanceof ShiftReduceConflict || conf instanceof ReduceReduceConflict) {
allInterstingConflicts.add(conf);
}
}
Enumeration allEnum = sharedState.all();
while (allEnum.hasMoreElements()) {
......@@ -314,9 +326,15 @@ public class CupConflictGraphView implements ICupParserLaLrChangeObserver,
}
}
// TODO: This should only contain tainted states!!
List<String> stateNames = new ArrayList<String>();
for (lalr_state state : stateHashMap.values()) {
stateNames.add("State: " + state.index());
for (Conflict conf:allInterstingConflicts) {
lalr_state state = conf.getState();
if(conf instanceof ShiftReduceConflict) {
stateNames.add("SR:State: "+state.index());
} else if(conf instanceof ReduceReduceConflict) {
stateNames.add("RR:State: "+state.index());
}
}
nodeSelection.setItems(stateNames.toArray(new String[0]));
if (nodeSelectionListener != null) {
......@@ -365,7 +383,6 @@ public class CupConflictGraphView implements ICupParserLaLrChangeObserver,
LayoutStyles.NO_LAYOUT_NODE_RESIZING) });
graphViewer.setLayoutAlgorithm(layout, true);
graphViewer.applyLayout();
graphViewer.refresh();
String resultString = "";
for (ParserConflictNode n:nodeModel.getNodes()) {
......@@ -420,6 +437,9 @@ public class CupConflictGraphView implements ICupParserLaLrChangeObserver,
Rectangle r = scroll.getClientArea();
scroll.setMinSize(symbolLabel.computeSize(r.width, SWT.DEFAULT));
}
if(zoomManager!=null) {
zoomManager.setZoomAsText("Page");
}
}
private HashMap<Integer, DijkstraNode> dijkstraSearch() {
......@@ -850,8 +870,7 @@ public class CupConflictGraphView implements ICupParserLaLrChangeObserver,
@Override
public Color getNodeHighlightColor(Object entity) {
Device device = Display.getCurrent();
return device.getSystemColor(SWT.COLOR_BLUE);
return new Color(Display.getCurrent(), Colors.stateBrightYellow);
}
@Override
......@@ -875,11 +894,9 @@ public class CupConflictGraphView implements ICupParserLaLrChangeObserver,
&& entity instanceof ParserConflictNode) {
ParserConflictNode n = (ParserConflictNode) entity;
if (showColordStartState && n.id == 0) {
Device device = Display.getCurrent();
return device.getSystemColor(SWT.COLOR_RED);
return new Color(Display.getCurrent(), Colors.stateGreen);
} else if (showColordEndStates && n.getConnectedTo().isEmpty()) {
Device device = Display.getCurrent();
return device.getSystemColor(SWT.COLOR_GREEN);
return new Color(Display.getCurrent(), Colors.stateRed);
}
return null;
}
......@@ -888,7 +905,7 @@ public class CupConflictGraphView implements ICupParserLaLrChangeObserver,
@Override
public Color getForegroundColour(Object entity) {
return null;
return new Color(Display.getCurrent(), Colors.darkGray);
}
@Override
......
......@@ -27,7 +27,10 @@ import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.viewers.ArrayContentProvider;
import org.eclipse.jface.viewers.LabelProvider;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.jface.viewers.ViewerFilter;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.MouseAdapter;
import org.eclipse.swt.events.MouseEvent;
import org.eclipse.swt.events.MouseTrackAdapter;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.Device;
......@@ -105,6 +108,7 @@ public class CupReduceGraphView implements ICupParserLaLrChangeObserver,
private boolean isVisible = false;
private boolean shouldRebuildWhenVisible = false;
private BuildUpNodeFilter nodeFilter;
private CupTextEditor editor;
......@@ -134,8 +138,14 @@ public class CupReduceGraphView implements ICupParserLaLrChangeObserver,
nodeModel.getConnections());
graphViewer.setLabelProvider(labelProvider);
nodeFilter = new BuildUpNodeFilter(new LinkedList<ParserReduceNode>(nodeModel.getNodes()));
ViewerFilter[] filters = new ViewerFilter[1];
filters[0] = nodeFilter;
graphViewer.setFilters(filters);
// graphViewer.setConnectionStyle(ZestStyles.CONNECTIONS_DIRECTED);
//graphViewer.getGraphControl().setNodeStyle(ZestStyles.NODES_NO_ANIMATION);
graphViewer.setNodeStyle(ZestStyles.NODES_NO_ANIMATION);
graphViewer.setInput(nodeModel.getNodes());
LayoutAlgorithm layout = new CompositeLayoutAlgorithm(
......@@ -149,6 +159,16 @@ public class CupReduceGraphView implements ICupParserLaLrChangeObserver,
graphViewer.setLayoutAlgorithm(layout, true);
graphViewer.applyLayout();
graphViewer.getGraphControl().addMouseListener(new MouseAdapter() {
@Override
public void mouseDoubleClick(MouseEvent e) {
System.out.println("Double Click: "+e+" "+e.widget.getClass());
}
});
// Setup Buttons to enable/disable some features
Button labelDisplayButton = new Button(this.parentComposite, SWT.CHECK);
labelDisplayButton.setText("Show labels");
......@@ -286,11 +306,18 @@ public class CupReduceGraphView implements ICupParserLaLrChangeObserver,
new HorizontalShift(
LayoutStyles.NO_LAYOUT_NODE_RESIZING) });
}
graphViewer.setLayoutAlgorithm(layout, true);
graphViewer.applyLayout();
synchronized (CupReduceGraphView.modelBuildLock) {
nodeFilter.getNodeList().clear();
nodeFilter.getNodeList().addAll(nodeModel.getNodes());
graphViewer.refresh();
}
graphViewer.setLayoutAlgorithm(layout, true);
graphViewer.applyLayout();
if(zoomManager!=null) {
zoomManager.setZoomAsText("Page");
}
}
@Override
......@@ -870,6 +897,37 @@ public class CupReduceGraphView implements ICupParserLaLrChangeObserver,
}
static class BuildUpNodeFilter extends ViewerFilter {
private List<ParserReduceNode> nodeList;
public BuildUpNodeFilter(List<ParserReduceNode> nodeList) {
this.nodeList = nodeList;
}
@Override
public boolean select(Viewer viewer, Object parentElement,
Object element) {
if (element instanceof ParserReduceNode) {
if (nodeList.contains(element)) {
return true;
} else {
return false;
}
}
return true;
}
public List<ParserReduceNode> getNodeList() {
return nodeList;
}
public void setNodeList(List<ParserReduceNode> nodeList) {
this.nodeList = nodeList;
}
}
@Override
public AbstractZoomableViewer getZoomableViewer() {
return getGraphViewer();
......
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