From: jsimomaa Date: Tue, 15 May 2018 11:32:45 +0000 (+0300) Subject: Deprecate duplicate functionality in SimanticsUI X-Git-Tag: v1.43.0~136^2~480 X-Git-Url: https://gerrit.simantics.org/r/gitweb?a=commitdiff_plain;h=9ad477fff4177576f0cf43a4dda14783deabc9e3;p=simantics%2Fplatform.git Deprecate duplicate functionality in SimanticsUI gitlab #4 Change-Id: I0f4482a8c2d482e59d0e1641de65a3936a03f1eb --- diff --git a/bundles/org.simantics.ui/src/org/simantics/ui/SimanticsUI.java b/bundles/org.simantics.ui/src/org/simantics/ui/SimanticsUI.java index 4b1554c86..b90e48088 100644 --- a/bundles/org.simantics.ui/src/org/simantics/ui/SimanticsUI.java +++ b/bundles/org.simantics.ui/src/org/simantics/ui/SimanticsUI.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2010 Association for Decentralized Information Management + * Copyright (c) 2007, 2010, 2018 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 @@ -17,6 +17,7 @@ import org.eclipse.swt.widgets.Display; import org.eclipse.swt.widgets.Widget; import org.eclipse.ui.PlatformUI; import org.simantics.DatabaseJob; +import org.simantics.Simantics; import org.simantics.db.Resource; import org.simantics.db.Session; import org.simantics.db.common.primitiverequest.Adapter; @@ -232,8 +233,9 @@ public class SimanticsUI { * * @return a valid ISessionContextProvider */ + @Deprecated public static ISessionContextProvider getSessionContextProvider() { - return getProviderSource().getActive(); + return Simantics.getSessionContextProvider(); } /** @@ -265,9 +267,9 @@ public class SimanticsUI { * workbench window or null if the active window has no * session context */ + @Deprecated public static ISessionContext getSessionContext() { - ISessionContextProvider provider = getSessionContextProvider(); - return provider != null ? provider.getSessionContext() : null; + return Simantics.getSessionContext(); } /** @@ -360,11 +362,9 @@ public class SimanticsUI { * @return the Session bound to the currently active workbench window * @throws IllegalStateException if no Session was available */ + @Deprecated public static Session getSession() { - ISessionContext ctx = getSessionContext(); - if (ctx == null) - throw new IllegalStateException("Session unavailable, no database session open"); - return ctx.getSession(); + return Simantics.getSession(); } /** @@ -381,24 +381,25 @@ public class SimanticsUI { * @return the Session bound to the currently active workbench window or * null */ + @Deprecated public static Session peekSession() { - ISessionContext ctx = getSessionContext(); - return ctx == null ? null : ctx.peekSession(); + return Simantics.peekSession(); } /** * @return the currently open and active project as an IProject or * null if there is no active session or project */ + @Deprecated public static IProject peekProject() { - ISessionContext ctx = getSessionContext(); - return ctx == null ? null : (org.simantics.project.IProject) ctx.getHint(ProjectKeys.KEY_PROJECT); + return Simantics.peekProject(); } /** * @return the currently open and active project for the specified database * session or null if there is no current project */ + @Deprecated public static IProject peekProject(ISessionContext ctx) { if (ctx == null) return null; @@ -411,11 +412,9 @@ public class SimanticsUI { * session, which also means there is no active project at the * moment */ + @Deprecated public static IProject getProject() { - ISessionContext ctx = getSessionContext(); - if (ctx == null) - throw new IllegalStateException("No current database session"); - return ctx.getHint(ProjectKeys.KEY_PROJECT); + return Simantics.getProject(); } /**