Reference Class:
SysSystemDefinedButtons
Sample code:
[ExtensionOf(classStr(SysSystemDefinedButtons))]
internal final class SysSystemDefinedButtonsCls_SAN_Extension
{
private static str SANDE_SystemDefinedButtonsActionPane = "SystemDefinedButtonsActionPane";
private static str SAN_SystemDefinedButtonsActionPane = "SAN_SystemDefinedButtonsActionPane";
private static str SAN_SystemDefinedFormButtonGroup = "SAN_SystemDefinedButtonsButtonGroup_Form";
private static str SAN_SystemDefinedWorkFlowButton = "SAN_SystemDefinedButtonWorkflow";
private static str SAN_SystemDefinedWorkdlowActionPaneTab = "SAN_SystemDefinedWorkflow";
private static str SAN_SystemDefinedWorkflowGroup = "SAN_SystemDefinedWorkflowGroup";
public void addSystemDefinedButtons()
{
next addSystemDefinedButtons();
if (this.isFormStyleSupportedForSystemDefinedButtons())
{
FormActionPaneControl actionPane;
List listOfActionPanes;
ListEnumerator apListEnumerator;
listOfActionPanes = this.san_GetActionPanesForSystemButtons();
apListEnumerator = listOfActionPanes.getEnumerator();
while (apListEnumerator.moveNext())
{
actionPane = apListEnumerator.current();
this.san_AddButtonsToActionPane(actionPane);
}
}
}
private List san_GetActionPanesForSystemButtons()
{
List listOfActionPanes = new List(Types::Class);
FormActionPaneControl actionPane;
Object childControl;
FormRun form = this.getFormRun();
for (int i = 1; i <= form.design().controlCount(); i++)
{
childControl = form.design().controlNum(i);
if (classidget(childControl) == classnum(FormActionPaneControl))
{
actionPane = childControl as FormActionPaneControl;
if (actionPane.Style() == ActionPaneStyle::Standard)
{
listOfActionPanes.addEnd(actionPane);
}
}
}
if (listOfActionPanes.empty())
{
actionPane = form.design().addControl(FormControlType::ActionPane, SANDE_SystemDefinedButtonsActionPane);
form.design().moveControl(actionPane.id());
listOfActionPanes.addEnd(actionPane);
}
return listOfActionPanes;
}
private void san_AddButtonsToActionPane(FormActionPaneControl _actionPane)
{
FormButtonGroupControl buttonGroup;
FormMenuButtonControl menuButton;
FormCommandButtonControl commandButton;
FormRun formRun = this.getFormRun();
if (this.getFormStyle() != FormStyle::Workspace)
{
this.SAN_AddWorkflowsTab(_actionPane);
}
}
private void SAN_AddWorkflowsTab(FormActionPaneControl _actionPane)
{
FormButtonGroupControl buttonGroup;
FormMenuButtonControl menuButton;
FormActionPaneTabControl workflowTab = _actionPane.addControl(FormControlType::ActionPaneTab, this.SAN_CreateUniqueName(SAN_SystemDefinedWorkdlowActionPaneTab));
workflowTab.allowUserSetup(FormAllowUserSetup::No);
FormRun form = this.getFormRun();
workflowTab.caption("Custom Workflow");
workflowTab.hideIfEmpty(true);
buttonGroup = workflowTab.addControl(FormControlType::ButtonGroup, this.SAN_CreateUniqueName("SAN_SystemDefinedWorkflowGroup"));
buttonGroup.allowUserSetup(FormAllowUserSetup::No);
buttonGroup.caption("Workflow");
FormFunctionButtonControl menuItemButton = buttonGroup.addControl(FormControlType::MenuFunctionButton, "SAN_WorflowButton", buttonGroup);
menuItemButton.menuItemType(MenuItemType::Display);
menuItemButton.menuItemName(menuItemDisplayStr(<Display menu item>));
menuItemButton.dataSource(form.dataSource());
menuItemButton.visible(true);
}
private str SAN_CreateUniqueName(str baseControlName)
{
str candidateName = baseControlName;
int i = 1;
if(this.SAN_isControlFound(candidateName))
{
do
{
candidateName = strFmt("%1%2", baseControlName, i);
i++;
}
while (this.SAN_isControlFound(candidateName));
}
return candidateName;
}
private boolean SAN_isControlFound(str controlName)
{
FormRun form = this.getFormRun();
boolean isControlFound = false;
if (form.controlId(controlName) > 0)
{
isControlFound = true;
}
return isControlFound;
}
}
No comments:
Post a Comment