1402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll/*******************************************************************************
2402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * Copyright (c) 2000, 2009 IBM Corporation and others.
3402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * All rights reserved. This program and the accompanying materials
4402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * are made available under the terms of the Eclipse Public License v1.0
5402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * which accompanies this distribution, and is available at
6402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * http://www.eclipse.org/legal/epl-v10.html
7402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll *
8402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * Contributors:
9402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll *     IBM Corporation - initial API and implementation
10402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll *******************************************************************************/
11402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Mollpackage org.eclipse.test.internal.performance.results.ui;
12402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll
13402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Mollimport java.io.File;
14402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Mollimport java.util.Arrays;
15402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Mollimport java.util.Iterator;
16402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll
17402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Mollimport org.osgi.service.prefs.BackingStoreException;
18402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll
19402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Mollimport org.eclipse.test.internal.performance.PerformanceTestPlugin;
20402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Mollimport org.eclipse.test.internal.performance.results.db.DB_Results;
21402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Mollimport org.eclipse.test.internal.performance.results.utils.IPerformancesConstants;
22402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Mollimport org.eclipse.test.internal.performance.results.utils.Util;
23402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Mollimport org.eclipse.test.performance.ui.UiPlugin;
24402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll
25402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Mollimport org.eclipse.swt.SWT;
26402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Mollimport org.eclipse.swt.custom.CCombo;
27402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Mollimport org.eclipse.swt.events.ModifyEvent;
28402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Mollimport org.eclipse.swt.events.ModifyListener;
29402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Mollimport org.eclipse.swt.events.SelectionEvent;
30402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Mollimport org.eclipse.swt.events.SelectionListener;
31402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Mollimport org.eclipse.swt.layout.GridData;
32402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Mollimport org.eclipse.swt.layout.GridLayout;
33402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Mollimport org.eclipse.swt.widgets.Button;
34402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Mollimport org.eclipse.swt.widgets.Composite;
35402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Mollimport org.eclipse.swt.widgets.Control;
36402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Mollimport org.eclipse.swt.widgets.DirectoryDialog;
37402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Mollimport org.eclipse.swt.widgets.Display;
38402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Mollimport org.eclipse.swt.widgets.Group;
39402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Mollimport org.eclipse.swt.widgets.Label;
40402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Mollimport org.eclipse.swt.widgets.List;
41402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Mollimport org.eclipse.swt.widgets.Text;
42402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll
43402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Mollimport org.eclipse.core.runtime.preferences.IEclipsePreferences;
44402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Mollimport org.eclipse.core.runtime.preferences.InstanceScope;
45402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll
46402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Mollimport org.eclipse.jface.dialogs.MessageDialog;
47402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Mollimport org.eclipse.jface.preference.IPreferenceStore;
48402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Mollimport org.eclipse.jface.preference.PreferencePage;
49402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll
50402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Mollimport org.eclipse.ui.IWorkbench;
51402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Mollimport org.eclipse.ui.IWorkbenchPreferencePage;
52402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll
53402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll/**
54402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * Defines the 'Performances' preferences page.
55402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll */
56402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Mollpublic class PerformanceResultsPreferencePage extends PreferencePage
57402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	implements IWorkbenchPreferencePage, SelectionListener, ModifyListener, IPerformancesConstants {
58402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll
59402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	private Button mVersionRadioButton;
60402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	private Button dVersionRadionButton;
61402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	private CCombo databaseLocationCombo;
62402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	private Button dbConnectionCheckBox;
63402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	private Button dbLocalBrowseButton;
64402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	private Button dbRelengRadioButton;
65402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	private Button dbLocalRadioButton;
66402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	private CCombo defaultDimensionCombo;
67402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	private CCombo lastBuildCombo;
68402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	private List resultsDimensionsList;
69402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	private CCombo milestonesCombo;
70402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	private Label dbLocationLabel;
71402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll
72402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	// Status SWT objects
73402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	private Button statusValuesCheckBox;
74402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	private Button statusErrorNoneRadioButton;
75402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	private Button statusErrorNoticeableRadioButton;
76402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	private Button statusErrorSuspiciousRadioButton;
77402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	private Button statusErrorWeirdRadioButton;
78402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	private Button statusErrorInvalidRadioButton;
79402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	private Button statusSmallBuildValueCheckBox;
80402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	private Button statusSmallDeltaValueCheckBox;
81402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	private Button statusStatisticNoneRadioButton;
82402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	private Button statusStatisticErraticRadioButton;
83402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	private Button statusStatisticUnstableRadioButton;
84402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	private Text statusBuildsToConfirm;
85402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll
86402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	// TODO See whether config descriptors need to be set as preferences or not...
87402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	// private Table configDescriptorsTable;
88402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll
89402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	private BuildsView buildsView;
90402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll
91402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll/**
92402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * Utility method that creates a push button instance and sets the default
93402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * layout data.
94402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll *
95402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * @param parent
96402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll *            the parent for the new button
97402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * @param label
98402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll *            the label for the new button
99402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * @return the newly-created button
100402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll */
101402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Mollprivate Button createCheckBox(Composite parent, String label) {
102402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	Button button = new Button(parent, SWT.CHECK);
103402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	button.setText(label);
104402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	button.addSelectionListener(this);
105402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	GridData data = new GridData();
106402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	data.horizontalAlignment = GridData.FILL;
107402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	data.horizontalSpan = 5;
108402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	button.setLayoutData(data);
109402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	return button;
110402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll}
111402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll
112402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll/**
113402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * Create a text field specific for this application
114402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll *
115402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * @param parent
116402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll *            the parent of the new text field
117402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * @return the new text field
118402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll */
119402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Mollprivate CCombo createCombo(Composite parent) {
120402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	CCombo combo= new CCombo(parent, SWT.BORDER);
121402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	combo.addModifyListener(this);
122402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	GridData data = new GridData();
123402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	data.horizontalSpan = 3;
124402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	data.horizontalAlignment = GridData.FILL;
125402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	data.grabExcessHorizontalSpace = true;
126402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	data.verticalAlignment = GridData.CENTER;
127402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	data.grabExcessVerticalSpace = false;
128402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	combo.setLayoutData(data);
129402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	return combo;
130402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll}
131402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll
132402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll
133402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll/**
134402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * Creates composite control and sets the default layout data.
135402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll *
136402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * @param parent
137402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll *            the parent of the new composite
138402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * @param numColumns
139402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll *            the number of columns for the new composite
140402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * @param hSpan TODO
141402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * @return the newly-created coposite
142402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll */
143402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Mollprivate Composite createComposite(Composite parent, int numColumns, int hSpan) {
144402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	Composite composite = new Composite(parent, SWT.NULL);
145402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll
146402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	// GridLayout
147402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	GridLayout layout = new GridLayout();
148402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	layout.numColumns = numColumns;
149402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	composite.setLayout(layout);
150402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll
151402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	// GridData
152402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	GridData data = new GridData();
153402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	data.verticalAlignment = GridData.FILL;
154402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	data.horizontalAlignment = GridData.FILL;
155402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	data.horizontalSpan = hSpan;
156402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	composite.setLayoutData(data);
157402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	return composite;
158402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll}
159402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll
160402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll/**
161402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * (non-Javadoc) Method declared on PreferencePage
162402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll */
163402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Mollprotected Control createContents(Composite parent) {
164402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll
165402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	this.buildsView = (BuildsView) PerformancesView.getWorkbenchView("org.eclipse.test.internal.performance.results.ui.BuildsView");
166402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	if (this.buildsView == null) {
167402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll		Label errorLabel = createLabel(parent, "No performances preferences can be set because the build view has not been created yet!", false);
168402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll		errorLabel.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_RED));
169402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	} else {
170402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll		// Eclipse version choice
171402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll		Composite composite_eclipseVersion = createComposite(parent, 5, 1);
172402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll		createLabel(composite_eclipseVersion, "Eclipse version", false);
173402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll		Composite composite_versionChoice = createComposite(composite_eclipseVersion, 5, 1);
174402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll		this.mVersionRadioButton = createRadioButton(composite_versionChoice, "v"+ECLIPSE_MAINTENANCE_VERSION);
175402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll		this.dVersionRadionButton = createRadioButton(composite_versionChoice, "v"+ECLIPSE_DEVELOPMENT_VERSION);
176402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll
177402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll		// Database location
178402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll		Composite compositeDatabase = createComposite(parent, 5, 1);
179402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll		Group databaseGroup = createGroup(compositeDatabase, "Database", 5);
180402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll		Composite compositeDatabaseConnection = createComposite(databaseGroup, 3, 5);
181402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll		this.dbConnectionCheckBox = createCheckBox(compositeDatabaseConnection, "Connected");
182402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll		this.dbRelengRadioButton = createRadioButton(compositeDatabaseConnection, "Releng");
183402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll		this.dbLocalRadioButton = createRadioButton(compositeDatabaseConnection, "Local");
184402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll		this.dbLocationLabel = createLabel(databaseGroup, "Location", false);
185402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll		this.databaseLocationCombo = createCombo(databaseGroup);
186402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll		this.databaseLocationCombo.setEditable(false);
187402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	    this.dbLocalBrowseButton = createPushButton(databaseGroup, "Browse");
188402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll
189402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll		// Status
190402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll		Composite compositeStatus = createComposite(parent, 1, 3);
191402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll		Group statusGroup = createGroup(compositeStatus, "Status", 1);
192402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll		this.statusValuesCheckBox = createCheckBox(statusGroup, "Values");
193402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll		this.statusValuesCheckBox.setToolTipText("Include numbers while writing status");
194402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll		Group statusErrorGroup = createGroup(statusGroup, "Error level", 5);
195402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll		statusErrorGroup.setToolTipText("Exclude from the written status failures depending on their build result error...");
196402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll		this.statusErrorNoneRadioButton = createRadioButton(statusErrorGroup, "None");
197402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll		this.statusErrorNoneRadioButton.setToolTipText("Do not exclude failures if they have a noticeable error");
198402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll		this.statusErrorInvalidRadioButton = createRadioButton(statusErrorGroup, "Invalid");
199402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll		this.statusErrorInvalidRadioButton.setToolTipText("Exclude all invalid failures (i.e. result error is over 100%)");
200402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll		this.statusErrorWeirdRadioButton = createRadioButton(statusErrorGroup, "Weird");
201402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll		this.statusErrorWeirdRadioButton.setToolTipText("Exclude all weird failures (i.e. result error is over 50%)");
202402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll		this.statusErrorSuspiciousRadioButton = createRadioButton(statusErrorGroup, "Suspicious");
203402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll		this.statusErrorSuspiciousRadioButton.setToolTipText("Exclude all suspicious failures (i.e. result error is over 25%)");
204402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll		this.statusErrorNoticeableRadioButton = createRadioButton(statusErrorGroup, "Noticeable");
205402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll		this.statusErrorNoticeableRadioButton.setToolTipText("Exclude all failures which have a noticeable error (i.e result error is over 3%)");
206402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll		Group statusSmallGroup = createGroup(statusGroup, "Small value", 5);
207402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll		statusErrorGroup.setToolTipText("Exclude from the written status failures depending on their value");
208402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll		this.statusSmallBuildValueCheckBox = createCheckBox(statusSmallGroup, "Build value");
209402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll		this.statusSmallBuildValueCheckBox.setToolTipText("Exclude all failures which have a build result value smaller than 100ms");
210402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll		this.statusSmallDeltaValueCheckBox = createCheckBox(statusSmallGroup, "Delta value");
211402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll		this.statusSmallDeltaValueCheckBox.setToolTipText("Exclude all failures which have a delta result value smaller than 100ms");
212402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll		Group statusStatisticsGroup = createGroup(statusGroup, "Statistics", 5);
213402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll		statusStatisticsGroup.setToolTipText("Exclude from the written status failures depending on build results statistics...");
214402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll		this.statusStatisticNoneRadioButton = createRadioButton(statusStatisticsGroup, "None");
215402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll		this.statusStatisticNoneRadioButton.setToolTipText("Do not exclude failures which have bad baseline results statistics (i.e. variation is over 10%)");
216402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll		this.statusStatisticUnstableRadioButton = createRadioButton(statusStatisticsGroup, "Unstable");
217402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll		this.statusStatisticUnstableRadioButton.setToolTipText("Exclude all failures which have unstable baseline results statistics (i.e. variation is between 10% and 20%)");
218402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll		this.statusStatisticErraticRadioButton = createRadioButton(statusStatisticsGroup, "Erratic");
219402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll		this.statusStatisticErraticRadioButton.setToolTipText("Exclude all failures which have erratic baseline results statistics (i.e. variation is over 20%)");
220402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll		createLabel(statusGroup, "Builds to confirm:", false);
221402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll		this.statusBuildsToConfirm = createTextField(statusGroup);
222402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll		this.statusBuildsToConfirm.setToolTipText("The number of previous builds to take into account to confirm a regression");
223402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll
224402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll		// Milestones
225402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll		Composite compositeMilestones = createComposite(parent, 3, 1);
226402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll		createLabel(compositeMilestones, "Milestones", false);
227402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll		this.milestonesCombo = createCombo(compositeMilestones);
228402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll		this.milestonesCombo.setToolTipText("Enter the date of the milestone as yyyymmddHHMM");
229402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll
230402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll		// Last build
231402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll		StringBuffer tooltip = new StringBuffer("Select the last build to display performance results\n");
232402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll		tooltip.append("If set then performance results won't be displayed for any build after this date...");
233402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll		String tooltipText = tooltip.toString();
234402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll		Composite compositeLastBuild = createComposite(parent, 3, 1);
235402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	//	this.lastBuildCheckBox = createCheckBox(compositeLastBuild, "Until last build");
236402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll		createLabel(compositeLastBuild, "Last build: ", false);
237402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll		this.lastBuildCombo = createCombo(compositeLastBuild);
238402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll		this.lastBuildCombo.setEditable(false);
239402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll		this.lastBuildCombo.setToolTipText(tooltipText);
240402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll		this.lastBuildCombo.add("");
241402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll		initBuildsList();
242402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll
243402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll		// Default dimension layout
244402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll		tooltip = new StringBuffer("Select the default dimension which will be used for performance results\n");
245402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll		tooltip.append("When changed, the new selected dimension is automatically added to the dimensions list below...");
246402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll		tooltipText = tooltip.toString();
247402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll		Composite compositeDefaultDimension = createComposite(parent, 3, 1);
248402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll		createLabel(compositeDefaultDimension, "Default dimension: ", false);
249402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll		this.defaultDimensionCombo = createCombo(compositeDefaultDimension);
250402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll		this.defaultDimensionCombo.setEditable(false);
251402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll		this.defaultDimensionCombo.setToolTipText(tooltipText);
252402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll
253402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll		// Results dimensions layout
254402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll		tooltip = new StringBuffer("Select the dimensions which will be used while generating performance results\n");
255402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll		tooltip.append("When changed, the default dimension above is automatically added to the new list...");
256402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll		tooltipText = tooltip.toString();
257402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll		Composite compositeResultsDimensions = createComposite(parent, 3, 1);
258402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll		createLabel(compositeResultsDimensions, "Results dimensions: ", true/*beginning*/);
259402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll		this.resultsDimensionsList = createList(compositeResultsDimensions);
260402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll		this.resultsDimensionsList.setToolTipText(tooltipText);
261402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll
262402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll		// Config descriptors layout
263402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll		/* TODO See whether config descriptors need to be set as preferences or not...
264402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll		Composite compositeConfigDescriptors = createComposite(parent, 3);
265402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll		createLabel(compositeConfigDescriptors, "Config descriptors: ", false);
266402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll		this.configDescriptorsTable = createTable(compositeConfigDescriptors);
267402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll		TableColumn firstColumn = new TableColumn(this.configDescriptorsTable, SWT.LEFT);
268402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll		firstColumn.setText ("Name");
269402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll		firstColumn.setWidth(50);
270402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll		TableColumn secondColumn = new TableColumn(this.configDescriptorsTable, SWT.FILL | SWT.LEFT);
271402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll		secondColumn.setText ("Description");
272402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll		secondColumn.setWidth(300);
273402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll		*/
274402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll
275402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll		// init values
276402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll		initializeValues();
277402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	}
278402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll
279402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	// font = null;
280402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	Composite contents = new Composite(parent, SWT.NULL);
281402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	contents.pack(true);
282402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	return contents;
283402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll}
284402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll
285402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll/**
286402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * Utility method that creates a label instance and sets the default layout
287402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * data.
288402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll *
289402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * @param parent
290402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll *            the parent for the new label
291402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * @param text
292402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll *            the text for the new label
293402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * @return the new label
294402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll */
295402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Mollprivate Group createGroup(Composite parent, String text, int columns) {
296402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	Group group = new Group(parent, SWT.NONE);
297402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	group.setLayout(new GridLayout(columns, false));
298402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	group.setText(text);
299402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	GridData data = new GridData(SWT.FILL, SWT.FILL, true, true);
300402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll//	data.horizontalSpan = 1;
301402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	group.setLayoutData(data);
302402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	return group;
303402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll}
304402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll
305402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll/**
306402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * Utility method that creates a label instance and sets the default layout
307402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * data.
308402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll *
309402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * @param parent
310402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll *            the parent for the new label
311402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * @param text
312402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll *            the text for the new label
313402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * @param beginning TODO
314402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * @return the new label
315402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll */
316402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Mollprivate Label createLabel(Composite parent, String text, boolean beginning) {
317402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	Label label = new Label(parent, SWT.BEGINNING|SWT.LEFT);
318402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	label.setText(text);
319402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	GridData data = new GridData();
320402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	data.horizontalAlignment = GridData.FILL;
321402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	data.verticalAlignment = beginning ? GridData.BEGINNING : GridData.CENTER;
322402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	label.setLayoutData(data);
323402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	return label;
324402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll}
325402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll
326402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll/**
327402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * Create a text field specific for this application
328402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll *
329402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * @param parent
330402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll *            the parent of the new text field
331402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * @return the new text field
332402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll */
333402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Mollprivate List createList(Composite parent) {
334402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	List list = new List(parent, SWT.MULTI | SWT.BORDER);
335402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	list.addSelectionListener(this);
336402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	GridData data = new GridData();
337402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	data.horizontalSpan = 2;
338402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	data.horizontalAlignment = GridData.FILL;
339402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	data.grabExcessHorizontalSpace = true;
340402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	data.verticalAlignment = GridData.CENTER;
341402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	data.grabExcessVerticalSpace = false;
342402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	list.setLayoutData(data);
343402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	return list;
344402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll}
345402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll
346402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll/**
347402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * Utility method that creates a push button instance and sets the default
348402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * layout data.
349402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll *
350402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * @param parent
351402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll *            the parent for the new button
352402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * @param label
353402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll *            the label for the new button
354402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * @return the newly-created button
355402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll */
356402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Mollprivate Button createPushButton(Composite parent, String label) {
357402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	Button button = new Button(parent, SWT.PUSH);
358402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	button.setText(label);
359402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	button.addSelectionListener(this);
360402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	GridData data = new GridData();
361402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	data.horizontalAlignment = SWT.LEFT;
362402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	data.grabExcessHorizontalSpace = true;
363402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll//	data.horizontalSpan = 2;
364402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	data.minimumWidth = 100;
365402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	button.setLayoutData(data);
366402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	return button;
367402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll}
368402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll
369402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll/**
370402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * Utility method that creates a radio button instance and sets the default
371402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * layout data.
372402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll *
373402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * @param parent
374402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll *            the parent for the new button
375402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * @param label
376402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll *            the label for the new button
377402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * @return the newly-created button
378402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll */
379402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Mollprivate Button createRadioButton(Composite parent, String label) {
380402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	Button button = new Button(parent, SWT.RADIO | SWT.LEFT);
381402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	button.setText(label);
382402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	button.addSelectionListener(this);
383402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	GridData data = new GridData();
384402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	button.setLayoutData(data);
385402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	return button;
386402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll}
387402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll
388402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll/*
389402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * Create a text field specific for this application
390402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll *
391402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * @param parent
392402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll *            the parent of the new text field
393402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * @return the new text field
394402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll *
395402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Mollprivate Table createTable(Composite parent) {
396402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	Table table = new Table(parent, SWT.BORDER);
397402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	table.setLinesVisible (true);
398402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	table.setHeaderVisible (true);
399402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	GridData gridData = new GridData(SWT.FILL, SWT.FILL, true, true, 3, 1);
400402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	gridData.heightHint = 150;
401402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	table.setLayoutData(gridData);
402402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	return table;
403402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll}
404402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll*/
405402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll
406402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll/*
407402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * Create a text field specific for this application
408402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll *
409402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * @param parent
410402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll *            the parent of the new text field
411402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * @return the new text field
412402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll */
413402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Mollprivate Text createTextField(Composite parent) {
414402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	Text text = new Text(parent, SWT.SINGLE | SWT.BORDER);
415402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	text.addModifyListener(this);
416402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	GridData data = new GridData();
417402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	data.horizontalAlignment = GridData.FILL;
418402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	data.grabExcessHorizontalSpace = true;
419402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	data.verticalAlignment = GridData.CENTER;
420402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	data.grabExcessVerticalSpace = false;
421402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	text.setLayoutData(data);
422402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	return text;
423402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll}
424402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll
425402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll/**
426402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * The <code>ReadmePreferencePage</code> implementation of this
427402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * <code>PreferencePage</code> method returns preference store that belongs to
428402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * the our plugin. This is important because we want to store our preferences
429402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * separately from the workbench.
430402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll */
431402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Mollprotected IPreferenceStore doGetPreferenceStore() {
432402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	return UiPlugin.getDefault().getPreferenceStore();
433402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll}
434402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll
435402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll/**
436402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * @return The dialog title
437402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll */
438402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael MollString getDialogTitle() {
439402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	String title = DB_Results.getDbTitle();
440402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	if (title == null) {
441402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll		// DB is not connected
442402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll		int version;
443402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll		if (this.mVersionRadioButton.getSelection()) {
444402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll			version = ECLIPSE_MAINTENANCE_VERSION;
445402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll		} else {
446402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll			version = ECLIPSE_DEVELOPMENT_VERSION;
447402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll		}
448402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll		title = "Eclipse " + version + " - DB not connected";
449402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	}
450402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	return title;
451402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll}
452402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll
453402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll/*
454402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * Get the directory path using the given location as default.
455402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll */
456402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Mollprivate String getDirectoryPath(String location) {
457402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	DirectoryDialog dialog = new DirectoryDialog(getShell(), SWT.OPEN);
458402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	dialog.setText(getDialogTitle());
459402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	dialog.setMessage("Select local database directory:");
460402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	dialog.setFilterPath(location);
461402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	String path = dialog.open();
462402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	if (path != null) {
463402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll		File dir = new File(path);
464402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll		if (dir.exists() && dir.isDirectory()) {
465402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll			return dir.getAbsolutePath();
466402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll		}
467402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	}
468402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	return null;
469402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll}
470402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll
471402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll/*
472402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * (non-Javadoc) Method declared on IWorkbenchPreferencePage
473402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll */
474402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Mollpublic void init(IWorkbench workbench) {
475402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	// do nothing
476402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll}
477402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll
478402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll/*
479402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * Init he contents of the dimensions list controls.
480402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll */
481402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Mollvoid initDimensionsLists() {
482402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	// Dimensions lists
483402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	java.util.List dimensions = PerformanceTestPlugin.getDimensions();
484402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	Iterator names = dimensions.iterator();
485402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	while (names.hasNext()) {
486402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll		String name = (String) names.next();
487402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll		this.defaultDimensionCombo.add(name);
488402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll		this.resultsDimensionsList.add(name);
489402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	}
490402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll}
491402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll
492402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll/*
493402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * Init he contents of the dimensions list controls.
494402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll */
495402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Mollprivate void initBuildsList() {
496402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	String[] builds = DB_Results.getBuilds();
497402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	Arrays.sort(builds, Util.BUILD_DATE_COMPARATOR);
498402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	int length = builds.length;
499402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	for (int i=length-1; i>=0; i--) {
500402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll		this.lastBuildCombo.add(builds[i]);
501402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	}
502402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll}
503402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll
504402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll/**
505402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * Initializes states of the controls using default values in the preference
506402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * store.
507402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll */
508402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Mollprivate void initializeDefaults() {
509402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	IPreferenceStore store = getPreferenceStore();
510402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll
511402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	// Init default database values
512402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	this.dbConnectionCheckBox.setSelection(store.getDefaultBoolean(PRE_DATABASE_CONNECTION));
513402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	this.dbRelengRadioButton.setSelection(false);
514402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	this.dbLocalRadioButton.setSelection(false);
515402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	final boolean dbLocal = store.getDefaultBoolean(PRE_DATABASE_LOCAL);
516402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	if (dbLocal) {
517402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll		this.dbLocalRadioButton.setSelection(true);
518402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	} else {
519402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll		this.dbRelengRadioButton.setSelection(true);
520402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	}
521402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	this.databaseLocationCombo.removeAll();
522402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	this.databaseLocationCombo.setText(store.getDefaultString(PRE_DATABASE_LOCATION));
523402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	updateDatabaseGroup();
524402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll
525402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	// Init default status values
526402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	int writeStatus = store.getDefaultInt(PRE_WRITE_STATUS);
527402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	initStatusValues(writeStatus);
528402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll
529402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	// Init eclipse version
530402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	this.mVersionRadioButton.setSelection(false);
531402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	this.dVersionRadionButton.setSelection(false);
532402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	int version = store.getDefaultInt(PRE_ECLIPSE_VERSION);
533402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	if (version == ECLIPSE_MAINTENANCE_VERSION) {
534402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll		this.mVersionRadioButton.setSelection(true);
535402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	} else {
536402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll		this.dVersionRadionButton.setSelection(true);
537402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	}
538402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll    updateBrowseButtonToolTip(version);
539402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll
540402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	// Milestones
541402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	this.milestonesCombo.removeAll();
542402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	String prefix = PRE_MILESTONE_BUILDS + "." + version;
543402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	String milestone = store.getDefaultString(prefix + "0");
544402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	int index = 0;
545402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	while (milestone != null && milestone.length() > 0) {
546402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll		this.milestonesCombo.add(milestone);
547402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll		milestone = store.getDefaultString(prefix + ++index);
548402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	}
549402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll
550402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	// Init last build
551402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	String lastBuild = store.getDefaultString(PRE_LAST_BUILD);
552402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll//	if (lastBuild.length() == 0) {
553402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll//		this.lastBuildCheckBox.setSelection(false);
554402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll//		this.lastBuildCombo.setEnabled(false);
555402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll//	} else {
556402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll//		this.lastBuildCombo.setEnabled(true);
557402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll//	}
558402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	this.lastBuildCombo.setText(lastBuild);
559402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll
560402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	// Init default default dimension
561402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	String defaultDimension = store.getDefaultString(PRE_DEFAULT_DIMENSION);
562402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	this.defaultDimensionCombo.setText(defaultDimension);
563402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll
564402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	// Init default generated dimensions
565402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	this.resultsDimensionsList.add(store.getDefaultString(PRE_RESULTS_DIMENSION+".0"));
566402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	this.resultsDimensionsList.add(store.getDefaultString(PRE_RESULTS_DIMENSION+".1"));
567402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll}
568402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll
569402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll/**
570402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * Initializes states of the controls from the preference store.
571402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll */
572402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Mollprivate void initializeValues() {
573402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	IPreferenceStore store = getPreferenceStore();
574402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll
575402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	// Init database info
576402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	this.dbConnectionCheckBox.setSelection(store.getBoolean(PRE_DATABASE_CONNECTION));
577402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	final boolean dbLocal = store.getBoolean(PRE_DATABASE_LOCAL);
578402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	if (dbLocal) {
579402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll		this.dbLocalRadioButton.setSelection(true);
580402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll		this.dbRelengRadioButton.setToolTipText("");
581402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	} else {
582402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll		this.dbRelengRadioButton.setSelection(true);
583402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll		this.dbRelengRadioButton.setToolTipText(NETWORK_DATABASE_LOCATION);
584402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	}
585402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	this.databaseLocationCombo.removeAll();
586402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	this.databaseLocationCombo.setText(store.getString(PRE_DATABASE_LOCATION));
587402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	for (int i = 0; i < 3; i++) {
588402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll		String history = store.getString(PRE_DATABASE_LOCATION + "." + i);
589402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll		if (history.length() == 0)
590402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll			break;
591402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll		this.databaseLocationCombo.add(history);
592402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	}
593402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	updateDatabaseGroup();
594402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll
595402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	// Init status values
596402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	int writeStatus = store.getInt(PRE_WRITE_STATUS);
597402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	initStatusValues(writeStatus);
598402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll
599402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	// Init eclipse version
600402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	int version = store.getInt(PRE_ECLIPSE_VERSION);
601402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	if (version == ECLIPSE_MAINTENANCE_VERSION) {
602402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll		this.mVersionRadioButton.setSelection(true);
603402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	} else {
604402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll		this.dVersionRadionButton.setSelection(true);
605402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	}
606402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll    updateBrowseButtonToolTip(version);
607402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll
608402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	// Milestones
609402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	String prefix = PRE_MILESTONE_BUILDS + "." + version;
610402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	int index = 0;
611402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	String milestone = store.getString(prefix + index);
612402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	while (milestone != null && milestone.length() > 0) {
613402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll		this.milestonesCombo.add(milestone);
614402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll		milestone = store.getString(prefix + ++index);
615402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	}
616402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll
617402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	// Init last build
618402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	String lastBuild = store.getString(PRE_LAST_BUILD);
619402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll//	if (lastBuild.length() == 0) {
620402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll//		this.lastBuildCheckBox.setSelection(false);
621402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll//		this.lastBuildCombo.setEnabled(false);
622402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll//	} else {
623402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll//		this.lastBuildCombo.setEnabled(true);
624402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll//	}
625402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	this.lastBuildCombo.setText(lastBuild);
626402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll
627402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	// Init composite lists
628402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	initDimensionsLists();
629402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll
630402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	// Init default dimension
631402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	String defaultDimension = store.getString(PRE_DEFAULT_DIMENSION);
632402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	this.defaultDimensionCombo.setText(defaultDimension);
633402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll
634402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	// Init generated dimensions
635402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	int count = this.resultsDimensionsList.getItemCount();
636402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	int[] indices = new int[count];
637402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	int n = 0;
638402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	String resultsDimension = store.getString(PRE_RESULTS_DIMENSION + "." + n);
639402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	while (resultsDimension.length() > 0) {
640402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll		indices[n++] = this.resultsDimensionsList.indexOf(resultsDimension);
641402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll		resultsDimension = store.getString(PRE_RESULTS_DIMENSION + "." + n);
642402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	}
643402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	if (n < count) {
644402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll		System.arraycopy(indices, 0, indices = new int[n], 0, n);
645402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	}
646402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	this.resultsDimensionsList.select(indices);
647402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll
648402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	// Init config descriptors
649402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	/* TODO See whether config descriptors need to be set as preferences or not...
650402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	this.configDescriptorsTable.clearAll();
651402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	int d = 0;
652402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	String descriptorName = store.getString(PRE_CONFIG_DESCRIPTOR_NAME + "." + d);
653402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	String descriptorDescription = store.getString(PRE_CONFIG_DESCRIPTOR_DESCRIPTION + "." + d++);
654402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	while (descriptorName.length() > 0) {
655402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll		TableItem tableItem = new TableItem (this.configDescriptorsTable, SWT.NONE);
656402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll		tableItem.setText (0, descriptorName);
657402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll		tableItem.setText (1, descriptorDescription);
658402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll		descriptorName = store.getString(PRE_CONFIG_DESCRIPTOR_NAME + "." + d);
659402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll		descriptorDescription = store.getString(PRE_CONFIG_DESCRIPTOR_DESCRIPTION + "." + d++);
660402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	}
661402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	*/
662402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll}
663402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll
664402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll/**
665402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * @param writeStatus The observed status to write
666402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll */
667402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Mollprivate void initStatusValues(int writeStatus) {
668402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	this.statusValuesCheckBox.setSelection((writeStatus & STATUS_VALUES) != 0);
669402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	this.statusErrorNoneRadioButton.setSelection(false);
670402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	this.statusErrorNoticeableRadioButton.setSelection(false);
671402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	this.statusErrorSuspiciousRadioButton.setSelection(false);
672402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	this.statusErrorWeirdRadioButton.setSelection(false);
673402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	this.statusErrorInvalidRadioButton.setSelection(false);
674402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	switch (writeStatus & STATUS_ERROR_LEVEL_MASK) {
675402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll		case STATUS_ERROR_NONE:
676402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll			this.statusErrorNoneRadioButton.setSelection(true);
677402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll			break;
678402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll		case STATUS_ERROR_NOTICEABLE:
679402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll			this.statusErrorNoticeableRadioButton.setSelection(true);
680402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll			break;
681402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll		case STATUS_ERROR_SUSPICIOUS:
682402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll			this.statusErrorSuspiciousRadioButton.setSelection(true);
683402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll			break;
684402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll		case STATUS_ERROR_WEIRD:
685402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll			this.statusErrorWeirdRadioButton.setSelection(true);
686402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll			break;
687402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll		case STATUS_ERROR_INVALID:
688402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll			this.statusErrorInvalidRadioButton.setSelection(true);
689402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll			break;
690402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	}
691402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	this.statusSmallBuildValueCheckBox.setSelection(false);
692402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	this.statusSmallDeltaValueCheckBox.setSelection(false);
693402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	switch (writeStatus & STATUS_SMALL_VALUE_MASK) {
694402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll		case STATUS_SMALL_VALUE_BUILD:
695402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll			this.statusSmallBuildValueCheckBox.setSelection(true);
696402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll			break;
697402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll		case STATUS_SMALL_VALUE_DELTA:
698402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll			this.statusSmallDeltaValueCheckBox.setSelection(true);
699402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll			break;
700402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	}
701402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	this.statusStatisticNoneRadioButton.setSelection(false);
702402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	this.statusStatisticErraticRadioButton.setSelection(false);
703402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	this.statusStatisticUnstableRadioButton.setSelection(false);
704402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	switch (writeStatus & STATUS_STATISTICS_MASK) {
705402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll		case 0:
706402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll			this.statusStatisticNoneRadioButton.setSelection(true);
707402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll			break;
708402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll		case STATUS_STATISTICS_ERRATIC:
709402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll			this.statusStatisticErraticRadioButton.setSelection(true);
710402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll			break;
711402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll		case STATUS_STATISTICS_UNSTABLE:
712402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll			this.statusStatisticUnstableRadioButton.setSelection(true);
713402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll			break;
714402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	}
715402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	this.statusBuildsToConfirm.setText(String.valueOf(writeStatus & STATUS_BUILDS_NUMBER_MASK));
716402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll}
717402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll
718402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll/**
719402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * (non-Javadoc) Method declared on ModifyListener
720402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll */
721402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Mollpublic void modifyText(ModifyEvent event) {
722402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll
723402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	// Add default dimension to results if necessary
724402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	if (event.getSource() == this.defaultDimensionCombo) {
725402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll		String[] resultsDimensions = this.resultsDimensionsList.getSelection();
726402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll		int length = resultsDimensions.length;
727402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll		String defaultDimension = this.defaultDimensionCombo.getText();
728402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll		for (int i = 0; i < length; i++) {
729402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll			if (resultsDimensions[i].equals(defaultDimension)) {
730402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll				// Default dim is already set as a results dimension, hence nothing has to be done
731402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll				return;
732402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll			}
733402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll		}
734402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll		System.arraycopy(resultsDimensions, 0, resultsDimensions = new String[length + 1], 0, length);
735402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll		resultsDimensions[length] = defaultDimension;
736402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll		this.resultsDimensionsList.setSelection(resultsDimensions);
737402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	}
738402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll
739402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	// Add default dimension to results if necessary
740402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	if (event.getSource() == this.milestonesCombo) {
741402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll
742402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll		// Verify the only digits are entered
743402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll		String milestoneDate = this.milestonesCombo.getText();
744402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll		final int mLength = milestoneDate.length();
745402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll		if (mLength > 0) {
746402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll			for (int i=0; i<mLength; i++) {
747402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll				if (!Character.isDigit(milestoneDate.charAt(i))) {
748402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll					String[] items = this.milestonesCombo.getItems();
749402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll					int length = items.length;
750402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll					for (int j=0; j<length; j++) {
751402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll						if (items[j].equals(milestoneDate)) {
752402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll							// already existing milestone, leave silently
753402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll							if (MessageDialog.openQuestion(getShell(), getDialogTitle(), "Do you want to select milestone "+milestoneDate+" as the last build?")) {
754402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll								String builds[] = this.lastBuildCombo.getItems();
755402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll								int bLength = builds.length;
756402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll								String milestone = milestoneDate.substring(milestoneDate.indexOf('-')+1);
757402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll								for (int b=0; b<bLength; b++) {
758402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll									if (builds[b].length() > 0 && Util.getBuildDate(builds[b]).equals(milestone)) {
759402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll										this.lastBuildCombo.select(b);
760402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll										break;
761402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll									}
762402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll								}
763402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll							}
764402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll							return;
765402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll						}
766402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll					}
767402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll					openMilestoneErrorMessage(milestoneDate);
768402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll					return;
769402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll				}
770402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll			}
771402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll		}
772402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll
773402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll		// Do not verify further until a complete milestone date is entered
774402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll		if (mLength < 12) return;
775402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll
776402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll		// Verify the digits
777402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll		try {
778402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll			String str = milestoneDate.substring(0, 4);
779402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll			int year = Integer.parseInt(str);
780402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll			if (year < 2009 || year > 2020) { // 2020 should be enough!
781402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll				MessageDialog.openError(getShell(), getDialogTitle(), milestoneDate+": "+str+" is an invalid year, only value between 2009 and 2020 is accepted!");
782402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll				return;
783402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll			}
784402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll			str = milestoneDate.substring(4, 6);
785402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll			int month = Integer.parseInt(str);
786402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll			if (month <= 0 || month > 12) {
787402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll				MessageDialog.openError(getShell(), getDialogTitle(), milestoneDate+": "+str+" is an invalid month, it should be only from 01 to 12!");
788402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll				return;
789402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll			}
790402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll			str = milestoneDate.substring(6, 8);
791402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll			int day = Integer.parseInt(str);
792402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll			if (day <= 0 || day > 31) {
793402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll				// TODO improve this verification
794402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll				MessageDialog.openError(getShell(), getDialogTitle(), milestoneDate+": "+str+" is an invalid day, it should be only from 01 to 31!");
795402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll				return;
796402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll			}
797402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll			str = milestoneDate.substring(8, 10);
798402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll			int hour = Integer.parseInt(str);
799402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll			if (hour < 0 || hour > 23) {
800402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll				MessageDialog.openError(getShell(), getDialogTitle(), milestoneDate+": "+str+" is an invalid hour, it should be only from 00 to 23!");
801402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll				return;
802402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll			}
803402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll			str = milestoneDate.substring(10, 12);
804402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll			int min = Integer.parseInt(str);
805402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll			if (min < 0 || min > 59) {
806402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll				MessageDialog.openError(getShell(), getDialogTitle(), milestoneDate+": "+str+" is invalid minutes, it should be only from 00 to 59!");
807402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll				return;
808402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll			}
809402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll		}
810402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll		catch (NumberFormatException nfe) {
811402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll			openMilestoneErrorMessage(milestoneDate);
812402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll		}
813402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll
814402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll		// Get combo info
815402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll		String[] milestones = this.milestonesCombo.getItems();
816402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll		int length = milestones.length;
817402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll		String lastMilestone = length == 0 ? null : milestones[length-1];
818402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll
819402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll		// Verify that the added milestone is valid
820402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll		final String databaseLocation = this.databaseLocationCombo.getText();
821402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll		char version = databaseLocation.charAt(databaseLocation.length()-1);
822402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll
823402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll		// Verify that the milestone follow the last one
824402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll		String milestoneName;
825402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll		if (lastMilestone == null) {
826402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll			// No previous last milestone
827402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll			milestoneName = "M1";
828402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll		} else {
829402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll			// Compare with last milestone
830402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll			if (lastMilestone.charAt(0) == 'M') {
831402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll				char digit = lastMilestone.charAt(1);
832402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll				if (digit == '6') {
833402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll					// M6 is the last dvpt milestone
834402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll					milestoneName = "RC1";
835402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll				} else {
836402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll					milestoneName = "M" +((char)(digit+1));
837402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll				}
838402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll			} else if (lastMilestone.startsWith("RC")) {
839402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll				char digit = lastMilestone.charAt(2);
840402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll				if (digit == '4') {
841402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll					// RC4 is the last release candidate milestone
842402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll					milestoneName = "R3_"+version;
843402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll				} else {
844402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll					milestoneName = "RC" +((char)(digit+1));
845402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll				}
846402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll			} else if (lastMilestone.startsWith("R3_"+version+"-")) {
847402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll				milestoneName = "R3_" + version + "_1";
848402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll			} else if (lastMilestone.startsWith("R3_"+version+"_")) {
849402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll				char digit = lastMilestone.charAt(5);
850402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll				milestoneName = "R3_" + version + "_" + ((char)(digit+1));
851402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll			} else {
852402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll				MessageDialog.openError(getShell(), getDialogTitle(), "Unexpected last milestone name: "+lastMilestone+"!");
853402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll				return;
854402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll			}
855402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll
856402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll			// Verify the date of the new milestone
857402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll			int lastMilestoneDash = lastMilestone.indexOf('-');
858402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll			final String lastMilestoneDate = lastMilestone.substring(lastMilestoneDash+1);
859402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll			if (milestoneDate.compareTo(lastMilestoneDate) <= 0) {
860402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll				// TODO improve this verification
861402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll				MessageDialog.openError(getShell(), getDialogTitle(), "Milestone "+milestoneDate+" should be after the last milestone: "+lastMilestoneDate+"!");
862402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll				return;
863402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll			}
864402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll		}
865402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll
866402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll		// Verification are ok, ask to add the milestone
867402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll		final String milestone = milestoneName + "-" + milestoneDate;
868402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll		if (MessageDialog.openConfirm(getShell(), getDialogTitle(), milestoneDate+" is a valid milestone date.\n\nDo you want to add the milestone '"+milestone+"' to the preferences?")) {
869402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll			this.milestonesCombo.add(milestone);
870402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll			this.milestonesCombo.setText("");
871402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll		}
872402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	}
873402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll
874402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	// Verify the 'builds to confirm' number
875402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	if (event.getSource() == this.statusBuildsToConfirm) {
876402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll		try {
877402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll			int number = Integer.parseInt(this.statusBuildsToConfirm.getText());
878402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll			if (number < 1 ) {
879402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll				this.statusBuildsToConfirm.setText("1");
880402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll			} else {
881402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll				int buildsNumber = DB_Results.getBuildsNumber();
882402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll				if (number > buildsNumber) {
883402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll					this.statusBuildsToConfirm.setText(String.valueOf(buildsNumber));
884402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll				}
885402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll			}
886402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll		}
887402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll		catch (NumberFormatException nfe) {
888402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll			this.statusBuildsToConfirm.setText("1");
889402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll		}
890402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	}
891402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll}
892402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll
893402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll
894402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll/**
895402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * @param milestone
896402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll */
897402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Mollvoid openMilestoneErrorMessage(String milestone) {
898402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	MessageDialog.openError(getShell(), getDialogTitle(), milestone+" is an invalid milestone date. Only 'yyyymmddHHMM' format is accepted!");
899402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll}
900402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll
901402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll/*
902402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * (non-Javadoc) Method declared on PreferencePage
903402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll */
904402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Mollprotected void performDefaults() {
905402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	super.performDefaults();
906402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	initializeDefaults();
907402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll}
908402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll
909402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll/*
910402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * (non-Javadoc) Method declared on PreferencePage
911402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll */
912402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Mollpublic boolean performOk() {
913402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	final boolean hasBuildsView = this.buildsView != null;
914402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	if (hasBuildsView) {
915402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll		storeValues();
916402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll		try {
917402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll			IEclipsePreferences preferences = new InstanceScope().getNode(PLUGIN_ID);
918402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll			preferences.flush();
919402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll			this.buildsView.resetView();
920402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll		} catch (BackingStoreException e) {
921402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll			e.printStackTrace();
922402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll			return false;
923402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll		}
924402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	}
925402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	return true;
926402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll}
927402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll
928402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll/**
929402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * Stores the values of the controls back to the preference store.
930402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll */
931402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Mollprivate void storeValues() {
932402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	IPreferenceStore store = getPreferenceStore();
933402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll
934402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	// Set version
935402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	int version;
936402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	if (this.mVersionRadioButton.getSelection()) {
937402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll		version = ECLIPSE_MAINTENANCE_VERSION;
938402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	} else {
939402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll		version = ECLIPSE_DEVELOPMENT_VERSION;
940402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	}
941402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	store.setValue(PRE_ECLIPSE_VERSION, version);
942402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll
943402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	// Set database values
944402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	store.setValue(PRE_DATABASE_CONNECTION, this.dbConnectionCheckBox.getSelection());
945402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	final boolean dbLocal = this.dbLocalRadioButton.getSelection();
946402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	store.setValue(PRE_DATABASE_LOCAL, dbLocal);
947402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	String location = this.databaseLocationCombo.getText();
948402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	if (dbLocal) {
949402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll		store.setValue(PRE_DATABASE_LOCATION, location);
950402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	} else {
951402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll		store.setValue(PRE_DATABASE_LOCATION, NETWORK_DATABASE_LOCATION);
952402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	}
953402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	int count = this.databaseLocationCombo.getItemCount();
954402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	for (int i=0; i<count; i++) {
955402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll		String item = this.databaseLocationCombo.getItem(i);
956402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll		if (item.equals(location)) {
957402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll			this.databaseLocationCombo.remove(i);
958402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll			break;
959402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll		}
960402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	}
961402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	if (dbLocal) {
962402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll		this.databaseLocationCombo.add(location, 0);
963402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	}
964402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	int i=0;
965402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	for (; i<count; i++) {
966402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll		String item = this.databaseLocationCombo.getItem(i);
967402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll		if (item.length() == 0) break;
968402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll		store.setValue(PRE_DATABASE_LOCATION+"."+i, item);
969402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	}
970402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	while (store.getString(PRE_DATABASE_LOCATION+"."+i).length() > 0) {
971402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll		store.setToDefault(PRE_DATABASE_LOCATION+"."+i);
972402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll		i++;
973402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	}
974402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll
975402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	// Set status values
976402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	int writeStatus = 0;
977402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	if (this.statusValuesCheckBox.getSelection()) {
978402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll		writeStatus |= STATUS_VALUES;
979402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	}
980402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	if (this.statusErrorNoneRadioButton.getSelection()) {
981402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll		writeStatus |= STATUS_ERROR_NONE;
982402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	} else if (this.statusErrorNoticeableRadioButton.getSelection()) {
983402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll		writeStatus |= STATUS_ERROR_NOTICEABLE;
984402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	} else if (this.statusErrorSuspiciousRadioButton.getSelection()) {
985402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll		writeStatus |= STATUS_ERROR_SUSPICIOUS;
986402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	} else if (this.statusErrorWeirdRadioButton.getSelection()) {
987402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll		writeStatus |= STATUS_ERROR_WEIRD;
988402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	} else if (this.statusErrorInvalidRadioButton.getSelection()) {
989402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll		writeStatus |= STATUS_ERROR_INVALID;
990402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	}
991402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	if (this.statusSmallBuildValueCheckBox.getSelection()) {
992402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll		writeStatus |= STATUS_SMALL_VALUE_BUILD;
993402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	}
994402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	if (this.statusSmallDeltaValueCheckBox.getSelection()) {
995402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll		writeStatus |= STATUS_SMALL_VALUE_DELTA;
996402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	}
997402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	if (this.statusStatisticNoneRadioButton.getSelection()) {
998402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll		writeStatus &= ~STATUS_STATISTICS_MASK;
999402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	} else if (this.statusStatisticErraticRadioButton.getSelection()) {
1000402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll		writeStatus |= STATUS_STATISTICS_ERRATIC;
1001402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	} else if (this.statusStatisticUnstableRadioButton.getSelection()) {
1002402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll		writeStatus |= STATUS_STATISTICS_UNSTABLE;
1003402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	}
1004402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	writeStatus += Integer.parseInt(this.statusBuildsToConfirm.getText());
1005402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	store.setValue(PRE_WRITE_STATUS, writeStatus);
1006402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll
1007402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	// Set milestones
1008402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	String prefix = PRE_MILESTONE_BUILDS + "." + version;
1009402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	count  = this.milestonesCombo.getItemCount();
1010402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	for (i=0; i<count; i++) {
1011402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll		store.putValue(prefix + i, this.milestonesCombo.getItem(i));
1012402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	}
1013402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	Util.setMilestones(this.milestonesCombo.getItems());
1014402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll
1015402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	// Unset previous additional milestones
1016402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	String milestone = store.getString(prefix + count);
1017402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	while (milestone != null && milestone.length() > 0) {
1018402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll		store.putValue(prefix + count++, "");
1019402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll		milestone = store.getString(prefix + count);
1020402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	}
1021402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll
1022402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	// Set last build
1023402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	String lastBuild = this.lastBuildCombo.getText();
1024402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	store.putValue(PRE_LAST_BUILD, lastBuild);
1025402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll
1026402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	// Set default dimension
1027402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	String defaultDimension = this.defaultDimensionCombo.getText();
1028402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	store.putValue(PRE_DEFAULT_DIMENSION, defaultDimension);
1029402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	DB_Results.setDefaultDimension(defaultDimension);
1030402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll
1031402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	// Set generated dimensions
1032402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	int[] indices = this.resultsDimensionsList.getSelectionIndices();
1033402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	int length = indices.length;
1034402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	String[] dimensions = new String[length];
1035402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	if (length > 0) {
1036402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll		for (i = 0; i < indices.length; i++) {
1037402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll			dimensions[i] = this.resultsDimensionsList.getItem(indices[i]);
1038402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll			store.putValue(PRE_RESULTS_DIMENSION + "." + i, dimensions[i]);
1039402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll		}
1040402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	}
1041402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	int currentLength = DB_Results.getResultsDimensions().length;
1042402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	if (currentLength > length) {
1043402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll		for (i = currentLength - 1; i >= length; i--) {
1044402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll			store.putValue(PRE_RESULTS_DIMENSION + "." + i, ""); // reset extra dimensions
1045402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll		}
1046402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	}
1047402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	DB_Results.setResultsDimensions(dimensions);
1048402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll
1049402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	// Set config descriptors
1050402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	/* TODO See whether config descriptors need to be set as preferences or not...
1051402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	TableItem[] items = this.configDescriptorsTable.getItems();
1052402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	length = items.length;
1053402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	for (int i = 0; i < length; i++) {
1054402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll		TableItem item = items[i];
1055402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll		store.putValue(PRE_CONFIG_DESCRIPTOR_NAME + "." + i, item.getText(0));
1056402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll		store.putValue(PRE_CONFIG_DESCRIPTOR_DESCRIPTION + "." + i, item.getText(1));
1057402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	}
1058402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	*/
1059402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll}
1060402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll
1061402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll/**
1062402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * (non-Javadoc) Method declared on SelectionListener
1063402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll */
1064402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Mollpublic void widgetDefaultSelected(SelectionEvent event) {
1065402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll}
1066402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll
1067402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll/**
1068402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * (non-Javadoc) Method declared on SelectionListener
1069402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll */
1070402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Mollpublic void widgetSelected(SelectionEvent event) {
1071402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll
1072402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	// As for directory when 'Local' button is pushed
1073402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	final Object source = event.getSource();
1074402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	if (source == this.dbLocalBrowseButton) {
1075402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll		String location = this.databaseLocationCombo.getText();
1076402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll		String path = getDirectoryPath(location);
1077402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll		if (path != null) {
1078402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll			// First verify that the selected dir was correct
1079402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll			int version;
1080402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll			if (this.mVersionRadioButton.getSelection()) {
1081402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll				version = ECLIPSE_MAINTENANCE_VERSION;
1082402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll			} else {
1083402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll				version = ECLIPSE_DEVELOPMENT_VERSION;
1084402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll			}
1085402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll			File dbDir = new File(path, "perfDb"+version);
1086402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll			if (!dbDir.exists() || !dbDir.isDirectory()) {
1087402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll				StringBuffer message = new StringBuffer("Invalid performance database directory\n");
1088402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll				message.append(path+" should contain 'perfDb");
1089402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll				message.append(version);
1090402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll				message.append("' directory and none was found!");
1091402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll				MessageDialog.openError(getShell(), getDialogTitle(), message.toString());
1092402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll				return;
1093402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll			}
1094402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll
1095402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll			// Look for selected dir in combo box list
1096402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll			int count = this.databaseLocationCombo.getItemCount();
1097402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll			int index = -1;
1098402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll			for (int i = 0; i < count; i++) {
1099402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll				String item = this.databaseLocationCombo.getItem(i);
1100402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll				if (item.length() == 0) { // nothing in the combo-box list
1101402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll					break;
1102402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll				}
1103402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll				if (item.equals(path)) {
1104402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll					index = i;
1105402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll					break;
1106402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll				}
1107402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll			}
1108402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll			// Set the selected dir the more recent in the previous dirs list
1109402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll			if (index !=  0) {
1110402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll				if (index > 0) {
1111402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll					// the dir was used before, but not recently => remove it from previous dirs list
1112402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll					this.databaseLocationCombo.remove(index);
1113402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll				}
1114402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll				// add the selected dir on the top of the previous dirs list
1115402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll				this.databaseLocationCombo.add(path, 0);
1116402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll			}
1117402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll			// Set combo box text
1118402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll			this.databaseLocationCombo.setText(path);
1119402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll			updateLocalDb();
1120402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll		}
1121402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	}
1122402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll
1123402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	// Reset dabase location when 'Releng' button is pushed
1124402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	if (source == this.dbConnectionCheckBox) {
1125402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll		updateDatabaseGroup();
1126402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	}
1127402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll
1128402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	// Reset dabase location when 'Releng' check-box is checked
1129402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	if (source == this.dbLocalRadioButton) {
1130402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll		updateLocalDb();
1131402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	}
1132402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll
1133402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	// Add default dimension to results if necessary
1134402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	if (source == this.resultsDimensionsList) {
1135402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll		String[] resultsDimensions = this.resultsDimensionsList.getSelection();
1136402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll		int length = resultsDimensions.length;
1137402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll		String defaultDimension = this.defaultDimensionCombo.getText();
1138402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll		for (int i = 0; i < length; i++) {
1139402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll			if (resultsDimensions[i].equals(defaultDimension)) {
1140402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll				// Default dim is already set as a results dimension, hence nothing has to be done
1141402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll				return;
1142402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll			}
1143402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll		}
1144402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll		System.arraycopy(resultsDimensions, 0, resultsDimensions = new String[length + 1], 0, length);
1145402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll		resultsDimensions[length] = defaultDimension;
1146402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll		this.resultsDimensionsList.setSelection(resultsDimensions);
1147402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	}
1148402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll
1149402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll//	if (source == this.lastBuildCheckBox) {
1150402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll//		this.lastBuildCombo.setEnabled(this.lastBuildCheckBox.getSelection());
1151402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll//	}
1152402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll
1153402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	if (source == this.mVersionRadioButton) {
1154402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll		if (this.mVersionRadioButton.getSelection()) {
1155402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll		    updateBrowseButtonToolTip(ECLIPSE_MAINTENANCE_VERSION);
1156402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll		}
1157402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	}
1158402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll
1159402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	if (source == this.dVersionRadionButton) {
1160402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll		if (this.dVersionRadionButton.getSelection()) {
1161402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll		    updateBrowseButtonToolTip(ECLIPSE_DEVELOPMENT_VERSION);
1162402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll		}
1163402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	}
1164402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll}
1165402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll
1166402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll/*
1167402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * Update browse tooltip
1168402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll */
1169402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Mollvoid updateBrowseButtonToolTip(int version) {
1170402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	this.dbLocalBrowseButton.setToolTipText("Select the directory where the database was unzipped\n(i.e. should contain the perfDb"+version+" subdirectory)");
1171402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll}
1172402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll
1173402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll/*
1174402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * Update database group controls.
1175402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll */
1176402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Mollvoid updateDatabaseGroup() {
1177402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	if (this.dbConnectionCheckBox.getSelection()) {
1178402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll		this.dbRelengRadioButton.setEnabled(true);
1179402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll		this.dbLocalRadioButton.setEnabled(true);
1180402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll		updateLocalDb();
1181402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	} else {
1182402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll		this.dbRelengRadioButton.setEnabled(false);
1183402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll		this.dbLocalRadioButton.setEnabled(false);
1184402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll		this.databaseLocationCombo.setEnabled(false);
1185402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll		this.dbLocalBrowseButton.setEnabled(false);
1186402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll		setValid(true);
1187402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	}
1188402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll}
1189402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll
1190402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll/*
1191402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll * Update database location controls.
1192402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll */
1193402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Mollvoid updateLocalDb() {
1194402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	if (this.dbLocalRadioButton.getSelection()) {
1195402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll		this.databaseLocationCombo.setEnabled(true);
1196402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll		this.dbLocalBrowseButton.setEnabled(true);
1197402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll		if (this.databaseLocationCombo.getItemCount() == 0) {
1198402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll			this.databaseLocationCombo.setText("");
1199402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll			setValid(false);
1200402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll		} else {
1201402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll			this.databaseLocationCombo.select(0);
1202402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll			setValid(true);
1203402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll		}
1204402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll		this.dbRelengRadioButton.setToolTipText("");
1205402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll		this.dbLocationLabel.setEnabled(true);
1206402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	} else {
1207402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll		this.dbRelengRadioButton.setToolTipText(NETWORK_DATABASE_LOCATION);
1208402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll		this.databaseLocationCombo.setText("");
1209402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll		this.databaseLocationCombo.setEnabled(false);
1210402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll		this.dbLocalBrowseButton.setEnabled(false);
1211402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll		setValid(true);
1212402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll		this.dbLocationLabel.setEnabled(false);
1213402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll	}
1214402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll}
1215402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll
1216402794e73aed8611d62eb4b01cd155e2d76fcb87Raphael Moll}
1217