-
Notifications
You must be signed in to change notification settings - Fork 85
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[2177] Disable editing of properties for a lib with read-only access
Bug 2177 Conflicts: core/plugins/org.polarsys.capella.core.model.handler/META-INF/MANIFEST.MF Change-Id: I4cea31a10d06f85fd7db6603d9d471222931d001 Signed-off-by: Ali Akar <ali.akar82@gmail.com>
- Loading branch information
Showing
8 changed files
with
296 additions
and
152 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
57 changes: 57 additions & 0 deletions
57
...ries/src/org/polarsys/capella/core/libraries/provider/LibAwareReadOnlySectionHandler.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2018 THALES GLOBAL SERVICES. | ||
* 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: | ||
* Thales - initial API and implementation | ||
*******************************************************************************/ | ||
package org.polarsys.capella.core.libraries.provider; | ||
|
||
import org.eclipse.emf.ecore.EObject; | ||
import org.eclipse.emf.transaction.TransactionalEditingDomain; | ||
import org.eclipse.emf.transaction.util.TransactionUtil; | ||
import org.polarsys.capella.common.libraries.AccessPolicy; | ||
import org.polarsys.capella.common.libraries.ILibraryManager; | ||
import org.polarsys.capella.common.libraries.IModel; | ||
import org.polarsys.capella.core.model.handler.provider.IReadOnlyListener; | ||
import org.polarsys.capella.core.model.handler.provider.IReadOnlySectionHandler; | ||
|
||
/** | ||
* This implementation of the {@link IReadOnlySectionHandler} is aware about access policy of elements inside libraries. | ||
* It's contributed to disable sections for elements of with read-only access policy. | ||
* | ||
*/ | ||
public class LibAwareReadOnlySectionHandler implements IReadOnlySectionHandler { | ||
|
||
@Override | ||
public void register(EObject semanticElement, IReadOnlyListener listener) { | ||
// Do nothing | ||
} | ||
|
||
@Override | ||
public void unregister(EObject semanticElement, IReadOnlyListener listener) { | ||
// Do nothing | ||
} | ||
|
||
@Override | ||
public boolean isLockedByOthers(EObject semanticElement) { | ||
TransactionalEditingDomain domain = TransactionUtil.getEditingDomain(semanticElement); | ||
if(domain != null) { | ||
return isLockedByOthers(ILibraryManager.INSTANCE.getModel(domain), ILibraryManager.INSTANCE.getModel(semanticElement)); | ||
} | ||
return false; | ||
} | ||
|
||
private boolean isLockedByOthers(IModel domainModel, IModel elementModel) { | ||
return domainModel != null && elementModel != null ? domainModel.getAccess(elementModel) == AccessPolicy.READ_ONLY : false; | ||
} | ||
|
||
@Override | ||
public boolean isControllable(EObject semanticElement) { | ||
TransactionalEditingDomain domain = TransactionUtil.getEditingDomain(semanticElement); | ||
return domain != null ? domain.isControllable(semanticElement) : false; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
235 changes: 117 additions & 118 deletions
235
core/plugins/org.polarsys.capella.core.model.handler/schema/readOnlySectionHandler.exsd
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,118 +1,117 @@ | ||
<?xml version='1.0' encoding='UTF-8'?> | ||
<!-- Schema file written by PDE --> | ||
<schema targetNamespace="org.polarsys.capella.core.model.handler" xmlns="http://www.w3.org/2001/XMLSchema"> | ||
<annotation> | ||
<appInfo> | ||
<meta.schema plugin="org.polarsys.capella.core.model.handler" id="readOnlySectionHandler" name="Read Only Section Handler"/> | ||
</appInfo> | ||
<documentation> | ||
Read Only section handler. | ||
This extension mustbe contributed only once. | ||
</documentation> | ||
</annotation> | ||
|
||
<element name="extension"> | ||
<annotation> | ||
<appInfo> | ||
<meta.element /> | ||
</appInfo> | ||
</annotation> | ||
<complexType> | ||
<sequence> | ||
<element ref="readOnlySectionHandler"/> | ||
</sequence> | ||
<attribute name="point" type="string" use="required"> | ||
<annotation> | ||
<documentation> | ||
|
||
</documentation> | ||
</annotation> | ||
</attribute> | ||
<attribute name="id" type="string"> | ||
<annotation> | ||
<documentation> | ||
|
||
</documentation> | ||
</annotation> | ||
</attribute> | ||
<attribute name="name" type="string"> | ||
<annotation> | ||
<documentation> | ||
|
||
</documentation> | ||
<appInfo> | ||
<meta.attribute translatable="true"/> | ||
</appInfo> | ||
</annotation> | ||
</attribute> | ||
</complexType> | ||
</element> | ||
|
||
<element name="readOnlySectionHandler"> | ||
<complexType> | ||
<attribute name="class" type="string" use="required"> | ||
<annotation> | ||
<documentation> | ||
Must be contributed only once. | ||
</documentation> | ||
<appInfo> | ||
<meta.attribute kind="java" basedOn=":org.polarsys.capella.core.model.handler.provider.IReadOnlySectionHandler"/> | ||
</appInfo> | ||
</annotation> | ||
</attribute> | ||
</complexType> | ||
</element> | ||
|
||
<annotation> | ||
<appInfo> | ||
<meta.section type="since"/> | ||
</appInfo> | ||
<documentation> | ||
[Enter the first release in which this extension point appears.] | ||
</documentation> | ||
</annotation> | ||
|
||
<annotation> | ||
<appInfo> | ||
<meta.section type="examples"/> | ||
</appInfo> | ||
<documentation> | ||
[Enter extension point usage example here.] | ||
</documentation> | ||
</annotation> | ||
|
||
<annotation> | ||
<appInfo> | ||
<meta.section type="apiinfo"/> | ||
</appInfo> | ||
<documentation> | ||
[Enter API information here.] | ||
</documentation> | ||
</annotation> | ||
|
||
<annotation> | ||
<appInfo> | ||
<meta.section type="implementation"/> | ||
</appInfo> | ||
<documentation> | ||
[Enter information about supplied implementation of this extension point.] | ||
</documentation> | ||
</annotation> | ||
|
||
<annotation> | ||
<appInfo> | ||
<meta.section type="copyright"/> | ||
</appInfo> | ||
<documentation> | ||
Copyright (c) 2006, 2014 THALES GLOBAL SERVICES. | ||
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: | ||
Thales - initial API and implementation | ||
</documentation> | ||
</annotation> | ||
|
||
</schema> | ||
<?xml version='1.0' encoding='UTF-8'?> | ||
<!-- Schema file written by PDE --> | ||
<schema targetNamespace="org.polarsys.capella.core.model.handler" xmlns="http://www.w3.org/2001/XMLSchema"> | ||
<annotation> | ||
<appInfo> | ||
<meta.schema plugin="org.polarsys.capella.core.model.handler" id="readOnlySectionHandler" name="Read Only Section Handler"/> | ||
</appInfo> | ||
<documentation> | ||
Read Only section handler. | ||
</documentation> | ||
</annotation> | ||
|
||
<element name="extension"> | ||
<annotation> | ||
<appInfo> | ||
<meta.element /> | ||
</appInfo> | ||
</annotation> | ||
<complexType> | ||
<sequence> | ||
<element ref="readOnlySectionHandler"/> | ||
</sequence> | ||
<attribute name="point" type="string" use="required"> | ||
<annotation> | ||
<documentation> | ||
|
||
</documentation> | ||
</annotation> | ||
</attribute> | ||
<attribute name="id" type="string"> | ||
<annotation> | ||
<documentation> | ||
|
||
</documentation> | ||
</annotation> | ||
</attribute> | ||
<attribute name="name" type="string"> | ||
<annotation> | ||
<documentation> | ||
|
||
</documentation> | ||
<appInfo> | ||
<meta.attribute translatable="true"/> | ||
</appInfo> | ||
</annotation> | ||
</attribute> | ||
</complexType> | ||
</element> | ||
|
||
<element name="readOnlySectionHandler"> | ||
<complexType> | ||
<attribute name="class" type="string" use="required"> | ||
<annotation> | ||
<documentation> | ||
Must be contributed only once. | ||
</documentation> | ||
<appInfo> | ||
<meta.attribute kind="java" basedOn=":org.polarsys.capella.core.model.handler.provider.IReadOnlySectionHandler"/> | ||
</appInfo> | ||
</annotation> | ||
</attribute> | ||
</complexType> | ||
</element> | ||
|
||
<annotation> | ||
<appInfo> | ||
<meta.section type="since"/> | ||
</appInfo> | ||
<documentation> | ||
[Enter the first release in which this extension point appears.] | ||
</documentation> | ||
</annotation> | ||
|
||
<annotation> | ||
<appInfo> | ||
<meta.section type="examples"/> | ||
</appInfo> | ||
<documentation> | ||
[Enter extension point usage example here.] | ||
</documentation> | ||
</annotation> | ||
|
||
<annotation> | ||
<appInfo> | ||
<meta.section type="apiinfo"/> | ||
</appInfo> | ||
<documentation> | ||
[Enter API information here.] | ||
</documentation> | ||
</annotation> | ||
|
||
<annotation> | ||
<appInfo> | ||
<meta.section type="implementation"/> | ||
</appInfo> | ||
<documentation> | ||
[Enter information about supplied implementation of this extension point.] | ||
</documentation> | ||
</annotation> | ||
|
||
<annotation> | ||
<appInfo> | ||
<meta.section type="copyright"/> | ||
</appInfo> | ||
<documentation> | ||
Copyright (c) 2006, 2014 THALES GLOBAL SERVICES. | ||
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: | ||
Thales - initial API and implementation | ||
</documentation> | ||
</annotation> | ||
|
||
</schema> |
Oops, something went wrong.