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.db.layer0.internal;
16 import org.eclipse.core.runtime.Platform;
17 import org.simantics.db.Resource;
18 import org.simantics.db.layer0.util.SimanticsClipboard;
19 import org.simantics.db.layer0.util.SimanticsKeys;
20 import org.simantics.db.management.ISessionContext;
23 * An internal facade for accessing basic Simantics platform services.
24 * Usable without a graphical UI, i.e. in headless contexts.
26 * Use org.simantics.Simantics instead where ever possible.
28 public class SimanticsInternal extends org.simantics.db.common.SimanticsInternal {
31 * @return the currently open and active project as an IProject
32 * @throws IllegalStateException if there is no currently active database
33 * session, which also means there is no active project at the
36 public static Resource getProject() {
37 ISessionContext ctx = getSessionContext();
39 throw new IllegalStateException("No current database session");
40 return ctx.getHint(SimanticsKeys.KEY_PROJECT);
44 * @return the currently open and active project as an IProject or null if
45 * there is either no project or no active database session
47 public static Resource peekProject() {
48 ISessionContext ctx = getSessionContext();
49 return ctx != null ? (Resource) ctx.getHint(SimanticsKeys.KEY_PROJECT) : null;
52 private static SimanticsClipboard clipboard = SimanticsClipboard.EMPTY;
57 public static void setClipboard(SimanticsClipboard content) {
59 throw new NullPointerException("null clipboard content");
63 public static SimanticsClipboard getClipboard() {
67 public static File getTemporaryDirectory() {
68 File workspace = Platform.getLocation().toFile();
69 File temp = new File(workspace, "tempFiles");