Skip to content

Commit

Permalink
empty
Browse files Browse the repository at this point in the history
  • Loading branch information
rjolly committed May 5, 2018
1 parent 20e6ff0 commit 60fb1c7
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 17 deletions.
2 changes: 1 addition & 1 deletion src/main/java/linoleum/FileList.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public int getNextMatch(final String prefix, final int startIndex, final Positio
// start search from the next element before/after the selected element
final boolean backwards = (bias == Position.Bias.Backward);
for (int i = startIndex; backwards ? i >= 0 : i < max; i += (backwards ? -1 : 1)) {
final String filename = FileManager.getFileName(model.getElementAt(i));
final String filename = model.getElementAt(i).getFileName().toString();
if (filename.regionMatches(true, 0, prefix, 0, prefix.length())) {
return i;
}
Expand Down
29 changes: 14 additions & 15 deletions src/main/java/linoleum/FileManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ public Component getTableCellRendererComponent(final JTable table, final Object
setIcon(null);
if (value instanceof Path) {
setIcon(getFileIcon((Path) value));
setText(getFileName((Path) value));
setText(((Path) value).getFileName().toString());
} else if (value instanceof FileTime) {
setText(format.format(new Date(((FileTime) value).toMillis())));
}
Expand All @@ -137,7 +137,7 @@ public Object getCellEditorValue() {

@Override
public boolean stopCellEditing() {
applyEdit(getFileName((Path) getCellEditorValue()));
applyEdit(((Path) getCellEditorValue()).getFileName().toString());
return true;
}

Expand All @@ -154,7 +154,7 @@ public boolean isCellEditable(final EventObject anEvent) {
public Component getTableCellEditorComponent(final JTable table, final Object value, final boolean isSelected, final int row, final int column) {
final Component comp = super.getTableCellEditorComponent(table, value, isSelected, row, column);
if (value instanceof Path) {
((JTextField) comp).setText(getFileName((Path) value));
((JTextField) comp).setText(((Path) value).getFileName().toString());
}
return comp;
}
Expand Down Expand Up @@ -213,7 +213,7 @@ public boolean importData(final TransferHandler.TransferSupport support) {
}
}
for (final Path entry : files) {
final Path target = recipient.resolve(getFileName(entry));
final Path target = recipient.resolve(entry.getFileName().toString());
try {
if (!Files.isSameFile(recipient, entry) && !Files.isSameFile(recipient, getParent(entry))) switch (action) {
case COPY:
Expand Down Expand Up @@ -477,7 +477,7 @@ private void applyEdit() {

private void applyEdit(final String newFileName) {
if (editFile != null && Files.exists(editFile)) {
final String oldFileName = getFileName(editFile);
final String oldFileName = editFile.getFileName().toString();

if (!newFileName.equals(oldFileName)) try {
Files.move(editFile, editFile.resolveSibling(newFileName));
Expand Down Expand Up @@ -511,7 +511,7 @@ private void editFileName() {
editFile = jList1.getModel().getElementAt(index);
final Rectangle r = jList1.getCellBounds(index, index);
jList1.add(editCell);
editCell.setText(getFileName(editFile));
editCell.setText(editFile.getFileName().toString());
final ComponentOrientation orientation = jList1.getComponentOrientation();
editCell.setComponentOrientation(orientation);

Expand Down Expand Up @@ -566,7 +566,7 @@ public Component getListCellRendererComponent(final JList list, final Object val
}
final Path path = (Path)value;
setIcon(getFileIcon(path));
setText(getFileName(path));
setText(path.getFileName().toString());
setFont(list.getFont());
return this;
}
Expand Down Expand Up @@ -772,10 +772,14 @@ private void doOpen() {
if (fs == defaultfs) {
(thread = new Thread(this)).start();
} else {
setTitle(getFileName(path));
setTitle(getFileName(path).toString());
}
}

private Path getFileName(final Path path) {
return path.getNameCount() > 0?path.getFileName():path;
}

public void run() {
try (final WatchService service = fs.newWatchService()) {
WatchKey key = register(service);
Expand Down Expand Up @@ -816,17 +820,12 @@ private void process(final WatchEvent<?> event) {
}

private WatchKey register(final WatchService service) throws IOException {
setTitle(getFileName(path));
setTitle(path.getFileName().toString());
return path.register(service, StandardWatchEventKinds.ENTRY_CREATE, StandardWatchEventKinds.ENTRY_DELETE, StandardWatchEventKinds.ENTRY_MODIFY, StandardWatchEventKinds.OVERFLOW);
}

static String getFileName(final Path path) {
final int n = path.getNameCount();
return (n > 0?path.getName(n - 1):path).toString();
}

private Icon getFileIcon(final Path path) {
return getFileName(path).equals("..")?upFolderIcon:Files.isDirectory(path)?
return path.getFileName().toString().equals("..")?upFolderIcon:Files.isDirectory(path)?
Files.isSymbolicLink(path)?directoryLinkIcon:directoryIcon:
Files.isSymbolicLink(path)?fileLinkIcon:fileIcon;
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/linoleum/FileTable.java
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ private int getNextMatch(int startIndex, int finishIndex) {
// Search element
for (int index = startIndex; index <= finishIndex; index++) {
final Path path = (Path) model.getValueAt(rowSorter.convertRowIndexToModel(index), 0);
final String name = FileManager.getFileName(path);
final String name = path.getFileName().toString();
if (name.regionMatches(true, 0, prefix, 0, prefix.length())) {
return index;
}
Expand Down

0 comments on commit 60fb1c7

Please sign in to comment.