Skip to content

Package: CheckoutProjectCompositeImpl$1

CheckoutProjectCompositeImpl$1

nameinstructionbranchcomplexitylinemethod
modifyText(ModifyEvent)
M: 18 C: 0
0%
M: 2 C: 0
0%
M: 2 C: 0
0%
M: 4 C: 0
0%
M: 1 C: 0
0%
{...}
M: 9 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-2012 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: * Eugen Neufeld - initial API and implementation
13: *
14: *******************************************************************************/
15:
16: package org.eclipse.emf.ecp.internal.ui.composites;
17:
18: import org.eclipse.emf.ecp.core.util.ECPCheckoutSource;
19: import org.eclipse.emf.ecp.core.util.ECPProperties;
20: import org.eclipse.emf.ecp.core.util.ECPUtil;
21: import org.eclipse.emf.ecp.internal.ui.Messages;
22: import org.eclipse.emf.ecp.spi.ui.UIProvider;
23: import org.eclipse.emf.ecp.spi.ui.UIProviderRegistry;
24: import org.eclipse.emf.ecp.ui.common.CheckoutProjectComposite;
25: import org.eclipse.swt.SWT;
26: import org.eclipse.swt.custom.StackLayout;
27: import org.eclipse.swt.events.ModifyEvent;
28: import org.eclipse.swt.events.ModifyListener;
29: import org.eclipse.swt.layout.GridData;
30: import org.eclipse.swt.layout.GridLayout;
31: import org.eclipse.swt.widgets.Composite;
32: import org.eclipse.swt.widgets.Control;
33: import org.eclipse.swt.widgets.Label;
34: import org.eclipse.swt.widgets.Text;
35:
36: /**
37: * @author Eugen Neufeld
38: */
39: public class CheckoutProjectCompositeImpl implements CheckoutProjectComposite {
40:
41:         private CheckoutProjectChangeListener listener;
42:
43:         private String projectName;
44:
45:         private final ECPProperties projectProperties = ECPUtil.createProperties();
46:
47:         private final ECPCheckoutSource checkoutSource;
48:
49:         private final UIProvider uiProvider;
50:
51:         /**
52:          * Constructor for creating a checkout composite.
53:          *
54:          * @param checkoutSource the object to checkout
55:          */
56:         public CheckoutProjectCompositeImpl(ECPCheckoutSource checkoutSource) {
57:                 this.checkoutSource = checkoutSource;
58:                 projectName = this.checkoutSource.getDefaultCheckoutName();
59:                 if (projectName == null) {
60:                         projectName = ""; //$NON-NLS-1$
61:                 }
62:                 uiProvider = UIProviderRegistry.INSTANCE.getUIProvider(checkoutSource);
63:         }
64:
65:         /** {@inheritDoc} **/
66:         @Override
67:         public Composite createUI(Composite parent) {
68:                 final Composite composite = new Composite(parent, SWT.NONE);
69:                 composite.setLayoutData(new GridData(GridData.FILL_BOTH));
70:                 composite.setLayout(new GridLayout(2, false));
71:
72:                 final Label lblNewLabel = new Label(composite, SWT.NONE);
73:                 lblNewLabel.setText(Messages.CheckoutProjectComposite_ProjectName);
74:
75:                 final Text projectNameText = new Text(composite, SWT.BORDER);
76:                 projectNameText.setText(projectName);
77:                 projectNameText.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
78:                 projectNameText.addModifyListener(new ModifyListener() {
79:                         @Override
80:                         public void modifyText(ModifyEvent e) {
81:                                 projectName = projectNameText.getText();
82:•                                if (listener != null) {
83:                                         listener.projectNameChanged(projectName);
84:                                 }
85:                         }
86:                 });
87:                 final StackLayout providerStackLayout = new StackLayout();
88:                 final Composite providerStack = new Composite(composite, SWT.NONE);
89:                 providerStack.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 2, 1));
90:                 providerStack.setLayout(providerStackLayout);
91:                 final Control checkoutUI = uiProvider.createCheckoutUI(providerStack, checkoutSource, projectProperties);
92:                 if (checkoutUI != null) {
93:                         providerStackLayout.topControl = checkoutUI;
94:                         providerStack.layout();
95:                 }
96:
97:                 return composite;
98:         }
99:
100:         /** {@inheritDoc} **/
101:         @Override
102:         public String getProjectName() {
103:                 return projectName;
104:         }
105:
106:         /** {@inheritDoc} **/
107:         @Override
108:         public ECPProperties getProjectProperties() {
109:                 return projectProperties;
110:         }
111:
112:         /** {@inheritDoc} **/
113:         @Override
114:         public ECPCheckoutSource getCheckoutSource() {
115:                 return checkoutSource;
116:         }
117:
118:         /** {@inheritDoc} **/
119:         @Override
120:         public UIProvider getUiProvider() {
121:                 return uiProvider;
122:         }
123:
124:         /** {@inheritDoc} **/
125:         @Override
126:         public void setListener(CheckoutProjectChangeListener listener) {
127:                 this.listener = listener;
128:         }
129:
130:         /** {@inheritDoc} **/
131:         @Override
132:         public void dispose() {
133:         }
134: }