Hi All,
I just upgraded to 2.10 and I found some bugs immediately.
1. in the right-click-menu there is no `move-to-group` but 2 `remove
from group` instead.
2. I like the new add/remove/move panel, but the scrolling is not
working, which is a big problem. Because I have lots of groups which
cannot even fit into the full screen height after expansion.
3. no way to expand or collapse all nodes
I tried the dev version, all problems still exist.
Should I got a git account to commit fixes?
Cheers,
W.L.
Here is some quick fixes:
#######################################
Precedes:
fix the right-click menu `move-to-group` and the scrollbar of
GroupAddRemoveDialog.
Add expandAll and collapseAll
--------------- src/main/java/net/sf/jabref/RightClickMenu.java ---------------
index 59a29a5..27431d8 100644
@@ -46,7 +46,7 @@ public class RightClickMenu extends JPopupMenu
rankingMenu = new JMenu(),
priorityMenu = new JMenu(),
typeMenu = new JMenu(Globals.lang("Change entry type"));
- JMenuItem groupAdd, groupRemove;
+ JMenuItem groupAdd, groupRemove, groupMoveTo;
JCheckBoxMenuItem
floatMarked = new JCheckBoxMenuItem(Globals.lang("Float
marked entries"),
Globals.prefs.getBoolean("floatMarkedEntries"));
@@ -323,16 +323,17 @@ public class RightClickMenu extends JPopupMenu
});
add(groupRemove);
- add(new AbstractAction(Globals.lang("Remove from group"))
+ groupMoveTo=add(new AbstractAction(Globals.lang("move to group"))
{
public void actionPerformed(ActionEvent e) {
try {
- panel.runCommand("removeFromGroup");
+ panel.runCommand("moveToGroup");
} catch (Throwable ex) {
logger.warning(ex.getMessage());
}
}
});
+ add(groupMoveTo);
floatMarked.addActionListener(new ActionListener() {
---------- src/main/java/net/sf/jabref/gui/GroupAddRemoveDialog.java ----------
index fd71a9d..0d02b85 100644
@@ -10,10 +10,14 @@ import net.sf.jabref.groups.*;
import javax.swing.*;
import javax.swing.event.TreeSelectionEvent;
import javax.swing.event.TreeSelectionListener;
+import javax.swing.tree.DefaultTreeModel;
+import javax.swing.tree.TreeNode;
+import javax.swing.tree.TreePath;
import javax.swing.tree.TreeSelectionModel;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
+import java.util.Enumeration;
/**
* Created with IntelliJ IDEA.
@@ -53,14 +57,43 @@ public class GroupAddRemoveDialog extends BaseAction {
tree = new JTree(groups);
tree.setCellRenderer(new AddRemoveGroupTreeCellRenderer());
tree.setVisibleRowCount(22);
- tree.setPreferredSize(new Dimension(200,
tree.getPreferredSize().height));
+
+// tree.setPreferredSize(new Dimension(200,
tree.getPreferredSize().height));
+// The scrollbar appears when the preferred size of a component
is greater than the size of the viewport. If one hard coded the
preferred size, it will never change according to the
expansion/collapse. Thus the scrollbar cannot appear accordingly.
//tree.setSelectionModel(new VetoableTreeSelectionModel());
tree.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
tree.addTreeSelectionListener(new SelectionListener());
+
+
+
+ //STA add expand and collapse all buttons
+ JButton jbExpandAll = new JButton("Expand All");
+
+ jbExpandAll.addActionListener(new ActionListener() {
+
+
+ public void actionPerformed(ActionEvent e) {
+ expandAll(tree, true);
+ }
+
+ });
+
+ JButton jbCollapseAll = new JButton("Collapse All");
+ jbCollapseAll.addActionListener(new ActionListener() {
+ public void actionPerformed(ActionEvent e) {
+ expandAll(tree, false);
+ }
+ });
+ //END add expand and collapse all buttons
+
ButtonBarBuilder bb = new ButtonBarBuilder();
bb.addGlue();
bb.addButton(ok);
bb.addButton(cancel);
+
+ bb.addButton(jbExpandAll);
+ bb.addButton(jbCollapseAll);
+
bb.addGlue();
bb.getPanel().setBorder(BorderFactory.createEmptyBorder(5,5,5,5));
@@ -76,8 +109,10 @@ public class GroupAddRemoveDialog extends BaseAction {
}
});
ok.setEnabled(false);
+
- JScrollPane sp = new JScrollPane(tree);
+ JScrollPane sp = new
JScrollPane(tree,JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
+ JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
// Key bindings:
ActionMap am = sp.getActionMap();
@@ -90,6 +125,11 @@ public class GroupAddRemoveDialog extends BaseAction {
});
diag.getContentPane().add(sp, BorderLayout.CENTER);
+
+
+
+
+
diag.getContentPane().add(bb.getPanel(), BorderLayout.SOUTH);
diag.pack();
diag.setLocationRelativeTo(panel.frame());
@@ -97,6 +137,35 @@ public class GroupAddRemoveDialog extends BaseAction {
}
+ // If "expand" is true, all nodes in the tree area expanded
+ // otherwise all nodes in the tree are collapsed:
+ public void expandAll(final JTree tree, final boolean expand) {
+ SwingUtilities.invokeLater(new Runnable() {
+ public void run() {
+ TreeNode root = ((TreeNode) tree.getModel().getRoot());
+ // walk through the tree, beginning at the root:
+ expandAll(tree, new TreePath(((DefaultTreeModel)
tree.getModel()).getPathToRoot(root)), expand);
+ tree.requestFocusInWindow();
+ }
+ });
+ }
+ private void expandAll(final JTree tree, final TreePath parent,
final boolean expand) {
+ // walk through the children:
+ TreeNode node = (TreeNode) parent.getLastPathComponent();
+ if (node.getChildCount() >= 0) {
+ for (Enumeration e = node.children(); e.hasMoreElements();) {
+ TreeNode n = (TreeNode) e.nextElement();
+ TreePath path = parent.pathByAddingChild(n);
+ expandAll(tree, path, expand);
+ }
+ }
+ // "expand" / "collapse" occurs from bottom to top:
+ if (expand) {
+ tree.expandPath(parent);
+ } else {
+ tree.collapsePath(parent);
+ }
+ }
###########################################
------------------------------------------------------------------------------
Is your legacy SCM system holding you back? Join Perforce May 7 to find out:
• 3 signs your SCM is hindering your productivity
• Requirements for releasing software faster
• Expert tips and advice for migrating your SCM now
http://p.sf.net/sfu/perforce
_______________________________________________
Jabref-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jabref-users