/*******************************************************************************
* Copyright (c) 2008 Pierre-Antoine Grégoire.
* 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:
* Pierre-Antoine Grégoire - initial API and implementation
*******************************************************************************/
package org.org.eclipse.core.utils.platform.tools;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.jface.dialogs.DialogPage;
import org.eclipse.jface.dialogs.IMessageProvider;
/**
* Toolbox for the purpose of workbench manipulations inside Eclipse PDE.
*
* @author pagregoire
*/
public final class DialogHelper {
private DialogHelper() {
}
/**
* Applies the status to the status line of a dialog page.
*/
public static void applyToStatusLine(DialogPage page, IStatus status) {
String message = status.getMessage();
if (message != null) {
switch (status.getSeverity()) {
case IStatus.OK:
page.setMessage(message, IMessageProvider.NONE);
page.setErrorMessage(null);
break;
case IStatus.WARNING:
page.setMessage(message, IMessageProvider.WARNING);
page.setErrorMessage(null);
break;
case IStatus.INFO:
page.setMessage(message, IMessageProvider.INFORMATION);
page.setErrorMessage(null);
break;
default:
if (message.length() == 0) {
message = null;
}
page.setMessage(message,IMessageProvider.ERROR);
page.setErrorMessage(null);
break;
}
}
}
}