Skip to content

Commit

Permalink
openFiles handle List of string, fixes: bug 3426
Browse files Browse the repository at this point in the history
Had to make it take an Object and then cast to either String of IFile and hope for the best… It's used for scripting anyway so generics is not really supported.
  • Loading branch information
jonalv committed Nov 8, 2012
1 parent 62bf2c6 commit 5d32892
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
Expand Up @@ -56,10 +56,11 @@ public interface IUIManager extends IBioclipseManager {
public void open(IFile file);

@Recorded
@PublishedMethod(params="List<IFile> files",
methodSummary="Opens a list of files (e.g. a gist) in an editor.")
@PublishedMethod(params="List<Object> files",
methodSummary="Opens a list of files (e.g. a gist) represented either " +
"as IFiles or Strings in an editor.")
@GuiAction
public void openFiles( List<IFile> files );
public void openFiles( List<Object> files );

@GuiAction
public void open(String filePath, String editor) throws BioclipseException;
Expand Down
Expand Up @@ -22,6 +22,7 @@
import java.util.List;
import java.util.Map;

import net.bioclipse.core.ResourcePathTransformer;
import net.bioclipse.core.business.BioclipseException;
import net.bioclipse.core.domain.IBioObject;
import net.bioclipse.managers.business.IBioclipseManager;
Expand Down Expand Up @@ -112,11 +113,19 @@ public void open( final IFile file ) {
}
}

public void openFiles( List<IFile> files ) {
public void openFiles( List<Object> files ) {
IWorkbenchPage page = PlatformUI.getWorkbench()
.getActiveWorkbenchWindow()
.getActivePage();
for ( IFile file : files) {
for ( Object object : files) {
IFile file = null;
if ( object instanceof IFile) {
file = (IFile)object;
}
else if ( object instanceof String ) {
file = ResourcePathTransformer.getInstance()
.transform( (String) object );
}
try {
IDE.openEditor(page, file);
}
Expand Down

0 comments on commit 5d32892

Please sign in to comment.