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 1143 additions and 99 deletions
/*-------------------------------------------------------------------------+
| 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.items;
import java.util.List;
import java.util.Map;
import org.eclipse.emf.ecore.EObject;
import org.fortiss.tooling.kernel.introspection.IIntrospectionDetailsItem;
import org.fortiss.tooling.kernel.introspection.items.EObjectAwareIntrospectionDetailsItemBase;
import org.fortiss.tooling.kernel.ui.extension.IModelElementHandler;
import org.fortiss.tooling.kernel.ui.internal.ModelElementHandlerService;
/**
* {@link IIntrospectionDetailsItem} for {@link ModelElementHandlerService}.
*
* @author hoelzl
*/
public final class ModelElementHandlerServiceIntrospectionDetailsItem
extends EObjectAwareIntrospectionDetailsItemBase<IModelElementHandler<EObject>> {
/** Constructor. */
public ModelElementHandlerServiceIntrospectionDetailsItem(
Map<Class<?>, List<IModelElementHandler<EObject>>> handlerMap) {
super(handlerMap);
}
}
<!-- (c) 2017 fortiss GmbH -->
<body>
User interface for the kernel introspection system service (KISS).
It provides an Eclipse view with a tree viewer showing all introspective
services (and their specific items) as well as a section for service-specific,
detailed information.
</body>
......@@ -2,9 +2,7 @@ DoubleClick.java a94d27299814a93b0d8914050a5da7378a7eccd1 GREEN
GenericNewMenu.java 7e0dd435cb5ca6d4b486235ec17eef3e5c7aa5f6 GREEN
LibraryViewDragSourceAdapter.java 56ef61b214ef5d6cb5b751791a92158bda0391ec GREEN
LinkWithEditorPartListener.java c5ab74424378e7b158a805c4dd14fc03c8abeded GREEN
MarkerViewContentProvider.java 4cb1192baebe21bca951c439c163d0c171512515 GREEN
MarkerViewPart.java cbb650271b6877af205421b7cb11f930440a7ef9 GREEN
ModelElementsViewFX.java b1d03d57b67bf2c7b1d8da0ad3b16ea7d59efab5 GREEN
ModelElementsViewFX.java 68accd2cc94a0df58a2742329f75f6fda25a8606 GREEN
NavigatorNewMenu.java a35e391960d1dacbe7f77982e53e1891e9382d5a GREEN
NavigatorTreeContentComparator.java d9f1354cfdff78b104b28887d2397e5ca0e9755b GREEN
NavigatorTreeContentProvider.java 1fbe97bebf3805cc1af190cecd784fc1cfd12306 GREEN
......
......@@ -24,7 +24,6 @@ import static org.fortiss.tooling.kernel.utils.KernelModelElementUtils.getParent
import java.util.Collection;
import java.util.List;
import java.util.Set;
import java.util.function.Predicate;
import org.conqat.ide.commons.ui.ui.EmptyPartListener;
import org.conqat.lib.commons.collections.IdentityHashSet;
......@@ -193,19 +192,6 @@ public final class ModelElementsViewFX extends FXViewPart {
}
return false;
}
/** {@inheritDoc} */
@Override
protected Predicate<Object> getFilterPredicate(String filterValue) {
// this override is needed, because super implementation does not
// call filter(Object, String) when filter value is null.
if(filterValue == null || "".equals(filterValue)) {
return (o) -> {
return filter(o, null);
};
}
return super.getFilterPredicate(filterValue);
}
}
/** {@link DynamicTreeUIProviderBase} for the library view. */
......
ClipboardCopyHelper.java 1d9a9891278ab84932857eaa978dda4391978047 GREEN
KISSCompositeFXController.java 10f73a3a2034824eb14a8fda1f67bcc05285e3b0 GREEN
KISSFXController.java c38fc9efa826c68e74ac118e666088f407cb54fb GREEN
KISSServicesFXController.java cb59024c94164cf187041634c38a6dee1107e3a2 GREEN
KISSServicesFXViewPart.java 1a8370028bf79a8071f616dae985df3831c7f8b6 GREEN
/*******************************************************************************
* Copyright (c) 2019 fortiss GmbH.
*
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0
* which is available at https://www.apache.org/licenses/LICENSE-2.0.
*
* SPDX-License-Identifier: EPL-2.0 OR Apache-2.0
*******************************************************************************/
package org.fortiss.tooling.kernel.ui.introspection;
import static javafx.scene.input.Clipboard.getSystemClipboard;
import javafx.scene.control.ContextMenu;
import javafx.scene.control.MenuItem;
import javafx.scene.input.Clipboard;
import javafx.scene.input.ClipboardContent;
/** Helper class for copying a class name to the system clipboard. */
public final class ClipboardCopyHelper {
/** Creates a context menu to copy the given class name. */
public static ContextMenu createCopyClassNameMenu(Class<?> toCopy) {
return createCopyClassNameMenu(toCopy.getName());
}
/** Creates a context menu to copy the given class name. */
public static ContextMenu createCopyClassNameMenu(String fullyQualified) {
return createContextMenu("Copy '" + fullyQualified + "' to clipboard.", fullyQualified);
}
/** Creates a context menu to copy the stack trace of the given {@link Throwable}. */
public static ContextMenu createCopyStrackTraceMenu(Throwable throwable) {
StringBuilder sb = new StringBuilder();
for(StackTraceElement ste : throwable.getStackTrace()) {
sb.append(ste.toString()).append('\n');
}
return createContextMenu("Copy Stack Trace", sb.toString());
}
/** Creates the context menu. */
private static ContextMenu createContextMenu(String label, String data) {
ContextMenu menu = new ContextMenu();
MenuItem item = new MenuItem(label);
item.setOnAction(event -> {
Clipboard clipboard = getSystemClipboard();
ClipboardContent content = new ClipboardContent();
content.putString(data);
clipboard.setContent(content);
});
menu.getItems().add(item);
return menu;
}
}
/*-------------------------------------------------------------------------+
| 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,25 +13,27 @@
| See the License for the specific language governing permissions and |
| limitations under the License. |
+--------------------------------------------------------------------------*/
package org.fortiss.tooling.kernel.ui.internal.introspection.items;
package org.fortiss.tooling.kernel.ui.introspection;
import java.util.List;
import org.fortiss.tooling.common.ui.javafx.control.treetableview.DynamicTreeTableViewer;
import org.fortiss.tooling.common.ui.javafx.layout.CompositeFXControllerBase;
import org.fortiss.tooling.kernel.introspection.IIntrospectionItem;
import org.fortiss.tooling.kernel.introspection.IIntrospectionDetailsItem;
import org.fortiss.tooling.kernel.introspection.items.HandlerListIntrospectionDetailsItemBase;
import org.fortiss.tooling.kernel.ui.extension.IContextMenuContributor;
import org.fortiss.tooling.kernel.ui.internal.ContextMenuService;
import javafx.scene.Node;
/**
* {@link IIntrospectionDetailsItem} for the {@link ContextMenuService}.
* Abstract class specifying the functionality to be provided by a controller to be contained in a
* {@link KISSFXController}-based view.
*
* @author hoelzl
* @author munaro
*/
public final class ContextMenuServiceIntrospectionDetailsItem
extends HandlerListIntrospectionDetailsItemBase<IContextMenuContributor> {
@SuppressWarnings("unchecked")
public abstract class KISSCompositeFXController<T extends Node>
extends CompositeFXControllerBase<T, Node> {
/** Constructor. */
public ContextMenuServiceIntrospectionDetailsItem(List<IContextMenuContributor> handlerList) {
super(handlerList);
}
/**
* This method is executed each time the {@link IIntrospectionItem} selected in the
* {@link KISSFXController}'s {@link DynamicTreeTableViewer} changes.
*/
public abstract void changed(IIntrospectionItem selection);
}
/*-------------------------------------------------------------------------+
| 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.kernel.ui.introspection;
import static org.fortiss.tooling.common.util.LambdaUtils.getFirst;
import java.util.stream.Collectors;
import org.fortiss.tooling.common.ui.javafx.layout.CompositeFXControllerBase;
import org.fortiss.tooling.kernel.introspection.IIntrospectionItem;
import org.fortiss.tooling.kernel.introspection.KernelIntrospectionSystemService;
import javafx.beans.value.ChangeListener;
import javafx.beans.value.ObservableValue;
import javafx.fxml.FXML;
import javafx.scene.Node;
import javafx.scene.control.TreeCell;
import javafx.scene.control.TreeItem;
import javafx.scene.control.TreeView;
import javafx.scene.layout.BorderPane;
/**
* Controller for the Java FX-based UI common to all KISS-based views. The specific views to be
* displayed have extend the abstract {@link KISSCompositeFXController} class.
*
* @author munaro
*/
public class KISSFXController extends CompositeFXControllerBase<BorderPane, Node>
implements ChangeListener<TreeItem<IIntrospectionItem>> {
/** The pane of the view. */
@FXML
protected BorderPane borderPane;
/** The introspection service. */
protected KernelIntrospectionSystemService kiss;
/** The tree viewer. */
private TreeView<IIntrospectionItem> treeview;
/** The {@link KISSCompositeFXController} of the specific KISS view to be displayed. */
private KISSCompositeFXController<? extends Node> composite;
/** Constructor. */
@SuppressWarnings("unchecked")
public KISSFXController(KISSCompositeFXController<? extends Node> composite) {
super(composite);
this.composite = composite;
this.kiss = KernelIntrospectionSystemService.getInstance();
}
/**
* Implementation for tree cells returning the
* {@link IIntrospectionItem#getIntrospectionLabel()}.
*/
private class TreeCellImpl extends TreeCell<IIntrospectionItem> {
/** {@inheritDoc} */
@Override
protected void updateItem(IIntrospectionItem item, boolean empty) {
super.updateItem(item, empty);
String text = null;
if(!empty && item != null) {
text = item.getIntrospectionLabel();
}
setText(text);
setGraphic(null);
}
}
/** {@inheritDoc} */
@Override
public String getFXMLLocation() {
return "KISS.fxml";
}
/** {@inheritDoc} */
@Override
public void initialize() {
TreeItem<IIntrospectionItem> root = new TreeItem<IIntrospectionItem>(kiss);
root.getChildren()
.addAll(kiss.getIntrospectionItems().stream().map((IIntrospectionItem iii) -> {
return new TreeItem<IIntrospectionItem>(iii);
}).collect(Collectors.toList()));
root.setExpanded(true);
root.getChildren().sort((c0, c1) -> {
String l0 = c0.getValue().getIntrospectionLabel();
String l1 = c1.getValue().getIntrospectionLabel();
return l0.compareTo(l1);
});
treeview = new TreeView<IIntrospectionItem>(root);
treeview.setCellFactory((TreeView<IIntrospectionItem> tv) -> {
return new TreeCellImpl();
});
treeview.getSelectionModel().selectedItemProperty().addListener(this);
borderPane.setLeft(treeview);
Node center = getFirst(getContainments()).get().getLayout();
borderPane.setCenter(center);
}
/** {@inheritDoc} */
@Override
public void changed(ObservableValue<? extends TreeItem<IIntrospectionItem>> observable,
TreeItem<IIntrospectionItem> oldValue, TreeItem<IIntrospectionItem> newValue) {
composite.changed(newValue.getValue());
}
}
/*-------------------------------------------------------------------------+
| Copyright 2013 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,73 +13,75 @@
| 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.kernel.ui.introspection;
import java.util.Collection;
import org.eclipse.jface.viewers.ITreeContentProvider;
import org.eclipse.jface.viewers.Viewer;
import org.fortiss.tooling.kernel.introspection.IIntrospectionDetailsItem;
import org.fortiss.tooling.kernel.introspection.IIntrospectionItem;
import org.fortiss.tooling.kernel.introspection.IIntrospectiveKernelService;
import org.fortiss.tooling.kernel.introspection.KernelIntrospectionSystemService;
import org.fortiss.tooling.kernel.service.IKernelIntrospectionSystemService;
import org.fortiss.tooling.kernel.ui.introspection.details.DetailsUIHandlerBase;
import org.fortiss.tooling.kernel.ui.introspection.details.KISSDetailsUIRegistry;
import javafx.fxml.FXML;
import javafx.scene.Node;
import javafx.scene.control.Label;
import javafx.scene.layout.BorderPane;
import javafx.scene.layout.VBox;
/**
* Content provider for the {@link KISSViewPart}.
* Controller for the view for the detailed inspection of KISS services.
*
* @author hoelzl
* @author munaro
*/
public class KISSViewerContentProvider implements ITreeContentProvider {
/** {@inheritDoc} */
@Override
public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
// ignore
}
public class KISSServicesFXController extends KISSCompositeFXController<VBox> {
/** {@inheritDoc} */
@Override
public void dispose() {
// do nothing
}
/** {@link BorderPane} displaying the description and the details of the selected service. */
@FXML
private BorderPane borderPane;
/** {@inheritDoc} */
@Override
public boolean hasChildren(Object element) {
Object[] objs = getChildren(element);
return objs != null && objs.length > 0;
}
/** {@link VBox} displaying the description of the selected service. */
@FXML
private VBox vBox;
/** The description label at the bottom. */
@FXML
private Label label;
/** The greeting text. */
static final String GREETING =
"Welcome to KISS!\n\nThis is the kernel introspection system service.";
/** {@inheritDoc} */
@Override
public Object getParent(Object element) {
if(element == IKernelIntrospectionSystemService.getInstance()) {
return KernelIntrospectionSystemService.class;
}
if(element instanceof IIntrospectiveKernelService) {
return IKernelIntrospectionSystemService.getInstance();
}
return null;
public String getFXMLLocation() {
return "KISSServices.fxml";
}
/** {@inheritDoc} */
@Override
public Object[] getElements(Object inputElement) {
if(inputElement == KernelIntrospectionSystemService.class) {
return new Object[] {IKernelIntrospectionSystemService.getInstance()};
}
return getChildren(inputElement);
public void initialize() {
// nothing to do
}
/** {@inheritDoc} */
@Override
public Object[] getChildren(Object parentElement) {
if(parentElement instanceof IIntrospectionItem) {
Collection<IIntrospectionItem> items =
((IIntrospectionItem)parentElement).getIntrospectionItems();
if(items != null) {
return items.stream().filter(c -> c.showInIntrospectionNavigation()).toArray();
public void changed(IIntrospectionItem selection) {
Node center = new Label("No details available!");
String descr = GREETING;
if(selection instanceof IIntrospectiveKernelService) {
IIntrospectiveKernelService ks = (IIntrospectiveKernelService)selection;
descr = ks.getIntrospectionDescription();
IIntrospectionDetailsItem item = ks.getDetailsItem();
if(item != null) {
DetailsUIHandlerBase handler =
KISSDetailsUIRegistry.getInstance().getHandler(item.getClass());
if(handler != null) {
handler.setService(ks);
handler.setDataItem(item);
center = handler.createDisplayControl();
}
}
}
return null;
label.setText(descr);
borderPane.setCenter(center);
}
}
/*******************************************************************************
* Copyright (c) 2011, 2018 fortiss GmbH.
*
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0
* which is available at https://www.apache.org/licenses/LICENSE-2.0.
*
* SPDX-License-Identifier: EPL-2.0 OR Apache-2.0
*******************************************************************************/
package org.fortiss.tooling.kernel.ui.introspection;
import org.fortiss.tooling.common.ui.javafx.AF3FXViewPart;
import org.fortiss.tooling.kernel.introspection.KernelIntrospectionSystemService;
/** View part for {@link KernelIntrospectionSystemService KISS}. */
public class KISSServicesFXViewPart extends AF3FXViewPart {
/** Constructor. */
public KISSServicesFXViewPart() throws Exception {
super(new KISSFXController(new KISSServicesFXController()), null);
}
}
DetailsUIHandlerBase.java 123df7b1e0ca97f3ed190cc725a83730f09d3bf1 GREEN
KISSDetailsUIRegistry.java e8264a46606710b58fe5e6d830b37c223d9ddced GREEN
/*-------------------------------------------------------------------------+
| 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.details;
/*******************************************************************************
* Copyright (c) 2011, 2018 fortiss GmbH.
*
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0
* which is available at https://www.apache.org/licenses/LICENSE-2.0.
*
* SPDX-License-Identifier: EPL-2.0 OR Apache-2.0
*******************************************************************************/
package org.fortiss.tooling.kernel.ui.introspection.details;
import org.eclipse.swt.custom.ScrolledComposite;
import org.eclipse.swt.widgets.Control;
import org.fortiss.tooling.kernel.introspection.IIntrospectionDetailsItem;
import org.fortiss.tooling.kernel.introspection.IIntrospectiveKernelService;
import org.fortiss.tooling.kernel.introspection.KernelIntrospectionSystemService;
import javafx.scene.Node;
/**
* Base class for factory implementations of the details view of the
* {@link KernelIntrospectionSystemService} GUI.
......@@ -28,7 +24,6 @@ import org.fortiss.tooling.kernel.introspection.KernelIntrospectionSystemService
* @author hoelzl
*/
public abstract class DetailsUIHandlerBase {
/** The {@link IIntrospectionDetailsItem data item}. */
protected IIntrospectiveKernelService service;
/** The {@link IIntrospectionDetailsItem data item}. */
......@@ -44,6 +39,6 @@ public abstract class DetailsUIHandlerBase {
this.service = service;
}
/** Creates the control within the given parent scrolled composite. */
public abstract Control createComposite(ScrolledComposite parent);
/** Creates the control for the details display. */
public abstract Node createDisplayControl();
}
/*******************************************************************************
* Copyright (c) 2011, 2018 fortiss GmbH.
*
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0
* which is available at https://www.apache.org/licenses/LICENSE-2.0.
*
* SPDX-License-Identifier: EPL-2.0 OR Apache-2.0
*******************************************************************************/
package org.fortiss.tooling.kernel.ui.introspection.details;
import java.util.HashMap;
import org.fortiss.tooling.kernel.introspection.IIntrospectionDetailsItem;
import org.fortiss.tooling.kernel.introspection.IIntrospectionItem;
import org.fortiss.tooling.kernel.introspection.items.ConnectionCompositorKISSDetailsItem;
import org.fortiss.tooling.kernel.introspection.items.ConstraintCheckerKISSDetailsItem;
import org.fortiss.tooling.kernel.introspection.items.EclipseResourceStorageKISSDetailsItem;
import org.fortiss.tooling.kernel.introspection.items.ElementCompositorKISSDetailsItem;
import org.fortiss.tooling.kernel.introspection.items.LibraryKISSDetailsItem;
import org.fortiss.tooling.kernel.introspection.items.MigrationKISSDetailsItem;
import org.fortiss.tooling.kernel.introspection.items.PersistencyKISSDetailsItem;
import org.fortiss.tooling.kernel.introspection.items.PrototypeKISSDetailsItem;
import org.fortiss.tooling.kernel.introspection.items.TransformationKISSDetailsItem;
import org.fortiss.tooling.kernel.ui.introspection.details.handler.AllocationEditPartFactoryKISSDetailsUIHandler;
import org.fortiss.tooling.kernel.ui.introspection.details.handler.ConnectionCompositorKISSDetailsUIHandler;
import org.fortiss.tooling.kernel.ui.introspection.details.handler.ConstraintCheckerKISSDetailsUIHandler;
import org.fortiss.tooling.kernel.ui.introspection.details.handler.ContextMenuKISSDetailsUIHandler;
import org.fortiss.tooling.kernel.ui.introspection.details.handler.EclipseResourceStorageKISSDetailsUIHandler;
import org.fortiss.tooling.kernel.ui.introspection.details.handler.EditPartFactoryKISSDetailsUIHandler;
import org.fortiss.tooling.kernel.ui.introspection.details.handler.ElementCompositorKISSDetailsUIHandler;
import org.fortiss.tooling.kernel.ui.introspection.details.handler.LibraryKISSDetailsUIHandler;
import org.fortiss.tooling.kernel.ui.introspection.details.handler.MigrationKISSDetailsUIHandler;
import org.fortiss.tooling.kernel.ui.introspection.details.handler.ModelEditorBindingKISSDetailsUIHandler;
import org.fortiss.tooling.kernel.ui.introspection.details.handler.ModelElementHandlerKISSDetailsUIHandler;
import org.fortiss.tooling.kernel.ui.introspection.details.handler.PersistencyKISSDetailsUIHandler;
import org.fortiss.tooling.kernel.ui.introspection.details.handler.PrototypeKISSDetailsUIHandler;
import org.fortiss.tooling.kernel.ui.introspection.details.handler.TransformationKISSDetailsUIHandler;
import org.fortiss.tooling.kernel.ui.introspection.items.AllocationEditPartFactoryKISSDetailsItem;
import org.fortiss.tooling.kernel.ui.introspection.items.ContextMenuKISSDetailsItem;
import org.fortiss.tooling.kernel.ui.introspection.items.EditPartFactoryKISSDetailsItem;
import org.fortiss.tooling.kernel.ui.introspection.items.ModelEditorBindingKISSDetailsItem;
import org.fortiss.tooling.kernel.ui.introspection.items.ModelElementHandlerKISSDetailsItem;
/** Registry class to provide the details GUI for a given {@link IIntrospectionItem}. */
public final class KISSDetailsUIRegistry {
/** Returns the singleton instance of the service. */
private static final KISSDetailsUIRegistry INSTANCE = new KISSDetailsUIRegistry();
/** Returns the singleton instance. */
public static KISSDetailsUIRegistry getInstance() {
return INSTANCE;
}
/** The registry. */
private final HashMap<Class<? extends IIntrospectionDetailsItem>, DetailsUIHandlerBase> registry =
new HashMap<Class<? extends IIntrospectionDetailsItem>, DetailsUIHandlerBase>();
/** Constructor. */
public KISSDetailsUIRegistry() {
registerHandler(AllocationEditPartFactoryKISSDetailsItem.class,
new AllocationEditPartFactoryKISSDetailsUIHandler());
registerHandler(ConnectionCompositorKISSDetailsItem.class,
new ConnectionCompositorKISSDetailsUIHandler());
registerHandler(ConstraintCheckerKISSDetailsItem.class,
new ConstraintCheckerKISSDetailsUIHandler());
registerHandler(ContextMenuKISSDetailsItem.class,
new ContextMenuKISSDetailsUIHandler());
registerHandler(EclipseResourceStorageKISSDetailsItem.class,
new EclipseResourceStorageKISSDetailsUIHandler());
registerHandler(EditPartFactoryKISSDetailsItem.class,
new EditPartFactoryKISSDetailsUIHandler());
registerHandler(ElementCompositorKISSDetailsItem.class,
new ElementCompositorKISSDetailsUIHandler());
registerHandler(LibraryKISSDetailsItem.class,
new LibraryKISSDetailsUIHandler());
registerHandler(MigrationKISSDetailsItem.class,
new MigrationKISSDetailsUIHandler());
registerHandler(ModelEditorBindingKISSDetailsItem.class,
new ModelEditorBindingKISSDetailsUIHandler());
registerHandler(ModelElementHandlerKISSDetailsItem.class,
new ModelElementHandlerKISSDetailsUIHandler());
registerHandler(PrototypeKISSDetailsItem.class,
new PrototypeKISSDetailsUIHandler());
registerHandler(PersistencyKISSDetailsItem.class,
new PersistencyKISSDetailsUIHandler());
registerHandler(TransformationKISSDetailsItem.class,
new TransformationKISSDetailsUIHandler());
}
/** Registers the given composite */
public void registerHandler(Class<? extends IIntrospectionDetailsItem> clazz,
DetailsUIHandlerBase detailsHandler) {
registry.put(clazz, detailsHandler);
}
/** Returns the composite factory for the given class. */
public DetailsUIHandlerBase getHandler(Class<? extends IIntrospectionDetailsItem> clazz) {
return registry.get(clazz);
}
}
AllocationEditPartFactoryKISSDetailsUIHandler.java 96794fac55a7d37451d361312a0c4314695ede83 GREEN
ConnectionCompositorKISSDetailsUIHandler.java ebc85ae220655ca741af69c8957a8dd018de013d GREEN
ConstraintCheckerKISSDetailsUIHandler.java a4472923f74039e53162bac35694f0c01857315a GREEN
ContextMenuKISSDetailsUIHandler.java 6e329ca7f4e4919285a743cf49fba90e3789fcab GREEN
EObjectAware2KISSDetailsUIHandlerBase.java 301276017de4db9bdd7fb90df09eaba8342a9e26 GREEN
EObjectAwareKISSDetailsUIHandlerBase.java ff5a70e09a5a556cd7848179ca07031c87a3a17e GREEN
EclipseResourceStorageKISSDetailsUIHandler.java b4a8d448631af61f79196e2b225aec586a77179d GREEN
EditPartFactoryKISSDetailsUIHandler.java 6f04164781420e096cfbafa889449b037df11df2 GREEN
ElementCompositorKISSDetailsUIHandler.java 9d416344ef4ae563a3d17ed81344c2b11bea1aa7 GREEN
KISSDetailsUIHandlerBase.java 5008ec4bd54df3f7dbd91463a859dd955db5532b GREEN
LibraryKISSDetailsUIHandler.java 47fe04336719264f697847671c7ec6fdacaf71ba GREEN
MigrationKISSDetailsUIHandler.java eff83731e0115c0dff73b21438199e20b645ce39 GREEN
ModelEditorBindingKISSDetailsUIHandler.java 324aa57296919b09c882ab415b90507267c5f75e GREEN
ModelElementHandlerKISSDetailsUIHandler.java 3a20a86d7e053e7c7801e9f895628e451c93077b GREEN
PersistencyKISSDetailsUIHandler.java 05d704220db19e0e31fb94ada2ddfc4dd6f28355 GREEN
PrototypeKISSDetailsUIHandler.java 772e56f5ac42d719b93b4de894e3893528c47f7b GREEN
TransformationKISSDetailsUIHandler.java f3641f3cc43df7b285badee15c31261f1a83a51b GREEN
......@@ -13,56 +13,56 @@
| See the License for the specific language governing permissions and |
| limitations under the License. |
+--------------------------------------------------------------------------*/
package org.fortiss.tooling.kernel.ui.internal.introspection.details.handler;
package org.fortiss.tooling.kernel.ui.introspection.details.handler;
import org.eclipse.jface.viewers.ITreeContentProvider;
import org.eclipse.swt.custom.ScrolledComposite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Tree;
import org.fortiss.tooling.kernel.introspection.items.EObjectAwareIntrospectionDetailsItemBase;
import org.fortiss.tooling.common.ui.javafx.control.treetableview.DynamicTreeContentProviderBase;
import org.fortiss.tooling.common.ui.javafx.control.treetableview.DynamicTreeTableViewer;
import org.fortiss.tooling.kernel.introspection.items.EObjectAwareKISSDetailsItemBase;
import org.fortiss.tooling.kernel.ui.internal.AllocationEditPartFactoryService;
import org.fortiss.tooling.kernel.ui.internal.introspection.details.DetailsUIHandlerBase;
import org.fortiss.tooling.kernel.ui.internal.introspection.items.AllocationEditPartFactoryServiceIntrospectionDetailsItem;
import org.fortiss.tooling.kernel.ui.introspection.details.DetailsUIHandlerBase;
import org.fortiss.tooling.kernel.ui.introspection.items.AllocationEditPartFactoryKISSDetailsItem;
import javafx.scene.Node;
/**
* {@link DetailsUIHandlerBase} for {@link AllocationEditPartFactoryService}.
*
* @author hoelzl
*/
public class AllocationEditPartFactoryServiceIntrospectionDetailsUIHandler
extends EObjectAwareIntrospectionDetailsUIHandlerBase {
public class AllocationEditPartFactoryKISSDetailsUIHandler
extends EObjectAwareKISSDetailsUIHandlerBase {
/** {@inheritDoc} */
@Override
public Control createComposite(ScrolledComposite parent) {
public Node createDisplayControl() {
String heading = "Type to search registered allocation editpart factories:";
String footer = "Number of currently registered allocation editpart factories: " +
getInputObject().countHandlers();
return createFilteredTreeInTabFolder(parent, heading, footer, "Registered Factories");
getRootObject().countHandlers();
return createFilteredTree(heading, footer);
}
/** {@inheritDoc} */
@Override
protected void createTreeColumns(Tree tree) {
protected void createTreeColumns(DynamicTreeTableViewer<Object> tree) {
createDefaultTreeColumns(tree, "Class / Factory", 250, "Factory Class", 400,
"EObject Class", 400);
}
/** {@inheritDoc} */
@Override
protected ITreeContentProvider createContentProvider() {
protected DynamicTreeContentProviderBase<Object> createContentProvider() {
return new EObjectAwareTreeContentProviderBase() {
@Override
protected EObjectAwareIntrospectionDetailsItemBase<?> getInputObject() {
return AllocationEditPartFactoryServiceIntrospectionDetailsUIHandler.this
.getInputObject();
protected EObjectAwareKISSDetailsItemBase<?> getInputObject() {
return AllocationEditPartFactoryKISSDetailsUIHandler.this
.getRootObject();
}
};
}
/** {@inheritDoc} */
@Override
protected AllocationEditPartFactoryServiceIntrospectionDetailsItem getInputObject() {
return (AllocationEditPartFactoryServiceIntrospectionDetailsItem)dataItem;
protected AllocationEditPartFactoryKISSDetailsItem getRootObject() {
return (AllocationEditPartFactoryKISSDetailsItem)dataItem;
}
}
/*******************************************************************************
* Copyright (c) 2011, 2018 fortiss GmbH.
*
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0
* which is available at https://www.apache.org/licenses/LICENSE-2.0.
*
* SPDX-License-Identifier: EPL-2.0 OR Apache-2.0
*******************************************************************************/
package org.fortiss.tooling.kernel.ui.introspection.details.handler;
import org.fortiss.tooling.common.ui.javafx.control.treetableview.DynamicTreeContentProviderBase;
import org.fortiss.tooling.common.ui.javafx.control.treetableview.DynamicTreeTableViewer;
import org.fortiss.tooling.kernel.introspection.items.ConnectionCompositorKISSDetailsItem;
import org.fortiss.tooling.kernel.introspection.items.EObjectAware2KISSDetailsItemBase;
import org.fortiss.tooling.kernel.service.IConnectionCompositorService;
import javafx.scene.Node;
/**
* Introspection UI handler for the {@link IConnectionCompositorService}.
*
* @author hoelzl
*/
public final class ConnectionCompositorKISSDetailsUIHandler
extends EObjectAware2KISSDetailsUIHandlerBase {
/** {@inheritDoc} */
@Override
public Node createDisplayControl() {
String heading = "Type to search registered connection compositors:";
String footer = "Number of currently registered connection compositors: " +
getRootObject().countHandlers();
return createFilteredTree(heading, footer);
}
/** {@inheritDoc} */
@Override
protected void createTreeColumns(DynamicTreeTableViewer<Object> tree) {
createDefaultTreeColumns(tree, "Source / Target / Compositor", 250, "Compositor Class", 400,
"Source EObject Class", 400, "Target EObject Class", 400);
}
/** {@inheritDoc} */
@Override
protected DynamicTreeContentProviderBase<Object> createContentProvider() {
return new EObjectAware2TreeContentProviderBase() {
@Override
protected EObjectAware2KISSDetailsItemBase<?> getInputObject() {
return ConnectionCompositorKISSDetailsUIHandler.this.getRootObject();
}
};
}
/** {@inheritDoc} */
@Override
protected ConnectionCompositorKISSDetailsItem getRootObject() {
return (ConnectionCompositorKISSDetailsItem)dataItem;
}
}
/*******************************************************************************
* Copyright (c) 2011, 2018 fortiss GmbH.
*
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0
* which is available at https://www.apache.org/licenses/LICENSE-2.0.
*
* SPDX-License-Identifier: EPL-2.0 OR Apache-2.0
*******************************************************************************/
package org.fortiss.tooling.kernel.ui.introspection.details.handler;
import java.util.Collection;
import org.eclipse.emf.ecore.EObject;
import org.fortiss.tooling.common.ui.javafx.control.treetableview.DynamicTreeContentProviderBase;
import org.fortiss.tooling.common.ui.javafx.control.treetableview.DynamicTreeTableUIProviderBase;
import org.fortiss.tooling.common.ui.javafx.control.treetableview.DynamicTreeTableViewer;
import org.fortiss.tooling.kernel.extension.IConstraintChecker;
import org.fortiss.tooling.kernel.introspection.IIntrospectionItem;
import org.fortiss.tooling.kernel.introspection.items.ConstraintCheckerKISSDetailsItem;
import org.fortiss.tooling.kernel.service.IConstraintCheckerService;
import javafx.scene.Node;
import javafx.scene.control.ContextMenu;
/**
* Introspection UI handler for {@link IIntrospectionItem}s provided by
* {@link IConstraintCheckerService}.
*
* @author hoelzl
*/
public final class ConstraintCheckerKISSDetailsUIHandler extends KISSDetailsUIHandlerBase {
/** {@inheritDoc} */
@Override
public Node createDisplayControl() {
String h = "Type to search registered checkers:";
String f = "Number of registered constraint checkers: " + countCheckers();
return createFilteredTree(h, f);
}
/** Computes the number of constraint checkers. */
private int countCheckers() {
int count = 0;
for(Class<?> c : getRootObject().getHandlerKeyClasses()) {
count += getRootObject().getHandlerList(c).size();
}
return count;
}
/** {@inheritDoc} */
@Override
protected void createTreeColumns(DynamicTreeTableViewer<Object> tree) {
tree.addColumn("Model Element / Checker", 400);
tree.addColumn("Model Element Class", 400);
tree.addColumn("Constraint Checker Implementation Class", 400);
}
/** {@inheritDoc} */
@Override
protected DynamicTreeContentProviderBase<Object> createContentProvider() {
return new DynamicTreeContentProviderBase<Object>() {
/** {@inheritDoc} */
@Override
protected Collection<? extends Object> getChildren(Object parent) {
if(parent == getRootObject()) {
return getRootObject().getHandlerKeyClasses();
} else if(parent instanceof Class) {
return getRootObject().getHandlerList((Class<?>)parent);
}
return null;
}
};
}
/** {@inheritDoc} */
@SuppressWarnings("unchecked")
@Override
protected DynamicTreeTableUIProviderBase<Object> createUIProvider() {
return new DynamicTreeTableUIProviderBase<Object>() {
@Override
public Node getIconNode(Object element, int column) {
return null;
}
@Override
public String getLabel(Object data, int column) {
if(data instanceof Class) {
switch(column) {
case 0:
return ((Class<?>)data).getSimpleName();
case 1:
return ((Class<?>)data).getName();
}
} else if(data instanceof IConstraintChecker) {
IConstraintChecker<EObject> icc = (IConstraintChecker<EObject>)data;
switch(column) {
case 0:
return icc.getClass().getSimpleName();
case 2:
return icc.getClass().getName();
}
}
return null;
}
/** {@inheritDoc} */
@Override
public ContextMenu createContextMenu(Object element, int column) {
if(element instanceof Class) {
return createCopyClassNameMenuItem((Class<?>)element);
}
if(element instanceof IConstraintChecker<?>) {
return createCopyClassNameMenuItem(element.getClass());
}
return null;
}
};
}
/** {@inheritDoc} */
@Override
protected ConstraintCheckerKISSDetailsItem getRootObject() {
return (ConstraintCheckerKISSDetailsItem)dataItem;
}
}
/*******************************************************************************
* Copyright (c) 2011, 2018 fortiss GmbH.
*
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0
* which is available at https://www.apache.org/licenses/LICENSE-2.0.
*
* SPDX-License-Identifier: EPL-2.0 OR Apache-2.0
*******************************************************************************/
package org.fortiss.tooling.kernel.ui.introspection.details.handler;
import static java.util.Arrays.asList;
import static java.util.stream.Collectors.toList;
import java.util.Collection;
import org.fortiss.tooling.common.ui.javafx.control.treetableview.DynamicTreeContentProviderBase;
import org.fortiss.tooling.common.ui.javafx.control.treetableview.DynamicTreeTableUIProviderBase;
import org.fortiss.tooling.common.ui.javafx.control.treetableview.DynamicTreeTableViewer;
import org.fortiss.tooling.kernel.introspection.IIntrospectionItem;
import org.fortiss.tooling.kernel.service.IConstraintCheckerService;
import org.fortiss.tooling.kernel.ui.extension.IContextMenuContributor;
import org.fortiss.tooling.kernel.ui.introspection.items.ContextMenuKISSDetailsItem;
import org.fortiss.tooling.kernel.ui.service.IContextMenuService;
import javafx.scene.Node;
import javafx.scene.control.ContextMenu;
/**
* Introspection UI handler for {@link IIntrospectionItem}s provided by
* {@link IConstraintCheckerService}.
*
* @author hoelzl
*/
public final class ContextMenuKISSDetailsUIHandler extends KISSDetailsUIHandlerBase {
/** {@inheritDoc} */
@Override
public Node createDisplayControl() {
String h = "Type to search registered menu contributors:";
String f = "Number of registered menu contributors: " +
getRootObject().getHandlerList().size();
return createFilteredTree(h, f);
}
/** {@inheritDoc} */
@Override
protected void createTreeColumns(DynamicTreeTableViewer<Object> tree) {
tree.addColumn("Menu Section", 400);
tree.addColumn("Menu Provider Class", 500);
}
/** {@inheritDoc} */
@Override
protected DynamicTreeContentProviderBase<Object> createContentProvider() {
return new DynamicTreeContentProviderBase<Object>() {
/** {@inheritDoc} */
@Override
protected Collection<? extends Object> getChildren(Object parent) {
if(parent == getRootObject()) {
return asList(IContextMenuService.MENU_SECTION_IDS);
} else if(parent instanceof String) {
return getRootObject().getHandlerList().stream()
.filter(h -> parent.equals(h.getMenuSectionID())).collect(toList());
}
return null;
}
};
}
/** {@inheritDoc} */
@Override
protected DynamicTreeTableUIProviderBase<Object> createUIProvider() {
return new DynamicTreeTableUIProviderBase<Object>() {
@Override
public Node getIconNode(Object element, int column) {
return null;
}
@Override
public String getLabel(Object data, int column) {
if(data instanceof String && column == 0) {
return (String)data;
} else if(data instanceof IContextMenuContributor) {
IContextMenuContributor icc = (IContextMenuContributor)data;
switch(column) {
case 0:
return icc.getClass().getSimpleName();
case 1:
return icc.getClass().getName();
}
}
return null;
}
/** {@inheritDoc} */
@Override
public ContextMenu createContextMenu(Object element, int column) {
if(element instanceof IContextMenuContributor) {
return createCopyClassNameMenuItem(element.getClass());
}
return null;
}
};
}
/** {@inheritDoc} */
@Override
protected ContextMenuKISSDetailsItem getRootObject() {
return (ContextMenuKISSDetailsItem)dataItem;
}
}
/*-------------------------------------------------------------------------+
| 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.details.handler;
/*******************************************************************************
* Copyright (c) 2011, 2018 fortiss GmbH.
*
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0
* which is available at https://www.apache.org/licenses/LICENSE-2.0.
*
* SPDX-License-Identifier: EPL-2.0 OR Apache-2.0
*******************************************************************************/
package org.fortiss.tooling.kernel.ui.introspection.details.handler;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Comparator;
import java.util.List;
import org.conqat.ide.commons.ui.jface.TreeContentProviderBase;
import org.conqat.lib.commons.collections.Pair;
import org.eclipse.jface.action.MenuManager;
import org.eclipse.jface.viewers.ITableLabelProvider;
import org.eclipse.jface.viewers.TableLabelProviderBase;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Tree;
import org.eclipse.swt.widgets.TreeColumn;
import org.eclipse.ui.dialogs.PatternFilter;
import org.fortiss.tooling.kernel.introspection.items.EObjectAware2IntrospectionDetailsItemBase;
import org.apache.commons.lang3.tuple.ImmutablePair;
import org.apache.commons.lang3.tuple.Pair;
import org.fortiss.tooling.common.ui.javafx.control.treetableview.DynamicTreeContentProviderBase;
import org.fortiss.tooling.common.ui.javafx.control.treetableview.DynamicTreeTableUIProviderBase;
import org.fortiss.tooling.common.ui.javafx.control.treetableview.DynamicTreeTableViewer;
import org.fortiss.tooling.kernel.introspection.items.EObjectAware2KISSDetailsItemBase;
import javafx.scene.Node;
import javafx.scene.control.ContextMenu;
/**
* Base class for details UI implementations with filtered tree viewer.
*
* @author hoelzl
*/
public abstract class EObjectAware2IntrospectionDetailsUIHandlerBase
extends IntrospectionDetailsUIHandlerBase {
public abstract class EObjectAware2KISSDetailsUIHandlerBase extends KISSDetailsUIHandlerBase {
/** Creates the default tree columns. */
protected final void createDefaultTreeColumns(Tree tree, String text0, int width0, String text1,
int width1, String text2, int width2, String text3, int width3) {
TreeColumn col0 = new TreeColumn(tree, SWT.LEFT);
col0.setText(text0);
col0.setWidth(width0);
TreeColumn col1 = new TreeColumn(tree, SWT.LEFT);
col1.setText(text1);
col1.setWidth(width1);
TreeColumn col2 = new TreeColumn(tree, SWT.LEFT);
col2.setText(text2);
col2.setWidth(width2);
TreeColumn col3 = new TreeColumn(tree, SWT.LEFT);
col3.setText(text3);
col3.setWidth(width3);
protected final void createDefaultTreeColumns(DynamicTreeTableViewer<Object> viewer,
String text0, int width0, String text1, int width1, String text2, int width2,
String text3, int width3) {
viewer.addColumn(text0, width0);
viewer.addColumn(text1, width1);
viewer.addColumn(text2, width2);
viewer.addColumn(text3, width3);
}
/** {@inheritDoc} */
@Override
protected ITableLabelProvider createLabelProvider() {
protected DynamicTreeTableUIProviderBase<Object> createUIProvider() {
return new EObjectAware2TableLabelProvider();
}
/** {@inheritDoc} */
@Override
protected PatternFilter createPatternFilter() {
PatternFilter pf = new TableViewerPatternFilter();
pf.setIncludeLeadingWildcard(true);
return pf;
}
/** Table label provider for handler registrations with two classes. */
protected static class EObjectAware2TableLabelProvider extends TableLabelProviderBase {
protected class EObjectAware2TableLabelProvider extends DynamicTreeTableUIProviderBase<Object> {
/** {@inheritDoc} */
@Override
public String getColumnText(Object element, int columnIndex) {
public String getLabel(Object element, int columnIndex) {
if(element instanceof Class) {
return columnIndex == 0 ? ((Class<?>)element).getSimpleName() : "";
}
if(element instanceof Pair) {
Pair<?, ?> pair = (Pair<?, ?>)element;
if(pair.getFirst() instanceof Class) {
Class<?> c = (Class<?>)((Pair<?, ?>)element).getSecond();
if(pair.getLeft() instanceof Class) {
Class<?> c = (Class<?>)((Pair<?, ?>)element).getRight();
return columnIndex == 0 ? c.getSimpleName() : "";
}
if(pair.getFirst() != null) {
Object provider = pair.getFirst();
Pair<?, ?> regClasses = (Pair<?, ?>)pair.getSecond();
Class<?> sourceClass = (Class<?>)regClasses.getFirst();
Class<?> targetClass = (Class<?>)regClasses.getSecond();
if(pair.getLeft() != null) {
Object provider = pair.getLeft();
Pair<?, ?> regClasses = (Pair<?, ?>)pair.getRight();
Class<?> sourceClass = (Class<?>)regClasses.getLeft();
Class<?> targetClass = (Class<?>)regClasses.getRight();
switch(columnIndex) {
case 0:
return provider.getClass().getSimpleName();
......@@ -104,76 +82,102 @@ public abstract class EObjectAware2IntrospectionDetailsUIHandlerBase
}
return "";
}
/** {@inheritDoc} */
@Override
public Node getIconNode(Object element, int column) {
return null;
}
/** {@inheritDoc} */
@Override
public ContextMenu createContextMenu(Object element, int column) {
if(element instanceof Pair) {
Pair<?, ?> pair = (Pair<?, ?>)element;
if(pair.getLeft() != null && pair.getRight() instanceof Pair) {
Pair<?, ?> rightPair = (Pair<?, ?>)pair.getRight();
switch(column) {
case 0:
break;
case 1:
Class<?> handlerClass = pair.getLeft().getClass();
return createCopyClassNameMenuItem(handlerClass);
case 2:
Class<?> srcClass = (Class<?>)rightPair.getLeft();
return createCopyClassNameMenuItem(srcClass);
case 3:
Class<?> trgClass = (Class<?>)rightPair.getRight();
return createCopyClassNameMenuItem(trgClass);
default:
}
}
}
return null;
}
}
/** Tree content provider for handler registrations with two classes. */
protected static abstract class EObjectAware2TreeContentProviderBase
extends TreeContentProviderBase {
extends DynamicTreeContentProviderBase<Object> {
/** Returns the input object for this content provider. */
protected abstract EObjectAware2IntrospectionDetailsItemBase<?> getInputObject();
protected abstract EObjectAware2KISSDetailsItemBase<?> getInputObject();
/** {@inheritDoc} */
@Override
public Object[] getChildren(Object parentElement) {
public Collection<? extends Object> getChildren(Object parentElement) {
if(parentElement == getInputObject()) {
return getInputObject().getFirstHandlerKeyClasses().toArray();
return getInputObject().getFirstHandlerKeyClasses();
}
if(parentElement instanceof Class<?>) {
Class<?> firstClass = (Class<?>)parentElement;
Collection<Class<?>> secondaryClasses =
getInputObject().getSecondHandlerKeyClasses(firstClass);
if(secondaryClasses == null || secondaryClasses.isEmpty()) {
return new Object[0];
return null;
}
Pair<?, ?>[] pairs = new Pair<?, ?>[secondaryClasses.size()];
int idx = 0;
Collection<Pair<?, ?>> pairs = new ArrayList<Pair<?, ?>>(secondaryClasses.size());
for(Class<?> secondary : secondaryClasses) {
pairs[idx] = new Pair<Class<?>, Class<?>>(firstClass, secondary);
idx++;
pairs.add(new ImmutablePair<Class<?>, Class<?>>(firstClass, secondary));
}
return pairs;
}
if(parentElement instanceof Pair) {
Pair<?, ?> pair = (Pair<?, ?>)parentElement;
if(pair.getFirst() instanceof Class) {
Class<?> first = (Class<?>)pair.getFirst();
Class<?> second = (Class<?>)pair.getSecond();
if(pair.getLeft() instanceof Class) {
Class<?> first = (Class<?>)pair.getLeft();
Class<?> second = (Class<?>)pair.getRight();
List<?> handlerList = getInputObject().getHandlerList(first, second);
if(handlerList == null || handlerList.isEmpty()) {
return new Object[0];
return null;
}
Pair<?, ?>[] pairs = new Pair<?, ?>[handlerList.size()];
int idx = 0;
Collection<Pair<?, ?>> pairs = new ArrayList<Pair<?, ?>>(handlerList.size());
for(Object handler : handlerList) {
pairs[idx] = new Pair<Object, Pair<?, ?>>(handler, pair);
idx++;
pairs.add(new ImmutablePair<Object, Pair<?, ?>>(handler, pair));
}
return pairs;
}
// no children for handlers
}
return new Object[0];
}
}
/** {@inheritDoc} */
@Override
protected boolean testSelection(Object selection) {
if(selection instanceof Pair<?, ?>) {
Pair<?, ?> pair = (Pair<?, ?>)selection;
return !(pair.getFirst() instanceof Class<?>);
return null;
}
return false;
}
/** {@inheritDoc} */
@Override
protected void populateContextMenu(Object selection, MenuManager mgr) {
Pair<?, ?> pair = (Pair<?, ?>)selection;
mgr.add(createCopyClassNameAction(pair.getFirst().getClass()));
Pair<?, ?> classPair = (Pair<?, ?>)pair.getSecond();
mgr.add(createCopyClassNameAction((Class<?>)classPair.getFirst()));
mgr.add(createCopyClassNameAction((Class<?>)classPair.getSecond()));
protected Comparator<Object> createSorter() {
return (o1, o2) -> {
if(o1 instanceof Pair && o2 instanceof Pair) {
Pair<?, ?> pair1 = (Pair<?, ?>)o1;
Pair<?, ?> pair2 = (Pair<?, ?>)o2;
o1 = pair1.getLeft().getClass();
o2 = pair2.getLeft().getClass();
// fall through to next if statement
}
if(o1 instanceof Class && o2 instanceof Class) {
return ((Class<?>)o1).getSimpleName().compareTo(((Class<?>)o2).getSimpleName());
}
return 0;
};
}
}
/*******************************************************************************
* Copyright (c) 2011, 2018 fortiss GmbH.
*
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0
* which is available at https://www.apache.org/licenses/LICENSE-2.0.
*
* SPDX-License-Identifier: EPL-2.0 OR Apache-2.0
*******************************************************************************/
package org.fortiss.tooling.kernel.ui.introspection.details.handler;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Comparator;
import java.util.List;
import org.apache.commons.lang3.tuple.ImmutablePair;
import org.apache.commons.lang3.tuple.Pair;
import org.fortiss.tooling.common.ui.javafx.control.treetableview.DynamicTreeContentProviderBase;
import org.fortiss.tooling.common.ui.javafx.control.treetableview.DynamicTreeTableUIProviderBase;
import org.fortiss.tooling.common.ui.javafx.control.treetableview.DynamicTreeTableViewer;
import org.fortiss.tooling.kernel.introspection.items.EObjectAwareKISSDetailsItemBase;
import javafx.scene.Node;
import javafx.scene.control.ContextMenu;
/**
* Base class for details UI implementations with filtered tree viewer.
*
* @author hoelzl
*/
public abstract class EObjectAwareKISSDetailsUIHandlerBase extends KISSDetailsUIHandlerBase {
/** Creates the default tree columns. */
protected final void createDefaultTreeColumns(DynamicTreeTableViewer<Object> viewer,
String text0, int width0, String text1, int width1, String text2, int width2) {
viewer.addColumn(text0, width0);
viewer.addColumn(text1, width1);
viewer.addColumn(text2, width2);
}
/** {@inheritDoc} */
@Override
protected DynamicTreeTableUIProviderBase<Object> createUIProvider() {
return new DynamicTreeTableUIProviderBase<Object>() {
@Override
public String getLabel(Object element, int column) {
if(element instanceof Class) {
return column == 0 ? ((Class<?>)element).getSimpleName() : "";
}
if(element instanceof Pair) {
Pair<?, ?> pair = (Pair<?, ?>)element;
if(pair.getLeft() != null) {
Object provider = pair.getLeft();
Class<?> regClass = (Class<?>)pair.getRight();
switch(column) {
case 0:
return provider.getClass().getSimpleName();
case 1:
return provider.getClass().getName();
case 2:
return regClass.getName();
}
}
}
return "";
}
@Override
public Node getIconNode(Object element, int column) {
return null;
}
/** {@inheritDoc} */
@Override
public ContextMenu createContextMenu(Object element, int column) {
if(element instanceof Pair) {
Pair<?, ?> pair = (Pair<?, ?>)element;
if(pair.getLeft() == null) {
return null;
}
Object provider = pair.getLeft();
Class<?> regClass = (Class<?>)pair.getRight();
switch(column) {
case 0:
break;
case 1:
return createCopyClassNameMenuItem(provider.getClass());
case 2:
return createCopyClassNameMenuItem(regClass);
default:
}
}
return null;
}
};
}
/** {@inheritDoc} */
@Override
protected boolean testObjectFilter(String filterExpression, Object element) {
Class<?> toMatch = null;
if(element instanceof Class) {
toMatch = (Class<?>)element;
} else if(element instanceof Pair) {
Pair<?, ?> pair = (Pair<?, ?>)element;
if(pair.getLeft() != null) {
toMatch = pair.getLeft().getClass();
}
}
if(toMatch == null) {
return false;
}
filterExpression = filterExpressionSanityCheck(filterExpression);
return toMatch.getSimpleName().matches(filterExpression);
}
/** {@inheritDoc} */
@Override
protected Comparator<Object> createSorter() {
return (o1, o2) -> {
if(o1 instanceof Pair && o2 instanceof Pair) {
Pair<?, ?> pair1 = (Pair<?, ?>)o1;
Pair<?, ?> pair2 = (Pair<?, ?>)o2;
o1 = pair1.getLeft().getClass();
o2 = pair2.getLeft().getClass();
// fall through to next if statement
}
if(o1 instanceof Class && o2 instanceof Class) {
return ((Class<?>)o1).getSimpleName().compareTo(((Class<?>)o2).getSimpleName());
}
return 0;
};
}
/** Tree content provider for handler registrations with two classes. */
protected static abstract class EObjectAwareTreeContentProviderBase
extends DynamicTreeContentProviderBase<Object> {
/** Returns the input object for this content provider. */
protected abstract EObjectAwareKISSDetailsItemBase<?> getInputObject();
/** {@inheritDoc} */
@Override
public Collection<? extends Object> getChildren(Object parentElement) {
if(parentElement == getInputObject()) {
return getInputObject().getHandlerKeyClasses();
}
if(parentElement instanceof Class<?>) {
Class<?> regClass = (Class<?>)parentElement;
List<?> handlerList = getInputObject().getHandlerList(regClass);
if(handlerList == null || handlerList.isEmpty()) {
return null;
}
Collection<Pair<?, ?>> pairs = new ArrayList<Pair<?, ?>>(handlerList.size());
for(Object handler : handlerList) {
pairs.add(new ImmutablePair<Object, Class<?>>(handler, regClass));
}
return pairs;
}
return null;
}
}
}