X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=bundles%2Forg.simantics.modeling.ui%2Fsrc%2Forg%2Fsimantics%2Fmodeling%2Fui%2FdiagramEditor%2Fhandlers%2FWorkbenchStructuralSelectionProvider.java;h=b9323bec4dbe6cea8ec1064b4f1c0a476eef2a9a;hb=b000e272429e157638c0384878b07b8dcd758472;hp=4b46b9b2ac8fa9aa11cadc9978a50526039a8d37;hpb=969bd23cab98a79ca9101af33334000879fb60c5;p=simantics%2Fplatform.git diff --git a/bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/diagramEditor/handlers/WorkbenchStructuralSelectionProvider.java b/bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/diagramEditor/handlers/WorkbenchStructuralSelectionProvider.java index 4b46b9b2a..b9323bec4 100644 --- a/bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/diagramEditor/handlers/WorkbenchStructuralSelectionProvider.java +++ b/bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/diagramEditor/handlers/WorkbenchStructuralSelectionProvider.java @@ -1,65 +1,65 @@ -/******************************************************************************* - * 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.modeling.ui.diagramEditor.handlers; - -import java.util.ArrayList; - -import org.eclipse.jface.viewers.IPostSelectionProvider; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.viewers.StructuredSelection; -import org.eclipse.ui.IWorkbenchPartSite; -import org.simantics.db.Resource; -import org.simantics.db.common.ResourceArray; -import org.simantics.diagram.ui.WorkbenchSelectionProvider; -import org.simantics.g2d.element.ElementHints; -import org.simantics.g2d.element.IElement; -import org.simantics.utils.threads.IThreadWorkQueue; - -/** - * A canvas participant that listens to the #0 mouse selection and provides it - * forward through the {@link IPostSelectionProvider} interface. - * - * @author Tuukka Lehtonen - */ -public class WorkbenchStructuralSelectionProvider extends WorkbenchSelectionProvider { - - ResourceArray suffix; - - public WorkbenchStructuralSelectionProvider(IThreadWorkQueue swt, ResourceArray appendToSelections) { - this(swt, null, appendToSelections); - } - - public WorkbenchStructuralSelectionProvider(IThreadWorkQueue swt, IWorkbenchPartSite site, ResourceArray appendToSelections) { - super(swt, site); - this.suffix = appendToSelections; - } - - protected ISelection constructAdaptableSelection(Iterable selection) { - ArrayList objects = new ArrayList(); - for (Object o : selection) { - if (o instanceof IElement) { - IElement e = (IElement) o; - Object object = e.getHint(ElementHints.KEY_OBJECT); - if (object instanceof Resource) { - objects.add(suffix.prepended((Resource) object)); - } else { - objects.add(object); - objects.add(suffix); - } - } else { - System.out.println(" unrecognized selection: " + o.getClass() + ": " + o); - } - } - return new StructuredSelection(objects); - } - -} +/******************************************************************************* + * 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.modeling.ui.diagramEditor.handlers; + +import java.util.ArrayList; + +import org.eclipse.jface.viewers.IPostSelectionProvider; +import org.eclipse.jface.viewers.ISelection; +import org.eclipse.jface.viewers.StructuredSelection; +import org.eclipse.ui.IWorkbenchPartSite; +import org.simantics.db.Resource; +import org.simantics.db.common.ResourceArray; +import org.simantics.diagram.ui.WorkbenchSelectionProvider; +import org.simantics.g2d.element.ElementHints; +import org.simantics.g2d.element.IElement; +import org.simantics.utils.threads.IThreadWorkQueue; + +/** + * A canvas participant that listens to the #0 mouse selection and provides it + * forward through the {@link IPostSelectionProvider} interface. + * + * @author Tuukka Lehtonen + */ +public class WorkbenchStructuralSelectionProvider extends WorkbenchSelectionProvider { + + ResourceArray suffix; + + public WorkbenchStructuralSelectionProvider(IThreadWorkQueue swt, ResourceArray appendToSelections) { + this(swt, null, appendToSelections); + } + + public WorkbenchStructuralSelectionProvider(IThreadWorkQueue swt, IWorkbenchPartSite site, ResourceArray appendToSelections) { + super(swt, site); + this.suffix = appendToSelections; + } + + protected ISelection constructAdaptableSelection(Iterable selection) { + ArrayList objects = new ArrayList(); + for (Object o : selection) { + if (o instanceof IElement) { + IElement e = (IElement) o; + Object object = e.getHint(ElementHints.KEY_OBJECT); + if (object instanceof Resource) { + objects.add(suffix.prepended((Resource) object)); + } else { + objects.add(object); + objects.add(suffix); + } + } else { + System.out.println(" unrecognized selection: " + o.getClass() + ": " + o); + } + } + return new StructuredSelection(objects); + } + +}