### Get IJson Service Instance for JSON Operations Source: https://github.com/ku-m/gpf-codebase/blob/main/findings/20250711_145607/gpf_dc_scgc_src_core_cell_fe_scgc_pages_home_par_AppMenuTreeNodeProc2.java.md Demonstrates how to obtain an `IJson` instance via `IJsonService`'s static method chain. This instance is used for JSON serialization and deserialization. The example uses `try-with-resources` to ensure proper resource management and shows commented-out examples for `fromJson` and `toJson`. ```java import cell.cmn.IJson; import cell.cmn.IJsonService; /** * 获取IJson服务实例,用于JSON的序列化和反序列化操作。 * 使用try-with-resources确保资源被正确管理。 */ public class GetIJsonServiceExample { public static void main(String[] args) { try (IJson jsonService = IJsonService.get().getJson()) { System.out.println("IJson service instance obtained successfully."); // 示例:此处可以进行JSON相关的操作,例如反序列化一个对象 // String jsonString = "{\"name\":\"Test\", \"value\":123}"; // YourObject yourObject = jsonService.fromJson(jsonString, YourObject.class); // System.out.println("Deserialized object: " + yourObject.getName()); // 示例:或序列化一个对象 // YourObject myObject = new YourObject("Another Test", 456); // String serializedJson = jsonService.toJson(myObject); // System.out.println("Serialized JSON: " + serializedJson); } catch (Exception e) { System.err.println("Failed to get or use JSON service: " + e.getMessage()); e.printStackTrace(); } } // 仅作为示例数据传输对象,实际应替换为您自己的POJO // static class YourObject { // public String name; // public int value; // public YourObject(String name, int value) { this.name = name; this.value = value; } // public String getName() { return name; } // } } ``` -------------------------------- ### Get Application Settings with AppCacheUtil Source: https://github.com/ku-m/gpf-codebase/blob/main/findings/20250711_145607/gpf_dc_pmc_src_core_cell_pmc_page_IFactoryOrgMgrView.java.md Illustrates how to obtain application-level configuration settings via `AppCacheUtil.getSetting`. Similar to `getAppContext`, it requires a `PanelContext` instance to fetch the correct settings. ```Java import fe.cmn.panel.PanelContext; import gpf.dc.basic.fe.component.app.AppCacheUtil; import gpf.dc.basic.param.view.dto.ApplicationSetting; // 目的:展示如何通过 AppCacheUtil.getSetting 方法获取应用层级的配置设置。 // 前提:需要一个 PanelContext 实例作为输入参数。 // PanelContext yourPanelContext = ...; // 假设此处已获得 PanelContext 实例 ApplicationSetting appSetting = AppCacheUtil.getSetting(yourPanelContext); ``` -------------------------------- ### Get IChatGroupService Instance Source: https://github.com/ku-m/gpf-codebase/blob/main/findings/20250711_145607/gpf_dc_orchestration_src_src_cell_chatgroup_service_IChatGroupService.java.md This example demonstrates how to obtain an instance of `IChatGroupService` using a reliable static method call, serving as the service entry point. ```java IChatGroupService service = IChatGroupService.get(); ``` -------------------------------- ### Query Application Settings using IApplicationService in Java Source: https://github.com/ku-m/gpf-codebase/blob/main/findings/20250711_145607/gpf_dc_scgc_src_core_cell_fe_scgc_pages_login_ILoginPARLoginPage.java.md This example shows how to obtain an `IApplicationService` instance via a static `get()` method and then use it to query application settings. It represents a typical service lookup and data retrieval pattern for application configurations. ```java import cell.fe.gpf.dc.basic.IApplicationService; import gpf.dc.basic.param.view.dto.ApplicationSetting; // 通过IApplicationService静态方法查询应用设置 // "your_application_uuid_placeholder" 应替换为实际的应用UUID ApplicationSetting setting = IApplicationService.get().queryApplicationSetting("your_application_uuid_placeholder"); // 注意:此处仅展示查询API的使用,对返回结果(setting)的后续操作(如getLabel(), getLoginLogo()等) // 因其依赖于非通用类型ApplicationSetting的实例,若无可靠创建方式,则不单独提取。 // 如果ApplicationSetting可以被通用Java类型完全模拟构造,则其getter方法可被进一步提取。 ``` -------------------------------- ### Configure AssocDataPlusQueryParam Object Source: https://github.com/ku-m/gpf-codebase/blob/main/findings/20250711_145607/gpf_dc_pmc_src_core_fe_pmc_component_fieldExtend_editor_CustomSelectModelListEditor.java.md Demonstrates how to instantiate and set basic properties of an `AssocDataPlusQueryParam` object. It includes setting a `FormField`, a value object, a widget ID, and a writable flag, along with calling a default parameter setup method. ```Java import gpf.dc.basic.fe.component.param.AssocDataPlusQueryParam; import fe.cmn.editor.FormField; // Assuming FormField is a standard type used in your framework // 假设这些变量已准备好,或者将被AI生成 FormField your_form_field_instance = new FormField(); // 示例:实际应用中可能从上下文获取 Object your_value_object = new Object(); // 示例:可以是任何对象类型 String your_widget_id = "widget_id_placeholder"; boolean your_writable_flag = true; AssocDataPlusQueryParam param = new AssocDataPlusQueryParam(); param.setField(your_form_field_instance); param.setValue(your_value_object); param.setWidgetId(your_widget_id); param.defaultParam(); // 调用默认参数设置方法 param.setWritable(your_writable_flag); ``` -------------------------------- ### Get IDao Instance via Service (IDaoService.get().newDao) in Java Source: https://github.com/ku-m/gpf-codebase/blob/main/findings/20250711_143110/gpf_rapidView_pmc_src_core_cell_rapidView_function_RapidViewBasicFunc.java.md Demonstrates how to obtain an `IDaoService` object via its singleton or service instance method, and then create an `IDao` instance through it. This differs slightly from directly using `IDaoService.newIDao()`, showcasing another service acquisition pattern. It also includes a try-with-resources example. ```java import cell.cdao.IDao; import cell.cdao.IDaoService; IDao daoInstance = IDaoService.get().newDao(); // Can be used in a try-with-resources statement to ensure automatic resource closure // try (IDao dao = IDaoService.get().newDao()) { // // Use dao // } ``` -------------------------------- ### Instantiate ChatGroupChatPanel and Get WidgetDto Source: https://github.com/ku-m/gpf-codebase/blob/main/findings/20250711_145607/gpf_dc_orchestration_src_src_fe_chatgroup_component_ChatGroupPanel.java.md Demonstrates how to instantiate ChatGroupChatPanel, set its parameters, and retrieve a renderable WidgetDto, which is an abstract representation of a UI component. This requires a PanelContext instance and an initialized ChatGroupChatParam instance. ```java ChatGroupChatPanel chatGroupChatPanel = new ChatGroupChatPanel<>(); chatGroupChatPanel.setWidgetParam(chat_group_chat_param); WidgetDto chatWidget = chatGroupChatPanel.getWidget(your_panel_context); ``` -------------------------------- ### Get User Manager and Update User Object Source: https://github.com/ku-m/gpf-codebase/blob/main/findings/20250711_145607/gpf_dc_pmc_src_core_fe_pmc_component_fieldExtend_editor_CustomSelectModelListEditor.java.md Explains how to obtain an `IUserMgr` instance via its static factory `IUserMgr.get()` and then update a `User` object. This method requires an `IDao` instance (for database operations) and the `User` object containing the updated information. ```java import cell.cdao.IDao; import cell.gpf.adur.user.IUserMgr; import gpf.adur.user.User; // 假设 User 是返回类型 // 假设 your_dao_instance 和 your_user_object 已准备好 IDao your_dao_instance = null; // 示例 User your_user_object = new User(); // 示例 IUserMgr.get().updateUser(your_dao_instance, your_user_object); ``` -------------------------------- ### Get Full Exception Stack Trace using ToolUtilities Source: https://github.com/ku-m/gpf-codebase/blob/main/findings/20250711_145607/gpf_dc_orchestration_src_src_cell_orchestration_function_flow_OrchestrationNodeCommonAction.java.md Demonstrates how to use the `ToolUtilities.getFullExceptionStack` method to retrieve the complete stack trace of an `Exception` object as a string. This is useful for robust logging and error handling within the framework, providing detailed diagnostic information. ```java import com.kwaidoo.ms.tool.ToolUtilities; // Assume this is a framework utility class public class ToolUtilitiesExceptionSample { public static void main(String[] args) { try { // Simulate a business logic that might throw an exception performSomeOperation(); } catch (Exception e) { // Core code pattern: Call ToolUtilities to get the full exception stack trace String fullStackTrace = ToolUtilities.getFullExceptionStack(e); // The obtained stack trace information can be logged or displayed here System.out.println("Caught exception, full stack trace as follows:"); System.out.println(fullStackTrace); } } private static void performSomeOperation() { // Your business logic goes here, which might throw an exception throw new RuntimeException("Your business error message here"); } } ``` -------------------------------- ### Get IFormMgr Instance in Java Source: https://github.com/ku-m/gpf-codebase/blob/main/findings/20250711_145607/gpf_dc_OctoCM_Workbench_src_core_octo_cm_util_PanelDesignFormUtil.java.md Demonstrates how to obtain a singleton instance of `IFormMgr`, which serves as the primary entry point for managing `Form` objects. This is a reliable static method call, representing a single, atomic task to acquire the form manager. ```java import cell.gpf.adur.data.IFormMgr; // 获取IFormMgr的单一实例 IFormMgr formManager = IFormMgr.get(); ``` -------------------------------- ### Get a single property from ChatRoleInfoDto Source: https://github.com/ku-m/gpf-codebase/blob/main/findings/20250711_145607/gpf_dc_orchestration_src_src_chatgroup_dto_ChatRoleInfoDto.java.md This example demonstrates how to retrieve the value of a specific property from an existing `ChatRoleInfoDto` instance. ```java // 准备一个 ChatRoleInfoDto 实例,并为其设置一个值以便获取 // 实际使用时,此对象可能是从其他地方传入或查询得到的 ChatRoleInfoDto preInitializedChatRoleInfo = new ChatRoleInfoDto() .setRolePrompt("此角色提示词将被获取"); // 执行动作:获取对象的角色提示词属性 String retrievedRolePrompt = preInitializedChatRoleInfo.getRolePrompt(); // retrievedRolePrompt 变量现在包含了 "此角色提示词将被获取" ``` -------------------------------- ### Instantiate BuildAndParseInfoDto Object Source: https://github.com/ku-m/gpf-codebase/blob/main/findings/20250711_145607/gpf_dc_orchestration_src_src_fe_orchestration_component_dto_BuildAndParseInfoDto.java.md This example shows how to create a new instance of the `BuildAndParseInfoDto` class. This is the fundamental step to begin working with the DTO. ```java BuildAndParseInfoDto newInfo = new BuildAndParseInfoDto(); ``` -------------------------------- ### Build SinglePanelDto with Label and Preferred Size (Java) Source: https://github.com/ku-m/gpf-codebase/blob/main/findings/20250711_145607/gpf_dc_OctoCM_Workbench_src_core_octo_cm_util_EasyOperation.java.md Demonstrates the creation of a `SinglePanelDto` that incorporates a `LabelDto` for displaying text content. It also illustrates how to set the panel's preferred dimensions using `SizeDto.all()`. This process is self-contained, relying on `new` keyword instantiation and direct method calls for configuration, focusing on the panel's basic setup. ```java // 构建一个包含文本标签并设置首选尺寸的单一面板 SinglePanelDto panelWithLabel = new SinglePanelDto(new LabelDto("此处填写您的面板内容提示信息")); panelWithLabel.setPreferSize(SizeDto.all(your_width, your_height)); // 例如:SizeDto.all(300, 100) ``` -------------------------------- ### Build a PopDialog Instance for Configuration in Java Source: https://github.com/ku-m/gpf-codebase/blob/main/findings/20250711_143110/gpf_rapidView_pmc_src_core_fe_rapidView_util_ETSStyleUtil.java.md This snippet explains how to build a `PopDialog` instance using `PopDialog.build` before displaying it. This approach allows for more granular configuration of the dialog's properties, such as decoration, GUI value handling, and timeout settings, enabling a more flexible dialog setup. ```java import fe.cmn.panel.PanelDto; import fe.cmn.panel.EscapeButtonDto; import fe.cmn.panel.DialogDecorationDto; import fe.cmn.panel.ability.PopDialog; // 假设 yourPanelDtoInstance 已存在 PanelDto yourPanelDtoInstance; EscapeButtonDto yourOkButtonInstance = new EscapeButtonDto().setText("确认"); // 示例 DialogDecorationDto yourDialogDecorationInstance = new DialogDecorationDto(); // 示例 // 构建一个 PopDialog 实例 PopDialog dialog = PopDialog.build( "此处填写对话框标题", yourPanelDtoInstance, yourOkButtonInstance, // 确认按钮 null, // 取消按钮,可为 null your_boolean_value_showCloseButton // 是否显示关闭按钮 ); // 设置对话框装饰 dialog.setDecoration(yourDialogDecorationInstance); // ... 其他配置,例如: dialog.setOnlyGuiValue(your_boolean_value_onlyGuiValue); dialog.setWaitForClose(your_long_value_timeoutMillis); dialog.setTimeout(dialog.getWaitForClose()); // 通常与 WaitForClose 相同 ``` -------------------------------- ### Get Form Associated Data List in Java Source: https://github.com/ku-m/gpf-codebase/blob/main/findings/20250711_145607/gpf_dc_scgc_src_core_cell_scgc_action_formView_IFormViewGlpsjhgllcProcess.java.md Demonstrates how to retrieve a list of other data associated with a `Form` object. This relies on an existing `Form` variable (e.g., obtained via method parameters or previous examples). ```Java List associationList = form.getAssociations("your_association_name"); ``` -------------------------------- ### Initialize ChatRoleInfoDto instance using chained setters Source: https://github.com/ku-m/gpf-codebase/blob/main/findings/20250711_145607/gpf_dc_orchestration_src_src_chatgroup_dto_ChatRoleInfoDto.java.md This example demonstrates how to create a new instance of `ChatRoleInfoDto` and set all relevant properties at once using its chained setter methods. This is a common and recommended pattern for building DTOs. ```java // 准备示例数据(请替换为您的实际业务值) String roleNameValue = "your_role_name_example"; String roleCodeValue = "your_role_code_example"; String rolePromptValue = "此处填写您的角色提示信息,例如:你是一个专业的客户服务助理。"; String nickNameValue = "your_nick_name_example"; byte[] profileData = new byte[]{/* 请在此处填充字节数组数据,例如:0x01, 0x02, 0x03 */}; String llmConfigCodeValue = "your_llm_config_code_example"; // 假设 GptServiceConfigDto 可通过默认构造函数实例化。 // 如果其构造复杂,应在其自身样例中体现。 GptServiceConfigDto serviceConfigInstance = new GptServiceConfigDto(); String agentCodeValue = "your_agent_code_example"; // 执行动作:使用链式调用构建并初始化 ChatRoleInfoDto 实例 ChatRoleInfoDto chatRoleInfo = new ChatRoleInfoDto() .setRoleName(roleNameValue) .setRoleCode(roleCodeValue) .setRolePrompt(rolePromptValue) .setNickName(nickNameValue) .setProfile(profileData) .setLlmConfigCode(llmConfigCodeValue) .setServiceConfig(serviceConfigInstance) .setAgentCode(agentCodeValue); // chatRoleInfo 现已是一个完整初始化的 ChatRoleInfoDto 对象 ``` -------------------------------- ### Get Element from LinkedList by Index in Java Source: https://github.com/ku-m/gpf-codebase/blob/main/findings/20250711_145607/gpf_dc_pmc_src_core_fe_pmc_component_fieldExtend_AddressSelectHandler.java.md This example illustrates how to retrieve an element from a `LinkedList` at a specific index. It includes crucial boundary checks to prevent `IndexOutOfBoundsException` and demonstrates handling both valid and invalid index attempts. ```java // 从LinkedList中根据索引获取元素 import java.util.LinkedList; public class GetElementFromLinkedListExample { public static void main(String[] args) { LinkedList yourList = new LinkedList<>(); yourList.add("第一个元素"); yourList.add("第二个元素"); yourList.add("第三个元素"); int targetIndex = 0; // 此处填写您要获取的元素索引 // 确保索引在有效范围内,避免IndexOutOfBoundsException if (targetIndex >= 0 && targetIndex < yourList.size()) { Object element = yourList.get(targetIndex); // 此处可以使用获取到的元素 System.out.println("成功获取到索引 " + targetIndex + " 处的元素: " + element); } else { System.out.println("索引 " + targetIndex + " 超出列表范围或列表为空。当前列表大小: " + yourList.size()); } // 尝试获取一个不存在的索引(为了演示边界情况) int invalidIndex = 5; if (invalidIndex >= 0 && invalidIndex < yourList.size()) { Object element = yourList.get(invalidIndex); System.out.println("成功获取到索引 " + invalidIndex + " 处的元素: " + element); } else { System.out.println("尝试获取索引 " + invalidIndex + " 失败:超出列表范围。"); } } } ``` -------------------------------- ### Create ProgressBarDto Instance and Configure Basic Properties Source: https://github.com/ku-m/gpf-codebase/blob/main/findings/20250711_145607/gpf_dc_orchestration_src_src_fe_orchestration_component_progress_ProgressPanel.java.md This example demonstrates how to instantiate a ProgressBarDto and associate it with a pre-configured ProgressBarDecorationDto. It also shows how to set the progress bar's unique identifier (Widget ID) and preferred height. Requires a ProgressBarDecorationDto instance. ```java ProgressBarDecorationDto progressBarDecoration = new ProgressBarDecorationDto() .setErrorColor(CColor.fromColor(java.awt.Color.GRAY)) .setDottedBorderWidth(1.0) .setShowMessage(false) .setShowCancelButton(false) .setBorder(java.awt.Color.LIGHT_GRAY, 0.5, 10d); ProgressBarDto progressBar = new ProgressBarDto(); progressBar.setProgressBarDecoration(progressBarDecoration) .setWidgetId("your_progress_bar_widget_id") // 替换为您的进度条组件ID .setPreferHeight(20); // 示例:设置进度条的首选高度(单位:像素) ``` -------------------------------- ### Get EasyOperation Instance in Java Source: https://github.com/ku-m/gpf-codebase/blob/main/findings/20250711_145607/gpf_dc_OctoCM_Workbench_src_core_octo_cm_util_PanelDesignFormUtil.java.md Demonstrates how to obtain a singleton instance of `EasyOperation` using a static `get()` method. This instance is typically used for convenient, high-level operations within the application. The method call is reliable and represents a single, atomic task. ```java import octo.cm.util.EasyOperation; // 获取EasyOperation的单一实例 EasyOperation easyOperation = EasyOperation.get(); ``` -------------------------------- ### Create CCodeEditorDto and Configure Line Numbers, Widget ID, and Theme Source: https://github.com/ku-m/gpf-codebase/blob/main/findings/20250711_145607/gpf_dc_orchestration_src_src_fe_orchestration_component_progress_ProgressPanel.java.md This example demonstrates how to instantiate a CCodeEditorDto and chain calls to set its functionality and appearance. This includes whether to show line numbers, its unique component ID, and the code editor's visual theme. ```java CCodeEditorDto codeEditor = new CCodeEditorDto() .setShowLineNumber(true) // 示例:设置代码编辑器是否显示行号 .setWidgetId("your_code_editor_widget_id") // 替换为您的代码编辑器组件ID .setTheme(CCodeEditorTheme.darculaTheme); // 示例:设置代码编辑器的主题为Darcula风格 ``` -------------------------------- ### Retrieving a Single Property Value from PanelFormDto Source: https://github.com/ku-m/gpf-codebase/blob/main/findings/20250711_145607/gpf_dc_PanelCM_src_core_octo_cm_excel_dto_PanelFormDto.java.md Shows how to read a specific property's value from an instantiated `PanelFormDto` object. To ensure reliability, the example first initializes the DTO and sets a value, then demonstrates how to retrieve it, focusing only on the action of getting a single attribute value. ```java // 从 PanelFormDto 对象中获取单个属性值 PanelFormDto panelForm = new PanelFormDto(); panelForm.setFormName("示例表单名称"); // 预设一个值,以便后续获取 String retrievedFormName = panelForm.getFormName(); // 您可以在此处进一步处理 retrievedFormName 变量 // 例如: System.out.println("获取到的表单名称: " + retrievedFormName); ``` -------------------------------- ### Create IconStyleDto Object for Icon Styling Source: https://github.com/ku-m/gpf-codebase/blob/main/findings/20250711_145607/gpf_dc_scgc_src_core_cell_fe_scgc_pages_home_par_AppMenuTreeNodeProc2.java.md Shows how to instantiate an `IconStyleDto` object to define the color and size of an icon. The example demonstrates multiple ways to construct the object, including using predefined `CColor` instances, creating `CColor` directly in the constructor, and using custom `CColor` values. ```java import fe.cmn.data.CColor; import fe.cmn.widget.decoration.IconStyleDto; import java.awt.Color; // 用于java.awt.Color.BLACK /** * 创建IconStyleDto,用于定义图标的颜色和大小样式。 */ public class IconStyleDtoCreationExample { public static void main(String[] args) { // 方式一:直接提供已存在的CColor实例和大小 CColor predefinedColor = CColor.fromColor(Color.BLUE); // 假设已有一个CColor实例 int size1 = 24; IconStyleDto iconStyle1 = new IconStyleDto(predefinedColor, size1); System.out.println("IconStyleDto 1 created: Color=" + iconStyle1.getColor() + ", Size=" + iconStyle1.getSize()); // 方式二:在构造函数中直接创建CColor实例 int size2 = 16; IconStyleDto iconStyle2 = new IconStyleDto(CColor.fromColor(Color.BLACK), size2); System.out.println("IconStyleDto 2 created: Color=" + iconStyle2.getColor() + ", Size=" + iconStyle2.getSize()); // 方式三:使用自定义CColor和大小 CColor customCColor = CColor.fromColor(new Color(255, 128, 0)); // 橙色 int size3 = 32; IconStyleDto iconStyle3 = new IconStyleDto(customCColor, size3); System.out.println("IconStyleDto 3 created: Color=" + iconStyle3.getColor() + ", Size=" + iconStyle3.getSize()); } } ``` -------------------------------- ### Create and Populate a HashMap for Template Rendering in Java Source: https://github.com/ku-m/gpf-codebase/blob/main/findings/20250711_143110/gpf_rapidView_pmc_src_core_fe_rapidView_view_card_OperateSuccessResultView.java.md This example demonstrates how to use the standard Java `HashMap` to build a string-to-string map. This pattern is commonly used to provide dynamic data to template engines, showcasing the direct use of the data structure for data preparation. ```Java import java.util.HashMap; import java.util.Map; /** * 教学样例:如何创建并填充一个用于模板渲染的键值对映射 (Map) * 适用于向HTML模板或其他需要动态数据的场景传递参数。 */ public class TemplateDataMapExample { public static void main(String[] args) { // 1. 创建一个新的HashMap实例,用于存储模板参数的键值对 Map templateData = new HashMap<>(); // 2. 使用put方法添加模板所需的参数 // 键(Key)通常对应模板中的占位符名称,值(Value)则是要填充的具体内容。 templateData.put("your_template_key_for_title", "此处填写您的动态标题内容"); templateData.put("your_template_key_for_subtitle", "此处填写您的动态副标题内容"); templateData.put("your_template_key_for_button_text", "点击此处查看详情"); templateData.put("your_template_key_for_button_url", "https://your_dynamic_url_here.com"); // 您可以根据需要添加任意数量的键值对 templateData.put("another_placeholder_key", "另一个动态值"); System.out.println("成功创建并填充了模板数据映射:"); templateData.forEach((key, value) -> System.out.println(" " + key + ": " + value)); } } ``` -------------------------------- ### Retrieve Specific Role Information by Name from ChatGroupInfoDto in Java Source: https://github.com/ku-m/gpf-codebase/blob/main/findings/20250711_145607/gpf_dc_orchestration_src_src_chatgroup_dto_ChatGroupInfoDto.java.md Shows how to use the `getRoleInfoByName(String roleName)` business method of `ChatGroupInfoDto`. The example includes necessary setup to make it self-contained, demonstrating how to look up objects within a collection by a specific identifier and handle the retrieved result. ```java import chatgroup.dto.ChatGroupInfoDto; import chatgroup.dto.ChatRoleInfoDto; import java.util.Map; // 虽然代码中没有直接使用Map变量,但它是getRoleMap()的返回类型,因此建议保留import // 示例:从 ChatGroupInfoDto 实例中根据角色名称获取 ChatRoleInfoDto // 该模式适用于需要从对象内部的集合中按特定标识符查找子对象的情况。 // 1. 准备一个包含数据的 ChatGroupInfoDto 实例 (用于确保可靠性) ChatGroupInfoDto chatGroupInfo = new ChatGroupInfoDto(); Map roleMap = chatGroupInfo.getRoleMap(); // 填充一些示例角色数据 ChatRoleInfoDto roleExample1 = new ChatRoleInfoDto() .setRoleName("ExampleUser") .setRolePrompt("这是用户角色的提示信息。"); roleMap.put(roleExample1.getRoleName(), roleExample1); ChatRoleInfoDto roleExample2 = new ChatRoleInfoDto() .setRoleName("ExampleAssistant") .setRolePrompt("这是助手角色的提示信息。"); roleMap.put(roleExample2.getRoleName(), roleExample2); // 2. 定义要查找的角色名称 String roleNameToRetrieve = "ExampleUser"; // 请替换为您希望查找的实际角色名称 // 3. 调用 ChatGroupInfoDto 的 getRoleInfoByName 方法 ChatRoleInfoDto retrievedRole = chatGroupInfo.getRoleInfoByName(roleNameToRetrieve); // 4. 处理获取到的结果 if (retrievedRole != null) { System.out.println("成功获取角色信息:"); System.out.println(" 角色名称: " + retrievedRole.getRoleName()); System.out.println(" 角色提示: " + retrievedRole.getRolePrompt()); } else { System.out.println("未找到名称为 '" + roleNameToRetrieve + "' 的角色。"); } ``` -------------------------------- ### Get Panel View Driver Instance in Java Source: https://github.com/ku-m/gpf-codebase/blob/main/findings/20250711_145607/gpf_dc_PanelCM_src_core_cell_octo_cm_panel_driver_PanelCM_ViewDriver.java.md This snippet demonstrates how to obtain an instance of a specific driver interface, such as `PanelCM_ViewDriver`, using a static `get()` method. This pattern is commonly used in frameworks to retrieve registered service or driver implementations without requiring external dependencies or complex setup. ```java // 获取面板视图驱动接口的实例 PanelCM_ViewDriver driver = PanelCM_ViewDriver.get(); ``` -------------------------------- ### Displaying a Pop-up Dialog with PopDialog.showInput Source: https://github.com/ku-m/gpf-codebase/blob/main/findings/20250711_145607/gpf_dc_pmc_src_core_fe_pmc_page_FactoryMountedUserTable.java.md This example demonstrates how to use the `PopDialog.showInput` static method to display a generic input dialog. It shows how to prepare the dialog title, wrap custom content (like a `TableDto`) into a `SinglePanelDto`, set preferred window size, and process the return value from the dialog, typically a `PanelValue` containing user selections or inputs. ```java import fe.cmn.panel.PanelContext; import fe.cmn.panel.PanelValue; import fe.cmn.panel.SinglePanelDto; import fe.cmn.panel.ability.PopDialog; import fe.cmn.table.TableDto; import fe.cmn.widget.WindowSizeDto; /** * Displays a pop-up dialog. * Demonstrates how to use PopDialog.showInput to pop up a dialog containing custom content and get its return value. */ public class PopDialogPattern { public void showCustomInputDialog(PanelContext context) { // 1. Prepare the dialog title String dialog_title = "此处填写您的对话框标题"; // 2. Prepare the dialog content (usually a subclass of PanelDto, such as SinglePanelDto) TableDto inner_content_dto = new TableDto(); // Assume the dialog displays a table internally inner_content_dto.setWidgetId("your_dialog_content_widget_id"); // Set ID for internal component to get value later SinglePanelDto content_panel = SinglePanelDto.wrap(inner_content_dto); // Can set preferred dialog size content_panel.setPreferSize(WindowSizeDto.all(0.8, 0.8)); // Width and height both occupy 80% of parent container // 3. Display the dialog and get the return value PanelValue panelValue = PopDialog.showInput(context, dialog_title, content_panel); // 4. Process the value returned by the dialog if (panelValue != null) { // Get the value selected or entered by the user in the dialog based on the previously set widgetId Object selected_value = panelValue.getValue("your_dialog_content_widget_id"); System.out.println("用户在对话框中选择的值: " + selected_value); // Further process selected_value, e.g., convert it to List etc. } else { System.out.println("用户取消了对话框操作。"); } } } ``` -------------------------------- ### Retrieve chatGroupCode Property from ChatGroupParam in Java Source: https://github.com/ku-m/gpf-codebase/blob/main/findings/20250711_145607/gpf_dc_orchestration_src_src_fe_chatgroup_component_param_ChatGroupParam.java.md Shows how to call the `getChatGroupCode` method to retrieve the value of the `chatGroupCode` property from a `ChatGroupParam` instance. This example demonstrates the API call pattern, even though it might retrieve a default value (typically null) in this specific setup, ensuring the operation is atomic and self-contained. ```java // 如何从 ChatGroupParam 实例中获取 chatGroupCode 属性 String retrievedChatGroupCode = new ChatGroupParam().getChatGroupCode(); // 注意:此样例将获取到默认值(通常是 null),但演示了API的调用模式 ``` -------------------------------- ### ApplicationSetting Java Class API Documentation Source: https://github.com/ku-m/gpf-codebase/blob/main/snippets/ApplicationSetting.md Comprehensive API documentation for the `ApplicationSetting` Java class, detailing its role as a global configuration container, its properties for various application settings (UI, permissions, internationalization, etc.), and its methods for accessing and dynamically generating runtime objects based on these configurations. ```APIDOC ApplicationSetting Class: public class ApplicationSetting implements Serializable - Description: 作为应用程序的全局配置容器,存储并管理所有与应用运行相关的参数和设置,并提供访问这些配置的接口。它允许应用通过配置进行高度定制,包括UI、流程、权限等。 Properties: serialVersionUID: static final long - Description: 序列化版本UID,用于确保序列化兼容性。 MENU_ADMIN_APP: static final String - Description: 管理后台应用的菜单常量标识。 uuid: String - Description: 应用的唯一标识符。 name: String - Description: 应用的名称。 label: String - Description: 应用的中文名称或显示名称。 navigatorLogo: byte[] - Description: 导航栏Logo的二进制数据。 loginLogo: byte[] - Description: 登录页Logo的二进制数据。 favicon: byte[] - Description: 网站图标(Favicon)的二进制数据。 loading: byte[] - Description: 首页加载图的二进制数据。 subjectStyle: SubjectStyle - Description: 应用的主题样式配置对象。 adminAppCode: String - Description: 管理后台的应用编号。 applicableTerminals: List - Description: 应用适用的终端列表(如“PC端”、“移动端”)。 adaptAppCode: String - Description: 适配应用名称。 userModelId: String - Description: 用户模型ID。 orgModelId: String - Description: 组织模型ID。 noticeModelId: String - Description: 通知模型ID。 sessionKey: String - Description: 会话键等核心系统配置ID。 homeViewModelId: String - Description: 首页视图的模型ID。 homeViewCode: String - Description: 首页视图的编码,用于动态加载。 roleBasedHomePageViews: List - Description: 基于角色的首页视图配置列表,支持不同角色用户显示不同首页。 loginViewModelId: String - Description: 登录视图的模型ID。 loginViewCode: String - Description: 登录视图的编码。 registViewModelId: String - Description: 注册视图的模型ID。 registViewCode: String - Description: 注册视图的编码。 registFormCreator: String - Description: 注册表单的创建者。 todoSettings: List - Description: 待办事项的配置列表。 showTodo: boolean - Description: 是否显示待办事项的开关。 privilegeSettings: List - Description: 权限设置列表。 loginVerifyFuncs: List - Description: 登录验证功能(动作)的配置列表。 actionDefines: List - Description: 应用程序中定义的动作列表,默认为空列表。 eventSubscribes: List - Description: 前端事件订阅配置列表,默认为空列表。 timerConfigs: List - Description: 定时器配置列表,默认为空列表。 guestAccount: String - Description: 访客账号(未认证时的默认账号)。 appViewSetting: AppViewSetting - Description: 应用扩展视图配置对象,默认为新实例。 parameters: List - Description: 应用通用配置参数列表,默认为空列表。 i18nResSettings: List - Description: 国际化资源配置列表,默认为空列表。 publishTime: Long - Description: 发布时间戳。 updateTime: Long - Description: 更新时间戳。 serviceAgreement: AttachData - Description: 服务协议附件数据。 Methods: getUuid(): String - Description: 获取应用的唯一标识符。 setUuid(String uuid): ApplicationSetting - Description: 设置应用的唯一标识符。Setter方法通常返回 this 实现链式调用(Fluent API)。 // ... (Other standard Getter/Setter methods for properties listed above) getHomeViewAction(): Action - Description: 根据 homeViewModelId 和 homeViewCode 动态获取首页对应的 Action 对象。涉及到数据库查询。 getRoleBasedHomePageViewAction(Set identifies): Action - Description: 根据用户身份(角色标识)匹配并获取相应的角色首页视图的 Action 对象。 getLoginViewAction(): Action - Description: 动态获取登录视图对应的 Action 对象。 getRegistViewAction(): Action - Description: 动态获取注册视图对应的 Action 对象。 getTodoSetting(String pdfUuid): TodoSetting - Description: 根据PDF UUID获取特定的待办事项设置。 getPDFFormTodoQuery(String user): UnionQuery - Description: 根据待办事项配置,为指定用户构建一个用于查询待办表单的联合查询对象。涉及字段映射和PDF定义查询。 getPDFFormProgressQuery(String user): UnionQuery - Description: 根据待办事项配置,为指定用户构建一个用于查询表单进度的联合查询对象。 isApplicablePC(): boolean - Description: 判断应用是否适用于PC端。 isApplicableMobile(): boolean - Description: 判断应用是否适用于移动端。 isAuthorizedAdminApp(Map menuPrivs): static boolean - Description: 静态方法,判断用户是否具有管理后台应用的访问权限,通过检查菜单权限映射。 getI18nResSettingMap(): Map - Description: 将国际化资源设置列表转换为以语言为键的Map,方便查找。 getActionDefineMap(): Map - Description: 将动作定义列表转换为以动作为名称的Map,方便查找。 ``` -------------------------------- ### Instantiate ChatGroupRoleChatPanel and Get WidgetDto Source: https://github.com/ku-m/gpf-codebase/blob/main/findings/20250711_145607/gpf_dc_orchestration_src_src_fe_chatgroup_component_ChatGroupPanel.java.md Demonstrates how to instantiate ChatGroupRoleChatPanel, set its parameters, and retrieve a renderable WidgetDto. This requires a PanelContext instance and an initialized ChatGroupRoleChatParam instance. ```java ChatGroupRoleChatPanel chatGroupRoleChatPanel = new ChatGroupRoleChatPanel<>(); chatGroupRoleChatPanel.setWidgetParam(chat_group_role_chat_param); WidgetDto roleChatWidget = chatGroupRoleChatPanel.getWidget(your_panel_context); ``` -------------------------------- ### Get Current Panel Context from View Action Parameters Source: https://github.com/ku-m/gpf-codebase/blob/main/findings/20250711_145607/gpf_dc_scgc_src_core_cell_scgc_action_formView_IFormViewQualityCertification.java.md This example demonstrates how to retrieve the current `PanelContext` from a view action's input parameters (`ViewActionParameter` or `BaseFeActionParameter`). It depends on `fe.cmn.panel.PanelContext` and `jit.param.view.action.ViewActionParameter` or `gpf.dc.basic.param.view.BaseFeActionParameter`. ```java import fe.cmn.panel.PanelContext; import jit.param.view.action.ViewActionParameter; // 或 gpf.dc.basic.param.view.BaseFeActionParameter // 模式:从视图动作参数中获取当前面板上下文 // 假设 'your_view_action_parameter_input' 是一个 ViewActionParameter 或 BaseFeActionParameter 实例 PanelContext currentPanelContext = your_view_action_parameter_input.getPanelContext(); ``` -------------------------------- ### Build and Load Style Tree via IStyleTreeIntf Source: https://github.com/ku-m/gpf-codebase/blob/main/findings/20250711_145607/gpf_dc_orchestration_src_src_cell_fe_orchestration_IOrchestrationChatPortalPanel.java.md Shows how to build and load an application style tree using the static method `IStyleTreeIntf.buildStyleTree`. This process is essential for dynamically applying UI styles based on a predefined style tree structure. It requires a `Context` instance to retrieve necessary information for building the style tree. ```java // 通过接口静态方法构建并加载应用样式树 AppStyleDto appStyleDto = IStyleTreeIntf.buildStyleTree(context); ``` -------------------------------- ### Apply Configuration to Object via Reflection (Java) Source: https://github.com/ku-m/gpf-codebase/blob/main/snippets/GpfDCBasicUtil.md This method uses reflection to apply configuration values from a list of key-value maps (`settingProps`) to the corresponding fields of a target object (`setting`). It iterates through the object's fields, finds matches based on the map keys, and sets the values dynamically. ```APIDOC T getSetting(T setting, List> settingProps) - Parameters: - setting: The target object to apply settings to. - settingProps: A list of maps, each containing "key" and "value" for configuration. - Returns: T (the modified setting object) - Description: Uses reflection to set field values of a target object from a list of key-value configuration maps. ``` -------------------------------- ### Get UI Widget from FactoryOrgMgrPanel Source: https://github.com/ku-m/gpf-codebase/blob/main/findings/20250711_145607/gpf_dc_pmc_src_core_cell_pmc_page_IFactoryOrgMgrView.java.md Demonstrates how to retrieve the final UI component, or 'widget', from a `FactoryOrgMgrPanel` instance. This operation requires a `PanelContext` instance to properly render or obtain the widget. ```Java import fe.cmn.panel.PanelContext; import fe.pmc.page.FactoryOrgMgrPanel; import gpf.dc.basic.fe.component.param.AppUserMgrParam; // 目的:展示如何从 FactoryOrgMgrPanel 实例中获取最终的UI组件(widget)。 // 前提:已有一个 FactoryOrgMgrPanel 实例和一个 PanelContext 实例。 // FactoryOrgMgrPanel yourOrgMgrPanel = new FactoryOrgMgrPanel<>(); // 假设已实例化 // PanelContext yourPanelContext = ...; // 假设已获得 PanelContext 实例 Object widget = yourOrgMgrPanel.getWidget(yourPanelContext); ``` -------------------------------- ### Instantiating SimpleJsonDataParam Object Source: https://github.com/ku-m/gpf-codebase/blob/main/findings/20250711_143110/gpf_rapidView_pmc_src_core_fe_rapidView_param_SimpleJsonDataParam.java.md This code example demonstrates the basic instantiation of a `SimpleJsonDataParam` object using its default constructor. It shows the fundamental way to create an instance of this data transfer object before populating its fields. ```Java SimpleJsonDataParam simpleJsonDataParam = new SimpleJsonDataParam(); ``` -------------------------------- ### Get Application Context with AppCacheUtil Source: https://github.com/ku-m/gpf-codebase/blob/main/findings/20250711_145607/gpf_dc_pmc_src_core_cell_pmc_page_IFactoryOrgMgrView.java.md Demonstrates how to retrieve the application context information using `AppCacheUtil.getAppContext`. This method requires a `PanelContext` instance as an input parameter to identify the relevant context. ```Java import fe.cmn.panel.PanelContext; import gpf.dc.basic.fe.component.app.AppCacheUtil; // 目的:展示如何通过 AppCacheUtil.getAppContext 方法获取应用上下文信息。 // 前提:需要一个 PanelContext 实例作为输入参数。 // PanelContext yourPanelContext = ...; // 假设此处已获得 PanelContext 实例 Object appContext = AppCacheUtil.getAppContext(yourPanelContext); ``` -------------------------------- ### Get Class Literal Source: https://github.com/ku-m/gpf-codebase/blob/main/findings/20250711_145607/gpf_dc_pmc_src_core_cell_pmc_page_IFactoryOrgMgrView.java.md Explains how to obtain the `Class` literal for a specific type, such as `AppUserMgrViewParameter.class`. This technique is frequently used in frameworks for runtime type reflection, dynamic instantiation, or parameter validation. ```Java import gpf.dc.basic.param.view.AppUserMgrViewParameter; // 目的:展示如何获取一个类的 Class 字面量,这在框架中常用于类型反射或参数校验。 Class inputParamClass = AppUserMgrViewParameter.class; ``` -------------------------------- ### PopupPanel Instance Methods Source: https://github.com/ku-m/gpf-codebase/blob/main/snippets/PopupPanel.md Defines core instance methods for `PopupPanel` objects, handling service retrieval, widget construction, and event listening for internal pop-up components. ```APIDOC public Class getService() - Description: Retrieves the service interface class associated with the current component. Defaults to `IFeCmnService` if not specified in parameters. public WidgetDto getWidget(PanelContext panelContext) - Description: Core method. Constructs and returns a `WidgetDto` representing the pop-up content based on `PopupPanelParam`. This method is responsible for assembling various parts of the pop-up, including the content panel and bottom action bar (if needed), and setting its dimensions and ID. public Object onListener(ListenerDto listener, PanelContext panelContext, WidgetDto source) - Description: Core method. Handles event listening for internal pop-up components. Specifically, when a user clicks the confirm button, it retrieves data from the internal panel, performs data validation, writes data to a memory object, writes the last operation command to `WIDGET_ID_LAST_COMMAND`, and triggers the pop-up exit logic. ``` -------------------------------- ### File and Dynamic Class Loading Utilities Source: https://github.com/ku-m/gpf-codebase/blob/main/snippets/GpfDCBasicFeUtil.md Provides essential utilities for reading file bytes and dynamically loading classes, crucial for resource handling and creating component instances at runtime. ```APIDOC com.leavay.common.util.Utils: getFileBytes(String filePath): byte[] - Reads all bytes from the file specified by the path. com.leavay.common.util.javac.ClassFactory: getValidClassLoader(): ClassLoader - Returns a valid class loader instance. loadClass(String className): Class - Dynamically loads a class by its fully qualified name using the class loader. - Usage: ClassFactory.getValidClassLoader().loadClass("com.example.MyClass") ```