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);
Showing changes from revision #0 to #1:
Added | Removed
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
implement org.openjump.core.ui.swing.wizard.WizardGroup or extend
org.openjump.core.ui.swing.wizard.AbstractWizardGroup. extend org.openjump.core.ui.swing.wizard.AbstractWizardGroup.
For the
the AbstractWizard group there are 3 arguments, the display name and icon to
to display in the Open Wizard and the last is the ID of the first wizard panel.
public class WFSWizard WFSWizard extends AbstractWizardGroup {
{
private static final String KEY = WFSWizard.class.getName();
WFSWizard.class.getName();
public WFSWizard() {
super(I18N.get(KEY), IconLoader.icon(“wfs.gif”), WfsWizardPanel.getClass().getName());
WFSWizard() {
super(
I18N.get(KEY),
IconLoader.icon("wfs.gif"),
WfsWizardPanel.getClass().getName()
);
}
}
}
2. Implement the initialize method on your wizard to create the panels
panels for each time the wizard is shown. The reason you don’t do this in the
the constructor is that the information you need may not be initialized when
when you construct the wizard.
private ChooseProjectPanel chooseProjectPanel;
chooseProjectPanel;
public void initialize(WorkbenchContext workbenchContext, WizardDialog dialog) {
{
removeAllPanels(); // Start from a clean slate
slate
// The chooseProject panel ensures that there is an open project to open the file into
into
chooseProjectPanel = new ChooseProjectPanel(workbenchContext,
urlPanel.getID());
addPanel(chooseProjectPanel);
ChooseProjectPanel(workbenchContext, urlPanel.getID());
addPanel(chooseProjectPanel);
// Add the wizard panels for your type of data
data
addPanel(new WfsWizardPanel();
WfsWizardPanel();
}
3. Implement the method getFirstId to return the ID of the first wizard
wizard panel, if the first panel is always the same then this method is not
not required in the AbstractWizardGroup because you passed in the value in
in the constructor. If using the ChoosePeojectPanel you’ll need to
implement it using the following approach.
public String getFirstId() {
{
String firstId = super.getFirstId();
super.getFirstId();
if (!chooseProjectPanel.hasActiveTaskFrame()
(!chooseProjectPanel.hasActiveTaskFrame() && chooseProjectPanel.hasTaskFrames()) {
chooseProjectPanel.setNextID(firstId);
{
chooseProjectPanel.setNextID(firstId);
return chooseProjectPanel.getID();
chooseProjectPanel.getID();
} else {
{
return firstId;
firstId;
}
}
}
4. Implement the run method to actually do the loading of the data, this
this method is run in a separate thread so as not to block the GUI thread, so
so follow the standard Swing Threading rules (see SwingUtilities.invokeLater())
public void run(WizardDialog dialog, TaskMonitor monitor) {
chooseProjectPanel.activateSelectedProject();
{
chooseProjectPanel.activateSelectedProject();
// Do the code for your plugin
plugin
}
5. Register your wizard
WfsWizard wfsWizard = new WfsWizard();
WfsWizard();
OpenWizardPlugIn.addWizard(workbenchContext, wfsWizard);