Skip to content

Commit

Permalink
Implemented validation on entry. Solves #1788.
Browse files Browse the repository at this point in the history
  • Loading branch information
olas authored and egonw committed Jun 17, 2010
1 parent 7cd1b3a commit 717efdb
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 11 deletions.
8 changes: 4 additions & 4 deletions plugins/net.bioclipse.cdk.smartsmatching/META-INF/MANIFEST.MF
Expand Up @@ -16,12 +16,12 @@ Require-Bundle: org.eclipse.core.runtime,
org.openscience.cdk.renderbasic,
org.openscience.cdk.renderextra,
net.bioclipse.cdk.ui.sdfeditor,
javax.vecmath
javax.vecmath,
org.openscience.cdk.smarts,
org.openscience.cdk.standard
Bundle-ActivationPolicy: lazy
Import-Package: net.bioclipse.core.business,
net.bioclipse.core.domain,
net.bioclipse.core.domain.props,
org.apache.log4j,
org.eclipse.core.resources,
org.openscience.cdk.exception,
org.openscience.cdk.smiles.smarts
org.eclipse.core.resources
Expand Up @@ -29,6 +29,7 @@
import org.eclipse.ui.PlatformUI;
import org.openscience.cdk.exception.CDKException;
import org.openscience.cdk.smiles.smarts.SMARTSQueryTool;
import org.openscience.cdk.smiles.smarts.parser.TokenMgrError;


public class AddEditSmartsDialog extends TitleAreaDialog{
Expand Down Expand Up @@ -135,6 +136,7 @@ protected void buttonPressed(int buttonId) {

smartsWrapper.setName( txtName.getText() );
smartsWrapper.setSmartsString( txtSmarts.getText() );
smartsWrapper.validate();

okPressed();
return;
Expand All @@ -153,16 +155,19 @@ private void updateStatus(){
setErrorMessage("SMARTS string must not be empty");
return;
}
if (!(cdk.isValidSmarts( txtSmarts.getText() ))){
try {
new SMARTSQueryTool( txtSmarts.getText() );
} catch (CDKException e) {
setErrorMessage( "SMARTS string is not valid: \""
+ e.getMessage() + "\"" );
}

try {
new SMARTSQueryTool(txtSmarts.getText());
} catch (Exception e) {
setErrorMessage( e.getMessage() );
}

// if (!(cdk.isValidSmarts( txtSmarts.getText() ))){
// setErrorMessage( "SMARTS string is not valid. " );
// }

getButtonBar().update();

}

private void showMessage(String message) {
Expand Down

0 comments on commit 717efdb

Please sign in to comment.