All,

Here is a HOWTO for creating a new Open Wizard, excluding a File Layer 
which uses the Open File plug-in mechanism.

1. Define your wizard class to implement 
org.openjump.core.ui.swing.wizard.WizardGroup or extend 
org.openjump.core.ui.swing.wizard.AbstractWizardGroup. For the 
AbstractWizard group there are 3 arguments, the display name and icon to 
display in the Open Wizard and the last is the ID of the first wizard panel.

public class WFSWizard extends AbstractWizardGroup {
  private static final String KEY = WFSWizard.class.getName();

  public WFSWizard() {
    super(I18N.get(KEY), IconLoader.icon("wfs.gif"), 
WfsWizardPanel.getClass().getName());
  }
    :
}


2. Implement the initialize method on your wizard to create the panels 
for each time the wizard is shown. The reason you don't do this in the 
constructor is that the information you need may not be initialized when 
you construct the wizard.

  private ChooseProjectPanel chooseProjectPanel;

  public void initialize(WorkbenchContext workbenchContext, WizardDialog 
dialog) {
    removeAllPanels(); // Start from a clean slate

    // The chooseProject panel ensures that there is an open project to open 
the file into
    chooseProjectPanel = new ChooseProjectPanel(workbenchContext,
      urlPanel.getID());
    addPanel(chooseProjectPanel);
    
    // Add the wizard panels for your type of data
    addPanel(new WfsWizardPanel();
  }


3. Implement the method getFirstId to return the ID of the first wizard 
panel, if the first panel is always the same then this method is not 
required in the AbstractWizardGroup because you passed in the value in 
the constructor. If using the ChoosePeojectPanel you'll need to 
implement it using the following approach.

  public String getFirstId() {
    String firstId = super.getFirstId();
    if (!chooseProjectPanel.hasActiveTaskFrame()
      && chooseProjectPanel.hasTaskFrames()) {
      chooseProjectPanel.setNextID(firstId);
      return chooseProjectPanel.getID();
    } else {
      return firstId;
    }
  }

4. Implement the run method to actually do the loading of the data, this 
method is run in a separate thread so as not to block the GUI thread, so 
follow the standard Swing Threading rules (see SwingUtilities.invokeLater())

  public void run(WizardDialog dialog, TaskMonitor monitor) {
    chooseProjectPanel.activateSelectedProject();
    // Do the code for your plugin
  }

5. Register your wizard

    WfsWizard wfsWizard = new WfsWizard();
    OpenWizardPlugIn.addWizard(workbenchContext, wfsWizard);




-------------------------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc.
Still grepping through log files to find problems?  Stop.
Now Search log events and configuration files using AJAX and a browser.
Download your FREE copy of Splunk now >> http://get.splunk.com/
_______________________________________________
Jump-pilot-devel mailing list
Jump-pilot-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jump-pilot-devel

Reply via email to