Commit 6c8da780 authored by Benedikt Engeser's avatar Benedikt Engeser

Merge branch 'master' of git@github.com:jroith/cup-eclipse.git

parents 9662d760 0df20a3b
......@@ -17,9 +17,7 @@ public class Jumper {
}
public void jumpToConflictGraphState(ConflictType conflictType, int index) {
//PluginUtility.showMessage("Jumper: Jump to conflict graph state - not yet implemented!");
mpe.jumpTo(mpe.CONFLICT_GRAPH_PAGE_INDEX);
// TODO!
mpe.getConflictGraphView().showConflict(conflictType, index);
}
......
package de.tum.in.www2.cupplugin.views;
import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.ArrayList;
......@@ -16,6 +17,8 @@ import java.util.Stack;
import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.draw2d.IFigure;
import org.eclipse.draw2d.MarginBorder;
import org.eclipse.draw2d.geometry.Dimension;
import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.viewers.ArrayContentProvider;
import org.eclipse.jface.viewers.LabelProvider;
......@@ -25,6 +28,8 @@ import org.eclipse.swt.events.ControlAdapter;
import org.eclipse.swt.events.ControlEvent;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.Device;
import org.eclipse.swt.graphics.Font;
import org.eclipse.swt.graphics.FontData;
import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.layout.GridData;
......@@ -43,8 +48,11 @@ import org.eclipse.zest.core.viewers.GraphViewer;
import org.eclipse.zest.core.viewers.IEntityConnectionStyleProvider;
import org.eclipse.zest.core.viewers.IEntityStyleProvider;
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.GraphConnection;
import org.eclipse.zest.core.widgets.GraphNode;
import org.eclipse.zest.core.widgets.ZestStyles;
import org.eclipse.zest.layouts.LayoutAlgorithm;
import org.eclipse.zest.layouts.LayoutStyles;
......@@ -313,6 +321,12 @@ public class CupConflictGraphView implements ICupParserLaLrChangeObserver,
}
stateHashMap.clear();
CupContext lalrContext = model.getLaLrContext();
if (lalrContext == null) {
System.err.println("CupConflictGraphView: lalrResult was null.");
return;
}
lalr_state.lalr_state_shared sharedState = lalr_state
.getShared(lalrContext);
Enumeration allEnum = sharedState.all();
......@@ -450,7 +464,7 @@ public class CupConflictGraphView implements ICupParserLaLrChangeObserver,
int idx = 0;
for (String item : nodeSelection.getItems()) {
if(item.equals(itemString)) {
if (item.equals(itemString)) {
break;
} else {
idx++;
......@@ -621,7 +635,8 @@ public class CupConflictGraphView implements ICupParserLaLrChangeObserver,
}
static class ParserConflictLabelProvider extends LabelProvider implements
IEntityStyleProvider, IEntityConnectionStyleProvider {
IEntityStyleProvider, IEntityConnectionStyleProvider,
ISelfStyleProvider {
private List<ParserConflictConnection> connections;
......@@ -742,6 +757,53 @@ public class CupConflictGraphView implements ICupParserLaLrChangeObserver,
public int getLineWidth(Object src, Object dest) {
return 0;
}
@Override
public void selfStyleConnection(Object element,
GraphConnection connection) {
FontData font = new FontData();
font.setHeight(12);
font.setStyle(SWT.BOLD);
connection.setFont(new Font(Display.getCurrent(), font));
// connection.setLineColor(new Color(Display.getCurrent(),
// Colors.conflictBgYellow));
try {
Field privLabelField = GraphConnection.class
.getDeclaredField("connectionLabel");
privLabelField.setAccessible(true);
org.eclipse.draw2d.Label privLabel = (org.eclipse.draw2d.Label) privLabelField
.get(connection);
privLabel.setBorder(new MarginBorder(2, 3, 2, 3));
// privLabel.setSize(new Dimension(privLabel.getSize().width+3,
// privLabel.getSize().height+3));
if (showTransitionLabels) {
privLabel.setForegroundColor(new Color(
Display.getCurrent(), Colors.white));
privLabel.setOpaque(true);
privLabel.setBackgroundColor(connection.getLineColor());
} else {
privLabel.setOpaque(false);
}
} catch (NoSuchFieldException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (SecurityException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IllegalArgumentException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IllegalAccessException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
@Override
public void selfStyleNode(Object element, GraphNode node) {
// TODO Auto-generated method stub
}
}
@Override
......
......@@ -304,6 +304,7 @@ public class CupConflictsView implements ICupEditorPageVisibility,
builder.append("</a>");
if (i != size - 1)
builder.append(", ");
gridData.heightHint += SIZE_INCREASE_PER_LINE;
}
detailText.setText(builder.toString());
......
......@@ -491,6 +491,11 @@ public class CupReduceGraphView implements ICupParserLaLrChangeObserver,
this.lalrContext = lalrContext;
this.lalrResult = lalrResult;
if (lalrResult == null) {
System.err.println("ParserNodeModelContentProvider: lalrResult was null.");
return;
}
if (rebuildJob == null || (rebuildJob.getState() != Job.RUNNING)) {
if (rebuildJob != null) {
rebuildJob.cancel();
......
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