1 /*******************************************************************************
2 * Copyright (c) 2007, 2010 Association for Decentralized Information Management
4 * All rights reserved. This program and the accompanying materials
5 * are made available under the terms of the Eclipse Public License v1.0
6 * which accompanies this distribution, and is available at
7 * http://www.eclipse.org/legal/epl-v10.html
10 * VTT Technical Research Centre of Finland - initial API and implementation
11 *******************************************************************************/
12 package org.simantics.diagram.symbolcontribution;
14 import java.util.ArrayList;
15 import java.util.Collection;
16 import java.util.Collections;
17 import java.util.Comparator;
19 import org.simantics.diagram.symbollibrary.ISymbolGroup;
20 import org.simantics.diagram.symbollibrary.ISymbolItem;
23 * @author Hannu Niemistö
25 public class CompositeSymbolGroup extends ModifiableSymbolGroup {
27 Collection<ISymbolGroup> groups = new ArrayList<ISymbolGroup>(4);
29 public CompositeSymbolGroup(Object identification, String name, String description) {
30 super(identification, name, description);
33 public void add(ISymbolGroup group) {
37 public Collection<ISymbolGroup> getGroups() {
42 public ISymbolItem[] getItems() {
43 ArrayList<ISymbolItem> items = new ArrayList<ISymbolItem>();
44 for(ISymbolGroup group : groups)
45 for(ISymbolItem item : group.getItems())
46 items.add(new GroupProxySymbolItem(item, this));
47 Collections.sort(items, new Comparator<ISymbolItem>() {
49 public int compare(ISymbolItem o1, ISymbolItem o2) {
50 return o1.getName().compareTo(o2.getName());
53 return items.toArray(new ISymbolItem[items.size()]);
57 public String toString() {
58 return super.toString() + "[composed group count=" + groups.size() + "]";