Skip to content

Commit d41f26e

Browse files
committed
Add option to hide/show gridlines in the main table
1 parent 423047b commit d41f26e

File tree

10 files changed

+38
-9
lines changed

10 files changed

+38
-9
lines changed

CHANGELOG

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
[master]
2+
- Some UI updates (mainly removing unnecessary boundaries)
3+
- Feature: Gridlines are now optional (and disabled by default)
24
- Fix for bug #1248: Key bindings not modified
35
- Fix for bug #876: Windows 7/8/10 - Pinning Jabref to the taskbar
46
- Feature: Option to change the table row height padding

src/main/java/net/sf/jabref/AppearancePrefsTab.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
class AppearancePrefsTab extends JPanel implements PrefsTab {
3232

3333
JabRefPreferences _prefs;
34-
private JCheckBox colorCodes, overrideFonts;//, useCustomIconTheme;
34+
private JCheckBox colorCodes, overrideFonts, showGrid;//, useCustomIconTheme;
3535
private ColorSetupPanel colorPanel = new ColorSetupPanel();
3636
private Font font = GUIGlobals.CURRENTFONT;
3737
private int oldMenuFontSize;
@@ -59,6 +59,8 @@ public AppearancePrefsTab(JabRefPreferences prefs) {
5959
("Use antialiasing font"));*/
6060
overrideFonts = new JCheckBox(Globals.lang("Override default font settings"));
6161

62+
showGrid = new JCheckBox(Globals.lang("Show gridlines"));
63+
6264
//useCustomIconTheme = new JCheckBox(Globals.lang("Use custom icon theme"));
6365
//customIconThemeFile = new JTextField();
6466
FormLayout layout = new FormLayout
@@ -86,6 +88,8 @@ public AppearancePrefsTab(JabRefPreferences prefs) {
8688
builder.nextLine();
8789
builder.append(colorCodes);
8890
builder.nextLine();
91+
builder.append(showGrid);
92+
builder.nextLine();
8993
JButton fontButton = new JButton(Globals.lang("Set table font"));
9094
builder.append(fontButton);
9195
builder.nextLine();
@@ -157,6 +161,7 @@ public void setValues() {
157161
fontSize.setEnabled(overrideFonts.isSelected());
158162
//useCustomIconTheme.setSelected(_prefs.getBoolean("useCustomIconTheme"));
159163
//customIconThemeFile.setText(_prefs.get("customIconThemeFile"));
164+
showGrid.setSelected(_prefs.getBoolean("tableShowGrid"));
160165
colorPanel.setValues();
161166
}
162167

@@ -175,6 +180,7 @@ public void storeSettings() {
175180
_prefs.putBoolean("overrideDefaultFonts", overrideFonts.isSelected());
176181
GUIGlobals.CURRENTFONT = font;
177182
colorPanel.storeSettings();
183+
_prefs.putBoolean("tableShowGrid", showGrid.isSelected());
178184
try {
179185
int size = Integer.parseInt(fontSize.getText());
180186
if ((overrideFonts.isSelected() != oldOverrideFontSize) ||
@@ -187,7 +193,6 @@ public void storeSettings() {
187193
Globals.lang("Changed font settings"),
188194
JOptionPane.WARNING_MESSAGE);
189195
}
190-
191196
} catch (NumberFormatException ex) {
192197
ex.printStackTrace();
193198
}

src/main/java/net/sf/jabref/BasePanel.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
package net.sf.jabref;
1717

1818
import java.awt.BorderLayout;
19+
import java.awt.Color;
1920
import java.awt.Component;
2021
import java.awt.GridBagConstraints;
2122
import java.awt.GridBagLayout;
@@ -45,6 +46,7 @@
4546
import java.util.logging.Logger;
4647

4748
import javax.swing.AbstractAction;
49+
import javax.swing.BorderFactory;
4850
import javax.swing.JComponent;
4951
import javax.swing.JFileChooser;
5052
import javax.swing.JOptionPane;
@@ -2084,6 +2086,10 @@ protected boolean accept(Component c) {
20842086

20852087
splitPane.setTopComponent(mainTable.getPane());
20862088

2089+
// Remove borders
2090+
splitPane.setBorder(BorderFactory.createEmptyBorder());
2091+
setBorder(BorderFactory.createEmptyBorder());
2092+
20872093
//setupTable();
20882094
// If an entry is currently being shown, make sure it stays shown,
20892095
// otherwise set the bottom component to null.

src/main/java/net/sf/jabref/EntryEditorTab.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
import java.util.List;
2727

2828
import javax.swing.ActionMap;
29+
import javax.swing.BorderFactory;
2930
import javax.swing.InputMap;
3031
import javax.swing.JComponent;
3132
import javax.swing.JPanel;
@@ -129,7 +130,7 @@ void setupPanel(JabRefFrame frame, BasePanel bPanel, boolean addKeyField,
129130

130131
DefaultFormBuilder builder = new DefaultFormBuilder
131132
(new FormLayout(colSpec, rowSpec), panel);
132-
133+
133134
for (int i = 0; i < fields.length; i++) {
134135
// Create the text area:
135136
int editorType = BibtexFields.getEditorType(fields[i]);

src/main/java/net/sf/jabref/FieldNameLabel.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,9 @@ public FieldNameLabel(String name) {
3030
setVerticalAlignment(TOP);
3131
//setFont(GUIGlobals.fieldNameFont);
3232
setForeground(GUIGlobals.entryEditorLabelColor);
33-
setBorder(BorderFactory.createMatteBorder(1,0,0,0, Color.GRAY));
33+
// setBorder(BorderFactory.createMatteBorder(1,0,0,0, Color.GRAY));
3434
//setBorder(BorderFactory.createEtchedBorder());
35+
setBorder(BorderFactory.createEmptyBorder());
3536
}
3637

3738
public void paintComponent(Graphics g) {

src/main/java/net/sf/jabref/GUIGlobals.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ public class GUIGlobals {
7878
public static final int
7979
SPLIT_PANE_DIVIDER_SIZE = 4,
8080
SPLIT_PANE_DIVIDER_LOCATION = 145 + 15, // + 15 for possible scrollbar.
81-
TABLE_ROW_PADDING = 4,
81+
TABLE_ROW_PADDING = 8,
8282
KEYBIND_COL_0 = 200,
8383
KEYBIND_COL_1 = 80, // Added to the font size when determining table
8484
MAX_CONTENT_SELECTOR_WIDTH = 240; // The max width of the combobox for content selectors.

src/main/java/net/sf/jabref/JabRefFrame.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1797,7 +1797,7 @@ public void addTab(BasePanel bp, File file, boolean raisePanel) {
17971797
} else {
17981798
title = file.getName();
17991799
}
1800-
tabbedPane.add(title, bp);
1800+
tabbedPane.add("<html><div style='padding:2px 5px;'>" + title + "</div></html>", bp);
18011801
tabbedPane.setToolTipTextAt(tabbedPane.getTabCount()-1,
18021802
file != null ? file.getAbsolutePath() : null);
18031803
if (raisePanel) {

src/main/java/net/sf/jabref/JabRefPreferences.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -398,6 +398,7 @@ private JabRefPreferences() {
398398
defaults.put("menuFontStyle", java.awt.Font.PLAIN);
399399
defaults.put("menuFontSize", 11);
400400
defaults.put("tableRowPadding", GUIGlobals.TABLE_ROW_PADDING);
401+
defaults.put("tableShowGrid", Boolean.FALSE);
401402
// Main table color settings:
402403
defaults.put("tableBackground", "255:255:255");
403404
defaults.put("tableReqFieldBackground", "230:235:255");

src/main/java/net/sf/jabref/SidePaneComponent.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import java.awt.event.ActionListener;
2222
import java.net.URL;
2323

24+
import javax.swing.BorderFactory;
2425
import javax.swing.ImageIcon;
2526
import javax.swing.JButton;
2627
import javax.swing.JToolBar;
@@ -50,7 +51,7 @@ public SidePaneComponent(SidePaneManager manager, URL icon, String title) {
5051
close.addActionListener(new CloseButtonListener());
5152
setToolBar(tlb);
5253
// setBorder(BorderFactory.createEtchedBorder());
53-
54+
setBorder(BorderFactory.createEmptyBorder());
5455
// setBorder(BorderFactory.createMatteBorder(1,1,1,1,java.awt.Color.green));
5556
// setPreferredSize(new java.awt.Dimension
5657
// (GUIGlobals.SPLIT_PANE_DIVIDER_LOCATION, 200));

src/main/java/net/sf/jabref/gui/MainTable.java

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
package net.sf.jabref.gui;
1717

1818
import java.awt.Color;
19+
import java.awt.Dimension;
1920
import java.awt.Rectangle;
2021
import java.awt.event.ActionEvent;
2122
import java.awt.event.ActionListener;
@@ -25,6 +26,7 @@
2526

2627
import javax.swing.*;
2728
import javax.swing.plaf.TableUI;
29+
import javax.swing.table.DefaultTableCellRenderer;
2830
import javax.swing.table.TableCellRenderer;
2931
import javax.swing.table.TableColumnModel;
3032

@@ -84,6 +86,7 @@ public MainTable(MainTableFormat tableFormat, EventList<BibtexEntry> list, JabRe
8486

8587
addFocusListener(Globals.focusListener);
8688
setAutoResizeMode(Globals.prefs.getInt("autoResizeMode"));
89+
8790
this.tableFormat = tableFormat;
8891
this.panel = panel;
8992
// This SortedList has a Comparator controlled by the TableComparatorChooser
@@ -109,8 +112,16 @@ public MainTable(MainTableFormat tableFormat, EventList<BibtexEntry> list, JabRe
109112
selectionModel = new EventSelectionModel<BibtexEntry>(sortedForGrouping);
110113
setSelectionModel(selectionModel);
111114
pane = new JScrollPane(this);
115+
pane.setBorder(BorderFactory.createEmptyBorder());
112116
pane.getViewport().setBackground(Globals.prefs.getColor("tableBackground"));
113117
setGridColor(Globals.prefs.getColor("gridColor"));
118+
if(Globals.prefs.getBoolean("tableShowGrid"))
119+
setShowGrid(true);
120+
else
121+
{
122+
setShowGrid(false);
123+
setIntercellSpacing(new Dimension(0, 0));
124+
}
114125

115126
this.setTableHeader(new PreventDraggingJTableHeader(this.getColumnModel()));
116127

@@ -217,7 +228,7 @@ public JScrollPane getPane() {
217228
public TableCellRenderer getCellRenderer(int row, int column) {
218229

219230
int score = -3;
220-
TableCellRenderer renderer = defRenderer;
231+
DefaultTableCellRenderer renderer = defRenderer;
221232

222233
int status = getCellStatus(row, column);
223234

@@ -256,14 +267,15 @@ else if (column == 0) {
256267
} else
257268
renderer = compRenderer;
258269
}
270+
renderer.setHorizontalAlignment( JLabel.CENTER );
259271
}
260272
else if (tableColorCodes) {
261273
if (status == REQUIRED)
262274
renderer = reqRenderer;
263275
else if (status == OPTIONAL)
264276
renderer = optRenderer;
265277
else if (status == BOOLEAN)
266-
renderer = getDefaultRenderer(Boolean.class);
278+
renderer = (DefaultTableCellRenderer) getDefaultRenderer(Boolean.class);
267279
}
268280

269281
// For MARKED feature:

0 commit comments

Comments
 (0)