Ignore:
Timestamp:
03/29/12 23:10:04 (12 years ago)
Author:
wschamai
Message:

MOD: validation method

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/modelicaml/org.openmodelica.modelicaml.tabbedproperties.editors.glue/src/org/openmodelica/modelicaml/tabbedproperties/editors/glue/edit/part/PropertiesSectionXtextEditorHelper.java

    r1356 r1471  
    4646import org.eclipse.core.runtime.IStatus;
    4747import org.eclipse.core.runtime.Status;
     48import org.eclipse.core.runtime.jobs.Job;
     49import org.eclipse.emf.common.util.Diagnostic;
    4850import org.eclipse.emf.ecore.EObject;
     51import org.eclipse.emf.ecore.util.Diagnostician;
    4952import org.eclipse.jface.action.Action;
    5053import org.eclipse.jface.action.IAction;
     
    363366     * @return boolean
    364367     */
     368//  public boolean isDocumentHasErrors() {
     369//      IXtextDocument xtextDocument = sourceViewerHandle.getDocument();
     370//      return (xtextDocument.readOnly(new IUnitOfWork<Boolean, XtextResource>() {
     371//          public Boolean exec(XtextResource state) throws Exception {
     372//              IParseResult parseResult = state.getParseResult();
     373//              return !state.getErrors().isEmpty() || parseResult == null;
     374//          }
     375//      }));
     376//  }
     377// 
     378
     379    /**
     380     * Checks if is document has errors.
     381     *
     382     * @return boolean
     383     */
    365384    public boolean isDocumentHasErrors() {
     385//      partialEditor.createResource(getText());
     386        if (getXtextResource().getContents() != null && getXtextResource().getContents().size() > 0) {
     387            EObject myModel = getXtextResource().getContents().get(0);
     388            Diagnostic diagnostic = Diagnostician.INSTANCE.validate(myModel);
     389            switch (diagnostic.getSeverity()) {
     390              case Diagnostic.ERROR: {
     391                  return true;
     392//              System.err.println("Model has errors: ",diagnostic);
     393              }
     394              case Diagnostic.WARNING:
     395                  return false;
     396//              System.err.println("Model has warnings: ",diagnostic);
     397            }
     398        }
     399       
    366400        IXtextDocument xtextDocument = sourceViewerHandle.getDocument();
    367401        return (xtextDocument.readOnly(new IUnitOfWork<Boolean, XtextResource>() {
     
    371405            }
    372406        }));
    373     }
     407       
     408    }
     409
     410   
     411
     412
     413
    374414   
    375415   
Note: See TracChangeset for help on using the changeset viewer.