1/*******************************************************************************
2 * Copyright (c) 2000, 2009 IBM Corporation and others.
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the Eclipse Public License v1.0
5 * which accompanies this distribution, and is available at
6 * http://www.eclipse.org/legal/epl-v10.html
7 *
8 * Contributors:
9 *     IBM Corporation - initial API and implementation
10 *******************************************************************************/
11package org.eclipse.test.internal.performance.results.ui;
12
13import org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer;
14import org.eclipse.core.runtime.preferences.DefaultScope;
15import org.eclipse.core.runtime.preferences.IEclipsePreferences;
16import org.eclipse.core.runtime.preferences.IScopeContext;
17import org.eclipse.test.internal.performance.PerformanceTestPlugin;
18import org.eclipse.test.internal.performance.data.Dim;
19import org.eclipse.test.internal.performance.results.utils.IPerformancesConstants;
20import org.eclipse.test.performance.Dimension;
21
22/**
23 * Default performances preferences initializer.
24 */
25public class PerformanceResultsPreferenceInitializer extends AbstractPreferenceInitializer implements IPerformancesConstants {
26
27/*
28 * (non-Javadoc)
29 *
30 * @see org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer#initializeDefaultPreferences()
31 */
32public void initializeDefaultPreferences() {
33	IEclipsePreferences defaultPreferences = ((IScopeContext) new DefaultScope()).getNode(PLUGIN_ID);
34
35	// Eclipse version
36	defaultPreferences.putInt(PRE_ECLIPSE_VERSION, IPerformancesConstants.DEFAULT_ECLIPSE_VERSION);
37
38	// Database
39	defaultPreferences.putBoolean(PRE_DATABASE_CONNECTION, IPerformancesConstants.DEFAULT_DATABASE_CONNECTION);
40	defaultPreferences.putBoolean(PRE_DATABASE_LOCAL, IPerformancesConstants.DEFAULT_DATABASE_LOCAL);
41	defaultPreferences.put(PRE_DATABASE_LOCATION, IPerformancesConstants.NETWORK_DATABASE_LOCATION);
42
43	// Status
44	defaultPreferences.putInt(PRE_WRITE_STATUS, IPerformancesConstants.DEFAULT_WRITE_STATUS);
45
46	// Config descriptors
47	String[][] configDescriptors = PerformanceTestPlugin.getConfigDescriptors();
48	int cdLength = configDescriptors.length;
49	for (int i = 0; i < cdLength; i++) {
50		String[] descriptor = configDescriptors[i];
51		defaultPreferences.put(PRE_CONFIG_DESCRIPTOR_NAME + "." + i, descriptor[0]);
52		defaultPreferences.put(PRE_CONFIG_DESCRIPTOR_DESCRIPTION + "." + i, descriptor[1]);
53	}
54
55	// Default dimension
56	defaultPreferences.put(PRE_DEFAULT_DIMENSION, ((Dim) PerformanceTestPlugin.getDefaultDimension()).getName());
57
58	// Result dimensions
59	Dimension[] dimensions = PerformanceTestPlugin.getResultsDimensions();
60	int length = dimensions.length;
61	for (int i = 0; i < length; i++) {
62		Dim dim = (Dim) dimensions[i];
63		defaultPreferences.put(PRE_RESULTS_DIMENSION + "." + i, dim.getName());
64	}
65
66	// Filters
67	defaultPreferences.putBoolean(PRE_FILTER_ADVANCED_SCENARIOS, IPerformancesConstants.DEFAULT_FILTER_ADVANCED_SCENARIOS);
68	defaultPreferences.putBoolean(PRE_FILTER_OLD_BUILDS, IPerformancesConstants.DEFAULT_FILTER_OLD_BUILDS);
69	defaultPreferences.putBoolean(PRE_FILTER_NIGHTLY_BUILDS, IPerformancesConstants.DEFAULT_FILTER_NIGHTLY_BUILDS);
70
71	// Milestones
72	String[] milestones = IPerformancesConstants.V35_MILESTONES;
73	String prefix = PRE_MILESTONE_BUILDS + "." + ECLIPSE_MAINTENANCE_VERSION;
74	length = milestones.length;
75	for (int i = 0; i < length; i++) {
76		defaultPreferences.put(prefix + i, milestones[i]);
77	}
78	milestones = IPerformancesConstants.V36_MILESTONES;
79	prefix = PRE_MILESTONE_BUILDS + "." + ECLIPSE_DEVELOPMENT_VERSION;
80	length = milestones.length;
81	for (int i = 0; i < length; i++) {
82		defaultPreferences.put(prefix + i, milestones[i]);
83	}
84}
85
86}
87