net.java.truelicense.swing.nexes.WizardPanelDescriptor Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of truelicense-swing Show documentation
Show all versions of truelicense-swing Show documentation
The TrueLicense Swing module provides a graphical user interface for
consuming license keys.
/*
* Copyright (C) 2005-2013 Schlichtherle IT Services.
* All rights reserved. Use is subject to license terms.
*/
package net.java.truelicense.swing.nexes;
import javax.annotation.CheckForNull;
import javax.swing.JPanel;
import static net.java.truelicense.core.util.Objects.*;
/**
* A descriptor for a wizard panel.
*
* @author Robert Eckstein (original code)
* @author Christian Schlichtherle (revision)
*/
public class WizardPanelDescriptor {
/**
* Identifier returned by getNextPanelIdentifier() to indicate that this is
* the last panel and the text of the 'Next' button should change to
* 'Finish'.
*/
public static final String FINISH = "FINISH"; // NOI18N
private final String id;
private final JPanel panel;
private Wizard wizard;
/**
* Constructs a wizard panel descriptor.
*
* @param id the identifier.
* @param panel the panel.
*/
public WizardPanelDescriptor(final String id, final JPanel panel) {
this.id = requireNonNull(id);
this.panel = requireNonNull(panel);
}
/**
* Returns the unique identifier for this panel descriptor.
*/
public String getIdentifier() { return id; }
/**
* Returns the identifier of the panel that the user should traverse to
* if the Back button gets pressed.
* Return {@code null} if the button should get disabled.
*/
public @CheckForNull String getBackPanelIdentifier() { return null; }
/**
* Returns the identifier of the panel that the user should traverse to
* if the Next button gets pressed.
* Return {@code null} if the button should get disabled.
* Return {@link #FINISH} if the button text should change to 'Finish' and
* the dialog should end.
*/
public @CheckForNull String getNextPanelIdentifier() { return null; }
/**
* Returns to java.awt.Component that serves as the actual panel.
*
* @return A reference to the java.awt.Component that serves as the panel
*/
public JPanel getPanel() { return panel; }
void setWizard(final Wizard wizard) {
assert null != wizard;
this.wizard = wizard;
}
/**
* Returns the wizard.
*/
public Wizard getWizard() { return wizard; }
/**
* Returns the model of the wizard.
*/
public WizardModel getWizardModel() { return wizard.getModel(); }
/**
* Override this method to provide functionality that will get performed
* just before the panel is to be displayed.
*/
public void aboutToDisplayPanel() { }
/**
* Override this method to perform functionality when the panel itself is
* displayed.
*/
public void displayingPanel() { }
/**
* Override this method to perform functionality just before the panel is
* to be hidden.
*/
public void aboutToHidePanel() { }
}