<commit_before>/*
 * FindBugs Eclipse Plug-in.
 * Copyright (C) 2003 - 2004, <NAME>
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 */

package de.tobject.findbugs.view;

import java.util.Calendar;

import org.eclipse.core.resources.IMarker;
import org.eclipse.jface.action.IToolBarManager;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.ModifyEvent;
import org.eclipse.swt.events.ModifyListener;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.events.SelectionListener;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Combo;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Text;
import org.eclipse.ui.ISelectionListener;
import org.eclipse.ui.ISelectionService;

import de.tobject.findbugs.FindbugsPlugin;
import de.tobject.findbugs.marker.FindBugsMarker;
import de.tobject.findbugs.reporter.MarkerUtil;
import edu.umd.cs.findbugs.BugInstance;
import edu.umd.cs.findbugs.BugPattern;
import edu.umd.cs.findbugs.I18N;
import edu.umd.cs.findbugs.annotations.CheckForNull;

/**
 * View which shows bug annotations.
 *
 * @author <NAME>
 * @author <NAME>
 * @version 2.0
 * @since 19.04.2004
 */
public class UserAnnotationsView extends AbstractFindbugsView {

	private String userAnnotation;

	private String firstVersionText;

	private @CheckForNull
	BugInstance theBug;

	private Text userAnnotationTextField;

	private Label firstVersionLabel;

	private Combo designationComboBox;

	private ISelectionListener selectionListener;

	public UserAnnotationsView() {
		super();
		userAnnotation = "";
		firstVersionText = "";
	}

	/*
	 * (non-Javadoc)
	 *
	 * @see org.eclipse.ui.IWorkbenchPart#createPartControl(org.eclipse.swt.widgets.Composite)
	 */
	@Override
	public Composite createRootControl(Composite parent) {
		Composite main = new Composite(parent, SWT.VERTICAL);
		main.setLayout(new GridLayout(2, false));
		designationComboBox = new Combo(main, SWT.LEFT | SWT.DROP_DOWN
				| SWT.READ_ONLY);
		designationComboBox.setToolTipText("User-specified bug designation");
		designationComboBox.setLayoutData(new GridData());
		for (String s : I18N.instance().getUserDesignationKeys(true)) {
			designationComboBox.add(I18N.instance().getUserDesignation(s));
		}
		designationComboBox.addSelectionListener(new SelectionListener() {
			public void widgetSelected(SelectionEvent e) {
				if (theBug != null) {
					theBug.setUserDesignationKeyIndex(
						designationComboBox.getSelectionIndex(), null, null);
				}
			}

			public void widgetDefaultSelected(SelectionEvent e) {
				widgetSelected(e);
			}
		});
		designationComboBox.setSize(designationComboBox.computeSize(
				SWT.DEFAULT, SWT.DEFAULT));
		designationComboBox.setEnabled(false);

		firstVersionLabel = new Label(main, SWT.LEFT);
		firstVersionLabel
				.setToolTipText("The earliest version in which the bug was present");
		firstVersionLabel.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));

		userAnnotationTextField = new Text(main, SWT.LEFT | SWT.WRAP
				| SWT.BORDER);
		userAnnotationTextField
				.setToolTipText("Type comments about the selected bug here");
		userAnnotationTextField.setEnabled(false);
		GridData uatfData = new GridData(GridData.FILL_BOTH);
		uatfData.horizontalSpan = 2;
		userAnnotationTextField.setLayoutData(uatfData);
		userAnnotationTextField.addModifyListener(new ModifyListener() {
			public void modifyText(ModifyEvent e) {
				if (theBug != null) {
					theBug.getUserDesignation().setAnnotationText(
							userAnnotationTextField.getText());
				}
			}
		});
		// Add selection listener to detect click in problems view or bug tree
		// view
		ISelectionService theService = getSite().getWorkbenchWindow()
				.getSelectionService();

		selectionListener = new MarkerSelectionListener(this);
		theService.addSelectionListener(selectionListener);
		return main;
	}

	@Override
	public void dispose() {
		if (selectionListener != null) {
			getSite().getWorkbenchWindow().getSelectionService()
					.removeSelectionListener(selectionListener);
			selectionListener = null;<commit_msg>simplification<commit_after>/*
 * FindBugs Eclipse Plug-in.
 * Copyright (C) 2003 - 2004, <NAME>
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
 */

package de.tobject.findbugs.view;

import java.util.Calendar;

import org.eclipse.core.resources.IMarker;
import org.eclipse.jface.action.IToolBarManager;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.ModifyEvent;
import org.eclipse.swt.events.ModifyListener;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.events.SelectionListener;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Combo;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Text;
import org.eclipse.ui.ISelectionListener;
import org.eclipse.ui.ISelectionService;

import de.tobject.findbugs.FindbugsPlugin;
import de.tobject.findbugs.marker.FindBugsMarker;
import de.tobject.findbugs.reporter.MarkerUtil;
import edu.umd.cs.findbugs.BugInstance;
import edu.umd.cs.findbugs.BugPattern;
import edu.umd.cs.findbugs.I18N;
import edu.umd.cs.findbugs.annotations.CheckForNull;

/**
 * View which shows bug annotations.
 *
 * @author <NAME>
 * @author <NAME>
 * @version 2.0
 * @since 19.04.2004
 */
public class UserAnnotationsView extends AbstractFindbugsView {

	private String userAnnotation;

	private String firstVersionText;

	private @CheckForNull
	BugInstance theBug;

	private Text userAnnotationTextField;

	private Label firstVersionLabel;

	private Combo designationComboBox;

	private ISelectionListener selectionListener;

	public UserAnnotationsView() {
		super();
		userAnnotation = "";
		firstVersionText = "";
	}

	/*
	 * (non-Javadoc)
	 *
	 * @see org.eclipse.ui.IWorkbenchPart#createPartControl(org.eclipse.swt.widgets.Composite)
	 */
	@Override
	public Composite createRootControl(Composite parent) {
		Composite main = new Composite(parent, SWT.VERTICAL);
		main.setLayout(new GridLayout(2, false));
		designationComboBox = new Combo(main, SWT.LEFT | SWT.DROP_DOWN
				| SWT.READ_ONLY);
		designationComboBox.setToolTipText("User-specified bug designation");
		designationComboBox.setLayoutData(new GridData());
		for (String s : I18N.instance().getUserDesignationKeys(true)) {
			designationComboBox.add(I18N.instance().getUserDesignation(s));
		}
		designationComboBox.addSelectionListener(new SelectionListener() {
			public void widgetSelected(SelectionEvent e) {
				if (theBug != null) {
					theBug.setUserDesignationKeyIndex(
						designationComboBox.getSelectionIndex(), null, null);
				}
			}

			public void widgetDefaultSelected(SelectionEvent e) {
				widgetSelected(e);
			}
		});
		designationComboBox.setSize(designationComboBox.computeSize(
				SWT.DEFAULT, SWT.DEFAULT));
		designationComboBox.setEnabled(false);

		firstVersionLabel = new Label(main, SWT.LEFT);
		firstVersionLabel
				.setToolTipText("The earliest version in which the bug was present");
		firstVersionLabel.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));

		userAnnotationTextField = new Text(main, SWT.LEFT | SWT.WRAP
				| SWT.BORDER);
		userAnnotationTextField
				.setToolTipText("Type comments about the selected bug here");
		userAnnotationTextField.setEnabled(false);
		GridData uatfData = new GridData(GridData.FILL_BOTH);
		uatfData.horizontalSpan = 2;
		userAnnotationTextField.setLayoutData(uatfData);
		userAnnotationTextField.addModifyListener(new ModifyListener() {
			public void modifyText(ModifyEvent e) {
				if (theBug != null) {
					theBug.setAnnotationText(
							userAnnotationTextField.getText(), null, null);
				}
			}
		});
		// Add selection listener to detect click in problems view or bug tree
		// view
		ISelectionService theService = getSite().getWorkbenchWindow()
				.getSelectionService();

		selectionListener = new MarkerSelectionListener(this);
		theService.addSelectionListener(selectionListener);
		return main;
	}

	@Override
	public void dispose() {
		if (selectionListener != null) {
			getSite().getWorkbenchWindow().getSelectionService()
					.removeSelectionListener(selectionListener);
			selectionListener = null;
{'fraction_non_alphanumeric': 0.09677752530468911, 'fraction_numerical': 0.008675893410452386, 'mean_word_length': 4.854292623941959, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, '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': '16440', 'n_tokens_mistral': 3230, 'n_tokens_neox': 2845, 'n_words': 711}