Commit 6966477c authored by Simon Barner's avatar Simon Barner
Browse files

Update tabbed property sheet title when edited input is changed

* PropertySectionBase: Register (non-recursive) EMF notification adapter
* NamedCommentedPropertySection: special case due to input "retargeting"

Issue-Ref: 3470
Issue-Url: https://af3-developer.fortiss.org/issues/3470

Signed-off-by: Simon Barner's avatarSimon Barner <barner@fortiss.org>
parent 52d56c82
......@@ -10,7 +10,7 @@ ModelEditorBindingBase.java 4c5ac569c0b6e7678fc8191096b26dfd09fdcb98 GREEN
ModelElementHandlerBase.java 384727748f125c9d43f19d9c0eba4ba1be5a7a26 GREEN
MultiEObjectActionBase.java 9e237d8ea640c4194e4877af4a9cfce88698e543 GREEN
NamedCommentedModelElementHandlerBase.java 681b98b50b362f01abb7a36f108f4f11b9e51829 GREEN
PropertySectionBase.java 8a0c90a7657fb93695d50f570ff8043cf7bb8602 YELLOW
PropertySectionBase.java c061c62531621d96b1e1d1c27ad99889c92bacb7 YELLOW
TutorialStepUIAtomicBase.java cea2a158158b476de2108d2309afcf47f217b6d9 GREEN
TutorialStepUIAtomicWithWhitelistBase.java a9788ae514f62d27169c737ef59fb583234b5d43 GREEN
TutorialStepUICompositeBase.java 8225210eacb5b88de47d78280c5819f572f00ffa GREEN
......
......@@ -32,6 +32,9 @@ import org.conqat.ide.commons.ui.databinding.validate.TextToDoubleValidator;
import org.conqat.ide.commons.ui.databinding.validate.TextToIntegerValidator;
import org.eclipse.core.databinding.observable.value.IObservableValue;
import org.eclipse.core.databinding.validation.IValidator;
import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.Notifier;
import org.eclipse.emf.common.notify.impl.AdapterImpl;
import org.eclipse.emf.databinding.EMFDataBindingContext;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.gef.EditPart;
......@@ -66,6 +69,26 @@ import com.ibm.icu.text.NumberFormat;
*/
public abstract class PropertySectionBase extends AbstractPropertySection {
/** Adapter to synchronize property sheet title. */
private final class TitleSyncAdapter extends AdapterImpl {
/** {@inheritDoc} */
@Override
public void notifyChanged(org.eclipse.emf.common.notify.Notification msg) {
if(msg.getEventType() != Notification.REMOVING_ADAPTER) {
// Updates the tabbed property sheets title
tabbedPropertySheetPage.labelProviderChanged(null);
}
}
/** Removes itself. */
public void remove() {
Notifier target = getTarget();
if(target != null) {
target.eAdapters().remove(this);
}
}
}
/** Label width. */
public static final int PROPERTIES_LABEL_WIDTH = 150;
......@@ -75,10 +98,17 @@ public abstract class PropertySectionBase extends AbstractPropertySection {
/** Stores the data binding context used. */
protected EMFDataBindingContext dbc = new EMFDataBindingContext();
/** Underlying {@link TabbedPropertySheetPage}. */
private TabbedPropertySheetPage tabbedPropertySheetPage;
/** Adapter to synchronize property sheet title. */
private TitleSyncAdapter titleSyncAdapter = new TitleSyncAdapter();
/** {@inheritDoc} */
@Override
public void createControls(Composite parent, TabbedPropertySheetPage tabbedPropertySheetPage) {
super.createControls(parent, tabbedPropertySheetPage);
this.tabbedPropertySheetPage = tabbedPropertySheetPage;
composite = getWidgetFactory().createFlatFormComposite(parent);
composite.setLayout(new GridLayout(2, false));
......@@ -112,11 +142,23 @@ public abstract class PropertySectionBase extends AbstractPropertySection {
if(object instanceof EditPart) {
object = ((EditPart)object).getModel();
}
if(object instanceof EObject) {
addTitleSyncAdapter((EObject)object);
}
disableControlsForLibraryReferences(object);
setSectionInput(object);
}
/**
* Adds the {@link #titleSyncAdapter} to the given {@link EObject}, and undoes any
* possible previous registration.
*/
protected void addTitleSyncAdapter(EObject eObj) {
titleSyncAdapter.remove();
eObj.eAdapters().add(titleSyncAdapter);
}
/**
* Disables the graphical controls in the case we are in an {@link ILibraryElementReference}.
*/
......
IdLabeledPropertySection.java dcfb39d225391c87f47e29f6d1ba1cb22a3d3fe4 GREEN
NamedCommentedPropertySection.java d15d490708e5c7362ebc4f30a04bccb0f6b64f39 GREEN
NamedCommentedPropertySection.java d4fab618eca361f132b1baafecd66ad8f7919dfa YELLOW
PropertiesAdapterFactory.java edcf34766a60f21c9ba22a1ba73aa487c3d9a946 GREEN
......@@ -67,14 +67,15 @@ public class NamedCommentedPropertySection extends PropertySectionBase {
protected void setSectionInput(Object input) {
namedCommented = (INamedCommentedElement)input;
// do section retargeting
IModelElementHandler<EObject> handler =
IModelElementHandlerService.getInstance().getModelElementHandler(namedCommented);
// "Re-target" section
IModelElementHandlerService hs = IModelElementHandlerService.getInstance();
IModelElementHandler<EObject> handler = hs.getModelElementHandler(namedCommented);
if(handler != null) {
EObject retarget = handler.getPropertySectionRetargetElement(namedCommented);
if(retarget instanceof INamedCommentedElement) {
namedCommented = (INamedCommentedElement)retarget;
}
addTitleSyncAdapter(namedCommented);
}
}
......
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