Search in sources :

Example 1 with ObjectTableSorter

use of org.apache.jorphan.gui.ObjectTableSorter in project jmeter by apache.

the class StatGraphVisualizer method init.

/**
     * Main visualizer setup.
     */
private void init() {
    // WARNING: called from ctor so must not be overridden (i.e. must be private or final)
    this.setLayout(new BorderLayout());
    // MAIN PANEL
    JPanel mainPanel = new JPanel();
    Border margin = new EmptyBorder(10, 10, 5, 10);
    Border margin2 = new EmptyBorder(10, 10, 5, 10);
    mainPanel.setBorder(margin);
    mainPanel.setLayout(new BoxLayout(mainPanel, BoxLayout.Y_AXIS));
    mainPanel.add(makeTitlePanel());
    myJTable = new JTable(model);
    myJTable.setRowSorter(new ObjectTableSorter(model).fixLastRow());
    JMeterUtils.applyHiDPI(myJTable);
    // Fix centering of titles
    HeaderAsPropertyRendererWrapper.setupDefaultRenderer(myJTable, getColumnsMsgParameters());
    myJTable.setPreferredScrollableViewportSize(new Dimension(500, 70));
    RendererUtils.applyRenderers(myJTable, getRenderers());
    myScrollPane = new JScrollPane(myJTable);
    settingsPane = new VerticalPanel();
    settingsPane.setBorder(margin2);
    graphPanel = new AxisGraph();
    graphPanel.setPreferredSize(new Dimension(defaultWidth, defaultHeight));
    settingsPane.add(createGraphActionsPane());
    settingsPane.add(createGraphColumnPane());
    settingsPane.add(createGraphTitlePane());
    settingsPane.add(createGraphDimensionPane());
    JPanel axisPane = new JPanel(new BorderLayout());
    axisPane.add(createGraphXAxisPane(), BorderLayout.WEST);
    axisPane.add(createGraphYAxisPane(), BorderLayout.CENTER);
    settingsPane.add(axisPane);
    settingsPane.add(createLegendPane());
    //$NON-NLS-1$
    tabbedGraph.addTab(JMeterUtils.getResString("aggregate_graph_tab_settings"), settingsPane);
    //$NON-NLS-1$
    tabbedGraph.addTab(JMeterUtils.getResString("aggregate_graph_tab_graph"), graphPanel);
    // If clic on the Graph tab, make the graph (without apply interval or filter)
    tabbedGraph.addChangeListener(changeEvent -> {
        JTabbedPane srcTab = (JTabbedPane) changeEvent.getSource();
        int index = srcTab.getSelectedIndex();
        if (srcTab.getTitleAt(index).equals(JMeterUtils.getResString("aggregate_graph_tab_graph"))) {
            actionMakeGraph();
        }
    });
    spane = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
    spane.setOneTouchExpandable(true);
    spane.setLeftComponent(myScrollPane);
    spane.setRightComponent(tabbedGraph);
    spane.setResizeWeight(.2);
    // see bug jdk 4131528
    spane.setBorder(null);
    spane.setContinuousLayout(true);
    this.add(mainPanel, BorderLayout.NORTH);
    this.add(spane, BorderLayout.CENTER);
    new Timer(REFRESH_PERIOD, e -> {
        synchronized (lock) {
            while (!newRows.isEmpty()) {
                model.insertRow(newRows.pop(), model.getRowCount() - 1);
            }
        }
        model.fireTableDataChanged();
    }).start();
}
Also used : JScrollPane(javax.swing.JScrollPane) Color(java.awt.Color) VerticalPanel(org.apache.jmeter.gui.util.VerticalPanel) UIManager(javax.swing.UIManager) Format(java.text.Format) NumberRenderer(org.apache.jorphan.gui.NumberRenderer) LoggerFactory(org.slf4j.LoggerFactory) SampleResult(org.apache.jmeter.samplers.SampleResult) TableCellRenderer(javax.swing.table.TableCellRenderer) ActionRouter(org.apache.jmeter.gui.action.ActionRouter) Border(javax.swing.border.Border) Matcher(java.util.regex.Matcher) GuiUtils(org.apache.jorphan.gui.GuiUtils) Map(java.util.Map) JFileChooser(javax.swing.JFileChooser) BorderLayout(java.awt.BorderLayout) JComboBox(javax.swing.JComboBox) Timer(javax.swing.Timer) PatternSyntaxException(java.util.regex.PatternSyntaxException) Font(java.awt.Font) ObjectTableSorter(org.apache.jorphan.gui.ObjectTableSorter) RendererUtils(org.apache.jorphan.gui.RendererUtils) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) CSVSaveService(org.apache.jmeter.save.CSVSaveService) BorderFactory(javax.swing.BorderFactory) Box(javax.swing.Box) ActionNames(org.apache.jmeter.gui.action.ActionNames) FilePanel(org.apache.jmeter.gui.util.FilePanel) Dimension(java.awt.Dimension) List(java.util.List) AbstractVisualizer(org.apache.jmeter.visualizers.gui.AbstractVisualizer) JCheckBox(javax.swing.JCheckBox) JTable(javax.swing.JTable) EmptyBorder(javax.swing.border.EmptyBorder) Pattern(java.util.regex.Pattern) JPanel(javax.swing.JPanel) JColorChooser(javax.swing.JColorChooser) JMeterUtils(org.apache.jmeter.util.JMeterUtils) ActionListener(java.awt.event.ActionListener) JSplitPane(javax.swing.JSplitPane) JTextField(javax.swing.JTextField) FileDialoger(org.apache.jmeter.gui.util.FileDialoger) ArrayUtils(org.apache.commons.lang3.ArrayUtils) Deque(java.util.Deque) SwingConstants(javax.swing.SwingConstants) MessageFormat(java.text.MessageFormat) ArrayList(java.util.ArrayList) SaveGraphics(org.apache.jmeter.gui.action.SaveGraphics) RateRenderer(org.apache.jorphan.gui.RateRenderer) Charset(java.nio.charset.Charset) JTabbedPane(javax.swing.JTabbedPane) JLabeledTextField(org.apache.jorphan.gui.JLabeledTextField) OutputStreamWriter(java.io.OutputStreamWriter) HeaderAsPropertyRendererWrapper(org.apache.jmeter.gui.util.HeaderAsPropertyRendererWrapper) BoxLayout(javax.swing.BoxLayout) JComponent(javax.swing.JComponent) FlowLayout(java.awt.FlowLayout) Clearable(org.apache.jmeter.samplers.Clearable) JButton(javax.swing.JButton) Functor(org.apache.jorphan.reflect.Functor) Logger(org.slf4j.Logger) DecimalFormat(java.text.DecimalFormat) FileOutputStream(java.io.FileOutputStream) IOException(java.io.IOException) JOptionPane(javax.swing.JOptionPane) ActionEvent(java.awt.event.ActionEvent) ConcurrentLinkedDeque(java.util.concurrent.ConcurrentLinkedDeque) JScrollPane(javax.swing.JScrollPane) JLabel(javax.swing.JLabel) ObjectTableModel(org.apache.jorphan.gui.ObjectTableModel) JPanel(javax.swing.JPanel) BoxLayout(javax.swing.BoxLayout) JTabbedPane(javax.swing.JTabbedPane) Dimension(java.awt.Dimension) VerticalPanel(org.apache.jmeter.gui.util.VerticalPanel) BorderLayout(java.awt.BorderLayout) Timer(javax.swing.Timer) JTable(javax.swing.JTable) ObjectTableSorter(org.apache.jorphan.gui.ObjectTableSorter) EmptyBorder(javax.swing.border.EmptyBorder) JSplitPane(javax.swing.JSplitPane) Border(javax.swing.border.Border) EmptyBorder(javax.swing.border.EmptyBorder)

Example 2 with ObjectTableSorter

use of org.apache.jorphan.gui.ObjectTableSorter in project jmeter by apache.

the class StatVisualizer method init.

/**
     * Main visualizer setup.
     */
private void init() {
    // WARNING: called from ctor so must not be overridden (i.e. must be private or final)
    this.setLayout(new BorderLayout());
    // MAIN PANEL
    JPanel mainPanel = new JPanel();
    Border margin = new EmptyBorder(10, 10, 5, 10);
    mainPanel.setBorder(margin);
    mainPanel.setLayout(new BoxLayout(mainPanel, BoxLayout.Y_AXIS));
    mainPanel.add(makeTitlePanel());
    myJTable = new JTable(model);
    myJTable.setRowSorter(new ObjectTableSorter(model).fixLastRow());
    JMeterUtils.applyHiDPI(myJTable);
    HeaderAsPropertyRendererWrapper.setupDefaultRenderer(myJTable, StatGraphVisualizer.getColumnsMsgParameters());
    myJTable.setPreferredScrollableViewportSize(new Dimension(500, 70));
    RendererUtils.applyRenderers(myJTable, StatGraphVisualizer.getRenderers());
    myScrollPane = new JScrollPane(myJTable);
    this.add(mainPanel, BorderLayout.NORTH);
    this.add(myScrollPane, BorderLayout.CENTER);
    saveTable.addActionListener(this);
    JPanel opts = new JPanel();
    opts.add(useGroupName, BorderLayout.WEST);
    opts.add(saveTable, BorderLayout.CENTER);
    opts.add(saveHeaders, BorderLayout.EAST);
    this.add(opts, BorderLayout.SOUTH);
    new Timer(REFRESH_PERIOD, e -> {
        synchronized (lock) {
            while (!newRows.isEmpty()) {
                model.insertRow(newRows.pop(), model.getRowCount() - 1);
            }
        }
        model.fireTableDataChanged();
    }).start();
}
Also used : JScrollPane(javax.swing.JScrollPane) JMeterUtils(org.apache.jmeter.util.JMeterUtils) ActionListener(java.awt.event.ActionListener) FileDialoger(org.apache.jmeter.gui.util.FileDialoger) SampleResult(org.apache.jmeter.samplers.SampleResult) TestElement(org.apache.jmeter.testelement.TestElement) Deque(java.util.Deque) Border(javax.swing.border.Border) Charset(java.nio.charset.Charset) Map(java.util.Map) OutputStreamWriter(java.io.OutputStreamWriter) JFileChooser(javax.swing.JFileChooser) BorderLayout(java.awt.BorderLayout) HeaderAsPropertyRendererWrapper(org.apache.jmeter.gui.util.HeaderAsPropertyRendererWrapper) BoxLayout(javax.swing.BoxLayout) Timer(javax.swing.Timer) Clearable(org.apache.jmeter.samplers.Clearable) JButton(javax.swing.JButton) ObjectTableSorter(org.apache.jorphan.gui.ObjectTableSorter) RendererUtils(org.apache.jorphan.gui.RendererUtils) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) FileOutputStream(java.io.FileOutputStream) CSVSaveService(org.apache.jmeter.save.CSVSaveService) IOException(java.io.IOException) ActionEvent(java.awt.event.ActionEvent) ConcurrentLinkedDeque(java.util.concurrent.ConcurrentLinkedDeque) JScrollPane(javax.swing.JScrollPane) Dimension(java.awt.Dimension) AbstractVisualizer(org.apache.jmeter.visualizers.gui.AbstractVisualizer) JCheckBox(javax.swing.JCheckBox) JTable(javax.swing.JTable) EmptyBorder(javax.swing.border.EmptyBorder) ObjectTableModel(org.apache.jorphan.gui.ObjectTableModel) JPanel(javax.swing.JPanel) JPanel(javax.swing.JPanel) BorderLayout(java.awt.BorderLayout) Timer(javax.swing.Timer) BoxLayout(javax.swing.BoxLayout) JTable(javax.swing.JTable) ObjectTableSorter(org.apache.jorphan.gui.ObjectTableSorter) Dimension(java.awt.Dimension) EmptyBorder(javax.swing.border.EmptyBorder) Border(javax.swing.border.Border) EmptyBorder(javax.swing.border.EmptyBorder)

Example 3 with ObjectTableSorter

use of org.apache.jorphan.gui.ObjectTableSorter in project jmeter by apache.

the class SummaryReport method init.

/**
     * Main visualizer setup.
     */
private void init() {
    // WARNING: called from ctor so must not be overridden (i.e. must be private or final)
    this.setLayout(new BorderLayout());
    // MAIN PANEL
    JPanel mainPanel = new JPanel();
    Border margin = new EmptyBorder(10, 10, 5, 10);
    mainPanel.setBorder(margin);
    mainPanel.setLayout(new BoxLayout(mainPanel, BoxLayout.Y_AXIS));
    mainPanel.add(makeTitlePanel());
    myJTable = new JTable(model);
    myJTable.setRowSorter(new ObjectTableSorter(model).fixLastRow());
    JMeterUtils.applyHiDPI(myJTable);
    HeaderAsPropertyRendererWrapper.setupDefaultRenderer(myJTable);
    myJTable.setPreferredScrollableViewportSize(new Dimension(500, 70));
    RendererUtils.applyRenderers(myJTable, RENDERERS);
    myScrollPane = new JScrollPane(myJTable);
    this.add(mainPanel, BorderLayout.NORTH);
    this.add(myScrollPane, BorderLayout.CENTER);
    saveTable.addActionListener(this);
    JPanel opts = new JPanel();
    opts.add(useGroupName, BorderLayout.WEST);
    opts.add(saveTable, BorderLayout.CENTER);
    opts.add(saveHeaders, BorderLayout.EAST);
    this.add(opts, BorderLayout.SOUTH);
}
Also used : JScrollPane(javax.swing.JScrollPane) JPanel(javax.swing.JPanel) BorderLayout(java.awt.BorderLayout) BoxLayout(javax.swing.BoxLayout) JTable(javax.swing.JTable) ObjectTableSorter(org.apache.jorphan.gui.ObjectTableSorter) Dimension(java.awt.Dimension) EmptyBorder(javax.swing.border.EmptyBorder) Border(javax.swing.border.Border) EmptyBorder(javax.swing.border.EmptyBorder)

Example 4 with ObjectTableSorter

use of org.apache.jorphan.gui.ObjectTableSorter in project jmeter by apache.

the class TableVisualizer method init.

private void init() {
    // WARNING: called from ctor so must not be overridden (i.e. must be private or final)
    this.setLayout(new BorderLayout());
    // MAIN PANEL
    JPanel mainPanel = new JPanel();
    Border margin = new EmptyBorder(10, 10, 5, 10);
    mainPanel.setBorder(margin);
    mainPanel.setLayout(new VerticalLayout(5, VerticalLayout.BOTH));
    // NAME
    mainPanel.add(makeTitlePanel());
    // Set up the table itself
    table = new JTable(model);
    table.setRowSorter(new ObjectTableSorter(model).setValueComparator(5, Comparator.nullsFirst((ImageIcon o1, ImageIcon o2) -> {
        if (o1 == o2) {
            return 0;
        }
        if (o1 == imageSuccess) {
            return -1;
        }
        if (o1 == imageFailure) {
            return 1;
        }
        throw new IllegalArgumentException("Only success and failure images can be compared");
    })));
    JMeterUtils.applyHiDPI(table);
    HeaderAsPropertyRendererWrapper.setupDefaultRenderer(table);
    RendererUtils.applyRenderers(table, RENDERERS);
    tableScrollPanel = new JScrollPane(table);
    tableScrollPanel.setViewportBorder(BorderFactory.createEmptyBorder(2, 2, 2, 2));
    //$NON-NLS-1$
    autoscroll = new JCheckBox(JMeterUtils.getResString("view_results_autoscroll"));
    //$NON-NLS-1$
    childSamples = new JCheckBox(JMeterUtils.getResString("view_results_childsamples"));
    // Set up footer of table which displays numerics of the graphs
    JPanel dataPanel = new JPanel();
    // $NON-NLS-1$
    JLabel dataLabel = new JLabel(JMeterUtils.getResString("graph_results_latest_sample"));
    dataLabel.setForeground(Color.black);
    dataField = new JTextField(5);
    dataField.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
    dataField.setEditable(false);
    dataField.setForeground(Color.black);
    dataField.setBackground(getBackground());
    dataPanel.add(dataLabel);
    dataPanel.add(dataField);
    JPanel averagePanel = new JPanel();
    // $NON-NLS-1$
    JLabel averageLabel = new JLabel(JMeterUtils.getResString("graph_results_average"));
    averageLabel.setForeground(Color.blue);
    averageField = new JTextField(5);
    averageField.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
    averageField.setEditable(false);
    averageField.setForeground(Color.blue);
    averageField.setBackground(getBackground());
    averagePanel.add(averageLabel);
    averagePanel.add(averageField);
    JPanel deviationPanel = new JPanel();
    // $NON-NLS-1$
    JLabel deviationLabel = new JLabel(JMeterUtils.getResString("graph_results_deviation"));
    deviationLabel.setForeground(Color.red);
    deviationField = new JTextField(5);
    deviationField.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
    deviationField.setEditable(false);
    deviationField.setForeground(Color.red);
    deviationField.setBackground(getBackground());
    deviationPanel.add(deviationLabel);
    deviationPanel.add(deviationField);
    JPanel noSamplesPanel = new JPanel();
    // $NON-NLS-1$
    JLabel noSamplesLabel = new JLabel(JMeterUtils.getResString("graph_results_no_samples"));
    noSamplesField = new JTextField(8);
    noSamplesField.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
    noSamplesField.setEditable(false);
    noSamplesField.setForeground(Color.black);
    noSamplesField.setBackground(getBackground());
    noSamplesPanel.add(noSamplesLabel);
    noSamplesPanel.add(noSamplesField);
    JPanel tableInfoPanel = new JPanel();
    tableInfoPanel.setLayout(new FlowLayout());
    tableInfoPanel.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
    tableInfoPanel.add(noSamplesPanel);
    tableInfoPanel.add(dataPanel);
    tableInfoPanel.add(averagePanel);
    tableInfoPanel.add(deviationPanel);
    JPanel tableControlsPanel = new JPanel(new BorderLayout());
    tableControlsPanel.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 0));
    JPanel jp = new HorizontalPanel();
    jp.add(autoscroll);
    jp.add(childSamples);
    tableControlsPanel.add(jp, BorderLayout.WEST);
    tableControlsPanel.add(tableInfoPanel, BorderLayout.CENTER);
    // Set up the table with footer
    JPanel tablePanel = new JPanel();
    tablePanel.setLayout(new BorderLayout());
    tablePanel.add(tableScrollPanel, BorderLayout.CENTER);
    tablePanel.add(tableControlsPanel, BorderLayout.SOUTH);
    // Add the main panel and the graph
    this.add(mainPanel, BorderLayout.NORTH);
    this.add(tablePanel, BorderLayout.CENTER);
    new Timer(REFRESH_PERIOD, e -> collectNewSamples()).start();
}
Also used : JScrollPane(javax.swing.JScrollPane) Color(java.awt.Color) JMeterUtils(org.apache.jmeter.util.JMeterUtils) Format(java.text.Format) JTextField(javax.swing.JTextField) Calculator(org.apache.jmeter.util.Calculator) SimpleDateFormat(java.text.SimpleDateFormat) SampleResult(org.apache.jmeter.samplers.SampleResult) Deque(java.util.Deque) TableCellRenderer(javax.swing.table.TableCellRenderer) HorizontalPanel(org.apache.jmeter.gui.util.HorizontalPanel) Border(javax.swing.border.Border) VerticalLayout(org.apache.jorphan.gui.layout.VerticalLayout) ImageIcon(javax.swing.ImageIcon) BorderLayout(java.awt.BorderLayout) HeaderAsPropertyRendererWrapper(org.apache.jmeter.gui.util.HeaderAsPropertyRendererWrapper) Timer(javax.swing.Timer) FlowLayout(java.awt.FlowLayout) Clearable(org.apache.jmeter.samplers.Clearable) Functor(org.apache.jorphan.reflect.Functor) ObjectTableSorter(org.apache.jorphan.gui.ObjectTableSorter) RendererUtils(org.apache.jorphan.gui.RendererUtils) BorderFactory(javax.swing.BorderFactory) ConcurrentLinkedDeque(java.util.concurrent.ConcurrentLinkedDeque) JScrollPane(javax.swing.JScrollPane) JMeter(org.apache.jmeter.JMeter) AbstractVisualizer(org.apache.jmeter.visualizers.gui.AbstractVisualizer) JLabel(javax.swing.JLabel) JCheckBox(javax.swing.JCheckBox) JTable(javax.swing.JTable) EmptyBorder(javax.swing.border.EmptyBorder) ObjectTableModel(org.apache.jorphan.gui.ObjectTableModel) RightAlignRenderer(org.apache.jorphan.gui.RightAlignRenderer) Comparator(java.util.Comparator) JPanel(javax.swing.JPanel) JPanel(javax.swing.JPanel) ImageIcon(javax.swing.ImageIcon) FlowLayout(java.awt.FlowLayout) JLabel(javax.swing.JLabel) JTextField(javax.swing.JTextField) JCheckBox(javax.swing.JCheckBox) BorderLayout(java.awt.BorderLayout) Timer(javax.swing.Timer) JTable(javax.swing.JTable) HorizontalPanel(org.apache.jmeter.gui.util.HorizontalPanel) VerticalLayout(org.apache.jorphan.gui.layout.VerticalLayout) ObjectTableSorter(org.apache.jorphan.gui.ObjectTableSorter) EmptyBorder(javax.swing.border.EmptyBorder) Border(javax.swing.border.Border) EmptyBorder(javax.swing.border.EmptyBorder)

Aggregations

BorderLayout (java.awt.BorderLayout)4 JPanel (javax.swing.JPanel)4 JScrollPane (javax.swing.JScrollPane)4 JTable (javax.swing.JTable)4 Dimension (java.awt.Dimension)3 Deque (java.util.Deque)3 ConcurrentLinkedDeque (java.util.concurrent.ConcurrentLinkedDeque)3 BoxLayout (javax.swing.BoxLayout)3 JCheckBox (javax.swing.JCheckBox)3 Border (javax.swing.border.Border)3 EmptyBorder (javax.swing.border.EmptyBorder)3 ObjectTableSorter (org.apache.jorphan.gui.ObjectTableSorter)3 Color (java.awt.Color)2 FlowLayout (java.awt.FlowLayout)2 ActionEvent (java.awt.event.ActionEvent)2 ActionListener (java.awt.event.ActionListener)2 FileOutputStream (java.io.FileOutputStream)2 IOException (java.io.IOException)2 OutputStreamWriter (java.io.OutputStreamWriter)2 Charset (java.nio.charset.Charset)2