diff options
author | Dani Megert | 2015-02-20 12:08:00 +0000 |
---|---|---|
committer | Dani Megert | 2015-02-20 12:08:00 +0000 |
commit | 035b16c4845dde58ab3f6463878cbe662349e58c (patch) | |
tree | a312725ef6ac6c4aeedc3ca81bad03b0583f5fb1 /org.eclipse.debug.examples.ui/src/org/eclipse/debug/examples | |
parent | 87bf3db976790862ceb9b321661e0234afb342ca (diff) | |
download | eclipse.platform.debug-035b16c4845dde58ab3f6463878cbe662349e58c.tar.gz eclipse.platform.debug-035b16c4845dde58ab3f6463878cbe662349e58c.tar.xz eclipse.platform.debug-035b16c4845dde58ab3f6463878cbe662349e58c.zip |
Fixed bug 460417: Fix compiler problems from generified IAdaptable#getAdapter(..)
Diffstat (limited to 'org.eclipse.debug.examples.ui/src/org/eclipse/debug/examples')
8 files changed, 64 insertions, 54 deletions
diff --git a/org.eclipse.debug.examples.ui/src/org/eclipse/debug/examples/ui/midi/adapters/MidiAdapterFactory.java b/org.eclipse.debug.examples.ui/src/org/eclipse/debug/examples/ui/midi/adapters/MidiAdapterFactory.java index b3dfbbead..db3b6ab71 100644 --- a/org.eclipse.debug.examples.ui/src/org/eclipse/debug/examples/ui/midi/adapters/MidiAdapterFactory.java +++ b/org.eclipse.debug.examples.ui/src/org/eclipse/debug/examples/ui/midi/adapters/MidiAdapterFactory.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008, 2009 IBM Corporation and others. + * Copyright (c) 2008, 2015 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -15,6 +15,7 @@ import javax.sound.midi.MidiEvent; import javax.sound.midi.Track; import org.eclipse.core.runtime.IAdapterFactory; + import org.eclipse.debug.core.commands.IStepOverHandler; import org.eclipse.debug.examples.core.midi.launcher.MidiLaunch; import org.eclipse.debug.examples.core.midi.launcher.SequencerControl; @@ -50,63 +51,64 @@ public class MidiAdapterFactory implements IAdapterFactory { private static IModelProxyFactory fgCheckboxModelProxyFactory = new CheckboxModelProxyFactory(); + @SuppressWarnings("unchecked") @Override - public Object getAdapter(Object adaptableObject, Class adapterType) { + public <T> T getAdapter(Object adaptableObject, Class<T> adapterType) { if (IElementContentProvider.class.equals(adapterType)) { if (adaptableObject instanceof MidiLaunch) { - return fgSequencerContentProvider; + return (T) fgSequencerContentProvider; } if (adaptableObject instanceof Track) { - return fgTackContentProvider; + return (T) fgTackContentProvider; } } if (IElementLabelProvider.class.equals(adapterType)) { if (adaptableObject instanceof Track) { - return fgTrackLabelProvider; + return (T) fgTrackLabelProvider; } if (adaptableObject instanceof SequencerControl) { - return fgControlLabelProvider; + return (T) fgControlLabelProvider; } if (adaptableObject instanceof MidiEvent) { - return fgMidiEventLabelProvdier; + return (T) fgMidiEventLabelProvdier; } } if (IColumnPresentationFactory.class.equals(adapterType)) { if (adaptableObject instanceof MidiLaunch) { - return fgSequencerColumnFactory; + return (T) fgSequencerColumnFactory; } if (adaptableObject instanceof Track) { - return fgTrackColumnFactory; + return (T) fgTrackColumnFactory; } } if (IElementEditor.class.equals(adapterType)) { if (adaptableObject instanceof SequencerControl) { - return new ControlEditor(); + return (T) new ControlEditor(); } } if (IModelProxyFactory.class.equals(adapterType)) { if (adaptableObject instanceof MidiLaunch) { - return fgSequencerModelProxyFactory; + return (T) fgSequencerModelProxyFactory; } else if (adaptableObject instanceof Track) { - return fgCheckboxModelProxyFactory; + return (T) fgCheckboxModelProxyFactory; } else if (adaptableObject instanceof MidiEvent) { - return fgCheckboxModelProxyFactory; + return (T) fgCheckboxModelProxyFactory; } } if (IElementMementoProvider.class.equals(adapterType)) { - return fgMementoProvider; + return (T) fgMementoProvider; } if (IStepOverHandler.class.equals(adapterType)) { - return fgStepOverHandler; + return (T) fgStepOverHandler; } return null; } @Override - public Class[] getAdapterList() { + public Class<?>[] getAdapterList() { return new Class[]{IElementContentProvider.class, IElementLabelProvider.class, IStepOverHandler.class,}; } } diff --git a/org.eclipse.debug.examples.ui/src/org/eclipse/debug/examples/ui/pda/adapters/AdapterFactory.java b/org.eclipse.debug.examples.ui/src/org/eclipse/debug/examples/ui/pda/adapters/AdapterFactory.java index 02a382c5c..b7b756f46 100644 --- a/org.eclipse.debug.examples.ui/src/org/eclipse/debug/examples/ui/pda/adapters/AdapterFactory.java +++ b/org.eclipse.debug.examples.ui/src/org/eclipse/debug/examples/ui/pda/adapters/AdapterFactory.java @@ -1,10 +1,10 @@ /******************************************************************************* - * Copyright (c) 2006, 2012 IBM Corporation and others. - * All rights reserved. This program and the accompanying materials + * Copyright (c) 2006, 2015 IBM Corporation and others. + * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html - * + * * Contributors: * IBM Corporation - initial API and implementation * Bjorn Freeman-Benson - initial API and implementation @@ -12,6 +12,7 @@ package org.eclipse.debug.examples.ui.pda.adapters; import org.eclipse.core.runtime.IAdapterFactory; + import org.eclipse.debug.examples.core.pda.model.PDADebugTarget; import org.eclipse.debug.examples.core.pda.model.PDAStackFrame; import org.eclipse.debug.internal.ui.viewers.model.provisional.IElementContentProvider; @@ -20,38 +21,39 @@ import org.eclipse.debug.internal.ui.viewers.model.provisional.IViewActionProvid /** - * + * * @since 3.2 * */ public class AdapterFactory implements IAdapterFactory { - + private static IElementContentProvider fgTargetAdapter = new PDADebugTargetContentProvider(); private static IModelProxyFactory fgFactory = new ModelProxyFactory(); private static IViewActionProvider fgViewActionProvider = new PDAViewActionProvider(); + @SuppressWarnings("unchecked") @Override - public Object getAdapter(Object adaptableObject, Class adapterType) { + public <T> T getAdapter(Object adaptableObject, Class<T> adapterType) { if (IElementContentProvider.class.equals(adapterType)) { if (adaptableObject instanceof PDADebugTarget) { - return fgTargetAdapter; + return (T) fgTargetAdapter; } } if (IModelProxyFactory.class.equals(adapterType)) { if (adaptableObject instanceof PDADebugTarget) { - return fgFactory; + return (T) fgFactory; } } if (IViewActionProvider.class.equals(adapterType)) { if (adaptableObject instanceof PDAStackFrame) { - return fgViewActionProvider; + return (T) fgViewActionProvider; } } return null; } @Override - public Class[] getAdapterList() { + public Class<?>[] getAdapterList() { return new Class[]{IElementContentProvider.class, IModelProxyFactory.class, IViewActionProvider.class}; } diff --git a/org.eclipse.debug.examples.ui/src/org/eclipse/debug/examples/ui/pda/adapters/CommandAdapterFactory.java b/org.eclipse.debug.examples.ui/src/org/eclipse/debug/examples/ui/pda/adapters/CommandAdapterFactory.java index 3eed074e3..e3da52e57 100644 --- a/org.eclipse.debug.examples.ui/src/org/eclipse/debug/examples/ui/pda/adapters/CommandAdapterFactory.java +++ b/org.eclipse.debug.examples.ui/src/org/eclipse/debug/examples/ui/pda/adapters/CommandAdapterFactory.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2009 Wind River Systems and others. + * Copyright (c) 2009, 2015 Wind River Systems and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -11,6 +11,7 @@ package org.eclipse.debug.examples.ui.pda.adapters; import org.eclipse.core.runtime.IAdapterFactory; + import org.eclipse.debug.core.commands.IRestartHandler; import org.eclipse.debug.examples.core.pda.model.PDADebugTarget; @@ -24,18 +25,19 @@ public class CommandAdapterFactory implements IAdapterFactory { private static IRestartHandler fgRestartHandler = new PDARestartDebugCommand(); - @Override - public Object getAdapter(Object adaptableObject, Class adapterType) { + @SuppressWarnings("unchecked") + @Override + public <T> T getAdapter(Object adaptableObject, Class<T> adapterType) { if (IRestartHandler.class.equals(adapterType)) { if (adaptableObject instanceof PDADebugTarget) { - return fgRestartHandler; + return (T) fgRestartHandler; } } return null; } @Override - public Class[] getAdapterList() { + public Class<?>[] getAdapterList() { return new Class[]{IRestartHandler.class}; } diff --git a/org.eclipse.debug.examples.ui/src/org/eclipse/debug/examples/ui/pda/breakpoints/PDABreakpointAdapter.java b/org.eclipse.debug.examples.ui/src/org/eclipse/debug/examples/ui/pda/breakpoints/PDABreakpointAdapter.java index ca4706959..1486e78ff 100644 --- a/org.eclipse.debug.examples.ui/src/org/eclipse/debug/examples/ui/pda/breakpoints/PDABreakpointAdapter.java +++ b/org.eclipse.debug.examples.ui/src/org/eclipse/debug/examples/ui/pda/breakpoints/PDABreakpointAdapter.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2005, 2013 IBM Corporation and others. + * Copyright (c) 2005, 2015 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -42,7 +42,7 @@ public class PDABreakpointAdapter implements IToggleBreakpointsTargetExtension { public void toggleLineBreakpoints(IWorkbenchPart part, ISelection selection) throws CoreException { ITextEditor textEditor = getEditor(part); if (textEditor != null) { - IResource resource = (IResource) textEditor.getEditorInput().getAdapter(IResource.class); + IResource resource = textEditor.getEditorInput().getAdapter(IResource.class); ITextSelection textSelection = (ITextSelection) selection; int lineNumber = textSelection.getStartLine(); IBreakpoint[] breakpoints = DebugPlugin.getDefault().getBreakpointManager().getBreakpoints(DebugCorePlugin.ID_PDA_DEBUG_MODEL); @@ -80,7 +80,7 @@ public class PDABreakpointAdapter implements IToggleBreakpointsTargetExtension { private ITextEditor getEditor(IWorkbenchPart part) { if (part instanceof ITextEditor) { ITextEditor editorPart = (ITextEditor) part; - IResource resource = (IResource) editorPart.getEditorInput().getAdapter(IResource.class); + IResource resource = editorPart.getEditorInput().getAdapter(IResource.class); if (resource != null) { String extension = resource.getFileExtension(); if (extension != null && extension.equals("pda")) { //$NON-NLS-1$ @@ -113,7 +113,7 @@ public class PDABreakpointAdapter implements IToggleBreakpointsTargetExtension { if (variableAndFunctionName != null && part instanceof ITextEditor && selection instanceof ITextSelection) { ITextEditor editorPart = (ITextEditor)part; int lineNumber = ((ITextSelection)selection).getStartLine(); - IResource resource = (IResource) editorPart.getEditorInput().getAdapter(IResource.class); + IResource resource = editorPart.getEditorInput().getAdapter(IResource.class); String var = variableAndFunctionName[0]; String fcn = variableAndFunctionName[1]; toggleWatchpoint(resource, lineNumber, fcn, var, true, true); diff --git a/org.eclipse.debug.examples.ui/src/org/eclipse/debug/examples/ui/pda/breakpoints/PDAEditorAdapterFactory.java b/org.eclipse.debug.examples.ui/src/org/eclipse/debug/examples/ui/pda/breakpoints/PDAEditorAdapterFactory.java index a81d6d2c8..22243aabd 100644 --- a/org.eclipse.debug.examples.ui/src/org/eclipse/debug/examples/ui/pda/breakpoints/PDAEditorAdapterFactory.java +++ b/org.eclipse.debug.examples.ui/src/org/eclipse/debug/examples/ui/pda/breakpoints/PDAEditorAdapterFactory.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2005, 2013 IBM Corporation and others. + * Copyright (c) 2005, 2015 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -12,10 +12,14 @@ package org.eclipse.debug.examples.ui.pda.breakpoints; import org.eclipse.core.resources.IResource; + import org.eclipse.core.runtime.IAdapterFactory; + import org.eclipse.debug.examples.ui.pda.editor.PDAEditor; + import org.eclipse.debug.ui.actions.IRunToLineTarget; import org.eclipse.debug.ui.actions.IToggleBreakpointsTarget; + import org.eclipse.ui.texteditor.ITextEditor; @@ -26,22 +30,23 @@ public class PDAEditorAdapterFactory implements IAdapterFactory { /* (non-Javadoc) * @see org.eclipse.core.runtime.IAdapterFactory#getAdapter(java.lang.Object, java.lang.Class) */ + @SuppressWarnings("unchecked") @Override - public Object getAdapter(Object adaptableObject, Class adapterType) { + public <T> T getAdapter(Object adaptableObject, Class<T> adapterType) { if (adaptableObject instanceof PDAEditor) { ITextEditor editorPart = (ITextEditor) adaptableObject; - IResource resource = (IResource) editorPart.getEditorInput().getAdapter(IResource.class); + IResource resource = editorPart.getEditorInput().getAdapter(IResource.class); if (resource != null) { String extension = resource.getFileExtension(); if (extension != null && extension.equals("pda")) { //$NON-NLS-1$ if (adapterType.equals(IToggleBreakpointsTarget.class)) { - return new PDABreakpointAdapter(); + return (T) new PDABreakpointAdapter(); } //#ifdef ex7 //# // TODO: Exercise 7 - create run to line adapter //#else if (adapterType.equals(IRunToLineTarget.class)) { - return new PDARunToLineAdapter(); + return (T) new PDARunToLineAdapter(); } //#endif } @@ -53,7 +58,7 @@ public class PDAEditorAdapterFactory implements IAdapterFactory { * @see org.eclipse.core.runtime.IAdapterFactory#getAdapterList() */ @Override - public Class[] getAdapterList() { + public Class<?>[] getAdapterList() { return new Class[]{IToggleBreakpointsTarget.class}; } } diff --git a/org.eclipse.debug.examples.ui/src/org/eclipse/debug/examples/ui/pda/breakpoints/PDARunToLineAdapter.java b/org.eclipse.debug.examples.ui/src/org/eclipse/debug/examples/ui/pda/breakpoints/PDARunToLineAdapter.java index 9855de3c2..6a9eecdd9 100644 --- a/org.eclipse.debug.examples.ui/src/org/eclipse/debug/examples/ui/pda/breakpoints/PDARunToLineAdapter.java +++ b/org.eclipse.debug.examples.ui/src/org/eclipse/debug/examples/ui/pda/breakpoints/PDARunToLineAdapter.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2005, 2007 IBM Corporation and others. + * Copyright (c) 2005, 2015 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -47,7 +47,7 @@ public class PDARunToLineAdapter implements IRunToLineTarget { int lineNumber = textSelection.getStartLine() + 1; if (lineNumber > 0) { if (target instanceof IAdaptable) { - IDebugTarget debugTarget = (IDebugTarget) ((IAdaptable)target).getAdapter(IDebugTarget.class); + IDebugTarget debugTarget = ((IAdaptable)target).getAdapter(IDebugTarget.class); if (debugTarget != null) { //#ifdef ex7 //# // TODO: Exercise 7 - perform the run-to-line with a run-to-line breakpoint and handler diff --git a/org.eclipse.debug.examples.ui/src/org/eclipse/debug/examples/ui/pda/breakpoints/PDAToggleWatchpointsTarget.java b/org.eclipse.debug.examples.ui/src/org/eclipse/debug/examples/ui/pda/breakpoints/PDAToggleWatchpointsTarget.java index 2e716724c..d799e50bf 100644 --- a/org.eclipse.debug.examples.ui/src/org/eclipse/debug/examples/ui/pda/breakpoints/PDAToggleWatchpointsTarget.java +++ b/org.eclipse.debug.examples.ui/src/org/eclipse/debug/examples/ui/pda/breakpoints/PDAToggleWatchpointsTarget.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008, 2013 IBM Corporation and others. + * Copyright (c) 2008, 2015 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -72,7 +72,7 @@ public class PDAToggleWatchpointsTarget extends PDABreakpointAdapter { // current source line. ITextEditor editorPart = (ITextEditor)part; int lineNumber = ((ITextSelection)selection).getStartLine(); - IResource resource = (IResource) editorPart.getEditorInput().getAdapter(IResource.class); + IResource resource = editorPart.getEditorInput().getAdapter(IResource.class); String var = variableAndFunctionName[0]; String fcn = variableAndFunctionName[1]; toggleWatchpoint(resource, lineNumber, fcn, var, fAccessModeEnabled, fModificationModeEnabled); diff --git a/org.eclipse.debug.examples.ui/src/org/eclipse/debug/examples/ui/pda/views/CanPushTester.java b/org.eclipse.debug.examples.ui/src/org/eclipse/debug/examples/ui/pda/views/CanPushTester.java index c937d1493..b2b0ee939 100644 --- a/org.eclipse.debug.examples.ui/src/org/eclipse/debug/examples/ui/pda/views/CanPushTester.java +++ b/org.eclipse.debug.examples.ui/src/org/eclipse/debug/examples/ui/pda/views/CanPushTester.java @@ -1,10 +1,10 @@ /******************************************************************************* - * Copyright (c) 2008, 2013 Wind River Systems and others. + * Copyright (c) 2008, 2015 Wind River Systems and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html - * + * * Contributors: * Wind River Systems - initial API and implementation * IBM Corporation - bug fixing @@ -18,26 +18,25 @@ import org.eclipse.debug.examples.core.pda.model.PDAStackFrame; import org.eclipse.debug.examples.core.pda.model.PDAThread; /** - * Property tester for use with standard expressions to determine whether + * Property tester for use with standard expressions to determine whether * the given debug target can perform a push operation. */ public class CanPushTester extends PropertyTester { - + private static final String CAN_PUSH_PROPERTY = "canPush"; //$NON-NLS-1$ - + @Override public boolean test(Object receiver, String property, Object[] args, Object expectedValue) { if (CAN_PUSH_PROPERTY.equals(property)) { if (receiver instanceof IAdaptable) { - PDADebugElement element = (PDADebugElement) - ((IAdaptable)receiver).getAdapter(PDADebugElement.class); + PDADebugElement element = ((IAdaptable) receiver).getAdapter(PDADebugElement.class); PDAThread thread = null; if (element instanceof PDAThread) { thread = (PDAThread)element; } else if (element instanceof PDAStackFrame) { thread = (PDAThread)((PDAStackFrame)element).getThread(); - } - + } + if (thread != null) { return thread.canPushData(); } |