X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=bundles%2Forg.simantics.selectionview%2Fsrc%2Forg%2Fsimantics%2Fselectionview%2FStandardPropertyPage.java;fp=bundles%2Forg.simantics.selectionview%2Fsrc%2Forg%2Fsimantics%2Fselectionview%2FStandardPropertyPage.java;h=b534e647a18f45a718651ea0132d822d41f69c15;hb=969bd23cab98a79ca9101af33334000879fb60c5;hp=0000000000000000000000000000000000000000;hpb=866dba5cd5a3929bbeae85991796acb212338a08;p=simantics%2Fplatform.git
diff --git a/bundles/org.simantics.selectionview/src/org/simantics/selectionview/StandardPropertyPage.java b/bundles/org.simantics.selectionview/src/org/simantics/selectionview/StandardPropertyPage.java
new file mode 100644
index 000000000..b534e647a
--- /dev/null
+++ b/bundles/org.simantics.selectionview/src/org/simantics/selectionview/StandardPropertyPage.java
@@ -0,0 +1,292 @@
+/*******************************************************************************
+ * Copyright (c) 2007, 2010 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.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.Set;
+import java.util.TreeSet;
+import java.util.function.Consumer;
+
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.ui.IWorkbenchPartSite;
+import org.simantics.utils.ObjectUtils;
+
+/**
+ *
+ * See PropertyPage for more information on what can be extended or
+ * reimplemented from the superclasses. In addition to those, subclasses may
+ * extend or reimplement the following methods:
+ *
+ *
getContexts - reimplement to define what browse contexts
+ * this property page should be initialized with. The same result can also be
+ * achieved by using the
+ * {@link StandardPropertyPage#StandardPropertyPage(IWorkbenchPartSite, Set)}
+ * constructor.
+ *
+ *
+ *
+ * @author Tuukka Lehtonen
+ *
+ * @see StandardProperties
+ */
+public class StandardPropertyPage extends PropertyPage {
+
+ private final Set contexts;
+ private StandardProperties tabs;
+
+ /**
+ * For updating the view title when the active tab changes.
+ */
+ //private transient ISelection lastSelection;
+ private transient Consumer lastTitleCallback;
+
+ /**
+ * Initializes a new standard property page for the specified workbench part
+ * without loading the page configuration from any extensible contexts.
+ *
+ * @param site the workbench part site that contains this page or
+ * null if there is no site, i.e. the page is within a
+ * dialog or a plain shell.
+ */
+ public StandardPropertyPage(IWorkbenchPartSite site) {
+ this(site, new TreeSet());
+ }
+
+ /**
+ * Initializes a new standard property page for the specified workbench part
+ * and specifies which contexts should be searched for
+ * {@link SelectionProcessor} and {@link PropertyTabContributor} bindings to
+ * initialize the page.
+ *
+ * @param site the workbench part site that contains this page or
+ * null if there is no site, i.e. the page is within a
+ * dialog or a plain shell.
+ * @param contexts the contexts to search bindings for to initialize the
+ * property page
+ */
+ public StandardPropertyPage(IWorkbenchPartSite site, Set contexts) {
+ super(site);
+ this.contexts = contexts;
+ }
+
+ protected SelectionProcessor, ?> getSelectionProcessor() {
+ return new StandardSelectionProcessor();
+ }
+
+ protected Set getContexts() {
+ return contexts;
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ protected void createPageControls(Composite parent) {
+ SelectionProcessor, ?> sp = getSelectionProcessor();
+ @SuppressWarnings("rawtypes")
+ Collection sps = null;
+ if (sp != null)
+ sps = Collections.singleton(sp);
+
+ tabs = new StandardProperties(sourceSite, getSite(), parent, SWT.NONE, getContexts(), sps) {
+ @Override
+ protected void activeTabChanged(TabChangeEvent event) {
+ StandardPropertyPage.this.activeTabChanged(event);
+ }
+ @Override
+ protected ComparableTabContributor selectInitialTab(Collection