X-Git-Url: https://gerrit.simantics.org/r/gitweb?p=simantics%2Fplatform.git;a=blobdiff_plain;f=bundles%2Forg.simantics.diagram%2Fsrc%2Forg%2Fsimantics%2Fdiagram%2Fsymbolcontribution%2FCompositeSymbolGroup.java;h=c217de2f9591de468a42244fe5dc1f17d42fc761;hp=27d286f8779ec10c2f9086dfc20ed5c1e591adb0;hb=a090a5d168c397d90ce129e851cc80a158b89d0b;hpb=969bd23cab98a79ca9101af33334000879fb60c5 diff --git a/bundles/org.simantics.diagram/src/org/simantics/diagram/symbolcontribution/CompositeSymbolGroup.java b/bundles/org.simantics.diagram/src/org/simantics/diagram/symbolcontribution/CompositeSymbolGroup.java index 27d286f87..c217de2f9 100644 --- a/bundles/org.simantics.diagram/src/org/simantics/diagram/symbolcontribution/CompositeSymbolGroup.java +++ b/bundles/org.simantics.diagram/src/org/simantics/diagram/symbolcontribution/CompositeSymbolGroup.java @@ -1,61 +1,62 @@ -/******************************************************************************* - * 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.diagram.symbolcontribution; - -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.Comparator; - -import org.simantics.diagram.symbollibrary.ISymbolGroup; -import org.simantics.diagram.symbollibrary.ISymbolItem; - -/** - * @author Hannu Niemistö - */ -public class CompositeSymbolGroup extends ModifiableSymbolGroup { - - Collection groups = new ArrayList(4); - - public CompositeSymbolGroup(Object identification, String name, String description) { - super(identification, name, description); - } - - public void add(ISymbolGroup group) { - groups.add(group); - } - - public Collection getGroups() { - return groups; - } - - @Override - public ISymbolItem[] getItems() { - ArrayList items = new ArrayList(); - for(ISymbolGroup group : groups) - for(ISymbolItem item : group.getItems()) - items.add(new GroupProxySymbolItem(item, this)); - Collections.sort(items, new Comparator() { - @Override - public int compare(ISymbolItem o1, ISymbolItem o2) { - return o1.getName().compareTo(o2.getName()); - } - }); - return items.toArray(new ISymbolItem[items.size()]); - } - - @Override - public String toString() { - return super.toString() + "[composed group count=" + groups.size() + "]"; - } - -} +/******************************************************************************* + * 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.diagram.symbolcontribution; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.Comparator; + +import org.simantics.diagram.symbollibrary.ISymbolGroup; +import org.simantics.diagram.symbollibrary.ISymbolItem; +import org.simantics.utils.strings.AlphanumComparator; + +/** + * @author Hannu Niemistö + */ +public class CompositeSymbolGroup extends ModifiableSymbolGroup { + + Collection groups = new ArrayList(4); + + public CompositeSymbolGroup(Object identification, String name, String description) { + super(identification, name, description); + } + + public void add(ISymbolGroup group) { + groups.add(group); + } + + public Collection getGroups() { + return groups; + } + + @Override + public ISymbolItem[] getItems() { + ArrayList items = new ArrayList(); + for(ISymbolGroup group : groups) + for(ISymbolItem item : group.getItems()) + items.add(new GroupProxySymbolItem(item, this)); + Collections.sort(items, new Comparator() { + @Override + public int compare(ISymbolItem o1, ISymbolItem o2) { + return AlphanumComparator.COMPARATOR.compare(o1.getName(),o2.getName()); + } + }); + return items.toArray(new ISymbolItem[items.size()]); + } + + @Override + public String toString() { + return super.toString() + "[composed group count=" + groups.size() + "]"; + } + +}