zoukankan      html  css  js  c++  java
  • Pluggable JXTaskPane

    http://blogs.oracle.com/geertjan/entry/pluggable_jxtaskpane

    ——————————————————————————————————————————————————————————————

    Pluggable JXTaskPane

    By Geertjan on May 21, 2010

    Some of the students on the recent NetBeans Platform Certified Training at the TU Braunschweig are creating an application in the medical domain. I was shown their application, which included a JXTaskPane from the SwingX project.

    Each task in the task pane represents a different department at the hospital. E.g., one task for "Anamnesis" and another task for "Radiology", each with their own labels, icons, and actions. So then, I stated, it would be completely logical for each task to be provided by a different module since each module could then more easily be created by different departments, the application could be created for different users, and the users themselves could potentially have a choice in the features available in their local distribution. Today I experimented with this scenario. And, as you can see, my medical application has one module that displays tasks, with supporting modules coming from each department in the hospital (currently two only for demo purposes):

    To the end user, there's no difference, of course, since the UI is the same regardless of whether the application is modular or not:

    In the TaskDisplayer module, I have a TopComponent with the following added to the constructor:

    //Read the "tasks" folder in the layer file via the NetBeans Filesystems API: FileObject tasksFolder = FileUtil.getConfigFile("tasks"); //Get all the children, which represent tasks: FileObject[] tasks = tasksFolder.getChildren();  //Create a JXTaskPaneContainer: JXTaskPaneContainer taskpanecontainer = new JXTaskPaneContainer();  //Create the JXPanel: JXPanel panel = new JXPanel(); panel.setLayout(new BorderLayout());  //Iterate through the tasks in the order //specified by the "position" attribute: for (FileObject task : FileUtil.getOrder(Arrays.asList(tasks), true)) {      String name = task.getName();     String room = task.getAttribute("location").toString();      //Create a new JXTaskPane     //for each task:     JXTaskPane taskpane = new JXTaskPane();     taskpane.setTitle(name + " (" + room + ")");      //Add Actions registered in the layer:     List<? extends Action> actions = Utilities.actionsForPath("Actions/" + name);     for (Action action : actions) {         taskpane.add(action);     }      //Add the JXTaskPane to the JXTaskPaneContainer:     taskpanecontainer.add(taskpane);  }  //Add the JXTaskPaneContainer to the JXTaskPanel: panel.setAlpha(0.7f); panel.add(taskpanecontainer, BorderLayout.CENTER); panel.setPreferredSize(new Dimension(250, 200));  //Add the JXTaskPanel to the TopComponent: add(panel, BorderLayout.CENTER);

    And then, in each module for the departments, I have content like this in the layer file, which is what is read by the code above:

    <folder name="tasks">     <folder name="Radiology">         <attr name="location" stringvalue="Sector 3B"/>         <attr name="position" intvalue="200"/>     </folder> </folder>  <folder name="Actions">     <folder name="Radiology">         <file name="org-medical-task-radiology-AnalyzeAction.instance">             <attr name="delegate" newvalue="org.medical.task.radiology.AnalyzeAction"/>             <attr name="displayName" bundlevalue="org.medical.task.radiology.Bundle#CTL_AnalyzeAction"/>             <attr name="instanceCreate" methodvalue="org.openide.awt.Actions.alwaysEnabled"/>             <attr name="noIconInMenu" boolvalue="false"/>             <attr name="position" intvalue="200"/>         </file>         <file name="org-medical-task-radiology-ScanAction.instance">             <attr name="delegate" newvalue="org.medical.task.radiology.ScanAction"/>             <attr name="displayName" bundlevalue="org.medical.task.radiology.Bundle#CTL_ScanAction"/>             <attr name="instanceCreate" methodvalue="org.openide.awt.Actions.alwaysEnabled"/>             <attr name="noIconInMenu" boolvalue="false"/>             <attr name="position" intvalue="100"/>         </file>     </folder> </folder>

    Finally, it would even be possible to make supplemental tasks available depending on the actions selected in the tasks above. I.e., the "Radiology" task would only be added once "Assess Symptoms" has been completed in the "Anamnesis" task. To really optimize performance, you could load a module on demand, i.e., only load the "Radiology" module at the time that that module becomes relevant.

    And, to make the solution even better, each task could be created from a Node, meaning that each task would then have its own context (i.e., its own Lookup), so that it could be context sensitive, i.e, depending on the current patient (a Patient POJO in the Lookup), different capabilities could be made available.

    In other news. For more on NetBeans Platform in the medical domain, read Interview: NetBeans Platform Helps Advance Biomechanics Research, which was published today.

    ——————————————————————————————————
    傲轩游戏网
  • 相关阅读:
    mybatis3.0-[topic10-14] -全局配置文件_plugins插件简介/ typeHandlers_类型处理器简介 /enviroments_运行环境 /多数据库支持/mappers_sql映射注册
    _MyBatis3-topic06.07.08.09_ 全局配置文件_引入dtd约束(xml提示)/ 引入properties引用/ 配置驼峰命名自动匹配 /typeAliases起别名.批量起别名
    MyBatis3-topic04,05 -接口式编程
    JDBC终章- 使用 DBUtils实现增删查改- C3P0Utils数据源/QueryRunner runner连接数据源并执行sql
    [课本10.1.4]JDBC数据库连接池- C3P0数据源--通过构造方法创建数据源对象--通过配置文件创建数据源对象[推荐]
    JDBC课程5--利用反射及JDBC元数据(ResultSetMetaData)编写通用的查询方法
    JDBC课程4--使用PreparedStatement进行增删查改--封装进JDBCTools的功能中;模拟SQL注入 ; sql的date()传入参数值格式!
    本周进度总结
    本周进度总结
    大道至简读后感
  • 原文地址:https://www.cnblogs.com/cuizhf/p/2234349.html
Copyright © 2011-2022 走看看