diff options
Diffstat (limited to 'plugins/org.eclipse.emf.cdo.ui/src/org')
5 files changed, 204 insertions, 44 deletions
diff --git a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/ExportResourceAction.java b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/ExportResourceAction.java index ec00837480..190df985cd 100644 --- a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/ExportResourceAction.java +++ b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/ExportResourceAction.java @@ -5,11 +5,14 @@ package org.eclipse.emf.cdo.internal.ui.actions; */ public class ExportResourceAction extends EditingDomainAction { + public static final String ID = "export-resource"; + private static final String TITLE = "Export Resource"; public ExportResourceAction() { super(TITLE + INTERACTIVE); + setId(ID); } @Override diff --git a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/ImportRootsAction.java b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/ImportRootsAction.java index ebc2c35228..d18d94fb00 100644 --- a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/ImportRootsAction.java +++ b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/ImportRootsAction.java @@ -22,6 +22,8 @@ import java.util.List; */ public class ImportRootsAction extends EditingDomainAction { + public static final String ID = "import-roots"; + private static final String TITLE = "Import Roots"; private CDOResource targetResource; @@ -31,6 +33,7 @@ public class ImportRootsAction extends EditingDomainAction public ImportRootsAction() { super(TITLE + INTERACTIVE); + setId(ID); } public CDOResource getTargetResource() 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 new file mode 100644 index 0000000000..2a7be4ea5d --- /dev/null +++ b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/ReloadObjectsAction.java @@ -0,0 +1,80 @@ +package org.eclipse.emf.cdo.internal.ui.actions; + +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 java.util.ArrayList; +import java.util.Iterator; +import java.util.List; + +/** + * @author Eike Stepper + */ +public class ReloadObjectsAction extends EditingDomainAction +{ + public static final String ID = "reload-objects"; + + private static final String TITLE = "Reload"; + + private CDOEditor editor; + + private List<InternalCDOObject> objects = new ArrayList<InternalCDOObject>(); + + public ReloadObjectsAction() + { + super(TITLE); + setId(ID); + } + + public CDOEditor getEditor() + { + return editor; + } + + public void setEditor(CDOEditor editor) + { + this.editor = editor; + } + + public void selectionChanged(IStructuredSelection selection) + { + objects.clear(); + if (selection != null) + { + for (Iterator<Object> it = selection.iterator(); it.hasNext();) + { + Object object = it.next(); + if (object instanceof InternalCDOObject) + { + objects.add((InternalCDOObject)object); + } + } + } + + update(); + } + + @Override + public void update() + { + setEnabled(!objects.isEmpty()); + } + + @Override + protected void doRun() throws Exception + { + if (!objects.isEmpty()) + { + InternalCDOObject[] array = objects.toArray(new InternalCDOObject[objects.size()]); + CDOStateMachine.INSTANCE.reload(array); + if (editor != null) + { + editor.refreshViewer(null); + } + } + } +}
\ No newline at end of file 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 3dbf70ef2f..e20d56e008 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 @@ -9,6 +9,7 @@ package org.eclipse.emf.cdo.internal.ui.editor; import org.eclipse.emf.cdo.eresource.CDOResource; import org.eclipse.emf.cdo.internal.ui.actions.ExportResourceAction; import org.eclipse.emf.cdo.internal.ui.actions.ImportRootsAction; +import org.eclipse.emf.cdo.internal.ui.actions.ReloadObjectsAction; import org.eclipse.emf.common.ui.viewer.IViewerProvider; import org.eclipse.emf.edit.domain.EditingDomain; @@ -58,12 +59,22 @@ public class CDOActionBarContributor extends EditingDomainActionBarContributor i /** * @ADDED */ - public static final String IMPORT_RESOURCE_ID = "import-resource"; + public static final String REFRESH_VIEWER_ID = "refresh-viewer"; /** * @ADDED */ - public static final String EXPORT_RESOURCE_ID = "export-resource"; + protected ImportRootsAction importResourceAction; + + /** + * @ADDED + */ + protected ExportResourceAction exportResourceAction; + + /** + * @ADDED + */ + protected ReloadObjectsAction reloadObjectsAction; /** * This keeps track of the active editor. <!-- begin-user-doc --> <!-- end-user-doc --> @@ -161,10 +172,6 @@ public class CDOActionBarContributor extends EditingDomainActionBarContributor i */ protected IMenuManager createSiblingMenuManager; - protected ImportRootsAction importResourceAction; - - protected ExportResourceAction exportResourceAction; - /** * This creates an instance of the contributor. <!-- begin-user-doc --> <!-- end-user-doc --> * @@ -177,11 +184,13 @@ public class CDOActionBarContributor extends EditingDomainActionBarContributor i loadResourceAction.setId(LOAD_RESOURCE_ID); importResourceAction = new ImportRootsAction(); - importResourceAction.setId(IMPORT_RESOURCE_ID); + importResourceAction.setId(ImportRootsAction.ID); // exportResourceAction = new ExportResourceAction(); // TODO // exportResourceAction.setId(EXPORT_RESOURCE_ID); + reloadObjectsAction = new ReloadObjectsAction(); + validateAction = new ValidateAction(); controlAction = new ControlAction(); } @@ -246,11 +255,47 @@ 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. // @@ -351,24 +396,32 @@ public class CDOActionBarContributor extends EditingDomainActionBarContributor i Collection<?> newSiblingDescriptors = null; ISelection selection = event.getSelection(); - if (selection instanceof IStructuredSelection && ((IStructuredSelection)selection).size() == 1) + if (selection instanceof IStructuredSelection) { - Object object = ((IStructuredSelection)selection).getFirstElement(); + if (reloadObjectsAction != null) + { + reloadObjectsAction.selectionChanged((IStructuredSelection)selection); + } - EditingDomain domain = ((IEditingDomainProvider)activeEditorPart).getEditingDomain(); + if (((IStructuredSelection)selection).size() == 1) + { + Object object = ((IStructuredSelection)selection).getFirstElement(); - newChildDescriptors = domain.getNewChildDescriptors(object, null); - newSiblingDescriptors = domain.getNewChildDescriptors(null, object); + EditingDomain domain = ((IEditingDomainProvider)activeEditorPart).getEditingDomain(); - if (importResourceAction != null) - { - if (object instanceof CDOResource) - { - importResourceAction.setTargetResource((CDOResource)object); - } - else + newChildDescriptors = domain.getNewChildDescriptors(object, null); + newSiblingDescriptors = domain.getNewChildDescriptors(null, object); + + if (importResourceAction != null) { - importResourceAction.setTargetResource(null); + if (object instanceof CDOResource) + { + importResourceAction.setTargetResource((CDOResource)object); + } + else + { + importResourceAction.setTargetResource(null); + } } } } @@ -540,20 +593,21 @@ public class CDOActionBarContributor extends EditingDomainActionBarContributor i menuManager.insertAfter("ui-actions", showPropertiesViewAction); refreshViewerAction.setEnabled(refreshViewerAction.isEnabled()); + refreshViewerAction.setId(REFRESH_VIEWER_ID); menuManager.insertAfter("ui-actions", refreshViewerAction); - + menuManager.insertBefore(refreshViewerAction.getId(), reloadObjectsAction); super.addGlobalActions(menuManager); if (loadResourceAction != null) { if (exportResourceAction != null) { - menuManager.insertAfter(LOAD_RESOURCE_ID, exportResourceAction); + menuManager.insertAfter(loadResourceAction.getId(), exportResourceAction); } if (importResourceAction != null) { - menuManager.insertAfter(LOAD_RESOURCE_ID, importResourceAction); + menuManager.insertAfter(loadResourceAction.getId(), importResourceAction); } } else @@ -648,5 +702,10 @@ public class CDOActionBarContributor extends EditingDomainActionBarContributor i { exportResourceAction.update(); } + + if (reloadObjectsAction != null) + { + reloadObjectsAction.update(); + } } }
\ 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 30c8ecc133..2df5db6915 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 @@ -1202,25 +1202,7 @@ public class CDOEditor extends MultiPageEditorPart implements IEditingDomainProv @Override protected void viewConflict(final CDOObject conflictingObject, boolean firstConflict) { - try - { - selectionViewer.getControl().getDisplay().syncExec(new Runnable() - { - public void run() - { - try - { - selectionViewer.refresh(conflictingObject, true); - } - catch (Exception ignore) - { - } - } - }); - } - catch (Exception ignore) - { - } + refreshViewer(conflictingObject); } @Override @@ -1920,7 +1902,7 @@ public class CDOEditor extends MultiPageEditorPart implements IEditingDomainProv { ((IMenuListener)getEditorSite().getActionBarContributor()).menuAboutToShow(menuManager); MenuManager submenuManager = new MenuManager("New Root"); - if (populateManager(submenuManager)) + if (populateNewRoot(submenuManager)) { menuManager.insertBefore("edit", submenuManager); } @@ -1929,7 +1911,7 @@ public class CDOEditor extends MultiPageEditorPart implements IEditingDomainProv /** * @ADDED */ - private boolean populateManager(MenuManager menuManager) + protected boolean populateNewRoot(MenuManager menuManager) { boolean populated = false; List<CDOPackage> cdoPackages = Arrays.asList(view.getSession().getPackageManager().getPackages()); @@ -2120,6 +2102,39 @@ public class CDOEditor extends MultiPageEditorPart implements IEditingDomainProv /** * @ADDED */ + public void refreshViewer(final Object element) + { + try + { + selectionViewer.getControl().getDisplay().syncExec(new Runnable() + { + public void run() + { + try + { + if (element == null) + { + selectionViewer.refresh(true); + } + else + { + selectionViewer.refresh(element, true); + } + } + catch (Exception ignore) + { + } + } + }); + } + catch (Exception ignore) + { + } + } + + /** + * @ADDED + */ public static void open(final IWorkbenchPage page, final CDOView view, final String resourcePath) { Display display = page.getWorkbenchWindow().getShell().getDisplay(); |