-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Bug 497015 - History view not displayed if server is remote and
FileBasedChangePackages are used * Enable lazy loading * Enable via extension point or system property Change-Id: I75f99d051ef3e6d75b8e9d7dcfa61b8af00d6c3b Author: Markus Barchfeld <markus.barchfeld@gmxde> Signed-off-by: Markus Barchfeld <markus.barchfeld@gmx.de> [initial API and implementation] Signed-off-by: Johannes Faltermeier <jfaltermeier@eclipsesource.com> [minor cleanup]
- Loading branch information
1 parent
c20f6ec
commit f95e96a
Showing
5 changed files
with
381 additions
and
64 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
114 changes: 114 additions & 0 deletions
114
bundles/org.eclipse.emf.emfstore.client.ui/schema/enableLazyLoadingOfChangePackages.exsd
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,114 @@ | ||
<?xml version='1.0' encoding='UTF-8'?> | ||
<!-- Schema file written by PDE --> | ||
<schema targetNamespace="org.eclipse.emf.emfstore.client.ui" xmlns="http://www.w3.org/2001/XMLSchema"> | ||
<annotation> | ||
<appInfo> | ||
<meta.schema plugin="org.eclipse.emf.emfstore.client.ui" id="enableLazyLoadingOfChangePackages" name="Enable lazy loading of change Packages"/> | ||
</appInfo> | ||
<documentation> | ||
Enable lazy loading of change packages in the History Browser View. If enabled the initial list will only show history info (commit message, date, ...) but no change details. Change details can be loaded via context menu on the history info for one or more history infos. | ||
|
||
Per default lazy loading is disabled. | ||
</documentation> | ||
</annotation> | ||
|
||
<element name="extension"> | ||
<annotation> | ||
<appInfo> | ||
<meta.element /> | ||
</appInfo> | ||
</annotation> | ||
<complexType> | ||
<sequence> | ||
<element ref="enablement"/> | ||
</sequence> | ||
<attribute name="point" type="string" use="required"> | ||
<annotation> | ||
<documentation> | ||
|
||
</documentation> | ||
</annotation> | ||
</attribute> | ||
<attribute name="id" type="string"> | ||
<annotation> | ||
<documentation> | ||
|
||
</documentation> | ||
</annotation> | ||
</attribute> | ||
<attribute name="name" type="string"> | ||
<annotation> | ||
<documentation> | ||
|
||
</documentation> | ||
<appInfo> | ||
<meta.attribute translatable="true"/> | ||
</appInfo> | ||
</annotation> | ||
</attribute> | ||
</complexType> | ||
</element> | ||
|
||
<element name="enablement"> | ||
<complexType> | ||
<attribute name="enabled" type="boolean" use="default" value="false"> | ||
<annotation> | ||
<documentation> | ||
|
||
</documentation> | ||
</annotation> | ||
</attribute> | ||
</complexType> | ||
</element> | ||
|
||
<annotation> | ||
<appInfo> | ||
<meta.section type="since"/> | ||
</appInfo> | ||
<documentation> | ||
1.9.0 | ||
</documentation> | ||
</annotation> | ||
|
||
<annotation> | ||
<appInfo> | ||
<meta.section type="examples"/> | ||
</appInfo> | ||
<documentation> | ||
[Enter extension point usage example here.] | ||
</documentation> | ||
</annotation> | ||
|
||
<annotation> | ||
<appInfo> | ||
<meta.section type="apiinfo"/> | ||
</appInfo> | ||
<documentation> | ||
[Enter API information here.] | ||
</documentation> | ||
</annotation> | ||
|
||
<annotation> | ||
<appInfo> | ||
<meta.section type="implementation"/> | ||
</appInfo> | ||
<documentation> | ||
[Enter information about supplied implementation of this extension point.] | ||
</documentation> | ||
</annotation> | ||
|
||
<annotation> | ||
<appInfo> | ||
<meta.section type="copyright"/> | ||
</appInfo> | ||
<documentation> | ||
Copyright (c) 2011-2016 EclipseSource Muenchen GmbH and others.<br/> | ||
|
||
All rights reserved. This program and the accompanying materials | ||
are made available under the terms of the Eclipse Public License v1.0 | ||
which accompanies this distribution, and is available at | ||
http://www.eclipse.org/legal/epl-v10.html | ||
</documentation> | ||
</annotation> | ||
|
||
</schema> |
135 changes: 135 additions & 0 deletions
135
...i/src/org/eclipse/emf/emfstore/internal/client/ui/handlers/LoadChangePackagesHandler.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,135 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2016 Metus GmbH | ||
* | ||
* All rights reserved. This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License v1.0 | ||
* which accompanies this distribution, and is available at | ||
* http://www.eclipse.org/legal/epl-v10.html | ||
* | ||
* Contributors: | ||
* mbarchfe | ||
******************************************************************************/ | ||
package org.eclipse.emf.emfstore.internal.client.ui.handlers; | ||
|
||
import java.text.MessageFormat; | ||
import java.util.ArrayList; | ||
import java.util.Iterator; | ||
import java.util.List; | ||
|
||
import org.eclipse.core.commands.ExecutionEvent; | ||
import org.eclipse.core.runtime.IStatus; | ||
import org.eclipse.emf.emfstore.internal.client.model.ESWorkspaceProviderImpl; | ||
import org.eclipse.emf.emfstore.internal.client.model.ProjectSpace; | ||
import org.eclipse.emf.emfstore.internal.client.model.connectionmanager.ConnectionManager; | ||
import org.eclipse.emf.emfstore.internal.client.ui.views.historybrowserview.HistoryBrowserView; | ||
import org.eclipse.emf.emfstore.internal.common.model.util.ModelUtil; | ||
import org.eclipse.emf.emfstore.internal.server.model.ProjectId; | ||
import org.eclipse.emf.emfstore.internal.server.model.SessionId; | ||
import org.eclipse.emf.emfstore.internal.server.model.versioning.AbstractChangePackage; | ||
import org.eclipse.emf.emfstore.internal.server.model.versioning.HistoryInfo; | ||
import org.eclipse.emf.emfstore.internal.server.model.versioning.PrimaryVersionSpec; | ||
import org.eclipse.emf.emfstore.server.exceptions.ESException; | ||
import org.eclipse.jface.viewers.ISelection; | ||
import org.eclipse.jface.viewers.IStructuredSelection; | ||
import org.eclipse.ui.IWorkbenchPage; | ||
import org.eclipse.ui.IWorkbenchWindow; | ||
import org.eclipse.ui.PlatformUI; | ||
import org.eclipse.ui.handlers.HandlerUtil; | ||
|
||
/** | ||
* Handler for getting a list of change packages for given {@link HistoryInfo}s . | ||
* | ||
* @author mbarchfe | ||
* | ||
*/ | ||
public class LoadChangePackagesHandler extends AbstractEMFStoreHandler { | ||
|
||
/** | ||
* Gets the selection from an {@link ExecutionEvent}. Only elements which are instances of the given class will be | ||
* returned. | ||
* | ||
* @param event the event | ||
* @param clazz the type | ||
* @return the selection | ||
* | ||
* @param <T> the type | ||
*/ | ||
@SuppressWarnings("unchecked") | ||
public static <T> List<T> getSelection(ExecutionEvent event, Class<T> clazz) { | ||
final List<T> result = new ArrayList<T>(); | ||
ISelection sel = HandlerUtil.getCurrentSelection(event); | ||
if (sel == null) { | ||
sel = HandlerUtil.getActiveMenuSelection(event); | ||
} | ||
if (sel instanceof IStructuredSelection) { | ||
final IStructuredSelection structuredSelection = (IStructuredSelection) sel; | ||
@SuppressWarnings("rawtypes") | ||
final Iterator it = structuredSelection.iterator(); | ||
while (it.hasNext()) { | ||
final Object selectedElement = it.next(); | ||
if (clazz.isInstance(selectedElement)) { | ||
result.add((T) selectedElement); | ||
} | ||
} | ||
} | ||
return result; | ||
} | ||
|
||
@Override | ||
public void handle() { | ||
|
||
final IWorkbenchWindow activeWorkbenchWindow = PlatformUI.getWorkbench().getActiveWorkbenchWindow(); | ||
final IWorkbenchPage activePage = activeWorkbenchWindow.getActivePage(); | ||
if (activePage == null) { | ||
return; | ||
} | ||
|
||
if (!(activePage.getActivePart() instanceof HistoryBrowserView)) { | ||
return; | ||
} | ||
|
||
final HistoryBrowserView view = (HistoryBrowserView) activePage.getActivePart(); | ||
final ProjectSpace projectSpace = view.getProjectSpace(); | ||
final ESWorkspaceProviderImpl esWorkspaceProviderImpl = ESWorkspaceProviderImpl.getInstance(); | ||
|
||
final ConnectionManager connectionManager = esWorkspaceProviderImpl.getConnectionManager(); | ||
|
||
final ProjectId projectId = projectSpace.getProjectId(); | ||
final SessionId sessionId = projectSpace.getUsersession().getSessionId(); | ||
|
||
final List<HistoryInfo> historyInfos = getSelection(getEvent(), HistoryInfo.class); | ||
for (final HistoryInfo historyInfo : historyInfos) { | ||
final PrimaryVersionSpec fromSpec = ModelUtil.clone(historyInfo.getPreviousSpec()); | ||
final PrimaryVersionSpec toSpec = ModelUtil.clone(historyInfo.getPrimarySpec()); | ||
// e.g. local change would be invalid to send to server | ||
if (!isValid(fromSpec) || !isValid(toSpec)) { | ||
continue; | ||
} | ||
|
||
try { | ||
final List<AbstractChangePackage> changes = connectionManager.getChanges(sessionId, projectId, | ||
fromSpec, | ||
toSpec); | ||
// the result should be one change package, if there were more or none this would be suprising | ||
if (changes.size() != 1) { | ||
ModelUtil.log( | ||
MessageFormat.format("Expected to retrieve one change package but got {0}", changes.size()), //$NON-NLS-1$ | ||
null, IStatus.ERROR); | ||
} else { | ||
historyInfo.setChangePackage(changes.get(0)); | ||
} | ||
} catch (final ESException ex) { | ||
ModelUtil.log( | ||
MessageFormat.format("Could not load changes for history info {0}", historyInfo), //$NON-NLS-1$ | ||
ex, IStatus.ERROR); | ||
} | ||
view.refresh(historyInfo); | ||
} | ||
|
||
} | ||
|
||
private boolean isValid(PrimaryVersionSpec spec) { | ||
return spec != null && spec.getIdentifier() > -1; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.