|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjavax.servlet.GenericServlet
javax.servlet.http.HttpServlet
com.yworks.yfiles.server.tiles.servlet.BaseServlet
com.yworks.yfiles.server.tiles.servlet.UndoServlet
This servlet handles requests related to undo/redo.
Since undo/redo requires extra resources it is not enabled by default. This servlet handles requests for enabling and disabling undo/redo for a graph cached at the current session. ("setUndoRedoEnabled" and "isUndoRedoEnabled").
Even if undo/redo is enabled undo can only be performed, if there was at least one update to a graph after undo/redo was enabled for the graph. So there is a request for checking whether undo or redo is possible ("canUndoRedo").
Finally, this servlet handles the requests for performing an undo or redo operation ("undo", "redo").
The requests for performing the operations which actually change the state ("setUndoRedoEnabled", "undo" and "redo") have to be POST requests. The requests for performing a query operation ("isUndoRedoEnabled", "canUndoRedo") may be GET or POST requests.
If undo/redo is enabled for a graph then a standard Graph2DUndoManager
is created and
registered as the backup realizers handler at the graph. This manager is then used by all other operations.
Subclasses may implement their undo management differently by redefining createUndoManager(y.view.Graph2D)
and getUndoManager(y.view.Graph2D)
.
Field Summary |
Fields inherited from class com.yworks.yfiles.server.tiles.servlet.BaseServlet |
EDGE_DESCRIPTION_KEY, EDGE_URL_KEY, NODE_DESCRIPTION_KEY, NODE_URL_KEY |
Constructor Summary | |
UndoServlet()
|
Method Summary | |
protected boolean |
canRedo(Graph2D graph)
Returns whether a redo can be performed for the given graph. |
protected boolean |
canUndo(Graph2D graph)
Returns whether an undo can be performed for the given graph. |
protected Graph2DUndoManager |
createUndoManager(Graph2D graph)
Creates and returns a new undo manager for the given graph. |
protected Graph2DUndoManager |
getUndoManager(Graph2D graph)
Returns the undo manager for the given graph. |
protected void |
handleGetRequest(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
handles "isUndoRedoEnabled" and "canUndoRedo" requests. |
protected void |
handlePostRequest(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
handles "setUndoRedoEnabled", "undo" and "redo" requests. |
protected boolean |
isUndoRedoEnabled(Graph2D graph)
Returns whether undo/redo is enabled for the given graph. |
protected void |
redo(Graph2D graph)
reverts the last undo for the given graph. |
protected void |
setUndoRedoEnabled(Graph2D graph,
boolean enabled)
Sets whether undo/redo is enabled for the given graph. |
protected void |
undo(Graph2D graph)
reverts the last change for the given graph. |
Methods inherited from class com.yworks.yfiles.server.tiles.servlet.BaseServlet |
addViewConfigurator, cachedGraphs, cacheGraph, doGet, doPost, getEdgeDescription, getEdgeURL, getForId, getGraph, getGraphBounds, getGraphContentBounds, getId, getId, getId, getId, getNodeDescription, getNodeURL, getReadWriteLock, getSessionMonitor, getViewConfigurators, getWriter, hasDescriptions, hasURLs, init, initialize, isUseJSONPrefixing, lookupId, lookupId, lookupId, lookupId, newGraph, readLock, registerLicense, removeViewConfigurator, setEdgeDescription, setEdgeURL, setNodeDescription, setNodeURL, uncacheGraph, unlockRead, unlockWrite, updateEdgePaths, validateIds, writeContentBounds, writeLock, writeWorldBounds |
Methods inherited from class javax.servlet.http.HttpServlet |
doDelete, doHead, doOptions, doPut, doTrace, getLastModified, service, service |
Methods inherited from class javax.servlet.GenericServlet |
destroy, getInitParameter, getInitParameterNames, getServletConfig, getServletContext, getServletInfo, getServletName, init, log, log |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public UndoServlet()
Method Detail |
protected void handlePostRequest(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws javax.servlet.ServletException, IOException
handles "setUndoRedoEnabled", "undo" and "redo" requests. The parameter "name" is mandatory for all requests. It is the symbolic name of the graph to be used.
This method detects the operation to perform, fetches the necessary parameters from the requests and
the graph from the session and then calls one of the protected methods in this class which act on the
graph like undo(y.view.Graph2D)
.
If the requests is neither "setUndoRedoEnabled", "undo" or "redo" then the method for handling GET requests is called. Thus a query operation ("isUndoRedoEnabled", "canUndoRedo") can also be initiated by a POST request.
handlePostRequest
in class BaseServlet
request
- the requestresponse
- the response to write to
javax.servlet.ServletException
IOException
protected void handleGetRequest(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws javax.servlet.ServletException, IOException
handles "isUndoRedoEnabled" and "canUndoRedo" requests. The parameter "name" is mandatory for all requests. It is the symbolic name of the graph to be used. "canUndoRedo" returns an object in JSON format like the following.
{ "canUndo" : true, "canRedo" : false }
This method detects the operation to perform, fetches the necessary parameters from the requests and
the graph from the session and then calls one of the protected methods in this class which act on the
graph like canUndo(y.view.Graph2D)
.
handleGetRequest
in class BaseServlet
request
- the requestresponse
- the response to write to
javax.servlet.ServletException
IOException
protected boolean isUndoRedoEnabled(Graph2D graph)
getUndoManager(y.view.Graph2D)
.
graph
- a graph
protected void setUndoRedoEnabled(Graph2D graph, boolean enabled)
getUndoManager(y.view.Graph2D)
. This method creates an
undo manager if necessary using createUndoManager(y.view.Graph2D)
.
graph
- a graphenabled
- if true
enable undo/redo, disable it otherwiseprotected void undo(Graph2D graph)
getUndoManager(y.view.Graph2D)
.
graph
- a graphprotected void redo(Graph2D graph)
getUndoManager(y.view.Graph2D)
.
graph
- a graphprotected boolean canUndo(Graph2D graph)
getUndoManager(y.view.Graph2D)
.
graph
- a graph
protected boolean canRedo(Graph2D graph)
getUndoManager(y.view.Graph2D)
.
graph
- a graph
protected Graph2DUndoManager createUndoManager(Graph2D graph)
graph
- the graph
getUndoManager(y.view.Graph2D)
protected Graph2DUndoManager getUndoManager(Graph2D graph)
graph
- a graph
null
createUndoManager(y.view.Graph2D)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |