Permalink
Browse files

Create the "Gists" project when needed

  • Loading branch information...
1 parent 8580cf5 commit 94f50947f56b22c5be6a833e5a0744a09c0a0a04 @jonalv jonalv committed Mar 6, 2012
Showing with 23 additions and 0 deletions.
  1. +23 −0 plugins/net.bioclipse.gist/src/net/bioclipse/gist/business/GistManager.java
@@ -29,9 +29,13 @@
import org.apache.log4j.Logger;
import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IWorkspaceRoot;
+import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.SubMonitor;
import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.MessageBox;
@@ -54,10 +58,29 @@
public void download(int gist, IReturner<IFile> returner, IProgressMonitor monitor)
throws BioclipseException {
+
if (monitor == null) {
monitor = new NullProgressMonitor();
}
+ SubMonitor subMonitor = SubMonitor.convert(monitor);
+ subMonitor.beginTask( "Downloading Gist", 100 );
+
+ IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
+ IProject project = root.getProject(GIST_PROJECT);
+ try {
+ if ( !project.exists() ) {
+ project.create(subMonitor.newChild(10));
+ }
+ project.open(subMonitor.newChild(10));
+ }
+ catch ( CoreException e ) {
+ throw new RuntimeException(
+ "Failed to prepare the Gists project",
@egonw

egonw Mar 6, 2012

Member

Why not a BioclipseException? Can you explain that in a blog post, please?

+ e );
+ }
+
+ monitor = subMonitor.newChild( 80 );
monitor.beginTask("Downloading Gist...", 2);
try {

0 comments on commit 94f5094

Please sign in to comment.