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

Added ElementCompositorService introspection with UI.

refs 2460
parent f849ce1c
No related branches found
No related tags found
No related merge requests found
......@@ -24,6 +24,7 @@ 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.EclipseResourceStorageProviderIntrospectionDetailsItem;
import org.fortiss.tooling.kernel.introspection.items.ElementCompositorServiceIntrospectionDetailsItem;
import org.fortiss.tooling.kernel.introspection.items.PersistencyServiceIntrospectionDetailsItem;
import org.fortiss.tooling.kernel.introspection.items.PrototypeServiceIntrospectionDetailsItem;
import org.fortiss.tooling.kernel.introspection.items.TransformationServiceIntrospectionDetailsItem;
......@@ -31,6 +32,7 @@ import org.fortiss.tooling.kernel.ui.internal.introspection.details.handler.Conn
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.EclipseResourceStorageProviderIntrospectionDetailsUIHandler;
import org.fortiss.tooling.kernel.ui.internal.introspection.details.handler.ElementCompositorServiceIntrospectionDetailsUIHandler;
import org.fortiss.tooling.kernel.ui.internal.introspection.details.handler.PersistencyServiceIntrospectionDetailsUIHandler;
import org.fortiss.tooling.kernel.ui.internal.introspection.details.handler.PrototypeServiceIntrospectionDetailsUIHandler;
import org.fortiss.tooling.kernel.ui.internal.introspection.details.handler.TransformationServiceIntrospectionDetailsUIHandler;
......@@ -63,6 +65,8 @@ public final class KISSDetailsUIRegistry {
new ContextMenuServiceIntrospectionDetailsUIHandler());
registerHandler(EclipseResourceStorageProviderIntrospectionDetailsItem.class,
new EclipseResourceStorageProviderIntrospectionDetailsUIHandler());
registerHandler(ElementCompositorServiceIntrospectionDetailsItem.class,
new ElementCompositorServiceIntrospectionDetailsUIHandler());
registerHandler(PrototypeServiceIntrospectionDetailsItem.class,
new PrototypeServiceIntrospectionDetailsUIHandler());
registerHandler(PersistencyServiceIntrospectionDetailsItem.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 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.EObjectAwareIntrospectionDetailsItemBase;
/**
* Base class for details UI implementations with filtered tree viewer.
*
* @author hoelzl
* @author $Author$
* @version $Rev$
* @ConQAT.Rating RED Hash:
*/
public abstract class EObjectAwareIntrospectionDetailsUIHandlerBase 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() != null) {
Object provider = pair.getFirst();
Class<?> regClass = (Class<?>)pair.getSecond();
switch(columnIndex) {
case 0:
return provider.getClass().getSimpleName();
case 1:
return provider.getClass().getName();
case 2:
return regClass.getName();
}
}
}
return "";
}
}
/** Tree content provider for handler registrations with two classes. */
protected static abstract class EObjectAwareTreeContentProviderBase extends
TreeContentProviderBase {
/** Returns the input object for this content provider. */
protected abstract EObjectAwareIntrospectionDetailsItemBase<?> getInputObject();
/** {@inheritDoc} */
@Override
public Object[] getChildren(Object parentElement) {
if(parentElement == getInputObject()) {
return getInputObject().getHandlerKeyClasses().toArray();
}
if(parentElement instanceof Class<?>) {
Class<?> regClass = (Class<?>)parentElement;
List<?> handlerList = getInputObject().getHandlerList(regClass);
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, Class<?>>(handler, regClass);
idx++;
}
return pairs;
}
return new Object[0];
}
}
}
/*--------------------------------------------------------------------------+
$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.EObjectAwareIntrospectionDetailsItemBase;
import org.fortiss.tooling.kernel.introspection.items.ElementCompositorServiceIntrospectionDetailsItem;
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 ElementCompositorServiceIntrospectionDetailsUIHandler extends
EObjectAwareIntrospectionDetailsUIHandlerBase {
/** {@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("Class / 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("EObject Class");
col2.setWidth(400);
}
/** {@inheritDoc} */
@Override
protected ITreeContentProvider createContentProvider() {
return new EObjectAwareTreeContentProviderBase() {
@Override
protected EObjectAwareIntrospectionDetailsItemBase<?> getInputObject() {
return ElementCompositorServiceIntrospectionDetailsUIHandler.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 ElementCompositorServiceIntrospectionDetailsItem getInputObject() {
return (ElementCompositorServiceIntrospectionDetailsItem)dataItem;
}
}
......@@ -30,6 +30,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.ElementCompositorServiceIntrospectionDetailsItem;
import org.fortiss.tooling.kernel.model.ILibraryElementReference;
import org.fortiss.tooling.kernel.service.IElementCompositorService;
import org.fortiss.tooling.kernel.service.IPersistencyService;
......@@ -196,7 +197,6 @@ public final class ElementCompositorService extends
/** {@inheritDoc} */
@Override
public IIntrospectionDetailsItem getDetailsItem() {
// TODO Auto-generated method stub
return null;
return new ElementCompositorServiceIntrospectionDetailsItem(handlerMap);
}
}
/*--------------------------------------------------------------------------+
$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 static java.util.Collections.unmodifiableList;
import static java.util.Collections.unmodifiableSet;
import java.util.Collection;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import org.fortiss.tooling.kernel.introspection.IIntrospectionDetailsItem;
/**
* Base class for {@link IIntrospectionDetailsItem}s with class-based handler registrations.
* <P>
* The handler key set and the returned handler lists are read-only.
*
* @author hoelzl
* @author $Author$
* @version $Rev$
* @ConQAT.Rating RED Hash:
*/
public abstract class EObjectAwareIntrospectionDetailsItemBase<T extends Object> implements
IIntrospectionDetailsItem {
/** Read-only copy of the services handler list. */
protected final Map<Class<?>, List<T>> handlerMap;
/** Constructor. */
public EObjectAwareIntrospectionDetailsItemBase(Map<Class<?>, List<T>> handlerMap) {
this.handlerMap = handlerMap;
}
/** Returns the first registration classes. */
public Collection<Class<?>> getHandlerKeyClasses() {
return unmodifiableSet(handlerMap.keySet());
}
/** Returns the handler list for the given registration class. */
public List<T> getHandlerList(Class<?> regClass) {
List<T> l = handlerMap.get(regClass);
return unmodifiableList(l);
}
/** Counts all unique handlers. */
public final int countHandlers() {
Set<T> handlerSet = new HashSet<T>();
for(Class<?> c : handlerMap.keySet()) {
List<T> hlist = handlerMap.get(c);
if(hlist == null) {
continue;
}
handlerSet.addAll(hlist);
}
return handlerSet.size();
}
}
/*--------------------------------------------------------------------------+
$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.IElementCompositor;
import org.fortiss.tooling.kernel.internal.ElementCompositorService;
import org.fortiss.tooling.kernel.introspection.IIntrospectionDetailsItem;
/**
* {@link IIntrospectionDetailsItem} for the {@link ElementCompositorService}.
*
* @author hoelzl
* @author $Author$
* @version $Rev$
* @ConQAT.Rating RED Hash:
*/
public final class ElementCompositorServiceIntrospectionDetailsItem extends
EObjectAwareIntrospectionDetailsItemBase<IElementCompositor<EObject>> {
/** Constructor. */
public ElementCompositorServiceIntrospectionDetailsItem(
Map<Class<?>, List<IElementCompositor<EObject>>> handlers) {
super(handlers);
}
}
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