summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2007-11-08 07:40:59 (EST)
committerEike Stepper2007-11-08 07:40:59 (EST)
commit1cb173a004255851ad89d530a61ce90e1ba56cfb (patch)
tree05382d68c50eaa2cbe3c91902b316cc1d74ff3de
parent4fdea5c7868e736a61996a1d3a0484cb27b71813 (diff)
downloadcdo-1cb173a004255851ad89d530a61ce90e1ba56cfb.zip
cdo-1cb173a004255851ad89d530a61ce90e1ba56cfb.tar.gz
cdo-1cb173a004255851ad89d530a61ce90e1ba56cfb.tar.bz2
[209007] Add CDOObject.cdoReload() API
https://bugs.eclipse.org/bugs/show_bug.cgi?id=209007
-rw-r--r--plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/ReloadObjectsAction.java30
-rw-r--r--plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/editor/CDOActionBarContributor.java46
-rw-r--r--plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/editor/CDOEditor.java20
3 files changed, 38 insertions, 58 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 2a7be4e..27af905 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
@@ -1,11 +1,14 @@
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.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;
import java.util.Iterator;
@@ -20,8 +23,6 @@ public class ReloadObjectsAction extends EditingDomainAction
private static final String TITLE = "Reload";
- private CDOEditor editor;
-
private List<InternalCDOObject> objects = new ArrayList<InternalCDOObject>();
public ReloadObjectsAction()
@@ -30,16 +31,6 @@ public class ReloadObjectsAction extends EditingDomainAction
setId(ID);
}
- public CDOEditor getEditor()
- {
- return editor;
- }
-
- public void setEditor(CDOEditor editor)
- {
- this.editor = editor;
- }
-
public void selectionChanged(IStructuredSelection selection)
{
objects.clear();
@@ -71,9 +62,20 @@ public class ReloadObjectsAction extends EditingDomainAction
{
InternalCDOObject[] array = objects.toArray(new InternalCDOObject[objects.size()]);
CDOStateMachine.INSTANCE.reload(array);
- if (editor != null)
+
+ IWorkbenchPage page = getPage();
+ if (page != null)
{
- editor.refreshViewer(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);
+ }
+ }
}
}
}
diff --git a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/editor/CDOActionBarContributor.java b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/editor/CDOActionBarContributor.java
index e20d56e..c5e616e 100644
--- a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/editor/CDOActionBarContributor.java
+++ b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/editor/CDOActionBarContributor.java
@@ -255,47 +255,11 @@ public class CDOActionBarContributor extends EditingDomainActionBarContributor i
*
* @generated
*/
- public void setActiveEditorGen(IEditorPart part)
- {
- super.setActiveEditor(part);
- activeEditorPart = part;
-
- // Switch to the new selection provider.
- //
- if (selectionProvider != null)
- {
- selectionProvider.removeSelectionChangedListener(this);
- }
- if (part == null)
- {
- selectionProvider = null;
- }
- else
- {
- selectionProvider = part.getSite().getSelectionProvider();
- selectionProvider.addSelectionChangedListener(this);
-
- // Fake a selection changed event to update the menus.
- //
- if (selectionProvider.getSelection() != null)
- {
- selectionChanged(new SelectionChangedEvent(selectionProvider, selectionProvider.getSelection()));
- }
- }
- }
-
- /**
- * @ADDED
- */
@Override
public void setActiveEditor(IEditorPart part)
{
super.setActiveEditor(part);
activeEditorPart = part;
- if (reloadObjectsAction != null && activeEditor instanceof CDOEditor)
- {
- reloadObjectsAction.setEditor((CDOEditor)activeEditorPart);
- }
// Switch to the new selection provider.
//
@@ -663,6 +627,11 @@ public class CDOActionBarContributor extends EditingDomainActionBarContributor i
exportResourceAction.setActiveWorkbenchPart(activeEditor);
}
+ if (reloadObjectsAction != null)
+ {
+ reloadObjectsAction.setActiveWorkbenchPart(activeEditor);
+ }
+
super.activate();
}
@@ -683,6 +652,11 @@ public class CDOActionBarContributor extends EditingDomainActionBarContributor i
exportResourceAction.setActiveWorkbenchPart(null);
}
+ if (reloadObjectsAction != null)
+ {
+ reloadObjectsAction.setActiveWorkbenchPart(null);
+ }
+
super.deactivate();
}
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 2df5db6..bd5b35c 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
@@ -2144,10 +2144,10 @@ public class CDOEditor extends MultiPageEditorPart implements IEditingDomainProv
{
try
{
- IEditorReference reference = find(page, view, resourcePath);
- if (reference != null)
+ IEditorReference[] references = find(page, view, resourcePath);
+ if (references.length != 0)
{
- IEditorPart editor = reference.getEditor(true);
+ IEditorPart editor = references[0].getEditor(true);
page.activate(editor);
}
else
@@ -2167,8 +2167,9 @@ public class CDOEditor extends MultiPageEditorPart implements IEditingDomainProv
/**
* @ADDED
*/
- public static IEditorReference find(IWorkbenchPage page, CDOView view, String resourcePath)
+ public static IEditorReference[] find(IWorkbenchPage page, CDOView view, String resourcePath)
{
+ List<IEditorReference> result = new ArrayList<IEditorReference>();
IEditorReference[] editorReferences = page.getEditorReferences();
for (IEditorReference editorReference : editorReferences)
{
@@ -2180,20 +2181,23 @@ public class CDOEditor extends MultiPageEditorPart implements IEditingDomainProv
if (editorInput instanceof CDOEditorInput)
{
CDOEditorInput cdoInput = (CDOEditorInput)editorInput;
- if (cdoInput.getView() == view && ObjectUtil.equals(cdoInput.getResourcePath(), resourcePath))
+ if (cdoInput.getView() == view)
{
- return editorReference;
+ if (resourcePath == null || ObjectUtil.equals(cdoInput.getResourcePath(), resourcePath))
+ {
+ result.add(editorReference);
+ }
}
}
}
}
catch (PartInitException ex)
{
- ex.printStackTrace();
+ OM.LOG.error(ex);
}
}
- return null;
+ return result.toArray(new IEditorReference[result.size()]);
}
/**