blob: f50e91f139d243f449deca1db6cb0520468c7fe1 [file] [log] [blame]
//------------------------------------------------------------------------------
// Copyright (c) 2005, 2007 IBM Corporation 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:
// IBM Corporation - initial implementation
//------------------------------------------------------------------------------
package org.eclipse.epf.common.ui;
import java.util.HashMap;
import java.util.Map;
import org.eclipse.epf.common.AbstractActivator;
import org.eclipse.epf.common.ui.util.MsgDialog;
import org.eclipse.swt.widgets.Display;
/**
* The abstract base class for all EPF plug-ins.
*
* @author Kelvin Low
* @author Jinhua Xi
* @since 1.0
*/
public abstract class AbstractPlugin extends AbstractActivator {
// The message dialog hash map.
private static Map<String, MsgDialog> msgDialogs = new HashMap<String, MsgDialog>();
/**
* Default constructor.
*/
public AbstractPlugin() {
super();
}
/**
* Returns the message dialog given the plug-in ID.
*
* @return The new or cached message dialog.
*/
public MsgDialog getMsgDialog(AbstractActivator plugin) {
MsgDialog msgDialog = (MsgDialog) msgDialogs.get(plugin.getId());
if (msgDialog == null) {
msgDialog = new MsgDialog(plugin, getWorkbench().getDisplay().getActiveShell());
msgDialogs.put(plugin.getId(), msgDialog);
}
return msgDialog;
}
public MsgDialog getMsgDialog() {
MsgDialog msgDialog = (MsgDialog) msgDialogs.get(getId());
if (msgDialog == null) {
msgDialog = new MsgDialog(this);
msgDialogs.put(getId(), msgDialog);
}
return msgDialog;
}
/**
* Returns the standard display to be used. The method first checks, if the
* thread calling this method has an associated disaply. If so, this display
* is returned. Otherwise the method returns the default display.
*/
public static Display getStandardDisplay() {
Display display;
display = Display.getCurrent();
if (display == null)
display = Display.getDefault();
return display;
}
}