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 0 additions and 1475 deletions
DetailsUIHandlerBase.java d3d2038cee67f61ca0be7e0c832ffc95771cee0f GREEN
KISSDetailsUIRegistry.java 4ae512082e0a7751f9da1d631b1bba44c2e5e8c4 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;
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.EclipseResourceStorageServiceIntrospectionDetailsItem;
import org.fortiss.tooling.kernel.introspection.items.ElementCompositorServiceIntrospectionDetailsItem;
import org.fortiss.tooling.kernel.introspection.items.LibraryServiceIntrospectionDetailsItem;
import org.fortiss.tooling.kernel.introspection.items.MigrationServiceIntrospectionDetailsItem;
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.AllocationEditPartFactoryServiceIntrospectionDetailsUIHandler;
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.EclipseResourceStorageProviderIntrospectionDetailsUIHandler;
import org.fortiss.tooling.kernel.ui.internal.introspection.details.handler.EditPartFactoryServiceIntrospectionDetailsUIHandler;
import org.fortiss.tooling.kernel.ui.internal.introspection.details.handler.ElementCompositorServiceIntrospectionDetailsUIHandler;
import org.fortiss.tooling.kernel.ui.internal.introspection.details.handler.LibraryServiceIntrospectionDetailsUIHandler;
import org.fortiss.tooling.kernel.ui.internal.introspection.details.handler.MigrationServiceIntrospectionDetailsUIHandler;
import org.fortiss.tooling.kernel.ui.internal.introspection.details.handler.ModelEditorBindingServiceIntrospectionDetailsUIHandler;
import org.fortiss.tooling.kernel.ui.internal.introspection.details.handler.ModelElementHandlerServiceIntrospectionDetailsUIHandler;
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;
import org.fortiss.tooling.kernel.ui.internal.introspection.items.AllocationEditPartFactoryServiceIntrospectionDetailsItem;
import org.fortiss.tooling.kernel.ui.internal.introspection.items.ContextMenuServiceIntrospectionDetailsItem;
import org.fortiss.tooling.kernel.ui.internal.introspection.items.EditPartFactoryServiceIntrospectionDetailsItem;
import org.fortiss.tooling.kernel.ui.internal.introspection.items.ModelEditorBindingServiceIntrospectionDetailsItem;
import org.fortiss.tooling.kernel.ui.internal.introspection.items.ModelElementHandlerServiceIntrospectionDetailsItem;
/**
* Registry class to provide the details GUI for a given {@link IIntrospectionItem}.
*
* @author hoelzl
*/
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(AllocationEditPartFactoryServiceIntrospectionDetailsItem.class,
new AllocationEditPartFactoryServiceIntrospectionDetailsUIHandler());
registerHandler(ConnectionCompositorServiceIntrospectionDetailsItem.class,
new ConnectionCompositorServiceIntrospectionDetailsUIHandler());
registerHandler(ConstraintCheckerServiceIntrospectionDetailsItem.class,
new ConstraintCheckerServiceIntrospectionDetailsUIHandler());
registerHandler(ContextMenuServiceIntrospectionDetailsItem.class,
new ContextMenuServiceIntrospectionDetailsUIHandler());
registerHandler(EclipseResourceStorageServiceIntrospectionDetailsItem.class,
new EclipseResourceStorageProviderIntrospectionDetailsUIHandler());
registerHandler(EditPartFactoryServiceIntrospectionDetailsItem.class,
new EditPartFactoryServiceIntrospectionDetailsUIHandler());
registerHandler(ElementCompositorServiceIntrospectionDetailsItem.class,
new ElementCompositorServiceIntrospectionDetailsUIHandler());
registerHandler(LibraryServiceIntrospectionDetailsItem.class,
new LibraryServiceIntrospectionDetailsUIHandler());
registerHandler(MigrationServiceIntrospectionDetailsItem.class,
new MigrationServiceIntrospectionDetailsUIHandler());
registerHandler(ModelEditorBindingServiceIntrospectionDetailsItem.class,
new ModelEditorBindingServiceIntrospectionDetailsUIHandler());
registerHandler(ModelElementHandlerServiceIntrospectionDetailsItem.class,
new ModelElementHandlerServiceIntrospectionDetailsUIHandler());
registerHandler(PrototypeServiceIntrospectionDetailsItem.class,
new PrototypeServiceIntrospectionDetailsUIHandler());
registerHandler(PersistencyServiceIntrospectionDetailsItem.class,
new PersistencyServiceIntrospectionDetailsUIHandler());
registerHandler(TransformationServiceIntrospectionDetailsItem.class,
new TransformationServiceIntrospectionDetailsUIHandler());
}
/** 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);
}
}
AllocationEditPartFactoryServiceIntrospectionDetailsUIHandler.java 944cc4d5db305ceba7ca1f1f1957a5160511a228 GREEN
ConnectionCompositorServiceIntrospectionDetailsUIHandler.java bf4744afe94f1b97c2f8442466c10d4969b81854 GREEN
ConstraintCheckerServiceIntrospectionDetailsUIHandler.java 33758640bc77148162b88143dd1ed758a12bcf30 GREEN
ContextMenuServiceIntrospectionDetailsUIHandler.java 33f39e000e14a9c2661ca280e82139593852be7c GREEN
CopyClassNameToClipBoardRunnable.java 884555c7026c466d3401b272fc64b9f693074950 GREEN
EObjectAware2IntrospectionDetailsUIHandlerBase.java 18aefde758dc370f564a535d71bab9afc8bdf91f GREEN
EObjectAwareIntrospectionDetailsUIHandlerBase.java dc14e1cdcb550aaada7d35396de60cb6515d04ce GREEN
EclipseResourceStorageProviderIntrospectionDetailsUIHandler.java 987f882a82cfa20af08e85629e2767c0ebab042f GREEN
EditPartFactoryServiceIntrospectionDetailsUIHandler.java e14b000ffface065dd58f7a9799cceb74acd095e GREEN
ElementCompositorServiceIntrospectionDetailsUIHandler.java 3e5d8e4c268a4498c0b17d2ab83bf17665b37cd0 GREEN
IntrospectionDetailsUIHandlerBase.java fae98d41eaf47401b27e80da542e187d952fb287 GREEN
LibraryServiceIntrospectionDetailsUIHandler.java a17e31bfdb1215b9d50279a37165fac6db0733ea GREEN
MigrationServiceIntrospectionDetailsUIHandler.java 66c7b9094dbf373e56c5a5558bb35073e70d4ec3 GREEN
ModelEditorBindingServiceIntrospectionDetailsUIHandler.java e8c55cd97cba5b4286c9681649970e348e248bf2 GREEN
ModelElementHandlerServiceIntrospectionDetailsUIHandler.java c4f7b3ddb66b2bfa14e0dd64516d613fa54d6df0 GREEN
PersistencyServiceIntrospectionDetailsUIHandler.java 8019c9fa146eb5831be048edc94c8d284cc90595 GREEN
PrototypeServiceIntrospectionDetailsUIHandler.java b61fffe1291bec05fc0f727834be9ab0f1a7acba GREEN
TableViewerPatternFilter.java 7a7cb1f25d12b5c89c91a3e29169412de8cbb867 GREEN
TransformationServiceIntrospectionDetailsUIHandler.java 8e8d54dbc2ad0b765467a25b1fc1fdbc8c388a20 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.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.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
*/
public final class ConnectionCompositorServiceIntrospectionDetailsUIHandler
extends EObjectAware2IntrospectionDetailsUIHandlerBase {
/** {@inheritDoc} */
@Override
public Control createComposite(ScrolledComposite parent) {
String heading = "Type to search 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) {
createDefaultTreeColumns(tree, "Source / Target / Compositor", 250, "Compositor Class", 400,
"Source EObject Class", 400, "Target EObject Class", 400);
}
/** {@inheritDoc} */
@Override
protected ITreeContentProvider createContentProvider() {
return new EObjectAware2TreeContentProviderBase() {
@Override
protected EObjectAware2IntrospectionDetailsItemBase<?> getInputObject() {
return ConnectionCompositorServiceIntrospectionDetailsUIHandler.this
.getInputObject();
}
};
}
/** {@inheritDoc} */
@Override
protected ConnectionCompositorServiceIntrospectionDetailsItem getInputObject() {
return (ConnectionCompositorServiceIntrospectionDetailsItem)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;
import org.conqat.ide.commons.ui.jface.TreeContentProviderBase;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.jface.action.MenuManager;
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.IConstraintChecker;
import org.fortiss.tooling.kernel.introspection.IIntrospectionItem;
import org.fortiss.tooling.kernel.introspection.items.ConstraintCheckerServiceIntrospectionDetailsItem;
import org.fortiss.tooling.kernel.service.IConstraintCheckerService;
/**
* Introspection UI handler for {@link IIntrospectionItem}s provided by
* {@link IConstraintCheckerService}.
*
* @author hoelzl
*/
public final class ConstraintCheckerServiceIntrospectionDetailsUIHandler
extends IntrospectionDetailsUIHandlerBase {
/** {@inheritDoc} */
@Override
public Control createComposite(ScrolledComposite parent) {
String h = "Type to search registered checkers:";
String f = "Number of registered constraint checkers: " + countCheckers();
return createFilteredTreeInTabFolder(parent, h, f, "Registered Checkers");
}
/** Computes the number of constraint checkers. */
private int countCheckers() {
int count = 0;
for(Class<?> c : getInputObject().getHandlerKeyClasses()) {
count += getInputObject().getHandlerList(c).size();
}
return count;
}
/** {@inheritDoc} */
@Override
protected void createTreeColumns(Tree tree) {
TreeColumn col0 = new TreeColumn(tree, SWT.LEFT);
col0.setText("Model Element / Checker");
col0.setWidth(400);
TreeColumn col1 = new TreeColumn(tree, SWT.LEFT);
col1.setText("Model Element Class");
col1.setWidth(400);
TreeColumn col2 = new TreeColumn(tree, SWT.LEFT);
col2.setText("Constraint Checker Implementation Class");
col2.setWidth(400);
}
/** {@inheritDoc} */
@Override
protected ITreeContentProvider createContentProvider() {
return new TreeContentProviderBase() {
@Override
public Object[] getChildren(Object parentElement) {
if(parentElement == getInputObject()) {
return getInputObject().getHandlerKeyClasses().toArray();
} else if(parentElement instanceof Class) {
return getInputObject().getHandlerList((Class<?>)parentElement).toArray();
}
return null;
}
};
}
/** {@inheritDoc} */
@Override
protected ITableLabelProvider createLabelProvider() {
return new TableLabelProviderBase() {
@SuppressWarnings("unchecked")
@Override
public String getColumnText(Object element, int columnIndex) {
if(element instanceof Class) {
switch(columnIndex) {
case 0:
return ((Class<?>)element).getSimpleName();
case 1:
return ((Class<?>)element).getName();
}
} else if(element instanceof IConstraintChecker) {
IConstraintChecker<EObject> icc = (IConstraintChecker<EObject>)element;
switch(columnIndex) {
case 0:
return icc.getClass().getSimpleName();
case 2:
return icc.getClass().getName();
}
}
return "";
}
};
}
/** {@inheritDoc} */
@Override
protected PatternFilter createPatternFilter() {
return new TableViewerPatternFilter();
}
/** {@inheritDoc} */
@Override
protected ConstraintCheckerServiceIntrospectionDetailsItem getInputObject() {
return (ConstraintCheckerServiceIntrospectionDetailsItem)dataItem;
}
/** {@inheritDoc} */
@Override
protected boolean testSelection(Object selection) {
return true;
}
/** {@inheritDoc} */
@Override
protected void populateContextMenu(Object selection, MenuManager mgr) {
if(selection instanceof Class<?>) {
mgr.add(createCopyClassNameAction((Class<?>)selection));
} else if(selection instanceof IConstraintChecker<?>) {
mgr.add(createCopyClassNameAction(selection.getClass()));
}
}
}
/*-------------------------------------------------------------------------+
| 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.conqat.ide.commons.ui.jface.TreeContentProviderBase;
import org.eclipse.jface.action.MenuManager;
import org.eclipse.jface.viewers.ITableLabelProvider;
import org.eclipse.jface.viewers.ITreeContentProvider;
import org.eclipse.jface.viewers.TableLabelProviderBase;
import org.eclipse.jface.viewers.ViewerComparator;
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.IIntrospectionItem;
import org.fortiss.tooling.kernel.service.IConstraintCheckerService;
import org.fortiss.tooling.kernel.ui.extension.IContextMenuContributor;
import org.fortiss.tooling.kernel.ui.internal.introspection.items.ContextMenuServiceIntrospectionDetailsItem;
import org.fortiss.tooling.kernel.ui.service.IContextMenuService;
/**
* Introspection UI handler for {@link IIntrospectionItem}s provided by
* {@link IConstraintCheckerService}.
*
* @author hoelzl
*/
public final class ContextMenuServiceIntrospectionDetailsUIHandler
extends IntrospectionDetailsUIHandlerBase {
/** {@inheritDoc} */
@Override
public Control createComposite(ScrolledComposite parent) {
String h = "Type to search registered menu contributors:";
String f = "Number of registered menu contributors: " + getInputObject().getHandlerList();
return createFilteredTreeInTabFolder(parent, h, f, "Registered Contributors");
}
/** {@inheritDoc} */
@Override
protected void createTreeColumns(Tree tree) {
TreeColumn col0 = new TreeColumn(tree, SWT.LEFT);
col0.setText("Menu Section");
col0.setWidth(400);
TreeColumn col1 = new TreeColumn(tree, SWT.LEFT);
col1.setText("Menu Provider Class");
col1.setWidth(500);
}
/** {@inheritDoc} */
@Override
protected ITreeContentProvider createContentProvider() {
return new TreeContentProviderBase() {
@Override
public Object[] getChildren(Object parentElement) {
if(parentElement == getInputObject()) {
return IContextMenuService.MENU_SECTION_IDS;
} else if(parentElement instanceof String) {
return getInputObject().getHandlerList().stream()
.filter(h -> parentElement.equals(h.getMenuSectionID())).toArray();
}
return null;
}
};
}
/** {@inheritDoc} */
@Override
protected ITableLabelProvider createLabelProvider() {
return new TableLabelProviderBase() {
@Override
public String getColumnText(Object element, int columnIndex) {
if(element instanceof String && columnIndex == 0) {
return (String)element;
} else if(element instanceof IContextMenuContributor) {
IContextMenuContributor icc = (IContextMenuContributor)element;
switch(columnIndex) {
case 0:
return icc.getClass().getSimpleName();
case 1:
return icc.getClass().getName();
}
}
return "";
}
};
}
/** {@inheritDoc} */
@Override
protected boolean testSelection(Object selection) {
return selection instanceof IContextMenuContributor;
}
/** {@inheritDoc} */
@Override
protected void populateContextMenu(Object selection, MenuManager mgr) {
IContextMenuContributor c = (IContextMenuContributor)selection;
mgr.add(createCopyClassNameAction(c.getClass()));
}
/** {@inheritDoc} */
@Override
protected PatternFilter createPatternFilter() {
return new TableViewerPatternFilter();
}
/** {@inheritDoc} */
@Override
protected ViewerComparator createComparator() {
return new ViewerComparator() {
/** {@inheritDoc} */
@Override
public int category(Object element) {
if(element instanceof String) {
String section = (String)element;
for(int i = 0; i < IContextMenuService.MENU_SECTION_IDS.length; i++) {
if(section.equals(IContextMenuService.MENU_SECTION_IDS[i])) {
return i;
}
}
return IContextMenuService.MENU_SECTION_IDS.length;
}
return super.category(element);
}
};
}
/** {@inheritDoc} */
@Override
protected ContextMenuServiceIntrospectionDetailsItem getInputObject() {
return (ContextMenuServiceIntrospectionDetailsItem)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;
import org.eclipse.swt.dnd.Clipboard;
import org.eclipse.swt.dnd.TextTransfer;
import org.eclipse.swt.dnd.Transfer;
import org.eclipse.swt.widgets.Display;
/**
* {@link Runnable} implementation that copies a given class name to the {@link Clipboard}.
*
* @author hoelzl
*/
public final class CopyClassNameToClipBoardRunnable implements Runnable {
/** The class name. */
private final String className;
/** Constructor. */
public CopyClassNameToClipBoardRunnable(String className) {
this.className = className;
}
/** {@inheritDoc} */
@Override
public void run() {
Clipboard clipboard = new Clipboard(Display.getCurrent());
String[] content = new String[] {className};
Transfer[] transfer = new Transfer[] {TextTransfer.getInstance()};
clipboard.setContents(content, transfer);
}
}
/*-------------------------------------------------------------------------+
| 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.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.EObjectAwareIntrospectionDetailsItemBase;
/**
* Base class for details UI implementations with filtered tree viewer.
*
* @author hoelzl
*/
public abstract class EObjectAwareIntrospectionDetailsUIHandlerBase
extends IntrospectionDetailsUIHandlerBase {
/** Creates the default tree columns. */
protected final void createDefaultTreeColumns(Tree tree, String text0, int width0, String text1,
int width1, String text2, int width2) {
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);
}
/** {@inheritDoc} */
@Override
protected ITableLabelProvider createLabelProvider() {
return new EObjectAwareTableLabelProvider();
}
/** {@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 EObjectAwareTableLabelProvider 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];
}
}
/** {@inheritDoc} */
@Override
protected boolean testSelection(Object selection) {
return selection instanceof Pair<?, ?>;
}
/** {@inheritDoc} */
@Override
protected void populateContextMenu(Object selection, MenuManager mgr) {
Pair<?, ?> pair = (Pair<?, ?>)selection;
mgr.add(createCopyClassNameAction(pair.getFirst().getClass()));
mgr.add(createCopyClassNameAction((Class<?>)pair.getSecond()));
}
}
/*-------------------------------------------------------------------------+
| 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.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.kernel.introspection.items.ElementCompositorServiceIntrospectionDetailsItem;
import org.fortiss.tooling.kernel.service.IElementCompositorService;
/**
* Introspection UI handler for the {@link IElementCompositorService}.
*
* @author hoelzl
*/
public final class ElementCompositorServiceIntrospectionDetailsUIHandler
extends EObjectAwareIntrospectionDetailsUIHandlerBase {
/** {@inheritDoc} */
@Override
public Control createComposite(ScrolledComposite parent) {
String heading = "Type to search registered element compositors:";
String footer = "Number of currently registered element compositors: " +
getInputObject().countHandlers();
return createFilteredTreeInTabFolder(parent, heading, footer, "Registered Compositors");
}
/** {@inheritDoc} */
@Override
protected void createTreeColumns(Tree tree) {
createDefaultTreeColumns(tree, "Class / Compositor", 250, "Compositor Class", 400,
"EObject Class", 400);
}
/** {@inheritDoc} */
@Override
protected ITreeContentProvider createContentProvider() {
return new EObjectAwareTreeContentProviderBase() {
@Override
protected EObjectAwareIntrospectionDetailsItemBase<?> getInputObject() {
return ElementCompositorServiceIntrospectionDetailsUIHandler.this.getInputObject();
}
};
}
/** {@inheritDoc} */
@Override
protected ElementCompositorServiceIntrospectionDetailsItem getInputObject() {
return (ElementCompositorServiceIntrospectionDetailsItem)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;
import org.eclipse.jface.action.Action;
import org.eclipse.jface.action.IMenuListener;
import org.eclipse.jface.action.IMenuManager;
import org.eclipse.jface.action.MenuManager;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.jface.viewers.ITableLabelProvider;
import org.eclipse.jface.viewers.ITreeContentProvider;
import org.eclipse.jface.viewers.TreeViewer;
import org.eclipse.jface.viewers.ViewerComparator;
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.CTabFolder;
import org.eclipse.swt.custom.CTabItem;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Tree;
import org.eclipse.ui.dialogs.FilteredTree;
import org.eclipse.ui.dialogs.PatternFilter;
import org.fortiss.tooling.kernel.ui.internal.introspection.details.DetailsUIHandlerBase;
/**
* Base class for details UI implementations with filtered tree viewer.
*
* @author hoelzl
*/
public abstract class IntrospectionDetailsUIHandlerBase extends DetailsUIHandlerBase {
/** Creates only the filtered tree control. */
protected final Composite createFilteredTree(Composite parent) {
return createFilteredTree(parent, null, null);
}
/** Creates the filtered tree control. */
protected final Composite createFilteredTree(Composite parent, String headingsLabel,
String footerLabel) {
Composite composite = new Composite(parent, SWT.BORDER);
composite.setLayout(new GridLayout(1, true));
if(headingsLabel != null) {
Label heading = new Label(composite, SWT.NONE);
heading.setText(headingsLabel);
heading.setLayoutData(new GridData(SWT.BEGINNING, SWT.CENTER, true, false));
}
FilteredTree filteredTree =
new FilteredTree(composite, SWT.BORDER, createPatternFilter(), true);
TreeViewer treeViewer = filteredTree.getViewer();
Tree tree = treeViewer.getTree();
tree.setHeaderVisible(true);
tree.setLinesVisible(true);
createTreeColumns(tree);
treeViewer.setContentProvider(createContentProvider());
treeViewer.setLabelProvider(createLabelProvider());
treeViewer.setComparator(createComparator());
treeViewer.setInput(getInputObject());
addContextMenu(treeViewer);
if(footerLabel != null) {
Label lbl = new Label(composite, SWT.BOLD);
lbl.setText(footerLabel);
lbl.setLayoutData(new GridData(SWT.BEGINNING, SWT.CENTER, true, false));
}
return composite;
}
/**
* Creates the context menu by delegating menu entry creation
* to {@link #populateContextMenu(Object, MenuManager)} and {@link #testSelection(Object)}.
*/
private void addContextMenu(final TreeViewer treeViewer) {
final MenuManager mgr = new MenuManager();
mgr.setRemoveAllWhenShown(true);
mgr.addMenuListener(new IMenuListener() {
@Override
public void menuAboutToShow(IMenuManager manager) {
IStructuredSelection sel = (IStructuredSelection)treeViewer.getSelection();
if(sel != null && !sel.isEmpty() && testSelection(sel.getFirstElement())) {
populateContextMenu(sel.getFirstElement(), mgr);
}
}
});
treeViewer.getControl().setMenu(mgr.createContextMenu(treeViewer.getControl()));
}
/**
* Populates the context menu. May assume {@link #testSelection(Object)} returned {@code true}.
* The default does not create any menu entry.
*/
protected void populateContextMenu(@SuppressWarnings("unused") Object selection,
@SuppressWarnings("unused") MenuManager mgr) {
// create nothing
}
/** Creates an action with the given name and selection handler. */
protected final Action createAction(String name, Runnable runner) {
return new Action(name) {
/** {@inheritDoc} */
@Override
public void run() {
runner.run();
}
};
}
/** Creates the copy class name action for the given class. */
protected final Action createCopyClassNameAction(Class<?> clazz) {
return createAction("Copy Qualified Class Name: " + clazz.getSimpleName(),
new CopyClassNameToClipBoardRunnable(clazz.getName()));
}
/**
* Tests the given selected object for validity to show context menu. The default returns
* {@code false}.
*/
protected boolean testSelection(@SuppressWarnings("unused") Object selection) {
return false;
}
/** Creates a tab folder with the filtered tree as a tab. */
protected final CTabFolder createTabFolder(Composite parent, String... tabNames) {
CTabFolder tabFolder = new CTabFolder(parent, SWT.BOTTOM);
if(tabNames != null && tabNames.length > 0) {
for(String tName : tabNames) {
CTabItem filterTreeTab = new CTabItem(tabFolder, SWT.NULL);
filterTreeTab.setText(tName);
}
tabFolder.setSelection(tabFolder.getItem(0));
}
return tabFolder;
}
/** Creates the filtered tree inside the tab folder. */
protected final CTabFolder createFilteredTreeInTabFolder(Composite parent, String headingsLabel,
String footerLabel, String... tabNames) {
CTabFolder tabFolder = createTabFolder(parent, tabNames);
Composite c = createFilteredTree(tabFolder, headingsLabel, footerLabel);
tabFolder.getItem(0).setControl(c);
return tabFolder;
}
/** Create the columns of the tree. */
protected abstract void createTreeColumns(Tree tree);
/** Creates the content provider. */
protected abstract ITreeContentProvider createContentProvider();
/** Creates the label provider. */
protected abstract ITableLabelProvider createLabelProvider();
/** Creates the pattern filter. */
protected abstract PatternFilter createPatternFilter();
/** Returns the input object for the tree viewer. */
protected abstract Object getInputObject();
/**
* Creates the comparator for the filtered tree. The default is
* {@link ViewerComparator#ViewerComparator()}.
*/
protected ViewerComparator createComparator() {
return new ViewerComparator();
}
}
/*-------------------------------------------------------------------------+
| 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.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.kernel.introspection.items.MigrationServiceIntrospectionDetailsItem;
import org.fortiss.tooling.kernel.service.IMigrationService;
import org.fortiss.tooling.kernel.ui.internal.introspection.details.DetailsUIHandlerBase;
/**
* {@link DetailsUIHandlerBase} for {@link IMigrationService}.
*
* @author hoelzl
*/
public class MigrationServiceIntrospectionDetailsUIHandler
extends EObjectAwareIntrospectionDetailsUIHandlerBase {
/** {@inheritDoc} */
@Override
public Control createComposite(ScrolledComposite parent) {
String heading = "Type to search registered migration providers:";
String footer = "Number of currently registered migration providers: " +
getInputObject().countHandlers();
return createFilteredTreeInTabFolder(parent, heading, footer, "Registered Providers");
}
/** {@inheritDoc} */
@Override
protected void createTreeColumns(Tree tree) {
createDefaultTreeColumns(tree, "Class / Provider", 250, "Provider Class", 400,
"EObject Class", 400);
}
/** {@inheritDoc} */
@Override
protected ITreeContentProvider createContentProvider() {
return new EObjectAwareTreeContentProviderBase() {
@Override
protected EObjectAwareIntrospectionDetailsItemBase<?> getInputObject() {
return MigrationServiceIntrospectionDetailsUIHandler.this.getInputObject();
}
};
}
/** {@inheritDoc} */
@Override
protected MigrationServiceIntrospectionDetailsItem getInputObject() {
return (MigrationServiceIntrospectionDetailsItem)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;
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.kernel.ui.internal.ModelEditorBindingService;
import org.fortiss.tooling.kernel.ui.internal.introspection.details.DetailsUIHandlerBase;
import org.fortiss.tooling.kernel.ui.internal.introspection.items.ModelEditorBindingServiceIntrospectionDetailsItem;
/**
* {@link DetailsUIHandlerBase} for {@link ModelEditorBindingService}.
*
* @author hoelzl
*/
public final class ModelEditorBindingServiceIntrospectionDetailsUIHandler
extends EObjectAwareIntrospectionDetailsUIHandlerBase {
/** {@inheritDoc} */
@Override
public Control createComposite(ScrolledComposite parent) {
String heading = "Type to search registered model editor bindings:";
String footer = "Number of currently registered model editor bindings: " +
getInputObject().countHandlers();
return createFilteredTreeInTabFolder(parent, heading, footer, "Registered Bindings");
}
/** {@inheritDoc} */
@Override
protected void createTreeColumns(Tree tree) {
createDefaultTreeColumns(tree, "Class / Binding", 250, "Binding Class", 400,
"EObject Class", 400);
}
/** {@inheritDoc} */
@Override
protected ITreeContentProvider createContentProvider() {
return new EObjectAwareTreeContentProviderBase() {
@Override
protected EObjectAwareIntrospectionDetailsItemBase<?> getInputObject() {
return ModelEditorBindingServiceIntrospectionDetailsUIHandler.this.getInputObject();
}
};
}
/** {@inheritDoc} */
@Override
protected ModelEditorBindingServiceIntrospectionDetailsItem getInputObject() {
return (ModelEditorBindingServiceIntrospectionDetailsItem)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;
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.kernel.ui.internal.ModelElementHandlerService;
import org.fortiss.tooling.kernel.ui.internal.introspection.details.DetailsUIHandlerBase;
import org.fortiss.tooling.kernel.ui.internal.introspection.items.ModelElementHandlerServiceIntrospectionDetailsItem;
/**
* {@link DetailsUIHandlerBase} for {@link ModelElementHandlerService}.
*
* @author hoelzl
*/
public final class ModelElementHandlerServiceIntrospectionDetailsUIHandler
extends EObjectAwareIntrospectionDetailsUIHandlerBase {
/** {@inheritDoc} */
@Override
public Control createComposite(ScrolledComposite parent) {
String heading = "Type to search registered model element handlers:";
String footer = "Number of currently registered model element handlers: " +
getInputObject().countHandlers();
return createFilteredTreeInTabFolder(parent, heading, footer, "Registered Handlers");
}
/** {@inheritDoc} */
@Override
protected void createTreeColumns(Tree tree) {
createDefaultTreeColumns(tree, "Class / Handler", 250, "Handler Class", 400,
"EObject Class", 400);
}
/** {@inheritDoc} */
@Override
protected ITreeContentProvider createContentProvider() {
return new EObjectAwareTreeContentProviderBase() {
@Override
protected EObjectAwareIntrospectionDetailsItemBase<?> getInputObject() {
return ModelElementHandlerServiceIntrospectionDetailsUIHandler.this
.getInputObject();
}
};
}
/** {@inheritDoc} */
@Override
protected ModelElementHandlerServiceIntrospectionDetailsItem getInputObject() {
return (ModelElementHandlerServiceIntrospectionDetailsItem)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;
import org.conqat.ide.commons.ui.jface.TreeContentProviderBase;
import org.eclipse.jface.action.MenuManager;
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.IPrototypeProvider;
import org.fortiss.tooling.kernel.extension.data.Prototype;
import org.fortiss.tooling.kernel.extension.data.PrototypeCategory;
import org.fortiss.tooling.kernel.service.IPrototypeService;
/**
* Introspection UI handler for the {@link IPrototypeService}.
*
* @author hoelzl
*/
public final class PrototypeServiceIntrospectionDetailsUIHandler
extends IntrospectionDetailsUIHandlerBase {
/** {@inheritDoc} */
@Override
public Control createComposite(ScrolledComposite parent) {
String heading = "Type to search registered providers:";
String footer = "Number of currently registered prototypes: " +
IPrototypeService.getInstance().getAllPrototypes().size() + " (" +
IPrototypeService.getInstance().getPrimaryPrototypes().size() +
" primary prototypes)";
return createFilteredTreeInTabFolder(parent, heading, footer, "Registered Providers");
}
/** Find the prototype provider for the given prototype. */
private Class<? extends IPrototypeProvider> findProtoypeProviderClass(Prototype proto) {
for(IPrototypeProvider provider : IPrototypeService.getInstance().getPrototypeProviders()) {
if(provider.getPrototypes().contains(proto)) {
return provider.getClass();
}
}
return null;
}
/** {@inheritDoc} */
@Override
protected void createTreeColumns(Tree tree) {
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(50);
}
/** {@inheritDoc} */
@Override
protected void populateContextMenu(Object selection, MenuManager mgr) {
Prototype proto = (Prototype)selection;
final Class<? extends IPrototypeProvider> provClass = findProtoypeProviderClass(proto);
mgr.add(createCopyClassNameAction(provClass));
mgr.add(createCopyClassNameAction(proto.getPrototype().getClass()));
}
/** {@inheritDoc} */
@Override
protected boolean testSelection(Object selection) {
return selection instanceof Prototype;
}
/** {@inheritDoc} */
@Override
protected ITreeContentProvider createContentProvider() {
return 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;
}
};
}
/** {@inheritDoc} */
@Override
protected ITableLabelProvider createLabelProvider() {
return new TableLabelProviderBase() {
@Override
public String getColumnText(Object parentElement, int columnIndex) {
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 findProtoypeProviderClass(proto).getName();
case 2:
return proto.getPrototype().getClass().getName();
case 3:
return proto.isPrimary() ? "X" : "";
}
}
return "";
}
};
}
/** {@inheritDoc} */
@Override
protected PatternFilter createPatternFilter() {
return new TableViewerPatternFilter();
}
/** {@inheritDoc} */
@Override
protected Object getInputObject() {
return IPrototypeService.getInstance();
}
}
/*-------------------------------------------------------------------------+
| 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.ColumnLabelProvider;
import org.eclipse.jface.viewers.TreeViewer;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.ui.dialogs.PatternFilter;
/**
* Class for tree table viewer {@link PatternFilter}s.
* Sub-classes should override {@link #basicMatch(String, int)}.
*
* @author hoelzl
*/
class TableViewerPatternFilter extends 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 |= basicMatch(labelText, columnIndex);
}
return isMatch;
}
/**
* Matches the label in the given column.
*
* @param labelText
* Label text to be matched.
* @param columnIndex
* Index of column for which label text has to be matched.
*
* @return {@code true} in case of match.
*/
protected boolean basicMatch(String labelText, int columnIndex) {
return wordMatches(labelText);
}
}
/*-------------------------------------------------------------------------+
| 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.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.EObjectAware2IntrospectionDetailsItemBase;
import org.fortiss.tooling.kernel.introspection.items.TransformationServiceIntrospectionDetailsItem;
import org.fortiss.tooling.kernel.service.ITransformationService;
/**
* Introspection UI handler for the {@link ITransformationService}.
*
* @author hoelzl
*/
public final class TransformationServiceIntrospectionDetailsUIHandler
extends EObjectAware2IntrospectionDetailsUIHandlerBase {
/** {@inheritDoc} */
@Override
public Control createComposite(ScrolledComposite parent) {
String heading = "Type to serach registered transformation providers:";
String footer = "Number of currently registered transformation providers: " +
getInputObject().countHandlers();
return createFilteredTreeInTabFolder(parent, heading, footer, "Registered Providers");
}
/** {@inheritDoc} */
@Override
protected void createTreeColumns(Tree tree) {
createDefaultTreeColumns(tree, "Source / Target / Provider", 250, "Provider Class", 400,
"Source EObject Class", 400, "Target EObject Class", 400);
}
/** {@inheritDoc} */
@Override
protected ITreeContentProvider createContentProvider() {
return new EObjectAware2TreeContentProviderBase() {
@Override
protected EObjectAware2IntrospectionDetailsItemBase<?> getInputObject() {
return TransformationServiceIntrospectionDetailsUIHandler.this.getInputObject();
}
};
}
/** {@inheritDoc} */
@Override
protected TransformationServiceIntrospectionDetailsItem getInputObject() {
return (TransformationServiceIntrospectionDetailsItem)dataItem;
}
}
<!-- (c) 2017 fortiss GmbH -->
<body>
User interface for details display of the kernel introspection system service (KISS).
This package contains service-specific, detailed information UI elements.
</body>
<!-- (c) 2017 fortiss GmbH -->
<body>
User interface for details display of the kernel introspection system service (KISS).
This package contains base classes for the service-specific, detailed information UI elements.
</body>
AllocationEditPartFactoryServiceIntrospectionDetailsItem.java e2067b2d95c270a9aed82a2368177d76b0144d79 GREEN
ContextMenuServiceIntrospectionDetailsItem.java ce7c725510e986b99fcddb40676cf6a5e7c2351d GREEN
EditPartFactoryServiceIntrospectionDetailsItem.java f11316c73b6de0e254c4e319e063065e598d5c96 GREEN
ModelEditorBindingServiceIntrospectionDetailsItem.java b241c242f5d8597542d9b63276b64ac2ca81ec7d GREEN
ModelElementHandlerServiceIntrospectionDetailsItem.java 327eec0c247f1413bc629dd57b3a71a885e51a1b 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.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.IModelEditorBinding;
import org.fortiss.tooling.kernel.ui.internal.ModelEditorBindingService;
/**
* {@link IIntrospectionDetailsItem} for {@link ModelEditorBindingService}.
*
* @author hoelzl
*/
public final class ModelEditorBindingServiceIntrospectionDetailsItem
extends EObjectAwareIntrospectionDetailsItemBase<IModelEditorBinding<EObject>> {
/** Constructor. */
public ModelEditorBindingServiceIntrospectionDetailsItem(
Map<Class<?>, List<IModelEditorBinding<EObject>>> handlerMap) {
super(handlerMap);
}
}