Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGoulwen Le Fur2013-09-11 08:17:17 +0000
committerGoulwen Le Fur2013-09-11 12:19:14 +0000
commit12bd15bb57b5e48e46cf735d9998aafd71b548ba (patch)
tree7499fa62c0a46da072a8e3d65caaf199725c6270
parent52a20ed7dd3179f493cdd4c8816a3d558fd9a21e (diff)
downloadorg.eclipse.eef-v1_2_2_BRANCH.tar.gz
org.eclipse.eef-v1_2_2_BRANCH.tar.xz
org.eclipse.eef-v1_2_2_BRANCH.zip
UPDATED: fixed errors when CDO adapter is installed and editing a non-cdo resourcev1_2_2_BRANCH
-rw-r--r--plugins/org.eclipse.emf.eef.cdo.runtime/src/org/eclipse/emf/eef/cdo/runtime/policies/CDOReadOnlyPolicy.java3
-rw-r--r--plugins/org.eclipse.emf.eef.cdo.runtime/src/org/eclipse/emf/eef/cdo/runtime/policies/EEFWizardLockPolicy.java236
2 files changed, 121 insertions, 118 deletions
diff --git a/plugins/org.eclipse.emf.eef.cdo.runtime/src/org/eclipse/emf/eef/cdo/runtime/policies/CDOReadOnlyPolicy.java b/plugins/org.eclipse.emf.eef.cdo.runtime/src/org/eclipse/emf/eef/cdo/runtime/policies/CDOReadOnlyPolicy.java
index 3f7dda69a..3b849e41e 100644
--- a/plugins/org.eclipse.emf.eef.cdo.runtime/src/org/eclipse/emf/eef/cdo/runtime/policies/CDOReadOnlyPolicy.java
+++ b/plugins/org.eclipse.emf.eef.cdo.runtime/src/org/eclipse/emf/eef/cdo/runtime/policies/CDOReadOnlyPolicy.java
@@ -11,6 +11,7 @@
package org.eclipse.emf.eef.cdo.runtime.policies;
import org.eclipse.emf.cdo.CDOObject;
+import org.eclipse.emf.cdo.eresource.CDOResource;
import org.eclipse.emf.cdo.util.CDOUtil;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.eef.runtime.api.providers.IReadOnlyPolicy;
@@ -28,7 +29,7 @@ public class CDOReadOnlyPolicy implements IReadOnlyPolicy {
* @see org.eclipse.emf.eef.runtime.api.providers.IReadOnlyPolicy#isReadOnly(org.eclipse.emf.ecore.EObject, java.lang.Object)
*/
public boolean isReadOnly(EObject context, Object eStructuralFeature) {
- if (context != null) {
+ if (context != null && context.eResource() instanceof CDOResource) {
CDOObject cdoObject = CDOUtil.getCDOObject(context);
if (cdoObject != null
&& cdoObject.cdoWriteLock().isLockedByOthers()) {
diff --git a/plugins/org.eclipse.emf.eef.cdo.runtime/src/org/eclipse/emf/eef/cdo/runtime/policies/EEFWizardLockPolicy.java b/plugins/org.eclipse.emf.eef.cdo.runtime/src/org/eclipse/emf/eef/cdo/runtime/policies/EEFWizardLockPolicy.java
index 00ddf660c..10a36447e 100644
--- a/plugins/org.eclipse.emf.eef.cdo.runtime/src/org/eclipse/emf/eef/cdo/runtime/policies/EEFWizardLockPolicy.java
+++ b/plugins/org.eclipse.emf.eef.cdo.runtime/src/org/eclipse/emf/eef/cdo/runtime/policies/EEFWizardLockPolicy.java
@@ -1,117 +1,119 @@
-/*******************************************************************************
- * Copyright (c) 2012 Obeo.
- * 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:
- * Obeo - initial API and implementation
- *******************************************************************************/
-package org.eclipse.emf.eef.cdo.runtime.policies;
-
-import java.util.List;
-
-import org.eclipse.emf.cdo.CDOObject;
-import org.eclipse.emf.cdo.transaction.CDOTransaction;
-import org.eclipse.emf.cdo.util.CDOUtil;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.eef.cdo.runtime.provider.ICDOLockStrategyProvider;
-import org.eclipse.emf.eef.cdo.runtime.service.CDOLockStrategyProviderService;
-import org.eclipse.emf.eef.runtime.api.component.IPropertiesEditionComponent;
-import org.eclipse.emf.eef.runtime.impl.components.SinglePartPropertiesEditingComponent;
-import org.eclipse.emf.eef.runtime.impl.parts.CompositePropertiesEditionPart;
-import org.eclipse.emf.eef.runtime.policies.ILockPolicy;
-import org.eclipse.emf.eef.runtime.ui.widgets.settings.EEFEditorSettings;
-import org.eclipse.emf.eef.runtime.ui.widgets.settings.EEFEditorSettingsBuilder.EEFEditorSettingsImpl;
-
-/**
- * Lock policy for EEF wizard : lock the semantic elements and its EEFEditorSettings for SmartModelNavigation.
- *
- * @author <a href="mailto:nathalie.lepine@obeo.fr">Nathalie Lepine</a>
- *
- */
-public class EEFWizardLockPolicy implements ILockPolicy {
-
- /**
- * (non-Javadoc)
- *
- * @see org.eclipse.emf.eef.runtime.policies.ILockPolicy#lock(org.eclipse.emf.eef.runtime.api.component.IPropertiesEditionComponent)
- */
- public void lock(IPropertiesEditionComponent propertiesEditingComponent) {
- lock(propertiesEditingComponent.getEditingContext().getEObject());
- if (propertiesEditingComponent instanceof SinglePartPropertiesEditingComponent && ((SinglePartPropertiesEditingComponent) propertiesEditingComponent).getEditingPart() instanceof CompositePropertiesEditionPart) {
- lock(((CompositePropertiesEditionPart) ((SinglePartPropertiesEditingComponent) propertiesEditingComponent).getEditingPart()).getSettings());
- }
-
- }
-
- private void lock(List<EEFEditorSettings> allSettings) {
- for (EEFEditorSettings eefEditorSettings : allSettings) {
- if (eefEditorSettings instanceof EEFEditorSettingsImpl) {
- EObject significantObject = ((EEFEditorSettingsImpl) eefEditorSettings)
- .getSignificantObject();
- if (significantObject != null) {
- lock(significantObject);
- }
- }
- }
- }
-
- private void lock(EObject eObject) {
- if (eObject != null) {
- CDOObject cdoObject = CDOUtil.getCDOObject(eObject);
- if (cdoObject != null) {
- if (!CDOLockStrategyProviderService.getInstance().getProviders()
- .isEmpty()) {
- for (ICDOLockStrategyProvider provider : CDOLockStrategyProviderService.getInstance().getProviders()) {
- provider.lock(cdoObject);
- }
- } else if (cdoObject.cdoWriteLock() != null) {
- cdoObject.cdoWriteLock().tryLock();
- }
- }
- }
- }
-
- private void unlock(List<EEFEditorSettings> allSettings) {
- for (EEFEditorSettings eefEditorSettings : allSettings) {
- if (eefEditorSettings instanceof EEFEditorSettingsImpl) {
- EObject significantObject = ((EEFEditorSettingsImpl) eefEditorSettings)
- .getSignificantObject();
- if (significantObject != null) {
- unlock(significantObject);
- }
- }
- }
- }
-
- private void unlock(EObject eObject) {
- if (eObject != null) {
- CDOObject cdoObject = CDOUtil.getCDOObject(eObject);
- if (cdoObject != null && cdoObject.cdoView() instanceof CDOTransaction) {
- if (!CDOLockStrategyProviderService.getInstance().getProviders()
- .isEmpty()) {
- for (ICDOLockStrategyProvider provider : CDOLockStrategyProviderService.getInstance().getProviders()) {
- provider.release(cdoObject);
- }
- } else if (cdoObject.cdoWriteLock() != null) {
- cdoObject.cdoWriteLock().unlock();
- }
- }
- }
- }
-
- /**
- * (non-Javadoc)
- *
- * @see org.eclipse.emf.eef.runtime.policies.ILockPolicy#release(org.eclipse.emf.eef.runtime.api.component.IPropertiesEditionComponent)
- */
- public void release(IPropertiesEditionComponent propertiesEditingComponent) {
- unlock(propertiesEditingComponent.getEditingContext().getEObject());
- if (propertiesEditingComponent instanceof SinglePartPropertiesEditingComponent && ((SinglePartPropertiesEditingComponent) propertiesEditingComponent).getEditingPart() instanceof CompositePropertiesEditionPart) {
- unlock(((CompositePropertiesEditionPart) ((SinglePartPropertiesEditingComponent) propertiesEditingComponent).getEditingPart()).getSettings());
- }
- }
-
-}
+/*******************************************************************************
+ * Copyright (c) 2012 Obeo.
+ * 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:
+ * Obeo - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.emf.eef.cdo.runtime.policies;
+
+import java.util.List;
+
+import org.eclipse.emf.cdo.CDOObject;
+import org.eclipse.emf.cdo.eresource.CDOResource;
+import org.eclipse.emf.cdo.transaction.CDOTransaction;
+import org.eclipse.emf.cdo.util.CDOUtil;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.eef.cdo.runtime.provider.ICDOLockStrategyProvider;
+import org.eclipse.emf.eef.cdo.runtime.service.CDOLockStrategyProviderService;
+import org.eclipse.emf.eef.runtime.api.component.IPropertiesEditionComponent;
+import org.eclipse.emf.eef.runtime.impl.components.SinglePartPropertiesEditingComponent;
+import org.eclipse.emf.eef.runtime.impl.parts.CompositePropertiesEditionPart;
+import org.eclipse.emf.eef.runtime.policies.ILockPolicy;
+import org.eclipse.emf.eef.runtime.ui.widgets.settings.EEFEditorSettings;
+import org.eclipse.emf.eef.runtime.ui.widgets.settings.EEFEditorSettingsBuilder.EEFEditorSettingsImpl;
+import org.eclipse.emf.spi.cdo.FSMUtil;
+
+/**
+ * Lock policy for EEF wizard : lock the semantic elements and its EEFEditorSettings for SmartModelNavigation.
+ *
+ * @author <a href="mailto:nathalie.lepine@obeo.fr">Nathalie Lepine</a>
+ *
+ */
+public class EEFWizardLockPolicy implements ILockPolicy {
+
+ /**
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.emf.eef.runtime.policies.ILockPolicy#lock(org.eclipse.emf.eef.runtime.api.component.IPropertiesEditionComponent)
+ */
+ public void lock(IPropertiesEditionComponent propertiesEditingComponent) {
+ lock(propertiesEditingComponent.getEditingContext().getEObject());
+ if (propertiesEditingComponent instanceof SinglePartPropertiesEditingComponent && ((SinglePartPropertiesEditingComponent) propertiesEditingComponent).getEditingPart() instanceof CompositePropertiesEditionPart) {
+ lock(((CompositePropertiesEditionPart) ((SinglePartPropertiesEditingComponent) propertiesEditingComponent).getEditingPart()).getSettings());
+ }
+
+ }
+
+ private void lock(List<EEFEditorSettings> allSettings) {
+ for (EEFEditorSettings eefEditorSettings : allSettings) {
+ if (eefEditorSettings instanceof EEFEditorSettingsImpl) {
+ EObject significantObject = ((EEFEditorSettingsImpl) eefEditorSettings)
+ .getSignificantObject();
+ if (significantObject != null) {
+ lock(significantObject);
+ }
+ }
+ }
+ }
+
+ private void lock(EObject eObject) {
+ if (eObject != null && eObject.eResource() instanceof CDOResource) {
+ CDOObject cdoObject = CDOUtil.getCDOObject(eObject);
+ if (cdoObject != null && !FSMUtil.isTransient(cdoObject)) {
+ if (!CDOLockStrategyProviderService.getInstance().getProviders()
+ .isEmpty()) {
+ for (ICDOLockStrategyProvider provider : CDOLockStrategyProviderService.getInstance().getProviders()) {
+ provider.lock(cdoObject);
+ }
+ } else if (cdoObject.cdoWriteLock() != null) {
+ cdoObject.cdoWriteLock().tryLock();
+ }
+ }
+ }
+ }
+
+ private void unlock(List<EEFEditorSettings> allSettings) {
+ for (EEFEditorSettings eefEditorSettings : allSettings) {
+ if (eefEditorSettings instanceof EEFEditorSettingsImpl) {
+ EObject significantObject = ((EEFEditorSettingsImpl) eefEditorSettings)
+ .getSignificantObject();
+ if (significantObject != null) {
+ unlock(significantObject);
+ }
+ }
+ }
+ }
+
+ private void unlock(EObject eObject) {
+ if (eObject != null && eObject.eResource() instanceof CDOResource) {
+ CDOObject cdoObject = CDOUtil.getCDOObject(eObject);
+ if (cdoObject != null && !FSMUtil.isTransient(cdoObject) && cdoObject.cdoView() instanceof CDOTransaction) {
+ if (!CDOLockStrategyProviderService.getInstance().getProviders()
+ .isEmpty()) {
+ for (ICDOLockStrategyProvider provider : CDOLockStrategyProviderService.getInstance().getProviders()) {
+ provider.release(cdoObject);
+ }
+ } else if (cdoObject.cdoWriteLock() != null) {
+ cdoObject.cdoWriteLock().unlock();
+ }
+ }
+ }
+ }
+
+ /**
+ * (non-Javadoc)
+ *
+ * @see org.eclipse.emf.eef.runtime.policies.ILockPolicy#release(org.eclipse.emf.eef.runtime.api.component.IPropertiesEditionComponent)
+ */
+ public void release(IPropertiesEditionComponent propertiesEditingComponent) {
+ unlock(propertiesEditingComponent.getEditingContext().getEObject());
+ if (propertiesEditingComponent instanceof SinglePartPropertiesEditingComponent && ((SinglePartPropertiesEditingComponent) propertiesEditingComponent).getEditingPart() instanceof CompositePropertiesEditionPart) {
+ unlock(((CompositePropertiesEditionPart) ((SinglePartPropertiesEditingComponent) propertiesEditingComponent).getEditingPart()).getSettings());
+ }
+ }
+
+} \ No newline at end of file

Back to the top