Package net.sf.jabref

Examples of net.sf.jabref.BibtexEntry


                    .lang("Fetch Citeseer"), JOptionPane.INFORMATION_MESSAGE);
                continue;
            }

            // Create an empty entry
            BibtexEntry entry = new BibtexEntry(Util.createNeutralId(), BibtexEntryType
                .getType("article"));
            entry.setField("citeseerurl", id);

            try {
                URL citeseerUrl = new URL(OAI_URL + id);
                HttpURLConnection citeseerConnection = (HttpURLConnection) citeseerUrl
                    .openConnection();
                InputStream inputStream = citeseerConnection.getInputStream();

                DefaultHandler handlerBase = new CiteSeerEntryFetcherHandler(entry);

                if (saxParser == null)
                    saxParser = SAXParserFactory.newInstance().newSAXParser();

                saxParser.parse(inputStream, handlerBase);

                /* Correct line breaks and spacing */
                for (String name : entry.getAllFields()) {
                    entry.setField(name, OAI2Fetcher.correctLineBreaks(entry.getField(name)
                        .toString()));
                }

                dialog.addEntry(entry);
                dialog.setProgress(i + 1, ids.length);
View Full Code Here


          BibtexDatabase fromDatabase = pr.getDatabase();
          ArrayList<BibtexEntry> appendedEntries = new ArrayList<BibtexEntry>();
          ArrayList<BibtexEntry> originalEntries = new ArrayList<BibtexEntry>();
          BibtexDatabase database = panel.database();
          BibtexEntry originalEntry;
          NamedCompound ce = new NamedCompound(Globals.lang("Append database"));
          MetaData meta = new MetaData(pr.getMetaData(), pr.getDatabase());

          if (importEntries) { // Add entries
              boolean overwriteOwner = Globals.prefs.getBoolean("overwriteOwner");
              boolean overwriteTimeStamp = Globals.prefs.getBoolean("overwriteTimeStamp");

            for (String key : fromDatabase.getKeySet()){
                originalEntry = fromDatabase.getEntryById(key);
                  BibtexEntry be = (BibtexEntry) (originalEntry.clone());
                  be.setId(Util.createNeutralId());
                  Util.setAutomaticFields(be, overwriteOwner, overwriteTimeStamp);
                  database.insertEntry(be);
                  appendedEntries.add(be);
                  originalEntries.add(originalEntry);
                  ce.addEdit(new UndoableInsertEntry(database, be, panel));
              }
          }

          if (importStrings) {
              for (BibtexString bs : fromDatabase.getStringValues()){
                  if (!database.hasStringLabel(bs.getName())) {
                      database.addString(bs);
                      ce.addEdit(new UndoableInsertString(panel, database, bs));
                  }
              }
          }

          if (importGroups) {
              GroupTreeNode newGroups = meta.getGroups();
              if (newGroups != null) {

                  // ensure that there is always only one AllEntriesGroup
                  if (newGroups.getGroup() instanceof AllEntriesGroup) {
                      // create a dummy group
                      ExplicitGroup group = new ExplicitGroup("Imported",
                              AbstractGroup.INDEPENDENT); // JZTODO lyrics
                      newGroups.setGroup(group);
                      for (int i = 0; i < appendedEntries.size(); ++i)
                          group.addEntry(appendedEntries.get(i));
                  }

                  // groupsSelector is always created, even when no groups
                  // have been defined. therefore, no check for null is
                  // required here
                  frame.groupSelector.addGroups(newGroups, ce);
                  // for explicit groups, the entries copied to the mother fromDatabase have to
                  // be "reassigned", i.e. the old reference is removed and the reference
                  // to the new fromDatabase is added.
                  GroupTreeNode node;
                  ExplicitGroup group;
                  BibtexEntry entry;
                 
                  for (Enumeration<GroupTreeNode> e = newGroups
          .preorderEnumeration(); e.hasMoreElements();) {
          node = e.nextElement();
          if (!(node.getGroup() instanceof ExplicitGroup))
View Full Code Here

 
        if (this.lastLine.startsWith("-----------------------------")) {
          this.inOverviewSection = this.preLine.startsWith("In this issue we have");
        }
        if (isStartOfWorkingPaper()) {
          BibtexEntry be = new BibtexEntry(Util.createNeutralId());
          be.setType(BibtexEntryType.getType("techreport"));
          paperNoStr = this.lastLine.substring(0, this.lastLine.indexOf('.'))
          parseTitleString(be);
          if (startsWithKeyword(recognizedFields)) {
            parseAdditionalFields(be, false);
          } else {
View Full Code Here

      // Skip empty entries
      if (hm.size() == 0)
        continue;

      BibtexEntry b = new BibtexEntry(BibtexFields.DEFAULT_BIBTEXENTRY_ID, Globals
        .getEntryType(Type));
      // id assumes an existing database so don't

      // Remove empty fields:
      ArrayList<Object> toRemove = new ArrayList<Object>();
      for (Iterator<String> it = hm.keySet().iterator(); it.hasNext();) {
        Object key = it.next();
        String content = hm.get(key);
        if ((content == null) || (content.trim().length() == 0))
          toRemove.add(key);
      }
      for (Iterator<Object> iterator = toRemove.iterator(); iterator.hasNext();) {
        hm.remove(iterator.next());

      }

      // Polish entries
      processSubSup(hm);
      processCapitalization(hm);

      b.setField(hm);

      bibitems.add(b);
    }

    return bibitems;
View Full Code Here

//        Globals.getEntryType(mapMSBibToBibtexTypeString(sourceType)));

//    BibtexEntry entry = new BibtexEntry(BibtexFields.DEFAULT_BIBTEXENTRY_ID,
//        mapMSBibToBibtexType(sourceType));

    BibtexEntry entry = null;
    if(tag == null)
      entry = new BibtexEntry(BibtexFields.DEFAULT_BIBTEXENTRY_ID,
          mapMSBibToBibtexType(sourceType));
    else
      entry = new BibtexEntry(tag,
          mapMSBibToBibtexType(sourceType)); // id assumes an existing database so don't
   

    // Todo: add check for BibTexEntry types
//    BibtexEntry entry = new BibtexEntry();
//    if(sourceType.equals("Book"))
//      entry.setType(BibtexEntryType.BOOK);
//    else if(sourceType.equals("BookSection"))
//      entry.setType(BibtexEntryType.INBOOK);
//    else if(sourceType.equals("JournalArticle"))
//      entry.setType(BibtexEntryType.ARTICLE);
//    else if(sourceType.equals("ArticleInAPeriodical"))
//      entry.setType(BibtexEntryType.ARTICLE);
//    else if(sourceType.equals("ConferenceProceedings"))
//      entry.setType(BibtexEntryType.CONFERENCE);
//    else if(sourceType.equals("Report"))
//      entry.setType(BibtexEntryType.TECHREPORT);
//    else if(sourceType.equals("InternetSite"))
//      entry.setType(BibtexEntryType.OTHER);
//    else if(sourceType.equals("DocumentFromInternetSite"))
//      entry.setType(BibtexEntryType.OTHER);
//    else if(sourceType.equals("DocumentFromInternetSite"))
//      entry.setType(BibtexEntryType.OTHER);
//    else if(sourceType.equals("ElectronicSource"))
//      entry.setType(BibtexEntryType.OTHER);
//    else if(sourceType.equals("Art"))
//      entry.setType(BibtexEntryType.OTHER);
//    else if(sourceType.equals("SoundRecording"))
//      entry.setType(BibtexEntryType.OTHER);
//    else if(sourceType.equals("Performance"))
//      entry.setType(BibtexEntryType.OTHER);
//    else if(sourceType.equals("Film"))
//      entry.setType(BibtexEntryType.OTHER);
//    else if(sourceType.equals("Interview"))
//      entry.setType(BibtexEntryType.OTHER);
//    else if(sourceType.equals("Patent"))
//      entry.setType(BibtexEntryType.OTHER);
//    else if(sourceType.equals("Case"))
//      entry.setType(BibtexEntryType.OTHER);
//    else if(sourceType.equals("Misc"))
//      entry.setType(BibtexEntryType.MISC);
//    else
//      entry.setType(BibtexEntryType.MISC);

    HashMap<String, String> hm = new HashMap<String, String>();
   
    if(tag != null)
      hm.put("bibtexkey",tag);
//    if(GUID != null)
//      hm.put("GUID",GUID);
    if(LCID >= 0)
      hm.put("language",getLanguage(LCID));
    if(title != null)
      hm.put("title",title);
    if(year != null)
      hm.put("year",year);
    if(shortTitle != null)
      hm.put(MSBIB+"shorttitle",shortTitle);
    if(comments != null)
      hm.put("note",comments);

    addAuthor(hm,"author",authors);
    addAuthor(hm,MSBIB+"bookauthor",bookAuthors);
    addAuthor(hm,"editor",editors);
    addAuthor(hm,MSBIB+"translator",translators);
    addAuthor(hm,MSBIB+"producername",producerNames);
    addAuthor(hm,MSBIB+"composer",composers);
    addAuthor(hm,MSBIB+"conductor",conductors);
    addAuthor(hm,MSBIB+"performer",performers);
    addAuthor(hm,MSBIB+"writer",writers);
    addAuthor(hm,MSBIB+"director",directors);
    addAuthor(hm,MSBIB+"compiler",compilers);
    addAuthor(hm,MSBIB+"interviewer",interviewers);
    addAuthor(hm,MSBIB+"interviewee",interviewees);
    addAuthor(hm,MSBIB+"inventor",inventors);
    addAuthor(hm,MSBIB+"counsel",counsels);
      
    if(pages !=null )
      hm.put("pages",pages.toString("--"));
    if(volume !=null )
      hm.put("volume",volume);
    if(numberOfVolumes !=null )
      hm.put(MSBIB+"numberofvolume",numberOfVolumes);
    if(edition !=null )
      hm.put("edition",edition);
    if(edition !=null )
      hm.put("edition",edition);
    parseStandardNumber(standardNumber,hm);

    if(publisher !=null )
      hm.put("publisher",publisher);
    if(publisher !=null )
      hm.put("publisher",publisher);
    if(address !=null )
      hm.put("address",address);
    if(bookTitle !=null )
      hm.put("booktitle",bookTitle);
    if(chapterNumber !=null )
      hm.put("chapter",chapterNumber);
    if(journalName !=null )
      hm.put("journal",journalName);
    if(issue !=null )
      hm.put("number",issue);
    if(periodicalTitle !=null )
      hm.put("organization",periodicalTitle);
    if(conferenceName !=null )
      hm.put("organization",conferenceName);
    if(department !=null )
      hm.put("school",department);
    if(institution !=null )
      hm.put("institution",institution);
//    if(thesisType !=null )
//      hm.put("type",thesisType);
//    if(internetSiteTitle !=null )
//      hm.put("title",internetSiteTitle);
    if(dateAccessed !=null )
      hm.put(MSBIB+"accessed",dateAccessed);
    if(url !=null )
      hm.put("url",url);
    if(productionCompany !=null )
      hm.put(MSBIB+"productioncompany",productionCompany);
//    if(publicationTitle !=null )
//      hm.put("title",publicationTitle);
    if(medium !=null )
      hm.put(MSBIB+"medium",medium);
//    if(albumTitle !=null )
//      hm.put("title",albumTitle);
    if(recordingNumber !=null )
      hm.put(MSBIB+"recordingnumber",recordingNumber);
    if(theater !=null )
      hm.put(MSBIB+"theater",theater);
    if(distributor !=null )
      hm.put(MSBIB+"distributor",distributor);
//    if(broadcastTitle !=null )
//      hm.put("title",broadcastTitle);
    if(broadcaster !=null )
      hm.put(MSBIB+"broadcaster",broadcaster);
    if(station !=null )
      hm.put(MSBIB+"station",station);
    if(type !=null )
      hm.put(MSBIB+"type",type);
    if(patentNumber !=null )
      hm.put(MSBIB+"patentnumber",patentNumber);
    if(court !=null )
      hm.put(MSBIB+"court",court);
    if(reporter !=null )
      hm.put(MSBIB+"reporter",reporter);
    if(caseNumber !=null )
      hm.put(MSBIB+"casenumber",caseNumber);
    if(abbreviatedCaseNumber !=null )
      hm.put(MSBIB+"abbreviatedcasenumber",abbreviatedCaseNumber);

    if(bibTex_Series !=null )
      hm.put("series",bibTex_Series);
    if(bibTex_Abstract !=null )
      hm.put("abstract",bibTex_Abstract);
    if(bibTex_KeyWords !=null )
      hm.put("keywords",bibTex_KeyWords);
    if(bibTex_CrossRef !=null )
      hm.put("crossref",bibTex_CrossRef);
    if(bibTex_HowPublished !=null )
      hm.put("howpublished",bibTex_HowPublished);
    if(bibTex_Affiliation !=null )
      hm.put("affiliation",bibTex_Affiliation);
    if(bibTex_Contents !=null )
      hm.put("contents",bibTex_Contents);
    if(bibTex_Copyright !=null )
      hm.put("copyright",bibTex_Copyright);
    if(bibTex_Price !=null )
      hm.put("price",bibTex_Price);
    if(bibTex_Size !=null )
      hm.put("size",bibTex_Size);

    entry.setField(hm);
    return entry;
  }
View Full Code Here

    }

    private void addEntries(BibtexDatabase database, Set<String> keySet) {
        entries = new HashSet<MSBibEntry>();
        for (String s : keySet){
          BibtexEntry entry = database.getEntryById(s);
      MSBibEntry newMods = new MSBibEntry(entry);
      entries.add(newMods);
    }
  }
View Full Code Here

     */
    public static List<FileListEntry> getExternalLinksForEntries(List<BibtexEntry> entries) {
        List<FileListEntry> files = new ArrayList<FileListEntry>();
        FileListTableModel model = new FileListTableModel();
        for (Iterator<BibtexEntry> iterator = entries.iterator(); iterator.hasNext();) {
            BibtexEntry entry = iterator.next();
            String links = entry.getField(GUIGlobals.FILE_FIELD);
            if (links == null)
                continue;
            model.setContent(links);
            for (int i=0; i<model.getRowCount(); i++)
                files.add(model.getEntry(i));
View Full Code Here

        public void action() throws Throwable {

            ArrayList<BibtexEntry> entries = new ArrayList<BibtexEntry>();
            BibtexEntry[] sel = panel.getSelectedEntries();
            for (int i = 0; i < sel.length; i++) {
                BibtexEntry bibtexEntry = sel[i];
                entries.add(bibtexEntry);
            }
            final List<FileListEntry> links =
                    AccessLinksForEntries.getExternalLinksForEntries(entries);
            for (Iterator<FileListEntry> iterator = links.iterator(); iterator.hasNext();) {
View Full Code Here

        }

        if (newSelected != null) {

            // Ok, we have a single new entry that has been selected. Now decide what to do with it:
            final BibtexEntry toShow = (BibtexEntry) newSelected;
            final int mode = panel.getMode(); // What is the panel already showing?
            if ((mode == BasePanel.WILL_SHOW_EDITOR) || (mode == BasePanel.SHOWING_EDITOR)) {
                // An entry is currently being edited.
                EntryEditor oldEditor = panel.getCurrentEditor();
                String visName = null;
View Full Code Here

                row = table.rowAtPoint(e.getPoint());

        // A double click on an entry should open the entry's editor.
        if (e.getClickCount() == 2) {

            BibtexEntry toShow = tableRows.get(row);
            editSignalled(toShow);
        }

        // Check if the user has clicked on an icon cell to open url or pdf.
        final String[] iconType = table.getIconTypeForColumn(col);


         // Workaround for Windows. Right-click is not popup trigger on mousePressed, but
         // on mouseReleased. Therefore we need to avoid taking action at this point, because
         // action will be taken when the button is released:
        if (Globals.ON_WIN && (iconType != null) && (e.getButton() != MouseEvent.BUTTON1))
            return;


        if (iconType != null) {

            Object value = table.getValueAt(row, col);
            if (value == null) return; // No icon here, so we do nothing.

            final BibtexEntry entry = tableRows.get(row);

            // Get the icon type. Corresponds to the field name.
            int hasField = -1;
            for (int i = iconType.length - 1; i >= 0; i--)
                if (entry.getField(iconType[i]) != null)
                    hasField = i;
            if (hasField == -1)
                return;
            final String fieldName = iconType[hasField];

            // Open it now. We do this in a thread, so the program won't freeze during the wait.
            (new Thread() {
                public void run() {
                    panel.output(Globals.lang("External viewer called") + ".");

                    Object link = entry.getField(fieldName);
                    if (link == null) {
                        Globals.logger("Error: no link to " + fieldName + ".");
                        return; // There is an icon, but the field is not set.
                    }
View Full Code Here

TOP

Related Classes of net.sf.jabref.BibtexEntry

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.