Skip to content

Package: EMFFormsStyleSelectorWizardPage$1

EMFFormsStyleSelectorWizardPage$1

nameinstructionbranchcomplexitylinemethod
widgetSelected(SelectionEvent)
M: 51 C: 0
0%
M: 8 C: 0
0%
M: 5 C: 0
0%
M: 12 C: 0
0%
M: 1 C: 0
0%
{...}
M: 15 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%

Coverage

1: /*******************************************************************************
2: * Copyright (c) 2011-2016 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: * Johannes Faltermeier - initial API and implementation
13: ******************************************************************************/
14: package org.eclipse.emf.ecp.view.template.tooling.wizards;
15:
16: import org.eclipse.emf.ecore.EClass;
17: import org.eclipse.emf.ecp.view.template.internal.tooling.Messages;
18: import org.eclipse.emf.ecp.view.template.selector.domainmodelreference.model.VTDomainmodelreferencePackage;
19: import org.eclipse.emf.ecp.view.template.selector.viewModelElement.model.VTViewModelElementPackage;
20: import org.eclipse.emfforms.common.Optional;
21: import org.eclipse.jface.layout.GridLayoutFactory;
22: import org.eclipse.jface.wizard.WizardPage;
23: import org.eclipse.swt.SWT;
24: import org.eclipse.swt.events.SelectionAdapter;
25: import org.eclipse.swt.events.SelectionEvent;
26: import org.eclipse.swt.widgets.Button;
27: import org.eclipse.swt.widgets.Composite;
28: import org.eclipse.swt.widgets.Label;
29:
30: /**
31: * This page allows users whether to create DMR-Selector or a ViewModelElement-Selector.
32: *
33: * @author Johannes Faltermeier
34: *
35: */
36: public class EMFFormsStyleSelectorWizardPage extends WizardPage {
37:
38:         private final boolean showControlSelectors;
39:
40:         private EClass selectorEClass;
41:         private Boolean uuidAttribute;
42:
43:         /**
44:          * Default constructor.
45:          *
46:          * @param showControlSelectors whether to show control dmr selector option
47:          */
48:         EMFFormsStyleSelectorWizardPage(boolean showControlSelectors) {
49:                 super("styleSelector");//$NON-NLS-1$
50:                 setTitle(Messages.EMFFormsStyleSelectorWizardPage_Title);
51:                 setDescription(
52:                         Messages.EMFFormsStyleSelectorWizardPage_Description);
53:                 this.showControlSelectors = showControlSelectors;
54:         }
55:
56:         @Override
57:         public void createControl(Composite parent) {
58:                 final Composite composite = new Composite(parent, SWT.NONE);
59:                 GridLayoutFactory.fillDefaults().numColumns(2).applyTo(composite);
60:
61:                 final Button dmrSelector;
62:                 if (showControlSelectors) {
63:                         dmrSelector = new Button(composite, SWT.RADIO);
64:                         dmrSelector.setText(Messages.EMFFormsStyleSelectorWizardPage_DMRSelectorButton);
65:                         selectorEClass = VTDomainmodelreferencePackage.eINSTANCE.getDomainModelReferenceSelector();
66:                         dmrSelector.setSelection(true);
67:
68:                         final Label dmrSelectorLabel = new Label(composite, SWT.WRAP);
69:                         dmrSelectorLabel.setForeground(dmrSelectorLabel.getDisplay().getSystemColor(SWT.COLOR_DARK_GRAY));
70:                         dmrSelectorLabel.setText(
71:                                 Messages.EMFFormsStyleSelectorWizardPage_DMRSelectorLabel);
72:                 } else {
73:                         dmrSelector = null;
74:                 }
75:
76:                 final Button elementSelector = new Button(composite, SWT.RADIO);
77:                 elementSelector.setText(Messages.EMFFormsStyleSelectorWizardPage_ViewModelElementButton);
78:
79:                 final Label elementSelectorLabel = new Label(composite, SWT.WRAP);
80:                 elementSelectorLabel.setForeground(elementSelectorLabel.getDisplay().getSystemColor(SWT.COLOR_DARK_GRAY));
81:                 elementSelectorLabel.setText(
82:                         Messages.EMFFormsStyleSelectorWizardPage_ViewElementSelectorLabel);
83:
84:                 final Button uuidSelector = new Button(composite, SWT.RADIO);
85:                 uuidSelector.setText(Messages.EMFFormsStyleSelectorWizardPage_UUIDButtonText);
86:
87:                 final Label uuidSelectorLabel = new Label(composite, SWT.WRAP);
88:                 uuidSelectorLabel.setForeground(uuidSelectorLabel.getDisplay().getSystemColor(SWT.COLOR_DARK_GRAY));
89:                 uuidSelectorLabel.setText(
90:                         Messages.EMFFormsStyleSelectorWizardPage_UUIDLabelText);
91:
92:                 final SelectionAdapter selectionListener = new SelectionAdapter() {
93:                         @Override
94:                         public void widgetSelected(SelectionEvent e) {
95:•                                if (e.widget == null) {
96:                                         return;
97:                                 }
98:•                                if (e.widget == dmrSelector) {
99:                                         selectorEClass = VTDomainmodelreferencePackage.eINSTANCE.getDomainModelReferenceSelector();
100:                                         uuidAttribute = null;
101:•                                } else if (e.widget == elementSelector) {
102:                                         selectorEClass = VTViewModelElementPackage.eINSTANCE.getViewModelElementSelector();
103:                                         uuidAttribute = false;
104:•                                } else if (e.widget == uuidSelector) {
105:                                         selectorEClass = VTViewModelElementPackage.eINSTANCE.getViewModelElementSelector();
106:                                         uuidAttribute = true;
107:                                 }
108:                         }
109:                 };
110:
111:                 if (dmrSelector != null) {
112:                         dmrSelector.addSelectionListener(selectionListener);
113:                 }
114:                 elementSelector.addSelectionListener(selectionListener);
115:                 uuidSelector.addSelectionListener(selectionListener);
116:
117:                 setPageComplete(true);
118:                 setControl(composite);
119:         }
120:
121:         /**
122:          * Returns the EClass of the selector to create.
123:          *
124:          * @return the selector class
125:          */
126:         public EClass getSelectorEClass() {
127:                 return selectorEClass;
128:         }
129:
130:         /**
131:          * Whether to select the uuid in an selector.
132:          *
133:          * @return whether to use uuid attribute in selector
134:          */
135:         public Optional<Boolean> getUseUUID() {
136:                 return Optional.ofNullable(uuidAttribute);
137:         }
138:
139: }