/**
   * @param logs
   * @param firstOrg
   * @param secondOrg
   * @return
   */
  private ProMSplitPane additionalDependencyPanelCreator(
      OrganizationalLogs logs, int firstOrg, int secondOrg) {
    ProMSplitPane splitPanelRefinedActivity = new ProMSplitPane();
    splitPanelRefinedActivity.setBackground(null);

    ProMTable comp = additionalDependencyTableCreator(logs, firstOrg, secondOrg);
    if (comp == null) return null;

    JTextPane textField = new JTextPane();
    textField.setContentType("text/html");
    textField.setText(
        fontBlack6
            + "Additional Dependencies ("
            + comp.getTable().getRowCount()
            + ")</font><hr>"
            + fontBlack4
            + " This pattern is a special case of different dependencies where one set of activities includes the other and results with additional dependencies. In the list you can see additional dependency sets in two organizations as "
            + logs.organizationNames.get(firstOrg)
            + "(Selected) and "
            + logs.organizationNames.get(secondOrg)
            + "(Other).");
    textField.setEditable(false);
    textField.setBackground(new Color(192, 192, 192));
    JScrollPane scrollPane = new JScrollPane(textField);
    scrollPane.setPreferredSize(new Dimension(500, 0));

    splitPanelRefinedActivity.setLeftComponent(comp);
    splitPanelRefinedActivity.setRightComponent(scrollPane);
    return splitPanelRefinedActivity;
  }
  /**
   * @param logs
   * @param firstOrg
   * @param secondOrg
   * @return
   */
  private ProMSplitPane differentConditionsPanelCreator(
      OrganizationalLogs logs, int firstOrg, int secondOrg) {
    ProMSplitPane splitPanelRefinedActivity = new ProMSplitPane();
    splitPanelRefinedActivity.setBackground(null);

    ProMTable comp = differentConditionsTableCreator(logs, firstOrg, secondOrg);
    if (comp == null) return null;

    JTextPane textField = new JTextPane();
    textField.setContentType("text/html");
    textField.setText(
        fontBlack6
            + "Different Conditions for Occurrence ("
            + comp.getTable().getRowCount()
            + ")</font><hr>"
            + fontBlack4
            + "Set of dependencies are same for two processes; however, occurrence condition is different in organizations. In the list you can see different occurrence conditions in two organizations as "
            + logs.organizationNames.get(firstOrg)
            + "(Selected) and "
            + logs.organizationNames.get(secondOrg)
            + "(Other).");
    textField.setEditable(false);
    textField.setBackground(new Color(192, 192, 192));
    JScrollPane scrollPane = new JScrollPane(textField);
    scrollPane.setPreferredSize(new Dimension(500, 0));

    splitPanelRefinedActivity.setLeftComponent(comp);
    splitPanelRefinedActivity.setRightComponent(scrollPane);
    return splitPanelRefinedActivity;
  }
  /**
   * @param logs
   * @param firstOrg
   * @param secondOrg
   * @return
   */
  private ProMSplitPane refinedActivityPanelCreator(
      OrganizationalLogs logs, int firstOrg, int secondOrg) {
    ProMSplitPane splitPanelRefinedActivity = new ProMSplitPane();
    splitPanelRefinedActivity.setBackground(null);

    ProMTable comp = refinedActivityTableCreator(logs, firstOrg, secondOrg);
    if (comp == null) return null;

    JTextPane textField = new JTextPane();
    textField.setContentType("text/html");
    textField.setText(
        fontBlack6
            + "Refined Activities ("
            + comp.getTable().getRowCount()
            + ")</font><hr>"
            + fontBlack4
            + "An activity exists in one process but, as an equivalent, a collection of activitiesare existing in the other process to achieve the same task. In the list you can see the refined activity in "
            + logs.organizationNames.get(firstOrg)
            + " and a potential list of activities in "
            + logs.organizationNames.get(secondOrg)
            + ".");
    textField.setEditable(false);
    textField.setBackground(new Color(192, 192, 192));
    JScrollPane scrollPane = new JScrollPane(textField);
    scrollPane.setPreferredSize(new Dimension(500, 0));

    splitPanelRefinedActivity.setLeftComponent(comp);
    splitPanelRefinedActivity.setRightComponent(scrollPane);
    return splitPanelRefinedActivity;
  }
  /**
   * Create the panel.
   *
   * @return
   */
  public JComponent create(OrganizationalLogs logs) {
    factory = SlickerFactory.instance();

    splitPanel = new ProMSplitPane(ProMSplitPane.VERTICAL_SPLIT);
    splitPanel.setBackground((Color.white));
    splitPanel.setBorder(BorderFactory.createEmptyBorder());
    splitPanel.setDividerLocation(0.5);
    ProMSplitPane headerPanel = createHeaderPanel(logs, factory);
    splitPanel.setTopComponent(headerPanel);

    return splitPanel;
  }
  /**
   * @param logs
   * @param firstOrg
   * @param secondOrg
   * @return
   */
  private ProMSplitPane skippedActivityPanelCreator(
      OrganizationalLogs logs, int firstOrg, int secondOrg) {
    ProMSplitPane splitPanelSkippedActivity = new ProMSplitPane();
    splitPanelSkippedActivity.setBackground(null);

    ProMTable comp = null;
    if (firstOrg == secondOrg) {
      comp = skippedActivityTableCreator(logs, firstOrg);
    } else {
      comp = skippedActivityTableCreator(logs, secondOrg);
    }
    if (comp == null) return null;

    JTextPane textField = new JTextPane();
    textField.setContentType("text/html");
    if (firstOrg == secondOrg) {
      textField.setText(
          fontBlack6
              + "Skipped Activities ("
              + comp.getTable().getRowCount()
              + ") </font><hr>"
              + fontBlack4
              + " An activity exists in one process but no equivalent activity is found in the other process. In the list you can see the skipped activities in "
              + logs.organizationNames.get(firstOrg)
              + ".");
    } else {
      textField.setText(
          fontBlack6
              + "Skipped Activities ("
              + comp.getTable().getRowCount()
              + ")</font><hr>"
              + fontBlack4
              + " An activity exists in one process but no equivalent activity is found in the other process. In the list you can see the skipped activities in "
              + logs.organizationNames.get(secondOrg)
              + " compared to "
              + logs.organizationNames.get(firstOrg)
              + ".");
    }
    textField.setEditable(false);
    textField.setBackground(new Color(192, 192, 192));
    JScrollPane scrollPane = new JScrollPane(textField);
    scrollPane.setPreferredSize(new Dimension(500, 0));

    splitPanelSkippedActivity.setLeftComponent(comp);
    splitPanelSkippedActivity.setRightComponent(scrollPane);
    return splitPanelSkippedActivity;
  }
  /**
   * Steps to handle when "Analyze" button is clicked
   *
   * @param logs
   */
  private void analyzeClicked(OrganizationalLogs logs) {
    IconVerticalTabbedPane tabbed = new IconVerticalTabbedPane(Color.GRAY, Color.BLACK, 85);

    int firstOrg = logs.organizationNames.indexOf(organizationName);

    if (logs != null) {
      for (String s : logs.organizationNames) {
        if (!s.equals("Select")) {
          int secondOrg = logs.organizationNames.indexOf(s);
          JPanel panel = new JPanel(new GridBagLayout());
          panel.setBackground(new Color(40, 40, 40));

          if (!s.equals(organizationName)) {

            GridBagConstraints c = new GridBagConstraints();

            JTextPane headerPanel = new JTextPane();
            headerPanel.setContentType("text/html");
            headerPanel.setText(
                "<center><font color='white' face='helvetica,arial,sans-serif' size='8'>Mismatch Patterns</font><font color='white' face='helvetica,arial,sans-serif' size='4'> <br>"
                    + organizationName
                    + " (Selected) vs "
                    + s
                    + " (Other)");
            headerPanel.setEditable(false);
            headerPanel.setBackground(null);
            c.gridx = 0;
            c.gridy = 0;
            panel.add(headerPanel, c);

            ProMSplitPane splitPanelSkippedActivity =
                skippedActivityPanelCreator(logs, firstOrg, secondOrg);
            c.gridy = 1;
            if (splitPanelSkippedActivity != null) panel.add(splitPanelSkippedActivity, c);

            ProMSplitPane splitPanelRefinedActivity =
                refinedActivityPanelCreator(logs, firstOrg, secondOrg);
            c.gridy = 2;
            if (splitPanelRefinedActivity != null) panel.add(splitPanelRefinedActivity, c);

            ProMSplitPane splitPanelDifferentMoments =
                differentMomentsPanelCreator(logs, firstOrg, secondOrg);
            c.gridy = 3;
            if (splitPanelDifferentMoments != null) panel.add(splitPanelDifferentMoments, c);

            ProMSplitPane splitPanelDifferentMoments2 =
                differentConditionsPanelCreator(logs, firstOrg, secondOrg);
            c.gridy = 4;
            if (splitPanelDifferentMoments2 != null) panel.add(splitPanelDifferentMoments2, c);

            ProMSplitPane splitPanelDifferentMoments3 =
                differentDependencyPanelCreator(logs, firstOrg, secondOrg);
            c.gridy = 5;
            if (splitPanelDifferentMoments3 != null) panel.add(splitPanelDifferentMoments3, c);

            ProMSplitPane splitPanelDifferentMoments4 =
                additionalDependencyPanelCreator(logs, firstOrg, secondOrg);
            c.gridy = 6;
            if (splitPanelDifferentMoments4 != null) panel.add(splitPanelDifferentMoments4, c);

          } else {

            GridBagConstraints c = new GridBagConstraints();

            JTextPane headerPanel = new JTextPane();
            headerPanel.setContentType("text/html");
            headerPanel.setText(
                "<center><font color='white' face='helvetica,arial,sans-serif' size='8'>Mismatch Patterns</font><font color='white' face='helvetica,arial,sans-serif' size='4'> <br>"
                    + organizationName);
            headerPanel.setEditable(false);
            headerPanel.setBackground(null);
            c.gridx = 0;
            c.gridy = 0;
            panel.add(headerPanel, c);

            ProMSplitPane splitPanelSkippedActivity =
                skippedActivityPanelCreator(logs, firstOrg, secondOrg);
            c.gridy = 1;
            panel.add(splitPanelSkippedActivity, c);
          }
          // tabbed.addTab(s, panel);
          ProMScrollPane jScrollPane = new ProMScrollPane(panel);
          jScrollPane.getVerticalScrollBar().setUnitIncrement(20);
          jScrollPane.setBackground(Color.black);
          String label = "Org #";
          if (firstOrg == secondOrg) {
            label = label + firstOrg;
          } else {
            label = label + secondOrg;
          }

          tabbed.addTab(label, gearsIcon.getImage(), jScrollPane);
        }
      }
    }
    splitPanel.setBottomComponent(tabbed);
  }
  /**
   * Create header panel
   *
   * @param logs
   * @param factory
   * @return
   */
  private ProMSplitPane createHeaderPanel(final OrganizationalLogs logs, SlickerFactory factory) {
    ProMSplitPane headerPanel = new ProMSplitPane(ProMSplitPane.HORIZONTAL_SPLIT);

    {
      JTextPane headerExplanation = new JTextPane();
      headerExplanation.setContentType("text/html");
      headerExplanation.setText(
          fontBlack6
              + "Mismatch Pattern Analysis without Performance Clustering</font><hr>"
              + fontBlack4
              + " Select an organization from left and click \"Analyze\" to list mismatch patterns compared to other organizations.");
      headerExplanation.setEditable(false);
      headerExplanation.setBackground(null);
      headerPanel.setRightComponent(headerExplanation);
    }

    {
      JPanel headerLeftPanel = new JPanel();
      headerLeftPanel.setBackground(null);
      headerLeftPanel.setLayout(new GridBagLayout());
      {
        List<String> organizationList = new ArrayList<String>();
        if (logs != null) {

          organizationList.addAll(logs.organizationNames);
        }
        organizationCombo = factory.createComboBox(organizationList.toArray());

        GridBagConstraints organizationComboConstraint = new GridBagConstraints();
        organizationComboConstraint.gridx = 0;
        organizationComboConstraint.gridy = 1;

        organizationComboConstraint.anchor = GridBagConstraints.WEST;

        organizationCombo.addActionListener(
            (new ActionListener() {
              public void actionPerformed(ActionEvent arg0) {
                organizationName = (String) organizationCombo.getSelectedItem();
              }
            }));
        headerLeftPanel.add(organizationCombo, organizationComboConstraint);
      }
      {
        JLabel organizationComboLabel = factory.createLabel("Organization");
        GridBagConstraints organizationComboLabelConstraint = new GridBagConstraints();
        organizationComboLabelConstraint.gridx = 0;
        organizationComboLabelConstraint.gridy = 0;
        organizationComboLabelConstraint.fill = GridBagConstraints.HORIZONTAL;
        headerLeftPanel.add(organizationComboLabel, organizationComboLabelConstraint);
      }

      {
        JButton analyzeButton = factory.createButton("Analyze");
        GridBagConstraints analyzeButtonConstraint = new GridBagConstraints();
        analyzeButtonConstraint.gridx = 0;
        analyzeButtonConstraint.gridy = 3;
        analyzeButtonConstraint.gridwidth = 3;
        analyzeButtonConstraint.fill = GridBagConstraints.HORIZONTAL;
        analyzeButtonConstraint.anchor = GridBagConstraints.WEST;
        analyzeButton.addActionListener(
            (new ActionListener() {
              public void actionPerformed(ActionEvent arg0) {
                organizationName = (String) organizationCombo.getSelectedItem();
                if (!(organizationName.equals("Select") || organizationName.equals(""))) {
                  System.out.println(organizationName + " " + performanceDifferentThresholdValue);
                  analyzeClicked(logs);
                }
              }
            }));
        headerLeftPanel.add(analyzeButton, analyzeButtonConstraint);
      }
      headerPanel.setLeftComponent(headerLeftPanel);
    }
    return headerPanel;
  }