/** * Initialize the components and layout of this component. */ private void init() { // WARNING: called from ctor so must not be overridden (i.e. must be private or final) setLayout(new BorderLayout(0, 10)); if (displayName) { setBorder(makeBorder()); add(makeTitlePanel(), BorderLayout.NORTH); } add(createTablePanel(), BorderLayout.CENTER); // Force the table to be at least 70 pixels high add(Box.createVerticalStrut(70), BorderLayout.WEST); add(createButtonPanel(), BorderLayout.SOUTH); }
/** * Invoked when an action occurs. This implementation supports the add and * delete buttons. * * @param e * the event that has occurred */ @Override public void actionPerformed(ActionEvent e) { String action = e.getActionCommand(); if (action.equals(DELETE)) { deleteArgument(); } else if (action.equals(ADD)) { addArgument(); } }
/** * Create a new SimpleConfigGui as either a standalone or an embedded * component. * * @param displayName * indicates whether or not this component should display its * name. If true, this is a standalone component. If false, this * component is intended to be used as a subpanel for another * component. */ public SimpleConfigGui(boolean displayName) { this.displayName = displayName; init(); }
/** * Create a panel containing the add and delete buttons. * * @return a GUI panel containing the buttons */ private JPanel createButtonPanel() { /** A button for adding new parameters to the table. */ JButton add = new JButton(JMeterUtils.getResString("add")); //$NON-NLS-1$ add.setActionCommand(ADD); add.addActionListener(this); add.setEnabled(true); delete = new JButton(JMeterUtils.getResString("delete")); // $NON-NLS-1$ delete.setActionCommand(DELETE); delete.addActionListener(this); checkDeleteStatus(); JPanel buttonPanel = new JPanel(); buttonPanel.add(add); buttonPanel.add(delete); return buttonPanel; }
/** * Create a GUI panel containing the table of configuration parameters. * * @return a GUI panel containing the parameter table */ private Component createTablePanel() { tableModel = new PowerTableModel( new String[] { COLUMN_NAMES_0, COLUMN_NAMES_1 }, new Class[] { String.class, String.class }); table = new JTable(tableModel); JMeterUtils.applyHiDPI(table); table.getTableHeader().setDefaultRenderer(new HeaderAsPropertyRenderer()); table.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); return makeScrollPane(table); }
/** * A newly created component can be initialized with the contents of a Test * Element object by calling this method. The component is responsible for * querying the Test Element object for the relevant information to display * in its GUI. * <p> * This implementation retrieves all key/value pairs from the TestElement * object and sets these values in the GUI. * * @param el * the TestElement to configure */ @Override public void configure(TestElement el) { super.configure(el); tableModel.clearData(); PropertyIterator iter = el.propertyIterator(); while (iter.hasNext()) { JMeterProperty prop = iter.next(); tableModel.addRow(new Object[] { prop.getName(), prop.getStringValue() }); } checkDeleteStatus(); }