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%2Fcontentassist%2FNamedObjectContentProposalProvider.java;h=fddb3f477a2f870aa48314e5ff8c1f9b7a27a4c9;hp=d8fb97be0cb273491f5f3344a41fd8d9ca4971d4;hb=0ae2b770234dfc3cbb18bd38f324125cf0faca07;hpb=969bd23cab98a79ca9101af33334000879fb60c5 diff --git a/bundles/org.simantics.browsing.ui.swt/src/org/simantics/browsing/ui/swt/contentassist/NamedObjectContentProposalProvider.java b/bundles/org.simantics.browsing.ui.swt/src/org/simantics/browsing/ui/swt/contentassist/NamedObjectContentProposalProvider.java index d8fb97be0..fddb3f477 100644 --- a/bundles/org.simantics.browsing.ui.swt/src/org/simantics/browsing/ui/swt/contentassist/NamedObjectContentProposalProvider.java +++ b/bundles/org.simantics.browsing.ui.swt/src/org/simantics/browsing/ui/swt/contentassist/NamedObjectContentProposalProvider.java @@ -1,60 +1,60 @@ -/******************************************************************************* - * 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.contentassist; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collection; -import java.util.List; - -import org.eclipse.jface.fieldassist.IContentProposal; -import org.eclipse.jface.fieldassist.IContentProposalProvider; - -/** - * @author Tuukka Lehtonen - * - * @param - */ -public class NamedObjectContentProposalProvider implements IContentProposalProvider { - - private final Collection content; - - public NamedObjectContentProposalProvider(T[] content) { - this(Arrays.asList(content)); - } - - public NamedObjectContentProposalProvider(Collection content) { - this.content = content; - } - - @Override - public IContentProposal[] getProposals(String contents, int position) { - String prefix = contents.substring(0, position).toLowerCase(); - - List result = new ArrayList(content.size()); - for (INamedObject obj : content) { - if (obj.getName().toLowerCase().startsWith(prefix)) - result.add(obj); - } - - IContentProposal[] proposals = new IContentProposal[result.size()]; - for (int i = 0; i < result.size(); ++i) - proposals[i] = createProposal(result.get(i), position); - - return proposals; - } - - public INamedObjectContentProposal createProposal(INamedObject object, int position) { - return new NamedObjectContentProposal((NamedObject) object, position); - } - -} +/******************************************************************************* + * 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.contentassist; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.List; + +import org.eclipse.jface.fieldassist.IContentProposal; +import org.eclipse.jface.fieldassist.IContentProposalProvider; + +/** + * @author Tuukka Lehtonen + * + * @param + */ +public class NamedObjectContentProposalProvider implements IContentProposalProvider { + + private final Collection content; + + public NamedObjectContentProposalProvider(T[] content) { + this(Arrays.asList(content)); + } + + public NamedObjectContentProposalProvider(Collection content) { + this.content = content; + } + + @Override + public IContentProposal[] getProposals(String contents, int position) { + String prefix = contents.substring(0, position).toLowerCase(); + + List result = new ArrayList(content.size()); + for (INamedObject obj : content) { + if (obj.getName().toLowerCase().startsWith(prefix)) + result.add(obj); + } + + IContentProposal[] proposals = new IContentProposal[result.size()]; + for (int i = 0; i < result.size(); ++i) + proposals[i] = createProposal(result.get(i), position); + + return proposals; + } + + public INamedObjectContentProposal createProposal(INamedObject object, int position) { + return new NamedObjectContentProposal((NamedObject) object, position); + } + +}