Skip to content

Commit

Permalink
fffsdff
Browse files Browse the repository at this point in the history
  • Loading branch information
goglepox committed Sep 13, 2012
1 parent 2519153 commit c5de6ce
Showing 1 changed file with 13 additions and 13 deletions.
Expand Up @@ -26,7 +26,9 @@
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
Expand Down Expand Up @@ -87,10 +89,12 @@ public Object execute(ExecutionEvent event) throws ExecutionException {
if (!(obj instanceof IFile))
throw new ExecutionException("Selection is not a SMILES file");

final IFile file = (IFile) obj;
final String newPath = file.getFullPath().toOSString()
.replace(".smi", ".sdf");
if ( ui.fileExists( newPath ) ) {
final IFile input = (IFile) obj;

IPath outPath = input.getFullPath().removeFileExtension().addFileExtension("sdf");

final IFile output = ResourcesPlugin.getWorkspace().getRoot().getFile(outPath);
if ( ui.fileExists( output ) ) {
if ( !MessageDialog.openConfirm(
PlatformUI.getWorkbench().getActiveWorkbenchWindow()
.getShell(),
Expand All @@ -101,18 +105,17 @@ public Object execute(ExecutionEvent event) throws ExecutionException {
}
}

Job job=new Job("Converting SMILES to SDF"){
Job job=new Job("Converting "+input.getFullPath().toPortableString()+" to SDF"){

@Override
protected IStatus run(IProgressMonitor monitor) {
List<ICDKMolecule> mols;
monitor.beginTask("Converting SMILES", 100);
ICDKManager cdk = Activator.getDefault().getJavaCDKManager();

int count = 0;
Scanner s;
try {
s = new Scanner( file.getContents() );
s = new Scanner( input.getContents() );
} catch ( CoreException e ) {
LogUtils.handleException( e, logger,
"net.bioclipse.cdk.ui" );
Expand All @@ -128,7 +131,7 @@ protected IStatus run(IProgressMonitor monitor) {
Iterator<ICDKMolecule> iterator = null;

try {
iterator = cdk.createMoleculeIterator(file);
iterator = cdk.createMoleculeIterator(input);
}
catch ( Exception e ) {
LogUtils.handleException( e, logger,
Expand All @@ -138,11 +141,8 @@ protected IStatus run(IProgressMonitor monitor) {
"Error, failed to read file.");
}

//Create output filename


if ( ui.fileExists( newPath ) ) {
ui.remove(newPath);
if ( ui.fileExists( output ) ) {
ui.remove(output);
}
monitor.beginTask( "Converting file", count );
long timestamp = System.currentTimeMillis();
Expand Down

0 comments on commit c5de6ce

Please sign in to comment.