Search in sources :

Example 1 with ContentSelectors

use of org.jabref.model.metadata.ContentSelectors in project jabref by JabRef.

the class ContentSelectorDialog method setupFieldSelector.

/**
     * Set the contents of the field selector list.
     *
     */
private void setupFieldSelector() {
    fieldListModel.clear();
    SortedSet<String> contents = new TreeSet<>();
    ContentSelectors selectors = metaData.getContentSelectors();
    for (String s : selectors.getFieldNamesWithSelectors()) {
        contents.add(s);
    }
    if (contents.isEmpty()) {
        // if nothing was added, put the default fields (as described in the help)
        fieldListModel.addElement(FieldName.AUTHOR);
        fieldListModel.addElement(FieldName.JOURNAL);
        fieldListModel.addElement(FieldName.KEYWORDS);
        fieldListModel.addElement(FieldName.PUBLISHER);
    } else {
        for (String s : contents) {
            fieldListModel.addElement(s);
        }
    }
    if (currentField == null) {
        // if dialog is created for the whole database,
        // select the first field to avoid confusions in GUI usage
        fieldList.setSelectedIndex(0);
    } else {
        // a specific field has been chosen at the constructor
        // select this field
        int i = fieldListModel.indexOf(currentField);
        if (i != -1) {
            // field has been found in list, select it
            fieldList.setSelectedIndex(i);
        }
    }
}
Also used : ContentSelectors(org.jabref.model.metadata.ContentSelectors) TreeSet(java.util.TreeSet)

Aggregations

TreeSet (java.util.TreeSet)1 ContentSelectors (org.jabref.model.metadata.ContentSelectors)1