Notes on TaskFrames

From OpenJUMP Wiki
Jump to navigation Jump to search

I'm creating this wiki page as a place holder for some notes on TaskFrame objects. A TaskFrame is a JInternalFrame that is used to display the LayerNamePanel and LayerViewPanel to the user within the WorkbenchFrame.

For the time being this page just has some notes on the methods used to add and close TaskFrames. I hope to add more material as I become more familiar with the TaskFrame class and how it interacts with the rest of the OpenJUMP Core.

The Sunburned Surveyor

WorkbenchFrame.closeTaskFrame

Private method warns the user if there are layers with the task that have unmodified features. It also asks the user if they want to close other JInternalFrames that are open in the Workbench AND associated with the TaskFrame that is being closed. Calls the confirmClose methods defined in the WorkbenchFrame class. I think this method is currently the place where the closing of a task frame begins. (This is probably the method that is called when the user clicks on the close button of a TaskFrame. Should it be called by the TaskFrame class by triggering a callto the InternalFrameAdapter class associated with each TaskFrame?)

WorkbenchFrame.addInternalFrame

public method that allows a JInternalFrame to be added to the WorkbenchFrame. If the JInternalFrame being added is a LayerManagerProxy, as a TaskFrame is, then the WorkbenchFrame.setClosingBehavior method is called.

Workbench.addTaskFrame(Task argTask)

Uses a TaskFrameFactory to create a TaskFrame if a TaskFrameFactory exists. If a TaskFrameFactory does not exist, one of the TaskFrame constructors is called directly. The WorkBenchFrame.addTaskFrame(TaskFrame argTaskFrame) method is called.

Workbench.addTaskFrame(TaskFrame argFrame)

Calls the add internalFrame method.

Workbench.setClosingBehavior(LayerManagerProxy argProxy)

Adds an InternalFrameCloseHandler to the TaskFrame being added to the WorkbenchFrame. This is an internal class. The internal class is an InternalFrameAdapter that simply calls the InternalFrameCloseHandler.close method. The InternalFrameCloseHandler class whose clsoe method is called by the InternalFrameAdapter is whatever InternalFrameCloseHandler is set with the workbenchFrame.setInternalFrameCloseHandler method.

Proposed Changes For Customizable TaskFrames

(this is probably realized in BizzJUMP)

When questioning the purpose of the TaskFrame.setTask method I disovered that Paul Austin had enabled a system to allow for customized extensions of the TaskFrame class. Paul did this in an effort to test the InfoNode docking framework in OpenJUMP.

I am proposing some changes to the system that Paul implemented. It will eliminate the use of the setTask method, which I think could produce some bugs, and will allow TaskFrame extensions to be added via a plug-in.

Here is how it would work.

The Workbench.addTask method will be modified to accept a String identifying the TaskFrame type in addition to the Task beind displayed in the TaskFrame.

The Workbench.addTask method will create a TaskFrameFactory (a new class that extends org.openjump.swing.ComponentFactory) and will use it to create the type of TaskFrame identified by the String argument passed to the addTask method. It obtains the new TaskFrame by using the TaskFrameFactory.createComponent method.

The TaskFrameFactory method obtains a list of TaskFrame extensions from the Registry. It then loads the appropriate class based on the String argument passed to the addTask method and creates and instance from it. This is returned and added to the WorkbenchFrame.

A programmer can add support for a custom task by creating a plug-in that adds the TaskFrame extension class name to the Registry during initialization. This will make it available to the TaskFrameFactory.

All custom TaskFrame's will need to extend the TaskFrame class and implement the constructor that accepts a Task and a WorkbenchContext as its only arguments.

I am close to having this system implemented, and I will begin testing it soon.