@OpenApiAll
public class SessionManager
extends java.lang.Object
In order to edit some Element session with this manager must be created. After Element editing session must be closed. After that all changes will be applied to model and registered in command history(for undo/redo).
Only one session can be active.
The sample of code is :
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(Project project,
java.lang.String sessionName,
java.util.concurrent.Callable<V> callable)
Calls given callable inside session.
|
<V> V |
callInsideSession(java.lang.String sessionName,
java.util.concurrent.Callable<V> callable)
Deprecated.
|
void |
cancelSession()
Deprecated.
|
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()
Deprecated.
|
void |
checkSessionExistance(Project project)
Deprecated.
typo. Use
checkSessionExistence(Project) |
void |
checkSessionExistence()
Deprecated.
type. Use
checkSessionExistence(Project) |
void |
checkSessionExistence(Project project)
Checks if the session is created in a given project.
|
void |
closeSession()
Deprecated.
|
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)
Deprecated.
|
void |
executeInsideSession(Project project,
java.lang.String sessionName,
java.lang.Runnable runnable)
Executes given runnable inside session.
|
void |
executeInsideSession(java.lang.String sessionName,
java.lang.Runnable runnable)
Deprecated.
|
static SessionManager |
getInstance()
Returns an instance of this manager.
|
boolean |
isSessionCreated()
Deprecated.
|
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()
@Deprecated public void closeSession()
closeSession(Project)
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)
@Deprecated public void cancelSession()
cancelSession(Project)
createSession
before that.java.lang.IllegalStateException
- if session was not created.createSession(java.lang.String)
public void cancelSession(@CheckForNull Project project)
createSession
before that.project
- projectjava.lang.IllegalStateException
- if session was not created.createSession(java.lang.String)
@Deprecated public void checkSessionExistance()
checkSessionExistence(Project)
java.lang.IllegalStateException
- if session is not created at the current moment.isSessionCreated()
@Deprecated public void checkSessionExistence()
checkSessionExistence(Project)
java.lang.IllegalStateException
- if session is not created at the current moment.isSessionCreated()
@Deprecated public void checkSessionExistance(@CheckForNull Project project)
checkSessionExistence(Project)
project
- projectjava.lang.IllegalStateException
- if session is not created at the current moment.isSessionCreated()
public void checkSessionExistence(@CheckForNull Project project)
project
- projectjava.lang.IllegalStateException
- if session is not created at the current moment.isSessionCreated()
@Deprecated public void createSession(java.lang.String sessionName)
createSession(Project, String)
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()
@Deprecated public boolean isSessionCreated()
isSessionCreated(Project)
createSession(java.lang.String)
public boolean isSessionCreated(@CheckForNull 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 run@Deprecated public void executeInsideSession(java.lang.String sessionName, java.lang.Runnable runnable)
executeInsideSession(Project, String, 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(Project, String, Callable)
V
- the return typesessionName
- the session namecallable
- the callable object@Deprecated public <V> V callInsideSession(java.lang.String sessionName, java.util.concurrent.Callable<V> callable) throws java.lang.Exception
callInsideSession(Project, String, Callable)
V
- return type.sessionName
- new session name.callable
- callable to call.java.lang.Exception
public <V> V callInsideSession(Project project, java.lang.String sessionName, java.util.concurrent.Callable<V> callable) throws java.lang.Exception
V
- return type.project
- projectsessionName
- new session name.callable
- callable to call.java.lang.Exception
public void executeInsideSession(Project project, java.lang.String sessionName, java.lang.Runnable runnable)
project
- projectsessionName
- new session name.runnable
- runnable to execute.