Skip to content

Package: UpdateProjectHelper

UpdateProjectHelper

nameinstructionbranchcomplexitylinemethod
update(InternalProject, Shell)
M: 35 C: 0
0%
M: 2 C: 0
0%
M: 2 C: 0
0%
M: 8 C: 0
0%
M: 1 C: 0
0%
updateToVersion(InternalProject, Shell)
M: 35 C: 0
0%
M: 2 C: 0
0%
M: 2 C: 0
0%
M: 8 C: 0
0%
M: 1 C: 0
0%

Coverage

1: /*******************************************************************************
2: * Copyright (c) 2011-2014 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 - initial API and implementation
13: ******************************************************************************/
14: package org.eclipse.emf.ecp.emfstore.internal.ui.handler;
15:
16: import java.util.Collections;
17:
18: import org.eclipse.emf.ecp.emfstore.core.internal.EMFStoreProvider;
19: import org.eclipse.emf.ecp.spi.core.InternalProject;
20: import org.eclipse.emf.emfstore.client.ESLocalProject;
21: import org.eclipse.emf.emfstore.client.ESServer;
22: import org.eclipse.emf.emfstore.internal.client.model.impl.api.ESLocalProjectImpl;
23: import org.eclipse.emf.emfstore.internal.client.model.impl.api.ESUsersessionImpl;
24: import org.eclipse.emf.emfstore.internal.client.ui.controller.UIUpdateProjectController;
25: import org.eclipse.emf.emfstore.internal.client.ui.controller.UIUpdateProjectToVersionController;
26: import org.eclipse.swt.widgets.Shell;
27:
28: /**
29: * This is the EMFStore UpdateProject Helper.
30: *
31: * @author Eugen Neufeld
32: *
33: */
34: public final class UpdateProjectHelper {
35:
36:         private UpdateProjectHelper() {
37:         }
38:
39:         /**
40:          * Updates an {@link InternalProject} to head. Delegates to {@link UIUpdateProjectController}.
41:          *
42:          * @param project the {@link InternalProject}
43:          * @param shell the {@link Shell}
44:          */
45:         public static void update(InternalProject project, Shell shell) {
46:                 final ESLocalProject projectSpace = EMFStoreProvider.INSTANCE.getProjectSpace(project);
47:                 // TODO EMFStore how to set user session?
48:•                if (projectSpace.getUsersession() == null) {
49:                         final ESServer serverInfo = EMFStoreProvider.INSTANCE.getServerInfo(project.getRepository());
50:                         ((ESLocalProjectImpl) projectSpace).toInternalAPI().setUsersession(
51:                                 ((ESUsersessionImpl) serverInfo.getLastUsersession()).toInternalAPI());
52:                 }
53:                 new UIUpdateProjectController(shell, projectSpace).execute();
54:                 project.notifyObjectsChanged(Collections.singleton((Object) project), true);
55:         }
56:
57:         /**
58:          * Updates an {@link InternalProject} to a specific version. Delegates to {@link UIUpdateProjectToVersionController}
59:          * .
60:          *
61:          * @param project the {@link InternalProject}
62:          * @param shell the {@link Shell}
63:          */
64:         public static void updateToVersion(InternalProject project, Shell shell) {
65:                 final ESLocalProject projectSpace = EMFStoreProvider.INSTANCE.getProjectSpace(project);
66:                 // TODO Ugly
67:•                if (projectSpace.getUsersession() == null) {
68:                         final ESServer serverInfo = EMFStoreProvider.INSTANCE.getServerInfo(project.getRepository());
69:                         ((ESLocalProjectImpl) projectSpace).toInternalAPI().setUsersession(
70:                                 ((ESUsersessionImpl) serverInfo.getLastUsersession()).toInternalAPI());
71:                 }
72:                 new UIUpdateProjectToVersionController(shell, projectSpace).execute();
73:                 project.notifyObjectsChanged(Collections.singleton((Object) project), true);
74:         }
75: }