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>.
36 * the wizard page's name
38 public NewElementWizardPage(String name) {
41 fCurrStatus = new StatusInfo();
44 // ---- WizardPage ----------------
47 * @see WizardPage#becomesVisible
49 public void setVisible(boolean visible) {
50 super.setVisible(visible);
51 fPageVisible = visible;
52 // policy: wizards are not allowed to come up with an error message
53 if (visible && fCurrStatus.matches(IStatus.ERROR)) {
54 StatusInfo status = new StatusInfo();
55 status.setError(""); //$NON-NLS-1$
58 updateStatus(fCurrStatus);
62 * Updates the status line and the ok button according to the given status
67 protected void updateStatus(IStatus status) {
69 setPageComplete(!status.matches(IStatus.ERROR));
71 StatusUtil.applyToStatusLine(this, status);
76 * Updates the status line and the ok button according to the status
77 * evaluate from an array of status. The most severe error is taken. In case
78 * that two status with the same severity exists, the status with lower
84 protected void updateStatus(IStatus[] status) {
85 updateStatus(StatusUtil.getMostSevere(status));