public FramesPanel(Project project, DebuggerStateManager stateManager) { super(project, stateManager); myStateManager = stateManager; setLayout(new BorderLayout()); myThreadsCombo = new ComboBoxWithWidePopup(); myThreadsCombo.setRenderer(new DebuggerComboBoxRenderer()); myThreadsListener = new ThreadsListener(); myThreadsCombo.addItemListener(myThreadsListener); myFramesList = new FramesList(); myFramesListener = new FramesListener(); myFramesList.addListSelectionListener(myFramesListener); myFramesList.addMouseListener( new MouseAdapter() { public void mousePressed(final MouseEvent e) { int index = myFramesList.locationToIndex(e.getPoint()); if (index >= 0 && myFramesList.isSelectedIndex(index)) { processListValue(myFramesList.getModel().getElementAt(index)); } } }); registerThreadsPopupMenu(myFramesList); setBorder(null); add(myThreadsCombo, BorderLayout.NORTH); add(new JScrollPane(myFramesList), BorderLayout.CENTER); }
/*invoked in swing thread*/ private void selectFrame(StackFrameProxy frame) { synchronized (myFramesList) { final int count = myFramesList.getElementCount(); final Object selectedValue = myFramesList.getSelectedValue(); final DefaultListModel model = myFramesList.getModel(); for (int idx = 0; idx < count; idx++) { final Object elem = model.getElementAt(idx); if (elem instanceof StackFrameDescriptorImpl) { final StackFrameDescriptorImpl item = (StackFrameDescriptorImpl) elem; if (frame.equals(item.getFrameProxy())) { if (!item.equals(selectedValue)) { myFramesList.setSelectedIndex(idx); } return; } } } } }
/*invoked in swing thread*/ protected void rebuild(final boolean updateOnly) { if (!updateOnly) { myThreadsCombo.removeAllItems(); synchronized (myFramesList) { myFramesList.clear(); } } final DebugProcessImpl process = getContext().getDebugProcess(); if (process != null) { process .getManagerThread() .schedule(new RefreshFramePanelCommand(updateOnly && myThreadsCombo.getItemCount() != 0)); } }