Refactory: remove unused classes, imports, fields and methods.
[phpeclipse.git] / net.sourceforge.phpeclipse.ui / src / net / sourceforge / phpdt / ui / wizards / NewElementWizardPage.java
1 /*******************************************************************************
2  * Copyright (c) 2000, 2003 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials 
4  * are made available under the terms of the Common Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/cpl-v10.html
7  * 
8  * Contributors:
9  *     IBM Corporation - initial API and implementation
10  *******************************************************************************/
11 package net.sourceforge.phpdt.ui.wizards;
12
13 //incastrix
14 //import net.sourceforge.phpdt.externaltools.internal.ui.StatusInfo;
15 import net.sourceforge.phpeclipse.ui.StatusInfo;
16 import net.sourceforge.phpdt.internal.ui.dialogs.StatusUtil;
17
18 import org.eclipse.core.runtime.IStatus;
19 import org.eclipse.jface.wizard.WizardPage;
20
21 /**
22  * Base class for wizard page responsible to create PHP elements. The class
23  * provides API to update the wizard's statis line and OK button according to
24  * the value of a <code>IStatus</code> object.
25  * 
26  * @since 2.0
27  */
28 public abstract class NewElementWizardPage extends WizardPage {
29
30         private IStatus fCurrStatus;
31
32         private boolean fPageVisible;
33
34         /**
35          * Creates a <code>NewElementWizardPage</code>.
36          * 
37          * @param name
38          *            the wizard page's name
39          */
40         public NewElementWizardPage(String name) {
41                 super(name);
42                 fPageVisible = false;
43                 fCurrStatus = new StatusInfo();
44         }
45
46         // ---- WizardPage ----------------
47
48         /*
49          * @see WizardPage#becomesVisible
50          */
51         public void setVisible(boolean visible) {
52                 super.setVisible(visible);
53                 fPageVisible = visible;
54                 // policy: wizards are not allowed to come up with an error message
55                 if (visible && fCurrStatus.matches(IStatus.ERROR)) {
56                         StatusInfo status = new StatusInfo();
57                         status.setError(""); //$NON-NLS-1$
58                         fCurrStatus = status;
59                 }
60                 updateStatus(fCurrStatus);
61         }
62
63         /**
64          * Updates the status line and the ok button according to the given status
65          * 
66          * @param status
67          *            status to apply
68          */
69         protected void updateStatus(IStatus status) {
70                 fCurrStatus = status;
71                 setPageComplete(!status.matches(IStatus.ERROR));
72                 if (fPageVisible) {
73                         StatusUtil.applyToStatusLine(this, status);
74                 }
75         }
76
77         /**
78          * Updates the status line and the ok button according to the status
79          * evaluate from an array of status. The most severe error is taken. In case
80          * that two status with the same severity exists, the status with lower
81          * index is taken.
82          * 
83          * @param status
84          *            the array of status
85          */
86         protected void updateStatus(IStatus[] status) {
87                 updateStatus(StatusUtil.getMostSevere(status));
88         }
89
90 }