private void init() {
    templateList.setValues(TemplateManager.getInstance().getTemplateNames());
    templateList.addChangeListener(this);
    reloadTemplateButton.addActionListener(this);
    reloadTemplateButton.setFont(FONT_SMALL);
    this.getContentPane().setLayout(new BorderLayout(10, 0));

    JPanel templateBar = new JPanel(new BorderLayout());
    templateBar.add(templateList, BorderLayout.CENTER);
    JPanel reloadBtnBar = new JPanel();
    reloadBtnBar.add(reloadTemplateButton);
    templateBar.add(reloadBtnBar, BorderLayout.EAST);
    this.getContentPane().add(templateBar, BorderLayout.NORTH);
    helpDoc.setContentType("text/html"); // $NON-NLS-1$
    helpDoc.setEditable(false);
    helpDoc.addHyperlinkListener(this);
    this.getContentPane().add(scroller, BorderLayout.CENTER);

    applyTemplateButton.addActionListener(this);
    cancelButton.addActionListener(this);

    // Bottom buttons bar
    JPanel actionBtnBar = new JPanel(new FlowLayout());
    actionBtnBar.add(applyTemplateButton);
    actionBtnBar.add(cancelButton);
    this.getContentPane().add(actionBtnBar, BorderLayout.SOUTH);

    this.pack();
    this.setMinimumSize(new Dimension(MINIMAL_BOX_WIDTH, MINIMAL_BOX_HEIGHT));
    ComponentUtil.centerComponentInWindow(this, 50); // center position and 50% of screen size
    populateTemplatePage();
  }
 public void configure(TestElement element) {
   super.configure(element);
   LineChart bc = (LineChart) element;
   xItems.setText(bc.getXAxis());
   yItems.setText(bc.getYAxis());
   xAxisLabel.setText(bc.getXLabel());
   yAxisLabel.setText(bc.getYLabel());
   caption.setText(bc.getCaption());
   urls.setText(bc.getURLs());
 }
 public void modifyTestElement(TestElement element) {
   this.configureTestElement(element);
   LineChart bc = (LineChart) element;
   bc.setXAxis(xItems.getText());
   bc.setYAxis(yItems.getText());
   bc.setXLabel(xAxisLabel.getText());
   bc.setYLabel(yAxisLabel.getText());
   bc.setCaption(caption.getText());
   bc.setURLs(urls.getText());
 }
 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"));
 }
 /**
  * Do search
  *
  * @param e {@link ActionEvent}
  */
 @Override
 public void actionPerformed(ActionEvent e) {
   final Object source = e.getSource();
   if (source == cancelButton) {
     this.setVisible(false);
     return;
   } else if (source == applyTemplateButton) {
     checkDirtyAndLoad(e);
   } else if (source == reloadTemplateButton) {
     templateList.setValues(TemplateManager.getInstance().reset().getTemplateNames());
   }
 }
 /**
  * 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 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);
  }