Commit 1ea0f5ad authored by Florian Hölzl's avatar Florian Hölzl

Kernel: DynamicTreeTableUIProvider added selection change propagation.

Issue-Ref: 3907
Issue-Url: https://af3-developer.fortiss.org/issues/3907Signed-off-by: Florian Hölzl's avatarFlorian Hoelzl <hoelzl@fortiss.org>
parent c997c70d
DynamicTreeContentProviderBase.java dff437afeaf7486af05460fa54eca4fa61d7eae6 GREEN
DynamicTreeItem.java afc105cf5acf3d2506d89e0892555100c234ce5b GREEN
DynamicTreeTableUIProviderBase.java 5f0c418cfc157738be079e21933429ff892b00eb YELLOW
DynamicTreeTableViewer.java 4eb55f9b0b0bb3c9198fe192d43f3bcb29643f12 YELLOW
DynamicTreeTableUIProviderBase.java 7bfc1395283d3dc10026aff5e2e65df88d25f3a7 YELLOW
DynamicTreeTableViewer.java 41bfddb704b5fd7ba546d574103ad01192072d2a YELLOW
DynamicTreeUIProviderBase.java 56fe4df4577b35f1e5e6e4c4be189b706c852d52 GREEN
DynamicTreeViewer.java da5e24ae57777a482d8e12c8262513d8143bfa93 GREEN
DynamicTreeViewerBase.java 47124c847de322a0ae26eb7a114f85ce4bd02d7e GREEN
......
......@@ -84,6 +84,19 @@ public abstract class DynamicTreeTableUIProviderBase<T> {
// ignored, since not editable
}
/**
* Notifies the provider about the selection of the given new value (and the deselection of the
* given old value.
*
* @param oldValue
* unselected value
* @param newValue
* the selected value
*/
public void select(T oldValue, T newValue) {
// ignored
}
/** Applies the editing support to the given column. */
/* package */ final void applyToColumn(int i, TreeTableColumn<T, String> column) {
if(!isEditable(i)) {
......
......@@ -20,6 +20,7 @@ import javafx.scene.control.SelectionMode;
import javafx.scene.control.TreeItem;
import javafx.scene.control.TreeTableColumn;
import javafx.scene.control.TreeTableView;
import javafx.scene.control.TreeTableView.TreeTableViewSelectionModel;
/**
* A JavaFX {@link TreeTableView} based on an {@link DynamicTreeContentProviderBase},
......@@ -51,7 +52,14 @@ public final class DynamicTreeTableViewer<T> extends DynamicTreeViewerBase<T> {
view.setRoot(rootItem);
view.setShowRoot(showRoot);
view.setEditable(true);
view.getSelectionModel().setSelectionMode(SelectionMode.MULTIPLE);
TreeTableViewSelectionModel<T> selectionModel = view.getSelectionModel();
selectionModel.setSelectionMode(SelectionMode.MULTIPLE);
selectionModel.selectedItemProperty().addListener((obs, oVal, nVal) -> {
T ov = (oVal != null) ? oVal.getValue() : null;
T nv = (nVal != null) ? nVal.getValue() : null;
uiProvider.select(ov, nv);
});
rootItem.update();
// expand to reveal (+1 if root node is not shown
expandItem(rootItem, showRoot ? revealLevel : revealLevel + 1);
......
......@@ -4,9 +4,9 @@ EObjectActionBase.java 4ef9f8be59e64d4838acc9e268d418ba5d94fa1a GREEN
EReferenceListPropertySectionBase.java 7390dd7bfdc979e8ff0c5c30c67ab7b6c9d70c92 GREEN
EReferencePropertySectionBase.java 0548da6778516003257f59d0b4c2b60d458be3b6 GREEN
EditorBase.java 9c09fff92945256bb8680992ae7bb2c78f47b150 GREEN
FXEditorBase.java 2e520be0bbae7d0aebdff70218a124dbe0896ce2 GREEN
FXEditorBase.java 545085c3270f09d69b609f328792e904ebda23ff YELLOW
IListPropertySection.java 8bb00fe7959583e794ff9437b7a77404c9a9e70f GREEN
LWFXEFEditorBase.java 2bd06235f20c18dc2e7d433700b2ad74a16664e2 GREEN
LWFXEFEditorBase.java 3a6df817142f5edf2bf45b58df9a9626be6c0c4d YELLOW
ModelEditorBindingBase.java c258cb0ea28d74440856cd2abf367408fbbc1279 GREEN
ModelElementHandlerBase.java d08583ffdf78938a14caeb46124eda4ce5cac3e4 YELLOW
MultiEObjectActionBase.java 9e237d8ea640c4194e4877af4a9cfce88698e543 GREEN
......
......@@ -15,7 +15,15 @@
+--------------------------------------------------------------------------*/
package org.fortiss.tooling.kernel.ui.extension.base;
import java.util.ArrayList;
import java.util.List;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.ISelectionChangedListener;
import org.eclipse.jface.viewers.ISelectionProvider;
import org.eclipse.jface.viewers.SelectionChangedEvent;
import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Composite;
......@@ -28,15 +36,50 @@ import javafx.scene.Scene;
*
* @author hoelzlf
*/
public abstract class FXEditorBase<T extends EObject> extends EditorBase<T> {
public abstract class FXEditorBase<T extends EObject> extends EditorBase<T>
implements ISelectionProvider {
/** The list of {@link ISelectionChangedListener}s. */
private final List<ISelectionChangedListener> selectionListeners = new ArrayList<>();
/** {@inheritDoc} */
@Override
public final void createPartControl(Composite parent) {
FXCanvas canvas = new FXCanvas(parent, SWT.NONE);
Scene scene = new Scene(createSceneRoot());
canvas.setScene(scene);
getSite().setSelectionProvider(this);
}
/** Creates the root node of the scene. */
protected abstract Parent createSceneRoot();
/** {@inheritDoc} */
@Override
public final void addSelectionChangedListener(ISelectionChangedListener listener) {
if(!selectionListeners.contains(listener)) {
selectionListeners.add(listener);
}
}
/** {@inheritDoc} */
@Override
public final void removeSelectionChangedListener(ISelectionChangedListener listener) {
selectionListeners.remove(listener);
}
/** {@inheritDoc} */
@Override
public final void setSelection(ISelection selection) {
SelectionChangedEvent evt = new SelectionChangedEvent(this, selection);
for(ISelectionChangedListener scl : selectionListeners) {
scl.selectionChanged(evt);
}
}
/** {@inheritDoc} */
@Override
public ISelection getSelection() {
return StructuredSelection.EMPTY;
}
}
......@@ -23,10 +23,7 @@ import java.util.Objects;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.ISelectionChangedListener;
import org.eclipse.jface.viewers.ISelectionProvider;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.SelectionChangedEvent;
import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.systemfocus.kernel.common.ui.javafx.lwfxef.DiagramViewer;
import org.eclipse.systemfocus.kernel.common.ui.javafx.lwfxef.DiagramViewerSelection;
......@@ -51,12 +48,9 @@ import javafx.scene.Parent;
* @author hoelzl
* @author diewald
*/
public abstract class LWFXEFEditorBase<T extends EObject> extends FXEditorBase<T>
implements ISelectionProvider {
public abstract class LWFXEFEditorBase<T extends EObject> extends FXEditorBase<T> {
/** The diagram viewer. */
protected DiagramViewer viewer;
/** The list of {@link ISelectionChangedListener}s. */
private final List<ISelectionChangedListener> selectionListeners = new ArrayList<>();
/** References the delegating {@link IModelFactory} of this JavaFX {@link IEditorPart}. */
private IModelFactory delegatingModelFactory;
......@@ -75,7 +69,6 @@ public abstract class LWFXEFEditorBase<T extends EObject> extends FXEditorBase<T
viewer = new DiagramViewer(delegatingModelFactory, delegatingVisualFactory,
delegatingControllerFactory, cb -> modelSelected(), chg -> applyModelChange(chg));
customizeViewer();
getSite().setSelectionProvider(this);
return viewer.getVisualNode();
}
......@@ -117,29 +110,6 @@ public abstract class LWFXEFEditorBase<T extends EObject> extends FXEditorBase<T
ICommandStackService.getInstance().runAsCommand(editedObject, () -> chg.applyChange());
}
/** {@inheritDoc} */
@Override
public void addSelectionChangedListener(ISelectionChangedListener listener) {
if(!selectionListeners.contains(listener)) {
selectionListeners.add(listener);
}
}
/** {@inheritDoc} */
@Override
public void removeSelectionChangedListener(ISelectionChangedListener listener) {
selectionListeners.remove(listener);
}
/** {@inheritDoc} */
@Override
public void setSelection(ISelection selection) {
SelectionChangedEvent evt = new SelectionChangedEvent(this, selection);
for(ISelectionChangedListener scl : selectionListeners) {
scl.selectionChanged(evt);
}
}
/** {@inheritDoc} */
@Override
public ISelection getSelection() {
......
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