Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added icons/navigateup.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
41 changes: 38 additions & 3 deletions src/client/gui/FilesTab.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -48,6 +49,7 @@
import javax.swing.tree.TreePath;

import common.FS2Constants;
import common.HttpUtil;
import common.ProgressTracker;
import common.Util;

Expand Down Expand Up @@ -302,7 +304,8 @@ JPanel createSearchBar() {
JSplitPane splitPane;
JTable filesTable;
LoadingAnimationHelper spinner;

JButton upButton;
JLabel directoryLabel;

/**
* Records the time at which tree nodes were expanded so that they may be collapsed if idle after a defined period.
Expand All @@ -329,6 +332,8 @@ public boolean required(TreePath path) {
});
fs.addTreeModelListener(spinner);

directoryLabel = new JLabel();

browseTree.setCellRenderer(browseTreeRenderer = new BrowseTreeCellRenderer());
browseTree.addTreeSelectionListener(this);
browseTree.addMouseMotionListener(this);
Expand All @@ -347,7 +352,19 @@ public boolean required(TreePath path) {
filesTable.getColumn(fs.getColumnName(0)).setCellRenderer(new FilesTableNameRenderer());

JScrollPane filesView = new JScrollPane(filesTable);
splitPane.setRightComponent(filesView);

upButton = new JButton("Up", frame.gui.util.getImage("navigateup"));
upButton.addActionListener(this);

JPanel navigationPanel = new JPanel(new FlowLayout(FlowLayout.LEADING, 5, 2));
navigationPanel.add(upButton);
navigationPanel.add(directoryLabel);

JPanel filesViewPanel = new JPanel(new BorderLayout());
filesViewPanel.add(navigationPanel, 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);

Expand Down Expand Up @@ -521,6 +538,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();
Expand Down Expand Up @@ -612,7 +635,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()) {
directoryLabel.setText(fse.getSearchTerms());
} else if (fse.isDirectory()) {
directoryLabel.setText(HttpUtil.urlDecode(fse.getIndexNodePath()));
} else {
directoryLabel.setText("");
}
}
}

@Override
Expand Down