Skip to content

Commit

Permalink
Merge pull request #18 from pinetree408/minorui
Browse files Browse the repository at this point in the history
Fix & Add minor UI issue
  • Loading branch information
pinetree408 committed Jun 2, 2016
2 parents 73d9ce9 + e4866e6 commit e6b01d2
Show file tree
Hide file tree
Showing 2 changed files with 153 additions and 53 deletions.
106 changes: 76 additions & 30 deletions VFT/src/vft/views/VFTGraph.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@

import org.jgrapht.ListenableGraph;
import org.jgrapht.graph.ListenableDirectedGraph;
import org.jgrapht.graph.DirectedMultigraph;

import java.util.ArrayList;

import vft.filter.FilterWrapper;
import vft.filter.Filter.GraphNode;

Expand All @@ -14,7 +16,10 @@ public static ListenableGraph<String, String> init(int filteringRule, ArrayList<
// create a JGraphT graph
ListenableGraph<String, String> g =
new ListenableDirectedGraph<String, String>(
String.class);
String.class);
//DirectedMultigraph<String, String> g =
// new DirectedMultigraph<String, String>(
// String.class);
ArrayList<GraphNode> graphNode = new ArrayList<GraphNode>();
ArrayList<String> componentList;

Expand Down Expand Up @@ -73,33 +78,73 @@ public static ListenableGraph<String, String> init(int filteringRule, ArrayList<
// 2nd step : select package or file or test case
if (filteringRule == Filter.INTER_COMPONENT_FILTER) {

Filter.selectComponent(Filter.INTER_COMPONENT_FILTER, options.get(0), options.get(1));
graphNode = Filter.getGraphNode();

System.out.println("VFTGraph : ##### Interface between Atm <-> Simulation #####");
GraphNode gNodeToDebug = Filter.new GraphNode();
for (i = 0; i < graphNode.size(); i++) {
gNodeToDebug = graphNode.get(i);
g.addVertex(gNodeToDebug.caller);
g.addVertex(gNodeToDebug.callee);
g.addEdge(gNodeToDebug.caller, gNodeToDebug.callee, gNodeToDebug.functionName);
System.out.println("VFTGraph : " + gNodeToDebug.caller + " -> " + gNodeToDebug.functionName + " -> " + gNodeToDebug.callee);
}
if (options.size() != 0) {
Filter.selectComponent(Filter.INTER_COMPONENT_FILTER, options.get(0), options.get(1));
graphNode = Filter.getGraphNode();

System.out.println("VFTGraph : ##### Interface between Atm <-> Simulation #####");
GraphNode gNodeToDebug = Filter.new GraphNode();
for (i = 0; i < graphNode.size(); i++) {
gNodeToDebug = graphNode.get(i);
g.addVertex(gNodeToDebug.caller);
g.addVertex(gNodeToDebug.callee);
g.addEdge(gNodeToDebug.caller, gNodeToDebug.callee, gNodeToDebug.functionName);
System.out.println("VFTGraph : " + gNodeToDebug.caller + " -> " + gNodeToDebug.functionName + " -> " + gNodeToDebug.callee);
}
} else {
componentList = Filter.setFilterRule(Filter.INTER_COMPONENT_FILTER);
for(int j = 0; j < componentList.size(); j++) {
if (j != componentList.size() - 1) {
Filter.selectComponent(Filter.INTER_COMPONENT_FILTER, componentList.get(j),componentList.get(j+1));
} else {
Filter.selectComponent(Filter.INTER_COMPONENT_FILTER, componentList.get(j),componentList.get(0));
}
graphNode = Filter.getGraphNode();

System.out.println("VFTGraph : ##### Interface between Atm <-> Simulation #####");
GraphNode gNodeToDebug = Filter.new GraphNode();
for (i = 0; i < graphNode.size(); i++) {
gNodeToDebug = graphNode.get(i);
g.addVertex(gNodeToDebug.caller);
g.addVertex(gNodeToDebug.callee);
g.addEdge(gNodeToDebug.caller, gNodeToDebug.callee, gNodeToDebug.functionName);
System.out.println("VFTGraph : " + gNodeToDebug.caller + " -> " + gNodeToDebug.functionName + " -> " + gNodeToDebug.callee);
}
}
}

} else if (filteringRule == Filter.FILE_FILTER) {

Filter.selectComponent(Filter.FILE_FILTER, options.get(0), null);
graphNode = Filter.getGraphNode();

System.out.println("VFTGraph : ##### Interface with this file #####");
GraphNode gNodeToDebug = Filter.new GraphNode();
for (i = 0; i < graphNode.size(); i++) {
gNodeToDebug = graphNode.get(i);
g.addVertex(gNodeToDebug.caller);
g.addVertex(gNodeToDebug.callee);
g.addEdge(gNodeToDebug.caller, gNodeToDebug.callee, gNodeToDebug.functionName);
System.out.println("VFTGraph : " + gNodeToDebug.caller + " -> " + gNodeToDebug.functionName + " -> " + gNodeToDebug.callee);
}
if (options.size() != 0) {
Filter.selectComponent(Filter.FILE_FILTER, options.get(0), null);
graphNode = Filter.getGraphNode();

System.out.println("VFTGraph : ##### Interface with this file #####");
GraphNode gNodeToDebug = Filter.new GraphNode();
for (i = 0; i < graphNode.size(); i++) {
gNodeToDebug = graphNode.get(i);
g.addVertex(gNodeToDebug.caller);
g.addVertex(gNodeToDebug.callee);
g.addEdge(gNodeToDebug.caller, gNodeToDebug.callee, gNodeToDebug.functionName);
System.out.println("VFTGraph : " + gNodeToDebug.caller + " -> " + gNodeToDebug.functionName + " -> " + gNodeToDebug.callee);
}
} else {
componentList = Filter.setFilterRule(Filter.FILE_FILTER);
for(int j = 0; j < componentList.size(); j++) {
Filter.selectComponent(Filter.FILE_FILTER, componentList.get(j), null);
graphNode = Filter.getGraphNode();

System.out.println("VFTGraph : ##### Interface with this file #####");
GraphNode gNodeToDebug = Filter.new GraphNode();
for (i = 0; i < graphNode.size(); i++) {
gNodeToDebug = graphNode.get(i);
g.addVertex(gNodeToDebug.caller);
g.addVertex(gNodeToDebug.callee);
g.addEdge(gNodeToDebug.caller, gNodeToDebug.callee, gNodeToDebug.functionName);
System.out.println("VFTGraph : " + gNodeToDebug.caller + " -> " + gNodeToDebug.functionName + " -> " + gNodeToDebug.callee);
}
}
}

} else if (filteringRule == Filter.TEST_CASE_FILTER) {

Expand Down Expand Up @@ -144,15 +189,16 @@ public static ListenableGraph<String, String> init(int filteringRule, ArrayList<
g.addVertex(v3);
g.addVertex(v4);

g.addEdge(v1, v2);
g.addEdge(v2, v3);
g.addEdge(v3, v1);
g.addEdge(v4, v3);
g.addEdge(v1, v2, v1 + v2);
g.addEdge(v1, v2, v1 + v1);
g.addEdge(v2, v3, v2 + v3);
g.addEdge(v3, v1, v3 + v4);
g.addEdge(v4, v3, v4 + v3);
}

long end = System.currentTimeMillis();
System.out.println("VFTGraph : Filter (ms) " + (end - start));

System.out.println(g.toString());

return g;

Expand Down
100 changes: 77 additions & 23 deletions VFT/src/vft/views/VFTView.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,24 @@

import vft.views.VFTGraph;
import vft.views.VFTTree;
import vft.filter.FilterWrapper;

import java.awt.BorderLayout;
import java.awt.Button;
import java.awt.Dimension;
import java.awt.Frame;
import java.awt.GridBagLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.awt.event.MouseWheelEvent;
import java.awt.event.MouseWheelListener;

import javax.swing.JComboBox;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JSplitPane;
import javax.swing.JTabbedPane;

Expand All @@ -22,15 +32,13 @@
// Import Lib for Graph
import org.jgrapht.ListenableGraph;
import org.jgrapht.ext.JGraphXAdapter;
import org.jgrapht.graph.DirectedMultigraph;

import com.mxgraph.layout.mxCircleLayout;
import com.mxgraph.layout.mxIGraphLayout;
import com.mxgraph.layout.hierarchical.mxHierarchicalLayout;
import com.mxgraph.swing.mxGraphComponent;

import java.util.ArrayList;

import vft.filter.FilterWrapper;

/**
* This sample class demonstrates how to plug-in a new
* workbench view. The view shows data obtained from the
Expand Down Expand Up @@ -59,6 +67,7 @@ public class VFTView extends ViewPart {
private JPanel graphPanel;
private JPanel treePanel;
private JPanel selectPane;
private JTabbedPane tabPane;
private Integer filterRule;

private ArrayList<String> options;
Expand All @@ -67,6 +76,8 @@ public class VFTView extends ViewPart {
private String file;
private String testCase;
private String testMethod;

private double zoom = 1.0;

/**
* The constructor.
Expand All @@ -83,41 +94,62 @@ public void createPartControl(Composite parent) {
// Add JFrame in plug-in view
Composite composite = new Composite(parent, SWT.EMBEDDED | SWT.NO_BACKGROUND);
Frame frame = SWT_AWT.new_Frame(composite);
JSplitPane splitPaneV = new JSplitPane( JSplitPane.VERTICAL_SPLIT);
JSplitPane splitPaneV = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
splitPaneV.setDividerLocation(500);

JTabbedPane tabPane = new JTabbedPane();
tabPane = new JTabbedPane();

// Add Panel for graph
graphPanel = new JPanel();
graphPanel = new JPanel(new BorderLayout());

// Add Graph
filterRule = 0;
options = new ArrayList<String>();
ListenableGraph<String, String> g = VFTGraph.init(filterRule, options);
JGraphXAdapter<String, String> graphAdapter =
new JGraphXAdapter<String, String>(g);
mxIGraphLayout layout = new mxCircleLayout(graphAdapter);
layout.execute(graphAdapter.getDefaultParent());
graphPanel.add(new mxGraphComponent(graphAdapter));
drawGraph(filterRule, options);

// Add Panel for Tree
treePanel = new JPanel();
treePanel = new JPanel(new BorderLayout());

// Add Tree
treePanel.add(VFTTree.init(filterRule, options));

tabPane.addTab("VFT Graph", graphPanel);
tabPane.addTab("VFT Graph", new JScrollPane(graphPanel));
tabPane.addTab("VFT Tree", treePanel);

selectPane = new JPanel();
drawInitialSelectPane();

splitPaneV.setLeftComponent(tabPane);
splitPaneV.setRightComponent(selectPane);
splitPaneV.setTopComponent(tabPane);
splitPaneV.setBottomComponent(selectPane);

frame.add(splitPaneV);

}

private void drawGraph(int filterRule, ArrayList<String> options) {

ListenableGraph<String, String> g = VFTGraph.init(filterRule, options);
JGraphXAdapter<String, String> graphAdapter =
new JGraphXAdapter<String, String>(g);

Object[] edgeCellArray = new Object[graphAdapter.getEdgeToCellMap().size()];
for (int i = 0; i < graphAdapter.getEdgeToCellMap().size(); ++i) {
edgeCellArray[i] = (Object)(graphAdapter.getEdgeToCellMap().get(g.edgeSet().toArray()[i]));
}
graphAdapter.setCellStyle("fontSize=5", edgeCellArray);

mxHierarchicalLayout layout = new mxHierarchicalLayout(graphAdapter);
layout.setInterHierarchySpacing(5.0);
layout.setInterRankCellSpacing(150.0);
layout.setIntraCellSpacing(15.0);
layout.execute(graphAdapter.getDefaultParent());

mxGraphComponent test = new mxGraphComponent(graphAdapter);

graphPanel.add(test);

}

private void drawInitialSelectPane() {

String[] filterRules = { "NONE", "INTER_COMPONENT_FILTER", "FILE_FILTER", "TEST_CASE_FILTE", "TEST_METHOD_FILTER"};
Expand Down Expand Up @@ -153,6 +185,13 @@ public void actionPerformed(ActionEvent e) {
packageTo = packageBoxTo.getSelectedItem().toString();
}
});
options.clear();
if (packageFrom == null && packageTo == null) {
graphPanel.removeAll();
drawGraph(filterRule, options);
graphPanel.revalidate();
graphPanel.repaint();
}
selectPane.add(packageBoxFrom);
selectPane.add(packageBoxTo);
} else if (filterRule == Filter.FILE_FILTER) {
Expand All @@ -164,6 +203,13 @@ public void actionPerformed(ActionEvent e) {
file = fileBox.getSelectedItem().toString();
}
});
options.clear();
if (file == null) {
graphPanel.removeAll();
drawGraph(filterRule, options);
graphPanel.revalidate();
graphPanel.repaint();
}
selectPane.add(fileBox);
} else if (filterRule == Filter.TEST_CASE_FILTER) {
ArrayList<String> componentList = Filter.setFilterRule(Filter.TEST_CASE_FILTER);
Expand Down Expand Up @@ -232,12 +278,7 @@ public void actionPerformed(ActionEvent e) {
}

graphPanel.removeAll();
ListenableGraph<String, String> g = VFTGraph.init(filterRule, options);
JGraphXAdapter<String, String> graphAdapter =
new JGraphXAdapter<String, String>(g);
mxIGraphLayout layout = new mxCircleLayout(graphAdapter);
layout.execute(graphAdapter.getDefaultParent());
graphPanel.add(new mxGraphComponent(graphAdapter));
drawGraph(filterRule, options);
graphPanel.revalidate();
graphPanel.repaint();

Expand All @@ -249,8 +290,20 @@ public void actionPerformed(ActionEvent e) {
}
});

/*
Button b = new Button("Zoom");
b.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
System.out.println(graphPanel.getWidth());
}
});
Button c = new Button("Export");
*/

selectPane.add(a);
selectPane.add(comboBox);
//selectPane.add(b);
}

/**
Expand All @@ -259,4 +312,5 @@ public void actionPerformed(ActionEvent e) {
public void setFocus() {
//viewer.getControl().setFocus();
}

}

0 comments on commit e6b01d2

Please sign in to comment.