|
Lines 46-51
Link Here
|
| 46 |
*/ |
46 |
*/ |
| 47 |
final class ContextAuthority extends ExpressionAuthority { |
47 |
final class ContextAuthority extends ExpressionAuthority { |
| 48 |
|
48 |
|
|
|
49 |
private static final String DIALOG_WITH_WORKBENCH = "org.eclipse.ui.contexts.internal.dialog_with_workbench"; //$NON-NLS-1$ |
| 50 |
|
| 49 |
/** |
51 |
/** |
| 50 |
* The default size of the set containing the activations to recompute. This |
52 |
* The default size of the set containing the activations to recompute. This |
| 51 |
* is more than enough to cover the average case. |
53 |
* is more than enough to cover the average case. |
|
Lines 177-183
Link Here
|
| 177 |
for (int i = 1; i <= 32; i++) { |
179 |
for (int i = 1; i <= 32; i++) { |
| 178 |
if ((sourcePriority & (1 << i)) != 0) { |
180 |
if ((sourcePriority & (1 << i)) != 0) { |
| 179 |
Set activations = activationsBySourcePriority[i]; |
181 |
Set activations = activationsBySourcePriority[i]; |
| 180 |
if (activations == null) { |
182 |
if (activations == null) { |
| 181 |
activations = new HashSet(1); |
183 |
activations = new HashSet(1); |
| 182 |
activationsBySourcePriority[i] = activations; |
184 |
activationsBySourcePriority[i] = activations; |
| 183 |
} |
185 |
} |
|
Lines 378-383
Link Here
|
| 378 |
return (Shell) getVariable(ISources.ACTIVE_SHELL_NAME); |
380 |
return (Shell) getVariable(ISources.ACTIVE_SHELL_NAME); |
| 379 |
} |
381 |
} |
| 380 |
|
382 |
|
|
|
383 |
public final boolean dialogSupportsWorkbench(final Shell shell) { |
| 384 |
if (shell != null) { |
| 385 |
final Collection activations = (Collection) registeredWindows |
| 386 |
.get(shell); |
| 387 |
if (activations != null) { |
| 388 |
// The shell is registered, so check what type it was registered |
| 389 |
// as. |
| 390 |
if (activations.isEmpty()) { |
| 391 |
// It was registered as none. |
| 392 |
return false; |
| 393 |
} |
| 394 |
|
| 395 |
// Look for the right type of context id. |
| 396 |
final Iterator activationItr = activations.iterator(); |
| 397 |
while (activationItr.hasNext()) { |
| 398 |
final IContextActivation activation = (IContextActivation) activationItr |
| 399 |
.next(); |
| 400 |
final String contextId = activation.getContextId(); |
| 401 |
if (contextId == DIALOG_WITH_WORKBENCH) { |
| 402 |
return true; |
| 403 |
} |
| 404 |
} |
| 405 |
} |
| 406 |
} |
| 407 |
return false; |
| 408 |
} |
| 409 |
|
| 381 |
/** |
410 |
/** |
| 382 |
* Returns the shell type for the given shell. |
411 |
* Returns the shell type for the given shell. |
| 383 |
* |
412 |
* |
|
Lines 418-426
Link Here
|
| 418 |
} |
447 |
} |
| 419 |
|
448 |
|
| 420 |
// This shouldn't be possible. |
449 |
// This shouldn't be possible. |
| 421 |
Assert.isTrue( |
450 |
Assert |
| 422 |
false, |
451 |
.isTrue( |
| 423 |
"A registered shell should have at least one submission matching TYPE_WINDOW or TYPE_DIALOG"); //$NON-NLS-1$ |
452 |
false, |
|
|
453 |
"A registered shell should have at least one submission matching TYPE_WINDOW or TYPE_DIALOG"); //$NON-NLS-1$ |
| 424 |
return IContextService.TYPE_NONE; // not reachable |
454 |
return IContextService.TYPE_NONE; // not reachable |
| 425 |
|
455 |
|
| 426 |
} else if (shell.getParent() != null) { |
456 |
} else if (shell.getParent() != null) { |
|
Lines 486-491
Link Here
|
| 486 |
case IContextService.TYPE_DIALOG: |
516 |
case IContextService.TYPE_DIALOG: |
| 487 |
buffer.append("dialog"); //$NON-NLS-1$ |
517 |
buffer.append("dialog"); //$NON-NLS-1$ |
| 488 |
break; |
518 |
break; |
|
|
519 |
case IContextService.TYPE_DIALOG_SUPPORTS_WORKBENCH: |
| 520 |
buffer.append("dialog-workbench"); //$NON-NLS-1$ |
| 521 |
break; |
| 489 |
case IContextService.TYPE_WINDOW: |
522 |
case IContextService.TYPE_WINDOW: |
| 490 |
buffer.append("window"); //$NON-NLS-1$ |
523 |
buffer.append("window"); //$NON-NLS-1$ |
| 491 |
break; |
524 |
break; |
|
Lines 504-509
Link Here
|
| 504 |
Expression expression; |
537 |
Expression expression; |
| 505 |
IContextActivation dialogWindowActivation; |
538 |
IContextActivation dialogWindowActivation; |
| 506 |
switch (type) { |
539 |
switch (type) { |
|
|
540 |
case IContextService.TYPE_DIALOG_SUPPORTS_WORKBENCH: |
| 541 |
// add the bogus activation for reference purposes |
| 542 |
activations.add(new ContextActivation(DIALOG_WITH_WORKBENCH, null, |
| 543 |
contextService)); |
| 507 |
case IContextService.TYPE_DIALOG: |
544 |
case IContextService.TYPE_DIALOG: |
| 508 |
expression = new ActiveShellExpression(shell); |
545 |
expression = new ActiveShellExpression(shell); |
| 509 |
dialogWindowActivation = new ContextActivation( |
546 |
dialogWindowActivation = new ContextActivation( |
|
Lines 568-574
Link Here
|
| 568 |
*/ |
605 |
*/ |
| 569 |
public void widgetDisposed(DisposeEvent e) { |
606 |
public void widgetDisposed(DisposeEvent e) { |
| 570 |
registeredWindows.remove(shell); |
607 |
registeredWindows.remove(shell); |
| 571 |
shell.removeDisposeListener(this); |
608 |
if (!shell.isDisposed()) { |
|
|
609 |
shell.removeDisposeListener(this); |
| 610 |
} |
| 572 |
|
611 |
|
| 573 |
/* |
612 |
/* |
| 574 |
* In the case where a dispose has happened, we are expecting an |
613 |
* In the case where a dispose has happened, we are expecting an |
|
Lines 605-611
Link Here
|
| 605 |
if (DEBUG_PERFORMANCE) { |
644 |
if (DEBUG_PERFORMANCE) { |
| 606 |
startTime = System.currentTimeMillis(); |
645 |
startTime = System.currentTimeMillis(); |
| 607 |
} |
646 |
} |
| 608 |
|
647 |
|
| 609 |
/* |
648 |
/* |
| 610 |
* In this first phase, we cycle through all of the activations that |
649 |
* In this first phase, we cycle through all of the activations that |
| 611 |
* could have potentially changed. Each such activation is added to a |
650 |
* could have potentially changed. Each such activation is added to a |
|
Lines 662-668
Link Here
|
| 662 |
updateContext(contextId, false); |
701 |
updateContext(contextId, false); |
| 663 |
} |
702 |
} |
| 664 |
} |
703 |
} |
| 665 |
|
704 |
|
| 666 |
// If tracing performance, then print the results. |
705 |
// If tracing performance, then print the results. |
| 667 |
if (DEBUG_PERFORMANCE) { |
706 |
if (DEBUG_PERFORMANCE) { |
| 668 |
final long elapsedTime = System.currentTimeMillis() - startTime; |
707 |
final long elapsedTime = System.currentTimeMillis() - startTime; |