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.g2d.diagram;
14 import java.util.ArrayList;
15 import java.util.Collection;
17 import org.simantics.g2d.diagram.handler.DiagramHandler;
18 import org.simantics.g2d.diagram.handler.impl.DataElementMapImpl;
19 import org.simantics.g2d.diagram.handler.impl.LockingTransactionContext;
20 import org.simantics.g2d.diagram.handler.impl.PickContextImpl;
21 import org.simantics.g2d.diagram.handler.impl.TopologyImpl;
22 import org.simantics.g2d.diagram.impl.AbstractHandlerClass;
25 * DiagramClass is a compilation of DiagramHandlers
27 * @See {@link DiagramHandler}
28 * @author Toni Kalajainen
30 public final class DiagramClass extends AbstractHandlerClass<DiagramHandler> {
32 private static final long serialVersionUID = 1541784948072436274L;
35 * Compile new Diagram class from a set of contributions
36 * @param contributions
39 public static DiagramClass compile(Collection<DiagramHandler> contributions)
41 return new DiagramClass(contributions);
45 * Compile new Diagram class from a set of contributions
46 * @param contributions
49 public static DiagramClass compile(DiagramHandler... contributions)
51 ArrayList<DiagramHandler> al = new ArrayList<DiagramHandler>(contributions.length);
52 for (DiagramHandler eh : contributions)
54 return new DiagramClass(al);
57 DiagramClass(Collection<DiagramHandler> contributions) {
61 public static final DiagramClass DEFAULT =
63 new PickContextImpl(),
64 new LockingTransactionContext(),
66 //ConnectionValidator.INSTANCE,
67 new DataElementMapImpl()
70 public DiagramClass newClassWith(DiagramHandler... addedHandlers) {
71 Collection<DiagramHandler> newHandlers = new ArrayList<DiagramHandler>(getAll());
72 for (DiagramHandler h : addedHandlers)
74 return DiagramClass.compile(newHandlers);
77 public DiagramClass newClassWith(Collection<DiagramHandler> addedHandlers) {
78 Collection<DiagramHandler> newHandlers = new ArrayList<DiagramHandler>(getAll());
79 newHandlers.addAll(addedHandlers);
80 return DiagramClass.compile(newHandlers);