<commit_before>/*******************************************************************************
 * Copyright (c) 2004, 2007 Mylyn project committers and others.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *******************************************************************************/

package org.eclipse.mylyn.internal.bugzilla.ui.tasklist;

import org.eclipse.mylyn.internal.bugzilla.core.BugzillaRepositoryQuery;
import org.eclipse.mylyn.internal.tasks.ui.TasksUiImages;
import org.eclipse.mylyn.tasks.core.TaskRepository;
import org.eclipse.mylyn.tasks.ui.search.AbstractRepositoryQueryPage;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.KeyEvent;
import org.eclipse.swt.events.KeyListener;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Group;
import org.eclipse.swt.widgets.Text;

/**
 * @author <NAME>
 * @author <NAME>
 */
public class BugzillaCustomQueryWizardPage extends AbstractRepositoryQueryPage {

	private static final String LABEL_CUSTOM_QUERY = "&Enter query URL";

	private static final String TITLE = "Create query from URL";

	private static final String DESCRIPTION = "Enter the title and URL for the query";

	private Text queryText;

	private Composite composite;

	private BugzillaRepositoryQuery query;

	public BugzillaCustomQueryWizardPage(TaskRepository repository, BugzillaRepositoryQuery query) {
		super(TITLE, query.getSummary());
		this.query = query;
		this.repository = repository;
		setTitle(LABEL_CUSTOM_QUERY);
		setDescription(DESCRIPTION);
		setImageDescriptor(TasksUiImages.BANNER_REPOSITORY);
	}

	public BugzillaCustomQueryWizardPage(TaskRepository repository) {
		super(TITLE);
		this.repository = repository;
		setTitle(LABEL_CUSTOM_QUERY);
		setDescription(DESCRIPTION);
		setImageDescriptor(TasksUiImages.BANNER_REPOSITORY);
	}

	@Override
	public void createControl(Composite parent) {
		composite = new Composite(parent, SWT.NONE);
		composite.setLayout(new GridLayout());

		super.createControl(composite);
		createCustomQueryGroup(composite);
		composite.pack();
		setControl(composite);
	}

	private void createCustomQueryGroup(Composite composite) {
		Group group = new Group(composite, SWT.NONE);
		group.setText(LABEL_CUSTOM_QUERY);
		GridLayout layout = new GridLayout();
		layout.numColumns = 1;
		group.setLayout(layout);
		GridData gd = new GridData(GridData.FILL_HORIZONTAL);
		gd.horizontalSpan = 2;
		gd.widthHint = 300;
		group.setLayoutData(gd);

		queryText = new Text(group, SWT.BORDER);
		gd = new GridData(GridData.FILL_HORIZONTAL | GridData.GRAB_HORIZONTAL);
		queryText.setLayoutData(gd);

		if (query != null) {
			queryText.setText(query.getUrl());
		}

		queryText.addKeyListener(new KeyListener() {

			public void keyPressed(KeyEvent e) {
				// ignore

			}

			public void keyReleased(KeyEvent e) {
				setPageComplete(canFlipToNextPage());

			}
		});

	}

	@Override
	public boolean canFlipToNextPage() {
		return false;
	}

//	@Override
//	public boolean isPageComplete() {
//		return super.canFlipToNextPage();
//	}

//	@Override
//	public IWizardPage getNextPage() {
//		return null;
//	}<commit_msg>NEW - bug 204847: [patch] polish create bugzilla query from url page https://bugs.eclipse.org/bugs/show_bug.cgi?id=204847<commit_after>/*******************************************************************************
 * Copyright (c) 2004, 2007 Mylyn project committers and others.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *******************************************************************************/

package org.eclipse.mylyn.internal.bugzilla.ui.tasklist;

import org.eclipse.mylyn.internal.bugzilla.core.BugzillaRepositoryQuery;
import org.eclipse.mylyn.internal.tasks.ui.TasksUiImages;
import org.eclipse.mylyn.tasks.core.TaskRepository;
import org.eclipse.mylyn.tasks.ui.search.AbstractRepositoryQueryPage;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.ModifyEvent;
import org.eclipse.swt.events.ModifyListener;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Text;

/**
 * @author <NAME>
 * @author <NAME>
 * @author <NAME>
 */
public class BugzillaCustomQueryWizardPage extends AbstractRepositoryQueryPage {

	private static final String LABEL_CUSTOM_TITLE = "&Query Title:";

	private static final String LABEL_CUSTOM_QUERY = "Query &URL";

	private static final String TITLE = "Create query from URL";

	private static final String DESCRIPTION = "Enter the title and URL for the query";

	private Text queryText;

	private BugzillaRepositoryQuery query;

	public BugzillaCustomQueryWizardPage(TaskRepository repository, BugzillaRepositoryQuery query) {
		super(TITLE, query.getSummary());
		this.query = query;
		this.repository = repository;
		setTitle(TITLE);
		setDescription(DESCRIPTION);
		setImageDescriptor(TasksUiImages.BANNER_REPOSITORY);
	}

	public BugzillaCustomQueryWizardPage(TaskRepository repository) {
		super(TITLE);
		this.repository = repository;
		setTitle(TITLE);
		setDescription(DESCRIPTION);
		setImageDescriptor(TasksUiImages.BANNER_REPOSITORY);
	}

	@Override
	public void createControl(Composite parent) {
		Composite composite = new Composite(parent, SWT.NONE);
		composite.setLayout(new GridLayout(2, false));
		setControl(composite);

		ModifyListener modifyListener = new ModifyListener() {
			public void modifyText(ModifyEvent e) {
				setPageComplete(isPageComplete());
			}
		};

		final Label queryTitleLabel = new Label(composite, SWT.NONE);
		queryTitleLabel.setText(LABEL_CUSTOM_TITLE);

		Text queryTitle = new Text(composite, SWT.BORDER);
		queryTitle.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false));
		queryTitle.addModifyListener(modifyListener);
		title = queryTitle;
		title.setFocus();
		
		final Label queryUrlLabel = new Label(composite, SWT.NONE);
		queryUrlLabel.setText(LABEL_CUSTOM_QUERY);

		queryText = new Text(composite, SWT.BORDER);
		final GridData gd_queryText = new GridData(SWT.FILL, SWT.CENTER, true, false);
		gd_queryText.widthHint = 300;
		queryText.setLayoutData(gd_queryText);
		queryText.addModifyListener(modifyListener);

		if(query!=null) {
			queryTitle.setText(query.getSummary());
			queryText.setText(query.getUrl());
		}
	}

	@Override
	public boolean canFlipToNextPage() {
		return false;
	}

	@Override
	public boolean isPageComplete() {
		if(super.isPageComplete()) {
			if(queryText.getText().length() > 0) {
				return true;
			}
			setErrorMessage("Please specify Query URL");
		}
		return false;
	}
{'fraction_non_alphanumeric': 0.14392655367231638, 'fraction_numerical': 0.0064971751412429375, 'mean_word_length': 5.41976427923844, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 9, 'https://': 1, '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': '5837716', 'n_tokens_mistral': 2364, 'n_tokens_neox': 2124, 'n_words': 465}