Added
Link Here
|
1 |
/* |
2 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER. |
3 |
* |
4 |
* Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved. |
5 |
* |
6 |
* The contents of this file are subject to the terms of either the GNU |
7 |
* General Public License Version 2 only ("GPL") or the Common |
8 |
* Development and Distribution License("CDDL") (collectively, the |
9 |
* "License"). You may not use this file except in compliance with the |
10 |
* License. You can obtain a copy of the License at |
11 |
* http://www.netbeans.org/cddl-gplv2.html |
12 |
* or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the |
13 |
* specific language governing permissions and limitations under the |
14 |
* License. When distributing the software, include this License Header |
15 |
* Notice in each file and include the License file at |
16 |
* nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this |
17 |
* particular file as subject to the "Classpath" exception as provided |
18 |
* by Sun in the GPL Version 2 section of the License file that |
19 |
* accompanied this code. If applicable, add the following below the |
20 |
* License Header, with the fields enclosed by brackets [] replaced by |
21 |
* your own identifying information: |
22 |
* "Portions Copyrighted [year] [name of copyright owner]" |
23 |
* |
24 |
* Contributor(s): |
25 |
* |
26 |
* The Original Software is NetBeans. The Initial Developer of the Original |
27 |
* Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun |
28 |
* Microsystems, Inc. All Rights Reserved. |
29 |
* |
30 |
* If you wish your version of this file to be governed by only the CDDL |
31 |
* or only the GPL Version 2, indicate your decision by adding |
32 |
* "[Contributor] elects to include this software in this distribution |
33 |
* under the [CDDL or GPL Version 2] license." If you do not indicate a |
34 |
* single choice of license, a recipient has the option to distribute |
35 |
* your version of this file under either the CDDL, the GPL Version 2 or |
36 |
* to extend the choice of license to its licensees as provided above. |
37 |
* However, if you add GPL Version 2 code and therefore, elected the GPL |
38 |
* Version 2 license, then the option applies only if the new code is |
39 |
* made subject to such option by the copyright holder. |
40 |
*/ |
41 |
package org.netbeans.api.visual.action; |
42 |
|
43 |
import org.netbeans.api.visual.widget.Widget; |
44 |
|
45 |
import java.awt.*; |
46 |
|
47 |
/** |
48 |
* Represents an event for ContiguousSelectEvent passed to ContiguousSelectProvider. Contains information about selection-type, previously and currently choosen objects spots. |
49 |
* |
50 |
* @author David Kaspar |
51 |
* @since |
52 |
*/ |
53 |
public final class ContiguousSelectEvent { |
54 |
|
55 |
private final Widget previouslyChoosenWidget; |
56 |
private final Point previouslyChoosenLocalLocation; |
57 |
|
58 |
private final Widget choosenWidget; |
59 |
private final Point choosenLocalLocation; |
60 |
|
61 |
private final SelectionType selectionType; |
62 |
|
63 |
private ContiguousSelectEvent (Widget previouslyChoosenWidget, Point previouslyChoosenLocalLocation, Widget choosenWidget, Point choosenLocalLocation, SelectionType selectionType) { |
64 |
this.previouslyChoosenWidget = previouslyChoosenWidget; |
65 |
this.previouslyChoosenLocalLocation = previouslyChoosenLocalLocation; |
66 |
this.choosenWidget = choosenWidget; |
67 |
this.choosenLocalLocation = choosenLocalLocation; |
68 |
this.selectionType = selectionType; |
69 |
} |
70 |
|
71 |
/** |
72 |
* Returns a previously choosen widget. |
73 |
* @return the previously choosen widget |
74 |
*/ |
75 |
public Widget getPreviouslyChoosenWidget () { |
76 |
return previouslyChoosenWidget; |
77 |
} |
78 |
|
79 |
/** |
80 |
* Returns a local location of a previously choosen widget. |
81 |
* @return the local location of the previously choosen widget |
82 |
*/ |
83 |
public Point getPreviouslyChoosenLocalLocation () { |
84 |
return previouslyChoosenLocalLocation != null ? new Point (previouslyChoosenLocalLocation) : null; |
85 |
} |
86 |
|
87 |
/** |
88 |
* Returns a choosen widget. |
89 |
* @return the choosen widget |
90 |
*/ |
91 |
public Widget getChoosenWidget () { |
92 |
return choosenWidget; |
93 |
} |
94 |
|
95 |
/** |
96 |
* Returns a local location of a choosen widget. |
97 |
* @return the local location of the choosen widget |
98 |
*/ |
99 |
public Point getChoosenLocalLocation () { |
100 |
return choosenLocalLocation != null ? new Point (choosenLocalLocation) : null; |
101 |
} |
102 |
|
103 |
/** |
104 |
* Represents a selection type. |
105 |
* @return the selection type |
106 |
*/ |
107 |
public SelectionType getSelectionType () { |
108 |
return selectionType; |
109 |
} |
110 |
|
111 |
/** |
112 |
* Creates an event. Meant to be used by the library only. |
113 |
* @param previousWidget the previously choosen widget |
114 |
* @param previousLocalLocation the local location of the previously choosen widget |
115 |
* @param choosenWidget the choosen widget |
116 |
* @param choosenLocalLocation the local location of the currently choosen widget |
117 |
* @param selectionType the selection type invoked by an user |
118 |
* @return the contiguous select event |
119 |
*/ |
120 |
public static ContiguousSelectEvent create (Widget previousWidget, Point previousLocalLocation, Widget choosenWidget, Point choosenLocalLocation, SelectionType selectionType) { |
121 |
assert selectionType != null; |
122 |
return new ContiguousSelectEvent (previousWidget, previousLocalLocation, choosenWidget, choosenLocalLocation, selectionType); |
123 |
} |
124 |
|
125 |
/** |
126 |
* Defines a type of a selection. |
127 |
*/ |
128 |
public enum SelectionType { |
129 |
|
130 |
/** |
131 |
* Represents a normal selection that replace the previous selection. |
132 |
* Usually invokes without any key-modifier. |
133 |
*/ |
134 |
REPLACE_NON_CONTIGUOUS, |
135 |
|
136 |
/** |
137 |
* Represents a normal selection that replace the previous selection. |
138 |
* All objects that are between previously and current choosen spots defines the current selection. |
139 |
* Usually invokes with Shift key-modifier. |
140 |
*/ |
141 |
REPLACE_CONTIGUOUS, |
142 |
|
143 |
/** |
144 |
* Represents an additive selection where the new selection should be added to the current selection. |
145 |
* Usually invokes with Ctrl key-modifier. |
146 |
*/ |
147 |
ADDITIVE_NON_CONTIGUOUS, |
148 |
|
149 |
/** |
150 |
* Represents an additive selection where the new selection should be added to the current selection. |
151 |
* All objects that are between previously and current choosen spots defines the current selection. |
152 |
* Usually invokes with Ctrl and Shift key-modifiers. |
153 |
*/ |
154 |
ADDITIVE_CONTIGUOUS, |
155 |
|
156 |
} |
157 |
|
158 |
} |