-/*******************************************************************************\r
- * Copyright (c) 2007, 2011 Association for Decentralized Information Management in\r
- * Industry THTH ry.\r
- * All rights reserved. This program and the accompanying materials\r
- * are made available under the terms of the Eclipse Public License v1.0\r
- * which accompanies this distribution, and is available at\r
- * http://www.eclipse.org/legal/epl-v10.html\r
- *\r
- * Contributors:\r
- * VTT Technical Research Centre of Finland - initial API and implementation\r
- *******************************************************************************/\r
-package org.simantics.selectionview;\r
-\r
-import java.util.function.Consumer;\r
-\r
-import org.eclipse.jface.layout.GridDataFactory;\r
-import org.eclipse.jface.viewers.ISelection;\r
-import org.eclipse.jface.viewers.ISelectionProvider;\r
-import org.eclipse.swt.SWT;\r
-import org.eclipse.swt.widgets.Composite;\r
-import org.eclipse.swt.widgets.Control;\r
-import org.eclipse.swt.widgets.Tree;\r
-import org.eclipse.ui.IWorkbenchSite;\r
-import org.simantics.browsing.ui.Column;\r
-import org.simantics.browsing.ui.Column.Align;\r
-import org.simantics.browsing.ui.GraphExplorer;\r
-import org.simantics.browsing.ui.common.ColumnKeys;\r
-import org.simantics.browsing.ui.common.EvaluatorData;\r
-import org.simantics.browsing.ui.common.EvaluatorData.Evaluator;\r
-import org.simantics.browsing.ui.common.comparators.AlphanumericComparatorFactory;\r
-import org.simantics.browsing.ui.common.processors.FilterSelectionRequestQueryProcessor;\r
-import org.simantics.browsing.ui.common.views.IFilterArea;\r
-import org.simantics.browsing.ui.graph.impl.ArrayPropertyLabelerFactory;\r
-import org.simantics.browsing.ui.graph.impl.ArrayPropertyValueViewpointFactory;\r
-import org.simantics.browsing.ui.graph.impl.PropertyViewpointFactory;\r
-import org.simantics.browsing.ui.graph.impl.RelationContextLabelerFactory;\r
-import org.simantics.browsing.ui.graph.impl.ResourceProperty;\r
-import org.simantics.browsing.ui.graph.impl.StringRepresentationLabelerFactory;\r
-import org.simantics.browsing.ui.swt.ArrayPropertyImagerFactory;\r
-import org.simantics.browsing.ui.swt.PropertyIsExpandedProcessor;\r
-import org.simantics.browsing.ui.swt.PropertyLabelDecoratorFactory;\r
-import org.simantics.browsing.ui.swt.RootFilterArea;\r
-import org.simantics.browsing.ui.swt.SingleSelectionInputSource;\r
-import org.simantics.browsing.ui.swt.widgets.GraphExplorerComposite;\r
-import org.simantics.browsing.ui.swt.widgets.impl.WidgetSupport;\r
-import org.simantics.db.RelationContext;\r
-import org.simantics.db.Resource;\r
-import org.simantics.db.Statement;\r
-import org.simantics.db.common.ResourceArray;\r
-import org.simantics.db.management.ISessionContext;\r
-import org.simantics.utils.datastructures.ArrayMap;\r
-\r
-/**\r
- * @author Tuukka Lehtonen\r
- */\r
-public class BasicPropertyTab extends PropertyTabContributorImpl {\r
-\r
- protected RootFilterArea filterArea;\r
- protected GraphExplorerComposite parameterExplorer;\r
-\r
- public void updatePartName(ISelection forSelection, Consumer<String> updateCallback) {\r
- updateCallback.accept(null);\r
- }\r
-\r
- protected void initializeExplorerWithEvaluator(GraphExplorer explorer, ISessionContext context,\r
- EvaluatorData data) {\r
-\r
- Evaluator resourceEvaluator = data.newEvaluator()\r
- .addViewpoint(new PropertyViewpointFactory(), 1.0)\r
- .addComparator(new AlphanumericComparatorFactory(ColumnKeys.PROPERTY), 2.0)\r
- .addComparator(new AlphanumericComparatorFactory(ColumnKeys.PROPERTY, true), 1.0)\r
- .addLabeler(new StringRepresentationLabelerFactory(ColumnKeys.PROPERTY), 1.0);\r
-\r
- Evaluator statementEvaluator = data.newEvaluator()\r
- .addViewpoint(new PropertyViewpointFactory(), 1.0)\r
- .addComparator(new AlphanumericComparatorFactory(ColumnKeys.PROPERTY), 2.0)\r
- .addComparator(new AlphanumericComparatorFactory(ColumnKeys.PROPERTY, true), 1.0);\r
-\r
- Evaluator relationContextEvaluator = data.newEvaluator()\r
- .addLabeler(new RelationContextLabelerFactory(), 1.0);\r
-\r
- Evaluator propertyEvaluator = data.newEvaluator()\r
- .addViewpoint(new ArrayPropertyValueViewpointFactory(), 1.0)\r
- .addLabeler(new ArrayPropertyLabelerFactory(), 1.0)\r
- .addImager(new ArrayPropertyImagerFactory(), 1.0)\r
- .addLabelDecorator(new PropertyLabelDecoratorFactory(), 1.0);\r
-\r
- data.addEvaluator(Resource.class, resourceEvaluator);\r
- data.addEvaluator(ResourceArray.class, resourceEvaluator);\r
- data.addEvaluator(Statement.class, statementEvaluator);\r
- data.addEvaluator(RelationContext.class, relationContextEvaluator);\r
- data.addEvaluator(ResourceProperty.class, propertyEvaluator);\r
- \r
- }\r
-\r
- @Override\r
- public void createControls(Composite body, IWorkbenchSite site, ISessionContext context, WidgetSupport support) {\r
- Column[] COLUMNS = new Column[] {\r
- new Column(ColumnKeys.PROPERTY, Align.LEFT, 175, "Property Name", true, 1),\r
- new Column(ColumnKeys.VALUE, Align.LEFT, 175, "Value of Property", true, 3)\r
- };\r
-\r
- parameterExplorer = new GraphExplorerComposite(\r
- ArrayMap.keys("displaySelectors", "displayFilter").values(false, false),\r
- site, body, support, SWT.FULL_SELECTION | SWT.MULTI) {\r
- @Override\r
- protected void initializeExplorerWithEvaluator(GraphExplorer explorer, ISessionContext context, EvaluatorData data) {\r
- BasicPropertyTab.this.initializeExplorerWithEvaluator(explorer, context, data);\r
- }\r
- };\r
- // Must set, even if empty.\r
- parameterExplorer.setBrowseContexts();\r
- //parameterExplorer.setStatePersistor(new IdentifiedStatePersistor(getClass().getCanonicalName()));\r
- parameterExplorer.setContextMenuId("#PropertiesPopup");\r
- parameterExplorer.setEditingColumn(ColumnKeys.VALUE);\r
- parameterExplorer.setColumns(COLUMNS);\r
- parameterExplorer.setInputSource(new SingleSelectionInputSource(Resource.class));\r
- parameterExplorer.finish();\r
- GridDataFactory.fillDefaults().grab(true, true).span(2, 1).applyTo(parameterExplorer);\r
-\r
- Control c = parameterExplorer.getExplorerControl();\r
- if (c instanceof Tree)\r
- ((Tree) c).setLinesVisible(true);\r
-\r
- FilterSelectionRequestQueryProcessor filterProcessor = new FilterSelectionRequestQueryProcessor();\r
- parameterExplorer.getExplorer().setPrimitiveProcessor(filterProcessor);\r
- filterArea = new RootFilterArea(parameterExplorer.getExplorer(), filterProcessor, parameterExplorer, SWT.NONE);\r
- filterArea.moveAbove(parameterExplorer.getExplorerComposite());\r
-\r
- // IMPORTANT: without this property expandedness tracking will not work properly\r
- parameterExplorer.getExplorer().setPrimitiveProcessor(new PropertyIsExpandedProcessor());\r
- }\r
-\r
- @Override\r
- public IFilterArea getFilterArea() {\r
- return filterArea;\r
- }\r
-\r
- @Override\r
- public ISelectionProvider getSelectionProvider() {\r
- return (ISelectionProvider) parameterExplorer.getAdapter(ISelectionProvider.class);\r
- }\r
-\r
+/*******************************************************************************
+ * Copyright (c) 2007, 2011 Association for Decentralized Information Management in
+ * Industry THTH ry.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * VTT Technical Research Centre of Finland - initial API and implementation
+ *******************************************************************************/
+package org.simantics.selectionview;
+
+import java.util.function.Consumer;
+
+import org.eclipse.jface.layout.GridDataFactory;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.ISelectionProvider;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Tree;
+import org.eclipse.ui.IWorkbenchSite;
+import org.simantics.browsing.ui.Column;
+import org.simantics.browsing.ui.Column.Align;
+import org.simantics.browsing.ui.GraphExplorer;
+import org.simantics.browsing.ui.common.ColumnKeys;
+import org.simantics.browsing.ui.common.EvaluatorData;
+import org.simantics.browsing.ui.common.EvaluatorData.Evaluator;
+import org.simantics.browsing.ui.common.comparators.AlphanumericComparatorFactory;
+import org.simantics.browsing.ui.common.processors.FilterSelectionRequestQueryProcessor;
+import org.simantics.browsing.ui.common.views.IFilterArea;
+import org.simantics.browsing.ui.graph.impl.ArrayPropertyLabelerFactory;
+import org.simantics.browsing.ui.graph.impl.ArrayPropertyValueViewpointFactory;
+import org.simantics.browsing.ui.graph.impl.PropertyViewpointFactory;
+import org.simantics.browsing.ui.graph.impl.RelationContextLabelerFactory;
+import org.simantics.browsing.ui.graph.impl.ResourceProperty;
+import org.simantics.browsing.ui.graph.impl.StringRepresentationLabelerFactory;
+import org.simantics.browsing.ui.swt.ArrayPropertyImagerFactory;
+import org.simantics.browsing.ui.swt.PropertyIsExpandedProcessor;
+import org.simantics.browsing.ui.swt.PropertyLabelDecoratorFactory;
+import org.simantics.browsing.ui.swt.RootFilterArea;
+import org.simantics.browsing.ui.swt.SingleSelectionInputSource;
+import org.simantics.browsing.ui.swt.widgets.GraphExplorerComposite;
+import org.simantics.browsing.ui.swt.widgets.impl.WidgetSupport;
+import org.simantics.db.RelationContext;
+import org.simantics.db.Resource;
+import org.simantics.db.Statement;
+import org.simantics.db.common.ResourceArray;
+import org.simantics.db.management.ISessionContext;
+import org.simantics.utils.datastructures.ArrayMap;
+
+/**
+ * @author Tuukka Lehtonen
+ */
+public class BasicPropertyTab extends PropertyTabContributorImpl {
+
+ protected RootFilterArea filterArea;
+ protected GraphExplorerComposite parameterExplorer;
+
+ public void updatePartName(ISelection forSelection, Consumer<String> updateCallback) {
+ updateCallback.accept(null);
+ }
+
+ protected void initializeExplorerWithEvaluator(GraphExplorer explorer, ISessionContext context,
+ EvaluatorData data) {
+
+ Evaluator resourceEvaluator = data.newEvaluator()
+ .addViewpoint(new PropertyViewpointFactory(), 1.0)
+ .addComparator(new AlphanumericComparatorFactory(ColumnKeys.PROPERTY), 2.0)
+ .addComparator(new AlphanumericComparatorFactory(ColumnKeys.PROPERTY, true), 1.0)
+ .addLabeler(new StringRepresentationLabelerFactory(ColumnKeys.PROPERTY), 1.0);
+
+ Evaluator statementEvaluator = data.newEvaluator()
+ .addViewpoint(new PropertyViewpointFactory(), 1.0)
+ .addComparator(new AlphanumericComparatorFactory(ColumnKeys.PROPERTY), 2.0)
+ .addComparator(new AlphanumericComparatorFactory(ColumnKeys.PROPERTY, true), 1.0);
+
+ Evaluator relationContextEvaluator = data.newEvaluator()
+ .addLabeler(new RelationContextLabelerFactory(), 1.0);
+
+ Evaluator propertyEvaluator = data.newEvaluator()
+ .addViewpoint(new ArrayPropertyValueViewpointFactory(), 1.0)
+ .addLabeler(new ArrayPropertyLabelerFactory(), 1.0)
+ .addImager(new ArrayPropertyImagerFactory(), 1.0)
+ .addLabelDecorator(new PropertyLabelDecoratorFactory(), 1.0);
+
+ data.addEvaluator(Resource.class, resourceEvaluator);
+ data.addEvaluator(ResourceArray.class, resourceEvaluator);
+ data.addEvaluator(Statement.class, statementEvaluator);
+ data.addEvaluator(RelationContext.class, relationContextEvaluator);
+ data.addEvaluator(ResourceProperty.class, propertyEvaluator);
+
+ }
+
+ @Override
+ public void createControls(Composite body, IWorkbenchSite site, ISessionContext context, WidgetSupport support) {
+ Column[] COLUMNS = new Column[] {
+ new Column(ColumnKeys.PROPERTY, Align.LEFT, 175, "Property Name", true, 1),
+ new Column(ColumnKeys.VALUE, Align.LEFT, 175, "Value of Property", true, 3)
+ };
+
+ parameterExplorer = new GraphExplorerComposite(
+ ArrayMap.keys("displaySelectors", "displayFilter").values(false, false),
+ site, body, support, SWT.FULL_SELECTION | SWT.MULTI) {
+ @Override
+ protected void initializeExplorerWithEvaluator(GraphExplorer explorer, ISessionContext context, EvaluatorData data) {
+ BasicPropertyTab.this.initializeExplorerWithEvaluator(explorer, context, data);
+ }
+ };
+ // Must set, even if empty.
+ parameterExplorer.setBrowseContexts();
+ //parameterExplorer.setStatePersistor(new IdentifiedStatePersistor(getClass().getCanonicalName()));
+ parameterExplorer.setContextMenuId("#PropertiesPopup");
+ parameterExplorer.setEditingColumn(ColumnKeys.VALUE);
+ parameterExplorer.setColumns(COLUMNS);
+ parameterExplorer.setInputSource(new SingleSelectionInputSource(Resource.class));
+ parameterExplorer.finish();
+ GridDataFactory.fillDefaults().grab(true, true).span(2, 1).applyTo(parameterExplorer);
+
+ Control c = parameterExplorer.getExplorerControl();
+ if (c instanceof Tree)
+ ((Tree) c).setLinesVisible(true);
+
+ FilterSelectionRequestQueryProcessor filterProcessor = new FilterSelectionRequestQueryProcessor();
+ parameterExplorer.getExplorer().setPrimitiveProcessor(filterProcessor);
+ filterArea = new RootFilterArea(parameterExplorer.getExplorer(), filterProcessor, parameterExplorer, SWT.NONE);
+ filterArea.moveAbove(parameterExplorer.getExplorerComposite());
+
+ // IMPORTANT: without this property expandedness tracking will not work properly
+ parameterExplorer.getExplorer().setPrimitiveProcessor(new PropertyIsExpandedProcessor());
+ }
+
+ @Override
+ public IFilterArea getFilterArea() {
+ return filterArea;
+ }
+
+ @Override
+ public ISelectionProvider getSelectionProvider() {
+ return (ISelectionProvider) parameterExplorer.getAdapter(ISelectionProvider.class);
+ }
+
}
\ No newline at end of file