haorenhui
2023-10-30 6d6cc10d9e8e242661da7fd655dec155a09d676c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
Quintiq file version 2.0
#parent: ListIssue
Response OnClick (
  structured[LibOpt_Issue] selection
) id:Response_ListIssue_MenuSelectRelatedSuboptimizerScopeElement_OnClick
{
  #keys: '[142652.0.1936757326]'
  Body:
  [*
    // Select the Suboptimizer Scope Elements in ListSuboptimizerScopeElement for the Issues selected here.
    
    // The elements shown in ListSuboptimizerScopeElement is based on the selection in ListComponent.
    // So, we need to update ListComponent first before we can select the related elements in ListSuboptimizerScopeElement.   
    
    listcomponent := LibOpt_GlobalState.GetActivatedFormComponent().ListComponent();
    
    // See comment about WORKAROUND below.
    formsuboptimizerscopeelement := LibOpt_GlobalState.GetActivatedFormSuboptimizerScopeElement();
    listsuboptimizerscopelement := formsuboptimizerscopeelement.ListSuboptimizerScopeElement();
    
    // Select the Components of the related Suboptimizer Scope Elements first,
    // to populate ListSuboptimizerScopeElement with the relevant elements. 
    traverse( selection, Elements.SuboptimizerScopeElement.Suboptimizer, suboptimizer )
    {
      listcomponent.ExtendSelectByKey( suboptimizer.Key() );
    }  
    
    // Select the related Suboptimizer Scope Elements.
    traverse( selection, Elements.SuboptimizerScopeElement, suboptscopelement )
    {
      listsuboptimizerscopelement.ExtendSelectByKey( suboptscopelement.Key() );
    }
    
    /*  WORKAROUND:
        
        Even though we have called the `GetActivatedFormSuboptimizerScopeElement` method above,
        LibOpt_FormSuboptimizerScopeElement doesn't get activated accordingly because the method is called
        right after `GetActivatedFormCompenent`, where LibOpt_FormCompenent is activated.
        This is a known software limitation (that is yet to be solved) as documented in:
        - https://support.quintiq.com/cs:solutions:trouble:form.activate_doesn_t_work_for_second_form
        
        As such, we use a workaround where we activate LibOpt_FormSuboptimizerScopeElement in the `OnTimer`
        response of the GUITimerActivateFormSuboptimizerScopeElement component, which `Interval` has been
        set to 500ms.
        - 500ms was used because lower values don't result in the intended behavior of activating the form.
    */
    // Enable the GUITimerActivateFormSuboptimizerScopeElement component.
    // When the timer's Interval is used up, LibOpt_FormSuboptimizerScopeElement is activated, and the timer is disabled.
    formsuboptimizerscopeelement.GUITimerActivateFormSuboptimizerScopeElement().Enabled( true );
  *]
  DefinitionID => /ListIssue/Responsedef_ListIssue_Menu_OnClick
  Initiator: 'MenuSelectRelatedSuboptimizerScopeElement'
  Precondition:
  [*
    return LibOpt_Issue::SelectRelatedSuboptimizerScopeElementPrecondition( selection );
  *]
}