/// <summary> /// Open message box with title id and message id that will take from MGBCL*ENG.xml (created by mgconst) /// </summary> /// <param name = "form"></param> /// <param name = "titleId">message from from MGBCL*ENG.xml</param> /// <param name = "msgId">message from from MGBCL*ENG.xml</param> /// <param name = "style">the style of the message box can be flags of Styles.MSGBOX_xxx </param> /// <returns> message box style from Styles.MSGBOX_XXX</returns> internal int writeToMessageBox(MgForm form, string titleId, string msgId, int style) { String title = ClientManager.Instance.getMessageString(titleId); String msg = ClientManager.Instance.getMessageString(msgId); return(Commands.messageBox(form.getTopMostForm(), title, msg, style)); }
/// <summary> /// sets action enabled or disabled /// </summary> /// <param name = "act"></param> /// <param name = "enable"></param> public void enable(int act, bool enable) { //If Zoom/Wide is enabled/disabled, update it's status on status bar. if (act == InternalInterface.MG_ACT_ZOOM || act == InternalInterface.MG_ACT_WIDE) { MgForm form = (MgForm)_parentTask.getForm(); if (form != null) { if (act == InternalInterface.MG_ACT_ZOOM) { form.UpdateStatusBar(GuiConstants.SB_ZOOMOPTION_PANE_LAYER, form.GetMessgaeForStatusBar(GuiConstants.SB_ZOOMOPTION_PANE_LAYER, enable), false); } else { form.UpdateStatusBar(GuiConstants.SB_WIDEMODE_PANE_LAYER, form.GetMessgaeForStatusBar(GuiConstants.SB_WIDEMODE_PANE_LAYER, enable), false); } } } bool valueChanged = (_actState[act] != enable); _actState[act] = enable; if (enable) { _numerator++; _actCount[act] = _numerator; } if (valueChanged) { _parentTask.enableActionMenu(act, enable); } }
/// <summary> /// /// </summary> internal override void Execute() { Task parentTask = Manager.MGDataTable.GetTaskByID(CallingTaskTag) as Task; MgForm parentForm = parentTask.getForm() as MgForm; MgControl destSubformCtrl = parentForm.getSubFormCtrlByName(SubformCtrlName); // Subform task is not allowed to be opened before the first record prefix of the parent. // In Task Prefix or in the first Record Prefix do not execute call but put the task from the call on the subform control property. // So after the first record prefix the task from the call operation will be loaded into the subform control. if (destSubformCtrl != null && !((Task)destSubformCtrl.getForm().getTask()).AfterFirstRecordPrefix) { // QCR #310113. If the subform was loaded, now it must be closed. Task subformTaskToRemove = destSubformCtrl.getSubformTask(); if (subformTaskToRemove != null) { subformTaskToRemove.stop(); } SetCalledTaskDefinitionId(destSubformCtrl); SetCalledSubformType(destSubformCtrl); destSubformCtrl.ArgList = ArgList; // TODO: Task Suffix } else { base.Execute(); } }
/// <summary> /// close the task, if the wide is open, then close is before close the task /// </summary> /// <param name = "form"> </param> internal void abort(MgForm form) { if (form != null) { Task mainProg = MGDataCollection.Instance.GetMainProgByCtlIdx(form.getTask().getCtlIdx()); Manager.Abort(form, mainProg); } }
/// <summary> /// display a Message Box (confirm) with 2 buttons : yes & no and icon question. /// </summary> /// <param name = "form">the parent form </param> /// <param name = "msgId">message number (from MsgInterface.java) that will be display on the content of the Message Box /// return true if the button YES was pressed /// </param> internal bool confirm(MgForm form, string msgId) { int retResult = confirm(form, msgId, Styles.MSGBOX_ICON_QUESTION | Styles.MSGBOX_BUTTON_YES_NO | Styles.MSGBOX_DEFAULT_BUTTON_2); return(retResult == Styles.MSGBOX_RESULT_YES); }
/// <summary> /// Get the TaskDefinitionId of the task to be run, from the SelectProgram property on the command's control /// </summary> /// <param name="command"></param> /// <returns></returns> private TaskDefinitionId GetTaskIdFromCommandCtrlProp(ExecOperCommand command) { Task task = Manager.MGDataTable.GetTaskByID(command.TaskTag) as Task; MgForm form = task.getForm() as MgForm; MgControl control = form.CtrlTab.getCtrl(command.DitIdx) as MgControl; Property prop = control.getProp(PropInterface.PROP_TYPE_SELECT_PROGRAM); return(prop.TaskDefinitionId); }
/// <summary> /// /// </summary> /// <param name="task"></param> internal override void DoFirstRefreshTable(Task task) { MgForm form = task.getForm() as MgForm; if (form != null) { Manager.DoFirstRefreshTable(form); } }
/// <summary> /// Creates a command for a subform open /// </summary> /// <param name="subformCtrl"></param> /// <returns></returns> private LocalRunTimeCommandBase CreateSubformCallCommand(SubformOpenEventCommand command) { Task task = Manager.MGDataTable.GetTaskByID(command.TaskTag) as Task; MgForm form = task.getForm() as MgForm; MgControl subformCtrl = form.CtrlTab.getCtrl(command.DitIdx) as MgControl; Property prop = subformCtrl.getProp(PropInterface.PROP_TYPE_PRGTSK_NUM); return(new LocalRunTimeCommandOpenTask(prop.TaskDefinitionId) { ArgList = subformCtrl.ArgList, CallingTaskTag = task.getTaskTag(), PathParentTaskTag = task.getTaskTag(), SubformDitIdx = subformCtrl.getDitIdx() }); }
/// <summary> /// CTOR /// </summary> /// <param name="taskDefinitionId"></param> /// <param name="command"></param> public LocalRunTimeCommandSelectProgram(TaskDefinitionId taskDefinitionId, IClientCommand command) : base(taskDefinitionId) { ExecOperCommand cmd = command as ExecOperCommand; Debug.Assert(cmd != null); Task task = Manager.MGDataTable.GetTaskByID(cmd.TaskTag) as Task; MgForm form = task.getForm() as MgForm; mgControl = form.CtrlTab.getCtrl(cmd.DitIdx) as MgControl; CallingTaskTag = cmd.TaskTag; PathParentTaskTag = CallingTaskTag; ForceModal = true; }
/// <summary> /// prepare the main display /// </summary> /// <param name="task"></param> internal static ReturnResult PreparePropMainDisplay(Task task) { task.ComputeMainDisplay(); bool mainDisplayIsLegal = task.FormIsLegal(); ReturnResult result = (mainDisplayIsLegal ? ReturnResult.SuccessfulResult : new ReturnResult(MsgInterface.BRKTAB_STR_ERR_FORM)); if (result.Success && !task.TaskService.IsFrameAllowed(task)) { MgForm form = task.getForm() as MgForm; if (form != null && form.IsFrameSet) { result = new ReturnResult(MsgInterface.CHK_ERR_OFFLINE_NOT_SUPPORT_FRAME_INTERFACE); } } return(result); }
/// <summary> /// Show the form now /// </summary> /// <param name="task"></param> internal override void OpenForm(Task task, bool callByDestSubForm) { MgForm form = task.getForm() as MgForm; if (form != null) { // remove the form from the list of forms to be opened, so this task's dataview will be initialized // when we want it to ClientManager.Instance.CreatedForms.remove(form); // open other forms, to ensure correct modality relationships ClientManager.Instance.OpenForms(callByDestSubForm); // open this form Manager.OpenForm(form); } }
/// <summary> /// This method is activated when an Event menu was selected. It performs the needed operations in order to /// translate the selected event menu into the matching operation /// </summary> /// <param name = "menuEntryEvent">the selected menu \ bar menuEntryEvent object</param> /// <param name = "activeForm">last active Form</param> /// <param name = "ctlIdx">the index of the ctl which the menu is attached to in toolkit</param> internal static void onEventMenuSelection(MenuEntryEvent menuEntryEvent, MgForm activeForm, int ctlIdx) { MgControl lastFocusedControl = getLastFocusedControl(activeForm); Task task = getLastFocusedTask(activeForm); RunTimeEvent aRtEvt = new RunTimeEvent(menuEntryEvent, task, lastFocusedControl, ctlIdx); aRtEvt.setPublicName(); aRtEvt.setMainPrgCreator(null); // build the argument list from the mainProgVars List <String> mainProgVars = menuEntryEvent.MainProgVars; if (mainProgVars != null && mainProgVars.Count > 0) { ArgumentsList argList = new ArgumentsList(); argList.fillListByMainProgVars(mainProgVars, task.getCtlIdx()); aRtEvt.setArgList(argList); aRtEvt.setTask(null); } ClientManager.Instance.EventsManager.addToTail(aRtEvt); }
/// <summary> /// add form into vector /// </summary> /// <param name="mgForm"></param> public void add(MgForm mgForm) { _createdFormVec.Add(mgForm); }
/// <summary> /// remove form into vector /// </summary> /// <param name="mgForm"></param> public void remove(MgForm mgForm) { _createdFormVec.Remove(mgForm); }
public override void Execute(rt.IResultValue res) { MGData mgd = null; MGDataCollection mgDataTab = MGDataCollection.Instance; bool destinationSubformSucceeded = false; bool refreshWhenHidden = true; int mgdID = 0; MgControl subformCtrl = null; List <Int32> oldTimers = new List <Int32>(), newTimers = new List <Int32>(); bool moveToFirstControl = true; Task guiParentTask; MGData guiParentMgData = null; Task callingTask = (_callingTaskTag != null ? (Task)mgDataTab.GetTaskByID(_callingTaskTag) : null); Task pathParentTask = (_pathParentTaskTag != null ? (Task)mgDataTab.GetTaskByID(_pathParentTaskTag) : null); MgForm formToBeActivatedOnClosingCurrentForm = null; Task lastFocusedTask = ClientManager.Instance.getLastFocusedTask(); if (lastFocusedTask != null && lastFocusedTask.IsOffline) { formToBeActivatedOnClosingCurrentForm = (MgForm)lastFocusedTask.getForm(); } // TODO (Ronak): It is wrong to set Parent task as a last focus task when // non-offline task is being called from an offline task. //When a nonOffline task was called from an Offline task (of course via MP event), //the calling task id was not sent to the server because the server is unaware of the //offline task. So, when coming back from the server, assign the correct calling task. //Task lastFocusedTask = ClientManager.Instance.getLastFocusedTask(); //if (lastFocusedTask != null && lastFocusedTask.IsOffline) // _callingTaskTag = lastFocusedTask.getTaskTag(); guiParentTask = callingTask = (Task)mgDataTab.GetTaskByID(_callingTaskTag); if (callingTask != null) { mgd = callingTask.getMGData(); } //QCR#712370: we should always perform refreshTables for the old MgData before before opening new window ClientManager.Instance.EventsManager.refreshTables(); //ditIdx is send by server only for subform opening for refreshWhenHidden if ((_subformCtrlName != null) || (_ditIdx != Int32.MinValue)) { subformCtrl = (_ditIdx != Int32.MinValue ? (MgControl)callingTask.getForm().getCtrl(_ditIdx) : ((MgForm)callingTask.getForm()).getSubFormCtrlByName(_subformCtrlName)); if (subformCtrl != null) { var subformTask = subformCtrl.getSubformTask(); guiParentTask = (Task)subformCtrl.getForm().getTask(); mgdID = guiParentTask.getMgdID(); guiParentMgData = guiParentTask.getMGData(); if (guiParentMgData.getTimerHandlers() != null) { oldTimers = guiParentMgData.getTimerHandlers().getTimersVector(); } if (_ditIdx != Int32.MinValue) //for refresh when hidden { refreshWhenHidden = false; moveToFirstControl = false; } else //for destination { destinationSubformSucceeded = true; // Pass transaction ownership if (_transOwner != null) { var newTransOwnerTask = (Task)mgDataTab.GetTaskByID(_transOwner); if (newTransOwnerTask != null) { newTransOwnerTask.setTransOwnerTask(); } } if (subformTask != null) { subformTask.setDestinationSubform(true); subformTask.stop(); } if (!ClientManager.Instance.validReturnToCtrl()) { ClientManager.Instance.ReturnToCtrl = GUIManager.getLastFocusedControl(); } } subformCtrl.setSubformTaskId(_newId); } } MGData parentMgData; if (callingTask == null) { parentMgData = MGDataCollection.Instance.getMGData(0); } else { parentMgData = callingTask.getMGData(); } if (!destinationSubformSucceeded && refreshWhenHidden) { mgdID = mgDataTab.getAvailableIdx(); Debug.Assert(mgdID > 0); mgd = new MGData(mgdID, parentMgData, _isModal, _forceModal); mgd.copyUnframedCmds(); MGDataCollection.Instance.addMGData(mgd, mgdID, false); MGDataCollection.Instance.currMgdID = mgdID; } Obj = _key; _key = null; try { // Large systems appear to consume a lot of memory, the garbage collector is not always // "quick" enough to catch it, so free memory before initiating a memory consuming job as // reading a new MGData. if (GC.GetTotalMemory(false) > 30000000) { GC.Collect(); } ClientManager.Instance.ProcessResponse(NewTaskXML, mgdID, new OpeningTaskDetails(callingTask, pathParentTask, formToBeActivatedOnClosingCurrentForm), null); } finally { ClientManager.Instance.EventsManager.setIgnoreUnknownAbort(false); } if (callingTask != null && subformCtrl != null) { callingTask.PrepareForSubform(subformCtrl); } if (destinationSubformSucceeded || !refreshWhenHidden) { subformCtrl.initSubformTask(); if (destinationSubformSucceeded) { var subformTask = subformCtrl.getSubformTask(); moveToFirstControl = !callingTask.RetainFocus; subformTask.setIsDestinationCall(true); } } if (subformCtrl != null) { if (guiParentMgData.getTimerHandlers() != null) { newTimers = guiParentMgData.getTimerHandlers().getTimersVector(); } guiParentMgData.changeTimers(oldTimers, newTimers); } Task nonInteractiveTask = ClientManager.Instance.StartProgram(destinationSubformSucceeded, moveToFirstControl, _varList, _returnVal, null); if (destinationSubformSucceeded || !refreshWhenHidden) { guiParentTask.resetRcmpTabOrder(); } // in local tasks, ismodal is calculated after the main display, so we need to update the command member _isModal = mgd.IsModal; // If we have a non interactive task starting, we need to create an eventLoop for it , just like modal. // This is because we cannot allow the tasks above it to catch events. if (nonInteractiveTask == null) { // a non interactive parent will cause the called task to behave like modal by having its own events loop. // In case of main program caller (which is flagged as non interactive) we will have a new events loop for the called program // if the main program is without a form. If the main prog has a form , then the callee can be included in the main prog loop. if (callingTask != null && ((_isModal && !destinationSubformSucceeded && refreshWhenHidden) || (!callingTask.IsInteractive && (!callingTask.isMainProg() || callingTask.getForm() == null)))) { ClientManager.Instance.EventsManager.EventsLoop(mgd); } } else { ClientManager.Instance.EventsManager.NonInteractiveEventsLoop(mgd, nonInteractiveTask); } }
/// <summary> /// This method is activated when a program menu was selected. It performs the needed operations in order to /// translate the selected program menu into the matching operation /// </summary> /// <param name="contextID">active/target context (irelevant for RC)</param> /// <param name="menuEntryProgram">the selected menu \ bar menuEntryProgram object</param> /// <param name="activeForm"></param> /// <param name="ActivatedFromMDIFrame"></param> /// <returns></returns> internal static void onProgramMenuSelection(Int64 contextID, MenuEntryProgram menuEntryProgram, MgForm activeForm, bool ActivatedFromMDIFrame) { Task menuTask = getLastFocusedTask(activeForm); ClientManager.Instance.RuntimeCtx.LastClickedMenuUid = menuEntryProgram.menuUid(); RunTimeEvent programMenuEvt = new RunTimeEvent(menuEntryProgram, menuTask, ActivatedFromMDIFrame); ClientManager.Instance.EventsManager.addToTail(programMenuEvt); }
/// <summary> /// according to shell return the last task that was in focus /// it can be on subform \ sub sub form.... * /// </summary> /// <param name = "mgForm"></param> /// <returns></returns> private static Task getLastFocusedTask(MgForm mgForm) { int windowIndex = ((Task)mgForm.getTask()).getMGData().GetId(); return(ClientManager.Instance.getLastFocusedTask(windowIndex)); }
/// <summary> /// according to shell return the last control that was in focus /// it can be on subform \ sub sub form.... /// </summary> /// <param name = "mgForm"></param> /// <returns></returns> private static MgControl getLastFocusedControl(MgForm mgForm) { int windowIndex = getLastFocusedTask(mgForm).getMGData().GetId(); return(GUIManager.getLastFocusedControl(windowIndex)); }
/// <summary> Catch the enable/disable of the soft keyboard. When the keyboard state changes, /// resize the active form and scroll to the control in focus /// </summary> /// <param name="sender"></param> /// <param name="e"></param> void inputPanel_EnabledChanged(object sender, EventArgs e) { // Get the active form ClientManager cm = ClientManager.Instance; tasks.Task task = cm.getLastFocusedTask(); if (task == null) { return; } MgForm mgForm = (MgForm)cm.getLastFocusedTask().getForm(); if (mgForm == null) { return; } mgForm = (MgForm)mgForm.getTopMostForm(); Form form = GuiCommandQueue.getInstance().mgFormToForm(mgForm); // If form size changed if (form != null && form.Bounds != _inputPanel.VisibleDesktop) { Size changeFormSizeTo; if (_inputPanel.Enabled || _previousSize == null) { // remember the form's size before the soft keyboard was opened _previousSize = form.Size; changeFormSizeTo = _inputPanel.VisibleDesktop.Size; } else { // use the size from before the soft keyboard was opened - the VisibleDesktop ignores // the menu bar size changeFormSizeTo = _previousSize; } // Set the new size. The .Net way of changing the bounds does not work in this case, // so lets do it via win32 functions NativeWindowCommon.SetWindowPos(form.Handle, IntPtr.Zero, 0, 0, changeFormSizeTo.Width, changeFormSizeTo.Height, NativeWindowCommon.SWP_NOMOVE | NativeWindowCommon.SWP_NOZORDER); // Find the control in focus and scroll to it MapData mapData = ((TagData)form.Tag).LastFocusedMapData; GuiMgControl guiMgcontrol = mapData.getControl(); if (guiMgcontrol == null) { return; } object o = ControlsMap.getInstance().object2Widget(guiMgcontrol, mapData.getIdx()); Control control = null; LogicalControl logicalControl = null; if (o is LogicalControl) { logicalControl = (LogicalControl)o; control = logicalControl.getEditorControl(); } else { control = (Control)o; } GuiUtils.scrollToControl(control, logicalControl); } }
/// <summary> /// display a Message Box (confirm) with 2 buttons . /// </summary> /// <param name = "form">the parent form </param> /// <param name = "msgId">message number (from MsgInterface.java) that will be display on the content of the Message Box </param> /// <param name = "style">the icon and the button that will be display on the confirmation box </param> /// <returns> the button that was pressed (Styles.MSGBOX_BUTTON_xxx) </returns> internal int confirm(MgForm form, string msgId, int style) { return(writeToMessageBox(form, MsgInterface.CONFIRM_STR_WINDOW_TITLE, msgId, style)); }
/// <summary> /// /// </summary> /// <param name="contextID">active/target context (irelevant for RC)</param> /// <param name="osCommandMenuEntry"></param> /// <param name="lastFocusedCtrlTask"> ///the task of the last focused control. This is required because even if there is no ///last focused control, then also we have task and hence expression/function will be executed properly. ///Previously task was obtained from the control and when there was no control,task could not be obtained. /// </param> /// <returns></returns> internal static void onOSMenuSelection(Int64 contextID, MenuEntryOSCommand osCommandMenuEntry, MgForm activeForm) { Task lastFocusedCtrlTask = getLastFocusedTask(activeForm); RunTimeEvent osMenuEvent = new RunTimeEvent(osCommandMenuEntry, lastFocusedCtrlTask); if (osCommandMenuEntry.Wait) { ClientManager.Instance.EventsManager.handleEvent(osMenuEvent, false); } else { ClientManager.Instance.EventsManager.addToTail(osMenuEvent); } }