Skip to main content
summaryrefslogtreecommitdiffstats
blob: 8a0bc79497144944e6f7dc3c2bf8c101f2870e48 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
/*******************************************************************************
 * Copyright (c) 2005, 2006 Texas Instruments Incorporated and others.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 * 
 * Contributors:
 *     Texas Instruments - initial API and implementation
 *     IBM Corporation
 *******************************************************************************/

package org.eclipse.cdt.managedbuilder.ui.wizards;

import org.eclipse.jface.wizard.IWizard;
import org.eclipse.jface.wizard.IWizardPage;

/**
 * This abstract class provides a convenient, partial implementation of the IWizardPage interface.
 * This class consults with the MBSCustomPageManager to determine its actions.
 
 * If an ISV’s custom pages do not subclass MBSCustomPage then their page implementation must be
 * carefully coded to function properly while still respecting the rules laid out by the page manager.
 */
public abstract class MBSCustomPage implements IWizardPage
{

	protected String pageID = null;
	protected IWizard wizard = null;
	
	/**
	 * Preferred constructor which sets the (required) pageID
	 * @param pageID identifies this page including for accessing the page data.
	 */
	public MBSCustomPage(String pageID) {
		this.pageID=pageID;
	}
	
	/**
	 * Default constructor is not recommended; pageID must be set
	 * so the other constructor, with pageID parameter, is preferred.
	 * 
	 * @deprecated
	 *
	 */
	public MBSCustomPage() {
	}
	
	/* (non-Javadoc)
	 * @see org.eclipse.jface.wizard.IWizardPage#isCustomPageComplete()
	 */
	public boolean canFlipToNextPage() {
		return (getNextPage() != null && isCustomPageComplete());
		
	}
	
	/* (non-Javadoc)
	 * @see org.eclipse.jface.wizard.IWizardPage#getWizard()
	 */
	public IWizard getWizard()
	{
		return wizard;
	}

	/* (non-Javadoc)
	 * @see org.eclipse.jface.wizard.IWizardPage#setPreviousPage
	 */
	public void setPreviousPage(IWizardPage page)
	{
		// do nothing, we use the page manager

	}

	/* (non-Javadoc)
	 * @see org.eclipse.jface.wizard.IWizardPage#setWizard()
	 */
	public void setWizard(IWizard newWizard)
	{
		wizard = newWizard;

	}
	
	/* (non-Javadoc)
	 * @see org.eclipse.jface.wizard.IWizardPage#getNextPage()
	 */
	public IWizardPage getNextPage()
	{
		// consult with the page manager to determine which pages are to be displayed
		return MBSCustomPageManager.getNextPage(pageID);
	}

	/* (non-Javadoc)
	 * @see org.eclipse.jface.wizard.IWizardPage#getPreviousPage()
	 */
	public IWizardPage getPreviousPage()
	{
		// consult with the page manager to determine which pages are to be displayed
		return MBSCustomPageManager.getPreviousPage(pageID);
	}

	
	
	/* (non-Javadoc)
	 * @see org.eclipse.jface.wizard.IWizardPage#isPageComplete()
	 */
	public boolean isPageComplete()
	{
		/* Since the wizard must have all the pages added to it regardless of whether they are visible
		 * or not, this method consults the page manager to see if the page is visible.  If it is not,
		 * then the page is always considered complete.  If the page is visible then the child class is
		 * consulted to see if it determines the page to be complete based on its own criteria.  
		*/
		
		// if we are not visible then return true so that the wizard can enable the Finish button
		if (!MBSCustomPageManager.isPageVisible(pageID))
		{
			return true;
		}

		return isCustomPageComplete();
	}

	/**
	 * @return The unique ID by which this page is referred.
	 */
	public String getPageID()
	{
		return pageID;
	}

	/**
	 * @return true if the page is complete, false otherwise.  This method is called to determine
	 * the status of the wizard's Finish button.
	 * 
	 * @see org.eclipse.jface.wizard.IWizardPage#isPageComplete()
	 */
	protected abstract boolean isCustomPageComplete();
}

Back to the top