📄 swinggui.java
字号:
context.hidePopup(); ((WindowListener)l[0]).windowClosing(e); } }); //adjustVerticalSplit = true; } leftDocked = false; } else { leftDocked = true; } } parent = finalT2.getParent(); if (parent != null) { if (parent != finalP2) { while (!(parent instanceof JFrame)) { parent = parent.getParent(); } JFrame frame = (JFrame)parent; debugGui.addTopLevel("Evaluate", frame); frame.setResizable(true); rightDocked = false; } else { rightDocked = true; } } if (leftDocked && t2Docked && rightDocked && t2Docked) { // no change return; } t1Docked = leftDocked; t2Docked = rightDocked; JSplitPane split = (JSplitPane)thisParent; if (leftDocked) { if (rightDocked) { finalSplit.setDividerLocation(0.5); } else { finalSplit.setDividerLocation(1.0); } if (adjustVerticalSplit) { split.setDividerLocation(0.66); } } else if (rightDocked) { finalSplit.setDividerLocation(0.0); split.setDividerLocation(0.66); } else { // both undocked split.setDividerLocation(1.0); } } public void componentHidden(ComponentEvent e) { check(e.getComponent()); } public void componentMoved(ComponentEvent e) { check(e.getComponent()); } public void componentResized(ComponentEvent e) { check(e.getComponent()); } public void componentShown(ComponentEvent e) { check(e.getComponent()); } }; p1.addContainerListener(new ContainerListener() { public void componentAdded(ContainerEvent e) { Component thisParent = finalThis.getParent(); JSplitPane split = (JSplitPane)thisParent; if (e.getChild() == finalT1) { if (finalT2.getParent() == finalP2) { // both docked finalSplit.setDividerLocation(0.5); } else { // left docked only finalSplit.setDividerLocation(1.0); } split.setDividerLocation(0.66); } } public void componentRemoved(ContainerEvent e) { Component thisParent = finalThis.getParent(); JSplitPane split = (JSplitPane)thisParent; if (e.getChild() == finalT1) { if (finalT2.getParent() == finalP2) { // right docked only finalSplit.setDividerLocation(0.0); split.setDividerLocation(0.66); } else { // both undocked split.setDividerLocation(1.0); } } } }); t1.addComponentListener(clistener); t2.addComponentListener(clistener); disable(); } public void actionPerformed(ActionEvent e) { if (!enabled) return; if (e.getActionCommand().equals("ContextSwitch")) { Dim.ContextData contextData = debugGui.dim.currentContextData(); if (contextData == null) { return; } int frameIndex = context.getSelectedIndex(); context.setToolTipText(toolTips.elementAt(frameIndex).toString()); int frameCount = contextData.frameCount(); if (frameIndex >= frameCount) { return; } Dim.StackFrame frame = contextData.getFrame(frameIndex); Object scope = frame.scope(); Object thisObj = frame.thisObj(); thisTable.resetTree(new VariableModel(debugGui.dim, thisObj)); VariableModel scopeModel; if (scope != thisObj) { scopeModel = new VariableModel(debugGui.dim, scope); } else { scopeModel = new VariableModel(); } localsTable.resetTree(scopeModel); debugGui.dim.contextSwitch(frameIndex); debugGui.showStopLine(frame); tableModel.updateModel(); } } public void disable() { context.setEnabled(false); thisTable.setEnabled(false); localsTable.setEnabled(false); evaluator.setEnabled(false); cmdLine.setEnabled(false); } public void enable() { context.setEnabled(true); thisTable.setEnabled(true); localsTable.setEnabled(true); evaluator.setEnabled(true); cmdLine.setEnabled(true); } public void disableUpdate() { enabled = false; } public void enableUpdate() { enabled = true; }};class Menubar extends JMenuBar implements ActionListener{ static final long serialVersionUID = 3217170497245911461L; private Vector interruptOnlyItems = new Vector(); private Vector runOnlyItems = new Vector(); SwingGui debugGui; JMenu windowMenu; JCheckBoxMenuItem breakOnExceptions; JCheckBoxMenuItem breakOnEnter; JCheckBoxMenuItem breakOnReturn; JMenu getDebugMenu() { return getMenu(2); } Menubar(SwingGui debugGui) { super(); this.debugGui = debugGui; String[] fileItems = {"Open...", "Run...", "", "Exit"}; String[] fileCmds = {"Open", "Load", "", "Exit"}; char[] fileShortCuts = {'0', 'N', '\0', 'X'}; int[] fileAccelerators = {KeyEvent.VK_O, KeyEvent.VK_N, 0, KeyEvent.VK_Q}; String[] editItems = {"Cut", "Copy", "Paste", "Go to function..."}; char[] editShortCuts = {'T', 'C', 'P', 'F'}; String[] debugItems = {"Break", "Go", "Step Into", "Step Over", "Step Out"}; char[] debugShortCuts = {'B', 'G', 'I', 'O', 'T'}; String[] plafItems = {"Metal", "Windows", "Motif"}; char [] plafShortCuts = {'M', 'W', 'F'}; int[] debugAccelerators = {KeyEvent.VK_PAUSE, KeyEvent.VK_F5, KeyEvent.VK_F11, KeyEvent.VK_F7, KeyEvent.VK_F8, 0, 0}; JMenu fileMenu = new JMenu("File"); fileMenu.setMnemonic('F'); JMenu editMenu = new JMenu("Edit"); editMenu.setMnemonic('E'); JMenu plafMenu = new JMenu("Platform"); plafMenu.setMnemonic('P'); JMenu debugMenu = new JMenu("Debug"); debugMenu.setMnemonic('D'); windowMenu = new JMenu("Window"); windowMenu.setMnemonic('W'); for (int i = 0; i < fileItems.length; ++i) { if (fileItems[i].length() == 0) { fileMenu.addSeparator(); } else { JMenuItem item = new JMenuItem(fileItems[i], fileShortCuts[i]); item.setActionCommand(fileCmds[i]); item.addActionListener(this); fileMenu.add(item); if (fileAccelerators[i] != 0) { KeyStroke k = KeyStroke.getKeyStroke(fileAccelerators[i], Event.CTRL_MASK); item.setAccelerator(k); } } } for (int i = 0; i < editItems.length; ++i) { JMenuItem item = new JMenuItem(editItems[i], editShortCuts[i]); item.addActionListener(this); editMenu.add(item); } for (int i = 0; i < plafItems.length; ++i) { JMenuItem item = new JMenuItem(plafItems[i], plafShortCuts[i]); item.addActionListener(this); plafMenu.add(item); } for (int i = 0; i < debugItems.length; ++i) { JMenuItem item = new JMenuItem(debugItems[i], debugShortCuts[i]); item.addActionListener(this); if (debugAccelerators[i] != 0) { KeyStroke k = KeyStroke.getKeyStroke(debugAccelerators[i], 0); item.setAccelerator(k); } if (i != 0) { interruptOnlyItems.add(item); } else { runOnlyItems.add(item); } debugMenu.add(item); } breakOnExceptions = new JCheckBoxMenuItem("Break on Exceptions"); breakOnExceptions.setMnemonic('X'); breakOnExceptions.addActionListener(this); breakOnExceptions.setSelected(false); debugMenu.add(breakOnExceptions); breakOnEnter = new JCheckBoxMenuItem("Break on Function Enter"); breakOnEnter.setMnemonic('E'); breakOnEnter.addActionListener(this); breakOnEnter.setSelected(false); debugMenu.add(breakOnEnter); breakOnReturn = new JCheckBoxMenuItem("Break on Function Return"); breakOnReturn.setMnemonic('R'); breakOnReturn.addActionListener(this); breakOnReturn.setSelected(false); debugMenu.add(breakOnReturn); add(fileMenu); add(editMenu); //add(plafMenu); add(debugMenu); JMenuItem item; windowMenu.add(item = new JMenuItem("Cascade", 'A')); item.addActionListener(this); windowMenu.add(item = new JMenuItem("Tile", 'T')); item.addActionListener(this); windowMenu.addSeparator(); windowMenu.add(item = new JMenuItem("Console", 'C')); item.addActionListener(this); add(windowMenu); updateEnabled(false); } public void actionPerformed(ActionEvent e) { String cmd = e.getActionCommand(); String plaf_name = null; if (cmd.equals("Metal")) { plaf_name = "javax.swing.plaf.metal.MetalLookAndFeel"; } else if (cmd.equals("Windows")) { plaf_name = "com.sun.java.swing.plaf.windows.WindowsLookAndFeel"; } else if (cmd.equals("Motif")) { plaf_name = "com.sun.java.swing.plaf.motif.MotifLookAndFeel"; } else { Object source = e.getSource(); if (source == breakOnExceptions) { debugGui.dim.breakOnExceptions = breakOnExceptions.isSelected(); } else if (source == breakOnEnter) { debugGui.dim.breakOnEnter = breakOnEnter.isSelected(); } else if (source == breakOnReturn) { debugGui.dim.breakOnReturn = breakOnReturn.isSelected(); } else { debugGui.actionPerformed(e); } return; } try { UIManager.setLookAndFeel(plaf_name); SwingUtilities.updateComponentTreeUI(debugGui); SwingUtilities.updateComponentTreeUI(debugGui.dlg); } catch (Exception ignored) { //ignored.printStackTrace(); } } void addFile(String url) { int count = windowMenu.getItemCount(); JMenuItem item; if (count == 4) { windowMenu.addSeparator(); count++; } JMenuItem lastItem = windowMenu.getItem(count -1); boolean hasMoreWin = false; int maxWin = 5; if (lastItem != null && lastItem.getText().equals("More Windows...")) { hasMoreWin = true; maxWin++; } if (!hasMoreWin && count - 4 == 5) { windowMenu.add(item = new JMenuItem("More Windows...", 'M')); item.setActionCommand("More Windows..."); item.addActionListener(this); return; } else if (count - 4 <= maxWin) { if (hasMoreWin) { count--; windowMenu.remove(lastItem); } String shortName = SwingGui.getShortName(url); windowMenu.add(item = new JMenuItem((char)('0' + (count-4)) + " " + shortName, '0' + (count - 4))); if (hasMoreWin) { windowMenu.add(lastItem); } } else { return; } item.setActionCommand(url); item.addActionListener(this); } void updateEnabled(boolean interrupted) { for (int i = 0; i != interruptOnlyItems.size(); ++i) { JMenuItem item = (JMenuItem)interruptOnlyItems.elementAt(i); item.setEnabled(interrupted); } for (int i = 0; i != runOnlyItems.size(); ++i) { JMenuItem item = (JMenuItem)runOnlyItems.elementAt(i); item.setEnabled(!interrupted); } }}/** * Class to consolidate all cases that require to implement Runnable * to avoid class generation bloat. */class RunProxy implements Runnable{ static final int OPEN_FILE = 1; static final int LOAD_FILE = 2; static final int UPDATE_SOURCE_TEXT = 3; static final int ENTER_INTERRUPT = 4; private SwingGui debugGui; private int type; String fileName; String text; Dim.SourceInfo sourceInfo; Dim.StackFrame lastFrame; String threadTitle; String alertMessage; RunProxy(SwingGui debugGui, int type) { this.debugGui = debugGui; this.type = type;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -