@OpenApiAll
public class SessionManager
extends java.lang.Object
Class classA = ...;
SessionManager.getInstance().createSession("Edit class A");
classA.setName("nameB");
Operation operation = Project.getProject(classA).getElementsFactory().createOperationInstance();
ModelElementsManager.getInstance().addElement(operation, classA);
SessionManager.getInstance().closeSession();
Not editable(read only) Elements cannot be edited.Modifier and Type | Method and Description |
---|---|
<V> V |
callInsideSession(java.lang.String sessionName,
java.util.concurrent.Callable<V> callable)
Calls given callable inside session.
|
void |
cancelSession()
Closes active session.
|
void |
cancelSession(Project project)
Closes active session in a given project.
|
void |
checkReadOnly(Element target)
Tests if the given element is read only.
|
void |
checkSessionExistance()
Checks if the session is created.
|
void |
checkSessionExistance(Project project)
Checks if the session is created in a given project.
|
void |
closeSession()
Closes active session in an active project.
|
void |
closeSession(Project project)
Closes active session in a given project.
|
void |
createSession(Project project,
java.lang.String sessionName)
Creates new session in a given project.
|
void |
createSession(java.lang.String sessionName)
Creates new session in an active project.
|
void |
executeInsideSession(java.lang.String sessionName,
java.lang.Runnable runnable)
Executes given runnable inside session.
|
static SessionManager |
getInstance()
Returns an instance of this manager.
|
boolean |
isSessionCreated()
Returns true if some session is created in an active project.
|
boolean |
isSessionCreated(Project project)
Returns true if some session is created in a given project.
|
<V> V |
runInSession(java.lang.String sessionName,
java.util.concurrent.Callable<V> callable)
Deprecated.
|
void |
runInSession(java.lang.String sessionName,
java.lang.Runnable runnable)
Deprecated.
|
public static SessionManager getInstance()
public void closeSession()
createSession
before that.java.lang.IllegalStateException
- if session was not created.createSession(java.lang.String)
public void closeSession(Project project)
createSession
before that.project
- projectjava.lang.IllegalStateException
- if session was not created.createSession(java.lang.String)
public void cancelSession()
createSession
before that.java.lang.IllegalStateException
- if session was not created.createSession(java.lang.String)
public void cancelSession(Project project)
createSession
before that.project
- projectjava.lang.IllegalStateException
- if session was not created.createSession(java.lang.String)
public void checkSessionExistance()
java.lang.IllegalStateException
- if session is not created at the current moment.isSessionCreated()
public void checkSessionExistance(Project project)
project
- projectjava.lang.IllegalStateException
- if session is not created at the current moment.isSessionCreated()
public void createSession(java.lang.String sessionName)
closeSession
method.sessionName
- name of session which will be the name of command the command history(undo/redo).java.lang.IllegalStateException
- if other session is already created and not closed.closeSession()
public void createSession(Project project, java.lang.String sessionName)
closeSession
method.project
- projectsessionName
- name of session which will be the name of command the command history(undo/redo).java.lang.IllegalStateException
- if other session is already created and not closed.closeSession()
public boolean isSessionCreated()
createSession(java.lang.String)
public boolean isSessionCreated(Project project)
project
- projectcreateSession(java.lang.String)
public void checkReadOnly(Element target) throws ReadOnlyElementException
target
- element to checkReadOnlyElementException
- exception if given element is read only.@Deprecated public void runInSession(java.lang.String sessionName, java.lang.Runnable runnable)
executeInsideSession(String, Runnable)
sessionName
- session name if needs to be createdrunnable
- runnable to runpublic void executeInsideSession(java.lang.String sessionName, java.lang.Runnable runnable)
sessionName
- new session name.runnable
- runnable to execute.@Deprecated public <V> V runInSession(java.lang.String sessionName, java.util.concurrent.Callable<V> callable)
callInsideSession(String, Callable)
V
- the return typesessionName
- the session namecallable
- the callable objectpublic <V> V callInsideSession(java.lang.String sessionName, java.util.concurrent.Callable<V> callable) throws java.lang.Exception
V
- return type.sessionName
- new session name.callable
- callable to call.java.lang.Exception