Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: ee0c5379d2395b34688c39ed780376e352aaf6dd (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
/*******************************************************************************
 * Copyright (c) 2015, 2017 Tasktop Technologies 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
 *
 * Contributors:
 *     Tasktop Technologies - initial API and implementation
 *     Red Hat Inc. - modified for use with OpenShift.io
 *******************************************************************************/

package org.eclipse.linuxtools.internal.mylyn.osio.rest.ui.provisional;

import org.eclipse.jface.dialogs.Dialog;
import org.eclipse.jface.wizard.IWizardPage;
import org.eclipse.jface.wizard.WizardPage;
import org.eclipse.linuxtools.internal.mylyn.osio.rest.core.OSIORestConnector;
import org.eclipse.linuxtools.internal.mylyn.osio.rest.core.OSIORestTaskAttributeMapper;
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 OSIORestQueryTypeWizardPage extends WizardPage {

	private final AbstractRepositoryQueryPage2 customPage;

	private final AbstractRepositoryQueryPage2 searchPage;

	private Button buttonCustom;

	private Button buttonForm;

	private Composite composite;

	public OSIORestQueryTypeWizardPage(TaskRepository repository, AbstractRepositoryConnector connector) {
		super(Messages.OSIORestQueryTypeWizardPage_ChooseQueryType);
		setTitle(Messages.OSIORestQueryTypeWizardPage_ChooseQueryType);
		setDescription(Messages.OSIORestQueryTypeWizardPage_SelectAvailableQueryTypes);
		setImageDescriptor(TasksUiImages.BANNER_REPOSITORY);
		OSIORestConnector connectorREST = (OSIORestConnector) connector;
		TaskData taskDataSimpleURL = new TaskData(new OSIORestTaskAttributeMapper(repository, connectorREST),
				repository.getConnectorKind(), Messages.OSIORestQueryTypeWizardPage_Query,
				Messages.OSIORestQueryTypeWizardPage_Query);
		TaskData taskDataSearch = new TaskData(new OSIORestTaskAttributeMapper(repository, connectorREST),
				repository.getConnectorKind(), Messages.OSIORestQueryTypeWizardPage_Query,
				Messages.OSIORestQueryTypeWizardPage_Query);
		customPage = OSIORestUIUtil.createOSIORestSearchPage(true, false, taskDataSimpleURL, connectorREST,
				repository, null);
		searchPage = OSIORestUIUtil.createOSIORestSearchPage(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.OSIORestQueryTypeWizardPage_CreateQueryUsingForm);
		buttonForm.setSelection(true);

		buttonCustom = new Button(composite, SWT.RADIO);
		buttonCustom.setText(Messages.OSIORestQueryTypeWizardPage_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