diff options
author | Martin Fluegge | 2011-10-30 09:38:11 +0000 |
---|---|---|
committer | Martin Fluegge | 2011-10-30 09:38:11 +0000 |
commit | 319a26b38370be25077108eb0a3097110f284c89 (patch) | |
tree | 277a74198db4e30bf688ced8d6d611a8cb9feb5c /plugins/org.eclipse.emf.cdo.dawn | |
parent | b0bbe60695ef9e3c8c79797a41de6437a725c869 (diff) | |
download | cdo-319a26b38370be25077108eb0a3097110f284c89.tar.gz cdo-319a26b38370be25077108eb0a3097110f284c89.tar.xz cdo-319a26b38370be25077108eb0a3097110f284c89.zip |
[319486] [Dawn] Implement locking mechanism for extended editors
https://bugs.eclipse.org/bugs/show_bug.cgi?id=319486
Diffstat (limited to 'plugins/org.eclipse.emf.cdo.dawn')
-rw-r--r-- | plugins/org.eclipse.emf.cdo.dawn/src/org/eclipse/emf/cdo/dawn/editors/impl/DawnAbstractEditorSupport.java | 329 |
1 files changed, 165 insertions, 164 deletions
diff --git a/plugins/org.eclipse.emf.cdo.dawn/src/org/eclipse/emf/cdo/dawn/editors/impl/DawnAbstractEditorSupport.java b/plugins/org.eclipse.emf.cdo.dawn/src/org/eclipse/emf/cdo/dawn/editors/impl/DawnAbstractEditorSupport.java index 88dce2bc11..954aad8c6f 100644 --- a/plugins/org.eclipse.emf.cdo.dawn/src/org/eclipse/emf/cdo/dawn/editors/impl/DawnAbstractEditorSupport.java +++ b/plugins/org.eclipse.emf.cdo.dawn/src/org/eclipse/emf/cdo/dawn/editors/impl/DawnAbstractEditorSupport.java @@ -1,164 +1,165 @@ -/* - * Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) 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: - * Martin Fluegge - initial API and implementation - */ -package org.eclipse.emf.cdo.dawn.editors.impl; - -import org.eclipse.emf.cdo.dawn.editors.IDawnEditor; -import org.eclipse.emf.cdo.dawn.editors.IDawnEditorSupport; -import org.eclipse.emf.cdo.dawn.notifications.BasicDawnListener; -import org.eclipse.emf.cdo.transaction.CDOTransaction; -import org.eclipse.emf.cdo.transaction.CDOTransactionHandlerBase; -import org.eclipse.emf.cdo.view.CDOAdapterPolicy; -import org.eclipse.emf.cdo.view.CDOView; - -import java.util.List; - -/** - * @author Martin Fluegge - */ -public abstract class DawnAbstractEditorSupport implements IDawnEditorSupport -{ - private final IDawnEditor editor; - - private CDOView view; - - private boolean dirty; - - public CDOView getView() - { - return view; - } - - public void setView(CDOView view) - { - this.view = view; - } - - public DawnAbstractEditorSupport(IDawnEditor editor) - { - this.editor = editor; - } - - public void setDirty(boolean dirty) - { - this.dirty = dirty; - } - - public boolean isDirty() - { - return dirty; - } - - public IDawnEditor getEditor() - { - return editor; - } - - /** - * This method registeres the listeners for the DawnEditorSupport. Concrete implementaions can influence the - * registered listeneres by implementing the methods - * <ul> - * <li>getBasicHandler()</li> - * <li>getLockingHandler()</li> - * </ul> - * If one of these methods returns null the specific handler will not be registered and activated. - * - * @see #getBasicHandler() - * @see #getLockingHandler() - * @since 2.0 - */ - public void registerListeners() - { - BasicDawnListener listener = getBasicHandler(); - CDOView view = getView(); - - if (listener != null) - { - view.addListener(listener); - } - - BasicDawnListener lockingHandler = getLockingHandler(); - if (lockingHandler != null) - { - view.addListener(lockingHandler); - view.options().setLockNotificationEnabled(true); - } - - if (view instanceof CDOTransaction) - { - CDOTransaction transaction = (CDOTransaction)view; - CDOTransactionHandlerBase transactionHandler = getTransactionHandler(); - if (transactionHandler != null) - { - transaction.addTransactionHandler(transactionHandler); - } - transaction.options().addChangeSubscriptionPolicy(CDOAdapterPolicy.CDO); - } - } - - /** - * Subclasses must implement this method to deliver a IDawnListener that implements the behavior for Session - * invalidations. If the method returns null, the handler will not be registered. - * - * @since 2.0 - */ - protected abstract BasicDawnListener getBasicHandler(); - - /** - * Subclasses must implement this method to deliver a IDawnListener that implements the behavior for remote locking - * notifications. If the method returns null, the handler will not be registered. - * - * @since 2.0 - */ - protected abstract BasicDawnListener getLockingHandler(); - - /** - * Subclasses must implement this method to deliver a CDOTransactionHandlerBase that implements the behavior for - * remote changes notifications. If the method returns null, the handler will not be registered. - * - * @since 2.0 - */ - protected abstract CDOTransactionHandlerBase getTransactionHandler(); - - /** - * @since 1.0 - */ - public void rollback() - { - CDOView view = getEditor().getView(); - - if (view != null && view instanceof CDOTransaction) - { - ((CDOTransaction)view).rollback(); - } - } - - /** - * @since 2.0 - */ - public void lockObjects(List<Object> objectsToBeLocked) - { - for (Object objectToBeLocked : objectsToBeLocked) - { - lockObject(objectToBeLocked); - } - } - - /** - * @since 2.0 - */ - public void unlockObjects(List<Object> objectsToBeLocked) - { - for (Object objectToBeUnlocked : objectsToBeLocked) - { - unlockObject(objectToBeUnlocked); - } - } -} +/*
+ * Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) 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:
+ * Martin Fluegge - initial API and implementation
+ */
+package org.eclipse.emf.cdo.dawn.editors.impl;
+
+import org.eclipse.emf.cdo.dawn.editors.IDawnEditor;
+import org.eclipse.emf.cdo.dawn.editors.IDawnEditorSupport;
+import org.eclipse.emf.cdo.dawn.notifications.BasicDawnListener;
+import org.eclipse.emf.cdo.transaction.CDOTransaction;
+import org.eclipse.emf.cdo.transaction.CDOTransactionHandlerBase;
+import org.eclipse.emf.cdo.view.CDOAdapterPolicy;
+import org.eclipse.emf.cdo.view.CDOView;
+
+import java.util.List;
+
+/**
+ * @author Martin Fluegge
+ */
+public abstract class DawnAbstractEditorSupport implements IDawnEditorSupport
+{
+ private final IDawnEditor editor;
+
+ private CDOView view;
+
+ private boolean dirty;
+
+ public CDOView getView()
+ {
+ return view;
+ }
+
+ public void setView(CDOView view)
+ {
+ this.view = view;
+ }
+
+ public DawnAbstractEditorSupport(IDawnEditor editor)
+ {
+ this.editor = editor;
+ }
+
+ public void setDirty(boolean dirty)
+ {
+ this.dirty = dirty;
+ }
+
+ public boolean isDirty()
+ {
+ return dirty;
+ }
+
+ public IDawnEditor getEditor()
+ {
+ return editor;
+ }
+
+ /**
+ * This method registeres the listeners for the DawnEditorSupport. Concrete implementaions can influence the
+ * registered listeneres by implementing the methods
+ * <ul>
+ * <li>getBasicHandler()</li>
+ * <li>getLockingHandler()</li>
+ * </ul>
+ * If one of these methods returns null the specific handler will not be registered and activated.
+ *
+ * @see #getBasicHandler()
+ * @see #getLockingHandler()
+ * @since 2.0
+ */
+ public void registerListeners()
+ {
+ BasicDawnListener listener = getBasicHandler();
+ CDOView view = getView();
+
+ if (listener != null)
+ {
+ view.addListener(listener);
+ }
+
+ BasicDawnListener lockingHandler = getLockingHandler();
+ if (lockingHandler != null)
+ {
+ view.addListener(lockingHandler);
+ view.options().setLockNotificationEnabled(true);
+ }
+
+ if (view instanceof CDOTransaction)
+ {
+ CDOTransaction transaction = (CDOTransaction)view;
+ CDOTransactionHandlerBase transactionHandler = getTransactionHandler();
+ if (transactionHandler != null)
+ {
+ transaction.addTransactionHandler(transactionHandler);
+ }
+ transaction.options().addChangeSubscriptionPolicy(CDOAdapterPolicy.CDO);
+ transaction.options().setAutoReleaseLocksEnabled(false);
+ }
+ }
+
+ /**
+ * Subclasses must implement this method to deliver a IDawnListener that implements the behavior for Session
+ * invalidations. If the method returns null, the handler will not be registered.
+ *
+ * @since 2.0
+ */
+ protected abstract BasicDawnListener getBasicHandler();
+
+ /**
+ * Subclasses must implement this method to deliver a IDawnListener that implements the behavior for remote locking
+ * notifications. If the method returns null, the handler will not be registered.
+ *
+ * @since 2.0
+ */
+ protected abstract BasicDawnListener getLockingHandler();
+
+ /**
+ * Subclasses must implement this method to deliver a CDOTransactionHandlerBase that implements the behavior for
+ * remote changes notifications. If the method returns null, the handler will not be registered.
+ *
+ * @since 2.0
+ */
+ protected abstract CDOTransactionHandlerBase getTransactionHandler();
+
+ /**
+ * @since 1.0
+ */
+ public void rollback()
+ {
+ CDOView view = getEditor().getView();
+
+ if (view != null && view instanceof CDOTransaction)
+ {
+ ((CDOTransaction)view).rollback();
+ }
+ }
+
+ /**
+ * @since 2.0
+ */
+ public void lockObjects(List<Object> objectsToBeLocked)
+ {
+ for (Object objectToBeLocked : objectsToBeLocked)
+ {
+ lockObject(objectToBeLocked);
+ }
+ }
+
+ /**
+ * @since 2.0
+ */
+ public void unlockObjects(List<Object> objectsToBeLocked)
+ {
+ for (Object objectToBeUnlocked : objectsToBeLocked)
+ {
+ unlockObject(objectToBeUnlocked);
+ }
+ }
+}
|