Skip to content

Package: EmfFormsMainPreferencePage

EmfFormsMainPreferencePage

nameinstructionbranchcomplexitylinemethod
EmfFormsMainPreferencePage()
M: 3 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 2 C: 0
0%
M: 1 C: 0
0%
EmfFormsMainPreferencePage(String)
M: 4 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 2 C: 0
0%
M: 1 C: 0
0%
EmfFormsMainPreferencePage(String, ImageDescriptor)
M: 5 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 2 C: 0
0%
M: 1 C: 0
0%
createContents(Composite)
M: 84 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 19 C: 0
0%
M: 1 C: 0
0%
init(IWorkbench)
M: 1 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
performDefaults()
M: 6 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 3 C: 0
0%
M: 1 C: 0
0%
performOk()
M: 7 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 2 C: 0
0%
M: 1 C: 0
0%
updateToolingModeButtons(boolean)
M: 13 C: 0
0%
M: 2 C: 0
0%
M: 2 C: 0
0%
M: 3 C: 0
0%
M: 1 C: 0
0%

Coverage

1: /*******************************************************************************
2: * Copyright (c) 2011-2019 EclipseSource Muenchen GmbH and others.
3: *
4: * All rights reserved. This program and the accompanying materials
5: * are made available under the terms of the Eclipse Public License 2.0
6: * which accompanies this distribution, and is available at
7: * https://www.eclipse.org/legal/epl-2.0/
8: *
9: * SPDX-License-Identifier: EPL-2.0
10: *
11: * Contributors:
12: * Lucas Koehler - initial API and implementation
13: ******************************************************************************/
14: package org.eclipse.emfforms.internal.ide.preferences;
15:
16: import org.eclipse.emfforms.spi.ide.preferences.EmfFormsPreferences;
17: import org.eclipse.jface.layout.GridLayoutFactory;
18: import org.eclipse.jface.preference.PreferencePage;
19: import org.eclipse.jface.resource.ImageDescriptor;
20: import org.eclipse.swt.SWT;
21: import org.eclipse.swt.layout.RowLayout;
22: import org.eclipse.swt.widgets.Button;
23: import org.eclipse.swt.widgets.Composite;
24: import org.eclipse.swt.widgets.Control;
25: import org.eclipse.swt.widgets.Group;
26: import org.eclipse.swt.widgets.Label;
27: import org.eclipse.ui.IWorkbench;
28: import org.eclipse.ui.IWorkbenchPreferencePage;
29:
30: /**
31: * Main preference page for EMF Forms.
32: *
33: * @author Lucas Koehler
34: *
35: */
36: public class EmfFormsMainPreferencePage extends PreferencePage implements IWorkbenchPreferencePage {
37:
38:         private Button legacyButton;
39:         private Button segmentsButton;
40:
41:         /**
42:          * Create me with an empty title and no image.
43:          */
44:         public EmfFormsMainPreferencePage() {
45:                 // Nothing to do here
46:         }
47:
48:         /**
49:          * Creates me with a title.
50:          *
51:          * @param title Title of this preference page
52:          */
53:         public EmfFormsMainPreferencePage(String title) {
54:                 super(title);
55:         }
56:
57:         /**
58:          * Creates me with a title and an image.
59:          *
60:          * @param title Title of this preference page
61:          * @param image Image of this preference page
62:          */
63:         public EmfFormsMainPreferencePage(String title, ImageDescriptor image) {
64:                 super(title, image);
65:         }
66:
67:         @Override
68:         public void init(IWorkbench workbench) {
69:                 // Nothing to do here
70:         }
71:
72:         @Override
73:         protected Control createContents(Composite parent) {
74:                 final Composite composite = new Composite(parent, SWT.NONE);
75:
76:                 final Group modeGroup = new Group(composite, SWT.TITLE);
77:                 modeGroup.setText(Messages.EmfFormsMainPreferencePage_toolingModeTitle);
78:                 final Composite padding = new Composite(modeGroup, SWT.NONE);
79:                 final Label modeDescription = new Label(padding, SWT.WRAP);
80:                 modeDescription.setText(
81:                         Messages.EmfFormsMainPreferencePage_toolingModeDescription);
82:                 final Composite modeSelection = new Composite(padding, SWT.NONE);
83:                 modeSelection.setLayout(new RowLayout(SWT.VERTICAL));
84:                 legacyButton = new Button(modeSelection, SWT.RADIO);
85:                 legacyButton.setText(Messages.EmfFormsMainPreferencePage_legacyMode);
86:                 segmentsButton = new Button(modeSelection, SWT.RADIO);
87:                 segmentsButton.setText(Messages.EmfFormsMainPreferencePage_segmentMode);
88:
89:                 GridLayoutFactory.fillDefaults().generateLayout(modeSelection);
90:                 GridLayoutFactory.fillDefaults().generateLayout(padding);
91:                 GridLayoutFactory.fillDefaults().margins(5, 5).generateLayout(modeGroup);
92:                 GridLayoutFactory.fillDefaults().generateLayout(composite);
93:
94:                 updateToolingModeButtons(EmfFormsPreferences.isSegmentTooling());
95:                 return composite;
96:         }
97:
98:         @Override
99:         protected void performDefaults() {
100:                 updateToolingModeButtons(EmfFormsPreferences.SEGMENT_TOOLING_DEFAULT);
101:                 super.performDefaults();
102:         }
103:
104:         private void updateToolingModeButtons(boolean segmentTooling) {
105:•                legacyButton.setSelection(!segmentTooling);
106:                 segmentsButton.setSelection(segmentTooling);
107:         }
108:
109:         @Override
110:         public boolean performOk() {
111:                 EmfFormsPreferences.setSegmentTooling(segmentsButton.getSelection());
112:                 return super.performOk();
113:         }
114: }