Ejemplo n.º 1
0
  /**
   * Customization of external program paths.
   *
   * @param prefs a <code>JabRefPreferences</code> value
   */
  public TableColumnsTab(JabRefPreferences prefs, JabRefFrame frame) {
    _prefs = prefs;
    this.frame = frame;
    setLayout(new BorderLayout());

    TableModel tm =
        new AbstractTableModel() {
          public int getRowCount() {
            return rowCount;
          }

          public int getColumnCount() {
            return 2;
          }

          public Object getValueAt(int row, int column) {
            if (row == 0) return (column == 0 ? GUIGlobals.NUMBER_COL : "" + ncWidth);
            row--;
            if (row >= tableRows.size()) return "";
            Object rowContent = tableRows.elementAt(row);
            if (rowContent == null) return "";
            TableRow tr = (TableRow) rowContent;
            switch (column) {
              case 0:
                return tr.name;
              case 1:
                return ((tr.length > 0) ? Integer.toString(tr.length) : "");
            }
            return null; // Unreachable.
          }

          public String getColumnName(int col) {
            return (col == 0 ? Globals.lang("Field name") : Globals.lang("Column width"));
          }

          public Class<?> getColumnClass(int column) {
            if (column == 0) return String.class;
            else return Integer.class;
          }

          public boolean isCellEditable(int row, int col) {
            return !((row == 0) && (col == 0));
          }

          public void setValueAt(Object value, int row, int col) {
            tableChanged = true;
            // Make sure the vector is long enough.
            while (row >= tableRows.size()) tableRows.add(new TableRow("", -1));

            if ((row == 0) && (col == 1)) {
              ncWidth = Integer.parseInt(value.toString());
              return;
            }

            TableRow rowContent = tableRows.elementAt(row - 1);

            if (col == 0) {
              rowContent.name = value.toString();
              if (((String) getValueAt(row, 1)).equals(""))
                setValueAt("" + GUIGlobals.DEFAULT_FIELD_LENGTH, row, 1);
            } else {
              if (value == null) rowContent.length = -1;
              else rowContent.length = Integer.parseInt(value.toString());
            }
          }
        };

    colSetup = new JTable(tm);
    TableColumnModel cm = colSetup.getColumnModel();
    cm.getColumn(0).setPreferredWidth(140);
    cm.getColumn(1).setPreferredWidth(80);

    FormLayout layout =
        new FormLayout(
            "1dlu, 8dlu, left:pref, 4dlu, fill:pref", // , 4dlu, fill:60dlu, 4dlu, fill:pref",
            "");
    DefaultFormBuilder builder = new DefaultFormBuilder(layout);
    JPanel pan = new JPanel();
    JPanel tabPanel = new JPanel();
    tabPanel.setLayout(new BorderLayout());
    JScrollPane sp =
        new JScrollPane(
            colSetup,
            JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
            JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
    colSetup.setPreferredScrollableViewportSize(new Dimension(250, 200));
    sp.setMinimumSize(new Dimension(250, 300));
    tabPanel.add(sp, BorderLayout.CENTER);
    JToolBar tlb = new JToolBar(SwingConstants.VERTICAL);
    tlb.setFloatable(false);
    // tlb.setRollover(true);
    // tlb.setLayout(gbl);
    AddRowAction ara = new AddRowAction();
    DeleteRowAction dra = new DeleteRowAction();
    MoveRowUpAction moveUp = new MoveRowUpAction();
    MoveRowDownAction moveDown = new MoveRowDownAction();
    tlb.setBorder(null);
    tlb.add(ara);
    tlb.add(dra);
    tlb.addSeparator();
    tlb.add(moveUp);
    tlb.add(moveDown);
    // tlb.addSeparator();
    // tlb.add(new UpdateWidthsAction());
    tabPanel.add(tlb, BorderLayout.EAST);

    showOneLetterHeadingForIconColumns =
        new JCheckBox(Globals.lang("Show one letter heading for icon columns"));

    fileColumn = new JCheckBox(Globals.lang("Show file column"));
    pdfColumn = new JCheckBox(Globals.lang("Show PDF/PS column"));
    urlColumn = new JCheckBox(Globals.lang("Show URL/DOI column"));
    preferUrl = new JRadioButton(Globals.lang("Show URL first"));
    preferDoi = new JRadioButton(Globals.lang("Show DOI first"));
    preferUrlDoiGroup = new ButtonGroup();
    preferUrlDoiGroup.add(preferUrl);
    preferUrlDoiGroup.add(preferDoi);

    urlColumn.addChangeListener(
        new ChangeListener() {
          @Override
          public void stateChanged(ChangeEvent arg0) {
            preferUrl.setEnabled(urlColumn.isSelected());
            preferDoi.setEnabled(urlColumn.isSelected());
          }
        });
    arxivColumn = new JCheckBox(Globals.lang("Show ArXiv column"));

    /** * begin: special table columns and special fields ** */
    HelpAction help = new HelpAction(frame.helpDiag, GUIGlobals.specialFieldsHelp);
    hlb = new JButton(GUIGlobals.getImage("helpSmall"));
    hlb.setToolTipText(Globals.lang("Help on special fields"));
    hlb.addActionListener(help);

    specialFieldsEnabled = new JCheckBox(Globals.lang("Enable special fields"));
    //		.concat(". ").concat(Globals.lang("You must restart JabRef for this to come into
    // effect.")));
    specialFieldsEnabled.addChangeListener(
        new ChangeListener() {
          public void stateChanged(ChangeEvent event) {
            boolean isEnabled = specialFieldsEnabled.isSelected();
            rankingColumn.setEnabled(isEnabled);
            compactRankingColumn.setEnabled(isEnabled ? rankingColumn.isSelected() : false);
            qualityColumn.setEnabled(isEnabled);
            priorityColumn.setEnabled(isEnabled);
            relevanceColumn.setEnabled(isEnabled);
            syncKeywords.setEnabled(isEnabled);
            writeSpecialFields.setEnabled(isEnabled);
          }
        });
    rankingColumn = new JCheckBox(Globals.lang("Show rank"));
    rankingColumn.addChangeListener(
        new ChangeListener() {
          public void stateChanged(ChangeEvent event) {
            compactRankingColumn.setEnabled(rankingColumn.isSelected());
          }
        });
    compactRankingColumn = new JCheckBox(Globals.lang("Compact rank"));
    qualityColumn = new JCheckBox(Globals.lang("Show quality"));
    priorityColumn = new JCheckBox(Globals.lang("Show priority"));
    relevanceColumn = new JCheckBox(Globals.lang("Show relevance"));

    // "sync keywords" and "write special" fields may be configured mutually exclusive only
    // The implementation supports all combinations (TRUE+TRUE and FALSE+FALSE, even if the latter
    // does not make sense)
    // To avoid confusion, we opted to make the setting mutually exclusive
    syncKeywords = new JRadioButton(Globals.lang("Synchronize with keywords"));
    writeSpecialFields =
        new JRadioButton(
            Globals.lang("Write values of special fields as separate fields to BibTeX"));
    ButtonGroup group = new ButtonGroup();
    group.add(syncKeywords);
    group.add(writeSpecialFields);

    builder.appendSeparator(Globals.lang("Special table columns"));
    builder.nextLine();
    builder.append(pan);

    DefaultFormBuilder specialTableColumnsBuilder =
        new DefaultFormBuilder(
            new FormLayout(
                "8dlu, 8dlu, 8cm, 8dlu, 8dlu, left:pref:grow",
                "pref, pref, pref, pref, pref, pref, pref, pref, pref, pref"));
    CellConstraints cc = new CellConstraints();

    specialTableColumnsBuilder.add(specialFieldsEnabled, cc.xyw(1, 1, 3));
    specialTableColumnsBuilder.add(rankingColumn, cc.xyw(2, 2, 2));
    specialTableColumnsBuilder.add(compactRankingColumn, cc.xy(3, 3));
    specialTableColumnsBuilder.add(relevanceColumn, cc.xyw(2, 4, 2));
    specialTableColumnsBuilder.add(qualityColumn, cc.xyw(2, 5, 2));
    specialTableColumnsBuilder.add(priorityColumn, cc.xyw(2, 6, 2));
    specialTableColumnsBuilder.add(syncKeywords, cc.xyw(2, 7, 2));
    specialTableColumnsBuilder.add(writeSpecialFields, cc.xyw(2, 8, 2));
    specialTableColumnsBuilder.add(showOneLetterHeadingForIconColumns, cc.xyw(1, 9, 5));
    specialTableColumnsBuilder.add(hlb, cc.xyw(1, 10, 2));

    specialTableColumnsBuilder.add(fileColumn, cc.xyw(5, 1, 2));
    specialTableColumnsBuilder.add(pdfColumn, cc.xyw(5, 2, 2));
    specialTableColumnsBuilder.add(urlColumn, cc.xyw(5, 3, 2));
    specialTableColumnsBuilder.add(preferUrl, cc.xy(6, 4));
    specialTableColumnsBuilder.add(preferDoi, cc.xy(6, 5));
    specialTableColumnsBuilder.add(arxivColumn, cc.xyw(5, 6, 2));

    builder.append(specialTableColumnsBuilder.getPanel());
    builder.nextLine();

    /** * end: special table columns and special fields ** */
    builder.appendSeparator(Globals.lang("Entry table columns"));
    builder.nextLine();
    builder.append(pan);
    builder.append(tabPanel);
    builder.nextLine();
    //	lab = new JLabel("<HTML>("+Globals.lang("this button will update the column width
    // settings<BR>"
    //						+"to match the current widths in your table")+")</HTML>");
    //        lab = new JLabel("<HTML>("+Globals.lang("this_button_will_update") +")</HTML>") ;
    builder.append(pan);
    JButton buttonWidth = new JButton(new UpdateWidthsAction());
    JButton buttonOrder = new JButton(new UpdateOrderAction());
    builder.append(buttonWidth);
    builder.nextLine();
    builder.append(pan);
    builder.append(buttonOrder);
    builder.nextLine();
    builder.append(pan);
    // builder.append(lab);
    builder.nextLine();
    pan = builder.getPanel();
    pan.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
    add(pan, BorderLayout.CENTER);
  }
Ejemplo n.º 2
0
 public MoveRowDownAction() {
   super("Down", GUIGlobals.getImage("down"));
   putValue(SHORT_DESCRIPTION, Globals.lang("Down"));
 }
Ejemplo n.º 3
0
 public AddRowAction() {
   super("Add row", GUIGlobals.getImage("add"));
   putValue(SHORT_DESCRIPTION, Globals.lang("Insert rows"));
 }
Ejemplo n.º 4
0
 public MoveRowUpAction() {
   super("Up", GUIGlobals.getImage("up"));
   putValue(SHORT_DESCRIPTION, Globals.lang("Move up"));
 }
Ejemplo n.º 5
0
 public DeleteRowAction() {
   super("Delete row", GUIGlobals.getImage("remove"));
   putValue(SHORT_DESCRIPTION, Globals.lang("Delete rows"));
 }