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
Showing
with 220 additions and 282 deletions
......@@ -16,6 +16,11 @@
package org.fortiss.tooling.common.ui.javafx.control.treetableview;
import static java.lang.Integer.MAX_VALUE;
import static javafx.scene.control.cell.CheckBoxTreeTableCell.forTreeTableColumn;
import java.util.Collection;
import java.util.function.Supplier;
import java.util.stream.Stream;
import javafx.beans.property.SimpleObjectProperty;
import javafx.scene.control.SelectionMode;
......@@ -24,7 +29,6 @@ import javafx.scene.control.TreeTableColumn;
import javafx.scene.control.TreeTableRow;
import javafx.scene.control.TreeTableView;
import javafx.scene.control.TreeTableView.TreeTableViewSelectionModel;
import javafx.scene.control.cell.CheckBoxTreeTableCell;
import javafx.scene.input.TransferMode;
import javafx.util.Callback;
......@@ -45,15 +49,51 @@ public final class DynamicTreeTableViewer<T> extends DynamicTreeViewerBase<T> {
/** The UI provider of this tree-table. */
private final DynamicTreeTableUIProviderBase<T> uiProvider;
/**
* Constructor. The given {@link Supplier} is queried on updates to obtain a list of elements to
* display.
*/
public DynamicTreeTableViewer(TreeTableView<T> view, Supplier<Stream<T>> listFctn,
DynamicStreamContentProvider<T, Supplier<Stream<T>>> contentProvider,
DynamicTreeTableUIProviderBase<T> uiProvider) {
this(view, new DynamicList<T>(listFctn, contentProvider), false, 0, contentProvider,
uiProvider);
}
/**
* Constructor. The given input collection must be updated by the caller such that changes are
* reflected in the corresponding {@link TreeTableView}.
*/
public DynamicTreeTableViewer(TreeTableView<T> view, Collection<T> list,
DynamicListContentProvider<T> contentProvider,
DynamicTreeTableUIProviderBase<T> uiProvider) {
this(view, new DynamicList<T>(list, contentProvider), false, 0, contentProvider,
uiProvider);
}
/** Constructor. */
public DynamicTreeTableViewer(TreeTableView<T> view, T root, boolean showRoot, int revealLevel,
DynamicTreeContentProviderBase<T> contentProvider,
DynamicTreeTableUIProviderBase<T> uiProvider) {
this(view, new DynamicTreeItem<T>(root, contentProvider), showRoot, revealLevel,
contentProvider, uiProvider);
}
/** Constructor. */
public DynamicTreeTableViewer(T root, boolean showRoot, int revealLevel,
DynamicTreeContentProviderBase<T> contentProvider,
DynamicTreeTableUIProviderBase<T> uiProvider) {
this(new TreeTableView<T>(), root, showRoot, revealLevel, contentProvider, uiProvider);
}
/** Constructor. */
public DynamicTreeTableViewer(TreeTableView<T> view, DynamicTreeItemBase<T> rootItem,
boolean showRoot, int revealLevel, DynamicTreeContentProviderBase<T> contentProvider,
DynamicTreeTableUIProviderBase<T> uiProvider) {
super(view, contentProvider);
this.uiProvider = uiProvider;
// construct view
this.view = view;
DynamicTreeItem<T> rootItem = new DynamicTreeItem<T>(root, this);
view.setRoot(rootItem);
view.setShowRoot(showRoot);
view.setEditable(true);
......@@ -88,21 +128,14 @@ public final class DynamicTreeTableViewer<T> extends DynamicTreeViewerBase<T> {
});
rootItem.update();
// expand to reveal (+1 if root node is not shown
// expand to reveal (+1 if root node is not shown)
expandItem(rootItem, showRoot ? revealLevel : revealLevel + 1);
}
/** Constructor. */
public DynamicTreeTableViewer(T root, boolean showRoot, int revealLevel,
DynamicTreeContentProviderBase<T> contentProvider,
DynamicTreeTableUIProviderBase<T> uiProvider) {
this(new TreeTableView<T>(), root, showRoot, revealLevel, contentProvider, uiProvider);
}
/** Updates the viewer content. */
public void update() {
// wild cast works: see constructor
DynamicTreeItem<T> rootItem = (DynamicTreeItem<T>)view.getRoot();
IDynamicItem rootItem = (IDynamicItem)view.getRoot();
rootItem.update();
view.refresh();
}
......@@ -164,24 +197,12 @@ public final class DynamicTreeTableViewer<T> extends DynamicTreeViewerBase<T> {
int num = view.getColumns().size();
TreeTableColumn<T, Boolean> column = new TreeTableColumn<>(headerLabel);
column.setPrefWidth(prefWidth);
column.setCellFactory(CheckBoxTreeTableCell.forTreeTableColumn(column));
column.setCellFactory(forTreeTableColumn(column));
uiProvider.applyToCheckboxColumn(num, column);
view.getColumns().add(column);
return column;
}
/**
* Adds a column to the table part of the view. The labels, context menus and icons are shown as
* defined in the {@link DynamicTreeTableUIProviderBase}.
*
* @deprecated use {@link DynamicTreeTableUIProviderBase}
*/
@Deprecated
public TreeTableColumn<T, String> addColumn(String headerLabel, int prefWidth,
@SuppressWarnings("unused") boolean readOnly) {
return addColumn(headerLabel, prefWidth);
}
/** Returns the underlying {@link TreeTableView}. */
public TreeTableView<T> getControl() {
return view;
......
......@@ -15,6 +15,7 @@ package org.fortiss.tooling.common.ui.javafx.control.treetableview;
import javafx.scene.Node;
import javafx.scene.control.ContextMenu;
import javafx.scene.control.TreeItem;
import javafx.scene.input.ClipboardContent;
import javafx.scene.input.Dragboard;
......@@ -41,6 +42,18 @@ public abstract class DynamicTreeUIProviderBase<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.
* @return style of the element in the CSS format.
*/
public String getCellStyle(T element) {
return null;
}
/**
* @param element
* the displayed element
......
......@@ -17,10 +17,13 @@ package org.fortiss.tooling.common.ui.javafx.control.treetableview;
import static org.apache.commons.lang3.SystemUtils.IS_OS_LINUX;
import java.util.Collection;
import javafx.beans.value.ChangeListener;
import javafx.scene.control.ContextMenu;
import javafx.scene.control.TreeCell;
import javafx.scene.control.TreeItem;
import javafx.scene.control.TreeTableView;
import javafx.scene.control.TreeView;
import javafx.scene.input.ClipboardContent;
import javafx.scene.input.DragEvent;
......@@ -38,21 +41,47 @@ public final class DynamicTreeViewer<T> extends DynamicTreeViewerBase<T> {
/** The {@link TreeView} control to be managed. */
private final TreeView<T> view;
/** {@link TreeItem} constructed for the root object. */
private final DynamicTreeItem<T> rootItem;
private final DynamicTreeItemBase<T> rootItem;
/** The UI provider implementation. */
private final DynamicTreeUIProviderBase<T> uiProvider;
/** The selection change listener. */
private ChangeListener<Object> selectionChangeListener = null;
/**
* Constructor. The given input collection must be updated by the caller such that changes are
* reflected in the corresponding {@link TreeTableView}.
*/
public DynamicTreeViewer(TreeView<T> view, Collection<T> list,
DynamicListContentProvider<T> contentProvider,
DynamicTreeUIProviderBase<T> uiProvider) {
this(view, new DynamicList<T>(list, contentProvider), false, 0, contentProvider,
uiProvider);
}
/** Constructor. */
public DynamicTreeViewer(TreeView<T> view, T root, boolean showRoot, int revealLevel,
DynamicTreeContentProviderBase<T> contentProvider,
DynamicTreeUIProviderBase<T> uiProvider) {
this(view, new DynamicTreeItem<T>(root, contentProvider), showRoot, revealLevel,
contentProvider, uiProvider);
}
/** Constructor. */
public DynamicTreeViewer(T root, boolean showRoot, int revealLevel,
DynamicTreeContentProviderBase<T> contentProvider,
DynamicTreeUIProviderBase<T> uiProvider) {
this(new TreeView<T>(), root, showRoot, revealLevel, contentProvider, uiProvider);
}
/** Constructor. */
public DynamicTreeViewer(TreeView<T> view, DynamicTreeItemBase<T> rootItem, boolean showRoot,
int revealLevel, DynamicTreeContentProviderBase<T> contentProvider,
DynamicTreeUIProviderBase<T> uiProvider) {
super(view, contentProvider);
this.uiProvider = uiProvider;
// construct view
this.view = view;
rootItem = new DynamicTreeItem<T>(root, this);
this.rootItem = rootItem;
view.setRoot(rootItem);
view.setShowRoot(showRoot);
configureCellFactory();
......@@ -68,36 +97,29 @@ public final class DynamicTreeViewer<T> extends DynamicTreeViewerBase<T> {
expandItem(rootItem, showRoot ? revealLevel : revealLevel + 1);
}
/** Constructor. */
public DynamicTreeViewer(T root, boolean showRoot, int revealLevel,
DynamicTreeContentProviderBase<T> contentProvider,
DynamicTreeUIProviderBase<T> uiProvider) {
this(new TreeView<T>(), root, showRoot, revealLevel, contentProvider, uiProvider);
}
/** Updates the tree view. */
public void update() {
// wild cast works: see constructor
DynamicTreeItem<T> rootItem = (DynamicTreeItem<T>)view.getRoot();
DynamicTreeItemBase<T> rootItem = (DynamicTreeItemBase<T>)view.getRoot();
rootItem.update();
}
/** Sets the selection of this tree view. */
public void setSelection(Object value) {
// wild cast works: see constructor
DynamicTreeItem<T> rootItem = (DynamicTreeItem<T>)view.getRoot();
DynamicTreeItem<T> item = findItem(rootItem, value);
DynamicTreeItemBase<T> rootItem = (DynamicTreeItemBase<T>)view.getRoot();
DynamicTreeItemBase<T> item = findItem(rootItem, value);
int row = view.getRow(item);
view.getSelectionModel().select(row);
}
/** Searches the {@link DynamicTreeItem} for the given value from the root. */
public DynamicTreeItem<T> findItem(T value) {
public DynamicTreeItemBase<T> findItem(T value) {
return findItem(rootItem, value);
}
/** Searches the {@link DynamicTreeItem} for the given value. */
public DynamicTreeItem<T> findItem(DynamicTreeItem<T> item, Object value) {
public DynamicTreeItemBase<T> findItem(DynamicTreeItemBase<T> item, Object value) {
if(item == null || value == null || item.getValue() == null) {
return null;
}
......@@ -105,8 +127,8 @@ public final class DynamicTreeViewer<T> extends DynamicTreeViewerBase<T> {
return item;
}
for(TreeItem<T> subItem : item.getChildren()) {
if(subItem instanceof DynamicTreeItem) {
DynamicTreeItem<T> i = findItem((DynamicTreeItem<T>)subItem, value);
if(subItem instanceof DynamicTreeItemBase) {
DynamicTreeItemBase<T> i = findItem((DynamicTreeItemBase<T>)subItem, value);
if(i != null) {
return i;
}
......@@ -137,6 +159,8 @@ public final class DynamicTreeViewer<T> extends DynamicTreeViewerBase<T> {
this.setText(uiProvider.getLabel(item));
this.setGraphic(uiProvider.getIconNode(item));
this.setStyle(uiProvider.getCellStyle(item));
this.setOnDragDetected(evt -> {
dragDetected(evt, this, item);
});
......
/*-------------------------------------------------------------------------+
| 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.common.ui.javafx.control.treetableview;
import static java.util.Collections.emptyList;
import java.util.Collection;
/**
* Dummy {@link DynamicListContentProvider} for collections whose elements do not provide further
* children.
*
* @author diewald
*/
public class EmptyChildrenContentProvider<T> extends DynamicListContentProvider<T> {
/** {@inheritDoc} */
@Override
protected Collection<T> getChildren(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 javafx.scene.control.TreeItem;
/**
* Common methods of dynamic {@link TreeItem}s of lists and tables.
*
* @author diewald
*/
public interface IDynamicItem {
/** Updates the children of this item from the underlying content model. */
public void update();
}
# (c) 2011 fortiss GmbH
source.. = src/
source.. = src/,\
res/
output.. = build/
bin.includes = .,\
plugin.xml,\
......
......@@ -41,9 +41,9 @@
</view>
<view
allowMultiple="false"
class="org.fortiss.tooling.kernel.ui.internal.introspection.KISSViewPart"
class="org.fortiss.tooling.kernel.ui.introspection.KISSServicesFXViewPart"
icon="icons/introspection.gif"
id="org.fortiss.tooling.kernel.ui.introspection.view"
id="org.fortiss.tooling.kernel.ui.introspection"
name="Kernel Introspection System Service (KISS)"
restorable="true">
</view>
......
<?xml version="1.0" encoding="UTF-8"?>
<?import javafx.scene.layout.BorderPane?>
<BorderPane fx:id="borderPane" xmlns:fx="http://javafx.com/fxml/1" />
<?xml version="1.0" encoding="UTF-8"?>
<?import javafx.scene.control.Label?>
<?import javafx.scene.control.ScrollPane?>
<?import javafx.scene.layout.AnchorPane?>
<?import javafx.scene.layout.BorderPane?>
<?import javafx.scene.layout.VBox?>
<AnchorPane xmlns="http://javafx.com/javafx/11.0.1" xmlns:fx="http://javafx.com/fxml/1">
<children>
<BorderPane fx:id="borderPane" maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity" AnchorPane.bottomAnchor="0.0" AnchorPane.leftAnchor="0.0" AnchorPane.rightAnchor="0.0" AnchorPane.topAnchor="0.0">
<bottom>
<VBox fx:id="vBox" prefHeight="150.0" prefWidth="800.0" BorderPane.alignment="CENTER">
<children>
<ScrollPane fitToWidth="true" hbarPolicy="NEVER" prefHeight="300.0" prefWidth="800.0">
<content>
<Label fx:id="label" style="-fx-padding: 5; -fx-border-style: solid inside; -fx-border-width: 2; -fx-border-insets: 5; -fx-border-radius: 5; -fx-border-color: lightblue;" text="Welcome to KISS!&#10;&#10;This is the kernel introspection system service." wrapText="true" />
</content>
</ScrollPane>
</children>
</VBox>
</bottom>
</BorderPane>
</children>
</AnchorPane>
......@@ -8,4 +8,4 @@ IModelElementHandler.java 86a8ec88b9679bbe7f53cfa8d1592bd862873f80 GREEN
ITutorialStepUI.java b8aee2b95857484ab6ad9ecd55b5de9f0ea158e5 GREEN
ITutorialUIProvider.java aa0ff5db4d7ba0953e34edeb99f3e8279567e18f GREEN
ITutorialUIWhitelistProvider.java d703c1531c6ae7677c2d94cbc95d498dfa4a7e9b GREEN
ModelEditorNotAvailableBinding.java aa2a519ff0dcc53985b9759a94adb52f213ecc84 GREEN
ModelEditorNotAvailableBinding.java ba0ea0fe9004cf16579d053d0ddf7eb3f35ed101 GREEN
......@@ -24,7 +24,7 @@ import org.fortiss.tooling.kernel.ui.extension.base.ModelEditorBindingBase;
*
* @author barner
*/
public final class ModelEditorNotAvailableBinding extends ModelEditorBindingBase<EObject> {
public class ModelEditorNotAvailableBinding<T extends EObject> extends ModelEditorBindingBase<T> {
// Nothing to do: The type ModelEditorNotAvailableBinding is used in ModelEditorBindingService
// to make a case distinction for model elements without dedicated editors.
}
ActionService.java e29126b5947c9fd2f1d82bb87001b9d0ead50c3b GREEN
AllocationEditPartFactoryService.java 81bd227736013f1157ba9d0f79a9f3deefe10064 GREEN
ContextMenuService.java ca3c899293f25b70ce8e5f0d86ca2f9683329d81 GREEN
EditPartFactoryService.java e9180c0020f1769d9e24ef3c08f9ca5599dbc5c3 GREEN
AllocationEditPartFactoryService.java 1656319f018b4df6d18643e2eb76e012f45c2392 GREEN
ContextMenuService.java 802b6d0ade78f91478cd8959cfb423b9963d43bf GREEN
EditPartFactoryService.java 14c44fd426da4a26bfd4012652ea510a4b149421 GREEN
MarkerService.java 505296c356f8d66c5c009b6d6181a971d02a9501 GREEN
ModelEditorBindingService.java d980691db4b700714c0669050014d08751354d5e GREEN
ModelElementHandlerService.java eeb07f6926012aa98256d452d1e554a5486dc657 GREEN
ModelEditorBindingService.java 52038a912db203fb8d63a000a59872cfa94e0eea GREEN
ModelElementHandlerService.java 34adeef844bf98c69f1b9a7252f34d0a2b741b54 GREEN
NavigatorService.java 1d773dde3791ddf7051616fe249558e7e307757d GREEN
ToolingKernelUIInternal.java a70d19883dfb315d860233156d8524cf1ac2952f GREEN
TutorialUIService.java b1d632eca91b4feb583f3930cd6ee4722dd9bfed GREEN
......@@ -28,7 +28,7 @@ import org.fortiss.tooling.kernel.service.IKernelIntrospectionSystemService;
import org.fortiss.tooling.kernel.service.base.EObjectAwareServiceBase;
import org.fortiss.tooling.kernel.ui.ToolingKernelUIActivator;
import org.fortiss.tooling.kernel.ui.extension.IAllocationEditPartFactory;
import org.fortiss.tooling.kernel.ui.internal.introspection.items.AllocationEditPartFactoryServiceIntrospectionDetailsItem;
import org.fortiss.tooling.kernel.ui.introspection.items.AllocationEditPartFactoryKISSDetailsItem;
import org.fortiss.tooling.kernel.ui.service.IAllocationEditPartFactoryService;
import org.fortiss.tooling.kernel.utils.LoggingUtils;
......@@ -150,6 +150,6 @@ public class AllocationEditPartFactoryService
/** {@inheritDoc} */
@Override
public IIntrospectionDetailsItem getDetailsItem() {
return new AllocationEditPartFactoryServiceIntrospectionDetailsItem(handlerMap);
return new AllocationEditPartFactoryKISSDetailsItem(handlerMap);
}
}
......@@ -39,7 +39,7 @@ import org.fortiss.tooling.kernel.service.ITutorialService;
import org.fortiss.tooling.kernel.ui.extension.IContextMenuContributor;
import org.fortiss.tooling.kernel.ui.extension.IContextMenuMultiSelectionContributor;
import org.fortiss.tooling.kernel.ui.extension.data.ContextMenuContextProvider;
import org.fortiss.tooling.kernel.ui.internal.introspection.items.ContextMenuServiceIntrospectionDetailsItem;
import org.fortiss.tooling.kernel.ui.introspection.items.ContextMenuKISSDetailsItem;
import org.fortiss.tooling.kernel.ui.service.IActionService;
import org.fortiss.tooling.kernel.ui.service.IContextMenuService;
import org.fortiss.tooling.kernel.ui.service.ITutorialUIService;
......@@ -278,6 +278,6 @@ public class ContextMenuService implements IContextMenuService, IIntrospectiveKe
/** {@inheritDoc} */
@Override
public IIntrospectionDetailsItem getDetailsItem() {
return new ContextMenuServiceIntrospectionDetailsItem(contextMenuContributorList);
return new ContextMenuKISSDetailsItem(contextMenuContributorList);
}
}
......@@ -29,7 +29,7 @@ import org.fortiss.tooling.kernel.service.IKernelIntrospectionSystemService;
import org.fortiss.tooling.kernel.service.base.EObjectAwareServiceBase;
import org.fortiss.tooling.kernel.ui.ToolingKernelUIActivator;
import org.fortiss.tooling.kernel.ui.extension.IEditPartFactory;
import org.fortiss.tooling.kernel.ui.internal.introspection.items.EditPartFactoryServiceIntrospectionDetailsItem;
import org.fortiss.tooling.kernel.ui.introspection.items.EditPartFactoryKISSDetailsItem;
import org.fortiss.tooling.kernel.ui.service.IEditPartFactoryService;
/**
......@@ -147,6 +147,6 @@ public class EditPartFactoryService extends EObjectAwareServiceBase<IEditPartFac
/** {@inheritDoc} */
@Override
public IIntrospectionDetailsItem getDetailsItem() {
return new EditPartFactoryServiceIntrospectionDetailsItem(handlerMap);
return new EditPartFactoryKISSDetailsItem(handlerMap);
}
}
......@@ -58,8 +58,8 @@ import org.fortiss.tooling.kernel.ui.extension.IModelElementHandler;
import org.fortiss.tooling.kernel.ui.extension.ModelEditorNotAvailableBinding;
import org.fortiss.tooling.kernel.ui.internal.editor.ExtendableMultiPageEditor;
import org.fortiss.tooling.kernel.ui.internal.editor.ModelElementEditorInput;
import org.fortiss.tooling.kernel.ui.internal.introspection.items.ModelEditorBindingServiceIntrospectionDetailsItem;
import org.fortiss.tooling.kernel.ui.internal.views.library.LibraryViewPart;
import org.fortiss.tooling.kernel.ui.introspection.items.ModelEditorBindingKISSDetailsItem;
import org.fortiss.tooling.kernel.ui.service.IModelEditorBindingService;
import org.fortiss.tooling.kernel.ui.service.IModelElementHandlerService;
......@@ -155,18 +155,18 @@ public class ModelEditorBindingService extends EObjectAwareServiceBase<IModelEdi
List<IModelEditorBinding<EObject>> bindings = getBindings(element);
int numBindings = bindings.size();
// There is exactly one binding that indicates that no editor should be displayed.
if(numBindings == 1 && bindings.get(0) instanceof ModelEditorNotAvailableBinding) {
return;
}
// Recurse if there is an editor for one the model element's ancestors.
if(numBindings == 0) {
// Recurse if there is no binding or no editor for the current model element.
boolean noEditor =
numBindings == 1 && bindings.get(0) instanceof ModelEditorNotAvailableBinding;
boolean noBindings = numBindings == 0;
if(noBindings || noEditor) {
if(element.eContainer() != null) {
openInEditor(element.eContainer());
}
return;
}
try {
IWorkbench workbench = PlatformUI.getWorkbench();
IWorkbenchPage activePage = workbench.getActiveWorkbenchWindow().getActivePage();
......@@ -404,6 +404,6 @@ public class ModelEditorBindingService extends EObjectAwareServiceBase<IModelEdi
/** {@inheritDoc} */
@Override
public IIntrospectionDetailsItem getDetailsItem() {
return new ModelEditorBindingServiceIntrospectionDetailsItem(handlerMap);
return new ModelEditorBindingKISSDetailsItem(handlerMap);
}
}
......@@ -30,7 +30,7 @@ import org.fortiss.tooling.kernel.introspection.IIntrospectiveKernelService;
import org.fortiss.tooling.kernel.service.IKernelIntrospectionSystemService;
import org.fortiss.tooling.kernel.service.base.EObjectAwareServiceBase;
import org.fortiss.tooling.kernel.ui.extension.IModelElementHandler;
import org.fortiss.tooling.kernel.ui.internal.introspection.items.ModelElementHandlerServiceIntrospectionDetailsItem;
import org.fortiss.tooling.kernel.ui.introspection.items.ModelElementHandlerKISSDetailsItem;
import org.fortiss.tooling.kernel.ui.service.IModelElementHandlerService;
import javafx.scene.Node;
......@@ -186,6 +186,6 @@ public class ModelElementHandlerService
/** {@inheritDoc} */
@Override
public IIntrospectionDetailsItem getDetailsItem() {
return new ModelElementHandlerServiceIntrospectionDetailsItem(handlerMap);
return new ModelElementHandlerKISSDetailsItem(handlerMap);
}
}
KISSViewPart.java 0de931d1947b2fc8c95cb5b5c9ed9d9d3bc82c6e GREEN
KISSViewerContentProvider.java b9740ee3471a70726f3f7e4dd500668301af3f61 GREEN
KISSViewerLabelProvider.java 639495bdc8ce8c13edd464869ff625f745ed9809 GREEN
/*-------------------------------------------------------------------------+
| Copyright 2011 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.kernel.ui.internal.introspection;
import org.eclipse.jface.viewers.ISelectionChangedListener;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.SelectionChangedEvent;
import org.eclipse.jface.viewers.TreeViewer;
import org.eclipse.jface.viewers.ViewerComparator;
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.ScrolledComposite;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.ui.part.ViewPart;
import org.fortiss.tooling.kernel.introspection.IIntrospectionDetailsItem;
import org.fortiss.tooling.kernel.introspection.IIntrospectiveKernelService;
import org.fortiss.tooling.kernel.introspection.KernelIntrospectionSystemService;
import org.fortiss.tooling.kernel.ui.internal.introspection.details.DetailsUIHandlerBase;
import org.fortiss.tooling.kernel.ui.internal.introspection.details.KISSDetailsUIRegistry;
/**
* {@link ViewPart} for the marker display.
*
* @author hoelzl
*/
public class KISSViewPart extends ViewPart implements ISelectionChangedListener {
/** The greeting text. */
private static final String GREETING =
"Welcome to KISS!\n\nThis is the kernel introspection system service.";
/** GUI builder viewer instance. */
private KISSViewerGUI gui;
/** {@inheritDoc} */
@Override
public void createPartControl(Composite parent) {
parent.setLayout(new FillLayout());
gui = new KISSViewerGUI(parent, SWT.NONE);
TreeViewer tv = gui.getTreeViewer();
tv.setContentProvider(new KISSViewerContentProvider());
tv.setLabelProvider(new KISSViewerLabelProvider());
tv.setComparator(new ViewerComparator());
tv.addSelectionChangedListener(this);
gui.getDescriptionText().setText(GREETING);
// the class is used as hidden root element, which contains the instance
// see also content provider implementation for this setup
tv.setInput(KernelIntrospectionSystemService.class);
}
/** {@inheritDoc} */
@Override
public void setFocus() {
gui.getTreeViewer().getControl().setFocus();
}
/** Refreshes the view. Needs to be called on UI thread. */
public void refresh() {
if(!gui.getTreeViewer().getControl().isDisposed()) {
gui.getTreeViewer().refresh();
}
}
/** {@inheritDoc} */
@Override
public void selectionChanged(SelectionChangedEvent event) {
if(gui.getTreeViewer().getControl().isDisposed()) {
return;
}
if(event.getSelection().isEmpty()) {
gui.getDescriptionText().setText(GREETING);
return;
}
if(event.getSelection() instanceof IStructuredSelection) {
IStructuredSelection sel = (IStructuredSelection)event.getSelection();
if(sel.getFirstElement() instanceof IIntrospectiveKernelService) {
updateWidgets((IIntrospectiveKernelService)sel.getFirstElement());
return;
}
}
// fallback
gui.getDescriptionText().setText(GREETING);
}
/** Update the KISS view widgets and controls. */
private void updateWidgets(IIntrospectiveKernelService service) {
gui.getDescriptionText().setText(service.getIntrospectionDescription());
ScrolledComposite sc = gui.getDetailsScrolledComposite();
if(sc.getContent() != null) {
Control old = sc.getContent();
gui.getDetailsScrolledComposite().setContent(null);
old.dispose();
}
IIntrospectionDetailsItem item = service.getDetailsItem();
if(item != null) {
DetailsUIHandlerBase handler =
KISSDetailsUIRegistry.getInstance().getHandler(item.getClass());
if(handler != null) {
handler.setService(service);
handler.setDataItem(item);
Control newContent = handler.createComposite(sc);
sc.setContent(newContent);
}
}
}
}
/*-------------------------------------------------------------------------+
| Copyright 2016 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.kernel.ui.internal.introspection;
import org.eclipse.jface.viewers.TreeViewer;
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.SashForm;
import org.eclipse.swt.custom.ScrolledComposite;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Text;
/**
* GENERATED CODE (WindowBuilder)
*
* @author hoelzl
*/
@SuppressWarnings("javadoc")
public class KISSViewerGUI extends Composite {
private TreeViewer treeViewer;
private ScrolledComposite detailsScrolledComposite;
private Composite descriptionComposite;
private Text descriptionText;
/**
* Create the composite.
*
* @param parent
* @param style
*/
public KISSViewerGUI(Composite parent, int style) {
super(parent, style);
setLayout(new FillLayout(SWT.HORIZONTAL));
SashForm verticalSplitSash = new SashForm(this, SWT.VERTICAL | SWT.BORDER | SWT.SMOOTH);
SashForm horizontalSplitSash = new SashForm(verticalSplitSash, SWT.BORDER | SWT.SMOOTH);
treeViewer = new TreeViewer(horizontalSplitSash, SWT.SINGLE | SWT.BORDER);
treeViewer.setAutoExpandLevel(2);
detailsScrolledComposite = new ScrolledComposite(horizontalSplitSash,
SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL);
detailsScrolledComposite.setExpandHorizontal(true);
detailsScrolledComposite.setExpandVertical(true);
horizontalSplitSash.setWeights(new int[] {1, 5});
descriptionComposite = new Composite(verticalSplitSash, SWT.BORDER);
descriptionComposite.setLayout(new GridLayout());
verticalSplitSash.setWeights(new int[] {7, 1});
descriptionText = new Text(descriptionComposite, SWT.READ_ONLY | SWT.V_SCROLL | SWT.MULTI);
Color gray = Display.getCurrent().getSystemColor(SWT.COLOR_WIDGET_BACKGROUND);
descriptionText.setBackground(gray);
descriptionText.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true));
}
public TreeViewer getTreeViewer() {
return treeViewer;
}
public ScrolledComposite getDetailsScrolledComposite() {
return detailsScrolledComposite;
}
public Composite getDescriptionComposite() {
return descriptionComposite;
}
public Text getDescriptionText() {
return descriptionText;
}
}