From 5f9005ada72fbc3fd6583d09adf0422cc3498cd2 Mon Sep 17 00:00:00 2001 From: Ben Staddon Date: Mon, 24 Feb 2014 14:22:10 +0000 Subject: [PATCH 1/5] Basic implementation of 'up' button --- src/client/gui/FilesTab.java | 45 +++++++++++++++++++++++++++++++----- 1 file changed, 39 insertions(+), 6 deletions(-) diff --git a/src/client/gui/FilesTab.java b/src/client/gui/FilesTab.java index 16c29a5..09e9a59 100644 --- a/src/client/gui/FilesTab.java +++ b/src/client/gui/FilesTab.java @@ -3,6 +3,7 @@ import java.awt.BorderLayout; import java.awt.Component; import java.awt.Dimension; +import java.awt.FlowLayout; import java.awt.Image; import java.awt.Point; import java.awt.Rectangle; @@ -50,7 +51,6 @@ import common.FS2Constants; import common.ProgressTracker; import common.Util; - import client.indexnode.FileSystem; import client.indexnode.FileSystemEntry; import client.indexnode.ListableEntry; @@ -302,7 +302,8 @@ JPanel createSearchBar() { JSplitPane splitPane; JTable filesTable; LoadingAnimationHelper spinner; - + JButton upButton; + JLabel currentDirectory; /** * Records the time at which tree nodes were expanded so that they may be collapsed if idle after a defined period. @@ -311,7 +312,7 @@ JPanel createSearchBar() { Timer collapseTimer; BrowseTreeCellRenderer browseTreeRenderer; - + JSplitPane createBrowseSection() { spinner = new LoadingAnimationHelper(); splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT); @@ -329,6 +330,8 @@ public boolean required(TreePath path) { }); fs.addTreeModelListener(spinner); + currentDirectory = new JLabel(); + browseTree.setCellRenderer(browseTreeRenderer = new BrowseTreeCellRenderer()); browseTree.addTreeSelectionListener(this); browseTree.addMouseMotionListener(this); @@ -345,9 +348,21 @@ public boolean required(TreePath path) { filesTable.addMouseListener(this); filesTable.getSelectionModel().addListSelectionListener(this); filesTable.getColumn(fs.getColumnName(0)).setCellRenderer(new FilesTableNameRenderer()); - + JScrollPane filesView = new JScrollPane(filesTable); - splitPane.setRightComponent(filesView); + + upButton = new JButton("Up"); + upButton.addActionListener(this); + + JPanel directoryPanel = new JPanel(new FlowLayout(FlowLayout.LEADING)); + directoryPanel.add(upButton); + directoryPanel.add(currentDirectory); + + JPanel filesViewPanel = new JPanel(new BorderLayout()); + filesViewPanel.add(directoryPanel, BorderLayout.NORTH); + filesViewPanel.add(filesView, BorderLayout.CENTER); + + splitPane.setRightComponent(filesViewPanel); splitPane.setDividerLocation(frame.gui.conf.getInt(CK.FILES_DIVIDER_LOCATION)); splitPane.addPropertyChangeListener(JSplitPane.DIVIDER_LOCATION_PROPERTY, this); @@ -521,6 +536,12 @@ public Component getTableCellRendererComponent(JTable table, public void actionPerformed(ActionEvent e) { if (e.getSource()==collapseTimer) { collapseOldNodes(); + } else if (e.getSource() == upButton) { + TreePath path = browseTree.getSelectionPath().getParentPath(); + if (path != null && path.getPathCount() > 1) { + browseTree.setSelectionPath(path); + browseTree.collapsePath(path); + } } else if (e.getActionCommand().equals("search")) { if (searchQuery.getText().equals("")) return; TreePath path = fs.newSearch(searchQuery.getText()).getPath(); @@ -612,7 +633,19 @@ public void mouseReleased(MouseEvent e) {} @Override public void valueChanged(TreeSelectionEvent e) { - if (e.getPath().getLastPathComponent() instanceof ListableEntry) fs.setSelectedEntry((ListableEntry) e.getPath().getLastPathComponent()); + if (e.getPath().getLastPathComponent() instanceof ListableEntry) { + fs.setSelectedEntry((ListableEntry) e.getPath().getLastPathComponent()); + } + if (e.getPath().getLastPathComponent() instanceof FileSystemEntry) { + FileSystemEntry fse = (FileSystemEntry) e.getPath().getLastPathComponent(); + if (fse.isSearch()) { + currentDirectory.setText(fse.getSearchTerms()); + } else if (fse.isDirectory()) { + currentDirectory.setText(fse.getIndexNodePath()); + } else { + currentDirectory.setText(""); + } + } } @Override From 2201fd9d277bc9ee8c16dc3c69d40cbfd1a99989 Mon Sep 17 00:00:00 2001 From: Ben Staddon Date: Tue, 25 Feb 2014 09:22:34 +0000 Subject: [PATCH 2/5] Added icon for up button --- icons/navigateup.png | Bin 0 -> 437 bytes src/client/gui/FilesTab.java | 7 ++++--- 2 files changed, 4 insertions(+), 3 deletions(-) create mode 100644 icons/navigateup.png diff --git a/icons/navigateup.png b/icons/navigateup.png new file mode 100644 index 0000000000000000000000000000000000000000..ac4c6b787b3965c73349f9d13a171a4a818d259f GIT binary patch literal 437 zcmV;m0ZRUfP)z-q?Zzf#zF~+lFUXdEtHM2V#>l(vF7CPK{O)t^JwSjK(uu>l{psVN^McC#g7XJ6Cr;QIa3W6M z?B3K_DL~oR&0;zcR@Dn9QXgxnZi8AyCY!Azav9;0p ze*z3>i5K?;wbgYnt{ER$iTgqV9Z-nuYZg_}N_4mP3^vp@tPU;r+kvHC`)3Eaw;XPt zZV-xu5NnNLI6eYX^d|lQmoOs8Twde(A&2~{3qu331kHDV?=Kk7KvdAv*@g7c5za5q zA5n%HQo=(08-PkgE240{JVdnlboDClm+KF330gu`VGI#eT*AS}9EjCl2Pt3@iS6wj f2nAZybFtn56H4Pg#gfWE00000NkvXXu0mjf9__=1 literal 0 HcmV?d00001 diff --git a/src/client/gui/FilesTab.java b/src/client/gui/FilesTab.java index 09e9a59..aeaa164 100644 --- a/src/client/gui/FilesTab.java +++ b/src/client/gui/FilesTab.java @@ -51,6 +51,7 @@ import common.FS2Constants; import common.ProgressTracker; import common.Util; + import client.indexnode.FileSystem; import client.indexnode.FileSystemEntry; import client.indexnode.ListableEntry; @@ -312,7 +313,7 @@ JPanel createSearchBar() { Timer collapseTimer; BrowseTreeCellRenderer browseTreeRenderer; - + JSplitPane createBrowseSection() { spinner = new LoadingAnimationHelper(); splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT); @@ -348,10 +349,10 @@ public boolean required(TreePath path) { filesTable.addMouseListener(this); filesTable.getSelectionModel().addListSelectionListener(this); filesTable.getColumn(fs.getColumnName(0)).setCellRenderer(new FilesTableNameRenderer()); - + JScrollPane filesView = new JScrollPane(filesTable); - upButton = new JButton("Up"); + upButton = new JButton("Up", frame.gui.util.getImage("navigateup")); upButton.addActionListener(this); JPanel directoryPanel = new JPanel(new FlowLayout(FlowLayout.LEADING)); From 151971400f2712a1473bfc07e487031fe2cedefa Mon Sep 17 00:00:00 2001 From: Ben Staddon Date: Wed, 26 Feb 2014 11:34:39 +0000 Subject: [PATCH 3/5] Clean up directory label --- src/client/gui/FilesTab.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/client/gui/FilesTab.java b/src/client/gui/FilesTab.java index aeaa164..dc69c6f 100644 --- a/src/client/gui/FilesTab.java +++ b/src/client/gui/FilesTab.java @@ -49,6 +49,7 @@ import javax.swing.tree.TreePath; import common.FS2Constants; +import common.HttpUtil; import common.ProgressTracker; import common.Util; @@ -642,7 +643,7 @@ public void valueChanged(TreeSelectionEvent e) { if (fse.isSearch()) { currentDirectory.setText(fse.getSearchTerms()); } else if (fse.isDirectory()) { - currentDirectory.setText(fse.getIndexNodePath()); + currentDirectory.setText(HttpUtil.urlDecode(fse.getIndexNodePath())); } else { currentDirectory.setText(""); } From 3d4cd3646344d197fec347739513fac1e64a07d7 Mon Sep 17 00:00:00 2001 From: Ben Staddon Date: Wed, 26 Feb 2014 14:14:10 +0000 Subject: [PATCH 4/5] Make navigation bar a bit more compact --- src/client/gui/FilesTab.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/client/gui/FilesTab.java b/src/client/gui/FilesTab.java index dc69c6f..3aa64ab 100644 --- a/src/client/gui/FilesTab.java +++ b/src/client/gui/FilesTab.java @@ -356,7 +356,7 @@ public boolean required(TreePath path) { upButton = new JButton("Up", frame.gui.util.getImage("navigateup")); upButton.addActionListener(this); - JPanel directoryPanel = new JPanel(new FlowLayout(FlowLayout.LEADING)); + JPanel directoryPanel = new JPanel(new FlowLayout(FlowLayout.LEADING, 5, 2)); directoryPanel.add(upButton); directoryPanel.add(currentDirectory); From a6504c9d13d0767164ce3a2b4d061bde16899fb4 Mon Sep 17 00:00:00 2001 From: Ben Staddon Date: Fri, 28 Feb 2014 23:54:20 +0000 Subject: [PATCH 5/5] Better variable names --- src/client/gui/FilesTab.java | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/client/gui/FilesTab.java b/src/client/gui/FilesTab.java index 3aa64ab..5e774f9 100644 --- a/src/client/gui/FilesTab.java +++ b/src/client/gui/FilesTab.java @@ -305,7 +305,7 @@ JPanel createSearchBar() { JTable filesTable; LoadingAnimationHelper spinner; JButton upButton; - JLabel currentDirectory; + JLabel directoryLabel; /** * Records the time at which tree nodes were expanded so that they may be collapsed if idle after a defined period. @@ -332,7 +332,7 @@ public boolean required(TreePath path) { }); fs.addTreeModelListener(spinner); - currentDirectory = new JLabel(); + directoryLabel = new JLabel(); browseTree.setCellRenderer(browseTreeRenderer = new BrowseTreeCellRenderer()); browseTree.addTreeSelectionListener(this); @@ -356,12 +356,12 @@ public boolean required(TreePath path) { upButton = new JButton("Up", frame.gui.util.getImage("navigateup")); upButton.addActionListener(this); - JPanel directoryPanel = new JPanel(new FlowLayout(FlowLayout.LEADING, 5, 2)); - directoryPanel.add(upButton); - directoryPanel.add(currentDirectory); + JPanel navigationPanel = new JPanel(new FlowLayout(FlowLayout.LEADING, 5, 2)); + navigationPanel.add(upButton); + navigationPanel.add(directoryLabel); JPanel filesViewPanel = new JPanel(new BorderLayout()); - filesViewPanel.add(directoryPanel, BorderLayout.NORTH); + filesViewPanel.add(navigationPanel, BorderLayout.NORTH); filesViewPanel.add(filesView, BorderLayout.CENTER); splitPane.setRightComponent(filesViewPanel); @@ -641,11 +641,11 @@ public void valueChanged(TreeSelectionEvent e) { if (e.getPath().getLastPathComponent() instanceof FileSystemEntry) { FileSystemEntry fse = (FileSystemEntry) e.getPath().getLastPathComponent(); if (fse.isSearch()) { - currentDirectory.setText(fse.getSearchTerms()); + directoryLabel.setText(fse.getSearchTerms()); } else if (fse.isDirectory()) { - currentDirectory.setText(HttpUtil.urlDecode(fse.getIndexNodePath())); + directoryLabel.setText(HttpUtil.urlDecode(fse.getIndexNodePath())); } else { - currentDirectory.setText(""); + directoryLabel.setText(""); } } }