123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377 |
- function CUndoManager()
- {
- this.init();
- var date = new Date();
- this.m_timeId = date.getTime();
- this.m_bReuseConversation = true;
- };
- CUndoManager.prototype.init = function()
- {
- this.m_undoStack = new Array();
- this.m_redoStack = new Array();
- this.m_promptValueUndoStack = new Array();
- this.m_promptValueRedoStack = new Array();
- this.m_status = null;
- this.m_sCurrentSpec = null;
- };
- CUndoManager.prototype.canUndo = function()
- {
- if (this.m_undoStack === null || this.getUndoStackSize() <= 0)
- {
- return false;
- }
- return true;
- };
- CUndoManager.prototype.canRedo = function()
- {
- var bCanRedo = true;
- if (this.m_redoStack === null || this.getRedoStackSize() <= 0)
- {
- return false;
- }
- return true;
- };
- CUndoManager.prototype.addToUndo = function(sSpecToAddToUndo, sCurrentSpec, aPromptValues)
- {
- if (sSpecToAddToUndo === null ||
- (typeof sSpecToAddToUndo !== "string" && !(sSpecToAddToUndo instanceof String)) ||
- this.m_undoStack === null)
- {
- this.updateStatus(1, "Unable to add a non-string to the undo stack");
- return false;
- }
- var iUndoLen = this.getUndoStackSize();
- this.m_undoStack.push(sSpecToAddToUndo);
-
-
- if (! aPromptValues)
- {
- aPromptValues = [];
- }
- this.m_promptValueUndoStack.push(aPromptValues);
-
- if (this.getRedoStackSize() > 0)
- {
- this.m_redoStack = new Array();
- }
- if (this.getUndoStackSize() > iUndoLen && this.getRedoStackSize() == 0)
- {
- this.m_sCurrentSpec = sCurrentSpec;
- this.updateStatus(0, "Successfully added to the undo stack");
- return true;
- }
- this.m_sCurrentSpec = sCurrentSpec;
- this.updateStatus(1, "Unable to add following value to undo stack: " + sSpecToAddToUndo);
- return false;
- };
- CUndoManager.prototype.undo = function(sCurrentSpec)
- {
- if (!this.canUndo())
- {
- return false;
- }
- var sSpec = this.m_undoStack.pop();
-
- var oReportManager = goApplicationManager.getReportManager();
-
-
- var aCurrentPromptValues = oReportManager.getParameterManager().getPromptPageParameters();
- this.m_promptValueRedoStack.push(aCurrentPromptValues);
-
-
- var aPromptValues = this.m_promptValueUndoStack.pop();
- oReportManager.getParameterManager().clearPromptPageParameters();
- oReportManager.getParameterManager().addPromptPageParameters(aPromptValues);
-
-
-
-
- var iMode = dlgGlobalGetParm("xxFilterComplexMode");
- if(null != iMode && iMode > 0)
- {
- dlgGlobalSetParm("xxFilterComplexMode", 0);
- }
- if (sCurrentSpec)
- {
- this.m_redoStack.push(sCurrentSpec);
- this.m_sCurrentSpec = sSpec;
- }
- else
- {
- this.updateStatus(1, "Invalid spec being added to stack: " + sCurrentSpec);
- }
- return this.executeSpec(sSpec);
- };
- CUndoManager.prototype.redo = function(sCurrentSpec)
- {
- if (!this.canRedo())
- {
- return false;
- }
- var sSpec = this.m_redoStack.pop();
-
-
- var oReportManager = goApplicationManager.getReportManager();
- var aCurrentPromptValues = oReportManager.getParameterManager().getPromptPageParameters();
- this.m_promptValueUndoStack.push(aCurrentPromptValues);
-
-
- var aPromptValues = this.m_promptValueRedoStack.pop();
- oReportManager.getParameterManager().clearPromptPageParameters();
- oReportManager.getParameterManager().addPromptPageParameters(aPromptValues);
-
- if (sCurrentSpec)
- {
- this.m_undoStack.push(sCurrentSpec);
- this.m_sCurrentSpec = sSpec;
- }
- else
- {
- this.updateStatus(1, "Invalid spec being added to stack: " + sCurrentSpec);
- }
- return this.executeSpec(sSpec);
- };
- CUndoManager.prototype.getUndoManagerStatus = function()
- {
- return this.m_status;
- };
- CUndoManager.prototype.updateStatus = function(statusValue, statusString)
- {
- if (this.m_status === null)
- {
- this.m_status = new CStatus(statusValue, statusString);
- }
- else
- {
- this.m_status.updateStatus(statusValue, statusString);
- }
- };
- CUndoManager.prototype.executeSpec = function(sSpec)
- {
- var oReportManager = goApplicationManager.getReportManager();
- var oQSRequest = oReportManager.createRequest("runSpecification");
- oReportManager.setRequestDefaultOptions(oQSRequest);
-
- oQSRequest.addOption("ui.spec", sSpec);
- var oCRQReport = XMLBuilderLoadXMLFromString(stripSignature(sSpec)).documentElement;
- var limitData = oCRQReport.getAttribute("limitData") ? oCRQReport.getAttribute("limitData") : "full";
- oQSRequest.addOption("ui.action", "edit");
- oQSRequest.addOption("ui.command", createCommand("P", "F") + ";" + createCommand("O", "N", new Array(limitData)));
-
-
-
-
- oQSRequest.addOption("rerun", "true");
- oQSRequest.addOption("run.xslURL", "qs.xsl");
- oQSRequest.addOption("run.prompt", "false");
- var objid = cfgGet("SearchPath");
- if (objid != null && objid != "")
- {
- oQSRequest.addOption("ui.object", objid);
- }
-
-
-
- var bSendConversation = this.getReuseConversation();
- if (! bSendConversation)
- {
- cfgRemove("m_tracking");
- }
- oReportManager.setRequestDefaultOptionsForCV(bSendConversation, true, "any", oQSRequest);
- oReportManager.getParameterManager().clearExecutionParameters();
- oReportManager.asyncSubmit(false, oQSRequest);
-
-
- this.setReuseConversation(true);
-
- return oQSRequest;
- };
- CUndoManager.prototype.getUndoStackSize = function()
- {
- if (this.m_undoStack != null)
- {
- return this.m_undoStack.length;
- }
- return 0;
- };
- CUndoManager.prototype.getRedoStackSize = function()
- {
- if (this.m_redoStack != null)
- {
- return this.m_redoStack.length;
- }
- return 0;
- };
- CUndoManager.prototype.getId = function()
- {
- return this.m_timeId;
- };
- CUndoManager.prototype.updateUndoManagerState = function(iUndoLen, iRedoLen, sCurrentSpec, aPromptParameters)
- {
- var bAddCurrentSpecToTopOfStack = false;
- var sPoppedSpec = null;
- var oStackToPop = null;
- var oStackToPush = null;
- var oPromptStackToPop = null;
- var oPromptStackToPush = null;
-
- var iIterator = 0;
- if (iUndoLen < this.getUndoStackSize())
- {
- oStackToPop = this.m_undoStack;
- oStackToPush = this.m_redoStack;
-
-
- oPromptStackToPop = this.m_promptValueUndoStack;
- oPromptStackToPush = this.m_promptValueRedoStack;
-
- iIterator = this.getUndoStackSize() - iUndoLen;
- }
- else if (iUndoLen > this.getUndoStackSize())
- {
- oStackToPop = this.m_redoStack;
- oStackToPush = this.m_undoStack;
-
-
- oPromptStackToPop = this.m_promptValueRedoStack;
- oPromptStackToPush = this.m_promptValueUndoStack;
-
- iIterator = iUndoLen - this.getUndoStackSize();
- }
- else
- {
- return;
- }
- for (var i = 0; i < iIterator; i++)
- {
- sPoppedSpec = oStackToPop.pop();
- var aPoppedPromptParams = oPromptStackToPop.pop();
-
- if (i == 0 && i == iIterator - 1)
- {
- bAddCurrentSpecToTopOfStack = true;
- }
- else if (i == 0)
- {
- oStackToPush.push(this.m_sCurrentSpec);
- oPromptStackToPush.push(aPromptParameters);
- }
- if (!bAddCurrentSpecToTopOfStack &&
- sPoppedSpec !== null &&
- typeof sPoppedSpec != "undefined" &&
- sPoppedSpec != sCurrentSpec)
- {
- oStackToPush.push(sPoppedSpec);
- oPromptStackToPush.push(aPoppedPromptParams);
- }
- }
- if (bAddCurrentSpecToTopOfStack)
- {
- oStackToPush.push(this.m_sCurrentSpec);
- oPromptStackToPush.push(aPromptParameters);
- }
- if (this.getUndoStackSize() != iUndoLen || this.getRedoStackSize() != iRedoLen)
- {
- this.updateStatus(1, "stacks are out of sync with backJax form");
- }
- this.m_sCurrentSpec = sCurrentSpec;
- };
- CUndoManager.prototype.getReuseConversation = function()
- {
- return this.m_bReuseConversation;
- };
- CUndoManager.prototype.setReuseConversation = function(bReuseConversation)
- {
- this.m_bReuseConversation = true;
- if (!bReuseConversation)
- {
- this.m_bReuseConversation = false;
- }
- };
- function CStatus(iStatusValue, sStatusString)
- {
- this.updateStatus(iStatusValue, sStatusString);
- };
- CStatus.prototype.getStatusString = function()
- {
- return this.m_sStatusString;
- };
- CStatus.prototype.getStatusValue = function()
- {
- return this.m_iStatusValue;
- };
- CStatus.prototype.updateStatus = function(iStatusValue, sStatusString)
- {
- this.m_iStatusValue = iStatusValue;
- this.m_sStatusString = sStatusString;
- };
|