Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 3009b03476da78490febdeebf7243d228db5d457 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
/*****************************************************************************
 * Copyright (c) 2010 CEA LIST.
 *
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *  Camille Letavernier (CEA LIST) camille.letavernier@cea.fr - Initial API and implementation
 *****************************************************************************/
/*****************************************************************************
 * Copyright (c) 2010 CEA LIST.
 *
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *  Camille Letavernier (CEA LIST) camille.letavernier@cea.fr - Initial API and implementation
 *****************************************************************************/
package org.eclipse.papyrus.customization.properties.preferences;

import org.eclipse.jface.preference.BooleanFieldEditor;
import org.eclipse.jface.preference.FieldEditorPreferencePage;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.papyrus.customization.properties.Activator;
import org.eclipse.papyrus.customization.properties.messages.Messages;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.IWorkbenchPreferencePage;

/**
 * This page handles preferences for dialog boxes
 *
 * @author Camille Letavernier
 */
public class CustomizationPreferencePage extends FieldEditorPreferencePage implements IWorkbenchPreferencePage {

	/**
	 *
	 */
	public final static String OPEN_CUSTOMIZATION_PERSPECTIVE = "openCustomizationPerspective"; //$NON-NLS-1$

	/**
	 *
	 */
	public final static String ASK_FOR_CONFIRMATION = "askForConfirmation"; //$NON-NLS-1$

	/**
	 *
	 * Constructor.
	 *
	 */
	public CustomizationPreferencePage() {
	}

	/**
	 *
	 * Constructor.
	 *
	 * @param style
	 */
	public CustomizationPreferencePage(int style) {
		super(style);
	}

	/**
	 *
	 * Constructor.
	 *
	 * @param title
	 * @param style
	 */
	public CustomizationPreferencePage(String title, int style) {
		super(title, style);
	}

	/**
	 *
	 * Constructor.
	 *
	 * @param title
	 * @param image
	 * @param style
	 */
	public CustomizationPreferencePage(String title, ImageDescriptor image, int style) {
		super(title, image, style);
	}

	@Override
	public void init(IWorkbench workbench) {
		setPreferenceStore(Activator.getDefault().getPreferenceStore());
		setDescription(Messages.CustomizationPreferencePage_PropertyViewCustomizationPreferences);
	}

	@Override
	protected void createFieldEditors() {
		addField(new BooleanFieldEditor(OPEN_CUSTOMIZATION_PERSPECTIVE, Messages.CustomizationPreferencePage_OpenCustomizationPerspective, getFieldEditorParent()));
		addField(new BooleanFieldEditor(ASK_FOR_CONFIRMATION, Messages.CustomizationPreferencePage_AskForConfirmation, getFieldEditorParent()));
	}

	/**
	 * Indicates if the customization perspective should be opened
	 *
	 * @return true if the customization perspective should be opened
	 */
	public static boolean openCustomizationPerspective() {
		return Activator.getDefault().getPreferenceStore().getBoolean(OPEN_CUSTOMIZATION_PERSPECTIVE);
	}

	/**
	 * Indicates if a dialog should ask the user for a confirmation before opening
	 * the customization perspective
	 *
	 * @return true if a user confirmation is needed
	 */
	public static boolean askForConfirmation() {
		return Activator.getDefault().getPreferenceStore().getBoolean(ASK_FOR_CONFIRMATION);
	}
}

Back to the top