<commit_before>package eu.cloudscaleproject.env.toolchain.ui.widgets;

import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.MouseAdapter;
import org.eclipse.swt.events.MouseEvent;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Label;

import eu.cloudscaleproject.env.common.ColorResources;
import eu.cloudscaleproject.env.common.dialogs.TextInputDialog;
import eu.cloudscaleproject.env.common.ui.GradientComposite;
import eu.cloudscaleproject.env.common.ui.resources.SWTResourceManager;
import eu.cloudscaleproject.env.toolchain.resources.types.IEditorInput;

public class TitleWidget extends GradientComposite
{

	private Label lblTitle;
	private IEditorInput alternative;
	
	private MouseAdapter mouseListener = new MouseAdapter() {
			@Override
			public void mouseDoubleClick(MouseEvent e) {

				TextInputDialog dialog = new TextInputDialog(Display.getDefault().getActiveShell(), alternative.getName());
				dialog.open();
				
				if(dialog.getReturnCode() == IDialogConstants.OK_ID){
					String name = dialog.getText();
					alternative.setName(name);
					updateTitle();
				}
			}
		};


	/**
	 * Create the composite.
	 * @param parent
	 * @param style
	 */
	public TitleWidget(Composite parent, int style, IEditorInput alternative)
	{
		super(parent, style);
		this.alternative = alternative;

		this.setBackground(SWTResourceManager.getColor(SWT.COLOR_GRAY));
		this.setLayout(new GridLayout(1, false));
		
		this.setGradientDirection(false);
		this.setGradientColorStart(ColorResources.COLOR_CS_BLUE);
		this.setGradientColorEnd(ColorResources.COLOR_CS_BLUE_LIGHT);

		lblTitle = new Label(this, SWT.NONE);
		lblTitle.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false, 1, 1));
		lblTitle.setFont(SWTResourceManager.getFont("Sans", 14, SWT.NORMAL));
		lblTitle.setForeground(ColorResources.COLOR_CS_BLUE_DARK);
		
		lblTitle.addMouseListener(mouseListener);
		this.addMouseListener(mouseListener);

		updateTitle();
	}

	private void updateTitle()
	{
		String title = this.alternative.getName();
/*		if (this.alternative.getType() != null)
		{
			title = String.format("%s [%s]",this.alternative.getName(), this.alternative.getType().toLowerCase()) ;
		}*/

		lblTitle.setText(title);
	}
	
	public String getTitle ()
	{
		return lblTitle.getText();
	}
	@Override
	protected void checkSubclass()
	{
		// Disable the check that prevents subclassing of SWT components
	}
<commit_msg>TitleWidget - show alternative type<commit_after>package eu.cloudscaleproject.env.toolchain.ui.widgets;

import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.MouseAdapter;
import org.eclipse.swt.events.MouseEvent;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Label;

import eu.cloudscaleproject.env.common.ColorResources;
import eu.cloudscaleproject.env.common.dialogs.TextInputDialog;
import eu.cloudscaleproject.env.common.ui.GradientComposite;
import eu.cloudscaleproject.env.common.ui.resources.SWTResourceManager;
import eu.cloudscaleproject.env.toolchain.resources.types.IEditorInput;
import eu.cloudscaleproject.env.toolchain.resources.types.IEditorInputResource;

public class TitleWidget extends GradientComposite
{

	private Label lblTitle;
	private IEditorInput alternative;
	
	private MouseAdapter mouseListener = new MouseAdapter() {
			@Override
			public void mouseDoubleClick(MouseEvent e) {

				TextInputDialog dialog = new TextInputDialog(Display.getDefault().getActiveShell(), alternative.getName());
				dialog.open();
				
				if(dialog.getReturnCode() == IDialogConstants.OK_ID){
					String name = dialog.getText();
					alternative.setName(name);
					updateTitle();
				}
			}
		};


	/**
	 * Create the composite.
	 * @param parent
	 * @param style
	 */
	public TitleWidget(Composite parent, int style, IEditorInput alternative)
	{
		super(parent, style);
		this.alternative = alternative;

		this.setBackground(SWTResourceManager.getColor(SWT.COLOR_GRAY));
		this.setLayout(new GridLayout(1, false));
		
		this.setGradientDirection(false);
		this.setGradientColorStart(ColorResources.COLOR_CS_BLUE);
		this.setGradientColorEnd(ColorResources.COLOR_CS_BLUE_LIGHT);

		lblTitle = new Label(this, SWT.NONE);
		lblTitle.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false, 1, 1));
		lblTitle.setFont(SWTResourceManager.getFont("Sans", 14, SWT.NORMAL));
		lblTitle.setForeground(ColorResources.COLOR_CS_BLUE_DARK);
		
		lblTitle.addMouseListener(mouseListener);
		this.addMouseListener(mouseListener);

		updateTitle();
	}

	private void updateTitle()
	{
		if (this.alternative == null) return;
		String title = this.alternative.getName();

		if (this.alternative instanceof IEditorInputResource)  
		{
			String type = ((IEditorInputResource)this.alternative).getType();
			if ( type != null)
			{
				title = String.format("%s [%s]", title, type) ;
			}
		}

		lblTitle.setText(title);
	}
	
	public String getTitle ()
	{
		return lblTitle.getText();
	}
	@Override
	protected void checkSubclass()
	{
		// Disable the check that prevents subclassing of SWT components
	}

{'fraction_non_alphanumeric': 0.11449676823638043, 'fraction_numerical': 0.0018467220683287165, 'mean_word_length': 5.058165548098434, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '1379765', 'n_tokens_mistral': 1891, 'n_tokens_neox': 1713, 'n_words': 295}