<commit_before>/*
 * Copyright 2009 Google Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
 * use this file except in compliance with the License. You may obtain a copy of
 * the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 * License for the specific language governing permissions and limitations under
 * the License.
 */
package com.google.test.metric.eclipse.ui;

import com.google.test.metric.eclipse.internal.util.JavaProjectHelper;
import com.google.test.metric.eclipse.internal.util.TestabilityConstants;
import com.google.test.metric.eclipse.ui.plugin.Activator;

import org.eclipse.core.runtime.CoreException;
import org.eclipse.debug.core.ILaunchConfiguration;
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
import org.eclipse.debug.ui.AbstractLaunchConfigurationTab;
import org.eclipse.jdt.core.IJavaProject;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.jface.viewers.ILabelProvider;
import org.eclipse.jface.viewers.LabelProvider;
import org.eclipse.jface.window.Window;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.KeyEvent;
import org.eclipse.swt.events.KeyListener;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.events.SelectionListener;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.DirectoryDialog;
import org.eclipse.swt.widgets.Group;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Text;
import org.eclipse.ui.dialogs.ElementListSelectionDialog;

import java.net.MalformedURLException;
import java.net.URL;
import java.text.MessageFormat;

public class TestabilityLaunchConfigurationTab extends AbstractLaunchConfigurationTab {
  private Text projectText;
  private Text reportFolderText;
  private Text whiteListList;
  private Text recordingDepthText;
  private Text cyclomaticCostText;
  private Text globalStateCostText;
  private Text maxExcellentCostText;
  private Text maxAcceptableCostText;


  private JavaProjectHelper javaProjectHelper = new JavaProjectHelper();

  private Image projectImage;

  @Override
  public void dispose() {
    super.dispose();
    if (projectImage != null) {
      projectImage.dispose();
    }
  }

  public void createControl(Composite parent) {
    Composite control = new Composite(parent, SWT.NONE);
    control.setLayout(new GridLayout(1, false));
    super.setControl(control);

    Group projectPropertiesControl = new Group(control, SWT.BORDER);
    projectPropertiesControl.setLayout(new GridLayout(3, false));
    projectPropertiesControl.setText("Project:");
    GridData projectGridData = new GridData(GridData.FILL_HORIZONTAL);
    projectPropertiesControl.setLayoutData(projectGridData);

    createProjectProperties(projectPropertiesControl);

    Group testabilityPropertiesControl = new Group(control, SWT.BORDER);
    testabilityPropertiesControl.setLayout(new GridLayout(2, false));
    testabilityPropertiesControl.setText("Testability Report Properties:");
    GridData testabilityGridData = new GridData(GridData.FILL_HORIZONTAL);
    testabilityPropertiesControl.setLayoutData(testabilityGridData);

    createTestabilityPropertiesControls(testabilityPropertiesControl);
  }

  private void createProjectProperties(Composite control) {
    Label projectLabel = new Label(control, SWT.NONE);
    projectLabel.setText("Project:");

    projectText = new Text(control, SWT.BORDER);
    GridData projectGridData = new GridData(GridData.FILL_HORIZONTAL);
    projectText.setLayoutData(projectGridData);
    projectText.addKeyListener(new KeyListener() {
      public void keyPressed(KeyEvent e) {
      }

      public void keyReleased(KeyEvent e) {
        setTabDirty();
      }
    });

    Button projectBrowseButton = new Button(control, SWT.PUSH);
    projectBrowseButton.setText("Browse...");
    projectBrowseButton.addSelectionListener(new SelectionListener() {
      public void widgetDefaultSelected(SelectionEvent e) {
      }

      public void widgetSelected(SelectionEvent e) {
        setUpBrowseProjectDialog();
      }
    });

    Label reportFolderLabel = new Label(control, SWT.NONE);
    reportFolderLabel.setText("Report Folder:");

    reportFolderText = new Text(control, SWT.BORDER);
    GridData folderGridData = new GridData(GridData.FILL_HORIZONTAL);
    reportFolderText.setLayoutData(folderGridData);
    reportFolderText.addKeyListener(new KeyListener() {
      public void keyPressed(KeyEvent e) {
      }

      public void keyReleased(KeyEvent e) {
        setTabDirty();
      }
    });

    Button reportFolderBrowseButton = new Button(control, SWT.PUSH);
    reportFolderBrowseButton.setText("Browse...");
    reportFolderBrowseButton.addSelectionListener(new SelectionListener() {

      public void widgetDefaultSelected(SelectionEvent e) {
      }

      public void widgetSelected(SelectionEvent e) {
        setUpBrowseFolderDialog();
      }
    });

    Label whiteList = new Label(control, SWT.NONE);
    whiteList.setText("White list:");
    whiteListList = new Text(control, SWT.BORDER);
    GridData whiteListGridData = new GridData(GridData.FILL_HORIZONTAL);
    whiteListList.setLayoutData(whiteListGridData);
    createEmptyCell(control, 1);
  }

  private void createTestabilityPropertiesControls(Composite control) {
    Label depth = new Label(control, SWT.NONE);
    depth.setText("Depth:");
    recordingDepthText = new Text(control, SWT.BORDER);
    GridData recordingDepthGridData = new GridData();
    recordingDepthGridData.widthHint = 50;
    recordingDepthText.setLayoutData(recordingDepthGridData);

    Label cyclomaticCost = new Label(control, SWT.NONE);
    cyclomaticCost.setText("Cyclomatic Cost:");
    cyclomaticCostText = new Text(control, SWT.BORDER);
    GridData cyclomaticCostGridData = new GridData();
    cyclomaticCostGridData.widthHint = 50;
    cyclomaticCostText.setLayoutData(cyclomaticCostGridData);

    Label globalStateCost = new Label(control, SWT.NONE);
    globalStateCost.setText("Global State Cost:");
    globalStateCostText = new Text(control, SWT.BORDER);
    GridData globalStateCostGridData = new GridData();
    globalStateCostGridData.widthHint = 50;
    globalStateCostText.setLayoutData(globalStateCostGridData);

    Label maxExcellentCost = new Label(control, SWT.NONE);
    maxExcellentCost.setText("Max Cost for Excellent Classes:");
    maxExcellentCostText = new Text(control, SWT.BORDER);
    GridData maxExcellentCostGridData = new GridData();
    maxExcellentCostGridData.widthHint = 50;
    maxExcellentCostText.setLayoutData(maxExcellentCostGridData);

    Label maxAcceptableCost = new Label(control, SWT.NONE);
    maxAcceptableCost.setText("Max Cost for Acceptable Classes:");
    maxAcceptableCostText = new Text(control, SWT.BORDER);
    GridData maxAcceptableCostGridData = new GridData();
    maxAcceptableCostGridData.widthHint = 50;
    maxAcceptableCostText.setLayoutData(maxAcceptableCostGridData);
  }

  private void createEmptyCell(Composite control, int span) {
    Label empty;
    empty = new Label(control, SWT.NONE);
    GridData emptyGridData = new GridData();
    emptyGridData.horizontalSpan = span;
    empty.setLayoutData(emptyGridData);
  }

  public String getName() {
    return "Testability";
  }
<commit_msg>When editing a Testability configuration, if you change one of the testability<commit_after>/*
 * Copyright 2009 Google Inc.
 *
 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
 * use this file except in compliance with the License. You may obtain a copy of
 * the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 * License for the specific language governing permissions and limitations under
 * the License.
 */
package com.google.test.metric.eclipse.ui;

import com.google.test.metric.eclipse.internal.util.JavaProjectHelper;
import com.google.test.metric.eclipse.internal.util.TestabilityConstants;
import com.google.test.metric.eclipse.ui.plugin.Activator;

import org.eclipse.core.runtime.CoreException;
import org.eclipse.debug.core.ILaunchConfiguration;
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
import org.eclipse.debug.ui.AbstractLaunchConfigurationTab;
import org.eclipse.jdt.core.IJavaProject;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.jface.viewers.ILabelProvider;
import org.eclipse.jface.viewers.LabelProvider;
import org.eclipse.jface.window.Window;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.KeyEvent;
import org.eclipse.swt.events.KeyListener;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.events.SelectionListener;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.DirectoryDialog;
import org.eclipse.swt.widgets.Group;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Text;
import org.eclipse.ui.dialogs.ElementListSelectionDialog;

import java.net.MalformedURLException;
import java.net.URL;
import java.text.MessageFormat;

public class TestabilityLaunchConfigurationTab extends AbstractLaunchConfigurationTab {
  private Text projectText;
  private Text reportFolderText;
  private Text whiteListList;
  private Text recordingDepthText;
  private Text cyclomaticCostText;
  private Text globalStateCostText;
  private Text maxExcellentCostText;
  private Text maxAcceptableCostText;


  private JavaProjectHelper javaProjectHelper = new JavaProjectHelper();

  private Image projectImage;

  @Override
  public void dispose() {
    super.dispose();
    if (projectImage != null) {
      projectImage.dispose();
    }
  }

  public void createControl(Composite parent) {
    Composite control = new Composite(parent, SWT.NONE);
    control.setLayout(new GridLayout(1, false));
    super.setControl(control);

    Group projectPropertiesControl = new Group(control, SWT.BORDER);
    projectPropertiesControl.setLayout(new GridLayout(3, false));
    projectPropertiesControl.setText("Project:");
    GridData projectGridData = new GridData(GridData.FILL_HORIZONTAL);
    projectPropertiesControl.setLayoutData(projectGridData);

    createProjectProperties(projectPropertiesControl);

    Group testabilityPropertiesControl = new Group(control, SWT.BORDER);
    testabilityPropertiesControl.setLayout(new GridLayout(2, false));
    testabilityPropertiesControl.setText("Testability Report Properties:");
    GridData testabilityGridData = new GridData(GridData.FILL_HORIZONTAL);
    testabilityPropertiesControl.setLayoutData(testabilityGridData);

    createTestabilityPropertiesControls(testabilityPropertiesControl);
  }

  private void createProjectProperties(Composite control) {
    Label projectLabel = new Label(control, SWT.NONE);
    projectLabel.setText("Project:");

    projectText = new Text(control, SWT.BORDER);
    GridData projectGridData = new GridData(GridData.FILL_HORIZONTAL);
    projectText.setLayoutData(projectGridData);
    projectText.addKeyListener(new KeyListener() {
      public void keyPressed(KeyEvent e) {
      }

      public void keyReleased(KeyEvent e) {
        setTabDirty();
      }
    });

    Button projectBrowseButton = new Button(control, SWT.PUSH);
    projectBrowseButton.setText("Browse...");
    projectBrowseButton.addSelectionListener(new SelectionListener() {
      public void widgetDefaultSelected(SelectionEvent e) {
      }

      public void widgetSelected(SelectionEvent e) {
        setUpBrowseProjectDialog();
      }
    });

    Label reportFolderLabel = new Label(control, SWT.NONE);
    reportFolderLabel.setText("Report Folder:");

    reportFolderText = new Text(control, SWT.BORDER);
    GridData folderGridData = new GridData(GridData.FILL_HORIZONTAL);
    reportFolderText.setLayoutData(folderGridData);
    reportFolderText.addKeyListener(new KeyListener() {
      public void keyPressed(KeyEvent e) {
      }

      public void keyReleased(KeyEvent e) {
        setTabDirty();
      }
    });

    Button reportFolderBrowseButton = new Button(control, SWT.PUSH);
    reportFolderBrowseButton.setText("Browse...");
    reportFolderBrowseButton.addSelectionListener(new SelectionListener() {

      public void widgetDefaultSelected(SelectionEvent e) {
      }

      public void widgetSelected(SelectionEvent e) {
        setUpBrowseFolderDialog();
      }
    });

    Label whiteList = new Label(control, SWT.NONE);
    whiteList.setText("White list:");
    whiteListList = new Text(control, SWT.BORDER);
    GridData whiteListGridData = new GridData(GridData.FILL_HORIZONTAL);
    whiteListList.setLayoutData(whiteListGridData);
    whiteListList.addKeyListener(new KeyListener() {
      public void keyPressed(KeyEvent e) {
      }

      public void keyReleased(KeyEvent e) {
        setTabDirty();
      }
    });
    createEmptyCell(control, 1);
  }

  private void createTestabilityPropertiesControls(Composite control) {
    Label depth = new Label(control, SWT.NONE);
    depth.setText("Depth:");
    recordingDepthText = new Text(control, SWT.BORDER);
    GridData recordingDepthGridData = new GridData();
    recordingDepthGridData.widthHint = 50;
    recordingDepthText.setLayoutData(recordingDepthGridData);
    recordingDepthText.addKeyListener(new KeyListener() {
      public void keyPressed(KeyEvent e) {
      }

      public void keyReleased(KeyEvent e) {
        setTabDirty();
      }
    });

    Label cyclomaticCost = new Label(control, SWT.NONE);
    cyclomaticCost.setText("Cyclomatic Cost:");
    cyclomaticCostText = new Text(control, SWT.BORDER);
    GridData cyclomaticCostGridData = new GridData();
    cyclomaticCostGridData.widthHint = 50;
    cyclomaticCostText.setLayoutData(cyclomaticCostGridData);
    cyclomaticCostText.addKeyListener(new KeyListener() {
      public void keyPressed(KeyEvent e) {
      }

      public void keyReleased(KeyEvent e) {
        setTabDirty();
      }
    });

    Label globalStateCost = new Label(control, SWT.NONE);
    globalStateCost.setText("Global State Cost:");
    globalStateCostText = new Text(control, SWT.BORDER);
    GridData globalStateCostGridData = new GridData();
    globalStateCostGridData.widthHint = 50;
    globalStateCostText.setLayoutData(globalStateCostGridData);
    globalStateCostText.addKeyListener(new KeyListener() {
      public void keyPressed(KeyEvent e) {
      }

      public void keyReleased(KeyEvent e) {
        setTabDirty();
      }
    });

    Label maxExcellentCost = new Label(control, SWT.NONE);
    maxExcellentCost.setText("Max Cost for Excellent Classes:");
    maxExcellentCostText = new Text(control, SWT.BORDER);
    GridData maxExcellentCostGridData = new GridData();
    maxExcellentCostGridData.widthHint = 50;
    maxExcellentCostText.setLayoutData(maxExcellentCostGridData);
    maxExcellentCostText.addKeyListener(new KeyListener() {
      public void keyPressed(KeyEvent e) {
      }

      public void keyReleased(KeyEvent e) {
        setTabDirty();
      }
    });

    Label maxAcceptableCost = new Label(control, SWT.NONE);
    maxAcceptableCost.setText("Max Cost for Acceptable Classes:");
    maxAcceptableCostText = new Text(control, SWT.BORDER);
    GridData maxAcceptableCostGridData = new GridData();
    maxAcceptableCostGridData.widthHint = 50;
    maxAcceptableCostText.setLayoutData(maxAcceptableCostGridData);
    maxAcceptableCostText.addKeyListener(new KeyListener() {
      public void keyPressed(KeyEvent e) {
      }

      public void keyReleased(KeyEvent e) {
        setTabDirty();
      }
    });
  }

  private void createEmptyCell(Composite control, int span) {
    Label empty;
    empty = new Label(control, SWT.NONE);
    GridData emptyGridData = new GridData();
    emptyGridData.horizontalSpan = span;
    empty.setLayoutData(emptyGridData);
  }

  public String getName() {
    return "Testability";
  }

{'fraction_non_alphanumeric': 0.09154929577464789, 'fraction_numerical': 0.0026483688455519443, 'mean_word_length': 4.487120211360634, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6278774', 'n_tokens_mistral': 4827, 'n_tokens_neox': 4662, 'n_words': 1015}