Skip to main content
summaryrefslogtreecommitdiffstats
blob: b3c06739cb93fc0d5c800fc2428bec3ab9053da2 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
/*******************************************************************************
 * Copyright (c) 2015 Tasktop Technologies and others.
 * 
 * This program and the accompanying materials are made available under the
 * terms of the Eclipse Public License v. 2.0 which is available at
 * https://www.eclipse.org/legal/epl-2.0
 * 
 * SPDX-License-Identifier: EPL-2.0
 *
 * Contributors:
 *     Tasktop Technologies - initial API and implementation
 *******************************************************************************/

package org.eclipse.mylyn.internal.provisional.bugzilla.rest.ui;

import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.jface.wizard.IWizardPage;
import org.eclipse.jface.wizard.WizardPage;
import org.eclipse.mylyn.internal.bugzilla.rest.core.BugzillaRestConnector;
import org.eclipse.mylyn.internal.bugzilla.rest.core.BugzillaRestTaskAttributeMapper;
import org.eclipse.mylyn.tasks.core.AbstractRepositoryConnector;
import org.eclipse.mylyn.tasks.core.TaskRepository;
import org.eclipse.mylyn.tasks.core.data.TaskData;
import org.eclipse.mylyn.tasks.ui.TasksUiImages;
import org.eclipse.mylyn.tasks.ui.wizards.AbstractRepositoryQueryPage2;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Composite;

public class BugzillaRestQueryTypeWizardPage extends WizardPage {

	private final AbstractRepositoryQueryPage2 customPage;

	private final AbstractRepositoryQueryPage2 searchPage;

	private Button buttonCustom;

	private Button buttonForm;

	private Composite composite;

	public BugzillaRestQueryTypeWizardPage(TaskRepository repository, AbstractRepositoryConnector connector) {
		super(Messages.BugzillaRestQueryTypeWizardPage_ChooseQueryType);
		setTitle(Messages.BugzillaRestQueryTypeWizardPage_ChooseQueryType);
		setDescription(Messages.BugzillaRestQueryTypeWizardPage_SelectAvailableQueryTypes);
		setImageDescriptor(TasksUiImages.BANNER_REPOSITORY);
		BugzillaRestConnector connectorREST = (BugzillaRestConnector) connector;
		TaskData taskDataSimpleURL = new TaskData(new BugzillaRestTaskAttributeMapper(repository, connectorREST),
				repository.getConnectorKind(), Messages.BugzillaRestQueryTypeWizardPage_Query,
				Messages.BugzillaRestQueryTypeWizardPage_Query);
		TaskData taskDataSearch = new TaskData(new BugzillaRestTaskAttributeMapper(repository, connectorREST),
				repository.getConnectorKind(), Messages.BugzillaRestQueryTypeWizardPage_Query,
				Messages.BugzillaRestQueryTypeWizardPage_Query);
		customPage = BugzillaRestUiUtil.createBugzillaRestSearchPage(true, false, taskDataSimpleURL, connectorREST,
				repository, null);
		searchPage = BugzillaRestUiUtil.createBugzillaRestSearchPage(false, false, taskDataSearch, connectorREST,
				repository, null);
	}

	@Override
	public void createControl(Composite parent) {
		composite = new Composite(parent, SWT.NONE);
		GridData gridData = new GridData(GridData.FILL_HORIZONTAL);
		gridData.grabExcessVerticalSpace = false;
		composite.setLayoutData(gridData);
		composite.setLayout(new GridLayout(1, false));

		buttonForm = new Button(composite, SWT.RADIO);
		buttonForm.setText(Messages.BugzillaRestQueryTypeWizardPage_CreateQueryUsingForm);
		buttonForm.setSelection(true);

		buttonCustom = new Button(composite, SWT.RADIO);
		buttonCustom.setText(Messages.BugzillaRestQueryTypeWizardPage_CreateQueryFromExistingURL);

		setPageComplete(true);
		setControl(composite);
		Dialog.applyDialogFont(composite);
	}

	@Override
	public IWizardPage getNextPage() {
		if (buttonForm.getSelection()) {
			searchPage.setWizard(this.getWizard());
			return searchPage;
		}
		customPage.setWizard(this.getWizard());
		return customPage;
	}
}

Back to the top