Commit 9d14a84a authored by Sebastian Pretscher's avatar Sebastian Pretscher

Added view to find conflicts

parent af9ab62a
......@@ -142,17 +142,24 @@ public class DocumentDidChangeJob extends Job {
e.printStackTrace();
}
errorReporter.pushToUIThread();
//errorReporter.pushToUIThread();
if (result != null) {
// System.out.println(result.toString());
ParserResultJob resultModelJob = new ParserResultJob(result,
revNumber);
resultModelJob.setSystem(true);
resultModelJob.schedule();
try {
resultModelJob.join();
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
} else {
return Status.CANCEL_STATUS;
}
}
if (jobs.contains(JobsToDo.buildTable)) {
......@@ -168,6 +175,12 @@ public class DocumentDidChangeJob extends Job {
LaLrResultJob resultLaLrModelJob = new LaLrResultJob(lalrResult, revNumber, context);
resultLaLrModelJob.setSystem(true);
resultLaLrModelJob.schedule();
try {
resultLaLrModelJob.join();
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
} else {
return Status.CANCEL_STATUS;
}
......
package de.tum.in.www2.cupplugin.editors;
public interface CupEditorPageVisibility {
public void willBecomeVisible();
public void becameHidden();
}
package de.tum.in.www2.cupplugin.editors;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Enumeration;
import java.util.HashMap;
......@@ -33,6 +35,7 @@ import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Combo;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Display;
......@@ -47,6 +50,7 @@ import org.eclipse.zest.core.viewers.IEntityStyleProvider;
import org.eclipse.zest.core.viewers.IGraphEntityContentProvider;
import org.eclipse.zest.core.viewers.IZoomableWorkbenchPart;
import org.eclipse.zest.core.viewers.ZoomContributionViewItem;
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;
......@@ -71,10 +75,11 @@ import de.tum.in.www2.cupplugin.model.CupParserLaLrChangeObserver;
import de.tum.in.www2.cupplugin.model.Model;
public class CupReduceGraphView implements CupParserLaLrChangeObserver,
IZoomableWorkbenchPart {
IZoomableWorkbenchPart, CupEditorPageVisibility {
// Some Constants
private static final int BUTTON_WIDTH = 120;
public static final Object modelBuildLock = new Object();
public GraphViewer graphViewer;
private Model parseModel;
......@@ -82,8 +87,8 @@ public class CupReduceGraphView implements CupParserLaLrChangeObserver,
private Composite graphComposite;
private Composite parentComposite;
public static final Object modelBuildLock = new Object();
private ZoomManager zoomManager;
private boolean isVisible = false;
private boolean shouldRebuildWhenVisible = false;
......@@ -181,8 +186,41 @@ public class CupReduceGraphView implements CupParserLaLrChangeObserver,
}
}
});
try {
Method protectedGetZoomMethod = AbstractZoomableViewer.class
.getDeclaredMethod("getZoomManager", null);
protectedGetZoomMethod.setAccessible(true);
zoomManager = (ZoomManager) protectedGetZoomMethod.invoke(
this.getZoomableViewer(), null);
} catch (NoSuchMethodException | SecurityException
| IllegalAccessException | IllegalArgumentException
| InvocationTargetException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
if (zoomManager != null) {
Combo combo = new Combo(this.parentComposite, SWT.READ_ONLY);
combo.setLayoutData(new GridData(BUTTON_WIDTH, 20));
String[] levels = zoomManager.getZoomLevelsAsText();
combo.setItems(levels);
combo.select(0);
combo.addListener(SWT.Selection, new Listener() {
@Override
public void handleEvent(Event e) {
if (e.widget instanceof Combo) {
Combo c = (Combo)e.widget;
int idx = c.getSelectionIndex();
zoomManager.setZoomAsText(levels[idx]);
}
System.out.println(e.widget + " - Default Selection");
}
});
}
}
@Override
public void willBecomeVisible() {
System.out.println("CupGraphView will become visible.");
isVisible = true;
......@@ -197,11 +235,12 @@ public class CupReduceGraphView implements CupParserLaLrChangeObserver,
LayoutStyles.NO_LAYOUT_NODE_RESIZING) });
graphViewer.setLayoutAlgorithm(layout, true);
graphViewer.applyLayout();
synchronized(CupReduceGraphView.modelBuildLock) {
synchronized (CupReduceGraphView.modelBuildLock) {
graphViewer.refresh();
}
}
@Override
public void becameHidden() {
System.out.println("CupGraphView became hidden.");
isVisible = false;
......
......@@ -41,12 +41,14 @@ public class MultiPageEditor extends MultiPageEditorPart implements
private CupOverviewView overviewView;
private CupActionTableView actionTableView;
private CupReduceTableView reduceTableView;
private CupConflictGraphView conflictGraphView;
private final int OVERVIEW_PAGE_INDEX = 0;
private final int EDITOR_PAGE_INDEX = 1;
private final int GRAPH_PAGE_INDEX = 2;
private final int ACTION_TABLE_PAGE_INDEX = 3;
private final int REDUCE_TABLE_PAGE_INDEX = 4;
private final int CONFLICT_GRAPH_PAGE_INDEX = 5;
private int previousPageIndex = EDITOR_PAGE_INDEX;
......@@ -116,12 +118,22 @@ public class MultiPageEditor extends MultiPageEditorPart implements
setPageText(REDUCE_TABLE_PAGE_INDEX, "Reduce Table");
}
void createConflictGraphPage() {
Composite composite = new Composite(getContainer(), SWT.NONE);
IDocument doc = editor.getDocumentProvider().getDocument(
editor.getEditorInput());
conflictGraphView = new CupConflictGraphView(composite, doc);
addPage(CONFLICT_GRAPH_PAGE_INDEX, composite);
setPageText(CONFLICT_GRAPH_PAGE_INDEX, "Conflict Graph");
}
protected void createPages() {
createEditorPage();
createOverviewPage();
createGraphPage();
createActionTablePage();
createReduceTablePage();
createConflictGraphPage();
setActivePage(previousPageIndex);
}
......@@ -178,8 +190,10 @@ public class MultiPageEditor extends MultiPageEditorPart implements
actionTableView.becameHidden();
break;
case REDUCE_TABLE_PAGE_INDEX:
reduceTableView.becameHidden();
reduceTableView.becameHidden();
break;
case CONFLICT_GRAPH_PAGE_INDEX:
conflictGraphView.becameHidden();
break;
}
switch (newPageIndex) {
......@@ -196,6 +210,9 @@ public class MultiPageEditor extends MultiPageEditorPart implements
case REDUCE_TABLE_PAGE_INDEX:
reduceTableView.willBecomeVisible();
break;
case CONFLICT_GRAPH_PAGE_INDEX:
conflictGraphView.willBecomeVisible();
break;
}
previousPageIndex = newPageIndex;
super.pageChange(newPageIndex);
......
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