Package edu.harvard.wcfia.yoshikoder.util

Examples of edu.harvard.wcfia.yoshikoder.util.TaskWorker


            String f = htmlExporter.getFile();
            if (f==null) return;
           
            final File file = new File(htmlExporter.getDirectory(), f);
           
            worker = new TaskWorker(this){
                protected void doWork() throws Exception {
                    report.saveAsHtml(FileUtil.suffix(file, "html", "htm"));
                }
                protected void onError() {
                    DialogUtil.yelp(YKReportDialog.this, "Could not save as HTML", e)// TODO loc
                }
            };
            worker.start();
        } else {
            if (excelExporter == null)
                excelExporter =
                    DialogUtil.makeFileDialog(yoshikoder, "Export as Excel",
                            FileDialog.SAVE, DialogUtil.xlsFilenameFilter); // TODO loc
           
            excelExporter.show();
            String f = excelExporter.getFile();
            if (f==null) return;
           
            final File file = new File(excelExporter.getDirectory(), f);
           
            worker = new TaskWorker(this){
                protected void doWork() throws Exception {
                    report.saveAsExcel(FileUtil.suffix(file, "xls"));
                }
                protected void onError() {
                    DialogUtil.yelp(YKReportDialog.this, "Could not save as Excel", e)// TODO loc
View Full Code Here


        return;
      final File f = chooser.getSelectedFile();
     
      if (chooser.getFileFilter().equals(ykd)){
       
        tworker = new TaskWorker(yoshikoder){
                YKDictionary dict;
                protected void doWork() throws Exception {
                    dict = ImportUtil.importYKDictionary(f);
                    if (dict == null)
                        throw new Exception("Null dictionary returned");
                }
                protected void onSuccess() {
                    yoshikoder.setDictionary(dict);
                    yoshikoder.setUnsavedChanges(true);
                }
                protected void onError() {
                    DialogUtil.yelp(yoshikoder, "Could not open dictionary", e);
                }
            };
            tworker.start();
       
      } else if (chooser.getFileFilter().equals(vbpro)){
        byte[] fileBytes = null;
        try {
                fileBytes = FileUtil.getBytes(f, 1000);
            } catch (IOException ioe){
                DialogUtil.yelp(yoshikoder, "Could not open file " + f.getName(), ioe);
                return;
            }
           
            final PreviewPanel preview = new PreviewPanel(fileBytes, yoshikoder.getDefaultEncoding());
            int i = JOptionPane.showConfirmDialog(yoshikoder, preview,
                    "Preview Dictionary",  JOptionPane.OK_CANCEL_OPTION,
                    JOptionPane.PLAIN_MESSAGE);   
            if (i != JOptionPane.OK_OPTION)
                return;
           
            tworker = new TaskWorker(yoshikoder){
                VBProFileParser parser = new VBProFileParser();
                YKDictionary importedDictionary;
               
                protected void doWork() throws Exception {
                    importedDictionary = parser.parse(f, preview.getSelectedEncoding().name());
View Full Code Here

        String file = projectChooser.getFile();
        if (file == null) return;
       
        final File f = new File(projectChooser.getDirectory(), file);
       
        tworker = new TaskWorker(yoshikoder){
            YKProject project;
            protected void doWork() throws Exception {
              project = ImportUtil.importYKProject(f);
            }
            protected void onSuccess() {
View Full Code Here

        String filename = concordanceExporter.getFile();
        if (filename == null) return;
       
        final File file = new File(concordanceExporter.getDirectory(),
                FileUtil.suffix(filename, "xls"));
        tworker = new TaskWorker(yoshikoder){
            protected void doWork() throws Exception {
                ExportUtil.exportAsXLS(concordance, file);
            }
            protected void onError() {
                DialogUtil.yelp(yoshikoder, "Could not export concordance in Excel format", e);
View Full Code Here

          cnode = (CategoryNode)n;
        else // patternnode
          cnode = (CategoryNode)n.getParent();
        final CategoryNode catnode = cnode;
       
        TaskWorker tworker = new TaskWorker(yoshikoder){
            YKDictionaryReportDialog dia;
          protected void doWork() throws Exception {
                TokenizationCache tcache = yoshikoder.getTokenizationCache();
                TokenList tl = tcache.getTokenList(doc);
                if (tl == null){
                    tl = TokenizationService.getTokenizationService().tokenize(doc);
                    tcache.putTokenList(doc, tl);
                }
               
                EntryFrequencyMap efm = new EntryFrequencyMap(catnode, tl);
               
                DictionaryFrequencyReport catsAndPats =
                    new DictionaryFrequencyReport("Dictionary Entry Frequencies",
                            "Frequencies of each dictionary entry in " + doc.getTitle(),
                            yoshikoder.getDictionary().getName(),
                            doc, efm, true);
                DictionaryFrequencyReport catsOnly =
                    new DictionaryFrequencyReport("Dictionary Entry Frequencies",
                            "Frequencies of each dictionary entry in " + doc.getTitle(),
                            yoshikoder.getDictionary().getName(),
                            doc, efm, false);
               
                dia = new YKDictionaryReportDialog(yoshikoder, catsOnly, catsAndPats, onlyShowCats);
            }
            protected void onSuccess() {
              dia.setVisible(true);
              // why is this called without the dialog returning
              onlyShowCats = !dia.getCurrentReport().getShowPatterns();
              log.info("now closed dialog said that the cats only flag was set when it last looked? " + onlyShowCats);
            }
            protected void onError() {
                if (e instanceof TokenizationException){
                    DialogUtil.yelp(yoshikoder, "Tokenization Error", e);
                } else if (e instanceof IOException){
                    DialogUtil.yelp(yoshikoder, "Input/Ouput Error", e);
                } else {
                    DialogUtil.yelp(yoshikoder, "Error", e);
                }
            }
        };
        tworker.start();
    }
View Full Code Here

TOP

Related Classes of edu.harvard.wcfia.yoshikoder.util.TaskWorker

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.