|
Lines 27-32
Link Here
|
| 27 |
import org.eclipse.ui.contexts.IContextService; |
27 |
import org.eclipse.ui.contexts.IContextService; |
| 28 |
import org.eclipse.ui.internal.Workbench; |
28 |
import org.eclipse.ui.internal.Workbench; |
| 29 |
import org.eclipse.ui.internal.WorkbenchWindow; |
29 |
import org.eclipse.ui.internal.WorkbenchWindow; |
|
|
30 |
import org.eclipse.ui.internal.contexts.ContextService; |
| 30 |
|
31 |
|
| 31 |
/** |
32 |
/** |
| 32 |
* A provider of notifications for when the active shell changes. |
33 |
* A provider of notifications for when the active shell changes. |
|
Lines 63-69
Link Here
|
| 63 |
* <code>null</code>. |
64 |
* <code>null</code>. |
| 64 |
*/ |
65 |
*/ |
| 65 |
private Shell lastActiveWorkbenchWindowShell = null; |
66 |
private Shell lastActiveWorkbenchWindowShell = null; |
| 66 |
|
67 |
|
| 67 |
/** |
68 |
/** |
| 68 |
* The last workbench window seen as active by this provider. This value may |
69 |
* The last workbench window seen as active by this provider. This value may |
| 69 |
* be null if the last call to |
70 |
* be null if the last call to |
|
Lines 81-87
Link Here
|
| 81 |
* @since 3.3 |
82 |
* @since 3.3 |
| 82 |
*/ |
83 |
*/ |
| 83 |
private Boolean lastCoolbarVisibility = Boolean.FALSE; |
84 |
private Boolean lastCoolbarVisibility = Boolean.FALSE; |
| 84 |
|
85 |
|
| 85 |
/** |
86 |
/** |
| 86 |
* The result of the last visibility check on the perspective bar of the |
87 |
* The result of the last visibility check on the perspective bar of the |
| 87 |
* last active workbench window. |
88 |
* last active workbench window. |
|
Lines 89-95
Link Here
|
| 89 |
* @since 3.3 |
90 |
* @since 3.3 |
| 90 |
*/ |
91 |
*/ |
| 91 |
private Boolean lastPerspectiveBarVisibility = Boolean.FALSE; |
92 |
private Boolean lastPerspectiveBarVisibility = Boolean.FALSE; |
| 92 |
|
93 |
|
| 93 |
/** |
94 |
/** |
| 94 |
* The listener to individual window properties. |
95 |
* The listener to individual window properties. |
| 95 |
* |
96 |
* |
|
Lines 110-117
Link Here
|
| 110 |
newValue); |
111 |
newValue); |
| 111 |
lastCoolbarVisibility = (Boolean) newValue; |
112 |
lastCoolbarVisibility = (Boolean) newValue; |
| 112 |
} |
113 |
} |
| 113 |
} |
114 |
} else if (WorkbenchWindow.PROP_PERSPECTIVEBAR_VISIBLE.equals(event |
| 114 |
else if (WorkbenchWindow.PROP_PERSPECTIVEBAR_VISIBLE.equals(event |
|
|
| 115 |
.getProperty())) { |
115 |
.getProperty())) { |
| 116 |
Object newValue = event.getNewValue(); |
116 |
Object newValue = event.getNewValue(); |
| 117 |
if (newValue == null || !(newValue instanceof Boolean)) |
117 |
if (newValue == null || !(newValue instanceof Boolean)) |
|
Lines 125-133
Link Here
|
| 125 |
} |
125 |
} |
| 126 |
} |
126 |
} |
| 127 |
} |
127 |
} |
| 128 |
|
128 |
|
| 129 |
}; |
129 |
}; |
| 130 |
|
130 |
|
| 131 |
/** |
131 |
/** |
| 132 |
* The listener to shell activations on the display. |
132 |
* The listener to shell activations on the display. |
| 133 |
*/ |
133 |
*/ |
|
Lines 142-148
Link Here
|
| 142 |
} |
142 |
} |
| 143 |
return; |
143 |
return; |
| 144 |
} |
144 |
} |
| 145 |
|
145 |
|
| 146 |
if (DEBUG) { |
146 |
if (DEBUG) { |
| 147 |
logDebuggingInfo("\tASSP:lastActiveShell: " + lastActiveShell); //$NON-NLS-1$ |
147 |
logDebuggingInfo("\tASSP:lastActiveShell: " + lastActiveShell); //$NON-NLS-1$ |
| 148 |
logDebuggingInfo("\tASSP:lastActiveWorkbenchWindowShell" + lastActiveWorkbenchWindowShell); //$NON-NLS-1$ |
148 |
logDebuggingInfo("\tASSP:lastActiveWorkbenchWindowShell" + lastActiveWorkbenchWindowShell); //$NON-NLS-1$ |
|
Lines 155-161
Link Here
|
| 155 |
.get(ISources.ACTIVE_WORKBENCH_WINDOW_NAME); |
155 |
.get(ISources.ACTIVE_WORKBENCH_WINDOW_NAME); |
| 156 |
final Shell newActiveWorkbenchWindowShell = (Shell) currentState |
156 |
final Shell newActiveWorkbenchWindowShell = (Shell) currentState |
| 157 |
.get(ISources.ACTIVE_WORKBENCH_WINDOW_SHELL_NAME); |
157 |
.get(ISources.ACTIVE_WORKBENCH_WINDOW_SHELL_NAME); |
| 158 |
|
158 |
|
| 159 |
// dont update the coolbar/perspective bar visibility unless we're |
159 |
// dont update the coolbar/perspective bar visibility unless we're |
| 160 |
// processing a workbench window change |
160 |
// processing a workbench window change |
| 161 |
final Boolean newCoolbarVisibility = newActiveWorkbenchWindow == null ? lastCoolbarVisibility |
161 |
final Boolean newCoolbarVisibility = newActiveWorkbenchWindow == null ? lastCoolbarVisibility |
|
Lines 180-195
Link Here
|
| 180 |
sourceValuesByName.put( |
180 |
sourceValuesByName.put( |
| 181 |
ISources.ACTIVE_WORKBENCH_WINDOW_SHELL_NAME, |
181 |
ISources.ACTIVE_WORKBENCH_WINDOW_SHELL_NAME, |
| 182 |
newActiveWorkbenchWindowShell); |
182 |
newActiveWorkbenchWindowShell); |
| 183 |
int sourceFlags = ISources.ACTIVE_SHELL | ISources.ACTIVE_WORKBENCH_WINDOW; |
183 |
int sourceFlags = ISources.ACTIVE_SHELL |
| 184 |
|
184 |
| ISources.ACTIVE_WORKBENCH_WINDOW; |
|
|
185 |
|
| 185 |
if (coolbarChanged) { |
186 |
if (coolbarChanged) { |
| 186 |
sourceValuesByName.put(ISources.ACTIVE_WORKBENCH_WINDOW_IS_COOLBAR_VISIBLE_NAME, |
187 |
sourceValuesByName |
| 187 |
newCoolbarVisibility); |
188 |
.put( |
|
|
189 |
ISources.ACTIVE_WORKBENCH_WINDOW_IS_COOLBAR_VISIBLE_NAME, |
| 190 |
newCoolbarVisibility); |
| 188 |
sourceFlags |= ISources.ACTIVE_WORKBENCH_WINDOW_SUBORDINATE; |
191 |
sourceFlags |= ISources.ACTIVE_WORKBENCH_WINDOW_SUBORDINATE; |
| 189 |
} |
192 |
} |
| 190 |
if (perspectiveBarChanged) { |
193 |
if (perspectiveBarChanged) { |
| 191 |
sourceValuesByName.put(ISources.ACTIVE_WORKBENCH_WINDOW_IS_PERSPECTIVEBAR_VISIBLE_NAME, |
194 |
sourceValuesByName |
| 192 |
newPerspectiveBarVisibility); |
195 |
.put( |
|
|
196 |
ISources.ACTIVE_WORKBENCH_WINDOW_IS_PERSPECTIVEBAR_VISIBLE_NAME, |
| 197 |
newPerspectiveBarVisibility); |
| 193 |
sourceFlags |= ISources.ACTIVE_WORKBENCH_WINDOW_SUBORDINATE; |
198 |
sourceFlags |= ISources.ACTIVE_WORKBENCH_WINDOW_SUBORDINATE; |
| 194 |
} |
199 |
} |
| 195 |
|
200 |
|
|
Lines 205-213
Link Here
|
| 205 |
logDebuggingInfo("Active workbench window perspective bar visibility " //$NON-NLS-1$ |
210 |
logDebuggingInfo("Active workbench window perspective bar visibility " //$NON-NLS-1$ |
| 206 |
+ newPerspectiveBarVisibility); |
211 |
+ newPerspectiveBarVisibility); |
| 207 |
} |
212 |
} |
| 208 |
|
213 |
|
| 209 |
fireSourceChanged(sourceFlags, sourceValuesByName); |
214 |
fireSourceChanged(sourceFlags, sourceValuesByName); |
| 210 |
hookListener(lastActiveWorkbenchWindow, newActiveWorkbenchWindow); |
215 |
hookListener(lastActiveWorkbenchWindow, |
|
|
216 |
newActiveWorkbenchWindow); |
| 211 |
|
217 |
|
| 212 |
} else if (shellChanged) { |
218 |
} else if (shellChanged) { |
| 213 |
if (DEBUG) { |
219 |
if (DEBUG) { |
|
Lines 224-243
Link Here
|
| 224 |
sourceValuesByName.put( |
230 |
sourceValuesByName.put( |
| 225 |
ISources.ACTIVE_WORKBENCH_WINDOW_SHELL_NAME, |
231 |
ISources.ACTIVE_WORKBENCH_WINDOW_SHELL_NAME, |
| 226 |
newActiveWorkbenchWindowShell); |
232 |
newActiveWorkbenchWindowShell); |
| 227 |
|
233 |
|
| 228 |
int sourceFlags = ISources.ACTIVE_SHELL | ISources.ACTIVE_WORKBENCH_WINDOW; |
234 |
int sourceFlags = ISources.ACTIVE_SHELL |
| 229 |
|
235 |
| ISources.ACTIVE_WORKBENCH_WINDOW; |
|
|
236 |
|
| 230 |
if (coolbarChanged) { |
237 |
if (coolbarChanged) { |
| 231 |
sourceValuesByName.put(ISources.ACTIVE_WORKBENCH_WINDOW_IS_COOLBAR_VISIBLE_NAME, |
238 |
sourceValuesByName |
| 232 |
newCoolbarVisibility); |
239 |
.put( |
|
|
240 |
ISources.ACTIVE_WORKBENCH_WINDOW_IS_COOLBAR_VISIBLE_NAME, |
| 241 |
newCoolbarVisibility); |
| 233 |
sourceFlags |= ISources.ACTIVE_WORKBENCH_WINDOW_SUBORDINATE; |
242 |
sourceFlags |= ISources.ACTIVE_WORKBENCH_WINDOW_SUBORDINATE; |
| 234 |
} |
243 |
} |
| 235 |
if (perspectiveBarChanged) { |
244 |
if (perspectiveBarChanged) { |
| 236 |
sourceValuesByName.put(ISources.ACTIVE_WORKBENCH_WINDOW_IS_PERSPECTIVEBAR_VISIBLE_NAME, |
245 |
sourceValuesByName |
| 237 |
newPerspectiveBarVisibility); |
246 |
.put( |
|
|
247 |
ISources.ACTIVE_WORKBENCH_WINDOW_IS_PERSPECTIVEBAR_VISIBLE_NAME, |
| 248 |
newPerspectiveBarVisibility); |
| 238 |
sourceFlags |= ISources.ACTIVE_WORKBENCH_WINDOW_SUBORDINATE; |
249 |
sourceFlags |= ISources.ACTIVE_WORKBENCH_WINDOW_SUBORDINATE; |
| 239 |
} |
250 |
} |
| 240 |
|
251 |
|
| 241 |
if (DEBUG) { |
252 |
if (DEBUG) { |
| 242 |
logDebuggingInfo("Active workbench window changed to " //$NON-NLS-1$ |
253 |
logDebuggingInfo("Active workbench window changed to " //$NON-NLS-1$ |
| 243 |
+ newActiveWorkbenchWindow); |
254 |
+ newActiveWorkbenchWindow); |
|
Lines 249-257
Link Here
|
| 249 |
+ newPerspectiveBarVisibility); |
260 |
+ newPerspectiveBarVisibility); |
| 250 |
} |
261 |
} |
| 251 |
|
262 |
|
| 252 |
fireSourceChanged(sourceFlags, |
263 |
fireSourceChanged(sourceFlags, sourceValuesByName); |
| 253 |
sourceValuesByName); |
264 |
hookListener(lastActiveWorkbenchWindow, |
| 254 |
hookListener(lastActiveWorkbenchWindow, newActiveWorkbenchWindow); |
265 |
newActiveWorkbenchWindow); |
| 255 |
} |
266 |
} |
| 256 |
|
267 |
|
| 257 |
// Update the member variables. |
268 |
// Update the member variables. |
|
Lines 297-308
Link Here
|
| 297 |
|
308 |
|
| 298 |
/* |
309 |
/* |
| 299 |
* We will fallback to the workbench window, but only if a dialog is not |
310 |
* We will fallback to the workbench window, but only if a dialog is not |
| 300 |
* open. |
311 |
* open or it's not a specially registered TYPE_DIALOG_WITH_WORKBENCH. |
| 301 |
*/ |
312 |
*/ |
| 302 |
final IContextService contextService = (IContextService) workbench |
313 |
final IContextService contextService = (IContextService) workbench |
| 303 |
.getService(IContextService.class); |
314 |
.getService(IContextService.class); |
|
|
315 |
boolean dialogSupportsWorkbench = false; |
| 316 |
if (contextService instanceof ContextService) { |
| 317 |
dialogSupportsWorkbench = ((ContextService) contextService) |
| 318 |
.dialogSupportsWorkbench(newActiveShell); |
| 319 |
} |
| 304 |
final int shellType = contextService.getShellType(newActiveShell); |
320 |
final int shellType = contextService.getShellType(newActiveShell); |
| 305 |
if (shellType != IContextService.TYPE_DIALOG) { |
321 |
if (shellType != IContextService.TYPE_DIALOG || dialogSupportsWorkbench) { |
| 306 |
final IWorkbenchWindow newActiveWorkbenchWindow = workbench |
322 |
final IWorkbenchWindow newActiveWorkbenchWindow = workbench |
| 307 |
.getActiveWorkbenchWindow(); |
323 |
.getActiveWorkbenchWindow(); |
| 308 |
final Shell newActiveWorkbenchWindowShell; |
324 |
final Shell newActiveWorkbenchWindowShell; |
|
Lines 324-336
Link Here
|
| 324 |
public final String[] getProvidedSourceNames() { |
340 |
public final String[] getProvidedSourceNames() { |
| 325 |
return PROVIDED_SOURCE_NAMES; |
341 |
return PROVIDED_SOURCE_NAMES; |
| 326 |
} |
342 |
} |
| 327 |
|
343 |
|
| 328 |
private void hookListener(WorkbenchWindow lastActiveWorkbenchWindow, |
344 |
private void hookListener(WorkbenchWindow lastActiveWorkbenchWindow, |
| 329 |
WorkbenchWindow newActiveWorkbenchWindow) { |
345 |
WorkbenchWindow newActiveWorkbenchWindow) { |
| 330 |
if (lastActiveWorkbenchWindow != null) |
346 |
if (lastActiveWorkbenchWindow != null) |
| 331 |
lastActiveWorkbenchWindow.removePropertyChangeListener(propertyListener); |
347 |
lastActiveWorkbenchWindow |
| 332 |
|
348 |
.removePropertyChangeListener(propertyListener); |
|
|
349 |
|
| 333 |
if (newActiveWorkbenchWindow != null) |
350 |
if (newActiveWorkbenchWindow != null) |
| 334 |
newActiveWorkbenchWindow.addPropertyChangeListener(propertyListener); |
351 |
newActiveWorkbenchWindow |
|
|
352 |
.addPropertyChangeListener(propertyListener); |
| 335 |
} |
353 |
} |
| 336 |
} |
354 |
} |