X-Git-Url: https://gerrit.simantics.org/r/gitweb?p=simantics%2Fplatform.git;a=blobdiff_plain;f=bundles%2Forg.simantics.browsing.ui.swt%2Fsrc%2Forg%2Fsimantics%2Fbrowsing%2Fui%2Fswt%2FResourceSelectionFilter.java;h=724d8b7e08adbdfb14a55e3367a78a2e6f80bf4e;hp=79cfcb4553e1cd16dbd768ad44f63c23e052fa60;hb=0ae2b770234dfc3cbb18bd38f324125cf0faca07;hpb=24e2b34260f219f0d1644ca7a138894980e25b14 diff --git a/bundles/org.simantics.browsing.ui.swt/src/org/simantics/browsing/ui/swt/ResourceSelectionFilter.java b/bundles/org.simantics.browsing.ui.swt/src/org/simantics/browsing/ui/swt/ResourceSelectionFilter.java index 79cfcb455..724d8b7e0 100644 --- a/bundles/org.simantics.browsing.ui.swt/src/org/simantics/browsing/ui/swt/ResourceSelectionFilter.java +++ b/bundles/org.simantics.browsing.ui.swt/src/org/simantics/browsing/ui/swt/ResourceSelectionFilter.java @@ -1,47 +1,47 @@ -/******************************************************************************* - * Copyright (c) 2007, 2012 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.browsing.ui.swt; - -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.ui.IWorkbenchPart; -import org.simantics.db.Resource; -import org.simantics.ui.utils.ResourceAdaptionUtils; - -/** - * @author Tuukka Lehtonen - * - */ -public class ResourceSelectionFilter implements WorkbenchSelectionFilter { - - public static final ResourceSelectionFilter FILTER = new ResourceSelectionFilter(); - - @Override - public ISelection filterSelection(IWorkbenchPart part, ISelection s) { - // Nevermind the part, just check that the selection contains nothing - // but resources. - if (s instanceof IStructuredSelection) { - IStructuredSelection ss = (IStructuredSelection) s; - if (ss.isEmpty()) - return null; - - Resource[] resources = ResourceAdaptionUtils.toResources(ss); - if (resources.length == ss.size()) { - return s; - } - } - - // Not worth passing. - return null; - } - -} +/******************************************************************************* + * Copyright (c) 2007, 2012 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.browsing.ui.swt; + +import org.eclipse.jface.viewers.ISelection; +import org.eclipse.jface.viewers.IStructuredSelection; +import org.eclipse.ui.IWorkbenchPart; +import org.simantics.db.Resource; +import org.simantics.ui.utils.ResourceAdaptionUtils; + +/** + * @author Tuukka Lehtonen + * + */ +public class ResourceSelectionFilter implements WorkbenchSelectionFilter { + + public static final ResourceSelectionFilter FILTER = new ResourceSelectionFilter(); + + @Override + public ISelection filterSelection(IWorkbenchPart part, ISelection s) { + // Nevermind the part, just check that the selection contains nothing + // but resources. + if (s instanceof IStructuredSelection) { + IStructuredSelection ss = (IStructuredSelection) s; + if (ss.isEmpty()) + return null; + + Resource[] resources = ResourceAdaptionUtils.toResources(ss); + if (resources.length == ss.size()) { + return s; + } + } + + // Not worth passing. + return null; + } + +}