Skip to content

Package: ViewMigrationDialog

ViewMigrationDialog

nameinstructionbranchcomplexitylinemethod
ViewMigrationDialog(Shell)
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%
configureShell(Shell)
M: 7 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 3 C: 0
0%
M: 1 C: 0
0%
create()
M: 10 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 4 C: 0
0%
M: 1 C: 0
0%
createDialogArea(Composite)
M: 74 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 15 C: 0
0%
M: 1 C: 0
0%
createInput(Composite, String)
M: 30 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 8 C: 0
0%
M: 1 C: 0
0%
getNewNamespaceFragment()
M: 3 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
getOldNamespaceFragment()
M: 3 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
isHelpAvailable()
M: 2 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
isResizable()
M: 2 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
okPressed()
M: 18 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 5 C: 0
0%
M: 1 C: 0
0%
shouldShowWarning()
M: 3 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) 2017 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: * Edgar Mueller - initial API and implementation
13: ******************************************************************************/
14: package org.eclipse.emf.ecp.ide.internal.migration;
15:
16: import org.eclipse.jface.dialogs.IMessageProvider;
17: import org.eclipse.jface.dialogs.TitleAreaDialog;
18: import org.eclipse.jface.layout.GridDataFactory;
19: import org.eclipse.swt.SWT;
20: import org.eclipse.swt.layout.GridData;
21: import org.eclipse.swt.layout.GridLayout;
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.Label;
26: import org.eclipse.swt.widgets.Shell;
27: import org.eclipse.swt.widgets.Text;
28:
29: /**
30: * A dialog that enables the migration of view model files.
31: *
32: */
33: public class ViewMigrationDialog extends TitleAreaDialog {
34:
35:         private Text updatedNamespaceText;
36:         private Text currentNamespaceText;
37:         private String oldNamespaceFragment;
38:         private String newNamespaceFragment;
39:         private Button showWarningsButton;
40:         private boolean showWarnings;
41:
42:         /**
43:          * Constructor.
44:          *
45:          * @param parentShell the parent shell of this dialog
46:          */
47:         public ViewMigrationDialog(Shell parentShell) {
48:                 super(parentShell);
49:         }
50:
51:         /**
52:          * {@inheritDoc}
53:          *
54:          * @see org.eclipse.jface.window.Window#configureShell(org.eclipse.swt.widgets.Shell)
55:          */
56:         @Override
57:         protected void configureShell(Shell newShell) {
58:                 super.configureShell(newShell);
59:                 newShell.setText(Messages.ViewMigrationDialog_ShellTitle);
60:         }
61:
62:         /**
63:          * {@inheritDoc}
64:          *
65:          * @see org.eclipse.jface.dialogs.Dialog#create()
66:          */
67:         @Override
68:         public void create() {
69:                 super.create();
70:                 setTitle(Messages.UpdateNSDialog_MigrationDialogTitle);
71:                 setMessage(Messages.UpdateNSDialog_MigrationDialog_Message, IMessageProvider.INFORMATION);
72:         }
73:
74:         /**
75:          * {@inheritDoc}
76:          *
77:          * @see org.eclipse.jface.dialogs.Dialog#createDialogArea(org.eclipse.swt.widgets.Composite)
78:          */
79:         @Override
80:         protected Control createDialogArea(Composite parent) {
81:                 final Composite area = (Composite) super.createDialogArea(parent);
82:                 final Composite container = new Composite(area, SWT.NONE);
83:                 container.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
84:                 final GridLayout layout = new GridLayout(2, false);
85:                 container.setLayout(layout);
86:
87:                 final Label label = new Label(container, SWT.NONE);
88:                 label.setText(
89:                         Messages.ViewMigrationDialog_LabelText);
90:                 currentNamespaceText = createInput(container, Messages.ViewMigrationDialog_CurrentNSLabel);
91:                 updatedNamespaceText = createInput(container, Messages.ViewMigrationDialog_UpdatedNSLabel);
92:                 label.setLayoutData(GridDataFactory.fillDefaults().span(2, 1).create());
93:
94:                 showWarningsButton = new Button(container, SWT.CHECK);
95:                 showWarningsButton.setText(Messages.ViewMigrationDialog_ShowWarnings);
96:                 showWarningsButton.setSelection(true);
97:
98:                 return area;
99:         }
100:
101:         /**
102:          * {@inheritDoc}
103:          *
104:          * @see org.eclipse.jface.dialogs.TrayDialog#isHelpAvailable()
105:          */
106:         @Override
107:         public boolean isHelpAvailable() {
108:                 return false;
109:         }
110:
111:         /**
112:          * {@inheritDoc}
113:          *
114:          * @see org.eclipse.jface.dialogs.Dialog#isResizable()
115:          */
116:         @Override
117:         protected boolean isResizable() {
118:                 return true;
119:         }
120:
121:         private Text createInput(Composite container, String labelText) {
122:                 final Label label = new Label(container, SWT.NONE);
123:                 label.setText(labelText);
124:                 final GridData layoutData = new GridData();
125:                 layoutData.grabExcessHorizontalSpace = true;
126:                 layoutData.horizontalAlignment = GridData.FILL;
127:                 final Text text = new Text(container, SWT.BORDER);
128:                 text.setLayoutData(layoutData);
129:                 return text;
130:         }
131:
132:         /**
133:          * {@inheritDoc}
134:          *
135:          * @see org.eclipse.jface.dialogs.Dialog#okPressed()
136:          */
137:         @Override
138:         protected void okPressed() {
139:                 oldNamespaceFragment = currentNamespaceText.getText();
140:                 newNamespaceFragment = updatedNamespaceText.getText();
141:                 showWarnings = showWarningsButton.getSelection();
142:                 super.okPressed();
143:         }
144:
145:         /**
146:          * Returns the namespace fragments to be replaced.
147:          *
148:          * @return the namespace fragments to be replaced
149:          */
150:         public String getOldNamespaceFragment() {
151:                 return oldNamespaceFragment;
152:         }
153:
154:         /**
155:          * Returns the new namespace fragments with which to replace the old ones.
156:          *
157:          * @return the new namespace fragments
158:          */
159:         public String getNewNamespaceFragment() {
160:                 return newNamespaceFragment;
161:         }
162:
163:         /**
164:          * Whether to show migration warnings.
165:          *
166:          * @return {@code true}, if migration warnings are to be shown
167:          */
168:         public boolean shouldShowWarning() {
169:                 return showWarnings;
170:         }
171: }