author | Stephen Talley <stephen.talley@oracle.com> |
Mon, 28 Mar 2011 10:53:34 -0400 | |
changeset 685 | 767674b0a2fb |
parent 661 | b872751c9419 |
permissions | -rw-r--r-- |
0 | 1 |
/* |
2 |
* CDDL HEADER START |
|
3 |
* |
|
4 |
* The contents of this file are subject to the terms of the |
|
5 |
* Common Development and Distribution License (the "License"). |
|
6 |
* You may not use this file except in compliance with the License. |
|
7 |
* |
|
8 |
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE |
|
9 |
* or http://www.opensolaris.org/os/licensing. |
|
10 |
* See the License for the specific language governing permissions |
|
11 |
* and limitations under the License. |
|
12 |
* |
|
13 |
* When distributing Covered Code, include this CDDL HEADER in each |
|
14 |
* file and include the License file at usr/src/OPENSOLARIS.LICENSE. |
|
15 |
* If applicable, add the following below this CDDL HEADER, with the |
|
16 |
* fields enclosed by brackets "[]" replaced with your own identifying |
|
17 |
* information: Portions Copyright [yyyy] [name of copyright owner] |
|
18 |
* |
|
19 |
* CDDL HEADER END |
|
20 |
*/ |
|
21 |
||
22 |
/* |
|
657
9fdd9a66d201
17928 Control.start should allow broader range of failures
Stephen Talley <stephen.talley@oracle.com>
parents:
489
diff
changeset
|
23 |
* Copyright (c) 2010, 2011, Oracle and/or its affiliates. All rights reserved. |
0 | 24 |
*/ |
25 |
||
40
d1412af1ae5b
3215 ActionAbortedException is used too broadly
Stephen Talley <stephen.talley@sun.com>
parents:
30
diff
changeset
|
26 |
package org.opensolaris.os.vp.panel.common.control; |
0 | 27 |
|
28 |
import java.util.*; |
|
29 |
import java.util.concurrent.*; |
|
30 |
import java.util.regex.Pattern; |
|
219
57841c113efe
6788 package names should share o.o.o.vp prefix
Stephen Talley <stephen.talley@sun.com>
parents:
190
diff
changeset
|
31 |
import org.opensolaris.os.vp.util.misc.*; |
0 | 32 |
|
33 |
public class Navigator { |
|
34 |
// |
|
35 |
// Static data |
|
36 |
// |
|
37 |
||
38 |
public static final String PATH_SEPARATOR = "/"; |
|
39 |
public static final String PARENT_ID = ".."; |
|
323
497a785649eb
10071 apply new design to SMF panel
David Powell <David.Powell@sun.com>
parents:
304
diff
changeset
|
40 |
|
340
8bdbfc87f145
10594 sharemgr: new selection-based UI design
Stephen Talley <stephen.talley@sun.com>
parents:
323
diff
changeset
|
41 |
public static final Navigable PARENT_NAVIGABLE = |
8bdbfc87f145
10594 sharemgr: new selection-based UI design
Stephen Talley <stephen.talley@sun.com>
parents:
323
diff
changeset
|
42 |
new SimpleNavigable(PARENT_ID, null); |
323
497a785649eb
10071 apply new design to SMF panel
David Powell <David.Powell@sun.com>
parents:
304
diff
changeset
|
43 |
|
275
1e055a67a9b6
8094 Navigator interface could be simplified
Stephen Talley <stephen.talley@sun.com>
parents:
274
diff
changeset
|
44 |
private static int instanceCounter = 0; |
0 | 45 |
|
59
25cc24ff4f57
3329 navigation thread pool should be non-static, per-Navigator
Stephen Talley <stephen.talley@sun.com>
parents:
54
diff
changeset
|
46 |
// |
25cc24ff4f57
3329 navigation thread pool should be non-static, per-Navigator
Stephen Talley <stephen.talley@sun.com>
parents:
54
diff
changeset
|
47 |
// Instance data |
25cc24ff4f57
3329 navigation thread pool should be non-static, per-Navigator
Stephen Talley <stephen.talley@sun.com>
parents:
54
diff
changeset
|
48 |
// |
25cc24ff4f57
3329 navigation thread pool should be non-static, per-Navigator
Stephen Talley <stephen.talley@sun.com>
parents:
54
diff
changeset
|
49 |
|
25cc24ff4f57
3329 navigation thread pool should be non-static, per-Navigator
Stephen Talley <stephen.talley@sun.com>
parents:
54
diff
changeset
|
50 |
private Thread dispatchThread; |
25cc24ff4f57
3329 navigation thread pool should be non-static, per-Navigator
Stephen Talley <stephen.talley@sun.com>
parents:
54
diff
changeset
|
51 |
private ThreadPoolExecutor threadPool; |
190
555203a2de79
5952 Stack API should conform to java.util.Dequeue specification
Stephen Talley <stephen.talley@sun.com>
parents:
157
diff
changeset
|
52 |
private LinkedList<Control> stack = new LinkedList<Control>(); |
366
610ee2561491
10344 need to reload panel when server changes
Stephen Talley <stephen.talley@sun.com>
parents:
340
diff
changeset
|
53 |
private List<Control> roStack = Collections.unmodifiableList(stack); |
374
a7af53c5e114
12280 EventListeners performance/feature enhancements
Stephen Talley <stephen.talley@sun.com>
parents:
373
diff
changeset
|
54 |
private NavigationListeners listeners = new NavigationListeners(); |
373
faddb1b7fb76
12184 Navigator's address validation is incomplete, and uncompletable
Stephen Talley <stephen.talley@sun.com>
parents:
366
diff
changeset
|
55 |
private UITransitionManager manager = new UITransitionManager(); |
156
ad266190d7e6
4537 sysid: closing window during login + confirmation = hang
Stephen Talley <stephen.talley@sun.com>
parents:
139
diff
changeset
|
56 |
|
ad266190d7e6
4537 sysid: closing window during login + confirmation = hang
Stephen Talley <stephen.talley@sun.com>
parents:
139
diff
changeset
|
57 |
// |
ad266190d7e6
4537 sysid: closing window during login + confirmation = hang
Stephen Talley <stephen.talley@sun.com>
parents:
139
diff
changeset
|
58 |
// Constructors |
ad266190d7e6
4537 sysid: closing window during login + confirmation = hang
Stephen Talley <stephen.talley@sun.com>
parents:
139
diff
changeset
|
59 |
// |
ad266190d7e6
4537 sysid: closing window during login + confirmation = hang
Stephen Talley <stephen.talley@sun.com>
parents:
139
diff
changeset
|
60 |
|
275
1e055a67a9b6
8094 Navigator interface could be simplified
Stephen Talley <stephen.talley@sun.com>
parents:
274
diff
changeset
|
61 |
public Navigator() { |
304
6630c8b85735
9343 Class.getSimpleName is insufficient for most uses
Stephen Talley <stephen.talley@sun.com>
parents:
302
diff
changeset
|
62 |
String tName = String.format("%s-%d-", TextUtil.getBaseName(getClass()), |
275
1e055a67a9b6
8094 Navigator interface could be simplified
Stephen Talley <stephen.talley@sun.com>
parents:
274
diff
changeset
|
63 |
instanceCounter++); |
156
ad266190d7e6
4537 sysid: closing window during login + confirmation = hang
Stephen Talley <stephen.talley@sun.com>
parents:
139
diff
changeset
|
64 |
|
59
25cc24ff4f57
3329 navigation thread pool should be non-static, per-Navigator
Stephen Talley <stephen.talley@sun.com>
parents:
54
diff
changeset
|
65 |
ThreadFactory factory = |
156
ad266190d7e6
4537 sysid: closing window during login + confirmation = hang
Stephen Talley <stephen.talley@sun.com>
parents:
139
diff
changeset
|
66 |
new NamedThreadFactory(tName) { |
59
25cc24ff4f57
3329 navigation thread pool should be non-static, per-Navigator
Stephen Talley <stephen.talley@sun.com>
parents:
54
diff
changeset
|
67 |
@Override |
25cc24ff4f57
3329 navigation thread pool should be non-static, per-Navigator
Stephen Talley <stephen.talley@sun.com>
parents:
54
diff
changeset
|
68 |
public Thread newThread(Runnable r) { |
25cc24ff4f57
3329 navigation thread pool should be non-static, per-Navigator
Stephen Talley <stephen.talley@sun.com>
parents:
54
diff
changeset
|
69 |
dispatchThread = super.newThread(r); |
25cc24ff4f57
3329 navigation thread pool should be non-static, per-Navigator
Stephen Talley <stephen.talley@sun.com>
parents:
54
diff
changeset
|
70 |
return dispatchThread; |
25cc24ff4f57
3329 navigation thread pool should be non-static, per-Navigator
Stephen Talley <stephen.talley@sun.com>
parents:
54
diff
changeset
|
71 |
} |
25cc24ff4f57
3329 navigation thread pool should be non-static, per-Navigator
Stephen Talley <stephen.talley@sun.com>
parents:
54
diff
changeset
|
72 |
}; |
30
0ad10e34fb31
3025 Thread pools should be named for better diagnostics
Stephen Talley <stephen.talley@sun.com>
parents:
21
diff
changeset
|
73 |
|
0 | 74 |
// Unbounded |
75 |
BlockingQueue<Runnable> queue = new LinkedBlockingQueue<Runnable>(); |
|
76 |
||
390
62c7eb34e283
13347 sysmon: initial system monitor tray
Stephen Talley <stephen.talley@sun.com>
parents:
375
diff
changeset
|
77 |
// Use a thread pool with a single core thread to automatically handle |
62c7eb34e283
13347 sysmon: initial system monitor tray
Stephen Talley <stephen.talley@sun.com>
parents:
375
diff
changeset
|
78 |
// uncaught exceptions and queued requests. Use a minuscule timeout so |
62c7eb34e283
13347 sysmon: initial system monitor tray
Stephen Talley <stephen.talley@sun.com>
parents:
375
diff
changeset
|
79 |
// that threads herein don't hold up shutdown of the JVM. |
30
0ad10e34fb31
3025 Thread pools should be named for better diagnostics
Stephen Talley <stephen.talley@sun.com>
parents:
21
diff
changeset
|
80 |
threadPool = new ThreadPoolExecutor( |
390
62c7eb34e283
13347 sysmon: initial system monitor tray
Stephen Talley <stephen.talley@sun.com>
parents:
375
diff
changeset
|
81 |
1, 1, 1, TimeUnit.NANOSECONDS, queue, factory); |
0 | 82 |
|
30
0ad10e34fb31
3025 Thread pools should be named for better diagnostics
Stephen Talley <stephen.talley@sun.com>
parents:
21
diff
changeset
|
83 |
threadPool.allowCoreThreadTimeOut(true); |
373
faddb1b7fb76
12184 Navigator's address validation is incomplete, and uncompletable
Stephen Talley <stephen.talley@sun.com>
parents:
366
diff
changeset
|
84 |
|
faddb1b7fb76
12184 Navigator's address validation is incomplete, and uncompletable
Stephen Talley <stephen.talley@sun.com>
parents:
366
diff
changeset
|
85 |
addNavigationListener(manager); |
0 | 86 |
} |
87 |
||
88 |
// |
|
89 |
// Navigator methods |
|
90 |
// |
|
91 |
||
92 |
/** |
|
93 |
* Adds a {@link NavigationListener} to be notified when navigation is |
|
94 |
* stopped and started. |
|
95 |
*/ |
|
96 |
public void addNavigationListener(NavigationListener l) { |
|
97 |
listeners.add(l); |
|
98 |
} |
|
99 |
||
100 |
/** |
|
60
9a179bed654e
3334 navigation should be run solely on navigation thread
Stephen Talley <stephen.talley@sun.com>
parents:
59
diff
changeset
|
101 |
* Runs the given {@code Runnable} asynchronously on this {@code |
133
e1112f707f32
4258 navigator shouldn't navigate to root control in constructor
Stephen Talley <stephen.talley@sun.com>
parents:
68
diff
changeset
|
102 |
* Navigator}'s navigation thread. This thread is intended to be used |
60
9a179bed654e
3334 navigation should be run solely on navigation thread
Stephen Talley <stephen.talley@sun.com>
parents:
59
diff
changeset
|
103 |
* specifically for navigation; the given {@code Runnable} should thus be |
302
ac70675de834
9318 Navigator/Control should distinguish between cancel and non-cancel navigations
Stephen Talley <stephen.talley@sun.com>
parents:
275
diff
changeset
|
104 |
* limited to calling {@link #goTo(boolean,Control,Navigable...)} and |
ac70675de834
9318 Navigator/Control should distinguish between cancel and non-cancel navigations
Stephen Talley <stephen.talley@sun.com>
parents:
275
diff
changeset
|
105 |
* (briefly) handling any thrown exceptions. |
60
9a179bed654e
3334 navigation should be run solely on navigation thread
Stephen Talley <stephen.talley@sun.com>
parents:
59
diff
changeset
|
106 |
* <p/> |
9a179bed654e
3334 navigation should be run solely on navigation thread
Stephen Talley <stephen.talley@sun.com>
parents:
59
diff
changeset
|
107 |
* Note: If this method is called when the navigation thread is busy, the |
9a179bed654e
3334 navigation should be run solely on navigation thread
Stephen Talley <stephen.talley@sun.com>
parents:
59
diff
changeset
|
108 |
* given {@code Runnable} will be queued and run when the thread is |
9a179bed654e
3334 navigation should be run solely on navigation thread
Stephen Talley <stephen.talley@sun.com>
parents:
59
diff
changeset
|
109 |
* available. |
0 | 110 |
* |
111 |
* @param r |
|
60
9a179bed654e
3334 navigation should be run solely on navigation thread
Stephen Talley <stephen.talley@sun.com>
parents:
59
diff
changeset
|
112 |
* the {@code Runnable} to run and handle any resulting |
0 | 113 |
* exceptions |
114 |
*/ |
|
19
9c1f74f86687
2837 Minor spelling errors and inconsistencies
Stephen Talley <stephen.talley@sun.com>
parents:
0
diff
changeset
|
115 |
public void asyncExec(Runnable r) { |
30
0ad10e34fb31
3025 Thread pools should be named for better diagnostics
Stephen Talley <stephen.talley@sun.com>
parents:
21
diff
changeset
|
116 |
threadPool.execute(r); |
0 | 117 |
} |
118 |
||
119 |
/** |
|
68
712f02aa3c15
3348 After selecting existing login from new window, unable to close window
Stephen Talley <stephen.talley@sun.com>
parents:
60
diff
changeset
|
120 |
* Runs the given {@link NavRunnable} on this {@code Navigator}'s navigation |
712f02aa3c15
3348 After selecting existing login from new window, unable to close window
Stephen Talley <stephen.talley@sun.com>
parents:
60
diff
changeset
|
121 |
* thread and waits for it to complete. Any exceptions thrown by {@code r} |
712f02aa3c15
3348 After selecting existing login from new window, unable to close window
Stephen Talley <stephen.talley@sun.com>
parents:
60
diff
changeset
|
122 |
* are thrown here. |
60
9a179bed654e
3334 navigation should be run solely on navigation thread
Stephen Talley <stephen.talley@sun.com>
parents:
59
diff
changeset
|
123 |
* <p/> |
9a179bed654e
3334 navigation should be run solely on navigation thread
Stephen Talley <stephen.talley@sun.com>
parents:
59
diff
changeset
|
124 |
* See {@link #asyncExec}. |
9a179bed654e
3334 navigation should be run solely on navigation thread
Stephen Talley <stephen.talley@sun.com>
parents:
59
diff
changeset
|
125 |
* |
9a179bed654e
3334 navigation should be run solely on navigation thread
Stephen Talley <stephen.talley@sun.com>
parents:
59
diff
changeset
|
126 |
* @param r |
9a179bed654e
3334 navigation should be run solely on navigation thread
Stephen Talley <stephen.talley@sun.com>
parents:
59
diff
changeset
|
127 |
* the {@link NavRunnable} to run |
9a179bed654e
3334 navigation should be run solely on navigation thread
Stephen Talley <stephen.talley@sun.com>
parents:
59
diff
changeset
|
128 |
*/ |
9a179bed654e
3334 navigation should be run solely on navigation thread
Stephen Talley <stephen.talley@sun.com>
parents:
59
diff
changeset
|
129 |
public void asyncExecAndWait(final NavRunnable r) |
9a179bed654e
3334 navigation should be run solely on navigation thread
Stephen Talley <stephen.talley@sun.com>
parents:
59
diff
changeset
|
130 |
throws NavigationAbortedException, InvalidAddressException, |
373
faddb1b7fb76
12184 Navigator's address validation is incomplete, and uncompletable
Stephen Talley <stephen.talley@sun.com>
parents:
366
diff
changeset
|
131 |
MissingParameterException, InvalidParameterException, |
657
9fdd9a66d201
17928 Control.start should allow broader range of failures
Stephen Talley <stephen.talley@oracle.com>
parents:
489
diff
changeset
|
132 |
NavigationFailedException, EmptyNavigationStackException, |
9fdd9a66d201
17928 Control.start should allow broader range of failures
Stephen Talley <stephen.talley@oracle.com>
parents:
489
diff
changeset
|
133 |
RootNavigableNotControlException { |
60
9a179bed654e
3334 navigation should be run solely on navigation thread
Stephen Talley <stephen.talley@sun.com>
parents:
59
diff
changeset
|
134 |
|
68
712f02aa3c15
3348 After selecting existing login from new window, unable to close window
Stephen Talley <stephen.talley@sun.com>
parents:
60
diff
changeset
|
135 |
if (isDispatchThread()) { |
712f02aa3c15
3348 After selecting existing login from new window, unable to close window
Stephen Talley <stephen.talley@sun.com>
parents:
60
diff
changeset
|
136 |
r.run(); |
712f02aa3c15
3348 After selecting existing login from new window, unable to close window
Stephen Talley <stephen.talley@sun.com>
parents:
60
diff
changeset
|
137 |
return; |
712f02aa3c15
3348 After selecting existing login from new window, unable to close window
Stephen Talley <stephen.talley@sun.com>
parents:
60
diff
changeset
|
138 |
} |
712f02aa3c15
3348 After selecting existing login from new window, unable to close window
Stephen Talley <stephen.talley@sun.com>
parents:
60
diff
changeset
|
139 |
|
60
9a179bed654e
3334 navigation should be run solely on navigation thread
Stephen Talley <stephen.talley@sun.com>
parents:
59
diff
changeset
|
140 |
final boolean[] done = {false}; |
9a179bed654e
3334 navigation should be run solely on navigation thread
Stephen Talley <stephen.talley@sun.com>
parents:
59
diff
changeset
|
141 |
final Throwable[] throwable = {null}; |
9a179bed654e
3334 navigation should be run solely on navigation thread
Stephen Talley <stephen.talley@sun.com>
parents:
59
diff
changeset
|
142 |
|
9a179bed654e
3334 navigation should be run solely on navigation thread
Stephen Talley <stephen.talley@sun.com>
parents:
59
diff
changeset
|
143 |
asyncExec( |
9a179bed654e
3334 navigation should be run solely on navigation thread
Stephen Talley <stephen.talley@sun.com>
parents:
59
diff
changeset
|
144 |
new Runnable() { |
9a179bed654e
3334 navigation should be run solely on navigation thread
Stephen Talley <stephen.talley@sun.com>
parents:
59
diff
changeset
|
145 |
@Override |
9a179bed654e
3334 navigation should be run solely on navigation thread
Stephen Talley <stephen.talley@sun.com>
parents:
59
diff
changeset
|
146 |
public void run() { |
9a179bed654e
3334 navigation should be run solely on navigation thread
Stephen Talley <stephen.talley@sun.com>
parents:
59
diff
changeset
|
147 |
try { |
9a179bed654e
3334 navigation should be run solely on navigation thread
Stephen Talley <stephen.talley@sun.com>
parents:
59
diff
changeset
|
148 |
r.run(); |
9a179bed654e
3334 navigation should be run solely on navigation thread
Stephen Talley <stephen.talley@sun.com>
parents:
59
diff
changeset
|
149 |
} catch (Throwable t) { |
9a179bed654e
3334 navigation should be run solely on navigation thread
Stephen Talley <stephen.talley@sun.com>
parents:
59
diff
changeset
|
150 |
throwable[0] = t; |
9a179bed654e
3334 navigation should be run solely on navigation thread
Stephen Talley <stephen.talley@sun.com>
parents:
59
diff
changeset
|
151 |
} |
9a179bed654e
3334 navigation should be run solely on navigation thread
Stephen Talley <stephen.talley@sun.com>
parents:
59
diff
changeset
|
152 |
synchronized (done) { |
9a179bed654e
3334 navigation should be run solely on navigation thread
Stephen Talley <stephen.talley@sun.com>
parents:
59
diff
changeset
|
153 |
done[0] = true; |
9a179bed654e
3334 navigation should be run solely on navigation thread
Stephen Talley <stephen.talley@sun.com>
parents:
59
diff
changeset
|
154 |
done.notify(); |
9a179bed654e
3334 navigation should be run solely on navigation thread
Stephen Talley <stephen.talley@sun.com>
parents:
59
diff
changeset
|
155 |
} |
9a179bed654e
3334 navigation should be run solely on navigation thread
Stephen Talley <stephen.talley@sun.com>
parents:
59
diff
changeset
|
156 |
} |
9a179bed654e
3334 navigation should be run solely on navigation thread
Stephen Talley <stephen.talley@sun.com>
parents:
59
diff
changeset
|
157 |
}); |
9a179bed654e
3334 navigation should be run solely on navigation thread
Stephen Talley <stephen.talley@sun.com>
parents:
59
diff
changeset
|
158 |
|
9a179bed654e
3334 navigation should be run solely on navigation thread
Stephen Talley <stephen.talley@sun.com>
parents:
59
diff
changeset
|
159 |
// Sleep until nav thread is done |
9a179bed654e
3334 navigation should be run solely on navigation thread
Stephen Talley <stephen.talley@sun.com>
parents:
59
diff
changeset
|
160 |
synchronized (done) { |
9a179bed654e
3334 navigation should be run solely on navigation thread
Stephen Talley <stephen.talley@sun.com>
parents:
59
diff
changeset
|
161 |
while (!done[0]) { |
9a179bed654e
3334 navigation should be run solely on navigation thread
Stephen Talley <stephen.talley@sun.com>
parents:
59
diff
changeset
|
162 |
try { |
9a179bed654e
3334 navigation should be run solely on navigation thread
Stephen Talley <stephen.talley@sun.com>
parents:
59
diff
changeset
|
163 |
done.wait(); |
9a179bed654e
3334 navigation should be run solely on navigation thread
Stephen Talley <stephen.talley@sun.com>
parents:
59
diff
changeset
|
164 |
} catch (InterruptedException ignore) { |
9a179bed654e
3334 navigation should be run solely on navigation thread
Stephen Talley <stephen.talley@sun.com>
parents:
59
diff
changeset
|
165 |
} |
9a179bed654e
3334 navigation should be run solely on navigation thread
Stephen Talley <stephen.talley@sun.com>
parents:
59
diff
changeset
|
166 |
} |
9a179bed654e
3334 navigation should be run solely on navigation thread
Stephen Talley <stephen.talley@sun.com>
parents:
59
diff
changeset
|
167 |
} |
9a179bed654e
3334 navigation should be run solely on navigation thread
Stephen Talley <stephen.talley@sun.com>
parents:
59
diff
changeset
|
168 |
|
9a179bed654e
3334 navigation should be run solely on navigation thread
Stephen Talley <stephen.talley@sun.com>
parents:
59
diff
changeset
|
169 |
Throwable t = throwable[0]; |
9a179bed654e
3334 navigation should be run solely on navigation thread
Stephen Talley <stephen.talley@sun.com>
parents:
59
diff
changeset
|
170 |
if (t != null) { |
375
a368eea114ba
12302 asynchronously-thrown Throwables should have blocking thread's stack trace appended for debuggability
Stephen Talley <stephen.talley@sun.com>
parents:
374
diff
changeset
|
171 |
ThrowableUtil.appendStackTrace(t); |
a368eea114ba
12302 asynchronously-thrown Throwables should have blocking thread's stack trace appended for debuggability
Stephen Talley <stephen.talley@sun.com>
parents:
374
diff
changeset
|
172 |
|
60
9a179bed654e
3334 navigation should be run solely on navigation thread
Stephen Talley <stephen.talley@sun.com>
parents:
59
diff
changeset
|
173 |
if (t instanceof NavigationAbortedException) |
9a179bed654e
3334 navigation should be run solely on navigation thread
Stephen Talley <stephen.talley@sun.com>
parents:
59
diff
changeset
|
174 |
throw (NavigationAbortedException)t; |
9a179bed654e
3334 navigation should be run solely on navigation thread
Stephen Talley <stephen.talley@sun.com>
parents:
59
diff
changeset
|
175 |
|
9a179bed654e
3334 navigation should be run solely on navigation thread
Stephen Talley <stephen.talley@sun.com>
parents:
59
diff
changeset
|
176 |
if (t instanceof InvalidAddressException) |
9a179bed654e
3334 navigation should be run solely on navigation thread
Stephen Talley <stephen.talley@sun.com>
parents:
59
diff
changeset
|
177 |
throw (InvalidAddressException)t; |
9a179bed654e
3334 navigation should be run solely on navigation thread
Stephen Talley <stephen.talley@sun.com>
parents:
59
diff
changeset
|
178 |
|
9a179bed654e
3334 navigation should be run solely on navigation thread
Stephen Talley <stephen.talley@sun.com>
parents:
59
diff
changeset
|
179 |
if (t instanceof MissingParameterException) |
9a179bed654e
3334 navigation should be run solely on navigation thread
Stephen Talley <stephen.talley@sun.com>
parents:
59
diff
changeset
|
180 |
throw (MissingParameterException)t; |
9a179bed654e
3334 navigation should be run solely on navigation thread
Stephen Talley <stephen.talley@sun.com>
parents:
59
diff
changeset
|
181 |
|
9a179bed654e
3334 navigation should be run solely on navigation thread
Stephen Talley <stephen.talley@sun.com>
parents:
59
diff
changeset
|
182 |
if (t instanceof InvalidParameterException) |
9a179bed654e
3334 navigation should be run solely on navigation thread
Stephen Talley <stephen.talley@sun.com>
parents:
59
diff
changeset
|
183 |
throw (InvalidParameterException)t; |
9a179bed654e
3334 navigation should be run solely on navigation thread
Stephen Talley <stephen.talley@sun.com>
parents:
59
diff
changeset
|
184 |
|
661
b872751c9419
17927 rzd: zone console access
Stephen Talley <stephen.talley@oracle.com>
parents:
657
diff
changeset
|
185 |
if (t instanceof NavigationFailedException) |
b872751c9419
17927 rzd: zone console access
Stephen Talley <stephen.talley@oracle.com>
parents:
657
diff
changeset
|
186 |
throw (NavigationFailedException)t; |
b872751c9419
17927 rzd: zone console access
Stephen Talley <stephen.talley@oracle.com>
parents:
657
diff
changeset
|
187 |
|
373
faddb1b7fb76
12184 Navigator's address validation is incomplete, and uncompletable
Stephen Talley <stephen.talley@sun.com>
parents:
366
diff
changeset
|
188 |
if (t instanceof EmptyNavigationStackException) |
faddb1b7fb76
12184 Navigator's address validation is incomplete, and uncompletable
Stephen Talley <stephen.talley@sun.com>
parents:
366
diff
changeset
|
189 |
throw (EmptyNavigationStackException)t; |
faddb1b7fb76
12184 Navigator's address validation is incomplete, and uncompletable
Stephen Talley <stephen.talley@sun.com>
parents:
366
diff
changeset
|
190 |
|
faddb1b7fb76
12184 Navigator's address validation is incomplete, and uncompletable
Stephen Talley <stephen.talley@sun.com>
parents:
366
diff
changeset
|
191 |
if (t instanceof RootNavigableNotControlException) |
faddb1b7fb76
12184 Navigator's address validation is incomplete, and uncompletable
Stephen Talley <stephen.talley@sun.com>
parents:
366
diff
changeset
|
192 |
throw (RootNavigableNotControlException)t; |
faddb1b7fb76
12184 Navigator's address validation is incomplete, and uncompletable
Stephen Talley <stephen.talley@sun.com>
parents:
366
diff
changeset
|
193 |
|
60
9a179bed654e
3334 navigation should be run solely on navigation thread
Stephen Talley <stephen.talley@sun.com>
parents:
59
diff
changeset
|
194 |
if (t instanceof RuntimeException) |
9a179bed654e
3334 navigation should be run solely on navigation thread
Stephen Talley <stephen.talley@sun.com>
parents:
59
diff
changeset
|
195 |
throw (RuntimeException)t; |
9a179bed654e
3334 navigation should be run solely on navigation thread
Stephen Talley <stephen.talley@sun.com>
parents:
59
diff
changeset
|
196 |
|
9a179bed654e
3334 navigation should be run solely on navigation thread
Stephen Talley <stephen.talley@sun.com>
parents:
59
diff
changeset
|
197 |
if (t instanceof Error) |
9a179bed654e
3334 navigation should be run solely on navigation thread
Stephen Talley <stephen.talley@sun.com>
parents:
59
diff
changeset
|
198 |
throw (Error)t; |
9a179bed654e
3334 navigation should be run solely on navigation thread
Stephen Talley <stephen.talley@sun.com>
parents:
59
diff
changeset
|
199 |
|
9a179bed654e
3334 navigation should be run solely on navigation thread
Stephen Talley <stephen.talley@sun.com>
parents:
59
diff
changeset
|
200 |
// All Throwables should be accounted for |
9a179bed654e
3334 navigation should be run solely on navigation thread
Stephen Talley <stephen.talley@sun.com>
parents:
59
diff
changeset
|
201 |
assert false; |
9a179bed654e
3334 navigation should be run solely on navigation thread
Stephen Talley <stephen.talley@sun.com>
parents:
59
diff
changeset
|
202 |
} |
9a179bed654e
3334 navigation should be run solely on navigation thread
Stephen Talley <stephen.talley@sun.com>
parents:
59
diff
changeset
|
203 |
} |
9a179bed654e
3334 navigation should be run solely on navigation thread
Stephen Talley <stephen.talley@sun.com>
parents:
59
diff
changeset
|
204 |
|
9a179bed654e
3334 navigation should be run solely on navigation thread
Stephen Talley <stephen.talley@sun.com>
parents:
59
diff
changeset
|
205 |
/** |
0 | 206 |
* Notifies all registered {@link NavigationListener}s that a navigation has |
207 |
* begun. |
|
208 |
*/ |
|
373
faddb1b7fb76
12184 Navigator's address validation is incomplete, and uncompletable
Stephen Talley <stephen.talley@sun.com>
parents:
366
diff
changeset
|
209 |
protected void fireNavigationStarted(NavigationStartEvent e) { |
157
f4316b998c95
4857 all classes that handle event management should use EventListeners class
Stephen Talley <stephen.talley@sun.com>
parents:
156
diff
changeset
|
210 |
listeners.navigationStarted(e); |
0 | 211 |
} |
212 |
||
213 |
/** |
|
214 |
* Notifies all registered {@link NavigationListener}s that a navigation has |
|
215 |
* stopped. |
|
216 |
*/ |
|
373
faddb1b7fb76
12184 Navigator's address validation is incomplete, and uncompletable
Stephen Talley <stephen.talley@sun.com>
parents:
366
diff
changeset
|
217 |
protected void fireNavigationStopped(NavigationStopEvent e) { |
157
f4316b998c95
4857 all classes that handle event management should use EventListeners class
Stephen Talley <stephen.talley@sun.com>
parents:
156
diff
changeset
|
218 |
listeners.navigationStopped(e); |
0 | 219 |
} |
220 |
||
133
e1112f707f32
4258 navigator shouldn't navigate to root control in constructor
Stephen Talley <stephen.talley@sun.com>
parents:
68
diff
changeset
|
221 |
/** |
e1112f707f32
4258 navigator shouldn't navigate to root control in constructor
Stephen Talley <stephen.talley@sun.com>
parents:
68
diff
changeset
|
222 |
* Returns the current {@link Control}, or {@code null} if the root element |
e1112f707f32
4258 navigator shouldn't navigate to root control in constructor
Stephen Talley <stephen.talley@sun.com>
parents:
68
diff
changeset
|
223 |
* of the navigation stack has not yet been set. |
e1112f707f32
4258 navigator shouldn't navigate to root control in constructor
Stephen Talley <stephen.talley@sun.com>
parents:
68
diff
changeset
|
224 |
*/ |
e1112f707f32
4258 navigator shouldn't navigate to root control in constructor
Stephen Talley <stephen.talley@sun.com>
parents:
68
diff
changeset
|
225 |
public Control getCurrentControl() { |
e1112f707f32
4258 navigator shouldn't navigate to root control in constructor
Stephen Talley <stephen.talley@sun.com>
parents:
68
diff
changeset
|
226 |
synchronized (stack) { |
190
555203a2de79
5952 Stack API should conform to java.util.Dequeue specification
Stephen Talley <stephen.talley@sun.com>
parents:
157
diff
changeset
|
227 |
return stack.peekLast(); |
133
e1112f707f32
4258 navigator shouldn't navigate to root control in constructor
Stephen Talley <stephen.talley@sun.com>
parents:
68
diff
changeset
|
228 |
} |
e1112f707f32
4258 navigator shouldn't navigate to root control in constructor
Stephen Talley <stephen.talley@sun.com>
parents:
68
diff
changeset
|
229 |
} |
e1112f707f32
4258 navigator shouldn't navigate to root control in constructor
Stephen Talley <stephen.talley@sun.com>
parents:
68
diff
changeset
|
230 |
|
0 | 231 |
/** |
366
610ee2561491
10344 need to reload panel when server changes
Stephen Talley <stephen.talley@sun.com>
parents:
340
diff
changeset
|
232 |
* Gets a read-only wrapper around the list of elements of the current path, |
610ee2561491
10344 need to reload panel when server changes
Stephen Talley <stephen.talley@sun.com>
parents:
340
diff
changeset
|
233 |
* with the root element at the beginning of the list. The contents of the |
610ee2561491
10344 need to reload panel when server changes
Stephen Talley <stephen.talley@sun.com>
parents:
340
diff
changeset
|
234 |
* returned list are live, and will change with subsequent navigations. |
0 | 235 |
*/ |
236 |
public List<Control> getPath() { |
|
366
610ee2561491
10344 need to reload panel when server changes
Stephen Talley <stephen.talley@sun.com>
parents:
340
diff
changeset
|
237 |
return roStack; |
0 | 238 |
} |
239 |
||
240 |
/** |
|
366
610ee2561491
10344 need to reload panel when server changes
Stephen Talley <stephen.talley@sun.com>
parents:
340
diff
changeset
|
241 |
* Gets the current path as a {@code String}. |
0 | 242 |
*/ |
243 |
public String getPathString() { |
|
54
ffbdd1a03fca
3305 consumers of Navigator's getPath subject to ConcurrentModificationExceptions
Stephen Talley <stephen.talley@sun.com>
parents:
40
diff
changeset
|
244 |
return getPathString(stack); |
0 | 245 |
} |
246 |
||
247 |
/** |
|
248 |
* Navigates to the {@link Control} identified by the given path. |
|
249 |
* |
|
302
ac70675de834
9318 Navigator/Control should distinguish between cancel and non-cancel navigations
Stephen Talley <stephen.talley@sun.com>
parents:
275
diff
changeset
|
250 |
* @param cancel |
ac70675de834
9318 Navigator/Control should distinguish between cancel and non-cancel navigations
Stephen Talley <stephen.talley@sun.com>
parents:
275
diff
changeset
|
251 |
* {@code true} if the {@code Control}s, if any, that are |
ac70675de834
9318 Navigator/Control should distinguish between cancel and non-cancel navigations
Stephen Talley <stephen.talley@sun.com>
parents:
275
diff
changeset
|
252 |
* stopped as part of this navigation should be cancelled, |
ac70675de834
9318 Navigator/Control should distinguish between cancel and non-cancel navigations
Stephen Talley <stephen.talley@sun.com>
parents:
275
diff
changeset
|
253 |
* {@code false} otherwise; this parameter is passed along to |
ac70675de834
9318 Navigator/Control should distinguish between cancel and non-cancel navigations
Stephen Talley <stephen.talley@sun.com>
parents:
275
diff
changeset
|
254 |
* the {@link Control#stop} method |
ac70675de834
9318 Navigator/Control should distinguish between cancel and non-cancel navigations
Stephen Talley <stephen.talley@sun.com>
parents:
275
diff
changeset
|
255 |
* |
0 | 256 |
* @param relativeTo |
257 |
* a {@link Control} within the navigation stack to which |
|
258 |
* {@code path} is relative, or {@code null} if {@code path} is |
|
259 |
* absolute |
|
260 |
* |
|
261 |
* @param path |
|
262 |
* the path (relative to {@code relativeTo}), or unspecified to |
|
133
e1112f707f32
4258 navigator shouldn't navigate to root control in constructor
Stephen Talley <stephen.talley@sun.com>
parents:
68
diff
changeset
|
263 |
* navigate up the stack to {@code relativeTo}; if the root of |
e1112f707f32
4258 navigator shouldn't navigate to root control in constructor
Stephen Talley <stephen.talley@sun.com>
parents:
68
diff
changeset
|
264 |
* this {@code Navigator} has not yet been set, the first |
e1112f707f32
4258 navigator shouldn't navigate to root control in constructor
Stephen Talley <stephen.talley@sun.com>
parents:
68
diff
changeset
|
265 |
* element of this path <strong>must</strong> be a {@link |
e1112f707f32
4258 navigator shouldn't navigate to root control in constructor
Stephen Talley <stephen.talley@sun.com>
parents:
68
diff
changeset
|
266 |
* Control} |
0 | 267 |
* |
373
faddb1b7fb76
12184 Navigator's address validation is incomplete, and uncompletable
Stephen Talley <stephen.talley@sun.com>
parents:
366
diff
changeset
|
268 |
* @return a {@link Navigable} array that can be used to return to the |
faddb1b7fb76
12184 Navigator's address validation is incomplete, and uncompletable
Stephen Talley <stephen.talley@sun.com>
parents:
366
diff
changeset
|
269 |
* previously current {@link #getPath path} (with the first |
faddb1b7fb76
12184 Navigator's address validation is incomplete, and uncompletable
Stephen Talley <stephen.talley@sun.com>
parents:
366
diff
changeset
|
270 |
* element a {@link Control}, as required by the {@code path} |
faddb1b7fb76
12184 Navigator's address validation is incomplete, and uncompletable
Stephen Talley <stephen.talley@sun.com>
parents:
366
diff
changeset
|
271 |
* parameter of this method) |
0 | 272 |
* |
40
d1412af1ae5b
3215 ActionAbortedException is used too broadly
Stephen Talley <stephen.talley@sun.com>
parents:
30
diff
changeset
|
273 |
* @exception NavigationAbortedException |
0 | 274 |
* if the navigation is vetoed |
275 |
* |
|
276 |
* @exception InvalidAddressException |
|
373
faddb1b7fb76
12184 Navigator's address validation is incomplete, and uncompletable
Stephen Talley <stephen.talley@sun.com>
parents:
366
diff
changeset
|
277 |
* if some {@link Navigable} in {@code path} does not refer to |
faddb1b7fb76
12184 Navigator's address validation is incomplete, and uncompletable
Stephen Talley <stephen.talley@sun.com>
parents:
366
diff
changeset
|
278 |
* a valid {@link Control} |
0 | 279 |
* |
280 |
* @exception MissingParameterException |
|
281 |
* if some {@link Control} in the process of navigation could |
|
282 |
* not be {@link Control#start started} due to a missing |
|
657
9fdd9a66d201
17928 Control.start should allow broader range of failures
Stephen Talley <stephen.talley@oracle.com>
parents:
489
diff
changeset
|
283 |
* initialization parameter |
0 | 284 |
* |
285 |
* @exception InvalidParameterException |
|
286 |
* if some {@link Control} in the process of navigation could |
|
287 |
* not be {@link Control#start started} due to an invalid |
|
657
9fdd9a66d201
17928 Control.start should allow broader range of failures
Stephen Talley <stephen.talley@oracle.com>
parents:
489
diff
changeset
|
288 |
* initialization parameter |
9fdd9a66d201
17928 Control.start should allow broader range of failures
Stephen Talley <stephen.talley@oracle.com>
parents:
489
diff
changeset
|
289 |
* |
9fdd9a66d201
17928 Control.start should allow broader range of failures
Stephen Talley <stephen.talley@oracle.com>
parents:
489
diff
changeset
|
290 |
* @exception NavigationFailedException |
9fdd9a66d201
17928 Control.start should allow broader range of failures
Stephen Talley <stephen.talley@oracle.com>
parents:
489
diff
changeset
|
291 |
* if a {@link Control} could not be started for some other |
9fdd9a66d201
17928 Control.start should allow broader range of failures
Stephen Talley <stephen.talley@oracle.com>
parents:
489
diff
changeset
|
292 |
* reason |
0 | 293 |
* |
373
faddb1b7fb76
12184 Navigator's address validation is incomplete, and uncompletable
Stephen Talley <stephen.talley@sun.com>
parents:
366
diff
changeset
|
294 |
* @exception EmptyNavigationStackException |
faddb1b7fb76
12184 Navigator's address validation is incomplete, and uncompletable
Stephen Talley <stephen.talley@sun.com>
parents:
366
diff
changeset
|
295 |
* if the navigation stack is empty and the next {@link |
faddb1b7fb76
12184 Navigator's address validation is incomplete, and uncompletable
Stephen Talley <stephen.talley@sun.com>
parents:
366
diff
changeset
|
296 |
* Navigable} in {@code path} has an ID of {@link #PARENT_ID} |
faddb1b7fb76
12184 Navigator's address validation is incomplete, and uncompletable
Stephen Talley <stephen.talley@sun.com>
parents:
366
diff
changeset
|
297 |
* |
faddb1b7fb76
12184 Navigator's address validation is incomplete, and uncompletable
Stephen Talley <stephen.talley@sun.com>
parents:
366
diff
changeset
|
298 |
* @exception RootNavigableNotControlException |
faddb1b7fb76
12184 Navigator's address validation is incomplete, and uncompletable
Stephen Talley <stephen.talley@sun.com>
parents:
366
diff
changeset
|
299 |
* if the navigation stack is empty and the next {@link |
faddb1b7fb76
12184 Navigator's address validation is incomplete, and uncompletable
Stephen Talley <stephen.talley@sun.com>
parents:
366
diff
changeset
|
300 |
* Navigable} in {@code path} is not a {@link Control} |
faddb1b7fb76
12184 Navigator's address validation is incomplete, and uncompletable
Stephen Talley <stephen.talley@sun.com>
parents:
366
diff
changeset
|
301 |
* |
0 | 302 |
* @exception IllegalArgumentException |
303 |
* if {@code relativeTo} is not in the navigation stack |
|
304 |
*/ |
|
373
faddb1b7fb76
12184 Navigator's address validation is incomplete, and uncompletable
Stephen Talley <stephen.talley@sun.com>
parents:
366
diff
changeset
|
305 |
public Navigable[] goTo(boolean cancel, Control relativeTo, |
faddb1b7fb76
12184 Navigator's address validation is incomplete, and uncompletable
Stephen Talley <stephen.talley@sun.com>
parents:
366
diff
changeset
|
306 |
Navigable... path) throws NavigationAbortedException, |
faddb1b7fb76
12184 Navigator's address validation is incomplete, and uncompletable
Stephen Talley <stephen.talley@sun.com>
parents:
366
diff
changeset
|
307 |
InvalidAddressException, MissingParameterException, |
657
9fdd9a66d201
17928 Control.start should allow broader range of failures
Stephen Talley <stephen.talley@oracle.com>
parents:
489
diff
changeset
|
308 |
InvalidParameterException, NavigationFailedException, |
9fdd9a66d201
17928 Control.start should allow broader range of failures
Stephen Talley <stephen.talley@oracle.com>
parents:
489
diff
changeset
|
309 |
EmptyNavigationStackException, RootNavigableNotControlException { |
0 | 310 |
|
60
9a179bed654e
3334 navigation should be run solely on navigation thread
Stephen Talley <stephen.talley@sun.com>
parents:
59
diff
changeset
|
311 |
assert isDispatchThread(); |
9a179bed654e
3334 navigation should be run solely on navigation thread
Stephen Talley <stephen.talley@sun.com>
parents:
59
diff
changeset
|
312 |
|
0 | 313 |
synchronized (stack) { |
373
faddb1b7fb76
12184 Navigator's address validation is incomplete, and uncompletable
Stephen Talley <stephen.talley@sun.com>
parents:
366
diff
changeset
|
314 |
// The original path, before navigation |
faddb1b7fb76
12184 Navigator's address validation is incomplete, and uncompletable
Stephen Talley <stephen.talley@sun.com>
parents:
366
diff
changeset
|
315 |
int n = stack.size(); |
faddb1b7fb76
12184 Navigator's address validation is incomplete, and uncompletable
Stephen Talley <stephen.talley@sun.com>
parents:
366
diff
changeset
|
316 |
Navigable[] last = new Navigable[n]; |
faddb1b7fb76
12184 Navigator's address validation is incomplete, and uncompletable
Stephen Talley <stephen.talley@sun.com>
parents:
366
diff
changeset
|
317 |
for (int i = 0; i < n; i++) { |
faddb1b7fb76
12184 Navigator's address validation is incomplete, and uncompletable
Stephen Talley <stephen.talley@sun.com>
parents:
366
diff
changeset
|
318 |
Control c = stack.get(i); |
faddb1b7fb76
12184 Navigator's address validation is incomplete, and uncompletable
Stephen Talley <stephen.talley@sun.com>
parents:
366
diff
changeset
|
319 |
last[i] = i == 0 ? c : new SimpleNavigable( |
faddb1b7fb76
12184 Navigator's address validation is incomplete, and uncompletable
Stephen Talley <stephen.talley@sun.com>
parents:
366
diff
changeset
|
320 |
c.getId(), c.getName(), c.getParameters()); |
faddb1b7fb76
12184 Navigator's address validation is incomplete, and uncompletable
Stephen Talley <stephen.talley@sun.com>
parents:
366
diff
changeset
|
321 |
} |
0 | 322 |
|
258
521fd086e813
7977 navigator: getForwardingPath should be called after Control is started
Stephen Talley <stephen.talley@sun.com>
parents:
251
diff
changeset
|
323 |
List<Control> stopped = new ArrayList<Control>(); |
521fd086e813
7977 navigator: getForwardingPath should be called after Control is started
Stephen Talley <stephen.talley@sun.com>
parents:
251
diff
changeset
|
324 |
List<Control> started = new ArrayList<Control>(); |
373
faddb1b7fb76
12184 Navigator's address validation is incomplete, and uncompletable
Stephen Talley <stephen.talley@sun.com>
parents:
366
diff
changeset
|
325 |
NavigationException exception = null; |
261
56505bb0e870
8005 aborted navigation can result in blocked UI
Stephen Talley <stephen.talley@sun.com>
parents:
258
diff
changeset
|
326 |
boolean needStopEvent = false; |
251
2d4060817fe2
7905 NavigationListeners that resize a window or handle UI flicker should not be tied to a specific Window
Stephen Talley <stephen.talley@sun.com>
parents:
248
diff
changeset
|
327 |
|
258
521fd086e813
7977 navigator: getForwardingPath should be called after Control is started
Stephen Talley <stephen.talley@sun.com>
parents:
251
diff
changeset
|
328 |
try { |
521fd086e813
7977 navigator: getForwardingPath should be called after Control is started
Stephen Talley <stephen.talley@sun.com>
parents:
251
diff
changeset
|
329 |
boolean done = false; |
521fd086e813
7977 navigator: getForwardingPath should be called after Control is started
Stephen Talley <stephen.talley@sun.com>
parents:
251
diff
changeset
|
330 |
while (!done) { |
373
faddb1b7fb76
12184 Navigator's address validation is incomplete, and uncompletable
Stephen Talley <stephen.talley@sun.com>
parents:
366
diff
changeset
|
331 |
// Destination path (absolute) |
faddb1b7fb76
12184 Navigator's address validation is incomplete, and uncompletable
Stephen Talley <stephen.talley@sun.com>
parents:
366
diff
changeset
|
332 |
LinkedList<Navigable> dPath = new LinkedList<Navigable>(); |
0 | 333 |
|
258
521fd086e813
7977 navigator: getForwardingPath should be called after Control is started
Stephen Talley <stephen.talley@sun.com>
parents:
251
diff
changeset
|
334 |
if (relativeTo != null) { |
373
faddb1b7fb76
12184 Navigator's address validation is incomplete, and uncompletable
Stephen Talley <stephen.talley@sun.com>
parents:
366
diff
changeset
|
335 |
dPath.addAll(stack); |
258
521fd086e813
7977 navigator: getForwardingPath should be called after Control is started
Stephen Talley <stephen.talley@sun.com>
parents:
251
diff
changeset
|
336 |
try { |
521fd086e813
7977 navigator: getForwardingPath should be called after Control is started
Stephen Talley <stephen.talley@sun.com>
parents:
251
diff
changeset
|
337 |
// Remove path elements until relativeTo is at top |
373
faddb1b7fb76
12184 Navigator's address validation is incomplete, and uncompletable
Stephen Talley <stephen.talley@sun.com>
parents:
366
diff
changeset
|
338 |
while (!((HasControl)dPath.getLast()).getControl(). |
258
521fd086e813
7977 navigator: getForwardingPath should be called after Control is started
Stephen Talley <stephen.talley@sun.com>
parents:
251
diff
changeset
|
339 |
equals(relativeTo)) { |
373
faddb1b7fb76
12184 Navigator's address validation is incomplete, and uncompletable
Stephen Talley <stephen.talley@sun.com>
parents:
366
diff
changeset
|
340 |
dPath.removeLast(); |
258
521fd086e813
7977 navigator: getForwardingPath should be called after Control is started
Stephen Talley <stephen.talley@sun.com>
parents:
251
diff
changeset
|
341 |
} |
521fd086e813
7977 navigator: getForwardingPath should be called after Control is started
Stephen Talley <stephen.talley@sun.com>
parents:
251
diff
changeset
|
342 |
} catch (NoSuchElementException e) { |
521fd086e813
7977 navigator: getForwardingPath should be called after Control is started
Stephen Talley <stephen.talley@sun.com>
parents:
251
diff
changeset
|
343 |
throw new IllegalArgumentException(String.format( |
521fd086e813
7977 navigator: getForwardingPath should be called after Control is started
Stephen Talley <stephen.talley@sun.com>
parents:
251
diff
changeset
|
344 |
"Control not in navigation path: %s (%s)", |
521fd086e813
7977 navigator: getForwardingPath should be called after Control is started
Stephen Talley <stephen.talley@sun.com>
parents:
251
diff
changeset
|
345 |
relativeTo.getClass().getName(), |
521fd086e813
7977 navigator: getForwardingPath should be called after Control is started
Stephen Talley <stephen.talley@sun.com>
parents:
251
diff
changeset
|
346 |
relativeTo.getId())); |
0 | 347 |
} |
348 |
} |
|
258
521fd086e813
7977 navigator: getForwardingPath should be called after Control is started
Stephen Talley <stephen.talley@sun.com>
parents:
251
diff
changeset
|
349 |
|
521fd086e813
7977 navigator: getForwardingPath should be called after Control is started
Stephen Talley <stephen.talley@sun.com>
parents:
251
diff
changeset
|
350 |
if (path.length != 0) { |
373
faddb1b7fb76
12184 Navigator's address validation is incomplete, and uncompletable
Stephen Talley <stephen.talley@sun.com>
parents:
366
diff
changeset
|
351 |
CollectionUtil.addAll(dPath, path); |
258
521fd086e813
7977 navigator: getForwardingPath should be called after Control is started
Stephen Talley <stephen.talley@sun.com>
parents:
251
diff
changeset
|
352 |
|
521fd086e813
7977 navigator: getForwardingPath should be called after Control is started
Stephen Talley <stephen.talley@sun.com>
parents:
251
diff
changeset
|
353 |
// Remove unnecessary ".." segments |
373
faddb1b7fb76
12184 Navigator's address validation is incomplete, and uncompletable
Stephen Talley <stephen.talley@sun.com>
parents:
366
diff
changeset
|
354 |
normalize(dPath); |
258
521fd086e813
7977 navigator: getForwardingPath should be called after Control is started
Stephen Talley <stephen.talley@sun.com>
parents:
251
diff
changeset
|
355 |
} |
521fd086e813
7977 navigator: getForwardingPath should be called after Control is started
Stephen Talley <stephen.talley@sun.com>
parents:
251
diff
changeset
|
356 |
|
373
faddb1b7fb76
12184 Navigator's address validation is incomplete, and uncompletable
Stephen Talley <stephen.talley@sun.com>
parents:
366
diff
changeset
|
357 |
List<Navigable> relPath = getRelativePath(stack, dPath); |
258
521fd086e813
7977 navigator: getForwardingPath should be called after Control is started
Stephen Talley <stephen.talley@sun.com>
parents:
251
diff
changeset
|
358 |
if (!relPath.isEmpty()) { |
521fd086e813
7977 navigator: getForwardingPath should be called after Control is started
Stephen Talley <stephen.talley@sun.com>
parents:
251
diff
changeset
|
359 |
|
373
faddb1b7fb76
12184 Navigator's address validation is incomplete, and uncompletable
Stephen Talley <stephen.talley@sun.com>
parents:
366
diff
changeset
|
360 |
List<Navigable> roRelPath = |
faddb1b7fb76
12184 Navigator's address validation is incomplete, and uncompletable
Stephen Talley <stephen.talley@sun.com>
parents:
366
diff
changeset
|
361 |
Collections.unmodifiableList(relPath); |
faddb1b7fb76
12184 Navigator's address validation is incomplete, and uncompletable
Stephen Talley <stephen.talley@sun.com>
parents:
366
diff
changeset
|
362 |
List<Navigable> roDPath = |
faddb1b7fb76
12184 Navigator's address validation is incomplete, and uncompletable
Stephen Talley <stephen.talley@sun.com>
parents:
366
diff
changeset
|
363 |
Collections.unmodifiableList(dPath); |
faddb1b7fb76
12184 Navigator's address validation is incomplete, and uncompletable
Stephen Talley <stephen.talley@sun.com>
parents:
366
diff
changeset
|
364 |
NavigationStartEvent event = |
faddb1b7fb76
12184 Navigator's address validation is incomplete, and uncompletable
Stephen Talley <stephen.talley@sun.com>
parents:
366
diff
changeset
|
365 |
new NavigationStartEvent(this, roDPath, |
faddb1b7fb76
12184 Navigator's address validation is incomplete, and uncompletable
Stephen Talley <stephen.talley@sun.com>
parents:
366
diff
changeset
|
366 |
roRelPath); |
258
521fd086e813
7977 navigator: getForwardingPath should be called after Control is started
Stephen Talley <stephen.talley@sun.com>
parents:
251
diff
changeset
|
367 |
|
521fd086e813
7977 navigator: getForwardingPath should be called after Control is started
Stephen Talley <stephen.talley@sun.com>
parents:
251
diff
changeset
|
368 |
fireNavigationStarted(event); |
261
56505bb0e870
8005 aborted navigation can result in blocked UI
Stephen Talley <stephen.talley@sun.com>
parents:
258
diff
changeset
|
369 |
needStopEvent = true; |
258
521fd086e813
7977 navigator: getForwardingPath should be called after Control is started
Stephen Talley <stephen.talley@sun.com>
parents:
251
diff
changeset
|
370 |
|
373
faddb1b7fb76
12184 Navigator's address validation is incomplete, and uncompletable
Stephen Talley <stephen.talley@sun.com>
parents:
366
diff
changeset
|
371 |
// Iterate through relPath, adding/removing elements |
faddb1b7fb76
12184 Navigator's address validation is incomplete, and uncompletable
Stephen Talley <stephen.talley@sun.com>
parents:
366
diff
changeset
|
372 |
// to/from stack as appropriate |
faddb1b7fb76
12184 Navigator's address validation is incomplete, and uncompletable
Stephen Talley <stephen.talley@sun.com>
parents:
366
diff
changeset
|
373 |
for (Navigable nav : relPath) { |
258
521fd086e813
7977 navigator: getForwardingPath should be called after Control is started
Stephen Talley <stephen.talley@sun.com>
parents:
251
diff
changeset
|
374 |
Control curControl = getCurrentControl(); |
521fd086e813
7977 navigator: getForwardingPath should be called after Control is started
Stephen Talley <stephen.talley@sun.com>
parents:
251
diff
changeset
|
375 |
|
373
faddb1b7fb76
12184 Navigator's address validation is incomplete, and uncompletable
Stephen Talley <stephen.talley@sun.com>
parents:
366
diff
changeset
|
376 |
if (nav.getId().equals(PARENT_ID)) { |
faddb1b7fb76
12184 Navigator's address validation is incomplete, and uncompletable
Stephen Talley <stephen.talley@sun.com>
parents:
366
diff
changeset
|
377 |
if (curControl == null) { |
faddb1b7fb76
12184 Navigator's address validation is incomplete, and uncompletable
Stephen Talley <stephen.talley@sun.com>
parents:
366
diff
changeset
|
378 |
throw new EmptyNavigationStackException(); |
faddb1b7fb76
12184 Navigator's address validation is incomplete, and uncompletable
Stephen Talley <stephen.talley@sun.com>
parents:
366
diff
changeset
|
379 |
} |
faddb1b7fb76
12184 Navigator's address validation is incomplete, and uncompletable
Stephen Talley <stephen.talley@sun.com>
parents:
366
diff
changeset
|
380 |
|
302
ac70675de834
9318 Navigator/Control should distinguish between cancel and non-cancel navigations
Stephen Talley <stephen.talley@sun.com>
parents:
275
diff
changeset
|
381 |
curControl.stop(cancel); |
258
521fd086e813
7977 navigator: getForwardingPath should be called after Control is started
Stephen Talley <stephen.talley@sun.com>
parents:
251
diff
changeset
|
382 |
stopped.add(curControl); |
521fd086e813
7977 navigator: getForwardingPath should be called after Control is started
Stephen Talley <stephen.talley@sun.com>
parents:
251
diff
changeset
|
383 |
stack.removeLast(); |
521fd086e813
7977 navigator: getForwardingPath should be called after Control is started
Stephen Talley <stephen.talley@sun.com>
parents:
251
diff
changeset
|
384 |
descendantStopped(curControl); |
521fd086e813
7977 navigator: getForwardingPath should be called after Control is started
Stephen Talley <stephen.talley@sun.com>
parents:
251
diff
changeset
|
385 |
} else { |
373
faddb1b7fb76
12184 Navigator's address validation is incomplete, and uncompletable
Stephen Talley <stephen.talley@sun.com>
parents:
366
diff
changeset
|
386 |
Control newControl; |
258
521fd086e813
7977 navigator: getForwardingPath should be called after Control is started
Stephen Talley <stephen.talley@sun.com>
parents:
251
diff
changeset
|
387 |
|
373
faddb1b7fb76
12184 Navigator's address validation is incomplete, and uncompletable
Stephen Talley <stephen.talley@sun.com>
parents:
366
diff
changeset
|
388 |
if (curControl == null) { |
faddb1b7fb76
12184 Navigator's address validation is incomplete, and uncompletable
Stephen Talley <stephen.talley@sun.com>
parents:
366
diff
changeset
|
389 |
try { |
faddb1b7fb76
12184 Navigator's address validation is incomplete, and uncompletable
Stephen Talley <stephen.talley@sun.com>
parents:
366
diff
changeset
|
390 |
newControl = (Control)nav; |
faddb1b7fb76
12184 Navigator's address validation is incomplete, and uncompletable
Stephen Talley <stephen.talley@sun.com>
parents:
366
diff
changeset
|
391 |
} catch (ClassCastException e) { |
faddb1b7fb76
12184 Navigator's address validation is incomplete, and uncompletable
Stephen Talley <stephen.talley@sun.com>
parents:
366
diff
changeset
|
392 |
throw new |
faddb1b7fb76
12184 Navigator's address validation is incomplete, and uncompletable
Stephen Talley <stephen.talley@sun.com>
parents:
366
diff
changeset
|
393 |
RootNavigableNotControlException( |
faddb1b7fb76
12184 Navigator's address validation is incomplete, and uncompletable
Stephen Talley <stephen.talley@sun.com>
parents:
366
diff
changeset
|
394 |
nav); |
faddb1b7fb76
12184 Navigator's address validation is incomplete, and uncompletable
Stephen Talley <stephen.talley@sun.com>
parents:
366
diff
changeset
|
395 |
} |
faddb1b7fb76
12184 Navigator's address validation is incomplete, and uncompletable
Stephen Talley <stephen.talley@sun.com>
parents:
366
diff
changeset
|
396 |
} else { |
faddb1b7fb76
12184 Navigator's address validation is incomplete, and uncompletable
Stephen Talley <stephen.talley@sun.com>
parents:
366
diff
changeset
|
397 |
String id = nav.getId(); |
faddb1b7fb76
12184 Navigator's address validation is incomplete, and uncompletable
Stephen Talley <stephen.talley@sun.com>
parents:
366
diff
changeset
|
398 |
newControl = curControl.getChildControl(id); |
faddb1b7fb76
12184 Navigator's address validation is incomplete, and uncompletable
Stephen Talley <stephen.talley@sun.com>
parents:
366
diff
changeset
|
399 |
|
faddb1b7fb76
12184 Navigator's address validation is incomplete, and uncompletable
Stephen Talley <stephen.talley@sun.com>
parents:
366
diff
changeset
|
400 |
if (newControl == null) { |
faddb1b7fb76
12184 Navigator's address validation is incomplete, and uncompletable
Stephen Talley <stephen.talley@sun.com>
parents:
366
diff
changeset
|
401 |
Navigable[] array = stack.toArray( |
faddb1b7fb76
12184 Navigator's address validation is incomplete, and uncompletable
Stephen Talley <stephen.talley@sun.com>
parents:
366
diff
changeset
|
402 |
new Navigable[stack.size()]); |
faddb1b7fb76
12184 Navigator's address validation is incomplete, and uncompletable
Stephen Talley <stephen.talley@sun.com>
parents:
366
diff
changeset
|
403 |
|
faddb1b7fb76
12184 Navigator's address validation is incomplete, and uncompletable
Stephen Talley <stephen.talley@sun.com>
parents:
366
diff
changeset
|
404 |
throw new InvalidAddressException(array, |
faddb1b7fb76
12184 Navigator's address validation is incomplete, and uncompletable
Stephen Talley <stephen.talley@sun.com>
parents:
366
diff
changeset
|
405 |
nav); |
faddb1b7fb76
12184 Navigator's address validation is incomplete, and uncompletable
Stephen Talley <stephen.talley@sun.com>
parents:
366
diff
changeset
|
406 |
} |
faddb1b7fb76
12184 Navigator's address validation is incomplete, and uncompletable
Stephen Talley <stephen.talley@sun.com>
parents:
366
diff
changeset
|
407 |
} |
faddb1b7fb76
12184 Navigator's address validation is incomplete, and uncompletable
Stephen Talley <stephen.talley@sun.com>
parents:
366
diff
changeset
|
408 |
|
390
62c7eb34e283
13347 sysmon: initial system monitor tray
Stephen Talley <stephen.talley@sun.com>
parents:
375
diff
changeset
|
409 |
Map<String, String> parameters = |
62c7eb34e283
13347 sysmon: initial system monitor tray
Stephen Talley <stephen.talley@sun.com>
parents:
375
diff
changeset
|
410 |
nav.getParameters(); |
62c7eb34e283
13347 sysmon: initial system monitor tray
Stephen Talley <stephen.talley@sun.com>
parents:
375
diff
changeset
|
411 |
if (parameters == null) { |
62c7eb34e283
13347 sysmon: initial system monitor tray
Stephen Talley <stephen.talley@sun.com>
parents:
375
diff
changeset
|
412 |
parameters = Collections.emptyMap(); |
62c7eb34e283
13347 sysmon: initial system monitor tray
Stephen Talley <stephen.talley@sun.com>
parents:
375
diff
changeset
|
413 |
} |
62c7eb34e283
13347 sysmon: initial system monitor tray
Stephen Talley <stephen.talley@sun.com>
parents:
375
diff
changeset
|
414 |
newControl.start(this, parameters); |
258
521fd086e813
7977 navigator: getForwardingPath should be called after Control is started
Stephen Talley <stephen.talley@sun.com>
parents:
251
diff
changeset
|
415 |
started.add(newControl); |
521fd086e813
7977 navigator: getForwardingPath should be called after Control is started
Stephen Talley <stephen.talley@sun.com>
parents:
251
diff
changeset
|
416 |
stack.add(newControl); |
521fd086e813
7977 navigator: getForwardingPath should be called after Control is started
Stephen Talley <stephen.talley@sun.com>
parents:
251
diff
changeset
|
417 |
descendantStarted(); |
521fd086e813
7977 navigator: getForwardingPath should be called after Control is started
Stephen Talley <stephen.talley@sun.com>
parents:
251
diff
changeset
|
418 |
} |
521fd086e813
7977 navigator: getForwardingPath should be called after Control is started
Stephen Talley <stephen.talley@sun.com>
parents:
251
diff
changeset
|
419 |
|
521fd086e813
7977 navigator: getForwardingPath should be called after Control is started
Stephen Talley <stephen.talley@sun.com>
parents:
251
diff
changeset
|
420 |
if (System.getProperty("vpanels.debug.navigator") != |
521fd086e813
7977 navigator: getForwardingPath should be called after Control is started
Stephen Talley <stephen.talley@sun.com>
parents:
251
diff
changeset
|
421 |
null) { |
521fd086e813
7977 navigator: getForwardingPath should be called after Control is started
Stephen Talley <stephen.talley@sun.com>
parents:
251
diff
changeset
|
422 |
System.out.printf("%s\n", getPathString()); |
521fd086e813
7977 navigator: getForwardingPath should be called after Control is started
Stephen Talley <stephen.talley@sun.com>
parents:
251
diff
changeset
|
423 |
} |
521fd086e813
7977 navigator: getForwardingPath should be called after Control is started
Stephen Talley <stephen.talley@sun.com>
parents:
251
diff
changeset
|
424 |
} |
521fd086e813
7977 navigator: getForwardingPath should be called after Control is started
Stephen Talley <stephen.talley@sun.com>
parents:
251
diff
changeset
|
425 |
} |
521fd086e813
7977 navigator: getForwardingPath should be called after Control is started
Stephen Talley <stephen.talley@sun.com>
parents:
251
diff
changeset
|
426 |
|
302
ac70675de834
9318 Navigator/Control should distinguish between cancel and non-cancel navigations
Stephen Talley <stephen.talley@sun.com>
parents:
275
diff
changeset
|
427 |
// Navigation is complete. However, if the current |
258
521fd086e813
7977 navigator: getForwardingPath should be called after Control is started
Stephen Talley <stephen.talley@sun.com>
parents:
251
diff
changeset
|
428 |
// Control's getForwardingPath returns a non-null value, |
521fd086e813
7977 navigator: getForwardingPath should be called after Control is started
Stephen Talley <stephen.talley@sun.com>
parents:
251
diff
changeset
|
429 |
// invoke another round of navigation. |
521fd086e813
7977 navigator: getForwardingPath should be called after Control is started
Stephen Talley <stephen.talley@sun.com>
parents:
251
diff
changeset
|
430 |
done = true; |
521fd086e813
7977 navigator: getForwardingPath should be called after Control is started
Stephen Talley <stephen.talley@sun.com>
parents:
251
diff
changeset
|
431 |
Control curControl = getCurrentControl(); |
521fd086e813
7977 navigator: getForwardingPath should be called after Control is started
Stephen Talley <stephen.talley@sun.com>
parents:
251
diff
changeset
|
432 |
if (curControl != null) { |
404
32e9b6a2b5f2
13501 generic support for window-creating Controls
Stephen Talley <stephen.talley@sun.com>
parents:
390
diff
changeset
|
433 |
Navigable[] forward = curControl.getForwardingPath( |
32e9b6a2b5f2
13501 generic support for window-creating Controls
Stephen Talley <stephen.talley@sun.com>
parents:
390
diff
changeset
|
434 |
!started.contains(curControl)); |
258
521fd086e813
7977 navigator: getForwardingPath should be called after Control is started
Stephen Talley <stephen.talley@sun.com>
parents:
251
diff
changeset
|
435 |
if (forward != null && forward.length != 0) { |
521fd086e813
7977 navigator: getForwardingPath should be called after Control is started
Stephen Talley <stephen.talley@sun.com>
parents:
251
diff
changeset
|
436 |
// Is this path absolute? |
521fd086e813
7977 navigator: getForwardingPath should be called after Control is started
Stephen Talley <stephen.talley@sun.com>
parents:
251
diff
changeset
|
437 |
if (forward[0] == null) { |
521fd086e813
7977 navigator: getForwardingPath should be called after Control is started
Stephen Talley <stephen.talley@sun.com>
parents:
251
diff
changeset
|
438 |
relativeTo = null; |
521fd086e813
7977 navigator: getForwardingPath should be called after Control is started
Stephen Talley <stephen.talley@sun.com>
parents:
251
diff
changeset
|
439 |
path = new Navigable[forward.length - 1]; |
521fd086e813
7977 navigator: getForwardingPath should be called after Control is started
Stephen Talley <stephen.talley@sun.com>
parents:
251
diff
changeset
|
440 |
System.arraycopy(forward, 1, path, 0, |
521fd086e813
7977 navigator: getForwardingPath should be called after Control is started
Stephen Talley <stephen.talley@sun.com>
parents:
251
diff
changeset
|
441 |
path.length); |
521fd086e813
7977 navigator: getForwardingPath should be called after Control is started
Stephen Talley <stephen.talley@sun.com>
parents:
251
diff
changeset
|
442 |
} else { |
521fd086e813
7977 navigator: getForwardingPath should be called after Control is started
Stephen Talley <stephen.talley@sun.com>
parents:
251
diff
changeset
|
443 |
relativeTo = curControl; |
521fd086e813
7977 navigator: getForwardingPath should be called after Control is started
Stephen Talley <stephen.talley@sun.com>
parents:
251
diff
changeset
|
444 |
path = forward; |
521fd086e813
7977 navigator: getForwardingPath should be called after Control is started
Stephen Talley <stephen.talley@sun.com>
parents:
251
diff
changeset
|
445 |
} |
521fd086e813
7977 navigator: getForwardingPath should be called after Control is started
Stephen Talley <stephen.talley@sun.com>
parents:
251
diff
changeset
|
446 |
done = false; |
521fd086e813
7977 navigator: getForwardingPath should be called after Control is started
Stephen Talley <stephen.talley@sun.com>
parents:
251
diff
changeset
|
447 |
} |
521fd086e813
7977 navigator: getForwardingPath should be called after Control is started
Stephen Talley <stephen.talley@sun.com>
parents:
251
diff
changeset
|
448 |
} |
521fd086e813
7977 navigator: getForwardingPath should be called after Control is started
Stephen Talley <stephen.talley@sun.com>
parents:
251
diff
changeset
|
449 |
} |
373
faddb1b7fb76
12184 Navigator's address validation is incomplete, and uncompletable
Stephen Talley <stephen.talley@sun.com>
parents:
366
diff
changeset
|
450 |
} catch (NavigationAbortedException e) { |
faddb1b7fb76
12184 Navigator's address validation is incomplete, and uncompletable
Stephen Talley <stephen.talley@sun.com>
parents:
366
diff
changeset
|
451 |
exception = e; |
faddb1b7fb76
12184 Navigator's address validation is incomplete, and uncompletable
Stephen Talley <stephen.talley@sun.com>
parents:
366
diff
changeset
|
452 |
throw e; |
faddb1b7fb76
12184 Navigator's address validation is incomplete, and uncompletable
Stephen Talley <stephen.talley@sun.com>
parents:
366
diff
changeset
|
453 |
|
faddb1b7fb76
12184 Navigator's address validation is incomplete, and uncompletable
Stephen Talley <stephen.talley@sun.com>
parents:
366
diff
changeset
|
454 |
} catch (InvalidAddressException e) { |
faddb1b7fb76
12184 Navigator's address validation is incomplete, and uncompletable
Stephen Talley <stephen.talley@sun.com>
parents:
366
diff
changeset
|
455 |
exception = e; |
faddb1b7fb76
12184 Navigator's address validation is incomplete, and uncompletable
Stephen Talley <stephen.talley@sun.com>
parents:
366
diff
changeset
|
456 |
throw e; |
faddb1b7fb76
12184 Navigator's address validation is incomplete, and uncompletable
Stephen Talley <stephen.talley@sun.com>
parents:
366
diff
changeset
|
457 |
|
faddb1b7fb76
12184 Navigator's address validation is incomplete, and uncompletable
Stephen Talley <stephen.talley@sun.com>
parents:
366
diff
changeset
|
458 |
} catch (MissingParameterException e) { |
faddb1b7fb76
12184 Navigator's address validation is incomplete, and uncompletable
Stephen Talley <stephen.talley@sun.com>
parents:
366
diff
changeset
|
459 |
exception = e; |
faddb1b7fb76
12184 Navigator's address validation is incomplete, and uncompletable
Stephen Talley <stephen.talley@sun.com>
parents:
366
diff
changeset
|
460 |
throw e; |
faddb1b7fb76
12184 Navigator's address validation is incomplete, and uncompletable
Stephen Talley <stephen.talley@sun.com>
parents:
366
diff
changeset
|
461 |
|
faddb1b7fb76
12184 Navigator's address validation is incomplete, and uncompletable
Stephen Talley <stephen.talley@sun.com>
parents:
366
diff
changeset
|
462 |
} catch (InvalidParameterException e) { |
faddb1b7fb76
12184 Navigator's address validation is incomplete, and uncompletable
Stephen Talley <stephen.talley@sun.com>
parents:
366
diff
changeset
|
463 |
exception = e; |
faddb1b7fb76
12184 Navigator's address validation is incomplete, and uncompletable
Stephen Talley <stephen.talley@sun.com>
parents:
366
diff
changeset
|
464 |
throw e; |
faddb1b7fb76
12184 Navigator's address validation is incomplete, and uncompletable
Stephen Talley <stephen.talley@sun.com>
parents:
366
diff
changeset
|
465 |
|
657
9fdd9a66d201
17928 Control.start should allow broader range of failures
Stephen Talley <stephen.talley@oracle.com>
parents:
489
diff
changeset
|
466 |
} catch (NavigationFailedException e) { |
9fdd9a66d201
17928 Control.start should allow broader range of failures
Stephen Talley <stephen.talley@oracle.com>
parents:
489
diff
changeset
|
467 |
exception = e; |
9fdd9a66d201
17928 Control.start should allow broader range of failures
Stephen Talley <stephen.talley@oracle.com>
parents:
489
diff
changeset
|
468 |
throw e; |
9fdd9a66d201
17928 Control.start should allow broader range of failures
Stephen Talley <stephen.talley@oracle.com>
parents:
489
diff
changeset
|
469 |
|
373
faddb1b7fb76
12184 Navigator's address validation is incomplete, and uncompletable
Stephen Talley <stephen.talley@sun.com>
parents:
366
diff
changeset
|
470 |
} catch (EmptyNavigationStackException e) { |
faddb1b7fb76
12184 Navigator's address validation is incomplete, and uncompletable
Stephen Talley <stephen.talley@sun.com>
parents:
366
diff
changeset
|
471 |
exception = e; |
faddb1b7fb76
12184 Navigator's address validation is incomplete, and uncompletable
Stephen Talley <stephen.talley@sun.com>
parents:
366
diff
changeset
|
472 |
throw e; |
faddb1b7fb76
12184 Navigator's address validation is incomplete, and uncompletable
Stephen Talley <stephen.talley@sun.com>
parents:
366
diff
changeset
|
473 |
|
faddb1b7fb76
12184 Navigator's address validation is incomplete, and uncompletable
Stephen Talley <stephen.talley@sun.com>
parents:
366
diff
changeset
|
474 |
} catch (RootNavigableNotControlException e) { |
faddb1b7fb76
12184 Navigator's address validation is incomplete, and uncompletable
Stephen Talley <stephen.talley@sun.com>
parents:
366
diff
changeset
|
475 |
exception = e; |
faddb1b7fb76
12184 Navigator's address validation is incomplete, and uncompletable
Stephen Talley <stephen.talley@sun.com>
parents:
366
diff
changeset
|
476 |
throw e; |
faddb1b7fb76
12184 Navigator's address validation is incomplete, and uncompletable
Stephen Talley <stephen.talley@sun.com>
parents:
366
diff
changeset
|
477 |
|
258
521fd086e813
7977 navigator: getForwardingPath should be called after Control is started
Stephen Talley <stephen.talley@sun.com>
parents:
251
diff
changeset
|
478 |
} finally { |
261
56505bb0e870
8005 aborted navigation can result in blocked UI
Stephen Talley <stephen.talley@sun.com>
parents:
258
diff
changeset
|
479 |
if (needStopEvent) { |
390
62c7eb34e283
13347 sysmon: initial system monitor tray
Stephen Talley <stephen.talley@sun.com>
parents:
375
diff
changeset
|
480 |
Navigable[] copy = Arrays.copyOf(last, last.length); |
373
faddb1b7fb76
12184 Navigator's address validation is incomplete, and uncompletable
Stephen Talley <stephen.talley@sun.com>
parents:
366
diff
changeset
|
481 |
NavigationStopEvent event = new NavigationStopEvent(this, |
390
62c7eb34e283
13347 sysmon: initial system monitor tray
Stephen Talley <stephen.talley@sun.com>
parents:
375
diff
changeset
|
482 |
copy, Collections.unmodifiableList(stopped), |
373
faddb1b7fb76
12184 Navigator's address validation is incomplete, and uncompletable
Stephen Talley <stephen.talley@sun.com>
parents:
366
diff
changeset
|
483 |
Collections.unmodifiableList(started), exception); |
0 | 484 |
fireNavigationStopped(event); |
485 |
} |
|
486 |
} |
|
487 |
||
373
faddb1b7fb76
12184 Navigator's address validation is incomplete, and uncompletable
Stephen Talley <stephen.talley@sun.com>
parents:
366
diff
changeset
|
488 |
return last; |
0 | 489 |
} |
490 |
} |
|
491 |
||
492 |
/** |
|
20
5423319ed064
2853 Async navigation in serious need of factoring
David Powell <David.Powell@sun.com>
parents:
19
diff
changeset
|
493 |
* Asynchronously navigates to the {@link Control} identified by the |
302
ac70675de834
9318 Navigator/Control should distinguish between cancel and non-cancel navigations
Stephen Talley <stephen.talley@sun.com>
parents:
275
diff
changeset
|
494 |
* given path. A wrapper around {@link #goTo(boolean,Control,Navigable...)} |
60
9a179bed654e
3334 navigation should be run solely on navigation thread
Stephen Talley <stephen.talley@sun.com>
parents:
59
diff
changeset
|
495 |
* that is run asynchronously using {@link #asyncExec}. |
20
5423319ed064
2853 Async navigation in serious need of factoring
David Powell <David.Powell@sun.com>
parents:
19
diff
changeset
|
496 |
*/ |
302
ac70675de834
9318 Navigator/Control should distinguish between cancel and non-cancel navigations
Stephen Talley <stephen.talley@sun.com>
parents:
275
diff
changeset
|
497 |
public void goToAsync(final boolean cancel, final Control relativeTo, |
ac70675de834
9318 Navigator/Control should distinguish between cancel and non-cancel navigations
Stephen Talley <stephen.talley@sun.com>
parents:
275
diff
changeset
|
498 |
final Navigable... path) { |
20
5423319ed064
2853 Async navigation in serious need of factoring
David Powell <David.Powell@sun.com>
parents:
19
diff
changeset
|
499 |
asyncExec( |
5423319ed064
2853 Async navigation in serious need of factoring
David Powell <David.Powell@sun.com>
parents:
19
diff
changeset
|
500 |
new Runnable() { |
5423319ed064
2853 Async navigation in serious need of factoring
David Powell <David.Powell@sun.com>
parents:
19
diff
changeset
|
501 |
@Override |
5423319ed064
2853 Async navigation in serious need of factoring
David Powell <David.Powell@sun.com>
parents:
19
diff
changeset
|
502 |
public void run() { |
5423319ed064
2853 Async navigation in serious need of factoring
David Powell <David.Powell@sun.com>
parents:
19
diff
changeset
|
503 |
try { |
302
ac70675de834
9318 Navigator/Control should distinguish between cancel and non-cancel navigations
Stephen Talley <stephen.talley@sun.com>
parents:
275
diff
changeset
|
504 |
goTo(cancel, relativeTo, path); |
20
5423319ed064
2853 Async navigation in serious need of factoring
David Powell <David.Powell@sun.com>
parents:
19
diff
changeset
|
505 |
} catch (NavigationException ignore) { |
5423319ed064
2853 Async navigation in serious need of factoring
David Powell <David.Powell@sun.com>
parents:
19
diff
changeset
|
506 |
} |
5423319ed064
2853 Async navigation in serious need of factoring
David Powell <David.Powell@sun.com>
parents:
19
diff
changeset
|
507 |
} |
5423319ed064
2853 Async navigation in serious need of factoring
David Powell <David.Powell@sun.com>
parents:
19
diff
changeset
|
508 |
}); |
5423319ed064
2853 Async navigation in serious need of factoring
David Powell <David.Powell@sun.com>
parents:
19
diff
changeset
|
509 |
} |
5423319ed064
2853 Async navigation in serious need of factoring
David Powell <David.Powell@sun.com>
parents:
19
diff
changeset
|
510 |
|
5423319ed064
2853 Async navigation in serious need of factoring
David Powell <David.Powell@sun.com>
parents:
19
diff
changeset
|
511 |
/** |
60
9a179bed654e
3334 navigation should be run solely on navigation thread
Stephen Talley <stephen.talley@sun.com>
parents:
59
diff
changeset
|
512 |
* Asynchronously navigates to the {@link Control} identified by the given |
9a179bed654e
3334 navigation should be run solely on navigation thread
Stephen Talley <stephen.talley@sun.com>
parents:
59
diff
changeset
|
513 |
* path, returning only when navigation is complete. A wrapper around |
302
ac70675de834
9318 Navigator/Control should distinguish between cancel and non-cancel navigations
Stephen Talley <stephen.talley@sun.com>
parents:
275
diff
changeset
|
514 |
* {@link #goTo(boolean,Control,Navigable...)} that is run asynchronously |
ac70675de834
9318 Navigator/Control should distinguish between cancel and non-cancel navigations
Stephen Talley <stephen.talley@sun.com>
parents:
275
diff
changeset
|
515 |
* using {@link #asyncExecAndWait}. |
60
9a179bed654e
3334 navigation should be run solely on navigation thread
Stephen Talley <stephen.talley@sun.com>
parents:
59
diff
changeset
|
516 |
*/ |
302
ac70675de834
9318 Navigator/Control should distinguish between cancel and non-cancel navigations
Stephen Talley <stephen.talley@sun.com>
parents:
275
diff
changeset
|
517 |
public void goToAsyncAndWait(final boolean cancel, final Control relativeTo, |
ac70675de834
9318 Navigator/Control should distinguish between cancel and non-cancel navigations
Stephen Talley <stephen.talley@sun.com>
parents:
275
diff
changeset
|
518 |
final Navigable... path) throws NavigationAbortedException, |
ac70675de834
9318 Navigator/Control should distinguish between cancel and non-cancel navigations
Stephen Talley <stephen.talley@sun.com>
parents:
275
diff
changeset
|
519 |
InvalidAddressException, MissingParameterException, |
657
9fdd9a66d201
17928 Control.start should allow broader range of failures
Stephen Talley <stephen.talley@oracle.com>
parents:
489
diff
changeset
|
520 |
InvalidParameterException, NavigationFailedException, |
9fdd9a66d201
17928 Control.start should allow broader range of failures
Stephen Talley <stephen.talley@oracle.com>
parents:
489
diff
changeset
|
521 |
EmptyNavigationStackException, RootNavigableNotControlException { |
60
9a179bed654e
3334 navigation should be run solely on navigation thread
Stephen Talley <stephen.talley@sun.com>
parents:
59
diff
changeset
|
522 |
|
9a179bed654e
3334 navigation should be run solely on navigation thread
Stephen Talley <stephen.talley@sun.com>
parents:
59
diff
changeset
|
523 |
asyncExecAndWait( |
9a179bed654e
3334 navigation should be run solely on navigation thread
Stephen Talley <stephen.talley@sun.com>
parents:
59
diff
changeset
|
524 |
new NavRunnable() { |
9a179bed654e
3334 navigation should be run solely on navigation thread
Stephen Talley <stephen.talley@sun.com>
parents:
59
diff
changeset
|
525 |
@Override |
9a179bed654e
3334 navigation should be run solely on navigation thread
Stephen Talley <stephen.talley@sun.com>
parents:
59
diff
changeset
|
526 |
public void run() |
9a179bed654e
3334 navigation should be run solely on navigation thread
Stephen Talley <stephen.talley@sun.com>
parents:
59
diff
changeset
|
527 |
throws NavigationAbortedException, InvalidAddressException, |
373
faddb1b7fb76
12184 Navigator's address validation is incomplete, and uncompletable
Stephen Talley <stephen.talley@sun.com>
parents:
366
diff
changeset
|
528 |
MissingParameterException, InvalidParameterException, |
657
9fdd9a66d201
17928 Control.start should allow broader range of failures
Stephen Talley <stephen.talley@oracle.com>
parents:
489
diff
changeset
|
529 |
NavigationFailedException, EmptyNavigationStackException, |
373
faddb1b7fb76
12184 Navigator's address validation is incomplete, and uncompletable
Stephen Talley <stephen.talley@sun.com>
parents:
366
diff
changeset
|
530 |
RootNavigableNotControlException { |
60
9a179bed654e
3334 navigation should be run solely on navigation thread
Stephen Talley <stephen.talley@sun.com>
parents:
59
diff
changeset
|
531 |
|
302
ac70675de834
9318 Navigator/Control should distinguish between cancel and non-cancel navigations
Stephen Talley <stephen.talley@sun.com>
parents:
275
diff
changeset
|
532 |
goTo(cancel, relativeTo, path); |
60
9a179bed654e
3334 navigation should be run solely on navigation thread
Stephen Talley <stephen.talley@sun.com>
parents:
59
diff
changeset
|
533 |
} |
9a179bed654e
3334 navigation should be run solely on navigation thread
Stephen Talley <stephen.talley@sun.com>
parents:
59
diff
changeset
|
534 |
}); |
9a179bed654e
3334 navigation should be run solely on navigation thread
Stephen Talley <stephen.talley@sun.com>
parents:
59
diff
changeset
|
535 |
} |
9a179bed654e
3334 navigation should be run solely on navigation thread
Stephen Talley <stephen.talley@sun.com>
parents:
59
diff
changeset
|
536 |
|
9a179bed654e
3334 navigation should be run solely on navigation thread
Stephen Talley <stephen.talley@sun.com>
parents:
59
diff
changeset
|
537 |
/** |
373
faddb1b7fb76
12184 Navigator's address validation is incomplete, and uncompletable
Stephen Talley <stephen.talley@sun.com>
parents:
366
diff
changeset
|
538 |
* Gets the {@link UITransitionManager} for this {@code Navigator}. |
faddb1b7fb76
12184 Navigator's address validation is incomplete, and uncompletable
Stephen Talley <stephen.talley@sun.com>
parents:
366
diff
changeset
|
539 |
*/ |
faddb1b7fb76
12184 Navigator's address validation is incomplete, and uncompletable
Stephen Talley <stephen.talley@sun.com>
parents:
366
diff
changeset
|
540 |
public UITransitionManager getUITransitionManager() { |
faddb1b7fb76
12184 Navigator's address validation is incomplete, and uncompletable
Stephen Talley <stephen.talley@sun.com>
parents:
366
diff
changeset
|
541 |
return manager; |
faddb1b7fb76
12184 Navigator's address validation is incomplete, and uncompletable
Stephen Talley <stephen.talley@sun.com>
parents:
366
diff
changeset
|
542 |
} |
faddb1b7fb76
12184 Navigator's address validation is incomplete, and uncompletable
Stephen Talley <stephen.talley@sun.com>
parents:
366
diff
changeset
|
543 |
|
faddb1b7fb76
12184 Navigator's address validation is incomplete, and uncompletable
Stephen Talley <stephen.talley@sun.com>
parents:
366
diff
changeset
|
544 |
/** |
133
e1112f707f32
4258 navigator shouldn't navigate to root control in constructor
Stephen Talley <stephen.talley@sun.com>
parents:
68
diff
changeset
|
545 |
* Determines whether the current thread is the navigation dispatch thread. |
e1112f707f32
4258 navigator shouldn't navigate to root control in constructor
Stephen Talley <stephen.talley@sun.com>
parents:
68
diff
changeset
|
546 |
* The navigation dispatch thread may change over time, but only one is |
e1112f707f32
4258 navigator shouldn't navigate to root control in constructor
Stephen Talley <stephen.talley@sun.com>
parents:
68
diff
changeset
|
547 |
* alive at a time. |
e1112f707f32
4258 navigator shouldn't navigate to root control in constructor
Stephen Talley <stephen.talley@sun.com>
parents:
68
diff
changeset
|
548 |
*/ |
e1112f707f32
4258 navigator shouldn't navigate to root control in constructor
Stephen Talley <stephen.talley@sun.com>
parents:
68
diff
changeset
|
549 |
public boolean isDispatchThread() { |
e1112f707f32
4258 navigator shouldn't navigate to root control in constructor
Stephen Talley <stephen.talley@sun.com>
parents:
68
diff
changeset
|
550 |
return Thread.currentThread() == dispatchThread; |
e1112f707f32
4258 navigator shouldn't navigate to root control in constructor
Stephen Talley <stephen.talley@sun.com>
parents:
68
diff
changeset
|
551 |
} |
e1112f707f32
4258 navigator shouldn't navigate to root control in constructor
Stephen Talley <stephen.talley@sun.com>
parents:
68
diff
changeset
|
552 |
|
e1112f707f32
4258 navigator shouldn't navigate to root control in constructor
Stephen Talley <stephen.talley@sun.com>
parents:
68
diff
changeset
|
553 |
/** |
0 | 554 |
* Removes a {@link NavigationListener} from notification of when navigation |
555 |
* is stopped and started. |
|
556 |
*/ |
|
557 |
public boolean removeNavigationListener(NavigationListener l) { |
|
558 |
return listeners.remove(l); |
|
559 |
} |
|
560 |
||
561 |
// |
|
562 |
// Private methods |
|
563 |
// |
|
564 |
||
248
d947462c8e37
7851 Control should support notification of descendants starting/stopping
Stephen Talley <stephen.talley@sun.com>
parents:
247
diff
changeset
|
565 |
private void descendantStarted() { |
d947462c8e37
7851 Control should support notification of descendants starting/stopping
Stephen Talley <stephen.talley@sun.com>
parents:
247
diff
changeset
|
566 |
int n = stack.size(); |
d947462c8e37
7851 Control should support notification of descendants starting/stopping
Stephen Talley <stephen.talley@sun.com>
parents:
247
diff
changeset
|
567 |
for (int i = n - 2; i >= 0; i--) { |
d947462c8e37
7851 Control should support notification of descendants starting/stopping
Stephen Talley <stephen.talley@sun.com>
parents:
247
diff
changeset
|
568 |
Control alert = stack.get(i); |
d947462c8e37
7851 Control should support notification of descendants starting/stopping
Stephen Talley <stephen.talley@sun.com>
parents:
247
diff
changeset
|
569 |
Control[] path = new Control[n - i - 1]; |
d947462c8e37
7851 Control should support notification of descendants starting/stopping
Stephen Talley <stephen.talley@sun.com>
parents:
247
diff
changeset
|
570 |
for (int j = i + 1; j < n; j++) { |
d947462c8e37
7851 Control should support notification of descendants starting/stopping
Stephen Talley <stephen.talley@sun.com>
parents:
247
diff
changeset
|
571 |
path[j - i - 1] = stack.get(j); |
d947462c8e37
7851 Control should support notification of descendants starting/stopping
Stephen Talley <stephen.talley@sun.com>
parents:
247
diff
changeset
|
572 |
} |
d947462c8e37
7851 Control should support notification of descendants starting/stopping
Stephen Talley <stephen.talley@sun.com>
parents:
247
diff
changeset
|
573 |
alert.descendantStarted(path); |
d947462c8e37
7851 Control should support notification of descendants starting/stopping
Stephen Talley <stephen.talley@sun.com>
parents:
247
diff
changeset
|
574 |
} |
d947462c8e37
7851 Control should support notification of descendants starting/stopping
Stephen Talley <stephen.talley@sun.com>
parents:
247
diff
changeset
|
575 |
} |
d947462c8e37
7851 Control should support notification of descendants starting/stopping
Stephen Talley <stephen.talley@sun.com>
parents:
247
diff
changeset
|
576 |
|
d947462c8e37
7851 Control should support notification of descendants starting/stopping
Stephen Talley <stephen.talley@sun.com>
parents:
247
diff
changeset
|
577 |
private void descendantStopped(Control control) { |
d947462c8e37
7851 Control should support notification of descendants starting/stopping
Stephen Talley <stephen.talley@sun.com>
parents:
247
diff
changeset
|
578 |
int n = stack.size(); |
d947462c8e37
7851 Control should support notification of descendants starting/stopping
Stephen Talley <stephen.talley@sun.com>
parents:
247
diff
changeset
|
579 |
for (int i = n - 1; i >= 0; i--) { |
d947462c8e37
7851 Control should support notification of descendants starting/stopping
Stephen Talley <stephen.talley@sun.com>
parents:
247
diff
changeset
|
580 |
Control alert = stack.get(i); |
d947462c8e37
7851 Control should support notification of descendants starting/stopping
Stephen Talley <stephen.talley@sun.com>
parents:
247
diff
changeset
|
581 |
Control[] path = new Control[n - i]; |
d947462c8e37
7851 Control should support notification of descendants starting/stopping
Stephen Talley <stephen.talley@sun.com>
parents:
247
diff
changeset
|
582 |
path[path.length - 1] = control; |
d947462c8e37
7851 Control should support notification of descendants starting/stopping
Stephen Talley <stephen.talley@sun.com>
parents:
247
diff
changeset
|
583 |
for (int j = i + 1; j < n; j++) { |
d947462c8e37
7851 Control should support notification of descendants starting/stopping
Stephen Talley <stephen.talley@sun.com>
parents:
247
diff
changeset
|
584 |
path[j - i - 1] = stack.get(j); |
d947462c8e37
7851 Control should support notification of descendants starting/stopping
Stephen Talley <stephen.talley@sun.com>
parents:
247
diff
changeset
|
585 |
} |
d947462c8e37
7851 Control should support notification of descendants starting/stopping
Stephen Talley <stephen.talley@sun.com>
parents:
247
diff
changeset
|
586 |
alert.descendantStopped(path); |
d947462c8e37
7851 Control should support notification of descendants starting/stopping
Stephen Talley <stephen.talley@sun.com>
parents:
247
diff
changeset
|
587 |
} |
d947462c8e37
7851 Control should support notification of descendants starting/stopping
Stephen Talley <stephen.talley@sun.com>
parents:
247
diff
changeset
|
588 |
} |
d947462c8e37
7851 Control should support notification of descendants starting/stopping
Stephen Talley <stephen.talley@sun.com>
parents:
247
diff
changeset
|
589 |
|
0 | 590 |
/** |
591 |
* Gets the relative path between the given absolute paths. |
|
592 |
* |
|
593 |
* @param fromPath |
|
594 |
* an absolute source path |
|
595 |
* |
|
596 |
* @param toPath |
|
597 |
* an absolute destination path |
|
598 |
* |
|
599 |
* @return a relative path from the current path to the given path |
|
600 |
*/ |
|
601 |
private List<Navigable> getRelativePath( |
|
602 |
List<? extends Navigable> fromPath, |
|
603 |
List<? extends Navigable> toPath) { |
|
604 |
||
605 |
List<Navigable> rPath = new ArrayList<Navigable>(); |
|
606 |
||
607 |
// Determine branching index |
|
608 |
int branch = 0; |
|
609 |
while (branch < fromPath.size() && branch < toPath.size() && |
|
610 |
Navigable.Util.equals(fromPath.get(branch), toPath.get(branch))) { |
|
611 |
||
612 |
branch++; |
|
613 |
} |
|
614 |
||
615 |
for (int i = fromPath.size() - 1; i >= branch; i--) { |
|
373
faddb1b7fb76
12184 Navigator's address validation is incomplete, and uncompletable
Stephen Talley <stephen.talley@sun.com>
parents:
366
diff
changeset
|
616 |
rPath.add(PARENT_NAVIGABLE); |
0 | 617 |
} |
618 |
||
619 |
for (int i = branch; i < toPath.size(); i++) { |
|
620 |
rPath.add(toPath.get(i)); |
|
621 |
} |
|
622 |
||
623 |
return rPath; |
|
624 |
} |
|
625 |
||
626 |
/** |
|
627 |
* Removes each ".." segment and preceding non-".." segment the given path. |
|
628 |
*/ |
|
629 |
private void normalize(List<? extends HasId> path) { |
|
630 |
for (int i = 1; i < path.size(); i++) { |
|
631 |
if (path.get(i).getId().equals(PARENT_ID) && |
|
632 |
!path.get(i - 1).getId().equals(PARENT_ID)) { |
|
633 |
path.remove(i--); |
|
634 |
path.remove(i--); |
|
635 |
} |
|
636 |
} |
|
637 |
} |
|
638 |
||
639 |
// |
|
640 |
// Static methods |
|
641 |
// |
|
642 |
||
643 |
/** |
|
644 |
* Gets the given path as a {@code String}. |
|
645 |
*/ |
|
373
faddb1b7fb76
12184 Navigator's address validation is incomplete, and uncompletable
Stephen Talley <stephen.talley@sun.com>
parents:
366
diff
changeset
|
646 |
public static String getPathString(Iterable<? extends Navigable> path) { |
685
767674b0a2fb
18094 s/StringBuffer/StringBuilder/g
Stephen Talley <stephen.talley@oracle.com>
parents:
661
diff
changeset
|
647 |
StringBuilder buffer = new StringBuilder(); |
0 | 648 |
|
133
e1112f707f32
4258 navigator shouldn't navigate to root control in constructor
Stephen Talley <stephen.talley@sun.com>
parents:
68
diff
changeset
|
649 |
for (Navigable nav : path) { |
0 | 650 |
buffer.append(PATH_SEPARATOR).append(Control.encode( |
133
e1112f707f32
4258 navigator shouldn't navigate to root control in constructor
Stephen Talley <stephen.talley@sun.com>
parents:
68
diff
changeset
|
651 |
nav.getId(), nav.getParameters())); |
0 | 652 |
} |
653 |
||
654 |
return buffer.toString(); |
|
655 |
} |
|
656 |
||
657 |
/** |
|
658 |
* Determines whether the given path is absolute. If the given path starts |
|
659 |
* with PATH_SEPARATOR, it is considered absolute. |
|
660 |
*/ |
|
661 |
public static boolean isAbsolute(String path) { |
|
662 |
return path.startsWith(PATH_SEPARATOR); |
|
663 |
} |
|
664 |
||
665 |
public static SimpleNavigable[] toArray(String path) { |
|
666 |
path = path.replaceFirst( |
|
667 |
"^(" + Pattern.quote(PATH_SEPARATOR) + ")+", ""); |
|
668 |
||
669 |
String[] parts = path.split(PATH_SEPARATOR, 0); |
|
670 |
SimpleNavigable[] elements = new SimpleNavigable[parts.length]; |
|
671 |
||
672 |
for (int i = 0; i < parts.length; i++) { |
|
673 |
elements[i] = Control.decode(parts[i]); |
|
674 |
} |
|
675 |
||
676 |
return elements; |
|
677 |
} |
|
678 |
} |