Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: be275f9e07fd4e375b436a125e0fe335cbc96b38 (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
/*****************************************************************************
 * Copyright (c) 2013, 2015 CEA LIST, Christian W. Damus, and others.
 *
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *  CEA LIST - Initial API and implementation
 *  Christian W. Damus - bug 461629
 *  
 *****************************************************************************/
package org.eclipse.papyrus.uml.diagram.statemachine.custom.preferences;

import org.eclipse.jface.preference.BooleanFieldEditor;
import org.eclipse.jface.preference.FieldEditorPreferencePage;
import org.eclipse.jface.preference.IntegerFieldEditor;
import org.eclipse.papyrus.infra.gmfdiag.common.helper.DiagramHelper;
import org.eclipse.papyrus.uml.diagram.statemachine.part.UMLDiagramEditorPlugin;
import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.IWorkbenchPreferencePage;

public class CustomTransitionPreferencePage extends FieldEditorPreferencePage
		implements IWorkbenchPreferencePage
{
	public CustomTransitionPreferencePage() {
		super(GRID);
		setPreferenceStore(UMLDiagramEditorPlugin.getInstance().getPreferenceStore());
		setDescription(
		"This preference page allows to customize label appearance on transitions. " + //$NON-NLS-1$
				"Please note that per diagram or element settings can be done via CSS."); //$NON-NLS-1$
	}

	boolean updatePending;

	/**
	 * @see org.eclipse.jface.preference.FieldEditorPreferencePage#createFieldEditors()
	 *
	 */
	@Override
	protected void createFieldEditors() {
		addField(new BooleanFieldEditor(
				PreferenceConstants.INDICATE_PARAMETERS, "Indicate parameters", //$NON-NLS-1$
				getFieldEditorParent()));

		addField(new BooleanFieldEditor(
				PreferenceConstants.LINEBREAK_BEFORE_EFFECT, "Line break before effect label", //$NON-NLS-1$
				getFieldEditorParent()));

		addField(new IntegerFieldEditor(
				PreferenceConstants.BODY_CUT_LENGTH, "Shown number of lines for opaque expressions/behaviors", //$NON-NLS-1$
				getFieldEditorParent()));

	}

	@Override
	public boolean performOk() {
		if (!updatePending) {
			Display.getDefault().asyncExec(new Runnable() {

				@Override
				public void run() {
					DiagramHelper.forceRefresh();
					updatePending = false;
				}
			});
		}
		updatePending = true;

		return super.performOk();
	}


	/**
	 * @see org.eclipse.ui.IWorkbenchPreferencePage#init(org.eclipse.ui.IWorkbench)
	 *
	 * @param workbench
	 */
	@Override
	public void init(IWorkbench workbench) {
	}
}

Back to the top