Commit fbb025a5 authored by Adrien's avatar Adrien Committed by GitHub
Browse files

feat(access control) switch to an emf model for the whole access control feature (#761)

* refactor ExternalResourcesChangeListener
use IFormPart to handle form lifecycle for dirty state

* feat(access control) switch to an emf model for the whole access control
feature

* implementation of converters to switch between engine and emf model
* better management of the dirty state because of the emf model
* improve dev validation (unknown elements, duplication ..)
* implementation of comparators according to emf classes for all the
viewers

closes [BS-17359](https://bonitasoft.atlassian.net/browse/BS-17359)
parent 41f4115d
/*******************************************************************************
* Copyright (C) 2017 BonitaSoft S.A.
* BonitaSoft is a trademark of BonitaSoft SA.
* This software file is BONITASOFT CONFIDENTIAL. Not For Distribution.
* For commercial licensing information, contact:
* BonitaSoft, 32 rue Gustave Eiffel 38000 Grenoble
* or BonitaSoft US, 51 Federal Street, Suite 305, San Francisco, CA 94107
*******************************************************************************/
package org.bonitasoft.studio.ui.databinding;
import org.eclipse.core.databinding.UpdateListStrategy;
import org.eclipse.core.databinding.conversion.IConverter;
public class UpdateListStrategyFactory {
private final UpdateListStrategy updateListStrategy;
public UpdateListStrategyFactory(final int updatePolicy) {
updateListStrategy = new UpdateListStrategy(updatePolicy);
}
public UpdateListStrategyFactory withConverter(final IConverter converter) {
updateListStrategy.setConverter(converter);
return this;
}
public UpdateListStrategy create() {
return updateListStrategy;
}
}
...@@ -14,6 +14,7 @@ ...@@ -14,6 +14,7 @@
*/ */
package org.bonitasoft.studio.ui.databinding; package org.bonitasoft.studio.ui.databinding;
import org.eclipse.core.databinding.UpdateListStrategy;
import org.eclipse.core.databinding.UpdateSetStrategy; import org.eclipse.core.databinding.UpdateSetStrategy;
import org.eclipse.core.databinding.UpdateValueStrategy; import org.eclipse.core.databinding.UpdateValueStrategy;
...@@ -42,4 +43,12 @@ public class UpdateStrategyFactory { ...@@ -42,4 +43,12 @@ public class UpdateStrategyFactory {
public static UpdateValueStrategyFactory convertUpdateValueStrategy() { public static UpdateValueStrategyFactory convertUpdateValueStrategy() {
return new UpdateValueStrategyFactory(UpdateValueStrategy.POLICY_CONVERT); return new UpdateValueStrategyFactory(UpdateValueStrategy.POLICY_CONVERT);
} }
public static UpdateListStrategyFactory updateListStrategyFactory() {
return new UpdateListStrategyFactory(UpdateListStrategy.POLICY_UPDATE);
}
public static UpdateListStrategyFactory neverUpdateListStrategyFactory() {
return new UpdateListStrategyFactory(UpdateListStrategy.POLICY_NEVER);
}
} }
...@@ -108,15 +108,8 @@ public abstract class AbstractFormPage<T> extends FormPage { ...@@ -108,15 +108,8 @@ public abstract class AbstractFormPage<T> extends FormPage {
scrolledForm.reflow(true); scrolledForm.reflow(true);
} }
/*
* (non-Javadoc)
* @see org.eclipse.ui.forms.editor.FormPage#setActive(boolean)
*/
@Override @Override
public void setActive(boolean active) { public void setActive(boolean active) {
if (active) {
update();
}
super.setActive(active); super.setActive(active);
} }
...@@ -146,6 +139,10 @@ public abstract class AbstractFormPage<T> extends FormPage { ...@@ -146,6 +139,10 @@ public abstract class AbstractFormPage<T> extends FormPage {
return workingCopy; return workingCopy;
} }
public void setWorkingCopy(T workingCopy) {
this.workingCopy = workingCopy;
}
public IDocument getDocument() { public IDocument getDocument() {
return document; return document;
} }
......
...@@ -158,10 +158,6 @@ public class LabelProviderBuilder<T> { ...@@ -158,10 +158,6 @@ public class LabelProviderBuilder<T> {
return super.getToolTipText(element); return super.getToolTipText(element);
} }
/*
* (non-Javadoc)
* @see org.eclipse.jface.viewers.ColumnLabelProvider#getText(java.lang.Object)
*/
@Override @Override
public String getText(Object element) { public String getText(Object element) {
try { try {
...@@ -172,10 +168,6 @@ public class LabelProviderBuilder<T> { ...@@ -172,10 +168,6 @@ public class LabelProviderBuilder<T> {
} }
} }
/*
* (non-Javadoc)
* @see org.eclipse.jface.viewers.ColumnLabelProvider#getImage(java.lang.Object)
*/
@Override @Override
public Image getImage(Object element) { public Image getImage(Object element) {
try { try {
...@@ -203,6 +195,8 @@ public class LabelProviderBuilder<T> { ...@@ -203,6 +195,8 @@ public class LabelProviderBuilder<T> {
return JFaceResources.getImage(Dialog.DLG_IMG_MESSAGE_ERROR); return JFaceResources.getImage(Dialog.DLG_IMG_MESSAGE_ERROR);
case IStatus.WARNING: case IStatus.WARNING:
return JFaceResources.getImage(Dialog.DLG_IMG_MESSAGE_WARNING); return JFaceResources.getImage(Dialog.DLG_IMG_MESSAGE_WARNING);
case IStatus.INFO:
return JFaceResources.getImage(Dialog.DLG_IMG_MESSAGE_INFO);
default: default:
return imageFunction.map(function -> function.apply(element)).orElse(super.getImage(element)); return imageFunction.map(function -> function.apply(element)).orElse(super.getImage(element));
} }
...@@ -213,10 +207,6 @@ public class LabelProviderBuilder<T> { ...@@ -213,10 +207,6 @@ public class LabelProviderBuilder<T> {
public LabelProvider createLabelProvider() { public LabelProvider createLabelProvider() {
return new LabelProvider() { return new LabelProvider() {
/*
* (non-Javadoc)
* @see org.eclipse.jface.viewers.ColumnLabelProvider#getText(java.lang.Object)
*/
@Override @Override
public String getText(Object element) { public String getText(Object element) {
try { try {
...@@ -227,10 +217,6 @@ public class LabelProviderBuilder<T> { ...@@ -227,10 +217,6 @@ public class LabelProviderBuilder<T> {
} }
} }
/*
* (non-Javadoc)
* @see org.eclipse.jface.viewers.ColumnLabelProvider#getImage(java.lang.Object)
*/
@Override @Override
public Image getImage(Object element) { public Image getImage(Object element) {
try { try {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment