File Source: PasteDialogFocusTraversalPolicy.java
/*
P/P * Method: com.dmdirc.addons.ui_swing.dialogs.paste.PasteDialogFocusTraversalPolicy__static_init
*/
1 /*
2 * Copyright (c) 2006-2009 Chris Smith, Shane Mc Cormack, Gregory Holmes
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a copy
5 * of this software and associated documentation files (the "Software"), to deal
6 * in the Software without restriction, including without limitation the rights
7 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8 * copies of the Software, and to permit persons to whom the Software is
9 * furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice shall be included in
12 * all copies or substantial portions of the Software.
13 *
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20 * SOFTWARE.
21 */
22
23 package com.dmdirc.addons.ui_swing.dialogs.paste;
24
25 import java.awt.Component;
26 import java.awt.Container;
27 import java.awt.FocusTraversalPolicy;
28
29 import javax.swing.JButton;
30
31 /**
32 * Focus traversal policy for the paste dialog.
33 */
34 public final class PasteDialogFocusTraversalPolicy extends FocusTraversalPolicy {
35
36 /** Cancel button. */
37 private final JButton cancelButton;
38 /** Edit button. */
39 private final JButton editButton;
40 /** Send button. */
41 private final JButton sendButton;
42
43 /**
44 * Creates a new instance of PasteDialogFocusTraversalPolicy.
45 *
46 * @param cancelButton Cancel button
47 * @param editButton Edit button
48 * @param sendButton Send button
49 */
50 public PasteDialogFocusTraversalPolicy(final JButton cancelButton,
51 final JButton editButton, final JButton sendButton) {
/*
P/P * Method: void com.dmdirc.addons.ui_swing.dialogs.paste.PasteDialogFocusTraversalPolicy(JButton, JButton, JButton)
*
* Postconditions:
* this.cancelButton == cancelButton
* init'ed(this.cancelButton)
* this.editButton == editButton
* init'ed(this.editButton)
* this.sendButton == sendButton
* init'ed(this.sendButton)
*/
52 super();
53
54 this.cancelButton = cancelButton;
55 this.editButton = editButton;
56 this.sendButton = sendButton;
57 }
58
59 /** {@inheritDoc} */
60 public Component getComponentAfter(final Container aContainer,
61 final Component aComponent) {
/*
P/P * Method: Component getComponentAfter(Container, Component)
*
* Preconditions:
* aComponent != null
*
* Postconditions:
* return_value == One-of{this.editButton, this.sendButton, this.cancelButton}
* init'ed(return_value)
*
* Test Vectors:
* java.lang.Object:equals(...)@62: {0}, {1}
* java.lang.Object:equals(...)@64: {0}, {1}
* java.lang.Object:equals(...)@66: {0}, {1}
*/
62 if (aComponent.equals(cancelButton)) {
63 return editButton;
64 } else if (aComponent.equals(editButton)) {
65 return sendButton;
66 } else if (aComponent.equals(sendButton)) {
67 return cancelButton;
68 } else {
69 return cancelButton;
70 }
71 }
72
73 /** {@inheritDoc} */
74 public Component getComponentBefore(final Container aContainer,
75 final Component aComponent) {
/*
P/P * Method: Component getComponentBefore(Container, Component)
*
* Preconditions:
* aComponent != null
*
* Postconditions:
* return_value == One-of{this.sendButton, this.cancelButton, this.editButton}
* init'ed(return_value)
*
* Test Vectors:
* java.lang.Object:equals(...)@76: {0}, {1}
* java.lang.Object:equals(...)@78: {0}, {1}
* java.lang.Object:equals(...)@80: {0}, {1}
*/
76 if (aComponent.equals(cancelButton)) {
77 return sendButton;
78 } else if (aComponent.equals(editButton)) {
79 return cancelButton;
80 } else if (aComponent.equals(sendButton)) {
81 return editButton;
82 } else {
83 return sendButton;
84 }
85 }
86
87 /** {@inheritDoc} */
88 public Component getFirstComponent(final Container aContainer) {
/*
P/P * Method: Component getFirstComponent(Container)
*
* Postconditions:
* return_value == this.cancelButton
* init'ed(return_value)
*/
89 return cancelButton;
90 }
91
92 /** {@inheritDoc} */
93 public Component getLastComponent(final Container aContainer) {
/*
P/P * Method: Component getLastComponent(Container)
*
* Postconditions:
* return_value == this.sendButton
* init'ed(return_value)
*/
94 return sendButton;
95 }
96
97 /** {@inheritDoc} */
98 public Component getDefaultComponent(final Container aContainer) {
/*
P/P * Method: Component getDefaultComponent(Container)
*
* Postconditions:
* return_value == this.sendButton
* init'ed(return_value)
*/
99 return sendButton;
100 }
101
102 }
SofCheck Inspector Build Version : 2.17854
| PasteDialogFocusTraversalPolicy.java |
2009-Jun-25 01:54:24 |
| PasteDialogFocusTraversalPolicy.class |
2009-Sep-02 17:04:16 |