summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2007-11-08 08:03:19 (EST)
committerEike Stepper2007-11-08 08:03:19 (EST)
commit13691c0a444d1bf75b36917d6adcca3fc139f4e4 (patch)
treea8033ab4942bd782d56da2fa72bd7efc42e5e8eb
parent1cb173a004255851ad89d530a61ce90e1ba56cfb (diff)
downloadcdo-13691c0a444d1bf75b36917d6adcca3fc139f4e4.zip
cdo-13691c0a444d1bf75b36917d6adcca3fc139f4e4.tar.gz
cdo-13691c0a444d1bf75b36917d6adcca3fc139f4e4.tar.bz2
[209176] Add CDOView.reload() API
https://bugs.eclipse.org/bugs/show_bug.cgi?id=209176
-rw-r--r--plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/ReloadObjectsAction.java11
-rw-r--r--plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/ReloadViewAction.java31
-rw-r--r--plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/editor/CDOEditor.java16
-rw-r--r--plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/views/CDOItemProvider.java5
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/CDOView.java2
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOViewImpl.java30
6 files changed, 84 insertions, 11 deletions
diff --git a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/ReloadObjectsAction.java b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/ReloadObjectsAction.java
index 27af905..3f046cad 100644
--- a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/ReloadObjectsAction.java
+++ b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/ReloadObjectsAction.java
@@ -7,7 +7,6 @@ import org.eclipse.emf.internal.cdo.CDOStateMachine;
import org.eclipse.emf.internal.cdo.InternalCDOObject;
import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.ui.IEditorReference;
import org.eclipse.ui.IWorkbenchPage;
import java.util.ArrayList;
@@ -67,15 +66,7 @@ public class ReloadObjectsAction extends EditingDomainAction
if (page != null)
{
CDOView view = array[0].cdoView();
- IEditorReference[] references = CDOEditor.find(page, view, null);
- for (IEditorReference reference : references)
- {
- CDOEditor editor = (CDOEditor)reference.getEditor(false);
- if (editor != null)
- {
- editor.refreshViewer(null);
- }
- }
+ CDOEditor.refresh(page, view);
}
}
}
diff --git a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/ReloadViewAction.java b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/ReloadViewAction.java
new file mode 100644
index 0000000..9cda24e
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/ReloadViewAction.java
@@ -0,0 +1,31 @@
+package org.eclipse.emf.cdo.internal.ui.actions;
+
+import org.eclipse.emf.cdo.CDOView;
+import org.eclipse.emf.cdo.internal.ui.editor.CDOEditor;
+
+import org.eclipse.ui.IWorkbenchPage;
+
+/**
+ * @author Eike Stepper
+ */
+public final class ReloadViewAction extends ViewAction
+{
+ private static final String TITLE = "Reload";
+
+ private static final String TOOL_TIP = "Reload this view";
+
+ public ReloadViewAction(IWorkbenchPage page, CDOView view)
+ {
+ super(page, TITLE, TOOL_TIP, null, view);
+ }
+
+ @Override
+ protected void doRun() throws Exception
+ {
+ int num = getView().reload();
+ if (num != 0)
+ {
+ CDOEditor.refresh(getPage(), getView());
+ }
+ }
+} \ No newline at end of file
diff --git a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/editor/CDOEditor.java b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/editor/CDOEditor.java
index bd5b35c..7f44656 100644
--- a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/editor/CDOEditor.java
+++ b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/editor/CDOEditor.java
@@ -2201,6 +2201,22 @@ public class CDOEditor extends MultiPageEditorPart implements IEditingDomainProv
}
/**
+ * @ADDED
+ */
+ public static void refresh(IWorkbenchPage page, CDOView view)
+ {
+ IEditorReference[] references = find(page, view, null);
+ for (IEditorReference reference : references)
+ {
+ CDOEditor editor = (CDOEditor)reference.getEditor(false);
+ if (editor != null)
+ {
+ editor.refreshViewer(null);
+ }
+ }
+ }
+
+ /**
* @author Eike Stepper
* @ADDED
*/
diff --git a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/views/CDOItemProvider.java b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/views/CDOItemProvider.java
index bc6b4d0..139f81e 100644
--- a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/views/CDOItemProvider.java
+++ b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/views/CDOItemProvider.java
@@ -22,13 +22,14 @@ import org.eclipse.emf.cdo.internal.ui.actions.CloseSessionAction;
import org.eclipse.emf.cdo.internal.ui.actions.CloseViewAction;
import org.eclipse.emf.cdo.internal.ui.actions.CommitTransactionAction;
import org.eclipse.emf.cdo.internal.ui.actions.CreateResourceAction;
-import org.eclipse.emf.cdo.internal.ui.actions.RollbackTransactionAction;
import org.eclipse.emf.cdo.internal.ui.actions.LoadResourceAction;
import org.eclipse.emf.cdo.internal.ui.actions.ManagePackagesAction;
import org.eclipse.emf.cdo.internal.ui.actions.OpenAuditAction;
import org.eclipse.emf.cdo.internal.ui.actions.OpenTransactionAction;
import org.eclipse.emf.cdo.internal.ui.actions.OpenViewAction;
import org.eclipse.emf.cdo.internal.ui.actions.OpenViewEditorAction;
+import org.eclipse.emf.cdo.internal.ui.actions.ReloadViewAction;
+import org.eclipse.emf.cdo.internal.ui.actions.RollbackTransactionAction;
import org.eclipse.emf.cdo.internal.ui.views.CDOViewHistory.Entry;
import org.eclipse.net4j.IConnector;
@@ -294,6 +295,8 @@ public class CDOItemProvider extends ContainerItemProvider<IContainer<Object>>
}
manager.add(new Separator());
+ manager.add(new ReloadViewAction(page, view));
+ manager.add(new Separator());
manager.add(new CloseViewAction(page, view));
}
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/CDOView.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/CDOView.java
index cd27da3..9b1b798 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/CDOView.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/CDOView.java
@@ -61,6 +61,8 @@ public interface CDOView extends INotifier
public boolean isObjectRegistered(CDOID id);
+ public int reload(CDOObject... objects);
+
public void close();
/**
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOViewImpl.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOViewImpl.java
index 8e884f2..eb6c35a 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOViewImpl.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOViewImpl.java
@@ -13,6 +13,7 @@
**************************************************************************/
package org.eclipse.emf.internal.cdo;
+import org.eclipse.emf.cdo.CDOObject;
import org.eclipse.emf.cdo.CDOState;
import org.eclipse.emf.cdo.CDOView;
import org.eclipse.emf.cdo.CDOViewEvent;
@@ -55,6 +56,7 @@ import org.eclipse.net4j.util.ImplementationError;
import java.text.MessageFormat;
import java.util.ArrayList;
+import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@@ -571,6 +573,34 @@ public class CDOViewImpl extends org.eclipse.net4j.internal.util.event.Notifier
}
}
+ public int reload(CDOObject... objects)
+ {
+ Collection<InternalCDOObject> internalObjects;
+ if (objects != null && objects.length != 0)
+ {
+ internalObjects = new ArrayList<InternalCDOObject>(objects.length);
+ for (CDOObject object : objects)
+ {
+ if (object instanceof InternalCDOObject)
+ {
+ internalObjects.add((InternalCDOObject)object);
+ }
+ }
+ }
+ else
+ {
+ internalObjects = this.objects.values();
+ }
+
+ int result = internalObjects.size();
+ if (result != 0)
+ {
+ CDOStateMachine.INSTANCE.reload(internalObjects.toArray(new InternalCDOObject[result]));
+ }
+
+ return result;
+ }
+
public void close()
{
session.viewDetached(this);