import eu.etaxonomy.taxeditor.store.internal.TaxeditorStorePlugin;
/**
+ * <p>Abstract AbstractUtility class.</p>
+ *
* @author n.hoffmann
* @created 11.05.2009
* @version 1.0
*/
public abstract class AbstractUtility {
+ /** Constant <code>statusLineManager</code> */
protected static IStatusLineManager statusLineManager;
/**
- * @return
+ * <p>getShell</p>
+ *
+ * @return a {@link org.eclipse.swt.widgets.Shell} object.
*/
public static Shell getShell() {
.getActiveWorkbenchWindow().getShell();
}
+ /**
+ * <p>getActivePage</p>
+ *
+ * @return a {@link org.eclipse.ui.IWorkbenchPage} object.
+ */
public static IWorkbenchPage getActivePage(){
return TaxeditorStorePlugin.getDefault().getWorkbench()
.getActiveWorkbenchWindow().getActivePage();
}
+ /**
+ * <p>getActivePart</p>
+ *
+ * @return a {@link org.eclipse.ui.IWorkbenchPart} object.
+ */
public static IWorkbenchPart getActivePart(){
return getActivePage() != null ? getActivePage().getActivePart() : null;
}
+ /**
+ * <p>getWorkbenchWindow</p>
+ *
+ * @return a {@link org.eclipse.jface.window.ApplicationWindow} object.
+ */
public static ApplicationWindow getWorkbenchWindow(){
if(TaxeditorStorePlugin.getDefault().getWorkbench().getWorkbenchWindowCount() > 1){
throw new IllegalStateException("More than one workbench window");
return (ApplicationWindow) TaxeditorStorePlugin.getDefault().getWorkbench().getWorkbenchWindows()[0];
}
+ /**
+ * <p>showView</p>
+ *
+ * @param id a {@link java.lang.String} object.
+ * @return a {@link org.eclipse.ui.IViewPart} object.
+ */
public static IViewPart showView(String id){
try {
return PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().showView(id);
}
}
+ /**
+ * <p>hideView</p>
+ *
+ * @param view a {@link org.eclipse.ui.IViewPart} object.
+ */
public static void hideView(IViewPart view){
PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().hideView(view);
}
+ /**
+ * <p>getView</p>
+ *
+ * @param id a {@link java.lang.String} object.
+ * @param restore a boolean.
+ * @return a {@link org.eclipse.ui.IViewPart} object.
+ */
public static IViewPart getView(String id, boolean restore){
IViewReference[] references = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getViewReferences();
for (IViewReference reference : references){
return null;
}
+ /**
+ * <p>closeAll</p>
+ *
+ * @return a boolean.
+ */
public static boolean closeAll() {
return getActivePage().closeAllEditors(true);
}
/**
- *
- * @param api
- * @return
+ * <p>getService</p>
+ *
+ * @param api a {@link java.lang.Class} object.
+ * @return a {@link java.lang.Object} object.
*/
public static Object getService(Class api){
return TaxeditorStorePlugin.getDefault().getWorkbench().getService(api);
}
+ /**
+ * <p>getCurrentTheme</p>
+ *
+ * @return a {@link org.eclipse.ui.themes.ITheme} object.
+ */
public static ITheme getCurrentTheme(){
IThemeManager themeManager = TaxeditorStorePlugin.getDefault().getWorkbench().getThemeManager();
return themeManager.getCurrentTheme();
/**
* Fonts registered to the plugin may be obtained with the Eclipse themeing functionality.
* Thus fonts are chooseable by the user via Preferences->General->Appearance->Colors and Fonts
- *
+ *
* @return the FontRegistry for the current theme
*/
public static FontRegistry getFontRegistry(){
return getCurrentTheme().getFontRegistry();
}
+ /**
+ * <p>getFont</p>
+ *
+ * @param symbolicName a {@link java.lang.String} object.
+ * @return a {@link org.eclipse.swt.graphics.Font} object.
+ */
public static Font getFont(String symbolicName){
return getFontRegistry().get(symbolicName);
}
/**
* Color registered to the plugin may be obtained with the Eclipse themeing functionality.
* Thus colors are editable by the user via Preferences->General->Appearance->Colors and Fonts
- *
+ *
* @return the ColorRegistry for the current theme
*/
public static ColorRegistry getColorRegistry(){
}
/**
- *
- * @param symbolicName
- * @return
+ * <p>getColor</p>
+ *
+ * @param symbolicName a {@link java.lang.String} object.
+ * @return a {@link org.eclipse.swt.graphics.Color} object.
*/
public static Color getColor(String symbolicName){
return getColorRegistry().get(symbolicName);
/**
* Open a message box that informs the user about unimplemented functionality.
* This method is for developer convenience.
+ *
+ * @param source a {@link java.lang.Object} object.
*/
public static void notImplementedMessage(Object source){
warningDialog("Not yet implemented", source, "This functionality is not yet implemented.");
}
+ /**
+ * <p>informationDialog</p>
+ *
+ * @param title a {@link java.lang.String} object.
+ * @param message a {@link java.lang.String} object.
+ */
public static void informationDialog(final String title, final String message){
Display.getDefault().asyncExec(new Runnable(){
}
/**
- *
+ * <p>warningDialog</p>
+ *
* @param title The dialogs title
* @param source The object where the warning was generated (used by log4j)
* @param message An informative String to be presented to the user
}
/**
- *
+ * <p>errorDialog</p>
+ *
* @param title The dialogs title
* @param source The object where the warning was generated (used by log4j)
* @param message An informative String to be presented to the user
+ * @param title The dialogs title
* @param t a Throwable if one exists or null
*/
public static void errorDialog(final String title, final Object source, final String message, final Throwable t){
});
}
+ /**
+ * <p>errorDialog</p>
+ *
+ * @param title a {@link java.lang.String} object.
+ * @param source a {@link java.lang.Object} object.
+ * @param status a {@link org.eclipse.core.runtime.IStatus} object.
+ */
public static void errorDialog(final String title, final Object source, final IStatus status){
}
+ /**
+ * <p>confirmDialog</p>
+ *
+ * @param title a {@link java.lang.String} object.
+ * @param message a {@link java.lang.String} object.
+ * @return a boolean.
+ */
public static boolean confirmDialog(String title, String message) {
return MessageDialog.openQuestion(getShell(), title, message);
}
+ /**
+ * <p>executeOperation</p>
+ *
+ * @param operation a {@link eu.etaxonomy.taxeditor.operations.AbstractPostOperation} object.
+ * @return a {@link org.eclipse.core.runtime.IStatus} object.
+ */
public static IStatus executeOperation(final AbstractPostOperation operation){
if(getOperationHistory() == null){
throw new IllegalArgumentException("There is no operation history for this context");
return Status.OK_STATUS;
}
+ /**
+ * <p>getOperationHistory</p>
+ *
+ * @return a {@link org.eclipse.core.commands.operations.IOperationHistory} object.
+ */
public static IOperationHistory getOperationHistory(){
return TaxeditorStorePlugin.getDefault().getWorkbench().
getOperationSupport().getOperationHistory();
}
+ /**
+ * <p>setStatusLine</p>
+ *
+ * @param message a {@link java.lang.String} object.
+ */
public static void setStatusLine(final String message) {
Display.getDefault().asyncExec(new Runnable(){
}
+ /**
+ * <p>getMonitor</p>
+ *
+ * @return a {@link org.eclipse.core.runtime.IProgressMonitor} object.
+ */
public static IProgressMonitor getMonitor() {
statusLineManager.setCancelEnabled(false);
return statusLineManager.getProgressMonitor();
}
- /**
- * Starts either the given {@link IProgressMonitor} if it's not <code>null</code> or a new {@link NullProgressMonitor}.
- *
- * @param progressMonitor The {@link IProgressMonitor} or <code>null</code> if no progress should be reported.
- * @param taskName The name of the main task.
- * @param steps The number of steps this task is subdivided into.
- * @return The {@link IProgressMonitor}.
- */
+ /**
+ * Starts either the given {@link IProgressMonitor} if it's not <code>null</code> or a new {@link NullProgressMonitor}.
+ *
+ * @param progressMonitor The {@link IProgressMonitor} or <code>null</code> if no progress should be reported.
+ * @param taskName The name of the main task.
+ * @param steps The number of steps this task is subdivided into.
+ * @return The {@link IProgressMonitor}.
+ */
public static IProgressMonitor startMainMonitor(IProgressMonitor progressMonitor, String taskName, int steps) {
IProgressMonitor newMonitor = progressMonitor;
if (newMonitor == null) {
/**
* Creates a {@link SubProgressMonitor} if the given {@link IProgressMonitor} is not <code>null</code> and not a {@link NullProgressMonitor}.
- * @param progressMonitor The parent {@link IProgressMonitor} of the {@link SubProgressMonitor} to be created.
+ *
+ * @param progressMonitor The parent {@link IProgressMonitor} of the {@link SubProgressMonitor} to be created.
* @param ticks The number of steps this subtask is subdivided into. Must be a positive number and must not be {@link IProgressMonitor#UNKNOWN}.
* @return The {@link IProgressMonitor}.
*/
/**
* Checks whether the user canceled this operation. If not canceled, the given number of steps are declared as done.
- * @param newMonitor
- * @return
+ *
+ * @param newMonitor a {@link org.eclipse.core.runtime.IProgressMonitor} object.
+ * @param steps a int.
*/
public static void workedChecked(IProgressMonitor newMonitor, int steps) {
// In case the progress monitor was canceled throw an exception.
/**
* Present a progress dialog to the user. This dialog will block the UI
- *
+ *
* @param runnable an implementation of {@link IRunnableWithProgress}
- * @throws InterruptedException
- * @throws InvocationTargetException
+ * @throws java.lang.InterruptedException if any.
+ * @throws java.lang.reflect.InvocationTargetException if any.
*/
public static void busyCursorWhile(IRunnableWithProgress runnable) throws InvocationTargetException, InterruptedException{
getProgressService().busyCursorWhile(runnable);
}
/**
- *
+ * <p>runInUI</p>
+ *
* @see {@link IProgressService#runInUI(org.eclipse.jface.operation.IRunnableContext, IRunnableWithProgress, ISchedulingRule)}
- *
- * @param runnable
- * @param rule
- * @throws InvocationTargetException
- * @throws InterruptedException
+ * @param runnable a {@link org.eclipse.jface.operation.IRunnableWithProgress} object.
+ * @param rule a {@link org.eclipse.core.runtime.jobs.ISchedulingRule} object.
+ * @throws java.lang.reflect.InvocationTargetException if any.
+ * @throws java.lang.InterruptedException if any.
*/
public static void runInUI(IRunnableWithProgress runnable, ISchedulingRule rule) throws InvocationTargetException, InterruptedException{
getProgressService().runInUI(getWorkbenchWindow(), runnable, rule);
}
/**
- *
- * @param fork
- * @param cancelable
- * @param runnable
- * @throws InvocationTargetException
- * @throws InterruptedException
+ * <p>run</p>
+ *
+ * @param fork a boolean.
+ * @param cancelable a boolean.
+ * @param runnable a {@link org.eclipse.jface.operation.IRunnableWithProgress} object.
+ * @throws java.lang.reflect.InvocationTargetException if any.
+ * @throws java.lang.InterruptedException if any.
*/
public static void run(boolean fork, boolean cancelable, IRunnableWithProgress runnable) throws InvocationTargetException, InterruptedException{
getProgressService().run(fork, cancelable, runnable);
}
/**
- *
- * @return
+ * <p>getProgressService</p>
+ *
+ * @return a {@link org.eclipse.ui.progress.IProgressService} object.
*/
public static IProgressService getProgressService(){
IWorkbench workbench = PlatformUI.getWorkbench();
}
/**
- *
- * @return
+ * <p>getProgressService2</p>
+ *
+ * @return a {@link org.eclipse.ui.progress.IWorkbenchSiteProgressService} object.
*/
public static IWorkbenchSiteProgressService getProgressService2(){
return (IWorkbenchSiteProgressService) getService(IWorkbenchSiteProgressService.class);
}
/**
- *
- * @param source
- * @param message
+ * <p>info</p>
+ *
+ * @param message a {@link java.lang.String} object.
*/
public static void info(String message){
IStatus status = new Status(IStatus.INFO, getPluginId(), message);
}
/**
- *
- * @param source
- * @param status
+ * <p>info</p>
+ *
+ * @param status a {@link org.eclipse.core.runtime.IStatus} object.
*/
public static void info(IStatus status){
log(status);
}
/**
- *
- * @param source
- * @param message
+ * <p>warn</p>
+ *
+ * @param source a {@link java.lang.Class} object.
+ * @param message a {@link java.lang.String} object.
*/
public static void warn(Class source, String message){
IStatus status = new Status(IStatus.WARNING, getPluginId(), message);
}
/**
- *
- * @param source
- * @param t
+ * <p>error</p>
+ *
+ * @param source a {@link java.lang.Class} object.
+ * @param t a {@link java.lang.Throwable} object.
*/
public static void error(Class source, Throwable t){
error(source.getClass(), t.getMessage(), t);
}
/**
- *
- * @param source
- * @param message
- * @param t
+ * <p>error</p>
+ *
+ * @param source a {@link java.lang.Class} object.
+ * @param message a {@link java.lang.String} object.
+ * @param t a {@link java.lang.Throwable} object.
*/
public static void error(Class source, String message, Throwable t){
IStatus status = new Status(IStatus.ERROR, getPluginId(), message, t);
error(source, status);
}
+ /**
+ * <p>error</p>
+ *
+ * @param source a {@link java.lang.Class} object.
+ * @param status a {@link org.eclipse.core.runtime.IStatus} object.
+ */
public static void error(Class source, IStatus status){
getLog4JLogger(source).error(status.getMessage(), status.getException());
log(status);
/**
- * @param class1
- * @return
+ * <p>getLog4JLogger</p>
+ *
+ * @param clazz a {@link java.lang.Class} object.
+ * @return a {@link org.apache.log4j.Logger} object.
*/
public static Logger getLog4JLogger(
Class clazz) {
TaxeditorStorePlugin.getDefault().getLog().log(status);
}
+ /**
+ * <p>getPluginId</p>
+ *
+ * @return a {@link java.lang.String} object.
+ */
protected static String getPluginId(){
return "eu.taxeditor";
}