]> gerrit.simantics Code Review - simantics/platform.git/blob - bundles/org.simantics.modeling.ui/src/org/simantics/modeling/ui/symbolEditor/SymbolEditorCopyPasteStrategy.java
Improved usability of shared library export wizard
[simantics/platform.git] / bundles / org.simantics.modeling.ui / src / org / simantics / modeling / ui / symbolEditor / SymbolEditorCopyPasteStrategy.java
1 /*******************************************************************************
2  * Copyright (c) 2007, 2010 Association for Decentralized Information Management
3  * in Industry THTH ry.
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
8  *
9  * Contributors:
10  *     VTT Technical Research Centre of Finland - initial API and implementation
11  *******************************************************************************/
12 package org.simantics.modeling.ui.symbolEditor;
13
14 import org.eclipse.core.runtime.IStatus;
15 import org.eclipse.core.runtime.Status;
16 import org.simantics.Simantics;
17 import org.simantics.db.ReadGraph;
18 import org.simantics.db.common.request.ReadRequest;
19 import org.simantics.db.exception.DatabaseException;
20 import org.simantics.diagram.handler.CopyOperation;
21 import org.simantics.diagram.handler.CopyStrategy;
22 import org.simantics.diagram.handler.DefaultCopyPasteStrategy;
23 import org.simantics.modeling.ui.Activator;
24
25 /**
26  * The default strategy for pasting diagram elements.
27  * 
28  * @author Tuukka Lehtonen
29  * @since 1.23
30  */
31 public class SymbolEditorCopyPasteStrategy extends DefaultCopyPasteStrategy implements CopyStrategy {
32
33     @Override
34     public IStatus copy(CopyOperation operation) {
35         try {
36             Simantics.getSession().syncRequest(new ReadRequest() {
37                 @Override
38                 public void run(ReadGraph graph) throws DatabaseException {
39                     // TODO: implement the necessary checks to prevent copying symbol terminals
40                 }
41             });
42             return Status.OK_STATUS;
43         } catch (DatabaseException e) {
44             IStatus status = new Status(IStatus.ERROR, Activator.PLUGIN_ID,
45                     "Failed to filter copied material.", e);
46             Activator.getDefault().getLog().log(status);
47             return status;
48         }
49     }
50
51 }