1 package ch
.cyberduck
.core
;
4 * Copyright (c) 2013 David Kocher. All rights reserved.
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * Bug fixes, suggestions and comments should be sent to:
18 * dkocher@cyberduck.ch
21 import java
.util
.List
;
26 public class Navigation
{
29 * Keeps a ordered backward history of previously visited paths
31 private List
<Path
> back
= new Collection
<Path
>();
34 * Keeps a ordered forward history of previously visited paths
36 private List
<Path
> forward
= new Collection
<Path
>();
41 public void add(final Path p
) {
43 // Do not add if this was a reload
44 if(p
.equals(back
.get(back
.size() - 1))) {
52 * Returns the prevously browsed path and moves it to the forward history
54 * @return The previously browsed path or null if there is none
57 int size
= back
.size();
59 forward
.add(back
.get(size
- 1));
60 Path p
= back
.get(size
- 2);
61 //delete the fetched path - otherwise we produce a loop
62 back
.remove(size
- 1);
63 back
.remove(size
- 2);
67 forward
.add(back
.get(size
- 1));
68 return back
.get(size
- 1);
74 * @return The last path browsed before #back was called
77 public Path
forward() {
78 int size
= forward
.size();
80 Path p
= forward
.get(size
- 1);
81 forward
.remove(size
- 1);
88 * @return The ordered array of previously visited directories
90 public List
<Path
> getBack() {
95 * @return The ordered array of previously visited directories
97 public List
<Path
> getForward() {
101 public void clear() {