1
|
/*******************************************************************************
|
2
|
* Copyright (c) 2003, 2008 IBM Corporation and others.
|
3
|
* All rights reserved. This program and the accompanying materials
|
4
|
* are made available under the terms of the Eclipse Public License v1.0
|
5
|
* which accompanies this distribution, and is available at
|
6
|
* http://www.eclipse.org/legal/epl-v10.html
|
7
|
*
|
8
|
* Contributors:
|
9
|
* IBM Corporation - initial API and implementation
|
10
|
*******************************************************************************/
|
11
|
package org.eclipse.ui.navigator;
|
12
|
|
13
|
/**
|
14
|
* <p>
|
15
|
* Enumeration of the OverridePolicy values supported by the Common Navigator.
|
16
|
* </p>
|
17
|
*
|
18
|
* @since 3.4
|
19
|
*/
|
20
|
public final class OverridePolicy {
|
21
|
|
22
|
/**
|
23
|
* Indicates InvokeOnlyIfSuppressedExtAlsoVisibleAndActive OverridePolicy as
|
24
|
* an int.
|
25
|
*/
|
26
|
public static final int InvokeOnlyIfSuppressedExtAlsoVisibleAndActive_VALUE = -1;
|
27
|
|
28
|
/**
|
29
|
* Indicates InvokeAlwaysRegardlessOfSuppressedExt OverridePolicy as an int.
|
30
|
*/
|
31
|
public static final int InvokeAlwaysRegardlessOfSuppressedExt_VALUE = 1;
|
32
|
|
33
|
/**
|
34
|
* Indicates InvokeOnlyIfSuppressedExtAlsoVisibleAndActive OverridePolicy as
|
35
|
* a String.
|
36
|
*/
|
37
|
public static final String InvokeOnlyIfSuppressedExtAlsoVisibleAndActive_LITERAL = "InvokeOnlyIfSuppressedExtAlsoVisibleAndActive"; //$NON-NLS-1$
|
38
|
|
39
|
/**
|
40
|
* Indicates InvokeAlwaysRegardlessOfSuppressedExt OverridePolicy as a
|
41
|
* String.
|
42
|
*/
|
43
|
public static final String InvokeAlwaysRegardlessOfSuppressedExt_LITERAL = "InvokeAlwaysRegardlessOfSuppressedExt"; //$NON-NLS-1$
|
44
|
|
45
|
/**
|
46
|
* Indicates InvokeOnlyIfSuppressedExtAlsoVisibleAndActive OverridePolicy as
|
47
|
* a OverridePolicy enumeration.
|
48
|
*/
|
49
|
public static final OverridePolicy InvokeOnlyIfSuppressedExtAlsoVisibleAndActive = new OverridePolicy(
|
50
|
InvokeOnlyIfSuppressedExtAlsoVisibleAndActive_VALUE,
|
51
|
InvokeOnlyIfSuppressedExtAlsoVisibleAndActive_LITERAL);
|
52
|
|
53
|
/**
|
54
|
* Indicates InvokeAlwaysRegardlessOfSuppressedExt OverridePolicy as a
|
55
|
* OverridePolicy enumeration.
|
56
|
*/
|
57
|
public static final OverridePolicy InvokeAlwaysRegardlessOfSuppressedExt = new OverridePolicy(
|
58
|
InvokeAlwaysRegardlessOfSuppressedExt_VALUE,
|
59
|
InvokeAlwaysRegardlessOfSuppressedExt_LITERAL);
|
60
|
|
61
|
/**
|
62
|
* The ordered array of possible enumeration values.
|
63
|
*/
|
64
|
public static final OverridePolicy[] ENUM_ARRAY = new OverridePolicy[] {
|
65
|
InvokeOnlyIfSuppressedExtAlsoVisibleAndActive,
|
66
|
InvokeAlwaysRegardlessOfSuppressedExt };
|
67
|
|
68
|
/**
|
69
|
*
|
70
|
* Returns the correct instance of the OverridePolicy ENUM for aLiteral.
|
71
|
*
|
72
|
* <p>
|
73
|
* This method will return InvokeAlwaysRegardlessOfSuppressedExt if the
|
74
|
* supplied value of aLiteral is invalid.
|
75
|
* </p>
|
76
|
*
|
77
|
* @param aLiteral
|
78
|
* One of the defined *_LITERAL constants of this class
|
79
|
* @return The corresponding OverridePolicy Enum or
|
80
|
* InvokeAlwaysRegardlessOfSuppressedExt if aLiteral is invalid
|
81
|
*/
|
82
|
public static OverridePolicy get(String aLiteral) {
|
83
|
for (int i = 0; i < ENUM_ARRAY.length; i++) {
|
84
|
if (ENUM_ARRAY[i].getLiteral().equals(aLiteral)) {
|
85
|
return ENUM_ARRAY[i];
|
86
|
}
|
87
|
}
|
88
|
return InvokeAlwaysRegardlessOfSuppressedExt;
|
89
|
}
|
90
|
|
91
|
/**
|
92
|
*
|
93
|
* Returns the correct instance of the OverridePolicy ENUM for aValue.
|
94
|
*
|
95
|
* <p>
|
96
|
* This method will return InvokeAlwaysRegardlessOfSuppressedExt if the
|
97
|
* supplied value of aValue is invalid.
|
98
|
* </p>
|
99
|
*
|
100
|
* @param aValue
|
101
|
* One of the defined *_VALUE constants of this class
|
102
|
* @return The corresponding OverridePolicy Enum or
|
103
|
* InvokeAlwaysRegardlessOfSuppressedExt if aValue is invalid
|
104
|
*/
|
105
|
public static OverridePolicy get(int aValue) {
|
106
|
|
107
|
switch (aValue) {
|
108
|
case InvokeOnlyIfSuppressedExtAlsoVisibleAndActive_VALUE:
|
109
|
return InvokeOnlyIfSuppressedExtAlsoVisibleAndActive;
|
110
|
case InvokeAlwaysRegardlessOfSuppressedExt_VALUE:
|
111
|
default:
|
112
|
return InvokeAlwaysRegardlessOfSuppressedExt;
|
113
|
|
114
|
}
|
115
|
}
|
116
|
|
117
|
private final int value;
|
118
|
|
119
|
private final String literal;
|
120
|
|
121
|
protected OverridePolicy(int aValue, String aLiteral) {
|
122
|
value = aValue;
|
123
|
literal = aLiteral;
|
124
|
}
|
125
|
|
126
|
/**
|
127
|
*
|
128
|
* @return The literal string for this specific OverridePolicy.
|
129
|
*/
|
130
|
public String getLiteral() {
|
131
|
return literal;
|
132
|
}
|
133
|
|
134
|
/**
|
135
|
*
|
136
|
* @return The integer value for this specific OverridePolicy.
|
137
|
*/
|
138
|
public int getValue() {
|
139
|
return value;
|
140
|
}
|
141
|
}
|