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

Introspection UI for the connection compositor service including some clean up of classes and code.

refs 2460
parent bc1c9282
No related branches found
No related tags found
No related merge requests found
Showing
with 288 additions and 89 deletions
......@@ -21,10 +21,12 @@ 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.ConnectionCompositorServiceIntrospectionDetailsItem;
import org.fortiss.tooling.kernel.introspection.items.ConstraintCheckerServiceIntrospectionDetailsItem;
import org.fortiss.tooling.kernel.introspection.items.PersistencyServiceIntrospectionDetailsItem;
import org.fortiss.tooling.kernel.introspection.items.PrototypeServiceIntrospectionDetailsItem;
import org.fortiss.tooling.kernel.introspection.items.TransformationServiceIntrospectionDetailsItem;
import org.fortiss.tooling.kernel.ui.internal.introspection.details.handler.ConnectionCompositorServiceIntrospectionDetailsUIHandler;
import org.fortiss.tooling.kernel.ui.internal.introspection.details.handler.ConstraintCheckerServiceIntrospectionDetailsUIHandler;
import org.fortiss.tooling.kernel.ui.internal.introspection.details.handler.ContextMenuServiceIntrospectionDetailsUIHandler;
import org.fortiss.tooling.kernel.ui.internal.introspection.details.handler.PersistencyServiceIntrospectionDetailsUIHandler;
......@@ -51,6 +53,8 @@ public final class KISSDetailsUIRegistry {
/** Constructor. */
public KISSDetailsUIRegistry() {
registerHandler(ConnectionCompositorServiceIntrospectionDetailsItem.class,
new ConnectionCompositorServiceIntrospectionDetailsUIHandler());
registerHandler(ConstraintCheckerServiceIntrospectionDetailsItem.class,
new ConstraintCheckerServiceIntrospectionDetailsUIHandler());
registerHandler(ContextMenuServiceIntrospectionDetailsItem.class,
......
/*--------------------------------------------------------------------------+
$Id$
| |
| 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;
import org.eclipse.jface.viewers.ITableLabelProvider;
import org.eclipse.jface.viewers.ITreeContentProvider;
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.ScrolledComposite;
import org.eclipse.swt.widgets.Control;
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.ConnectionCompositorServiceIntrospectionDetailsItem;
import org.fortiss.tooling.kernel.introspection.items.EObjectAware2IntrospectionDetailsItemBase;
import org.fortiss.tooling.kernel.service.IConnectionCompositorService;
/**
* Introspection UI handler for the {@link IConnectionCompositorService}.
*
* @author hoelzl
* @author $Author$
* @version $Rev$
* @ConQAT.Rating RED Hash:
*/
public final class ConnectionCompositorServiceIntrospectionDetailsUIHandler extends
EObjectAware2IntrospectionDetailsUIHandlerBase {
/** {@inheritDoc} */
@Override
public Control createComposite(ScrolledComposite parent) {
String heading = "Type to serach registered connection compositors:";
String footer =
"Number of currently registered connection compositors: " +
getInputObject().countHandlers();
return createFilteredTreeInTabFolder(parent, heading, footer, "Registered Compositors");
}
/** {@inheritDoc} */
@Override
protected void createTreeColumns(Tree tree) {
TreeColumn col0 = new TreeColumn(tree, SWT.LEFT);
col0.setText("Source / Target / Compositor");
col0.setWidth(250);
TreeColumn col1 = new TreeColumn(tree, SWT.LEFT);
col1.setText("Compositor Class");
col1.setWidth(400);
TreeColumn col2 = new TreeColumn(tree, SWT.LEFT);
col2.setText("Source EObject Class");
col2.setWidth(400);
TreeColumn col3 = new TreeColumn(tree, SWT.LEFT);
col3.setText("Target EObject Class");
col3.setWidth(400);
}
/** {@inheritDoc} */
@Override
protected ITreeContentProvider createContentProvider() {
return new EObjectAware2TreeContentProviderBase() {
@Override
protected EObjectAware2IntrospectionDetailsItemBase<?> getInputObject() {
return ConnectionCompositorServiceIntrospectionDetailsUIHandler.this
.getInputObject();
}
};
}
/** {@inheritDoc} */
@Override
protected ITableLabelProvider createLabelProvider() {
return new EObjectAware2TableLabelProvider();
}
/** {@inheritDoc} */
@Override
protected PatternFilter createPatternFilter() {
PatternFilter pf = new TableViewerPatternFilter();
pf.setIncludeLeadingWildcard(true);
return pf;
}
/** {@inheritDoc} */
@Override
protected ConnectionCompositorServiceIntrospectionDetailsItem getInputObject() {
return (ConnectionCompositorServiceIntrospectionDetailsItem)dataItem;
}
}
/*--------------------------------------------------------------------------+
$Id$
| |
| 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;
import java.util.Collection;
import java.util.List;
import org.conqat.ide.commons.ui.jface.TreeContentProviderBase;
import org.conqat.lib.commons.collections.Pair;
import org.eclipse.jface.viewers.TableLabelProviderBase;
import org.fortiss.tooling.kernel.introspection.items.EObjectAware2IntrospectionDetailsItemBase;
/**
* Base class for details UI implementations with filtered tree viewer.
*
* @author hoelzl
* @author $Author$
* @version $Rev$
* @ConQAT.Rating RED Hash:
*/
public abstract class EObjectAware2IntrospectionDetailsUIHandlerBase extends
IntrospectionDetailsUIHandlerBase {
/** Table label provider for handler registrations with two classes. */
protected static class EObjectAware2TableLabelProvider extends TableLabelProviderBase {
/** {@inheritDoc} */
@Override
public String getColumnText(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();
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();
switch(columnIndex) {
case 0:
return provider.getClass().getSimpleName();
case 1:
return provider.getClass().getName();
case 2:
return sourceClass.getName();
case 3:
return targetClass.getName();
}
}
}
return "";
}
}
/** Tree content provider for handler registrations with two classes. */
protected static abstract class EObjectAware2TreeContentProviderBase extends
TreeContentProviderBase {
/** Returns the input object for this content provider. */
protected abstract EObjectAware2IntrospectionDetailsItemBase<?> getInputObject();
/** {@inheritDoc} */
@Override
public Object[] getChildren(Object parentElement) {
if(parentElement == getInputObject()) {
return getInputObject().getFirstHandlerKeyClasses().toArray();
}
if(parentElement instanceof Class<?>) {
Class<?> firstClass = (Class<?>)parentElement;
Collection<Class<?>> secondaryClasses =
getInputObject().getSecondHandlerKeyClasses(firstClass);
if(secondaryClasses == null || secondaryClasses.isEmpty()) {
return new Object[0];
}
Pair<?, ?>[] pairs = new Pair<?, ?>[secondaryClasses.size()];
int idx = 0;
for(Class<?> secondary : secondaryClasses) {
pairs[idx] = new Pair<Class<?>, Class<?>>(firstClass, secondary);
idx++;
}
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();
List<?> handlerList = getInputObject().getHandlerList(first, second);
if(handlerList == null || handlerList.isEmpty()) {
return new Object[0];
}
Pair<?, ?>[] pairs = new Pair<?, ?>[handlerList.size()];
int idx = 0;
for(Object handler : handlerList) {
pairs[idx] = new Pair<Object, Pair<?, ?>>(handler, pair);
idx++;
}
return pairs;
}
// no children for handlers
}
return new Object[0];
}
}
}
......@@ -17,21 +17,15 @@ $Id$
+--------------------------------------------------------------------------*/
package org.fortiss.tooling.kernel.ui.internal.introspection.details.handler;
import java.util.Collection;
import java.util.List;
import org.conqat.ide.commons.ui.jface.TreeContentProviderBase;
import org.conqat.lib.commons.collections.Pair;
import org.eclipse.jface.viewers.ITableLabelProvider;
import org.eclipse.jface.viewers.ITreeContentProvider;
import org.eclipse.jface.viewers.TableLabelProviderBase;
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.ScrolledComposite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Tree;
import org.eclipse.swt.widgets.TreeColumn;
import org.eclipse.ui.dialogs.PatternFilter;
import org.fortiss.tooling.kernel.extension.ITransformationProvider;
import org.fortiss.tooling.kernel.introspection.items.EObjectAware2IntrospectionDetailsItemBase;
import org.fortiss.tooling.kernel.introspection.items.TransformationServiceIntrospectionDetailsItem;
import org.fortiss.tooling.kernel.service.ITransformationService;
......@@ -44,7 +38,7 @@ import org.fortiss.tooling.kernel.service.ITransformationService;
* @ConQAT.Rating RED Hash:
*/
public final class TransformationServiceIntrospectionDetailsUIHandler extends
IntrospectionDetailsUIHandlerBase {
EObjectAware2IntrospectionDetailsUIHandlerBase {
/** {@inheritDoc} */
@Override
......@@ -79,90 +73,18 @@ public final class TransformationServiceIntrospectionDetailsUIHandler extends
/** {@inheritDoc} */
@Override
protected ITreeContentProvider createContentProvider() {
return new TreeContentProviderBase() {
return new EObjectAware2TreeContentProviderBase() {
@Override
public Object[] getChildren(Object parentElement) {
if(parentElement == getInputObject()) {
return getInputObject().getFirstHandlerKeyClasses().toArray();
}
if(parentElement instanceof Class<?>) {
Class<?> firstClass = (Class<?>)parentElement;
Collection<Class<?>> secondaryClasses =
getInputObject().getSecondHandlerKeyClasses(firstClass);
if(secondaryClasses == null || secondaryClasses.isEmpty()) {
return new Object[0];
}
Pair<?, ?>[] pairs = new Pair<?, ?>[secondaryClasses.size()];
int idx = 0;
for(Class<?> secondary : secondaryClasses) {
pairs[idx] = new Pair<Class<?>, Class<?>>(firstClass, secondary);
idx++;
}
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();
List<ITransformationProvider> handlerList =
getInputObject().getHandlerList(first, second);
if(handlerList == null || handlerList.isEmpty()) {
return new Object[0];
}
Pair<?, ?>[] pairs = new Pair<?, ?>[handlerList.size()];
int idx = 0;
for(ITransformationProvider provider : handlerList) {
pairs[idx] =
new Pair<ITransformationProvider, Pair<?, ?>>(provider, pair);
idx++;
}
return pairs;
}
// no children for transformation providers
}
return new Object[0];
protected EObjectAware2IntrospectionDetailsItemBase<?> getInputObject() {
return TransformationServiceIntrospectionDetailsUIHandler.this.getInputObject();
}
};
}
/** {@inheritDoc} */
@Override
protected ITableLabelProvider createLabelProvider() {
return new TableLabelProviderBase() {
@Override
public String getColumnText(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();
return columnIndex == 0 ? c.getSimpleName() : "";
}
if(pair.getFirst() instanceof ITransformationProvider) {
ITransformationProvider provider = (ITransformationProvider)pair.getFirst();
Pair<?, ?> regClasses = (Pair<?, ?>)pair.getSecond();
Class<?> sourceClass = (Class<?>)regClasses.getFirst();
Class<?> targetClass = (Class<?>)regClasses.getSecond();
switch(columnIndex) {
case 0:
return provider.getClass().getSimpleName();
case 1:
return provider.getClass().getName();
case 2:
return sourceClass.getName();
case 3:
return targetClass.getName();
}
}
}
return "";
}
};
return new EObjectAware2TableLabelProvider();
}
/** {@inheritDoc} */
......
......@@ -29,6 +29,7 @@ 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.introspection.items.ConnectionCompositorServiceIntrospectionDetailsItem;
import org.fortiss.tooling.kernel.service.IConnectionCompositorService;
import org.fortiss.tooling.kernel.service.base.EObjectAware2ServiceBase;
......@@ -220,7 +221,6 @@ public class ConnectionCompositorService extends
/** {@inheritDoc} */
@Override
public IIntrospectionDetailsItem getDetailsItem() {
// TODO Auto-generated method stub
return null;
return new ConnectionCompositorServiceIntrospectionDetailsItem(handlersBySource);
}
}
/*--------------------------------------------------------------------------+
$Id$
| |
| 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.introspection.items;
import java.util.List;
import java.util.Map;
import org.eclipse.emf.ecore.EObject;
import org.fortiss.tooling.kernel.extension.IConnectionCompositor;
import org.fortiss.tooling.kernel.internal.ConnectionCompositorService;
import org.fortiss.tooling.kernel.introspection.IIntrospectionDetailsItem;
/**
* {@link IIntrospectionDetailsItem} for the {@link ConnectionCompositorService}.
*
* @author hoelzl
* @author $Author$
* @version $Rev$
* @ConQAT.Rating RED Hash:
*/
public final class ConnectionCompositorServiceIntrospectionDetailsItem
extends
EObjectAware2IntrospectionDetailsItemBase<IConnectionCompositor<EObject, EObject, EObject>> {
/** Constructor. */
public ConnectionCompositorServiceIntrospectionDetailsItem(
Map<Class<?>, Map<Class<?>, List<IConnectionCompositor<EObject, EObject, EObject>>>> handlersBySource) {
super(handlersBySource);
}
}
......@@ -40,14 +40,14 @@ import org.fortiss.tooling.kernel.introspection.IIntrospectionDetailsItem;
* @version $Rev$
* @ConQAT.Rating RED Hash:
*/
public abstract class ClassClassHandlerMapIntrospectionDetailsItemBase<T extends Object> implements
public abstract class EObjectAware2IntrospectionDetailsItemBase<T extends Object> implements
IIntrospectionDetailsItem {
/** Read-only copy of the services handler list. */
protected final Map<Class<?>, Map<Class<?>, List<T>>> handlerMap;
/** Constructor. */
public ClassClassHandlerMapIntrospectionDetailsItemBase(
public EObjectAware2IntrospectionDetailsItemBase(
Map<Class<?>, Map<Class<?>, List<T>>> handlerMap) {
this.handlerMap = handlerMap;
}
......
......@@ -33,7 +33,7 @@ import org.fortiss.tooling.kernel.service.ITransformationService;
* @ConQAT.Rating RED Hash:
*/
public final class TransformationServiceIntrospectionDetailsItem extends
ClassClassHandlerMapIntrospectionDetailsItemBase<ITransformationProvider> {
EObjectAware2IntrospectionDetailsItemBase<ITransformationProvider> {
/** Constructor. */
public TransformationServiceIntrospectionDetailsItem(
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment