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.handler;
14 import org.simantics.Simantics;
15 import org.simantics.db.Session;
16 import org.simantics.db.exception.DatabaseException;
17 import org.simantics.db.layer0.util.SimanticsClipboardImpl;
18 import org.simantics.utils.ui.ErrorLogger;
21 * The default strategy for pasting diagram elements.
23 * @author Tuukka Lehtonen
25 public class DefaultCopyPasteStrategy implements CopyPasteStrategy {
28 public void paste(final PasteOperation op) {
30 if (op.sameDiagram() && op.cut) {
31 CopyPasteUtil.localCutPaste(op);
33 Session session = Simantics.getSession();
34 if (CopyPasteUtil.onlyFlagsWithoutCorrespondence(session, op.ea)
35 && CopyPasteUtil.checkFlagExternality(session, op.ea.flags, false)) {
36 CopyPasteUtil.continueFlags(op);
38 CopyPasteUtil.performDefaultPaste(op);
41 } catch (DatabaseException e) {
42 ErrorLogger.defaultLogError(e);
47 public void copyToClipboard(DiagramSelection selection) {
49 Simantics.setClipboard( new SimanticsClipboardImpl( new DiagramSelectionRepresentation(selection) ) );