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
9 * IBM Corporation - initial API and implementation
10 *******************************************************************************/
11 package net.sourceforge.phpdt.ui.wizards;
13 import net.sourceforge.phpdt.externaltools.internal.ui.StatusInfo;
14 import net.sourceforge.phpdt.internal.ui.dialogs.StatusUtil;
16 import org.eclipse.core.runtime.IStatus;
17 import org.eclipse.jface.wizard.WizardPage;
20 * Base class for wizard page responsible to create PHP elements. The class
21 * provides API to update the wizard's statis line and OK button according to
22 * the value of a <code>IStatus</code> object.
26 public abstract class NewElementWizardPage extends WizardPage {
28 private IStatus fCurrStatus;
30 private boolean fPageVisible;
33 * Creates a <code>NewElementWizardPage</code>.
35 * @param name the wizard page's name
37 public NewElementWizardPage(String name) {
40 fCurrStatus= new StatusInfo();
43 // ---- WizardPage ----------------
46 * @see WizardPage#becomesVisible
48 public void setVisible(boolean visible) {
49 super.setVisible(visible);
50 fPageVisible= visible;
51 // policy: wizards are not allowed to come up with an error message
52 if (visible && fCurrStatus.matches(IStatus.ERROR)) {
53 StatusInfo status= new StatusInfo();
54 status.setError(""); //$NON-NLS-1$
57 updateStatus(fCurrStatus);
61 * Updates the status line and the ok button according to the given status
63 * @param status status to apply
65 protected void updateStatus(IStatus status) {
67 setPageComplete(!status.matches(IStatus.ERROR));
69 StatusUtil.applyToStatusLine(this, status);
74 * Updates the status line and the ok button according to the status evaluate from
75 * an array of status. The most severe error is taken. In case that two status with
76 * the same severity exists, the status with lower index is taken.
78 * @param status the array of status
80 protected void updateStatus(IStatus[] status) {
81 updateStatus(StatusUtil.getMostSevere(status));