private JPanel makeParameterPanel() { expressionField = new JLabeledTextField(JMeterUtils.getResString("expression_field")); // $NON-NLS-1$ attributeField = new JLabeledTextField(JMeterUtils.getResString("attribute_field")); // $NON-NLS-1$ defaultField = new JLabeledTextField(JMeterUtils.getResString("default_value_field")); // $NON-NLS-1$ refNameField = new JLabeledTextField(JMeterUtils.getResString("ref_name_field")); // $NON-NLS-1$ matchNumberField = new JLabeledTextField(JMeterUtils.getResString("match_num_field")); // $NON-NLS-1$ JPanel panel = new JPanel(new GridBagLayout()); GridBagConstraints gbc = new GridBagConstraints(); initConstraints(gbc); addField(panel, refNameField, gbc); resetContraints(gbc); addField(panel, expressionField, gbc); resetContraints(gbc); addField(panel, attributeField, gbc); resetContraints(gbc); addField(panel, matchNumberField, gbc); resetContraints(gbc); gbc.weighty = 1; addField(panel, defaultField, gbc); return panel; }
@Override public void mouseReleased(MouseEvent e) { if (dragging && isValidDragAction(draggedNodes, getCurrentNode())) { dragging = false; JPopupMenu dragNdrop = new JPopupMenu(); JMenuItem item = new JMenuItem(JMeterUtils.getResString("insert_before")); // $NON-NLS-1$ item.addActionListener(actionHandler); item.setActionCommand(ReportDragNDrop.INSERT_BEFORE); dragNdrop.add(item); item = new JMenuItem(JMeterUtils.getResString("insert_after")); // $NON-NLS-1$ item.addActionListener(actionHandler); item.setActionCommand(ReportDragNDrop.INSERT_AFTER); dragNdrop.add(item); item = new JMenuItem(JMeterUtils.getResString("add_as_child")); // $NON-NLS-1$ item.addActionListener(actionHandler); item.setActionCommand(ReportDragNDrop.ADD); dragNdrop.add(item); dragNdrop.addSeparator(); item = new JMenuItem(JMeterUtils.getResString("cancel")); // $NON-NLS-1$ dragNdrop.add(item); displayPopUp(e, dragNdrop); } else { ReportGuiPackage.getInstance().getMainFrame().repaint(); } dragging = false; }
/** * Create the XPath task pane * * @return XPath task pane */ private JPanel createXpathExtractorTasksPanel() { Box xpathActionPanel = Box.createVerticalBox(); Box selectorAndButton = Box.createHorizontalBox(); Border margin = new EmptyBorder(5, 5, 0, 5); xpathActionPanel.setBorder(margin); xpathExpressionField = new JLabeledTextField(JMeterUtils.getResString("xpath_tester_field")); // $NON-NLS-1$ JButton xpathTester = new JButton(JMeterUtils.getResString("xpath_tester_button_test")); // $NON-NLS-1$ xpathTester.setActionCommand(XPATH_TESTER_COMMAND); xpathTester.addActionListener(this); selectorAndButton.add(xpathExpressionField); selectorAndButton.add(xpathTester); xpathActionPanel.add(selectorAndButton); xpathActionPanel.add(xmlConfPanel); xpathActionPanel.add(getFragment); xpathResultField = new JTextArea(); xpathResultField.setEditable(false); xpathResultField.setLineWrap(true); xpathResultField.setWrapStyleWord(true); JPanel xpathTasksPanel = new JPanel(new BorderLayout(0, 5)); xpathTasksPanel.add(xpathActionPanel, BorderLayout.NORTH); xpathTasksPanel.add(GuiUtils.makeScrollPane(xpathResultField), BorderLayout.CENTER); return xpathTasksPanel; }
private JPanel createGraphTitlePane() { JPanel titleNamePane = new JPanel(new BorderLayout()); syncWithName.setFont(new Font("SansSerif", Font.PLAIN, 10)); titleNamePane.add(graphTitle, BorderLayout.CENTER); titleNamePane.add(syncWithName, BorderLayout.EAST); JPanel titleStylePane = new JPanel(); titleStylePane.setLayout(new FlowLayout(FlowLayout.LEFT, 0, 5)); titleStylePane.add( GuiUtils.createLabelCombo( JMeterUtils.getResString("aggregate_graph_font"), // $NON-NLS-1$ titleFontNameList)); titleFontNameList.setSelectedIndex(0); // default: sans serif titleStylePane.add( GuiUtils.createLabelCombo( JMeterUtils.getResString("aggregate_graph_size"), // $NON-NLS-1$ titleFontSizeList)); titleFontSizeList.setSelectedItem(StatGraphProperties.fontSize[6]); // default: 16 titleStylePane.add( GuiUtils.createLabelCombo( JMeterUtils.getResString("aggregate_graph_style"), // $NON-NLS-1$ titleFontStyleList)); titleFontStyleList.setSelectedItem(JMeterUtils.getResString("fontstyle.bold")); // default: bold JPanel titlePane = new JPanel(new BorderLayout()); titlePane.setBorder( BorderFactory.createTitledBorder( BorderFactory.createEtchedBorder(), JMeterUtils.getResString("aggregate_graph_title_group"))); // $NON-NLS-1$ titlePane.add(titleNamePane, BorderLayout.NORTH); titlePane.add(titleStylePane, BorderLayout.SOUTH); return titlePane; }
/** * Test whether an XPath is valid. It seems the Xalan has no easy way to check, so this creates a * dummy test document, then tries to evaluate the xpath against it. * * @param xpathString XPath String to validate * @param showDialog weather to show a dialog * @return returns true if valid, valse otherwise. */ public static boolean validXPath(String xpathString, boolean showDialog) { String ret = null; boolean success = true; Document testDoc = null; try { testDoc = XPathUtil.makeDocumentBuilder(false, false, false, false).newDocument(); Element el = testDoc.createElement("root"); // $NON-NLS-1$ testDoc.appendChild(el); XPathUtil.validateXPath(testDoc, xpathString); } catch (IllegalArgumentException e) { log.warn(e.getLocalizedMessage()); success = false; ret = e.getLocalizedMessage(); } catch (ParserConfigurationException e) { success = false; ret = e.getLocalizedMessage(); } catch (TransformerException e) { success = false; ret = e.getLocalizedMessage(); } if (showDialog) { JOptionPane.showMessageDialog( null, (success) ? JMeterUtils.getResString("xpath_assertion_valid") : ret, // $NON-NLS-1$ (success) ? JMeterUtils.getResString("xpath_assertion_valid") : JMeterUtils //$NON-NLS-1$ .getResString("xpath_assertion_failed"), (success) ? JOptionPane.INFORMATION_MESSAGE // $NON-NLS-1$ : JOptionPane.ERROR_MESSAGE); } return success; }
/** {@inheritDoc} */ @Override public void setupTabPane() { // Add xpath tester pane if (rightSide.indexOfTab(JMeterUtils.getResString("xpath_tester_title")) < 0) { // $NON-NLS-1$ rightSide.addTab( JMeterUtils.getResString("xpath_tester_title"), xmlWithXPathPane); // $NON-NLS-1$ } clearData(); }
private void populateTemplatePage() { String selectedTemplate = templateList.getText(); Template template = TemplateManager.getInstance().getTemplateByName(selectedTemplate); helpDoc.setText(template.getDescription()); applyTemplateButton.setText( template.isTestPlan() ? JMeterUtils.getResString("template_create_from") : JMeterUtils.getResString("template_merge_from")); }
/** * Get the text for the value as the translation of the resource name. * * @param value value for which to get the translation * @param column index which column message parameters should be used * @param row not used * @return the text */ protected String getText(Object value, int row, int column) { if (value == null) { return ""; } if (columnsMsgParameters != null && columnsMsgParameters[column] != null) { return MessageFormat.format( JMeterUtils.getResString(value.toString()), columnsMsgParameters[column]); } else { return JMeterUtils.getResString(value.toString()); } }
private void actionMakeGraph() { if (model.getRowCount() > 1) { makeGraph(); tabbedGraph.setSelectedIndex(1); } else { JOptionPane.showMessageDialog( null, JMeterUtils.getResString("aggregate_graph_no_values_to_graph"), // $NON-NLS-1$ JMeterUtils.getResString("aggregate_graph_no_values_to_graph"), // $NON-NLS-1$ JOptionPane.WARNING_MESSAGE); } }
/** Create a new TestPlanGui. */ public TestPlanGui() { browseJar = new FileListPanel( JMeterUtils.getResString("test_plan_classpath_browse"), ".jar"); // $NON-NLS-1$ $NON-NLS-2$ argsPanel = new ArgumentsPanel(JMeterUtils.getResString("user_defined_variables")); // $NON-NLS-1$ serializedMode = new JCheckBox(JMeterUtils.getResString("testplan.serialized")); // $NON-NLS-1$ functionalMode = new JCheckBox(JMeterUtils.getResString("functional_mode")); // $NON-NLS-1$ tearDownOnShutdown = new JCheckBox(JMeterUtils.getResString("teardown_on_shutdown")); // $NON-NLS-1$ init(); }
/** Inits the GUI. */ private void init() { setLayout(new BorderLayout(0, 10)); setBorder(makeBorder()); add(makeTitlePanel(), BorderLayout.NORTH); JPanel mainPanel = new JPanel(new BorderLayout()); // USER_INPUT VerticalPanel assertionPanel = new VerticalPanel(); assertionPanel.setBorder( BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), "XML Schema")); // doctype HorizontalPanel xmlSchemaPanel = new HorizontalPanel(); xmlSchemaPanel.add( new JLabel(JMeterUtils.getResString("xmlschema_assertion_label"))); // $NON-NLS-1$ xmlSchema = new JTextField(26); xmlSchemaPanel.add(xmlSchema); assertionPanel.add(xmlSchemaPanel); mainPanel.add(assertionPanel, BorderLayout.NORTH); add(mainPanel, BorderLayout.CENTER); }
/** * Create a panel allowing the user to define variables for the test. * * @return a panel for user-defined variables */ private JPanel createVariablePanel() { argsPanel = new ArgumentsPanel( JMeterUtils.getResString("user_defined_variables"), // $NON-NLS-1$ Color.white); return argsPanel; }
private void init() { // called from ctor, so must not be overridable setLayout(new BorderLayout(10, 10)); setBorder(makeBorder()); setBackground(Color.white); JPanel pane = new JPanel(); pane.setLayout(new BorderLayout(10, 10)); pane.setBackground(Color.white); pane.add(this.getNamePanel(), BorderLayout.NORTH); VerticalPanel options = new VerticalPanel(Color.white); yAxisLabel.setBackground(Color.white); JLabel xLabel = new JLabel(JMeterUtils.getResString("report_chart_x_axis")); HorizontalPanel xpanel = new HorizontalPanel(Color.white); xLabel.setBorder(new EmptyBorder(5, 2, 5, 2)); xItems.setBackground(Color.white); xItems.setValues(AbstractTable.xitems); xpanel.add(xLabel); xpanel.add(xItems); options.add(xpanel); JLabel xALabel = new JLabel(JMeterUtils.getResString("report_chart_x_axis_label")); HorizontalPanel xApanel = new HorizontalPanel(Color.white); xALabel.setBorder(new EmptyBorder(5, 2, 5, 2)); xAxisLabel.setBackground(Color.white); xAxisLabel.setValues(AbstractChart.X_LABELS); xApanel.add(xALabel); xApanel.add(xAxisLabel); options.add(xApanel); JLabel yLabel = new JLabel(JMeterUtils.getResString("report_chart_y_axis")); HorizontalPanel ypanel = new HorizontalPanel(Color.white); yLabel.setBorder(new EmptyBorder(5, 2, 5, 2)); yItems.setBackground(Color.white); yItems.setValues(AbstractTable.items); ypanel.add(yLabel); ypanel.add(yItems); options.add(ypanel); options.add(yAxisLabel); options.add(caption); options.add(urls); add(pane, BorderLayout.NORTH); add(options, BorderLayout.CENTER); }
/** * Negated chechbox * * @return JCheckBox */ public JCheckBox getNegatedCheckBox() { if (negated == null) { negated = new JCheckBox(JMeterUtils.getResString("xpath_assertion_negate"), false); // $NON-NLS-1$ } return negated; }
/** * @param keys I18N keys * @return labels */ static String[] getLabels(String[] keys) { String[] labels = new String[keys.length]; for (int i = 0; i < labels.length; i++) { labels[i] = MessageFormat.format(JMeterUtils.getResString(keys[i]), COLUMNS_MSG_PARAMETERS[i]); } return labels; }
/** * Create pane for legend settings * * @return Legend pane */ private JPanel createLegendPane() { JPanel legendPanel = new JPanel(); legendPanel.setLayout(new FlowLayout(FlowLayout.LEFT, 0, 0)); legendPanel.setBorder( BorderFactory.createTitledBorder( BorderFactory.createEtchedBorder(), JMeterUtils.getResString("aggregate_graph_legend"))); // $NON-NLS-1$ legendPanel.add( GuiUtils.createLabelCombo( JMeterUtils.getResString("aggregate_graph_legend_placement"), // $NON-NLS-1$ legendPlacementList)); legendPlacementList.setSelectedItem( JMeterUtils.getResString("aggregate_graph_legend.placement.bottom")); // default: bottom legendPanel.add( GuiUtils.createLabelCombo( JMeterUtils.getResString("aggregate_graph_font"), // $NON-NLS-1$ fontNameList)); fontNameList.setSelectedIndex(0); // default: sans serif legendPanel.add( GuiUtils.createLabelCombo( JMeterUtils.getResString("aggregate_graph_size"), // $NON-NLS-1$ fontSizeList)); fontSizeList.setSelectedItem(StatGraphProperties.fontSize[2]); // default: 10 legendPanel.add( GuiUtils.createLabelCombo( JMeterUtils.getResString("aggregate_graph_style"), // $NON-NLS-1$ fontStyleList)); fontStyleList.setSelectedItem(JMeterUtils.getResString("fontstyle.normal")); // default: normal return legendPanel; }
/** * Show a dialog indicating that JMeter threads are stopping on a particular host. * * @param host the host where JMeter threads are stopping */ public void showStoppingMessage(String host) { stoppingMessage = new JDialog(this, JMeterUtils.getResString("stopping_test_title"), true); // $NON-NLS-1$ JLabel stopLabel = new JLabel(JMeterUtils.getResString("stopping_test") + ": " + host); // $NON-NLS-1$ stopLabel.setBorder(BorderFactory.createEmptyBorder(20, 20, 20, 20)); stoppingMessage.getContentPane().add(stopLabel); stoppingMessage.pack(); ComponentUtil.centerComponentInComponent(this, stoppingMessage); SwingUtilities.invokeLater( new Runnable() { public void run() { if (stoppingMessage != null) { stoppingMessage.setVisible(true); } } }); }
private JPanel createResetPanel() { resetInterpreter = new JCheckBox(JMeterUtils.getResString("bsh_script_reset_interpreter")); // $NON-NLS-1$ resetInterpreter.setName(BeanShellAssertion.PARAMETERS); JPanel resetInterpreterPanel = new JPanel(new BorderLayout()); resetInterpreterPanel.add(resetInterpreter, BorderLayout.WEST); return resetInterpreterPanel; }
/** * Check if existing Test Plan has been modified and ask user what he wants to do if test plan is * dirty * * @param actionEvent {@link ActionEvent} */ private void checkDirtyAndLoad(final ActionEvent actionEvent) throws HeadlessException { final String selectedTemplate = templateList.getText(); final Template template = TemplateManager.getInstance().getTemplateByName(selectedTemplate); if (template == null) { return; } final boolean isTestPlan = template.isTestPlan(); // Check if the user wants to drop any changes if (isTestPlan) { ActionRouter.getInstance() .doActionNow( new ActionEvent( actionEvent.getSource(), actionEvent.getID(), ActionNames.CHECK_DIRTY)); GuiPackage guiPackage = GuiPackage.getInstance(); if (guiPackage.isDirty()) { // Check if the user wants to create from template int response = JOptionPane.showConfirmDialog( GuiPackage.getInstance().getMainFrame(), JMeterUtils.getResString("cancel_new_from_template"), // $NON-NLS-1$ JMeterUtils.getResString("template_load?"), // $NON-NLS-1$ JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE); if (response == JOptionPane.YES_OPTION) { ActionRouter.getInstance() .doActionNow( new ActionEvent(actionEvent.getSource(), actionEvent.getID(), ActionNames.SAVE)); } if (response == JOptionPane.CLOSED_OPTION || response == JOptionPane.CANCEL_OPTION) { return; // Don't clear the plan } } } ActionRouter.getInstance() .doActionNow( new ActionEvent(actionEvent.getSource(), actionEvent.getID(), ActionNames.STOP_THREAD)); final File parent = template.getParent(); final File fileToCopy = parent != null ? new File(parent, template.getFileName()) : new File(JMeterUtils.getJMeterHome(), template.getFileName()); Load.loadProjectFile(actionEvent, fileToCopy, !isTestPlan, false); this.setVisible(false); }
private Component makeExtractorPanel() { JPanel panel = new HorizontalPanel(); panel.setBorder( BorderFactory.createTitledBorder( JMeterUtils.getResString("html_extractor_type"))); // $NON-NLS-1$ DefaultComboBoxModel m = new DefaultComboBoxModel(); for (String s : HtmlExtractor.getImplementations()) { m.addElement(s); } m.addElement(USE_DEFAULT_EXTRACTOR_IMPL); extractorImplName = new JComboBox(m); extractorImplName.setSelectedItem(HtmlExtractor.DEFAULT_EXTRACTOR); JLabel label2 = new JLabel(JMeterUtils.getResString("html_extractor_type")); // $NON-NLS-1$ label2.setLabelFor(extractorImplName); panel.add(label2); panel.add(extractorImplName); return panel; }
/** * Create pane for Y Axis options * * @return Y Axis pane */ private JPanel createGraphYAxisPane() { JPanel yAxisPane = new JPanel(); yAxisPane.setLayout(new FlowLayout(FlowLayout.LEFT, 0, 0)); yAxisPane.setBorder( BorderFactory.createTitledBorder( BorderFactory.createEtchedBorder(), JMeterUtils.getResString("aggregate_graph_yaxis_group"))); // $NON-NLS-1$ yAxisPane.add(maxValueYAxisLabel); return yAxisPane; }
private JPanel createRequestPanel() { JLabel reqLabel = new JLabel(JMeterUtils.getResString("tcp_request_data")); // $NON-NLS-1$ requestData = new JTextArea(3, 0); requestData.setLineWrap(true); reqLabel.setLabelFor(requestData); JPanel reqDataPanel = new JPanel(new BorderLayout(5, 0)); reqDataPanel.add(reqLabel, BorderLayout.WEST); reqDataPanel.add(requestData, BorderLayout.CENTER); return reqDataPanel; }
private JPanel createPortPanel() { JLabel label = new JLabel(JMeterUtils.getResString("tcp_port")); // $NON-NLS-1$ port = new JTextField(10); label.setLabelFor(port); JPanel PortPanel = new JPanel(new BorderLayout(5, 0)); PortPanel.add(label, BorderLayout.WEST); PortPanel.add(port, BorderLayout.CENTER); return PortPanel; }
private JPanel createClosePortPanel() { JLabel label = new JLabel(JMeterUtils.getResString("reuseconnection")); // $NON-NLS-1$ reUseConnection = new JCheckBox("", true); label.setLabelFor(reUseConnection); JPanel closePortPanel = new JPanel(new BorderLayout(5, 0)); closePortPanel.add(label, BorderLayout.WEST); closePortPanel.add(reUseConnection, BorderLayout.CENTER); return closePortPanel; }
private JPanel createServerPanel() { JLabel label = new JLabel(JMeterUtils.getResString("server")); // $NON-NLS-1$ server = new JTextField(10); label.setLabelFor(server); JPanel serverPanel = new JPanel(new BorderLayout(5, 0)); serverPanel.add(label, BorderLayout.WEST); serverPanel.add(server, BorderLayout.CENTER); return serverPanel; }
private JPanel createNoDelayPanel() { JLabel label = new JLabel(JMeterUtils.getResString("tcp_nodelay")); // $NON-NLS-1$ setNoDelay = new JCheckBox(); label.setLabelFor(setNoDelay); JPanel nodelayPanel = new JPanel(new BorderLayout(5, 0)); nodelayPanel.add(label, BorderLayout.WEST); nodelayPanel.add(setNoDelay, BorderLayout.CENTER); return nodelayPanel; }
private JPanel createTimeoutPanel() { JLabel label = new JLabel(JMeterUtils.getResString("tcp_timeout")); // $NON-NLS-1$ timeout = new JTextField(10); label.setLabelFor(timeout); JPanel timeoutPanel = new JPanel(new BorderLayout(5, 0)); timeoutPanel.add(label, BorderLayout.WEST); timeoutPanel.add(timeout, BorderLayout.CENTER); return timeoutPanel; }
private JPanel createScriptPanel() { scriptField = new RSyntaxTextArea(); scriptField.setSyntaxEditingStyle("text/java"); JLabel label = new JLabel(JMeterUtils.getResString("bsh_assertion_script")); // $NON-NLS-1$ label.setLabelFor(scriptField); JPanel panel = new JPanel(new BorderLayout()); panel.add(label, BorderLayout.NORTH); panel.add(new RTextScrollPane(scriptField), BorderLayout.CENTER); JTextArea explain = new JTextArea(JMeterUtils.getResString("bsh_assertion_script_variables")); // $NON-NLS-1$ explain.setLineWrap(true); explain.setEditable(false); explain.setBackground(this.getBackground()); panel.add(explain, BorderLayout.SOUTH); return panel; }
private JPanel createParameterPanel() { JLabel label = new JLabel(JMeterUtils.getResString("bsh_script_parameters")); // $NON-NLS-1$ parameters = new JTextField(10); parameters.setName(BeanShellAssertion.PARAMETERS); label.setLabelFor(parameters); JPanel parameterPanel = new JPanel(new BorderLayout(5, 0)); parameterPanel.add(label, BorderLayout.WEST); parameterPanel.add(parameters, BorderLayout.CENTER); return parameterPanel; }
/** * Check XPath button * * @return JButton */ public JButton getCheckXPathButton() { if (checkXPath == null) { checkXPath = new JButton(JMeterUtils.getResString("xpath_assertion_button")); // $NON-NLS-1$ checkXPath.addActionListener( new ActionListener() { @Override public void actionPerformed(ActionEvent e) { validXPath(xpath.getText(), true); } }); } return checkXPath; }