Skip to content
Snippets Groups Projects
Commit 5a82ea22 authored by Florian Hölzl's avatar Florian Hölzl
Browse files

Components: JavaFX component editor.

Added model listeners and visual updates.

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


Signed-off-by: default avatarFlorian Hoelzl <hoelzl@fortiss.org>
parent 571a84af
No related branches found
No related tags found
1 merge request!743815 LWFXEditorFramework integration and FX Component Editor
......@@ -6,6 +6,7 @@ ConstraintsBaseUtils.java bba938b43756ce6f35c338f6cef21c3ab5d49a9d GREEN
DimensionUtils.java 0dc67f9de11a84e6e4c6e1eb627817dee91ff30a GREEN
EllipseLayoutUtils.java 5c3a0126fdca5d5b4fb441694747e1cb0f49cd9f GREEN
LayoutDataUtils.java 5739dd16f0212e8f94927c0a0f51503390f2be69 GREEN
LayoutModelElementAdapter.java 68acc3603acb1baede0aef02070604defe9abcf2 YELLOW
LayoutModelElementFactory.java c49fca2de5a8cb7502fb28cc2b7e64a272df11b0 GREEN
MigrationUtils.java ab9d8682233313c21c6a52b8b03e1c796aacd29c GREEN
OffsetOrientationUtils.java 913cebbac2a5628bdd08b4df669b9412d6e07d94 GREEN
......
/*-------------------------------------------------------------------------+
| Copyright 2019 fortiss GmbH |
| |
| Licensed under the Apache License, Version 2.0 (the "License"); |
| you may not use this file except in compliance with the License. |
| You may obtain a copy of the License at |
| |
| http://www.apache.org/licenses/LICENSE-2.0 |
| |
| Unless required by applicable law or agreed to in writing, software |
| distributed under the License is distributed on an "AS IS" BASIS, |
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| See the License for the specific language governing permissions and |
| limitations under the License. |
+--------------------------------------------------------------------------*/
package org.fortiss.tooling.base.utils;
import static java.util.Objects.requireNonNull;
import static org.fortiss.tooling.base.model.layout.LayoutPackage.ILAYOUTED_MODEL_ELEMENT__LAYOUT_DATA;
import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.ecore.EAttribute;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.util.EContentAdapter;
import org.fortiss.tooling.base.model.layout.ILayoutData;
import org.fortiss.tooling.base.model.layout.ILayoutedModelElement;
import org.fortiss.tooling.base.model.layout.LayoutPackage;
/**
* A specific {@link EContentAdapter} used for layouted model elements and layout data.
*
* @author hoelzl
*/
public class LayoutModelElementAdapter extends EContentAdapter {
/** The layouted model element. */
private final ILayoutedModelElement modelElement;
/** Constructor. */
public LayoutModelElementAdapter(ILayoutedModelElement layouted) {
this.modelElement = requireNonNull(layouted);
modelElement.eAdapters().add(this);
}
/** Removes this adapter from the underlying model element. */
public void unregisterAdapter() {
modelElement.eAdapters().remove(this);
}
/** {@inheritDoc} */
@Override
public void notifyChanged(Notification notification) {
Object notifier = notification.getNotifier();
if(notifier == modelElement) {
Object feature = notification.getFeature();
if(feature instanceof EAttribute) {
attributeChanged(notification);
// no selfAdapt needed for attributes
return;
}
if(feature == LayoutPackage.Literals.ILAYOUTED_MODEL_ELEMENT__LAYOUT_DATA) {
super.notifyChanged(notification);
layoutChanged(notification);
return;
}
} else if(notifier instanceof ILayoutData) {
super.notifyChanged(notification);
layoutChanged(notification);
return;
}
// prevent self-adapt for all other cases
}
/**
* Called when an attribute of the layouted model element receives the given notification.
*
* @param notification
* the notification
*/
protected void attributeChanged(Notification notification) {
// default does nothing
}
/**
* Called when layout data of the layouted model element receives the given notification.
*
* @param notification
* the notification
*/
protected void layoutChanged(Notification notification) {
// default does nothing
}
/** {@inheritDoc} */
@Override
protected void selfAdapt(Notification notification) {
// ignore resources and resource sets
if(notification.getNotifier() instanceof EObject) {
super.selfAdapt(notification);
}
}
/** {@inheritDoc} */
@Override
protected void handleContainment(Notification notification) {
if(notification.getNotifier() instanceof ILayoutData) {
super.handleContainment(notification);
return;
}
Class<?> instanceClass = LayoutPackage.Literals.ILAYOUTED_MODEL_ELEMENT.getInstanceClass();
if(notification.getFeatureID(instanceClass) == ILAYOUTED_MODEL_ELEMENT__LAYOUT_DATA) {
super.handleContainment(notification);
}
}
}
......@@ -7,7 +7,7 @@ EReferencePropertySectionBase.java 0548da6778516003257f59d0b4c2b60d458be3b6 GREE
EditorBase.java 9c09fff92945256bb8680992ae7bb2c78f47b150 GREEN
FXEditorBase.java 2e520be0bbae7d0aebdff70218a124dbe0896ce2 YELLOW
IListPropertySection.java 8bb00fe7959583e794ff9437b7a77404c9a9e70f GREEN
LWFXEFEditorBase.java 5aa3971c06da012c2c2d84d5858b5f977dc6dd8b YELLOW
LWFXEFEditorBase.java 9d735ea8539b3bb829fcae258b506bd4e1a04e4e YELLOW
ModelEditorBindingBase.java 4c5ac569c0b6e7678fc8191096b26dfd09fdcb98 GREEN
ModelElementHandlerBase.java 384727748f125c9d43f19d9c0eba4ba1be5a7a26 GREEN
MultiEObjectActionBase.java 9e237d8ea640c4194e4877af4a9cfce88698e543 GREEN
......
......@@ -17,6 +17,7 @@ package org.fortiss.tooling.kernel.ui.extension.base;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.systemfocus.kernel.common.ui.javafx.lwfxef.DiagramViewer;
import org.eclipse.systemfocus.kernel.common.ui.javafx.lwfxef.change.Change;
import org.eclipse.systemfocus.kernel.common.ui.javafx.lwfxef.controller.IControllerFactory;
import org.eclipse.systemfocus.kernel.common.ui.javafx.lwfxef.model.IModelFactory;
import org.eclipse.systemfocus.kernel.common.ui.javafx.lwfxef.visual.IVisualFactory;
......@@ -38,6 +39,8 @@ public abstract class LWFXEFEditorBase<T extends EObject> extends FXEditorBase<T
viewer = new DiagramViewer(createModelFactory(), createVisualFactory(),
createControllerFactory(), cb -> {
modelSelected(cb);
}, chg -> {
applyModelChange(chg);
});
customizeViewer();
return viewer.getVisualNode();
......@@ -59,4 +62,7 @@ public abstract class LWFXEFEditorBase<T extends EObject> extends FXEditorBase<T
/** Called when a model element is selected in the diagram viewer. */
protected abstract void modelSelected(Object model);
/** Called when some change to the model happens. */
protected abstract void applyModelChange(Change chg);
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment