components/visual-panels/core/src/java/vpanels/panel/com/oracle/solaris/vp/panel/common/control/NavigationStopEvent.java
changeset 3553 f1d133b09a8c
parent 3552 077ebe3d0d24
child 3554 ef58713bafc4
equal deleted inserted replaced
3552:077ebe3d0d24 3553:f1d133b09a8c
     1 /*
       
     2  * CDDL HEADER START
       
     3  *
       
     4  * The contents of this file are subject to the terms of the
       
     5  * Common Development and Distribution License (the "License").
       
     6  * You may not use this file except in compliance with the License.
       
     7  *
       
     8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
       
     9  * or http://www.opensolaris.org/os/licensing.
       
    10  * See the License for the specific language governing permissions
       
    11  * and limitations under the License.
       
    12  *
       
    13  * When distributing Covered Code, include this CDDL HEADER in each
       
    14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
       
    15  * If applicable, add the following below this CDDL HEADER, with the
       
    16  * fields enclosed by brackets "[]" replaced with your own identifying
       
    17  * information: Portions Copyright [yyyy] [name of copyright owner]
       
    18  *
       
    19  * CDDL HEADER END
       
    20  */
       
    21 
       
    22 /*
       
    23  * Copyright (c) 2009, 2012, Oracle and/or its affiliates. All rights reserved.
       
    24  */
       
    25 
       
    26 package com.oracle.solaris.vp.panel.common.control;
       
    27 
       
    28 import java.util.*;
       
    29 
       
    30 @SuppressWarnings({"serial"})
       
    31 public class NavigationStopEvent extends EventObject {
       
    32     //
       
    33     // Instance data
       
    34     //
       
    35 
       
    36     private Navigable[] last;
       
    37     private List<Control> stopped;
       
    38     private List<Control> started;
       
    39     private NavigationException exception;
       
    40 
       
    41     //
       
    42     // Constructors
       
    43     //
       
    44 
       
    45     /**
       
    46      * Constructs a {@code NavigationStopEvent} for a failed navigation.
       
    47      *
       
    48      * @param	    source
       
    49      *		    the source {@link Navigator}
       
    50      *
       
    51      * @param	    last
       
    52      *		    a {@link Navigable} array that can be used to return to the
       
    53      *		    previously current {@link Navigator#getPath path} (with the
       
    54      *		    first element a {@link Control}, as required by the {@code
       
    55      *		    path} parameter of {@link Navigator#goTo})
       
    56      *
       
    57      * @param	    stopped
       
    58      *		    the {@link Control}s that were {@link #getStopped stopped}
       
    59      *		    during navigation
       
    60      *
       
    61      * @param	    started
       
    62      *		    the {@link Control}s that were {@link #getStarted started}
       
    63      *		    during navigation
       
    64      *
       
    65      * @param	    exception
       
    66      *		    the {@link NavigationException}, if non-{@code null}, that
       
    67      *		    caused the navigation to fail
       
    68      */
       
    69     public NavigationStopEvent(Navigator source, Navigable[] last,
       
    70 	List<Control> stopped, List<Control> started, NavigationException
       
    71 	exception) {
       
    72 
       
    73 	super(source);
       
    74 	this.last = last;
       
    75 	this.stopped = stopped;
       
    76 	this.started = started;
       
    77 	this.exception = exception;
       
    78     }
       
    79 
       
    80     /**
       
    81      * Constructs a {@code NavigationStopEvent} for a successful navigation.
       
    82      *
       
    83      * @param	    source
       
    84      *		    the source {@link Navigator}
       
    85      *
       
    86      * @param	    stopped
       
    87      *		    the {@link Control}s that were {@link #getStopped stopped}
       
    88      *		    during navigation
       
    89      *
       
    90      * @param	    started
       
    91      *		    the {@link Control}s that were {@link #getStarted started}
       
    92      *		    during navigation
       
    93      */
       
    94     public NavigationStopEvent(Navigator source, Navigable[] last,
       
    95 	List<Control> stopped, List<Control> started) {
       
    96 
       
    97 	this(source, last, stopped, started, null);
       
    98     }
       
    99 
       
   100     //
       
   101     // EventObject methods
       
   102     //
       
   103 
       
   104     @Override
       
   105     public Navigator getSource() {
       
   106 	return (Navigator)super.getSource();
       
   107     }
       
   108 
       
   109     //
       
   110     // NavigationStopEvent methods
       
   111     //
       
   112 
       
   113     /**
       
   114      * Gets the {@link NavigationException}, if any, that caused the navigation
       
   115      * to fail.
       
   116      *
       
   117      * @return	    a {@link NavigationException}, or {@code null} if the
       
   118      *		    navigation completed successfully
       
   119      */
       
   120     public NavigationException getNavigationException() {
       
   121 	return exception;
       
   122     }
       
   123 
       
   124     /**
       
   125      * Indicates whether the navigation succeeded, based on whether this {@code
       
   126      * NavigationStopEvent}'s {@link #getNavigationException
       
   127      * NavigationException} is {@code null}.
       
   128      */
       
   129     public boolean getNavigationSuccessful() {
       
   130 	return exception == null;
       
   131     }
       
   132 
       
   133     /**
       
   134      * Gets the {@link Navigable} array that can be used to return to the
       
   135      * previously current {@link Navigator#getPath path} (with the first element
       
   136      * a {@link Control}, as required by the {@code path} parameter of {@link
       
   137      * Navigator#goTo}).
       
   138      */
       
   139     public Navigable[] getPreviousPath() {
       
   140 	return last;
       
   141     }
       
   142 
       
   143     /**
       
   144      * Gets the {@code Control}s that were started, in the order that they were
       
   145      * started, as part of the navigation.
       
   146      */
       
   147     public List<Control> getStarted() {
       
   148 	return started;
       
   149     }
       
   150 
       
   151     /**
       
   152      * Gets the {@code Control}s that were stopped, in the order that they were
       
   153      * stopped, as part of the navigation.
       
   154      */
       
   155     public List<Control> getStopped() {
       
   156 	return stopped;
       
   157     }
       
   158 }