Logo Search packages:      
Sourcecode: jabref version File versions  Download package

static boolean net::sf::jabref::Util::warnAssignmentSideEffects ( AbstractGroup[]  groups,
BibtexEntry[]  entries,
BibtexDatabase  db,
Component  parent 
) [inline, static]

Warns the user of undesired side effects of an explicit assignment/removal of entries to/from this group. Currently there are four types of groups: AllEntriesGroup, SearchGroup - do not support explicit assignment. ExplicitGroup - never modifies entries. KeywordGroup - only this modifies entries upon assignment/removal. Modifications are acceptable unless they affect a standard field (such as "author") besides the "keywords" field.

Parameters:
parent The Component used as a parent when displaying a confirmation dialog.
Returns:
true if the assignment has no undesired side effects, or the user chose to perform it anyway. false otherwise (this indicates that the user has aborted the assignment).

Definition at line 2075 of file Util.java.

References net::sf::jabref::groups::KeywordGroup::getSearchField().

                                                 {
            Vector<String> affectedFields = new Vector<String>();
            for (int k = 0; k < groups.length; ++k) {
                  if (groups[k] instanceof KeywordGroup) {
                        KeywordGroup kg = (KeywordGroup) groups[k];
                        String field = kg.getSearchField().toLowerCase();
                        if (field.equals("keywords"))
                              continue; // this is not undesired
                        for (int i = 0, len = BibtexFields.numberOfPublicFields(); i < len; ++i) {
                              if (field.equals(BibtexFields.getFieldName(i))) {
                                    affectedFields.add(field);
                                    break;
                              }
                        }
                  }
            }
            if (affectedFields.size() == 0)
                  return true; // no side effects

            // show a warning, then return
            StringBuffer message = // JZTODO lyrics...
            new StringBuffer("This action will modify the following field(s)\n"
                  + "in at least one entry each:\n");
            for (int i = 0; i < affectedFields.size(); ++i)
                  message.append(affectedFields.elementAt(i)).append("\n");
            message.append("This could cause undesired changes to "
                  + "your entries, so it is\nrecommended that you change the grouping field "
                  + "in your group\ndefinition to \"keywords\" or a non-standard name."
                  + "\n\nDo you still want to continue?");
            int choice = JOptionPane.showConfirmDialog(parent, message, Globals.lang("Warning"),
                  JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE);
            return choice != JOptionPane.NO_OPTION;

            // if (groups instanceof KeywordGroup) {
            // KeywordGroup kg = (KeywordGroup) groups;
            // String field = kg.getSearchField().toLowerCase();
            // if (field.equals("keywords"))
            // return true; // this is not undesired
            // for (int i = 0; i < GUIGlobals.ALL_FIELDS.length; ++i) {
            // if (field.equals(GUIGlobals.ALL_FIELDS[i])) {
            // // show a warning, then return
            // String message = Globals // JZTODO lyrics...
            // .lang(
            // "This action will modify the \"%0\" field "
            // + "of your entries.\nThis could cause undesired changes to "
            // + "your entries, so it is\nrecommended that you change the grouping
            // field "
            // + "in your group\ndefinition to \"keywords\" or a non-standard name."
            // + "\n\nDo you still want to continue?",
            // field);
            // int choice = JOptionPane.showConfirmDialog(parent, message,
            // Globals.lang("Warning"), JOptionPane.YES_NO_OPTION,
            // JOptionPane.WARNING_MESSAGE);
            // return choice != JOptionPane.NO_OPTION;
            // }
            // }
            // }
            // return true; // found no side effects
      }


Generated by  Doxygen 1.6.0   Back to index