View Javadoc
1   package com.github.sbugat.rundeckmonitor.wizard;
2   
3   import java.awt.Component;
4   
5   import com.github.sbugat.rundeckmonitor.configuration.RundeckMonitorConfiguration;
6   
7   /**
8    * Generic wizard panel with a next and previous step.
9    * 
10   * @author Sylvain bugat
11   * 
12   */
13  public abstract class WizardPanelDescriptor {
14  
15  	/** Panel identifier. */
16  	private final ConfigurationWizardStep panelIdentifier;
17  
18  	/** Previous panel or null. */
19  	private final ConfigurationWizardStep back;
20  
21  	/** Next panel or null. */
22  	private final ConfigurationWizardStep next;
23  
24  	/** RunDeck monitor configuration. */
25  	private final RundeckMonitorConfiguration rundeckMonitorConfiguration;
26  
27  	/**
28  	 * Copyr arguments to constants.
29  	 * 
30  	 * @param panelIdentifierArg panel identifier
31  	 * @param backArg previous panel or null if none
32  	 * @param nextArg next panel or null if none
33  	 * @param rundeckMonitorConfigurationArg RunDeck monitor configuration shared by all panels
34  	 */
35  	public WizardPanelDescriptor(final ConfigurationWizardStep panelIdentifierArg, final ConfigurationWizardStep backArg, final ConfigurationWizardStep nextArg, final RundeckMonitorConfiguration rundeckMonitorConfigurationArg) {
36  		panelIdentifier = panelIdentifierArg;
37  		back = backArg;
38  		next = nextArg;
39  		rundeckMonitorConfiguration = rundeckMonitorConfigurationArg;
40  	}
41  
42  	/**
43  	 * Get the main component of a panel.
44  	 * 
45  	 * @return the main component
46  	 */
47  	public abstract Component getPanelComponent();
48  
49  	/**
50  	 * Get the panel identifier.
51  	 * 
52  	 * @return the panel identifier
53  	 */
54  	public final ConfigurationWizardStep getPanelDescriptorIdentifier() {
55  		return panelIdentifier;
56  	}
57  
58  	/**
59  	 * Get the RunDeck monitor main configuration.
60  	 * 
61  	 * @return monitor configuration
62  	 */
63  	public final RundeckMonitorConfiguration getRundeckMonitorConfiguration() {
64  		return rundeckMonitorConfiguration;
65  	}
66  
67  	/**
68  	 * Return the next wizard panel or null.
69  	 * 
70  	 * @return next panel
71  	 */
72  	public final ConfigurationWizardStep getNext() {
73  		return next;
74  	}
75  
76  	/**
77  	 * Return the previous wizard panel or null.
78  	 * 
79  	 * @return previous panel
80  	 */
81  	public final ConfigurationWizardStep getBack() {
82  		return back;
83  	}
84  
85  	/**
86  	 * Method called before diplaying a panel for dynamic content update.
87  	 */
88  	public void aboutToDisplayPanel() {
89  		// Default: nothing to do
90  	}
91  
92  	/**
93  	 * Default method to validate the wizard step, must return true if input data are valid.
94  	 * 
95  	 * @return true if valid, false otherwise
96  	 */
97  	public abstract boolean validate();
98  }