usr/src/java/vpanels/panel/org/opensolaris/os/vp/panel/swing/control/SwingControl.java
author Stephen Talley <stephen.talley@sun.com>
Tue, 22 Sep 2009 16:46:54 -0400
changeset 360 8943c58ad2f5
parent 343 5d483801ed5e
child 361 d3611020acea
permissions -rw-r--r--
11508 Control, DefaultControl refactoring
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
/*
196
4aefd5567f1e 4364 sysid: resolve SysIdUtil.createNPException
Stephen Talley <stephen.talley@sun.com>
parents: 164
diff changeset
    23
 * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
0
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
    24
 * Use is subject to license terms.
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
    25
 */
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
    26
40
d1412af1ae5b 3215 ActionAbortedException is used too broadly
Stephen Talley <stephen.talley@sun.com>
parents: 39
diff changeset
    27
package org.opensolaris.os.vp.panel.swing.control;
0
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
    28
264
d5cd4b2e7426 8029 apache: ui redesign
Stephen Talley <stephen.talley@sun.com>
parents: 263
diff changeset
    29
import java.awt.*;
d5cd4b2e7426 8029 apache: ui redesign
Stephen Talley <stephen.talley@sun.com>
parents: 263
diff changeset
    30
import java.awt.event.*;
263
1cffd1fdcbb7 8011 SwingControl should provide a default PropertyListener implementation
Stephen Talley <stephen.talley@sun.com>
parents: 260
diff changeset
    31
import java.beans.*;
264
d5cd4b2e7426 8029 apache: ui redesign
Stephen Talley <stephen.talley@sun.com>
parents: 263
diff changeset
    32
import java.util.*;
d5cd4b2e7426 8029 apache: ui redesign
Stephen Talley <stephen.talley@sun.com>
parents: 263
diff changeset
    33
import java.util.List;
0
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
    34
import javax.swing.*;
40
d1412af1ae5b 3215 ActionAbortedException is used too broadly
Stephen Talley <stephen.talley@sun.com>
parents: 39
diff changeset
    35
import org.opensolaris.os.vp.panel.common.ClientContext;
d1412af1ae5b 3215 ActionAbortedException is used too broadly
Stephen Talley <stephen.talley@sun.com>
parents: 39
diff changeset
    36
import org.opensolaris.os.vp.panel.common.action.*;
d1412af1ae5b 3215 ActionAbortedException is used too broadly
Stephen Talley <stephen.talley@sun.com>
parents: 39
diff changeset
    37
import org.opensolaris.os.vp.panel.common.control.*;
263
1cffd1fdcbb7 8011 SwingControl should provide a default PropertyListener implementation
Stephen Talley <stephen.talley@sun.com>
parents: 260
diff changeset
    38
import org.opensolaris.os.vp.panel.common.model.*;
136
f9d1c2bd7b35 4401 ManagedObjectAction should be generalized to handle any preset input
Stephen Talley <stephen.talley@sun.com>
parents: 134
diff changeset
    39
import org.opensolaris.os.vp.panel.swing.action.SwingStructuredAction;
212
1d31ea6289bc 6410 javadoc errors
Stephen Talley <stephen.talley@sun.com>
parents: 196
diff changeset
    40
import org.opensolaris.os.vp.panel.swing.view.UITransitionManager;
223
aa68c366f3d0 6923 Menu, connection pull-down should be removed from main window
Stephen Talley <stephen.talley@sun.com>
parents: 219
diff changeset
    41
import org.opensolaris.os.vp.util.misc.*;
219
57841c113efe 6788 package names should share o.o.o.vp prefix
Stephen Talley <stephen.talley@sun.com>
parents: 214
diff changeset
    42
import org.opensolaris.os.vp.util.swing.*;
138
48a05b6471de 4366 wizard: wizard steps should not be limited to SwingControls
Stephen Talley <stephen.talley@sun.com>
parents: 136
diff changeset
    43
223
aa68c366f3d0 6923 Menu, connection pull-down should be removed from main window
Stephen Talley <stephen.talley@sun.com>
parents: 219
diff changeset
    44
public class SwingControl<P extends PanelDescriptor, C extends Component>
263
1cffd1fdcbb7 8011 SwingControl should provide a default PropertyListener implementation
Stephen Talley <stephen.talley@sun.com>
parents: 260
diff changeset
    45
    extends DefaultControl<P> implements HasComponent<C>,
1cffd1fdcbb7 8011 SwingControl should provide a default PropertyListener implementation
Stephen Talley <stephen.talley@sun.com>
parents: 260
diff changeset
    46
    PropertyChangeListener {
138
48a05b6471de 4366 wizard: wizard steps should not be limited to SwingControls
Stephen Talley <stephen.talley@sun.com>
parents: 136
diff changeset
    47
48a05b6471de 4366 wizard: wizard steps should not be limited to SwingControls
Stephen Talley <stephen.talley@sun.com>
parents: 136
diff changeset
    48
    //
0
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
    49
    // Instance data
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
    50
    //
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
    51
301
98464369f109 9311 MutableProperties should support PropertyChangeEvents
Stephen Talley <stephen.talley@sun.com>
parents: 298
diff changeset
    52
    private ManagedObject propSource;
98464369f109 9311 MutableProperties should support PropertyChangeEvents
Stephen Talley <stephen.talley@sun.com>
parents: 298
diff changeset
    53
    private String[] propNames;
98464369f109 9311 MutableProperties should support PropertyChangeEvents
Stephen Talley <stephen.talley@sun.com>
parents: 298
diff changeset
    54
    private boolean ignorePropChange;
98464369f109 9311 MutableProperties should support PropertyChangeEvents
Stephen Talley <stephen.talley@sun.com>
parents: 298
diff changeset
    55
327
bb43a6fa6f0b 10096 time: new UI design and NTP support
Stephen Talley <stephen.talley@sun.com>
parents: 302
diff changeset
    56
    private C comp;
0
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
    57
    private ComponentStack stack;
264
d5cd4b2e7426 8029 apache: ui redesign
Stephen Talley <stephen.talley@sun.com>
parents: 263
diff changeset
    58
    private JDialog childDialog;
d5cd4b2e7426 8029 apache: ui redesign
Stephen Talley <stephen.talley@sun.com>
parents: 263
diff changeset
    59
    private List<Control> dialogChildren = new ArrayList<Control>();
223
aa68c366f3d0 6923 Menu, connection pull-down should be removed from main window
Stephen Talley <stephen.talley@sun.com>
parents: 219
diff changeset
    60
aa68c366f3d0 6923 Menu, connection pull-down should be removed from main window
Stephen Talley <stephen.talley@sun.com>
parents: 219
diff changeset
    61
    private SwingStructuredAction<Object, Object, Object> resetAction =
aa68c366f3d0 6923 Menu, connection pull-down should be removed from main window
Stephen Talley <stephen.talley@sun.com>
parents: 219
diff changeset
    62
	new SwingStructuredAction<Object, Object, Object>(null, null, null,
aa68c366f3d0 6923 Menu, connection pull-down should be removed from main window
Stephen Talley <stephen.talley@sun.com>
parents: 219
diff changeset
    63
	    this) {
aa68c366f3d0 6923 Menu, connection pull-down should be removed from main window
Stephen Talley <stephen.talley@sun.com>
parents: 219
diff changeset
    64
aa68c366f3d0 6923 Menu, connection pull-down should be removed from main window
Stephen Talley <stephen.talley@sun.com>
parents: 219
diff changeset
    65
	    @Override
aa68c366f3d0 6923 Menu, connection pull-down should be removed from main window
Stephen Talley <stephen.talley@sun.com>
parents: 219
diff changeset
    66
	    public Object workBusy(Object pInput, Object rtInput)
aa68c366f3d0 6923 Menu, connection pull-down should be removed from main window
Stephen Talley <stephen.talley@sun.com>
parents: 219
diff changeset
    67
		throws ActionAbortedException, ActionFailedException,
aa68c366f3d0 6923 Menu, connection pull-down should be removed from main window
Stephen Talley <stephen.talley@sun.com>
parents: 219
diff changeset
    68
		ActionUnauthorizedException {
aa68c366f3d0 6923 Menu, connection pull-down should be removed from main window
Stephen Talley <stephen.talley@sun.com>
parents: 219
diff changeset
    69
260
507ac22496fe 7994 Control save/reset actions should act on descendents first
Stephen Talley <stephen.talley@sun.com>
parents: 248
diff changeset
    70
		resetAll();
223
aa68c366f3d0 6923 Menu, connection pull-down should be removed from main window
Stephen Talley <stephen.talley@sun.com>
parents: 219
diff changeset
    71
		return null;
aa68c366f3d0 6923 Menu, connection pull-down should be removed from main window
Stephen Talley <stephen.talley@sun.com>
parents: 219
diff changeset
    72
	    }
aa68c366f3d0 6923 Menu, connection pull-down should be removed from main window
Stephen Talley <stephen.talley@sun.com>
parents: 219
diff changeset
    73
	};
aa68c366f3d0 6923 Menu, connection pull-down should be removed from main window
Stephen Talley <stephen.talley@sun.com>
parents: 219
diff changeset
    74
aa68c366f3d0 6923 Menu, connection pull-down should be removed from main window
Stephen Talley <stephen.talley@sun.com>
parents: 219
diff changeset
    75
    private SwingStructuredAction<Object, Object, Object> saveAction =
aa68c366f3d0 6923 Menu, connection pull-down should be removed from main window
Stephen Talley <stephen.talley@sun.com>
parents: 219
diff changeset
    76
	new SwingStructuredAction<Object, Object, Object>(null, null, null,
aa68c366f3d0 6923 Menu, connection pull-down should be removed from main window
Stephen Talley <stephen.talley@sun.com>
parents: 219
diff changeset
    77
	    this) {
aa68c366f3d0 6923 Menu, connection pull-down should be removed from main window
Stephen Talley <stephen.talley@sun.com>
parents: 219
diff changeset
    78
aa68c366f3d0 6923 Menu, connection pull-down should be removed from main window
Stephen Talley <stephen.talley@sun.com>
parents: 219
diff changeset
    79
	    @Override
aa68c366f3d0 6923 Menu, connection pull-down should be removed from main window
Stephen Talley <stephen.talley@sun.com>
parents: 219
diff changeset
    80
	    public Object workBusy(Object pInput, Object rtInput)
aa68c366f3d0 6923 Menu, connection pull-down should be removed from main window
Stephen Talley <stephen.talley@sun.com>
parents: 219
diff changeset
    81
		throws ActionAbortedException, ActionFailedException,
aa68c366f3d0 6923 Menu, connection pull-down should be removed from main window
Stephen Talley <stephen.talley@sun.com>
parents: 219
diff changeset
    82
		ActionUnauthorizedException {
aa68c366f3d0 6923 Menu, connection pull-down should be removed from main window
Stephen Talley <stephen.talley@sun.com>
parents: 219
diff changeset
    83
260
507ac22496fe 7994 Control save/reset actions should act on descendents first
Stephen Talley <stephen.talley@sun.com>
parents: 248
diff changeset
    84
		saveAll();
223
aa68c366f3d0 6923 Menu, connection pull-down should be removed from main window
Stephen Talley <stephen.talley@sun.com>
parents: 219
diff changeset
    85
		return null;
aa68c366f3d0 6923 Menu, connection pull-down should be removed from main window
Stephen Talley <stephen.talley@sun.com>
parents: 219
diff changeset
    86
	    }
aa68c366f3d0 6923 Menu, connection pull-down should be removed from main window
Stephen Talley <stephen.talley@sun.com>
parents: 219
diff changeset
    87
	};
0
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
    88
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
    89
    //
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
    90
    // Constructors
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
    91
    //
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
    92
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
    93
    public SwingControl(String id, String name, ClientContext context) {
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
    94
	super(id, name, context);
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
223
aa68c366f3d0 6923 Menu, connection pull-down should be removed from main window
Stephen Talley <stephen.talley@sun.com>
parents: 219
diff changeset
    97
    public SwingControl(String id, String name, P descriptor) {
aa68c366f3d0 6923 Menu, connection pull-down should be removed from main window
Stephen Talley <stephen.talley@sun.com>
parents: 219
diff changeset
    98
	super(id, name, descriptor);
aa68c366f3d0 6923 Menu, connection pull-down should be removed from main window
Stephen Talley <stephen.talley@sun.com>
parents: 219
diff changeset
    99
    }
aa68c366f3d0 6923 Menu, connection pull-down should be removed from main window
Stephen Talley <stephen.talley@sun.com>
parents: 219
diff changeset
   100
0
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   101
    //
138
48a05b6471de 4366 wizard: wizard steps should not be limited to SwingControls
Stephen Talley <stephen.talley@sun.com>
parents: 136
diff changeset
   102
    // HasComponent methods
48a05b6471de 4366 wizard: wizard steps should not be limited to SwingControls
Stephen Talley <stephen.talley@sun.com>
parents: 136
diff changeset
   103
    //
48a05b6471de 4366 wizard: wizard steps should not be limited to SwingControls
Stephen Talley <stephen.talley@sun.com>
parents: 136
diff changeset
   104
48a05b6471de 4366 wizard: wizard steps should not be limited to SwingControls
Stephen Talley <stephen.talley@sun.com>
parents: 136
diff changeset
   105
    /**
48a05b6471de 4366 wizard: wizard steps should not be limited to SwingControls
Stephen Talley <stephen.talley@sun.com>
parents: 136
diff changeset
   106
     * Gets the {@code Component} for this {@code SwingControl}.
48a05b6471de 4366 wizard: wizard steps should not be limited to SwingControls
Stephen Talley <stephen.talley@sun.com>
parents: 136
diff changeset
   107
     *
48a05b6471de 4366 wizard: wizard steps should not be limited to SwingControls
Stephen Talley <stephen.talley@sun.com>
parents: 136
diff changeset
   108
     * @return	    a {@code Component}, or {@code null} if this {@code
48a05b6471de 4366 wizard: wizard steps should not be limited to SwingControls
Stephen Talley <stephen.talley@sun.com>
parents: 136
diff changeset
   109
     *		    SwingControl} has no {@code Component}.
244
b6f1fb4f5a89 7624 SwingControl: createComponent implementations should not be required to call setComponent
Stephen Talley <stephen.talley@sun.com>
parents: 235
diff changeset
   110
     *
b6f1fb4f5a89 7624 SwingControl: createComponent implementations should not be required to call setComponent
Stephen Talley <stephen.talley@sun.com>
parents: 235
diff changeset
   111
     * @see	    #setComponent
138
48a05b6471de 4366 wizard: wizard steps should not be limited to SwingControls
Stephen Talley <stephen.talley@sun.com>
parents: 136
diff changeset
   112
     */
48a05b6471de 4366 wizard: wizard steps should not be limited to SwingControls
Stephen Talley <stephen.talley@sun.com>
parents: 136
diff changeset
   113
    @Override
48a05b6471de 4366 wizard: wizard steps should not be limited to SwingControls
Stephen Talley <stephen.talley@sun.com>
parents: 136
diff changeset
   114
    public C getComponent() {
327
bb43a6fa6f0b 10096 time: new UI design and NTP support
Stephen Talley <stephen.talley@sun.com>
parents: 302
diff changeset
   115
	return comp;
138
48a05b6471de 4366 wizard: wizard steps should not be limited to SwingControls
Stephen Talley <stephen.talley@sun.com>
parents: 136
diff changeset
   116
    }
48a05b6471de 4366 wizard: wizard steps should not be limited to SwingControls
Stephen Talley <stephen.talley@sun.com>
parents: 136
diff changeset
   117
48a05b6471de 4366 wizard: wizard steps should not be limited to SwingControls
Stephen Talley <stephen.talley@sun.com>
parents: 136
diff changeset
   118
    //
263
1cffd1fdcbb7 8011 SwingControl should provide a default PropertyListener implementation
Stephen Talley <stephen.talley@sun.com>
parents: 260
diff changeset
   119
    // PropertyChangeListener methods
1cffd1fdcbb7 8011 SwingControl should provide a default PropertyListener implementation
Stephen Talley <stephen.talley@sun.com>
parents: 260
diff changeset
   120
    //
1cffd1fdcbb7 8011 SwingControl should provide a default PropertyListener implementation
Stephen Talley <stephen.talley@sun.com>
parents: 260
diff changeset
   121
1cffd1fdcbb7 8011 SwingControl should provide a default PropertyListener implementation
Stephen Talley <stephen.talley@sun.com>
parents: 260
diff changeset
   122
    /**
301
98464369f109 9311 MutableProperties should support PropertyChangeEvents
Stephen Talley <stephen.talley@sun.com>
parents: 298
diff changeset
   123
     * Convenience implementation that calls {@link #initComponentOnEventThread}
98464369f109 9311 MutableProperties should support PropertyChangeEvents
Stephen Talley <stephen.talley@sun.com>
parents: 298
diff changeset
   124
     * if property changes are not temporarilty being {@link
98464369f109 9311 MutableProperties should support PropertyChangeEvents
Stephen Talley <stephen.talley@sun.com>
parents: 298
diff changeset
   125
     * #getPropertyChangeIgnore ignored}.  If this {@link SwingControl}'s
98464369f109 9311 MutableProperties should support PropertyChangeEvents
Stephen Talley <stephen.talley@sun.com>
parents: 298
diff changeset
   126
     * component displayed the properties of a {@link ManagedObject}, for
98464369f109 9311 MutableProperties should support PropertyChangeEvents
Stephen Talley <stephen.talley@sun.com>
parents: 298
diff changeset
   127
     * example, it may make sense to add this {@code SwingControl} as a {@code
98464369f109 9311 MutableProperties should support PropertyChangeEvents
Stephen Talley <stephen.talley@sun.com>
parents: 298
diff changeset
   128
     * PropertyListener} to that object.
263
1cffd1fdcbb7 8011 SwingControl should provide a default PropertyListener implementation
Stephen Talley <stephen.talley@sun.com>
parents: 260
diff changeset
   129
     */
1cffd1fdcbb7 8011 SwingControl should provide a default PropertyListener implementation
Stephen Talley <stephen.talley@sun.com>
parents: 260
diff changeset
   130
    @Override
1cffd1fdcbb7 8011 SwingControl should provide a default PropertyListener implementation
Stephen Talley <stephen.talley@sun.com>
parents: 260
diff changeset
   131
    public void propertyChange(PropertyChangeEvent event) {
301
98464369f109 9311 MutableProperties should support PropertyChangeEvents
Stephen Talley <stephen.talley@sun.com>
parents: 298
diff changeset
   132
	if (!ignorePropChange && getComponent() != null) {
295
ec3ac4f44cad 8700 Mysql mbean created in incorrect domain
David Powell <David.Powell@sun.com>
parents: 273
diff changeset
   133
	    initComponentOnEventThread();
301
98464369f109 9311 MutableProperties should support PropertyChangeEvents
Stephen Talley <stephen.talley@sun.com>
parents: 298
diff changeset
   134
	}
263
1cffd1fdcbb7 8011 SwingControl should provide a default PropertyListener implementation
Stephen Talley <stephen.talley@sun.com>
parents: 260
diff changeset
   135
    }
1cffd1fdcbb7 8011 SwingControl should provide a default PropertyListener implementation
Stephen Talley <stephen.talley@sun.com>
parents: 260
diff changeset
   136
1cffd1fdcbb7 8011 SwingControl should provide a default PropertyListener implementation
Stephen Talley <stephen.talley@sun.com>
parents: 260
diff changeset
   137
    //
0
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   138
    // Control methods
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   139
    //
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   140
264
d5cd4b2e7426 8029 apache: ui redesign
Stephen Talley <stephen.talley@sun.com>
parents: 263
diff changeset
   141
    @Override
d5cd4b2e7426 8029 apache: ui redesign
Stephen Talley <stephen.talley@sun.com>
parents: 263
diff changeset
   142
    public void childStarted(final Control child) {
d5cd4b2e7426 8029 apache: ui redesign
Stephen Talley <stephen.talley@sun.com>
parents: 263
diff changeset
   143
	super.childStarted(child);
d5cd4b2e7426 8029 apache: ui redesign
Stephen Talley <stephen.talley@sun.com>
parents: 263
diff changeset
   144
d5cd4b2e7426 8029 apache: ui redesign
Stephen Talley <stephen.talley@sun.com>
parents: 263
diff changeset
   145
	assert childDialog == null;
d5cd4b2e7426 8029 apache: ui redesign
Stephen Talley <stephen.talley@sun.com>
parents: 263
diff changeset
   146
d5cd4b2e7426 8029 apache: ui redesign
Stephen Talley <stephen.talley@sun.com>
parents: 263
diff changeset
   147
	if (dialogChildren.contains(child)) {
d5cd4b2e7426 8029 apache: ui redesign
Stephen Talley <stephen.talley@sun.com>
parents: 263
diff changeset
   148
	    Component comp = getComponent();
d5cd4b2e7426 8029 apache: ui redesign
Stephen Talley <stephen.talley@sun.com>
parents: 263
diff changeset
   149
	    final Window owner = SwingUtilities.getWindowAncestor(comp);
d5cd4b2e7426 8029 apache: ui redesign
Stephen Talley <stephen.talley@sun.com>
parents: 263
diff changeset
   150
d5cd4b2e7426 8029 apache: ui redesign
Stephen Talley <stephen.talley@sun.com>
parents: 263
diff changeset
   151
	    childDialog = new JDialog(owner,
d5cd4b2e7426 8029 apache: ui redesign
Stephen Talley <stephen.talley@sun.com>
parents: 263
diff changeset
   152
		Dialog.ModalityType.DOCUMENT_MODAL);
d5cd4b2e7426 8029 apache: ui redesign
Stephen Talley <stephen.talley@sun.com>
parents: 263
diff changeset
   153
	    Container cont = childDialog.getContentPane();
d5cd4b2e7426 8029 apache: ui redesign
Stephen Talley <stephen.talley@sun.com>
parents: 263
diff changeset
   154
	    cont.setLayout(new BorderLayout());
d5cd4b2e7426 8029 apache: ui redesign
Stephen Talley <stephen.talley@sun.com>
parents: 263
diff changeset
   155
d5cd4b2e7426 8029 apache: ui redesign
Stephen Talley <stephen.talley@sun.com>
parents: 263
diff changeset
   156
	    Component cComp = ((SwingControl)child).getComponent();
d5cd4b2e7426 8029 apache: ui redesign
Stephen Talley <stephen.talley@sun.com>
parents: 263
diff changeset
   157
	    cont.add(cComp, BorderLayout.CENTER);
d5cd4b2e7426 8029 apache: ui redesign
Stephen Talley <stephen.talley@sun.com>
parents: 263
diff changeset
   158
d5cd4b2e7426 8029 apache: ui redesign
Stephen Talley <stephen.talley@sun.com>
parents: 263
diff changeset
   159
	    if (child instanceof HasImages) {
d5cd4b2e7426 8029 apache: ui redesign
Stephen Talley <stephen.talley@sun.com>
parents: 263
diff changeset
   160
		List<? extends Image> images = ((HasImages)child).getImages();
d5cd4b2e7426 8029 apache: ui redesign
Stephen Talley <stephen.talley@sun.com>
parents: 263
diff changeset
   161
		childDialog.setIconImages(images);
d5cd4b2e7426 8029 apache: ui redesign
Stephen Talley <stephen.talley@sun.com>
parents: 263
diff changeset
   162
	    }
d5cd4b2e7426 8029 apache: ui redesign
Stephen Talley <stephen.talley@sun.com>
parents: 263
diff changeset
   163
d5cd4b2e7426 8029 apache: ui redesign
Stephen Talley <stephen.talley@sun.com>
parents: 263
diff changeset
   164
	    childDialog.setTitle(child.getName());
d5cd4b2e7426 8029 apache: ui redesign
Stephen Talley <stephen.talley@sun.com>
parents: 263
diff changeset
   165
	    childDialog.setDefaultCloseOperation(
d5cd4b2e7426 8029 apache: ui redesign
Stephen Talley <stephen.talley@sun.com>
parents: 263
diff changeset
   166
		WindowConstants.DISPOSE_ON_CLOSE);
d5cd4b2e7426 8029 apache: ui redesign
Stephen Talley <stephen.talley@sun.com>
parents: 263
diff changeset
   167
	    childDialog.pack();
d5cd4b2e7426 8029 apache: ui redesign
Stephen Talley <stephen.talley@sun.com>
parents: 263
diff changeset
   168
d5cd4b2e7426 8029 apache: ui redesign
Stephen Talley <stephen.talley@sun.com>
parents: 263
diff changeset
   169
	    childDialog.addWindowListener(
d5cd4b2e7426 8029 apache: ui redesign
Stephen Talley <stephen.talley@sun.com>
parents: 263
diff changeset
   170
		new WindowAdapter() {
d5cd4b2e7426 8029 apache: ui redesign
Stephen Talley <stephen.talley@sun.com>
parents: 263
diff changeset
   171
		    @Override
d5cd4b2e7426 8029 apache: ui redesign
Stephen Talley <stephen.talley@sun.com>
parents: 263
diff changeset
   172
		    public void windowClosing(WindowEvent e) {
d5cd4b2e7426 8029 apache: ui redesign
Stephen Talley <stephen.talley@sun.com>
parents: 263
diff changeset
   173
			childDialog.removeWindowListener(this);
d5cd4b2e7426 8029 apache: ui redesign
Stephen Talley <stephen.talley@sun.com>
parents: 263
diff changeset
   174
			child.doCancel();
d5cd4b2e7426 8029 apache: ui redesign
Stephen Talley <stephen.talley@sun.com>
parents: 263
diff changeset
   175
		    }
d5cd4b2e7426 8029 apache: ui redesign
Stephen Talley <stephen.talley@sun.com>
parents: 263
diff changeset
   176
		});
d5cd4b2e7426 8029 apache: ui redesign
Stephen Talley <stephen.talley@sun.com>
parents: 263
diff changeset
   177
273
51b8326144a5 8083 apache: mimetype/module dialogs grow after being displayed
Stephen Talley <stephen.talley@sun.com>
parents: 264
diff changeset
   178
	    // Show the window after navigation has completed
51b8326144a5 8083 apache: mimetype/module dialogs grow after being displayed
Stephen Talley <stephen.talley@sun.com>
parents: 264
diff changeset
   179
	    getNavigator().asyncExec(
264
d5cd4b2e7426 8029 apache: ui redesign
Stephen Talley <stephen.talley@sun.com>
parents: 263
diff changeset
   180
		new Runnable() {
d5cd4b2e7426 8029 apache: ui redesign
Stephen Talley <stephen.talley@sun.com>
parents: 263
diff changeset
   181
		    @Override
d5cd4b2e7426 8029 apache: ui redesign
Stephen Talley <stephen.talley@sun.com>
parents: 263
diff changeset
   182
		    public void run() {
273
51b8326144a5 8083 apache: mimetype/module dialogs grow after being displayed
Stephen Talley <stephen.talley@sun.com>
parents: 264
diff changeset
   183
			EventQueue.invokeLater(
51b8326144a5 8083 apache: mimetype/module dialogs grow after being displayed
Stephen Talley <stephen.talley@sun.com>
parents: 264
diff changeset
   184
			    new Runnable() {
51b8326144a5 8083 apache: mimetype/module dialogs grow after being displayed
Stephen Talley <stephen.talley@sun.com>
parents: 264
diff changeset
   185
				@Override
51b8326144a5 8083 apache: mimetype/module dialogs grow after being displayed
Stephen Talley <stephen.talley@sun.com>
parents: 264
diff changeset
   186
				public void run() {
51b8326144a5 8083 apache: mimetype/module dialogs grow after being displayed
Stephen Talley <stephen.talley@sun.com>
parents: 264
diff changeset
   187
				    childDialog.setLocationRelativeTo(owner);
51b8326144a5 8083 apache: mimetype/module dialogs grow after being displayed
Stephen Talley <stephen.talley@sun.com>
parents: 264
diff changeset
   188
				    childDialog.setVisible(true);
51b8326144a5 8083 apache: mimetype/module dialogs grow after being displayed
Stephen Talley <stephen.talley@sun.com>
parents: 264
diff changeset
   189
				}
51b8326144a5 8083 apache: mimetype/module dialogs grow after being displayed
Stephen Talley <stephen.talley@sun.com>
parents: 264
diff changeset
   190
			    });
264
d5cd4b2e7426 8029 apache: ui redesign
Stephen Talley <stephen.talley@sun.com>
parents: 263
diff changeset
   191
		    }
d5cd4b2e7426 8029 apache: ui redesign
Stephen Talley <stephen.talley@sun.com>
parents: 263
diff changeset
   192
		});
d5cd4b2e7426 8029 apache: ui redesign
Stephen Talley <stephen.talley@sun.com>
parents: 263
diff changeset
   193
	}
d5cd4b2e7426 8029 apache: ui redesign
Stephen Talley <stephen.talley@sun.com>
parents: 263
diff changeset
   194
    }
d5cd4b2e7426 8029 apache: ui redesign
Stephen Talley <stephen.talley@sun.com>
parents: 263
diff changeset
   195
d5cd4b2e7426 8029 apache: ui redesign
Stephen Talley <stephen.talley@sun.com>
parents: 263
diff changeset
   196
    @Override
d5cd4b2e7426 8029 apache: ui redesign
Stephen Talley <stephen.talley@sun.com>
parents: 263
diff changeset
   197
    public void childStopped(Control child) {
d5cd4b2e7426 8029 apache: ui redesign
Stephen Talley <stephen.talley@sun.com>
parents: 263
diff changeset
   198
	super.childStopped(child);
d5cd4b2e7426 8029 apache: ui redesign
Stephen Talley <stephen.talley@sun.com>
parents: 263
diff changeset
   199
d5cd4b2e7426 8029 apache: ui redesign
Stephen Talley <stephen.talley@sun.com>
parents: 263
diff changeset
   200
	if (childDialog != null) {
d5cd4b2e7426 8029 apache: ui redesign
Stephen Talley <stephen.talley@sun.com>
parents: 263
diff changeset
   201
	    childDialog.dispose();
d5cd4b2e7426 8029 apache: ui redesign
Stephen Talley <stephen.talley@sun.com>
parents: 263
diff changeset
   202
	    childDialog = null;
d5cd4b2e7426 8029 apache: ui redesign
Stephen Talley <stephen.talley@sun.com>
parents: 263
diff changeset
   203
	}
d5cd4b2e7426 8029 apache: ui redesign
Stephen Talley <stephen.talley@sun.com>
parents: 263
diff changeset
   204
    }
d5cd4b2e7426 8029 apache: ui redesign
Stephen Talley <stephen.talley@sun.com>
parents: 263
diff changeset
   205
0
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   206
    /**
248
d947462c8e37 7851 Control should support notification of descendants starting/stopping
Stephen Talley <stephen.talley@sun.com>
parents: 244
diff changeset
   207
     * If a) this {@code SwingControl} defines a {@link #getComponentStack
d947462c8e37 7851 Control should support notification of descendants starting/stopping
Stephen Talley <stephen.talley@sun.com>
parents: 244
diff changeset
   208
     * ComponentStack}, b) the just-started {@link Control} implements {@link
d947462c8e37 7851 Control should support notification of descendants starting/stopping
Stephen Talley <stephen.talley@sun.com>
parents: 244
diff changeset
   209
     * HasComponent}, and c) its {@code Component} does not yet have a parent,
d947462c8e37 7851 Control should support notification of descendants starting/stopping
Stephen Talley <stephen.talley@sun.com>
parents: 244
diff changeset
   210
     * this method adds that {@code Component} to the stack.
d947462c8e37 7851 Control should support notification of descendants starting/stopping
Stephen Talley <stephen.talley@sun.com>
parents: 244
diff changeset
   211
     */
d947462c8e37 7851 Control should support notification of descendants starting/stopping
Stephen Talley <stephen.talley@sun.com>
parents: 244
diff changeset
   212
    @Override
d947462c8e37 7851 Control should support notification of descendants starting/stopping
Stephen Talley <stephen.talley@sun.com>
parents: 244
diff changeset
   213
    public void descendantStarted(Control[] path) {
d947462c8e37 7851 Control should support notification of descendants starting/stopping
Stephen Talley <stephen.talley@sun.com>
parents: 244
diff changeset
   214
	super.descendantStarted(path);
d947462c8e37 7851 Control should support notification of descendants starting/stopping
Stephen Talley <stephen.talley@sun.com>
parents: 244
diff changeset
   215
d947462c8e37 7851 Control should support notification of descendants starting/stopping
Stephen Talley <stephen.talley@sun.com>
parents: 244
diff changeset
   216
	final ComponentStack stack = getComponentStack();
d947462c8e37 7851 Control should support notification of descendants starting/stopping
Stephen Talley <stephen.talley@sun.com>
parents: 244
diff changeset
   217
	if (stack != null) {
d947462c8e37 7851 Control should support notification of descendants starting/stopping
Stephen Talley <stephen.talley@sun.com>
parents: 244
diff changeset
   218
	    Control control = path[path.length - 1];
d947462c8e37 7851 Control should support notification of descendants starting/stopping
Stephen Talley <stephen.talley@sun.com>
parents: 244
diff changeset
   219
	    if (control instanceof HasComponent) {
d947462c8e37 7851 Control should support notification of descendants starting/stopping
Stephen Talley <stephen.talley@sun.com>
parents: 244
diff changeset
   220
		final Component comp = ((HasComponent)control).getComponent();
d947462c8e37 7851 Control should support notification of descendants starting/stopping
Stephen Talley <stephen.talley@sun.com>
parents: 244
diff changeset
   221
		if (comp != null && comp.getParent() == null) {
d947462c8e37 7851 Control should support notification of descendants starting/stopping
Stephen Talley <stephen.talley@sun.com>
parents: 244
diff changeset
   222
		    GUIUtil.invokeAndWait(
d947462c8e37 7851 Control should support notification of descendants starting/stopping
Stephen Talley <stephen.talley@sun.com>
parents: 244
diff changeset
   223
			new Runnable() {
d947462c8e37 7851 Control should support notification of descendants starting/stopping
Stephen Talley <stephen.talley@sun.com>
parents: 244
diff changeset
   224
			    @Override
d947462c8e37 7851 Control should support notification of descendants starting/stopping
Stephen Talley <stephen.talley@sun.com>
parents: 244
diff changeset
   225
			    public void run() {
d947462c8e37 7851 Control should support notification of descendants starting/stopping
Stephen Talley <stephen.talley@sun.com>
parents: 244
diff changeset
   226
				stack.push(comp);
d947462c8e37 7851 Control should support notification of descendants starting/stopping
Stephen Talley <stephen.talley@sun.com>
parents: 244
diff changeset
   227
			    }
d947462c8e37 7851 Control should support notification of descendants starting/stopping
Stephen Talley <stephen.talley@sun.com>
parents: 244
diff changeset
   228
			});
d947462c8e37 7851 Control should support notification of descendants starting/stopping
Stephen Talley <stephen.talley@sun.com>
parents: 244
diff changeset
   229
		}
d947462c8e37 7851 Control should support notification of descendants starting/stopping
Stephen Talley <stephen.talley@sun.com>
parents: 244
diff changeset
   230
	    }
d947462c8e37 7851 Control should support notification of descendants starting/stopping
Stephen Talley <stephen.talley@sun.com>
parents: 244
diff changeset
   231
	}
d947462c8e37 7851 Control should support notification of descendants starting/stopping
Stephen Talley <stephen.talley@sun.com>
parents: 244
diff changeset
   232
    }
d947462c8e37 7851 Control should support notification of descendants starting/stopping
Stephen Talley <stephen.talley@sun.com>
parents: 244
diff changeset
   233
d947462c8e37 7851 Control should support notification of descendants starting/stopping
Stephen Talley <stephen.talley@sun.com>
parents: 244
diff changeset
   234
    /**
d947462c8e37 7851 Control should support notification of descendants starting/stopping
Stephen Talley <stephen.talley@sun.com>
parents: 244
diff changeset
   235
     * If a) this {@code SwingControl} defines a {@link #getComponentStack
d947462c8e37 7851 Control should support notification of descendants starting/stopping
Stephen Talley <stephen.talley@sun.com>
parents: 244
diff changeset
   236
     * ComponentStack}, b) the just-stopped {@link Control} implements {@link
d947462c8e37 7851 Control should support notification of descendants starting/stopping
Stephen Talley <stephen.talley@sun.com>
parents: 244
diff changeset
   237
     * HasComponent}, and c) its {@code Component} is at the top of the stack,
d947462c8e37 7851 Control should support notification of descendants starting/stopping
Stephen Talley <stephen.talley@sun.com>
parents: 244
diff changeset
   238
     * this method removes that {@code Component} from the stack.
d947462c8e37 7851 Control should support notification of descendants starting/stopping
Stephen Talley <stephen.talley@sun.com>
parents: 244
diff changeset
   239
     */
d947462c8e37 7851 Control should support notification of descendants starting/stopping
Stephen Talley <stephen.talley@sun.com>
parents: 244
diff changeset
   240
    @Override
d947462c8e37 7851 Control should support notification of descendants starting/stopping
Stephen Talley <stephen.talley@sun.com>
parents: 244
diff changeset
   241
    public void descendantStopped(Control[] path) {
d947462c8e37 7851 Control should support notification of descendants starting/stopping
Stephen Talley <stephen.talley@sun.com>
parents: 244
diff changeset
   242
	super.descendantStopped(path);
d947462c8e37 7851 Control should support notification of descendants starting/stopping
Stephen Talley <stephen.talley@sun.com>
parents: 244
diff changeset
   243
d947462c8e37 7851 Control should support notification of descendants starting/stopping
Stephen Talley <stephen.talley@sun.com>
parents: 244
diff changeset
   244
	final ComponentStack stack = getComponentStack();
d947462c8e37 7851 Control should support notification of descendants starting/stopping
Stephen Talley <stephen.talley@sun.com>
parents: 244
diff changeset
   245
	if (stack != null) {
d947462c8e37 7851 Control should support notification of descendants starting/stopping
Stephen Talley <stephen.talley@sun.com>
parents: 244
diff changeset
   246
	    Control control = path[path.length - 1];
d947462c8e37 7851 Control should support notification of descendants starting/stopping
Stephen Talley <stephen.talley@sun.com>
parents: 244
diff changeset
   247
	    if (control instanceof HasComponent) {
d947462c8e37 7851 Control should support notification of descendants starting/stopping
Stephen Talley <stephen.talley@sun.com>
parents: 244
diff changeset
   248
		final Component comp = ((HasComponent)control).getComponent();
d947462c8e37 7851 Control should support notification of descendants starting/stopping
Stephen Talley <stephen.talley@sun.com>
parents: 244
diff changeset
   249
		if (comp != null) {
d947462c8e37 7851 Control should support notification of descendants starting/stopping
Stephen Talley <stephen.talley@sun.com>
parents: 244
diff changeset
   250
		    GUIUtil.invokeAndWait(
d947462c8e37 7851 Control should support notification of descendants starting/stopping
Stephen Talley <stephen.talley@sun.com>
parents: 244
diff changeset
   251
			new Runnable() {
d947462c8e37 7851 Control should support notification of descendants starting/stopping
Stephen Talley <stephen.talley@sun.com>
parents: 244
diff changeset
   252
			    @Override
d947462c8e37 7851 Control should support notification of descendants starting/stopping
Stephen Talley <stephen.talley@sun.com>
parents: 244
diff changeset
   253
			    public void run() {
d947462c8e37 7851 Control should support notification of descendants starting/stopping
Stephen Talley <stephen.talley@sun.com>
parents: 244
diff changeset
   254
				StackUtil.popIfAtTop(stack, comp);
d947462c8e37 7851 Control should support notification of descendants starting/stopping
Stephen Talley <stephen.talley@sun.com>
parents: 244
diff changeset
   255
			    }
d947462c8e37 7851 Control should support notification of descendants starting/stopping
Stephen Talley <stephen.talley@sun.com>
parents: 244
diff changeset
   256
			});
d947462c8e37 7851 Control should support notification of descendants starting/stopping
Stephen Talley <stephen.talley@sun.com>
parents: 244
diff changeset
   257
		}
d947462c8e37 7851 Control should support notification of descendants starting/stopping
Stephen Talley <stephen.talley@sun.com>
parents: 244
diff changeset
   258
	    }
d947462c8e37 7851 Control should support notification of descendants starting/stopping
Stephen Talley <stephen.talley@sun.com>
parents: 244
diff changeset
   259
	}
d947462c8e37 7851 Control should support notification of descendants starting/stopping
Stephen Talley <stephen.talley@sun.com>
parents: 244
diff changeset
   260
    }
d947462c8e37 7851 Control should support notification of descendants starting/stopping
Stephen Talley <stephen.talley@sun.com>
parents: 244
diff changeset
   261
d947462c8e37 7851 Control should support notification of descendants starting/stopping
Stephen Talley <stephen.talley@sun.com>
parents: 244
diff changeset
   262
    /**
260
507ac22496fe 7994 Control save/reset actions should act on descendents first
Stephen Talley <stephen.talley@sun.com>
parents: 248
diff changeset
   263
     * Gets a {@link SwingStructuredAction} that invokes {@link #resetAll},
138
48a05b6471de 4366 wizard: wizard steps should not be limited to SwingControls
Stephen Talley <stephen.talley@sun.com>
parents: 136
diff changeset
   264
     * displaying errors.
48a05b6471de 4366 wizard: wizard steps should not be limited to SwingControls
Stephen Talley <stephen.talley@sun.com>
parents: 136
diff changeset
   265
     */
48a05b6471de 4366 wizard: wizard steps should not be limited to SwingControls
Stephen Talley <stephen.talley@sun.com>
parents: 136
diff changeset
   266
    @Override
48a05b6471de 4366 wizard: wizard steps should not be limited to SwingControls
Stephen Talley <stephen.talley@sun.com>
parents: 136
diff changeset
   267
    public SwingStructuredAction<?, ?, ?> getResetAction() {
48a05b6471de 4366 wizard: wizard steps should not be limited to SwingControls
Stephen Talley <stephen.talley@sun.com>
parents: 136
diff changeset
   268
	return resetAction;
48a05b6471de 4366 wizard: wizard steps should not be limited to SwingControls
Stephen Talley <stephen.talley@sun.com>
parents: 136
diff changeset
   269
    }
48a05b6471de 4366 wizard: wizard steps should not be limited to SwingControls
Stephen Talley <stephen.talley@sun.com>
parents: 136
diff changeset
   270
48a05b6471de 4366 wizard: wizard steps should not be limited to SwingControls
Stephen Talley <stephen.talley@sun.com>
parents: 136
diff changeset
   271
    /**
260
507ac22496fe 7994 Control save/reset actions should act on descendents first
Stephen Talley <stephen.talley@sun.com>
parents: 248
diff changeset
   272
     * Gets a {@link SwingStructuredAction} that invokes {@link #saveAll},
138
48a05b6471de 4366 wizard: wizard steps should not be limited to SwingControls
Stephen Talley <stephen.talley@sun.com>
parents: 136
diff changeset
   273
     * displaying errors and prompting for login on {@code
214
aed2b42f7344 6426 UnauthorizedActionException's name should follow convention
Stephen Talley <stephen.talley@sun.com>
parents: 212
diff changeset
   274
     * ActionUnauthorizedException}s.
138
48a05b6471de 4366 wizard: wizard steps should not be limited to SwingControls
Stephen Talley <stephen.talley@sun.com>
parents: 136
diff changeset
   275
     */
48a05b6471de 4366 wizard: wizard steps should not be limited to SwingControls
Stephen Talley <stephen.talley@sun.com>
parents: 136
diff changeset
   276
    @Override
48a05b6471de 4366 wizard: wizard steps should not be limited to SwingControls
Stephen Talley <stephen.talley@sun.com>
parents: 136
diff changeset
   277
    public SwingStructuredAction<?, ?, ?> getSaveAction() {
48a05b6471de 4366 wizard: wizard steps should not be limited to SwingControls
Stephen Talley <stephen.talley@sun.com>
parents: 136
diff changeset
   278
	return saveAction;
48a05b6471de 4366 wizard: wizard steps should not be limited to SwingControls
Stephen Talley <stephen.talley@sun.com>
parents: 136
diff changeset
   279
    }
48a05b6471de 4366 wizard: wizard steps should not be limited to SwingControls
Stephen Talley <stephen.talley@sun.com>
parents: 136
diff changeset
   280
48a05b6471de 4366 wizard: wizard steps should not be limited to SwingControls
Stephen Talley <stephen.talley@sun.com>
parents: 136
diff changeset
   281
    /**
360
8943c58ad2f5 11508 Control, DefaultControl refactoring
Stephen Talley <stephen.talley@sun.com>
parents: 343
diff changeset
   282
     * Prompts the user to save changes, discard changes, or cancel navigation,
8943c58ad2f5 11508 Control, DefaultControl refactoring
Stephen Talley <stephen.talley@sun.com>
parents: 343
diff changeset
   283
     * when navigating away from a {@code Control} with unsaved changes.
8943c58ad2f5 11508 Control, DefaultControl refactoring
Stephen Talley <stephen.talley@sun.com>
parents: 343
diff changeset
   284
     *
8943c58ad2f5 11508 Control, DefaultControl refactoring
Stephen Talley <stephen.talley@sun.com>
parents: 343
diff changeset
   285
     * @see	    #getUnsavedChangesMessage
8943c58ad2f5 11508 Control, DefaultControl refactoring
Stephen Talley <stephen.talley@sun.com>
parents: 343
diff changeset
   286
     */
8943c58ad2f5 11508 Control, DefaultControl refactoring
Stephen Talley <stephen.talley@sun.com>
parents: 343
diff changeset
   287
    @Override
8943c58ad2f5 11508 Control, DefaultControl refactoring
Stephen Talley <stephen.talley@sun.com>
parents: 343
diff changeset
   288
    protected UnsavedChangesAction getUnsavedChangesAction() {
8943c58ad2f5 11508 Control, DefaultControl refactoring
Stephen Talley <stephen.talley@sun.com>
parents: 343
diff changeset
   289
	String message = getUnsavedChangesMessage();
8943c58ad2f5 11508 Control, DefaultControl refactoring
Stephen Talley <stephen.talley@sun.com>
parents: 343
diff changeset
   290
	if (message == null) {
8943c58ad2f5 11508 Control, DefaultControl refactoring
Stephen Talley <stephen.talley@sun.com>
parents: 343
diff changeset
   291
	    message = Finder.getString("settings.unsavedchanges.message");
8943c58ad2f5 11508 Control, DefaultControl refactoring
Stephen Talley <stephen.talley@sun.com>
parents: 343
diff changeset
   292
	}
8943c58ad2f5 11508 Control, DefaultControl refactoring
Stephen Talley <stephen.talley@sun.com>
parents: 343
diff changeset
   293
8943c58ad2f5 11508 Control, DefaultControl refactoring
Stephen Talley <stephen.talley@sun.com>
parents: 343
diff changeset
   294
	String title = Finder.getString("settings.unsavedchanges.title");
8943c58ad2f5 11508 Control, DefaultControl refactoring
Stephen Talley <stephen.talley@sun.com>
parents: 343
diff changeset
   295
	int messageType = JOptionPane.WARNING_MESSAGE;
8943c58ad2f5 11508 Control, DefaultControl refactoring
Stephen Talley <stephen.talley@sun.com>
parents: 343
diff changeset
   296
	int optionType = JOptionPane.DEFAULT_OPTION;
8943c58ad2f5 11508 Control, DefaultControl refactoring
Stephen Talley <stephen.talley@sun.com>
parents: 343
diff changeset
   297
	Icon icon = GUIUtil.getIcon(JOptionPane.WARNING_MESSAGE);
8943c58ad2f5 11508 Control, DefaultControl refactoring
Stephen Talley <stephen.talley@sun.com>
parents: 343
diff changeset
   298
8943c58ad2f5 11508 Control, DefaultControl refactoring
Stephen Talley <stephen.talley@sun.com>
parents: 343
diff changeset
   299
	Object[] options = {
8943c58ad2f5 11508 Control, DefaultControl refactoring
Stephen Talley <stephen.talley@sun.com>
parents: 343
diff changeset
   300
	    Finder.getString("settings.unsavedchanges.button.cancel"),
8943c58ad2f5 11508 Control, DefaultControl refactoring
Stephen Talley <stephen.talley@sun.com>
parents: 343
diff changeset
   301
	    Finder.getString("settings.unsavedchanges.button.discard"),
8943c58ad2f5 11508 Control, DefaultControl refactoring
Stephen Talley <stephen.talley@sun.com>
parents: 343
diff changeset
   302
	    Finder.getString("settings.unsavedchanges.button.save"),
8943c58ad2f5 11508 Control, DefaultControl refactoring
Stephen Talley <stephen.talley@sun.com>
parents: 343
diff changeset
   303
	};
8943c58ad2f5 11508 Control, DefaultControl refactoring
Stephen Talley <stephen.talley@sun.com>
parents: 343
diff changeset
   304
8943c58ad2f5 11508 Control, DefaultControl refactoring
Stephen Talley <stephen.talley@sun.com>
parents: 343
diff changeset
   305
	Object defaultOption = options[0];
8943c58ad2f5 11508 Control, DefaultControl refactoring
Stephen Talley <stephen.talley@sun.com>
parents: 343
diff changeset
   306
8943c58ad2f5 11508 Control, DefaultControl refactoring
Stephen Talley <stephen.talley@sun.com>
parents: 343
diff changeset
   307
	int result = JOptionPane.showOptionDialog(getComponent(), message,
8943c58ad2f5 11508 Control, DefaultControl refactoring
Stephen Talley <stephen.talley@sun.com>
parents: 343
diff changeset
   308
	    title, optionType, messageType, icon, options, defaultOption);
8943c58ad2f5 11508 Control, DefaultControl refactoring
Stephen Talley <stephen.talley@sun.com>
parents: 343
diff changeset
   309
8943c58ad2f5 11508 Control, DefaultControl refactoring
Stephen Talley <stephen.talley@sun.com>
parents: 343
diff changeset
   310
	switch (result) {
8943c58ad2f5 11508 Control, DefaultControl refactoring
Stephen Talley <stephen.talley@sun.com>
parents: 343
diff changeset
   311
	    default:
8943c58ad2f5 11508 Control, DefaultControl refactoring
Stephen Talley <stephen.talley@sun.com>
parents: 343
diff changeset
   312
	    case 0: return UnsavedChangesAction.CANCEL;
8943c58ad2f5 11508 Control, DefaultControl refactoring
Stephen Talley <stephen.talley@sun.com>
parents: 343
diff changeset
   313
	    case 1: return UnsavedChangesAction.DISCARD;
8943c58ad2f5 11508 Control, DefaultControl refactoring
Stephen Talley <stephen.talley@sun.com>
parents: 343
diff changeset
   314
	    case 2: return UnsavedChangesAction.SAVE;
8943c58ad2f5 11508 Control, DefaultControl refactoring
Stephen Talley <stephen.talley@sun.com>
parents: 343
diff changeset
   315
	}
8943c58ad2f5 11508 Control, DefaultControl refactoring
Stephen Talley <stephen.talley@sun.com>
parents: 343
diff changeset
   316
    }
8943c58ad2f5 11508 Control, DefaultControl refactoring
Stephen Talley <stephen.talley@sun.com>
parents: 343
diff changeset
   317
8943c58ad2f5 11508 Control, DefaultControl refactoring
Stephen Talley <stephen.talley@sun.com>
parents: 343
diff changeset
   318
    /**
343
5d483801ed5e 10602 sharemgr: UI forces user to save changes at too fine a granularity
Stephen Talley <stephen.talley@sun.com>
parents: 327
diff changeset
   319
     * If this {@code SwingControl} has a {@link #getChangeableAggregator
5d483801ed5e 10602 sharemgr: UI forces user to save changes at too fine a granularity
Stephen Talley <stephen.talley@sun.com>
parents: 327
diff changeset
   320
     * ChangeableAggregator}, returns the value from the aggregator's {@link
5d483801ed5e 10602 sharemgr: UI forces user to save changes at too fine a granularity
Stephen Talley <stephen.talley@sun.com>
parents: 327
diff changeset
   321
     * ChangeableAggregator#isChanged isChanged} method.  Otherwise, returns
5d483801ed5e 10602 sharemgr: UI forces user to save changes at too fine a granularity
Stephen Talley <stephen.talley@sun.com>
parents: 327
diff changeset
   322
     * {@code false}.
5d483801ed5e 10602 sharemgr: UI forces user to save changes at too fine a granularity
Stephen Talley <stephen.talley@sun.com>
parents: 327
diff changeset
   323
     */
5d483801ed5e 10602 sharemgr: UI forces user to save changes at too fine a granularity
Stephen Talley <stephen.talley@sun.com>
parents: 327
diff changeset
   324
    @Override
5d483801ed5e 10602 sharemgr: UI forces user to save changes at too fine a granularity
Stephen Talley <stephen.talley@sun.com>
parents: 327
diff changeset
   325
    protected boolean isSaveNeeded() {
5d483801ed5e 10602 sharemgr: UI forces user to save changes at too fine a granularity
Stephen Talley <stephen.talley@sun.com>
parents: 327
diff changeset
   326
	ChangeableAggregator aggregator = getChangeableAggregator();
5d483801ed5e 10602 sharemgr: UI forces user to save changes at too fine a granularity
Stephen Talley <stephen.talley@sun.com>
parents: 327
diff changeset
   327
	if (aggregator != null) {
5d483801ed5e 10602 sharemgr: UI forces user to save changes at too fine a granularity
Stephen Talley <stephen.talley@sun.com>
parents: 327
diff changeset
   328
	    return aggregator.isChanged();
5d483801ed5e 10602 sharemgr: UI forces user to save changes at too fine a granularity
Stephen Talley <stephen.talley@sun.com>
parents: 327
diff changeset
   329
	}
5d483801ed5e 10602 sharemgr: UI forces user to save changes at too fine a granularity
Stephen Talley <stephen.talley@sun.com>
parents: 327
diff changeset
   330
	return false;
5d483801ed5e 10602 sharemgr: UI forces user to save changes at too fine a granularity
Stephen Talley <stephen.talley@sun.com>
parents: 327
diff changeset
   331
    }
5d483801ed5e 10602 sharemgr: UI forces user to save changes at too fine a granularity
Stephen Talley <stephen.talley@sun.com>
parents: 327
diff changeset
   332
5d483801ed5e 10602 sharemgr: UI forces user to save changes at too fine a granularity
Stephen Talley <stephen.talley@sun.com>
parents: 327
diff changeset
   333
    /**
5d483801ed5e 10602 sharemgr: UI forces user to save changes at too fine a granularity
Stephen Talley <stephen.talley@sun.com>
parents: 327
diff changeset
   334
     * If this {@code SwingControl} has a {@link #getChangeableAggregator
5d483801ed5e 10602 sharemgr: UI forces user to save changes at too fine a granularity
Stephen Talley <stephen.talley@sun.com>
parents: 327
diff changeset
   335
     * ChangeableAggregator}, calls its {@link ChangeableAggregator#reset}
5d483801ed5e 10602 sharemgr: UI forces user to save changes at too fine a granularity
Stephen Talley <stephen.talley@sun.com>
parents: 327
diff changeset
   336
     * method on the AWT event thread and waits for its completion.
5d483801ed5e 10602 sharemgr: UI forces user to save changes at too fine a granularity
Stephen Talley <stephen.talley@sun.com>
parents: 327
diff changeset
   337
     */
5d483801ed5e 10602 sharemgr: UI forces user to save changes at too fine a granularity
Stephen Talley <stephen.talley@sun.com>
parents: 327
diff changeset
   338
    @Override
5d483801ed5e 10602 sharemgr: UI forces user to save changes at too fine a granularity
Stephen Talley <stephen.talley@sun.com>
parents: 327
diff changeset
   339
    protected void reset() throws ActionAbortedException, ActionFailedException
5d483801ed5e 10602 sharemgr: UI forces user to save changes at too fine a granularity
Stephen Talley <stephen.talley@sun.com>
parents: 327
diff changeset
   340
    {
5d483801ed5e 10602 sharemgr: UI forces user to save changes at too fine a granularity
Stephen Talley <stephen.talley@sun.com>
parents: 327
diff changeset
   341
	final ChangeableAggregator aggregator = getChangeableAggregator();
5d483801ed5e 10602 sharemgr: UI forces user to save changes at too fine a granularity
Stephen Talley <stephen.talley@sun.com>
parents: 327
diff changeset
   342
	if (aggregator != null) {
5d483801ed5e 10602 sharemgr: UI forces user to save changes at too fine a granularity
Stephen Talley <stephen.talley@sun.com>
parents: 327
diff changeset
   343
	    GUIUtil.invokeAndWait(
5d483801ed5e 10602 sharemgr: UI forces user to save changes at too fine a granularity
Stephen Talley <stephen.talley@sun.com>
parents: 327
diff changeset
   344
		new Runnable() {
5d483801ed5e 10602 sharemgr: UI forces user to save changes at too fine a granularity
Stephen Talley <stephen.talley@sun.com>
parents: 327
diff changeset
   345
		    @Override
5d483801ed5e 10602 sharemgr: UI forces user to save changes at too fine a granularity
Stephen Talley <stephen.talley@sun.com>
parents: 327
diff changeset
   346
		    public void run() {
5d483801ed5e 10602 sharemgr: UI forces user to save changes at too fine a granularity
Stephen Talley <stephen.talley@sun.com>
parents: 327
diff changeset
   347
			aggregator.reset();
5d483801ed5e 10602 sharemgr: UI forces user to save changes at too fine a granularity
Stephen Talley <stephen.talley@sun.com>
parents: 327
diff changeset
   348
		    }
5d483801ed5e 10602 sharemgr: UI forces user to save changes at too fine a granularity
Stephen Talley <stephen.talley@sun.com>
parents: 327
diff changeset
   349
		});
5d483801ed5e 10602 sharemgr: UI forces user to save changes at too fine a granularity
Stephen Talley <stephen.talley@sun.com>
parents: 327
diff changeset
   350
	}
5d483801ed5e 10602 sharemgr: UI forces user to save changes at too fine a granularity
Stephen Talley <stephen.talley@sun.com>
parents: 327
diff changeset
   351
    }
5d483801ed5e 10602 sharemgr: UI forces user to save changes at too fine a granularity
Stephen Talley <stephen.talley@sun.com>
parents: 327
diff changeset
   352
5d483801ed5e 10602 sharemgr: UI forces user to save changes at too fine a granularity
Stephen Talley <stephen.talley@sun.com>
parents: 327
diff changeset
   353
    /**
5d483801ed5e 10602 sharemgr: UI forces user to save changes at too fine a granularity
Stephen Talley <stephen.talley@sun.com>
parents: 327
diff changeset
   354
     * If this {@code SwingControl} has a {@link #getChangeableAggregator
5d483801ed5e 10602 sharemgr: UI forces user to save changes at too fine a granularity
Stephen Talley <stephen.talley@sun.com>
parents: 327
diff changeset
   355
     * ChangeableAggregator}, calls its {@link ChangeableAggregator#save}
5d483801ed5e 10602 sharemgr: UI forces user to save changes at too fine a granularity
Stephen Talley <stephen.talley@sun.com>
parents: 327
diff changeset
   356
     * method on the AWT event thread and waits for its completion.
5d483801ed5e 10602 sharemgr: UI forces user to save changes at too fine a granularity
Stephen Talley <stephen.talley@sun.com>
parents: 327
diff changeset
   357
     */
5d483801ed5e 10602 sharemgr: UI forces user to save changes at too fine a granularity
Stephen Talley <stephen.talley@sun.com>
parents: 327
diff changeset
   358
    @Override
5d483801ed5e 10602 sharemgr: UI forces user to save changes at too fine a granularity
Stephen Talley <stephen.talley@sun.com>
parents: 327
diff changeset
   359
    protected void save() throws ActionAbortedException, ActionFailedException,
5d483801ed5e 10602 sharemgr: UI forces user to save changes at too fine a granularity
Stephen Talley <stephen.talley@sun.com>
parents: 327
diff changeset
   360
	ActionUnauthorizedException {
5d483801ed5e 10602 sharemgr: UI forces user to save changes at too fine a granularity
Stephen Talley <stephen.talley@sun.com>
parents: 327
diff changeset
   361
5d483801ed5e 10602 sharemgr: UI forces user to save changes at too fine a granularity
Stephen Talley <stephen.talley@sun.com>
parents: 327
diff changeset
   362
	final ChangeableAggregator aggregator = getChangeableAggregator();
5d483801ed5e 10602 sharemgr: UI forces user to save changes at too fine a granularity
Stephen Talley <stephen.talley@sun.com>
parents: 327
diff changeset
   363
	if (aggregator != null) {
5d483801ed5e 10602 sharemgr: UI forces user to save changes at too fine a granularity
Stephen Talley <stephen.talley@sun.com>
parents: 327
diff changeset
   364
	    GUIUtil.invokeAndWait(
5d483801ed5e 10602 sharemgr: UI forces user to save changes at too fine a granularity
Stephen Talley <stephen.talley@sun.com>
parents: 327
diff changeset
   365
		new Runnable() {
5d483801ed5e 10602 sharemgr: UI forces user to save changes at too fine a granularity
Stephen Talley <stephen.talley@sun.com>
parents: 327
diff changeset
   366
		    @Override
5d483801ed5e 10602 sharemgr: UI forces user to save changes at too fine a granularity
Stephen Talley <stephen.talley@sun.com>
parents: 327
diff changeset
   367
		    public void run() {
5d483801ed5e 10602 sharemgr: UI forces user to save changes at too fine a granularity
Stephen Talley <stephen.talley@sun.com>
parents: 327
diff changeset
   368
			aggregator.save();
5d483801ed5e 10602 sharemgr: UI forces user to save changes at too fine a granularity
Stephen Talley <stephen.talley@sun.com>
parents: 327
diff changeset
   369
		    }
5d483801ed5e 10602 sharemgr: UI forces user to save changes at too fine a granularity
Stephen Talley <stephen.talley@sun.com>
parents: 327
diff changeset
   370
		});
5d483801ed5e 10602 sharemgr: UI forces user to save changes at too fine a granularity
Stephen Talley <stephen.talley@sun.com>
parents: 327
diff changeset
   371
	}
5d483801ed5e 10602 sharemgr: UI forces user to save changes at too fine a granularity
Stephen Talley <stephen.talley@sun.com>
parents: 327
diff changeset
   372
    }
5d483801ed5e 10602 sharemgr: UI forces user to save changes at too fine a granularity
Stephen Talley <stephen.talley@sun.com>
parents: 327
diff changeset
   373
5d483801ed5e 10602 sharemgr: UI forces user to save changes at too fine a granularity
Stephen Talley <stephen.talley@sun.com>
parents: 327
diff changeset
   374
    /**
248
d947462c8e37 7851 Control should support notification of descendants starting/stopping
Stephen Talley <stephen.talley@sun.com>
parents: 244
diff changeset
   375
     * Calls the superclass implementation, {@link #getComponentCreate creates}
d947462c8e37 7851 Control should support notification of descendants starting/stopping
Stephen Talley <stephen.talley@sun.com>
parents: 244
diff changeset
   376
     * this {@code SwingControl}'s {@code Component} if necessary, then
d947462c8e37 7851 Control should support notification of descendants starting/stopping
Stephen Talley <stephen.talley@sun.com>
parents: 244
diff changeset
   377
     * {@link #initComponentOnEventThread initializes} it.
0
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   378
     */
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   379
    @Override
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   380
    public void start(Navigator navigator, Map<String, String> parameters)
40
d1412af1ae5b 3215 ActionAbortedException is used too broadly
Stephen Talley <stephen.talley@sun.com>
parents: 39
diff changeset
   381
	throws NavigationAbortedException, InvalidParameterException {
0
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   382
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   383
	super.start(navigator, parameters);
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   384
301
98464369f109 9311 MutableProperties should support PropertyChangeEvents
Stephen Talley <stephen.talley@sun.com>
parents: 298
diff changeset
   385
	if (propSource != null) {
98464369f109 9311 MutableProperties should support PropertyChangeEvents
Stephen Talley <stephen.talley@sun.com>
parents: 298
diff changeset
   386
	    if (propNames == null) {
98464369f109 9311 MutableProperties should support PropertyChangeEvents
Stephen Talley <stephen.talley@sun.com>
parents: 298
diff changeset
   387
		propSource.addPropertyChangeListener(this);
98464369f109 9311 MutableProperties should support PropertyChangeEvents
Stephen Talley <stephen.talley@sun.com>
parents: 298
diff changeset
   388
	    } else {
98464369f109 9311 MutableProperties should support PropertyChangeEvents
Stephen Talley <stephen.talley@sun.com>
parents: 298
diff changeset
   389
		for (String propName : propNames) {
98464369f109 9311 MutableProperties should support PropertyChangeEvents
Stephen Talley <stephen.talley@sun.com>
parents: 298
diff changeset
   390
		    propSource.addPropertyChangeListener(propName, this);
98464369f109 9311 MutableProperties should support PropertyChangeEvents
Stephen Talley <stephen.talley@sun.com>
parents: 298
diff changeset
   391
		}
98464369f109 9311 MutableProperties should support PropertyChangeEvents
Stephen Talley <stephen.talley@sun.com>
parents: 298
diff changeset
   392
	    }
98464369f109 9311 MutableProperties should support PropertyChangeEvents
Stephen Talley <stephen.talley@sun.com>
parents: 298
diff changeset
   393
	}
298
cc0001e49171 8703 Control subclasses should handle inherited start() method failures
David Powell <David.Powell@sun.com>
parents: 295
diff changeset
   394
164
afcaf3a72d02 4880 sysid: timezone panel grows window, which is then no longer centered
Stephen Talley <stephen.talley@sun.com>
parents: 154
diff changeset
   395
	Component comp = getComponentCreate();
248
d947462c8e37 7851 Control should support notification of descendants starting/stopping
Stephen Talley <stephen.talley@sun.com>
parents: 244
diff changeset
   396
	if (comp != null) {
26
8a459d117e4a 2991 Stricter enforcement of UI operations on event thread would help avoid deadlocks
Stephen Talley <stephen.talley@sun.com>
parents: 0
diff changeset
   397
	    initComponentOnEventThread();
0
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   398
	}
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   399
    }
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   400
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   401
    /**
248
d947462c8e37 7851 Control should support notification of descendants starting/stopping
Stephen Talley <stephen.talley@sun.com>
parents: 244
diff changeset
   402
     * Calls the superclass implementation, then {@link
d947462c8e37 7851 Control should support notification of descendants starting/stopping
Stephen Talley <stephen.talley@sun.com>
parents: 244
diff changeset
   403
     * #deinitComponentOnEventThread deinitializes} this {@code SwingControl}'s
d947462c8e37 7851 Control should support notification of descendants starting/stopping
Stephen Talley <stephen.talley@sun.com>
parents: 244
diff changeset
   404
     * {@code Component}.
0
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   405
     *
40
d1412af1ae5b 3215 ActionAbortedException is used too broadly
Stephen Talley <stephen.talley@sun.com>
parents: 39
diff changeset
   406
     * @exception   NavigationAbortedException
0
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   407
     *		    if the navigation is cancelled, or a save fails
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   408
     */
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   409
    @Override
302
ac70675de834 9318 Navigator/Control should distinguish between cancel and non-cancel navigations
Stephen Talley <stephen.talley@sun.com>
parents: 301
diff changeset
   410
    public void stop(boolean isCancel) throws NavigationAbortedException {
ac70675de834 9318 Navigator/Control should distinguish between cancel and non-cancel navigations
Stephen Talley <stephen.talley@sun.com>
parents: 301
diff changeset
   411
	super.stop(isCancel);
0
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   412
248
d947462c8e37 7851 Control should support notification of descendants starting/stopping
Stephen Talley <stephen.talley@sun.com>
parents: 244
diff changeset
   413
	Component comp = getComponent();
134
c2e6edafe4ae 4351 Refine wizard framework and add to API
Stephen Talley <stephen.talley@sun.com>
parents: 112
diff changeset
   414
	if (comp != null) {
248
d947462c8e37 7851 Control should support notification of descendants starting/stopping
Stephen Talley <stephen.talley@sun.com>
parents: 244
diff changeset
   415
	    deinitComponentOnEventThread();
0
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   416
	}
298
cc0001e49171 8703 Control subclasses should handle inherited start() method failures
David Powell <David.Powell@sun.com>
parents: 295
diff changeset
   417
301
98464369f109 9311 MutableProperties should support PropertyChangeEvents
Stephen Talley <stephen.talley@sun.com>
parents: 298
diff changeset
   418
	if (propSource != null) {
98464369f109 9311 MutableProperties should support PropertyChangeEvents
Stephen Talley <stephen.talley@sun.com>
parents: 298
diff changeset
   419
	    propSource.removePropertyChangeListener(this);
98464369f109 9311 MutableProperties should support PropertyChangeEvents
Stephen Talley <stephen.talley@sun.com>
parents: 298
diff changeset
   420
	    propSource = null;
98464369f109 9311 MutableProperties should support PropertyChangeEvents
Stephen Talley <stephen.talley@sun.com>
parents: 298
diff changeset
   421
	    propNames = null;
298
cc0001e49171 8703 Control subclasses should handle inherited start() method failures
David Powell <David.Powell@sun.com>
parents: 295
diff changeset
   422
	}
235
38f73435a683 7483 save/prompt functionality in SwingControl can be generalized and moved into Control and DefaultControl
Stephen Talley <stephen.talley@sun.com>
parents: 230
diff changeset
   423
    }
26
8a459d117e4a 2991 Stricter enforcement of UI operations on event thread would help avoid deadlocks
Stephen Talley <stephen.talley@sun.com>
parents: 0
diff changeset
   424
235
38f73435a683 7483 save/prompt functionality in SwingControl can be generalized and moved into Control and DefaultControl
Stephen Talley <stephen.talley@sun.com>
parents: 230
diff changeset
   425
    //
38f73435a683 7483 save/prompt functionality in SwingControl can be generalized and moved into Control and DefaultControl
Stephen Talley <stephen.talley@sun.com>
parents: 230
diff changeset
   426
    // DefaultControl methods
38f73435a683 7483 save/prompt functionality in SwingControl can be generalized and moved into Control and DefaultControl
Stephen Talley <stephen.talley@sun.com>
parents: 230
diff changeset
   427
    //
38f73435a683 7483 save/prompt functionality in SwingControl can be generalized and moved into Control and DefaultControl
Stephen Talley <stephen.talley@sun.com>
parents: 230
diff changeset
   428
264
d5cd4b2e7426 8029 apache: ui redesign
Stephen Talley <stephen.talley@sun.com>
parents: 263
diff changeset
   429
    @Override
d5cd4b2e7426 8029 apache: ui redesign
Stephen Talley <stephen.talley@sun.com>
parents: 263
diff changeset
   430
    protected void removeChild(int index) {
d5cd4b2e7426 8029 apache: ui redesign
Stephen Talley <stephen.talley@sun.com>
parents: 263
diff changeset
   431
	synchronized (children) {
d5cd4b2e7426 8029 apache: ui redesign
Stephen Talley <stephen.talley@sun.com>
parents: 263
diff changeset
   432
	    Control child = children.get(index);
d5cd4b2e7426 8029 apache: ui redesign
Stephen Talley <stephen.talley@sun.com>
parents: 263
diff changeset
   433
	    children.remove(index);
d5cd4b2e7426 8029 apache: ui redesign
Stephen Talley <stephen.talley@sun.com>
parents: 263
diff changeset
   434
	    dialogChildren.remove(child);
d5cd4b2e7426 8029 apache: ui redesign
Stephen Talley <stephen.talley@sun.com>
parents: 263
diff changeset
   435
	}
d5cd4b2e7426 8029 apache: ui redesign
Stephen Talley <stephen.talley@sun.com>
parents: 263
diff changeset
   436
    }
d5cd4b2e7426 8029 apache: ui redesign
Stephen Talley <stephen.talley@sun.com>
parents: 263
diff changeset
   437
0
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   438
    //
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   439
    // SwingControl methods
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   440
    //
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   441
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   442
    /**
264
d5cd4b2e7426 8029 apache: ui redesign
Stephen Talley <stephen.talley@sun.com>
parents: 263
diff changeset
   443
     * Calls {@link DefaultControl#addChildren addChildren} with the given
d5cd4b2e7426 8029 apache: ui redesign
Stephen Talley <stephen.talley@sun.com>
parents: 263
diff changeset
   444
     * controls.  When a child in the given list is started, it will
d5cd4b2e7426 8029 apache: ui redesign
Stephen Talley <stephen.talley@sun.com>
parents: 263
diff changeset
   445
     * automatically be placed in a modal dialog that corresponds to the child's
d5cd4b2e7426 8029 apache: ui redesign
Stephen Talley <stephen.talley@sun.com>
parents: 263
diff changeset
   446
     * lifecycle.
d5cd4b2e7426 8029 apache: ui redesign
Stephen Talley <stephen.talley@sun.com>
parents: 263
diff changeset
   447
     */
d5cd4b2e7426 8029 apache: ui redesign
Stephen Talley <stephen.talley@sun.com>
parents: 263
diff changeset
   448
    public void addDialogChildren(Control... controls) {
d5cd4b2e7426 8029 apache: ui redesign
Stephen Talley <stephen.talley@sun.com>
parents: 263
diff changeset
   449
	super.addChildren(controls);
d5cd4b2e7426 8029 apache: ui redesign
Stephen Talley <stephen.talley@sun.com>
parents: 263
diff changeset
   450
	for (Control child : controls) {
d5cd4b2e7426 8029 apache: ui redesign
Stephen Talley <stephen.talley@sun.com>
parents: 263
diff changeset
   451
	    dialogChildren.add(child);
d5cd4b2e7426 8029 apache: ui redesign
Stephen Talley <stephen.talley@sun.com>
parents: 263
diff changeset
   452
	}
d5cd4b2e7426 8029 apache: ui redesign
Stephen Talley <stephen.talley@sun.com>
parents: 263
diff changeset
   453
    }
d5cd4b2e7426 8029 apache: ui redesign
Stephen Talley <stephen.talley@sun.com>
parents: 263
diff changeset
   454
d5cd4b2e7426 8029 apache: ui redesign
Stephen Talley <stephen.talley@sun.com>
parents: 263
diff changeset
   455
    /**
d5cd4b2e7426 8029 apache: ui redesign
Stephen Talley <stephen.talley@sun.com>
parents: 263
diff changeset
   456
     * Configures the just-{@code #createComponent created} {@code Component}
d5cd4b2e7426 8029 apache: ui redesign
Stephen Talley <stephen.talley@sun.com>
parents: 263
diff changeset
   457
     * for this {@code SwingControl}.  This method is called automatically just
d5cd4b2e7426 8029 apache: ui redesign
Stephen Talley <stephen.talley@sun.com>
parents: 263
diff changeset
   458
     * after {@code createComponent}.
360
8943c58ad2f5 11508 Control, DefaultControl refactoring
Stephen Talley <stephen.talley@sun.com>
parents: 343
diff changeset
   459
     * <p/>
264
d5cd4b2e7426 8029 apache: ui redesign
Stephen Talley <stephen.talley@sun.com>
parents: 263
diff changeset
   460
     * This default implementation does nothing.  Most subclasses can do all
d5cd4b2e7426 8029 apache: ui redesign
Stephen Talley <stephen.talley@sun.com>
parents: 263
diff changeset
   461
     * configuration in {@link #createComponent}.  Only implementors that wish
d5cd4b2e7426 8029 apache: ui redesign
Stephen Talley <stephen.talley@sun.com>
parents: 263
diff changeset
   462
     * to provide a common configuration for all {@code Component}s created by
d5cd4b2e7426 8029 apache: ui redesign
Stephen Talley <stephen.talley@sun.com>
parents: 263
diff changeset
   463
     * their subclasses need to implement this method.
d5cd4b2e7426 8029 apache: ui redesign
Stephen Talley <stephen.talley@sun.com>
parents: 263
diff changeset
   464
     *
d5cd4b2e7426 8029 apache: ui redesign
Stephen Talley <stephen.talley@sun.com>
parents: 263
diff changeset
   465
     * @param	    comp
d5cd4b2e7426 8029 apache: ui redesign
Stephen Talley <stephen.talley@sun.com>
parents: 263
diff changeset
   466
     *		    the newly-created {@code Component}
d5cd4b2e7426 8029 apache: ui redesign
Stephen Talley <stephen.talley@sun.com>
parents: 263
diff changeset
   467
     */
d5cd4b2e7426 8029 apache: ui redesign
Stephen Talley <stephen.talley@sun.com>
parents: 263
diff changeset
   468
    protected void configComponent(C comp) {
d5cd4b2e7426 8029 apache: ui redesign
Stephen Talley <stephen.talley@sun.com>
parents: 263
diff changeset
   469
    }
d5cd4b2e7426 8029 apache: ui redesign
Stephen Talley <stephen.talley@sun.com>
parents: 263
diff changeset
   470
d5cd4b2e7426 8029 apache: ui redesign
Stephen Talley <stephen.talley@sun.com>
parents: 263
diff changeset
   471
    /**
0
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   472
     * Creates the {@code Component} for this {@code SwingControl}.
360
8943c58ad2f5 11508 Control, DefaultControl refactoring
Stephen Talley <stephen.talley@sun.com>
parents: 343
diff changeset
   473
     * <p/>
244
b6f1fb4f5a89 7624 SwingControl: createComponent implementations should not be required to call setComponent
Stephen Talley <stephen.talley@sun.com>
parents: 235
diff changeset
   474
     * This default implementation does nothing and returns {@code null}.
b6f1fb4f5a89 7624 SwingControl: createComponent implementations should not be required to call setComponent
Stephen Talley <stephen.talley@sun.com>
parents: 235
diff changeset
   475
     *
b6f1fb4f5a89 7624 SwingControl: createComponent implementations should not be required to call setComponent
Stephen Talley <stephen.talley@sun.com>
parents: 235
diff changeset
   476
     * @return	    the newly-created {@code Component}
0
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   477
     */
244
b6f1fb4f5a89 7624 SwingControl: createComponent implementations should not be required to call setComponent
Stephen Talley <stephen.talley@sun.com>
parents: 235
diff changeset
   478
    protected C createComponent() {
b6f1fb4f5a89 7624 SwingControl: createComponent implementations should not be required to call setComponent
Stephen Talley <stephen.talley@sun.com>
parents: 235
diff changeset
   479
	return null;
0
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   480
    }
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   481
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   482
    /**
264
d5cd4b2e7426 8029 apache: ui redesign
Stephen Talley <stephen.talley@sun.com>
parents: 263
diff changeset
   483
     * De-initializes the {@code Component} for this {@code SwingControl}.  This
d5cd4b2e7426 8029 apache: ui redesign
Stephen Talley <stephen.talley@sun.com>
parents: 263
diff changeset
   484
     * method is called automatically when this {@code Control} is stopped.
360
8943c58ad2f5 11508 Control, DefaultControl refactoring
Stephen Talley <stephen.talley@sun.com>
parents: 343
diff changeset
   485
     * <p/>
26
8a459d117e4a 2991 Stricter enforcement of UI operations on event thread would help avoid deadlocks
Stephen Talley <stephen.talley@sun.com>
parents: 0
diff changeset
   486
     * This default implementation does nothing.
8a459d117e4a 2991 Stricter enforcement of UI operations on event thread would help avoid deadlocks
Stephen Talley <stephen.talley@sun.com>
parents: 0
diff changeset
   487
     */
80
9256ce8453d7 3497 SwingControl methods are too permissive
Stephen Talley <stephen.talley@sun.com>
parents: 76
diff changeset
   488
    protected void deinitComponent() {
26
8a459d117e4a 2991 Stricter enforcement of UI operations on event thread would help avoid deadlocks
Stephen Talley <stephen.talley@sun.com>
parents: 0
diff changeset
   489
    }
8a459d117e4a 2991 Stricter enforcement of UI operations on event thread would help avoid deadlocks
Stephen Talley <stephen.talley@sun.com>
parents: 0
diff changeset
   490
8a459d117e4a 2991 Stricter enforcement of UI operations on event thread would help avoid deadlocks
Stephen Talley <stephen.talley@sun.com>
parents: 0
diff changeset
   491
    /**
8a459d117e4a 2991 Stricter enforcement of UI operations on event thread would help avoid deadlocks
Stephen Talley <stephen.talley@sun.com>
parents: 0
diff changeset
   492
     * Calls {@link #deinitComponent} on the event queue thread and waits until
264
d5cd4b2e7426 8029 apache: ui redesign
Stephen Talley <stephen.talley@sun.com>
parents: 263
diff changeset
   493
     * it has completed.  This method is called automatically when this {@code
d5cd4b2e7426 8029 apache: ui redesign
Stephen Talley <stephen.talley@sun.com>
parents: 263
diff changeset
   494
     * Control} is stopped.
26
8a459d117e4a 2991 Stricter enforcement of UI operations on event thread would help avoid deadlocks
Stephen Talley <stephen.talley@sun.com>
parents: 0
diff changeset
   495
     */
80
9256ce8453d7 3497 SwingControl methods are too permissive
Stephen Talley <stephen.talley@sun.com>
parents: 76
diff changeset
   496
    protected void deinitComponentOnEventThread() {
26
8a459d117e4a 2991 Stricter enforcement of UI operations on event thread would help avoid deadlocks
Stephen Talley <stephen.talley@sun.com>
parents: 0
diff changeset
   497
	GUIUtil.invokeAndWait(
8a459d117e4a 2991 Stricter enforcement of UI operations on event thread would help avoid deadlocks
Stephen Talley <stephen.talley@sun.com>
parents: 0
diff changeset
   498
	    new Runnable() {
8a459d117e4a 2991 Stricter enforcement of UI operations on event thread would help avoid deadlocks
Stephen Talley <stephen.talley@sun.com>
parents: 0
diff changeset
   499
		@Override
8a459d117e4a 2991 Stricter enforcement of UI operations on event thread would help avoid deadlocks
Stephen Talley <stephen.talley@sun.com>
parents: 0
diff changeset
   500
		public void run() {
8a459d117e4a 2991 Stricter enforcement of UI operations on event thread would help avoid deadlocks
Stephen Talley <stephen.talley@sun.com>
parents: 0
diff changeset
   501
		    deinitComponent();
8a459d117e4a 2991 Stricter enforcement of UI operations on event thread would help avoid deadlocks
Stephen Talley <stephen.talley@sun.com>
parents: 0
diff changeset
   502
		}
8a459d117e4a 2991 Stricter enforcement of UI operations on event thread would help avoid deadlocks
Stephen Talley <stephen.talley@sun.com>
parents: 0
diff changeset
   503
	    });
8a459d117e4a 2991 Stricter enforcement of UI operations on event thread would help avoid deadlocks
Stephen Talley <stephen.talley@sun.com>
parents: 0
diff changeset
   504
    }
8a459d117e4a 2991 Stricter enforcement of UI operations on event thread would help avoid deadlocks
Stephen Talley <stephen.talley@sun.com>
parents: 0
diff changeset
   505
8a459d117e4a 2991 Stricter enforcement of UI operations on event thread would help avoid deadlocks
Stephen Talley <stephen.talley@sun.com>
parents: 0
diff changeset
   506
    /**
343
5d483801ed5e 10602 sharemgr: UI forces user to save changes at too fine a granularity
Stephen Talley <stephen.talley@sun.com>
parents: 327
diff changeset
   507
     * Gets the {@link ChangeableAggregator}, if any, for this class.  This is
5d483801ed5e 10602 sharemgr: UI forces user to save changes at too fine a granularity
Stephen Talley <stephen.talley@sun.com>
parents: 327
diff changeset
   508
     * used in the default implementation of some {@link Control} methods to
5d483801ed5e 10602 sharemgr: UI forces user to save changes at too fine a granularity
Stephen Talley <stephen.talley@sun.com>
parents: 327
diff changeset
   509
     * track changes to this {@code Control}.
5d483801ed5e 10602 sharemgr: UI forces user to save changes at too fine a granularity
Stephen Talley <stephen.talley@sun.com>
parents: 327
diff changeset
   510
     * <p/>
5d483801ed5e 10602 sharemgr: UI forces user to save changes at too fine a granularity
Stephen Talley <stephen.talley@sun.com>
parents: 327
diff changeset
   511
     * This default implementation returns {@code null}.
5d483801ed5e 10602 sharemgr: UI forces user to save changes at too fine a granularity
Stephen Talley <stephen.talley@sun.com>
parents: 327
diff changeset
   512
     *
5d483801ed5e 10602 sharemgr: UI forces user to save changes at too fine a granularity
Stephen Talley <stephen.talley@sun.com>
parents: 327
diff changeset
   513
     * @return	    a {@link ChangeableAggregator}, or {@code null} if this
360
8943c58ad2f5 11508 Control, DefaultControl refactoring
Stephen Talley <stephen.talley@sun.com>
parents: 343
diff changeset
   514
     *		    {@code SwingControl} has none
343
5d483801ed5e 10602 sharemgr: UI forces user to save changes at too fine a granularity
Stephen Talley <stephen.talley@sun.com>
parents: 327
diff changeset
   515
     */
5d483801ed5e 10602 sharemgr: UI forces user to save changes at too fine a granularity
Stephen Talley <stephen.talley@sun.com>
parents: 327
diff changeset
   516
    public ChangeableAggregator getChangeableAggregator() {
5d483801ed5e 10602 sharemgr: UI forces user to save changes at too fine a granularity
Stephen Talley <stephen.talley@sun.com>
parents: 327
diff changeset
   517
	return null;
5d483801ed5e 10602 sharemgr: UI forces user to save changes at too fine a granularity
Stephen Talley <stephen.talley@sun.com>
parents: 327
diff changeset
   518
    }
5d483801ed5e 10602 sharemgr: UI forces user to save changes at too fine a granularity
Stephen Talley <stephen.talley@sun.com>
parents: 327
diff changeset
   519
5d483801ed5e 10602 sharemgr: UI forces user to save changes at too fine a granularity
Stephen Talley <stephen.talley@sun.com>
parents: 327
diff changeset
   520
    /**
0
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   521
     * Gets a {@link NavigationListener} to handle the UI transition that takes
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   522
     * place when a child {@link Control} is added to this {@code
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   523
     * ChildComponentHandler}.	This {@link NavigationListener} is automatically
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   524
     * invoked by the {@link UITransitionManager} class.
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   525
     *
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   526
     * @return	    a {@link NavigationListener}, or {@code null} to use the
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   527
     *		    default
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   528
     */
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   529
    public NavigationListener getChildAddedTransitionHandler() {
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   530
	return null;
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   531
    }
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   532
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   533
    /**
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   534
     * Gets a {@link NavigationListener} to handle the UI transition that takes
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   535
     * place when a child {@link Control} is removed from this {@code
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   536
     * ChildComponentHandler}.	This {@link NavigationListener} is automatically
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   537
     * invoked by the {@link UITransitionManager} class.
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   538
     *
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   539
     * @return	    a {@link NavigationListener}, or {@code null} to use the
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   540
     *		    default
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   541
     */
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   542
    public NavigationListener getChildRemovedTransitionHandler() {
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   543
	return null;
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   544
    }
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   545
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   546
    /**
244
b6f1fb4f5a89 7624 SwingControl: createComponent implementations should not be required to call setComponent
Stephen Talley <stephen.talley@sun.com>
parents: 235
diff changeset
   547
     * Gets the {@code Component} for this {@code SwingControl}, {@link
264
d5cd4b2e7426 8029 apache: ui redesign
Stephen Talley <stephen.talley@sun.com>
parents: 263
diff changeset
   548
     * #createComponent creating} it, {@code #configComponent configuring} it,
d5cd4b2e7426 8029 apache: ui redesign
Stephen Talley <stephen.talley@sun.com>
parents: 263
diff changeset
   549
     * and {@code #setComponent setting} it first if necessary.
164
afcaf3a72d02 4880 sysid: timezone panel grows window, which is then no longer centered
Stephen Talley <stephen.talley@sun.com>
parents: 154
diff changeset
   550
     * <p/>
afcaf3a72d02 4880 sysid: timezone panel grows window, which is then no longer centered
Stephen Talley <stephen.talley@sun.com>
parents: 154
diff changeset
   551
     * This method is not thread-safe; external locking may be necessary to
afcaf3a72d02 4880 sysid: timezone panel grows window, which is then no longer centered
Stephen Talley <stephen.talley@sun.com>
parents: 154
diff changeset
   552
     * ensure that {@link #createComponent} is not called by multiple threads.
afcaf3a72d02 4880 sysid: timezone panel grows window, which is then no longer centered
Stephen Talley <stephen.talley@sun.com>
parents: 154
diff changeset
   553
     *
afcaf3a72d02 4880 sysid: timezone panel grows window, which is then no longer centered
Stephen Talley <stephen.talley@sun.com>
parents: 154
diff changeset
   554
     * @return	    a {@code Component}, or {@code null} if this {@code
afcaf3a72d02 4880 sysid: timezone panel grows window, which is then no longer centered
Stephen Talley <stephen.talley@sun.com>
parents: 154
diff changeset
   555
     *		    SwingControl} has no {@code Component}.
afcaf3a72d02 4880 sysid: timezone panel grows window, which is then no longer centered
Stephen Talley <stephen.talley@sun.com>
parents: 154
diff changeset
   556
     */
afcaf3a72d02 4880 sysid: timezone panel grows window, which is then no longer centered
Stephen Talley <stephen.talley@sun.com>
parents: 154
diff changeset
   557
    public C getComponentCreate() {
afcaf3a72d02 4880 sysid: timezone panel grows window, which is then no longer centered
Stephen Talley <stephen.talley@sun.com>
parents: 154
diff changeset
   558
	C comp = getComponent();
afcaf3a72d02 4880 sysid: timezone panel grows window, which is then no longer centered
Stephen Talley <stephen.talley@sun.com>
parents: 154
diff changeset
   559
	if (comp == null) {
244
b6f1fb4f5a89 7624 SwingControl: createComponent implementations should not be required to call setComponent
Stephen Talley <stephen.talley@sun.com>
parents: 235
diff changeset
   560
	    comp = createComponent();
b6f1fb4f5a89 7624 SwingControl: createComponent implementations should not be required to call setComponent
Stephen Talley <stephen.talley@sun.com>
parents: 235
diff changeset
   561
	    if (comp != null) {
327
bb43a6fa6f0b 10096 time: new UI design and NTP support
Stephen Talley <stephen.talley@sun.com>
parents: 302
diff changeset
   562
		setComponent(comp);
264
d5cd4b2e7426 8029 apache: ui redesign
Stephen Talley <stephen.talley@sun.com>
parents: 263
diff changeset
   563
		configComponent(comp);
244
b6f1fb4f5a89 7624 SwingControl: createComponent implementations should not be required to call setComponent
Stephen Talley <stephen.talley@sun.com>
parents: 235
diff changeset
   564
	    }
164
afcaf3a72d02 4880 sysid: timezone panel grows window, which is then no longer centered
Stephen Talley <stephen.talley@sun.com>
parents: 154
diff changeset
   565
	}
afcaf3a72d02 4880 sysid: timezone panel grows window, which is then no longer centered
Stephen Talley <stephen.talley@sun.com>
parents: 154
diff changeset
   566
	return comp;
afcaf3a72d02 4880 sysid: timezone panel grows window, which is then no longer centered
Stephen Talley <stephen.talley@sun.com>
parents: 154
diff changeset
   567
    }
afcaf3a72d02 4880 sysid: timezone panel grows window, which is then no longer centered
Stephen Talley <stephen.talley@sun.com>
parents: 154
diff changeset
   568
afcaf3a72d02 4880 sysid: timezone panel grows window, which is then no longer centered
Stephen Talley <stephen.talley@sun.com>
parents: 154
diff changeset
   569
    /**
0
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   570
     * Gets the {@link ComponentStack} to which {@code Component}s of
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   571
     * descendant {@code SwingControl}s may be added.
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   572
     *
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   573
     * @return	    a {@link ComponentStack}, or {@code null} to defer to
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   574
     *		    {@code SwingControl}s higher in the navigation stack
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   575
     */
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   576
    public ComponentStack getComponentStack() {
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   577
	return stack;
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   578
    }
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   579
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   580
    /**
301
98464369f109 9311 MutableProperties should support PropertyChangeEvents
Stephen Talley <stephen.talley@sun.com>
parents: 298
diff changeset
   581
     * Gets whether property changes to the {@link #setPropertyChangeSource
98464369f109 9311 MutableProperties should support PropertyChangeEvents
Stephen Talley <stephen.talley@sun.com>
parents: 298
diff changeset
   582
     * property change source} are temporarily ignored.
98464369f109 9311 MutableProperties should support PropertyChangeEvents
Stephen Talley <stephen.talley@sun.com>
parents: 298
diff changeset
   583
     *
98464369f109 9311 MutableProperties should support PropertyChangeEvents
Stephen Talley <stephen.talley@sun.com>
parents: 298
diff changeset
   584
     * @see	    #setPropertyChangeIgnore
98464369f109 9311 MutableProperties should support PropertyChangeEvents
Stephen Talley <stephen.talley@sun.com>
parents: 298
diff changeset
   585
     */
98464369f109 9311 MutableProperties should support PropertyChangeEvents
Stephen Talley <stephen.talley@sun.com>
parents: 298
diff changeset
   586
    public boolean getPropertyChangeIgnore() {
98464369f109 9311 MutableProperties should support PropertyChangeEvents
Stephen Talley <stephen.talley@sun.com>
parents: 298
diff changeset
   587
	return ignorePropChange;
98464369f109 9311 MutableProperties should support PropertyChangeEvents
Stephen Talley <stephen.talley@sun.com>
parents: 298
diff changeset
   588
    }
98464369f109 9311 MutableProperties should support PropertyChangeEvents
Stephen Talley <stephen.talley@sun.com>
parents: 298
diff changeset
   589
98464369f109 9311 MutableProperties should support PropertyChangeEvents
Stephen Talley <stephen.talley@sun.com>
parents: 298
diff changeset
   590
    /**
0
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   591
     * Gets a custom message to display in the dialog that prompts the user to
235
38f73435a683 7483 save/prompt functionality in SwingControl can be generalized and moved into Control and DefaultControl
Stephen Talley <stephen.talley@sun.com>
parents: 230
diff changeset
   592
     * {@link #getUnsavedChangesAction handle unsaved changes}.
360
8943c58ad2f5 11508 Control, DefaultControl refactoring
Stephen Talley <stephen.talley@sun.com>
parents: 343
diff changeset
   593
     * <p/>
0
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   594
     * This default implementation returns {@code null}.
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   595
     *
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   596
     * @return	    a {@code String}, or {@code null} to use the default message
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   597
     */
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   598
    protected String getUnsavedChangesMessage() {
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   599
	return null;
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   600
    }
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   601
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   602
    /**
264
d5cd4b2e7426 8029 apache: ui redesign
Stephen Talley <stephen.talley@sun.com>
parents: 263
diff changeset
   603
     * Initializes the {@code Component} for this {@code SwingControl}.  This
d5cd4b2e7426 8029 apache: ui redesign
Stephen Talley <stephen.talley@sun.com>
parents: 263
diff changeset
   604
     * method is called automatically when this {@code Control} is started.
360
8943c58ad2f5 11508 Control, DefaultControl refactoring
Stephen Talley <stephen.talley@sun.com>
parents: 343
diff changeset
   605
     * <p/>
26
8a459d117e4a 2991 Stricter enforcement of UI operations on event thread would help avoid deadlocks
Stephen Talley <stephen.talley@sun.com>
parents: 0
diff changeset
   606
     * This default implementation does nothing.
8a459d117e4a 2991 Stricter enforcement of UI operations on event thread would help avoid deadlocks
Stephen Talley <stephen.talley@sun.com>
parents: 0
diff changeset
   607
     */
80
9256ce8453d7 3497 SwingControl methods are too permissive
Stephen Talley <stephen.talley@sun.com>
parents: 76
diff changeset
   608
    protected void initComponent() {
26
8a459d117e4a 2991 Stricter enforcement of UI operations on event thread would help avoid deadlocks
Stephen Talley <stephen.talley@sun.com>
parents: 0
diff changeset
   609
    }
8a459d117e4a 2991 Stricter enforcement of UI operations on event thread would help avoid deadlocks
Stephen Talley <stephen.talley@sun.com>
parents: 0
diff changeset
   610
8a459d117e4a 2991 Stricter enforcement of UI operations on event thread would help avoid deadlocks
Stephen Talley <stephen.talley@sun.com>
parents: 0
diff changeset
   611
    /**
8a459d117e4a 2991 Stricter enforcement of UI operations on event thread would help avoid deadlocks
Stephen Talley <stephen.talley@sun.com>
parents: 0
diff changeset
   612
     * Calls {@link #initComponent} on the event queue thread and waits until it
264
d5cd4b2e7426 8029 apache: ui redesign
Stephen Talley <stephen.talley@sun.com>
parents: 263
diff changeset
   613
     * has completed.  This method is called automatically when this {@code
d5cd4b2e7426 8029 apache: ui redesign
Stephen Talley <stephen.talley@sun.com>
parents: 263
diff changeset
   614
     * Control} is started.
26
8a459d117e4a 2991 Stricter enforcement of UI operations on event thread would help avoid deadlocks
Stephen Talley <stephen.talley@sun.com>
parents: 0
diff changeset
   615
     */
80
9256ce8453d7 3497 SwingControl methods are too permissive
Stephen Talley <stephen.talley@sun.com>
parents: 76
diff changeset
   616
    protected void initComponentOnEventThread() {
26
8a459d117e4a 2991 Stricter enforcement of UI operations on event thread would help avoid deadlocks
Stephen Talley <stephen.talley@sun.com>
parents: 0
diff changeset
   617
	GUIUtil.invokeAndWait(
8a459d117e4a 2991 Stricter enforcement of UI operations on event thread would help avoid deadlocks
Stephen Talley <stephen.talley@sun.com>
parents: 0
diff changeset
   618
	    new Runnable() {
8a459d117e4a 2991 Stricter enforcement of UI operations on event thread would help avoid deadlocks
Stephen Talley <stephen.talley@sun.com>
parents: 0
diff changeset
   619
		@Override
8a459d117e4a 2991 Stricter enforcement of UI operations on event thread would help avoid deadlocks
Stephen Talley <stephen.talley@sun.com>
parents: 0
diff changeset
   620
		public void run() {
8a459d117e4a 2991 Stricter enforcement of UI operations on event thread would help avoid deadlocks
Stephen Talley <stephen.talley@sun.com>
parents: 0
diff changeset
   621
		    initComponent();
8a459d117e4a 2991 Stricter enforcement of UI operations on event thread would help avoid deadlocks
Stephen Talley <stephen.talley@sun.com>
parents: 0
diff changeset
   622
		}
8a459d117e4a 2991 Stricter enforcement of UI operations on event thread would help avoid deadlocks
Stephen Talley <stephen.talley@sun.com>
parents: 0
diff changeset
   623
	    });
8a459d117e4a 2991 Stricter enforcement of UI operations on event thread would help avoid deadlocks
Stephen Talley <stephen.talley@sun.com>
parents: 0
diff changeset
   624
    }
8a459d117e4a 2991 Stricter enforcement of UI operations on event thread would help avoid deadlocks
Stephen Talley <stephen.talley@sun.com>
parents: 0
diff changeset
   625
244
b6f1fb4f5a89 7624 SwingControl: createComponent implementations should not be required to call setComponent
Stephen Talley <stephen.talley@sun.com>
parents: 235
diff changeset
   626
    /**
b6f1fb4f5a89 7624 SwingControl: createComponent implementations should not be required to call setComponent
Stephen Talley <stephen.talley@sun.com>
parents: 235
diff changeset
   627
     * Gets the {@code Component} for this {@code SwingControl}.
b6f1fb4f5a89 7624 SwingControl: createComponent implementations should not be required to call setComponent
Stephen Talley <stephen.talley@sun.com>
parents: 235
diff changeset
   628
     *
327
bb43a6fa6f0b 10096 time: new UI design and NTP support
Stephen Talley <stephen.talley@sun.com>
parents: 302
diff changeset
   629
     * @param	    comp
244
b6f1fb4f5a89 7624 SwingControl: createComponent implementations should not be required to call setComponent
Stephen Talley <stephen.talley@sun.com>
parents: 235
diff changeset
   630
     *		    a {@code Component}, or {@code null} if this {@code
b6f1fb4f5a89 7624 SwingControl: createComponent implementations should not be required to call setComponent
Stephen Talley <stephen.talley@sun.com>
parents: 235
diff changeset
   631
     *		    SwingControl} has no {@code Component}.
b6f1fb4f5a89 7624 SwingControl: createComponent implementations should not be required to call setComponent
Stephen Talley <stephen.talley@sun.com>
parents: 235
diff changeset
   632
     *
b6f1fb4f5a89 7624 SwingControl: createComponent implementations should not be required to call setComponent
Stephen Talley <stephen.talley@sun.com>
parents: 235
diff changeset
   633
     * @see	    #getComponent
b6f1fb4f5a89 7624 SwingControl: createComponent implementations should not be required to call setComponent
Stephen Talley <stephen.talley@sun.com>
parents: 235
diff changeset
   634
     */
327
bb43a6fa6f0b 10096 time: new UI design and NTP support
Stephen Talley <stephen.talley@sun.com>
parents: 302
diff changeset
   635
    protected void setComponent(C comp) {
bb43a6fa6f0b 10096 time: new UI design and NTP support
Stephen Talley <stephen.talley@sun.com>
parents: 302
diff changeset
   636
	this.comp = comp;
0
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   637
    }
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   638
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   639
    /**
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   640
     * Sets the {@link ComponentStack} to which {@code Component}s of
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   641
     * descendant {@code SwingControl}s may be added.
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   642
     *
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   643
     * @param	    stack
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   644
     *		    a {@link ComponentStack}, or {@code null} to defer to
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   645
     *		    {@code SwingControl}s higher in the navigation stack
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   646
     */
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   647
    protected void setComponentStack(ComponentStack stack) {
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   648
	this.stack = stack;
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   649
    }
298
cc0001e49171 8703 Control subclasses should handle inherited start() method failures
David Powell <David.Powell@sun.com>
parents: 295
diff changeset
   650
cc0001e49171 8703 Control subclasses should handle inherited start() method failures
David Powell <David.Powell@sun.com>
parents: 295
diff changeset
   651
    /**
301
98464369f109 9311 MutableProperties should support PropertyChangeEvents
Stephen Talley <stephen.talley@sun.com>
parents: 298
diff changeset
   652
     * Sets whether property changes to the {@link #setPropertyChangeSource
98464369f109 9311 MutableProperties should support PropertyChangeEvents
Stephen Talley <stephen.talley@sun.com>
parents: 298
diff changeset
   653
     * property change source} are temporarily ignored.
98464369f109 9311 MutableProperties should support PropertyChangeEvents
Stephen Talley <stephen.talley@sun.com>
parents: 298
diff changeset
   654
     *
98464369f109 9311 MutableProperties should support PropertyChangeEvents
Stephen Talley <stephen.talley@sun.com>
parents: 298
diff changeset
   655
     * @see	    #getPropertyChangeIgnore
98464369f109 9311 MutableProperties should support PropertyChangeEvents
Stephen Talley <stephen.talley@sun.com>
parents: 298
diff changeset
   656
     */
98464369f109 9311 MutableProperties should support PropertyChangeEvents
Stephen Talley <stephen.talley@sun.com>
parents: 298
diff changeset
   657
    public void setPropertyChangeIgnore(boolean ignorePropChange) {
98464369f109 9311 MutableProperties should support PropertyChangeEvents
Stephen Talley <stephen.talley@sun.com>
parents: 298
diff changeset
   658
	this.ignorePropChange = ignorePropChange;
98464369f109 9311 MutableProperties should support PropertyChangeEvents
Stephen Talley <stephen.talley@sun.com>
parents: 298
diff changeset
   659
    }
98464369f109 9311 MutableProperties should support PropertyChangeEvents
Stephen Talley <stephen.talley@sun.com>
parents: 298
diff changeset
   660
98464369f109 9311 MutableProperties should support PropertyChangeEvents
Stephen Talley <stephen.talley@sun.com>
parents: 298
diff changeset
   661
    /**
298
cc0001e49171 8703 Control subclasses should handle inherited start() method failures
David Powell <David.Powell@sun.com>
parents: 295
diff changeset
   662
     * Sets a {@link ManagedObject} to which this control should listen
301
98464369f109 9311 MutableProperties should support PropertyChangeEvents
Stephen Talley <stephen.talley@sun.com>
parents: 298
diff changeset
   663
     * for {@code PropertyChangeEvent}s once it is started.  Should not
298
cc0001e49171 8703 Control subclasses should handle inherited start() method failures
David Powell <David.Powell@sun.com>
parents: 295
diff changeset
   664
     * be called while the control is started.
cc0001e49171 8703 Control subclasses should handle inherited start() method failures
David Powell <David.Powell@sun.com>
parents: 295
diff changeset
   665
     *
301
98464369f109 9311 MutableProperties should support PropertyChangeEvents
Stephen Talley <stephen.talley@sun.com>
parents: 298
diff changeset
   666
     * @param	    propSource
98464369f109 9311 MutableProperties should support PropertyChangeEvents
Stephen Talley <stephen.talley@sun.com>
parents: 298
diff changeset
   667
     *		    the {@link ManagedObject} to listen to
98464369f109 9311 MutableProperties should support PropertyChangeEvents
Stephen Talley <stephen.talley@sun.com>
parents: 298
diff changeset
   668
     *
98464369f109 9311 MutableProperties should support PropertyChangeEvents
Stephen Talley <stephen.talley@sun.com>
parents: 298
diff changeset
   669
     * @param	    propNames
98464369f109 9311 MutableProperties should support PropertyChangeEvents
Stephen Talley <stephen.talley@sun.com>
parents: 298
diff changeset
   670
     *		    the names of the properties in which to listen for changes,
98464369f109 9311 MutableProperties should support PropertyChangeEvents
Stephen Talley <stephen.talley@sun.com>
parents: 298
diff changeset
   671
     *		    or an empty array to listen for changes in all properties on
98464369f109 9311 MutableProperties should support PropertyChangeEvents
Stephen Talley <stephen.talley@sun.com>
parents: 298
diff changeset
   672
     *		    {@code propSource}
298
cc0001e49171 8703 Control subclasses should handle inherited start() method failures
David Powell <David.Powell@sun.com>
parents: 295
diff changeset
   673
     */
301
98464369f109 9311 MutableProperties should support PropertyChangeEvents
Stephen Talley <stephen.talley@sun.com>
parents: 298
diff changeset
   674
    protected void setPropertyChangeSource(ManagedObject propSource,
98464369f109 9311 MutableProperties should support PropertyChangeEvents
Stephen Talley <stephen.talley@sun.com>
parents: 298
diff changeset
   675
	String... propNames) {
98464369f109 9311 MutableProperties should support PropertyChangeEvents
Stephen Talley <stephen.talley@sun.com>
parents: 298
diff changeset
   676
98464369f109 9311 MutableProperties should support PropertyChangeEvents
Stephen Talley <stephen.talley@sun.com>
parents: 298
diff changeset
   677
	assert !isStarted();
98464369f109 9311 MutableProperties should support PropertyChangeEvents
Stephen Talley <stephen.talley@sun.com>
parents: 298
diff changeset
   678
	this.propSource = propSource;
98464369f109 9311 MutableProperties should support PropertyChangeEvents
Stephen Talley <stephen.talley@sun.com>
parents: 298
diff changeset
   679
	this.propNames = propNames == null || propNames.length == 0 ? null :
98464369f109 9311 MutableProperties should support PropertyChangeEvents
Stephen Talley <stephen.talley@sun.com>
parents: 298
diff changeset
   680
	    propNames;
298
cc0001e49171 8703 Control subclasses should handle inherited start() method failures
David Powell <David.Powell@sun.com>
parents: 295
diff changeset
   681
    }
0
62ac12e07fc0 Initial integration.
David Powell <David.Powell@sun.com>
parents:
diff changeset
   682
}