Search in sources :

Example 86 with FileObject

use of org.openide.filesystems.FileObject in project Universal-G-Code-Sender by winder.

the class GcodeParser method parse.

@Override
public void parse(Snapshot snapshot, Task task, SourceModificationEvent sourceModificationEvent) {
    this.snapshot = snapshot;
    FileObject fileObject = snapshot.getSource().getFileObject();
    List<ErrorParser> errorParserList = new ArrayList<>();
    errorParserList.add(new FeedRateMissingErrorParser(fileObject));
    errorParserList.add(new InvalidGrblCommandErrorParser(fileObject));
    errorParserList.add(new MovementInMachineCoordinatesErrorParser(fileObject));
    errorParserList.add(new InvalidG2CommandErrorParser(fileObject));
    TokenSequence<?> tokenSequence = snapshot.getTokenHierarchy().tokenSequence();
    tokenSequence.moveStart();
    // The snapshot starts on line 1
    int line = 1;
    while (tokenSequence.moveNext()) {
        Token<?> token = tokenSequence.token();
        if (GcodeTokenId.END_OF_LINE.equals(token.id())) {
            line++;
        }
        final int currentLine = line;
        errorParserList.forEach(errorParser -> errorParser.handleToken(token, currentLine));
    }
    this.errors = errorParserList.stream().flatMap(ep -> ep.getErrors().stream()).collect(Collectors.toList());
}
Also used : ArrayList(java.util.ArrayList) FileObject(org.openide.filesystems.FileObject)

Aggregations

FileObject (org.openide.filesystems.FileObject)86 File (java.io.File)28 IOException (java.io.IOException)20 ArrayList (java.util.ArrayList)11 DataObject (org.openide.loaders.DataObject)8 NotifyDescriptor (org.openide.NotifyDescriptor)7 Project (org.netbeans.api.project.Project)6 ActionEvent (java.awt.event.ActionEvent)5 PropertyChangeEvent (java.beans.PropertyChangeEvent)5 PropertyChangeListener (java.beans.PropertyChangeListener)5 InputStream (java.io.InputStream)5 JFileChooser (javax.swing.JFileChooser)5 JPanel (javax.swing.JPanel)5 ImportControllerUI (org.gephi.desktop.importer.api.ImportControllerUI)5 DialogFileFilter (org.gephi.ui.utils.DialogFileFilter)5 DialogDescriptor (org.openide.DialogDescriptor)5 ActionListener (java.awt.event.ActionListener)4 DocumentBuilder (javax.xml.parsers.DocumentBuilder)4 DocumentBuilderFactory (javax.xml.parsers.DocumentBuilderFactory)4 OpenCookie (org.openide.cookies.OpenCookie)4