Skip to content

Commit

Permalink
Implement JabRef#1233: group side pane fills space
Browse files Browse the repository at this point in the history
  • Loading branch information
tobiasdiez committed Apr 19, 2016
1 parent 1afc777 commit ac93ee0
Show file tree
Hide file tree
Showing 7 changed files with 112 additions and 28 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ to [sourceforge feature requests](https://sourceforge.net/p/jabref/features/) by
- Added support for several Biblatex-fields through drop-down lists with valid alternatives
- Added integrity checker for an odd number of unescaped '#'
- Implemented [feature request 384](https://sourceforge.net/p/jabref/features/384): The merge entries dialog now show all text and colored differences between the fields
- Implemented [#1233](https://github.com/JabRef/jabref/issues/1233): Group side pane now takes up all the remaining space

### Fixed

Expand Down
5 changes: 5 additions & 0 deletions src/main/java/net/sf/jabref/collab/FileUpdatePanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,11 @@ public void componentClosing() {
manager.unregisterComponent(FileUpdatePanel.NAME);
}

@Override
public int getRescalingWeight() {
return 0;
}

/**
* actionPerformed
*
Expand Down
24 changes: 17 additions & 7 deletions src/main/java/net/sf/jabref/gui/SidePane.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,12 @@
*/
package net.sf.jabref.gui;

import java.awt.*;
import java.awt.BorderLayout;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;
import java.util.Collection;

import javax.swing.Box;
Expand Down Expand Up @@ -67,15 +72,20 @@ public SidePane() {
public void setComponents(Collection<SidePaneComponent> comps) {
mainPanel.removeAll();

constraint.weighty = 0;
for (Component c : comps) {
int totalWeights = 0;
for (SidePaneComponent c : comps) {
constraint.weighty = c.getRescalingWeight();
totalWeights += c.getRescalingWeight();
gridBagLayout.setConstraints(c, constraint);
mainPanel.add(c);
}
constraint.weighty = 1;
Component bx = Box.createVerticalGlue();
gridBagLayout.setConstraints(bx, constraint);
mainPanel.add(bx);
if(totalWeights <= 0) {
// Fill vertical space so that components start at top
constraint.weighty = 1;
Component bx = Box.createVerticalGlue();
gridBagLayout.setConstraints(bx, constraint);
mainPanel.add(bx);
}

revalidate();
repaint();
Expand Down
19 changes: 16 additions & 3 deletions src/main/java/net/sf/jabref/gui/SidePaneComponent.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,19 @@
*/
package net.sf.jabref.gui;

import java.awt.Color;
import java.awt.Dimension;
import java.awt.Insets;

import javax.swing.BorderFactory;
import javax.swing.Icon;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JToolBar;

import org.jdesktop.swingx.JXTitledPanel;
import org.jdesktop.swingx.painter.MattePainter;

import javax.swing.*;
import java.awt.*;

public abstract class SidePaneComponent extends JXTitledPanel {

protected final JButton close = new JButton(IconTheme.JabRefIcon.CLOSE.getSmallIcon());
Expand Down Expand Up @@ -102,4 +109,10 @@ public void componentOpening() {
public Dimension getMinimumSize() {
return getPreferredSize();
}

/**
* Specifies how to distribute extra vertical space between side pane components.
* 0: fixed height, 1: fill the remaining space
*/
public abstract int getRescalingWeight();
}
5 changes: 5 additions & 0 deletions src/main/java/net/sf/jabref/gui/groups/GroupSelector.java
Original file line number Diff line number Diff line change
Expand Up @@ -824,6 +824,11 @@ public void componentOpening() {
valueChanged(null);
}

@Override
public int getRescalingWeight() {
return 1;
}

@Override
public void componentClosing() {
if (panel != null) {// panel may be null if no file is open any more
Expand Down
46 changes: 37 additions & 9 deletions src/main/java/net/sf/jabref/gui/openoffice/OpenOfficePanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,25 +28,48 @@
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import javax.swing.*;

import com.jgoodies.forms.builder.ButtonBarBuilder;
import com.jgoodies.forms.builder.FormBuilder;
import com.jgoodies.forms.layout.FormLayout;
import com.sun.star.beans.UnknownPropertyException;
import com.sun.star.container.NoSuchElementException;
import com.sun.star.lang.WrappedTargetException;
import javax.swing.AbstractAction;
import javax.swing.Action;
import javax.swing.ButtonGroup;
import javax.swing.Icon;
import javax.swing.JButton;
import javax.swing.JCheckBoxMenuItem;
import javax.swing.JComponent;
import javax.swing.JDialog;
import javax.swing.JFrame;
import javax.swing.JMenuItem;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JPopupMenu;
import javax.swing.JRadioButtonMenuItem;
import javax.swing.JTextField;

import net.sf.jabref.Globals;
import net.sf.jabref.gui.*;
import net.sf.jabref.gui.BasePanel;
import net.sf.jabref.gui.IconTheme;
import net.sf.jabref.gui.JabRefFrame;
import net.sf.jabref.gui.SidePaneComponent;
import net.sf.jabref.gui.SidePaneManager;
import net.sf.jabref.gui.actions.BrowseAction;
import net.sf.jabref.gui.help.HelpAction;
import net.sf.jabref.gui.keyboard.KeyBinding;
import net.sf.jabref.gui.worker.AbstractWorker;
import net.sf.jabref.logic.l10n.Localization;
import net.sf.jabref.logic.openoffice.*;
import net.sf.jabref.logic.openoffice.OOBibStyle;
import net.sf.jabref.logic.openoffice.OpenOfficePreferences;
import net.sf.jabref.logic.openoffice.StyleLoader;
import net.sf.jabref.logic.openoffice.UndefinedParagraphFormatException;
import net.sf.jabref.logic.util.OS;
import net.sf.jabref.model.database.BibDatabase;
import net.sf.jabref.model.entry.BibEntry;

import com.jgoodies.forms.builder.ButtonBarBuilder;
import com.jgoodies.forms.builder.FormBuilder;
import com.jgoodies.forms.layout.FormLayout;
import com.sun.star.beans.UnknownPropertyException;
import com.sun.star.container.NoSuchElementException;
import com.sun.star.lang.WrappedTargetException;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

Expand Down Expand Up @@ -672,6 +695,11 @@ public void componentClosing() {
public void componentOpening() {
preferences.setShowPanel(true);
}

@Override
public int getRescalingWeight() {
return 0;
}
}

}
40 changes: 31 additions & 9 deletions src/main/java/net/sf/jabref/importer/fetcher/GeneralFetcher.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,24 +15,42 @@
*/
package net.sf.jabref.importer.fetcher;

import java.awt.BorderLayout;
import java.awt.CardLayout;
import java.awt.Dimension;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.Arrays;
import java.util.Comparator;
import java.util.List;

import javax.swing.AbstractAction;
import javax.swing.Action;
import javax.swing.BorderFactory;
import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JPanel;
import javax.swing.JTextField;
import javax.swing.SwingUtilities;

import net.sf.jabref.Globals;
import net.sf.jabref.JabRefExecutorService;
import net.sf.jabref.JabRefPreferences;
import net.sf.jabref.gui.*;
import net.sf.jabref.gui.FetcherPreviewDialog;
import net.sf.jabref.gui.IconTheme;
import net.sf.jabref.gui.ImportInspectionDialog;
import net.sf.jabref.gui.JabRefFrame;
import net.sf.jabref.gui.SidePaneComponent;
import net.sf.jabref.gui.SidePaneManager;
import net.sf.jabref.gui.help.HelpAction;
import net.sf.jabref.gui.keyboard.KeyBinding;
import net.sf.jabref.gui.util.FocusRequester;
import net.sf.jabref.logic.l10n.Localization;
import net.sf.jabref.logic.util.OS;

import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.Arrays;
import java.util.Comparator;
import java.util.List;


public class GeneralFetcher extends SidePaneComponent implements ActionListener {

Expand Down Expand Up @@ -290,6 +308,10 @@ public void componentOpening() {
Globals.prefs.putBoolean(JabRefPreferences.WEB_SEARCH_VISIBLE, Boolean.TRUE);
}

@Override
public int getRescalingWeight() {
return 0;
}

private static class EntryFetcherComparator implements Comparator<EntryFetcher> {

Expand Down

0 comments on commit ac93ee0

Please sign in to comment.