Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSergey Prigogin2016-06-26 00:44:56 -0400
committerSergey Prigogin2016-07-06 22:43:06 -0400
commit3b06c860315edfe76f726daffefe3b4377cf3226 (patch)
treed1ad35eda707bc4f694f575ba73c0c269701c6ea
parent3f0e65922f1b9b87102041cabd54859f0fc6a957 (diff)
downloadeclipse.platform.team-I20160708-1700.tar.gz
eclipse.platform.team-I20160708-1700.tar.xz
eclipse.platform.team-I20160708-1700.zip
Fixed compiler warnings.I20160708-1700
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/actions/CompareRevisionAction.java9
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/actions/OpenWithMenu.java64
-rw-r--r--bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/actions/TeamAction.java40
3 files changed, 52 insertions, 61 deletions
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/actions/CompareRevisionAction.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/actions/CompareRevisionAction.java
index 72a0ad8c1..89371a74c 100644
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/actions/CompareRevisionAction.java
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/actions/CompareRevisionAction.java
@@ -60,10 +60,11 @@ public class CompareRevisionAction extends BaseSelectionListenerAction {
case 1:
file1 = getCurrentFileRevision();
Object tempRevision = objArray[0];
- if (tempRevision instanceof IFileRevision)
+ if (tempRevision instanceof IFileRevision) {
file2 = (IFileRevision) tempRevision;
- else
+ } else {
return;
+ }
break;
case 2:
@@ -74,8 +75,9 @@ public class CompareRevisionAction extends BaseSelectionListenerAction {
tempRevision3 instanceof IFileRevision){
file1 = (IFileRevision) objArray[0];
file2 = (IFileRevision) objArray[1];
- } else
+ } else {
return;
+ }
break;
}
@@ -176,6 +178,7 @@ public class CompareRevisionAction extends BaseSelectionListenerAction {
* @deprecated As of 3.5, replaced by
* {@link Utils#findReusableCompareEditor(CompareEditorInput, IWorkbenchPage, Class[])}
*/
+ @SuppressWarnings("javadoc")
@Deprecated
public static IEditorPart findReusableCompareEditor(IWorkbenchPage workbenchPage) {
return Utils.findReusableCompareEditor(null, workbenchPage,
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/actions/OpenWithMenu.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/actions/OpenWithMenu.java
index 83b2225f1..9ee66aa0b 100644
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/actions/OpenWithMenu.java
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/actions/OpenWithMenu.java
@@ -56,7 +56,7 @@ public class OpenWithMenu extends ContributionItem {
private IEditorRegistry registry = PlatformUI.getWorkbench()
.getEditorRegistry();
- private static Hashtable imageCache = new Hashtable(11);
+ private static Hashtable<ImageDescriptor, Image> imageCache = new Hashtable<ImageDescriptor, Image>(11);
/**
* The id of this action.
@@ -73,13 +73,13 @@ public class OpenWithMenu extends ContributionItem {
/*
* Compares the labels from two IEditorDescriptor objects
*/
- private static final Comparator comparer = new Comparator() {
+ private static final Comparator<IEditorDescriptor> comparer = new Comparator<IEditorDescriptor>() {
private Collator collator = Collator.getInstance();
@Override
- public int compare(Object arg0, Object arg1) {
- String s1 = ((IEditorDescriptor) arg0).getLabel();
- String s2 = ((IEditorDescriptor) arg1).getLabel();
+ public int compare(IEditorDescriptor arg0, IEditorDescriptor arg1) {
+ String s1 = arg0.getLabel();
+ String s2 = arg1.getLabel();
return collator.compare(s1, s2);
}
};
@@ -108,7 +108,7 @@ public class OpenWithMenu extends ContributionItem {
if (imageDesc == null) {
return null;
}
- Image image = (Image) imageCache.get(imageDesc);
+ Image image = imageCache.get(imageDesc);
if (image == null) {
image = imageDesc.createImage();
imageCache.put(imageDesc, image);
@@ -167,12 +167,8 @@ public class OpenWithMenu extends ContributionItem {
Listener listener = new Listener() {
@Override
public void handleEvent(Event event) {
- switch (event.type) {
- case SWT.Selection:
- if (menuItem.getSelection()) {
- openEditor(descriptor, false);
- }
- break;
+ if (event.type == SWT.Selection && menuItem.getSelection()) {
+ openEditor(descriptor, false);
}
}
};
@@ -197,22 +193,17 @@ public class OpenWithMenu extends ContributionItem {
Listener listener = new Listener() {
@Override
public void handleEvent(Event event) {
- switch (event.type) {
- case SWT.Selection:
- EditorSelectionDialog dialog = new EditorSelectionDialog(
- menu.getShell());
- dialog
- .setMessage(NLS
- .bind(
- TeamUIMessages.LocalHistoryPage_OpenWithMenu_OtherDialogDescription,
- fileResource.getName()));
+ if (event.type == SWT.Selection) {
+ EditorSelectionDialog dialog = new EditorSelectionDialog(menu.getShell());
+ dialog.setMessage(NLS.bind(
+ TeamUIMessages.LocalHistoryPage_OpenWithMenu_OtherDialogDescription,
+ fileResource.getName()));
if (dialog.open() == Window.OK) {
IEditorDescriptor editor = dialog.getSelectedEditor();
if (editor != null) {
openEditor(editor, editor.isOpenExternal());
}
}
- break;
}
}
};
@@ -231,16 +222,16 @@ public class OpenWithMenu extends ContributionItem {
IEditorDescriptor preferredEditor = Utils
.getDefaultEditor(fileRevision);
- Object[] editors = Utils.getEditors(fileRevision);
+ IEditorDescriptor[] editors = Utils.getEditors(fileRevision);
Collections.sort(Arrays.asList(editors), comparer);
boolean defaultFound = false;
// Check that we don't add it twice. This is possible
// if the same editor goes to two mappings.
- ArrayList alreadyMapped = new ArrayList();
+ ArrayList<IEditorDescriptor> alreadyMapped = new ArrayList<>();
for (int i = 0; i < editors.length; i++) {
- IEditorDescriptor editor = (IEditorDescriptor) editors[i];
+ IEditorDescriptor editor = editors[i];
if (!alreadyMapped.contains(editor)) {
createMenuItem(menu, editor, preferredEditor);
if (defaultTextEditor != null
@@ -310,18 +301,13 @@ public class OpenWithMenu extends ContributionItem {
public void createDefaultMenuItem(Menu menu, final IFileRevision revision, boolean markAsSelected) {
final MenuItem menuItem = new MenuItem(menu, SWT.RADIO);
menuItem.setSelection(markAsSelected);
- menuItem
- .setText(TeamUIMessages.LocalHistoryPage_OpenWithMenu_DefaultEditorDescription);
+ menuItem.setText(TeamUIMessages.LocalHistoryPage_OpenWithMenu_DefaultEditorDescription);
Listener listener = new Listener() {
@Override
public void handleEvent(Event event) {
- switch (event.type) {
- case SWT.Selection:
- if (menuItem.getSelection()) {
- openEditor(Utils.getDefaultEditor(revision), false);
- }
- break;
+ if (event.type == SWT.Selection && menuItem.getSelection()) {
+ openEditor(Utils.getDefaultEditor(revision), false);
}
}
};
@@ -346,12 +332,12 @@ public class OpenWithMenu extends ContributionItem {
if (openUsingDescriptor) {
// discouraged access to open system editors
((WorkbenchPage) (page.getSite().getPage()))
- .openEditorFromDescriptor(isFile ? new FileEditorInput(
- (IFile) storage)
- : (IEditorInput) FileRevisionEditorInput
- .createEditorInputFor(fileRevision,
- monitor), editorDescriptor,
- true, null);
+ .openEditorFromDescriptor(
+ isFile ? new FileEditorInput((IFile) storage)
+ : (IEditorInput) FileRevisionEditorInput
+ .createEditorInputFor(
+ fileRevision, monitor),
+ editorDescriptor, true, null);
} else {
String editorId = editorDescriptor == null ? IEditorRegistry.SYSTEM_EXTERNAL_EDITOR_ID
: editorDescriptor.getId();
diff --git a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/actions/TeamAction.java b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/actions/TeamAction.java
index 17cdc6ee6..73fc02c35 100644
--- a/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/actions/TeamAction.java
+++ b/bundles/org.eclipse.team.ui/src/org/eclipse/team/internal/ui/actions/TeamAction.java
@@ -111,22 +111,23 @@ public abstract class TeamAction extends AbstractHandler implements IObjectActio
* @param c
* @return the selected adaptables
*/
- public static Object[] getSelectedAdaptables(ISelection selection, Class c) {
- ArrayList result = null;
+ @SuppressWarnings("unchecked")
+ public static <T> T[] getSelectedAdaptables(ISelection selection, Class<T> c) {
+ ArrayList<T> result = null;
if (selection != null && !selection.isEmpty()) {
- result = new ArrayList();
+ result = new ArrayList<>();
Iterator elements = ((IStructuredSelection) selection).iterator();
while (elements.hasNext()) {
- Object adapter = getAdapter(elements.next(), c);
+ T adapter = getAdapter(elements.next(), c);
if (c.isInstance(adapter)) {
result.add(adapter);
}
}
}
if (result != null && !result.isEmpty()) {
- return result.toArray((Object[])Array.newInstance(c, result.size()));
+ return result.toArray((T[]) Array.newInstance(c, result.size()));
}
- return (Object[])Array.newInstance(c, 0);
+ return (T[]) Array.newInstance(c, 0);
}
/**
@@ -138,13 +139,14 @@ public abstract class TeamAction extends AbstractHandler implements IObjectActio
* @param c
* @return Object
*/
- public static Object getAdapter(Object adaptable, Class c) {
+ @SuppressWarnings("unchecked")
+ public static <T> T getAdapter(Object adaptable, Class<T> c) {
if (c.isInstance(adaptable)) {
- return adaptable;
+ return (T) adaptable;
}
if (adaptable instanceof IAdaptable) {
IAdaptable a = (IAdaptable) adaptable;
- Object adapter = a.getAdapter(c);
+ T adapter = a.getAdapter(c);
if (c.isInstance(adapter)) {
return adapter;
}
@@ -160,14 +162,14 @@ public abstract class TeamAction extends AbstractHandler implements IObjectActio
protected IProject[] getSelectedProjects() {
IResource[] selectedResources = getSelectedResources();
if (selectedResources.length == 0) return new IProject[0];
- ArrayList projects = new ArrayList();
+ ArrayList<IProject> projects = new ArrayList<>();
for (int i = 0; i < selectedResources.length; i++) {
IResource resource = selectedResources[i];
if (resource.getType() == IResource.PROJECT) {
- projects.add(resource);
+ projects.add((IProject) resource);
}
}
- return (IProject[]) projects.toArray(new IProject[projects.size()]);
+ return projects.toArray(new IProject[projects.size()]);
}
/**
@@ -178,7 +180,7 @@ public abstract class TeamAction extends AbstractHandler implements IObjectActio
* @param c
* @return the selection adapted to the given class
*/
- protected Object[] getAdaptedSelection(Class c) {
+ protected <T> T[] getAdaptedSelection(Class<T> c) {
return getSelectedAdaptables(selection, c);
}
@@ -205,7 +207,7 @@ public abstract class TeamAction extends AbstractHandler implements IObjectActio
*/
protected ResourceMapping[] getSelectedResourceMappings(String providerId) {
Object[] elements = getSelection().toArray();
- ArrayList providerMappings = new ArrayList();
+ ArrayList<ResourceMapping> providerMappings = new ArrayList<>();
for (int i = 0; i < elements.length; i++) {
Object object = elements[i];
Object adapted = getResourceMapping(object);
@@ -216,7 +218,7 @@ public abstract class TeamAction extends AbstractHandler implements IObjectActio
}
}
}
- return (ResourceMapping[]) providerMappings.toArray(new ResourceMapping[providerMappings.size()]);
+ return providerMappings.toArray(new ResourceMapping[providerMappings.size()]);
}
private Object getResourceMapping(Object object) {
@@ -368,13 +370,13 @@ public abstract class TeamAction extends AbstractHandler implements IObjectActio
*
* @return a hashtable mapping providers to their resources
*/
- protected Hashtable getProviderMapping(IResource[] resources) {
- Hashtable result = new Hashtable();
+ protected Hashtable<RepositoryProvider, List<IResource>> getProviderMapping(IResource[] resources) {
+ Hashtable<RepositoryProvider, List<IResource>> result = new Hashtable<>();
for (int i = 0; i < resources.length; i++) {
RepositoryProvider provider = RepositoryProvider.getProvider(resources[i].getProject());
- List list = (List)result.get(provider);
+ List<IResource> list = result.get(provider);
if (list == null) {
- list = new ArrayList();
+ list = new ArrayList<>();
result.put(provider, list);
}
list.add(resources[i]);

Back to the top