X-Git-Url: https://gerrit.simantics.org/r/gitweb?p=simantics%2Fplatform.git;a=blobdiff_plain;f=bundles%2Forg.simantics.g2d%2Fsrc%2Forg%2Fsimantics%2Fg2d%2Fdiagram%2FDiagramClass.java;h=437c592d94e564d3d2dfa5f8b358b9c38b06f487;hp=b842367114536e28b54be2ee5b2b7f25ad223c7a;hb=refs%2Fchanges%2F38%2F238%2F2;hpb=24e2b34260f219f0d1644ca7a138894980e25b14 diff --git a/bundles/org.simantics.g2d/src/org/simantics/g2d/diagram/DiagramClass.java b/bundles/org.simantics.g2d/src/org/simantics/g2d/diagram/DiagramClass.java index b84236711..437c592d9 100644 --- a/bundles/org.simantics.g2d/src/org/simantics/g2d/diagram/DiagramClass.java +++ b/bundles/org.simantics.g2d/src/org/simantics/g2d/diagram/DiagramClass.java @@ -1,83 +1,83 @@ -/******************************************************************************* - * 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.g2d.diagram; - -import java.util.ArrayList; -import java.util.Collection; - -import org.simantics.g2d.diagram.handler.DiagramHandler; -import org.simantics.g2d.diagram.handler.impl.DataElementMapImpl; -import org.simantics.g2d.diagram.handler.impl.LockingTransactionContext; -import org.simantics.g2d.diagram.handler.impl.PickContextImpl; -import org.simantics.g2d.diagram.handler.impl.TopologyImpl; -import org.simantics.g2d.diagram.impl.AbstractHandlerClass; - -/** - * DiagramClass is a compilation of DiagramHandlers - * - * @See {@link DiagramHandler} - * @author Toni Kalajainen - */ -public final class DiagramClass extends AbstractHandlerClass { - - private static final long serialVersionUID = 1541784948072436274L; - - /** - * Compile new Diagram class from a set of contributions - * @param contributions - * @return - */ - public static DiagramClass compile(Collection contributions) - { - return new DiagramClass(contributions); - } - - /** - * Compile new Diagram class from a set of contributions - * @param contributions - * @return - */ - public static DiagramClass compile(DiagramHandler... contributions) - { - ArrayList al = new ArrayList(contributions.length); - for (DiagramHandler eh : contributions) - al.add(eh); - return new DiagramClass(al); - } - - DiagramClass(Collection contributions) { - super(contributions); - } - - public static final DiagramClass DEFAULT = - DiagramClass.compile( - new PickContextImpl(), - new LockingTransactionContext(), - new TopologyImpl(), - //ConnectionValidator.INSTANCE, - new DataElementMapImpl() - ); - - public DiagramClass newClassWith(DiagramHandler... addedHandlers) { - Collection newHandlers = new ArrayList(getAll()); - for (DiagramHandler h : addedHandlers) - newHandlers.add(h); - return DiagramClass.compile(newHandlers); - } - - public DiagramClass newClassWith(Collection addedHandlers) { - Collection newHandlers = new ArrayList(getAll()); - newHandlers.addAll(addedHandlers); - return DiagramClass.compile(newHandlers); - } - -} +/******************************************************************************* + * 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.g2d.diagram; + +import java.util.ArrayList; +import java.util.Collection; + +import org.simantics.g2d.diagram.handler.DiagramHandler; +import org.simantics.g2d.diagram.handler.impl.DataElementMapImpl; +import org.simantics.g2d.diagram.handler.impl.LockingTransactionContext; +import org.simantics.g2d.diagram.handler.impl.PickContextImpl; +import org.simantics.g2d.diagram.handler.impl.TopologyImpl; +import org.simantics.g2d.diagram.impl.AbstractHandlerClass; + +/** + * DiagramClass is a compilation of DiagramHandlers + * + * @See {@link DiagramHandler} + * @author Toni Kalajainen + */ +public final class DiagramClass extends AbstractHandlerClass { + + private static final long serialVersionUID = 1541784948072436274L; + + /** + * Compile new Diagram class from a set of contributions + * @param contributions + * @return + */ + public static DiagramClass compile(Collection contributions) + { + return new DiagramClass(contributions); + } + + /** + * Compile new Diagram class from a set of contributions + * @param contributions + * @return + */ + public static DiagramClass compile(DiagramHandler... contributions) + { + ArrayList al = new ArrayList(contributions.length); + for (DiagramHandler eh : contributions) + al.add(eh); + return new DiagramClass(al); + } + + DiagramClass(Collection contributions) { + super(contributions); + } + + public static final DiagramClass DEFAULT = + DiagramClass.compile( + new PickContextImpl(), + new LockingTransactionContext(), + new TopologyImpl(), + //ConnectionValidator.INSTANCE, + new DataElementMapImpl() + ); + + public DiagramClass newClassWith(DiagramHandler... addedHandlers) { + Collection newHandlers = new ArrayList(getAll()); + for (DiagramHandler h : addedHandlers) + newHandlers.add(h); + return DiagramClass.compile(newHandlers); + } + + public DiagramClass newClassWith(Collection addedHandlers) { + Collection newHandlers = new ArrayList(getAll()); + newHandlers.addAll(addedHandlers); + return DiagramClass.compile(newHandlers); + } + +}