usr/src/java/vpanels/panel/org/opensolaris/os/vp/panel/common/control/Control.java
author Stephen Talley <stephen.talley@oracle.com>
Mon, 28 Mar 2011 10:53:34 -0400
changeset 685 767674b0a2fb
parent 657 9fdd9a66d201
child 735 a25f22e2faa2
permissions -rw-r--r--
18094 s/StringBuffer/StringBuilder/g
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
0
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
     1
/*
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
     2
 * CDDL HEADER START
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
     3
 *
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
     4
 * The contents of this file are subject to the terms of the
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
     5
 * Common Development and Distribution License (the "License").
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
     6
 * You may not use this file except in compliance with the License.
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
     7
 *
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
     8
 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
     9
 * or http://www.opensolaris.org/os/licensing.
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
    10
 * See the License for the specific language governing permissions
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
    11
 * and limitations under the License.
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
    12
 *
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
    13
 * When distributing Covered Code, include this CDDL HEADER in each
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
    14
 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
    15
 * If applicable, add the following below this CDDL HEADER, with the
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
    16
 * fields enclosed by brackets "[]" replaced with your own identifying
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
    17
 * information: Portions Copyright [yyyy] [name of copyright owner]
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
    18
 *
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
    19
 * CDDL HEADER END
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
    20
 */
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
    21
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
    22
/*
657
9fdd9a66d201 17928 Control.start should allow broader range of failures
Stephen Talley <stephen.talley@oracle.com>
parents: 591
diff changeset
    23
 * Copyright (c) 2010, 2011, Oracle and/or its affiliates. All rights reserved.
0
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
    24
 */
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
    25
40
d1412af1ae5b 3215 ActionAbortedException is used too broadly
Stephen Talley <stephen.talley@sun.com>
parents: 26
diff changeset
    26
package org.opensolaris.os.vp.panel.common.control;
0
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
    27
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
    28
import java.io.UnsupportedEncodingException;
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
    29
import java.net.*;
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
    30
import java.util.*;
138
48a05b6471de 4366 wizard: wizard steps should not be limited to SwingControls
Stephen Talley <stephen.talley@sun.com>
parents: 79
diff changeset
    31
import org.opensolaris.os.vp.panel.common.action.*;
591
7c5752b99fd6 12473 panels should probably be run in a sandbox
Stephen Talley <stephen.talley@oracle.com>
parents: 456
diff changeset
    32
import org.opensolaris.os.vp.util.misc.finder.ResourceFinder;
0
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
    33
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
    34
/**
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
    35
 * The {@code Control} class encapsulates the control over all aspects of a
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
    36
 * single point in a navigation hierarchy.
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
    37
 */
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
    38
public abstract class Control implements Navigable, HasControl {
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
    39
    //
360
8943c58ad2f5 11508 Control, DefaultControl refactoring
Stephen Talley <stephen.talley@sun.com>
parents: 356
diff changeset
    40
    // Enums
8943c58ad2f5 11508 Control, DefaultControl refactoring
Stephen Talley <stephen.talley@sun.com>
parents: 356
diff changeset
    41
    //
8943c58ad2f5 11508 Control, DefaultControl refactoring
Stephen Talley <stephen.talley@sun.com>
parents: 356
diff changeset
    42
8943c58ad2f5 11508 Control, DefaultControl refactoring
Stephen Talley <stephen.talley@sun.com>
parents: 356
diff changeset
    43
    public enum UnsavedChangesAction {
8943c58ad2f5 11508 Control, DefaultControl refactoring
Stephen Talley <stephen.talley@sun.com>
parents: 356
diff changeset
    44
	CANCEL, DISCARD, SAVE
8943c58ad2f5 11508 Control, DefaultControl refactoring
Stephen Talley <stephen.talley@sun.com>
parents: 356
diff changeset
    45
    }
8943c58ad2f5 11508 Control, DefaultControl refactoring
Stephen Talley <stephen.talley@sun.com>
parents: 356
diff changeset
    46
8943c58ad2f5 11508 Control, DefaultControl refactoring
Stephen Talley <stephen.talley@sun.com>
parents: 356
diff changeset
    47
    //
0
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
    48
    // Static data
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
    49
    //
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
    50
279
b82f64a1f586 8129 smf/sharemgr/sysid: breadcrumbs should be shown until UI redesign is implemented
Stephen Talley <stephen.talley@sun.com>
parents: 274
diff changeset
    51
    /**
b82f64a1f586 8129 smf/sharemgr/sysid: breadcrumbs should be shown until UI redesign is implemented
Stephen Talley <stephen.talley@sun.com>
parents: 274
diff changeset
    52
     * The encoding used to encode/decode Control IDs and parameters in a path
b82f64a1f586 8129 smf/sharemgr/sysid: breadcrumbs should be shown until UI redesign is implemented
Stephen Talley <stephen.talley@sun.com>
parents: 274
diff changeset
    53
     * string.
b82f64a1f586 8129 smf/sharemgr/sysid: breadcrumbs should be shown until UI redesign is implemented
Stephen Talley <stephen.talley@sun.com>
parents: 274
diff changeset
    54
     */
b82f64a1f586 8129 smf/sharemgr/sysid: breadcrumbs should be shown until UI redesign is implemented
Stephen Talley <stephen.talley@sun.com>
parents: 274
diff changeset
    55
    public static final String ENCODING = "UTF-8";
0
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
    56
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
    57
    //
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
    58
    // Instance data
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
    59
    //
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
    60
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
    61
    private String id;
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
    62
    private String name;
360
8943c58ad2f5 11508 Control, DefaultControl refactoring
Stephen Talley <stephen.talley@sun.com>
parents: 356
diff changeset
    63
    private Navigator navigator;
0
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
    64
    private Map<String, String> parameters;
360
8943c58ad2f5 11508 Control, DefaultControl refactoring
Stephen Talley <stephen.talley@sun.com>
parents: 356
diff changeset
    65
    private Control child;
0
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
    66
138
48a05b6471de 4366 wizard: wizard steps should not be limited to SwingControls
Stephen Talley <stephen.talley@sun.com>
parents: 79
diff changeset
    67
    private StructuredAction<?, ?, ?> resetAction =
48a05b6471de 4366 wizard: wizard steps should not be limited to SwingControls
Stephen Talley <stephen.talley@sun.com>
parents: 79
diff changeset
    68
	new StructuredAction<Object, Object, Object>(null) {
48a05b6471de 4366 wizard: wizard steps should not be limited to SwingControls
Stephen Talley <stephen.talley@sun.com>
parents: 79
diff changeset
    69
	    @Override
48a05b6471de 4366 wizard: wizard steps should not be limited to SwingControls
Stephen Talley <stephen.talley@sun.com>
parents: 79
diff changeset
    70
	    public Object work(Object pInput, Object rtInput)
48a05b6471de 4366 wizard: wizard steps should not be limited to SwingControls
Stephen Talley <stephen.talley@sun.com>
parents: 79
diff changeset
    71
		throws ActionAbortedException, ActionFailedException {
48a05b6471de 4366 wizard: wizard steps should not be limited to SwingControls
Stephen Talley <stephen.talley@sun.com>
parents: 79
diff changeset
    72
360
8943c58ad2f5 11508 Control, DefaultControl refactoring
Stephen Talley <stephen.talley@sun.com>
parents: 356
diff changeset
    73
		resetAll();
138
48a05b6471de 4366 wizard: wizard steps should not be limited to SwingControls
Stephen Talley <stephen.talley@sun.com>
parents: 79
diff changeset
    74
		return null;
48a05b6471de 4366 wizard: wizard steps should not be limited to SwingControls
Stephen Talley <stephen.talley@sun.com>
parents: 79
diff changeset
    75
	    }
48a05b6471de 4366 wizard: wizard steps should not be limited to SwingControls
Stephen Talley <stephen.talley@sun.com>
parents: 79
diff changeset
    76
	};
48a05b6471de 4366 wizard: wizard steps should not be limited to SwingControls
Stephen Talley <stephen.talley@sun.com>
parents: 79
diff changeset
    77
48a05b6471de 4366 wizard: wizard steps should not be limited to SwingControls
Stephen Talley <stephen.talley@sun.com>
parents: 79
diff changeset
    78
    private StructuredAction<?, ?, ?> saveAction =
48a05b6471de 4366 wizard: wizard steps should not be limited to SwingControls
Stephen Talley <stephen.talley@sun.com>
parents: 79
diff changeset
    79
	new StructuredAction<Object, Object, Object>(null) {
48a05b6471de 4366 wizard: wizard steps should not be limited to SwingControls
Stephen Talley <stephen.talley@sun.com>
parents: 79
diff changeset
    80
	    @Override
48a05b6471de 4366 wizard: wizard steps should not be limited to SwingControls
Stephen Talley <stephen.talley@sun.com>
parents: 79
diff changeset
    81
	    public Object work(Object pInput, Object rtInput)
48a05b6471de 4366 wizard: wizard steps should not be limited to SwingControls
Stephen Talley <stephen.talley@sun.com>
parents: 79
diff changeset
    82
		throws ActionAbortedException, ActionFailedException {
48a05b6471de 4366 wizard: wizard steps should not be limited to SwingControls
Stephen Talley <stephen.talley@sun.com>
parents: 79
diff changeset
    83
48a05b6471de 4366 wizard: wizard steps should not be limited to SwingControls
Stephen Talley <stephen.talley@sun.com>
parents: 79
diff changeset
    84
		try {
360
8943c58ad2f5 11508 Control, DefaultControl refactoring
Stephen Talley <stephen.talley@sun.com>
parents: 356
diff changeset
    85
		    saveAll();
214
aed2b42f7344 6426 UnauthorizedActionException's name should follow convention
Stephen Talley <stephen.talley@sun.com>
parents: 196
diff changeset
    86
		} catch (ActionUnauthorizedException e) {
138
48a05b6471de 4366 wizard: wizard steps should not be limited to SwingControls
Stephen Talley <stephen.talley@sun.com>
parents: 79
diff changeset
    87
		    throw new ActionFailedException(e);
48a05b6471de 4366 wizard: wizard steps should not be limited to SwingControls
Stephen Talley <stephen.talley@sun.com>
parents: 79
diff changeset
    88
		}
48a05b6471de 4366 wizard: wizard steps should not be limited to SwingControls
Stephen Talley <stephen.talley@sun.com>
parents: 79
diff changeset
    89
		return null;
48a05b6471de 4366 wizard: wizard steps should not be limited to SwingControls
Stephen Talley <stephen.talley@sun.com>
parents: 79
diff changeset
    90
	    }
48a05b6471de 4366 wizard: wizard steps should not be limited to SwingControls
Stephen Talley <stephen.talley@sun.com>
parents: 79
diff changeset
    91
	};
48a05b6471de 4366 wizard: wizard steps should not be limited to SwingControls
Stephen Talley <stephen.talley@sun.com>
parents: 79
diff changeset
    92
0
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
    93
    //
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
    94
    // Constructors
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
    95
    //
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
    96
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
    97
    /**
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
    98
     * Constructs a {@code Control} with the given identifier and name.
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
    99
     */
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   100
    public Control(String id, String name) {
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   101
	setId(id);
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   102
	setName(name);
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   103
    }
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   104
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   105
    /**
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   106
     * Constructs a {@code Control} with a {@code null} identifier and name.
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   107
     */
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   108
    public Control() {
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   109
	this(null, null);
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   110
    }
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   111
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   112
    //
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   113
    // HasId methods
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   114
    //
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   115
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   116
    /**
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   117
     * Gets an identifier for this {@code Control}, sufficiently unique as to
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   118
     * distinguish itself from its siblings.
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   119
     */
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   120
    @Override
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   121
    public String getId() {
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   122
	return id;
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   123
    }
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   124
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   125
    //
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   126
    // Navigable methods
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   127
    //
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   128
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   129
    /**
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   130
     * Gets the localized name of this {@code Control}.
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   131
     */
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   132
    @Override
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   133
    public String getName() {
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   134
	return name;
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   135
    }
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   136
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   137
    /**
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   138
     * Gets the initialization parameters passed to the {@link #start} method,
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   139
     * if this {@code Control} is started, or {@code null} if this {@code
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   140
     * Control} is stopped.
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   141
     */
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   142
    @Override
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   143
    public Map<String, String> getParameters() {
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   144
	return parameters;
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   145
    }
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   146
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   147
    //
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   148
    // HasControl methods
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   149
    //
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   150
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   151
    @Override
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   152
    public Control getControl() {
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   153
	return this;
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   154
    }
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   155
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   156
    //
327
bb43a6fa6f0b 10096 time: new UI design and NTP support
Stephen Talley <stephen.talley@sun.com>
parents: 302
diff changeset
   157
    // Object methods
bb43a6fa6f0b 10096 time: new UI design and NTP support
Stephen Talley <stephen.talley@sun.com>
parents: 302
diff changeset
   158
    //
bb43a6fa6f0b 10096 time: new UI design and NTP support
Stephen Talley <stephen.talley@sun.com>
parents: 302
diff changeset
   159
bb43a6fa6f0b 10096 time: new UI design and NTP support
Stephen Talley <stephen.talley@sun.com>
parents: 302
diff changeset
   160
    @Override
bb43a6fa6f0b 10096 time: new UI design and NTP support
Stephen Talley <stephen.talley@sun.com>
parents: 302
diff changeset
   161
    public String toString() {
bb43a6fa6f0b 10096 time: new UI design and NTP support
Stephen Talley <stephen.talley@sun.com>
parents: 302
diff changeset
   162
	return getName();
bb43a6fa6f0b 10096 time: new UI design and NTP support
Stephen Talley <stephen.talley@sun.com>
parents: 302
diff changeset
   163
    }
bb43a6fa6f0b 10096 time: new UI design and NTP support
Stephen Talley <stephen.talley@sun.com>
parents: 302
diff changeset
   164
bb43a6fa6f0b 10096 time: new UI design and NTP support
Stephen Talley <stephen.talley@sun.com>
parents: 302
diff changeset
   165
    //
0
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   166
    // Control methods
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   167
    //
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   168
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   169
    /**
451
9dd6c980ba0c 10962 apache: help text should be updated to account for new UI design (source code update)
Stephen Talley <stephen.talley@sun.com>
parents: 414
diff changeset
   170
     * Builds a help URL from a page and optional section, falling back to the
407
b313617320f8 13567 help button doesn't launch context-specific help
Stephen Talley <stephen.talley@sun.com>
parents: 404
diff changeset
   171
     * page if the section is invalid.
b313617320f8 13567 help button doesn't launch context-specific help
Stephen Talley <stephen.talley@sun.com>
parents: 404
diff changeset
   172
     */
b313617320f8 13567 help button doesn't launch context-specific help
Stephen Talley <stephen.talley@sun.com>
parents: 404
diff changeset
   173
    protected URL buildHelpURL(String page, String section) {
456
3c23a2501f35 10964 time: need initial online help (source code update)
David Powell <David.Powell@sun.com>
parents: 451
diff changeset
   174
	return buildHelpURL(getClass(), page, section);
407
b313617320f8 13567 help button doesn't launch context-specific help
Stephen Talley <stephen.talley@sun.com>
parents: 404
diff changeset
   175
    }
b313617320f8 13567 help button doesn't launch context-specific help
Stephen Talley <stephen.talley@sun.com>
parents: 404
diff changeset
   176
b313617320f8 13567 help button doesn't launch context-specific help
Stephen Talley <stephen.talley@sun.com>
parents: 404
diff changeset
   177
    /**
360
8943c58ad2f5 11508 Control, DefaultControl refactoring
Stephen Talley <stephen.talley@sun.com>
parents: 356
diff changeset
   178
     * Saves the given child as the {@link #getRunningChild running child}.
8943c58ad2f5 11508 Control, DefaultControl refactoring
Stephen Talley <stephen.talley@sun.com>
parents: 356
diff changeset
   179
     * Called by {@link #descendantStarted} when a child of this {@code Control}
8943c58ad2f5 11508 Control, DefaultControl refactoring
Stephen Talley <stephen.talley@sun.com>
parents: 356
diff changeset
   180
     * is started.
8943c58ad2f5 11508 Control, DefaultControl refactoring
Stephen Talley <stephen.talley@sun.com>
parents: 356
diff changeset
   181
     *
8943c58ad2f5 11508 Control, DefaultControl refactoring
Stephen Talley <stephen.talley@sun.com>
parents: 356
diff changeset
   182
     * @exception   IllegalStateException
8943c58ad2f5 11508 Control, DefaultControl refactoring
Stephen Talley <stephen.talley@sun.com>
parents: 356
diff changeset
   183
     *		    if the running child has already been set
8943c58ad2f5 11508 Control, DefaultControl refactoring
Stephen Talley <stephen.talley@sun.com>
parents: 356
diff changeset
   184
     */
8943c58ad2f5 11508 Control, DefaultControl refactoring
Stephen Talley <stephen.talley@sun.com>
parents: 356
diff changeset
   185
    public void childStarted(Control child) {
8943c58ad2f5 11508 Control, DefaultControl refactoring
Stephen Talley <stephen.talley@sun.com>
parents: 356
diff changeset
   186
	if (this.child != null) {
8943c58ad2f5 11508 Control, DefaultControl refactoring
Stephen Talley <stephen.talley@sun.com>
parents: 356
diff changeset
   187
	    throw new IllegalStateException("child already started");
8943c58ad2f5 11508 Control, DefaultControl refactoring
Stephen Talley <stephen.talley@sun.com>
parents: 356
diff changeset
   188
	}
8943c58ad2f5 11508 Control, DefaultControl refactoring
Stephen Talley <stephen.talley@sun.com>
parents: 356
diff changeset
   189
8943c58ad2f5 11508 Control, DefaultControl refactoring
Stephen Talley <stephen.talley@sun.com>
parents: 356
diff changeset
   190
	this.child = child;
8943c58ad2f5 11508 Control, DefaultControl refactoring
Stephen Talley <stephen.talley@sun.com>
parents: 356
diff changeset
   191
    }
8943c58ad2f5 11508 Control, DefaultControl refactoring
Stephen Talley <stephen.talley@sun.com>
parents: 356
diff changeset
   192
8943c58ad2f5 11508 Control, DefaultControl refactoring
Stephen Talley <stephen.talley@sun.com>
parents: 356
diff changeset
   193
    /**
8943c58ad2f5 11508 Control, DefaultControl refactoring
Stephen Talley <stephen.talley@sun.com>
parents: 356
diff changeset
   194
     * Removes the given child as the {@link #getRunningChild running child}.
8943c58ad2f5 11508 Control, DefaultControl refactoring
Stephen Talley <stephen.talley@sun.com>
parents: 356
diff changeset
   195
     * Called by {@link #descendantStopped} when a child of this {@code Control}
8943c58ad2f5 11508 Control, DefaultControl refactoring
Stephen Talley <stephen.talley@sun.com>
parents: 356
diff changeset
   196
     * is stopped.
8943c58ad2f5 11508 Control, DefaultControl refactoring
Stephen Talley <stephen.talley@sun.com>
parents: 356
diff changeset
   197
     *
8943c58ad2f5 11508 Control, DefaultControl refactoring
Stephen Talley <stephen.talley@sun.com>
parents: 356
diff changeset
   198
     * @exception   IllegalStateException
8943c58ad2f5 11508 Control, DefaultControl refactoring
Stephen Talley <stephen.talley@sun.com>
parents: 356
diff changeset
   199
     *		    if the given control is not the running child
8943c58ad2f5 11508 Control, DefaultControl refactoring
Stephen Talley <stephen.talley@sun.com>
parents: 356
diff changeset
   200
     */
8943c58ad2f5 11508 Control, DefaultControl refactoring
Stephen Talley <stephen.talley@sun.com>
parents: 356
diff changeset
   201
    public void childStopped(Control child) {
8943c58ad2f5 11508 Control, DefaultControl refactoring
Stephen Talley <stephen.talley@sun.com>
parents: 356
diff changeset
   202
	if (this.child != child) {
8943c58ad2f5 11508 Control, DefaultControl refactoring
Stephen Talley <stephen.talley@sun.com>
parents: 356
diff changeset
   203
	    throw new IllegalStateException("not running child");
8943c58ad2f5 11508 Control, DefaultControl refactoring
Stephen Talley <stephen.talley@sun.com>
parents: 356
diff changeset
   204
	}
8943c58ad2f5 11508 Control, DefaultControl refactoring
Stephen Talley <stephen.talley@sun.com>
parents: 356
diff changeset
   205
8943c58ad2f5 11508 Control, DefaultControl refactoring
Stephen Talley <stephen.talley@sun.com>
parents: 356
diff changeset
   206
	this.child = null;
8943c58ad2f5 11508 Control, DefaultControl refactoring
Stephen Talley <stephen.talley@sun.com>
parents: 356
diff changeset
   207
    }
8943c58ad2f5 11508 Control, DefaultControl refactoring
Stephen Talley <stephen.talley@sun.com>
parents: 356
diff changeset
   208
8943c58ad2f5 11508 Control, DefaultControl refactoring
Stephen Talley <stephen.talley@sun.com>
parents: 356
diff changeset
   209
    /**
8943c58ad2f5 11508 Control, DefaultControl refactoring
Stephen Talley <stephen.talley@sun.com>
parents: 356
diff changeset
   210
     * Calls {@link #childStarted} iff the given path refers to an immediate
8943c58ad2f5 11508 Control, DefaultControl refactoring
Stephen Talley <stephen.talley@sun.com>
parents: 356
diff changeset
   211
     * child of this {@code Control}.
8943c58ad2f5 11508 Control, DefaultControl refactoring
Stephen Talley <stephen.talley@sun.com>
parents: 356
diff changeset
   212
     * <p/>
248
d947462c8e37 7851 Control should support notification of descendants starting/stopping
Stephen Talley <stephen.talley@sun.com>
parents: 247
diff changeset
   213
     * Called by the {@link Navigator} just after a descendant {@code Control}
d947462c8e37 7851 Control should support notification of descendants starting/stopping
Stephen Talley <stephen.talley@sun.com>
parents: 247
diff changeset
   214
     * of this {@code Control} has been started and pushed onto the {@link
0
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   215
     * Navigator}'s {@code Control} stack.
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   216
     *
248
d947462c8e37 7851 Control should support notification of descendants starting/stopping
Stephen Talley <stephen.talley@sun.com>
parents: 247
diff changeset
   217
     * @param	    path
d947462c8e37 7851 Control should support notification of descendants starting/stopping
Stephen Talley <stephen.talley@sun.com>
parents: 247
diff changeset
   218
     *		    the path to the descendant {@code Control}, relative to this
d947462c8e37 7851 Control should support notification of descendants starting/stopping
Stephen Talley <stephen.talley@sun.com>
parents: 247
diff changeset
   219
     *		    {@code Control} (with the just-started {@code Control} as
d947462c8e37 7851 Control should support notification of descendants starting/stopping
Stephen Talley <stephen.talley@sun.com>
parents: 247
diff changeset
   220
     *		    the last element)
0
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   221
     */
248
d947462c8e37 7851 Control should support notification of descendants starting/stopping
Stephen Talley <stephen.talley@sun.com>
parents: 247
diff changeset
   222
    public void descendantStarted(Control[] path) {
360
8943c58ad2f5 11508 Control, DefaultControl refactoring
Stephen Talley <stephen.talley@sun.com>
parents: 356
diff changeset
   223
	if (path.length == 1) {
8943c58ad2f5 11508 Control, DefaultControl refactoring
Stephen Talley <stephen.talley@sun.com>
parents: 356
diff changeset
   224
	    childStarted(path[0]);
8943c58ad2f5 11508 Control, DefaultControl refactoring
Stephen Talley <stephen.talley@sun.com>
parents: 356
diff changeset
   225
	}
0
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   226
    }
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   227
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   228
    /**
360
8943c58ad2f5 11508 Control, DefaultControl refactoring
Stephen Talley <stephen.talley@sun.com>
parents: 356
diff changeset
   229
     * Calls {@link #childStopped} iff the given path refers to an immediate
8943c58ad2f5 11508 Control, DefaultControl refactoring
Stephen Talley <stephen.talley@sun.com>
parents: 356
diff changeset
   230
     * child of this {@code Control}.
8943c58ad2f5 11508 Control, DefaultControl refactoring
Stephen Talley <stephen.talley@sun.com>
parents: 356
diff changeset
   231
     * <p/>
248
d947462c8e37 7851 Control should support notification of descendants starting/stopping
Stephen Talley <stephen.talley@sun.com>
parents: 247
diff changeset
   232
     * Called by the {@link Navigator} just after a descendant {@code Control}
d947462c8e37 7851 Control should support notification of descendants starting/stopping
Stephen Talley <stephen.talley@sun.com>
parents: 247
diff changeset
   233
     * of this {@code Control} has been stopped and popped off the {@link
0
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   234
     * Navigator}'s {@code Control} stack.
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   235
     *
248
d947462c8e37 7851 Control should support notification of descendants starting/stopping
Stephen Talley <stephen.talley@sun.com>
parents: 247
diff changeset
   236
     * @param	    path
d947462c8e37 7851 Control should support notification of descendants starting/stopping
Stephen Talley <stephen.talley@sun.com>
parents: 247
diff changeset
   237
     *		    the path to the descendant {@code Control}, relative to this
d947462c8e37 7851 Control should support notification of descendants starting/stopping
Stephen Talley <stephen.talley@sun.com>
parents: 247
diff changeset
   238
     *		    {@code Control} (with the just-stopped {@code Control} as
d947462c8e37 7851 Control should support notification of descendants starting/stopping
Stephen Talley <stephen.talley@sun.com>
parents: 247
diff changeset
   239
     *		    the last element)
0
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   240
     */
248
d947462c8e37 7851 Control should support notification of descendants starting/stopping
Stephen Talley <stephen.talley@sun.com>
parents: 247
diff changeset
   241
    public void descendantStopped(Control[] path) {
360
8943c58ad2f5 11508 Control, DefaultControl refactoring
Stephen Talley <stephen.talley@sun.com>
parents: 356
diff changeset
   242
	if (path.length == 1) {
8943c58ad2f5 11508 Control, DefaultControl refactoring
Stephen Talley <stephen.talley@sun.com>
parents: 356
diff changeset
   243
	    childStopped(path[0]);
8943c58ad2f5 11508 Control, DefaultControl refactoring
Stephen Talley <stephen.talley@sun.com>
parents: 356
diff changeset
   244
	}
0
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   245
    }
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   246
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   247
    /**
302
ac70675de834 9318 Navigator/Control should distinguish between cancel and non-cancel navigations
Stephen Talley <stephen.talley@sun.com>
parents: 279
diff changeset
   248
     * Asynchronously navigates up one level above this {@code Control} in the
ac70675de834 9318 Navigator/Control should distinguish between cancel and non-cancel navigations
Stephen Talley <stephen.talley@sun.com>
parents: 279
diff changeset
   249
     * navigation stack.  The {@link #stop stop methods} of all affected {@code
ac70675de834 9318 Navigator/Control should distinguish between cancel and non-cancel navigations
Stephen Talley <stephen.talley@sun.com>
parents: 279
diff changeset
   250
     * Control}s are called with a {@code true} argument.
264
d5cd4b2e7426 8029 apache: ui redesign
Stephen Talley <stephen.talley@sun.com>
parents: 260
diff changeset
   251
     */
d5cd4b2e7426 8029 apache: ui redesign
Stephen Talley <stephen.talley@sun.com>
parents: 260
diff changeset
   252
    public void doCancel() {
379
a915e5da7876 12716 minor javadoc improvements
Stephen Talley <stephen.talley@sun.com>
parents: 373
diff changeset
   253
	getNavigator().goToAsync(true, this, Navigator.PARENT_NAVIGABLE);
264
d5cd4b2e7426 8029 apache: ui redesign
Stephen Talley <stephen.talley@sun.com>
parents: 260
diff changeset
   254
    }
d5cd4b2e7426 8029 apache: ui redesign
Stephen Talley <stephen.talley@sun.com>
parents: 260
diff changeset
   255
d5cd4b2e7426 8029 apache: ui redesign
Stephen Talley <stephen.talley@sun.com>
parents: 260
diff changeset
   256
    /**
d5cd4b2e7426 8029 apache: ui redesign
Stephen Talley <stephen.talley@sun.com>
parents: 260
diff changeset
   257
     * Asynchronously invokes this {@link Control}'s save action, then navigates
d5cd4b2e7426 8029 apache: ui redesign
Stephen Talley <stephen.talley@sun.com>
parents: 260
diff changeset
   258
     * up one level in the navigation stack.
d5cd4b2e7426 8029 apache: ui redesign
Stephen Talley <stephen.talley@sun.com>
parents: 260
diff changeset
   259
     */
d5cd4b2e7426 8029 apache: ui redesign
Stephen Talley <stephen.talley@sun.com>
parents: 260
diff changeset
   260
    public void doOkay() {
d5cd4b2e7426 8029 apache: ui redesign
Stephen Talley <stephen.talley@sun.com>
parents: 260
diff changeset
   261
	final StructuredAction<?, ?, ?> saveAction = getSaveAction();
d5cd4b2e7426 8029 apache: ui redesign
Stephen Talley <stephen.talley@sun.com>
parents: 260
diff changeset
   262
	saveAction.asyncExec(
d5cd4b2e7426 8029 apache: ui redesign
Stephen Talley <stephen.talley@sun.com>
parents: 260
diff changeset
   263
	    new Runnable() {
d5cd4b2e7426 8029 apache: ui redesign
Stephen Talley <stephen.talley@sun.com>
parents: 260
diff changeset
   264
		@Override
d5cd4b2e7426 8029 apache: ui redesign
Stephen Talley <stephen.talley@sun.com>
parents: 260
diff changeset
   265
		public void run() {
d5cd4b2e7426 8029 apache: ui redesign
Stephen Talley <stephen.talley@sun.com>
parents: 260
diff changeset
   266
		    try {
d5cd4b2e7426 8029 apache: ui redesign
Stephen Talley <stephen.talley@sun.com>
parents: 260
diff changeset
   267
			saveAction.invoke();
d5cd4b2e7426 8029 apache: ui redesign
Stephen Talley <stephen.talley@sun.com>
parents: 260
diff changeset
   268
302
ac70675de834 9318 Navigator/Control should distinguish between cancel and non-cancel navigations
Stephen Talley <stephen.talley@sun.com>
parents: 279
diff changeset
   269
			getNavigator().goToAsync(false, Control.this,
373
faddb1b7fb76 12184 Navigator's address validation is incomplete, and uncompletable
Stephen Talley <stephen.talley@sun.com>
parents: 361
diff changeset
   270
			    Navigator.PARENT_NAVIGABLE);
264
d5cd4b2e7426 8029 apache: ui redesign
Stephen Talley <stephen.talley@sun.com>
parents: 260
diff changeset
   271
		    } catch (ActionException ignore) {
d5cd4b2e7426 8029 apache: ui redesign
Stephen Talley <stephen.talley@sun.com>
parents: 260
diff changeset
   272
		    }
d5cd4b2e7426 8029 apache: ui redesign
Stephen Talley <stephen.talley@sun.com>
parents: 260
diff changeset
   273
		}
d5cd4b2e7426 8029 apache: ui redesign
Stephen Talley <stephen.talley@sun.com>
parents: 260
diff changeset
   274
	    });
d5cd4b2e7426 8029 apache: ui redesign
Stephen Talley <stephen.talley@sun.com>
parents: 260
diff changeset
   275
    }
d5cd4b2e7426 8029 apache: ui redesign
Stephen Talley <stephen.talley@sun.com>
parents: 260
diff changeset
   276
d5cd4b2e7426 8029 apache: ui redesign
Stephen Talley <stephen.talley@sun.com>
parents: 260
diff changeset
   277
    /**
0
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   278
     * Gets a list of {@code Navigable}s that resolve to a child {@code Control}
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   279
     * of this {@code Control}.
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   280
     *
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   281
     * @return	    a non-{@code null} (but possibly empty) {@code Collection}
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   282
     */
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   283
    public abstract List<Navigable> getBrowsable();
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   284
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   285
    /**
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   286
     * Gets the child {@code Control} with the given identifier, creating it if
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   287
     * necessary.
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   288
     *
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   289
     * @param	    id
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   290
     *		    a unique identifier, as reported by the child {@code
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   291
     *		    Control}'s {@link #getId} method.
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   292
     *
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   293
     * @return	    a {@code Control} object, or {@code null} if no such child
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   294
     *		    is known
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   295
     */
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   296
    public abstract Control getChildControl(String id);
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   297
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   298
    /**
247
8ed978c14164 7820 Control.getForwardingPath should return a Navigable array instead of a String
Stephen Talley <stephen.talley@sun.com>
parents: 235
diff changeset
   299
     * Gets a {@link Navigable} path to navigate to automatically when this
8ed978c14164 7820 Control.getForwardingPath should return a Navigable array instead of a String
Stephen Talley <stephen.talley@sun.com>
parents: 235
diff changeset
   300
     * {@code Control} is the final destination of a navigation (not an
258
521fd086e813 7977 navigator: getForwardingPath should be called after Control is started
Stephen Talley <stephen.talley@sun.com>
parents: 248
diff changeset
   301
     * intermediate stop to another {@code Control}).  This method is called by
521fd086e813 7977 navigator: getForwardingPath should be called after Control is started
Stephen Talley <stephen.talley@sun.com>
parents: 248
diff changeset
   302
     * the {@link Navigator} <strong>after</strong> this {@code Control} has
521fd086e813 7977 navigator: getForwardingPath should be called after Control is started
Stephen Talley <stephen.talley@sun.com>
parents: 248
diff changeset
   303
     * been started.
360
8943c58ad2f5 11508 Control, DefaultControl refactoring
Stephen Talley <stephen.talley@sun.com>
parents: 356
diff changeset
   304
     * <p/>
247
8ed978c14164 7820 Control.getForwardingPath should return a Navigable array instead of a String
Stephen Talley <stephen.talley@sun.com>
parents: 235
diff changeset
   305
     * If the first element is {@code null}, the returned path is considered
8ed978c14164 7820 Control.getForwardingPath should return a Navigable array instead of a String
Stephen Talley <stephen.talley@sun.com>
parents: 235
diff changeset
   306
     * absolute.  Otherwise, it is relative to this {@code Control}.
360
8943c58ad2f5 11508 Control, DefaultControl refactoring
Stephen Talley <stephen.talley@sun.com>
parents: 356
diff changeset
   307
     * <p/>
0
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   308
     * This default implementation returns {@code null}.
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   309
     *
404
32e9b6a2b5f2 13501 generic support for window-creating Controls
Stephen Talley <stephen.talley@sun.com>
parents: 379
diff changeset
   310
     * @param	    childStopped
32e9b6a2b5f2 13501 generic support for window-creating Controls
Stephen Talley <stephen.talley@sun.com>
parents: 379
diff changeset
   311
     *		    {@code true} if navigation stopped here because a child
32e9b6a2b5f2 13501 generic support for window-creating Controls
Stephen Talley <stephen.talley@sun.com>
parents: 379
diff changeset
   312
     *		    {@code Control} of this {@code Control} stopped, {@code
32e9b6a2b5f2 13501 generic support for window-creating Controls
Stephen Talley <stephen.talley@sun.com>
parents: 379
diff changeset
   313
     *		    false} if this {@code Control} was started as part of this
32e9b6a2b5f2 13501 generic support for window-creating Controls
Stephen Talley <stephen.talley@sun.com>
parents: 379
diff changeset
   314
     *		    specific navigation
32e9b6a2b5f2 13501 generic support for window-creating Controls
Stephen Talley <stephen.talley@sun.com>
parents: 379
diff changeset
   315
     *
247
8ed978c14164 7820 Control.getForwardingPath should return a Navigable array instead of a String
Stephen Talley <stephen.talley@sun.com>
parents: 235
diff changeset
   316
     * @return	    a {@link Navigable} array, or {@code null} if no automatic
8ed978c14164 7820 Control.getForwardingPath should return a Navigable array instead of a String
Stephen Talley <stephen.talley@sun.com>
parents: 235
diff changeset
   317
     *		    forwarding should occur
0
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   318
     */
404
32e9b6a2b5f2 13501 generic support for window-creating Controls
Stephen Talley <stephen.talley@sun.com>
parents: 379
diff changeset
   319
    public Navigable[] getForwardingPath(boolean childStopped) {
0
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   320
	return null;
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   321
    }
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   322
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   323
    /**
360
8943c58ad2f5 11508 Control, DefaultControl refactoring
Stephen Talley <stephen.talley@sun.com>
parents: 356
diff changeset
   324
     * Gets the help URL for this {@code DefaultControl}.
8943c58ad2f5 11508 Control, DefaultControl refactoring
Stephen Talley <stephen.talley@sun.com>
parents: 356
diff changeset
   325
     * <p/>
8943c58ad2f5 11508 Control, DefaultControl refactoring
Stephen Talley <stephen.talley@sun.com>
parents: 356
diff changeset
   326
     * This default implementation returns {@code null}.
8943c58ad2f5 11508 Control, DefaultControl refactoring
Stephen Talley <stephen.talley@sun.com>
parents: 356
diff changeset
   327
     *
8943c58ad2f5 11508 Control, DefaultControl refactoring
Stephen Talley <stephen.talley@sun.com>
parents: 356
diff changeset
   328
     * @return	    a URL, or {@code null} if no URL applies
8943c58ad2f5 11508 Control, DefaultControl refactoring
Stephen Talley <stephen.talley@sun.com>
parents: 356
diff changeset
   329
     */
8943c58ad2f5 11508 Control, DefaultControl refactoring
Stephen Talley <stephen.talley@sun.com>
parents: 356
diff changeset
   330
    public URL getHelpURL() {
8943c58ad2f5 11508 Control, DefaultControl refactoring
Stephen Talley <stephen.talley@sun.com>
parents: 356
diff changeset
   331
	return null;
8943c58ad2f5 11508 Control, DefaultControl refactoring
Stephen Talley <stephen.talley@sun.com>
parents: 356
diff changeset
   332
    }
8943c58ad2f5 11508 Control, DefaultControl refactoring
Stephen Talley <stephen.talley@sun.com>
parents: 356
diff changeset
   333
8943c58ad2f5 11508 Control, DefaultControl refactoring
Stephen Talley <stephen.talley@sun.com>
parents: 356
diff changeset
   334
    /**
0
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   335
     * Gets the {@link Navigator} passed to the {@link #start} method, if
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   336
     * this {@code Control} is started, or {@code null} if this {@code Control}
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   337
     * is stopped.
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   338
     */
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   339
    public Navigator getNavigator() {
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   340
	return navigator;
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   341
    }
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   342
235
38f73435a683 7483 save/prompt functionality in SwingControl can be generalized and moved into Control and DefaultControl
Stephen Talley <stephen.talley@sun.com>
parents: 214
diff changeset
   343
    /**
348
6f9b5e56d0a1 11021 firewall: fails to start when breadcrumbs are enabled
Stephen Talley <stephen.talley@sun.com>
parents: 327
diff changeset
   344
     * Gets a {@link StructuredAction} that invokes {@link #resetAll}.
6f9b5e56d0a1 11021 firewall: fails to start when breadcrumbs are enabled
Stephen Talley <stephen.talley@sun.com>
parents: 327
diff changeset
   345
     */
6f9b5e56d0a1 11021 firewall: fails to start when breadcrumbs are enabled
Stephen Talley <stephen.talley@sun.com>
parents: 327
diff changeset
   346
    public StructuredAction<?, ?, ?> getResetAction() {
6f9b5e56d0a1 11021 firewall: fails to start when breadcrumbs are enabled
Stephen Talley <stephen.talley@sun.com>
parents: 327
diff changeset
   347
	return resetAction;
6f9b5e56d0a1 11021 firewall: fails to start when breadcrumbs are enabled
Stephen Talley <stephen.talley@sun.com>
parents: 327
diff changeset
   348
    }
6f9b5e56d0a1 11021 firewall: fails to start when breadcrumbs are enabled
Stephen Talley <stephen.talley@sun.com>
parents: 327
diff changeset
   349
6f9b5e56d0a1 11021 firewall: fails to start when breadcrumbs are enabled
Stephen Talley <stephen.talley@sun.com>
parents: 327
diff changeset
   350
    /**
360
8943c58ad2f5 11508 Control, DefaultControl refactoring
Stephen Talley <stephen.talley@sun.com>
parents: 356
diff changeset
   351
     * Gets the child {@code Control} currently running, or {@code null} if
8943c58ad2f5 11508 Control, DefaultControl refactoring
Stephen Talley <stephen.talley@sun.com>
parents: 356
diff changeset
   352
     * there is none.
8943c58ad2f5 11508 Control, DefaultControl refactoring
Stephen Talley <stephen.talley@sun.com>
parents: 356
diff changeset
   353
     */
8943c58ad2f5 11508 Control, DefaultControl refactoring
Stephen Talley <stephen.talley@sun.com>
parents: 356
diff changeset
   354
    public Control getRunningChild() {
8943c58ad2f5 11508 Control, DefaultControl refactoring
Stephen Talley <stephen.talley@sun.com>
parents: 356
diff changeset
   355
	return child;
8943c58ad2f5 11508 Control, DefaultControl refactoring
Stephen Talley <stephen.talley@sun.com>
parents: 356
diff changeset
   356
    }
8943c58ad2f5 11508 Control, DefaultControl refactoring
Stephen Talley <stephen.talley@sun.com>
parents: 356
diff changeset
   357
8943c58ad2f5 11508 Control, DefaultControl refactoring
Stephen Talley <stephen.talley@sun.com>
parents: 356
diff changeset
   358
    /**
348
6f9b5e56d0a1 11021 firewall: fails to start when breadcrumbs are enabled
Stephen Talley <stephen.talley@sun.com>
parents: 327
diff changeset
   359
     * Gets a {@link StructuredAction} that invokes {@link #saveAll}.
6f9b5e56d0a1 11021 firewall: fails to start when breadcrumbs are enabled
Stephen Talley <stephen.talley@sun.com>
parents: 327
diff changeset
   360
     */
6f9b5e56d0a1 11021 firewall: fails to start when breadcrumbs are enabled
Stephen Talley <stephen.talley@sun.com>
parents: 327
diff changeset
   361
    public StructuredAction<?, ?, ?> getSaveAction() {
6f9b5e56d0a1 11021 firewall: fails to start when breadcrumbs are enabled
Stephen Talley <stephen.talley@sun.com>
parents: 327
diff changeset
   362
	return saveAction;
6f9b5e56d0a1 11021 firewall: fails to start when breadcrumbs are enabled
Stephen Talley <stephen.talley@sun.com>
parents: 327
diff changeset
   363
    }
6f9b5e56d0a1 11021 firewall: fails to start when breadcrumbs are enabled
Stephen Talley <stephen.talley@sun.com>
parents: 327
diff changeset
   364
6f9b5e56d0a1 11021 firewall: fails to start when breadcrumbs are enabled
Stephen Talley <stephen.talley@sun.com>
parents: 327
diff changeset
   365
    /**
360
8943c58ad2f5 11508 Control, DefaultControl refactoring
Stephen Talley <stephen.talley@sun.com>
parents: 356
diff changeset
   366
     * Called by {@link #stop} when there are unsaved changes, gets the action
8943c58ad2f5 11508 Control, DefaultControl refactoring
Stephen Talley <stephen.talley@sun.com>
parents: 356
diff changeset
   367
     * that should be taken to handle them.
8943c58ad2f5 11508 Control, DefaultControl refactoring
Stephen Talley <stephen.talley@sun.com>
parents: 356
diff changeset
   368
     * <p/>
8943c58ad2f5 11508 Control, DefaultControl refactoring
Stephen Talley <stephen.talley@sun.com>
parents: 356
diff changeset
   369
     * This default implementation returns {@link UnsavedChangesAction#DISCARD}.
8943c58ad2f5 11508 Control, DefaultControl refactoring
Stephen Talley <stephen.talley@sun.com>
parents: 356
diff changeset
   370
     * Subclasses may wish to prompt the user to determine the appropriate
8943c58ad2f5 11508 Control, DefaultControl refactoring
Stephen Talley <stephen.talley@sun.com>
parents: 356
diff changeset
   371
     * action to take.
8943c58ad2f5 11508 Control, DefaultControl refactoring
Stephen Talley <stephen.talley@sun.com>
parents: 356
diff changeset
   372
     */
8943c58ad2f5 11508 Control, DefaultControl refactoring
Stephen Talley <stephen.talley@sun.com>
parents: 356
diff changeset
   373
    protected UnsavedChangesAction getUnsavedChangesAction() {
8943c58ad2f5 11508 Control, DefaultControl refactoring
Stephen Talley <stephen.talley@sun.com>
parents: 356
diff changeset
   374
	return UnsavedChangesAction.DISCARD;
8943c58ad2f5 11508 Control, DefaultControl refactoring
Stephen Talley <stephen.talley@sun.com>
parents: 356
diff changeset
   375
    }
8943c58ad2f5 11508 Control, DefaultControl refactoring
Stephen Talley <stephen.talley@sun.com>
parents: 356
diff changeset
   376
8943c58ad2f5 11508 Control, DefaultControl refactoring
Stephen Talley <stephen.talley@sun.com>
parents: 356
diff changeset
   377
    /**
348
6f9b5e56d0a1 11021 firewall: fails to start when breadcrumbs are enabled
Stephen Talley <stephen.talley@sun.com>
parents: 327
diff changeset
   378
     * Gets a hint as to whether this {@code Control} should be returned by a
6f9b5e56d0a1 11021 firewall: fails to start when breadcrumbs are enabled
Stephen Talley <stephen.talley@sun.com>
parents: 327
diff changeset
   379
     * parent {@code Control}'s {@link #getBrowsable} method.  The parent may
6f9b5e56d0a1 11021 firewall: fails to start when breadcrumbs are enabled
Stephen Talley <stephen.talley@sun.com>
parents: 327
diff changeset
   380
     * choose to ignore this hint.
360
8943c58ad2f5 11508 Control, DefaultControl refactoring
Stephen Talley <stephen.talley@sun.com>
parents: 356
diff changeset
   381
     * <p/>
8943c58ad2f5 11508 Control, DefaultControl refactoring
Stephen Talley <stephen.talley@sun.com>
parents: 356
diff changeset
   382
     * This default implementation returns {@code true}.
348
6f9b5e56d0a1 11021 firewall: fails to start when breadcrumbs are enabled
Stephen Talley <stephen.talley@sun.com>
parents: 327
diff changeset
   383
     */
360
8943c58ad2f5 11508 Control, DefaultControl refactoring
Stephen Talley <stephen.talley@sun.com>
parents: 356
diff changeset
   384
    public boolean isBrowsable() {
8943c58ad2f5 11508 Control, DefaultControl refactoring
Stephen Talley <stephen.talley@sun.com>
parents: 356
diff changeset
   385
	return true;
8943c58ad2f5 11508 Control, DefaultControl refactoring
Stephen Talley <stephen.talley@sun.com>
parents: 356
diff changeset
   386
    }
348
6f9b5e56d0a1 11021 firewall: fails to start when breadcrumbs are enabled
Stephen Talley <stephen.talley@sun.com>
parents: 327
diff changeset
   387
6f9b5e56d0a1 11021 firewall: fails to start when breadcrumbs are enabled
Stephen Talley <stephen.talley@sun.com>
parents: 327
diff changeset
   388
    /**
360
8943c58ad2f5 11508 Control, DefaultControl refactoring
Stephen Talley <stephen.talley@sun.com>
parents: 356
diff changeset
   389
     * Indicates whether there are any unsaved changes in this {@code Control}.
8943c58ad2f5 11508 Control, DefaultControl refactoring
Stephen Talley <stephen.talley@sun.com>
parents: 356
diff changeset
   390
     * <p/>
8943c58ad2f5 11508 Control, DefaultControl refactoring
Stephen Talley <stephen.talley@sun.com>
parents: 356
diff changeset
   391
     * This default implementation returns {@code false}.
235
38f73435a683 7483 save/prompt functionality in SwingControl can be generalized and moved into Control and DefaultControl
Stephen Talley <stephen.talley@sun.com>
parents: 214
diff changeset
   392
     */
361
d3611020acea 11509 Control: s/isSaveNeeded/isChanged/g
Stephen Talley <stephen.talley@sun.com>
parents: 360
diff changeset
   393
    protected boolean isChanged() {
360
8943c58ad2f5 11508 Control, DefaultControl refactoring
Stephen Talley <stephen.talley@sun.com>
parents: 356
diff changeset
   394
	return false;
8943c58ad2f5 11508 Control, DefaultControl refactoring
Stephen Talley <stephen.talley@sun.com>
parents: 356
diff changeset
   395
    }
235
38f73435a683 7483 save/prompt functionality in SwingControl can be generalized and moved into Control and DefaultControl
Stephen Talley <stephen.talley@sun.com>
parents: 214
diff changeset
   396
360
8943c58ad2f5 11508 Control, DefaultControl refactoring
Stephen Talley <stephen.talley@sun.com>
parents: 356
diff changeset
   397
    public boolean isStarted() {
17
b82508ab9887 2522 hard to differentiate group and share edit views
Stephen Talley <stephen.talley@sun.com>
parents: 0
diff changeset
   398
	return navigator != null;
b82508ab9887 2522 hard to differentiate group and share edit views
Stephen Talley <stephen.talley@sun.com>
parents: 0
diff changeset
   399
    }
b82508ab9887 2522 hard to differentiate group and share edit views
Stephen Talley <stephen.talley@sun.com>
parents: 0
diff changeset
   400
0
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   401
    /**
138
48a05b6471de 4366 wizard: wizard steps should not be limited to SwingControls
Stephen Talley <stephen.talley@sun.com>
parents: 79
diff changeset
   402
     * If appropriate, resets this {@code Control}, discarding any pending
48a05b6471de 4366 wizard: wizard steps should not be limited to SwingControls
Stephen Talley <stephen.talley@sun.com>
parents: 79
diff changeset
   403
     * changes.
48a05b6471de 4366 wizard: wizard steps should not be limited to SwingControls
Stephen Talley <stephen.talley@sun.com>
parents: 79
diff changeset
   404
     * <p/>
48a05b6471de 4366 wizard: wizard steps should not be limited to SwingControls
Stephen Talley <stephen.talley@sun.com>
parents: 79
diff changeset
   405
     * This default implementation does nothing.
48a05b6471de 4366 wizard: wizard steps should not be limited to SwingControls
Stephen Talley <stephen.talley@sun.com>
parents: 79
diff changeset
   406
     *
48a05b6471de 4366 wizard: wizard steps should not be limited to SwingControls
Stephen Talley <stephen.talley@sun.com>
parents: 79
diff changeset
   407
     * @exception   ActionAbortedException
48a05b6471de 4366 wizard: wizard steps should not be limited to SwingControls
Stephen Talley <stephen.talley@sun.com>
parents: 79
diff changeset
   408
     *		    if this operation is cancelled
48a05b6471de 4366 wizard: wizard steps should not be limited to SwingControls
Stephen Talley <stephen.talley@sun.com>
parents: 79
diff changeset
   409
     *
48a05b6471de 4366 wizard: wizard steps should not be limited to SwingControls
Stephen Talley <stephen.talley@sun.com>
parents: 79
diff changeset
   410
     * @exception   ActionFailedException
48a05b6471de 4366 wizard: wizard steps should not be limited to SwingControls
Stephen Talley <stephen.talley@sun.com>
parents: 79
diff changeset
   411
     *		    if this operation fails
48a05b6471de 4366 wizard: wizard steps should not be limited to SwingControls
Stephen Talley <stephen.talley@sun.com>
parents: 79
diff changeset
   412
     */
48a05b6471de 4366 wizard: wizard steps should not be limited to SwingControls
Stephen Talley <stephen.talley@sun.com>
parents: 79
diff changeset
   413
    protected void reset() throws ActionAbortedException, ActionFailedException
48a05b6471de 4366 wizard: wizard steps should not be limited to SwingControls
Stephen Talley <stephen.talley@sun.com>
parents: 79
diff changeset
   414
    {
48a05b6471de 4366 wizard: wizard steps should not be limited to SwingControls
Stephen Talley <stephen.talley@sun.com>
parents: 79
diff changeset
   415
    }
48a05b6471de 4366 wizard: wizard steps should not be limited to SwingControls
Stephen Talley <stephen.talley@sun.com>
parents: 79
diff changeset
   416
48a05b6471de 4366 wizard: wizard steps should not be limited to SwingControls
Stephen Talley <stephen.talley@sun.com>
parents: 79
diff changeset
   417
    /**
260
507ac22496fe 7994 Control save/reset actions should act on descendents first
Stephen Talley <stephen.talley@sun.com>
parents: 258
diff changeset
   418
     * {@link #reset Reset}s all {@code Control}s from the top of the navigation
507ac22496fe 7994 Control save/reset actions should act on descendents first
Stephen Talley <stephen.talley@sun.com>
parents: 258
diff changeset
   419
     * stack to this {@link Control}, discarding any pending changes.
507ac22496fe 7994 Control save/reset actions should act on descendents first
Stephen Talley <stephen.talley@sun.com>
parents: 258
diff changeset
   420
     *
507ac22496fe 7994 Control save/reset actions should act on descendents first
Stephen Talley <stephen.talley@sun.com>
parents: 258
diff changeset
   421
     * @exception   ActionAbortedException
507ac22496fe 7994 Control save/reset actions should act on descendents first
Stephen Talley <stephen.talley@sun.com>
parents: 258
diff changeset
   422
     *		    see {@link #reset}
507ac22496fe 7994 Control save/reset actions should act on descendents first
Stephen Talley <stephen.talley@sun.com>
parents: 258
diff changeset
   423
     *
507ac22496fe 7994 Control save/reset actions should act on descendents first
Stephen Talley <stephen.talley@sun.com>
parents: 258
diff changeset
   424
     * @exception   ActionFailedException
507ac22496fe 7994 Control save/reset actions should act on descendents first
Stephen Talley <stephen.talley@sun.com>
parents: 258
diff changeset
   425
     *		    see {@link #reset}
507ac22496fe 7994 Control save/reset actions should act on descendents first
Stephen Talley <stephen.talley@sun.com>
parents: 258
diff changeset
   426
     *
507ac22496fe 7994 Control save/reset actions should act on descendents first
Stephen Talley <stephen.talley@sun.com>
parents: 258
diff changeset
   427
     * @exception   IllegalStateException
360
8943c58ad2f5 11508 Control, DefaultControl refactoring
Stephen Talley <stephen.talley@sun.com>
parents: 356
diff changeset
   428
     *		    if this {@link Control} is not started
260
507ac22496fe 7994 Control save/reset actions should act on descendents first
Stephen Talley <stephen.talley@sun.com>
parents: 258
diff changeset
   429
     */
507ac22496fe 7994 Control save/reset actions should act on descendents first
Stephen Talley <stephen.talley@sun.com>
parents: 258
diff changeset
   430
    protected void resetAll() throws ActionAbortedException,
507ac22496fe 7994 Control save/reset actions should act on descendents first
Stephen Talley <stephen.talley@sun.com>
parents: 258
diff changeset
   431
	ActionFailedException {
507ac22496fe 7994 Control save/reset actions should act on descendents first
Stephen Talley <stephen.talley@sun.com>
parents: 258
diff changeset
   432
360
8943c58ad2f5 11508 Control, DefaultControl refactoring
Stephen Talley <stephen.talley@sun.com>
parents: 356
diff changeset
   433
	assertStartState(true);
260
507ac22496fe 7994 Control save/reset actions should act on descendents first
Stephen Talley <stephen.talley@sun.com>
parents: 258
diff changeset
   434
507ac22496fe 7994 Control save/reset actions should act on descendents first
Stephen Talley <stephen.talley@sun.com>
parents: 258
diff changeset
   435
	List<Control> path = navigator.getPath();
507ac22496fe 7994 Control save/reset actions should act on descendents first
Stephen Talley <stephen.talley@sun.com>
parents: 258
diff changeset
   436
	if (!path.contains(this)) {
507ac22496fe 7994 Control save/reset actions should act on descendents first
Stephen Talley <stephen.talley@sun.com>
parents: 258
diff changeset
   437
	    throw new IllegalStateException();
507ac22496fe 7994 Control save/reset actions should act on descendents first
Stephen Talley <stephen.talley@sun.com>
parents: 258
diff changeset
   438
	}
507ac22496fe 7994 Control save/reset actions should act on descendents first
Stephen Talley <stephen.talley@sun.com>
parents: 258
diff changeset
   439
507ac22496fe 7994 Control save/reset actions should act on descendents first
Stephen Talley <stephen.talley@sun.com>
parents: 258
diff changeset
   440
	for (int i = path.size() - 1; i >= 0; i--) {
507ac22496fe 7994 Control save/reset actions should act on descendents first
Stephen Talley <stephen.talley@sun.com>
parents: 258
diff changeset
   441
	    Control control = path.get(i);
507ac22496fe 7994 Control save/reset actions should act on descendents first
Stephen Talley <stephen.talley@sun.com>
parents: 258
diff changeset
   442
	    control.reset();
507ac22496fe 7994 Control save/reset actions should act on descendents first
Stephen Talley <stephen.talley@sun.com>
parents: 258
diff changeset
   443
	    if (control == this) {
507ac22496fe 7994 Control save/reset actions should act on descendents first
Stephen Talley <stephen.talley@sun.com>
parents: 258
diff changeset
   444
		break;
507ac22496fe 7994 Control save/reset actions should act on descendents first
Stephen Talley <stephen.talley@sun.com>
parents: 258
diff changeset
   445
	    }
507ac22496fe 7994 Control save/reset actions should act on descendents first
Stephen Talley <stephen.talley@sun.com>
parents: 258
diff changeset
   446
	}
507ac22496fe 7994 Control save/reset actions should act on descendents first
Stephen Talley <stephen.talley@sun.com>
parents: 258
diff changeset
   447
    }
507ac22496fe 7994 Control save/reset actions should act on descendents first
Stephen Talley <stephen.talley@sun.com>
parents: 258
diff changeset
   448
507ac22496fe 7994 Control save/reset actions should act on descendents first
Stephen Talley <stephen.talley@sun.com>
parents: 258
diff changeset
   449
    /**
138
48a05b6471de 4366 wizard: wizard steps should not be limited to SwingControls
Stephen Talley <stephen.talley@sun.com>
parents: 79
diff changeset
   450
     * If appropriate, saves any changes made while this {@code Control} is
48a05b6471de 4366 wizard: wizard steps should not be limited to SwingControls
Stephen Talley <stephen.talley@sun.com>
parents: 79
diff changeset
   451
     * running.
48a05b6471de 4366 wizard: wizard steps should not be limited to SwingControls
Stephen Talley <stephen.talley@sun.com>
parents: 79
diff changeset
   452
     * <p/>
48a05b6471de 4366 wizard: wizard steps should not be limited to SwingControls
Stephen Talley <stephen.talley@sun.com>
parents: 79
diff changeset
   453
     * This default implementation does nothing.
48a05b6471de 4366 wizard: wizard steps should not be limited to SwingControls
Stephen Talley <stephen.talley@sun.com>
parents: 79
diff changeset
   454
     *
48a05b6471de 4366 wizard: wizard steps should not be limited to SwingControls
Stephen Talley <stephen.talley@sun.com>
parents: 79
diff changeset
   455
     * @exception   ActionAbortedException
48a05b6471de 4366 wizard: wizard steps should not be limited to SwingControls
Stephen Talley <stephen.talley@sun.com>
parents: 79
diff changeset
   456
     *		    if this operation is cancelled
48a05b6471de 4366 wizard: wizard steps should not be limited to SwingControls
Stephen Talley <stephen.talley@sun.com>
parents: 79
diff changeset
   457
     *
48a05b6471de 4366 wizard: wizard steps should not be limited to SwingControls
Stephen Talley <stephen.talley@sun.com>
parents: 79
diff changeset
   458
     * @exception   ActionFailedException
48a05b6471de 4366 wizard: wizard steps should not be limited to SwingControls
Stephen Talley <stephen.talley@sun.com>
parents: 79
diff changeset
   459
     *		    if this operation fails
48a05b6471de 4366 wizard: wizard steps should not be limited to SwingControls
Stephen Talley <stephen.talley@sun.com>
parents: 79
diff changeset
   460
     *
214
aed2b42f7344 6426 UnauthorizedActionException's name should follow convention
Stephen Talley <stephen.talley@sun.com>
parents: 196
diff changeset
   461
     * @exception   ActionUnauthorizedException
138
48a05b6471de 4366 wizard: wizard steps should not be limited to SwingControls
Stephen Talley <stephen.talley@sun.com>
parents: 79
diff changeset
   462
     *		    if the current user has insufficient privileges for this
48a05b6471de 4366 wizard: wizard steps should not be limited to SwingControls
Stephen Talley <stephen.talley@sun.com>
parents: 79
diff changeset
   463
     *		    operation
48a05b6471de 4366 wizard: wizard steps should not be limited to SwingControls
Stephen Talley <stephen.talley@sun.com>
parents: 79
diff changeset
   464
     */
48a05b6471de 4366 wizard: wizard steps should not be limited to SwingControls
Stephen Talley <stephen.talley@sun.com>
parents: 79
diff changeset
   465
    protected void save() throws ActionAbortedException, ActionFailedException,
214
aed2b42f7344 6426 UnauthorizedActionException's name should follow convention
Stephen Talley <stephen.talley@sun.com>
parents: 196
diff changeset
   466
	ActionUnauthorizedException {
138
48a05b6471de 4366 wizard: wizard steps should not be limited to SwingControls
Stephen Talley <stephen.talley@sun.com>
parents: 79
diff changeset
   467
    }
48a05b6471de 4366 wizard: wizard steps should not be limited to SwingControls
Stephen Talley <stephen.talley@sun.com>
parents: 79
diff changeset
   468
48a05b6471de 4366 wizard: wizard steps should not be limited to SwingControls
Stephen Talley <stephen.talley@sun.com>
parents: 79
diff changeset
   469
    /**
260
507ac22496fe 7994 Control save/reset actions should act on descendents first
Stephen Talley <stephen.talley@sun.com>
parents: 258
diff changeset
   470
     * {@link #save Save}s all {@code Control}s from the top of the navigation
507ac22496fe 7994 Control save/reset actions should act on descendents first
Stephen Talley <stephen.talley@sun.com>
parents: 258
diff changeset
   471
     * stack to this {@link Control}.
507ac22496fe 7994 Control save/reset actions should act on descendents first
Stephen Talley <stephen.talley@sun.com>
parents: 258
diff changeset
   472
     *
507ac22496fe 7994 Control save/reset actions should act on descendents first
Stephen Talley <stephen.talley@sun.com>
parents: 258
diff changeset
   473
     * @exception   ActionAbortedException
507ac22496fe 7994 Control save/reset actions should act on descendents first
Stephen Talley <stephen.talley@sun.com>
parents: 258
diff changeset
   474
     *		    see {@link #save}
507ac22496fe 7994 Control save/reset actions should act on descendents first
Stephen Talley <stephen.talley@sun.com>
parents: 258
diff changeset
   475
     *
507ac22496fe 7994 Control save/reset actions should act on descendents first
Stephen Talley <stephen.talley@sun.com>
parents: 258
diff changeset
   476
     * @exception   ActionFailedException
507ac22496fe 7994 Control save/reset actions should act on descendents first
Stephen Talley <stephen.talley@sun.com>
parents: 258
diff changeset
   477
     *		    see {@link #save}
507ac22496fe 7994 Control save/reset actions should act on descendents first
Stephen Talley <stephen.talley@sun.com>
parents: 258
diff changeset
   478
     *
507ac22496fe 7994 Control save/reset actions should act on descendents first
Stephen Talley <stephen.talley@sun.com>
parents: 258
diff changeset
   479
     * @exception   ActionUnauthorizedException
507ac22496fe 7994 Control save/reset actions should act on descendents first
Stephen Talley <stephen.talley@sun.com>
parents: 258
diff changeset
   480
     *		    see {@link #save}
507ac22496fe 7994 Control save/reset actions should act on descendents first
Stephen Talley <stephen.talley@sun.com>
parents: 258
diff changeset
   481
     *
507ac22496fe 7994 Control save/reset actions should act on descendents first
Stephen Talley <stephen.talley@sun.com>
parents: 258
diff changeset
   482
     * @exception   IllegalStateException
360
8943c58ad2f5 11508 Control, DefaultControl refactoring
Stephen Talley <stephen.talley@sun.com>
parents: 356
diff changeset
   483
     *		    if this {@link Control} is not started
260
507ac22496fe 7994 Control save/reset actions should act on descendents first
Stephen Talley <stephen.talley@sun.com>
parents: 258
diff changeset
   484
     */
507ac22496fe 7994 Control save/reset actions should act on descendents first
Stephen Talley <stephen.talley@sun.com>
parents: 258
diff changeset
   485
    protected void saveAll() throws ActionAbortedException,
507ac22496fe 7994 Control save/reset actions should act on descendents first
Stephen Talley <stephen.talley@sun.com>
parents: 258
diff changeset
   486
	ActionFailedException, ActionUnauthorizedException {
507ac22496fe 7994 Control save/reset actions should act on descendents first
Stephen Talley <stephen.talley@sun.com>
parents: 258
diff changeset
   487
360
8943c58ad2f5 11508 Control, DefaultControl refactoring
Stephen Talley <stephen.talley@sun.com>
parents: 356
diff changeset
   488
	assertStartState(true);
260
507ac22496fe 7994 Control save/reset actions should act on descendents first
Stephen Talley <stephen.talley@sun.com>
parents: 258
diff changeset
   489
507ac22496fe 7994 Control save/reset actions should act on descendents first
Stephen Talley <stephen.talley@sun.com>
parents: 258
diff changeset
   490
	List<Control> path = navigator.getPath();
507ac22496fe 7994 Control save/reset actions should act on descendents first
Stephen Talley <stephen.talley@sun.com>
parents: 258
diff changeset
   491
	if (!path.contains(this)) {
507ac22496fe 7994 Control save/reset actions should act on descendents first
Stephen Talley <stephen.talley@sun.com>
parents: 258
diff changeset
   492
	    throw new IllegalStateException();
507ac22496fe 7994 Control save/reset actions should act on descendents first
Stephen Talley <stephen.talley@sun.com>
parents: 258
diff changeset
   493
	}
507ac22496fe 7994 Control save/reset actions should act on descendents first
Stephen Talley <stephen.talley@sun.com>
parents: 258
diff changeset
   494
507ac22496fe 7994 Control save/reset actions should act on descendents first
Stephen Talley <stephen.talley@sun.com>
parents: 258
diff changeset
   495
	for (int i = path.size() - 1; i >= 0; i--) {
507ac22496fe 7994 Control save/reset actions should act on descendents first
Stephen Talley <stephen.talley@sun.com>
parents: 258
diff changeset
   496
	    Control control = path.get(i);
361
d3611020acea 11509 Control: s/isSaveNeeded/isChanged/g
Stephen Talley <stephen.talley@sun.com>
parents: 360
diff changeset
   497
	    if (control.isChanged()) {
264
d5cd4b2e7426 8029 apache: ui redesign
Stephen Talley <stephen.talley@sun.com>
parents: 260
diff changeset
   498
		control.save();
d5cd4b2e7426 8029 apache: ui redesign
Stephen Talley <stephen.talley@sun.com>
parents: 260
diff changeset
   499
	    }
260
507ac22496fe 7994 Control save/reset actions should act on descendents first
Stephen Talley <stephen.talley@sun.com>
parents: 258
diff changeset
   500
	    if (control == this) {
507ac22496fe 7994 Control save/reset actions should act on descendents first
Stephen Talley <stephen.talley@sun.com>
parents: 258
diff changeset
   501
		break;
507ac22496fe 7994 Control save/reset actions should act on descendents first
Stephen Talley <stephen.talley@sun.com>
parents: 258
diff changeset
   502
	    }
507ac22496fe 7994 Control save/reset actions should act on descendents first
Stephen Talley <stephen.talley@sun.com>
parents: 258
diff changeset
   503
	}
507ac22496fe 7994 Control save/reset actions should act on descendents first
Stephen Talley <stephen.talley@sun.com>
parents: 258
diff changeset
   504
    }
507ac22496fe 7994 Control save/reset actions should act on descendents first
Stephen Talley <stephen.talley@sun.com>
parents: 258
diff changeset
   505
507ac22496fe 7994 Control save/reset actions should act on descendents first
Stephen Talley <stephen.talley@sun.com>
parents: 258
diff changeset
   506
    /**
0
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   507
     * Sets the identifier for this {@code Control}.
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   508
     */
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   509
    protected void setId(String id) {
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   510
	this.id = id;
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   511
    }
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   512
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   513
    /**
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   514
     * Sets the name for this {@code Control}.
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   515
     */
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   516
    protected void setName(String name) {
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   517
	this.name = name;
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   518
    }
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   519
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   520
    /**
360
8943c58ad2f5 11508 Control, DefaultControl refactoring
Stephen Talley <stephen.talley@sun.com>
parents: 356
diff changeset
   521
     * Saves references to the given {@link #getNavigator Navigator} and {@link
8943c58ad2f5 11508 Control, DefaultControl refactoring
Stephen Talley <stephen.talley@sun.com>
parents: 356
diff changeset
   522
     * #getParameters initialization parameters}.
8943c58ad2f5 11508 Control, DefaultControl refactoring
Stephen Talley <stephen.talley@sun.com>
parents: 356
diff changeset
   523
     * <p/>
0
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   524
     * Called by the {@link Navigator} when this {@code Control} is pushed onto
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   525
     * the {@code Control} stack.
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   526
     *
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   527
     * @param	    navigator
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   528
     *		    the {@link Navigator} that handles navigation to/from this
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   529
     *		    {@code Controls}
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   530
     *
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   531
     * @param	    parameters
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   532
     *		    non-{@code null}, but optional (may be empty) initialization
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   533
     *		    parameters
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   534
     *
40
d1412af1ae5b 3215 ActionAbortedException is used too broadly
Stephen Talley <stephen.talley@sun.com>
parents: 26
diff changeset
   535
     * @exception   NavigationAbortedException
657
9fdd9a66d201 17928 Control.start should allow broader range of failures
Stephen Talley <stephen.talley@oracle.com>
parents: 591
diff changeset
   536
     *		    if this action is cancelled or vetoed
0
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   537
     *
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   538
     * @exception   InvalidParameterException
657
9fdd9a66d201 17928 Control.start should allow broader range of failures
Stephen Talley <stephen.talley@oracle.com>
parents: 591
diff changeset
   539
     *		    if this action fails due to invalid initialization
9fdd9a66d201 17928 Control.start should allow broader range of failures
Stephen Talley <stephen.talley@oracle.com>
parents: 591
diff changeset
   540
     *		    parameters
9fdd9a66d201 17928 Control.start should allow broader range of failures
Stephen Talley <stephen.talley@oracle.com>
parents: 591
diff changeset
   541
     *
9fdd9a66d201 17928 Control.start should allow broader range of failures
Stephen Talley <stephen.talley@oracle.com>
parents: 591
diff changeset
   542
     * @exception   NavigationFailedException
9fdd9a66d201 17928 Control.start should allow broader range of failures
Stephen Talley <stephen.talley@oracle.com>
parents: 591
diff changeset
   543
     *		    if this action fails for some other reason
360
8943c58ad2f5 11508 Control, DefaultControl refactoring
Stephen Talley <stephen.talley@sun.com>
parents: 356
diff changeset
   544
     *
8943c58ad2f5 11508 Control, DefaultControl refactoring
Stephen Talley <stephen.talley@sun.com>
parents: 356
diff changeset
   545
     * @exception   IllegalStateException
8943c58ad2f5 11508 Control, DefaultControl refactoring
Stephen Talley <stephen.talley@sun.com>
parents: 356
diff changeset
   546
     *		    if this {@link Control} is already started
0
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   547
     */
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   548
    public void start(Navigator navigator, Map<String, String> parameters)
657
9fdd9a66d201 17928 Control.start should allow broader range of failures
Stephen Talley <stephen.talley@oracle.com>
parents: 591
diff changeset
   549
	throws NavigationAbortedException, InvalidParameterException,
9fdd9a66d201 17928 Control.start should allow broader range of failures
Stephen Talley <stephen.talley@oracle.com>
parents: 591
diff changeset
   550
	NavigationFailedException {
360
8943c58ad2f5 11508 Control, DefaultControl refactoring
Stephen Talley <stephen.talley@sun.com>
parents: 356
diff changeset
   551
8943c58ad2f5 11508 Control, DefaultControl refactoring
Stephen Talley <stephen.talley@sun.com>
parents: 356
diff changeset
   552
	assertStartState(false);
8943c58ad2f5 11508 Control, DefaultControl refactoring
Stephen Talley <stephen.talley@sun.com>
parents: 356
diff changeset
   553
	this.navigator = navigator;
8943c58ad2f5 11508 Control, DefaultControl refactoring
Stephen Talley <stephen.talley@sun.com>
parents: 356
diff changeset
   554
	this.parameters = parameters;
0
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   555
    }
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   556
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   557
    /**
360
8943c58ad2f5 11508 Control, DefaultControl refactoring
Stephen Talley <stephen.talley@sun.com>
parents: 356
diff changeset
   558
     * If {@code isCancel} is {@code false}, saves, resets, or cancels changes
361
d3611020acea 11509 Control: s/isSaveNeeded/isChanged/g
Stephen Talley <stephen.talley@sun.com>
parents: 360
diff changeset
   559
     * {@link #isChanged if necessary}, based on the return value of {@link
360
8943c58ad2f5 11508 Control, DefaultControl refactoring
Stephen Talley <stephen.talley@sun.com>
parents: 356
diff changeset
   560
     * #getUnsavedChangesAction}.  Then resets the references to the {@link
8943c58ad2f5 11508 Control, DefaultControl refactoring
Stephen Talley <stephen.talley@sun.com>
parents: 356
diff changeset
   561
     * #getNavigator Navigator} and {@link #getParameters initialization
8943c58ad2f5 11508 Control, DefaultControl refactoring
Stephen Talley <stephen.talley@sun.com>
parents: 356
diff changeset
   562
     * parameters}.
8943c58ad2f5 11508 Control, DefaultControl refactoring
Stephen Talley <stephen.talley@sun.com>
parents: 356
diff changeset
   563
     * <p/>
0
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   564
     * Called by the {@link Navigator} prior to this {@code Control} being
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   565
     * removed as the current {@code Control}.
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   566
     *
302
ac70675de834 9318 Navigator/Control should distinguish between cancel and non-cancel navigations
Stephen Talley <stephen.talley@sun.com>
parents: 279
diff changeset
   567
     * @param	    isCancel
356
379b8150bb93 11379 apache: unable to cancel app with bad data in outstanding changes
Stephen Talley <stephen.talley@sun.com>
parents: 350
diff changeset
   568
     *		    {@code true} if this {@code Control} is being stopped as
379b8150bb93 11379 apache: unable to cancel app with bad data in outstanding changes
Stephen Talley <stephen.talley@sun.com>
parents: 350
diff changeset
   569
     *		    part of a {@code cancel} operation, {@code false} otherwise
302
ac70675de834 9318 Navigator/Control should distinguish between cancel and non-cancel navigations
Stephen Talley <stephen.talley@sun.com>
parents: 279
diff changeset
   570
     *
40
d1412af1ae5b 3215 ActionAbortedException is used too broadly
Stephen Talley <stephen.talley@sun.com>
parents: 26
diff changeset
   571
     * @exception   NavigationAbortedException
0
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   572
     *		    if this {@code Control} should remain the current {@code
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   573
     *		    Control}
360
8943c58ad2f5 11508 Control, DefaultControl refactoring
Stephen Talley <stephen.talley@sun.com>
parents: 356
diff changeset
   574
     *
8943c58ad2f5 11508 Control, DefaultControl refactoring
Stephen Talley <stephen.talley@sun.com>
parents: 356
diff changeset
   575
     * @exception   IllegalStateException
8943c58ad2f5 11508 Control, DefaultControl refactoring
Stephen Talley <stephen.talley@sun.com>
parents: 356
diff changeset
   576
     *		    if this {@link Control} is not started
0
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   577
     */
302
ac70675de834 9318 Navigator/Control should distinguish between cancel and non-cancel navigations
Stephen Talley <stephen.talley@sun.com>
parents: 279
diff changeset
   578
    public void stop(boolean isCancel) throws NavigationAbortedException {
360
8943c58ad2f5 11508 Control, DefaultControl refactoring
Stephen Talley <stephen.talley@sun.com>
parents: 356
diff changeset
   579
	assertStartState(true);
8943c58ad2f5 11508 Control, DefaultControl refactoring
Stephen Talley <stephen.talley@sun.com>
parents: 356
diff changeset
   580
361
d3611020acea 11509 Control: s/isSaveNeeded/isChanged/g
Stephen Talley <stephen.talley@sun.com>
parents: 360
diff changeset
   581
	if (!isCancel && isChanged()) {
360
8943c58ad2f5 11508 Control, DefaultControl refactoring
Stephen Talley <stephen.talley@sun.com>
parents: 356
diff changeset
   582
	    try {
8943c58ad2f5 11508 Control, DefaultControl refactoring
Stephen Talley <stephen.talley@sun.com>
parents: 356
diff changeset
   583
		switch (getUnsavedChangesAction()) {
8943c58ad2f5 11508 Control, DefaultControl refactoring
Stephen Talley <stephen.talley@sun.com>
parents: 356
diff changeset
   584
		    case SAVE:
8943c58ad2f5 11508 Control, DefaultControl refactoring
Stephen Talley <stephen.talley@sun.com>
parents: 356
diff changeset
   585
			getSaveAction().invoke();
8943c58ad2f5 11508 Control, DefaultControl refactoring
Stephen Talley <stephen.talley@sun.com>
parents: 356
diff changeset
   586
			break;
8943c58ad2f5 11508 Control, DefaultControl refactoring
Stephen Talley <stephen.talley@sun.com>
parents: 356
diff changeset
   587
8943c58ad2f5 11508 Control, DefaultControl refactoring
Stephen Talley <stephen.talley@sun.com>
parents: 356
diff changeset
   588
		    case DISCARD:
8943c58ad2f5 11508 Control, DefaultControl refactoring
Stephen Talley <stephen.talley@sun.com>
parents: 356
diff changeset
   589
			getResetAction().invoke();
8943c58ad2f5 11508 Control, DefaultControl refactoring
Stephen Talley <stephen.talley@sun.com>
parents: 356
diff changeset
   590
			break;
8943c58ad2f5 11508 Control, DefaultControl refactoring
Stephen Talley <stephen.talley@sun.com>
parents: 356
diff changeset
   591
8943c58ad2f5 11508 Control, DefaultControl refactoring
Stephen Talley <stephen.talley@sun.com>
parents: 356
diff changeset
   592
		    default:
8943c58ad2f5 11508 Control, DefaultControl refactoring
Stephen Talley <stephen.talley@sun.com>
parents: 356
diff changeset
   593
		    case CANCEL:
8943c58ad2f5 11508 Control, DefaultControl refactoring
Stephen Talley <stephen.talley@sun.com>
parents: 356
diff changeset
   594
			throw new NavigationAbortedException();
8943c58ad2f5 11508 Control, DefaultControl refactoring
Stephen Talley <stephen.talley@sun.com>
parents: 356
diff changeset
   595
		}
8943c58ad2f5 11508 Control, DefaultControl refactoring
Stephen Talley <stephen.talley@sun.com>
parents: 356
diff changeset
   596
8943c58ad2f5 11508 Control, DefaultControl refactoring
Stephen Talley <stephen.talley@sun.com>
parents: 356
diff changeset
   597
	    // Thrown by invoke()
8943c58ad2f5 11508 Control, DefaultControl refactoring
Stephen Talley <stephen.talley@sun.com>
parents: 356
diff changeset
   598
	    } catch (ActionException e) {
8943c58ad2f5 11508 Control, DefaultControl refactoring
Stephen Talley <stephen.talley@sun.com>
parents: 356
diff changeset
   599
		throw new NavigationAbortedException(e);
8943c58ad2f5 11508 Control, DefaultControl refactoring
Stephen Talley <stephen.talley@sun.com>
parents: 356
diff changeset
   600
	    }
8943c58ad2f5 11508 Control, DefaultControl refactoring
Stephen Talley <stephen.talley@sun.com>
parents: 356
diff changeset
   601
	}
8943c58ad2f5 11508 Control, DefaultControl refactoring
Stephen Talley <stephen.talley@sun.com>
parents: 356
diff changeset
   602
8943c58ad2f5 11508 Control, DefaultControl refactoring
Stephen Talley <stephen.talley@sun.com>
parents: 356
diff changeset
   603
	this.navigator = null;
8943c58ad2f5 11508 Control, DefaultControl refactoring
Stephen Talley <stephen.talley@sun.com>
parents: 356
diff changeset
   604
	this.parameters = null;
8943c58ad2f5 11508 Control, DefaultControl refactoring
Stephen Talley <stephen.talley@sun.com>
parents: 356
diff changeset
   605
    }
8943c58ad2f5 11508 Control, DefaultControl refactoring
Stephen Talley <stephen.talley@sun.com>
parents: 356
diff changeset
   606
8943c58ad2f5 11508 Control, DefaultControl refactoring
Stephen Talley <stephen.talley@sun.com>
parents: 356
diff changeset
   607
    //
8943c58ad2f5 11508 Control, DefaultControl refactoring
Stephen Talley <stephen.talley@sun.com>
parents: 356
diff changeset
   608
    // Private methods
8943c58ad2f5 11508 Control, DefaultControl refactoring
Stephen Talley <stephen.talley@sun.com>
parents: 356
diff changeset
   609
    //
8943c58ad2f5 11508 Control, DefaultControl refactoring
Stephen Talley <stephen.talley@sun.com>
parents: 356
diff changeset
   610
8943c58ad2f5 11508 Control, DefaultControl refactoring
Stephen Talley <stephen.talley@sun.com>
parents: 356
diff changeset
   611
    private void assertStartState(boolean started) {
8943c58ad2f5 11508 Control, DefaultControl refactoring
Stephen Talley <stephen.talley@sun.com>
parents: 356
diff changeset
   612
	if (isStarted() != started) {
8943c58ad2f5 11508 Control, DefaultControl refactoring
Stephen Talley <stephen.talley@sun.com>
parents: 356
diff changeset
   613
	    throw new IllegalStateException(started ? "control started" :
8943c58ad2f5 11508 Control, DefaultControl refactoring
Stephen Talley <stephen.talley@sun.com>
parents: 356
diff changeset
   614
		"control not started");
8943c58ad2f5 11508 Control, DefaultControl refactoring
Stephen Talley <stephen.talley@sun.com>
parents: 356
diff changeset
   615
	}
0
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   616
    }
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   617
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   618
    //
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   619
    // Static methods
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   620
    //
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   621
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   622
    /**
350
1e9744735024 11081 parameter retrieval in Control start methods could be simplified
Stephen Talley <stephen.talley@sun.com>
parents: 348
diff changeset
   623
     * Decodes the given encoded {@code String} into an identifier and
1e9744735024 11081 parameter retrieval in Control start methods could be simplified
Stephen Talley <stephen.talley@sun.com>
parents: 348
diff changeset
   624
     * parameters, encapsulated by a {@link SimpleNavigable}.
1e9744735024 11081 parameter retrieval in Control start methods could be simplified
Stephen Talley <stephen.talley@sun.com>
parents: 348
diff changeset
   625
     *
1e9744735024 11081 parameter retrieval in Control start methods could be simplified
Stephen Talley <stephen.talley@sun.com>
parents: 348
diff changeset
   626
     * @param	    encoded
1e9744735024 11081 parameter retrieval in Control start methods could be simplified
Stephen Talley <stephen.talley@sun.com>
parents: 348
diff changeset
   627
     *		    an {@link #encode encode}d {@code String}
1e9744735024 11081 parameter retrieval in Control start methods could be simplified
Stephen Talley <stephen.talley@sun.com>
parents: 348
diff changeset
   628
     *
1e9744735024 11081 parameter retrieval in Control start methods could be simplified
Stephen Talley <stephen.talley@sun.com>
parents: 348
diff changeset
   629
     * @return	    a {@link SimpleNavigable}
1e9744735024 11081 parameter retrieval in Control start methods could be simplified
Stephen Talley <stephen.talley@sun.com>
parents: 348
diff changeset
   630
     */
1e9744735024 11081 parameter retrieval in Control start methods could be simplified
Stephen Talley <stephen.talley@sun.com>
parents: 348
diff changeset
   631
    public static SimpleNavigable decode(String encoded) {
1e9744735024 11081 parameter retrieval in Control start methods could be simplified
Stephen Talley <stephen.talley@sun.com>
parents: 348
diff changeset
   632
	String[] elements = encoded.split("\\?", 2);
1e9744735024 11081 parameter retrieval in Control start methods could be simplified
Stephen Talley <stephen.talley@sun.com>
parents: 348
diff changeset
   633
	String id = elements[0];
1e9744735024 11081 parameter retrieval in Control start methods could be simplified
Stephen Talley <stephen.talley@sun.com>
parents: 348
diff changeset
   634
	Map<String, String> parameters = new HashMap<String, String>();
1e9744735024 11081 parameter retrieval in Control start methods could be simplified
Stephen Talley <stephen.talley@sun.com>
parents: 348
diff changeset
   635
1e9744735024 11081 parameter retrieval in Control start methods could be simplified
Stephen Talley <stephen.talley@sun.com>
parents: 348
diff changeset
   636
	try {
1e9744735024 11081 parameter retrieval in Control start methods could be simplified
Stephen Talley <stephen.talley@sun.com>
parents: 348
diff changeset
   637
	    id = URLDecoder.decode(elements[0], ENCODING);
1e9744735024 11081 parameter retrieval in Control start methods could be simplified
Stephen Talley <stephen.talley@sun.com>
parents: 348
diff changeset
   638
	} catch (UnsupportedEncodingException ignore) {
1e9744735024 11081 parameter retrieval in Control start methods could be simplified
Stephen Talley <stephen.talley@sun.com>
parents: 348
diff changeset
   639
	}
1e9744735024 11081 parameter retrieval in Control start methods could be simplified
Stephen Talley <stephen.talley@sun.com>
parents: 348
diff changeset
   640
1e9744735024 11081 parameter retrieval in Control start methods could be simplified
Stephen Talley <stephen.talley@sun.com>
parents: 348
diff changeset
   641
	if (elements.length >= 2 && !elements[1].isEmpty()) {
1e9744735024 11081 parameter retrieval in Control start methods could be simplified
Stephen Talley <stephen.talley@sun.com>
parents: 348
diff changeset
   642
	    String[] keyEqVals = elements[1].split("&");
1e9744735024 11081 parameter retrieval in Control start methods could be simplified
Stephen Talley <stephen.talley@sun.com>
parents: 348
diff changeset
   643
1e9744735024 11081 parameter retrieval in Control start methods could be simplified
Stephen Talley <stephen.talley@sun.com>
parents: 348
diff changeset
   644
	    for (String keyEqVal : keyEqVals) {
1e9744735024 11081 parameter retrieval in Control start methods could be simplified
Stephen Talley <stephen.talley@sun.com>
parents: 348
diff changeset
   645
		String[] nvPair = keyEqVal.split("=", 2);
1e9744735024 11081 parameter retrieval in Control start methods could be simplified
Stephen Talley <stephen.talley@sun.com>
parents: 348
diff changeset
   646
		String key = nvPair[0];
1e9744735024 11081 parameter retrieval in Control start methods could be simplified
Stephen Talley <stephen.talley@sun.com>
parents: 348
diff changeset
   647
		String value = nvPair.length < 2 ? "" : nvPair[1];
1e9744735024 11081 parameter retrieval in Control start methods could be simplified
Stephen Talley <stephen.talley@sun.com>
parents: 348
diff changeset
   648
1e9744735024 11081 parameter retrieval in Control start methods could be simplified
Stephen Talley <stephen.talley@sun.com>
parents: 348
diff changeset
   649
		try {
1e9744735024 11081 parameter retrieval in Control start methods could be simplified
Stephen Talley <stephen.talley@sun.com>
parents: 348
diff changeset
   650
		    key = URLDecoder.decode(key, ENCODING);
1e9744735024 11081 parameter retrieval in Control start methods could be simplified
Stephen Talley <stephen.talley@sun.com>
parents: 348
diff changeset
   651
		    value = URLDecoder.decode(value, ENCODING);
1e9744735024 11081 parameter retrieval in Control start methods could be simplified
Stephen Talley <stephen.talley@sun.com>
parents: 348
diff changeset
   652
		} catch (UnsupportedEncodingException ignore) {
1e9744735024 11081 parameter retrieval in Control start methods could be simplified
Stephen Talley <stephen.talley@sun.com>
parents: 348
diff changeset
   653
		}
1e9744735024 11081 parameter retrieval in Control start methods could be simplified
Stephen Talley <stephen.talley@sun.com>
parents: 348
diff changeset
   654
1e9744735024 11081 parameter retrieval in Control start methods could be simplified
Stephen Talley <stephen.talley@sun.com>
parents: 348
diff changeset
   655
		parameters.put(key, value);
1e9744735024 11081 parameter retrieval in Control start methods could be simplified
Stephen Talley <stephen.talley@sun.com>
parents: 348
diff changeset
   656
	    }
1e9744735024 11081 parameter retrieval in Control start methods could be simplified
Stephen Talley <stephen.talley@sun.com>
parents: 348
diff changeset
   657
	}
1e9744735024 11081 parameter retrieval in Control start methods could be simplified
Stephen Talley <stephen.talley@sun.com>
parents: 348
diff changeset
   658
1e9744735024 11081 parameter retrieval in Control start methods could be simplified
Stephen Talley <stephen.talley@sun.com>
parents: 348
diff changeset
   659
	return new SimpleNavigable(id, null, parameters);
1e9744735024 11081 parameter retrieval in Control start methods could be simplified
Stephen Talley <stephen.talley@sun.com>
parents: 348
diff changeset
   660
    }
1e9744735024 11081 parameter retrieval in Control start methods could be simplified
Stephen Talley <stephen.talley@sun.com>
parents: 348
diff changeset
   661
1e9744735024 11081 parameter retrieval in Control start methods could be simplified
Stephen Talley <stephen.talley@sun.com>
parents: 348
diff changeset
   662
    /**
0
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   663
     * Encodes the given identifier and parameters.
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   664
     *
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   665
     * @param	    id
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   666
     *		    a {@link Control#getId Control identifier}
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   667
     *
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   668
     * @param	    parameters
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   669
     *		    initialization parameters, or {@code null} if no parameters
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   670
     *		    apply
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   671
     *
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   672
     * @return	    an encoded String
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   673
     */
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   674
    public static String encode(String id, Map<String, String> parameters) {
685
767674b0a2fb 18094 s/StringBuffer/StringBuilder/g
Stephen Talley <stephen.talley@oracle.com>
parents: 657
diff changeset
   675
	StringBuilder buffer = new StringBuilder();
0
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   676
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   677
	try {
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   678
	    buffer.append(URLEncoder.encode(id, ENCODING));
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   679
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   680
	    if (parameters != null && !parameters.isEmpty()) {
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   681
		buffer.append("?");
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   682
		boolean first = true;
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   683
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   684
		for (String key : parameters.keySet()) {
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   685
		    if (first) {
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   686
			first = false;
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   687
		    } else {
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   688
			buffer.append("&");
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   689
		    }
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   690
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   691
		    String value = parameters.get(key);
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   692
		    if (value == null) {
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   693
			value = "";
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   694
		    } else {
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   695
			value = URLEncoder.encode(value, ENCODING);
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   696
		    }
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   697
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   698
		    key = URLEncoder.encode(key, ENCODING);
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   699
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   700
		    buffer.append(key).append("=").append(value);
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   701
		}
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   702
	    }
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   703
	} catch (UnsupportedEncodingException ignore) {
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   704
	}
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   705
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   706
	return buffer.toString();
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   707
    }
456
3c23a2501f35 10964 time: need initial online help (source code update)
David Powell <David.Powell@sun.com>
parents: 451
diff changeset
   708
3c23a2501f35 10964 time: need initial online help (source code update)
David Powell <David.Powell@sun.com>
parents: 451
diff changeset
   709
    /**
3c23a2501f35 10964 time: need initial online help (source code update)
David Powell <David.Powell@sun.com>
parents: 451
diff changeset
   710
     * Builds a help URL from a page and optional section, falling back to the
3c23a2501f35 10964 time: need initial online help (source code update)
David Powell <David.Powell@sun.com>
parents: 451
diff changeset
   711
     * page if the section is invalid.
3c23a2501f35 10964 time: need initial online help (source code update)
David Powell <David.Powell@sun.com>
parents: 451
diff changeset
   712
     */
3c23a2501f35 10964 time: need initial online help (source code update)
David Powell <David.Powell@sun.com>
parents: 451
diff changeset
   713
    public static URL buildHelpURL(Class clazz, String page, String section) {
591
7c5752b99fd6 12473 panels should probably be run in a sandbox
Stephen Talley <stephen.talley@oracle.com>
parents: 456
diff changeset
   714
	URL url = new ResourceFinder().getResource(
7c5752b99fd6 12473 panels should probably be run in a sandbox
Stephen Talley <stephen.talley@oracle.com>
parents: 456
diff changeset
   715
	    clazz.getClassLoader(), clazz.getPackage().getName(), page);
456
3c23a2501f35 10964 time: need initial online help (source code update)
David Powell <David.Powell@sun.com>
parents: 451
diff changeset
   716
3c23a2501f35 10964 time: need initial online help (source code update)
David Powell <David.Powell@sun.com>
parents: 451
diff changeset
   717
	if (section != null) {
3c23a2501f35 10964 time: need initial online help (source code update)
David Powell <David.Powell@sun.com>
parents: 451
diff changeset
   718
	    try {
3c23a2501f35 10964 time: need initial online help (source code update)
David Powell <David.Powell@sun.com>
parents: 451
diff changeset
   719
		url = new URL(url, section);
3c23a2501f35 10964 time: need initial online help (source code update)
David Powell <David.Powell@sun.com>
parents: 451
diff changeset
   720
	    } catch (MalformedURLException ignore) {
3c23a2501f35 10964 time: need initial online help (source code update)
David Powell <David.Powell@sun.com>
parents: 451
diff changeset
   721
	    }
3c23a2501f35 10964 time: need initial online help (source code update)
David Powell <David.Powell@sun.com>
parents: 451
diff changeset
   722
	}
3c23a2501f35 10964 time: need initial online help (source code update)
David Powell <David.Powell@sun.com>
parents: 451
diff changeset
   723
3c23a2501f35 10964 time: need initial online help (source code update)
David Powell <David.Powell@sun.com>
parents: 451
diff changeset
   724
	return url;
3c23a2501f35 10964 time: need initial online help (source code update)
David Powell <David.Powell@sun.com>
parents: 451
diff changeset
   725
    }
0
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   726
}