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 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:

                                                                                                                                                                                                                

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.

转载于:https://www.cnblogs.com/cuizhf/archive/2011/11/03/2234349.html

你可能感兴趣的:(Pluggable JXTaskPane)