Skip to main content
summaryrefslogtreecommitdiffstats
blob: 003c72f759dfef09ed2c6bceb8fdafd2b6e119e6 (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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
/*******************************************************************************
 * Copyright (c) 2004 - 2006 University Of British Columbia 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:
 *     University Of British Columbia - initial API and implementation
 *******************************************************************************/

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

import org.eclipse.jface.wizard.WizardPage;
import org.eclipse.mylar.internal.tasklist.ui.TaskListImages;
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 Rob Elves
 */
public abstract class AbstractBugzillaQueryPage extends WizardPage {

	private static final String TITLE_QUERY_TITLE = "Query Title";

	private static final String TITLE = "Enter query parameters";

	private static final String DESCRIPTION = "If attributes are blank or stale press the Update button.";
	
	private Text title;

	private String titleString = "";

	public AbstractBugzillaQueryPage(String wizardTitle) {
		this(wizardTitle, "");
		setTitle(TITLE);
		setDescription(DESCRIPTION);
		setImageDescriptor(TaskListImages.BANNER_REPOSITORY);
		setPageComplete(false);
	}

	public AbstractBugzillaQueryPage(String wizardTitle, String queryTitle) {
		super(wizardTitle);
		titleString = queryTitle;
	}

	public void createControl(Composite parent) {
		createTitleGroup(parent);
		title.setFocus();
	}

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

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

		title.addKeyListener(new KeyListener() {

			public void keyPressed(KeyEvent e) {
				// ignore
			}

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

	public boolean canFlipToNextPage() {
		if (getErrorMessage() != null || !isPageComplete())
			return false;

		return true;
	}

	@Override
	public boolean isPageComplete() {
		if (title != null && !title.getText().equals("")) {
			return true;
		}
		return false;
	}

	public String getQueryTitle() {
		return title.getText();
	}

	public abstract BugzillaRepositoryQuery getQuery();

}

Back to the top