Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMiles Parker2013-04-17 20:31:04 -0400
committerMiles Parker2013-04-18 16:23:43 -0400
commit5c470d1c419260c79c963b9a60b20210355911a5 (patch)
treeceb6b0619f3b04eb1419439ffa3f999cc803b96d /org.eclipse.mylyn.reviews.edit
parenta4b2f2e773853d828cd440e0e0dc50d9db0bafc5 (diff)
downloadorg.eclipse.mylyn.reviews-5c470d1c419260c79c963b9a60b20210355911a5.tar.gz
org.eclipse.mylyn.reviews-5c470d1c419260c79c963b9a60b20210355911a5.tar.xz
org.eclipse.mylyn.reviews-5c470d1c419260c79c963b9a60b20210355911a5.zip
400168: implement gerrit Remote API
•Improve Remote API, separating consumer and observer concerns •Remote API now fully decouples remote access from UI •Editor and navigator interactions are now fully synchronized •Implement changes for Gerrit Remote API •Update Gerrit ChangeDetailX •Implement additional Gerrit Remote Factories applications •Fix update bugs affecting patch set and review detail sections •Additional testing Change-Id: I336942c1be7fbeeb9098b666b1371727df1bd776 Task-Url: https://bugs.eclipse.org/bugs/show_bug.cgi?id=400270
Diffstat (limited to 'org.eclipse.mylyn.reviews.edit')
-rw-r--r--org.eclipse.mylyn.reviews.edit/META-INF/MANIFEST.MF5
-rw-r--r--org.eclipse.mylyn.reviews.edit/icons/full/ctool16/CreateReview_reviewTask_TaskReference.gifbin223 -> 0 bytes
-rw-r--r--org.eclipse.mylyn.reviews.edit/plugin.xml1
-rw-r--r--org.eclipse.mylyn.reviews.edit/src/org/eclipse/mylyn/reviews/edit/ReviewsEditPlugin.java34
-rw-r--r--org.eclipse.mylyn.reviews.edit/src/org/eclipse/mylyn/reviews/edit/remote/AbstractRemoteEditFactoryProvider.java109
-rw-r--r--org.eclipse.mylyn.reviews.edit/src/org/eclipse/mylyn/reviews/edit/remote/ReviewsRemoteEditFactoryProvider.java31
6 files changed, 178 insertions, 2 deletions
diff --git a/org.eclipse.mylyn.reviews.edit/META-INF/MANIFEST.MF b/org.eclipse.mylyn.reviews.edit/META-INF/MANIFEST.MF
index 76ad24fd..d2bbe4db 100644
--- a/org.eclipse.mylyn.reviews.edit/META-INF/MANIFEST.MF
+++ b/org.eclipse.mylyn.reviews.edit/META-INF/MANIFEST.MF
@@ -14,4 +14,7 @@ Require-Bundle: org.eclipse.core.runtime,
Bundle-ActivationPolicy: lazy
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Bundle-Vendor: Eclipse Mylyn
-Export-Package: org.eclipse.mylyn.reviews.edit.provider;x-internal:=true
+Export-Package: org.eclipse.mylyn.reviews.edit,
+ org.eclipse.mylyn.reviews.edit.provider,
+ org.eclipse.mylyn.reviews.edit.remote
+Bundle-Activator: org.eclipse.mylyn.reviews.edit.ReviewsEditPlugin
diff --git a/org.eclipse.mylyn.reviews.edit/icons/full/ctool16/CreateReview_reviewTask_TaskReference.gif b/org.eclipse.mylyn.reviews.edit/icons/full/ctool16/CreateReview_reviewTask_TaskReference.gif
deleted file mode 100644
index c06fe361..00000000
--- a/org.eclipse.mylyn.reviews.edit/icons/full/ctool16/CreateReview_reviewTask_TaskReference.gif
+++ /dev/null
Binary files differ
diff --git a/org.eclipse.mylyn.reviews.edit/plugin.xml b/org.eclipse.mylyn.reviews.edit/plugin.xml
index 249b448a..4beb523d 100644
--- a/org.eclipse.mylyn.reviews.edit/plugin.xml
+++ b/org.eclipse.mylyn.reviews.edit/plugin.xml
@@ -26,5 +26,4 @@
org.eclipse.emf.edit.provider.IItemLabelProvider
org.eclipse.emf.edit.provider.IItemPropertySource"/>
</extension>
-
</plugin>
diff --git a/org.eclipse.mylyn.reviews.edit/src/org/eclipse/mylyn/reviews/edit/ReviewsEditPlugin.java b/org.eclipse.mylyn.reviews.edit/src/org/eclipse/mylyn/reviews/edit/ReviewsEditPlugin.java
new file mode 100644
index 00000000..db2215b1
--- /dev/null
+++ b/org.eclipse.mylyn.reviews.edit/src/org/eclipse/mylyn/reviews/edit/ReviewsEditPlugin.java
@@ -0,0 +1,34 @@
+/*******************************************************************************
+ * Copyright (c) 2013 Tasktop Technologies and others.
+ * 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:
+ * Tasktop Technologies - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.mylyn.reviews.edit;
+
+import org.osgi.framework.BundleActivator;
+import org.osgi.framework.BundleContext;
+
+public class ReviewsEditPlugin implements BundleActivator {
+
+ public static final String PLUGIN_ID = "org.eclipse.mylyn.reviews.edit"; //$NON-NLS-1$
+
+ private static ReviewsEditPlugin plugin;
+
+ public void start(BundleContext context) throws Exception {
+ plugin = this;
+ }
+
+ public void stop(BundleContext context) throws Exception {
+ plugin = null;
+ }
+
+ public static ReviewsEditPlugin getDefault() {
+ return plugin;
+ }
+}
diff --git a/org.eclipse.mylyn.reviews.edit/src/org/eclipse/mylyn/reviews/edit/remote/AbstractRemoteEditFactoryProvider.java b/org.eclipse.mylyn.reviews.edit/src/org/eclipse/mylyn/reviews/edit/remote/AbstractRemoteEditFactoryProvider.java
new file mode 100644
index 00000000..ea4e7f6a
--- /dev/null
+++ b/org.eclipse.mylyn.reviews.edit/src/org/eclipse/mylyn/reviews/edit/remote/AbstractRemoteEditFactoryProvider.java
@@ -0,0 +1,109 @@
+/*******************************************************************************
+ * Copyright (c) 2013 Ericsson and others.
+ * 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:
+ * Miles Parker (Tasktop Technologies) - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.mylyn.reviews.edit.remote;
+
+import java.util.HashMap;
+
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.emf.common.command.AbstractCommand;
+import org.eclipse.emf.common.command.BasicCommandStack;
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EFactory;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.emf.ecore.resource.impl.ResourceImpl;
+import org.eclipse.emf.edit.domain.AdapterFactoryEditingDomain;
+import org.eclipse.emf.edit.domain.EditingDomain;
+import org.eclipse.emf.edit.provider.ComposedAdapterFactory;
+import org.eclipse.emf.edit.provider.resource.ResourceItemProviderAdapterFactory;
+import org.eclipse.mylyn.commons.core.StatusHandler;
+import org.eclipse.mylyn.reviews.core.model.IReviewGroup;
+import org.eclipse.mylyn.reviews.core.spi.remote.AbstractRemoteFactoryProvider;
+import org.eclipse.mylyn.reviews.edit.ReviewsEditPlugin;
+import org.eclipse.mylyn.reviews.edit.provider.ReviewsItemProviderAdapterFactory;
+
+/**
+ * Supports decoupling of Reviews from remote API as well as job management.
+ *
+ * @author Miles Parker
+ */
+public abstract class AbstractRemoteEditFactoryProvider<ERootObject extends EObject> extends
+ AbstractRemoteFactoryProvider {
+
+ private final EditingDomain editingDomain;
+
+ ERootObject rootObject;
+
+ public AbstractRemoteEditFactoryProvider(EFactory emfFactory, EClass rootClass) {
+ ComposedAdapterFactory adapterFactory = new ComposedAdapterFactory(
+ ComposedAdapterFactory.Descriptor.Registry.INSTANCE);
+
+ adapterFactory.addAdapterFactory(new ResourceItemProviderAdapterFactory());
+ adapterFactory.addAdapterFactory(new ReviewsItemProviderAdapterFactory());
+
+ BasicCommandStack commandStack = new BasicCommandStack();
+ editingDomain = new AdapterFactoryEditingDomain(adapterFactory, commandStack, new HashMap<Resource, Boolean>());
+
+ Resource resource = new ResourceImpl();
+
+ if (resource.getContents().size() > 0 && resource.getContents().get(0) instanceof IReviewGroup) {
+ try {
+ rootObject = (ERootObject) resource.getContents().get(0);
+ } catch (ClassCastException e) {
+ StatusHandler.log(new Status(IStatus.ERROR, ReviewsEditPlugin.PLUGIN_ID,
+ "Problem creating editing domain. Unexpected root model content.", e));
+ }
+
+ } else {
+ try {
+ rootObject = (ERootObject) emfFactory.create(rootClass);
+ resource.getContents().add(rootObject);
+ } catch (ClassCastException e) {
+ StatusHandler.log(new Status(IStatus.ERROR, ReviewsEditPlugin.PLUGIN_ID,
+ "Problem creating editing domain. Root remote class must match remote editing domain type.", e));
+ }
+ }
+ }
+
+ @Override
+ public void modelExec(final Runnable runnable, boolean block) {
+ super.modelExec(new Runnable() { //Run in UI thread
+ public void run() {
+ editingDomain.getCommandStack().execute(new AbstractCommand() {
+
+ public void redo() {
+ // noop
+ }
+
+ public void execute() {
+ runnable.run();
+ }
+
+ @Override
+ protected boolean prepare() {
+ return true;
+ }
+
+ @Override
+ public boolean canUndo() {
+ return false;
+ }
+ });
+ }
+ }, block);
+ }
+
+ public ERootObject getRoot() {
+ return rootObject;
+ }
+}
diff --git a/org.eclipse.mylyn.reviews.edit/src/org/eclipse/mylyn/reviews/edit/remote/ReviewsRemoteEditFactoryProvider.java b/org.eclipse.mylyn.reviews.edit/src/org/eclipse/mylyn/reviews/edit/remote/ReviewsRemoteEditFactoryProvider.java
new file mode 100644
index 00000000..a4974b9f
--- /dev/null
+++ b/org.eclipse.mylyn.reviews.edit/src/org/eclipse/mylyn/reviews/edit/remote/ReviewsRemoteEditFactoryProvider.java
@@ -0,0 +1,31 @@
+/*******************************************************************************
+ * Copyright (c) 2013 Ericsson and others.
+ * 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:
+ * Miles Parker (Tasktop Technologies) - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.mylyn.reviews.edit.remote;
+
+import org.eclipse.emf.ecore.EFactory;
+import org.eclipse.mylyn.reviews.core.model.IRepository;
+import org.eclipse.mylyn.reviews.core.model.IReviewsFactory;
+import org.eclipse.mylyn.reviews.core.spi.remote.review.IReviewRemoteFactoryProvider;
+import org.eclipse.mylyn.reviews.internal.core.model.ReviewsPackage;
+
+/**
+ * Supports decoupling of Reviews from remote API as well as job management.
+ *
+ * @author Miles Parker
+ */
+public abstract class ReviewsRemoteEditFactoryProvider extends AbstractRemoteEditFactoryProvider<IRepository> implements
+ IReviewRemoteFactoryProvider {
+
+ public ReviewsRemoteEditFactoryProvider() {
+ super((EFactory) IReviewsFactory.INSTANCE, ReviewsPackage.Literals.REPOSITORY);
+ }
+}

Back to the top