diff --git a/bundles/org.eclipse.ui.ide/extensions/org/eclipse/ui/actions/CopyProjectAction.java b/bundles/org.eclipse.ui.ide/extensions/org/eclipse/ui/actions/CopyProjectAction.java index 8b7ec6b453d..4e65ce8c4a3 100644 --- a/bundles/org.eclipse.ui.ide/extensions/org/eclipse/ui/actions/CopyProjectAction.java +++ b/bundles/org.eclipse.ui.ide/extensions/org/eclipse/ui/actions/CopyProjectAction.java @@ -333,11 +333,11 @@ protected boolean updateSelection(IStructuredSelection selection) { // to enable this command there must be one project selected and nothing // else - List selectedResources = getSelectedResources(); + List selectedResources = getSelectedResources(); if (selectedResources.size() != 1) { return false; } - IResource source = (IResource) selectedResources.get(0); + IResource source = selectedResources.get(0); if (source instanceof IProject && ((IProject) source).isOpen()) { return true; } diff --git a/bundles/org.eclipse.ui.ide/extensions/org/eclipse/ui/actions/MoveResourceAction.java b/bundles/org.eclipse.ui.ide/extensions/org/eclipse/ui/actions/MoveResourceAction.java index f2f0ff08898..37f396807ec 100644 --- a/bundles/org.eclipse.ui.ide/extensions/org/eclipse/ui/actions/MoveResourceAction.java +++ b/bundles/org.eclipse.ui.ide/extensions/org/eclipse/ui/actions/MoveResourceAction.java @@ -18,6 +18,7 @@ import org.eclipse.core.resources.IContainer; import org.eclipse.core.resources.IResource; +import org.eclipse.core.runtime.IPath; import org.eclipse.jface.window.IShellProvider; import org.eclipse.swt.widgets.Shell; import org.eclipse.ui.PlatformUI; @@ -46,7 +47,7 @@ public class MoveResourceAction extends CopyResourceAction { * Keep a list of destinations so that any required update can be done after the * move. */ - protected List destinations; + protected List destinations; /** * Creates a new action. @@ -97,7 +98,7 @@ protected List getDestinations() { } @Override - protected IResource[] getResources(List resourceList) { + protected IResource[] getResources(List resourceList) { ReadOnlyStateChecker checker = new ReadOnlyStateChecker(getShell(), IDEWorkbenchMessages.MoveResourceAction_title, IDEWorkbenchMessages.MoveResourceAction_checkMoveMessage); @@ -107,7 +108,7 @@ protected IResource[] getResources(List resourceList) { @Override protected void runOperation(IResource[] resources, IContainer destination) { //Initialize the destinations - destinations = new ArrayList(); + destinations = new ArrayList<>(); IResource[] copiedResources = operation.copyResources(resources, destination); diff --git a/bundles/org.eclipse.ui.ide/extensions/org/eclipse/ui/actions/OpenResourceAction.java b/bundles/org.eclipse.ui.ide/extensions/org/eclipse/ui/actions/OpenResourceAction.java index a4cd3f5b11b..4590deabfc8 100644 --- a/bundles/org.eclipse.ui.ide/extensions/org/eclipse/ui/actions/OpenResourceAction.java +++ b/bundles/org.eclipse.ui.ide/extensions/org/eclipse/ui/actions/OpenResourceAction.java @@ -186,7 +186,7 @@ private boolean promptToOpenWithReferences() { @Override public void resourceChanged(IResourceChangeEvent event) { // Warning: code duplicated in CloseResourceAction - List sel = getSelectedResources(); + List sel = getSelectedResources(); // don't bother looking at delta if selection not applicable if (selectionIsOfType(IResource.PROJECT)) { IResourceDelta delta = event.getDelta(); diff --git a/bundles/org.eclipse.ui.ide/extensions/org/eclipse/ui/actions/ReadOnlyStateChecker.java b/bundles/org.eclipse.ui.ide/extensions/org/eclipse/ui/actions/ReadOnlyStateChecker.java index d8ea27b9111..66526bf7321 100644 --- a/bundles/org.eclipse.ui.ide/extensions/org/eclipse/ui/actions/ReadOnlyStateChecker.java +++ b/bundles/org.eclipse.ui.ide/extensions/org/eclipse/ui/actions/ReadOnlyStateChecker.java @@ -69,7 +69,7 @@ public ReadOnlyStateChecker(Shell parent, String title, String message) { * Return true if all items are selected and false if any are skipped. */ private boolean checkAcceptedResource(IResource resourceToCheck, - List selectedChildren) throws CoreException { + List selectedChildren) throws CoreException { if (resourceToCheck.getType() == IResource.FILE) { selectedChildren.add(resourceToCheck); @@ -142,7 +142,7 @@ public IResource[] checkReadOnlyResources(IResource[] itemsToCheck) { * @param allSelected the List of currently selected resources to add to. */ private int checkReadOnlyResources(IResource[] itemsToCheck, - List allSelected) throws CoreException { + List allSelected) throws CoreException { //Shortcut. If the user has already selected yes to all then just return it if (yesToAllSelected) { @@ -150,7 +150,7 @@ private int checkReadOnlyResources(IResource[] itemsToCheck, } boolean noneSkipped = true; - List selectedChildren = new ArrayList(); + List selectedChildren = new ArrayList<>(); for (IResource resourceToCheck : itemsToCheck) { ResourceAttributes checkAttributes = resourceToCheck.getResourceAttributes(); diff --git a/bundles/org.eclipse.ui.ide/extensions/org/eclipse/ui/dialogs/FilteredResourcesSelectionDialog.java b/bundles/org.eclipse.ui.ide/extensions/org/eclipse/ui/dialogs/FilteredResourcesSelectionDialog.java index 9bb5f8780f1..496c231b1ab 100644 --- a/bundles/org.eclipse.ui.ide/extensions/org/eclipse/ui/dialogs/FilteredResourcesSelectionDialog.java +++ b/bundles/org.eclipse.ui.ide/extensions/org/eclipse/ui/dialogs/FilteredResourcesSelectionDialog.java @@ -374,7 +374,7 @@ public Object[] getResult() { if (result == null) return null; - List resultToReturn = new ArrayList(); + List resultToReturn = new ArrayList<>(); for (Object element : result) { if (element instanceof IResource) { diff --git a/bundles/org.eclipse.ui.ide/extensions/org/eclipse/ui/dialogs/ResourceListSelectionDialog.java b/bundles/org.eclipse.ui.ide/extensions/org/eclipse/ui/dialogs/ResourceListSelectionDialog.java index 86bcf2aaf95..80e9f8d6e11 100644 --- a/bundles/org.eclipse.ui.ide/extensions/org/eclipse/ui/dialogs/ResourceListSelectionDialog.java +++ b/bundles/org.eclipse.ui.ide/extensions/org/eclipse/ui/dialogs/ResourceListSelectionDialog.java @@ -93,16 +93,16 @@ public class ResourceListSelectionDialog extends SelectionDialog { private boolean allowUserToToggleDerived; - static class ResourceDescriptor implements Comparable { + static class ResourceDescriptor implements Comparable { String label; - ArrayList resources = new ArrayList(); + ArrayList resources = new ArrayList<>(); boolean resourcesSorted = true; @Override - public int compareTo(Object o) { - return collator.compare(label, ((ResourceDescriptor) o).label); + public int compareTo(ResourceDescriptor o) { + return collator.compare(label, o.label); } } @@ -632,7 +632,7 @@ private void gatherResources(boolean force) { * @return an image for a resource descriptor. */ private Image getImage(ResourceDescriptor desc) { - IResource r = (IResource) desc.resources.get(0); + IResource r = desc.resources.get(0); return labelProvider.getImage(r); } @@ -773,10 +773,10 @@ private void initDescriptors(final IResource resources[]) { return; } ResourceDescriptor current = descriptors[index]; - IResource currentResource = (IResource) current.resources.get(0); + IResource currentResource = current.resources.get(0); for (int i2 = 1; i2 < descriptorsSize; i2++) { ResourceDescriptor next = descriptors[i2]; - IResource nextResource = (IResource) next.resources.get(0); + IResource nextResource = next.resources.get(0); if (nextResource.getType() == currentResource.getType() && next.label.equals(current.label)) { current.resources.add(nextResource); // If we are merging resources with the same name, into a single descriptor, @@ -791,7 +791,7 @@ private void initDescriptors(final IResource resources[]) { descriptors[index + 1] = descriptors[i2]; index++; current = descriptors[index]; - currentResource = (IResource) current.resources.get(0); + currentResource = current.resources.get(0); } } descriptorsSize = index + 1; @@ -819,7 +819,7 @@ private boolean match(String label) { protected void okPressed() { TableItem items[] = folderNames.getSelection(); if (items.length == 1) { - ArrayList result = new ArrayList(); + ArrayList result = new ArrayList<>(); result.add(items[0].getData()); setResult(result); } @@ -864,8 +864,8 @@ private void updateFolders(final ResourceDescriptor desc) { if (!desc.resourcesSorted) { // sort the folder names desc.resources.sort((o1, o2) -> { - String s1 = getParentLabel((IResource) o1); - String s2 = getParentLabel((IResource) o2); + String s1 = getParentLabel(o1); + String s2 = getParentLabel(o2); return collator.compare(s1, s2); }); desc.resourcesSorted = true; diff --git a/bundles/org.eclipse.ui.ide/extensions/org/eclipse/ui/dialogs/WizardExportResourcesPage.java b/bundles/org.eclipse.ui.ide/extensions/org/eclipse/ui/dialogs/WizardExportResourcesPage.java index cde00bebeb0..2d1d9cae286 100644 --- a/bundles/org.eclipse.ui.ide/extensions/org/eclipse/ui/dialogs/WizardExportResourcesPage.java +++ b/bundles/org.eclipse.ui.ide/extensions/org/eclipse/ui/dialogs/WizardExportResourcesPage.java @@ -79,7 +79,7 @@ public abstract class WizardExportResourcesPage extends WizardDataTransferPage { private IStructuredSelection initialResourceSelection; - private List selectedTypes = new ArrayList(); + private List selectedTypes = new ArrayList<>(); // widgets private ResourceTreeAndListGroup resourceGroup; @@ -272,7 +272,7 @@ protected final void createResourcesGroup(Composite parent) { // create the input element, which has the root resource // as its only child - List input = new ArrayList(); + List input = new ArrayList<>(); IProject[] projects = ResourcesPlugin.getWorkspace().getRoot().getProjects(); for (IProject project : projects) { if (project.isOpen()) { @@ -322,11 +322,11 @@ protected boolean ensureResourcesLocal(List resources) { * IResource) */ protected List extractNonLocalResources(List originalList) { - ArrayList result = new ArrayList(originalList.size()); - Iterator resourcesEnum = originalList.iterator(); + ArrayList result = new ArrayList<>(originalList.size()); + Iterator resourcesEnum = originalList.iterator(); while (resourcesEnum.hasNext()) { - IResource currentResource = (IResource) resourcesEnum.next(); + IResource currentResource = resourcesEnum.next(); if (!currentResource.isLocal(IResource.DEPTH_ZERO)) { result.add(currentResource); } @@ -424,8 +424,8 @@ protected void updateContentProviders(boolean showLinked) { * type: IResource) */ protected List getSelectedResources() { - Iterator resourcesToExportIterator = this.getSelectedResourcesIterator(); - List resourcesToExport = new ArrayList(); + Iterator resourcesToExportIterator = this.getSelectedResourcesIterator(); + List resourcesToExport = new ArrayList<>(); while (resourcesToExportIterator.hasNext()) { resourcesToExport.add(resourcesToExportIterator.next()); } @@ -477,7 +477,7 @@ protected void handleTypesEditButtonPressed() { Object[] newSelectedTypes = queryResourceTypesToExport(); if (newSelectedTypes != null) { // ie.- did not press Cancel - this.selectedTypes = new ArrayList(newSelectedTypes.length); + this.selectedTypes = new ArrayList<>(newSelectedTypes.length); this.selectedTypes.addAll(Arrays.asList(newSelectedTypes)); setupSelectionsBasedOnSelectedTypes(); } @@ -504,7 +504,7 @@ protected boolean hasExportableExtension(String resourceName) { String extension = resourceName.substring(separatorIndex + 1); - Iterator it = selectedTypes.iterator(); + Iterator it = selectedTypes.iterator(); while (it.hasNext()) { if (extension.equalsIgnoreCase((String) it.next())) { return true; @@ -584,18 +584,18 @@ protected void setupBasedOnInitialSelections() { private void setupSelectionsBasedOnSelectedTypes() { Runnable runnable = () -> { - Map selectionMap = new Hashtable(); + Map> selectionMap = new Hashtable<>(); // Only get the white selected ones - Iterator resourceIterator = resourceGroup.getAllWhiteCheckedItems().iterator(); + Iterator resourceIterator = resourceGroup.getAllWhiteCheckedItems().iterator(); while (resourceIterator.hasNext()) { // handle the files here - white checked containers require recursion IResource resource = (IResource) resourceIterator.next(); if (resource.getType() == IResource.FILE) { if (hasExportableExtension(resource.getName())) { - List resourceList = new ArrayList(); + List resourceList = new ArrayList<>(); IContainer parent = resource.getParent(); if (selectionMap.containsKey(parent)) { - resourceList = (List) selectionMap.get(parent); + resourceList = selectionMap.get(parent); } resourceList.add(resource); selectionMap.put(parent, resourceList); @@ -616,9 +616,9 @@ private void setupSelectionsBasedOnSelectedTypes() { * selectionMap. If a resource is a file see if it matches one of the selected * extensions. If not then check the children. */ - private void setupSelectionsBasedOnSelectedTypes(Map selectionMap, IContainer parent) { + private void setupSelectionsBasedOnSelectedTypes(Map> selectionMap, IContainer parent) { - List selections = new ArrayList(); + List selections = new ArrayList<>(); IResource[] resources; boolean hasFiles = false; diff --git a/bundles/org.eclipse.ui.ide/extensions/org/eclipse/ui/dialogs/WizardResourceImportPage.java b/bundles/org.eclipse.ui.ide/extensions/org/eclipse/ui/dialogs/WizardResourceImportPage.java index 69d8d3cc48e..444cc033860 100644 --- a/bundles/org.eclipse.ui.ide/extensions/org/eclipse/ui/dialogs/WizardResourceImportPage.java +++ b/bundles/org.eclipse.ui.ide/extensions/org/eclipse/ui/dialogs/WizardResourceImportPage.java @@ -18,6 +18,7 @@ import java.util.ArrayList; import java.util.Arrays; +import java.util.List; import java.util.Map; import org.eclipse.core.resources.IContainer; @@ -83,7 +84,7 @@ public abstract class WizardResourceImportPage extends WizardDataTransferPage { // initial value stores private String initialContainerFieldValue; - protected java.util.List selectedTypes = new ArrayList(); + protected List selectedTypes = new ArrayList<>(); // widgets private Text containerNameField; @@ -313,7 +314,7 @@ protected IPath getResourcePath() { * @return a list of resources currently selected for export (element type: * IResource) */ - protected java.util.List getSelectedResources() { + protected List getSelectedResources() { return this.selectionGroup.getAllCheckedListItems(); } @@ -365,7 +366,7 @@ protected IContainer getSpecifiedContainer() { * Returns a collection of the currently-specified resource types for use by the * type selection dialog. */ - protected java.util.List getTypesToImport() { + protected List getTypesToImport() { return selectedTypes; } @@ -417,7 +418,7 @@ protected void handleTypesEditButtonPressed() { Object[] newSelectedTypes = dialog.getResult(); if (newSelectedTypes != null) { // ie.- did not press Cancel - this.selectedTypes = new ArrayList(newSelectedTypes.length); + this.selectedTypes = new ArrayList<>(newSelectedTypes.length); this.selectedTypes.addAll(Arrays.asList(newSelectedTypes)); setupSelectionsBasedOnSelectedTypes(); diff --git a/bundles/org.eclipse.ui.ide/extensions/org/eclipse/ui/model/WorkbenchContentProvider.java b/bundles/org.eclipse.ui.ide/extensions/org/eclipse/ui/model/WorkbenchContentProvider.java index 75e9e23f535..1724e303e53 100644 --- a/bundles/org.eclipse.ui.ide/extensions/org/eclipse/ui/model/WorkbenchContentProvider.java +++ b/bundles/org.eclipse.ui.ide/extensions/org/eclipse/ui/model/WorkbenchContentProvider.java @@ -117,7 +117,7 @@ protected void processDelta(IResourceDelta delta) { } - final Collection runnables = new ArrayList(); + final Collection runnables = new ArrayList<>(); processDelta(delta, runnables); if (runnables.isEmpty()) { @@ -144,10 +144,10 @@ protected void processDelta(IResourceDelta delta) { /** * Run all of the runnables that are the widget updates */ - private void runUpdates(Collection runnables) { - Iterator runnableIterator = runnables.iterator(); + private void runUpdates(Collection runnables) { + Iterator runnableIterator = runnables.iterator(); while(runnableIterator.hasNext()){ - ((Runnable)runnableIterator.next()).run(); + runnableIterator.next().run(); } } @@ -155,7 +155,7 @@ private void runUpdates(Collection runnables) { /** * Process a resource delta. Add any runnables */ - private void processDelta(IResourceDelta delta, Collection runnables) { + private void processDelta(IResourceDelta delta, Collection runnables) { //he widget may have been destroyed // by the time this is run. Check for this and do nothing if so. Control ctrl = viewer.getControl(); diff --git a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/ide/dialogs/ResourceTreeAndListGroup.java b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/ide/dialogs/ResourceTreeAndListGroup.java index 88b92f2f94f..89a111f1e4c 100644 --- a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/ide/dialogs/ResourceTreeAndListGroup.java +++ b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/ide/dialogs/ResourceTreeAndListGroup.java @@ -130,9 +130,9 @@ public void treeExpanded(TreeExpansionEvent event) { private Object root; private Object currentTreeSelection; - private Collection expandedTreeNodes = new HashSet(); - private Map checkedStateStore = new HashMap(9); - private HashSet whiteCheckedTreeItems = new HashSet(); + private Collection expandedTreeNodes = new HashSet<>(); + private Map> checkedStateStore = new HashMap<>(9); + private HashSet whiteCheckedTreeItems = new HashSet<>(); private ITreeContentProvider treeContentProvider; private IStructuredContentProvider listContentProvider; private ILabelProvider treeLabelProvider; @@ -226,7 +226,7 @@ private boolean areAllChildrenWhiteChecked(Object treeElement) { * @param treeElement java.lang.Object */ private boolean areAllElementsChecked(Object treeElement) { - List checkedElements = (List) checkedStateStore.get(treeElement); + List checkedElements = checkedStateStore.get(treeElement); if (checkedElements == null) { return false; } @@ -325,7 +325,7 @@ private void createTreeViewer(Composite parent, boolean useHeightHint) { private boolean determineShouldBeAtLeastGrayChecked(Object treeElement) { // if any list items associated with treeElement are checked then it // retains its gray-checked status regardless of its children - List checked = (List) checkedStateStore.get(treeElement); + List checked = checkedStateStore.get(treeElement); if (checked != null && (!checked.isEmpty())) { return true; } @@ -412,7 +412,7 @@ private void expandTreeElement(final Object item) { setWhiteChecked(child, true); treeViewer.setChecked(child, true); checkedStateStore.put(child, - new ArrayList()); + new ArrayList<>()); } } @@ -449,7 +449,7 @@ private void findAllSelectedListElements(Object treeElement, String parentLabel, monitor); } else { //Add what we have stored if (checkedStateStore.containsKey(treeElement)) { - filter.filterElements((Collection) checkedStateStore + filter.filterElements(checkedStateStore .get(treeElement), monitor); } } @@ -474,11 +474,11 @@ private void findAllSelectedListElements(Object treeElement, String parentLabel, * @param treeElement java.lang.Object * @param result java.util.Collection */ - private void findAllWhiteCheckedItems(Object treeElement, Collection result) { + private void findAllWhiteCheckedItems(Object treeElement, Collection result) { if (whiteCheckedTreeItems.contains(treeElement)) { result.add(treeElement); } else { - Collection listChildren = (Collection) checkedStateStore + Collection listChildren = checkedStateStore .get(treeElement); //if it is not in the store then it and it's children are not interesting if (listChildren == null) { @@ -537,7 +537,7 @@ public boolean isEveryItemChecked() { * @return true if all items are checked, false otherwise. */ private boolean isEveryChildrenChecked(Object treeElement) { - List checked = (List) checkedStateStore.get(treeElement); + List checked = checkedStateStore.get(treeElement); if (checked != null && (!checked.isEmpty())) { Object[] listItems = listContentProvider.getElements(treeElement); if (listItems.length != checked.size()) @@ -560,8 +560,8 @@ private boolean isEveryChildrenChecked(Object treeElement) { * @return all of the leaf elements which are checked. This API does not * return null in order to keep backwards compatibility. */ - public List getAllCheckedListItems() { - final ArrayList returnValue = new ArrayList(); + public List getAllCheckedListItems() { + final List returnValue = new ArrayList<>(); IElementFilter passThroughFilter = new IElementFilter() { @@ -581,7 +581,7 @@ public void filterElements(Object[] elements, try { getAllCheckedListItems(passThroughFilter, null); } catch (InterruptedException exception) { - return Collections.EMPTY_LIST; + return Collections.emptyList(); } return returnValue; @@ -592,8 +592,8 @@ public void filterElements(Object[] elements, * * @return all of the leaf elements. */ - public List getAllListItems() { - final ArrayList returnValue = new ArrayList(); + public List getAllListItems() { + final List returnValue = new ArrayList<>(); IElementFilter passThroughFilter = new IElementFilter() { @@ -615,7 +615,7 @@ public void filterElements(Object[] elements, findAllSelectedListElements(child, null, true, passThroughFilter, null); } } catch (InterruptedException exception) { - return Collections.EMPTY_LIST; + return Collections.emptyList(); } return returnValue; @@ -628,8 +628,8 @@ public void filterElements(Object[] elements, * * @return the list of all of the items that are white checked */ - public List getAllWhiteCheckedItems() { - List result = new ArrayList(); + public List getAllWhiteCheckedItems() { + List result = new ArrayList<>(); //Iterate through the children of the root as the root is not in the store for (Object child : treeContentProvider.getChildren(root)) { findAllWhiteCheckedItems(child, result); @@ -689,7 +689,7 @@ private void grayCheckHierarchy(Object treeElement) { if (checkedStateStore.containsKey(treeElement)) { return; // no need to proceed upwards from here } - checkedStateStore.put(treeElement, new ArrayList()); + checkedStateStore.put(treeElement, new ArrayList<>()); Object parent = treeContentProvider.getParent(treeElement); if (parent != null) { grayCheckHierarchy(parent); @@ -761,7 +761,7 @@ private void initialize() { * initial list. */ private void listItemChecked(Object listElement, boolean state, boolean updatingFromSelection) { - List checkedListItems = (List) checkedStateStore.get(currentTreeSelection); + List checkedListItems = checkedStateStore.get(currentTreeSelection); //If it has not been expanded do so as the selection of list items will affect gray state if (!expandedTreeNodes.contains(currentTreeSelection)) { expandTreeElement(currentTreeSelection); @@ -772,7 +772,7 @@ private void listItemChecked(Object listElement, boolean state, boolean updating // since the associated tree item has gone from 0 -> 1 checked // list items, tree checking may need to be updated grayCheckHierarchy(currentTreeSelection); - checkedListItems = (List) checkedStateStore + checkedListItems = checkedStateStore .get(currentTreeSelection); } checkedListItems.add(listElement); @@ -831,10 +831,10 @@ private void populateListViewer(final Object treeElement) { }); } else { - List listItemsToCheck = (List) checkedStateStore.get(treeElement); + List listItemsToCheck = checkedStateStore.get(treeElement); if (listItemsToCheck != null) { - Iterator listItemsEnum = listItemsToCheck.iterator(); + Iterator listItemsEnum = listItemsToCheck.iterator(); while (listItemsEnum.hasNext()) { listViewer.setChecked(listItemsEnum.next(), true); } @@ -847,12 +847,12 @@ private void populateListViewer(final Object treeElement) { * appear in the checked table. Add any elements to the selectedNodes * so we can track that has been done. */ - private void primeHierarchyForSelection(Object item, Set selectedNodes) { + private void primeHierarchyForSelection(Object item, Set selectedNodes) { //Only prime it if we haven't visited yet if (selectedNodes.contains(item)) { return; } - checkedStateStore.put(item, new ArrayList()); + checkedStateStore.put(item, new ArrayList<>()); //mark as expanded as we are going to populate it after this expandedTreeNodes.add(item); selectedNodes.add(item); @@ -897,7 +897,7 @@ public void setAllSelections(final boolean selection) { * @param treeElement the element being updated */ private void setListForWhiteSelection(Object treeElement) { - List listItemsChecked = new ArrayList(Arrays.asList(listContentProvider.getElements(treeElement))); + List listItemsChecked = new ArrayList<>(Arrays.asList(listContentProvider.getElements(treeElement))); checkedStateStore.put(treeElement, listItemsChecked); } @@ -1063,18 +1063,19 @@ private void ungrayCheckHierarchy(Object treeElement) { * items, do not include the element in the Map. */ public void updateSelections(Map items) { + Map> typedItems = items; // We are replacing all selected items with the given selected items, // so reinitialize everything. this.listViewer.setAllChecked(false); this.treeViewer.setCheckedElements(new Object[0]); - this.whiteCheckedTreeItems = new HashSet(); - Set selectedNodes = new HashSet(); - checkedStateStore = new HashMap(); + this.whiteCheckedTreeItems = new HashSet<>(); + Set selectedNodes = new HashSet<>(); + checkedStateStore = new HashMap<>(); //Update the store before the hierarchy to prevent updating parents before all of the children are done - for (Entry entry : ((Map) items).entrySet()) { + for (Entry> entry : typedItems.entrySet()) { Object key = entry.getKey(); - List selections = entry.getValue(); + List selections = entry.getValue(); //Replace the items in the checked state store with those from the supplied items checkedStateStore.put(key, selections); selectedNodes.add(key); @@ -1093,9 +1094,9 @@ public void updateSelections(Map items) { // Update the listView of the currently selected tree item. if (currentTreeSelection != null) { - Object displayItems = items.get(currentTreeSelection); + List displayItems = typedItems.get(currentTreeSelection); if (displayItems != null) { - listViewer.setCheckedElements(((List) displayItems).toArray()); + listViewer.setCheckedElements(displayItems.toArray()); } } } diff --git a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/ide/undo/AbstractMarkersOperation.java b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/ide/undo/AbstractMarkersOperation.java index e78ce5264a7..b2056fe6d40 100644 --- a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/ide/undo/AbstractMarkersOperation.java +++ b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/ide/undo/AbstractMarkersOperation.java @@ -48,7 +48,7 @@ abstract class AbstractMarkersOperation extends AbstractWorkspaceOperation { IMarker[] markers; - Map[] attributes; + Map[] attributes; /** * Create an AbstractMarkersOperation by specifying a combination of markers @@ -68,8 +68,9 @@ abstract class AbstractMarkersOperation extends AbstractWorkspaceOperation { * the name used to describe the operation */ AbstractMarkersOperation(IMarker[] markers, - IMarkerSnapshot[] markerDescriptions, Map attributes, String name) { + IMarkerSnapshot[] markerDescriptions, Map attributes, String name) { super(name); + Map typedAttributes = attributes; this.markers = markers; this.attributes = null; // If there is more than one marker, create an array with a copy @@ -81,12 +82,12 @@ abstract class AbstractMarkersOperation extends AbstractWorkspaceOperation { if (markers.length > 1) { this.attributes = new Map[markers.length]; for (int i = 0; i < markers.length; i++) { - Map copiedAttributes = new HashMap(); - copiedAttributes.putAll(attributes); + Map copiedAttributes = new HashMap<>(); + copiedAttributes.putAll(typedAttributes); this.attributes[i] = copiedAttributes; } } else { - this.attributes = new Map[] { attributes }; + this.attributes = new Map[] { typedAttributes }; } } setMarkerDescriptions(markerDescriptions); @@ -169,13 +170,13 @@ protected void updateMarkers(int work, IProgressMonitor monitor, int markerWork = work / markers.length; for (int i = 0; i < markers.length; i++) { if (mergeAttributes) { - Map oldAttributes = markers[i].getAttributes(); + Map oldAttributes = markers[i].getAttributes(); int increment = markerWork / attributes[i].size(); - Map replacedAttributes = new HashMap(); + Map replacedAttributes = new HashMap<>(); - for (Iterator iter = attributes[i].keySet().iterator(); iter + for (Iterator iter = attributes[i].keySet().iterator(); iter .hasNext();) { - String key = (String) iter.next(); + String key = iter.next(); Object val = attributes[i].get(key); markers[i].setAttribute(key, val); replacedAttributes.put(key, oldAttributes.get(key)); @@ -184,7 +185,7 @@ protected void updateMarkers(int work, IProgressMonitor monitor, attributes[i] = replacedAttributes; } else { // replace all of the attributes - Map oldAttributes = markers[i].getAttributes(); + Map oldAttributes = markers[i].getAttributes(); markers[i].setAttributes(attributes[i]); attributes[i] = oldAttributes; } diff --git a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/ide/undo/CopyResourcesOperation.java b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/ide/undo/CopyResourcesOperation.java index 1e6670d9648..9c82d6b85e1 100644 --- a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/ide/undo/CopyResourcesOperation.java +++ b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/ide/undo/CopyResourcesOperation.java @@ -174,7 +174,7 @@ protected void copy(IProgressMonitor monitor, IAdaptable uiInfo) // Reset resource descriptions to the just overwritten resources setResourceDescriptions(overwrittenResources - .toArray(new IResourceSnapshot[overwrittenResources.size()])); + .toArray(new IResourceSnapshot[overwrittenResources.size()])); // Reset the target resources to refer to the resources in their new // location. @@ -195,7 +195,7 @@ protected void doUndo(IProgressMonitor monitor, IAdaptable uiInfo) WorkspaceUndoUtil.delete(resources, subMonitor.split(1), uiInfo, true); // then restoring any overwritten by the previous copy... WorkspaceUndoUtil.recreate(resourceDescriptions, subMonitor.split(1), uiInfo); - setResourceDescriptions(new IResourceSnapshot[0]); + setResourceDescriptions(new IResourceSnapshot[0]); // then setting the target resources back to the original ones. // Note that the destination paths never changed since they // are not used during undo. @@ -212,7 +212,7 @@ protected boolean updateResourceChangeDescriptionFactory( update = true; factory.delete(resource); } - for (IResourceSnapshot resourceDescription : resourceDescriptions) { + for (IResourceSnapshot resourceDescription : resourceDescriptions) { if (resourceDescription != null) { update = true; IResource resource = resourceDescription.createResourceHandle(); @@ -246,7 +246,7 @@ public IStatus computeUndoableStatus(IProgressMonitor monitor) { markInvalid(); return getErrorStatus(UndoMessages.CopyResourcesOperation_NotAllowedDueToDataLoss); } - for (IResourceSnapshot snapshotResourceDescription : snapshotResourceDescriptions) { + for (IResourceSnapshot snapshotResourceDescription : snapshotResourceDescriptions) { if (!snapshotResourceDescription.verifyExistence(true)) { markInvalid(); return getErrorStatus(UndoMessages.CopyResourcesOperation_NotAllowedDueToDataLoss); @@ -273,7 +273,7 @@ public IStatus computeUndoableStatus(IProgressMonitor monitor) { */ private void setOriginalResources(IResource[] originals) { originalResources = originals; - snapshotResourceDescriptions = new IResourceSnapshot[originals.length]; + snapshotResourceDescriptions = new IResourceSnapshot[originals.length]; for (int i = 0; i < originals.length; i++) { snapshotResourceDescriptions[i] = ResourceSnapshotFactory.fromResource(originals[i]); } diff --git a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/ide/undo/MoveProjectOperation.java b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/ide/undo/MoveProjectOperation.java index b327851e2e9..ef052730791 100644 --- a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/ide/undo/MoveProjectOperation.java +++ b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/ide/undo/MoveProjectOperation.java @@ -119,7 +119,7 @@ protected void doExecute(IProgressMonitor monitor, IAdaptable uiInfo) throws CoreException { projectLocation = moveProject(getProject(), projectLocation, monitor); // nothing was overwritten - setResourceDescriptions(new IResourceSnapshot[0]); + setResourceDescriptions(new IResourceSnapshot[0]); } @Override diff --git a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/IDESelectionConversionService.java b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/IDESelectionConversionService.java index a4f8485668f..c8b541eaf17 100644 --- a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/IDESelectionConversionService.java +++ b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/IDESelectionConversionService.java @@ -43,7 +43,7 @@ public class IDESelectionConversionService implements public IStructuredSelection convertToResources( IStructuredSelection originalSelection) { - List result = new ArrayList(); + List result = new ArrayList<>(); for (Object currentElement : originalSelection) { diff --git a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/actions/BuildUtilities.java b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/actions/BuildUtilities.java index fce435e5edb..8c1c32e4bda 100644 --- a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/actions/BuildUtilities.java +++ b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/actions/BuildUtilities.java @@ -170,7 +170,7 @@ private static boolean matchingTrigger(IProject[] projects, int trigger, boolean * @param projects The projects in which to save editors, or null * to save editors in all projects. */ - public static void saveEditors(Collection projects) { + public static void saveEditors(Collection projects) { if (!BuildAction.isSaveAllSet()) { return; } diff --git a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/dialogs/PathVariableDialog.java b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/dialogs/PathVariableDialog.java index dd29c24360e..a995c2094c2 100644 --- a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/dialogs/PathVariableDialog.java +++ b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/dialogs/PathVariableDialog.java @@ -121,7 +121,7 @@ public class PathVariableDialog extends TitleAreaDialog { * Set of variable names currently in use. Used when warning the user that * the currently selected name is already in use by another variable. */ - private Set namesInUse; + private Set namesInUse; /** * The current validation status. Its value can be one of the following:
    diff --git a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/dialogs/ResourceWorkingSetPage.java b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/dialogs/ResourceWorkingSetPage.java index 6de5c25a270..ab002e7d39f 100644 --- a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/dialogs/ResourceWorkingSetPage.java +++ b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/dialogs/ResourceWorkingSetPage.java @@ -102,7 +102,7 @@ public ResourceWorkingSetPage() { * @param collectedResources list of collected resources * @param container container to collect working set elements for */ - private void addWorkingSetElements(List collectedResources, IContainer container) { + private void addWorkingSetElements(List collectedResources, IContainer container) { IPath containerPath = container.getFullPath(); for (IAdaptable adaptable : workingSet.getElements()) { @@ -111,7 +111,7 @@ private void addWorkingSetElements(List collectedResources, IContainer container if (resource != null) { IPath resourcePath = resource.getFullPath(); if (containerPath.isPrefixOf(resourcePath)) { - collectedResources.add(adaptable); + collectedResources.add(resource); } } } @@ -233,7 +233,7 @@ public void widgetSelected(SelectionEvent selectionEvent) { * @param checkedResources the output, list of checked resources * @param container the container to collect checked resources in */ - private void findCheckedResources(List checkedResources, IContainer container) { + private void findCheckedResources(List checkedResources, IContainer container) { IResource[] resources = null; try { resources = container.members(); @@ -261,7 +261,7 @@ private void findCheckedResources(List checkedResources, IContainer container) { */ @Override public void finish() { - ArrayList resources = new ArrayList<>(10); + ArrayList resources = new ArrayList<>(10); findCheckedResources(resources, (IContainer) tree.getInput()); if (workingSet == null) { IWorkingSetManager workingSetManager = PlatformUI.getWorkbench().getWorkingSetManager(); diff --git a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/filesystem/FileSystemStructureProvider.java b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/filesystem/FileSystemStructureProvider.java index 32719ae7c25..52d2b3399dd 100644 --- a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/filesystem/FileSystemStructureProvider.java +++ b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/filesystem/FileSystemStructureProvider.java @@ -34,14 +34,14 @@ */ public class FileSystemStructureProvider implements IImportStructureProvider { - private Set visitedDirs; + private Set visitedDirs; @Override public List getChildren(Object element) { File folder = (File) element; String[] children = folder.list(); int childrenLength = children == null ? 0 : children.length; - List result = new ArrayList(childrenLength); + List result = new ArrayList<>(childrenLength); for (int i = 0; i < childrenLength; i++) { File file = new File(folder, children[i]); @@ -55,7 +55,7 @@ public List getChildren(Object element) { private void initVisitedDirs(){ if(visitedDirs == null){ - visitedDirs = new HashSet(); + visitedDirs = new HashSet<>(); } } diff --git a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/misc/CheckboxTreeAndListGroup.java b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/misc/CheckboxTreeAndListGroup.java index 857fc11139b..35e8757d775 100644 --- a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/misc/CheckboxTreeAndListGroup.java +++ b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/misc/CheckboxTreeAndListGroup.java @@ -59,7 +59,7 @@ public class CheckboxTreeAndListGroup extends EventManager implements private List expandedTreeNodes = new ArrayList<>(); - private Map checkedStateStore = new HashMap(9); + private Map> checkedStateStore = new HashMap<>(9); private List whiteCheckedTreeItems = new ArrayList<>(); @@ -373,12 +373,11 @@ public void expandAll() { * @return java.util.Vector */ public Iterator getAllCheckedListItems() { - List result = new ArrayList<>(); - Iterator listCollectionsEnum = checkedStateStore.values().iterator(); + List result = new ArrayList<>(); + Iterator> listCollectionsEnum = checkedStateStore.values().iterator(); while (listCollectionsEnum.hasNext()) { - Iterator currentCollection = ((List) listCollectionsEnum.next()) - .iterator(); + Iterator currentCollection = listCollectionsEnum.next().iterator(); while (currentCollection.hasNext()) { result.add(currentCollection.next()); } @@ -393,7 +392,7 @@ public Iterator getAllCheckedListItems() { * * @return java.util.Vector */ - public Set getAllCheckedTreeItems() { + public Set getAllCheckedTreeItems() { return checkedStateStore.keySet(); } @@ -438,7 +437,7 @@ protected void grayCheckHierarchy(Object treeElement) { return; // no need to proceed upwards from here } - checkedStateStore.put(treeElement, new ArrayList()); + checkedStateStore.put(treeElement, new ArrayList<>()); if (determineShouldBeWhiteChecked(treeElement)) { setWhiteChecked(treeElement, true); } @@ -485,7 +484,7 @@ protected void initialize() { */ protected void listItemChecked(Object listElement, boolean state, boolean updatingFromSelection) { - List checkedListItems = checkedStateStore + List checkedListItems = checkedStateStore .get(currentTreeSelection); if (state) { @@ -536,10 +535,10 @@ public void run() { */ protected void populateListViewer(final Object treeElement) { listViewer.setInput(treeElement); - List listItemsToCheck = checkedStateStore.get(treeElement); + List listItemsToCheck = checkedStateStore.get(treeElement); if (listItemsToCheck != null) { - Iterator listItemsEnum = listItemsToCheck.iterator(); + Iterator listItemsEnum = listItemsToCheck.iterator(); while (listItemsEnum.hasNext()) { listViewer.setChecked(listItemsEnum.next(), true); } @@ -636,7 +635,8 @@ protected void setTreeChecked(Object treeElement, boolean state) { } if (state) { - List listItemsChecked = new ArrayList(Arrays.asList(listContentProvider.getElements(treeElement))); + List listItemsChecked = new ArrayList<>( + Arrays.asList(listContentProvider.getElements(treeElement))); checkedStateStore.put(treeElement, listItemsChecked); } else { checkedStateStore.remove(treeElement); @@ -778,16 +778,15 @@ protected void updateHierarchy(Object treeElement) { * @param items Map with keys of Object (the tree element) and values of List (the selected * list elements). */ - public void updateSelections(final Map items) { - - //Potentially long operation - show a busy cursor + public void updateSelections(final Map> items) { + // Potentially long operation - show a busy cursor BusyIndicator.showWhile(treeViewer.getControl().getDisplay(), () -> { //Update the store before the hierarchy to prevent updating parents before all of the children are done - for (Entry entry : ((Map) items).entrySet()) { + for (Entry> entry : items.entrySet()) { Object key1 = entry.getKey(); //Replace the items in the checked state store with those from the supplied items - List selections = entry.getValue(); + List selections = entry.getValue(); if (selections.isEmpty()) { //If it is empty remove it from the list checkedStateStore.remove(key1); @@ -803,7 +802,7 @@ public void updateSelections(final Map items) { } //Now update hierarchies - for (Entry entry : ((Map) items).entrySet()) { + for (Entry> entry : items.entrySet()) { Object key2 = entry.getKey(); updateHierarchy(key2); if (currentTreeSelection != null diff --git a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/wizards/datatransfer/FileSystemExportOperation.java b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/wizards/datatransfer/FileSystemExportOperation.java index 2d65a6da354..accbf14b74d 100644 --- a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/wizards/datatransfer/FileSystemExportOperation.java +++ b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/wizards/datatransfer/FileSystemExportOperation.java @@ -45,7 +45,7 @@ public class FileSystemExportOperation implements IRunnableWithProgress { private FileSystemExporter exporter = new FileSystemExporter(); - private List resourcesToExport; + private List resourcesToExport; private IOverwriteQuery overwriteCallback; @@ -122,10 +122,10 @@ protected int countChildrenOf(IResource parentResource) */ protected int countSelectedResources() throws CoreException { int result = 0; - Iterator resources = resourcesToExport.iterator(); + Iterator resources = resourcesToExport.iterator(); while (resources.hasNext()) { - result += countChildrenOf((IResource) resources.next()); + result += countChildrenOf(resources.next()); } return result; @@ -263,11 +263,11 @@ protected void exportFile(IFile file, IPath location) * resourcesToExport collection */ protected void exportSpecifiedResources() throws InterruptedException { - Iterator resources = resourcesToExport.iterator(); + Iterator resources = resourcesToExport.iterator(); IPath initPath = (IPath) path.clone(); while (resources.hasNext()) { - IResource currentResource = (IResource) resources.next(); + IResource currentResource = resources.next(); if (!currentResource.isAccessible() || (!resolveLinks && currentResource.isLinked())) { continue; } diff --git a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/wizards/datatransfer/MinimizedFileSystemElement.java b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/wizards/datatransfer/MinimizedFileSystemElement.java index d124c8f80ac..ab6913de6bc 100644 --- a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/wizards/datatransfer/MinimizedFileSystemElement.java +++ b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/wizards/datatransfer/MinimizedFileSystemElement.java @@ -78,7 +78,7 @@ private void populate(IImportStructureProvider provider) { List children = provider.getChildren(fileSystemObject); if (children != null) { - Iterator childrenEnum = children.iterator(); + Iterator childrenEnum = children.iterator(); while (childrenEnum.hasNext()) { Object child = childrenEnum.next(); diff --git a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/wizards/datatransfer/TarFile.java b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/wizards/datatransfer/TarFile.java index bcdc14d0b5f..3053fe21f6c 100644 --- a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/wizards/datatransfer/TarFile.java +++ b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/wizards/datatransfer/TarFile.java @@ -93,15 +93,15 @@ public TarFile(String filename) throws TarException, IOException { * * @return enumeration of all files in the archive */ - public Enumeration entries() { - return new Enumeration() { + public Enumeration entries() { + return new Enumeration<>() { @Override public boolean hasMoreElements() { return (curEntry != null); } @Override - public Object nextElement() { + public TarEntry nextElement() { TarEntry oldEntry = curEntry; try { curEntry = entryEnumerationStream.getNextEntry(); diff --git a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/wizards/datatransfer/TarLeveledStructureProvider.java b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/wizards/datatransfer/TarLeveledStructureProvider.java index 5586aa9c7a1..5bc9aee0d56 100644 --- a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/wizards/datatransfer/TarLeveledStructureProvider.java +++ b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/wizards/datatransfer/TarLeveledStructureProvider.java @@ -40,9 +40,9 @@ public class TarLeveledStructureProvider implements private TarEntry root = new TarEntry("/");//$NON-NLS-1$ - private Map children; + private Map> children; - private Map directoryEntryCache = new HashMap(); + private Map directoryEntryCache = new HashMap<>(); private int stripLevel; @@ -67,7 +67,7 @@ public TarLeveledStructureProvider(TarFile sourceFile) { * @return The element represented by this pathname (it may have already existed) */ protected TarEntry createContainer(IPath pathname) { - TarEntry existingEntry = (TarEntry) directoryEntryCache.get(pathname); + TarEntry existingEntry = directoryEntryCache.get(pathname); if (existingEntry != null) { return existingEntry; } @@ -81,10 +81,10 @@ protected TarEntry createContainer(IPath pathname) { TarEntry newEntry = new TarEntry(pathname.toString()); newEntry.setFileType(TarEntry.DIRECTORY); directoryEntryCache.put(pathname, newEntry); - List childList = new ArrayList(); + List childList = new ArrayList<>(); children.put(newEntry, childList); - List parentChildList = (List) children.get(parent); + List parentChildList = children.get(parent); parentChildList.add(newEntry); return newEntry; } @@ -98,11 +98,11 @@ protected void createFile(TarEntry entry) { if (pathname.segmentCount() == 1) { parent = root; } else { - parent = (TarEntry) directoryEntryCache.get(pathname + parent = directoryEntryCache.get(pathname .removeLastSegments(1)); } - List childList = (List) children.get(parent); + List childList = children.get(parent); childList.add(entry); } @@ -112,7 +112,7 @@ public List getChildren(Object element) { initialize(); } - return ((List) children.get(element)); + return children.get(element); } @Override @@ -194,10 +194,10 @@ public void close() throws Exception { * specified source file. */ protected void initialize() { - children = new HashMap(1000); + children = new HashMap<>(1000); - children.put(root, new ArrayList()); - Enumeration entries = tarFile.entries(); + children.put(root, new ArrayList<>()); + Enumeration entries = tarFile.entries(); while (entries.hasMoreElements()) { TarEntry entry = (TarEntry) entries.nextElement(); IPath path = IPath.fromOSString(entry.getName()).addTrailingSeparator(); diff --git a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/wizards/datatransfer/WizardFileSystemResourceImportPage1.java b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/wizards/datatransfer/WizardFileSystemResourceImportPage1.java index 8cc8c9a7d6b..fa5084bc5e5 100644 --- a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/wizards/datatransfer/WizardFileSystemResourceImportPage1.java +++ b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/wizards/datatransfer/WizardFileSystemResourceImportPage1.java @@ -651,8 +651,8 @@ public boolean finish() { saveWidgetValues(); - Iterator resourcesEnum = getSelectedResources().iterator(); - List fileSystemObjects = new ArrayList(); + Iterator resourcesEnum = getSelectedResources().iterator(); + List fileSystemObjects = new ArrayList<>(); while (resourcesEnum.hasNext()) { fileSystemObjects.add(((FileSystemElement) resourcesEnum.next()) .getFileSystemObject()); @@ -850,7 +850,7 @@ protected void handleTypesEditButtonPressed() { /** * Import the resources with extensions as specified by the user */ - protected boolean importResources(List fileSystemObjects) { + protected boolean importResources(List fileSystemObjects) { ImportOperation operation; boolean shouldImportTopLevelFoldersRecursively = selectionGroup.isEveryItemChecked() && @@ -922,7 +922,7 @@ protected boolean isExportableExtension(String extension) { return true; } - Iterator itr = selectedTypes.iterator(); + Iterator itr = selectedTypes.iterator(); while (itr.hasNext()) { if (extension.equalsIgnoreCase((String) itr.next())) { return true; @@ -1110,7 +1110,7 @@ protected void setSourceName(String path) { protected void setupSelectionsBasedOnSelectedTypes() { ProgressMonitorDialog dialog = new ProgressMonitorJobsDialog( getContainer().getShell()); - final Map selectionMap = new Hashtable(); + final Map> selectionMap = new Hashtable<>(); final IElementFilter filter = new IElementFilter() { @@ -1120,7 +1120,7 @@ public void filterElements(Collection files, if (files == null) { throw new InterruptedException(); } - Iterator filesList = files.iterator(); + Iterator filesList = files.iterator(); while (filesList.hasNext()) { if (monitor.isCanceled()) { throw new InterruptedException(); @@ -1146,10 +1146,10 @@ public void filterElements(Object[] files, IProgressMonitor monitor) private void checkFile(Object fileElement) { MinimizedFileSystemElement file = (MinimizedFileSystemElement) fileElement; if (isExportableExtension(file.getFileNameExtension())) { - List elements = new ArrayList(); + List elements = new ArrayList<>(); FileSystemElement parent = file.getParent(); if (selectionMap.containsKey(parent)) { - elements = (List) selectionMap.get(parent); + elements = selectionMap.get(parent); } elements.add(file); selectionMap.put(parent, elements); @@ -1249,7 +1249,7 @@ protected boolean validateSourceGroup() { return false; } - List resourcesToExport = selectionGroup.getAllWhiteCheckedItems(); + List resourcesToExport = selectionGroup.getAllWhiteCheckedItems(); if (resourcesToExport.isEmpty()){ setMessage(null); setErrorMessage(DataTransferMessages.FileImport_noneSelected); diff --git a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/views/framelist/TreeFrame.java b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/views/framelist/TreeFrame.java index 27dab1236f6..7d521ae95a9 100644 --- a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/views/framelist/TreeFrame.java +++ b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/views/framelist/TreeFrame.java @@ -124,9 +124,9 @@ public AbstractTreeViewer getViewer() { * @param memento memento to restore elements from * @return list of restored elements. May be empty. */ - private List restoreElements(IMemento memento) { + private List restoreElements(IMemento memento) { IMemento[] elementMem = memento.getChildren(TAG_ELEMENT); - List elements = new ArrayList(elementMem.length); + List elements = new ArrayList<>(elementMem.length); for (IMemento currentMemento : elementMem) { String factoryID = currentMemento.getString(TAG_FACTORY_ID); @@ -167,14 +167,14 @@ public void restoreState(IMemento memento) { } IMemento expandedMem = memento.getChild(TAG_EXPANDED); if (expandedMem != null) { - List elements = restoreElements(expandedMem); + List elements = restoreElements(expandedMem); expandedElements = elements.toArray(new Object[elements.size()]); } else { expandedElements = new Object[0]; } IMemento selectionMem = memento.getChild(TAG_SELECTION); if (selectionMem != null) { - List elements = restoreElements(selectionMem); + List elements = restoreElements(selectionMem); selection = new StructuredSelection(elements); } else { selection = StructuredSelection.EMPTY; diff --git a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/views/markers/internal/TableComparator.java b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/views/markers/internal/TableComparator.java index c85e8737e04..2c35c080248 100644 --- a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/views/markers/internal/TableComparator.java +++ b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/views/markers/internal/TableComparator.java @@ -21,7 +21,7 @@ import org.eclipse.jface.viewers.Viewer; import org.eclipse.jface.viewers.ViewerComparator; -public class TableComparator extends ViewerComparator implements Comparator { +public class TableComparator extends ViewerComparator implements Comparator { public static final int MAX_DEPTH = 4; @@ -258,7 +258,7 @@ private static boolean verifyDirections(int[] directions) { } @Override - public int compare(Object o1, Object o2) { + public int compare(TableComparator o1, TableComparator o2) { return compare(null, o1, o2); } diff --git a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/wizards/datatransfer/FileStoreStructureProvider.java b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/wizards/datatransfer/FileStoreStructureProvider.java index a0fea848f35..d6c16d5d80e 100644 --- a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/wizards/datatransfer/FileStoreStructureProvider.java +++ b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/wizards/datatransfer/FileStoreStructureProvider.java @@ -44,7 +44,7 @@ public List getChildren(Object element) { new NullProgressMonitor())); } catch (CoreException exception) { logException(exception); - return new ArrayList(); + return new ArrayList<>(); } } diff --git a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/wizards/datatransfer/FileSystemStructureProvider.java b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/wizards/datatransfer/FileSystemStructureProvider.java index 808d7bc0760..56edd053301 100644 --- a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/wizards/datatransfer/FileSystemStructureProvider.java +++ b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/wizards/datatransfer/FileSystemStructureProvider.java @@ -45,7 +45,7 @@ public List getChildren(Object element) { File folder = (File) element; String[] children = folder.list(); int childrenLength = children == null ? 0 : children.length; - List result = new ArrayList(childrenLength); + List result = new ArrayList<>(childrenLength); for (int i = 0; i < childrenLength; i++) { result.add(new File(folder, children[i])); diff --git a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/wizards/datatransfer/ImportOperation.java b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/wizards/datatransfer/ImportOperation.java index 98894540d35..1fe8ef2c8fa 100644 --- a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/wizards/datatransfer/ImportOperation.java +++ b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/wizards/datatransfer/ImportOperation.java @@ -74,9 +74,9 @@ public class ImportOperation extends WorkspaceModifyOperation { private IContainer destinationContainer; - private List selectedFiles; + private List selectedFiles; - private List rejectedFiles; + private List rejectedFiles; private IImportStructureProvider provider; @@ -232,11 +232,11 @@ public ImportOperation(IPath containerPath, * @param policy on of the POLICY constants defined in the * class. */ - void collectExistingReadonlyFiles(IPath sourceStart, List sources, ArrayList noOverwrite, - ArrayList overwriteReadonly, int policy, IProgressMonitor monitor) { + void collectExistingReadonlyFiles(IPath sourceStart, List sources, ArrayList noOverwrite, + ArrayList overwriteReadonly, int policy, IProgressMonitor monitor) { SubMonitor subMonitor = SubMonitor.convert(monitor, 100); IWorkspaceRoot workspaceRoot = ResourcesPlugin.getWorkspace().getRoot(); - Iterator sourceIter = sources.iterator(); + Iterator sourceIter = sources.iterator(); IPath sourceRootPath = null; if (this.source != null) { @@ -269,7 +269,7 @@ void collectExistingReadonlyFiles(IPath sourceStart, List sources, ArrayList noO if (policy != POLICY_FORCE_OVERWRITE) { if (this.overwriteState == OVERWRITE_NONE || !queryOverwrite(newDestinationPath)) { - noOverwrite.add(folder); + noOverwrite.add(folder.getFullPath()); continue; } } @@ -284,7 +284,7 @@ void collectExistingReadonlyFiles(IPath sourceStart, List sources, ArrayList noO if (!queryOverwriteFile(file, policy)) { noOverwrite.add(file.getFullPath()); } else if (file.isReadOnly()) { - overwriteReadonly.add(file); + overwriteReadonly.add(file.getFullPath()); } } } @@ -457,8 +457,8 @@ IFolder getFolder(IResource resource) { * @param files source files * @return list of rejected files as absolute paths. Object type IPath. */ - ArrayList getRejectedFiles(IStatus multiStatus, IFile[] files) { - ArrayList filteredFiles = new ArrayList(); + ArrayList getRejectedFiles(IStatus multiStatus, IFile[] files) { + ArrayList filteredFiles = new ArrayList<>(); IStatus[] status = multiStatus.getChildren(); for (int i = 0; i < status.length; i++) { @@ -635,9 +635,9 @@ private void setResourceAttributes(IFile targetResource, Object fileObject) { * (element type: Object) * @exception OperationCanceledException if canceled */ - void importFileSystemObjects(List filesToImport, IProgressMonitor monitor) throws CoreException { + void importFileSystemObjects(List filesToImport, IProgressMonitor monitor) throws CoreException { SubMonitor subMonitor = SubMonitor.convert(monitor, filesToImport.size()); - Iterator filesEnum = filesToImport.iterator(); + Iterator filesEnum = filesToImport.iterator(); while (filesEnum.hasNext()) { SubMonitor iterationMonitor = subMonitor.split(1); Object fileSystemObject = filesEnum.next(); @@ -762,7 +762,7 @@ void importRecursivelyFrom(Object fileSystemObject, int policy, IProgressMonitor int childPolicy = importFolder(fileSystemObject, policy, subMonitor.split(10)); if (childPolicy != POLICY_SKIP_CHILDREN) { - List children = provider.getChildren(fileSystemObject); + List children = provider.getChildren(fileSystemObject); SubMonitor loopMonitor = subMonitor.split(90).setWorkRemaining(children.size()); for (Object child : children) { importRecursivelyFrom(child, childPolicy, loopMonitor.split(1)); @@ -879,7 +879,7 @@ public void setOverwriteResources(boolean value) { * @param existingFiles existing files to validate * @return list of rejected files as absolute paths. Object type IPath. */ - ArrayList validateEdit(List existingFiles) { + ArrayList validateEdit(List existingFiles) { if (existingFiles.size() > 0) { IFile[] files = existingFiles @@ -895,7 +895,7 @@ ArrayList validateEdit(List existingFiles) { if(!status.isOK()){ //If just a single status reject them all errorTable.add(status); - ArrayList filteredFiles = new ArrayList(); + ArrayList filteredFiles = new ArrayList<>(); for (IFile file : files) { filteredFiles.add(file.getFullPath()); @@ -904,7 +904,7 @@ ArrayList validateEdit(List existingFiles) { } } - return new ArrayList(); + return new ArrayList<>(); } /** @@ -914,9 +914,9 @@ ArrayList validateEdit(List existingFiles) { * * @param sourceFiles files to validate */ - void validateFiles(List sourceFiles, IProgressMonitor monitor) { - ArrayList noOverwrite = new ArrayList(); - ArrayList overwriteReadonly = new ArrayList(); + void validateFiles(List sourceFiles, IProgressMonitor monitor) { + ArrayList noOverwrite = new ArrayList<>(); + ArrayList overwriteReadonly = new ArrayList<>(); collectExistingReadonlyFiles(destinationPath, sourceFiles, noOverwrite, overwriteReadonly, POLICY_DEFAULT, monitor); diff --git a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/wizards/datatransfer/PopulateRootOperation.java b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/wizards/datatransfer/PopulateRootOperation.java index 30ff85bcd9c..d8baae71710 100644 --- a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/wizards/datatransfer/PopulateRootOperation.java +++ b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/wizards/datatransfer/PopulateRootOperation.java @@ -76,11 +76,11 @@ protected FileSystemElement createElement(FileSystemElement parent, if (isContainer) { if (depth > 0) { - List children = provider.getChildren(fileSystemObject); + List children = provider.getChildren(fileSystemObject); if (children == null) { - children = new ArrayList(1); + children = new ArrayList<>(1); } - Iterator childrenEnum = children.iterator(); + Iterator childrenEnum = children.iterator(); while (childrenEnum.hasNext()) { createElement(createdElement, childrenEnum.next(), depth - 1); } diff --git a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/wizards/datatransfer/SelectFilesOperation.java b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/wizards/datatransfer/SelectFilesOperation.java index 9cb99d63d73..da339ce15f4 100644 --- a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/wizards/datatransfer/SelectFilesOperation.java +++ b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/wizards/datatransfer/SelectFilesOperation.java @@ -79,11 +79,11 @@ protected FileSystemElement createElement(FileSystemElement parent, if (isContainer) { boolean haveChildOrFile = false; - List children = provider.getChildren(fileSystemObject); + List children = provider.getChildren(fileSystemObject); if (children == null) { - children = new ArrayList(1); + children = new ArrayList<>(1); } - Iterator childrenEnum = children.iterator(); + Iterator childrenEnum = children.iterator(); while (childrenEnum.hasNext()) { if (createElement(createdElement, childrenEnum.next()) != null) { haveChildOrFile = true;