1 /*******************************************************************************
2 * Copyright (c) 2007, 2010 Association for Decentralized Information Management
4 * All rights reserved. This program and the accompanying materials
5 * are made available under the terms of the Eclipse Public License v1.0
6 * which accompanies this distribution, and is available at
7 * http://www.eclipse.org/legal/epl-v10.html
10 * VTT Technical Research Centre of Finland - initial API and implementation
11 *******************************************************************************/
12 package org.simantics.selectionview;
14 import java.util.Collection;
15 import java.util.HashSet;
18 import org.eclipse.swt.widgets.Composite;
19 import org.eclipse.ui.IWorkbenchPartSite;
20 import org.eclipse.ui.part.IPageSite;
21 import org.simantics.browsing.ui.common.ErrorLogger;
22 import org.simantics.browsing.ui.common.views.IFilterArea;
23 import org.simantics.browsing.ui.common.views.IFilterAreaProvider;
24 import org.simantics.db.ReadGraph;
27 * @author Antti Villberg
29 * @see StandardPropertyPage
31 public class StandardProperties extends TabbedPropertyTable implements IFilterAreaProvider, IPropertyTab {
38 * @param browseContexts the browse contexts to use for loading this
40 * @param selectionProcessors a fixed set of selection processors, may be
43 public StandardProperties(IWorkbenchPartSite site, IPageSite pageSite, Composite parent, int style,
44 final Set<String> browseContexts, final Collection<SelectionProcessor<?, ?>> selectionProcessors) {
45 super(site, pageSite, parent, style);
47 final Set<SelectionProcessor<?, ?>> processors = new HashSet<SelectionProcessor<?, ?>>();
48 if (selectionProcessors != null)
49 processors.addAll(selectionProcessors);
51 //System.out.println("StandardProperties with contexts: " + browseContexts);
52 for (final SelectionProcessorBinding binding : SelectionProcessorBindingExtensionManager.getInstance().getBoundContributions(browseContexts)) {
53 //System.out.println("found " + binding.getProcessor());
54 processors.add(binding.getProcessor());
57 setSelectionProcessor(new SelectionProcessor<Object, ReadGraph>() {
59 @SuppressWarnings({ "rawtypes", "unchecked" })
61 public Collection<?> process(final Object selection, ReadGraph graph) {
63 HashSet<Object> l = new HashSet<Object>();
64 for (SelectionProcessor p : processors) {
65 Collection<?> c = p.process(selection, graph);
69 ErrorLogger.defaultLogWarning("SelectionProcessor '" + p + "' invalidly returned null with selection '" + selection + "'", null);
81 public IFilterArea getFilterArea() {
82 IPropertyTab active = getActiveTab();
83 if (!(active instanceof IFilterAreaProvider))
85 return ((IFilterAreaProvider) active).getFilterArea();