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

Completed prototype service introspection UI.

refs 2460
parent 6bb358f3
No related branches found
No related tags found
No related merge requests found
Showing
with 222 additions and 33 deletions
......@@ -31,7 +31,7 @@ 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.DetailsUICompositeFactoryBase;
import org.fortiss.tooling.kernel.ui.internal.introspection.details.DetailsUIHandlerBase;
import org.fortiss.tooling.kernel.ui.internal.introspection.details.KISSDetailsUIRegistry;
/**
......@@ -114,10 +114,12 @@ public class KISSViewPart extends ViewPart implements ISelectionChangedListener
}
IIntrospectionDetailsItem item = service.getDetailsItem();
if(item != null) {
DetailsUICompositeFactoryBase factory =
KISSDetailsUIRegistry.INSTANCE.getCompositeFactory(item.getClass());
if(factory != null) {
Control newContent = factory.createComposite(sc);
DetailsUIHandlerBase handler =
KISSDetailsUIRegistry.INSTANCE.getHandler(item.getClass());
if(handler != null) {
handler.setService(service);
handler.setDataItem(item);
Control newContent = handler.createComposite(sc);
sc.setContent(newContent);
}
}
......
......@@ -19,7 +19,8 @@ package org.fortiss.tooling.kernel.ui.internal.introspection.details;
import org.eclipse.swt.custom.ScrolledComposite;
import org.eclipse.swt.widgets.Control;
import org.fortiss.tooling.kernel.introspection.IIntrospectionItem;
import org.fortiss.tooling.kernel.introspection.IIntrospectionDetailsItem;
import org.fortiss.tooling.kernel.introspection.IIntrospectiveKernelService;
import org.fortiss.tooling.kernel.introspection.KernelIntrospectionSystemService;
/**
......@@ -31,16 +32,23 @@ import org.fortiss.tooling.kernel.introspection.KernelIntrospectionSystemService
* @version $Rev$
* @ConQAT.Rating RED Hash:
*/
public abstract class DetailsUICompositeFactoryBase {
public abstract class DetailsUIHandlerBase {
/** The III data item. */
protected IIntrospectionItem dataItem;
/** The {@link IIntrospectionDetailsItem data item}. */
protected IIntrospectiveKernelService service;
/** The {@link IIntrospectionDetailsItem data item}. */
protected IIntrospectionDetailsItem dataItem;
/** Sets the data item. */
public final void setDataItem(IIntrospectionItem dataItem) {
public final void setDataItem(IIntrospectionDetailsItem dataItem) {
this.dataItem = dataItem;
}
/** Sets the service. */
public final void setService(IIntrospectiveKernelService service) {
this.service = service;
}
/** Creates the control within the given parent scrolled composite. */
public abstract Control createComposite(ScrolledComposite parent);
}
......@@ -22,7 +22,9 @@ 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.ConstraintCheckerServiceIntrospectionDetailsItem;
import org.fortiss.tooling.kernel.ui.internal.introspection.details.factories.ConstraintCheckerServiceIntrospectionDetailsUIFactory;
import org.fortiss.tooling.kernel.introspection.items.PrototypeServiceIntrospectionDetailsItem;
import org.fortiss.tooling.kernel.ui.internal.introspection.details.factories.ConstraintCheckerServiceIntrospectionDetailsUIHandler;
import org.fortiss.tooling.kernel.ui.internal.introspection.details.factories.PrototypeServiceIntrospectionDetailsUIHandler;
/**
* Registry class to provide the details GUI for a given {@link IIntrospectionItem}.
......@@ -38,24 +40,25 @@ public final class KISSDetailsUIRegistry {
public static final KISSDetailsUIRegistry INSTANCE = new KISSDetailsUIRegistry();
/** The registry. */
private final HashMap<Class<? extends IIntrospectionDetailsItem>, DetailsUICompositeFactoryBase> registry =
new HashMap<Class<? extends IIntrospectionDetailsItem>, DetailsUICompositeFactoryBase>();
private final HashMap<Class<? extends IIntrospectionDetailsItem>, DetailsUIHandlerBase> registry =
new HashMap<Class<? extends IIntrospectionDetailsItem>, DetailsUIHandlerBase>();
/** Constructor. */
public KISSDetailsUIRegistry() {
register(ConstraintCheckerServiceIntrospectionDetailsItem.class,
new ConstraintCheckerServiceIntrospectionDetailsUIFactory());
registerHandler(ConstraintCheckerServiceIntrospectionDetailsItem.class,
new ConstraintCheckerServiceIntrospectionDetailsUIHandler());
registerHandler(PrototypeServiceIntrospectionDetailsItem.class,
new PrototypeServiceIntrospectionDetailsUIHandler());
}
/** Registers the given composite */
public void register(Class<? extends IIntrospectionDetailsItem> clazz,
DetailsUICompositeFactoryBase detailsCompositeFactory) {
registry.put(clazz, detailsCompositeFactory);
public void registerHandler(Class<? extends IIntrospectionDetailsItem> clazz,
DetailsUIHandlerBase detailsHandler) {
registry.put(clazz, detailsHandler);
}
/** Returns the composite factory for the given class. */
public DetailsUICompositeFactoryBase getCompositeFactory(
Class<? extends IIntrospectionDetailsItem> clazz) {
public DetailsUIHandlerBase getHandler(Class<? extends IIntrospectionDetailsItem> clazz) {
return registry.get(clazz);
}
}
......@@ -24,7 +24,7 @@ import org.eclipse.ui.dialogs.FilteredTree;
import org.eclipse.ui.dialogs.PatternFilter;
import org.fortiss.tooling.kernel.introspection.IIntrospectionItem;
import org.fortiss.tooling.kernel.service.IConstraintCheckerService;
import org.fortiss.tooling.kernel.ui.internal.introspection.details.DetailsUICompositeFactoryBase;
import org.fortiss.tooling.kernel.ui.internal.introspection.details.DetailsUIHandlerBase;
/**
* The details view for {@link IIntrospectionItem}s provided by {@link IConstraintCheckerService}.
......@@ -34,8 +34,8 @@ import org.fortiss.tooling.kernel.ui.internal.introspection.details.DetailsUICom
* @version $Rev$
* @ConQAT.Rating RED Hash:
*/
public class ConstraintCheckerServiceIntrospectionDetailsUIFactory extends
DetailsUICompositeFactoryBase {
public final class ConstraintCheckerServiceIntrospectionDetailsUIHandler extends
DetailsUIHandlerBase {
/** The tree with filter widget. */
private FilteredTree filteredTree;
......@@ -43,14 +43,7 @@ public class ConstraintCheckerServiceIntrospectionDetailsUIFactory extends
/** {@inheritDoc} */
@Override
public Control createComposite(ScrolledComposite parent) {
filteredTree = new FilteredTree(parent, SWT.BORDER, new PatternFilter(), true) {
/** {@inheritDoc} */
@Override
public void dispose() {
super.dispose();
System.out.println("tree disposed!");
}
};
filteredTree = new FilteredTree(parent, SWT.BORDER, new PatternFilter(), true);
return filteredTree;
}
}
/*--------------------------------------------------------------------------+
$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.factories;
import org.conqat.ide.commons.ui.jface.TreeContentProviderBase;
import org.eclipse.jface.viewers.ColumnLabelProvider;
import org.eclipse.jface.viewers.TableLabelProviderBase;
import org.eclipse.jface.viewers.TreeViewer;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.ScrolledComposite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Tree;
import org.eclipse.swt.widgets.TreeColumn;
import org.eclipse.ui.dialogs.FilteredTree;
import org.eclipse.ui.dialogs.PatternFilter;
import org.fortiss.tooling.kernel.extension.IPrototypeProvider;
import org.fortiss.tooling.kernel.extension.data.Prototype;
import org.fortiss.tooling.kernel.extension.data.PrototypeCategory;
import org.fortiss.tooling.kernel.service.IPrototypeService;
import org.fortiss.tooling.kernel.ui.internal.introspection.details.DetailsUIHandlerBase;
/**
*
* @author hoelzl
* @author $Author$
* @version $Rev$
* @ConQAT.Rating RED Hash:
*/
public final class PrototypeServiceIntrospectionDetailsUIHandler extends DetailsUIHandlerBase {
/** The tree with filter widget. */
private FilteredTree filteredTree;
/** {@inheritDoc} */
@Override
public Control createComposite(ScrolledComposite parent) {
filteredTree = new FilteredTree(parent, SWT.BORDER, new PatternFilter() {
/** {@inheritDoc} */
@Override
protected boolean isLeafMatch(Viewer viewer, Object element) {
TreeViewer tv = (TreeViewer)viewer;
int nCols = tv.getTree().getColumnCount();
boolean isMatch = false;
for(int columnIndex = 0; columnIndex < nCols; columnIndex++) {
ColumnLabelProvider labelProvider =
(ColumnLabelProvider)tv.getLabelProvider(columnIndex);
String labelText = labelProvider.getText(element);
isMatch |= wordMatches(labelText);
}
return isMatch;
}
}, true);
Label lbl = new Label(filteredTree, SWT.NONE);
lbl.setText("Number of currently registered prototypes: " +
IPrototypeService.INSTANCE.getAllPrototypes().size());
TreeViewer treeViewer = filteredTree.getViewer();
Tree tree = treeViewer.getTree();
tree.setHeaderVisible(true);
tree.setLinesVisible(true);
TreeColumn col0 = new TreeColumn(tree, SWT.LEFT);
col0.setText("Category / Prototype");
col0.setWidth(200);
TreeColumn col1 = new TreeColumn(tree, SWT.LEFT);
col1.setText("Provider Class");
col1.setWidth(400);
TreeColumn col2 = new TreeColumn(tree, SWT.LEFT);
col2.setText("EObject Class");
col2.setWidth(400);
TreeColumn col3 = new TreeColumn(tree, SWT.CENTER);
col3.setText("Primary");
col3.setWidth(40);
treeViewer.setContentProvider(new TreeContentProviderBase() {
@Override
public Object[] getChildren(Object parentElement) {
if(parentElement instanceof IPrototypeService) {
IPrototypeService srv = (IPrototypeService)parentElement;
return srv.getAllTopLevelPrototypesCategories().toArray();
}
if(parentElement instanceof PrototypeCategory) {
PrototypeCategory cat = (PrototypeCategory)parentElement;
return cat.getChildren();
}
return null;
}
});
treeViewer.setLabelProvider(new TableLabelProviderBase() {
@Override
public String getColumnText(Object parentElement, int columnIndex) {
if(parentElement instanceof IPrototypeService) {
return columnIndex == 0 ? "Prototype Service" : "";
}
if(parentElement instanceof PrototypeCategory) {
PrototypeCategory cat = (PrototypeCategory)parentElement;
return columnIndex == 0 ? cat.getName() : "";
}
if(parentElement instanceof Prototype) {
Prototype proto = (Prototype)parentElement;
switch(columnIndex) {
case 0:
return proto.getName();
case 1:
return findProtoypeProviderClassName(proto);
case 2:
return proto.getPrototype().getClass().getName();
case 3:
return proto.isPrimary() ? "X" : "";
}
}
return "";
}
});
treeViewer.setInput(IPrototypeService.INSTANCE);
return filteredTree;
}
/** Find the prototype provider for the given prototype. */
private String findProtoypeProviderClassName(Prototype proto) {
for(IPrototypeProvider provider : IPrototypeService.INSTANCE.getPrototypeProviders()) {
if(provider.getPrototypes().contains(proto)) {
return provider.getClass().getName();
}
}
return "Unknown Prototype Provider!";
}
}
......@@ -39,6 +39,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.PrototypeServiceIntrospectionDetailsItem;
import org.fortiss.tooling.kernel.service.IElementCompositorService;
import org.fortiss.tooling.kernel.service.IPrototypeService;
import org.osgi.framework.Bundle;
......@@ -176,7 +177,6 @@ public class PrototypeService implements IPrototypeService, IIntrospectiveKernel
/** {@inheritDoc} */
@Override
public IIntrospectionDetailsItem getDetailsItem() {
// TODO Auto-generated method stub
return null;
return new PrototypeServiceIntrospectionDetailsItem();
}
}
/*--------------------------------------------------------------------------+
$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 org.fortiss.tooling.kernel.introspection.IIntrospectionDetailsItem;
/**
*
* @author hoelzl
* @author $Author$
* @version $Rev$
* @ConQAT.Rating RED Hash:
*/
public final class PrototypeServiceIntrospectionDetailsItem implements IIntrospectionDetailsItem {
}
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