/**
  * Tests constructor for 'RemoveClassDiagramAction(Diagram)' for accuracy.
  *
  * <p>Verify that RemoveClassDiagramAction(Diagram) is correct and the instance should not be
  * null.
  */
 public void testRemoveClassDiagramAction() {
   assertNotNull("The RemoveClassDiagramAction instance should not be null.", action);
   assertEquals(
       "The presentation name is incorrect.",
       "Remove diagram " + diagram.getName(),
       action.getPresentationName());
 }
  /**
   * This method will check the action's name and type value.
   *
   * @param action the action instance to be checked.
   * @param name the name of action.
   * @param type the type of action.
   * @throws Exception if any exception occurs when testing.
   */
  private void checkCreateDiagramAction(CreateDiagramAction action, String name, String type)
      throws Exception {
    // check the attributes here.
    assertNotNull("The CreateDiagramAction constructor is incorrect.", action);

    // add the diagram into UMLModelManager.
    action.execute();

    // check the diagram here.
    Diagram diagram = UMLModelManager.getInstance().getDiagrams().get(0);
    assertEquals("The CreateDiagramAction constructor is incorrect.", diagram.getName(), name);

    Uml1SemanticModelBridge modelBridge = (Uml1SemanticModelBridge) diagram.getOwner();
    assertEquals(
        "The CreateDiagramAction constructor is incorrect.", modelBridge.getElement(), owner);
    /*
     * BugFix: UML-9507
     */
    //        assertEquals("The CreateDiagramAction constructor is incorrect.",
    //            StressTestHelper.findTypePropertyValue(diagram), type);
    assertEquals(
        "The CreateDiagramAction constructor is incorrect.",
        StressTestHelper.getTypeInfo(diagram),
        type);

    // remove the diagram from UMLModelManager.
    action.undo();
  }
  public void exportAllImages(String extension, String filePath, boolean showProcess) {

    /*
     * BUGR-108: The aim is to export all the diagrams (along with the
     * hidden ones) and preview them in a separate JFrame, that will have
     * JLabels describing the current action.
     *
     * To fix that, I will create a JFrame and have its contentPane as a
     * JPanel that will have 2 JLabels, 1 JProgressBar and the
     * DiagramViewer. Then, create all the diagrams inside the DiagramViewer
     * as tabs. Next, export each diagram in it and update the JPanel's
     * JLabels and JProgressBar. Finally close the frame.
     */
    UMLModelManager modelManager = UMLModelManager.getInstance();

    JFrame exportingFrame = null;
    JProgressBar bar = null;
    JPanel panel = null;
    JLabel export_num = null;
    JLabel export_name = null;

    exportingFrame = new JFrame("Exporting All Diagrams");
    if (showProcess) {
      exportingFrame.setBounds(100, 100, 500, 500);
      exportingFrame.setAlwaysOnTop(true);
    } else {
      exportingFrame.setBounds(0, 0, 0, 0);
      exportingFrame.setUndecorated(true);
      exportingFrame.setAlwaysOnTop(false);
    }

    exportingFrame.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
    exportingFrame.setResizable(false);
    exportingFrame.setEnabled(false);

    panel = new JPanel();
    panel.setLayout(null);
    panel.setVisible(true);
    if (showProcess) {
      export_num = new JLabel("Exporting:");
      export_num.setBounds(10, 10, 200, 20);
      export_num.setVisible(true);
      panel.add(export_num);

      export_name = new JLabel("Current Diagram:");
      export_name.setBounds(10, 30, 480, 20);
      export_name.setVisible(true);
      panel.add(export_name);

      bar = new JProgressBar(0, 0);
      bar.setStringPainted(true);
      bar.setBounds(250, 10, 240, 20);
      bar.setVisible(true);
      panel.add(bar);
    }

    DiagramViewer viewer = null;
    try {
      viewer = new DiagramViewer();
      viewer.setBackgroundGridVisible(false);
      List<Diagram> diagrams = modelManager.getDiagrams();
      int length = diagrams.size();
      for (int i = 0; i < length; i++) {
        Diagram diagram = diagrams.get(i);
        DiagramView view = viewer.openDiagramView(diagram);
        mainFrame.recoverDiagramView(diagram, view, mainFrame.isConverted);
      }
      if (showProcess) {
        bar.setMaximum(length);
      }
      viewer.setBounds(0, 50, 500, 450);

      panel.add(viewer);
      exportingFrame.setContentPane(panel);
      exportingFrame.setVisible(true);

      DiagramView[] views = viewer.getCachedDiagramViews();
      for (int i = 0; i < length; i++) {
        DiagramView view = views[i];
        Diagram diagram = view.getDiagram();
        if (showProcess) {
          export_num.setText("Exporting:                 " + (i + 1) + " of " + length);
          export_name.setText("Current Diagram:    " + diagram.getName());
          bar.setValue(i + 1);
        }
        viewer.getTabbedPane().setSelectedIndex(i);

        panel.paintImmediately(0, 0, 500, 500);

        if (diagram.isVisible()) {
          DeployHelper.exportToFile(
              mainFrame,
              view,
              filePath,
              DeployHelper.generateOutputFileName(diagram.getName()) + "." + extension,
              extension);
        }
      }
      exportingFrame.dispose();

      mainFrame.setLastImageExportPath(filePath);
    } catch (ConfigurationException e) {
    }
  }