X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=blobdiff_plain;f=bundles%2Forg.simantics.debug.ui%2Fsrc%2Forg%2Fsimantics%2Fdebug%2Fui%2FSearchResourceDialog.java;h=591436dc529ec8329cd41890b1c0f3cb7e63b7d2;hb=HEAD;hp=8532be1ae28a6cce6b97a280d399d399a2040897;hpb=236aa4e765e0acd6e31cbc42dd9df9c2c23677e2;p=simantics%2Fplatform.git diff --git a/bundles/org.simantics.debug.ui/src/org/simantics/debug/ui/SearchResourceDialog.java b/bundles/org.simantics.debug.ui/src/org/simantics/debug/ui/SearchResourceDialog.java index 8532be1ae..591436dc5 100644 --- a/bundles/org.simantics.debug.ui/src/org/simantics/debug/ui/SearchResourceDialog.java +++ b/bundles/org.simantics.debug.ui/src/org/simantics/debug/ui/SearchResourceDialog.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2016 Association for Decentralized Information Management + * Copyright (c) 2007, 2019 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 @@ -13,6 +13,7 @@ package org.simantics.debug.ui; import java.util.ArrayList; +import java.util.Arrays; import java.util.Collection; import java.util.Collections; import java.util.Comparator; @@ -23,6 +24,7 @@ import java.util.Set; import java.util.TreeSet; import java.util.regex.Matcher; import java.util.regex.Pattern; +import java.util.stream.Collectors; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IProgressMonitor; @@ -56,6 +58,8 @@ import org.simantics.db.common.request.UniqueRead; import org.simantics.db.common.uri.UnescapedChildMapOfResource; import org.simantics.db.common.utils.NameUtils; import org.simantics.db.exception.DatabaseException; +import org.simantics.db.layer0.genericrelation.Dependencies; +import org.simantics.db.layer0.genericrelation.IndexQueries; import org.simantics.db.layer0.migration.OntologiesFromLibrary; import org.simantics.db.layer0.variable.Variables.Role; import org.simantics.db.request.Read; @@ -302,15 +306,20 @@ public class SearchResourceDialog extends FilteredItemsSelectionDialog { } } } else { + String[] terms = pattern.trim().split("\\s+"); //$NON-NLS-1$ + if (terms.length == 0) return; + Resource project = Simantics.peekProjectResource(); if (project != null) { + Layer0 L0 = Layer0.getInstance(graph); IResourceFilter rf = resourceFilter; - String filter = getFilterForResourceFilter(rf); + String filter = getFilterForResourceFilter(L0, rf); if (!filter.isEmpty()) filter += " AND "; //$NON-NLS-1$ - filter += "Name:" + pattern + "*"; //$NON-NLS-1$ //$NON-NLS-2$ - - Layer0 L0 = Layer0.getInstance(graph); + + filter += Dependencies.FIELD_NAME_SEARCH + ":("; //$NON-NLS-1$ + filter += Arrays.stream(terms).map(term -> "+" + IndexQueries.escape(term.toLowerCase(), false) + "*").collect(Collectors.joining(" ")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ + filter +=")"; //$NON-NLS-1$ Set indexRoots = new HashSet<>(); indexRoots.addAll(graph.syncRequest(new ObjectsWithType(project, L0.ConsistsOf, L0.IndexRoot))); @@ -462,13 +471,13 @@ public class SearchResourceDialog extends FilteredItemsSelectionDialog { this.resourceFilter = resourceFilter; } - private String getFilterForResourceFilter(IResourceFilter filter) { + private String getFilterForResourceFilter(Layer0 l0, IResourceFilter filter) { if (filter == null || filter == ResourceSearch.FILTER_ALL) return ""; //$NON-NLS-1$ if (filter == ResourceSearch.FILTER_RELATIONS) - return "Types:Relation"; //$NON-NLS-1$ + return IndexQueries.resourceIdTerm(Dependencies.FIELD_TYPE_RESOURCE, l0.Relation); if (filter == ResourceSearch.FILTER_TYPES) - return "Types:Type"; //$NON-NLS-1$ + return IndexQueries.resourceIdTerm(Dependencies.FIELD_TYPE_RESOURCE, l0.Type); return ""; //$NON-NLS-1$ }