Skip to content

Package: PropertiesDialog

PropertiesDialog

nameinstructionbranchcomplexitylinemethod
PropertiesDialog(Shell, String, String, boolean, ECPProperties)
M: 19 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 7 C: 0
0%
M: 1 C: 0
0%
addTextProperty(Composite, String, String)
M: 54 C: 0
0%
M: 4 C: 0
0%
M: 3 C: 0
0%
M: 8 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%
createButtonsForButtonBar(Composite)
M: 20 C: 0
0%
M: 2 C: 0
0%
M: 2 C: 0
0%
M: 5 C: 0
0%
M: 1 C: 0
0%
createDialogArea(Composite)
M: 90 C: 0
0%
M: 2 C: 0
0%
M: 2 C: 0
0%
M: 16 C: 0
0%
M: 1 C: 0
0%
createSpecialProperties(Composite)
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%
getInitialSize()
M: 6 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 1 C: 0
0%
M: 1 C: 0
0%
getProperties()
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%
isEditable()
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) 2011 Eike Stepper (Berlin, Germany) 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: * Eike Stepper - initial API and implementation
13: ********************************************************************************/
14: package org.eclipse.emf.ecp.internal.ui.dialogs;
15:
16: import org.eclipse.emf.ecp.core.util.ECPProperties;
17: import org.eclipse.emf.ecp.internal.ui.Activator;
18: import org.eclipse.emf.ecp.internal.ui.Messages;
19: import org.eclipse.emf.ecp.internal.ui.composites.PropertiesComposite;
20: import org.eclipse.jface.dialogs.IDialogConstants;
21: import org.eclipse.jface.dialogs.IDialogLabelKeys;
22: import org.eclipse.jface.dialogs.TitleAreaDialog;
23: import org.eclipse.jface.resource.JFaceResources;
24: import org.eclipse.swt.SWT;
25: import org.eclipse.swt.graphics.Point;
26: import org.eclipse.swt.layout.FillLayout;
27: import org.eclipse.swt.layout.GridData;
28: import org.eclipse.swt.layout.GridLayout;
29: import org.eclipse.swt.widgets.Composite;
30: import org.eclipse.swt.widgets.Control;
31: import org.eclipse.swt.widgets.Label;
32: import org.eclipse.swt.widgets.Shell;
33: import org.eclipse.swt.widgets.Text;
34:
35: /**
36: * @author Eike Stepper
37: */
38: public class PropertiesDialog extends TitleAreaDialog {
39:         private final String title;
40:
41:         private final String message;
42:
43:         private final boolean editable;
44:
45:         private final ECPProperties properties;
46:
47:         public PropertiesDialog(Shell parentShell, String title, String message, boolean editable,
48:                 ECPProperties properties) {
49:                 super(parentShell);
50:                 setShellStyle(SWT.RESIZE | SWT.TITLE | SWT.APPLICATION_MODAL);
51:
52:                 this.title = title;
53:                 this.message = message;
54:                 this.editable = editable;
55:                 this.properties = properties;
56:         }
57:
58:         public final boolean isEditable() {
59:                 return editable;
60:         }
61:
62:         public final ECPProperties getProperties() {
63:                 return properties;
64:         }
65:
66:         @Override
67:         protected void configureShell(Shell newShell) {
68:                 super.configureShell(newShell);
69:                 newShell.setText(Messages.PropertiesDialog_DialogTitle);
70:         }
71:
72:         @Override
73:         protected Control createDialogArea(Composite parent) {
74:                 setTitle(title);
75:                 setTitleImage(Activator.getImage("icons/properties_wiz.png")); //$NON-NLS-1$
76:                 setMessage(message);
77:
78:                 final Composite area = (Composite) super.createDialogArea(parent);
79:                 final Composite container = new Composite(area, SWT.NONE);
80:                 container.setLayout(new GridLayout(1, false));
81:                 container.setLayoutData(new GridData(GridData.FILL_BOTH));
82:
83:                 final Composite specialProperties = new Composite(container, SWT.NONE);
84:                 specialProperties.setLayout(new FillLayout(SWT.HORIZONTAL));
85:                 specialProperties.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false, 1, 1));
86:
87:                 createSpecialProperties(specialProperties);
88:                 final PropertiesComposite propertiesComposite = new PropertiesComposite(container, editable, properties);
89:                 propertiesComposite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
90:
91:•                if (!editable) {
92:                         propertiesComposite.setFocus();
93:                 }
94:
95:                 return area;
96:         }
97:
98:         protected void createSpecialProperties(Composite parent) {
99:                 // Can be overridden in subclasses
100:         }
101:
102:         @Override
103:         protected void createButtonsForButtonBar(Composite parent) {
104:                 createButton(parent, IDialogConstants.OK_ID, JFaceResources.getString(IDialogLabelKeys.OK_LABEL_KEY), true);
105:
106:•                if (editable) {
107:                         createButton(parent, IDialogConstants.CANCEL_ID,
108:                                 JFaceResources.getString(IDialogLabelKeys.CANCEL_LABEL_KEY), false);
109:                 }
110:         }
111:
112:         @Override
113:         protected Point getInitialSize() {
114:                 return new Point(450, 500);
115:         }
116:
117:         protected Text addTextProperty(Composite composite, String key, String value) {
118:                 final Label label = new Label(composite, SWT.NONE);
119:•                label.setText(key == null ? "" : key); //$NON-NLS-1$
120:                 label.setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false, 1, 1));
121:
122:                 final Text text = new Text(composite, SWT.NONE);
123:•                text.setText(value == null ? "" : value); //$NON-NLS-1$
124:                 text.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
125:                 text.setEditable(isEditable());
126:                 return text;
127:         }
128: }