/** * Constructs a DelayedReadValueModel for the given subject ValueModel and the specified Timer * delay in milliseconds using the given coalesce mode. * * @param subject the underlying (or wrapped) ValueModel * @param delay the milliseconds to wait before a change shall be committed * @param coalesce {@code true} to coalesce all pending changes, {@code false} to fire changes * with the delay when an update has been received * @throws IllegalArgumentException if the delay is negative * @see #setCoalesce(boolean) */ public DelayedReadValueModel(ValueModel subject, int delay, boolean coalesce) { this.subject = subject; this.coalesce = coalesce; this.timer = new Timer(delay, new ValueUpdateListener()); timer.setRepeats(false); subject.addValueChangeListener(new SubjectValueChangeHandler()); oldValue = subject.getValue(); }
protected List getRows() { Object value = rowsModel.getValue(); if (value == null) { return Collections.EMPTY_LIST; } return InvokerHelper.asList(value); }
public void valueChanged(TreeSelectionEvent e) { TreeNode node = (TreeNode) e.getPath().getLastPathComponent(); // System.out.println("valueChanged("+node+")"); JipFrame frame = node.getFrameOrNull(); JipMethod method = (frame == null) ? null : frame.getMethod(); mMethodModel.setValue(method); }
public void changed(Object source) { if (source != mMethodModel) { throw new RuntimeException("i wish i used asserts!"); } JipMethod selectedMethod = mMethodModel.getValue(); selectInAllMethods(selectedMethod); selectInCallTree(selectedMethod); }
public void valueChanged(ListSelectionEvent e) { if (e.getValueIsAdjusting()) { return; } JipMethod method = null; ListSelectionModel selectionModel = mMethods.getSelectionModel(); if (!selectionModel.isSelectionEmpty()) { int iSelected = selectionModel.getMinSelectionIndex(); iSelected = mAllMethodsSorterModel.modelIndex(iSelected); MethodRow row = mAllMethodsModel.getRow(iSelected); method = row.getMethod(); } // System.out.println("valueChanged("+perMethod+")"); mMethodModel.setValue(method); }
public void setValueAt(Object value, int rowIndex, int columnIndex) { List rows = getRows(); if (rowIndex < 0 || rowIndex >= rows.size()) { return; } if (columnIndex < 0 || columnIndex >= columnModel.getColumnCount()) { return; } Object row = getRows().get(rowIndex); rowModel.setValue(row); DefaultTableColumn column = (DefaultTableColumn) columnModel.getColumn(columnIndex); if (row == null || column == null) { return; } column.setValue(row, value, rowIndex, columnIndex); }
public Object getValueAt(int rowIndex, int columnIndex) { List rows = getRows(); Object answer = null; if (rowIndex < 0 || rowIndex >= rows.size()) { return answer; } if (columnIndex < 0 || columnIndex >= columnModel.getColumnCount()) { return answer; } Object row = getRows().get(rowIndex); rowModel.setValue(row); DefaultTableColumn column = (DefaultTableColumn) columnModel.getColumn(columnIndex); if (row == null || column == null) { return answer; } return column.getValue(row, rowIndex, columnIndex); }
public JipViewer(String title, JipRun run) { super(title); addKeyListener(this); mMethodModel.addChangeListener(this); // build the call tree mCallTreeRoot = new TreeNode(title); buildTree(run, mCallTreeRoot); mCallTree = new JTree(mCallTreeRoot); mCallTree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION); mCallTree.addTreeSelectionListener(this); mCallTree.addKeyListener(this); // build the allMethods table Collection<JipRun.PerMethodInfo> perMethodInfos = run.perMethodsInTotalTimeOrder(); long totalTimeForAllThreads = run.getTotalTimeForAllThreads(); for (JipRun.PerMethodInfo perMethod : perMethodInfos) { MethodRow row = new MethodRow(perMethod.getMethod()); for (JipFrame frame : perMethod.allFrames()) { if (!frame.isReentrant()) { row.addFrame(frame); } row.setTimeDenominator(totalTimeForAllThreads); } mAllMethodsModel.add(row); } mMethods = MethodViewer.makeTableForMethodRows(mAllMethodsModel); mMethods.getSelectionModel().addListSelectionListener(this); mMethods.addKeyListener(this); mAllMethodsSorterModel = (TableSorter) mMethods.getModel(); // make the ByPackageViewer mPkgViewer = new ByPackageViewer(run); mPkgViewer.addKeyListener(this); // make the RemoteController mRemoteController = new RemoteController(); mRemoteController.addKeyListener(this); // make the methodViewer MethodViewer methodViewer = new MethodViewer(run, mMethodModel); // combine all the views JTabbedPane tabPane = new JTabbedPane(); tabPane.addTab("call tree", new JScrollPane(mCallTree)); tabPane.addTab("methods", new JScrollPane(mMethods)); tabPane.addTab("by package", new JScrollPane(mPkgViewer)); tabPane.addTab("remote control", mRemoteController); tabPane.addTab("help", new HelpViewer()); tabPane.addKeyListener(this); tabPane.setMinimumSize(new Dimension(100, 200)); JSplitPane split = new JSplitPane(JSplitPane.VERTICAL_SPLIT, tabPane, methodViewer); setContentPane(split); pack(); setSize(new Dimension(1024, 768)); setVisible(true); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); }
/** * Sets the given new value immediately as the subject's new value. Note that change notifications * from the subject are deferred by this model. Therefore listeners registered with this model * will be notified after this model's delay. * * @param newValue the value to set */ public void setValue(Object newValue) { subject.setValue(newValue); }
/** * Returns the subject's value or in case of a pending commit, the pending new value. * * @return the subject's current or future value. */ public Object getValue() { return isPending() ? oldValue : subject.getValue(); }
public JipViewer(String title, JipRun run) { super(title); addKeyListener(this); mMethodModel.addChangeListener(this); // build the call tree mCallTreeRoot = new TreeNode(title); buildTree(run, mCallTreeRoot); mCallTree = new JTree(mCallTreeRoot); mCallTree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION); mCallTree.addTreeSelectionListener(this); mCallTree.addKeyListener(this); // build the allMethods table Collection<JipRun.PerMethodInfo> perMethodInfos = run.perMethodsInTotalTimeOrder(); long totalTimeForAllThreads = run.getTotalTimeForAllThreads(); for (JipRun.PerMethodInfo perMethod : perMethodInfos) { MethodRow row = new MethodRow(perMethod.getMethod()); for (JipFrame frame : perMethod.allFrames()) { if (!frame.isReentrant()) { row.addFrame(frame); } row.setTimeDenominator(totalTimeForAllThreads); } mAllMethodsModel.add(row); } mAllMethodsModel.sort(); mMethods = MethodViewer.makeTableForMethodRows(mAllMethodsModel); mMethods.getSelectionModel().addListSelectionListener(this); mMethods.addKeyListener(this); mAllMethodsSorterModel = (TableSorter) mMethods.getModel(); // make the ByPackageViewer mPkgViewer = new ByPackageViewer(run); mPkgViewer.addKeyListener(this); // Make the classs count viewer mClassAllocationViewer = new ClassAllocationViewer(run); mClassAllocationViewer.addKeyListener(this); if (instanceNumero == 0) { // make the RemoteController only if root mRemoteController = new RemoteController(); mRemoteController.addKeyListener(this); } // make the methodViewer MethodViewer methodViewerMethods = new MethodViewer(run, mMethodModel); MethodViewer methodViewerCallTree = new MethodViewer(run, mMethodModel); // combine all the views JTabbedPane tabPane = new JTabbedPane(); if (instanceNumero != 0 || FIRST_HAS_DATA) { JSplitPane splitPane = new JSplitPane( JSplitPane.VERTICAL_SPLIT, new JScrollPane(mCallTree), methodViewerCallTree); splitPane.setLayout(new BoxLayout(splitPane, BoxLayout.Y_AXIS)); tabPane.addTab("call tree", splitPane); splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT, new JScrollPane(mMethods), methodViewerMethods); splitPane.setLayout(new BoxLayout(splitPane, BoxLayout.Y_AXIS)); tabPane.addTab("methods", splitPane); tabPane.addTab("by package", new JScrollPane(mPkgViewer)); tabPane.addTab("class allocation", mClassAllocationViewer); } if (instanceNumero == 0) { tabPane.addTab("remote control", mRemoteController); } tabPane.addTab("help", new HelpViewer()); tabPane.addKeyListener(this); setContentPane(tabPane); pack(); setSize(new Dimension(1024, 768)); setVisible(true); if (instanceNumero == 0) { setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); } else { setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); } instanceNumero++; }