Loading src/main/java/jetklee/ContextViewer.java +20 −20 Original line number Diff line number Diff line Loading @@ -2,7 +2,7 @@ package jetklee; import javax.swing.*; import static jetklee.Styles.BLUE_STYLE; import static jetklee.Styles.KEY_COLOR; import static jetklee.Styles.INFO_FONT; /** Loading Loading @@ -35,43 +35,43 @@ public class ContextViewer extends TextViewerBase { } private String createNodeInfoRow(NodeInfo.Context context) { return "<div><b><span style=" + BLUE_STYLE + ">nodeId:</span></b> " + context.nodeID() + "</div>" + "<div><span style=" + BLUE_STYLE + ">stateId:</span> " + context.stateID() + " <span style=" + BLUE_STYLE + ">parentId:</span> " + context.parentID() + " <span style=" + BLUE_STYLE + ">nextId:</span> " + context.nextID() + " <span style=" + BLUE_STYLE + ">depth:</span> " + context.depth() + return "<div><b><span style=" + KEY_COLOR + ">nodeId:</span></b> " + context.nodeID() + "</div>" + "<div><span style=" + KEY_COLOR + ">stateId:</span> " + context.stateID() + " <span style=" + KEY_COLOR + ">parentId:</span> " + context.parentID() + " <span style=" + KEY_COLOR + ">nextId:</span> " + context.nextID() + " <span style=" + KEY_COLOR + ">depth:</span> " + context.depth() + "</div>"; } private String createStateInfoRow(NodeInfo.Context context) { return "<div><span style=" + BLUE_STYLE + ">uniqueState:</span> " + context.uniqueState() + " <span style=" + BLUE_STYLE + ">coveredNew:</span> " + context.coveredNew() + " <span style=" + BLUE_STYLE + ">forkDisabled:</span> " + context.forkDisabled() + " <span style=" + BLUE_STYLE + ">instsSinceCovNew:</span> " + context.instsSinceCovNew() + " <span style=" + BLUE_STYLE + ">steppedInstructions:</span> " + context.steppedInstructions() + return "<div><span style=" + KEY_COLOR + ">uniqueState:</span> " + context.uniqueState() + " <span style=" + KEY_COLOR + ">coveredNew:</span> " + context.coveredNew() + " <span style=" + KEY_COLOR + ">forkDisabled:</span> " + context.forkDisabled() + " <span style=" + KEY_COLOR + ">instsSinceCovNew:</span> " + context.instsSinceCovNew() + " <span style=" + KEY_COLOR + ">steppedInstructions:</span> " + context.steppedInstructions() + "</div><br>"; } private String createLocationRow(String label, NodeInfo.Location location) { String formattedLocation = " - <span style=" + BLUE_STYLE + ">file:</span> " + location.file() + "<br>" + " - <span style=" + BLUE_STYLE + ">line:</span> " + location.line() + "<br>" + " - <span style=" + BLUE_STYLE + ">column:</span> " + location.column() + "<br>" + " - <span style=" + BLUE_STYLE + ">assemblyLine:</span> " + location.assemblyLine() + "<br>"; " - <span style=" + KEY_COLOR + ">file:</span> " + location.file() + "<br>" + " - <span style=" + KEY_COLOR + ">line:</span> " + location.line() + "<br>" + " - <span style=" + KEY_COLOR + ">column:</span> " + location.column() + "<br>" + " - <span style=" + KEY_COLOR + ">assemblyLine:</span> " + location.assemblyLine() + "<br>"; return "<div><b><span style=" + BLUE_STYLE + ">" + label + ":</span></b><br>" + return "<div><b><span style=" + KEY_COLOR + ">" + label + ":</span></b><br>" + formattedLocation + "</div><br>"; } private String createStackRow(NodeInfo.Context context) { StringBuilder stackBuilder = new StringBuilder(); stackBuilder.append("<div><b><span style=" + BLUE_STYLE + ">stack:</span></b><br>"); stackBuilder.append("<div><b><span style=" + KEY_COLOR + ">stack:</span></b><br>"); for (NodeInfo.Location stackLocation : context.stack()) { stackBuilder.append(" - <span style=" + BLUE_STYLE + ">file:</span> ") stackBuilder.append(" - <span style=" + KEY_COLOR + ">file:</span> ") .append(stackLocation.file()) .append(" <span style=" + BLUE_STYLE + ">line:</span> ").append(stackLocation.line()) .append(" <span style=" + BLUE_STYLE + ">column:</span> ").append(stackLocation.column()) .append(" <span style=" + KEY_COLOR + ">line:</span> ").append(stackLocation.line()) .append(" <span style=" + KEY_COLOR + ">column:</span> ").append(stackLocation.column()) .append("<br>"); } stackBuilder.append("</div>"); Loading src/main/java/jetklee/ProgressExplorer.java +94 −78 Original line number Diff line number Diff line Loading @@ -10,6 +10,7 @@ import java.util.Collections; import java.io.File; import java.util.prefs.Preferences; //import com.formdev.flatlaf.FlatDarkLaf; import com.formdev.flatlaf.FlatLightLaf; /** Loading @@ -25,62 +26,58 @@ public class ProgressExplorer implements ListSelectionListener, MouseWheelListen private JPanel rootPanel; private JList<String> roundsList; private JTabbedPane mainTabbedPane; private JTabbedPane nodeInfoTabbedPane; private JTabbedPane nodeTabbedPane; private JSplitPane splitPane; private JScrollPane roundScrollPane; private JSplitPane mainSplitPane; private JPanel treePanel; private JScrollPane treeScrollPane; private ConstraintsViewer constraintsViewer; private MemoryViewer memoryViewer; private ContextViewer contextViewer; private JPopupMenu rightClickMenu; private float divider; private JMenuBar menuBar; public ProgressExplorer() { tree = new Tree(); treeViewer = new TreeViewer(tree); treeViewer.addMouseListener(this); sourceLoader = new SourceLoader(); sourceC = new SourceViewerC(sourceLoader); sourceLL = new SourceViewerLL(sourceLoader); constraintsViewer = new ConstraintsViewer(); memoryViewer = new MemoryViewer(); contextViewer = new ContextViewer(); divider = 0.5f; initializeSourceViewer(); initliazeTreeViewer(); initializeNodePanel(); arrangePanels(); createRightClickMenu(); createOpenMenu(); } treeScrollPane = new JScrollPane(treeViewer); treeScrollPane.setWheelScrollingEnabled(false); treeScrollPane.addMouseWheelListener(new MouseWheelListener() { private void createOpenMenu() { menuBar = new JMenuBar(); JMenu fileMenu = new JMenu("File"); JMenuItem openMenuItem = new JMenuItem("Open"); openMenuItem.addActionListener(new ActionListener() { @Override public void mouseWheelMoved(MouseWheelEvent e) { treeViewer.onZoomChanged(-e.getWheelRotation()); public void actionPerformed(ActionEvent e) { openFile(); } }); treePanel = new JPanel(new BorderLayout()); treePanel.add(treeScrollPane, BorderLayout.CENTER); fileMenu.add(openMenuItem); menuBar.add(fileMenu); } roundsList = new JList<>(new DefaultListModel<>()); roundsList.addListSelectionListener(this); roundsList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); roundScrollPane = new JScrollPane(roundsList); private void createRightClickMenu() { rightClickMenu = new JPopupMenu(); NodeAction[] nodeActions = new NodeAction[]{NodeAction.NODE_INFO, NodeAction.NODE_TO_C, NodeAction.NODE_TO_LL}; for (NodeAction nodeAction : nodeActions) { JMenuItem newItem = new JMenuItem(nodeAction.value); newItem.addActionListener(this); newItem.setActionCommand(nodeAction.value); rightClickMenu.add(newItem); } } private void arrangePanels() { mainTabbedPane = new JTabbedPane(JTabbedPane.TOP); mainTabbedPane.addTab("Tree", treePanel); mainTabbedPane.addTab("C", sourceC); mainTabbedPane.addTab("LL", sourceLL); nodeInfoTabbedPane = new JTabbedPane(JTabbedPane.TOP); nodeInfoTabbedPane.addTab("Context", contextViewer); nodeInfoTabbedPane.addTab("Constraints", constraintsViewer); nodeInfoTabbedPane.addTab("Memory", memoryViewer); nodeInfoTabbedPane.setVisible(false); splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, mainTabbedPane, nodeInfoTabbedPane); splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, mainTabbedPane, nodeTabbedPane); splitPane.setResizeWeight(0.1); splitPane.setDividerLocation(0.1); Loading @@ -90,40 +87,57 @@ public class ProgressExplorer implements ListSelectionListener, MouseWheelListen rootPanel = new JPanel(new BorderLayout()); rootPanel.add(mainSplitPane, BorderLayout.CENTER); } rightClickMenu = new JPopupMenu(); NodeAction[] nodeActions = new NodeAction[]{NodeAction.NODE_INFO, NodeAction.NODE_TO_C, NodeAction.NODE_TO_LL}; for (NodeAction nodeAction : nodeActions) { JMenuItem newItem = new JMenuItem(nodeAction.value); newItem.addActionListener(this); newItem.setActionCommand(nodeAction.value); rightClickMenu.add(newItem); private void initializeSourceViewer() { sourceLoader = new SourceLoader(); sourceC = new SourceViewerC(sourceLoader); sourceLL = new SourceViewerLL(sourceLoader); } menuBar = new JMenuBar(); JMenu fileMenu = new JMenu("File"); JMenuItem openMenuItem = new JMenuItem("Open"); private void initliazeTreeViewer() { tree = new Tree(); treeViewer = new TreeViewer(tree); treeViewer.addMouseListener(this); openMenuItem.addActionListener(new ActionListener() { JScrollPane treeScrollPane = new JScrollPane(treeViewer); treeScrollPane.setWheelScrollingEnabled(false); treeScrollPane.addMouseWheelListener(new MouseWheelListener() { @Override public void actionPerformed(ActionEvent e) { openFile(); public void mouseWheelMoved(MouseWheelEvent e) { treeViewer.onZoomChanged(-e.getWheelRotation()); } }); fileMenu.add(openMenuItem); menuBar.add(fileMenu); treePanel = new JPanel(new BorderLayout()); treePanel.add(treeScrollPane, BorderLayout.CENTER); roundsList = new JList<>(new DefaultListModel<>()); roundsList.addListSelectionListener(this); roundsList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); roundScrollPane = new JScrollPane(roundsList); } private void initializeNodePanel() { constraintsViewer = new ConstraintsViewer(); memoryViewer = new MemoryViewer(); contextViewer = new ContextViewer(); nodeTabbedPane = new JTabbedPane(JTabbedPane.TOP); nodeTabbedPane.addTab("Context", contextViewer); nodeTabbedPane.addTab("Constraints", constraintsViewer); nodeTabbedPane.addTab("Memory", memoryViewer); nodeTabbedPane.setVisible(false); } public static void main(String[] args) { javax.swing.SwingUtilities.invokeLater(new Runnable() { /** * Initializes and displays the main application window. Loads recorded data from directory specified by * command line argument. * optional command line argument. */ public void run() { double startTime = System.currentTimeMillis(); UIManager.put( "TabbedPane.selectedBackground", Color.white ); FlatLightLaf.setGlobalExtraDefaults(Collections.singletonMap("@accentColor", "#ADD8E6")); try { UIManager.setLookAndFeel(new FlatLightLaf()); Loading @@ -131,17 +145,19 @@ public class ProgressExplorer implements ListSelectionListener, MouseWheelListen System.err.println("Failed to initialize LaF"); } JFrame frame = new JFrame("JetKlee: ProgressExplorer"); JFrame frame = new JFrame("JetKlee Progress Explorer"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setPreferredSize(new Dimension(800, 600)); ProgressExplorer explorer = new ProgressExplorer(); if (args.length != ARGS_COUNT) throw new IllegalArgumentException("Invalid number of arguments. Expected " + ARGS_COUNT + " arguments."); if (args.length == ARGS_COUNT) { explorer.load(Paths.get(args[0]).toAbsolutePath().toString()); } if (args.length > ARGS_COUNT) { throw new IllegalArgumentException("Invalid number of arguments. Expected " + ARGS_COUNT + " arguments."); } frame.setJMenuBar(explorer.menuBar); frame.setContentPane(explorer.rootPanel); frame.pack(); frame.setVisible(true); Loading @@ -153,6 +169,7 @@ public class ProgressExplorer implements ListSelectionListener, MouseWheelListen } }); } private void openFile() { Preferences prefs = Preferences.userNodeForPackage(ProgressExplorer.class); String lastDirectory = prefs.get("lastDirectory", System.getProperty("user.home")); Loading @@ -164,14 +181,13 @@ public class ProgressExplorer implements ListSelectionListener, MouseWheelListen int result = fileChooser.showOpenDialog(rootPanel); if (result == JFileChooser.APPROVE_OPTION) { File selectedDir = fileChooser.getSelectedFile(); File newDir = new File(selectedDir, "__JetKleeProgressRecording__"); load(newDir.getAbsolutePath()); prefs.put("lastDirectory", selectedDir.getAbsolutePath()); File recordingDir = new File(selectedDir, "__JetKleeProgressRecording__"); load(recordingDir.getAbsolutePath()); } } private enum TabbedPane { TREE_PANE, C_PANE, LL_PANE; } Loading @@ -180,8 +196,8 @@ public class ProgressExplorer implements ListSelectionListener, MouseWheelListen NODE_INFO("Node Information"), NODE_TO_C("C"), NODE_TO_LL("LL"); private final String value; NodeAction(String value_) { value = value_; NodeAction(String value) { this.value = value; } private static NodeAction parse(String actionStr) throws Exception { Loading @@ -195,14 +211,14 @@ public class ProgressExplorer implements ListSelectionListener, MouseWheelListen } /** * Updates current round based on the round selected in the list menu. * Updates current tree view based on the round selected in the list menu. * * @param e the event that characterizes the change in the list menu. */ public void valueChanged(ListSelectionEvent e) { if (e.getSource() != roundsList) return; if (roundsList.getValueIsAdjusting()) return; if (roundsList.getSelectedIndex() < 0) return; if (e.getSource() != roundsList || roundsList.getValueIsAdjusting() || roundsList.getSelectedIndex() < 0) { return; } treeViewer.setSelectedRound(roundsList.getSelectedIndex()); treeViewer.updateArea(); } Loading @@ -218,7 +234,6 @@ public class ProgressExplorer implements ListSelectionListener, MouseWheelListen sourceLoader.load(dir); } catch (Exception e) { JOptionPane.showMessageDialog(rootPanel, "Load has FAILED: " + e); rootPanel.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); return; } treeViewer.load(); Loading @@ -228,8 +243,9 @@ public class ProgressExplorer implements ListSelectionListener, MouseWheelListen DefaultListModel<String> model = (DefaultListModel<String>) roundsList.getModel(); model.clear(); for (int i = 0; i < tree.getRounds().size(); ++i) ((DefaultListModel<String>) roundsList.getModel()).addElement(tree.getRounds().get(i)); for (int i = 0; i < tree.getRounds().size(); ++i) { model.addElement(tree.getRounds().get(i)); } roundsList.setSelectedIndex(0); roundsList.ensureIndexIsVisible(0); roundsList.revalidate(); Loading @@ -254,12 +270,12 @@ public class ProgressExplorer implements ListSelectionListener, MouseWheelListen * * @param node the node for which information is displayed. */ private void displayNodeInfoPane(Node node) { private void displayNodePane(Node node) { contextViewer.displayContext(node.getInfo()); constraintsViewer.displayConstraints(node.getInfo().getConstraints()); memoryViewer.displayMemory(node, sourceLL); nodeInfoTabbedPane.setVisible(true); nodeTabbedPane.setVisible(true); splitPane.setDividerLocation(0.5); selectCodeLine(node, TabbedPane.TREE_PANE); } Loading @@ -279,7 +295,7 @@ public class ProgressExplorer implements ListSelectionListener, MouseWheelListen } Node node = (Node) rightClickMenu.getClientProperty("node"); switch (action) { case NODE_INFO -> displayNodeInfoPane(node); case NODE_INFO -> displayNodePane(node); case NODE_TO_C -> selectCodeLine(node, TabbedPane.C_PANE); case NODE_TO_LL -> selectCodeLine(node, TabbedPane.LL_PANE); } Loading @@ -288,8 +304,8 @@ public class ProgressExplorer implements ListSelectionListener, MouseWheelListen @Override public void mouseClicked(MouseEvent e) { if (SwingUtilities.isRightMouseButton(e)) { if (nodeInfoTabbedPane.isVisible()) { nodeInfoTabbedPane.setVisible(false); if (nodeTabbedPane.isVisible()) { nodeTabbedPane.setVisible(false); treeViewer.repaint(); treeViewer.setSelectedNode(null); } Loading src/main/java/jetklee/Styles.java +6 −3 Original line number Diff line number Diff line Loading @@ -7,12 +7,15 @@ import java.awt.*; */ public class Styles { // html styles public static final String BLUE_STYLE = "'color:blue;'"; public static final String KEY_COLOR = "'color:blue;'"; // colors public static final Color RED_COLOR = new Color(255, 0, 0, 125); public static final Color GREEN_COLOR = new Color(34, 139, 34, 125); public static final Color DELETIONS_COLOR = new Color(255, 0, 0, 125); public static final Color ADDITIONS_COLOR = new Color(34, 139, 34, 125); public static final Color CHANGE_COLOR = new Color(0, 0, 255, 125); public static final Color CODE_HIGH_LIGHT_COLOR = new Color(255, 255, 0, 125); public static final Color BLACK_COLOR = Color.BLACK; public static final Color BACKGROUND_COLOR = Color.WHITE; // private static final Color ORANGE_COLOR = new Color(255, 165, 0, 125); Loading src/main/java/jetklee/TextViewerBase.java +2 −2 Original line number Diff line number Diff line Loading @@ -6,7 +6,7 @@ import javax.swing.text.DefaultHighlighter; import javax.swing.text.Highlighter; import java.awt.*; import static jetklee.Styles.GREEN_COLOR; import static jetklee.Styles.ADDITIONS_COLOR; /** * General panel with text. Loading Loading @@ -48,7 +48,7 @@ public abstract class TextViewerBase extends JPanel { int endOffset = textArea.getLineEndOffset(line - 1); Highlighter highlighter = textArea.getHighlighter(); Highlighter.HighlightPainter painter = new DefaultHighlighter.DefaultHighlightPainter(GREEN_COLOR); Highlighter.HighlightPainter painter = new DefaultHighlighter.DefaultHighlightPainter(ADDITIONS_COLOR); highlighter.addHighlight(startOffset, endOffset, painter); } catch (BadLocationException e) { // Nothing to do. Loading src/main/java/jetklee/TreeViewer.java +11 −6 Original line number Diff line number Diff line Loading @@ -46,7 +46,14 @@ public class TreeViewer extends JPanel { viewRect = null; setAutoscrolls(true); MouseAdapter ma = new MouseAdapter() { MouseAdapter ma = createMouseAdapter(); addMouseListener(ma); addMouseMotionListener(ma); } private MouseAdapter createMouseAdapter() { return new MouseAdapter() { private Point origin = null; @Override Loading @@ -69,8 +76,6 @@ public class TreeViewer extends JPanel { } } }; addMouseListener(ma); addMouseMotionListener(ma); } /** Loading Loading @@ -276,11 +281,11 @@ public class TreeViewer extends JPanel { } if (node.getLeft() != null && isVisibleNode(node.getLeft(), selectedRound)) { g2d.setColor(RED_COLOR); g2d.setColor(DELETIONS_COLOR); drawChild(g2d, node.getLeft()); } if (node.getRight() != null && isVisibleNode(node.getRight(), selectedRound)) { g2d.setColor(GREEN_COLOR); g2d.setColor(ADDITIONS_COLOR); drawChild(g2d, node.getRight()); } Loading Loading
src/main/java/jetklee/ContextViewer.java +20 −20 Original line number Diff line number Diff line Loading @@ -2,7 +2,7 @@ package jetklee; import javax.swing.*; import static jetklee.Styles.BLUE_STYLE; import static jetklee.Styles.KEY_COLOR; import static jetklee.Styles.INFO_FONT; /** Loading Loading @@ -35,43 +35,43 @@ public class ContextViewer extends TextViewerBase { } private String createNodeInfoRow(NodeInfo.Context context) { return "<div><b><span style=" + BLUE_STYLE + ">nodeId:</span></b> " + context.nodeID() + "</div>" + "<div><span style=" + BLUE_STYLE + ">stateId:</span> " + context.stateID() + " <span style=" + BLUE_STYLE + ">parentId:</span> " + context.parentID() + " <span style=" + BLUE_STYLE + ">nextId:</span> " + context.nextID() + " <span style=" + BLUE_STYLE + ">depth:</span> " + context.depth() + return "<div><b><span style=" + KEY_COLOR + ">nodeId:</span></b> " + context.nodeID() + "</div>" + "<div><span style=" + KEY_COLOR + ">stateId:</span> " + context.stateID() + " <span style=" + KEY_COLOR + ">parentId:</span> " + context.parentID() + " <span style=" + KEY_COLOR + ">nextId:</span> " + context.nextID() + " <span style=" + KEY_COLOR + ">depth:</span> " + context.depth() + "</div>"; } private String createStateInfoRow(NodeInfo.Context context) { return "<div><span style=" + BLUE_STYLE + ">uniqueState:</span> " + context.uniqueState() + " <span style=" + BLUE_STYLE + ">coveredNew:</span> " + context.coveredNew() + " <span style=" + BLUE_STYLE + ">forkDisabled:</span> " + context.forkDisabled() + " <span style=" + BLUE_STYLE + ">instsSinceCovNew:</span> " + context.instsSinceCovNew() + " <span style=" + BLUE_STYLE + ">steppedInstructions:</span> " + context.steppedInstructions() + return "<div><span style=" + KEY_COLOR + ">uniqueState:</span> " + context.uniqueState() + " <span style=" + KEY_COLOR + ">coveredNew:</span> " + context.coveredNew() + " <span style=" + KEY_COLOR + ">forkDisabled:</span> " + context.forkDisabled() + " <span style=" + KEY_COLOR + ">instsSinceCovNew:</span> " + context.instsSinceCovNew() + " <span style=" + KEY_COLOR + ">steppedInstructions:</span> " + context.steppedInstructions() + "</div><br>"; } private String createLocationRow(String label, NodeInfo.Location location) { String formattedLocation = " - <span style=" + BLUE_STYLE + ">file:</span> " + location.file() + "<br>" + " - <span style=" + BLUE_STYLE + ">line:</span> " + location.line() + "<br>" + " - <span style=" + BLUE_STYLE + ">column:</span> " + location.column() + "<br>" + " - <span style=" + BLUE_STYLE + ">assemblyLine:</span> " + location.assemblyLine() + "<br>"; " - <span style=" + KEY_COLOR + ">file:</span> " + location.file() + "<br>" + " - <span style=" + KEY_COLOR + ">line:</span> " + location.line() + "<br>" + " - <span style=" + KEY_COLOR + ">column:</span> " + location.column() + "<br>" + " - <span style=" + KEY_COLOR + ">assemblyLine:</span> " + location.assemblyLine() + "<br>"; return "<div><b><span style=" + BLUE_STYLE + ">" + label + ":</span></b><br>" + return "<div><b><span style=" + KEY_COLOR + ">" + label + ":</span></b><br>" + formattedLocation + "</div><br>"; } private String createStackRow(NodeInfo.Context context) { StringBuilder stackBuilder = new StringBuilder(); stackBuilder.append("<div><b><span style=" + BLUE_STYLE + ">stack:</span></b><br>"); stackBuilder.append("<div><b><span style=" + KEY_COLOR + ">stack:</span></b><br>"); for (NodeInfo.Location stackLocation : context.stack()) { stackBuilder.append(" - <span style=" + BLUE_STYLE + ">file:</span> ") stackBuilder.append(" - <span style=" + KEY_COLOR + ">file:</span> ") .append(stackLocation.file()) .append(" <span style=" + BLUE_STYLE + ">line:</span> ").append(stackLocation.line()) .append(" <span style=" + BLUE_STYLE + ">column:</span> ").append(stackLocation.column()) .append(" <span style=" + KEY_COLOR + ">line:</span> ").append(stackLocation.line()) .append(" <span style=" + KEY_COLOR + ">column:</span> ").append(stackLocation.column()) .append("<br>"); } stackBuilder.append("</div>"); Loading
src/main/java/jetklee/ProgressExplorer.java +94 −78 Original line number Diff line number Diff line Loading @@ -10,6 +10,7 @@ import java.util.Collections; import java.io.File; import java.util.prefs.Preferences; //import com.formdev.flatlaf.FlatDarkLaf; import com.formdev.flatlaf.FlatLightLaf; /** Loading @@ -25,62 +26,58 @@ public class ProgressExplorer implements ListSelectionListener, MouseWheelListen private JPanel rootPanel; private JList<String> roundsList; private JTabbedPane mainTabbedPane; private JTabbedPane nodeInfoTabbedPane; private JTabbedPane nodeTabbedPane; private JSplitPane splitPane; private JScrollPane roundScrollPane; private JSplitPane mainSplitPane; private JPanel treePanel; private JScrollPane treeScrollPane; private ConstraintsViewer constraintsViewer; private MemoryViewer memoryViewer; private ContextViewer contextViewer; private JPopupMenu rightClickMenu; private float divider; private JMenuBar menuBar; public ProgressExplorer() { tree = new Tree(); treeViewer = new TreeViewer(tree); treeViewer.addMouseListener(this); sourceLoader = new SourceLoader(); sourceC = new SourceViewerC(sourceLoader); sourceLL = new SourceViewerLL(sourceLoader); constraintsViewer = new ConstraintsViewer(); memoryViewer = new MemoryViewer(); contextViewer = new ContextViewer(); divider = 0.5f; initializeSourceViewer(); initliazeTreeViewer(); initializeNodePanel(); arrangePanels(); createRightClickMenu(); createOpenMenu(); } treeScrollPane = new JScrollPane(treeViewer); treeScrollPane.setWheelScrollingEnabled(false); treeScrollPane.addMouseWheelListener(new MouseWheelListener() { private void createOpenMenu() { menuBar = new JMenuBar(); JMenu fileMenu = new JMenu("File"); JMenuItem openMenuItem = new JMenuItem("Open"); openMenuItem.addActionListener(new ActionListener() { @Override public void mouseWheelMoved(MouseWheelEvent e) { treeViewer.onZoomChanged(-e.getWheelRotation()); public void actionPerformed(ActionEvent e) { openFile(); } }); treePanel = new JPanel(new BorderLayout()); treePanel.add(treeScrollPane, BorderLayout.CENTER); fileMenu.add(openMenuItem); menuBar.add(fileMenu); } roundsList = new JList<>(new DefaultListModel<>()); roundsList.addListSelectionListener(this); roundsList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); roundScrollPane = new JScrollPane(roundsList); private void createRightClickMenu() { rightClickMenu = new JPopupMenu(); NodeAction[] nodeActions = new NodeAction[]{NodeAction.NODE_INFO, NodeAction.NODE_TO_C, NodeAction.NODE_TO_LL}; for (NodeAction nodeAction : nodeActions) { JMenuItem newItem = new JMenuItem(nodeAction.value); newItem.addActionListener(this); newItem.setActionCommand(nodeAction.value); rightClickMenu.add(newItem); } } private void arrangePanels() { mainTabbedPane = new JTabbedPane(JTabbedPane.TOP); mainTabbedPane.addTab("Tree", treePanel); mainTabbedPane.addTab("C", sourceC); mainTabbedPane.addTab("LL", sourceLL); nodeInfoTabbedPane = new JTabbedPane(JTabbedPane.TOP); nodeInfoTabbedPane.addTab("Context", contextViewer); nodeInfoTabbedPane.addTab("Constraints", constraintsViewer); nodeInfoTabbedPane.addTab("Memory", memoryViewer); nodeInfoTabbedPane.setVisible(false); splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, mainTabbedPane, nodeInfoTabbedPane); splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, mainTabbedPane, nodeTabbedPane); splitPane.setResizeWeight(0.1); splitPane.setDividerLocation(0.1); Loading @@ -90,40 +87,57 @@ public class ProgressExplorer implements ListSelectionListener, MouseWheelListen rootPanel = new JPanel(new BorderLayout()); rootPanel.add(mainSplitPane, BorderLayout.CENTER); } rightClickMenu = new JPopupMenu(); NodeAction[] nodeActions = new NodeAction[]{NodeAction.NODE_INFO, NodeAction.NODE_TO_C, NodeAction.NODE_TO_LL}; for (NodeAction nodeAction : nodeActions) { JMenuItem newItem = new JMenuItem(nodeAction.value); newItem.addActionListener(this); newItem.setActionCommand(nodeAction.value); rightClickMenu.add(newItem); private void initializeSourceViewer() { sourceLoader = new SourceLoader(); sourceC = new SourceViewerC(sourceLoader); sourceLL = new SourceViewerLL(sourceLoader); } menuBar = new JMenuBar(); JMenu fileMenu = new JMenu("File"); JMenuItem openMenuItem = new JMenuItem("Open"); private void initliazeTreeViewer() { tree = new Tree(); treeViewer = new TreeViewer(tree); treeViewer.addMouseListener(this); openMenuItem.addActionListener(new ActionListener() { JScrollPane treeScrollPane = new JScrollPane(treeViewer); treeScrollPane.setWheelScrollingEnabled(false); treeScrollPane.addMouseWheelListener(new MouseWheelListener() { @Override public void actionPerformed(ActionEvent e) { openFile(); public void mouseWheelMoved(MouseWheelEvent e) { treeViewer.onZoomChanged(-e.getWheelRotation()); } }); fileMenu.add(openMenuItem); menuBar.add(fileMenu); treePanel = new JPanel(new BorderLayout()); treePanel.add(treeScrollPane, BorderLayout.CENTER); roundsList = new JList<>(new DefaultListModel<>()); roundsList.addListSelectionListener(this); roundsList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); roundScrollPane = new JScrollPane(roundsList); } private void initializeNodePanel() { constraintsViewer = new ConstraintsViewer(); memoryViewer = new MemoryViewer(); contextViewer = new ContextViewer(); nodeTabbedPane = new JTabbedPane(JTabbedPane.TOP); nodeTabbedPane.addTab("Context", contextViewer); nodeTabbedPane.addTab("Constraints", constraintsViewer); nodeTabbedPane.addTab("Memory", memoryViewer); nodeTabbedPane.setVisible(false); } public static void main(String[] args) { javax.swing.SwingUtilities.invokeLater(new Runnable() { /** * Initializes and displays the main application window. Loads recorded data from directory specified by * command line argument. * optional command line argument. */ public void run() { double startTime = System.currentTimeMillis(); UIManager.put( "TabbedPane.selectedBackground", Color.white ); FlatLightLaf.setGlobalExtraDefaults(Collections.singletonMap("@accentColor", "#ADD8E6")); try { UIManager.setLookAndFeel(new FlatLightLaf()); Loading @@ -131,17 +145,19 @@ public class ProgressExplorer implements ListSelectionListener, MouseWheelListen System.err.println("Failed to initialize LaF"); } JFrame frame = new JFrame("JetKlee: ProgressExplorer"); JFrame frame = new JFrame("JetKlee Progress Explorer"); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setPreferredSize(new Dimension(800, 600)); ProgressExplorer explorer = new ProgressExplorer(); if (args.length != ARGS_COUNT) throw new IllegalArgumentException("Invalid number of arguments. Expected " + ARGS_COUNT + " arguments."); if (args.length == ARGS_COUNT) { explorer.load(Paths.get(args[0]).toAbsolutePath().toString()); } if (args.length > ARGS_COUNT) { throw new IllegalArgumentException("Invalid number of arguments. Expected " + ARGS_COUNT + " arguments."); } frame.setJMenuBar(explorer.menuBar); frame.setContentPane(explorer.rootPanel); frame.pack(); frame.setVisible(true); Loading @@ -153,6 +169,7 @@ public class ProgressExplorer implements ListSelectionListener, MouseWheelListen } }); } private void openFile() { Preferences prefs = Preferences.userNodeForPackage(ProgressExplorer.class); String lastDirectory = prefs.get("lastDirectory", System.getProperty("user.home")); Loading @@ -164,14 +181,13 @@ public class ProgressExplorer implements ListSelectionListener, MouseWheelListen int result = fileChooser.showOpenDialog(rootPanel); if (result == JFileChooser.APPROVE_OPTION) { File selectedDir = fileChooser.getSelectedFile(); File newDir = new File(selectedDir, "__JetKleeProgressRecording__"); load(newDir.getAbsolutePath()); prefs.put("lastDirectory", selectedDir.getAbsolutePath()); File recordingDir = new File(selectedDir, "__JetKleeProgressRecording__"); load(recordingDir.getAbsolutePath()); } } private enum TabbedPane { TREE_PANE, C_PANE, LL_PANE; } Loading @@ -180,8 +196,8 @@ public class ProgressExplorer implements ListSelectionListener, MouseWheelListen NODE_INFO("Node Information"), NODE_TO_C("C"), NODE_TO_LL("LL"); private final String value; NodeAction(String value_) { value = value_; NodeAction(String value) { this.value = value; } private static NodeAction parse(String actionStr) throws Exception { Loading @@ -195,14 +211,14 @@ public class ProgressExplorer implements ListSelectionListener, MouseWheelListen } /** * Updates current round based on the round selected in the list menu. * Updates current tree view based on the round selected in the list menu. * * @param e the event that characterizes the change in the list menu. */ public void valueChanged(ListSelectionEvent e) { if (e.getSource() != roundsList) return; if (roundsList.getValueIsAdjusting()) return; if (roundsList.getSelectedIndex() < 0) return; if (e.getSource() != roundsList || roundsList.getValueIsAdjusting() || roundsList.getSelectedIndex() < 0) { return; } treeViewer.setSelectedRound(roundsList.getSelectedIndex()); treeViewer.updateArea(); } Loading @@ -218,7 +234,6 @@ public class ProgressExplorer implements ListSelectionListener, MouseWheelListen sourceLoader.load(dir); } catch (Exception e) { JOptionPane.showMessageDialog(rootPanel, "Load has FAILED: " + e); rootPanel.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); return; } treeViewer.load(); Loading @@ -228,8 +243,9 @@ public class ProgressExplorer implements ListSelectionListener, MouseWheelListen DefaultListModel<String> model = (DefaultListModel<String>) roundsList.getModel(); model.clear(); for (int i = 0; i < tree.getRounds().size(); ++i) ((DefaultListModel<String>) roundsList.getModel()).addElement(tree.getRounds().get(i)); for (int i = 0; i < tree.getRounds().size(); ++i) { model.addElement(tree.getRounds().get(i)); } roundsList.setSelectedIndex(0); roundsList.ensureIndexIsVisible(0); roundsList.revalidate(); Loading @@ -254,12 +270,12 @@ public class ProgressExplorer implements ListSelectionListener, MouseWheelListen * * @param node the node for which information is displayed. */ private void displayNodeInfoPane(Node node) { private void displayNodePane(Node node) { contextViewer.displayContext(node.getInfo()); constraintsViewer.displayConstraints(node.getInfo().getConstraints()); memoryViewer.displayMemory(node, sourceLL); nodeInfoTabbedPane.setVisible(true); nodeTabbedPane.setVisible(true); splitPane.setDividerLocation(0.5); selectCodeLine(node, TabbedPane.TREE_PANE); } Loading @@ -279,7 +295,7 @@ public class ProgressExplorer implements ListSelectionListener, MouseWheelListen } Node node = (Node) rightClickMenu.getClientProperty("node"); switch (action) { case NODE_INFO -> displayNodeInfoPane(node); case NODE_INFO -> displayNodePane(node); case NODE_TO_C -> selectCodeLine(node, TabbedPane.C_PANE); case NODE_TO_LL -> selectCodeLine(node, TabbedPane.LL_PANE); } Loading @@ -288,8 +304,8 @@ public class ProgressExplorer implements ListSelectionListener, MouseWheelListen @Override public void mouseClicked(MouseEvent e) { if (SwingUtilities.isRightMouseButton(e)) { if (nodeInfoTabbedPane.isVisible()) { nodeInfoTabbedPane.setVisible(false); if (nodeTabbedPane.isVisible()) { nodeTabbedPane.setVisible(false); treeViewer.repaint(); treeViewer.setSelectedNode(null); } Loading
src/main/java/jetklee/Styles.java +6 −3 Original line number Diff line number Diff line Loading @@ -7,12 +7,15 @@ import java.awt.*; */ public class Styles { // html styles public static final String BLUE_STYLE = "'color:blue;'"; public static final String KEY_COLOR = "'color:blue;'"; // colors public static final Color RED_COLOR = new Color(255, 0, 0, 125); public static final Color GREEN_COLOR = new Color(34, 139, 34, 125); public static final Color DELETIONS_COLOR = new Color(255, 0, 0, 125); public static final Color ADDITIONS_COLOR = new Color(34, 139, 34, 125); public static final Color CHANGE_COLOR = new Color(0, 0, 255, 125); public static final Color CODE_HIGH_LIGHT_COLOR = new Color(255, 255, 0, 125); public static final Color BLACK_COLOR = Color.BLACK; public static final Color BACKGROUND_COLOR = Color.WHITE; // private static final Color ORANGE_COLOR = new Color(255, 165, 0, 125); Loading
src/main/java/jetklee/TextViewerBase.java +2 −2 Original line number Diff line number Diff line Loading @@ -6,7 +6,7 @@ import javax.swing.text.DefaultHighlighter; import javax.swing.text.Highlighter; import java.awt.*; import static jetklee.Styles.GREEN_COLOR; import static jetklee.Styles.ADDITIONS_COLOR; /** * General panel with text. Loading Loading @@ -48,7 +48,7 @@ public abstract class TextViewerBase extends JPanel { int endOffset = textArea.getLineEndOffset(line - 1); Highlighter highlighter = textArea.getHighlighter(); Highlighter.HighlightPainter painter = new DefaultHighlighter.DefaultHighlightPainter(GREEN_COLOR); Highlighter.HighlightPainter painter = new DefaultHighlighter.DefaultHighlightPainter(ADDITIONS_COLOR); highlighter.addHighlight(startOffset, endOffset, painter); } catch (BadLocationException e) { // Nothing to do. Loading
src/main/java/jetklee/TreeViewer.java +11 −6 Original line number Diff line number Diff line Loading @@ -46,7 +46,14 @@ public class TreeViewer extends JPanel { viewRect = null; setAutoscrolls(true); MouseAdapter ma = new MouseAdapter() { MouseAdapter ma = createMouseAdapter(); addMouseListener(ma); addMouseMotionListener(ma); } private MouseAdapter createMouseAdapter() { return new MouseAdapter() { private Point origin = null; @Override Loading @@ -69,8 +76,6 @@ public class TreeViewer extends JPanel { } } }; addMouseListener(ma); addMouseMotionListener(ma); } /** Loading Loading @@ -276,11 +281,11 @@ public class TreeViewer extends JPanel { } if (node.getLeft() != null && isVisibleNode(node.getLeft(), selectedRound)) { g2d.setColor(RED_COLOR); g2d.setColor(DELETIONS_COLOR); drawChild(g2d, node.getLeft()); } if (node.getRight() != null && isVisibleNode(node.getRight(), selectedRound)) { g2d.setColor(GREEN_COLOR); g2d.setColor(ADDITIONS_COLOR); drawChild(g2d, node.getRight()); } Loading