Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • af3/kernel
  • diewald/kernel
2 results
Show changes
Commits on Source (38)
Showing
with 328 additions and 46 deletions
ModelElementTreeViewer.java 9c7637313b0ce4d70566ebb4f90dfca0d9931d09 GREEN
DynamicTreeTableNameProvider.java 3ca45f24b94e97b02313e80b16ba8b370f541541 GREEN
ModelElementTreeViewer.java b541376d1b21d38dec80ae6dd5357fe289dcb643 GREEN
/*-------------------------------------------------------------------------+
| Copyright 2016 fortiss GmbH |
| Copyright 2020 fortiss GmbH |
| |
| Licensed under the Apache License, Version 2.0 (the "License"); |
| you may not use this file except in compliance with the License. |
......@@ -13,29 +13,24 @@
| See the License for the specific language governing permissions and |
| limitations under the License. |
+--------------------------------------------------------------------------*/
package org.fortiss.tooling.kernel.ui.internal.introspection;
package org.fortiss.tooling.base.ui.javafx.control.treetableview;
import org.eclipse.jface.viewers.LabelProvider;
import org.eclipse.swt.graphics.Image;
import org.fortiss.tooling.kernel.introspection.IIntrospectionItem;
import org.fortiss.tooling.common.ui.javafx.control.treetableview.DynamicTreeTableUIProviderBase;
import org.fortiss.tooling.kernel.model.INamedElement;
/**
* Label provider for the tree viewer of the {@link KISSViewPart}.
* Extensible {@link DynamicTreeTableUIProviderBase} providing the names of elements in the first
* column.
*
* @author hoelzl
* @author diewald
*/
final class KISSViewerLabelProvider extends LabelProvider {
public class DynamicTreeTableNameProvider<T extends INamedElement>
extends DynamicTreeTableUIProviderBase<T> {
/** {@inheritDoc} */
@Override
public Image getImage(Object element) {
return null;
}
/** {@inheritDoc} */
@Override
public String getText(Object element) {
if(element instanceof IIntrospectionItem) {
return ((IIntrospectionItem)element).getIntrospectionLabel();
public String getLabel(T element, int column) {
if(column == 0) {
return element.getName();
}
return null;
}
......
......@@ -25,7 +25,7 @@ import org.fortiss.tooling.base.model.element.IHierarchicElement;
import org.fortiss.tooling.base.model.element.IModelElement;
import org.fortiss.tooling.common.ui.javafx.AF3FXViewPart;
import org.fortiss.tooling.common.ui.javafx.control.treetableview.DynamicTreeContentProviderBase;
import org.fortiss.tooling.common.ui.javafx.control.treetableview.DynamicTreeItem;
import org.fortiss.tooling.common.ui.javafx.control.treetableview.DynamicTreeItemBase;
import org.fortiss.tooling.common.ui.javafx.control.treetableview.DynamicTreeUIProviderBase;
import org.fortiss.tooling.common.ui.javafx.control.treetableview.DynamicTreeViewer;
import org.fortiss.tooling.kernel.model.INamedElement;
......@@ -131,7 +131,12 @@ public class ModelElementTreeViewer<T extends INamedElement> {
/** Expands the tree down to the given value. */
public void expandItem(T value) {
DynamicTreeItem<T> item = dynTreeViewer.findItem(value);
DynamicTreeItemBase<T> item = dynTreeViewer.findItem(value);
dynTreeViewer.expandItem(item);
}
/** Returns the {@link DynamicTreeItemBase} of the given {@code value} if it exists. */
public DynamicTreeItemBase<T> findItem(T value) {
return dynTreeViewer.findItem(value);
}
}
......@@ -3,6 +3,11 @@
<classpathentry kind="src" path="src"/>
<classpathentry kind="src" path="external-src"/>
<classpathentry kind="src" path="res"/>
<classpathentry exported="true" kind="lib" path="lib/controlsfx-11.0.2.jar" sourcepath="lib/controlsfx-11.0.2-sources.jar">
<attributes>
<attribute name="javadoc_location" value="jar:platform:/resource/org.fortiss.tooling.common.ui/lib/controlsfx-11.0.2-javadoc.jar!/"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-11">
<attributes>
<attribute name="module" value="true"/>
......
......@@ -24,7 +24,8 @@ Require-Bundle: org.fortiss.tooling.common;visibility:=reexport,
Bundle-ClassPath: .,
lib/org.conqat.ide.commons.gef.jar,
lib/org.conqat.ide.commons.ui.jar,
lib/swt-grouplayout.jar
lib/swt-grouplayout.jar,
lib/controlsfx-11.0.2.jar
Export-Package: aerofx,
aquafx,
jfxtras,
......@@ -69,6 +70,20 @@ Export-Package: aerofx,
org.conqat.ide.commons.ui.xmlmodel,
org.conqat.ide.commons.ui.xmlmodel.databinding,
org.conqat.ide.commons.ui.xmlmodel.undo,
org.controlsfx.control,
org.controlsfx.control.action,
org.controlsfx.control.cell,
org.controlsfx.control.decoration,
org.controlsfx.control.table,
org.controlsfx.control.table.model,
org.controlsfx.control.textfield,
org.controlsfx.dialog,
org.controlsfx.glyphfont,
org.controlsfx.property,
org.controlsfx.property.editor,
org.controlsfx.tools,
org.controlsfx.validation,
org.controlsfx.validation.decoration,
org.eclipse.gmf.runtime.draw2d.ui.figures,
org.eclipse.gmf.runtime.draw2d.ui.geometry,
org.eclipse.jface.viewers,
......@@ -80,7 +95,6 @@ Export-Package: aerofx,
org.fortiss.tooling.common.ui.javafx,
org.fortiss.tooling.common.ui.javafx.control.treetableview,
org.fortiss.tooling.common.ui.javafx.layout,
org.fortiss.tooling.common.ui.javafx.style,
org.fortiss.tooling.common.ui.javafx.lwfxef,
org.fortiss.tooling.common.ui.javafx.lwfxef.change,
org.fortiss.tooling.common.ui.javafx.lwfxef.controller,
......@@ -96,6 +110,7 @@ Export-Package: aerofx,
org.fortiss.tooling.common.ui.javafx.lwfxef.visual.elliptic,
org.fortiss.tooling.common.ui.javafx.lwfxef.visual.rectangular,
org.fortiss.tooling.common.ui.javafx.lwfxef.visual.widgets,
org.fortiss.tooling.common.ui.javafx.style,
org.fortiss.tooling.common.ui.javafx.util
Bundle-Vendor: fortiss GmbH
Bundle-Activator: org.fortiss.tooling.common.ui.ToolingCommonUIActivator
......
......@@ -6,7 +6,8 @@ bin.includes = .,\
lib/org.conqat.ide.commons.ui.jar,\
lib/swt-grouplayout.jar,\
res/,\
icons/
icons/,\
lib/controlsfx-11.0.2.jar
jars.compile.order = .
source.. = src/,\
res/,\
......
File added
File added
File added
License of the ControlsFX library
Copyright (c) 2013, ControlsFX
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
3. Neither the name of ControlsFX, any associated website, nor the names of its
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
AF3FXViewPart.java 3e4510f9e9f86ecf5ba29432342acd50e030aaaa GREEN
AF3FXViewPart.java af974e21c086a86134d4b2d6cdf9da1a31aea7de GREEN
......@@ -49,7 +49,7 @@ public abstract class AF3FXViewPart extends FXViewPart {
private Pane root;
/** Specifies the view part's layout and logic. */
private ICompositeFXController<? extends Node, ? extends Node> controller;
protected final ICompositeFXController<? extends Node, ? extends Node> controller;
/**
* Constructor. Allows to pass the view's FXML definition file.
......
DynamicTreeContentProviderBase.java 6760a6dc5721175b1dada8f30fd9da05f7bcc4b3 GREEN
DynamicTreeItem.java 75dc5534b119ffdb3c10a65810c2a0f330b7955e GREEN
DynamicTreeTableUIProviderBase.java f78c0f8b52fbc939166b3f94f7f6006cc0f4d32b GREEN
DynamicTreeTableViewer.java 9eb192873acf4f08ab3570c195d8828224a61934 GREEN
DynamicTreeUIProviderBase.java e9b68607683de279d0cb8712a28dc131c5c33ece GREEN
DynamicTreeViewer.java 725f41f4fb4b6bfa813f010fb9083ab02eea164a GREEN
DynamicList.java 786300e2e914826da239329d190abea1710478ea GREEN
DynamicListContentProvider.java 817cba44f246a361207a88ef9a4e1869215803f7 GREEN
DynamicStreamContentProvider.java f46e91400609cba54793dd240be0fe2aa0d5cced GREEN
DynamicTreeContentProviderBase.java 0f6e0a6894752d135847608bc45efa504972bb28 GREEN
DynamicTreeItem.java 7486071d20e896d6ca9a9101bf105caccf3656d0 GREEN
DynamicTreeItemBase.java d883066ecc181120302ca32f328538de7a45b093 GREEN
DynamicTreeTableUIProviderBase.java 1078bd28a6bce5a5a2c60500f2aa1d8b1fdd341b GREEN
DynamicTreeTableViewer.java ea4ac3530edfa179cfce53bdd7e3a7ae80c435e4 GREEN
DynamicTreeUIProviderBase.java 82d3c051213f0147f4c67ad247a08696cee73110 GREEN
DynamicTreeViewer.java e58d2cf7239e45f1b790ce9770a8a8649b1b5fb9 GREEN
DynamicTreeViewerBase.java a2013538b62d86f6a09efdf2cd78babac2072484 GREEN
EmptyChildrenContentProvider.java 51b4468f9df8423abeea5ac6aa2f6cf99c2eb512 GREEN
IDoubleClickHandler.java 447f7769dead9a106b3ea3139ef0da51eb0b9a89 GREEN
IDynamicItem.java 083d02459e7ec33542d9910c04abe2581e0b5422 GREEN
/*******************************************************************************
* Copyright (c) 2016, 2018 fortiss GmbH.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v2.0 which is available at
* http://www.eclipse.org/legal/epl-v20.html
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Florian Hoelzl (fortiss GmbH) - initial implementation
* Alexander Diewald (fortiss GmbH) - backport to AF3 & Integration
* improvements
*
*******************************************************************************/
package org.fortiss.tooling.common.ui.javafx.control.treetableview;
import java.util.Collection;
import java.util.HashMap;
import java.util.function.Supplier;
import java.util.stream.Stream;
import javafx.scene.control.TreeItem;
/**
* {@link TreeItem} with support for dynamic children using the
* {@link DynamicList#update()} method.
*/
public class DynamicList<T> extends DynamicTreeItemBase<T> {
/** The viewer. */
private DynamicTreeContentProviderBase<T> contentProvider;
/**
* Constructor. The given {@link Supplier} is queried on updates to retrieve a recent list of
* elements to display.
*/
@SuppressWarnings("unchecked")
public DynamicList(Supplier<Stream<T>> data,
DynamicStreamContentProvider<T, Supplier<Stream<T>>> contentProvider) {
super((T)data);
this.contentProvider = contentProvider;
}
/** Constructor. The given collection must be updated by the initializer to reflect changes. */
@SuppressWarnings("unchecked")
public DynamicList(Collection<T> data, DynamicTreeContentProviderBase<T> contentProvider) {
super((T)data);
this.contentProvider = contentProvider;
}
/** {@inheritDoc} */
@Override
public void update() {
// remember expanded state of children
HashMap<T, TreeItem<T>> expanded = new HashMap<>();
for(TreeItem<T> c : getChildren()) {
if(c.isExpanded()) {
expanded.put(c.getValue(), c);
}
}
// get list of children and create tree items
getChildren().clear();
for(T element : contentProvider.getFilteredSortedChildren(getValue())) {
DynamicTreeItem<T> dti = new DynamicTreeItem<T>(element, contentProvider);
getChildren().add(dti);
dti.update();
}
}
/** {@inheritDoc} */
@Override
public boolean isLeaf() {
Collection<? extends Object> children =
contentProvider.getFilteredSortedChildren(getValue());
return children == null || children.isEmpty();
}
}
/*******************************************************************************
* Copyright (c) 2016, 2018 fortiss GmbH.
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v2.0 which is available at
* http://www.eclipse.org/legal/epl-v20.html
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Florian Hoelzl (fortiss GmbH) - initial implementation
* Alexander Diewald (fortiss GmbH) - backport to AF3 & Integration
* improvements
*
*******************************************************************************/
package org.fortiss.tooling.common.ui.javafx.control.treetableview;
import static java.util.Collections.emptyList;
import java.util.Collection;
/**
* Base class for implementing tree content providers used in {@link DynamicTreeViewer} and
* {@link DynamicTreeTableViewer}.
*/
public class DynamicListContentProvider<T> extends DynamicTreeContentProviderBase<T> {
/** Returns the children of the given parent in the tree. */
@SuppressWarnings("unchecked")
@Override
protected Collection<T> getChildren(T parent) {
// Pseudo-cast...
if(parent instanceof Collection) {
return (Collection<T>)parent;
}
return emptyList();
}
}
/*-------------------------------------------------------------------------+
| Copyright 2020 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.common.ui.javafx.control.treetableview;
import static java.util.Collections.emptyList;
import static java.util.stream.Collectors.toList;
import java.util.Collection;
import java.util.function.Supplier;
import java.util.stream.Stream;
/**
* Content provider whose element list is dynamically retrieved from a supplier.
*
* @author diewald
*/
public class DynamicStreamContentProvider<T, S extends Supplier<Stream<T>>>
extends DynamicTreeContentProviderBase<T> {
/** {@inheritDoc} */
@Override
protected Collection<? extends T> getChildren(T parent) {
if(parent instanceof Supplier) {
@SuppressWarnings("unchecked") Supplier<Stream<T>> supp = ((S)parent);
return supp.get().collect(toList());
}
return emptyList();
}
}
......@@ -51,10 +51,10 @@ public abstract class DynamicTreeContentProviderBase<T> {
* toString() contains the filter value. Sub-classes may override or implement
* {@link #filter(Object, String)}.
*/
protected Predicate<T> getFilterPredicate(String filterValue) {
if(filterValue != null && !"".equals(filterValue.trim())) {
protected Predicate<T> getFilterPredicate() {
if(getFilterExpression() != null && !"".equals(getFilterExpression().trim())) {
return (o) -> {
return filter(o, filterValue);
return filter(o, getFilterExpression());
};
}
return (o) -> true;
......@@ -77,12 +77,19 @@ public abstract class DynamicTreeContentProviderBase<T> {
}
/** Returns the filtered children of the given element. */
@SuppressWarnings("unchecked")
public final Collection<? extends T> getFilteredSortedChildren(T parent) {
Collection<? extends T> l = getChildren(parent);
Collection<? extends T> l = null;
if(parent instanceof Collection) {
l = (Collection<T>)parent;
} else {
l = getChildren(parent);
}
if(l == null) {
return emptyList();
}
return l.stream().filter(getFilterPredicate(getFilterExpression()))
.sorted(getSortingComparator()).collect(toList());
return l.stream().filter(getFilterPredicate()).sorted(getSortingComparator())
.collect(toList());
}
}
......@@ -24,17 +24,18 @@ import javafx.scene.control.TreeItem;
* {@link TreeItem} with support for dynamic children using the
* {@link DynamicTreeItem#update()} method.
*/
public class DynamicTreeItem<T> extends TreeItem<T> {
public class DynamicTreeItem<T> extends DynamicTreeItemBase<T> {
/** The viewer. */
private DynamicTreeViewerBase<T> viewer;
private DynamicTreeContentProviderBase<T> contentProvider;
/** Constructor. */
public DynamicTreeItem(T data, DynamicTreeViewerBase<T> viewer) {
public DynamicTreeItem(T data, DynamicTreeContentProviderBase<T> viewer) {
super(data);
this.viewer = viewer;
this.contentProvider = viewer;
}
/** Updates the children of this item from the underlying content model. */
/** {@inheritDoc} */
@Override
public void update() {
// remember expanded state of children
HashMap<T, TreeItem<T>> expanded = new HashMap<>();
......@@ -45,13 +46,12 @@ public class DynamicTreeItem<T> extends TreeItem<T> {
}
// get list of children and create tree items
getChildren().clear();
DynamicTreeContentProviderBase<T> cp = viewer.getContentProvider();
for(T element : cp.getFilteredSortedChildren(getValue())) {
for(T element : contentProvider.getFilteredSortedChildren(getValue())) {
DynamicTreeItem<T> dti;
if(expanded.containsKey(element)) {
dti = (DynamicTreeItem<T>)expanded.get(element);
} else {
dti = new DynamicTreeItem<T>(element, viewer);
dti = new DynamicTreeItem<T>(element, contentProvider);
}
getChildren().add(dti);
dti.update();
......@@ -61,7 +61,8 @@ public class DynamicTreeItem<T> extends TreeItem<T> {
/** {@inheritDoc} */
@Override
public boolean isLeaf() {
Collection<? extends Object> children = viewer.getContentProvider().getChildren(getValue());
Collection<? extends Object> children =
contentProvider.getFilteredSortedChildren(getValue());
return children == null || children.isEmpty();
}
}
/*-------------------------------------------------------------------------+
| Copyright 2020 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.common.ui.javafx.control.treetableview;
import javafx.scene.control.TreeItem;
/**
* Base class for dynamic {@link TreeItem}s.
*
* @author diewald
*/
public abstract class DynamicTreeItemBase<T> extends TreeItem<T> implements IDynamicItem {
/** Constructor. */
public DynamicTreeItemBase(T data) {
super(data);
}
}
......@@ -61,6 +61,20 @@ public abstract class DynamicTreeTableUIProviderBase<T> {
return null;
}
/**
* Returns the style that shall be applied to the {@link TreeItem} of the given element. Return
* {@code null} for the default style.
*
* @param element
* to apply a style to.
* @param column
* column of to apply the style (the element is a row in the table).
* @return style of the element in the CSS format.
*/
public String getCellStyle(T element, int column) {
return null;
}
/**
* @param element
* the element to be displayed in the current row
......@@ -249,6 +263,17 @@ public abstract class DynamicTreeTableUIProviderBase<T> {
validateOnKeyReleased(t, columnIndex, item, tf.getText());
}
});
tf.focusedProperty().addListener(new ChangeListener<Boolean>() {
// If the focus is lost (user clicking elsewhere), the currently entered value is
// committed.
@Override
public void changed(ObservableValue<? extends Boolean> val, Boolean oldVal,
Boolean newVal) {
if(!newVal) {
commitEdit(tf.getText());
}
}
});
}
/** {@inheritDoc} */
......@@ -308,6 +333,11 @@ public abstract class DynamicTreeTableUIProviderBase<T> {
// JFX-builtin handling is non-operation in Linux.
addContextMenuHandler(menu, data);
}
String style = getCellStyle(data, colIndex);
if(style != null) {
this.setStyle(style);
}
}
this.setGraphic(icon);
this.setContextMenu(menu);
......