diff options
author | Eike Stepper | 2007-11-08 12:15:51 +0000 |
---|---|---|
committer | Eike Stepper | 2007-11-08 12:15:51 +0000 |
commit | 4fdea5c7868e736a61996a1d3a0484cb27b71813 (patch) | |
tree | 030ed707c4b4207a6b385e353deaaea96f2d4883 | |
parent | f1bc8bdbb7f7df876f305e0341c74f15e28ca0c0 (diff) | |
download | cdo-4fdea5c7868e736a61996a1d3a0484cb27b71813.tar.gz cdo-4fdea5c7868e736a61996a1d3a0484cb27b71813.tar.xz cdo-4fdea5c7868e736a61996a1d3a0484cb27b71813.zip |
[209007] Add CDOObject.cdoReload() API
https://bugs.eclipse.org/bugs/show_bug.cgi?id=209007
18 files changed, 429 insertions, 95 deletions
diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/protocol/CDOServerProtocol.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/protocol/CDOServerProtocol.java index 0bef49a74d..4a2006d998 100644 --- a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/protocol/CDOServerProtocol.java +++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/protocol/CDOServerProtocol.java @@ -74,6 +74,9 @@ public class CDOServerProtocol extends SignalProtocol case CDOProtocolConstants.SIGNAL_LOAD_CHUNK: return new LoadChunkIndication(); + case CDOProtocolConstants.SIGNAL_VERIFY_REVISION: + return new VerifyRevisionIndication(); + case CDOProtocolConstants.SIGNAL_QUERY_OBJECT_TYPES: return new QueryObjectTypesIndication(); diff --git a/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/protocol/VerifyRevisionIndication.java b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/protocol/VerifyRevisionIndication.java new file mode 100644 index 0000000000..fad88e2670 --- /dev/null +++ b/plugins/org.eclipse.emf.cdo.server/src/org/eclipse/emf/cdo/internal/server/protocol/VerifyRevisionIndication.java @@ -0,0 +1,72 @@ +/*************************************************************************** + * Copyright (c) 2004 - 2007 Eike Stepper, Germany. + * 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: + * Eike Stepper - initial API and implementation + **************************************************************************/ +package org.eclipse.emf.cdo.internal.server.protocol; + +import org.eclipse.emf.cdo.internal.protocol.CDOIDImpl; +import org.eclipse.emf.cdo.internal.protocol.revision.CDORevisionImpl; +import org.eclipse.emf.cdo.internal.server.RevisionManager; +import org.eclipse.emf.cdo.internal.server.bundle.OM; +import org.eclipse.emf.cdo.protocol.CDOID; +import org.eclipse.emf.cdo.protocol.CDOProtocolConstants; + +import org.eclipse.net4j.internal.util.om.trace.ContextTracer; +import org.eclipse.net4j.util.io.ExtendedDataInputStream; +import org.eclipse.net4j.util.io.ExtendedDataOutputStream; + +import java.io.IOException; + +/** + * @author Eike Stepper + */ +public class VerifyRevisionIndication extends CDOReadIndication +{ + private static final ContextTracer PROTOCOL = new ContextTracer(OM.DEBUG_PROTOCOL, VerifyRevisionIndication.class); + + protected long[] timeStamps; + + public VerifyRevisionIndication() + { + } + + @Override + protected short getSignalID() + { + return CDOProtocolConstants.SIGNAL_VERIFY_REVISION; + } + + @Override + protected void indicating(ExtendedDataInputStream in) throws IOException + { + int size = in.readInt(); + if (PROTOCOL.isEnabled()) PROTOCOL.format("Reading {0} IDs and versions", size); + + RevisionManager revisionManager = getRevisionManager(); + timeStamps = new long[size]; + for (int i = 0; i < size; i++) + { + CDOID id = CDOIDImpl.read(in); + int version = in.readInt(); + if (PROTOCOL.isEnabled()) PROTOCOL.format("Read ID and version: {0}v{1}", id, version); + + CDORevisionImpl revision = revisionManager.getRevisionByVersion(id, 0, version); + timeStamps[i] = revision.getRevised(); + } + } + + @Override + protected void responding(ExtendedDataOutputStream out) throws IOException + { + for (long revised : timeStamps) + { + out.writeLong(revised); + } + } +} 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(); diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/CDOObject.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/CDOObject.java index f38fbe42a2..f73f7b7b5d 100644 --- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/CDOObject.java +++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/cdo/CDOObject.java @@ -34,5 +34,5 @@ public interface CDOObject extends EObject public CDORevision cdoRevision(); - public boolean cdoRefresh(boolean force); + public void cdoReload(); } diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOLegacyImpl.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOLegacyImpl.java index 0a79ec6950..8aebe2621c 100644 --- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOLegacyImpl.java +++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOLegacyImpl.java @@ -101,9 +101,9 @@ public abstract class CDOLegacyImpl extends CDOWrapperImpl implements Adapter.In return view; } - public boolean cdoRefresh(boolean force) + public void cdoReload() { - return CDOStateMachine.INSTANCE.refresh(this, force); + CDOStateMachine.INSTANCE.reload(this); } public boolean isAdapterForType(Object type) diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOMetaImpl.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOMetaImpl.java index 4aa4a5de4e..eb6d4749e9 100644 --- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOMetaImpl.java +++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOMetaImpl.java @@ -50,7 +50,7 @@ public class CDOMetaImpl extends CDOWrapperImpl throw new UnsupportedOperationException(); } - public boolean cdoRefresh(boolean force) + public void cdoReload() { throw new UnsupportedOperationException(); } diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOObjectImpl.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOObjectImpl.java index c5f47a9a70..5527d7b21e 100644 --- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOObjectImpl.java +++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOObjectImpl.java @@ -104,9 +104,9 @@ public class CDOObjectImpl extends EStoreEObjectImpl implements InternalCDOObjec return resource; } - public boolean cdoRefresh(boolean force) + public void cdoReload() { - return CDOStateMachine.INSTANCE.refresh(this, force); + CDOStateMachine.INSTANCE.reload(this); } public void cdoInternalSetID(CDOID id) diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOStateMachine.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOStateMachine.java index 9d5379e711..2a70a554f8 100644 --- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOStateMachine.java +++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/CDOStateMachine.java @@ -1,6 +1,7 @@ package org.eclipse.emf.internal.cdo; import org.eclipse.emf.cdo.CDOState; +import org.eclipse.emf.cdo.CDOView; import org.eclipse.emf.cdo.eresource.CDOResource; import org.eclipse.emf.cdo.internal.protocol.model.CDOClassImpl; import org.eclipse.emf.cdo.internal.protocol.revision.CDORevisionImpl; @@ -13,15 +14,20 @@ import org.eclipse.emf.cdo.util.ServerException; import org.eclipse.emf.internal.cdo.bundle.OM; import org.eclipse.emf.internal.cdo.protocol.CommitTransactionResult; import org.eclipse.emf.internal.cdo.protocol.ResourceIDRequest; +import org.eclipse.emf.internal.cdo.protocol.VerifyRevisionRequest; import org.eclipse.emf.internal.cdo.util.FSMUtil; +import org.eclipse.net4j.IChannel; import org.eclipse.net4j.internal.util.om.trace.ContextTracer; import org.eclipse.net4j.signal.IFailOverStrategy; import org.eclipse.net4j.util.fsm.FiniteStateMachine; import org.eclipse.net4j.util.fsm.ITransition; import java.text.MessageFormat; +import java.util.ArrayList; +import java.util.HashMap; import java.util.Iterator; +import java.util.List; import java.util.Map; /** @@ -49,7 +55,7 @@ public final class CDOStateMachine extends FiniteStateMachine<CDOState, CDOEvent init(CDOState.TRANSIENT, CDOEvent.READ, IGNORE); init(CDOState.TRANSIENT, CDOEvent.WRITE, IGNORE); init(CDOState.TRANSIENT, CDOEvent.INVALIDATE, FAIL); - init(CDOState.TRANSIENT, CDOEvent.REFRESH, IGNORE); + init(CDOState.TRANSIENT, CDOEvent.RELOAD, IGNORE); init(CDOState.TRANSIENT, CDOEvent.COMMIT, FAIL); init(CDOState.TRANSIENT, CDOEvent.ROLLBACK, FAIL); init(CDOState.TRANSIENT, CDOEvent.FINALIZE_ATTACH, FAIL); @@ -59,7 +65,7 @@ public final class CDOStateMachine extends FiniteStateMachine<CDOState, CDOEvent init(CDOState.PREPARED_ATTACH, CDOEvent.READ, IGNORE); init(CDOState.PREPARED_ATTACH, CDOEvent.WRITE, FAIL); init(CDOState.PREPARED_ATTACH, CDOEvent.INVALIDATE, FAIL); - init(CDOState.PREPARED_ATTACH, CDOEvent.REFRESH, FAIL); + init(CDOState.PREPARED_ATTACH, CDOEvent.RELOAD, FAIL); init(CDOState.PREPARED_ATTACH, CDOEvent.COMMIT, FAIL); init(CDOState.PREPARED_ATTACH, CDOEvent.ROLLBACK, FAIL); init(CDOState.PREPARED_ATTACH, CDOEvent.FINALIZE_ATTACH, new FinalizeAttachTransition()); @@ -69,7 +75,7 @@ public final class CDOStateMachine extends FiniteStateMachine<CDOState, CDOEvent init(CDOState.NEW, CDOEvent.READ, IGNORE); init(CDOState.NEW, CDOEvent.WRITE, IGNORE); init(CDOState.NEW, CDOEvent.INVALIDATE, FAIL); - init(CDOState.NEW, CDOEvent.REFRESH, IGNORE); + init(CDOState.NEW, CDOEvent.RELOAD, IGNORE); init(CDOState.NEW, CDOEvent.COMMIT, new CommitTransition()); init(CDOState.NEW, CDOEvent.ROLLBACK, FAIL); init(CDOState.NEW, CDOEvent.FINALIZE_ATTACH, FAIL); @@ -79,7 +85,7 @@ public final class CDOStateMachine extends FiniteStateMachine<CDOState, CDOEvent init(CDOState.CLEAN, CDOEvent.READ, IGNORE); init(CDOState.CLEAN, CDOEvent.WRITE, new WriteTransition()); init(CDOState.CLEAN, CDOEvent.INVALIDATE, new InvalidateTransition()); - init(CDOState.CLEAN, CDOEvent.REFRESH, new RefreshTransition()); + init(CDOState.CLEAN, CDOEvent.RELOAD, new ReloadTransition()); init(CDOState.CLEAN, CDOEvent.COMMIT, FAIL); init(CDOState.CLEAN, CDOEvent.ROLLBACK, FAIL); init(CDOState.CLEAN, CDOEvent.FINALIZE_ATTACH, FAIL); @@ -89,7 +95,7 @@ public final class CDOStateMachine extends FiniteStateMachine<CDOState, CDOEvent init(CDOState.DIRTY, CDOEvent.READ, IGNORE); init(CDOState.DIRTY, CDOEvent.WRITE, IGNORE); init(CDOState.DIRTY, CDOEvent.INVALIDATE, new ConflictTransition()); - init(CDOState.DIRTY, CDOEvent.REFRESH, new RefreshTransition()); + init(CDOState.DIRTY, CDOEvent.RELOAD, new ReloadTransition()); init(CDOState.DIRTY, CDOEvent.COMMIT, new CommitTransition()); init(CDOState.DIRTY, CDOEvent.ROLLBACK, new RollbackTransition()); init(CDOState.DIRTY, CDOEvent.FINALIZE_ATTACH, FAIL); @@ -99,7 +105,7 @@ public final class CDOStateMachine extends FiniteStateMachine<CDOState, CDOEvent init(CDOState.PROXY, CDOEvent.READ, new LoadTransition(false)); init(CDOState.PROXY, CDOEvent.WRITE, new LoadTransition(true)); init(CDOState.PROXY, CDOEvent.INVALIDATE, IGNORE); - init(CDOState.PROXY, CDOEvent.REFRESH, new RefreshTransition()); + init(CDOState.PROXY, CDOEvent.RELOAD, new ReloadTransition()); init(CDOState.PROXY, CDOEvent.COMMIT, FAIL); init(CDOState.PROXY, CDOEvent.ROLLBACK, FAIL); init(CDOState.PROXY, CDOEvent.FINALIZE_ATTACH, IGNORE); @@ -109,7 +115,7 @@ public final class CDOStateMachine extends FiniteStateMachine<CDOState, CDOEvent init(CDOState.CONFLICT, CDOEvent.READ, IGNORE); init(CDOState.CONFLICT, CDOEvent.WRITE, IGNORE); init(CDOState.CONFLICT, CDOEvent.INVALIDATE, IGNORE); - init(CDOState.CONFLICT, CDOEvent.REFRESH, new RefreshTransition()); + init(CDOState.CONFLICT, CDOEvent.RELOAD, new ReloadTransition()); init(CDOState.CONFLICT, CDOEvent.COMMIT, IGNORE); init(CDOState.CONFLICT, CDOEvent.ROLLBACK, new RollbackTransition()); init(CDOState.CONFLICT, CDOEvent.FINALIZE_ATTACH, IGNORE); @@ -148,12 +154,34 @@ public final class CDOStateMachine extends FiniteStateMachine<CDOState, CDOEvent process(object, CDOEvent.WRITE, null); } - public boolean refresh(InternalCDOObject object, boolean force) + public void reload(InternalCDOObject... objects) { - if (TRACER.isEnabled()) trace(object, CDOEvent.REFRESH); - boolean[] forceAndResult = { force }; - process(object, CDOEvent.REFRESH, forceAndResult); - return forceAndResult[0]; + Map<CDOID, InternalCDOObject> ids = new HashMap<CDOID, InternalCDOObject>(); + List<CDORevisionImpl> revisions = new ArrayList<CDORevisionImpl>(); + for (InternalCDOObject object : objects) + { + revisions.add((CDORevisionImpl)object.cdoRevision()); + ids.put(object.cdoID(), object); + } + + try + { + CDOView view = objects[0].cdoView(); + IChannel channel = view.getSession().getChannel(); + VerifyRevisionRequest request = new VerifyRevisionRequest(channel, revisions); + revisions = request.send(); + } + catch (Exception ex) + { + throw new TransportException(ex); + } + + for (CDORevisionImpl revision : revisions) + { + InternalCDOObject object = ids.get(revision.getID()); + if (TRACER.isEnabled()) trace(object, CDOEvent.RELOAD); + process(object, CDOEvent.RELOAD, null); + } } public void invalidate(InternalCDOObject object, long timeStamp) @@ -365,17 +393,10 @@ public final class CDOStateMachine extends FiniteStateMachine<CDOState, CDOEvent /** * @author Eike Stepper */ - private final class RefreshTransition implements ITransition<CDOState, CDOEvent, InternalCDOObject, boolean[]> + private final class ReloadTransition implements ITransition<CDOState, CDOEvent, InternalCDOObject, Object> { - public void execute(InternalCDOObject object, CDOState state, CDOEvent event, boolean[] forceAndResult) + public void execute(InternalCDOObject object, CDOState state, CDOEvent event, Object NULL) { - if (forceAndResult[0]) - { - // CDOViewImpl view = (CDOViewImpl)object.cdoView(); - // view.removeObject(object.cdoID()); - } - - // TODO Implement method RefreshTransition.execute() changeState(object, CDOState.PROXY); } } @@ -500,5 +521,5 @@ public final class CDOStateMachine extends FiniteStateMachine<CDOState, CDOEvent */ enum CDOEvent { - ATTACH, DETACH, READ, WRITE, INVALIDATE, REFRESH, COMMIT, ROLLBACK, FINALIZE_ATTACH + ATTACH, DETACH, READ, WRITE, INVALIDATE, RELOAD, COMMIT, ROLLBACK, FINALIZE_ATTACH } diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/LoadRevisionRequest.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/LoadRevisionRequest.java index e1bc7da826..fa465d65ee 100644 --- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/LoadRevisionRequest.java +++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/LoadRevisionRequest.java @@ -10,12 +10,6 @@ **************************************************************************/ package org.eclipse.emf.internal.cdo.protocol; -import java.io.IOException; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.List; - import org.eclipse.emf.cdo.analyzer.CDOFetchRuleManager; import org.eclipse.emf.cdo.internal.protocol.CDOIDImpl; import org.eclipse.emf.cdo.internal.protocol.revision.CDORevisionImpl; @@ -27,11 +21,18 @@ import org.eclipse.emf.internal.cdo.CDORevisionManagerImpl; import org.eclipse.emf.internal.cdo.CDOSessionImpl; import org.eclipse.emf.internal.cdo.CDOSessionPackageManager; import org.eclipse.emf.internal.cdo.bundle.OM; + import org.eclipse.net4j.IChannel; import org.eclipse.net4j.internal.util.om.trace.ContextTracer; import org.eclipse.net4j.util.io.ExtendedDataInputStream; import org.eclipse.net4j.util.io.ExtendedDataOutputStream; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.List; + /** * @author Eike Stepper */ @@ -100,7 +101,7 @@ public class LoadRevisionRequest extends CDOClientRequest<List<CDORevisionImpl>> } @Override - public List<CDORevisionImpl> confirming(ExtendedDataInputStream in) throws IOException + protected List<CDORevisionImpl> confirming(ExtendedDataInputStream in) throws IOException { CDOSessionImpl session = getSession(); CDORevisionManagerImpl revisionManager = session.getRevisionManager(); diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/VerifyRevisionRequest.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/VerifyRevisionRequest.java new file mode 100644 index 0000000000..2b39840544 --- /dev/null +++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/protocol/VerifyRevisionRequest.java @@ -0,0 +1,93 @@ +/*************************************************************************** + * Copyright (c) 2004 - 2007 Eike Stepper, Germany. + * 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: + * Eike Stepper - initial API and implementation + **************************************************************************/ +package org.eclipse.emf.internal.cdo.protocol; + +import org.eclipse.emf.cdo.internal.protocol.CDOIDImpl; +import org.eclipse.emf.cdo.internal.protocol.revision.CDORevisionImpl; +import org.eclipse.emf.cdo.protocol.CDOID; +import org.eclipse.emf.cdo.protocol.CDOProtocolConstants; +import org.eclipse.emf.cdo.protocol.revision.CDORevision; + +import org.eclipse.emf.internal.cdo.bundle.OM; + +import org.eclipse.net4j.IChannel; +import org.eclipse.net4j.internal.util.om.trace.ContextTracer; +import org.eclipse.net4j.util.io.ExtendedDataInputStream; +import org.eclipse.net4j.util.io.ExtendedDataOutputStream; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.List; + +/** + * @author Eike Stepper + */ +public class VerifyRevisionRequest extends CDOClientRequest<List<CDORevisionImpl>> +{ + private static final ContextTracer PROTOCOL = new ContextTracer(OM.DEBUG_PROTOCOL, VerifyRevisionRequest.class); + + private Collection<CDORevisionImpl> revisions; + + public VerifyRevisionRequest(IChannel channel, Collection<CDORevisionImpl> revisions) + { + super(channel); + this.revisions = revisions; + } + + public VerifyRevisionRequest(IChannel channel, CDORevisionImpl revision) + { + this(channel, Collections.singleton(revision)); + } + + @Override + protected short getSignalID() + { + return CDOProtocolConstants.SIGNAL_VERIFY_REVISION; + } + + @Override + protected void requesting(ExtendedDataOutputStream out) throws IOException + { + if (PROTOCOL.isEnabled()) PROTOCOL.format("Writing {0} IDs and versions", revisions.size()); + out.writeInt(revisions.size()); + + for (CDORevisionImpl revision : revisions) + { + CDOID id = revision.getID(); + int version = revision.getVersion(); + if (PROTOCOL.isEnabled()) PROTOCOL.format("Writing ID and version: {0}v{1}", id, version); + CDOIDImpl.write(out, id); + out.writeInt(version); + } + } + + @Override + protected List<CDORevisionImpl> confirming(ExtendedDataInputStream in) throws IOException + { + ArrayList<CDORevisionImpl> result = new ArrayList<CDORevisionImpl>(); + + if (PROTOCOL.isEnabled()) PROTOCOL.format("Reading {0} timeStamps", revisions.size()); + for (CDORevisionImpl revision : revisions) + { + long revised = in.readLong(); + if (PROTOCOL.isEnabled()) PROTOCOL.format("Reading timeStamp: {0}", revised); + if (revised != CDORevision.UNSPECIFIED_DATE) + { + revision.setRevised(revised); + result.add(revision); + } + } + + return result; + } +} diff --git a/plugins/org.eclipse.net4j.buddies.server/BuddiesServer.launch b/plugins/org.eclipse.net4j.buddies.server/BuddiesServer.launch index 1968f03414..b210c5ea6a 100644 --- a/plugins/org.eclipse.net4j.buddies.server/BuddiesServer.launch +++ b/plugins/org.eclipse.net4j.buddies.server/BuddiesServer.launch @@ -14,10 +14,6 @@ <booleanAttribute key="includeOptional" value="true"/> <stringAttribute key="location" value="${workspace_loc}/../buddies.server"/> <booleanAttribute key="org.eclipse.debug.core.appendEnvironmentVariables" value="true"/> -<listAttribute key="org.eclipse.debug.ui.favoriteGroups"> -<listEntry value="org.eclipse.debug.ui.launchGroup.debug"/> -<listEntry value="org.eclipse.debug.ui.launchGroup.run"/> -</listAttribute> <stringAttribute key="org.eclipse.jdt.launching.PROGRAM_ARGUMENTS" value="-os ${target.os} -ws ${target.ws} -arch ${target.arch} -nl ${target.nl} -debug -console --launcher.XXMaxPermSize 128M"/> <stringAttribute key="org.eclipse.jdt.launching.SOURCE_PATH_PROVIDER" value="org.eclipse.pde.ui.workbenchClasspathProvider"/> <stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="-Ddebug=true -Dnet4j.config=${resource_loc:/org.eclipse.net4j.buddies.server/config}"/> diff --git a/plugins/org.eclipse.net4j.buddies.ui/BuddiesClient1.launch b/plugins/org.eclipse.net4j.buddies.ui/BuddiesClient1.launch index bb2b35c884..2502f457e8 100644 --- a/plugins/org.eclipse.net4j.buddies.ui/BuddiesClient1.launch +++ b/plugins/org.eclipse.net4j.buddies.ui/BuddiesClient1.launch @@ -13,10 +13,6 @@ <booleanAttribute key="includeOptional" value="false"/> <stringAttribute key="location" value="${workspace_loc}/../buddies.client1"/> <booleanAttribute key="org.eclipse.debug.core.appendEnvironmentVariables" value="true"/> -<listAttribute key="org.eclipse.debug.ui.favoriteGroups"> -<listEntry value="org.eclipse.debug.ui.launchGroup.debug"/> -<listEntry value="org.eclipse.debug.ui.launchGroup.run"/> -</listAttribute> <stringAttribute key="org.eclipse.jdt.launching.PROGRAM_ARGUMENTS" value="-nosplash -console"/> <stringAttribute key="org.eclipse.jdt.launching.SOURCE_PATH_PROVIDER" value="org.eclipse.pde.ui.workbenchClasspathProvider"/> <stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="-Dorg.aspectj.tracing.debug=false -Xms40m -Xmx512m"/> diff --git a/plugins/org.eclipse.net4j.buddies.ui/BuddiesClient2.launch b/plugins/org.eclipse.net4j.buddies.ui/BuddiesClient2.launch index b8997fedba..22e75c1105 100644 --- a/plugins/org.eclipse.net4j.buddies.ui/BuddiesClient2.launch +++ b/plugins/org.eclipse.net4j.buddies.ui/BuddiesClient2.launch @@ -13,10 +13,6 @@ <booleanAttribute key="includeOptional" value="false"/> <stringAttribute key="location" value="${workspace_loc}/../buddies.client2"/> <booleanAttribute key="org.eclipse.debug.core.appendEnvironmentVariables" value="true"/> -<listAttribute key="org.eclipse.debug.ui.favoriteGroups"> -<listEntry value="org.eclipse.debug.ui.launchGroup.debug"/> -<listEntry value="org.eclipse.debug.ui.launchGroup.run"/> -</listAttribute> <stringAttribute key="org.eclipse.jdt.launching.PROGRAM_ARGUMENTS" value="-nosplash -console"/> <stringAttribute key="org.eclipse.jdt.launching.SOURCE_PATH_PROVIDER" value="org.eclipse.pde.ui.workbenchClasspathProvider"/> <stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="-Dorg.aspectj.tracing.debug=false -Xms40m -Xmx512m"/> diff --git a/plugins/org.eclipse.net4j.buddies.ui/BuddiesClient3.launch b/plugins/org.eclipse.net4j.buddies.ui/BuddiesClient3.launch index 397298f63c..354c073b48 100644 --- a/plugins/org.eclipse.net4j.buddies.ui/BuddiesClient3.launch +++ b/plugins/org.eclipse.net4j.buddies.ui/BuddiesClient3.launch @@ -13,10 +13,6 @@ <booleanAttribute key="includeOptional" value="false"/> <stringAttribute key="location" value="${workspace_loc}/../buddies.client3"/> <booleanAttribute key="org.eclipse.debug.core.appendEnvironmentVariables" value="true"/> -<listAttribute key="org.eclipse.debug.ui.favoriteGroups"> -<listEntry value="org.eclipse.debug.ui.launchGroup.debug"/> -<listEntry value="org.eclipse.debug.ui.launchGroup.run"/> -</listAttribute> <stringAttribute key="org.eclipse.jdt.launching.PROGRAM_ARGUMENTS" value="-nosplash -console"/> <stringAttribute key="org.eclipse.jdt.launching.SOURCE_PATH_PROVIDER" value="org.eclipse.pde.ui.workbenchClasspathProvider"/> <stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="-Dorg.aspectj.tracing.debug=false -Xms40m -Xmx512m"/> |