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.

    ——————————————————————————————————
    傲轩游戏网
  • 相关阅读:
    Xpath语法
    Centos 6.5 本地局域网基于HTTP搭建YUM
    前端接口自动化测试工具-DOClever使用介绍(转载)
    mysql指令
    vue+element+echarts饼状图+可折叠列表
    vue+element+echarts柱状图+列表
    缓冲流
    查询同一张表符合条件的某些数据的id拼接成一个字段返回
    Properties集合
    JDK7&JDK9处理异常新特性
  • 原文地址:https://www.cnblogs.com/cuizhf/p/2234349.html
Copyright © 2011-2022 走看看