diff --git a/apps/spreadsheeteditor/main/app/controller/DataTab.js b/apps/spreadsheeteditor/main/app/controller/DataTab.js index b407e8425c..6e1443d73f 100644 --- a/apps/spreadsheeteditor/main/app/controller/DataTab.js +++ b/apps/spreadsheeteditor/main/app/controller/DataTab.js @@ -565,7 +565,7 @@ define([ }], primary: 'ok', callback: function (btn) { - (btn === 'cancel') ? me.api.asc_StopSolver() : me.api.asc_StepSolver(); + (btn === 'cancel') ? me.api.asc_StopSolver() : me.api.asc_ContinueSolver(); } }); }, diff --git a/apps/spreadsheeteditor/main/app/controller/Main.js b/apps/spreadsheeteditor/main/app/controller/Main.js index f046a5259a..93808cf4cd 100644 --- a/apps/spreadsheeteditor/main/app/controller/Main.js +++ b/apps/spreadsheeteditor/main/app/controller/Main.js @@ -920,6 +920,11 @@ define([ text = this.loadingDocumentTitleText; break; + case Asc.c_oAscAsyncAction['SolverLookingSolution']: + title = this.txtSolverLookingSolution; + text = this.txtSolverLookingSolution; + break; + case Asc.c_oAscAsyncAction['Disconnect']: title = this.textDisconnect; text = this.textDisconnect; @@ -2276,6 +2281,10 @@ define([ config.msg = this.errorNotUniqueFieldWithCalculated; break; + case Asc.c_oAscError.ID.LockedCellSolver: + config.msg = this.errorLockedCellSolver; + break; + default: config.msg = (typeof id == 'string') ? id : this.errorDefaultMessage.replace('%1', id); break; diff --git a/apps/spreadsheeteditor/main/app/view/ConstraintDialog.js b/apps/spreadsheeteditor/main/app/view/ConstraintDialog.js index 7abf66254a..83604749e0 100644 --- a/apps/spreadsheeteditor/main/app/view/ConstraintDialog.js +++ b/apps/spreadsheeteditor/main/app/view/ConstraintDialog.js @@ -91,7 +91,7 @@ define([], function () { 'use strict'; allowBlank : true // validateOnChange: true }); - this.txtCellRef.on('button:click', _.bind(this.onSelectData, this)); + this.txtCellRef.on('button:click', _.bind(this.onSelectData, this, Asc.c_oAscSelectionDialogType.Chart)); this.txtConstraint = new Common.UI.InputFieldBtn({ el : this.$window.find('#id-dlg-constraint-constr'), @@ -101,7 +101,7 @@ define([], function () { 'use strict'; allowBlank : true // validateOnChange: true }); - this.txtConstraint.on('button:click', _.bind(this.onSelectData, this)); + this.txtConstraint.on('button:click', _.bind(this.onSelectData, this, Asc.c_oAscSelectionDialogType.Solver_Constraint)); this.cmbOperator = new Common.UI.ComboBox({ el: this.$window.find('#id-dlg-constraint-operator'), @@ -185,15 +185,10 @@ define([], function () { 'use strict'; var isvalid = true, txtError = '', value; - if (_.isEmpty(this.txtCellRef.getValue())) { + value = this.api.asc_checkDataRange(Asc.c_oAscSelectionDialogType.Chart, this.txtCellRef.getValue(), true); + if (value != Asc.c_oAscError.ID.No) { + txtError = this.txtNotValidRef; isvalid = false; - txtError = this.txtEmptyRef; - } else { - value = this.api.asc_checkDataRange(Asc.c_oAscSelectionDialogType.Chart, this.txtCellRef.getValue(), true); - if (value != Asc.c_oAscError.ID.No) { - txtError = ''; // TODO: check errors - isvalid = false; - } } if (!isvalid) { this.txtCellRef.showError([txtError]); @@ -201,16 +196,18 @@ define([], function () { 'use strict'; return isvalid; } - if (_.isEmpty(this.txtConstraint.getValue())) { - isvalid = false; - txtError = this.txtEmptyConstraint; - } else { - value = this.api.asc_checkDataRange(Asc.c_oAscSelectionDialogType.Chart, this.txtConstraint.getValue(), true); - if (value != Asc.c_oAscError.ID.No) { - txtError = ''; // // TODO: check errors + // if (_.isEmpty(this.txtConstraint.getValue())) { + // isvalid = false; + // txtError = this.textDataConstraint; + // } else { + value = this.api.asc_checkDataRange(Asc.c_oAscSelectionDialogType.Solver_Constraint, this.txtConstraint.getValue(), true); + if (value !== Asc.c_oAscError.ID.No) { + if (value === Asc.c_oAscError.ID.DataConstraintError) { + txtError = this.textDataConstraint; + } isvalid = false; } - } + // } if (!isvalid) { this.txtConstraint.showError([txtError]); this.txtConstraint.focus(); @@ -220,7 +217,7 @@ define([], function () { 'use strict'; return isvalid; }, - onSelectData: function(input) { + onSelectData: function(type, input) { var me = this; if (me.api) { var handlerDlg = function(dlg, result) { @@ -241,7 +238,7 @@ define([], function () { 'use strict'; win.setSettings({ api : me.api, range : input.getValue(), - type : Asc.c_oAscSelectionDialogType.Chart, + type : type, validation: function() {return true;} }); } diff --git a/apps/spreadsheeteditor/main/app/view/SolverDlg.js b/apps/spreadsheeteditor/main/app/view/SolverDlg.js index cbd40eedec..b6831d578e 100644 --- a/apps/spreadsheeteditor/main/app/view/SolverDlg.js +++ b/apps/spreadsheeteditor/main/app/view/SolverDlg.js @@ -456,7 +456,7 @@ define([ win.setSettings({ api : me.api, range : input.getValue(), - type : Asc.c_oAscSelectionDialogType.Chart, + type : Asc.c_oAscSelectionDialogType.Solver_VariableCell, validation: function() {return true;} }); } @@ -646,17 +646,16 @@ define([ txtError = '', value; - if (_.isEmpty(this.txtObjectiveRange.getValue())) { - isvalid = false; - txtError = this.txtEmpty; - } else { - value = this.api.asc_checkDataRange(Asc.c_oAscSelectionDialogType.Solver_ObjectiveCell, this.txtObjectiveRange.getValue(), true); - if (value != Asc.c_oAscError.ID.No) { - if (value == Asc.c_oAscError.ID.MustContainFormula) { - txtError = this.textMustContainFormula; - } - isvalid = false; + value = this.api.asc_checkDataRange(Asc.c_oAscSelectionDialogType.Solver_ObjectiveCell, this.txtObjectiveRange.getValue(), true); + if (value !== Asc.c_oAscError.ID.No) { + if (value === Asc.c_oAscError.ID.MustContainFormula) { + txtError = this.textMustContainFormula; + } else if (value === Asc.c_oAscError.ID.MustSingleCell) { + txtError = this.textMustSingleCell; + } else if (value === Asc.c_oAscError.ID.DataRangeError) { + txtError = this.textDataRange; } + isvalid = false; } if (!isvalid) { this.txtObjectiveRange.showError([txtError]); @@ -680,15 +679,14 @@ define([ } - if (_.isEmpty(this.txtVarsRange.getValue())) { - isvalid = false; - txtError = this.txtEmpty; - } else { - value = this.api.asc_checkDataRange(Asc.c_oAscSelectionDialogType.Chart, this.txtVarsRange.getValue(), true); - if (value != Asc.c_oAscError.ID.No) { - txtError = ''; // check errors - isvalid = false; + value = this.api.asc_checkDataRange(Asc.c_oAscSelectionDialogType.Solver_VariableCell, this.txtVarsRange.getValue(), true); + if (value != Asc.c_oAscError.ID.No) { + if (value === Asc.c_oAscError.ID.TooManyVarCellsSolver) { + txtError = this.textManyVarCells; + } else if (value === Asc.c_oAscError.ID.DataRangeError) { + txtError = this.textDataRange; } + isvalid = false; } if (!isvalid) { this.txtVarsRange.showError([txtError]); diff --git a/apps/spreadsheeteditor/main/locale/en.json b/apps/spreadsheeteditor/main/locale/en.json index f5f9dc5062..6e80a6e72c 100644 --- a/apps/spreadsheeteditor/main/locale/en.json +++ b/apps/spreadsheeteditor/main/locale/en.json @@ -1241,6 +1241,7 @@ "SSE.Controllers.Main.errorWrongOperator": "An error in the entered formula. Wrong operator is used.
Please correct the error.", "SSE.Controllers.Main.errorWrongPassword": "The password you supplied is not correct.", "SSE.Controllers.Main.errRemDuplicates": "Duplicate values found and deleted: {0}, unique values left: {1}.", + "SSE.Controllers.Main.errorLockedCellSolver": "One of the cells involved in the Solver process has been modified by another user.", "SSE.Controllers.Main.leavePageText": "You have unsaved changes in this spreadsheet. Click 'Stay on this Page' then 'Save' to save them. Click 'Leave this Page' to discard all the unsaved changes.", "SSE.Controllers.Main.leavePageTextOnClose": "All unsaved changes in this spreadsheet will be lost.
Click \"Cancel\" then \"Save\" to save them. Click \"OK\" to discard all the unsaved changes.", "SSE.Controllers.Main.loadFontsTextText": "Loading data...", @@ -1621,6 +1622,7 @@ "SSE.Controllers.Main.warnNoLicenseUsers": "You've reached the user limit for %1 editors. Contact %1 sales team for personal upgrade terms.", "SSE.Controllers.Main.warnProcessRightsChange": "You have been denied the right to edit the file.", "SSE.Controllers.Main.warnOpenCsv": "The CSV format does not support saving a multi-sheet file or any elements except text.
Only the active sheet will be saved.", + "SSE.Controllers.Main.txtSolverLookingSolution": "Solver are finding a solution.", "SSE.Controllers.PivotTable.strSheet": "Sheet", "SSE.Controllers.PivotTable.txtCalculatedItemInPageField": "The item cannot be added or modified. PivotTable report has this field in Filters.", "SSE.Controllers.PivotTable.txtCalculatedItemWarningDefault": "No actions with calculated items are allowed for this active cell.", @@ -2406,11 +2408,11 @@ "SSE.Views.ConstraintDialog.txtTitle": "Add constraint", "SSE.Views.ConstraintDialog.txtTitleChange": "Change constraint", "SSE.Views.ConstraintDialog.txtAdd": "Add", - "SSE.Views.ConstraintDialog.txtEmptyRef": "Cell reference is empty or contents are not valid.", - "SSE.Views.ConstraintDialog.txtEmptyConstraint": "Constraint must be a number, simple reference, or formula with a numeric value.", + "SSE.Views.ConstraintDialog.txtNotValidRef": "Cell reference is empty or contents are not valid.", "SSE.Views.ConstraintDialog.txtInt": "integer", "SSE.Views.ConstraintDialog.txtBin": "binary", "SSE.Views.ConstraintDialog.txtDiff": "AllDifferent", + "SSE.Views.ConstraintDialog.textDataConstraint": "Constraint must be a number, simple reference, or formula with a numeric value.", "SSE.Views.CreatePivotDialog.textDataRange": "Source data range", "SSE.Views.CreatePivotDialog.textDestination": "Choose where to place the table", "SSE.Views.CreatePivotDialog.textExist": "Existing sheet", @@ -4092,8 +4094,10 @@ "SSE.Views.SolverDlg.textInt": "int", "SSE.Views.SolverDlg.textBin": "bin", "SSE.Views.SolverDlg.textDif": "dif", - "SSE.Views.SolverDlg.textMustContainFormula": "The cell must contain a formula", - "SSE.Views.SolverDlg.textManyVarCells": "Too many Variable Cells", + "SSE.Views.SolverDlg.textMustContainFormula": "Objective cell contents must be a formula.", + "SSE.Views.SolverDlg.textMustSingleCell": "Objective cell must be a single cell on the active sheet.", + "SSE.Views.SolverDlg.textManyVarCells": "Too many Variable cells.", + "SSE.Views.SolverDlg.textDataRange": "Problem to solve not specified.", "SSE.Views.SolverMethodDialog.txtTitle": "Method options", "SSE.Views.SolverMethodDialog.txtPrecision": "Constraint precision", "SSE.Views.SolverMethodDialog.txtAutoScale": "Use automatic scaling", @@ -4117,20 +4121,20 @@ "SSE.Views.SolverResultsDlg.txtConvergedDesc": "Solver has performed 5 iterations for which the objective did not move significantly. Try a smaller convergence setting, or a different starting point.", "SSE.Views.SolverResultsDlg.txtCantImprove": "Solver cannot improve the current solution. All constraints are satisfied.", "SSE.Views.SolverResultsDlg.txtCantImproveDesc": "When the Evolutionary engine is used, this means Solver stopped because is can not find a better solution in the given time.", - "SSE.Views.SolverResultsDlg.txtNotConverge": "The Objective Cell values do not converge.", - "SSE.Views.SolverResultsDlg.txtNotConvergeDesc": "Solver can make the Objective Cell as large (or small when minimizing) as it wants.", + "SSE.Views.SolverResultsDlg.txtNotConverge": "The Objective cell values do not converge.", + "SSE.Views.SolverResultsDlg.txtNotConvergeDesc": "Solver can make the Objective cell as large (or small when minimizing) as it wants.", "SSE.Views.SolverResultsDlg.txtNoFeasible": "Solver could not find a feasible solution.", "SSE.Views.SolverResultsDlg.txtNoFeasibleDesc": "Solver can not find a point for which all Constraints are satisfied.", "SSE.Views.SolverResultsDlg.txtStopped": "Solver stopped at user’s request.", "SSE.Views.SolverResultsDlg.txtStoppedDesc": "Solver has stopped before finding a globally optimal solution. The best found solution, if any, will be given.", "SSE.Views.SolverResultsDlg.txtLineConditions": "The linearity conditions required by this LP Solver are not satisfied.", "SSE.Views.SolverResultsDlg.txtLineConditionsDesc": "Create a linearity report to see where the problem is, or switch to the GRG engine.", - "SSE.Views.SolverResultsDlg.txtErrorVal": "Solver encountered an error value in the Objective Cell or a Constraint cell.", + "SSE.Views.SolverResultsDlg.txtErrorVal": "Solver encountered an error value in the Objective cell or a Constraint cell.", "SSE.Views.SolverResultsDlg.txtErrorValDesc": "One of the cells in the worksheet became an error value when Solver tried certain values for the Variable Cells.", "SSE.Views.SolverResultsDlg.txtNotEnoughMemory": "There is not enough memory available to solve the problem.", "SSE.Views.SolverResultsDlg.txtNotEnoughMemoryDesc": "", "SSE.Views.SolverResultsDlg.txtErrorModel": "Error in model. Please verify that all cells and Constraints are valid.", - "SSE.Views.SolverResultsDlg.txtErrorModelDesc": "Perhaps some cells that are not Variable Cells are marked as Integer, Binary or AllDifferent.", + "SSE.Views.SolverResultsDlg.txtErrorModelDesc": "Perhaps some cells that are not Variable cells are marked as Integer, Binary or AllDifferent.", "SSE.Views.SolverResultsDlg.txtIntSolution": "Solver found an integer solution within tolerance. All constraints are satisfied.", "SSE.Views.SolverResultsDlg.txtIntSolutionDesc": "It is possible that better integer solutions exist. To make sure Solver finds the very best solution, set the integer tolerance in the options dialog to 0%.", "SSE.Views.SortDialog.errorEmpty": "All sort criteria must have a column or row specified.",