Permalink
Browse files

implemented @SilentNotification

This makes it possible with just an a manager method annotation to make any BioclipseUIJobs to be run not when the job i done but after the job is done and the user has clicked in the Progress view on the actual job. Fixes bug: #1611.
  • Loading branch information...
1 parent fd30cd5 commit 0c2212f568c11c0e71338f690c4d6de07d3c8a08 @jonalv jonalv committed Oct 29, 2009
@@ -22,7 +22,8 @@ Require-Bundle: org.eclipse.core.runtime,
org.springframework.bundle.spring.aop;bundle-version="2.5.1",
org.springframework.osgi.aopalliance.osgi;bundle-version="1.0.0",
org.springframework.bundle.spring.core;bundle-version="2.5.1",
- net.sf.cglib;bundle-version="2.1.3"
+ net.sf.cglib;bundle-version="2.1.3",
+ org.eclipse.jface
Bundle-ClassPath: libs/js.jar,
.,
libs/groovy-1.0.jar,
@@ -0,0 +1,28 @@
+/*******************************************************************************
+ * Copyright (c) 2009 Jonathan Alvarsson <jonalv@users.sourceforge.net>
+ *
+ * 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
+ * www.eclipse.orgÑepl-v10.html <http://www.eclipse.org/legal/epl-v10.html>
+ *
+ * Contact: http://www.bioclipse.net/
+ ******************************************************************************/
+package net.bioclipse.core;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * @author jonalv
+ *
+ */
+@Retention(RetentionPolicy.RUNTIME)
+@Target(ElementType.METHOD)
+public @interface SilentNotification {
+
+ String message() default "Job completed, results available!";
+
+}
@@ -7,6 +7,7 @@
import java.util.List;
import net.bioclipse.core.ResourcePathTransformer;
+import net.bioclipse.core.SilentNotification;
import net.bioclipse.core.business.BioclipseException;
import net.bioclipse.core.util.LogUtils;
import net.bioclipse.managers.business.IBioclipseManager;
@@ -19,7 +20,9 @@
import org.eclipse.core.runtime.OperationCanceledException;
import org.eclipse.core.runtime.Status;
import org.eclipse.core.runtime.jobs.Job;
+import org.eclipse.jface.action.Action;
import org.eclipse.swt.widgets.Display;
+import org.eclipse.ui.progress.IProgressConstants;
import org.eclipse.ui.progress.WorkbenchJob;
@@ -274,11 +277,28 @@ public void partialReturn( Object o ) {
if ( uiJob != null ) {
uiJob.setReturnValue( returnValue );
- Display.getDefault().asyncExec( new Runnable() {
- public void run() {
- uiJob.runInUI();
- }
- });
+ SilentNotification a
+ = this.methodCalled
+ .getAnnotation( SilentNotification.class );
+ if ( a != null ) {
+ setProperty(IProgressConstants.KEEP_PROPERTY, Boolean.TRUE);
+ monitor.subTask( a.message() );
+
+ setProperty( IProgressConstants.ACTION_PROPERTY,
+ new Action( a.message() ) {
+ public void run() {
+ uiJob.runInUI();
+ }
+ }
+ );
+ }
+ else {
+ Display.getDefault().asyncExec( new Runnable() {
+ public void run() {
+ uiJob.runInUI();
+ }
+ });
+ }
}
}
catch ( Exception e ) {

0 comments on commit 0c2212f

Please sign in to comment.