Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 156581 | Differences between
and this patch

Collapse All | Expand All

(-)Eclipse UI/org/eclipse/ui/internal/WorkingSet.java (-2 / +2 lines)
Lines 197-204 Link Here
197
            Iterator iterator = elements.iterator();
197
            Iterator iterator = elements.iterator();
198
            while (iterator.hasNext()) {
198
            while (iterator.hasNext()) {
199
                IAdaptable adaptable = (IAdaptable) iterator.next();
199
                IAdaptable adaptable = (IAdaptable) iterator.next();
200
                IPersistableElement persistable = (IPersistableElement) adaptable
200
                IPersistableElement persistable = (IPersistableElement) Util.getAdapter(adaptable,
201
                        .getAdapter(IPersistableElement.class);
201
                        IPersistableElement.class);
202
                if (persistable != null) {
202
                if (persistable != null) {
203
                    IMemento itemMemento = memento
203
                    IMemento itemMemento = memento
204
                            .createChild(IWorkbenchConstants.TAG_ITEM);
204
                            .createChild(IWorkbenchConstants.TAG_ITEM);
(-)Eclipse UI/org/eclipse/ui/internal/WorkbenchWindow.java (-10 / +7 lines)
Lines 133-138 Link Here
133
import org.eclipse.ui.internal.services.ISourceProviderService;
133
import org.eclipse.ui.internal.services.ISourceProviderService;
134
import org.eclipse.ui.internal.services.ServiceLocator;
134
import org.eclipse.ui.internal.services.ServiceLocator;
135
import org.eclipse.ui.internal.util.PrefUtil;
135
import org.eclipse.ui.internal.util.PrefUtil;
136
import org.eclipse.ui.internal.util.Util;
136
import org.eclipse.ui.presentations.AbstractPresentationFactory;
137
import org.eclipse.ui.presentations.AbstractPresentationFactory;
137
138
138
/**
139
/**
Lines 524-531 Link Here
524
	 * </p>
525
	 * </p>
525
	 */
526
	 */
526
	void submitGlobalActions() {
527
	void submitGlobalActions() {
527
		final IHandlerService handlerService = (IHandlerService) PlatformUI
528
		final IHandlerService handlerService = (IHandlerService) getWorkbench().getService(IHandlerService.class);
528
				.getWorkbench().getAdapter(IHandlerService.class);
529
529
530
		/*
530
		/*
531
		 * Mash the action sets and global actions together, with global actions
531
		 * Mash the action sets and global actions together, with global actions
Lines 850-857 Link Here
850
				IWorkbenchHelpContextIds.WORKBENCH_WINDOW);
850
				IWorkbenchHelpContextIds.WORKBENCH_WINDOW);
851
851
852
//		initializeDefaultServices();
852
//		initializeDefaultServices();
853
		final IContextService contextService = (IContextService) workbench
853
		final IContextService contextService = (IContextService) getWorkbench().getService(IContextService.class);
854
				.getAdapter(IContextService.class);
855
		contextService.registerShell(shell, IContextService.TYPE_WINDOW);
854
		contextService.registerShell(shell, IContextService.TYPE_WINDOW);
856
855
857
		trackShellActivation(shell);
856
		trackShellActivation(shell);
Lines 1466-1473 Link Here
1466
1465
1467
			// Remove the handler submissions. Bug 64024.
1466
			// Remove the handler submissions. Bug 64024.
1468
			final IWorkbench workbench = getWorkbench();
1467
			final IWorkbench workbench = getWorkbench();
1469
			final IHandlerService handlerService = (IHandlerService) workbench
1468
			final IHandlerService handlerService = (IHandlerService) workbench.getService(IHandlerService.class);
1470
					.getAdapter(IHandlerService.class);
1471
			handlerService.deactivateHandlers(handlerActivations);
1469
			handlerService.deactivateHandlers(handlerActivations);
1472
			final Iterator activationItr = handlerActivations.iterator();
1470
			final Iterator activationItr = handlerActivations.iterator();
1473
			while (activationItr.hasNext()) {
1471
			while (activationItr.hasNext()) {
Lines 1479-1486 Link Here
1479
			globalActionHandlersByCommandId.clear();
1477
			globalActionHandlersByCommandId.clear();
1480
1478
1481
			// Remove the enabled submissions. Bug 64024.
1479
			// Remove the enabled submissions. Bug 64024.
1482
			final IContextService contextService = (IContextService) workbench
1480
			final IContextService contextService = (IContextService) workbench.getService(IContextService.class);
1483
					.getAdapter(IContextService.class);
1484
			contextService.unregisterShell(getShell());
1481
			contextService.unregisterShell(getShell());
1485
1482
1486
			closeAllPages();
1483
			closeAllPages();
Lines 2446-2453 Link Here
2446
			// Get the input.
2443
			// Get the input.
2447
			IAdaptable input = page.getInput();
2444
			IAdaptable input = page.getInput();
2448
			if (input != null) {
2445
			if (input != null) {
2449
				IPersistableElement persistable = (IPersistableElement) input
2446
				IPersistableElement persistable = (IPersistableElement) Util.getAdapter(input,
2450
						.getAdapter(IPersistableElement.class);
2447
						IPersistableElement.class);
2451
				if (persistable == null) {
2448
				if (persistable == null) {
2452
					WorkbenchPlugin
2449
					WorkbenchPlugin
2453
							.log("Unable to save page input: " //$NON-NLS-1$
2450
							.log("Unable to save page input: " //$NON-NLS-1$
(-)Eclipse UI/org/eclipse/ui/internal/EditorManager.java (-5 / +3 lines)
Lines 169-176 Link Here
169
			}
169
			}
170
			if (pinEditorHandlerActivation != null) {
170
			if (pinEditorHandlerActivation != null) {
171
				// remove pin editor keyboard shortcut handler
171
				// remove pin editor keyboard shortcut handler
172
				final IHandlerService handlerService = (IHandlerService) window
172
				final IHandlerService handlerService = (IHandlerService) window.getWorkbench().getService(IHandlerService.class);
173
						.getWorkbench().getAdapter(IHandlerService.class);
174
				handlerService.deactivateHandler(pinEditorHandlerActivation);
173
				handlerService.deactivateHandler(pinEditorHandlerActivation);
175
				pinEditorHandlerActivation = null;
174
				pinEditorHandlerActivation = null;
176
			}
175
			}
Lines 230-237 Link Here
230
			};
229
			};
231
230
232
			// Assign the handler for the pin editor keyboard shortcut.
231
			// Assign the handler for the pin editor keyboard shortcut.
233
			final IHandlerService handlerService = (IHandlerService) window
232
			final IHandlerService handlerService = (IHandlerService) window.getWorkbench().getService(IHandlerService.class);
234
					.getWorkbench().getAdapter(IHandlerService.class);
235
			pinEditorHandlerActivation = handlerService.activateHandler(
233
			pinEditorHandlerActivation = handlerService.activateHandler(
236
					"org.eclipse.ui.window.pinEditor", pinEditorHandler, //$NON-NLS-1$
234
					"org.eclipse.ui.window.pinEditor", pinEditorHandler, //$NON-NLS-1$
237
					new ActiveShellExpression(shell));
235
					new ActiveShellExpression(shell));
Lines 1451-1457 Link Here
1451
			return (IPathEditorInput) input;
1449
			return (IPathEditorInput) input;
1452
		}
1450
		}
1453
1451
1454
		return (IPathEditorInput) input.getAdapter(IPathEditorInput.class);
1452
		return (IPathEditorInput) Util.getAdapter(input, IPathEditorInput.class);
1455
	}
1453
	}
1456
1454
1457
	private class InnerEditor extends EditorReference {
1455
	private class InnerEditor extends EditorReference {
(-)Eclipse UI/org/eclipse/ui/internal/SelectionConversionService.java (-12 / +5 lines)
Lines 15-23 Link Here
15
import java.util.Iterator;
15
import java.util.Iterator;
16
import java.util.List;
16
import java.util.List;
17
17
18
import org.eclipse.core.runtime.IAdaptable;
19
import org.eclipse.jface.viewers.IStructuredSelection;
18
import org.eclipse.jface.viewers.IStructuredSelection;
20
import org.eclipse.jface.viewers.StructuredSelection;
19
import org.eclipse.jface.viewers.StructuredSelection;
20
import org.eclipse.ui.internal.util.Util;
21
21
22
/**
22
/**
23
 * <p>
23
 * <p>
Lines 58-74 Link Here
58
58
59
		while (elements.hasNext()) {
59
		while (elements.hasNext()) {
60
			Object currentElement = elements.next();
60
			Object currentElement = elements.next();
61
			if (resourceClass.isInstance(currentElement)) { // already a
61
            Object resource = Util.getAdapter(currentElement, resourceClass);
62
				// resource
62
            if (resource != null) {
63
				result.add(currentElement);
63
            	result.add(resource);   
64
			} else if (currentElement instanceof IAdaptable) {
64
            }
65
				Object adapter = ((IAdaptable) currentElement)
66
						.getAdapter(resourceClass);
67
				if (resourceClass.isInstance(adapter)) {
68
					result.add(adapter); // add the converted resource
69
				}
70
71
			}
72
		}
65
		}
73
66
74
		// all that can be converted are done, answer new selection
67
		// all that can be converted are done, answer new selection
(-)Eclipse UI/org/eclipse/ui/internal/ActionExpression.java (-13 / +2 lines)
Lines 16-22 Link Here
16
import java.util.Iterator;
16
import java.util.Iterator;
17
import java.util.List;
17
import java.util.List;
18
18
19
import org.eclipse.core.runtime.IAdaptable;
20
import org.eclipse.core.runtime.IConfigurationElement;
19
import org.eclipse.core.runtime.IConfigurationElement;
21
import org.eclipse.core.runtime.Platform;
20
import org.eclipse.core.runtime.Platform;
22
import org.eclipse.jface.viewers.IStructuredSelection;
21
import org.eclipse.jface.viewers.IStructuredSelection;
Lines 471-484 Link Here
471
		}
470
		}
472
471
473
		private IActionFilter getActionFilter(Object object) {
472
		private IActionFilter getActionFilter(Object object) {
474
			IActionFilter filter = null;
473
			return (IActionFilter)Util.getAdapter(object, IActionFilter.class);
475
			if (object instanceof IActionFilter) {
476
				filter = (IActionFilter) object;
477
			} else if (object instanceof IAdaptable) {
478
				filter = (IActionFilter) ((IAdaptable) object)
479
						.getAdapter(IActionFilter.class);
480
			}
481
			return filter;
482
		}
474
		}
483
475
484
		/**
476
		/**
Lines 520-529 Link Here
520
				return false;
512
				return false;
521
			}
513
			}
522
514
523
			Object res = null;
515
			Object res = Util.getAdapter(object, resourceClass);
524
			if (object instanceof IAdaptable) {
525
				res = ((IAdaptable) object).getAdapter(resourceClass);
526
			}
527
			if (res == null) {
516
			if (res == null) {
528
				return false;
517
				return false;
529
			}
518
			}
(-)Eclipse UI/org/eclipse/ui/internal/ShowInMenu.java (-16 / +3 lines)
Lines 31-36 Link Here
31
import org.eclipse.ui.IWorkbenchPage;
31
import org.eclipse.ui.IWorkbenchPage;
32
import org.eclipse.ui.IWorkbenchPart;
32
import org.eclipse.ui.IWorkbenchPart;
33
import org.eclipse.ui.IWorkbenchWindow;
33
import org.eclipse.ui.IWorkbenchWindow;
34
import org.eclipse.ui.internal.util.Util;
34
import org.eclipse.ui.part.IShowInSource;
35
import org.eclipse.ui.part.IShowInSource;
35
import org.eclipse.ui.part.IShowInTargetList;
36
import org.eclipse.ui.part.IShowInTargetList;
36
import org.eclipse.ui.part.ShowInContext;
37
import org.eclipse.ui.part.ShowInContext;
Lines 208-221 Link Here
208
     * @return an <code>IShowInSource</code> or <code>null</code>
209
     * @return an <code>IShowInSource</code> or <code>null</code>
209
     */
210
     */
210
    private IShowInSource getShowInSource(IWorkbenchPart sourcePart) {
211
    private IShowInSource getShowInSource(IWorkbenchPart sourcePart) {
211
        if (sourcePart instanceof IShowInSource) {
212
        return (IShowInSource)Util.getAdapter(sourcePart, IShowInSource.class);
212
            return (IShowInSource) sourcePart;
213
        }
214
        Object o = sourcePart.getAdapter(IShowInSource.class);
215
        if (o instanceof IShowInSource) {
216
            return (IShowInSource) o;
217
        }
218
        return null;
219
    }
213
    }
220
214
221
    /**
215
    /**
Lines 226-239 Link Here
226
     * @return the <code>IShowInTargetList</code> or <code>null</code>
220
     * @return the <code>IShowInTargetList</code> or <code>null</code>
227
     */
221
     */
228
    private IShowInTargetList getShowInTargetList(IWorkbenchPart sourcePart) {
222
    private IShowInTargetList getShowInTargetList(IWorkbenchPart sourcePart) {
229
        if (sourcePart instanceof IShowInTargetList) {
223
        return (IShowInTargetList)Util.getAdapter(sourcePart, IShowInTargetList.class);
230
            return (IShowInTargetList) sourcePart;
231
        }
232
        Object o = sourcePart.getAdapter(IShowInTargetList.class);
233
        if (o instanceof IShowInTargetList) {
234
            return (IShowInTargetList) o;
235
        }
236
        return null;
237
    }
224
    }
238
225
239
    /**
226
    /**
(-)Eclipse UI/org/eclipse/ui/internal/ShowInAction.java (-16 / +3 lines)
Lines 20-25 Link Here
20
import org.eclipse.ui.IWorkbenchPart;
20
import org.eclipse.ui.IWorkbenchPart;
21
import org.eclipse.ui.IWorkbenchWindow;
21
import org.eclipse.ui.IWorkbenchWindow;
22
import org.eclipse.ui.PartInitException;
22
import org.eclipse.ui.PartInitException;
23
import org.eclipse.ui.internal.util.Util;
23
import org.eclipse.ui.part.IShowInSource;
24
import org.eclipse.ui.part.IShowInSource;
24
import org.eclipse.ui.part.IShowInTarget;
25
import org.eclipse.ui.part.IShowInTarget;
25
import org.eclipse.ui.part.ShowInContext;
26
import org.eclipse.ui.part.ShowInContext;
Lines 90-103 Link Here
90
     * @return an <code>IShowInSource</code> or <code>null</code>
91
     * @return an <code>IShowInSource</code> or <code>null</code>
91
     */
92
     */
92
    private IShowInSource getShowInSource(IWorkbenchPart sourcePart) {
93
    private IShowInSource getShowInSource(IWorkbenchPart sourcePart) {
93
        if (sourcePart instanceof IShowInSource) {
94
        return (IShowInSource)Util.getAdapter(sourcePart, IShowInSource.class);
94
            return (IShowInSource) sourcePart;
95
        }
96
        Object o = sourcePart.getAdapter(IShowInSource.class);
97
        if (o instanceof IShowInSource) {
98
            return (IShowInSource) o;
99
        }
100
        return null;
101
    }
95
    }
102
96
103
    /**
97
    /**
Lines 108-121 Link Here
108
     * @return the <code>IShowInTarget</code> or <code>null</code>
102
     * @return the <code>IShowInTarget</code> or <code>null</code>
109
     */
103
     */
110
    private IShowInTarget getShowInTarget(IWorkbenchPart targetPart) {
104
    private IShowInTarget getShowInTarget(IWorkbenchPart targetPart) {
111
        if (targetPart instanceof IShowInTarget) {
105
        return (IShowInTarget)Util.getAdapter(targetPart, IShowInTarget.class);
112
            return (IShowInTarget) targetPart;
113
        }
114
        Object o = targetPart.getAdapter(IShowInTarget.class);
115
        if (o instanceof IShowInTarget) {
116
            return (IShowInTarget) o;
117
        }
118
        return null;
119
    }
106
    }
120
107
121
    /**
108
    /**
(-)Eclipse UI/org/eclipse/ui/internal/CyclePartAction.java (-10 / +4 lines)
Lines 42-48 Link Here
42
import org.eclipse.ui.IWorkbenchPart;
42
import org.eclipse.ui.IWorkbenchPart;
43
import org.eclipse.ui.IWorkbenchPartReference;
43
import org.eclipse.ui.IWorkbenchPartReference;
44
import org.eclipse.ui.IWorkbenchWindow;
44
import org.eclipse.ui.IWorkbenchWindow;
45
import org.eclipse.ui.PlatformUI;
46
import org.eclipse.ui.commands.ICommandService;
45
import org.eclipse.ui.commands.ICommandService;
47
import org.eclipse.ui.contexts.IContextService;
46
import org.eclipse.ui.contexts.IContextService;
48
import org.eclipse.ui.keys.IBindingService;
47
import org.eclipse.ui.keys.IBindingService;
Lines 441-456 Link Here
441
		 * will not change while the dialog is open, but the context will. Bug
440
		 * will not change while the dialog is open, but the context will. Bug
442
		 * 55581.
441
		 * 55581.
443
		 */
442
		 */
444
		final IBindingService bindingService = (IBindingService) PlatformUI
443
		final IBindingService bindingService = (IBindingService) getWorkbenchWindow().getWorkbench().getService(IBindingService.class);
445
				.getWorkbench().getAdapter(IBindingService.class);
446
		forwardTriggerSequences = bindingService
444
		forwardTriggerSequences = bindingService
447
				.getActiveBindingsFor(commandForward);
445
				.getActiveBindingsFor(commandForward);
448
		backwardTriggerSequences = bindingService
446
		backwardTriggerSequences = bindingService
449
				.getActiveBindingsFor(commandBackward);
447
				.getActiveBindingsFor(commandBackward);
450
448
451
		final IContextService contextService = (IContextService) page
449
		final IContextService contextService = (IContextService) getWorkbenchWindow().getWorkbench().getService(IContextService.class);
452
				.getWorkbenchWindow().getWorkbench().getAdapter(
453
						IContextService.class);
454
		try {
450
		try {
455
			dialog.open();
451
			dialog.open();
456
			addMouseListener(table, dialog);
452
			addMouseListener(table, dialog);
Lines 526-533 Link Here
526
	 *            the action
522
	 *            the action
527
	 */
523
	 */
528
	public void setBackwardActionDefinitionId(String actionDefinitionId) {
524
	public void setBackwardActionDefinitionId(String actionDefinitionId) {
529
		final ICommandService commandService = (ICommandService) getWorkbenchWindow()
525
		final ICommandService commandService = (ICommandService) getWorkbenchWindow().getWorkbench().getService(ICommandService.class);
530
				.getWorkbench().getAdapter(ICommandService.class);
531
		final Command command = commandService.getCommand(actionDefinitionId);
526
		final Command command = commandService.getCommand(actionDefinitionId);
532
		commandBackward = new ParameterizedCommand(command, null);
527
		commandBackward = new ParameterizedCommand(command, null);
533
	}
528
	}
Lines 539-546 Link Here
539
	 *            the action
534
	 *            the action
540
	 */
535
	 */
541
	public void setForwardActionDefinitionId(String actionDefinitionId) {
536
	public void setForwardActionDefinitionId(String actionDefinitionId) {
542
		final ICommandService commandService = (ICommandService) getWorkbenchWindow()
537
		final ICommandService commandService = (ICommandService) getWorkbenchWindow().getWorkbench().getService(ICommandService.class);
543
				.getWorkbench().getAdapter(ICommandService.class);
544
		final Command command = commandService.getCommand(actionDefinitionId);
538
		final Command command = commandService.getCommand(actionDefinitionId);
545
		commandForward = new ParameterizedCommand(command, null);
539
		commandForward = new ParameterizedCommand(command, null);
546
	}
540
	}
(-)Eclipse UI/org/eclipse/ui/internal/BaseSaveAction.java (-4 / +3 lines)
Lines 22-27 Link Here
22
import org.eclipse.ui.IWorkbenchPage;
22
import org.eclipse.ui.IWorkbenchPage;
23
import org.eclipse.ui.IWorkbenchPart;
23
import org.eclipse.ui.IWorkbenchPart;
24
import org.eclipse.ui.IWorkbenchWindow;
24
import org.eclipse.ui.IWorkbenchWindow;
25
import org.eclipse.ui.internal.util.Util;
25
26
26
/**
27
/**
27
 * The abstract superclass for save actions that depend on the active editor.
28
 * The abstract superclass for save actions that depend on the active editor.
Lines 214-223 Link Here
214
        if (activeView == null) {
215
        if (activeView == null) {
215
            return null;
216
            return null;
216
        }
217
        }
217
        if (activeView instanceof ISaveablePart) {
218
218
            return (ISaveablePart) activeView;
219
        return (ISaveablePart) Util.getAdapter(activeView, ISaveablePart.class);
219
        }
220
        return (ISaveablePart) activeView.getAdapter(ISaveablePart.class);
221
    }
220
    }
222
221
223
    /* (non-Javadoc)
222
    /* (non-Javadoc)
(-)Eclipse UI/org/eclipse/ui/internal/ObjectActionContributor.java (-8 / +5 lines)
Lines 28-33 Link Here
28
import org.eclipse.ui.SelectionEnabler;
28
import org.eclipse.ui.SelectionEnabler;
29
import org.eclipse.ui.internal.misc.Policy;
29
import org.eclipse.ui.internal.misc.Policy;
30
import org.eclipse.ui.internal.registry.IWorkbenchRegistryConstants;
30
import org.eclipse.ui.internal.registry.IWorkbenchRegistryConstants;
31
import org.eclipse.ui.internal.util.Util;
31
import org.eclipse.ui.model.IWorkbenchAdapter;
32
import org.eclipse.ui.model.IWorkbenchAdapter;
32
33
33
/**
34
/**
Lines 273-286 Link Here
273
			return true;
274
			return true;
274
		}
275
		}
275
        String objectName = null;
276
        String objectName = null;
276
        if (object instanceof IAdaptable) {
277
        IWorkbenchAdapter de = (IWorkbenchAdapter)Util.getAdapter(object, IWorkbenchAdapter.class);
277
            IAdaptable element = (IAdaptable) object;
278
        if (de != null) {
278
            IWorkbenchAdapter de = (IWorkbenchAdapter) element
279
			objectName = de.getLabel(object);
279
                    .getAdapter(IWorkbenchAdapter.class);
280
		}
280
            if (de != null) {
281
				objectName = de.getLabel(element);
282
			}
283
        }
284
        if (objectName == null) {
281
        if (objectName == null) {
285
            objectName = object.toString();
282
            objectName = object.toString();
286
        }
283
        }
(-)Eclipse UI/org/eclipse/ui/internal/WorkbenchPage.java (-7 / +5 lines)
Lines 1938-1950 Link Here
1938
     */
1938
     */
1939
    public String getLabel() {
1939
    public String getLabel() {
1940
        String label = WorkbenchMessages.WorkbenchPage_UnknownLabel;
1940
        String label = WorkbenchMessages.WorkbenchPage_UnknownLabel;
1941
        if (input != null) {
1941
        IWorkbenchAdapter adapter = (IWorkbenchAdapter) Util.getAdapter(input, 
1942
            IWorkbenchAdapter adapter = (IWorkbenchAdapter) input
1942
                IWorkbenchAdapter.class);
1943
                    .getAdapter(IWorkbenchAdapter.class);
1943
        if (adapter != null) {
1944
            if (adapter != null) {
1944
			label = adapter.getLabel(input);
1945
				label = adapter.getLabel(input);
1945
		}
1946
			}
1947
        }
1948
        Perspective persp = getActivePerspective();
1946
        Perspective persp = getActivePerspective();
1949
        if (persp != null) {
1947
        if (persp != null) {
1950
			label = NLS.bind(WorkbenchMessages.WorkbenchPage_PerspectiveFormat,  label, persp.getDesc().getLabel());
1948
			label = NLS.bind(WorkbenchMessages.WorkbenchPage_PerspectiveFormat,  label, persp.getDesc().getLabel());
(-)Eclipse UI/org/eclipse/ui/internal/DetachedWindow.java (-5 / +2 lines)
Lines 242-250 Link Here
242
            bounds = windowShell.getBounds();
242
            bounds = windowShell.getBounds();
243
243
244
            // Unregister this detached view as a window (for key bindings).
244
            // Unregister this detached view as a window (for key bindings).
245
			final IContextService contextService = (IContextService) getWorkbenchPage()
245
			final IContextService contextService = (IContextService) getWorkbenchPage().getWorkbenchWindow().getWorkbench().getService(IContextService.class);
246
					.getWorkbenchWindow().getWorkbench().getAdapter(
247
							IContextService.class);
248
			contextService.unregisterShell(windowShell);
246
			contextService.unregisterShell(windowShell);
249
247
250
            windowShell.setData(null);
248
            windowShell.setData(null);
Lines 309-316 Link Here
309
307
310
        // Register this detached view as a window (for key bindings).
308
        // Register this detached view as a window (for key bindings).
311
		final IContextService contextService = (IContextService) getWorkbenchPage()
309
		final IContextService contextService = (IContextService) getWorkbenchPage()
312
				.getWorkbenchWindow().getWorkbench().getAdapter(
310
				.getWorkbenchWindow().getWorkbench().getService(IContextService.class);
313
						IContextService.class);
314
        contextService.registerShell(shell,
311
        contextService.registerShell(shell,
315
                IContextService.TYPE_WINDOW);
312
                IContextService.TYPE_WINDOW);
316
313
(-)Eclipse UI/org/eclipse/ui/internal/ObjectContributorManager.java (-6 / +5 lines)
Lines 31-36 Link Here
31
import org.eclipse.core.runtime.dynamichelpers.IExtensionTracker;
31
import org.eclipse.core.runtime.dynamichelpers.IExtensionTracker;
32
import org.eclipse.jface.viewers.IStructuredSelection;
32
import org.eclipse.jface.viewers.IStructuredSelection;
33
import org.eclipse.ui.PlatformUI;
33
import org.eclipse.ui.PlatformUI;
34
import org.eclipse.ui.internal.util.Util;
34
35
35
/**
36
/**
36
 * This class is a default implementation of <code>IObjectContributorManager</code>.
37
 * This class is a default implementation of <code>IObjectContributorManager</code>.
Lines 312-325 Link Here
312
        }
313
        }
313
        contributorList.add(contributor);
314
        contributorList.add(contributor);
314
        flushLookup();
315
        flushLookup();
316
317
        IConfigurationElement element = (IConfigurationElement) Util.getAdapter(contributor,
318
        	IConfigurationElement.class);
315
        
319
        
316
        //hook the object listener
320
        //hook the object listener
317
        if (contributor instanceof IAdaptable) {
321
        if (element != null) {
318
        	IConfigurationElement element = (IConfigurationElement) ((IAdaptable) contributor)
319
					.getAdapter(IConfigurationElement.class);
320
			if (element == null) {
321
				return;
322
			}
323
			ContributorRecord contributorRecord = new ContributorRecord(
322
			ContributorRecord contributorRecord = new ContributorRecord(
324
					contributor, targetType);
323
					contributor, targetType);
325
			contributorRecordSet.add(contributorRecord);
324
			contributorRecordSet.add(contributorRecord);
(-)Eclipse UI/org/eclipse/ui/internal/ViewReference.java (-2 / +2 lines)
Lines 373-380 Link Here
373
373
374
			result = view;
374
			result = view;
375
375
376
			IConfigurationElement element = (IConfigurationElement) desc
376
			IConfigurationElement element = (IConfigurationElement) Util.getAdapter(desc,
377
					.getAdapter(IConfigurationElement.class);
377
					IConfigurationElement.class);
378
			if (element != null) {
378
			if (element != null) {
379
				factory.page.getExtensionTracker().registerObject(
379
				factory.page.getExtensionTracker().registerObject(
380
						element.getDeclaringExtension(), view,
380
						element.getDeclaringExtension(), view,
(-)Eclipse UI/org/eclipse/ui/internal/ViewSite.java (-2 / +2 lines)
Lines 14-19 Link Here
14
import org.eclipse.ui.IViewPart;
14
import org.eclipse.ui.IViewPart;
15
import org.eclipse.ui.IViewReference;
15
import org.eclipse.ui.IViewReference;
16
import org.eclipse.ui.IViewSite;
16
import org.eclipse.ui.IViewSite;
17
import org.eclipse.ui.internal.util.Util;
17
import org.eclipse.ui.views.IViewDescriptor;
18
import org.eclipse.ui.views.IViewDescriptor;
18
19
19
/**
20
/**
Lines 37-44 Link Here
37
    public ViewSite(IViewReference ref, IViewPart view, WorkbenchPage page,
38
    public ViewSite(IViewReference ref, IViewPart view, WorkbenchPage page,
38
            IViewDescriptor desc) {
39
            IViewDescriptor desc) {
39
        super(ref, view, page);
40
        super(ref, view, page);
40
        setConfigurationElement((IConfigurationElement) desc
41
        setConfigurationElement((IConfigurationElement) Util.getAdapter(desc, IConfigurationElement.class));
41
				.getAdapter(IConfigurationElement.class));
42
    }
42
    }
43
43
44
    /**
44
    /**
(-)Eclipse UI/org/eclipse/ui/internal/ObjectFilterTest.java (-8 / +2 lines)
Lines 13-21 Link Here
13
import java.util.HashMap;
13
import java.util.HashMap;
14
import java.util.Iterator;
14
import java.util.Iterator;
15
15
16
import org.eclipse.core.runtime.IAdaptable;
17
import org.eclipse.core.runtime.IConfigurationElement;
16
import org.eclipse.core.runtime.IConfigurationElement;
18
import org.eclipse.ui.IActionFilter;
17
import org.eclipse.ui.IActionFilter;
18
import org.eclipse.ui.internal.util.Util;
19
19
20
/**
20
/**
21
 * An ObjectFilterTest is used to read an object filter from XML,
21
 * An ObjectFilterTest is used to read an object filter from XML,
Lines 85-97 Link Here
85
     */
85
     */
86
    private boolean preciselyMatches(Object object) {
86
    private boolean preciselyMatches(Object object) {
87
        // Get the action filter.
87
        // Get the action filter.
88
        IActionFilter filter = null;
88
        IActionFilter filter = (IActionFilter)Util.getAdapter(object, IActionFilter.class);
89
        if (object instanceof IActionFilter) {
90
			filter = (IActionFilter) object;
91
		} else if (object instanceof IAdaptable) {
92
			filter = (IActionFilter) ((IAdaptable) object)
93
                    .getAdapter(IActionFilter.class);
94
		}
95
        if (filter == null) {
89
        if (filter == null) {
96
			return false;
90
			return false;
97
		}
91
		}
(-)Eclipse UI/org/eclipse/ui/internal/actions/NewWizardShortcutAction.java (-3 / +4 lines)
Lines 29-34 Link Here
29
import org.eclipse.ui.internal.IWorkbenchHelpContextIds;
29
import org.eclipse.ui.internal.IWorkbenchHelpContextIds;
30
import org.eclipse.ui.internal.LegacyResourceSupport;
30
import org.eclipse.ui.internal.LegacyResourceSupport;
31
import org.eclipse.ui.internal.WorkbenchMessages;
31
import org.eclipse.ui.internal.WorkbenchMessages;
32
import org.eclipse.ui.internal.util.Util;
32
import org.eclipse.ui.wizards.IWizardDescriptor;
33
import org.eclipse.ui.wizards.IWizardDescriptor;
33
34
34
/**
35
/**
Lines 95-101 Link Here
95
                IEditorInput input = ((IEditorPart) part).getEditorInput();
96
                IEditorInput input = ((IEditorPart) part).getEditorInput();
96
                Class fileClass = LegacyResourceSupport.getFileClass();
97
                Class fileClass = LegacyResourceSupport.getFileClass();
97
                if (input != null && fileClass != null) {
98
                if (input != null && fileClass != null) {
98
                    Object file = input.getAdapter(fileClass);
99
                    Object file = Util.getAdapter(input, fileClass);
99
                    if (file != null) {
100
                    if (file != null) {
100
                        selectionToPass = new StructuredSelection(file);
101
                        selectionToPass = new StructuredSelection(file);
101
                    }
102
                    }
Lines 155-161 Link Here
155
     * @since 3.1
156
     * @since 3.1
156
     */
157
     */
157
    private IPluginContribution getPluginContribution() {
158
    private IPluginContribution getPluginContribution() {
158
		return (IPluginContribution) wizardElement
159
		return (IPluginContribution) Util.getAdapter(wizardElement,
159
				.getAdapter(IPluginContribution.class);
160
				IPluginContribution.class);
160
	}
161
	}
161
}
162
}
(-)Eclipse UI/org/eclipse/ui/internal/dialogs/WorkbenchWizardNode.java (-5 / +6 lines)
Lines 26-31 Link Here
26
import org.eclipse.ui.IWorkbenchWizard;
26
import org.eclipse.ui.IWorkbenchWizard;
27
import org.eclipse.ui.internal.WorkbenchMessages;
27
import org.eclipse.ui.internal.WorkbenchMessages;
28
import org.eclipse.ui.internal.WorkbenchPlugin;
28
import org.eclipse.ui.internal.WorkbenchPlugin;
29
import org.eclipse.ui.internal.util.Util;
29
import org.eclipse.ui.wizards.IWizardDescriptor;
30
import org.eclipse.ui.wizards.IWizardDescriptor;
30
31
31
/**
32
/**
Lines 95-102 Link Here
95
     * @see org.eclipse.ui.IPluginContribution#getLocalId()
96
     * @see org.eclipse.ui.IPluginContribution#getLocalId()
96
     */
97
     */
97
    public String getLocalId() {
98
    public String getLocalId() {
98
    	IPluginContribution contribution = (IPluginContribution) wizardElement
99
    	IPluginContribution contribution = (IPluginContribution) Util.getAdapter(wizardElement,
99
				.getAdapter(IPluginContribution.class);
100
				IPluginContribution.class);
100
		if (contribution != null) {
101
		if (contribution != null) {
101
			return contribution.getLocalId();
102
			return contribution.getLocalId();
102
		}
103
		}
Lines 107-114 Link Here
107
     * @see org.eclipse.ui.IPluginContribution#getPluginId()
108
     * @see org.eclipse.ui.IPluginContribution#getPluginId()
108
     */
109
     */
109
    public String getPluginId() {
110
    public String getPluginId() {
110
       	IPluginContribution contribution = (IPluginContribution) wizardElement
111
       	IPluginContribution contribution = (IPluginContribution) Util.getAdapter(wizardElement,
111
				.getAdapter(IPluginContribution.class);
112
				IPluginContribution.class);
112
		if (contribution != null) {
113
		if (contribution != null) {
113
			return contribution.getLocalId();
114
			return contribution.getLocalId();
114
		}
115
		}
Lines 134-140 Link Here
134
                             * Add the exception details to status is one happens.
135
                             * Add the exception details to status is one happens.
135
                             */
136
                             */
136
                            public void handleException(Throwable e) {
137
                            public void handleException(Throwable e) {
137
                               	IPluginContribution contribution = (IPluginContribution) wizardElement.getAdapter(IPluginContribution.class);
138
                               	IPluginContribution contribution = (IPluginContribution) Util.getAdapter(wizardElement, IPluginContribution.class);
138
                                statuses[0] = new Status(
139
                                statuses[0] = new Status(
139
                                        IStatus.ERROR,
140
                                        IStatus.ERROR,
140
                                        contribution != null ? contribution.getPluginId() : WorkbenchPlugin.PI_WORKBENCH,
141
                                        contribution != null ? contribution.getPluginId() : WorkbenchPlugin.PI_WORKBENCH,
(-)Eclipse UI/org/eclipse/ui/internal/dialogs/RegistryPageContributor.java (-14 / +8 lines)
Lines 35-40 Link Here
35
import org.eclipse.ui.internal.registry.CategorizedPageRegistryReader;
35
import org.eclipse.ui.internal.registry.CategorizedPageRegistryReader;
36
import org.eclipse.ui.internal.registry.IWorkbenchRegistryConstants;
36
import org.eclipse.ui.internal.registry.IWorkbenchRegistryConstants;
37
import org.eclipse.ui.internal.registry.PropertyPagesRegistryReader;
37
import org.eclipse.ui.internal.registry.PropertyPagesRegistryReader;
38
import org.eclipse.ui.internal.util.Util;
38
import org.eclipse.ui.model.IWorkbenchAdapter;
39
import org.eclipse.ui.model.IWorkbenchAdapter;
39
import org.eclipse.ui.plugin.AbstractUIPlugin;
40
import org.eclipse.ui.plugin.AbstractUIPlugin;
40
41
Lines 212-225 Link Here
212
				.getAttribute(PropertyPagesRegistryReader.ATT_NAME_FILTER);
213
				.getAttribute(PropertyPagesRegistryReader.ATT_NAME_FILTER);
213
		if (nameFilter != null) {
214
		if (nameFilter != null) {
214
			String objectName = object.toString();
215
			String objectName = object.toString();
215
			if (object instanceof IAdaptable) {
216
			IWorkbenchAdapter adapter = (IWorkbenchAdapter) Util.getAdapter(object, 
216
				IWorkbenchAdapter adapter = (IWorkbenchAdapter) ((IAdaptable) object)
217
                    IWorkbenchAdapter.class);
217
						.getAdapter(IWorkbenchAdapter.class);
218
			if (adapter != null) {
218
				if (adapter != null) {
219
				String elementName = adapter.getLabel(object);
219
					String elementName = adapter.getLabel(object);
220
				if (elementName != null) {
220
					if (elementName != null) {
221
					objectName = elementName;
221
						objectName = elementName;
222
					}
223
				}
222
				}
224
			}
223
			}
225
			if (!SelectionEnabler.verifyNameMatch(objectName, nameFilter))
224
			if (!SelectionEnabler.verifyNameMatch(objectName, nameFilter))
Lines 237-248 Link Here
237
			object = adaptedObject;
236
			object = adaptedObject;
238
		}
237
		}
239
238
240
		if (object instanceof IActionFilter) {
239
        filter = (IActionFilter)Util.getAdapter(object, IActionFilter.class);
241
			filter = (IActionFilter) object;
242
		} else if (object instanceof IAdaptable) {
243
			filter = (IActionFilter) ((IAdaptable) object)
244
					.getAdapter(IActionFilter.class);
245
		}
246
240
247
		if (filter != null)
241
		if (filter != null)
248
			return testCustom(object, filter);
242
			return testCustom(object, filter);
(-)Eclipse UI/org/eclipse/ui/internal/dialogs/AdaptableForwarder.java (-7 / +2 lines)
Lines 11-16 Link Here
11
package org.eclipse.ui.internal.dialogs;
11
package org.eclipse.ui.internal.dialogs;
12
12
13
import org.eclipse.core.runtime.IAdaptable;
13
import org.eclipse.core.runtime.IAdaptable;
14
import org.eclipse.ui.internal.util.Util;
14
15
15
/**
16
/**
16
 * Class that wraps an object and forwards adapter calls if possible, otherwise
17
 * Class that wraps an object and forwards adapter calls if possible, otherwise
Lines 35-46 Link Here
35
	 * @see org.eclipse.core.runtime.IAdaptable#getAdapter(java.lang.Class)
36
	 * @see org.eclipse.core.runtime.IAdaptable#getAdapter(java.lang.Class)
36
	 */
37
	 */
37
	public Object getAdapter(Class adapter) {
38
	public Object getAdapter(Class adapter) {
38
		if(adapter.isInstance(element)) {
39
        return Util.getAdapter(element, adapter);
39
			return element;
40
		}
41
		if(element instanceof IAdaptable) {
42
			return ((IAdaptable)element).getAdapter(adapter);
43
		}
44
		return null;
45
	}
40
	}
46
}
41
}
(-)Eclipse UI/org/eclipse/ui/internal/dialogs/PreferencePageHistory.java (-4 / +2 lines)
Lines 296-303 Link Here
296
	 */
296
	 */
297
	private void registerKeybindings(IAction action) {
297
	private void registerKeybindings(IAction action) {
298
		final IHandler handler = new ActionHandler(action);
298
		final IHandler handler = new ActionHandler(action);
299
		final IHandlerService handlerService = (IHandlerService) PlatformUI
299
		final IHandlerService handlerService = (IHandlerService) PlatformUI.getWorkbench().getService(IHandlerService.class);
300
				.getWorkbench().getAdapter(IHandlerService.class);
301
		final IHandlerActivation activation = handlerService.activateHandler(
300
		final IHandlerActivation activation = handlerService.activateHandler(
302
				action.getActionDefinitionId(), handler,
301
				action.getActionDefinitionId(), handler,
303
				new ActiveShellExpression(dialog.getShell()));
302
				new ActiveShellExpression(dialog.getShell()));
Lines 309-316 Link Here
309
	 *
308
	 *
310
	 */
309
	 */
311
	public void dispose() {
310
	public void dispose() {
312
		final IHandlerService handlerService = (IHandlerService) PlatformUI
311
		final IHandlerService handlerService = (IHandlerService) PlatformUI.getWorkbench().getService(IHandlerService.class);
313
				.getWorkbench().getAdapter(IHandlerService.class);
314
		final Iterator iterator = activations.iterator();
312
		final Iterator iterator = activations.iterator();
315
		while (iterator.hasNext()) {
313
		while (iterator.hasNext()) {
316
			handlerService.deactivateHandler((IHandlerActivation) iterator
314
			handlerService.deactivateHandler((IHandlerActivation) iterator
(-)Eclipse UI/org/eclipse/ui/internal/dialogs/PropertyDialog.java (-10 / +2 lines)
Lines 12-19 Link Here
12
12
13
import java.util.Iterator;
13
import java.util.Iterator;
14
14
15
import org.eclipse.core.runtime.IAdaptable;
16
import org.eclipse.core.runtime.Platform;
17
import org.eclipse.jface.dialogs.MessageDialog;
15
import org.eclipse.jface.dialogs.MessageDialog;
18
import org.eclipse.jface.preference.PreferenceManager;
16
import org.eclipse.jface.preference.PreferenceManager;
19
import org.eclipse.jface.viewers.ISelection;
17
import org.eclipse.jface.viewers.ISelection;
Lines 23-28 Link Here
23
import org.eclipse.ui.PlatformUI;
21
import org.eclipse.ui.PlatformUI;
24
import org.eclipse.ui.internal.IWorkbenchHelpContextIds;
22
import org.eclipse.ui.internal.IWorkbenchHelpContextIds;
25
import org.eclipse.ui.internal.WorkbenchMessages;
23
import org.eclipse.ui.internal.WorkbenchMessages;
24
import org.eclipse.ui.internal.util.Util;
26
import org.eclipse.ui.model.IWorkbenchAdapter;
25
import org.eclipse.ui.model.IWorkbenchAdapter;
27
26
28
/**
27
/**
Lines 98-111 Link Here
98
	 * @return the name of the element
97
	 * @return the name of the element
99
	 */
98
	 */
100
	private static String getName(Object element) {
99
	private static String getName(Object element) {
101
		IWorkbenchAdapter adapter = null;
100
		IWorkbenchAdapter adapter = (IWorkbenchAdapter)Util.getAdapter(element, IWorkbenchAdapter.class);
102
		if (element instanceof IAdaptable) {
103
			adapter = (IWorkbenchAdapter) ((IAdaptable) element)
104
					.getAdapter(IWorkbenchAdapter.class);
105
		} else {
106
			adapter = (IWorkbenchAdapter) Platform.getAdapterManager()
107
					.getAdapter(element, IWorkbenchAdapter.class);
108
		}
109
		if (adapter != null) {
101
		if (adapter != null) {
110
			return adapter.getLabel(element);
102
			return adapter.getLabel(element);
111
		}
103
		}
(-)Eclipse UI/org/eclipse/ui/internal/operations/AdvancedValidationUserApprover.java (-1 / +2 lines)
Lines 37-42 Link Here
37
import org.eclipse.ui.internal.WorkbenchMessages;
37
import org.eclipse.ui.internal.WorkbenchMessages;
38
import org.eclipse.ui.internal.WorkbenchPlugin;
38
import org.eclipse.ui.internal.WorkbenchPlugin;
39
import org.eclipse.ui.internal.misc.StatusUtil;
39
import org.eclipse.ui.internal.misc.StatusUtil;
40
import org.eclipse.ui.internal.util.Util;
40
41
41
/**
42
/**
42
 * <p>
43
 * <p>
Lines 387-393 Link Here
387
	 */
388
	 */
388
	Shell getShell(IAdaptable uiInfo) {
389
	Shell getShell(IAdaptable uiInfo) {
389
		if (uiInfo != null) {
390
		if (uiInfo != null) {
390
			Shell shell = (Shell) uiInfo.getAdapter(Shell.class);
391
			Shell shell = (Shell) Util.getAdapter(uiInfo, Shell.class);
391
			if (shell != null) {
392
			if (shell != null) {
392
				return shell;
393
				return shell;
393
			}
394
			}
(-)Eclipse UI/org/eclipse/ui/SelectionEnabler.java (-2 / +1 lines)
Lines 487-494 Link Here
487
			if (sc.nameFilter == null) {
487
			if (sc.nameFilter == null) {
488
				return true;
488
				return true;
489
			}
489
			}
490
			IWorkbenchAdapter de = (IWorkbenchAdapter) element
490
			IWorkbenchAdapter de = (IWorkbenchAdapter) Util.getAdapter(element, IWorkbenchAdapter.class);
491
					.getAdapter(IWorkbenchAdapter.class);
492
			if ((de != null)
491
			if ((de != null)
493
					&& verifyNameMatch(de.getLabel(element), sc.nameFilter)) {
492
					&& verifyNameMatch(de.getLabel(element), sc.nameFilter)) {
494
				return true;
493
				return true;
(-)Eclipse UI/org/eclipse/ui/internal/handlers/ShowKeyAssistHandler.java (-2 / +1 lines)
Lines 33-40 Link Here
33
	 */
33
	 */
34
	public Object execute(final ExecutionEvent event) {
34
	public Object execute(final ExecutionEvent event) {
35
		final IWorkbench workbench = PlatformUI.getWorkbench();
35
		final IWorkbench workbench = PlatformUI.getWorkbench();
36
		final IBindingService bindingService = (IBindingService) workbench
36
		final IBindingService bindingService = (IBindingService) workbench.getService(IBindingService.class);
37
				.getAdapter(IBindingService.class);
38
		bindingService.openKeyAssistDialog();
37
		bindingService.openKeyAssistDialog();
39
		return null;
38
		return null;
40
	}
39
	}
(-)Eclipse UI/org/eclipse/ui/actions/BaseNewWizardMenu.java (-2 / +3 lines)
Lines 35-40 Link Here
35
import org.eclipse.ui.internal.WorkbenchPlugin;
35
import org.eclipse.ui.internal.WorkbenchPlugin;
36
import org.eclipse.ui.internal.WorkbenchWindow;
36
import org.eclipse.ui.internal.WorkbenchWindow;
37
import org.eclipse.ui.internal.actions.NewWizardShortcutAction;
37
import org.eclipse.ui.internal.actions.NewWizardShortcutAction;
38
import org.eclipse.ui.internal.util.Util;
38
import org.eclipse.ui.wizards.IWizardDescriptor;
39
import org.eclipse.ui.wizards.IWizardDescriptor;
39
40
40
/**
41
/**
Lines 177-184 Link Here
177
                action = new NewWizardShortcutAction(workbenchWindow,
178
                action = new NewWizardShortcutAction(workbenchWindow,
178
						wizardDesc);
179
						wizardDesc);
179
				actions.put(id, action);
180
				actions.put(id, action);
180
				IConfigurationElement element = (IConfigurationElement) wizardDesc
181
				IConfigurationElement element = (IConfigurationElement) Util
181
						.getAdapter(IConfigurationElement.class);
182
						.getAdapter(wizardDesc, IConfigurationElement.class);
182
				if (element != null) {
183
				if (element != null) {
183
					workbenchWindow.getExtensionTracker().registerObject(
184
					workbenchWindow.getExtensionTracker().registerObject(
184
							element.getDeclaringExtension(), action,
185
							element.getDeclaringExtension(), action,
(-)Eclipse UI/org/eclipse/ui/actions/NewWizardAction.java (-1 / +2 lines)
Lines 30-35 Link Here
30
import org.eclipse.ui.internal.WorkbenchMessages;
30
import org.eclipse.ui.internal.WorkbenchMessages;
31
import org.eclipse.ui.internal.WorkbenchPlugin;
31
import org.eclipse.ui.internal.WorkbenchPlugin;
32
import org.eclipse.ui.internal.dialogs.NewWizard;
32
import org.eclipse.ui.internal.dialogs.NewWizard;
33
import org.eclipse.ui.internal.util.Util;
33
34
34
/**
35
/**
35
 * Invoke the resource creation wizard selection Wizard.
36
 * Invoke the resource creation wizard selection Wizard.
Lines 151-157 Link Here
151
                        .getActivePart();
152
                        .getActivePart();
152
                if (part instanceof IEditorPart) {
153
                if (part instanceof IEditorPart) {
153
                    IEditorInput input = ((IEditorPart) part).getEditorInput();
154
                    IEditorInput input = ((IEditorPart) part).getEditorInput();
154
                    Object resource = input.getAdapter(resourceClass);
155
                    Object resource = Util.getAdapter(input, resourceClass);
155
                    if (resource != null) {
156
                    if (resource != null) {
156
                        selectionToPass = new StructuredSelection(resource);
157
                        selectionToPass = new StructuredSelection(resource);
157
                    }
158
                    }
(-)Eclipse UI/org/eclipse/ui/internal/registry/ViewRegistry.java (-2 / +4 lines)
Lines 10-16 Link Here
10
 *******************************************************************************/
10
 *******************************************************************************/
11
package org.eclipse.ui.internal.registry;
11
package org.eclipse.ui.internal.registry;
12
12
13
import com.ibm.icu.text.MessageFormat;
14
import java.util.ArrayList;
13
import java.util.ArrayList;
15
import java.util.Comparator;
14
import java.util.Comparator;
16
import java.util.Iterator;
15
import java.util.Iterator;
Lines 30-40 Link Here
30
import org.eclipse.ui.IPluginContribution;
29
import org.eclipse.ui.IPluginContribution;
31
import org.eclipse.ui.PlatformUI;
30
import org.eclipse.ui.PlatformUI;
32
import org.eclipse.ui.internal.WorkbenchPlugin;
31
import org.eclipse.ui.internal.WorkbenchPlugin;
32
import org.eclipse.ui.internal.util.Util;
33
import org.eclipse.ui.views.IStickyViewDescriptor;
33
import org.eclipse.ui.views.IStickyViewDescriptor;
34
import org.eclipse.ui.views.IViewCategory;
34
import org.eclipse.ui.views.IViewCategory;
35
import org.eclipse.ui.views.IViewDescriptor;
35
import org.eclipse.ui.views.IViewDescriptor;
36
import org.eclipse.ui.views.IViewRegistry;
36
import org.eclipse.ui.views.IViewRegistry;
37
37
38
import com.ibm.icu.text.MessageFormat;
39
38
/**
40
/**
39
 * The central manager for view descriptors.
41
 * The central manager for view descriptors.
40
 */
42
 */
Lines 175-181 Link Here
175
			dirtyViewCategoryMappings = true;
177
			dirtyViewCategoryMappings = true;
176
			// Mark categories list as dirty
178
			// Mark categories list as dirty
177
			categories.add(desc);
179
			categories.add(desc);
178
			IConfigurationElement element = (IConfigurationElement) desc.getAdapter(IConfigurationElement.class);
180
			IConfigurationElement element = (IConfigurationElement) Util.getAdapter(desc, IConfigurationElement.class);
179
			if (element == null) {
181
			if (element == null) {
180
				return;
182
				return;
181
			}
183
			}
(-)Eclipse UI/org/eclipse/ui/internal/registry/ViewDescriptor.java (-4 / +2 lines)
Lines 251-258 Link Here
251
    public final void activateHandler() {
251
    public final void activateHandler() {
252
		if (handlerActivation == null) {
252
		if (handlerActivation == null) {
253
			final IHandler handler = new ShowViewHandler(getId());
253
			final IHandler handler = new ShowViewHandler(getId());
254
			final IHandlerService handlerService = (IHandlerService) PlatformUI
254
			final IHandlerService handlerService = (IHandlerService) PlatformUI.getWorkbench().getService(IHandlerService.class);
255
					.getWorkbench().getAdapter(IHandlerService.class);
256
			handlerActivation = handlerService
255
			handlerActivation = handlerService
257
					.activateHandler(getId(), handler);
256
					.activateHandler(getId(), handler);
258
		}
257
		}
Lines 267-274 Link Here
267
	 */
266
	 */
268
	public final void deactivateHandler() {
267
	public final void deactivateHandler() {
269
		if (handlerActivation != null) {
268
		if (handlerActivation != null) {
270
			final IHandlerService handlerService = (IHandlerService) PlatformUI
269
			final IHandlerService handlerService = (IHandlerService) PlatformUI.getWorkbench().getService(IHandlerService.class);
271
					.getWorkbench().getAdapter(IHandlerService.class);
272
			handlerService.deactivateHandler(handlerActivation);
270
			handlerService.deactivateHandler(handlerActivation);
273
			handlerActivation = null;
271
			handlerActivation = null;
274
		}
272
		}
(-)Eclipse UI/org/eclipse/ui/internal/registry/WizardsRegistryReader.java (-3 / +5 lines)
Lines 10-16 Link Here
10
 *******************************************************************************/
10
 *******************************************************************************/
11
package org.eclipse.ui.internal.registry;
11
package org.eclipse.ui.internal.registry;
12
12
13
import com.ibm.icu.text.Collator;
14
import java.util.ArrayList;
13
import java.util.ArrayList;
15
import java.util.Arrays;
14
import java.util.Arrays;
16
import java.util.Collections;
15
import java.util.Collections;
Lines 28-33 Link Here
28
import org.eclipse.ui.internal.WorkbenchPlugin;
27
import org.eclipse.ui.internal.WorkbenchPlugin;
29
import org.eclipse.ui.internal.dialogs.WizardCollectionElement;
28
import org.eclipse.ui.internal.dialogs.WizardCollectionElement;
30
import org.eclipse.ui.internal.dialogs.WorkbenchWizardElement;
29
import org.eclipse.ui.internal.dialogs.WorkbenchWizardElement;
30
import org.eclipse.ui.internal.util.Util;
31
32
import com.ibm.icu.text.Collator;
31
33
32
/**
34
/**
33
 *  Instances access the registry that is provided at creation time
35
 *  Instances access the registry that is provided at creation time
Lines 268-275 Link Here
268
		}
270
		}
269
271
270
        if (parent != null) {
272
        if (parent != null) {
271
			createCollectionElement(parent, (IConfigurationElement) category
273
			createCollectionElement(parent, (IConfigurationElement) Util.getAdapter(category,
272
					.getAdapter(IConfigurationElement.class));
274
					IConfigurationElement.class));
273
		}
275
		}
274
    }
276
    }
275
277
(-)Eclipse UI/org/eclipse/ui/internal/contexts/WorkbenchContextSupport.java (-4 / +2 lines)
Lines 80-89 Link Here
80
	public WorkbenchContextSupport(final Workbench workbenchToSupport,
80
	public WorkbenchContextSupport(final Workbench workbenchToSupport,
81
			final ContextManager contextManager) {
81
			final ContextManager contextManager) {
82
		workbench = workbenchToSupport;
82
		workbench = workbenchToSupport;
83
		contextService = (IContextService) workbench
83
		contextService = (IContextService) workbench.getService(IContextService.class);
84
				.getAdapter(IContextService.class);
84
		bindingService = (IBindingService) workbench.getService(IBindingService.class);
85
		bindingService = (IBindingService) workbench
86
				.getAdapter(IBindingService.class);
87
		contextManagerWrapper = ContextManagerFactory
85
		contextManagerWrapper = ContextManagerFactory
88
				.getContextManagerWrapper(contextManager);
86
				.getContextManagerWrapper(contextManager);
89
	}
87
	}
(-)Eclipse UI/org/eclipse/ui/operations/NonLocalUndoUserApprover.java (-10 / +9 lines)
Lines 26-31 Link Here
26
import org.eclipse.ui.IEditorPart;
26
import org.eclipse.ui.IEditorPart;
27
import org.eclipse.ui.internal.Workbench;
27
import org.eclipse.ui.internal.Workbench;
28
import org.eclipse.ui.internal.WorkbenchMessages;
28
import org.eclipse.ui.internal.WorkbenchMessages;
29
import org.eclipse.ui.internal.util.Util;
29
30
30
/**
31
/**
31
 * <p>
32
 * <p>
Lines 184-193 Link Here
184
					// one last try - try to adapt the modified element if a
185
					// one last try - try to adapt the modified element if a
185
					// preferred
186
					// preferred
186
					// comparison class has been provided.
187
					// comparison class has been provided.
187
					if (affectedObjectsClass != null
188
					if (affectedObjectsClass != null) {
188
							&& modifiedElement instanceof IAdaptable) {
189
						Object adapter = Util.getAdapter(modifiedElement, 
189
						if (elementsContains(((IAdaptable) modifiedElement)
190
								affectedObjectsClass);
190
								.getAdapter(affectedObjectsClass))) {
191
						if (adapter != null && elementsContains(adapter)) {
191
							local = true;
192
							local = true;
192
						}
193
						}
193
					}
194
					}
Lines 248-255 Link Here
248
		// not originate
249
		// not originate
249
		// in our context.
250
		// in our context.
250
		if (uiInfo != null) {
251
		if (uiInfo != null) {
251
			IUndoContext originatingContext = (IUndoContext) uiInfo
252
			IUndoContext originatingContext = (IUndoContext) Util.getAdapter(uiInfo, 
252
					.getAdapter(IUndoContext.class);
253
					IUndoContext.class);
253
			if (originatingContext != null
254
			if (originatingContext != null
254
					&& !(originatingContext.matches(context))) {
255
					&& !(originatingContext.matches(context))) {
255
				return false;
256
				return false;
Lines 276-285 Link Here
276
				Object element = elements[i];
277
				Object element = elements[i];
277
				elementsAndAdapters.add(element);
278
				elementsAndAdapters.add(element);
278
				if (affectedObjectsClass != null
279
				if (affectedObjectsClass != null
279
						&& !affectedObjectsClass.isInstance(element)
280
						&& !affectedObjectsClass.isInstance(element)) {
280
						&& element instanceof IAdaptable) {
281
					Object adapter = Util.getAdapter(element, affectedObjectsClass);
281
					Object adapter = ((IAdaptable) element)
282
							.getAdapter(affectedObjectsClass);
283
					if (adapter != null) {
282
					if (adapter != null) {
284
						elementsAndAdapters.add(adapter);
283
						elementsAndAdapters.add(adapter);
285
					}
284
					}
(-)Eclipse UI/org/eclipse/ui/operations/OperationHistoryActionHandler.java (-1 / +2 lines)
Lines 39-44 Link Here
39
import org.eclipse.ui.internal.WorkbenchPlugin;
39
import org.eclipse.ui.internal.WorkbenchPlugin;
40
import org.eclipse.ui.internal.misc.StatusUtil;
40
import org.eclipse.ui.internal.misc.StatusUtil;
41
import org.eclipse.ui.internal.operations.TimeTriggeredProgressMonitorDialog;
41
import org.eclipse.ui.internal.operations.TimeTriggeredProgressMonitorDialog;
42
import org.eclipse.ui.internal.util.Util;
42
import org.eclipse.ui.part.MultiPageEditorSite;
43
import org.eclipse.ui.part.MultiPageEditorSite;
43
44
44
/**
45
/**
Lines 330-336 Link Here
330
			// See https://bugs.eclipse.org/bugs/show_bug.cgi?id=108144
331
			// See https://bugs.eclipse.org/bugs/show_bug.cgi?id=108144
331
			IWorkbenchPart part = site.getPart();
332
			IWorkbenchPart part = site.getPart();
332
			if (part != null) {
333
			if (part != null) {
333
				return part.getAdapter(adapter);
334
				return Util.getAdapter(part, adapter);
334
			}
335
			}
335
		}
336
		}
336
		return null;
337
		return null;
(-)Eclipse UI/org/eclipse/ui/internal/util/Util.java (+55 lines)
Lines 28-33 Link Here
28
import java.util.TreeMap;
28
import java.util.TreeMap;
29
import java.util.TreeSet;
29
import java.util.TreeSet;
30
30
31
import org.eclipse.core.runtime.Assert;
32
import org.eclipse.core.runtime.IAdaptable;
33
import org.eclipse.core.runtime.Platform;
34
import org.eclipse.core.runtime.PlatformObject;
31
import org.eclipse.swt.widgets.Shell;
35
import org.eclipse.swt.widgets.Shell;
32
import org.eclipse.ui.IWorkbenchWindow;
36
import org.eclipse.ui.IWorkbenchWindow;
33
import org.eclipse.ui.PlatformUI;
37
import org.eclipse.ui.PlatformUI;
Lines 60-65 Link Here
60
64
61
        return ZERO_LENGTH_STRING;
65
        return ZERO_LENGTH_STRING;
62
    }
66
    }
67
    
68
    /**
69
     * If it is possible to adapt the given object to the given type, this
70
     * returns the adapter. Performs the following checks:
71
     * 
72
     * <ol>
73
     * <li>Returns <code>sourceObject</code> if it is an instance of the
74
     * adapter type.</li>
75
     * <li>If sourceObject implements IAdaptable, it is queried for adapters.</li>
76
     * <li>If sourceObject is not an instance of PlatformObject (which would have
77
     * already done so), the adapter manager is queried for adapters</li>
78
     * </ol>
79
     * 
80
     * Otherwise returns null.
81
     * 
82
     * @param sourceObject
83
     *            object to adapt, or null
84
     * @param adapterType
85
     *            type to adapt to
86
     * @return a representation of sourceObject that is assignable to the
87
     *         adapter type, or null if no such representation exists
88
     */
89
    public static Object getAdapter(Object sourceObject, Class adapterType) {
90
    	Assert.isNotNull(adapterType);
91
        if (sourceObject == null) {
92
            return null;
93
        }
94
        if (adapterType.isInstance(sourceObject)) {
95
            return sourceObject;
96
        }
97
98
        if (sourceObject instanceof IAdaptable) {
99
            IAdaptable adaptable = (IAdaptable) sourceObject;
100
101
            Object result = adaptable.getAdapter(adapterType);
102
            if (result != null) {
103
                // Sanity-check
104
                Assert.isTrue(adapterType.isInstance(result));
105
                return result;
106
            }
107
        } 
108
        
109
        if (!(sourceObject instanceof PlatformObject)) {
110
            Object result = Platform.getAdapterManager().getAdapter(sourceObject, adapterType);
111
            if (result != null) {
112
                return result;
113
            }
114
        }
115
116
        return null;
117
    }
63
118
64
    public static void assertInstance(Object object, Class c) {
119
    public static void assertInstance(Object object, Class c) {
65
        assertInstance(object, c, false);
120
        assertInstance(object, c, false);
(-)Eclipse UI/org/eclipse/ui/fieldassist/ContentAssistField.java (-1 / +1 lines)
Lines 126-132 Link Here
126
		// Always update the decoration text since the key binding may
126
		// Always update the decoration text since the key binding may
127
		// have changed since it was last retrieved.
127
		// have changed since it was last retrieved.
128
		IBindingService bindingService = (IBindingService) PlatformUI
128
		IBindingService bindingService = (IBindingService) PlatformUI
129
				.getWorkbench().getAdapter(IBindingService.class);
129
				.getWorkbench().getService(IBindingService.class);
130
		dec.setDescription(NLS.bind(
130
		dec.setDescription(NLS.bind(
131
				WorkbenchMessages.ContentAssist_Cue_Description_Key,
131
				WorkbenchMessages.ContentAssist_Cue_Description_Key,
132
				bindingService.getBestActiveBindingFormattedFor(adapter
132
				bindingService.getBestActiveBindingFormattedFor(adapter
(-)Eclipse UI/org/eclipse/ui/fieldassist/ContentAssistCommandAdapter.java (-2 / +1 lines)
Lines 115-122 Link Here
115
		addListeners(control);
115
		addListeners(control);
116
116
117
		// Cache the handler service so we don't have to retrieve it each time
117
		// Cache the handler service so we don't have to retrieve it each time
118
		this.handlerService = (IHandlerService) PlatformUI.getWorkbench()
118
		this.handlerService = (IHandlerService) PlatformUI.getWorkbench().getService(IHandlerService.class);
119
				.getAdapter(IHandlerService.class);
120
	}
119
	}
121
120
122
	/*
121
	/*
(-)Eclipse UI/org/eclipse/ui/internal/keys/KeysPreferencePage.java (-6 / +3 lines)
Lines 1215-1226 Link Here
1215
1215
1216
	public final void init(final IWorkbench workbench) {
1216
	public final void init(final IWorkbench workbench) {
1217
		activityManager = workbench.getActivitySupport().getActivityManager();
1217
		activityManager = workbench.getActivitySupport().getActivityManager();
1218
		bindingService = (IBindingService) workbench
1218
		bindingService = (IBindingService) workbench.getService(IBindingService.class);
1219
				.getAdapter(IBindingService.class);
1219
		commandService = (ICommandService) workbench.getService(ICommandService.class);
1220
		commandService = (ICommandService) workbench
1220
		contextService = (IContextService) workbench.getService(IContextService.class);
1221
				.getAdapter(ICommandService.class);
1222
		contextService = (IContextService) workbench
1223
				.getAdapter(IContextService.class);
1224
	}
1221
	}
1225
1222
1226
	/**
1223
	/**
(-)Eclipse UI/org/eclipse/ui/internal/keys/NewKeysPreferencePage.java (-8 / +4 lines)
Lines 1279-1292 Link Here
1279
	 * @see org.eclipse.ui.IWorkbenchPreferencePage#init(org.eclipse.ui.IWorkbench)
1279
	 * @see org.eclipse.ui.IWorkbenchPreferencePage#init(org.eclipse.ui.IWorkbench)
1280
	 */
1280
	 */
1281
	public final void init(final IWorkbench workbench) {
1281
	public final void init(final IWorkbench workbench) {
1282
		bindingService = (IBindingService) workbench
1282
		bindingService = (IBindingService) workbench.getService(IBindingService.class);
1283
				.getAdapter(IBindingService.class);
1283
		commandImageService = (ICommandImageService) workbench.getService(ICommandImageService.class);
1284
		commandImageService = (ICommandImageService) workbench
1284
		commandService = (ICommandService) workbench.getService(ICommandService.class);
1285
				.getAdapter(ICommandImageService.class);
1285
		contextService = (IContextService) workbench.getService(IContextService.class);
1286
		commandService = (ICommandService) workbench
1287
				.getAdapter(ICommandService.class);
1288
		contextService = (IContextService) workbench
1289
				.getAdapter(IContextService.class);
1290
	}
1286
	}
1291
1287
1292
	/**
1288
	/**
(-)Eclipse UI/org/eclipse/ui/internal/keys/WorkbenchKeyboard.java (-12 / +6 lines)
Lines 461-468 Link Here
461
		}
461
		}
462
462
463
		try {
463
		try {
464
			final IHandlerService handlerService = (IHandlerService) workbench
464
			final IHandlerService handlerService = (IHandlerService) workbench.getService(IHandlerService.class);
465
					.getAdapter(IHandlerService.class);
466
			handlerService.executeCommand(parameterizedCommand, trigger);
465
			handlerService.executeCommand(parameterizedCommand, trigger);
467
		} catch (final NotDefinedException e) {
466
		} catch (final NotDefinedException e) {
468
			// The command is not defined. Forwarded to the IExecutionListener.
467
			// The command is not defined. Forwarded to the IExecutionListener.
Lines 589-596 Link Here
589
	 */
588
	 */
590
	private Binding getPerfectMatch(KeySequence keySequence) {
589
	private Binding getPerfectMatch(KeySequence keySequence) {
591
		if (bindingService == null) {
590
		if (bindingService == null) {
592
			bindingService = (IBindingService) workbench
591
			bindingService = (IBindingService) workbench.getService(IBindingService.class);
593
					.getAdapter(IBindingService.class);
594
		}
592
		}
595
		return bindingService.getPerfectMatch(keySequence);
593
		return bindingService.getPerfectMatch(keySequence);
596
	}
594
	}
Lines 643-650 Link Here
643
	 */
641
	 */
644
	private boolean isPartialMatch(KeySequence keySequence) {
642
	private boolean isPartialMatch(KeySequence keySequence) {
645
		if (bindingService == null) {
643
		if (bindingService == null) {
646
			bindingService = (IBindingService) workbench
644
			bindingService = (IBindingService) workbench.getService(IBindingService.class);
647
					.getAdapter(IBindingService.class);
648
		}
645
		}
649
		return bindingService.isPartialMatch(keySequence);
646
		return bindingService.isPartialMatch(keySequence);
650
	}
647
	}
Lines 661-668 Link Here
661
	 */
658
	 */
662
	private boolean isPerfectMatch(KeySequence keySequence) {
659
	private boolean isPerfectMatch(KeySequence keySequence) {
663
		if (bindingService == null) {
660
		if (bindingService == null) {
664
			bindingService = (IBindingService) workbench
661
			bindingService = (IBindingService) workbench.getService(IBindingService.class);
665
					.getAdapter(IBindingService.class);
666
		}
662
		}
667
		return bindingService.isPerfectMatch(keySequence);
663
		return bindingService.isPerfectMatch(keySequence);
668
	}
664
	}
Lines 764-771 Link Here
764
			final Widget widget = event.widget;
760
			final Widget widget = event.widget;
765
761
766
			// Update the contexts.
762
			// Update the contexts.
767
			final ContextService contextService = (ContextService) workbench
763
			final ContextService contextService = (ContextService) workbench.getService(IContextService.class);
768
					.getAdapter(IContextService.class);
769
			if ((widget instanceof Control) && (!widget.isDisposed())) {
764
			if ((widget instanceof Control) && (!widget.isDisposed())) {
770
				final Shell shell = ((Control) widget).getShell();
765
				final Shell shell = ((Control) widget).getShell();
771
				contextService.updateShellKludge(shell);
766
				contextService.updateShellKludge(shell);
Lines 774-781 Link Here
774
			}
769
			}
775
770
776
			// Update the handlers.
771
			// Update the handlers.
777
			final HandlerService handlerService = (HandlerService) workbench
772
			final HandlerService handlerService = (HandlerService) workbench.getService(IHandlerService.class);
778
					.getAdapter(IHandlerService.class);
779
			if ((widget instanceof Control) && (!widget.isDisposed())) {
773
			if ((widget instanceof Control) && (!widget.isDisposed())) {
780
				final Shell shell = ((Control) widget).getShell();
774
				final Shell shell = ((Control) widget).getShell();
781
				handlerService.updateShellKludge(shell);
775
				handlerService.updateShellKludge(shell);
(-)Eclipse UI/org/eclipse/ui/internal/keys/KeyAssistDialog.java (-6 / +3 lines)
Lines 166-175 Link Here
166
166
167
		this.activityManager = workbench.getActivitySupport()
167
		this.activityManager = workbench.getActivitySupport()
168
				.getActivityManager();
168
				.getActivityManager();
169
		this.bindingService = (IBindingService) workbench
169
		this.bindingService = (IBindingService) workbench.getService(IBindingService.class);
170
				.getAdapter(IBindingService.class);
170
		this.commandService = (ICommandService) workbench.getService(ICommandService.class);
171
		this.commandService = (ICommandService) workbench
172
				.getAdapter(ICommandService.class);
173
		this.keyBindingState = associatedState;
171
		this.keyBindingState = associatedState;
174
		this.workbenchKeyboard = associatedKeyboard;
172
		this.workbenchKeyboard = associatedKeyboard;
175
		
173
		
Lines 650-657 Link Here
650
	private final void registerShellType() {
648
	private final void registerShellType() {
651
		final Shell shell = getShell();
649
		final Shell shell = getShell();
652
		final IContextService contextService = (IContextService) keyBindingState
650
		final IContextService contextService = (IContextService) keyBindingState
653
				.getAssociatedWindow().getWorkbench().getAdapter(
651
				.getAssociatedWindow().getWorkbench().getService(IContextService.class);
654
						IContextService.class);
655
		contextService.registerShell(shell, contextService
652
		contextService.registerShell(shell, contextService
656
				.getShellType((Shell) shell.getParent()));
653
				.getShellType((Shell) shell.getParent()));
657
	}
654
	}
(-)Eclipse UI/org/eclipse/ui/model/WorkbenchLabelProvider.java (-11 / +3 lines)
Lines 10-16 Link Here
10
 *******************************************************************************/
10
 *******************************************************************************/
11
package org.eclipse.ui.model;
11
package org.eclipse.ui.model;
12
12
13
import org.eclipse.core.runtime.IAdaptable;
14
import org.eclipse.jface.resource.ImageDescriptor;
13
import org.eclipse.jface.resource.ImageDescriptor;
15
import org.eclipse.jface.viewers.DecoratingLabelProvider;
14
import org.eclipse.jface.viewers.DecoratingLabelProvider;
16
import org.eclipse.jface.viewers.IColorProvider;
15
import org.eclipse.jface.viewers.IColorProvider;
Lines 28-33 Link Here
28
import org.eclipse.ui.IPropertyListener;
27
import org.eclipse.ui.IPropertyListener;
29
import org.eclipse.ui.PlatformUI;
28
import org.eclipse.ui.PlatformUI;
30
import org.eclipse.ui.internal.util.SWTResourceUtil;
29
import org.eclipse.ui.internal.util.SWTResourceUtil;
30
import org.eclipse.ui.internal.util.Util;
31
31
32
/**
32
/**
33
 * Provides basic labels for adaptable objects that have the
33
 * Provides basic labels for adaptable objects that have the
Lines 121-131 Link Here
121
     * object is not adaptable. 
121
     * object is not adaptable. 
122
     */
122
     */
123
    protected final IWorkbenchAdapter getAdapter(Object o) {
123
    protected final IWorkbenchAdapter getAdapter(Object o) {
124
        if (!(o instanceof IAdaptable)) {
124
        return (IWorkbenchAdapter)Util.getAdapter(o, IWorkbenchAdapter.class);
125
            return null;
126
        }
127
        return (IWorkbenchAdapter) ((IAdaptable) o)
128
                .getAdapter(IWorkbenchAdapter.class);
129
    }
125
    }
130
126
131
    /**
127
    /**
Lines 136-146 Link Here
136
     * object is not adaptable. 
132
     * object is not adaptable. 
137
     */
133
     */
138
    protected final IWorkbenchAdapter2 getAdapter2(Object o) {
134
    protected final IWorkbenchAdapter2 getAdapter2(Object o) {
139
        if (!(o instanceof IAdaptable)) {
135
        return (IWorkbenchAdapter2)Util.getAdapter(o, IWorkbenchAdapter2.class);
140
            return null;
141
        }
142
        return (IWorkbenchAdapter2) ((IAdaptable) o)
143
                .getAdapter(IWorkbenchAdapter2.class);
144
    }
136
    }
145
137
146
    /* (non-Javadoc)
138
    /* (non-Javadoc)
(-)Eclipse UI/org/eclipse/ui/model/BaseWorkbenchContentProvider.java (-6 / +2 lines)
Lines 10-18 Link Here
10
 *******************************************************************************/
10
 *******************************************************************************/
11
package org.eclipse.ui.model;
11
package org.eclipse.ui.model;
12
12
13
import org.eclipse.core.runtime.IAdaptable;
14
import org.eclipse.jface.viewers.ITreeContentProvider;
13
import org.eclipse.jface.viewers.ITreeContentProvider;
15
import org.eclipse.jface.viewers.Viewer;
14
import org.eclipse.jface.viewers.Viewer;
15
import org.eclipse.ui.internal.util.Util;
16
16
17
/**
17
/**
18
 * Tree content provider for objects that can be adapted to the interface
18
 * Tree content provider for objects that can be adapted to the interface
Lines 52-62 Link Here
52
     * @return the corresponding workbench adapter object
52
     * @return the corresponding workbench adapter object
53
     */
53
     */
54
    protected IWorkbenchAdapter getAdapter(Object element) {
54
    protected IWorkbenchAdapter getAdapter(Object element) {
55
        if (!(element instanceof IAdaptable)) {
55
        return (IWorkbenchAdapter)Util.getAdapter(element, IWorkbenchAdapter.class);
56
            return null;
57
        }
58
        return (IWorkbenchAdapter) ((IAdaptable) element)
59
                .getAdapter(IWorkbenchAdapter.class);
60
    }
56
    }
61
57
62
    /* (non-Javadoc)
58
    /* (non-Javadoc)
(-)Eclipse UI/org/eclipse/ui/part/MultiPageEditorPart.java (-1 / +2 lines)
Lines 42-47 Link Here
42
import org.eclipse.ui.PartInitException;
42
import org.eclipse.ui.PartInitException;
43
import org.eclipse.ui.internal.WorkbenchPlugin;
43
import org.eclipse.ui.internal.WorkbenchPlugin;
44
import org.eclipse.ui.internal.services.INestable;
44
import org.eclipse.ui.internal.services.INestable;
45
import org.eclipse.ui.internal.util.Util;
45
import org.eclipse.ui.services.IServiceLocator;
46
import org.eclipse.ui.services.IServiceLocator;
46
47
47
/**
48
/**
Lines 813-819 Link Here
813
			IEditorPart innerEditor = getActiveEditor();
814
			IEditorPart innerEditor = getActiveEditor();
814
			// see bug 138823 - this is a hack
815
			// see bug 138823 - this is a hack
815
			if (innerEditor != null && innerEditor != this) {
816
			if (innerEditor != null && innerEditor != this) {
816
				result = innerEditor.getAdapter(adapter);
817
				result = Util.getAdapter(innerEditor, adapter);
817
			}
818
			}
818
		}
819
		}
819
		return result;
820
		return result;
(-)Eclipse UI/org/eclipse/ui/part/PageBookView.java (-7 / +5 lines)
Lines 17-23 Link Here
17
import java.util.Set;
17
import java.util.Set;
18
18
19
import org.eclipse.core.commands.common.EventManager;
19
import org.eclipse.core.commands.common.EventManager;
20
import org.eclipse.core.runtime.IAdaptable;
21
import org.eclipse.core.runtime.Platform;
20
import org.eclipse.core.runtime.Platform;
22
import org.eclipse.jface.action.IAction;
21
import org.eclipse.jface.action.IAction;
23
import org.eclipse.jface.util.IPropertyChangeListener;
22
import org.eclipse.jface.util.IPropertyChangeListener;
Lines 39-44 Link Here
39
import org.eclipse.ui.PartInitException;
38
import org.eclipse.ui.PartInitException;
40
import org.eclipse.ui.SubActionBars;
39
import org.eclipse.ui.SubActionBars;
41
import org.eclipse.ui.internal.WorkbenchPlugin;
40
import org.eclipse.ui.internal.WorkbenchPlugin;
41
import org.eclipse.ui.internal.util.Util;
42
42
43
/**
43
/**
44
 * Abstract superclass of all multi-page workbench views.
44
 * Abstract superclass of all multi-page workbench views.
Lines 565-579 Link Here
565
	public Object getAdapter(Class key) {
565
	public Object getAdapter(Class key) {
566
		// delegate to the current page, if supported
566
		// delegate to the current page, if supported
567
		IPage page = getCurrentPage();
567
		IPage page = getCurrentPage();
568
		if (page instanceof IAdaptable) {
568
		Object adapter = Util.getAdapter(page, key);
569
			Object adapter = ((IAdaptable) page).getAdapter(key);
569
		if (adapter != null) {
570
			if (adapter != null) {
570
			return adapter;
571
				return adapter;
572
			}
573
		}
571
		}
574
		// if the page did not find the adapter, look for one provided by
572
		// if the page did not find the adapter, look for one provided by
575
		// this view before delegating to super.
573
		// this view before delegating to super.
576
		Object adapter = getViewAdapter(key);
574
		adapter = getViewAdapter(key);
577
		if (adapter != null) {
575
		if (adapter != null) {
578
			return adapter;
576
			return adapter;
579
		}
577
		}
(-)Eclipse UI/org/eclipse/ui/progress/DeferredTreeContentManager.java (-27 / +5 lines)
Lines 11-17 Link Here
11
package org.eclipse.ui.progress;
11
package org.eclipse.ui.progress;
12
12
13
import org.eclipse.core.runtime.Assert;
13
import org.eclipse.core.runtime.Assert;
14
import org.eclipse.core.runtime.IAdaptable;
15
import org.eclipse.core.runtime.IProgressMonitor;
14
import org.eclipse.core.runtime.IProgressMonitor;
16
import org.eclipse.core.runtime.IStatus;
15
import org.eclipse.core.runtime.IStatus;
17
import org.eclipse.core.runtime.Platform;
16
import org.eclipse.core.runtime.Platform;
Lines 26-31 Link Here
26
import org.eclipse.ui.IWorkbenchPartSite;
25
import org.eclipse.ui.IWorkbenchPartSite;
27
import org.eclipse.ui.PlatformUI;
26
import org.eclipse.ui.PlatformUI;
28
import org.eclipse.ui.internal.progress.ProgressMessages;
27
import org.eclipse.ui.internal.progress.ProgressMessages;
28
import org.eclipse.ui.internal.util.Util;
29
import org.eclipse.ui.model.IWorkbenchAdapter;
29
import org.eclipse.ui.model.IWorkbenchAdapter;
30
30
31
/**
31
/**
Lines 86-93 Link Here
86
    public DeferredTreeContentManager(ITreeContentProvider provider,
86
    public DeferredTreeContentManager(ITreeContentProvider provider,
87
            AbstractTreeViewer viewer, IWorkbenchPartSite site) {
87
            AbstractTreeViewer viewer, IWorkbenchPartSite site) {
88
        this(provider, viewer);
88
        this(provider, viewer);
89
        Object siteService = site
89
        Object siteService = Util.getAdapter(site, 
90
                .getAdapter(IWorkbenchSiteProgressService.class);
90
                IWorkbenchSiteProgressService.class);
91
        if (siteService != null) {
91
        if (siteService != null) {
92
			progressService = (IWorkbenchSiteProgressService) siteService;
92
			progressService = (IWorkbenchSiteProgressService) siteService;
93
		}
93
		}
Lines 163-180 Link Here
163
     * @return IDeferredWorkbenchAdapter or <code>null</code>
163
     * @return IDeferredWorkbenchAdapter or <code>null</code>
164
     */
164
     */
165
    protected IDeferredWorkbenchAdapter getAdapter(Object element) {
165
    protected IDeferredWorkbenchAdapter getAdapter(Object element) {
166
        if (element instanceof IDeferredWorkbenchAdapter) {
166
        return (IDeferredWorkbenchAdapter)Util.getAdapter(element, IDeferredWorkbenchAdapter.class);
167
			return (IDeferredWorkbenchAdapter) element;
168
		}
169
        if (!(element instanceof IAdaptable)) {
170
			return null;
171
		}
172
        Object adapter = ((IAdaptable) element)
173
                .getAdapter(IDeferredWorkbenchAdapter.class);
174
        if (adapter == null) {
175
			return null;
176
		}
177
        return (IDeferredWorkbenchAdapter) adapter;
178
    }
167
    }
179
168
180
    /**
169
    /**
Lines 260-277 Link Here
260
             *            The object we are adapting to.
249
             *            The object we are adapting to.
261
             */
250
             */
262
            private IWorkbenchAdapter getWorkbenchAdapter(Object element) {
251
            private IWorkbenchAdapter getWorkbenchAdapter(Object element) {
263
                if (element instanceof IWorkbenchAdapter) {
252
                return (IWorkbenchAdapter) Util.getAdapter(element, IWorkbenchAdapter.class);
264
					return (IWorkbenchAdapter) element;
265
				}
266
                if (!(element instanceof IAdaptable)) {
267
					return null;
268
				}
269
                Object workbenchAdapter = ((IAdaptable) element)
270
                        .getAdapter(IWorkbenchAdapter.class);
271
                if (workbenchAdapter == null) {
272
					return null;
273
				}
274
                return (IWorkbenchAdapter) workbenchAdapter;
275
            }
253
            }
276
        };
254
        };
277
        job.addJobChangeListener(new JobChangeAdapter() {
255
        job.addJobChangeListener(new JobChangeAdapter() {

Return to bug 156581