Skip to content

Commit

Permalink
New approach which should be much better
Browse files Browse the repository at this point in the history
  • Loading branch information
oscargus committed Aug 15, 2016
1 parent b37b6be commit f660186
Show file tree
Hide file tree
Showing 21 changed files with 100 additions and 101 deletions.
11 changes: 5 additions & 6 deletions src/main/java/net/sf/jabref/collab/ChangeDisplayDialog.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
package net.sf.jabref.collab;

import java.awt.BorderLayout;
import java.awt.FontMetrics;
import java.awt.Insets;
import java.util.Collections;
import java.util.Enumeration;
Expand All @@ -35,13 +36,10 @@
import javax.swing.event.TreeSelectionListener;
import javax.swing.tree.DefaultMutableTreeNode;

import net.sf.jabref.Globals;
import net.sf.jabref.gui.BasePanel;
import net.sf.jabref.gui.undo.NamedCompound;
import net.sf.jabref.logic.l10n.Localization;
import net.sf.jabref.logic.util.OS;
import net.sf.jabref.model.database.BibDatabase;
import net.sf.jabref.preferences.JabRefPreferences;

class ChangeDisplayDialog extends JDialog implements TreeSelectionListener {

Expand All @@ -67,9 +65,10 @@ public ChangeDisplayDialog(JFrame owner, final BasePanel panel,
}
tree = new JTree(root);
tree.addTreeSelectionListener(this);
if (OS.WINDOWS) { // Arbitrary trees scale with menu font size on Windows
tree.setRowHeight(Globals.prefs.getInt(JabRefPreferences.MENU_FONT_SIZE) + 2);
}
// Fix tree row height
FontMetrics metrics = tree.getFontMetrics(tree.getFont());
tree.setRowHeight(Math.max(tree.getRowHeight(), metrics.getHeight()));

JSplitPane pane = new JSplitPane();
pane.setLeftComponent(new JScrollPane(tree));
JPanel infoBorder = new JPanel();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

import java.awt.BorderLayout;
import java.awt.Component;
import java.awt.FontMetrics;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseAdapter;
Expand Down Expand Up @@ -51,8 +52,6 @@
import net.sf.jabref.gui.actions.MnemonicAwareAction;
import net.sf.jabref.gui.keyboard.KeyBinding;
import net.sf.jabref.logic.l10n.Localization;
import net.sf.jabref.logic.util.OS;
import net.sf.jabref.preferences.JabRefPreferences;

import com.jgoodies.forms.builder.ButtonBarBuilder;
import com.jgoodies.forms.builder.ButtonStackBuilder;
Expand Down Expand Up @@ -183,9 +182,9 @@ public void actionPerformed(ActionEvent e) {
table.getColumnModel().getColumn(3).setMinWidth(100);
table.getColumnModel().getColumn(0).setResizable(false);

if (OS.WINDOWS) { // Arbitrary tables scales with menu font size on Windows
table.setRowHeight(Globals.prefs.getInt(JabRefPreferences.MENU_FONT_SIZE) + 2);
}
// Set table height
FontMetrics metrics = table.getFontMetrics(table.getFont());
table.setRowHeight(Math.max(table.getRowHeight(), metrics.getHeight()));

JScrollPane sp = new JScrollPane(table);

Expand Down
9 changes: 5 additions & 4 deletions src/main/java/net/sf/jabref/gui/FindUnlinkedFilesDialog.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import java.awt.Component;
import java.awt.Container;
import java.awt.Dimension;
import java.awt.FontMetrics;
import java.awt.Frame;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
Expand Down Expand Up @@ -89,7 +90,6 @@
import net.sf.jabref.gui.importer.UnlinkedFilesCrawler;
import net.sf.jabref.gui.importer.UnlinkedPDFFileFilter;
import net.sf.jabref.logic.l10n.Localization;
import net.sf.jabref.logic.util.OS;
import net.sf.jabref.model.EntryTypes;
import net.sf.jabref.model.entry.EntryType;
import net.sf.jabref.model.entry.FieldName;
Expand Down Expand Up @@ -799,9 +799,10 @@ public void windowClosing(WindowEvent e) {
labelImportingInfo.setVisible(false);

tree = new JTree();
if (OS.WINDOWS) { // Arbitrary trees scale with menu font size on Windows
tree.setRowHeight(Globals.prefs.getInt(JabRefPreferences.MENU_FONT_SIZE) + 2);
}
// Fix tree row height
FontMetrics metrics = tree.getFontMetrics(tree.getFont());
tree.setRowHeight(Math.max(tree.getRowHeight(), metrics.getHeight()));

scrollpaneTree = new JScrollPane(tree);
scrollpaneTree.setWheelScrollingEnabled(true);

Expand Down
8 changes: 4 additions & 4 deletions src/main/java/net/sf/jabref/gui/StringDialog.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import java.awt.BorderLayout;
import java.awt.Component;
import java.awt.Container;
import java.awt.FontMetrics;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.event.ActionEvent;
Expand Down Expand Up @@ -58,7 +59,6 @@
import net.sf.jabref.logic.bibtex.comparator.BibtexStringComparator;
import net.sf.jabref.logic.help.HelpFile;
import net.sf.jabref.logic.l10n.Localization;
import net.sf.jabref.logic.util.OS;
import net.sf.jabref.model.database.BibDatabase;
import net.sf.jabref.model.database.KeyCollisionException;
import net.sf.jabref.model.entry.BibtexString;
Expand Down Expand Up @@ -124,9 +124,9 @@ protected boolean accept(Component c) {
table.setRowSelectionInterval(0, 0);
}

if (OS.WINDOWS) { // Arbitrary tables scales with menu font size on Windows
table.setRowHeight(Globals.prefs.getInt(JabRefPreferences.MENU_FONT_SIZE) + 2);
}
// Fix tree row height
FontMetrics metrics = table.getFontMetrics(table.getFont());
table.setRowHeight(Math.max(table.getRowHeight(), metrics.getHeight()));

gbl.setConstraints(table.getPane(), con);
pan.add(table.getPane());
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package net.sf.jabref.gui.actions;

import java.awt.FontMetrics;
import java.awt.event.ActionEvent;
import java.util.HashMap;
import java.util.List;
Expand All @@ -19,13 +20,10 @@
import javax.swing.table.TableModel;
import javax.swing.table.TableRowSorter;

import net.sf.jabref.Globals;
import net.sf.jabref.gui.JabRefFrame;
import net.sf.jabref.logic.integrity.IntegrityCheck;
import net.sf.jabref.logic.integrity.IntegrityMessage;
import net.sf.jabref.logic.l10n.Localization;
import net.sf.jabref.logic.util.OS;
import net.sf.jabref.preferences.JabRefPreferences;

import com.jgoodies.forms.builder.FormBuilder;
import com.jgoodies.forms.layout.FormLayout;
Expand Down Expand Up @@ -96,9 +94,9 @@ public boolean include(Entry<?, ?> entry) {
}
});

if (OS.WINDOWS) { // Arbitrary tables scales with menu font size on Windows
table.setRowHeight(Globals.prefs.getInt(JabRefPreferences.MENU_FONT_SIZE) + 2);
}
// Set table row height
FontMetrics metrics = table.getFontMetrics(table.getFont());
table.setRowHeight(Math.max(table.getRowHeight(), metrics.getHeight()));

table.getColumnModel().getColumn(0).setPreferredWidth(100);
table.getColumnModel().getColumn(1).setPreferredWidth(60);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import java.awt.BorderLayout;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.FontMetrics;
import java.awt.KeyboardFocusManager;
import java.awt.event.FocusListener;
import java.util.Collections;
Expand Down Expand Up @@ -49,11 +50,9 @@
import net.sf.jabref.gui.keyboard.KeyBinding;
import net.sf.jabref.gui.util.FocusRequester;
import net.sf.jabref.logic.autocompleter.AutoCompleter;
import net.sf.jabref.logic.util.OS;
import net.sf.jabref.model.entry.BibEntry;
import net.sf.jabref.model.entry.FieldProperties;
import net.sf.jabref.model.entry.InternalBibtexFields;
import net.sf.jabref.preferences.JabRefPreferences;

import com.jgoodies.forms.builder.DefaultFormBuilder;
import com.jgoodies.forms.layout.FormLayout;
Expand Down Expand Up @@ -155,9 +154,9 @@ private void setupPanel(JabRefFrame frame, BasePanel bPanel, boolean addKeyField
fieldEditor = new FileListEditor(frame, bPanel.getBibDatabaseContext(), field, null, parent);

fileListEditor = (FileListEditor) fieldEditor;
if (OS.WINDOWS) { // Arbitrary tables scales with menu font size on Windows
fileListEditor.setRowHeight(Globals.prefs.getInt(JabRefPreferences.MENU_FONT_SIZE) + 2);
}
// Fix table row height
FontMetrics metrics = fileListEditor.getFontMetrics(fileListEditor.getFont());
fileListEditor.setRowHeight(Math.max(fileListEditor.getRowHeight(), metrics.getHeight()));
defaultHeight = 0;
} else {
fieldEditor = new TextArea(field, null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.FontMetrics;
import java.awt.event.ActionEvent;
import java.util.ArrayList;
import java.util.Arrays;
Expand Down Expand Up @@ -44,8 +45,6 @@
import net.sf.jabref.gui.util.FocusRequester;
import net.sf.jabref.logic.help.HelpFile;
import net.sf.jabref.logic.l10n.Localization;
import net.sf.jabref.logic.util.OS;
import net.sf.jabref.preferences.JabRefPreferences;

import ca.odell.glazedlists.gui.TableFormat;
import ca.odell.glazedlists.swing.DefaultEventTableModel;
Expand Down Expand Up @@ -85,9 +84,9 @@ public ExportCustomizationDialog(final JabRefFrame frame) {
table.setRowSelectionInterval(0, 0);
}

if (OS.WINDOWS) { // Arbitrary tables scales with menu font size on Windows
table.setRowHeight(Globals.prefs.getInt(JabRefPreferences.MENU_FONT_SIZE) + 2);
}
// Fix table row height
FontMetrics metrics = table.getFontMetrics(table.getFont());
table.setRowHeight(Math.max(table.getRowHeight(), metrics.getHeight()));

JButton addExport = new JButton(Localization.lang("Add new"));
addExport.addActionListener(e -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Component;
import java.awt.FontMetrics;
import java.awt.Insets;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
Expand Down Expand Up @@ -106,6 +107,10 @@ public FileListEditor(JabRefFrame frame, BibDatabaseContext databaseContext, Str
setTableHeader(null);
addMouseListener(new TableClickListener());

// Fix table row height
FontMetrics metrics = getFontMetrics(getFont());
setRowHeight(Math.max(getRowHeight(), metrics.getHeight()));

JButton add = new JButton(IconTheme.JabRefIcon.ADD_NOBOX.getSmallIcon());
add.setToolTipText(Localization.lang("New file link (INSERT)"));
JButton remove = new JButton(IconTheme.JabRefIcon.REMOVE_NOBOX.getSmallIcon());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.FontMetrics;
import java.awt.event.ActionEvent;
import java.io.File;
import java.io.IOException;
Expand Down Expand Up @@ -56,8 +57,6 @@
import net.sf.jabref.logic.l10n.Localization;
import net.sf.jabref.logic.util.FileExtensions;
import net.sf.jabref.logic.xmp.XMPPreferences;
import net.sf.jabref.logic.util.OS;
import net.sf.jabref.preferences.JabRefPreferences;

import com.jgoodies.forms.builder.ButtonBarBuilder;
import org.apache.commons.logging.Log;
Expand Down Expand Up @@ -101,9 +100,9 @@ public ImportCustomizationDialog(final JabRefFrame frame) {
customImporterTable.setRowSelectionInterval(0, 0);
}

if (OS.WINDOWS) { // Arbitrary tables scales with menu font size on Windows
customImporterTable.setRowHeight(Globals.prefs.getInt(JabRefPreferences.MENU_FONT_SIZE) + 2);
}
// Set table height
FontMetrics metrics = customImporterTable.getFontMetrics(customImporterTable.getFont());
customImporterTable.setRowHeight(Math.max(customImporterTable.getRowHeight(), metrics.getHeight()));

JButton addFromFolderButton = new JButton(Localization.lang("Add from folder"));
addFromFolderButton.addActionListener(e -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.FontMetrics;
import java.awt.Rectangle;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
Expand Down Expand Up @@ -103,7 +104,6 @@
import net.sf.jabref.logic.importer.ImportInspector;
import net.sf.jabref.logic.importer.OutputPrinter;
import net.sf.jabref.logic.l10n.Localization;
import net.sf.jabref.logic.util.OS;
import net.sf.jabref.logic.util.UpdateField;
import net.sf.jabref.model.DuplicateCheck;
import net.sf.jabref.model.database.BibDatabase;
Expand Down Expand Up @@ -238,9 +238,9 @@ public ImportInspectionDialog(JabRefFrame frame, BasePanel panel, String undoNam
setupComparatorChooser();
glTable.addMouseListener(new TableClickListener());

if (OS.WINDOWS) { // Arbitrary tables scales with menu font size on Windows
glTable.setRowHeight(Globals.prefs.getInt(JabRefPreferences.MENU_FONT_SIZE) + 2);
}
// Fix table row height
FontMetrics metrics = glTable.getFontMetrics(glTable.getFont());
glTable.setRowHeight(Math.max(glTable.getRowHeight(), metrics.getHeight()));

setWidths();

Expand Down
10 changes: 4 additions & 6 deletions src/main/java/net/sf/jabref/gui/importer/ZipFileChooser.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@

import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.FontMetrics;
import java.io.IOException;
import java.time.ZoneId;
import java.time.ZonedDateTime;
Expand All @@ -53,13 +54,10 @@
import javax.swing.table.AbstractTableModel;
import javax.swing.table.TableColumnModel;

import net.sf.jabref.Globals;
import net.sf.jabref.gui.util.FocusRequester;
import net.sf.jabref.logic.importer.fileformat.CustomImporter;
import net.sf.jabref.logic.importer.fileformat.ImportFormat;
import net.sf.jabref.logic.l10n.Localization;
import net.sf.jabref.logic.util.OS;
import net.sf.jabref.preferences.JabRefPreferences;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
Expand Down Expand Up @@ -97,9 +95,9 @@ public ZipFileChooser(ImportCustomizationDialog importCustomizationDialog, ZipFi
if (table.getRowCount() > 0) {
table.setRowSelectionInterval(0, 0);
}
if (OS.WINDOWS) { // Arbitrary tables scales with menu font size on Windows
table.setRowHeight(Globals.prefs.getInt(JabRefPreferences.MENU_FONT_SIZE) + 2);
}
// Fix table row height
FontMetrics metrics = table.getFontMetrics(table.getFont());
table.setRowHeight(Math.max(table.getRowHeight(), metrics.getHeight()));

// cancel: no entry is selected
JButton cancelButton = new JButton(Localization.lang("Cancel"));
Expand Down
22 changes: 13 additions & 9 deletions src/main/java/net/sf/jabref/gui/journals/ManageJournalsPanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.FontMetrics;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseAdapter;
Expand Down Expand Up @@ -192,9 +193,10 @@ public ManageJournalsPanel(final JabRefFrame frame) {
viewBuiltin.addActionListener(e -> {
JTable table = new JTable(JournalAbbreviationsUtil.getTableModel(Globals.journalAbbreviationLoader
.getRepository(JournalAbbreviationPreferences.fromPreferences(Globals.prefs)).getAbbreviations()));
if (OS.WINDOWS) { // Arbitrary tables scales with menu font size on Windows
table.setRowHeight(Globals.prefs.getInt(JabRefPreferences.MENU_FONT_SIZE) + 2);
}
// Fix table row height
FontMetrics metrics = table.getFontMetrics(table.getFont());
table.setRowHeight(Math.max(table.getRowHeight(), metrics.getHeight()));

JScrollPane pane = new JScrollPane(table);
JOptionPane.showMessageDialog(null, pane, Localization.lang("Journal list preview"),
JOptionPane.INFORMATION_MESSAGE);
Expand Down Expand Up @@ -328,9 +330,10 @@ private void setupUserTable() {

tableModel.setJournals(userAbbreviations);
userTable = new JTable(tableModel);
if (OS.WINDOWS) { // Arbitrary tables scales with menu font size on Windows
userTable.setRowHeight(Globals.prefs.getInt(JabRefPreferences.MENU_FONT_SIZE) + 2);
}
// Fix table row height
FontMetrics metrics = userTable.getFontMetrics(userTable.getFont());
userTable.setRowHeight(Math.max(userTable.getRowHeight(), metrics.getHeight()));

userTable.addMouseListener(tableModel.getMouseListener());
userPanel.add(new JScrollPane(userTable), BorderLayout.CENTER);
}
Expand Down Expand Up @@ -586,9 +589,10 @@ private void setupPanel() {
.readJournalListFromFile(new File(tf.getText()));

JTable table = new JTable(JournalAbbreviationsUtil.getTableModel(abbreviations));
if (OS.WINDOWS) { // Arbitrary tables scales with menu font size on Windows
table.setRowHeight(Globals.prefs.getInt(JabRefPreferences.MENU_FONT_SIZE) + 2);
}
// Fix table row height
FontMetrics metrics = table.getFontMetrics(table.getFont());
table.setRowHeight(Math.max(table.getRowHeight(), metrics.getHeight()));

JScrollPane pane = new JScrollPane(table);
JOptionPane.showMessageDialog(null, pane, Localization.lang("Journal list preview"),
JOptionPane.INFORMATION_MESSAGE);
Expand Down
Loading

0 comments on commit f660186

Please sign in to comment.