diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/Checksums.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/Checksums.java index 56b4c551c8a..0b83514a68a 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/Checksums.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/Checksums.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2007 Wind River Systems, Inc. and others. + * Copyright (c) 2007, 2008 Wind River Systems, Inc. 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 @@ -8,7 +8,6 @@ * Contributors: * Markus Schorn - initial API and implementation *******************************************************************************/ - package org.eclipse.cdt.internal.core.pdom; import java.io.File; @@ -43,7 +42,7 @@ public class Checksums { * @throws NoSuchAlgorithmException * @since 4.0 */ - public static MessageDigest getAlgorithm(Map persistedMap) throws NoSuchAlgorithmException { + public static MessageDigest getAlgorithm(Map persistedMap) throws NoSuchAlgorithmException { Object obj= persistedMap.get(KEY_ALGORITHM); String alg= obj instanceof String ? (String) obj : DEFAULT_ALGORITHM; return MessageDigest.getInstance(alg); @@ -53,7 +52,7 @@ public class Checksums { * Stores the algorithm in a map. * @since 4.0 */ - public static void putAlgorithm(Map mapToPersist, MessageDigest md) { + public static void putAlgorithm(Map mapToPersist, MessageDigest md) { mapToPersist.put(KEY_ALGORITHM, md.getAlgorithm()); } @@ -81,12 +80,11 @@ public class Checksums { * Retrieves a checksum for a file from the persisted map. May return null. * @since 4.0 */ - public static byte[] getChecksum(Map persistedMap, IFile file) { + public static byte[] getChecksum(Map persistedMap, IFile file) { IPath prjRel= file.getProjectRelativePath(); Object checksum= persistedMap.get(prjRel.toString()); - if (checksum instanceof byte[]) { + if (checksum instanceof byte[]) return (byte[]) checksum; - } return null; } @@ -94,7 +92,7 @@ public class Checksums { * Stores a checksum in a map. * @since 4.0 */ - public static void putChecksum(Map mapToPersist, IFile file, byte[] checksum) { + public static void putChecksum(Map mapToPersist, IFile file, byte[] checksum) { IPath prjRel= file.getProjectRelativePath(); mapToPersist.put(prjRel.toString(), checksum); } @@ -104,16 +102,15 @@ public class Checksums { * @throws OperationCanceledException * @since 4.0 */ - public static Map createChecksumMap(IFile[] tus, MessageDigest md, IProgressMonitor pm) + public static Map createChecksumMap(IFile[] tus, MessageDigest md, IProgressMonitor pm) throws OperationCanceledException { - Map result= new HashMap(); + Map result= new HashMap(); putAlgorithm(result, md); pm.beginTask(Messages.Checksums_taskComputeChecksums, tus.length); - for (int i = 0; i < tus.length; i++) { + for (IFile file : tus) { if (pm.isCanceled()) { throw new OperationCanceledException(); } - IFile file = tus[i]; if (file != null) { IPath location= file.getLocation(); if (location != null) { diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CHHistoryListAction.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CHHistoryListAction.java index 2b9d284d810..104825814a9 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CHHistoryListAction.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/callhierarchy/CHHistoryListAction.java @@ -41,7 +41,7 @@ public class CHHistoryListAction extends Action { private class HistoryListDialog extends StatusDialog { - private ListDialogField fHistoryList; + private ListDialogField fHistoryList; private IStatus fHistoryStatus; private ICElement fResult; @@ -53,22 +53,22 @@ public class CHHistoryListAction extends Action { CHMessages.CHHistoryListAction_Remove_label, }; - IListAdapter adapter= new IListAdapter() { - public void customButtonPressed(ListDialogField field, int index) { + IListAdapter adapter= new IListAdapter() { + public void customButtonPressed(ListDialogField field, int index) { doCustomButtonPressed(); } - public void selectionChanged(ListDialogField field) { + public void selectionChanged(ListDialogField field) { doSelectionChanged(); } - public void doubleClicked(ListDialogField field) { + public void doubleClicked(ListDialogField field) { doDoubleClicked(); } }; LabelProvider labelProvider= new CUILabelProvider(CHHistoryAction.LABEL_OPTIONS, CElementImageProvider.OVERLAY_ICONS); - fHistoryList= new ListDialogField(adapter, buttonLabels, labelProvider); + fHistoryList= new ListDialogField(adapter, buttonLabels, labelProvider); fHistoryList.setLabelText(CHMessages.CHHistoryListAction_HistoryList_label); fHistoryList.setElements(Arrays.asList(historyEntries)); @@ -121,12 +121,12 @@ public class CHHistoryListAction extends Action { private void doSelectionChanged() { StatusInfo status= new StatusInfo(); - List selected= fHistoryList.getSelectedElements(); + List selected= fHistoryList.getSelectedElements(); if (selected.size() != 1) { status.setError(""); //$NON-NLS-1$ fResult= null; } else { - fResult= (ICElement) selected.get(0); + fResult= selected.get(0); } fHistoryList.enableButton(0, fHistoryList.getSize() > selected.size() && selected.size() != 0); fHistoryStatus= status; @@ -138,7 +138,7 @@ public class CHHistoryListAction extends Action { } public ICElement[] getRemaining() { - List elems= fHistoryList.getElements(); + List elems= fHistoryList.getElements(); return elems.toArray(new ICElement[elems.size()]); } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dnd/DelegatingDragAdapter.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dnd/DelegatingDragAdapter.java index cc747182232..2e00e3c4b13 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dnd/DelegatingDragAdapter.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dnd/DelegatingDragAdapter.java @@ -11,7 +11,6 @@ package org.eclipse.cdt.internal.ui.dnd; import java.util.ArrayList; -import java.util.Iterator; import java.util.List; import org.eclipse.core.runtime.Assert; @@ -52,8 +51,7 @@ public class DelegatingDragAdapter implements DragSourceListener { List transfers= new ArrayList(fPossibleListeners.length); fActiveListeners= new ArrayList(fPossibleListeners.length); - for (int i= 0; i < fPossibleListeners.length; i++) { - TransferDragSourceListener listener= fPossibleListeners[i]; + for (TransferDragSourceListener listener : fPossibleListeners) { event.doit= saveDoit; listener.dragStart(event); if (event.doit) { @@ -74,8 +72,9 @@ public class DelegatingDragAdapter implements DragSourceListener { */ public void dragSetData(DragSourceEvent event) { fFinishListener= getListener(event.dataType); - if (fFinishListener != null) + if (fFinishListener != null) { fFinishListener.dragSetData(event); + } } /* non Java-doc @@ -89,8 +88,9 @@ public class DelegatingDragAdapter implements DragSourceListener { // If the user presses Escape then we get a dragFinished without // getting a dragSetData before. fFinishListener= getListener(event.dataType); - if (fFinishListener != null) + if (fFinishListener != null) { fFinishListener.dragFinished(event); + } } } finally{ fFinishListener= null; @@ -102,11 +102,9 @@ public class DelegatingDragAdapter implements DragSourceListener { if (type == null) return null; - for (Iterator iter= fActiveListeners.iterator(); iter.hasNext();) { - TransferDragSourceListener listener= (TransferDragSourceListener)iter.next(); - if (listener.getTransfer().isSupportedType(type)) { + for (TransferDragSourceListener listener : fActiveListeners) { + if (listener.getTransfer().isSupportedType(type)) return listener; - } } return null; } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dnd/FileTransferDragAdapter.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dnd/FileTransferDragAdapter.java index 6ba17d1ad78..27f7edb2d58 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dnd/FileTransferDragAdapter.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dnd/FileTransferDragAdapter.java @@ -81,15 +81,13 @@ public class FileTransferDragAdapter implements TransferDragSourceListener { private static class RefreshOperation extends WorkspaceModifyOperation { private final Set roots; - public RefreshOperation(List resources) { + public RefreshOperation(List resources) { super(); roots = new HashSet(resources.size()); - for (Iterator iterator = resources.iterator(); iterator.hasNext();) { - IResource resource = (IResource) iterator.next(); + for (IResource resource : resources) { IResource parent = resource.getParent(); - roots.add(parent != null ? parent : resource); } } @@ -100,9 +98,7 @@ public class FileTransferDragAdapter implements TransferDragSourceListener { monitor.beginTask(CUIMessages.getString("FileTransferDragAdapter.refreshing"), roots.size()); //$NON-NLS-1$ MultiStatus status = new MultiStatus(CUIPlugin.getPluginId(), IStatus.OK, CUIMessages.getString("FileTransferDragAdapter.problem"), null); //$NON-NLS-1$ - for (Iterator iterator = roots.iterator(); iterator.hasNext();) { - IResource resource = (IResource) iterator.next(); - + for (IResource resource : roots) { try { resource.refreshLocal( IResource.DEPTH_ONE, @@ -120,7 +116,7 @@ public class FileTransferDragAdapter implements TransferDragSourceListener { } } - private List getResources() { + private List getResources() { List result = Collections.emptyList(); ISelection selection = provider.getSelection(); @@ -129,7 +125,7 @@ public class FileTransferDragAdapter implements TransferDragSourceListener { result = new ArrayList(structured.size()); - for (Iterator iterator = structured.iterator(); iterator.hasNext();) { + for (Iterator iterator = structured.iterator(); iterator.hasNext();) { Object object = iterator.next(); IResource resource = null; @@ -147,13 +143,12 @@ public class FileTransferDragAdapter implements TransferDragSourceListener { return result; } - private static String[] getResourceLocations(List resources) { + private static String[] getResourceLocations(List resources) { if (!resources.isEmpty()) { int count = resources.size(); List locations = new ArrayList(count); - for (Iterator iterator = resources.iterator(); iterator.hasNext();) { - IResource resource = (IResource) iterator.next(); + for (IResource resource : resources) { IPath location = resource.getLocation(); if (location != null) { diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dnd/ResourceTransferDragAdapter.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dnd/ResourceTransferDragAdapter.java index a5f122df7ad..9e0ba8037fb 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dnd/ResourceTransferDragAdapter.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dnd/ResourceTransferDragAdapter.java @@ -103,7 +103,7 @@ public class ResourceTransferDragAdapter implements TransferDragSourceListener { resources = new ArrayList(structured.size()); - for (Iterator iterator = structured.iterator(); iterator.hasNext();) { + for (Iterator iterator = structured.iterator(); iterator.hasNext();) { Object element = iterator.next(); IResource resource = null; if (element instanceof IResource) { diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dnd/ResourceTransferDropAdapter.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dnd/ResourceTransferDropAdapter.java index f48e1bd8c83..ecc67e563b8 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dnd/ResourceTransferDropAdapter.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dnd/ResourceTransferDropAdapter.java @@ -137,7 +137,7 @@ public class ResourceTransferDropAdapter extends CDTViewerDropAdapter implements .getSelection(); if (selection instanceof IStructuredSelection) { IStructuredSelection ssel = (IStructuredSelection) selection; - for (Iterator i = ssel.iterator(); i.hasNext();) { + for (Iterator i = ssel.iterator(); i.hasNext();) { Object o = i.next(); if (o instanceof IResource) { selectedResources.add((IResource) o); diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dnd/TextEditorDropAdapter.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dnd/TextEditorDropAdapter.java index 1947f6fa0e1..94b9ad7d0cf 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dnd/TextEditorDropAdapter.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/dnd/TextEditorDropAdapter.java @@ -67,22 +67,23 @@ public class TextEditorDropAdapter extends DropTargetAdapter implements * @see ITextEditorDropTargetListener */ public static class Factory implements IAdapterFactory { - private static final Class[] CLASSES= { ITextEditorDropTargetListener.class }; + private static final Class[] CLASSES= { ITextEditorDropTargetListener.class }; /* * @see org.eclipse.core.runtime.IAdapterFactory#getAdapter(java.lang.Object, * java.lang.Class) */ + @SuppressWarnings("unchecked") public Object getAdapter(Object adaptableObject, Class adapterType) { - if (adaptableObject instanceof ITextEditor) { + if (adaptableObject instanceof ITextEditor) return TextEditorDropAdapter.create((ITextEditor) adaptableObject); - } return null; } /* * @see org.eclipse.core.runtime.IAdapterFactory#getAdapterList() */ + @SuppressWarnings("unchecked") public Class[] getAdapterList() { return CLASSES; } @@ -323,13 +324,13 @@ public class TextEditorDropAdapter extends DropTargetAdapter implements * @param fileNames */ private void dropFiles(String[] fileNames) throws CoreException { - for (int i= 0; i < fileNames.length; i++) { - Path path= new Path(fileNames[i]); + for (String fileName : fileNames) { + Path path= new Path(fileName); java.io.File file= path.toFile(); if (!file.isFile()) { throw new CoreException(new Status(IStatus.ERROR, CUIPlugin .getPluginId(), 0, CUIMessages.getFormattedString( - "TextEditorDropAdapter.noFile", fileNames[i]), //$NON-NLS-1$ + "TextEditorDropAdapter.noFile", fileName), //$NON-NLS-1$ null)); } if (file.canRead()) { @@ -337,7 +338,7 @@ public class TextEditorDropAdapter extends DropTargetAdapter implements } else { throw new CoreException(new Status(IStatus.ERROR, CUIPlugin .getPluginId(), 0, CUIMessages.getFormattedString( - "TextEditorDropAdapter.unreadableFile", fileNames[i]), //$NON-NLS-1$ + "TextEditorDropAdapter.unreadableFile", fileName), //$NON-NLS-1$ null)); } } @@ -350,8 +351,7 @@ public class TextEditorDropAdapter extends DropTargetAdapter implements * @throws PartInitException */ private void dropMarkers(IMarker[] markers) throws PartInitException { - for (int i= 0; i < markers.length; i++) { - IMarker marker= markers[i]; + for (IMarker marker : markers) { IDE.openEditor(getPage(), marker); } } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/includebrowser/IBHistoryListAction.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/includebrowser/IBHistoryListAction.java index d8344351a01..a73e4bc4e0a 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/includebrowser/IBHistoryListAction.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/includebrowser/IBHistoryListAction.java @@ -41,7 +41,7 @@ public class IBHistoryListAction extends Action { private class HistoryListDialog extends StatusDialog { - private ListDialogField fHistoryList; + private ListDialogField fHistoryList; private IStatus fHistoryStatus; private ITranslationUnit fResult; @@ -53,22 +53,22 @@ public class IBHistoryListAction extends Action { IBMessages.IBHistoryListAction_Remove_label, }; - IListAdapter adapter= new IListAdapter() { - public void customButtonPressed(ListDialogField field, int index) { + IListAdapter adapter= new IListAdapter() { + public void customButtonPressed(ListDialogField field, int index) { doCustomButtonPressed(); } - public void selectionChanged(ListDialogField field) { + public void selectionChanged(ListDialogField field) { doSelectionChanged(); } - public void doubleClicked(ListDialogField field) { + public void doubleClicked(ListDialogField field) { doDoubleClicked(); } }; CUILabelProvider labelProvider= new CUILabelProvider(CElementBaseLabels.APPEND_ROOT_PATH, CElementImageProvider.OVERLAY_ICONS); - fHistoryList= new ListDialogField(adapter, buttonLabels, labelProvider); + fHistoryList= new ListDialogField(adapter, buttonLabels, labelProvider); fHistoryList.setLabelText(IBMessages.IBHistoryListAction_HistoryList_label); fHistoryList.setElements(Arrays.asList(elements)); @@ -121,12 +121,12 @@ public class IBHistoryListAction extends Action { private void doSelectionChanged() { StatusInfo status= new StatusInfo(); - List selected= fHistoryList.getSelectedElements(); + List selected= fHistoryList.getSelectedElements(); if (selected.size() != 1) { status.setError(""); //$NON-NLS-1$ fResult= null; } else { - fResult= (ITranslationUnit) selected.get(0); + fResult= selected.get(0); } fHistoryList.enableButton(0, fHistoryList.getSize() > selected.size() && selected.size() != 0); fHistoryStatus= status; @@ -138,7 +138,7 @@ public class IBHistoryListAction extends Action { } public ITranslationUnit[] getRemaining() { - List elems= fHistoryList.getElements(); + List elems= fHistoryList.getElements(); return elems.toArray(new ITranslationUnit[elems.size()]); } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/navigator/CNavigatorBuildActionGroup.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/navigator/CNavigatorBuildActionGroup.java index ff56dd068fb..f2d87c12566 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/navigator/CNavigatorBuildActionGroup.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/navigator/CNavigatorBuildActionGroup.java @@ -80,7 +80,7 @@ public class CNavigatorBuildActionGroup extends AbstractCNavigatorActionGroup { boolean hasBuilder= true; // false if any project is closed or does // not have builder - Iterator resources= selection.iterator(); + Iterator resources= selection.iterator(); while (resources.hasNext() && (!hasOpenProjects || !hasClosedProjects || hasBuilder || isProjectSelection)) { Object next= resources.next(); IProject project= null; diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/navigator/CNavigatorContentProvider.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/navigator/CNavigatorContentProvider.java index 967c6713ff2..137695db349 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/navigator/CNavigatorContentProvider.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/navigator/CNavigatorContentProvider.java @@ -272,6 +272,7 @@ public class CNavigatorContentProvider extends CViewContentProvider implements I /* * @see org.eclipse.ui.navigator.IPipelinedTreeContentProvider#getPipelinedChildren(java.lang.Object, java.util.Set) */ + @SuppressWarnings("unchecked") public void getPipelinedChildren(Object parent, Set currentChildren) { customizeCElements(getChildren(parent), currentChildren); } @@ -279,6 +280,7 @@ public class CNavigatorContentProvider extends CViewContentProvider implements I /* * @see org.eclipse.ui.navigator.IPipelinedTreeContentProvider#getPipelinedElements(java.lang.Object, java.util.Set) */ + @SuppressWarnings("unchecked") public void getPipelinedElements(Object input, Set currentElements) { // only replace plain resource elements with custom elements // and avoid duplicating elements already customized @@ -286,10 +288,9 @@ public class CNavigatorContentProvider extends CViewContentProvider implements I customizeCElements(getElements(input), currentElements); } - private void customizeCElements(Object[] cChildren, Set proposedChildren) { - List elementList= Arrays.asList(cChildren); - for (Iterator iter= proposedChildren.iterator(); iter.hasNext();) { - Object element= iter.next(); + private void customizeCElements(Object[] cChildren, Set proposedChildren) { + List elementList= Arrays.asList(cChildren); + for (Object element : proposedChildren) { IResource resource= null; if (element instanceof IResource) { resource= (IResource)element; @@ -303,8 +304,7 @@ public class CNavigatorContentProvider extends CViewContentProvider implements I } } } - for (int i= 0; i < cChildren.length; i++) { - Object element= cChildren[i]; + for (Object element : cChildren) { if (element instanceof ICElement) { ICElement cElement= (ICElement)element; IResource resource= cElement.getResource(); @@ -343,7 +343,7 @@ public class CNavigatorContentProvider extends CViewContentProvider implements I } } else if (parent instanceof IWorkspaceRoot) { // ignore adds of C projects (we are issuing a refresh) - for (Iterator iterator = addModification.getChildren().iterator(); iterator.hasNext();) { + for (Iterator iterator = addModification.getChildren().iterator(); iterator.hasNext();) { Object child= iterator.next(); if (child instanceof IProject) { if (CoreModel.hasCNature((IProject)child)) { @@ -360,14 +360,18 @@ public class CNavigatorContentProvider extends CViewContentProvider implements I * @see org.eclipse.ui.navigator.IPipelinedTreeContentProvider#interceptRefresh(org.eclipse.ui.navigator.PipelinedViewerUpdate) */ public boolean interceptRefresh(PipelinedViewerUpdate refreshSynchronization) { - return convertToCElements(refreshSynchronization.getRefreshTargets()); + @SuppressWarnings("unchecked") + final Set refreshTargets = refreshSynchronization.getRefreshTargets(); + return convertToCElements(refreshTargets); } /* * @see org.eclipse.ui.navigator.IPipelinedTreeContentProvider#interceptRemove(org.eclipse.ui.navigator.PipelinedShapeModification) */ public PipelinedShapeModification interceptRemove(PipelinedShapeModification removeModification) { - convertToCElements(removeModification.getChildren()); + @SuppressWarnings("unchecked") + final Set children = removeModification.getChildren(); + convertToCElements(children); return removeModification; } @@ -375,7 +379,9 @@ public class CNavigatorContentProvider extends CViewContentProvider implements I * @see org.eclipse.ui.navigator.IPipelinedTreeContentProvider#interceptUpdate(org.eclipse.ui.navigator.PipelinedViewerUpdate) */ public boolean interceptUpdate(PipelinedViewerUpdate updateSynchronization) { - return convertToCElements(updateSynchronization.getRefreshTargets()); + @SuppressWarnings("unchecked") + final Set refreshTargets = updateSynchronization.getRefreshTargets(); + return convertToCElements(refreshTargets); } /** @@ -399,7 +405,9 @@ public class CNavigatorContentProvider extends CViewContentProvider implements I if( !(element instanceof ICModel) && !(element instanceof ICProject) ) { modification.setParent(element); } - return convertToCElements(modification.getChildren()); + @SuppressWarnings("unchecked") + final Set children = modification.getChildren(); + return convertToCElements(children); } } } @@ -414,10 +422,10 @@ public class CNavigatorContentProvider extends CViewContentProvider implements I * refreshed in the viewer. * @return true if the input set was modified */ - private boolean convertToCElements(Set currentChildren) { - LinkedHashSet convertedChildren= new LinkedHashSet(); + private boolean convertToCElements(Set currentChildren) { + LinkedHashSet convertedChildren= new LinkedHashSet(); ICElement newChild; - for (Iterator iter= currentChildren.iterator(); iter.hasNext();) { + for (Iterator iter= currentChildren.iterator(); iter.hasNext();) { Object child= iter.next(); // do not convert IProject if (child instanceof IFile || child instanceof IFolder) { diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/navigator/CNavigatorDragAdapterAssistant.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/navigator/CNavigatorDragAdapterAssistant.java index 4ff76d51ec2..26a1f242abe 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/navigator/CNavigatorDragAdapterAssistant.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/navigator/CNavigatorDragAdapterAssistant.java @@ -45,11 +45,10 @@ public class CNavigatorDragAdapterAssistant extends CommonDragAdapterAssistant { * @see org.eclipse.ui.navigator.CommonDragAdapterAssistant#setDragData(org.eclipse.swt.dnd.DragSourceEvent, org.eclipse.jface.viewers.IStructuredSelection) */ @Override - public boolean setDragData(DragSourceEvent event, - IStructuredSelection selection) { + public boolean setDragData(DragSourceEvent event, IStructuredSelection selection) { if (selection != null) { boolean applicable= false; - for (Iterator iter= (selection).iterator(); iter.hasNext();) { + for (Iterator iter= (selection).iterator(); iter.hasNext();) { Object element= iter.next(); if (element instanceof ICElement) { if (element instanceof ITranslationUnit) { @@ -68,5 +67,4 @@ public class CNavigatorDragAdapterAssistant extends CommonDragAdapterAssistant { } return false; } - } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/navigator/CNavigatorDropAdapterAssistant.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/navigator/CNavigatorDropAdapterAssistant.java index 89fa2f11fc2..c0ffed22067 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/navigator/CNavigatorDropAdapterAssistant.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/navigator/CNavigatorDropAdapterAssistant.java @@ -179,8 +179,7 @@ public class CNavigatorDropAdapterAssistant extends CommonDropAdapterAssistant { if (LocalSelectionTransfer.getTransfer().isSupportedType(transferType)) { IResource[] selectedResources= getSelectedResources(); if (selectedResources.length > 0) { - for (int iRes = 0; iRes < selectedResources.length; iRes++) { - IResource res = selectedResources[iRes]; + for (IResource res : selectedResources) { if(res instanceof IProject) { // drop of projects not supported on other IResources // "Path for project must have only one segment." @@ -362,10 +361,9 @@ public class CNavigatorDropAdapterAssistant extends CommonDropAdapterAssistant { if (!(selection instanceof IStructuredSelection)) { return null; } - List elements = ((IStructuredSelection)selection).toList(); + List elements = ((IStructuredSelection)selection).toList(); List resources= new ArrayList(elements.size()); - for (Iterator iter= elements.iterator(); iter.hasNext();) { - Object element= iter.next(); + for (Object element : elements) { if (element instanceof ITranslationUnit) { continue; } @@ -394,11 +392,12 @@ public class CNavigatorDropAdapterAssistant extends CommonDropAdapterAssistant { ICElement parent = elements[0]; for (int i = 0; i < elements.length; ++i) { ICElement p = elements[i].getParent(); - if (parent == null && p!= null) { + if (parent == null) { + if (p!= null) + return false; + } + else if (!parent.equals(p)) return false; - } else if (!parent.equals(p)){ - return false; - } } } return true; @@ -438,7 +437,7 @@ public class CNavigatorDropAdapterAssistant extends CommonDropAdapterAssistant { private IResource[] getSelectedResources(IStructuredSelection selection) { ArrayList selectedResources = new ArrayList(); - for (Iterator i = selection.iterator(); i.hasNext();) { + for (Iterator i = selection.iterator(); i.hasNext();) { Object o = i.next(); if (o instanceof IResource) { selectedResources.add(o); diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/navigator/CNavigatorEditActionGroup.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/navigator/CNavigatorEditActionGroup.java index 97ac405ea30..922755286a7 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/navigator/CNavigatorEditActionGroup.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/navigator/CNavigatorEditActionGroup.java @@ -14,6 +14,7 @@ package org.eclipse.cdt.internal.ui.navigator; import org.eclipse.core.resources.IResource; import org.eclipse.jface.action.IMenuManager; import org.eclipse.jface.viewers.IStructuredSelection; +import org.eclipse.jface.window.SameShellProvider; import org.eclipse.swt.dnd.Clipboard; import org.eclipse.swt.widgets.Shell; import org.eclipse.ui.IActionBars; @@ -111,6 +112,7 @@ public class CNavigatorEditActionGroup extends ActionGroup { } protected void makeActions() { + final SameShellProvider shellProvider= new SameShellProvider(shell); clipboard = new Clipboard(shell.getDisplay()); pasteAction = new PasteAction(shell, clipboard); @@ -128,7 +130,7 @@ public class CNavigatorEditActionGroup extends ActionGroup { .getImageDescriptor(ISharedImages.IMG_TOOL_COPY)); copyAction.setActionDefinitionId(IWorkbenchActionDefinitionIds.COPY); - deleteAction = new DeleteResourceAction(shell); + deleteAction = new DeleteResourceAction(shellProvider); deleteAction.setDisabledImageDescriptor(images .getImageDescriptor(ISharedImages.IMG_TOOL_DELETE_DISABLED)); deleteAction.setImageDescriptor(images diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/AbstractConfigurationBlock.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/AbstractConfigurationBlock.java index 559604c5fb7..67f0fb76b55 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/AbstractConfigurationBlock.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/AbstractConfigurationBlock.java @@ -73,7 +73,7 @@ abstract class AbstractConfigurationBlock implements IPreferenceConfigurationBlo protected final class SectionManager { /** The preference setting for keeping no section open. */ private static final String __NONE= "__none"; //$NON-NLS-1$ - private Set fSections= new HashSet(); + private Set fSections= new HashSet(); private boolean fIsBeingManaged= false; private ExpansionAdapter fListener= new ExpansionAdapter() { @Override @@ -85,8 +85,7 @@ abstract class AbstractConfigurationBlock implements IPreferenceConfigurationBlo if (e.getState()) { try { fIsBeingManaged= true; - for (Iterator iter= fSections.iterator(); iter.hasNext();) { - ExpandableComposite composite= (ExpandableComposite) iter.next(); + for (ExpandableComposite composite : fSections) { if (composite != source) composite.setExpanded(false); } @@ -206,26 +205,26 @@ abstract class AbstractConfigurationBlock implements IPreferenceConfigurationBlo protected static final int INDENT= 20; private OverlayPreferenceStore fStore; - private Map fCheckBoxes= new HashMap(); + private Map fCheckBoxes= new HashMap(); private SelectionListener fCheckBoxListener= new SelectionListener() { public void widgetDefaultSelected(SelectionEvent e) { } public void widgetSelected(SelectionEvent e) { Button button= (Button) e.widget; - fStore.setValue((String) fCheckBoxes.get(button), button.getSelection()); + fStore.setValue(fCheckBoxes.get(button), button.getSelection()); } }; - private Map fTextFields= new HashMap(); + private Map fTextFields= new HashMap(); private ModifyListener fTextFieldListener= new ModifyListener() { public void modifyText(ModifyEvent e) { Text text= (Text) e.widget; - fStore.setValue((String) fTextFields.get(text), text.getText()); + fStore.setValue(fTextFields.get(text), text.getText()); } }; - private ArrayList fNumberFields= new ArrayList(); + private ArrayList fNumberFields= new ArrayList(); private ModifyListener fNumberFieldListener= new ModifyListener() { public void modifyText(ModifyEvent e) { numberFieldChanged((Text) e.widget); @@ -238,7 +237,7 @@ abstract class AbstractConfigurationBlock implements IPreferenceConfigurationBlo * @see #createDependency(Button, Control) * @since 3.0 */ - private ArrayList fMasterSlaveListeners= new ArrayList(); + private ArrayList fMasterSlaveListeners= new ArrayList(); private StatusInfo fStatus; private final PreferencePage fMainPage; @@ -359,8 +358,8 @@ abstract class AbstractConfigurationBlock implements IPreferenceConfigurationBlo SelectionListener listener= new SelectionListener() { public void widgetSelected(SelectionEvent e) { boolean state= master.getSelection(); - for (int i= 0; i < slaves.length; i++) { - slaves[i].setEnabled(state); + for (Control slave : slaves) { + slave.setEnabled(state); } } @@ -380,17 +379,17 @@ abstract class AbstractConfigurationBlock implements IPreferenceConfigurationBlo private void initializeFields() { - Iterator iter= fCheckBoxes.keySet().iterator(); + Iterator iter= fCheckBoxes.keySet().iterator(); while (iter.hasNext()) { Button b= (Button) iter.next(); - String key= (String) fCheckBoxes.get(b); + String key= fCheckBoxes.get(b); b.setSelection(fStore.getBoolean(key)); } iter= fTextFields.keySet().iterator(); while (iter.hasNext()) { Text t= (Text) iter.next(); - String key= (String) fTextFields.get(t); + String key= fTextFields.get(t); t.setText(fStore.getString(key)); } @@ -427,7 +426,7 @@ abstract class AbstractConfigurationBlock implements IPreferenceConfigurationBlo String number= textControl.getText(); IStatus status= validatePositiveNumber(number); if (!status.matches(IStatus.ERROR)) - fStore.setValue((String) fTextFields.get(textControl), number); + fStore.setValue(fTextFields.get(textControl), number); updateStatus(status); } @@ -461,12 +460,11 @@ abstract class AbstractConfigurationBlock implements IPreferenceConfigurationBlo protected Composite createSubsection(Composite parent, SectionManager manager, String label) { if (manager != null) { return manager.createSection(label); - } else { - Group group= new Group(parent, SWT.SHADOW_NONE); - group.setText(label); - GridData data= new GridData(SWT.FILL, SWT.CENTER, true, false); - group.setLayoutData(data); - return group; } + Group group= new Group(parent, SWT.SHADOW_NONE); + group.setText(label); + GridData data= new GridData(SWT.FILL, SWT.CENTER, true, false); + group.setLayoutData(data); + return group; } } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/AbstractPreferencePage.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/AbstractPreferencePage.java index f1b402f3268..ae34e13950c 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/AbstractPreferencePage.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/AbstractPreferencePage.java @@ -61,50 +61,50 @@ public abstract class AbstractPreferencePage extends PreferencePage implements I * @see #createDependency(Button, String, Control) * @since 3.0 */ - private ArrayList fMasterSlaveListeners= new ArrayList(); + private ArrayList fMasterSlaveListeners= new ArrayList(); - protected Map fTextFields = new HashMap(); + protected Map fTextFields = new HashMap(); private ModifyListener fTextFieldListener = new ModifyListener() { public void modifyText(ModifyEvent e) { Text text = (Text) e.widget; - fOverlayStore.setValue((String) fTextFields.get(text), text.getText()); + fOverlayStore.setValue(fTextFields.get(text), text.getText()); } }; - protected Map fComboBoxes = new HashMap(); + protected Map fComboBoxes = new HashMap(); private ModifyListener fComboBoxListener = new ModifyListener() { public void modifyText(ModifyEvent e) { Combo combo = (Combo) e.widget; String state = ProposalFilterPreferencesUtil.comboStateAsString(combo); - fOverlayStore.setValue((String) fComboBoxes.get(combo), state); + fOverlayStore.setValue(fComboBoxes.get(combo), state); } }; - protected Map fCheckBoxes = new HashMap(); + protected Map fCheckBoxes = new HashMap(); private SelectionListener fCheckBoxListener = new SelectionListener() { public void widgetDefaultSelected(SelectionEvent e) { } public void widgetSelected(SelectionEvent e) { Button button = (Button) e.widget; - fOverlayStore.setValue((String) fCheckBoxes.get(button), button.getSelection()); + fOverlayStore.setValue(fCheckBoxes.get(button), button.getSelection()); } }; - protected ArrayList fNumberFields = new ArrayList(); + protected ArrayList fNumberFields = new ArrayList(); private ModifyListener fNumberFieldListener = new ModifyListener() { public void modifyText(ModifyEvent e) { numberFieldChanged((Text) e.widget); } }; - protected Map fColorButtons = new HashMap(); + protected Map fColorButtons = new HashMap(); private SelectionListener fColorButtonListener = new SelectionListener() { public void widgetDefaultSelected(SelectionEvent e) { } public void widgetSelected(SelectionEvent e) { ColorSelector editor = (ColorSelector) e.widget.getData(); - PreferenceConverter.setValue(fOverlayStore, (String) fColorButtons.get(editor), editor.getColorValue()); + PreferenceConverter.setValue(fOverlayStore, fColorButtons.get(editor), editor.getColorValue()); } }; @@ -224,7 +224,7 @@ public abstract class AbstractPreferencePage extends PreferencePage implements I String number = textControl.getText(); IStatus status = validatePositiveNumber(number); if (!status.matches(IStatus.ERROR)) - fOverlayStore.setValue((String) fTextFields.get(textControl), number); + fOverlayStore.setValue(fTextFields.get(textControl), number); updateStatus(status); } @@ -247,7 +247,7 @@ public abstract class AbstractPreferencePage extends PreferencePage implements I protected void updateStatus(IStatus status) { if (!status.matches(IStatus.ERROR)) { for (int i = 0; i < fNumberFields.size(); i++) { - Text text = (Text) fNumberFields.get(i); + Text text = fNumberFields.get(i); IStatus s = validatePositiveNumber(text.getText()); status = StatusUtil.getMoreSevere(s, status); } @@ -310,10 +310,10 @@ public abstract class AbstractPreferencePage extends PreferencePage implements I protected void initializeFields() { - Iterator e = fColorButtons.keySet().iterator(); + Iterator e = fColorButtons.keySet().iterator(); while (e.hasNext()) { ColorSelector c = (ColorSelector) e.next(); - String key = (String) fColorButtons.get(c); + String key = fColorButtons.get(c); RGB rgb = PreferenceConverter.getColor(fOverlayStore, key); c.setColorValue(rgb); } @@ -321,21 +321,21 @@ public abstract class AbstractPreferencePage extends PreferencePage implements I e = fCheckBoxes.keySet().iterator(); while (e.hasNext()) { Button b = (Button) e.next(); - String key = (String) fCheckBoxes.get(b); + String key = fCheckBoxes.get(b); b.setSelection(fOverlayStore.getBoolean(key)); } e = fTextFields.keySet().iterator(); while (e.hasNext()) { Text t = (Text) e.next(); - String key = (String) fTextFields.get(t); + String key = fTextFields.get(t); t.setText(fOverlayStore.getString(key)); } e = fComboBoxes.keySet().iterator(); while (e.hasNext()) { Combo c = (Combo) e.next(); - String key = (String) fComboBoxes.get(c); + String key = fComboBoxes.get(c); String state = fOverlayStore.getString(key); // Interpret the state string as a Combo state description ProposalFilterPreferencesUtil.restoreComboFromString(c, state); diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CEditorColoringConfigurationBlock.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CEditorColoringConfigurationBlock.java index 6218c723a18..4d51d9b0a14 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CEditorColoringConfigurationBlock.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CEditorColoringConfigurationBlock.java @@ -17,7 +17,6 @@ import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.ArrayList; -import java.util.Iterator; import java.util.List; import org.eclipse.jface.dialogs.Dialog; @@ -371,26 +370,26 @@ class CEditorColoringConfigurationBlock extends AbstractConfigurationBlock { fColorManager= new CColorManager(false); - for (int i= 0, n= fSyntaxColorListModel.length; i < n; i++) + for (String[] element : fSyntaxColorListModel) fListModel.add(new HighlightingColorListItem ( - fSyntaxColorListModel[i][0], - fSyntaxColorListModel[i][1], - fSyntaxColorListModel[i][1] + BOLD, - fSyntaxColorListModel[i][1] + ITALIC, - fSyntaxColorListModel[i][1] + STRIKETHROUGH, - fSyntaxColorListModel[i][1] + UNDERLINE)); + element[0], + element[1], + element[1] + BOLD, + element[1] + ITALIC, + element[1] + STRIKETHROUGH, + element[1] + UNDERLINE)); SemanticHighlighting[] semanticHighlightings= SemanticHighlightings.getSemanticHighlightings(); - for (int i= 0, n= semanticHighlightings.length; i < n; i++) + for (SemanticHighlighting semanticHighlighting : semanticHighlightings) fListModel.add( new SemanticHighlightingColorListItem( - semanticHighlightings[i].getDisplayName(), - SemanticHighlightings.getColorPreferenceKey(semanticHighlightings[i]), - SemanticHighlightings.getBoldPreferenceKey(semanticHighlightings[i]), - SemanticHighlightings.getItalicPreferenceKey(semanticHighlightings[i]), - SemanticHighlightings.getStrikethroughPreferenceKey(semanticHighlightings[i]), - SemanticHighlightings.getUnderlinePreferenceKey(semanticHighlightings[i]), - SemanticHighlightings.getEnabledPreferenceKey(semanticHighlightings[i]) + semanticHighlighting.getDisplayName(), + SemanticHighlightings.getColorPreferenceKey(semanticHighlighting), + SemanticHighlightings.getBoldPreferenceKey(semanticHighlighting), + SemanticHighlightings.getItalicPreferenceKey(semanticHighlighting), + SemanticHighlightings.getStrikethroughPreferenceKey(semanticHighlighting), + SemanticHighlightings.getUnderlinePreferenceKey(semanticHighlighting), + SemanticHighlightings.getEnabledPreferenceKey(semanticHighlighting) )); store.addKeys(createOverlayStoreKeys()); @@ -613,8 +612,7 @@ class CEditorColoringConfigurationBlock extends AbstractConfigurationBlock { gd= new GridData(SWT.BEGINNING, SWT.BEGINNING, false, true); gd.heightHint= convertHeightInCharsToPixels(9); int maxWidth= 0; - for (Iterator it= fListModel.iterator(); it.hasNext();) { - HighlightingColorListItem item= (HighlightingColorListItem) it.next(); + for (HighlightingColorListItem item : fListModel) { maxWidth= Math.max(maxWidth, convertWidthInCharsToPixels(item.getDisplayName().length())); } ScrollBar vBar= ((Scrollable) fListViewer.getControl()).getVerticalBar(); diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CEditorHoverConfigurationBlock.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CEditorHoverConfigurationBlock.java index 9ddfdec8f60..2e8dd0ab24d 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CEditorHoverConfigurationBlock.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CEditorHoverConfigurationBlock.java @@ -59,6 +59,7 @@ import org.eclipse.cdt.ui.PreferenceConstants; import org.eclipse.cdt.internal.ui.ICHelpContextIds; import org.eclipse.cdt.internal.ui.dialogs.StatusInfo; import org.eclipse.cdt.internal.ui.dialogs.StatusUtil; +import org.eclipse.cdt.internal.ui.preferences.OverlayPreferenceStore.OverlayKey; import org.eclipse.cdt.internal.ui.text.c.hover.CEditorTextHoverDescriptor; import org.eclipse.cdt.internal.ui.util.PixelConverter; import org.eclipse.cdt.internal.ui.util.SWTUtil; @@ -171,7 +172,7 @@ public class CEditorHoverConfigurationBlock implements IPreferenceConfigurationB private OverlayPreferenceStore.OverlayKey[] createOverlayStoreKeys() { - ArrayList overlayKeys= new ArrayList(); + ArrayList overlayKeys= new ArrayList(); //overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_ANNOTATION_ROLL_OVER)); //overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_SHOW_TEXT_HOVER_AFFORDANCE)); @@ -437,7 +438,7 @@ public class CEditorHoverConfigurationBlock implements IPreferenceConfigurationB String compiledTextHoverModifiers= fStore.getString(PreferenceConstants.EDITOR_TEXT_HOVER_MODIFIERS); StringTokenizer tokenizer= new StringTokenizer(compiledTextHoverModifiers, CEditorTextHoverDescriptor.VALUE_SEPARATOR); - HashMap idToModifier= new HashMap(tokenizer.countTokens() / 2); + HashMap idToModifier= new HashMap(tokenizer.countTokens() / 2); while (tokenizer.hasMoreTokens()) { String id= tokenizer.nextToken(); @@ -448,7 +449,7 @@ public class CEditorHoverConfigurationBlock implements IPreferenceConfigurationB String compiledTextHoverModifierMasks= CUIPlugin.getDefault().getPreferenceStore().getString(PreferenceConstants.EDITOR_TEXT_HOVER_MODIFIER_MASKS); tokenizer= new StringTokenizer(compiledTextHoverModifierMasks, CEditorTextHoverDescriptor.VALUE_SEPARATOR); - HashMap idToModifierMask= new HashMap(tokenizer.countTokens() / 2); + HashMap idToModifierMask= new HashMap(tokenizer.countTokens() / 2); while (tokenizer.hasMoreTokens()) { String id= tokenizer.nextToken(); @@ -457,7 +458,7 @@ public class CEditorHoverConfigurationBlock implements IPreferenceConfigurationB } for (int i= 0; i < fHoverConfigs.length; i++) { - String modifierString= (String)idToModifier.get(getContributedHovers()[i].getId()); + String modifierString= idToModifier.get(getContributedHovers()[i].getId()); boolean enabled= true; if (modifierString == null) modifierString= CEditorTextHoverDescriptor.DISABLED_TAG; @@ -476,7 +477,7 @@ public class CEditorHoverConfigurationBlock implements IPreferenceConfigurationB if (fHoverConfigs[i].fStateMask == -1) { try { - fHoverConfigs[i].fStateMask= Integer.parseInt((String)idToModifierMask.get(getContributedHovers()[i].getId())); + fHoverConfigs[i].fStateMask= Integer.parseInt(idToModifierMask.get(getContributedHovers()[i].getId())); } catch (NumberFormatException ex) { fHoverConfigs[i].fStateMask= -1; } @@ -531,7 +532,7 @@ public class CEditorHoverConfigurationBlock implements IPreferenceConfigurationB fStatus= new StatusInfo(); int i= 0; - HashMap stateMasks= new HashMap(fHoverConfigs.length); + HashMap stateMasks= new HashMap(fHoverConfigs.length); while (fStatus.isOK() && i < fHoverConfigs.length) { if (fHoverConfigs[i].fIsEnabled) { String label= getContributedHovers()[i].getLabel(); @@ -539,7 +540,7 @@ public class CEditorHoverConfigurationBlock implements IPreferenceConfigurationB if (fHoverConfigs[i].fStateMask == -1) fStatus= new StatusInfo(IStatus.ERROR, NLS.bind(PreferencesMessages.CEditorHoverConfigurationBlock_modifierIsNotValidForHover, new String[] {fHoverConfigs[i].fModifierString, label})); else if (stateMasks.containsKey(stateMask)) - fStatus= new StatusInfo(IStatus.ERROR, NLS.bind(PreferencesMessages.CEditorHoverConfigurationBlock_duplicateModifier, new String[] {label, (String)stateMasks.get(stateMask)})); + fStatus= new StatusInfo(IStatus.ERROR, NLS.bind(PreferencesMessages.CEditorHoverConfigurationBlock_duplicateModifier, new String[] {label, stateMasks.get(stateMask)})); else stateMasks.put(stateMask, label); } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CEditorPreferencePage.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CEditorPreferencePage.java index 28e9e3828af..a2b4759ba7c 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CEditorPreferencePage.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CEditorPreferencePage.java @@ -34,7 +34,6 @@ import org.eclipse.swt.widgets.Label; import org.eclipse.swt.widgets.Link; import org.eclipse.swt.widgets.List; import org.eclipse.swt.widgets.Listener; -import org.eclipse.ui.IWorkbenchPreferencePage; import org.eclipse.ui.PlatformUI; import org.eclipse.ui.dialogs.PreferencesUtil; @@ -52,7 +51,7 @@ import org.eclipse.cdt.internal.ui.text.doctools.DocCommentOwnerManager; /* * The page for setting the editor options. */ -public class CEditorPreferencePage extends AbstractPreferencePage implements IWorkbenchPreferencePage { +public class CEditorPreferencePage extends AbstractPreferencePage { protected final String[][] fAppearanceColorListModel = new String[][] { {PreferencesMessages.CEditorPreferencePage_behaviorPage_matchingBracketColor, CEditor.MATCHING_BRACKETS_COLOR, null }, @@ -120,8 +119,8 @@ public class CEditorPreferencePage extends AbstractPreferencePage implements IWo if (control instanceof Composite) { Composite composite = (Composite) control; Control[] children = composite.getChildren(); - for (int i = 0; i < children.length; i++) - setEnabled(children[i], enable); + for (Control element : children) + setEnabled(element, enable); } } @@ -302,8 +301,8 @@ public class CEditorPreferencePage extends AbstractPreferencePage implements IWo initializeFields(); initializeDefaultColors(); - for (int i = 0; i < fAppearanceColorListModel.length; i++) { - fAppearanceColorList.add(fAppearanceColorListModel[i][0]); + for (String[] element : fAppearanceColorListModel) { + fAppearanceColorList.add(element[0]); } fAppearanceColorList.getDisplay().asyncExec(new Runnable() { public void run() { diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CFileTypeDialog.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CFileTypeDialog.java index eb97e629af9..a06220df72d 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CFileTypeDialog.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CFileTypeDialog.java @@ -12,7 +12,6 @@ package org.eclipse.cdt.internal.ui.preferences; import java.util.ArrayList; -import org.eclipse.cdt.core.model.CoreModel; import org.eclipse.core.runtime.Platform; import org.eclipse.core.runtime.content.IContentType; import org.eclipse.core.runtime.content.IContentTypeManager; @@ -31,6 +30,8 @@ import org.eclipse.swt.widgets.Label; import org.eclipse.swt.widgets.Shell; import org.eclipse.swt.widgets.Text; +import org.eclipse.cdt.core.model.CoreModel; + public class CFileTypeDialog extends Dialog { public CFileTypeDialog(Shell parentShell) { @@ -112,9 +113,9 @@ public class CFileTypeDialog extends Dialog { private void populateTypesCombo() { IContentTypeManager manager = Platform.getContentTypeManager(); String[] ids = CoreModel.getRegistedContentTypeIds(); - ArrayList list = new ArrayList(ids.length); - for (int i = 0; i < ids.length; i++) { - IContentType ctype = manager.getContentType(ids[i]); + ArrayList list = new ArrayList(ids.length); + for (String id : ids) { + IContentType ctype = manager.getContentType(id); if (ctype != null) { list.add(ctype); } @@ -124,8 +125,8 @@ public class CFileTypeDialog extends Dialog { list.toArray(ctypes); int index = -1; - for (int i = 0; i < ctypes.length; i++) { - fComboType.add(ctypes[i].getName()); + for (IContentType ctype : ctypes) { + fComboType.add(ctype.getName()); } fComboType.setData(ctypes); @@ -152,9 +153,9 @@ public class CFileTypeDialog extends Dialog { if (-1 != index) { String name = fComboType.getItem(index); IContentType[] types = (IContentType[]) fComboType.getData(); - for (int i = 0; i < types.length; i++) { - if (name.equals(types[i].getName())) { - type = types[i]; + for (IContentType type2 : types) { + if (name.equals(type2.getName())) { + type = type2; } } } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CFileTypesPreferenceBlock.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CFileTypesPreferenceBlock.java index 9a30848ad4b..b5c6131e17d 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CFileTypesPreferenceBlock.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CFileTypesPreferenceBlock.java @@ -67,8 +67,8 @@ public class CFileTypesPreferenceBlock { private static final int COL_DESCRIPTION = 1; private static final int COL_STATUS = 2; - private ArrayList fAddAssoc; - private ArrayList fRemoveAssoc; + private ArrayList fAddAssoc; + private ArrayList fRemoveAssoc; private boolean fDirty = false; private IProject fInput; private IContentType[] fContentTypes; @@ -175,8 +175,8 @@ public class CFileTypesPreferenceBlock { } public CFileTypesPreferenceBlock(IProject input) { - fAddAssoc = new ArrayList(); - fRemoveAssoc = new ArrayList(); + fAddAssoc = new ArrayList(); + fRemoveAssoc = new ArrayList(); fInput = input; setDirty(false); } @@ -318,8 +318,8 @@ public class CFileTypesPreferenceBlock { boolean changed = fDirty; if (fDirty) { - CFileTypeAssociation[] add = (CFileTypeAssociation[]) fAddAssoc.toArray(new CFileTypeAssociation[fAddAssoc.size()]); - CFileTypeAssociation[] rem = (CFileTypeAssociation[]) fRemoveAssoc.toArray(new CFileTypeAssociation[fRemoveAssoc.size()]); + CFileTypeAssociation[] add = fAddAssoc.toArray(new CFileTypeAssociation[fAddAssoc.size()]); + CFileTypeAssociation[] rem = fRemoveAssoc.toArray(new CFileTypeAssociation[fRemoveAssoc.size()]); changed = add.length > 0 || rem.length > 0; adjustAssociations(add, rem); @@ -333,7 +333,7 @@ public class CFileTypesPreferenceBlock { } private CFileTypeAssociation[] getCFileTypeAssociations() { - ArrayList list = new ArrayList(); + ArrayList list = new ArrayList(); if (fInput == null) { fillWithUserDefinedCFileTypeAssociations(list); fillWithPredefinedCFileTypeAssociations(list); @@ -411,33 +411,32 @@ public class CFileTypesPreferenceBlock { return fContentTypes; } - private void fillWithUserDefinedCFileTypeAssociations(ArrayList list) { + private void fillWithUserDefinedCFileTypeAssociations(ArrayList list) { IContentType[] ctypes = getRegistedContentTypes(); fillWithCFileTypeAssociations(ctypes, null, IContentType.IGNORE_PRE_DEFINED | IContentType.FILE_EXTENSION_SPEC, list); fillWithCFileTypeAssociations(ctypes, null, IContentType.IGNORE_PRE_DEFINED | IContentType.FILE_NAME_SPEC, list); } - private void fillWithPredefinedCFileTypeAssociations(ArrayList list) { + private void fillWithPredefinedCFileTypeAssociations(ArrayList list) { IContentType[] ctypes = getRegistedContentTypes(); fillWithCFileTypeAssociations(ctypes, null, IContentType.IGNORE_USER_DEFINED | IContentType.FILE_EXTENSION_SPEC, list); fillWithCFileTypeAssociations(ctypes, null, IContentType.IGNORE_USER_DEFINED | IContentType.FILE_NAME_SPEC, list); } - private void fillWithProjectCFileTypeAssociations(ArrayList list, IProject project) { + private void fillWithProjectCFileTypeAssociations(ArrayList list, IProject project) { IContentType[] ctypes = getRegistedContentTypes(); IScopeContext context = new ProjectScope(project); fillWithCFileTypeAssociations(ctypes, context, IContentType.IGNORE_PRE_DEFINED | IContentType.FILE_EXTENSION_SPEC, list); fillWithCFileTypeAssociations(ctypes, context, IContentType.IGNORE_PRE_DEFINED | IContentType.FILE_NAME_SPEC, list); } - private void fillWithCFileTypeAssociations(IContentType[] ctypes, IScopeContext context, int type, ArrayList list) { - for (int i = 0; i < ctypes.length; i++) { + private void fillWithCFileTypeAssociations(IContentType[] ctypes, IScopeContext context, int type, ArrayList list) { + for (IContentType ctype : ctypes) { try { - IContentType ctype = ctypes[i]; IContentTypeSettings setting = ctype.getSettings(context); String[] specs = setting.getFileSpecs(type); - for (int j = 0; j < specs.length; j++) { - CFileTypeAssociation assoc = new CFileTypeAssociation(specs[j], type, ctype); + for (String spec : specs) { + CFileTypeAssociation assoc = new CFileTypeAssociation(spec, type, ctype); list.add(assoc); } } catch (CoreException e) { @@ -461,9 +460,9 @@ public class CFileTypesPreferenceBlock { fBtnRemove.setEnabled(false); } else { boolean enabled = true; - List elements = sel.toList(); - for (Iterator i = elements.iterator(); i.hasNext();) { - CFileTypeAssociation assoc = (CFileTypeAssociation) i.next(); + List elements = sel.toList(); + for (Object element : elements) { + CFileTypeAssociation assoc = (CFileTypeAssociation) element; if (assoc.isPredefined()) enabled = false; } @@ -516,8 +515,7 @@ public class CFileTypesPreferenceBlock { } String newSpec= assoc.getSpec(); String[] specs= settings.getFileSpecs(assoc.getFileSpecType()); - for (int i = 0; i < specs.length; i++) { - String spec = specs[i]; + for (String spec : specs) { if (spec.equalsIgnoreCase(newSpec)) { reportDuplicateAssociation(assoc); return false; @@ -527,9 +525,8 @@ public class CFileTypesPreferenceBlock { return true; } - private boolean containsIgnoreCaseOfSpec(Collection collection, CFileTypeAssociation assoc) { - for (Iterator iter = collection.iterator(); iter.hasNext(); ) { - CFileTypeAssociation existing = (CFileTypeAssociation) iter.next(); + private boolean containsIgnoreCaseOfSpec(Collection collection, CFileTypeAssociation assoc) { + for (CFileTypeAssociation existing : collection) { if (assoc.equalsIgnoreCaseOfSpec(existing)) { return true; } @@ -547,7 +544,7 @@ public class CFileTypesPreferenceBlock { final protected void handleRemove() { IStructuredSelection sel = getSelection(); if ((null != sel) && (!sel.isEmpty())) { - for (Iterator iter = sel.iterator(); iter.hasNext();) { + for (Iterator iter = sel.iterator(); iter.hasNext();) { CFileTypeAssociation assoc = (CFileTypeAssociation) iter.next(); handleRemove(assoc); fAssocViewer.remove(assoc); diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CFileTypesPropertyPage.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CFileTypesPropertyPage.java index a08407397f5..b0a048f3c6f 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CFileTypesPropertyPage.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CFileTypesPropertyPage.java @@ -22,6 +22,7 @@ import org.eclipse.core.runtime.Platform; import org.eclipse.core.runtime.content.IContentType; import org.eclipse.core.runtime.content.IContentTypeManager; import org.eclipse.core.runtime.content.IContentTypeSettings; +import org.eclipse.core.runtime.content.IContentTypeManager.ContentTypeChangeEvent; import org.eclipse.core.runtime.preferences.IScopeContext; import org.eclipse.swt.SWT; import org.eclipse.swt.layout.GridData; @@ -48,7 +49,7 @@ import org.eclipse.cdt.internal.ui.ICHelpContextIds; public class CFileTypesPropertyPage extends PropertyPage { class FixCFileTypesPreferenceBlock extends CFileTypesPreferenceBlock { - ArrayList list = new ArrayList(); + ArrayList list = new ArrayList(); public FixCFileTypesPreferenceBlock() { super(); @@ -229,9 +230,8 @@ public class CFileTypesPropertyPage extends PropertyPage { void computeEvents(IProject project) { IScopeContext projectScope = new ProjectScope(project); IContentType[] ctypes = getRegistedContentTypes(); - ArrayList list = new ArrayList(ctypes.length); - for (int i = 0; i < ctypes.length; i++) { - IContentType ctype = ctypes[i]; + ArrayList list = new ArrayList(ctypes.length); + for (IContentType ctype : ctypes) { try { IContentTypeSettings projectSettings = ctype.getSettings(projectScope); String[] projectSpecs = projectSettings.getFileSpecs(IContentType.FILE_EXTENSION_SPEC); @@ -252,7 +252,7 @@ public class CFileTypesPropertyPage extends PropertyPage { if (list.size() > 0) { IContentTypeManager.ContentTypeChangeEvent[] events = new IContentTypeManager.ContentTypeChangeEvent[list.size()]; for (int i = 0; i < list.size(); ++i) { - IContentType source = (IContentType)list.get(i); + IContentType source = list.get(i); events[i] = new IContentTypeManager.ContentTypeChangeEvent(source, projectScope); } CModelManager.getDefault().contentTypeChanged(events); diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CParserPreferencePage.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CParserPreferencePage.java index 4ab99c75b67..dd677b2c1f7 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CParserPreferencePage.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CParserPreferencePage.java @@ -13,11 +13,6 @@ package org.eclipse.cdt.internal.ui.preferences; import java.util.ArrayList; -import org.eclipse.cdt.core.CCorePlugin; -import org.eclipse.cdt.core.dom.CDOM; -import org.eclipse.cdt.core.parser.CodeReaderCache; -import org.eclipse.cdt.core.parser.ICodeReaderCache; -import org.eclipse.cdt.ui.CUIPlugin; import org.eclipse.core.runtime.Preferences; import org.eclipse.jface.dialogs.IDialogConstants; import org.eclipse.jface.preference.IPreferenceStore; @@ -33,6 +28,14 @@ import org.eclipse.swt.widgets.Text; import org.eclipse.ui.IWorkbench; import org.eclipse.ui.IWorkbenchPreferencePage; +import org.eclipse.cdt.core.CCorePlugin; +import org.eclipse.cdt.core.dom.CDOM; +import org.eclipse.cdt.core.parser.CodeReaderCache; +import org.eclipse.cdt.core.parser.ICodeReaderCache; +import org.eclipse.cdt.ui.CUIPlugin; + +import org.eclipse.cdt.internal.ui.preferences.OverlayPreferenceStore.OverlayKey; + /** * @author dsteffle * @deprecated the one preference found on the page was moved to the @@ -51,7 +54,7 @@ public class CParserPreferencePage extends PreferencePage implements } private OverlayPreferenceStore createOverlayStore() { - ArrayList overlayKeys = new ArrayList(); + ArrayList overlayKeys = new ArrayList(); overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, CodeReaderCache.CODE_READER_BUFFER)); OverlayPreferenceStore.OverlayKey[] keys = new OverlayPreferenceStore.OverlayKey[overlayKeys.size()]; diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CodeAssistAdvancedConfigurationBlock.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CodeAssistAdvancedConfigurationBlock.java index 90efbd6baf1..ba16999c206 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CodeAssistAdvancedConfigurationBlock.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CodeAssistAdvancedConfigurationBlock.java @@ -24,9 +24,19 @@ import org.eclipse.core.commands.IParameter; import org.eclipse.core.commands.Parameterization; import org.eclipse.core.commands.ParameterizedCommand; import org.eclipse.core.commands.common.NotDefinedException; - import org.eclipse.core.runtime.Assert; - +import org.eclipse.jface.bindings.Binding; +import org.eclipse.jface.bindings.TriggerSequence; +import org.eclipse.jface.resource.ImageDescriptor; +import org.eclipse.jface.resource.JFaceResources; +import org.eclipse.jface.viewers.ArrayContentProvider; +import org.eclipse.jface.viewers.CheckStateChangedEvent; +import org.eclipse.jface.viewers.CheckboxTableViewer; +import org.eclipse.jface.viewers.ICheckStateListener; +import org.eclipse.jface.viewers.IStructuredSelection; +import org.eclipse.jface.viewers.ITableLabelProvider; +import org.eclipse.jface.viewers.LabelProvider; +import org.eclipse.jface.viewers.ViewerComparator; import org.eclipse.swt.SWT; import org.eclipse.swt.events.SelectionAdapter; import org.eclipse.swt.events.SelectionEvent; @@ -41,20 +51,6 @@ import org.eclipse.swt.widgets.Label; import org.eclipse.swt.widgets.Link; import org.eclipse.swt.widgets.Table; import org.eclipse.swt.widgets.TableColumn; - -import org.eclipse.jface.bindings.Binding; -import org.eclipse.jface.bindings.TriggerSequence; -import org.eclipse.jface.resource.ImageDescriptor; -import org.eclipse.jface.resource.JFaceResources; -import org.eclipse.jface.viewers.ArrayContentProvider; -import org.eclipse.jface.viewers.CheckStateChangedEvent; -import org.eclipse.jface.viewers.CheckboxTableViewer; -import org.eclipse.jface.viewers.ICheckStateListener; -import org.eclipse.jface.viewers.IStructuredSelection; -import org.eclipse.jface.viewers.ITableLabelProvider; -import org.eclipse.jface.viewers.LabelProvider; -import org.eclipse.jface.viewers.ViewerComparator; - import org.eclipse.ui.PlatformUI; import org.eclipse.ui.commands.ICommandService; import org.eclipse.ui.dialogs.PreferencesUtil; @@ -148,13 +144,9 @@ final class CodeAssistAdvancedConfigurationBlock extends OptionsConfigurationBlo } } - private final Comparator fCategoryComparator= new Comparator() { - private int getRank(Object o) { - return ((ModelElement) o).getRank(); - } - - public int compare(Object o1, Object o2) { - return getRank(o1) - getRank(o2); + private final Comparator fCategoryComparator= new Comparator() { + public int compare(ModelElement o1, ModelElement o2) { + return o1.getRank() - o2.getRank(); } }; @@ -163,17 +155,16 @@ final class CodeAssistAdvancedConfigurationBlock extends OptionsConfigurationBlo private static final String COLON= ":"; //$NON-NLS-1$ private static final String SEPARATOR= "\0"; //$NON-NLS-1$ - private final List fElements; + private final List fElements; /** * The read-only list of elements. */ - final List elements; + final List elements; public PreferenceModel(CompletionProposalComputerRegistry registry) { - List categories= registry.getProposalCategories(); - fElements= new ArrayList(); - for (Iterator it= categories.iterator(); it.hasNext();) { - CompletionProposalCategory category= (CompletionProposalCategory) it.next(); + List categories= registry.getProposalCategories(); + fElements= new ArrayList(); + for (CompletionProposalCategory category : categories) { if (category.hasComputers()) { fElements.add(new ModelElement(category, this)); } @@ -185,7 +176,7 @@ final class CodeAssistAdvancedConfigurationBlock extends OptionsConfigurationBlo public void moveUp(ModelElement category) { int index= fElements.indexOf(category); if (index > 0) { - Object item= fElements.remove(index); + ModelElement item= fElements.remove(index); fElements.add(index - 1, item); writeOrderPreference(null, false); } @@ -194,7 +185,7 @@ final class CodeAssistAdvancedConfigurationBlock extends OptionsConfigurationBlo public void moveDown(ModelElement category) { int index= fElements.indexOf(category); if (index < fElements.size() - 1) { - Object item= fElements.remove(index); + ModelElement item= fElements.remove(index); fElements.add(index + 1, item); writeOrderPreference(null, false); } @@ -202,8 +193,8 @@ final class CodeAssistAdvancedConfigurationBlock extends OptionsConfigurationBlo private void writeInclusionPreference(ModelElement changed, boolean isInDefaultCategory) { StringBuffer buf= new StringBuffer(); - for (Iterator it= fElements.iterator(); it.hasNext();) { - ModelElement item= (ModelElement) it.next(); + for (Object element : fElements) { + ModelElement item= (ModelElement) element; boolean included= changed == item ? isInDefaultCategory : item.isInDefaultCategory(); if (!included) buf.append(item.getId() + SEPARATOR); @@ -217,8 +208,8 @@ final class CodeAssistAdvancedConfigurationBlock extends OptionsConfigurationBlo private void writeOrderPreference(ModelElement changed, boolean isSeparate) { StringBuffer buf= new StringBuffer(); int i= 0; - for (Iterator it= fElements.iterator(); it.hasNext(); i++) { - ModelElement item= (ModelElement) it.next(); + for (Iterator it= fElements.iterator(); it.hasNext(); i++) { + ModelElement item= it.next(); boolean separate= changed == item ? isSeparate : item.isSeparateCommand(); int rank= separate ? i : i + LIMIT; buf.append(item.getId() + COLON + rank + SEPARATOR); @@ -232,8 +223,8 @@ final class CodeAssistAdvancedConfigurationBlock extends OptionsConfigurationBlo private boolean readInclusionPreference(CompletionProposalCategory cat) { String[] ids= getTokens(getValue(PREF_EXCLUDED_CATEGORIES), SEPARATOR); - for (int i= 0; i < ids.length; i++) { - if (ids[i].equals(cat.getId())) + for (String id : ids) { + if (id.equals(cat.getId())) return false; } return true; @@ -241,8 +232,8 @@ final class CodeAssistAdvancedConfigurationBlock extends OptionsConfigurationBlo private int readOrderPreference(CompletionProposalCategory cat) { String[] sortOrderIds= getTokens(getValue(PREF_CATEGORY_ORDER), SEPARATOR); - for (int i= 0; i < sortOrderIds.length; i++) { - String[] idAndRank= getTokens(sortOrderIds[i], COLON); + for (String sortOrderId : sortOrderIds) { + String[] idAndRank= getTokens(sortOrderId, COLON); if (idAndRank[0].equals(cat.getId())) return Integer.parseInt(idAndRank[1]); } @@ -330,7 +321,7 @@ final class CodeAssistAdvancedConfigurationBlock extends OptionsConfigurationBlo /** element type: {@link ModelElement}. */ private final PreferenceModel fModel; - private final Map fImages= new HashMap(); + private final Map fImages= new HashMap(); private CheckboxTableViewer fDefaultViewer; private CheckboxTableViewer fSeparateViewer; @@ -550,7 +541,7 @@ final class CodeAssistAdvancedConfigurationBlock extends OptionsConfigurationBlo public void widgetSelected(SelectionEvent e) { int index= getSelectionIndex(); if (index != -1) { - ((ModelElement) fModel.elements.get(index)).moveUp(); + (fModel.elements.get(index)).moveUp(); fSeparateViewer.refresh(); handleTableSelection(); } @@ -566,7 +557,7 @@ final class CodeAssistAdvancedConfigurationBlock extends OptionsConfigurationBlo public void widgetSelected(SelectionEvent e) { int index= getSelectionIndex(); if (index != -1) { - ((ModelElement) fModel.elements.get(index)).moveDown(); + (fModel.elements.get(index)).moveDown(); fSeparateViewer.refresh(); handleTableSelection(); } @@ -612,11 +603,11 @@ final class CodeAssistAdvancedConfigurationBlock extends OptionsConfigurationBlo private void updateCheckedState() { final int size= fModel.elements.size(); - List defaultChecked= new ArrayList(size); - List separateChecked= new ArrayList(size); + List defaultChecked= new ArrayList(size); + List separateChecked= new ArrayList(size); - for (Iterator it= fModel.elements.iterator(); it.hasNext();) { - ModelElement element= (ModelElement) it.next(); + for (Object element2 : fModel.elements) { + ModelElement element= (ModelElement) element2; if (element.isInDefaultCategory()) defaultChecked.add(element); if (element.isSeparateCommand()) @@ -632,8 +623,8 @@ final class CodeAssistAdvancedConfigurationBlock extends OptionsConfigurationBlo */ @Override protected boolean processChanges(IWorkbenchPreferenceContainer container) { - for (Iterator it= fModel.elements.iterator(); it.hasNext();) { - ModelElement item= (ModelElement) it.next(); + for (Object element : fModel.elements) { + ModelElement item= (ModelElement) element; item.update(); } @@ -660,8 +651,7 @@ final class CodeAssistAdvancedConfigurationBlock extends OptionsConfigurationBlo */ @Override public void dispose() { - for (Iterator it= fImages.values().iterator(); it.hasNext();) { - Image image= (Image) it.next(); + for (Image image : fImages.values()) { image.dispose(); } @@ -683,8 +673,7 @@ final class CodeAssistAdvancedConfigurationBlock extends OptionsConfigurationBlo private static String getKeyboardShortcut(ParameterizedCommand command) { final IBindingService bindingSvc= (IBindingService) PlatformUI.getWorkbench().getAdapter(IBindingService.class); final Binding[] bindings= bindingSvc.getBindings(); - for (int i= 0; i < bindings.length; i++) { - Binding binding= bindings[i]; + for (Binding binding : bindings) { if (command.equals(binding.getParameterizedCommand())) { TriggerSequence triggers= bindingSvc.getBestActiveBindingFor(command.getId()); return triggers.format(); @@ -697,7 +686,7 @@ final class CodeAssistAdvancedConfigurationBlock extends OptionsConfigurationBlo if (imgDesc == null) return null; - Image img= (Image) fImages.get(imgDesc); + Image img= fImages.get(imgDesc); if (img == null) { img= imgDesc.createImage(false); fImages.put(imgDesc, img); diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CodeAssistPreferencePage.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CodeAssistPreferencePage.java index a740a57a36f..034a186af9b 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CodeAssistPreferencePage.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CodeAssistPreferencePage.java @@ -25,6 +25,7 @@ import org.eclipse.ui.IWorkbench; import org.eclipse.ui.PlatformUI; import org.eclipse.cdt.internal.ui.ICHelpContextIds; +import org.eclipse.cdt.internal.ui.preferences.OverlayPreferenceStore.OverlayKey; import org.eclipse.cdt.internal.ui.text.contentassist.ContentAssistPreference; /** @@ -42,7 +43,7 @@ public class CodeAssistPreferencePage extends AbstractPreferencePage { @Override protected OverlayPreferenceStore.OverlayKey[] createOverlayStoreKeys() { - ArrayList overlayKeys = new ArrayList(); + ArrayList overlayKeys = new ArrayList(); overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.INT, ContentAssistPreference.AUTOACTIVATION_DELAY)); overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, ContentAssistPreference.AUTOINSERT)); diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CodeTemplateBlock.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CodeTemplateBlock.java index f99e53e8ab6..f207c565d27 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CodeTemplateBlock.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CodeTemplateBlock.java @@ -90,7 +90,7 @@ public class CodeTemplateBlock extends OptionsConfigurationBlock { } public void selectionChanged(TreeListDialogField field) { - List selected= field.getSelectedElements(); + List selected= field.getSelectedElements(); field.enableButton(IDX_ADD, canAdd(selected)); field.enableButton(IDX_EDIT, canEdit(selected)); field.enableButton(IDX_REMOVE, canRemove(selected)); @@ -100,7 +100,7 @@ public class CodeTemplateBlock extends OptionsConfigurationBlock { } public void doubleClicked(TreeListDialogField field) { - List selected= field.getSelectedElements(); + List selected= field.getSelectedElements(); if (canEdit(selected)) { doButtonPressed(IDX_EDIT, selected); } @@ -451,8 +451,7 @@ public class CodeTemplateBlock extends OptionsConfigurationBlock { protected TemplatePersistenceData[] getCodeTemplatesOfCategory(boolean isComment) { ArrayList res= new ArrayList(); TemplatePersistenceData[] templates= fTemplateStore.getTemplateData(); - for (int i= 0; i < templates.length; i++) { - TemplatePersistenceData curr= templates[i]; + for (TemplatePersistenceData curr : templates) { boolean isUserAdded= curr.getId() == null; boolean isFileTemplate= FileTemplateContextType.isFileTemplateContextType(curr.getTemplate().getContextTypeId()); if (!isUserAdded && !isFileTemplate && isComment == curr.getTemplate().getName().endsWith(CodeTemplateContextType.COMMENT_SUFFIX)) { @@ -469,8 +468,7 @@ public class CodeTemplateBlock extends OptionsConfigurationBlock { protected TemplatePersistenceData[] getTemplatesOfContextType(String contextTypeId) { ArrayList res= new ArrayList(); TemplatePersistenceData[] templates= fTemplateStore.getTemplateData(); - for (int i= 0; i < templates.length; i++) { - TemplatePersistenceData curr= templates[i]; + for (TemplatePersistenceData curr : templates) { if (contextTypeId.equals(curr.getTemplate().getContextTypeId())) { res.add(curr); } @@ -481,7 +479,7 @@ public class CodeTemplateBlock extends OptionsConfigurationBlock { protected ContextTypeRegistry getFileTemplateContextRegistry() { if (fFileTemplateContextTypes == null) { fFileTemplateContextTypes= new ContextTypeRegistry(); - Iterator contextTypesIter= CUIPlugin.getDefault().getCodeTemplateContextRegistry().contextTypes(); + Iterator contextTypesIter= CUIPlugin.getDefault().getCodeTemplateContextRegistry().contextTypes(); while(contextTypesIter.hasNext()) { TemplateContextType contextType= (TemplateContextType)contextTypesIter.next(); final String contextTypeId= contextType.getId(); @@ -495,7 +493,7 @@ public class CodeTemplateBlock extends OptionsConfigurationBlock { } protected TemplateContextType[] getFileTemplateContextTypes() { - Iterator iter= getFileTemplateContextRegistry().contextTypes(); + Iterator iter= getFileTemplateContextRegistry().contextTypes(); ArrayList result= new ArrayList(); while (iter.hasNext()) { TemplateContextType contextType= (TemplateContextType)iter.next(); @@ -506,7 +504,7 @@ public class CodeTemplateBlock extends OptionsConfigurationBlock { return result.toArray(new TemplateContextType[0]); } - protected static boolean canAdd(List selected) { + protected static boolean canAdd(List selected) { if (selected.size() == 1) { Object element= selected.get(0); if (element instanceof TemplateContextType || element == FILE_NODE) { @@ -522,11 +520,11 @@ public class CodeTemplateBlock extends OptionsConfigurationBlock { return false; } - protected static boolean canEdit(List selected) { + protected static boolean canEdit(List selected) { return selected.size() == 1 && (selected.get(0) instanceof TemplatePersistenceData); } - protected static boolean canRemove(List selected) { + protected static boolean canRemove(List selected) { if (selected.size() == 1 && (selected.get(0) instanceof TemplatePersistenceData)) { TemplatePersistenceData data= (TemplatePersistenceData)selected.get(0); return data.isUserAdded(); @@ -534,7 +532,7 @@ public class CodeTemplateBlock extends OptionsConfigurationBlock { return false; } - protected void updateSourceViewerInput(List selection) { + protected void updateSourceViewerInput(List selection) { if (fPatternViewer == null || fPatternViewer.getTextWidget().isDisposed()) { return; } @@ -550,7 +548,7 @@ public class CodeTemplateBlock extends OptionsConfigurationBlock { } } - protected void doButtonPressed(int buttonIndex, List selected) { + protected void doButtonPressed(int buttonIndex, List selected) { switch (buttonIndex) { case IDX_EDIT: edit((TemplatePersistenceData) selected.get(0), false); @@ -643,8 +641,8 @@ public class CodeTemplateBlock extends OptionsConfigurationBlock { InputStream input= new BufferedInputStream(new FileInputStream(file)); try { TemplatePersistenceData[] datas= reader.read(input, null); - for (int i= 0; i < datas.length; i++) { - updateTemplate(datas[i]); + for (TemplatePersistenceData data : datas) { + updateTemplate(data); } } finally { try { @@ -670,22 +668,22 @@ public class CodeTemplateBlock extends OptionsConfigurationBlock { TemplatePersistenceData[] datas= fTemplateStore.getTemplateData(); if (dataId != null) { // predefined - for (int i= 0; i < datas.length; i++) { - String id= datas[i].getId(); + for (TemplatePersistenceData data2 : datas) { + String id= data2.getId(); if (id != null && id.equals(dataId)) { - datas[i].setTemplate(data.getTemplate()); + data2.setTemplate(data.getTemplate()); return; } } } else { // user added String dataName= data.getTemplate().getName(); - for (int i= 0; i < datas.length; i++) { - if (datas[i].getId() == null) { - String name= datas[i].getTemplate().getName(); - String contextTypeId= datas[i].getTemplate().getContextTypeId(); + for (TemplatePersistenceData data2 : datas) { + if (data2.getId() == null) { + String name= data2.getTemplate().getName(); + String contextTypeId= data2.getTemplate().getContextTypeId(); if (name != null && name.equals(dataName) && contextTypeId.equals(data.getTemplate().getContextTypeId())) { - datas[i].setTemplate(data.getTemplate()); + data2.setTemplate(data.getTemplate()); return; } } @@ -699,7 +697,7 @@ public class CodeTemplateBlock extends OptionsConfigurationBlock { export(fTemplateStore.getTemplateData()); } - private void export(List selected) { + private void export(List selected) { Set datas= new HashSet(); for (int i= 0; i < selected.size(); i++) { Object curr= selected.get(i); @@ -710,8 +708,7 @@ public class CodeTemplateBlock extends OptionsConfigurationBlock { datas.addAll(Arrays.asList(cat)); } else if (curr == FILE_NODE) { TemplateContextType[] types= getFileTemplateContextTypes(); - for (int j = 0; j < types.length; j++) { - TemplateContextType contextType = types[j]; + for (TemplateContextType contextType : types) { TemplatePersistenceData[] cat= getTemplatesOfContextType(contextType); datas.addAll(Arrays.asList(cat)); } @@ -793,8 +790,8 @@ public class CodeTemplateBlock extends OptionsConfigurationBlock { if (fProject != null) { TemplatePersistenceData[] templateData= fTemplateStore.getTemplateData(); - for (int i= 0; i < templateData.length; i++) { - fTemplateStore.setProjectSpecific(templateData[i].getId(), enabled); + for (TemplatePersistenceData element : templateData) { + fTemplateStore.setProjectSpecific(element.getId(), enabled); } } try { diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CodeTemplatePreferencePage.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CodeTemplatePreferencePage.java index ef246f46ab2..7bd72552340 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CodeTemplatePreferencePage.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CodeTemplatePreferencePage.java @@ -160,12 +160,10 @@ public class CodeTemplatePreferencePage extends PropertyAndPreferencePage { @Override public void applyData(Object data) { if (data instanceof Map) { - Object id= ((Map) data).get(DATA_SELECT_TEMPLATE); + Object id= ((Map) data).get(DATA_SELECT_TEMPLATE); if (id instanceof String) { final TemplatePersistenceData[] templates= fCodeTemplateConfigurationBlock.fTemplateStore.getTemplateData(); - TemplatePersistenceData template= null; - for (int index= 0; index < templates.length; index++) { - template= templates[index]; + for (TemplatePersistenceData template : templates) { if (id.equals(template.getId()) || id.equals(template.getTemplate().getName())) { fCodeTemplateConfigurationBlock.postSetSelection(template); break; diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CodeTemplateSourceViewerConfiguration.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CodeTemplateSourceViewerConfiguration.java index 7a561006725..13c96338284 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CodeTemplateSourceViewerConfiguration.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/CodeTemplateSourceViewerConfiguration.java @@ -69,7 +69,7 @@ public class CodeTemplateSourceViewerConfiguration extends SimpleCSourceViewerCo String varName= doc.get(offset, subject.getLength()); TemplateContextType contextType= fProcessor.getContextType(); if (contextType != null) { - Iterator iter= contextType.resolvers(); + Iterator iter= contextType.resolvers(); while (iter.hasNext()) { TemplateVariableResolver var= (TemplateVariableResolver) iter.next(); if (varName.equals(var.getType())) { diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/EditTemplateDialog.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/EditTemplateDialog.java index 7ba80b7ba21..e457989f0af 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/EditTemplateDialog.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/EditTemplateDialog.java @@ -191,7 +191,7 @@ class EditTemplateDialog extends StatusDialog { // String delim= new Document().getLegalLineDelimiters()[0]; List contexts= new ArrayList(); - for (Iterator it= registry.contextTypes(); it.hasNext();) { + for (Iterator it= registry.contextTypes(); it.hasNext();) { TemplateContextType type= (TemplateContextType) it.next(); // TODO cppdoc? doxygen? // if (type.getId().equals("javadoc")) //$NON-NLS-1$ @@ -277,8 +277,8 @@ class EditTemplateDialog extends StatusDialog { createLabel(composite, PreferencesMessages.EditTemplateDialog_contextType); fContextCombo= new Combo(composite, SWT.READ_ONLY); fContextCombo.setVisibleItemCount(10); - for (int i= 0; i < fContextTypes.length; i++) { - fContextCombo.add(fContextTypes[i][1]); + for (String[] contextType : fContextTypes) { + fContextCombo.add(contextType[1]); } fContextCombo.addModifyListener(listener); @@ -359,9 +359,9 @@ class EditTemplateDialog extends StatusDialog { private String getContextId() { if (fContextCombo != null && !fContextCombo.isDisposed()) { String name= fContextCombo.getText(); - for (int i= 0; i < fContextTypes.length; i++) { - if (name.equals(fContextTypes[i][1])) { - return fContextTypes[i][0]; + for (String[] contextType : fContextTypes) { + if (name.equals(contextType[1])) { + return contextType[0]; } } } @@ -475,8 +475,7 @@ class EditTemplateDialog extends StatusDialog { int idx= getIndex(id); if (idx != -1) return fContextTypes[idx][2]; - else - return ""; //$NON-NLS-1$ + return ""; //$NON-NLS-1$ } private void initializeActions() { diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/FoldingConfigurationBlock.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/FoldingConfigurationBlock.java index 3190450d528..cb715185fb4 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/FoldingConfigurationBlock.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/FoldingConfigurationBlock.java @@ -46,6 +46,7 @@ import org.eclipse.cdt.ui.CUIPlugin; import org.eclipse.cdt.ui.PreferenceConstants; import org.eclipse.cdt.ui.text.folding.ICFoldingPreferenceBlock; +import org.eclipse.cdt.internal.ui.preferences.OverlayPreferenceStore.OverlayKey; import org.eclipse.cdt.internal.ui.text.folding.CFoldingStructureProviderDescriptor; import org.eclipse.cdt.internal.ui.text.folding.CFoldingStructureProviderRegistry; import org.eclipse.cdt.internal.ui.util.PixelConverter; @@ -98,10 +99,10 @@ class FoldingConfigurationBlock implements IPreferenceConfigurationBlock { private Combo fProviderCombo; protected Button fFoldingCheckbox; private ComboViewer fProviderViewer; - protected Map fProviderDescriptors; + protected Map fProviderDescriptors; private Composite fGroup; - private Map fProviderPreferences; - private Map fProviderControls; + private Map fProviderPreferences; + private Map fProviderControls; private StackLayout fStackLayout; @@ -110,15 +111,15 @@ class FoldingConfigurationBlock implements IPreferenceConfigurationBlock { fStore= store; fStore.addKeys(createOverlayStoreKeys()); fProviderDescriptors= createListModel(); - fProviderPreferences= new HashMap(); - fProviderControls= new HashMap(); + fProviderPreferences= new HashMap(); + fProviderControls= new HashMap(); } - private Map createListModel() { + private Map createListModel() { CFoldingStructureProviderRegistry reg= CUIPlugin.getDefault().getFoldingStructureProviderRegistry(); reg.reloadExtensions(); CFoldingStructureProviderDescriptor[] descs= reg.getFoldingProviderDescriptors(); - Map map= new HashMap(); + Map map= new HashMap(); for (int i= 0; i < descs.length; i++) { map.put(descs[i].getId(), descs[i]); } @@ -127,7 +128,7 @@ class FoldingConfigurationBlock implements IPreferenceConfigurationBlock { private OverlayPreferenceStore.OverlayKey[] createOverlayStoreKeys() { - ArrayList overlayKeys= new ArrayList(); + ArrayList overlayKeys= new ArrayList(); overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_FOLDING_ENABLED)); overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.STRING, PreferenceConstants.EDITOR_FOLDING_PROVIDER)); @@ -269,7 +270,7 @@ class FoldingConfigurationBlock implements IPreferenceConfigurationBlock { void updateListDependencies() { String id= fStore.getString(PreferenceConstants.EDITOR_FOLDING_PROVIDER); - CFoldingStructureProviderDescriptor desc= (CFoldingStructureProviderDescriptor) fProviderDescriptors.get(id); + CFoldingStructureProviderDescriptor desc= fProviderDescriptors.get(id); ICFoldingPreferenceBlock prefs; if (desc == null) { @@ -278,7 +279,7 @@ class FoldingConfigurationBlock implements IPreferenceConfigurationBlock { CUIPlugin.log(new Status(IStatus.WARNING, CUIPlugin.getPluginId(), IStatus.OK, message, null)); prefs= new ErrorPreferences(message); } else { - prefs= (ICFoldingPreferenceBlock) fProviderPreferences.get(id); + prefs= fProviderPreferences.get(id); if (prefs == null) { try { prefs= desc.createPreferences(); @@ -290,7 +291,7 @@ class FoldingConfigurationBlock implements IPreferenceConfigurationBlock { } } - Control control= (Control) fProviderControls.get(id); + Control control= fProviderControls.get(id); if (control == null) { control= prefs.createControl(fGroup); if (control == null) { @@ -319,8 +320,8 @@ class FoldingConfigurationBlock implements IPreferenceConfigurationBlock { * @see org.eclipse.cdt.internal.ui.preferences.IPreferenceConfigurationBlock#performOk() */ public void performOk() { - for (Iterator it= fProviderPreferences.values().iterator(); it.hasNext();) { - ICFoldingPreferenceBlock prefs= (ICFoldingPreferenceBlock) it.next(); + for (Iterator it= fProviderPreferences.values().iterator(); it.hasNext();) { + ICFoldingPreferenceBlock prefs= it.next(); prefs.performOk(); } } @@ -330,8 +331,8 @@ class FoldingConfigurationBlock implements IPreferenceConfigurationBlock { */ public void performDefaults() { restoreFromPreferences(); - for (Iterator it= fProviderPreferences.values().iterator(); it.hasNext();) { - ICFoldingPreferenceBlock prefs= (ICFoldingPreferenceBlock) it.next(); + for (Iterator it= fProviderPreferences.values().iterator(); it.hasNext();) { + ICFoldingPreferenceBlock prefs= it.next(); prefs.performDefaults(); } } @@ -340,8 +341,8 @@ class FoldingConfigurationBlock implements IPreferenceConfigurationBlock { * @see org.eclipse.cdt.internal.ui.preferences.IPreferenceConfigurationBlock#dispose() */ public void dispose() { - for (Iterator it= fProviderPreferences.values().iterator(); it.hasNext();) { - ICFoldingPreferenceBlock prefs= (ICFoldingPreferenceBlock) it.next(); + for (Iterator it= fProviderPreferences.values().iterator(); it.hasNext();) { + ICFoldingPreferenceBlock prefs= it.next(); prefs.dispose(); } } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/MarkOccurrencesConfigurationBlock.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/MarkOccurrencesConfigurationBlock.java index f43ba797a1e..5e2e8a39c2c 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/MarkOccurrencesConfigurationBlock.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/MarkOccurrencesConfigurationBlock.java @@ -35,6 +35,7 @@ import org.eclipse.ui.dialogs.PreferencesUtil; import org.eclipse.cdt.ui.PreferenceConstants; import org.eclipse.cdt.internal.ui.dialogs.StatusInfo; +import org.eclipse.cdt.internal.ui.preferences.OverlayPreferenceStore.OverlayKey; import org.eclipse.cdt.internal.ui.util.PixelConverter; /** @@ -47,13 +48,13 @@ class MarkOccurrencesConfigurationBlock implements IPreferenceConfigurationBlock private OverlayPreferenceStore fStore; - private Map fCheckBoxes= new HashMap(); + private Map fCheckBoxes= new HashMap(); private SelectionListener fCheckBoxListener= new SelectionListener() { public void widgetDefaultSelected(SelectionEvent e) { } public void widgetSelected(SelectionEvent e) { Button button= (Button) e.widget; - fStore.setValue((String) fCheckBoxes.get(button), button.getSelection()); + fStore.setValue(fCheckBoxes.get(button), button.getSelection()); } }; @@ -62,7 +63,7 @@ class MarkOccurrencesConfigurationBlock implements IPreferenceConfigurationBlock * * @see #createDependency(Button, String, Control) */ - private ArrayList fMasterSlaveListeners= new ArrayList(); + private ArrayList fMasterSlaveListeners= new ArrayList(); private StatusInfo fStatus; @@ -75,7 +76,7 @@ class MarkOccurrencesConfigurationBlock implements IPreferenceConfigurationBlock private OverlayPreferenceStore.OverlayKey[] createOverlayStoreKeys() { - ArrayList overlayKeys= new ArrayList(); + ArrayList overlayKeys= new ArrayList(); overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_MARK_OCCURRENCES)); overlayKeys.add(new OverlayPreferenceStore.OverlayKey(OverlayPreferenceStore.BOOLEAN, PreferenceConstants.EDITOR_STICKY_OCCURRENCES)); @@ -180,10 +181,10 @@ class MarkOccurrencesConfigurationBlock implements IPreferenceConfigurationBlock void initializeFields() { - Iterator iter= fCheckBoxes.keySet().iterator(); + Iterator iter= fCheckBoxes.keySet().iterator(); while (iter.hasNext()) { Button b= (Button) iter.next(); - String key= (String) fCheckBoxes.get(b); + String key= fCheckBoxes.get(b); b.setSelection(fStore.getBoolean(key)); } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/PathEntryVariableDialog.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/PathEntryVariableDialog.java index 6ee84085f43..c32ebb55e29 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/PathEntryVariableDialog.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/PathEntryVariableDialog.java @@ -93,7 +93,7 @@ public class PathEntryVariableDialog 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:
    @@ -149,7 +149,7 @@ public class PathEntryVariableDialog extends TitleAreaDialog { * this dialog. IResource.FILE or IResource.FOLDER * @param namesInUse a set of variable names currently in use */ - public PathEntryVariableDialog(Shell parentShell, int type, int variableType, Set namesInUse) { + public PathEntryVariableDialog(Shell parentShell, int type, int variableType, Set namesInUse) { super(parentShell); this.type = type; this.newVariable = type == NEW_VARIABLE; diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/PathEntryVariablesGroup.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/PathEntryVariablesGroup.java index d95c0d6a9c9..4ce226abcde 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/PathEntryVariablesGroup.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/PathEntryVariablesGroup.java @@ -14,15 +14,12 @@ package org.eclipse.cdt.internal.ui.preferences; import java.io.File; import java.util.HashSet; -import java.util.Iterator; -import java.util.Map; import java.util.Set; import java.util.SortedMap; import java.util.TreeMap; +import java.util.Map.Entry; -import org.eclipse.cdt.core.CCorePlugin; -import org.eclipse.cdt.core.resources.IPathEntryVariableManager; -import org.eclipse.cdt.internal.ui.CPluginImages; +import org.eclipse.core.resources.IPathVariableManager; import org.eclipse.core.resources.IResource; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IPath; @@ -53,6 +50,11 @@ import org.eclipse.swt.widgets.TableItem; import org.eclipse.ui.ISharedImages; import org.eclipse.ui.PlatformUI; +import org.eclipse.cdt.core.CCorePlugin; +import org.eclipse.cdt.core.resources.IPathEntryVariableManager; + +import org.eclipse.cdt.internal.ui.CPluginImages; + public class PathEntryVariablesGroup { /** @@ -93,10 +95,10 @@ public class PathEntryVariablesGroup { protected Listener selectionListener; // temporary collection for keeping currently defined variables - private SortedMap tempPathVariables; + private SortedMap tempPathVariables; // set of removed variables' names - private Set removedVariableNames; + private Set removedVariableNames; // reference to the workspace's path variable manager private IPathEntryVariableManager pathEntryVariableManager; @@ -124,8 +126,8 @@ public class PathEntryVariablesGroup { this.multiSelect = multiSelect; this.variableType = variableType; pathEntryVariableManager = CCorePlugin.getDefault().getPathEntryVariableManager(); - removedVariableNames = new HashSet(); - tempPathVariables = new TreeMap(); + removedVariableNames = new HashSet(); + tempPathVariables = new TreeMap(); // initialize internal model initTemporaryState(); } @@ -252,7 +254,7 @@ public class PathEntryVariablesGroup { TableItem item = variableTable.getItem(variableTable .getSelectionIndex()); String variableName = (String) item.getData(); - IPath variableValue = (IPath) tempPathVariables.get(variableName); + IPath variableValue = tempPathVariables.get(variableName); // constructs a dialog for editing the variable's current name and value PathEntryVariableDialog dialog = new PathEntryVariableDialog(shell, @@ -312,7 +314,7 @@ public class PathEntryVariablesGroup { String name = (String) items[i].getData(); selection[i] = new PathEntryVariableElement(); selection[i].name = name; - selection[i].path = (IPath)tempPathVariables.get(name); + selection[i].path = tempPathVariables.get(name); } return selection; } @@ -394,8 +396,8 @@ public class PathEntryVariablesGroup { String[] varNames = pathEntryVariableManager.getVariableNames(); tempPathVariables.clear(); - for (int i = 0; i < varNames.length; i++) { - IPath value = pathEntryVariableManager.getValue(varNames[i]); + for (String varName : varNames) { + IPath value = pathEntryVariableManager.getValue(varName); // the value may not exist any more if (value != null) { @@ -403,7 +405,7 @@ public class PathEntryVariablesGroup { if ((isFile && (variableType & IResource.FILE) != 0) || (isFile == false && (variableType & IResource.FOLDER) != 0)) { - tempPathVariables.put(varNames[i], value); + tempPathVariables.put(varName, value); } } } @@ -434,10 +436,9 @@ public class PathEntryVariablesGroup { private void updateVariableTable(String selectedVarName) { variableTable.removeAll(); int selectedVarIndex = 0; - for (Iterator varNames = tempPathVariables.keySet().iterator(); varNames.hasNext();) { + for (String varName : tempPathVariables.keySet()) { TableItem item = new TableItem(variableTable, SWT.NONE); - String varName = (String) varNames.next(); - IPath value = (IPath) tempPathVariables.get(varName); + IPath value = tempPathVariables.get(varName); File file = value.toFile(); item.setText(varName + " - " + value.toOSString()); //$NON-NLS-1$ @@ -466,18 +467,16 @@ public class PathEntryVariablesGroup { public boolean performOk() { try { // first process removed variables - for (Iterator removed = removedVariableNames.iterator(); removed.hasNext();) { - String removedVariableName = (String) removed.next(); + for (String removedVariableName : removedVariableNames) { // only removes variables that have not been added again if (!tempPathVariables.containsKey(removedVariableName)) pathEntryVariableManager.setValue(removedVariableName, null); } // then process the current collection of variables, adding/updating them - for (Iterator current = tempPathVariables.entrySet().iterator(); current.hasNext();) { - Map.Entry entry = (Map.Entry) current.next(); - String variableName = (String) entry.getKey(); - IPath variableValue = (IPath) entry.getValue(); + for (Entry entry : tempPathVariables.entrySet()) { + String variableName = entry.getKey(); + IPath variableValue = entry.getValue(); pathEntryVariableManager.setValue(variableName, variableValue); } // re-initialize temporary state @@ -497,8 +496,8 @@ public class PathEntryVariablesGroup { protected void removeSelectedVariables() { // remove each selected element int[] selectedIndices = variableTable.getSelectionIndices(); - for (int i = 0; i < selectedIndices.length; i++) { - TableItem selectedItem = variableTable.getItem(selectedIndices[i]); + for (int selectedIndice : selectedIndices) { + TableItem selectedItem = variableTable.getItem(selectedIndice); String varName = (String) selectedItem.getData(); removedVariableNames.add(varName); tempPathVariables.remove(varName); diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/ProjectSelectionDialog.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/ProjectSelectionDialog.java index 4ef3098d6ed..44e1b87c744 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/ProjectSelectionDialog.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/ProjectSelectionDialog.java @@ -37,6 +37,7 @@ import org.eclipse.ui.dialogs.SelectionStatusDialog; import org.eclipse.cdt.core.model.CoreModel; import org.eclipse.cdt.core.model.ICModel; +import org.eclipse.cdt.core.model.ICProject; import org.eclipse.cdt.ui.CElementContentProvider; import org.eclipse.cdt.ui.CElementLabelProvider; import org.eclipse.cdt.ui.CElementSorter; @@ -48,7 +49,7 @@ public class ProjectSelectionDialog extends SelectionStatusDialog { // the visual selection widget group private TableViewer fTableViewer; - private Set fProjectsWithSpecifics; + private Set fProjectsWithSpecifics; // sizing constants private final static int SIZING_SELECTION_WIDGET_HEIGHT= 250; @@ -58,7 +59,7 @@ public class ProjectSelectionDialog extends SelectionStatusDialog { private ViewerFilter fFilter; - public ProjectSelectionDialog(Shell parentShell, Set projectsWithSpecifics) { + public ProjectSelectionDialog(Shell parentShell, Set projectsWithSpecifics) { super(parentShell); setTitle(PreferencesMessages.ProjectSelectionDialog_title); setMessage(PreferencesMessages.ProjectSelectionDialog_desciption); diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/PropertyAndPreferencePage.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/PropertyAndPreferencePage.java index 76a69c0f588..d68bffe8820 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/PropertyAndPreferencePage.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/PropertyAndPreferencePage.java @@ -63,7 +63,7 @@ public abstract class PropertyAndPreferencePage extends PreferencePage implement private Composite fParentComposite; private IProject fProject; // project or null - private Map fData; // page data + private Map fData; // page data public static final String DATA_NO_LINK= "PropertyAndPreferencePage.nolink"; //$NON-NLS-1$ @@ -191,17 +191,16 @@ public abstract class PropertyAndPreferencePage extends PreferencePage implement * @param link the link */ final void doLinkActivated(Link link) { - Map data= new HashMap(); + Map data= new HashMap(); data.put(DATA_NO_LINK, Boolean.TRUE); if (isProjectPreferencePage()) { openWorkspacePreferences(data); } else { - HashSet projectsWithSpecifics= new HashSet(); + HashSet projectsWithSpecifics= new HashSet(); try { ICProject[] projects= CoreModel.getDefault().getCModel().getCProjects(); - for (int i= 0; i < projects.length; i++) { - ICProject curr= projects[i]; + for (ICProject curr : projects) { if (hasProjectSpecificOptions(curr.getProject())) { projectsWithSpecifics.add(curr); } @@ -334,7 +333,7 @@ public abstract class PropertyAndPreferencePage extends PreferencePage implement @Override public void applyData(Object data) { if (data instanceof Map) { - fData= (Map) data; + fData= (Map) data; } if (fChangeWorkspaceSettings != null) { if (!offerLink()) { @@ -344,8 +343,7 @@ public abstract class PropertyAndPreferencePage extends PreferencePage implement } } - protected Map getData() { + protected Map getData() { return fData; } - } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/ProposalFilterPreferencesUtil.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/ProposalFilterPreferencesUtil.java index 5aa70e74f78..ee772736c17 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/ProposalFilterPreferencesUtil.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/ProposalFilterPreferencesUtil.java @@ -12,8 +12,6 @@ package org.eclipse.cdt.internal.ui.preferences; import java.util.ArrayList; -import org.eclipse.cdt.internal.ui.text.contentassist.ContentAssistPreference; -import org.eclipse.cdt.ui.CUIPlugin; import org.eclipse.core.runtime.IConfigurationElement; import org.eclipse.core.runtime.IExtension; import org.eclipse.core.runtime.IExtensionPoint; @@ -22,6 +20,10 @@ import org.eclipse.core.runtime.Platform; import org.eclipse.jface.preference.IPreferenceStore; import org.eclipse.swt.widgets.Combo; +import org.eclipse.cdt.ui.CUIPlugin; + +import org.eclipse.cdt.internal.ui.text.contentassist.ContentAssistPreference; + /** * A class which encapsulates several utility functions * related to code completion preference settings. @@ -40,16 +42,14 @@ public class ProposalFilterPreferencesUtil { * to fill into the Combo) */ public static String[] getProposalFilterNames() { - ArrayList names = new ArrayList(); + ArrayList names = new ArrayList(); try { IExtensionPoint point = Platform.getExtensionRegistry() .getExtensionPoint(CUIPlugin.PLUGIN_ID, "ProposalFilter"); //$NON-NLS-1$ if (point != null) { IExtension[] extensions = point.getExtensions(); - for (int i = 0; i < extensions.length; i++) { - IExtension extension = extensions[i]; - IConfigurationElement[] elements = extension - .getConfigurationElements(); + for (IExtension extension : extensions) { + IConfigurationElement[] elements = extension.getConfigurationElements(); for (int j = 0; j < elements.length; ++j) { IConfigurationElement element = elements[j]; if ("ProposalFilter".equals(element.getName())) { //$NON-NLS-1$ @@ -65,8 +65,7 @@ public class ProposalFilterPreferencesUtil { // No action required since we will at least be using the fail-safe default filter CUIPlugin.log(e); } - String[] filterNames = (String[]) names - .toArray(new String[names.size()]); + String[] filterNames = names.toArray(new String[names.size()]); return filterNames; } @@ -82,8 +81,7 @@ public class ProposalFilterPreferencesUtil { StringBuffer filterNames = new StringBuffer("0;"); //$NON-NLS-1$ filterNames.append(PreferencesMessages.ProposalFilterPreferencesUtil_defaultFilterName); String[] names = getProposalFilterNames(); - for (int i = 0; i < names.length; i++) { - String name = names[i]; + for (String name : names) { filterNames.append(";"); //$NON-NLS-1$ filterNames.append(name); } @@ -104,9 +102,7 @@ public class ProposalFilterPreferencesUtil { try { IExtension[] extensions = point.getExtensions(); if (extensions.length >= 1) { - for (int i = 0; i < extensions.length; i++) { - IExtension extension = extensions[i]; - + for (IExtension extension : extensions) { IConfigurationElement[] elements = extension .getConfigurationElements(); @@ -153,9 +149,9 @@ public class ProposalFilterPreferencesUtil { int selectionIndex = combo.getSelectionIndex(); text.append(selectionIndex); String[] entries = combo.getItems(); - for (int i = 0; i < entries.length; i++) { + for (String entrie : entries) { text.append(";"); //$NON-NLS-1$ - String entry = entries[i].replaceAll(";", ","); //$NON-NLS-1$ //$NON-NLS-2$ + String entry = entrie.replaceAll(";", ","); //$NON-NLS-1$ //$NON-NLS-2$ text.append(entry); } return text.toString(); diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/SpellingConfigurationBlock.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/SpellingConfigurationBlock.java index 24d78eee37c..68177de3a8d 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/SpellingConfigurationBlock.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/SpellingConfigurationBlock.java @@ -13,20 +13,21 @@ package org.eclipse.cdt.internal.ui.preferences; import java.io.File; import java.util.ArrayList; -import java.util.Iterator; import java.util.List; import java.util.Locale; import java.util.Set; -import org.eclipse.core.variables.IStringVariableManager; -import org.eclipse.core.variables.VariablesPlugin; - -import org.eclipse.core.runtime.CoreException; -import org.eclipse.core.runtime.IStatus; - import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.ResourcesPlugin; - +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.variables.IStringVariableManager; +import org.eclipse.core.variables.VariablesPlugin; +import org.eclipse.jface.dialogs.DialogPage; +import org.eclipse.jface.preference.IPreferenceStore; +import org.eclipse.jface.preference.PreferenceStore; +import org.eclipse.jface.window.Window; +import org.eclipse.osgi.util.NLS; import org.eclipse.swt.SWT; import org.eclipse.swt.events.SelectionAdapter; import org.eclipse.swt.events.SelectionEvent; @@ -42,16 +43,9 @@ import org.eclipse.swt.widgets.FileDialog; import org.eclipse.swt.widgets.Group; import org.eclipse.swt.widgets.Label; import org.eclipse.swt.widgets.Text; - -import org.eclipse.jface.dialogs.DialogPage; -import org.eclipse.jface.preference.IPreferenceStore; -import org.eclipse.jface.preference.PreferenceStore; -import org.eclipse.jface.window.Window; - import org.eclipse.ui.PlatformUI; -import org.eclipse.ui.preferences.IWorkbenchPreferenceContainer; - import org.eclipse.ui.ide.dialogs.EncodingFieldEditor; +import org.eclipse.ui.preferences.IWorkbenchPreferenceContainer; import org.eclipse.cdt.ui.PreferenceConstants; @@ -123,13 +117,11 @@ public class SpellingConfigurationBlock extends OptionsConfigurationBlock { * The list of locales * @return Array of locale codes for the list */ - protected static String[] getDictionaryCodes(final Set locales) { + protected static String[] getDictionaryCodes(final Set locales) { int index= 0; - Locale locale= null; final String[] codes= new String[locales.size() + 1]; - for (final Iterator iterator= locales.iterator(); iterator.hasNext();) { - locale= (Locale)iterator.next(); + for (Locale locale : locales) { codes[index++]= locale.toString(); } codes[index++]= PREF_VALUE_NO_LOCALE; @@ -142,14 +134,11 @@ public class SpellingConfigurationBlock extends OptionsConfigurationBlock { * @param locales The list of locales * @return Array of display labels for the list */ - protected static String[] getDictionaryLabels(final Set locales) { + protected static String[] getDictionaryLabels(final Set locales) { int index= 0; - Locale locale= null; final String[] labels= new String[locales.size() + 1]; - for (final Iterator iterator= locales.iterator(); iterator.hasNext();) { - - locale= (Locale)iterator.next(); + for (Locale locale : locales) { labels[index++]= locale.getDisplayName(); } labels[index++]= PreferencesMessages.SpellingPreferencePage_dictionary_none; @@ -214,10 +203,10 @@ public class SpellingConfigurationBlock extends OptionsConfigurationBlock { try { final int value= Integer.parseInt(number); if (value < 0) { - status.setError(PreferencesMessages.bind(PreferencesMessages.SpellingPreferencePage_invalid_threshold, number)); + status.setError(NLS.bind(PreferencesMessages.SpellingPreferencePage_invalid_threshold, number)); } } catch (NumberFormatException exception) { - status.setError(PreferencesMessages.bind(PreferencesMessages.SpellingPreferencePage_invalid_threshold, number)); + status.setError(NLS.bind(PreferencesMessages.SpellingPreferencePage_invalid_threshold, number)); } } return status; @@ -354,7 +343,7 @@ public class SpellingConfigurationBlock extends OptionsConfigurationBlock { slave= addCheckBox(user, label, PREF_SPELLING_IGNORE_STRING_LITERALS, trueFalse, 0); allControls.add(slave); - final Set locales= SpellCheckEngine.getLocalesWithInstalledDictionaries(); + final Set locales= SpellCheckEngine.getLocalesWithInstalledDictionaries(); boolean hasPlaformDictionaries= locales.size() > 0; final Group engine= new Group(composite, SWT.NONE); @@ -518,8 +507,7 @@ public class SpellingConfigurationBlock extends OptionsConfigurationBlock { private static Key[] getAllKeys() { if (SUPPORT_CONTENT_ASSIST_PROPOSALS) return new Key[] { PREF_SPELLING_USER_DICTIONARY, PREF_SPELLING_USER_DICTIONARY_ENCODING, PREF_SPELLING_IGNORE_DIGITS, PREF_SPELLING_IGNORE_MIXED, PREF_SPELLING_IGNORE_SENTENCE, PREF_SPELLING_IGNORE_UPPER, PREF_SPELLING_IGNORE_URLS, PREF_SPELLING_IGNORE_NON_LETTERS, PREF_SPELLING_IGNORE_SINGLE_LETTERS, PREF_SPELLING_LOCALE, PREF_SPELLING_PROPOSAL_THRESHOLD, PREF_SPELLING_PROBLEMS_THRESHOLD, PREF_SPELLING_ENABLE_CONTENTASSIST, PREF_SPELLING_IGNORE_STRING_LITERALS }; - else - return new Key[] { PREF_SPELLING_USER_DICTIONARY, PREF_SPELLING_USER_DICTIONARY_ENCODING, PREF_SPELLING_IGNORE_DIGITS, PREF_SPELLING_IGNORE_MIXED, PREF_SPELLING_IGNORE_SENTENCE, PREF_SPELLING_IGNORE_UPPER, PREF_SPELLING_IGNORE_URLS, PREF_SPELLING_IGNORE_NON_LETTERS, PREF_SPELLING_IGNORE_SINGLE_LETTERS, PREF_SPELLING_LOCALE, PREF_SPELLING_PROPOSAL_THRESHOLD, PREF_SPELLING_PROBLEMS_THRESHOLD, PREF_SPELLING_IGNORE_STRING_LITERALS }; + return new Key[] { PREF_SPELLING_USER_DICTIONARY, PREF_SPELLING_USER_DICTIONARY_ENCODING, PREF_SPELLING_IGNORE_DIGITS, PREF_SPELLING_IGNORE_MIXED, PREF_SPELLING_IGNORE_SENTENCE, PREF_SPELLING_IGNORE_UPPER, PREF_SPELLING_IGNORE_URLS, PREF_SPELLING_IGNORE_NON_LETTERS, PREF_SPELLING_IGNORE_SINGLE_LETTERS, PREF_SPELLING_LOCALE, PREF_SPELLING_PROPOSAL_THRESHOLD, PREF_SPELLING_PROBLEMS_THRESHOLD, PREF_SPELLING_IGNORE_STRING_LITERALS }; } /* diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/TodoTaskConfigurationBlock.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/TodoTaskConfigurationBlock.java index e1d1443301a..613d5258965 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/TodoTaskConfigurationBlock.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/TodoTaskConfigurationBlock.java @@ -15,18 +15,8 @@ package org.eclipse.cdt.internal.ui.preferences; import java.util.ArrayList; import java.util.List; -import org.eclipse.core.runtime.IStatus; - import org.eclipse.core.resources.IProject; - -import org.eclipse.swt.SWT; -import org.eclipse.swt.graphics.Font; -import org.eclipse.swt.graphics.Image; -import org.eclipse.swt.layout.GridData; -import org.eclipse.swt.layout.GridLayout; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; - +import org.eclipse.core.runtime.IStatus; import org.eclipse.jface.resource.JFaceResources; import org.eclipse.jface.viewers.IFontProvider; import org.eclipse.jface.viewers.ITableLabelProvider; @@ -34,7 +24,13 @@ import org.eclipse.jface.viewers.LabelProvider; import org.eclipse.jface.viewers.Viewer; import org.eclipse.jface.viewers.ViewerComparator; import org.eclipse.jface.window.Window; - +import org.eclipse.swt.SWT; +import org.eclipse.swt.graphics.Font; +import org.eclipse.swt.graphics.Image; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Control; import org.eclipse.ui.preferences.IWorkbenchPreferenceContainer; import org.eclipse.cdt.core.CCorePreferenceConstants; @@ -106,16 +102,15 @@ public class TodoTaskConfigurationBlock extends OptionsConfigurationBlock { name = Messages.format(PreferencesMessages.TodoTaskConfigurationBlock_tasks_default, name); } return name; - } else { - if (TASK_PRIORITY_HIGH.equals(task.priority)) { - return PreferencesMessages.TodoTaskConfigurationBlock_markers_tasks_high_priority; - } else if (TASK_PRIORITY_NORMAL.equals(task.priority)) { - return PreferencesMessages.TodoTaskConfigurationBlock_markers_tasks_normal_priority; - } else if (TASK_PRIORITY_LOW.equals(task.priority)) { - return PreferencesMessages.TodoTaskConfigurationBlock_markers_tasks_low_priority; - } - return ""; //$NON-NLS-1$ - } + } + if (TASK_PRIORITY_HIGH.equals(task.priority)) { + return PreferencesMessages.TodoTaskConfigurationBlock_markers_tasks_high_priority; + } else if (TASK_PRIORITY_NORMAL.equals(task.priority)) { + return PreferencesMessages.TodoTaskConfigurationBlock_markers_tasks_normal_priority; + } else if (TASK_PRIORITY_LOW.equals(task.priority)) { + return PreferencesMessages.TodoTaskConfigurationBlock_markers_tasks_low_priority; + } + return ""; //$NON-NLS-1$ } /* (non-Javadoc) @@ -130,6 +125,7 @@ public class TodoTaskConfigurationBlock extends OptionsConfigurationBlock { } private static class TodoTaskSorter extends ViewerComparator { + @SuppressWarnings("unchecked") @Override public int compare(Viewer viewer, Object e1, Object e2) { return getComparator().compare(((TodoTask) e1).name, ((TodoTask) e2).name); @@ -142,7 +138,7 @@ public class TodoTaskConfigurationBlock extends OptionsConfigurationBlock { private static final int IDX_DEFAULT = 4; private IStatus fTaskTagsStatus; - private ListDialogField fTodoTasksList; + private ListDialogField fTodoTasksList; private SelectionButtonDialogField fCaseSensitiveCheckBox; @@ -157,7 +153,7 @@ public class TodoTaskConfigurationBlock extends OptionsConfigurationBlock { null, PreferencesMessages.TodoTaskConfigurationBlock_markers_tasks_setdefault_button, }; - fTodoTasksList = new ListDialogField(adapter, buttons, new TodoTaskLabelProvider()); + fTodoTasksList = new ListDialogField(adapter, buttons, new TodoTaskLabelProvider()); fTodoTasksList.setDialogFieldListener(adapter); fTodoTasksList.setRemoveButtonIndex(IDX_REMOVE); @@ -194,7 +190,7 @@ public class TodoTaskConfigurationBlock extends OptionsConfigurationBlock { } private void setToDefaultTask(TodoTask task) { - List elements = fTodoTasksList.getElements(); + List elements = fTodoTasksList.getElements(); elements.remove(task); elements.add(0, task); fTodoTasksList.setElements(elements); @@ -207,26 +203,26 @@ public class TodoTaskConfigurationBlock extends OptionsConfigurationBlock { }; } - public class TaskTagAdapter implements IListAdapter, IDialogFieldListener { - private boolean canEdit(List selectedElements) { + public class TaskTagAdapter implements IListAdapter, IDialogFieldListener { + private boolean canEdit(List selectedElements) { return selectedElements.size() == 1; } - private boolean canSetToDefault(List selectedElements) { - return selectedElements.size() == 1 && !isDefaultTask((TodoTask) selectedElements.get(0)); + private boolean canSetToDefault(List selectedElements) { + return selectedElements.size() == 1 && !isDefaultTask(selectedElements.get(0)); } - public void customButtonPressed(ListDialogField field, int index) { + public void customButtonPressed(ListDialogField field, int index) { doTodoButtonPressed(index); } - public void selectionChanged(ListDialogField field) { - List selectedElements = field.getSelectedElements(); + public void selectionChanged(ListDialogField field) { + List selectedElements = field.getSelectedElements(); field.enableButton(IDX_EDIT, canEdit(selectedElements)); field.enableButton(IDX_DEFAULT, canSetToDefault(selectedElements)); } - public void doubleClicked(ListDialogField field) { + public void doubleClicked(ListDialogField field) { if (canEdit(field.getSelectedElements())) { doTodoButtonPressed(IDX_EDIT); } @@ -300,13 +296,13 @@ public class TodoTaskConfigurationBlock extends OptionsConfigurationBlock { if (field == fTodoTasksList) { StringBuffer tags = new StringBuffer(); StringBuffer prios = new StringBuffer(); - List list = fTodoTasksList.getElements(); + List list = fTodoTasksList.getElements(); for (int i = 0; i < list.size(); i++) { if (i > 0) { tags.append(','); prios.append(','); } - TodoTask elem = (TodoTask) list.get(i); + TodoTask elem = list.get(i); tags.append(elem.name); prios.append(elem.priority); } @@ -332,7 +328,7 @@ public class TodoTaskConfigurationBlock extends OptionsConfigurationBlock { String currPrios = getValue(PREF_TODO_TASK_PRIORITIES); String[] tags = getTokens(currTags, ","); //$NON-NLS-1$ String[] prios = getTokens(currPrios, ","); //$NON-NLS-1$ - ArrayList elements = new ArrayList(tags.length); + ArrayList elements = new ArrayList(tags.length); for (int i = 0; i < tags.length; i++) { TodoTask task = new TodoTask(); task.name = tags[i].trim(); @@ -348,7 +344,7 @@ public class TodoTaskConfigurationBlock extends OptionsConfigurationBlock { private void doTodoButtonPressed(int index) { TodoTask edited = null; if (index != IDX_ADD) { - edited = (TodoTask) fTodoTasksList.getSelectedElements().get(0); + edited = fTodoTasksList.getSelectedElements().get(0); } if (index == IDX_ADD || index == IDX_EDIT) { TodoTaskInputDialog dialog = new TodoTaskInputDialog(getShell(), edited, fTodoTasksList.getElements()); diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/TodoTaskInputDialog.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/TodoTaskInputDialog.java index d43c303b158..02167a708e0 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/TodoTaskInputDialog.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/TodoTaskInputDialog.java @@ -15,14 +15,12 @@ package org.eclipse.cdt.internal.ui.preferences; import java.util.ArrayList; import java.util.List; +import org.eclipse.jface.dialogs.StatusDialog; import org.eclipse.swt.SWT; import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Control; import org.eclipse.swt.widgets.Shell; - -import org.eclipse.jface.dialogs.StatusDialog; - import org.eclipse.ui.PlatformUI; import org.eclipse.cdt.core.CCorePreferenceConstants; @@ -50,14 +48,14 @@ public class TodoTaskInputDialog extends StatusDialog { private StringDialogField fNameDialogField; private ComboDialogField fPriorityDialogField; - private List fExistingNames; + private List fExistingNames; - public TodoTaskInputDialog(Shell parent, TodoTask task, List existingEntries) { + public TodoTaskInputDialog(Shell parent, TodoTask task, List existingEntries) { super(parent); - fExistingNames = new ArrayList(existingEntries.size()); + fExistingNames = new ArrayList(existingEntries.size()); for (int i = 0; i < existingEntries.size(); i++) { - TodoTask curr = (TodoTask) existingEntries.get(i); + TodoTask curr = existingEntries.get(i); if (!curr.equals(task)) { fExistingNames.add(curr.name); } diff --git a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/WorkInProgressPreferencePage.java b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/WorkInProgressPreferencePage.java index 07f58208203..830add87a8a 100644 --- a/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/WorkInProgressPreferencePage.java +++ b/core/org.eclipse.cdt.ui/src/org/eclipse/cdt/internal/ui/preferences/WorkInProgressPreferencePage.java @@ -36,18 +36,18 @@ import org.eclipse.cdt.ui.CUIPlugin; */ public class WorkInProgressPreferencePage extends PreferencePage implements IWorkbenchPreferencePage { - private List fCheckBoxes; - private List fRadioButtons; - private List fTextControls; + private List