Examples of YKDocument


Examples of edu.harvard.wcfia.yoshikoder.document.YKDocument

            throw new CommitException("Please give the document a title");
        }
       
        DocumentList dl = yoshikoder.getDocumentList();
        for (Iterator iter = dl.iterator(); iter.hasNext();) {
            YKDocument doc = (YKDocument) iter.next();
            if (doctitle.equals(doc.getTitle()))
                throw new CommitException("A document with this name already exists.  Please choose another");
        }
       
        YKDocument doc =
            YKDocumentFactory.createYKDocument(file, doctitle, encName.name(), loc);
        doc.setLocale(loc);
        doc.setPreferedFont(f);
       
        yoshikoder.addDocument(doc);
        yoshikoder.setUnsavedChanges(true);
    }
View Full Code Here

Examples of edu.harvard.wcfia.yoshikoder.document.YKDocument

        YKDocument[] docarray =
            (YKDocument[])dl.toArray(new YKDocument[dl.size()]);
        doc1combo = new JComboBox(docarray);
        doc2combo = new JComboBox(docarray);
       
        YKDocument doc = yoshikoder.getSelectedDocument();
        if (doc != null){
            doc1combo.setSelectedItem(doc);
            int index = doc1combo.getSelectedIndex();
            if ((index+1) < docarray.length)
                doc2combo.setSelectedIndex(index+1);
View Full Code Here

Examples of edu.harvard.wcfia.yoshikoder.document.YKDocument

       
        concPanel = new TableConcordancePanel(){
          @Override
        public void reactToDoubleClickedConcordanceLine() {
            ConcLineWrapper wrapper = getCurrentlySelectedConcLineWrapper();
            YKDocument doc = wrapper.document;
            if (getDocumentList().contains(doc)){
              setSelectedDocument(doc);
              docPanel.selectSpan(wrapper.startLeft, wrapper.endRight);
            }
          }
View Full Code Here

Examples of edu.harvard.wcfia.yoshikoder.document.YKDocument

        tworker = new TaskWorker(yoshikoder){
            YKDocument[] docs;
            protected void doWork() throws Exception {
                docs = new YKDocument[fs.length];
                for (int ii = 0; ii < fs.length; ii++) {      
                    YKDocument doc = YKDocumentFactory.createYKDocument(fs[ii], fs[ii].getName(),
                        yoshikoder.getDefaultEncoding().toString(), defLoc);
                    docs[ii] = doc;
                }
            };
            protected void onSuccess(){
View Full Code Here

Examples of edu.harvard.wcfia.yoshikoder.document.YKDocument

              efmMap.put(doc, efm);
            }
           
            // FIXME use efmMap in the report, not the most recent one!
           
            YKDocument fake =
                    YKDocumentFactory.createDummyDocument("Concordance", "none", "UTF-8");
                DictionaryFrequencyReport reportcatsonly =
                    new DictionaryFrequencyReport("Concordance Report",
                            catnode.getName() + " applied to current concordance",
                            yoshikoder.getDictionary().getName(),
View Full Code Here

Examples of edu.harvard.wcfia.yoshikoder.document.YKDocument

        final File file =
            new File(concordanceSaver.getDirectory(), FileUtil.suffix(fname, "ykc"));
        tworker = new TaskWorker(yoshikoder){
            protected void doWork() throws Exception {
             
              YKDocument d = concordance.keySet().iterator().next();
                Concordance conc = concordance.get(d);
                int ws = conc.getWindowSize();
              ExportUtil.exportAsXML(concordance, ws, file); // save in the new style
            }
            protected void onError() {
View Full Code Here

Examples of edu.harvard.wcfia.yoshikoder.document.YKDocument

    public ExportDocumentAsUTF8Action(Yoshikoder yk) {
        super(yk, ExportDocumentAsUTF8Action.class.getName());
    }
   
    public void actionPerformed(ActionEvent e) {       
        final YKDocument doc = yoshikoder.getSelectedDocument();
        if (doc == null) return;
       
        if (documentExporter==null)
            documentExporter =
                DialogUtil.makeFileDialog(yoshikoder,
                        "Export Document as UTF-8",
                        FileDialog.SAVE, null); // TODO loc       
       
        documentExporter.setFile(null);
        documentExporter.show();
        String fname = documentExporter.getFile();
        if (fname == null) return;
       
        File filed = new File(documentExporter.getDirectory(), fname);
        final File file = FileUtil.suffix( filed, "txt");
        tworker = new TaskWorker(yoshikoder){
            protected void doWork() throws Exception {
                FileUtil.save(file, doc.getText(), "UTF-8");
            }
            protected void onError() {
                DialogUtil.yelp(yoshikoder, "Could not export the document", e); // TODO loc
            }
        };
View Full Code Here

Examples of edu.harvard.wcfia.yoshikoder.document.YKDocument

           
            int ret = JOptionPane.showConfirmDialog(yoshikoder, panel, "Comparison",
                    JOptionPane.OK_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE);
            if (ret != JOptionPane.OK_OPTION) return;
           
            final YKDocument doc1 = panel.getFirstDocument();
            final YKDocument doc2 = panel.getSecondDocument();
           
            if ((doc1 == null) || (doc2 == null)){
                return;           
            }
           
            Node n = yoshikoder.getSelectedNode();
            CategoryNode cnode = null;
            if (n instanceof CategoryNode)
              cnode = (CategoryNode)n;
            else // patternnode
              cnode = (CategoryNode)n.getParent();
            final CategoryNode catnode = cnode;
           
            dworker = new DialogWorker(yoshikoder){
                protected void doWork() throws Exception {
                    DocumentList dl = new DocumentListImpl();
                    dl.add(doc1);
                    dl.add(doc2);

                    TokenizationCache tcache = yoshikoder.getTokenizationCache();
                    TokenList tl1 = tcache.getTokenList(doc1);
                    TokenList tl2 = tcache.getTokenList(doc2);
                    if (tl1 == null){
                        tl1 = TokenizationService.getTokenizationService().tokenize(doc1);
                        tcache.putTokenList(doc1, tl1);
                    }
                    if (tl2 == null){
                        tl2 = TokenizationService.getTokenizationService().tokenize(doc2);
                        tcache.putTokenList(doc2, tl2);
                    }
                   
                    //YKDictionary dict = yoshikoder.getDictionary();
                    EntryFrequencyMap efm1 = new EntryFrequencyMap(catnode, tl1);
                    EntryFrequencyMap efm2 = new EntryFrequencyMap(catnode, tl2);
                   
                    String key = doc1.getTitle() +
                        " vs. " + doc2.getTitle();
                    DictionaryRRDocumentComparisonReport report =
                        new DictionaryRRDocumentComparisonReport(key,
                                key,
                                catnode.getName(), dl, efm1, efm2);
                   
View Full Code Here

Examples of edu.harvard.wcfia.yoshikoder.document.YKDocument

     
      } else {
          boolean changed = false;
       
        DocumentState s = dep.getDocumentState();
        YKDocument doc = s.getDocument();

        if (!doc.getCharsetName().equals(dep.getSelectedEncoding().name())){
          doc.setCharsetName(dep.getSelectedEncoding().name());
          changed = true;
        }
        if (changed){ // need to remove cached tokens
          TokenizationCache cache = yoshikoder.getTokenizationCache();
          cache.removeTokenList(doc);
          if (doc instanceof LazyYKDocument)
            ((LazyYKDocument)doc).clearCachedText(); // force a re-read from file system
          // does not do anything weird to the text area immediately, but probably should...
        }

        if (!doc.getLocale().equals(dep.getSelectedLocale())){
          doc.setLocale(dep.getSelectedLocale());
          changed = true;
       
        if (!doc.getTitle().equals(newtitle)){
          doc.setTitle(newtitle);
          changed = true;
        }
        repaint();
        return changed;
        // TODO reorder the list
View Full Code Here

Examples of edu.harvard.wcfia.yoshikoder.document.YKDocument

        return titleField.getText();
      }
     
      public void setDocumentState(DocumentState ds){
        state = ds;
        YKDocument doc = state.getDocument();
        localeBox.setSelectedItem(new LocaleWrapper(doc.getLocale()));
        encodingBox.setSelectedItem(new CharsetWrapper(Charset.forName(doc.getCharsetName())));
        titleField.setText(doc.getTitle());
      }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.