Example usage for javax.swing JScrollBar getMouseListeners

List of usage examples for javax.swing JScrollBar getMouseListeners

Introduction

In this page you can find the example usage for javax.swing JScrollBar getMouseListeners.

Prototype

public synchronized MouseListener[] getMouseListeners() 

Source Link

Document

Returns an array of all the mouse listeners registered on this component.

Usage

From source file:com.qspin.qtaste.ui.reporter.TestCaseReportTable.java

public void putEntry(TestResult tr, String campaignReportName) {
    boolean isInteractiveCommand = tr.getTestCaseDirectory().endsWith("QTaste_interactive");
    String testReportName = TestResultsReportManager.getInstance().getReportName();
    boolean isManualSUTStartOrStop = testReportName != null && testReportName.startsWith("Manual SUT");
    if (interactive) {
        if (!isInteractiveCommand && !isManualSUTStartOrStop) {
            return;
        }//from ww w .j a v a2  s  .c  o m
    } else {
        if (isInteractiveCommand) {
            return;
        }
        if (campaignReportName != null && !campaignReportName.equals(runName)) {
            return;
        }
        if (campaignReportName == null && !runName.equals("Run1")) {
            return;
        }
    }
    if (!testCases.containsKey(tr)) {
        Object[] cols = new Object[7];
        cols[TEST_CASE] = convertToUniqueTc(tr);
        cols[DETAILS] = tr.getExtraResultDetails();
        if (tr.getReturnValue() != null) {
            cols[RESULT] = tr.getReturnValue();
        }
        cols[STATUS] = getImage(tr.getStatus());
        if (tr.getStatus() != TestResult.Status.RUNNING) {
            cols[EXEC_TIME] = tr.getFormattedElapsedTime(false);
        }

        TestBedConfiguration testbed = TestBedConfiguration.getInstance();
        cols[TESTBED] = testbed.getFile().getName().replace("." + StaticConfiguration.CAMPAIGN_FILE_EXTENSION,
                "");

        cols[TC] = tr;
        //tcModel.addRow(cols);
        Integer rowNum = new Integer(tcModel.getRowCount());
        testCases.put(tr, rowNum);
        long currentScrollBarMax = 0;

        JScrollPane scrollPane = (JScrollPane) tcTable.getParent().getParent();
        JScrollBar scrollbar = scrollPane.getVerticalScrollBar();
        if (scrollbar != null) {
            if (scrollbar.getMouseListeners().length == 1) {
                scrollPane.addMouseWheelListener(new MouseWheelListener() {

                    public void mouseWheelMoved(MouseWheelEvent e) {
                        userScrollPosition = true;
                    }
                });
                scrollbar.addMouseListener(new MouseAdapter() {

                    @Override
                    public void mouseClicked(MouseEvent e) {
                        userScrollPosition = true;
                    }

                    @Override
                    public void mousePressed(MouseEvent e) {
                        userScrollPosition = true;
                    }
                });
            }
            currentScrollBarMax = scrollbar.getMaximum() - scrollbar.getSize().height - tcTable.getRowHeight();
            tcModel.addRow(cols);
            if (!userScrollPosition) {
                tcTable.scrollRectToVisible(tcTable.getCellRect(tcModel.getRowCount() - 1, 0, true));
                return;
            } else if (scrollbar.getValue() >= currentScrollBarMax) {
                tcTable.scrollRectToVisible(tcTable.getCellRect(tcModel.getRowCount() - 1, 0, true));
                userScrollPosition = false;
                return;
            } else {
                System.out.println("Scrollbar pos=" + scrollbar.getValue() + "; max=" + currentScrollBarMax
                        + "height=" + scrollbar.getSize().height);
            }
        } else {
            tcModel.addRow(cols);
        }
    } else {
        updateTestCaseRow(tr);
    }

}