Skip to content

Package: ShareWizard

ShareWizard

nameinstructionbranchcomplexitylinemethod
ShareWizard()
M: 6 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 2 C: 0
0%
M: 1 C: 0
0%
addPages()
M: 32 C: 0
0%
M: 0 C: 0
100%
M: 1 C: 0
0%
M: 8 C: 0
0%
M: 1 C: 0
0%
canFinish()
M: 32 C: 0
0%
M: 12 C: 0
0%
M: 7 C: 0
0%
M: 4 C: 0
0%
M: 1 C: 0
0%
getProvider()
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%
getSelectedRepository()
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%
init(ECPProvider)
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%
performFinish()
M: 35 C: 0
0%
M: 6 C: 0
0%
M: 4 C: 0
0%
M: 11 C: 0
0%
M: 1 C: 0
0%
setSelectedRepository(ECPRepository)
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%
setUseExistingRepository(boolean)
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%

Coverage

1: /*******************************************************************************
2: * Copyright (c) 2011-2013 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.wizards;
17:
18: import org.eclipse.emf.ecp.core.ECPProvider;
19: import org.eclipse.emf.ecp.core.ECPRepository;
20: import org.eclipse.emf.ecp.core.util.ECPUtil;
21: import org.eclipse.emf.ecp.internal.ui.Messages;
22: import org.eclipse.emf.ecp.internal.wizards.page.AddRepositoryPage;
23: import org.eclipse.emf.ecp.internal.wizards.page.SelectOrCreateRepositoryPage;
24: import org.eclipse.emf.ecp.internal.wizards.page.SelectRepositoryPage;
25: import org.eclipse.emf.ecp.ui.common.AddRepositoryComposite;
26: import org.eclipse.emf.ecp.ui.common.ECPCompositeFactory;
27: import org.eclipse.jface.wizard.Wizard;
28:
29: /**
30: * @author Eugen Neufeld
31: */
32: public class ShareWizard extends Wizard {
33:
34:         private ECPRepository selectedRepository;
35:
36:         private ECPProvider provider;
37:
38:         // private AddRepositoryPage addPage;
39:
40:         private AddRepositoryComposite repositoryComposite;
41:
42:         private boolean useExistingRepository = true;
43:
44:         /**
45:          * @return the provider
46:          */
47:         public ECPProvider getProvider() {
48:                 return provider;
49:         }
50:
51:         /**
52:          * @return the selectedRepository
53:          */
54:         public ECPRepository getSelectedRepository() {
55:                 return selectedRepository;
56:         }
57:
58:         /**
59:          * @param selectedRepository
60:          * the selectedRepository to set
61:          */
62:         public void setSelectedRepository(ECPRepository selectedRepository) {
63:                 this.selectedRepository = selectedRepository;
64:         }
65:
66:         /**
67:          *
68:          * @param useExistingRepository whether to use an existing repository.
69:          */
70:         public void setUseExistingRepository(boolean useExistingRepository) {
71:                 this.useExistingRepository = useExistingRepository;
72:         }
73:
74:         /**
75:          * . ({@inheritDoc})
76:          */
77:         @Override
78:         public void addPages() {
79:
80:                 final SelectOrCreateRepositoryPage userChoicePage = new SelectOrCreateRepositoryPage("UserChoice"); //$NON-NLS-1$
81:                 final SelectRepositoryPage selectPage = new SelectRepositoryPage("SelectRepository"); //$NON-NLS-1$
82:                 repositoryComposite = ECPCompositeFactory.getAddRepositoryComposite(provider);
83:                 final AddRepositoryPage addPage = new AddRepositoryPage("AddRepository", repositoryComposite); //$NON-NLS-1$
84:                 addPage(userChoicePage);
85:                 addPage(selectPage);
86:                 addPage(addPage);
87:         }
88:
89:         /**
90:          * . ({@inheritDoc})
91:          */
92:         @Override
93:         public boolean canFinish() {
94:•                if (useExistingRepository) {
95:•                        return selectedRepository != null;
96:                 }
97:•                return repositoryComposite.getProperties() != null && repositoryComposite.getProperties().hasProperties()
98:•                        && repositoryComposite.getRepositoryName() != null && repositoryComposite.getRepositoryName().length() != 0;
99:
100:         }
101:
102:         /*
103:          * (non-Javadoc)
104:          * @see org.eclipse.jface.wizard.Wizard#performFinish()
105:          */
106:         @Override
107:         public boolean performFinish() {
108:•                if (selectedRepository == null) {
109:                         selectedRepository = ECPUtil
110:                                 .getECPRepositoryManager()
111:                                 .addRepository(
112:                                         provider,
113:                                         repositoryComposite.getRepositoryName(),
114:•                                        repositoryComposite.getRepositoryLabel() == null ? "" : repositoryComposite.getRepositoryLabel(), //$NON-NLS-1$
115:•                                        repositoryComposite.getRepositoryDescription() == null ? "" //$NON-NLS-1$
116:                                                 : repositoryComposite.getRepositoryDescription(),
117:                                         repositoryComposite.getProperties());
118:                 }
119:                 return true;
120:         }
121:
122:         /**
123:          * @param provider
124:          * - {@link ECPProvider} to filter the known {@link ECPRepository}s by
125:          */
126:         public void init(ECPProvider provider) {
127:                 this.provider = provider;
128:                 setWindowTitle(Messages.ShareWizard_Title_Share);
129:         }
130:
131: }