diff options
author | Alexander Kurtakov | 2018-02-07 19:21:32 +0000 |
---|---|---|
committer | Alexander Kurtakov | 2018-02-07 19:21:32 +0000 |
commit | 2df4e713c2e9b6cf0a6f554c2f44797cb33e566c (patch) | |
tree | 1010db1e4ac5b606eccfc1e76a53f10b4ae1c489 /examples | |
parent | f9959fe40ae5943210c66dc0d0fd0aad14f2766f (diff) | |
download | eclipse.platform.team-2df4e713c2e9b6cf0a6f554c2f44797cb33e566c.tar.gz eclipse.platform.team-2df4e713c2e9b6cf0a6f554c2f44797cb33e566c.tar.xz eclipse.platform.team-2df4e713c2e9b6cf0a6f554c2f44797cb33e566c.zip |
Bug 530860 - Generify Class related APIsS4_8_0_M6I20180308-0630I20180307-2000I20180307-1025I20180307-0900I20180307-0825I20180307-0800I20180306-2000I20180306-0800I20180305-2000I20180305-0800I20180305-0300I20180304-2000I20180304-0800I20180303-1500I20180303-1200I20180303-0800I20180303-0335I20180303-0155I20180303-0055I20180302-2000I20180301-2000I20180228-2000I20180227-2000I20180226-2000I20180225-2000I20180224-1500I20180223-2000I20180222-2000I20180221-2000I20180220-2000I20180219-2000I20180218-2000I20180217-1500I20180216-2000I20180216-0415I20180215-2000I20180214-2000I20180213-2000I20180213-0125I20180212-2000I20180211-2000I20180210-1500I20180209-2000I20180208-2000I20180207-2000
Change-Id: I2ce29644a969e3df4d47bfcbe2557ebf439c7d0b
Signed-off-by: Alexander Kurtakov <akurtako@redhat.com>
Diffstat (limited to 'examples')
8 files changed, 29 insertions, 32 deletions
diff --git a/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/history/FileSystemFileRevision.java b/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/history/FileSystemFileRevision.java index 0b248c205..9939ebb47 100644 --- a/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/history/FileSystemFileRevision.java +++ b/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/history/FileSystemFileRevision.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2006, 2009 IBM Corporation and others. + * Copyright (c) 2006, 2018 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 @@ -62,7 +62,7 @@ public class FileSystemFileRevision extends FileRevision { return true; } - public Object getAdapter(Class adapter) { + public <T> T getAdapter(Class<T> adapter) { return null; } diff --git a/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/ui/ConfigurationWizard.java b/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/ui/ConfigurationWizard.java index 742f862b5..12a2c582c 100644 --- a/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/ui/ConfigurationWizard.java +++ b/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/ui/ConfigurationWizard.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2007 IBM Corporation and others. + * Copyright (c) 2000, 2018 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 @@ -96,13 +96,13 @@ public class ConfigurationWizard extends Wizard implements IConfigurationWizard, return true; } - public Object getAdapter(Class adapter) { + public <T> T getAdapter(Class<T> adapter) { if (adapter == IConfigurationWizardExtension.class) { - return new IConfigurationWizardExtension(){ + return adapter.cast(new IConfigurationWizardExtension(){ public void init(IWorkbench workbench, IProject[] projects) { setProjects(projects); } - }; + }); } return null; } diff --git a/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/ui/FileSystemHistoryPage.java b/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/ui/FileSystemHistoryPage.java index 9d0a744ae..e2f55e7d4 100644 --- a/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/ui/FileSystemHistoryPage.java +++ b/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/ui/FileSystemHistoryPage.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2006 IBM Corporation and others. + * Copyright (c) 2006, 2018 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 @@ -239,7 +239,7 @@ public class FileSystemHistoryPage extends HistoryPage { Utils.schedule(refreshFileHistoryJob, getWorkbenchSite(parentSite)); } - public Object getAdapter(Class adapter) { + public <T> T getAdapter(Class<T> adapter) { return null; } diff --git a/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/ui/FileSystemRevisionEditorInput.java b/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/ui/FileSystemRevisionEditorInput.java index 41757a4d6..bb915bd80 100644 --- a/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/ui/FileSystemRevisionEditorInput.java +++ b/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/ui/FileSystemRevisionEditorInput.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2006, 2009 IBM Corporation and others. + * Copyright (c) 2006, 2018 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 @@ -93,15 +93,15 @@ public class FileSystemRevisionEditorInput extends PlatformObject implements IWo return ""; //$NON-NLS-1$ } - public Object getAdapter(Class adapter) { + public <T> T getAdapter(Class<T> adapter) { if (adapter == IWorkbenchAdapter.class) { - return this; + return adapter.cast(this); } if (adapter == IFileRevision.class) - return fileRevision; + return adapter.cast(fileRevision); else if (adapter == IFileState.class){ if (storage != null && storage instanceof IFileState) - return storage; + return adapter.cast(storage); } return super.getAdapter(adapter); } diff --git a/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/ui/OpenFileSystemRevisionAction.java b/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/ui/OpenFileSystemRevisionAction.java index 270812c29..11d5b1920 100644 --- a/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/ui/OpenFileSystemRevisionAction.java +++ b/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/filesystem/ui/OpenFileSystemRevisionAction.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2006, 2017 IBM Corporation and others. + * Copyright (c) 2006, 2018 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 @@ -148,7 +148,7 @@ public class OpenFileSystemRevisionAction extends BaseSelectionListenerAction { for (int i = 0; i < editorRefs.length; i++) { IEditorPart part = editorRefs[i].getEditor(false); if (part != null && part.getEditorInput() instanceof FileSystemRevisionEditorInput) { - IFileRevision inputRevision = (IFileRevision) input.getAdapter(IFileRevision.class); + IFileRevision inputRevision = input.getAdapter(IFileRevision.class); IFileRevision editorRevision = part.getEditorInput().getAdapter(IFileRevision.class); if (inputRevision.equals(editorRevision)) { diff --git a/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/model/ui/AdapterFactory.java b/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/model/ui/AdapterFactory.java index ce0ce565c..d06230700 100644 --- a/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/model/ui/AdapterFactory.java +++ b/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/model/ui/AdapterFactory.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2006 IBM Corporation and others. + * Copyright (c) 2006, 2018 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 @@ -30,35 +30,32 @@ public class AdapterFactory implements IAdapterFactory { private CompareAdapter compareAdapter; private static Object historyPageSource = new FileSystemHistoryPageSource(); - public Object getAdapter(Object adaptableObject, Class adapterType) { + public <T> T getAdapter(Object adaptableObject, Class<T> adapterType) { if (adapterType == IWorkbenchAdapter.class && adaptableObject instanceof ModelObject) - return modelAdapter; + return adapterType.cast(modelAdapter); if (adapterType == ResourceMapping.class && adaptableObject instanceof ModelObject) - return ModelResourceMapping.create((ModelObject)adaptableObject); + return adapterType.cast(ModelResourceMapping.create((ModelObject)adaptableObject)); if (adapterType == IResourceMappingMerger.class && adaptableObject instanceof ExampleModelProvider) { if (modelMerger == null) { modelMerger = new ModelMerger((ExampleModelProvider)adaptableObject); } - return modelMerger; + return adapterType.cast(modelMerger); } if (adapterType == ISynchronizationCompareAdapter.class && adaptableObject instanceof ExampleModelProvider) { if (compareAdapter == null) { compareAdapter = new CompareAdapter((ExampleModelProvider)adaptableObject); } - return compareAdapter; + return adapterType.cast(compareAdapter); } if (adapterType == IHistoryPageSource.class){ - return historyPageSource; + return adapterType.cast(historyPageSource); } return null; } - /* (non-Javadoc) - * @see org.eclipse.core.runtime.IAdapterFactory#getAdapterList() - */ - public Class[] getAdapterList() { + public Class<?>[] getAdapterList() { return new Class[] { IWorkbenchAdapter.class, ResourceMapping.class, IResourceMappingMerger.class, ISynchronizationCompareAdapter.class }; } diff --git a/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/model/ui/ModelNavigatorContentProvider.java b/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/model/ui/ModelNavigatorContentProvider.java index 2e1d35c46..3db44963a 100644 --- a/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/model/ui/ModelNavigatorContentProvider.java +++ b/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/model/ui/ModelNavigatorContentProvider.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2006, 2007 IBM Corporation and others. + * Copyright (c) 2006, 2018 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 @@ -320,9 +320,9 @@ public class ModelNavigatorContentProvider extends BaseWorkbenchContentProvider return false; } - public Object getAdapter(Class adapter) { + public <T> T getAdapter(Class<T> adapter) { if (adapter == SaveablesProvider.class) { - return saveablesProvider; + return adapter.cast(saveablesProvider); } return Platform.getAdapterManager().getAdapter(this, adapter); } diff --git a/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/model/ui/ModelSaveable.java b/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/model/ui/ModelSaveable.java index 622e42cc8..15498a8f7 100644 --- a/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/model/ui/ModelSaveable.java +++ b/examples/org.eclipse.team.examples.filesystem/src/org/eclipse/team/examples/model/ui/ModelSaveable.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007, 2009 IBM Corporation and others. + * Copyright (c) 2007, 2018 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 @@ -73,9 +73,9 @@ public class ModelSaveable extends Saveable { dirty = true; } - public Object getAdapter(Class adapter) { + public <T> T getAdapter(Class<T> adapter) { if (adapter == ResourceMapping.class) { - return Adapters.adapt(getModelObject(), ResourceMapping.class); + return Adapters.adapt(getModelObject(), adapter); } return super.getAdapter(adapter); } |