Skip to content
Snippets Groups Projects
Commit 14293808 authored by Johannes Eder's avatar Johannes Eder
Browse files

Merge branch '4020' into 'master'

[4020] KISS View to JavaFX

See merge request !123
parents 69adf7dd 67659695
No related branches found
No related tags found
1 merge request!123[4020] KISS View to JavaFX
Showing
with 196 additions and 1034 deletions
/*-------------------------------------------------------------------------+
| Copyright 2016 fortiss GmbH |
| |
| Licensed under the Apache License, Version 2.0 (the "License"); |
| you may not use this file except in compliance with the License. |
| You may obtain a copy of the License at |
| |
| http://www.apache.org/licenses/LICENSE-2.0 |
| |
| Unless required by applicable law or agreed to in writing, software |
| distributed under the License is distributed on an "AS IS" BASIS, |
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| See the License for the specific language governing permissions and |
| limitations under the License. |
+--------------------------------------------------------------------------*/
package org.fortiss.tooling.kernel.ui.internal.introspection.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 org.fortiss.tooling.kernel.introspection.IIntrospectionDetailsItem;
import org.fortiss.tooling.kernel.introspection.items.HandlerListIntrospectionDetailsItemBase;
import org.fortiss.tooling.kernel.ui.extension.IContextMenuContributor;
import org.fortiss.tooling.kernel.ui.internal.ContextMenuService;
/**
* {@link IIntrospectionDetailsItem} for the {@link ContextMenuService}.
*
* @author hoelzl
*/
public final class ContextMenuServiceIntrospectionDetailsItem
extends HandlerListIntrospectionDetailsItemBase<IContextMenuContributor> {
/** Constructor. */
public ContextMenuServiceIntrospectionDetailsItem(List<IContextMenuContributor> handlerList) {
super(handlerList);
}
}
/*-------------------------------------------------------------------------+
| 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);
}
}
/*-------------------------------------------------------------------------+
| Copyright 2016 fortiss GmbH |
| |
| Licensed under the Apache License, Version 2.0 (the "License"); |
| you may not use this file except in compliance with the License. |
| You may obtain a copy of the License at |
| |
| http://www.apache.org/licenses/LICENSE-2.0 |
| |
| Unless required by applicable law or agreed to in writing, software |
| distributed under the License is distributed on an "AS IS" BASIS, |
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| See the License for the specific language governing permissions and |
| limitations under the License. |
+--------------------------------------------------------------------------*/
package org.fortiss.tooling.kernel.ui.internal.introspection.items;
import java.util.List;
import java.util.Map;
import org.eclipse.emf.ecore.EObject;
import org.fortiss.tooling.kernel.introspection.IIntrospectionDetailsItem;
import org.fortiss.tooling.kernel.introspection.items.EObjectAwareIntrospectionDetailsItemBase;
import org.fortiss.tooling.kernel.ui.extension.IModelElementHandler;
import org.fortiss.tooling.kernel.ui.internal.ModelElementHandlerService;
/**
* {@link IIntrospectionDetailsItem} for {@link ModelElementHandlerService}.
*
* @author hoelzl
*/
public final class ModelElementHandlerServiceIntrospectionDetailsItem
extends EObjectAwareIntrospectionDetailsItemBase<IModelElementHandler<EObject>> {
/** Constructor. */
public ModelElementHandlerServiceIntrospectionDetailsItem(
Map<Class<?>, List<IModelElementHandler<EObject>>> handlerMap) {
super(handlerMap);
}
}
<!-- (c) 2017 fortiss GmbH -->
<body>
User interface for the kernel introspection system service (KISS).
It provides an Eclipse view with a tree viewer showing all introspective
services (and their specific items) as well as a section for service-specific,
detailed information.
</body>
ClipboardCopyHelper.java 1d9a9891278ab84932857eaa978dda4391978047 GREEN
KISSCompositeFXController.java 10f73a3a2034824eb14a8fda1f67bcc05285e3b0 GREEN
KISSFXController.java c38fc9efa826c68e74ac118e666088f407cb54fb GREEN
KISSServicesFXController.java cb59024c94164cf187041634c38a6dee1107e3a2 GREEN
KISSServicesFXViewPart.java 1a8370028bf79a8071f616dae985df3831c7f8b6 GREEN
/*******************************************************************************
* Copyright (c) 2019 fortiss GmbH.
*
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License 2.0 which is available at
* http://www.eclipse.org/legal/epl-2.0, or the Apache License, Version 2.0
* which is available at https://www.apache.org/licenses/LICENSE-2.0.
*
* SPDX-License-Identifier: EPL-2.0 OR Apache-2.0
*******************************************************************************/
package org.fortiss.tooling.kernel.ui.introspection;
import static javafx.scene.input.Clipboard.getSystemClipboard;
import javafx.scene.control.ContextMenu;
import javafx.scene.control.MenuItem;
import javafx.scene.input.Clipboard;
import javafx.scene.input.ClipboardContent;
/** Helper class for copying a class name to the system clipboard. */
public final class ClipboardCopyHelper {
/** Creates a context menu to copy the given class name. */
public static ContextMenu createCopyClassNameMenu(Class<?> toCopy) {
return createCopyClassNameMenu(toCopy.getName());
}
/** Creates a context menu to copy the given class name. */
public static ContextMenu createCopyClassNameMenu(String fullyQualified) {
return createContextMenu("Copy '" + fullyQualified + "' to clipboard.", fullyQualified);
}
/** Creates a context menu to copy the stack trace of the given {@link Throwable}. */
public static ContextMenu createCopyStrackTraceMenu(Throwable throwable) {
StringBuilder sb = new StringBuilder();
for(StackTraceElement ste : throwable.getStackTrace()) {
sb.append(ste.toString()).append('\n');
}
return createContextMenu("Copy Stack Trace", sb.toString());
}
/** Creates the context menu. */
private static ContextMenu createContextMenu(String label, String data) {
ContextMenu menu = new ContextMenu();
MenuItem item = new MenuItem(label);
item.setOnAction(event -> {
Clipboard clipboard = getSystemClipboard();
ClipboardContent content = new ClipboardContent();
content.putString(data);
clipboard.setContent(content);
});
menu.getItems().add(item);
return menu;
}
}
/*-------------------------------------------------------------------------+
| Copyright 2016 fortiss GmbH |
| Copyright 2020 fortiss GmbH |
| |
| Licensed under the Apache License, Version 2.0 (the "License"); |
| you may not use this file except in compliance with the License. |
......@@ -13,30 +13,27 @@
| See the License for the specific language governing permissions and |
| limitations under the License. |
+--------------------------------------------------------------------------*/
package org.fortiss.tooling.kernel.ui.internal.introspection;
package org.fortiss.tooling.kernel.ui.introspection;
import org.eclipse.jface.viewers.LabelProvider;
import org.eclipse.swt.graphics.Image;
import org.fortiss.tooling.common.ui.javafx.control.treetableview.DynamicTreeTableViewer;
import org.fortiss.tooling.common.ui.javafx.layout.CompositeFXControllerBase;
import org.fortiss.tooling.kernel.introspection.IIntrospectionItem;
import javafx.scene.Node;
/**
* Label provider for the tree viewer of the {@link KISSViewPart}.
* Abstract class specifying the functionality to be provided by a controller to be contained in a
* {@link KISSFXController}-based view.
*
* @author hoelzl
* @author munaro
*/
final class KISSViewerLabelProvider extends LabelProvider {
/** {@inheritDoc} */
@Override
public Image getImage(Object element) {
return null;
}
@SuppressWarnings("unchecked")
public abstract class KISSCompositeFXController<T extends Node>
extends CompositeFXControllerBase<T, Node> {
/** {@inheritDoc} */
@Override
public String getText(Object element) {
if(element instanceof IIntrospectionItem) {
return ((IIntrospectionItem)element).getIntrospectionLabel();
}
return null;
}
/**
* This method is executed each time the {@link IIntrospectionItem} selected in the
* {@link KISSFXController}'s {@link DynamicTreeTableViewer} changes.
*/
public abstract void changed(IIntrospectionItem selection);
}
/*-------------------------------------------------------------------------+
| Copyright 2020 fortiss GmbH |
| |
| Licensed under the Apache License, Version 2.0 (the "License"); |
| you may not use this file except in compliance with the License. |
| You may obtain a copy of the License at |
| |
| http://www.apache.org/licenses/LICENSE-2.0 |
| |
| Unless required by applicable law or agreed to in writing, software |
| distributed under the License is distributed on an "AS IS" BASIS, |
| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| See the License for the specific language governing permissions and |
| limitations under the License. |
+--------------------------------------------------------------------------*/
package org.fortiss.tooling.kernel.ui.introspection;
import static org.fortiss.tooling.common.util.LambdaUtils.getFirst;
import java.util.stream.Collectors;
import org.fortiss.tooling.common.ui.javafx.layout.CompositeFXControllerBase;
import org.fortiss.tooling.kernel.introspection.IIntrospectionItem;
import org.fortiss.tooling.kernel.introspection.KernelIntrospectionSystemService;
import javafx.beans.value.ChangeListener;
import javafx.beans.value.ObservableValue;
import javafx.fxml.FXML;
import javafx.scene.Node;
import javafx.scene.control.TreeCell;
import javafx.scene.control.TreeItem;
import javafx.scene.control.TreeView;
import javafx.scene.layout.BorderPane;
/**
* Controller for the Java FX-based UI common to all KISS-based views. The specific views to be
* displayed have extend the abstract {@link KISSCompositeFXController} class.
*
* @author munaro
*/
public class KISSFXController extends CompositeFXControllerBase<BorderPane, Node>
implements ChangeListener<TreeItem<IIntrospectionItem>> {
/** The pane of the view. */
@FXML
protected BorderPane borderPane;
/** The introspection service. */
protected KernelIntrospectionSystemService kiss;
/** The tree viewer. */
private TreeView<IIntrospectionItem> treeview;
/** The {@link KISSCompositeFXController} of the specific KISS view to be displayed. */
private KISSCompositeFXController<? extends Node> composite;
/** Constructor. */
@SuppressWarnings("unchecked")
public KISSFXController(KISSCompositeFXController<? extends Node> composite) {
super(composite);
this.composite = composite;
this.kiss = KernelIntrospectionSystemService.getInstance();
}
/**
* Implementation for tree cells returning the
* {@link IIntrospectionItem#getIntrospectionLabel()}.
*/
private class TreeCellImpl extends TreeCell<IIntrospectionItem> {
/** {@inheritDoc} */
@Override
protected void updateItem(IIntrospectionItem item, boolean empty) {
super.updateItem(item, empty);
String text = null;
if(!empty && item != null) {
text = item.getIntrospectionLabel();
}
setText(text);
setGraphic(null);
}
}
/** {@inheritDoc} */
@Override
public String getFXMLLocation() {
return "KISS.fxml";
}
/** {@inheritDoc} */
@Override
public void initialize() {
TreeItem<IIntrospectionItem> root = new TreeItem<IIntrospectionItem>(kiss);
root.getChildren()
.addAll(kiss.getIntrospectionItems().stream().map((IIntrospectionItem iii) -> {
return new TreeItem<IIntrospectionItem>(iii);
}).collect(Collectors.toList()));
root.setExpanded(true);
root.getChildren().sort((c0, c1) -> {
String l0 = c0.getValue().getIntrospectionLabel();
String l1 = c1.getValue().getIntrospectionLabel();
return l0.compareTo(l1);
});
treeview = new TreeView<IIntrospectionItem>(root);
treeview.setCellFactory((TreeView<IIntrospectionItem> tv) -> {
return new TreeCellImpl();
});
treeview.getSelectionModel().selectedItemProperty().addListener(this);
borderPane.setLeft(treeview);
Node center = getFirst(getContainments()).get().getLayout();
borderPane.setCenter(center);
}
/** {@inheritDoc} */
@Override
public void changed(ObservableValue<? extends TreeItem<IIntrospectionItem>> observable,
TreeItem<IIntrospectionItem> oldValue, TreeItem<IIntrospectionItem> newValue) {
composite.changed(newValue.getValue());
}
}
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