diff --git a/bundles/org.eclipse.ui.ide/extensions/org/eclipse/ui/actions/AddBookmarkAction.java b/bundles/org.eclipse.ui.ide/extensions/org/eclipse/ui/actions/AddBookmarkAction.java index 5d58721925c..0c841a687ff 100644 --- a/bundles/org.eclipse.ui.ide/extensions/org/eclipse/ui/actions/AddBookmarkAction.java +++ b/bundles/org.eclipse.ui.ide/extensions/org/eclipse/ui/actions/AddBookmarkAction.java @@ -52,7 +52,7 @@ public class AddBookmarkAction extends SelectionListenerAction { /** * The IShellProvider in which to show any dialogs. */ - private IShellProvider shellProvider; + private final IShellProvider shellProvider; /** * Creates a new bookmark action. By default, prompts the user for the @@ -107,8 +107,9 @@ private void initAction() { @Override public void run() { - if (getSelectedResources().isEmpty()) + if (getSelectedResources().isEmpty()) { return; + } IResource resource= getSelectedResources().get(0); if (resource != null) { diff --git a/bundles/org.eclipse.ui.ide/extensions/org/eclipse/ui/actions/AddTaskAction.java b/bundles/org.eclipse.ui.ide/extensions/org/eclipse/ui/actions/AddTaskAction.java index d65384b34c9..c407be6aa30 100644 --- a/bundles/org.eclipse.ui.ide/extensions/org/eclipse/ui/actions/AddTaskAction.java +++ b/bundles/org.eclipse.ui.ide/extensions/org/eclipse/ui/actions/AddTaskAction.java @@ -43,7 +43,7 @@ public class AddTaskAction extends SelectionListenerAction { /** * The IShellProvider in which to show any dialogs. */ - private IShellProvider shellProvider; + private final IShellProvider shellProvider; /** * Creates a new instance of the receiver. @@ -91,8 +91,7 @@ private IResource getElement(IStructuredSelection selection) { Object element = selection.getFirstElement(); IResource resource = Adapters.adapt(element, IResource.class); - if (resource != null && resource instanceof IProject) { - IProject project = (IProject) resource; + if (resource != null && resource instanceof IProject project) { if (!project.isOpen()) { resource = null; } diff --git a/bundles/org.eclipse.ui.ide/extensions/org/eclipse/ui/actions/BuildAction.java b/bundles/org.eclipse.ui.ide/extensions/org/eclipse/ui/actions/BuildAction.java index d56991a3b22..34897059707 100644 --- a/bundles/org.eclipse.ui.ide/extensions/org/eclipse/ui/actions/BuildAction.java +++ b/bundles/org.eclipse.ui.ide/extensions/org/eclipse/ui/actions/BuildAction.java @@ -141,8 +141,9 @@ protected List getActionResources() { @Override protected String getOperationMessage() { - if (getProjectsToBuild().size() > 1) + if (getProjectsToBuild().size() > 1) { return IDEWorkbenchMessages.BuildAction_operationMessage_plural; + } return IDEWorkbenchMessages.BuildAction_operationMessage; } @@ -204,8 +205,9 @@ protected List getBuildConfigurationsToBuild() { * false if not, or if this couldn't be determined */ boolean hasBuilder(IProject project) { - if (!project.isAccessible()) + if (!project.isAccessible()) { return false; + } try { ICommand[] commands = project.getDescription().getBuildSpec(); if (commands.length > 0) { diff --git a/bundles/org.eclipse.ui.ide/extensions/org/eclipse/ui/actions/CloseResourceAction.java b/bundles/org.eclipse.ui.ide/extensions/org/eclipse/ui/actions/CloseResourceAction.java index ebcd9e9ee85..fd6aee00f48 100644 --- a/bundles/org.eclipse.ui.ide/extensions/org/eclipse/ui/actions/CloseResourceAction.java +++ b/bundles/org.eclipse.ui.ide/extensions/org/eclipse/ui/actions/CloseResourceAction.java @@ -151,8 +151,9 @@ private void initAction() { @Override protected String getOperationMessage() { - if (getActionResources().size() > 1) + if (getActionResources().size() > 1) { return IDEWorkbenchMessages.CloseResourceAction_operationMessage_plural; + } return IDEWorkbenchMessages.CloseResourceAction_operationMessage; } @@ -318,8 +319,7 @@ private boolean validateClose() { IResourceChangeDescriptionFactory factory = ResourceChangeValidator.getValidator().createDeltaFactory(); List resources = getActionResources(); for (IResource resource : resources) { - if (resource instanceof IProject) { - IProject project = (IProject) resource; + if (resource instanceof IProject project) { factory.close(project); } } diff --git a/bundles/org.eclipse.ui.ide/extensions/org/eclipse/ui/actions/CloseUnrelatedProjectsAction.java b/bundles/org.eclipse.ui.ide/extensions/org/eclipse/ui/actions/CloseUnrelatedProjectsAction.java index 6bb045a4647..2e0901417b5 100644 --- a/bundles/org.eclipse.ui.ide/extensions/org/eclipse/ui/actions/CloseUnrelatedProjectsAction.java +++ b/bundles/org.eclipse.ui.ide/extensions/org/eclipse/ui/actions/CloseUnrelatedProjectsAction.java @@ -165,8 +165,9 @@ private boolean promptForConfirmation() { projectName = firstSelected.getName(); } message = NLS.bind(IDEWorkbenchMessages.CloseUnrelatedProjectsAction_confirmMsg1, projectName); - } else // if more then one project is selected then print there number + } else { // if more then one project is selected then print there number message = NLS.bind(IDEWorkbenchMessages.CloseUnrelatedProjectsAction_confirmMsgN, selectionSize); + } MessageDialogWithToggle dialog = MessageDialogWithToggle.openOkCancelConfirm( getShell(), IDEWorkbenchMessages.CloseUnrelatedProjectsAction_toolTip, diff --git a/bundles/org.eclipse.ui.ide/extensions/org/eclipse/ui/actions/CopyFilesAndFoldersOperation.java b/bundles/org.eclipse.ui.ide/extensions/org/eclipse/ui/actions/CopyFilesAndFoldersOperation.java index 3a930c095a8..b91225fa15e 100644 --- a/bundles/org.eclipse.ui.ide/extensions/org/eclipse/ui/actions/CopyFilesAndFoldersOperation.java +++ b/bundles/org.eclipse.ui.ide/extensions/org/eclipse/ui/actions/CopyFilesAndFoldersOperation.java @@ -101,7 +101,7 @@ public class CopyFilesAndFoldersOperation { /** * The parent shell used to show any dialogs. */ - private Shell messageShell; + private final Shell messageShell; /** * Whether or not the copy has been canceled by the user. @@ -477,14 +477,17 @@ protected void copy(IResource[] resources, IPath destination, IProgressMonitor m if (createVirtualFoldersAndLinks) { folder.create(IResource.VIRTUAL, true, iterationMonitor.split(1)); IResource[] members = ((IContainer) resource).members(); - if (members.length > 0) + if (members.length > 0) { copy(members, destinationPath, iterationMonitor.split(99)); - } else + } + } else { folder.createLink(createRelativePath(resource.getLocationURI(), folder), 0, iterationMonitor.split(100)); + } } - } else + } else { resource.copy(destinationPath, IResource.SHALLOW, iterationMonitor.split(100)); + } } } } @@ -498,8 +501,9 @@ protected void copy(IResource[] resources, IPath destination, IProgressMonitor m * @return an URI that was made relative to a variable */ private URI createRelativePath(URI locationURI, IResource resource) { - if (relativeVariable == null) + if (relativeVariable == null) { return locationURI; + } IPath location = URIUtil.toPath(locationURI); IPath result; try { @@ -752,9 +756,9 @@ public void copyOrLinkFiles(final String[] fileNames, IContainer destination, in String variable= null; //check if resource linking is disabled - if (ResourcesPlugin.getPlugin().getPluginPreferences().getBoolean(ResourcesPlugin.PREF_DISABLE_LINKING)) + if (ResourcesPlugin.getPlugin().getPluginPreferences().getBoolean(ResourcesPlugin.PREF_DISABLE_LINKING)) { mode= ImportTypeDialog.IMPORT_COPY; - else if (dndPreference.equals(IDEInternalPreferences.IMPORT_FILES_AND_FOLDERS_MODE_PROMPT)) { + } else if (dndPreference.equals(IDEInternalPreferences.IMPORT_FILES_AND_FOLDERS_MODE_PROMPT)) { ImportTypeDialog dialog= new ImportTypeDialog(messageShell, dropOperation, fileNames, destination); dialog.setResource(destination); if (dialog.open() == Window.OK) { @@ -774,13 +778,15 @@ else if (dndPreference.equals(IDEInternalPreferences.IMPORT_FILES_AND_FOLDERS_MO copyFiles(fileNames, destination); break; case ImportTypeDialog.IMPORT_VIRTUAL_FOLDERS_AND_LINKS: - if (variable != null) + if (variable != null) { setRelativeVariable(variable); + } createVirtualFoldersAndLinks(fileNames, destination); break; case ImportTypeDialog.IMPORT_LINK: - if (variable != null) + if (variable != null) { setRelativeVariable(variable); + } linkFiles(fileNames, destination); break; case ImportTypeDialog.IMPORT_NONE: @@ -1239,8 +1245,7 @@ private boolean performCopy(IResource[] resources, IPath destination, AbstractWorkspaceOperation op = getUndoableCopyOrMoveOperation( resources, destination); op.setModelProviderIds(getModelProviderIds()); - if (op instanceof CopyResourcesOperation) { - CopyResourcesOperation copyMoveOp = (CopyResourcesOperation) op; + if (op instanceof CopyResourcesOperation copyMoveOp) { copyMoveOp.setCreateVirtualFolders(createVirtualFoldersAndLinks); copyMoveOp.setCreateLinks(createLinks); copyMoveOp.setRelativeVariable(relativeVariable); @@ -1574,8 +1579,9 @@ public String validateImportDestination(IContainer destination, */ private String validateImportDestinationInternal(IContainer destination, IFileStore[] sourceStores) { - if (!isAccessible(destination)) + if (!isAccessible(destination)) { return IDEWorkbenchMessages.CopyFilesAndFoldersOperation_destinationAccessError; + } if (!destination.isVirtual()) { IFileStore destinationStore; diff --git a/bundles/org.eclipse.ui.ide/extensions/org/eclipse/ui/actions/CopyProjectOperation.java b/bundles/org.eclipse.ui.ide/extensions/org/eclipse/ui/actions/CopyProjectOperation.java index 4750c14988e..a5a8a79fa94 100644 --- a/bundles/org.eclipse.ui.ide/extensions/org/eclipse/ui/actions/CopyProjectOperation.java +++ b/bundles/org.eclipse.ui.ide/extensions/org/eclipse/ui/actions/CopyProjectOperation.java @@ -58,7 +58,7 @@ public class CopyProjectOperation { /** * The parent shell used to show any dialogs. */ - private Shell parentShell; + private final Shell parentShell; private String[] modelProviderIds; diff --git a/bundles/org.eclipse.ui.ide/extensions/org/eclipse/ui/actions/DeleteResourceAction.java b/bundles/org.eclipse.ui.ide/extensions/org/eclipse/ui/actions/DeleteResourceAction.java index 585d44d6873..02bd91fefcd 100644 --- a/bundles/org.eclipse.ui.ide/extensions/org/eclipse/ui/actions/DeleteResourceAction.java +++ b/bundles/org.eclipse.ui.ide/extensions/org/eclipse/ui/actions/DeleteResourceAction.java @@ -67,7 +67,7 @@ public class DeleteResourceAction extends SelectionListenerAction { static class DeleteProjectDialog extends MessageDialog { - private List projects; + private final List projects; private boolean deleteContent; @@ -179,7 +179,7 @@ public void mouseUp(MouseEvent e) { return composite; } - private SelectionListener selectionListener = new SelectionAdapter() { + private final SelectionListener selectionListener = new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { Button button = (Button) e.widget; diff --git a/bundles/org.eclipse.ui.ide/extensions/org/eclipse/ui/actions/NewExampleAction.java b/bundles/org.eclipse.ui.ide/extensions/org/eclipse/ui/actions/NewExampleAction.java index cb7f28f3f8c..542a2d26d67 100644 --- a/bundles/org.eclipse.ui.ide/extensions/org/eclipse/ui/actions/NewExampleAction.java +++ b/bundles/org.eclipse.ui.ide/extensions/org/eclipse/ui/actions/NewExampleAction.java @@ -53,7 +53,7 @@ public class NewExampleAction extends Action { /** * The workbench window this action will run in */ - private IWorkbenchWindow window; + private final IWorkbenchWindow window; /** * This default constructor allows the the action to be called from the welcome page. diff --git a/bundles/org.eclipse.ui.ide/extensions/org/eclipse/ui/actions/NewProjectAction.java b/bundles/org.eclipse.ui.ide/extensions/org/eclipse/ui/actions/NewProjectAction.java index 319b68dde04..b6a30603eb7 100644 --- a/bundles/org.eclipse.ui.ide/extensions/org/eclipse/ui/actions/NewProjectAction.java +++ b/bundles/org.eclipse.ui.ide/extensions/org/eclipse/ui/actions/NewProjectAction.java @@ -51,7 +51,7 @@ public class NewProjectAction extends Action { /** * The workbench window this action will run in */ - private IWorkbenchWindow window; + private final IWorkbenchWindow window; /** * This default constructor allows the the action to be called from the welcome page. diff --git a/bundles/org.eclipse.ui.ide/extensions/org/eclipse/ui/actions/OpenFileAction.java b/bundles/org.eclipse.ui.ide/extensions/org/eclipse/ui/actions/OpenFileAction.java index 0ad74cdd9af..ac34c4bbbff 100644 --- a/bundles/org.eclipse.ui.ide/extensions/org/eclipse/ui/actions/OpenFileAction.java +++ b/bundles/org.eclipse.ui.ide/extensions/org/eclipse/ui/actions/OpenFileAction.java @@ -48,7 +48,7 @@ public class OpenFileAction extends OpenSystemEditorAction { /** * The editor to open. */ - private IEditorDescriptor editorDescriptor; + private final IEditorDescriptor editorDescriptor; /** * Creates a new action that will open editors on the then-selected file diff --git a/bundles/org.eclipse.ui.ide/extensions/org/eclipse/ui/actions/OpenResourceAction.java b/bundles/org.eclipse.ui.ide/extensions/org/eclipse/ui/actions/OpenResourceAction.java index 4590deabfc8..cbe3618076f 100644 --- a/bundles/org.eclipse.ui.ide/extensions/org/eclipse/ui/actions/OpenResourceAction.java +++ b/bundles/org.eclipse.ui.ide/extensions/org/eclipse/ui/actions/OpenResourceAction.java @@ -116,8 +116,9 @@ private int countClosedProjects() { @Override protected String getOperationMessage() { - if (getActionResources().size() > 1) + if (getActionResources().size() > 1) { return IDEWorkbenchMessages.OpenResourceAction_operationMessage_plural; + } return IDEWorkbenchMessages.OpenResourceAction_operationMessage; } @@ -139,8 +140,9 @@ private boolean hasOtherClosedProjects() { //count the closed projects in the selection int closedInSelection = 0; for (IResource project : getSelectedResources()) { - if (!((IProject) project).isOpen()) + if (!((IProject) project).isOpen()) { closedInSelection++; + } } //there are other closed projects if the selection does //not contain all closed projects in the workspace @@ -250,8 +252,9 @@ private void doOpenWithReferences(IProject project, IProgressMonitor mon) throws //remember that we have prompted to avoid repeating the analysis hasPrompted = true; }); - if (canceled) + if (canceled) { throw new OperationCanceledException(); + } } } if (openProjectReferences) { @@ -268,11 +271,10 @@ public IStatus runInWorkspace(IProgressMonitor monitor) throws CoreException { // at most we can only open all projects currently closed subMonitor.setTaskName(getOperationMessage()); for (IResource resource : resources) { - if (!(resource instanceof IProject)) { + if (!(resource instanceof IProject project)) { continue; } - IProject project = (IProject) resource; if (!project.exists() || project.isOpen()) { continue; } diff --git a/bundles/org.eclipse.ui.ide/extensions/org/eclipse/ui/actions/OpenSystemEditorAction.java b/bundles/org.eclipse.ui.ide/extensions/org/eclipse/ui/actions/OpenSystemEditorAction.java index eed4b14df4c..2d6c2c52b5f 100644 --- a/bundles/org.eclipse.ui.ide/extensions/org/eclipse/ui/actions/OpenSystemEditorAction.java +++ b/bundles/org.eclipse.ui.ide/extensions/org/eclipse/ui/actions/OpenSystemEditorAction.java @@ -44,7 +44,7 @@ public class OpenSystemEditorAction extends SelectionListenerAction { /** * The workbench page to open the editor in. */ - private IWorkbenchPage workbenchPage; + private final IWorkbenchPage workbenchPage; /** * Creates a new action that will open system editors on the then-selected file diff --git a/bundles/org.eclipse.ui.ide/extensions/org/eclipse/ui/actions/OpenWithMenu.java b/bundles/org.eclipse.ui.ide/extensions/org/eclipse/ui/actions/OpenWithMenu.java index 6bafc8d0d7a..dd078270043 100644 --- a/bundles/org.eclipse.ui.ide/extensions/org/eclipse/ui/actions/OpenWithMenu.java +++ b/bundles/org.eclipse.ui.ide/extensions/org/eclipse/ui/actions/OpenWithMenu.java @@ -65,11 +65,11 @@ */ public class OpenWithMenu extends ContributionItem { - private IWorkbenchPage page; + private final IWorkbenchPage page; - private IAdaptable adaptable; + private final IAdaptable adaptable; - private IEditorRegistry registry; + private final IEditorRegistry registry; /** * The id of this action. @@ -86,7 +86,7 @@ public class OpenWithMenu extends ContributionItem { * Compares the labels from two IEditorDescriptor objects */ private static final Comparator comparer = new Comparator<>() { - private Collator collator = Collator.getInstance(); + private final Collator collator = Collator.getInstance(); @Override public int compare(IEditorDescriptor arg0, IEditorDescriptor arg1) { diff --git a/bundles/org.eclipse.ui.ide/extensions/org/eclipse/ui/actions/ReadOnlyStateChecker.java b/bundles/org.eclipse.ui.ide/extensions/org/eclipse/ui/actions/ReadOnlyStateChecker.java index 66526bf7321..2acb57364c7 100644 --- a/bundles/org.eclipse.ui.ide/extensions/org/eclipse/ui/actions/ReadOnlyStateChecker.java +++ b/bundles/org.eclipse.ui.ide/extensions/org/eclipse/ui/actions/ReadOnlyStateChecker.java @@ -36,11 +36,11 @@ * not they wish to continue the operation on it. */ public class ReadOnlyStateChecker { - private Shell shell; + private final Shell shell; - private String titleMessage; + private final String titleMessage; - private String mainMessage; + private final String mainMessage; private boolean yesToAllSelected = false; @@ -48,7 +48,7 @@ public class ReadOnlyStateChecker { private boolean ignoreLinkedResources = false; - private String READ_ONLY_EXCEPTION_MESSAGE = IDEWorkbenchMessages.ReadOnlyCheck_problems; + private final String READ_ONLY_EXCEPTION_MESSAGE = IDEWorkbenchMessages.ReadOnlyCheck_problems; /** * Create a new checker that parents the dialog off of parent using the supplied diff --git a/bundles/org.eclipse.ui.ide/extensions/org/eclipse/ui/actions/RenameResourceAction.java b/bundles/org.eclipse.ui.ide/extensions/org/eclipse/ui/actions/RenameResourceAction.java index 8ed6c6ca1f4..974e1bf4628 100644 --- a/bundles/org.eclipse.ui.ide/extensions/org/eclipse/ui/actions/RenameResourceAction.java +++ b/bundles/org.eclipse.ui.ide/extensions/org/eclipse/ui/actions/RenameResourceAction.java @@ -408,8 +408,9 @@ protected String queryNewResourceName(final IResource resource) { resource.getName(), validator); dialog.setBlockOnOpen(true); int result = dialog.open(); - if (result == Window.OK) + if (result == Window.OK) { return dialog.getValue(); + } return null; } diff --git a/bundles/org.eclipse.ui.ide/extensions/org/eclipse/ui/actions/TextActionHandler.java b/bundles/org.eclipse.ui.ide/extensions/org/eclipse/ui/actions/TextActionHandler.java index 090e6eeee72..b0466ade5ea 100644 --- a/bundles/org.eclipse.ui.ide/extensions/org/eclipse/ui/actions/TextActionHandler.java +++ b/bundles/org.eclipse.ui.ide/extensions/org/eclipse/ui/actions/TextActionHandler.java @@ -56,15 +56,15 @@ * @noextend This class is not intended to be subclassed by clients. */ public class TextActionHandler { - private DeleteActionHandler textDeleteAction = new DeleteActionHandler(); + private final DeleteActionHandler textDeleteAction = new DeleteActionHandler(); - private CutActionHandler textCutAction = new CutActionHandler(); + private final CutActionHandler textCutAction = new CutActionHandler(); - private CopyActionHandler textCopyAction = new CopyActionHandler(); + private final CopyActionHandler textCopyAction = new CopyActionHandler(); - private PasteActionHandler textPasteAction = new PasteActionHandler(); + private final PasteActionHandler textPasteAction = new PasteActionHandler(); - private SelectAllActionHandler textSelectAllAction = new SelectAllActionHandler(); + private final SelectAllActionHandler textSelectAllAction = new SelectAllActionHandler(); private IAction deleteAction; @@ -76,26 +76,26 @@ public class TextActionHandler { private IAction selectAllAction; - private IPropertyChangeListener deleteActionListener = new PropertyChangeListener( + private final IPropertyChangeListener deleteActionListener = new PropertyChangeListener( textDeleteAction); - private IPropertyChangeListener cutActionListener = new PropertyChangeListener( + private final IPropertyChangeListener cutActionListener = new PropertyChangeListener( textCutAction); - private IPropertyChangeListener copyActionListener = new PropertyChangeListener( + private final IPropertyChangeListener copyActionListener = new PropertyChangeListener( textCopyAction); - private IPropertyChangeListener pasteActionListener = new PropertyChangeListener( + private final IPropertyChangeListener pasteActionListener = new PropertyChangeListener( textPasteAction); - private IPropertyChangeListener selectAllActionListener = new PropertyChangeListener( + private final IPropertyChangeListener selectAllActionListener = new PropertyChangeListener( textSelectAllAction); - private Listener textControlListener = new TextControlListener(); + private final Listener textControlListener = new TextControlListener(); private Text activeTextControl; - private IActionBars actionBars; + private final IActionBars actionBars; /** * If true the actions (copy, past, ...) are populated from the @@ -109,14 +109,14 @@ public class TextActionHandler { */ private boolean autoMode = false; - private MouseAdapter mouseAdapter = new MouseAdapter() { + private final MouseAdapter mouseAdapter = new MouseAdapter() { @Override public void mouseUp(MouseEvent e) { updateActionsEnableState(); } }; - private KeyAdapter keyAdapter = new KeyAdapter() { + private final KeyAdapter keyAdapter = new KeyAdapter() { @Override public void keyReleased(KeyEvent e) { updateActionsEnableState(); @@ -143,7 +143,7 @@ public void handleEvent(Event event) { } private class PropertyChangeListener implements IPropertyChangeListener { - private IAction actionHandler; + private final IAction actionHandler; protected PropertyChangeListener(IAction actionHandler) { super(); diff --git a/bundles/org.eclipse.ui.ide/extensions/org/eclipse/ui/actions/WorkspaceModifyDelegatingOperation.java b/bundles/org.eclipse.ui.ide/extensions/org/eclipse/ui/actions/WorkspaceModifyDelegatingOperation.java index 28c0e49e7cd..3274f0a37a7 100644 --- a/bundles/org.eclipse.ui.ide/extensions/org/eclipse/ui/actions/WorkspaceModifyDelegatingOperation.java +++ b/bundles/org.eclipse.ui.ide/extensions/org/eclipse/ui/actions/WorkspaceModifyDelegatingOperation.java @@ -35,7 +35,7 @@ public class WorkspaceModifyDelegatingOperation extends /** * The runnable to delegate work to at execution time. */ - private IRunnableWithProgress content; + private final IRunnableWithProgress content; /** * Creates a new operation which will delegate its work to the given diff --git a/bundles/org.eclipse.ui.ide/extensions/org/eclipse/ui/actions/WorkspaceModifyOperation.java b/bundles/org.eclipse.ui.ide/extensions/org/eclipse/ui/actions/WorkspaceModifyOperation.java index 49ed04cbb11..918c4ad22f5 100644 --- a/bundles/org.eclipse.ui.ide/extensions/org/eclipse/ui/actions/WorkspaceModifyOperation.java +++ b/bundles/org.eclipse.ui.ide/extensions/org/eclipse/ui/actions/WorkspaceModifyOperation.java @@ -55,7 +55,7 @@ * @see org.eclipse.core.resources.IWorkspace#run(ICoreRunnable, IProgressMonitor) * */ public abstract class WorkspaceModifyOperation implements IRunnableWithProgress, IThreadListener { - private ISchedulingRule rule; + private final ISchedulingRule rule; /** * Creates a new operation. diff --git a/bundles/org.eclipse.ui.ide/extensions/org/eclipse/ui/dialogs/ContainerGenerator.java b/bundles/org.eclipse.ui.ide/extensions/org/eclipse/ui/dialogs/ContainerGenerator.java index a53a9df60b9..03f57d6fa4a 100644 --- a/bundles/org.eclipse.ui.ide/extensions/org/eclipse/ui/dialogs/ContainerGenerator.java +++ b/bundles/org.eclipse.ui.ide/extensions/org/eclipse/ui/dialogs/ContainerGenerator.java @@ -55,7 +55,7 @@ * @noextend This class is not intended to be subclassed by clients. */ public class ContainerGenerator { - private IPath containerFullPath; + private final IPath containerFullPath; private IContainer generatedContainer; diff --git a/bundles/org.eclipse.ui.ide/extensions/org/eclipse/ui/dialogs/ContainerSelectionDialog.java b/bundles/org.eclipse.ui.ide/extensions/org/eclipse/ui/dialogs/ContainerSelectionDialog.java index 86d103d7f58..e1277465d7d 100644 --- a/bundles/org.eclipse.ui.ide/extensions/org/eclipse/ui/dialogs/ContainerSelectionDialog.java +++ b/bundles/org.eclipse.ui.ide/extensions/org/eclipse/ui/dialogs/ContainerSelectionDialog.java @@ -60,7 +60,7 @@ public class ContainerSelectionDialog extends SelectionDialog { ContainerSelectionGroup group; // the root resource to populate the viewer with - private IContainer initialSelection; + private final IContainer initialSelection; // allow the user to type in a new container name private boolean allowNewContainerName = true; diff --git a/bundles/org.eclipse.ui.ide/extensions/org/eclipse/ui/dialogs/FilteredResourcesSelectionDialog.java b/bundles/org.eclipse.ui.ide/extensions/org/eclipse/ui/dialogs/FilteredResourcesSelectionDialog.java index 496c231b1ab..65b3175ffc2 100644 --- a/bundles/org.eclipse.ui.ide/extensions/org/eclipse/ui/dialogs/FilteredResourcesSelectionDialog.java +++ b/bundles/org.eclipse.ui.ide/extensions/org/eclipse/ui/dialogs/FilteredResourcesSelectionDialog.java @@ -118,15 +118,15 @@ private int getDefaultMatchRules() { private ShowDerivedResourcesAction showDerivedResourcesAction; - private ResourceItemLabelProvider resourceItemLabelProvider; + private final ResourceItemLabelProvider resourceItemLabelProvider; - private ResourceItemDetailsLabelProvider resourceItemDetailsLabelProvider; + private final ResourceItemDetailsLabelProvider resourceItemDetailsLabelProvider; private WorkingSetFilterActionGroup workingSetFilterActionGroup; - private CustomWorkingSetFilter workingSetFilter = new CustomWorkingSetFilter(); + private final CustomWorkingSetFilter workingSetFilter = new CustomWorkingSetFilter(); - private FilterResourcesByLocation filterResourceByLocation = new FilterResourcesByLocation(); + private final FilterResourcesByLocation filterResourceByLocation = new FilterResourcesByLocation(); private GroupResourcesByLocationAction groupResourcesByLocationAction; private String title; @@ -137,7 +137,7 @@ private int getDefaultMatchRules() { * the root of the tree that spans the search space. Often, this is the * workspace root. */ - private IContainer container; + private final IContainer container; /** * The container to use as starting point for relative search, or @@ -147,7 +147,7 @@ private int getDefaultMatchRules() { */ private IContainer searchContainer; - private int typeMask; + private final int typeMask; private boolean isDerived; @@ -202,8 +202,7 @@ public FilteredResourcesSelectionDialog(Shell shell, boolean multi, IContainer c resource = ResourceUtil.getResource(editorInput); } else { ISelection selection = ww.getSelectionService().getSelection(); - if (selection instanceof IStructuredSelection) { - IStructuredSelection structuredSelection = (IStructuredSelection) selection; + if (selection instanceof IStructuredSelection structuredSelection) { if (structuredSelection.size() == 1) { resource = ResourceUtil.getResource(structuredSelection.getFirstElement()); } @@ -371,8 +370,9 @@ protected Control createExtendedContentArea(Composite parent) { public Object[] getResult() { Object[] result = super.getResult(); - if (result == null) + if (result == null) { return null; + } List resultToReturn = new ArrayList<>(); @@ -487,14 +487,16 @@ protected Comparator getItemsComparator() { } int comparability = collator.compare(n1, n2); - if (comparability != 0) + if (comparability != 0) { return comparability; + } // Compare full names if (s1Dot != -1 || s2Dot != -1) { comparability = collator.compare(s1, s2); - if (comparability != 0) + if (comparability != 0) { return comparability; + } } // Search for resource relative paths @@ -504,8 +506,9 @@ protected Comparator getItemsComparator() { // Return paths 'closer' to the searchContainer first comparability = pathDistance(c11) - pathDistance(c21); - if (comparability != 0) + if (comparability != 0) { return comparability; + } } // Finally compare full path segments @@ -516,8 +519,9 @@ protected Comparator getItemsComparator() { int c22 = p2.segmentCount() - 1; for (int i = 0; i < c12 && i < c22; i++) { comparability = collator.compare(p1.segment(i), p2.segment(i)); - if (comparability != 0) + if (comparability != 0) { return comparability; + } } comparability = c12 - c22; @@ -563,12 +567,14 @@ private int pathDistance(IContainer item) { // /a/x/e/f ==> Integer.MAX_VALUE/4 + 2 // /g/h ==> Integer.MAX_VALUE/2 IPath itemPath = item.getFullPath(); - if (itemPath.equals(containerPath)) + if (itemPath.equals(containerPath)) { return 0; + } int matching = containerPath.matchingFirstSegments(itemPath); - if (matching == 0) + if (matching == 0) { return Integer.MAX_VALUE / 2; + } int containerSegmentCount = containerPath.segmentCount(); if (matching == containerSegmentCount) { @@ -593,11 +599,13 @@ protected void fillContentProvider(AbstractContentProvider contentProvider, Item if (visitor.visit(container.createProxy())) { for (IResource member : members) { - if (member.isAccessible()) + if (member.isAccessible()) { member.accept(visitor, IResource.NONE); + } progressMonitor.worked(1); - if (progressMonitor.isCanceled()) + if (progressMonitor.isCanceled()) { break; + } } } @@ -662,7 +670,7 @@ private class ResourceItemLabelProvider extends LabelProvider implements ILabelProviderListener, IStyledLabelProvider { // Need to keep our own list of listeners - private ListenerList listeners = new ListenerList<>(); + private final ListenerList listeners = new ListenerList<>(); ILabelProvider provider = WorkbenchLabelProvider.getDecoratingWorkbenchLabelProvider(); @@ -676,22 +684,19 @@ public ResourceItemLabelProvider() { @Override public Image getImage(Object element) { - if (!(element instanceof IResource)) { + if (!(element instanceof IResource res)) { return super.getImage(element); } - IResource res = (IResource) element; - return provider.getImage(res); } @Override public String getText(Object element) { - if (!(element instanceof IResource)) { + if (!(element instanceof IResource res)) { return super.getText(element); } - IResource res = (IResource) element; StringBuilder str = new StringBuilder(res.getName()); if (!parentIsRoot(res)) { str.append(" - "); //$NON-NLS-1$ @@ -703,11 +708,10 @@ public String getText(Object element) { @Override public StyledString getStyledText(Object element) { - if (!(element instanceof IResource)) { + if (!(element instanceof IResource resource)) { return new StyledString(super.getText(element)); } - IResource resource = (IResource) element; String searchFieldString = ((Text) getPatternControl()).getText(); // We highlight just the matches in resource name, so cut off path if any @@ -848,12 +852,10 @@ public void labelProviderChanged(LabelProviderChangedEvent event) { private class ResourceItemDetailsLabelProvider extends ResourceItemLabelProvider { @Override public Image getImage(Object element) { - if (!(element instanceof IResource)) { + if (!(element instanceof final IResource resource)) { return super.getImage(element); } - final IResource resource = (IResource) element; - if (parentIsRoot(resource)) { return provider.getImage(resource); } @@ -891,7 +893,7 @@ public void labelProviderChanged(LabelProviderChangedEvent event) { * Viewer filter which filters resources due to current working set */ private static class CustomWorkingSetFilter extends ViewerFilter { - private ResourceWorkingSetFilter resourceWorkingSetFilter = new ResourceWorkingSetFilter(); + private final ResourceWorkingSetFilter resourceWorkingSetFilter = new ResourceWorkingSetFilter(); /** * Sets the active working set. @@ -915,11 +917,11 @@ public boolean select(Viewer viewer, Object parentElement, Object element) { */ private static class ResourceProxyVisitor implements IResourceProxyVisitor { - private AbstractContentProvider proxyContentProvider; + private final AbstractContentProvider proxyContentProvider; - private ResourceFilter resourceFilter; + private final ResourceFilter resourceFilter; - private IProgressMonitor progressMonitor; + private final IProgressMonitor progressMonitor; /** * Creates new ResourceProxyVisitor instance. @@ -935,8 +937,9 @@ public ResourceProxyVisitor(AbstractContentProvider contentProvider, ResourceFil @Override public boolean visit(IResourceProxy proxy) { - if (progressMonitor.isCanceled()) + if (progressMonitor.isCanceled()) { return false; + } IResource resource = proxy.requestResource(); @@ -963,7 +966,7 @@ protected class ResourceFilter extends ItemsFilter { private boolean showDerived = false; - private IContainer filterContainer; + private final IContainer filterContainer; /** * Container path pattern. Is null when only a file name pattern is @@ -995,7 +998,7 @@ protected class ResourceFilter extends ItemsFilter { */ SearchPattern extensionPattern; - private int filterTypeMask; + private final int filterTypeMask; /** * Creates new ResourceFilter instance @@ -1033,8 +1036,9 @@ private ResourceFilter(IContainer container, IContainer searchContainer, boolean filenamePattern = stringPattern.substring(sep + 1, stringPattern.length()); if (sep > 0) { - if (filenamePattern.isEmpty()) // relative patterns don't need a file name + if (filenamePattern.isEmpty()) { // relative patterns don't need a file name filenamePattern = "**"; //$NON-NLS-1$ + } String newContainerPattern = stringPattern.substring(isMatchPrefix(stringPattern) ? 1 : 0, sep); @@ -1098,12 +1102,12 @@ public ResourceFilter() { */ @Override public boolean isConsistentItem(Object item) { - if (!(item instanceof IResource)) { + if (!(item instanceof IResource resource)) { return false; } - IResource resource = (IResource) item; - if (this.filterContainer.findMember(resource.getFullPath()) != null) + if (this.filterContainer.findMember(resource.getFullPath()) != null) { return true; + } return false; } @@ -1114,10 +1118,9 @@ public boolean isConsistentItem(Object item) { */ @Override public boolean matchItem(Object item) { - if (!(item instanceof IResource)) { + if (!(item instanceof IResource resource)) { return false; } - IResource resource = (IResource) item; return (this.filterTypeMask & resource.getType()) != 0 && matchName(resource) && (this.showDerived || !resource.isDerived()); } @@ -1128,12 +1131,14 @@ private boolean matchName(IResource resource) { if (containerPattern != null) { // match full container path: String containerPath = resource.getParent().getFullPath().toString(); - if (containerPattern.matches(containerPath)) + if (containerPattern.matches(containerPath)) { return true; + } // match path relative to current selection: - if (relativeContainerPattern != null) + if (relativeContainerPattern != null) { return relativeContainerPattern.matches(containerPath); // match direct parency + } return false; } @@ -1156,10 +1161,10 @@ private boolean nameMatches(String name) { @Override public boolean isSubFilter(ItemsFilter filter) { - if (!super.isSubFilter(filter)) + if (!super.isSubFilter(filter)) { return false; - if (filter instanceof ResourceFilter) { - ResourceFilter resourceFilter = (ResourceFilter) filter; + } + if (filter instanceof ResourceFilter resourceFilter) { if (this.showDerived == resourceFilter.showDerived) { if (containerPattern == null) { return resourceFilter.containerPattern == null; @@ -1175,10 +1180,10 @@ public boolean isSubFilter(ItemsFilter filter) { @Override public boolean equalsFilter(ItemsFilter iFilter) { - if (!super.equalsFilter(iFilter)) + if (!super.equalsFilter(iFilter)) { return false; - if (iFilter instanceof ResourceFilter) { - ResourceFilter resourceFilter = (ResourceFilter) iFilter; + } + if (iFilter instanceof ResourceFilter resourceFilter) { if (this.showDerived == resourceFilter.showDerived) { if (containerPattern == null) { return resourceFilter.containerPattern == null; @@ -1218,8 +1223,7 @@ public Object[] filter(Viewer viewer, Object parent, Object[] elements) { } Map bestResourceForPath = new LinkedHashMap<>(); for (Object item : elements) { - if (item instanceof IResource) { - IResource currentResource = (IResource) item; + if (item instanceof IResource currentResource) { IResource otherResource = bestResourceForPath.get(currentResource.getLocation()); if (otherResource == null || otherResource.getFullPath().segmentCount() > currentResource .getFullPath().segmentCount()) { diff --git a/bundles/org.eclipse.ui.ide/extensions/org/eclipse/ui/dialogs/MarkerResolutionSelectionDialog.java b/bundles/org.eclipse.ui.ide/extensions/org/eclipse/ui/dialogs/MarkerResolutionSelectionDialog.java index ea73f101488..10a797d0a5c 100644 --- a/bundles/org.eclipse.ui.ide/extensions/org/eclipse/ui/dialogs/MarkerResolutionSelectionDialog.java +++ b/bundles/org.eclipse.ui.ide/extensions/org/eclipse/ui/dialogs/MarkerResolutionSelectionDialog.java @@ -54,7 +54,7 @@ public class MarkerResolutionSelectionDialog extends SelectionDialog { /** * The marker resolutions. */ - private IMarkerResolution[] resolutions; + private final IMarkerResolution[] resolutions; /** * List to display the resolutions. diff --git a/bundles/org.eclipse.ui.ide/extensions/org/eclipse/ui/dialogs/NewFolderDialog.java b/bundles/org.eclipse.ui.ide/extensions/org/eclipse/ui/dialogs/NewFolderDialog.java index f98b7408b04..0620b687cd8 100644 --- a/bundles/org.eclipse.ui.ide/extensions/org/eclipse/ui/dialogs/NewFolderDialog.java +++ b/bundles/org.eclipse.ui.ide/extensions/org/eclipse/ui/dialogs/NewFolderDialog.java @@ -75,7 +75,7 @@ public class NewFolderDialog extends SelectionStatusDialog { private CreateLinkedResourceGroup linkedResourceGroup; - private IContainer container; + private final IContainer container; private boolean firstLinkCheck = true; diff --git a/bundles/org.eclipse.ui.ide/extensions/org/eclipse/ui/dialogs/ProjectLocationMoveDialog.java b/bundles/org.eclipse.ui.ide/extensions/org/eclipse/ui/dialogs/ProjectLocationMoveDialog.java index be580829223..82c9fb3df0a 100644 --- a/bundles/org.eclipse.ui.ide/extensions/org/eclipse/ui/dialogs/ProjectLocationMoveDialog.java +++ b/bundles/org.eclipse.ui.ide/extensions/org/eclipse/ui/dialogs/ProjectLocationMoveDialog.java @@ -40,7 +40,7 @@ * project for moving. */ public class ProjectLocationMoveDialog extends SelectionDialog { - private IProject project; + private final IProject project; private Label statusMessageLabel; diff --git a/bundles/org.eclipse.ui.ide/extensions/org/eclipse/ui/dialogs/ProjectLocationSelectionDialog.java b/bundles/org.eclipse.ui.ide/extensions/org/eclipse/ui/dialogs/ProjectLocationSelectionDialog.java index 203af81eda3..2dd061565da 100644 --- a/bundles/org.eclipse.ui.ide/extensions/org/eclipse/ui/dialogs/ProjectLocationSelectionDialog.java +++ b/bundles/org.eclipse.ui.ide/extensions/org/eclipse/ui/dialogs/ProjectLocationSelectionDialog.java @@ -58,7 +58,7 @@ public class ProjectLocationSelectionDialog extends SelectionStatusDialog { // widgets private Text projectNameField; - private IProject project; + private final IProject project; private ProjectContentsLocationArea locationArea; @@ -116,8 +116,9 @@ private void applyValidationResult(String errorMsg, boolean infoOnly) { } updateStatus(new Status(code, IDEWorkbenchPlugin.IDE_WORKBENCH, code, errorMsg, null)); - if (getOkButton() != null) + if (getOkButton() != null) { getOkButton().setEnabled(allowFinish); + } } /** diff --git a/bundles/org.eclipse.ui.ide/extensions/org/eclipse/ui/dialogs/ResourceSelectionDialog.java b/bundles/org.eclipse.ui.ide/extensions/org/eclipse/ui/dialogs/ResourceSelectionDialog.java index 72696ce09d2..322e5e20499 100644 --- a/bundles/org.eclipse.ui.ide/extensions/org/eclipse/ui/dialogs/ResourceSelectionDialog.java +++ b/bundles/org.eclipse.ui.ide/extensions/org/eclipse/ui/dialogs/ResourceSelectionDialog.java @@ -59,7 +59,7 @@ */ public class ResourceSelectionDialog extends SelectionDialog { // the root element to populate the viewer with - private IAdaptable root; + private final IAdaptable root; // the visual selection widget group private CheckboxTreeAndListGroup selectionGroup; diff --git a/bundles/org.eclipse.ui.ide/extensions/org/eclipse/ui/dialogs/WizardExportResourcesPage.java b/bundles/org.eclipse.ui.ide/extensions/org/eclipse/ui/dialogs/WizardExportResourcesPage.java index d9e0ee19118..4637398ae75 100644 --- a/bundles/org.eclipse.ui.ide/extensions/org/eclipse/ui/dialogs/WizardExportResourcesPage.java +++ b/bundles/org.eclipse.ui.ide/extensions/org/eclipse/ui/dialogs/WizardExportResourcesPage.java @@ -77,7 +77,7 @@ * */ public abstract class WizardExportResourcesPage extends WizardDataTransferPage { - private IStructuredSelection initialResourceSelection; + private final IStructuredSelection initialResourceSelection; private List selectedTypes = new ArrayList<>(); @@ -337,8 +337,8 @@ protected List extractNonLocalResources(List originalList) { private static class ResourceProvider extends WorkbenchContentProvider { private static final Object[] EMPTY = new Object[0]; - private int resourceType; - private boolean showLinkedResources; + private final int resourceType; + private final boolean showLinkedResources; public ResourceProvider(int resourceType, boolean showLinkedResources) { super(); @@ -348,8 +348,7 @@ public ResourceProvider(int resourceType, boolean showLinkedResources) { @Override public Object[] getChildren(Object o) { - if (o instanceof IContainer) { - IContainer container = (IContainer) o; + if (o instanceof IContainer container) { if (!showLinkedResources && container.isLinked(IResource.CHECK_ANCESTORS)) { // just return an empty set of children return EMPTY; diff --git a/bundles/org.eclipse.ui.ide/extensions/org/eclipse/ui/dialogs/WizardNewFileCreationPage.java b/bundles/org.eclipse.ui.ide/extensions/org/eclipse/ui/dialogs/WizardNewFileCreationPage.java index cb4b8084194..8d97526689e 100644 --- a/bundles/org.eclipse.ui.ide/extensions/org/eclipse/ui/dialogs/WizardNewFileCreationPage.java +++ b/bundles/org.eclipse.ui.ide/extensions/org/eclipse/ui/dialogs/WizardNewFileCreationPage.java @@ -97,7 +97,7 @@ public class WizardNewFileCreationPage extends WizardPage implements Listener { private static final int SIZING_CONTAINER_GROUP_HEIGHT = 250; // the current resource selection - private IStructuredSelection currentSelection; + private final IStructuredSelection currentSelection; // cache of newly-created file private IFile newFile; @@ -379,8 +379,9 @@ public IFile createNewFile() { // only try to open } } - if (result == 2) + if (result == 2) { return null; + } } } } catch (CoreException | IOException e) { @@ -576,12 +577,13 @@ private void setupLinkedResourceTarget() { if (isFilteredByParent()) { URI existingLink = linkedResourceGroup.getLinkTargetURI(); boolean setDefaultLinkValue = false; - if (existingLink == null) + if (existingLink == null) { setDefaultLinkValue = true; - else { + } else { IPath path = URIUtil.toPath(existingLink); - if (path != null) + if (path != null) { setDefaultLinkValue = path.toPortableString().length() > 0; + } } if (setDefaultLinkValue) { @@ -813,18 +815,22 @@ protected boolean validatePage() { } private boolean isFilteredByParent() { - if ((linkedResourceGroup == null) || linkedResourceGroup.isEnabled()) + if ((linkedResourceGroup == null) || linkedResourceGroup.isEnabled()) { return false; + } IPath containerPath = resourceGroup.getContainerFullPath(); - if (containerPath == null) + if (containerPath == null) { return false; + } String resourceName = resourceGroup.getResource(); - if (resourceName == null) + if (resourceName == null) { return false; + } if (resourceName.length() > 0) { IPath newFilePath = containerPath.append(resourceName); - if (newFilePath.segmentCount() < 2) + if (newFilePath.segmentCount() < 2) { return false; + } IFile newFileHandle = createFileHandle(newFilePath); IWorkspace workspace = newFileHandle.getWorkspace(); return !workspace.validateFiltered(newFileHandle).isOK(); diff --git a/bundles/org.eclipse.ui.ide/extensions/org/eclipse/ui/dialogs/WizardNewFolderMainPage.java b/bundles/org.eclipse.ui.ide/extensions/org/eclipse/ui/dialogs/WizardNewFolderMainPage.java index 88ed9f4c018..065cfc03f92 100644 --- a/bundles/org.eclipse.ui.ide/extensions/org/eclipse/ui/dialogs/WizardNewFolderMainPage.java +++ b/bundles/org.eclipse.ui.ide/extensions/org/eclipse/ui/dialogs/WizardNewFolderMainPage.java @@ -98,7 +98,7 @@ public class WizardNewFolderMainPage extends WizardPage implements Listener { private static final int SIZING_CONTAINER_GROUP_HEIGHT = 250; - private IStructuredSelection currentSelection; + private final IStructuredSelection currentSelection; private IFolder newFolder; @@ -233,12 +233,13 @@ private void setupLinkedResourceTarget() { if (isFilteredByParent()) { URI existingLink = linkedResourceGroup.getLinkTargetURI(); boolean setDefaultLinkValue = false; - if (existingLink == null) + if (existingLink == null) { setDefaultLinkValue = true; - else { + } else { IPath path = URIUtil.toPath(existingLink); - if (path != null) + if (path != null) { setDefaultLinkValue = path.toPortableString().length() > 0; + } } if (setDefaultLinkValue) { @@ -362,8 +363,9 @@ protected IFolder createFolderHandle(IPath folderPath) { * @since 3.6 */ protected IContainer createContainerHandle(IPath containerPath) { - if (containerPath.segmentCount() == 1) + if (containerPath.segmentCount() == 1) { return IDEWorkbenchPlugin.getPluginWorkspace().getRoot().getProject(containerPath.segment(0)); + } return IDEWorkbenchPlugin.getPluginWorkspace().getRoot().getFolder(containerPath); } @@ -423,8 +425,9 @@ public IFolder createNewFolder() { if (result == Window.OK) { store.mkdir(0, new NullProgressMonitor()); } - if (result == 2) + if (result == 2) { return null; + } } } catch (CoreException e) { MessageDialog.open(MessageDialog.ERROR, getContainer().getShell(), @@ -646,8 +649,9 @@ private void handleRadioSelect() { private void handleEditFilterSelect() { ResourceFilterEditDialog dialog = new ResourceFilterEditDialog(getShell()); dialog.setFilters(filterList); - if (dialog.open() == Window.OK) + if (dialog.open() == Window.OK) { filterList = dialog.getFilters(); + } } /** @@ -764,20 +768,25 @@ protected boolean validatePage() { private boolean isFilteredByParent() { boolean createVirtualFolder = useVirtualFolder != null && useVirtualFolder.getSelection(); - if (createVirtualFolder) + if (createVirtualFolder) { return false; - if ((linkedResourceGroup == null) || linkedResourceGroup.isEnabled()) + } + if ((linkedResourceGroup == null) || linkedResourceGroup.isEnabled()) { return false; + } IPath containerPath = resourceGroup.getContainerFullPath(); - if (containerPath == null) + if (containerPath == null) { return false; + } String resourceName = resourceGroup.getResource(); - if (resourceName == null) + if (resourceName == null) { return false; + } if (resourceName.length() > 0) { IPath newFolderPath = containerPath.append(resourceName); - if (newFolderPath.segmentCount() < 2) + if (newFolderPath.segmentCount() < 2) { return false; + } IFolder newFolderHandle = createFolderHandle(newFolderPath); IWorkspace workspace = newFolderHandle.getWorkspace(); return !workspace.validateFiltered(newFolderHandle).isOK(); diff --git a/bundles/org.eclipse.ui.ide/extensions/org/eclipse/ui/dialogs/WizardNewLinkPage.java b/bundles/org.eclipse.ui.ide/extensions/org/eclipse/ui/dialogs/WizardNewLinkPage.java index 32f746ad47a..807f556b71e 100644 --- a/bundles/org.eclipse.ui.ide/extensions/org/eclipse/ui/dialogs/WizardNewLinkPage.java +++ b/bundles/org.eclipse.ui.ide/extensions/org/eclipse/ui/dialogs/WizardNewLinkPage.java @@ -59,7 +59,7 @@ public class WizardNewLinkPage extends WizardPage { private String initialLinkTarget; - private int type; + private final int type; private boolean createLink = false; diff --git a/bundles/org.eclipse.ui.ide/extensions/org/eclipse/ui/dialogs/WizardNewProjectCreationPage.java b/bundles/org.eclipse.ui.ide/extensions/org/eclipse/ui/dialogs/WizardNewProjectCreationPage.java index 878d78f0762..4cbaf35bb45 100644 --- a/bundles/org.eclipse.ui.ide/extensions/org/eclipse/ui/dialogs/WizardNewProjectCreationPage.java +++ b/bundles/org.eclipse.ui.ide/extensions/org/eclipse/ui/dialogs/WizardNewProjectCreationPage.java @@ -67,7 +67,7 @@ public class WizardNewProjectCreationPage extends WizardPage { // widgets Text projectNameField; - private Listener nameModifyListener = e -> { + private final Listener nameModifyListener = e -> { setLocationForSelection(); boolean valid = validatePage(); setPageComplete(valid); @@ -154,8 +154,9 @@ public void createControl(Composite parent) { */ public WorkingSetGroup createWorkingSetGroup(Composite composite, IStructuredSelection selection, String[] supportedWorkingSetTypes) { - if (workingSetGroup != null) + if (workingSetGroup != null) { return workingSetGroup; + } workingSetGroup = new WorkingSetGroup(composite, selection, supportedWorkingSetTypes); return workingSetGroup; } @@ -170,8 +171,9 @@ private IErrorMessageReporter getErrorReporter() { if (infoOnly) { setMessage(errorMessage, IStatus.INFO); setErrorMessage(null); - } else + } else { setErrorMessage(errorMessage); + } boolean valid = errorMessage == null; if (valid) { valid = validatePage(); diff --git a/bundles/org.eclipse.ui.ide/extensions/org/eclipse/ui/model/WorkbenchContentProvider.java b/bundles/org.eclipse.ui.ide/extensions/org/eclipse/ui/model/WorkbenchContentProvider.java index 1724e303e53..6271bf1eb1b 100644 --- a/bundles/org.eclipse.ui.ide/extensions/org/eclipse/ui/model/WorkbenchContentProvider.java +++ b/bundles/org.eclipse.ui.ide/extensions/org/eclipse/ui/model/WorkbenchContentProvider.java @@ -269,8 +269,7 @@ private void processDelta(IResourceDelta delta, Collection runnables) final boolean hasRename = numMovedFrom > 0 && numMovedTo > 0; Runnable addAndRemove = () -> { - if (viewer instanceof AbstractTreeViewer) { - AbstractTreeViewer treeViewer = (AbstractTreeViewer) viewer; + if (viewer instanceof AbstractTreeViewer treeViewer) { // Disable redraw until the operation is finished so we don't // get a flash of both the new and old item (in the case of // rename) diff --git a/bundles/org.eclipse.ui.ide/extensions/org/eclipse/ui/part/FileEditorInput.java b/bundles/org.eclipse.ui.ide/extensions/org/eclipse/ui/part/FileEditorInput.java index 53c1ea57ea1..662ace9a5a4 100644 --- a/bundles/org.eclipse.ui.ide/extensions/org/eclipse/ui/part/FileEditorInput.java +++ b/bundles/org.eclipse.ui.ide/extensions/org/eclipse/ui/part/FileEditorInput.java @@ -44,7 +44,7 @@ */ public class FileEditorInput extends PlatformObject implements IFileEditorInput, IPathEditorInput, IURIEditorInput, IPersistableElement { - private IFile file; + private final IFile file; /** * Return whether or not file is local. Only {@link IFile}s with a local value @@ -57,21 +57,25 @@ public class FileEditorInput extends PlatformObject implements IFileEditorInput, public static boolean isLocalFile(IFile file){ IPath location = file.getLocation(); - if (location != null) + if (location != null) { return true; + } //this is not a local file, so try to obtain a local file try { final URI locationURI = file.getLocationURI(); - if (locationURI == null) + if (locationURI == null) { return false; + } IFileStore store = EFS.getStore(locationURI); //first try to obtain a local file directly fo1r this store java.io.File localFile = store.toLocalFile(EFS.NONE, null); //if no local file is available, obtain a cached file - if (localFile == null) + if (localFile == null) { localFile = store.toLocalFile(EFS.CACHE, null); - if (localFile == null) + } + if (localFile == null) { return false; + } return true; } catch (CoreException e) { //this can only happen if the file system is not available for this scheme @@ -88,8 +92,9 @@ public static boolean isLocalFile(IFile file){ * @param file the file resource */ public FileEditorInput(IFile file) { - if (file == null) + if (file == null) { throw new IllegalArgumentException(); + } this.file = file; } @@ -110,10 +115,9 @@ public boolean equals(Object obj) { if (this == obj) { return true; } - if (!(obj instanceof IFileEditorInput)) { + if (!(obj instanceof IFileEditorInput other)) { return false; } - IFileEditorInput other = (IFileEditorInput) obj; return file.equals(other.getFile()); } @@ -175,21 +179,25 @@ public URI getURI() { @Override public IPath getPath() { IPath location = file.getLocation(); - if (location != null) + if (location != null) { return location; + } //this is not a local file, so try to obtain a local file try { final URI locationURI = file.getLocationURI(); - if (locationURI == null) + if (locationURI == null) { throw new IllegalArgumentException(); + } IFileStore store = EFS.getStore(locationURI); //first try to obtain a local file directly fo1r this store java.io.File localFile = store.toLocalFile(EFS.NONE, null); //if no local file is available, obtain a cached file - if (localFile == null) + if (localFile == null) { localFile = store.toLocalFile(EFS.CACHE, null); - if (localFile == null) + } + if (localFile == null) { throw new IllegalArgumentException(); + } return IPath.fromOSString(localFile.getAbsolutePath()); } catch (CoreException e) { //this can only happen if the file system is not available for this scheme diff --git a/bundles/org.eclipse.ui.ide/extensions/org/eclipse/ui/part/FileInPlaceEditorInput.java b/bundles/org.eclipse.ui.ide/extensions/org/eclipse/ui/part/FileInPlaceEditorInput.java index deaaa31b1e4..933b2957c1c 100644 --- a/bundles/org.eclipse.ui.ide/extensions/org/eclipse/ui/part/FileInPlaceEditorInput.java +++ b/bundles/org.eclipse.ui.ide/extensions/org/eclipse/ui/part/FileInPlaceEditorInput.java @@ -40,7 +40,7 @@ public class FileInPlaceEditorInput extends FileEditorInput implements * A resource listener to update the input and in-place * editor if the input's file resource changes. */ - private IResourceChangeListener resourceListener = new IResourceChangeListener() { + private final IResourceChangeListener resourceListener = new IResourceChangeListener() { @Override public void resourceChanged(IResourceChangeEvent event) { IResourceDelta mainDelta = event.getDelta(); diff --git a/bundles/org.eclipse.ui.ide/extensions/org/eclipse/ui/part/ResourceTransfer.java b/bundles/org.eclipse.ui.ide/extensions/org/eclipse/ui/part/ResourceTransfer.java index a671e221a21..d20d0cb4313 100644 --- a/bundles/org.eclipse.ui.ide/extensions/org/eclipse/ui/part/ResourceTransfer.java +++ b/bundles/org.eclipse.ui.ide/extensions/org/eclipse/ui/part/ResourceTransfer.java @@ -85,7 +85,7 @@ public class ResourceTransfer extends ByteArrayTransfer { private static final int TYPEID = registerType(TYPE_NAME); - private IWorkspace workspace = ResourcesPlugin.getWorkspace(); + private final IWorkspace workspace = ResourcesPlugin.getWorkspace(); /** * Creates a new transfer object. @@ -114,11 +114,11 @@ protected String[] getTypeNames() { @Override protected void javaToNative(Object data, TransferData transferData) { - if (!(data instanceof IResource[])) { + if (!(data instanceof IResource[] resources)) { return; } - IResource[] resources = (IResource[]) data; + /** * The resource serialization format is: * (int) number of resources diff --git a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/ide/FileStoreEditorInput.java b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/ide/FileStoreEditorInput.java index 22c567d83e1..e929d4f5078 100644 --- a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/ide/FileStoreEditorInput.java +++ b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/ide/FileStoreEditorInput.java @@ -62,7 +62,7 @@ public Object getParent(Object o) { } } - private IFileStore fileStore; + private final IFileStore fileStore; private WorkbenchAdapter workbenchAdapter = new WorkbenchAdapter(); /** @@ -109,11 +109,11 @@ public T getAdapter(Class adapter) { @Override public boolean equals(Object o) { - if (o == this) + if (o == this) { return true; + } - if (o instanceof FileStoreEditorInput) { - FileStoreEditorInput input = (FileStoreEditorInput) o; + if (o instanceof FileStoreEditorInput input) { return fileStore.equals(input.fileStore); } diff --git a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/ide/FileStoreEditorInputFactory.java b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/ide/FileStoreEditorInputFactory.java index d0570a6588c..39f65049f44 100644 --- a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/ide/FileStoreEditorInputFactory.java +++ b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/ide/FileStoreEditorInputFactory.java @@ -69,8 +69,9 @@ static void saveState(IMemento memento, FileStoreEditorInput input) { public IAdaptable createElement(IMemento memento) { // Get the file name. String uriString = memento.getString(TAG_URI); - if (uriString == null) + if (uriString == null) { return null; + } URI uri; try { diff --git a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/ide/IDE.java b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/ide/IDE.java index 72a92d3641a..6ca50e0db5b 100644 --- a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/ide/IDE.java +++ b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/ide/IDE.java @@ -408,8 +408,9 @@ public static IEditorPart openEditor(IWorkbenchPage page, URI uri, */ private static IEditorInput getEditorInput(IFileStore fileStore) { IFile workspaceFile = getWorkspaceFile(fileStore); - if (workspaceFile != null) + if (workspaceFile != null) { return new FileEditorInput(workspaceFile); + } return new FileStoreEditorInput(fileStore); } @@ -426,8 +427,9 @@ private static IFile getWorkspaceFile(IFileStore fileStore) { IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot(); IFile[] files = root.findFilesForLocationURI(fileStore.toURI()); files = filterNonExistentFiles(files); - if (files == null || files.length == 0) + if (files == null || files.length == 0) { return null; + } // for now only return the first file return files[0]; @@ -442,14 +444,16 @@ private static IFile getWorkspaceFile(IFileStore fileStore) { * @return The filtered array */ private static IFile[] filterNonExistentFiles(IFile[] files) { - if (files == null) + if (files == null) { return null; + } int length = files.length; ArrayList existentFiles = new ArrayList<>(length); for (int i = 0; i < length; i++) { - if (files[i].exists()) + if (files[i].exists()) { existentFiles.add(files[i]); + } } return existentFiles.toArray(new IFile[existentFiles.size()]); } @@ -1362,15 +1366,18 @@ public static IEditorPart openEditorOnFileStore(IWorkbenchPage page, IFileStore * @since 3.6 */ public static IEditorPart openInternalEditorOnFileStore(IWorkbenchPage page, IFileStore fileStore) throws PartInitException { - if (page == null) + if (page == null) { throw new IllegalArgumentException(); - if (fileStore == null) + } + if (fileStore == null) { throw new IllegalArgumentException(); + } IEditorInput input = getEditorInput(fileStore); String name = fileStore.fetchInfo().getName(); - if (name == null) + if (name == null) { throw new IllegalArgumentException(); + } IContentType[] contentTypes = null; InputStream is = null; @@ -1394,8 +1401,9 @@ public static IEditorPart openInternalEditorOnFileStore(IWorkbenchPage page, IFi for (IContentType contentType : contentTypes) { IEditorDescriptor editorDesc = editorReg.getDefaultEditor(name, contentType); editorDesc = overrideDefaultEditorAssociation(input, contentType, editorDesc); - if ((editorDesc != null) && (editorDesc.isInternal())) + if ((editorDesc != null) && (editorDesc.isInternal())) { return page.openEditor(input, editorDesc.getId()); + } } } @@ -1404,15 +1412,17 @@ public static IEditorPart openInternalEditorOnFileStore(IWorkbenchPage page, IFi if (editors != null) { editors = overrideEditorAssociations(input, null, editors); for (IEditorDescriptor editor : editors) { - if ((editor != null) && (editor.isInternal())) + if ((editor != null) && (editor.isInternal())) { return page.openEditor(input, editor.getId()); + } } } // fallback to the default text editor IEditorDescriptor textEditor = editorReg.findEditor(IDEWorkbenchPlugin.DEFAULT_TEXT_EDITOR_ID); - if (textEditor == null) + if (textEditor == null) { throw new PartInitException(IDEWorkbenchMessages.IDE_noFileEditorFound); + } return page.openEditor(input, textEditor.getId()); } @@ -1449,8 +1459,9 @@ public void run() { if (w == null) { IWorkbenchWindow[] windows = PlatformUI.getWorkbench() .getWorkbenchWindows(); - if (windows.length > 0) + if (windows.length > 0) { w = windows[0]; + } } if (w != null) { result[0] = PlatformUI.getWorkbench().saveAll(w, w, @@ -1772,8 +1783,7 @@ private static boolean isIgnoredStatus(IStatus status, if (ignoreModelProviderIds == null) { return false; } - if (status instanceof ModelStatus) { - ModelStatus ms = (ModelStatus) status; + if (status instanceof ModelStatus ms) { for (String id : ignoreModelProviderIds) { if (ms.getModelProviderId().equals(id)) { return true; @@ -1803,8 +1813,9 @@ private static boolean isIgnoredStatus(IStatus status, * @since 3.5 */ public static IEditorReference[] openEditors(IWorkbenchPage page, IFile[] inputs) throws MultiPartInitException { - if ((page == null) || (inputs == null)) + if ((page == null) || (inputs == null)) { throw new IllegalArgumentException(); + } String[] editorDescriptions = new String[inputs.length]; IEditorInput[] editorInputs = new IEditorInput[inputs.length]; diff --git a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/ide/ResourceSaveableFilter.java b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/ide/ResourceSaveableFilter.java index 7c11c1461d2..2a23b5b3225 100644 --- a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/ide/ResourceSaveableFilter.java +++ b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/ide/ResourceSaveableFilter.java @@ -53,8 +53,7 @@ public boolean select(Saveable saveable, IWorkbenchPart[] containingParts) { } // For backwards compatibility, we need to check the parts for (IWorkbenchPart workbenchPart : containingParts) { - if (workbenchPart instanceof IEditorPart) { - IEditorPart editorPart = (IEditorPart) workbenchPart; + if (workbenchPart instanceof IEditorPart editorPart) { if (isEditingDescendantOf(editorPart)) { return true; } diff --git a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/ide/dialogs/AbstractEncodingFieldEditor.java b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/ide/dialogs/AbstractEncodingFieldEditor.java index 93edc99bd3d..79dc64d2c5d 100644 --- a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/ide/dialogs/AbstractEncodingFieldEditor.java +++ b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/ide/dialogs/AbstractEncodingFieldEditor.java @@ -250,14 +250,18 @@ public void keyReleased(KeyEvent e) { @Override public void setEnabled(boolean enabled, Composite parent) { - if (container != null) + if (container != null) { container.setEnabled(enabled); - if (defaultEncodingButton != null) + } + if (defaultEncodingButton != null) { defaultEncodingButton.setEnabled(enabled); - if (otherEncodingButton != null) + } + if (otherEncodingButton != null) { otherEncodingButton.setEnabled(enabled); - if (encodingCombo != null) + } + if (encodingCombo != null) { encodingCombo.setEnabled(enabled && otherEncodingButton.getSelection()); + } } diff --git a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/ide/dialogs/ImportTypeDialog.java b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/ide/dialogs/ImportTypeDialog.java index 5bd6216df36..fb99067b3bb 100644 --- a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/ide/dialogs/ImportTypeDialog.java +++ b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/ide/dialogs/ImportTypeDialog.java @@ -88,8 +88,8 @@ public class ImportTypeDialog extends TrayDialog { private Button moveButton = null; - private int operationMask; - private String preferredVariable; + private final int operationMask; + private final String preferredVariable; private IResource receivingResource = null; private Button shadowCopyButton = null; private String variable = null; @@ -138,19 +138,22 @@ private ImportTypeDialog(Shell parentShell, int operationMask, String preferredV this.operationMask = operationMask; currentSelection = 0; String tmp = readContextPreference(IDEInternalPreferences.IMPORT_FILES_AND_FOLDERS_TYPE); - if (tmp.length() > 0) + if (tmp.length() > 0) { currentSelection = Integer.parseInt(tmp); + } currentSelection = currentSelection & operationMask; if (currentSelection == 0) { - if (hasFlag(IMPORT_COPY)) + if (hasFlag(IMPORT_COPY)) { currentSelection = IMPORT_COPY; - else + } else { currentSelection = IMPORT_MOVE; + } } IPreferenceStore store = IDEWorkbenchPlugin.getDefault().getPreferenceStore(); - if (store.getBoolean(IDEInternalPreferences.IMPORT_FILES_AND_FOLDERS_RELATIVE)) + if (store.getBoolean(IDEInternalPreferences.IMPORT_FILES_AND_FOLDERS_RELATIVE)) { variable = preferredVariable; + } } @Override @@ -191,22 +194,27 @@ private String readContextPreference(String key) { for (String keyPair : value.split(":")) { //$NON-NLS-1$ String [] element = keyPair.split(","); //$NON-NLS-1$ if (element.length == 2) { - if (element[0].equals(Integer.toString(operationMask))) + if (element[0].equals(Integer.toString(operationMask))) { return element[1]; + } } } return ""; //$NON-NLS-1$ } private void refreshSelection() { - if (copyButton != null) + if (copyButton != null) { copyButton.setSelection(currentSelection == IMPORT_COPY); - if (shadowCopyButton != null) + } + if (shadowCopyButton != null) { shadowCopyButton.setSelection(currentSelection == IMPORT_VIRTUAL_FOLDERS_AND_LINKS); - if (linkButton != null) + } + if (linkButton != null) { linkButton.setSelection(currentSelection == IMPORT_LINK); - if (moveButton != null) + } + if (moveButton != null) { moveButton.setSelection(currentSelection == IMPORT_MOVE); + } if (relativePathVariableGroup != null) { relativePathVariableGroup.setEnabled((currentSelection & (IMPORT_VIRTUAL_FOLDERS_AND_LINKS | IMPORT_LINK)) != 0); } @@ -218,21 +226,23 @@ private void writeContextPreference(String key, String value) { String [] keyPairs = oldValue.split(":"); //$NON-NLS-1$ boolean found = false; for (int i = 0; i < keyPairs.length; i++) { - if (i > 0) + if (i > 0) { buffer.append(":"); //$NON-NLS-1$ + } String [] element = keyPairs[i].split(","); //$NON-NLS-1$ if (element.length == 2) { if (element[0].equals(Integer.toString(operationMask))) { buffer.append(element[0] + "," + value); //$NON-NLS-1$ found = true; - } - else + } else { buffer.append(keyPairs[i]); + } } } if (!found) { - if (buffer.length() > 0) + if (buffer.length() > 0) { buffer.append(":"); //$NON-NLS-1$ + } buffer.append(operationMask + "," + value); //$NON-NLS-1$ } String newValue = buffer.toString(); @@ -264,8 +274,9 @@ protected void configureShell(Shell shell) { protected Control createDialogArea(Composite parent) { boolean linkIsOnlyChoice = hasFlag(IMPORT_LINK) && !(hasFlag(IMPORT_COPY | IMPORT_MOVE) || (hasFlag(IMPORT_VIRTUAL_FOLDERS_AND_LINKS) && !hasFlag(IMPORT_FILES_ONLY))); - if (!linkIsOnlyChoice) + if (!linkIsOnlyChoice) { createMessageArea(parent); + } Composite composite = new Composite(parent, 0); GridData gridData = new GridData(SWT.FILL, SWT.FILL, true, true); composite.setLayoutData(gridData); @@ -379,10 +390,11 @@ public String getVariable() { relativePathVariableGroup.createContents(variableGroup); relativePathVariableGroup.setSelection(variable != null); - if (variable != null) + if (variable != null) { relativePathVariableGroup.selectVariable(variable); - else + } else { relativePathVariableGroup.selectVariable(preferredVariable); + } } if (linkIsOnlyChoice) { @@ -450,8 +462,9 @@ protected Control createMessageArea(Composite parent) { */ private static boolean areOnlyFiles(IResource[] resources) { for (IResource resource : resources) { - if (resource.getType() != IResource.FILE) + if (resource.getType() != IResource.FILE) { return false; + } } return true; } @@ -464,8 +477,9 @@ private static boolean areOnlyFiles(IResource[] resources) { private static boolean areOnlyFiles(String[] names) { for (String name : names) { File file = new File(name); - if (file.exists() && !file.isFile()) + if (file.exists() && !file.isFile()) { return false; + } } return true; } @@ -482,10 +496,12 @@ private static boolean areOnlyFiles(String[] names) { */ private static int selectAppropriateMask(int dropOperation, IResource[] resources, IContainer target) { int mask = ImportTypeDialog.IMPORT_VIRTUAL_FOLDERS_AND_LINKS | ImportTypeDialog.IMPORT_LINK; - if (!target.isVirtual() && (dropOperation != DND.DROP_LINK)) + if (!target.isVirtual() && (dropOperation != DND.DROP_LINK)) { mask |= ImportTypeDialog.IMPORT_COPY; - if (areOnlyFiles(resources)) + } + if (areOnlyFiles(resources)) { mask |= ImportTypeDialog.IMPORT_FILES_ONLY; + } return mask; } @@ -501,10 +517,12 @@ private static int selectAppropriateMask(int dropOperation, IResource[] resource */ private static int selectAppropriateMask(int dropOperation, String[] names, IContainer target) { int mask = ImportTypeDialog.IMPORT_VIRTUAL_FOLDERS_AND_LINKS | ImportTypeDialog.IMPORT_LINK; - if (!target.isVirtual() && (dropOperation != DND.DROP_LINK)) + if (!target.isVirtual() && (dropOperation != DND.DROP_LINK)) { mask |= ImportTypeDialog.IMPORT_COPY; - if (areOnlyFiles(names)) + } + if (areOnlyFiles(names)) { mask |= ImportTypeDialog.IMPORT_FILES_ONLY; + } return mask; } } diff --git a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/ide/dialogs/PathVariableSelectionDialog.java b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/ide/dialogs/PathVariableSelectionDialog.java index 0c2498f6b00..432a27a047e 100644 --- a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/ide/dialogs/PathVariableSelectionDialog.java +++ b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/ide/dialogs/PathVariableSelectionDialog.java @@ -60,11 +60,11 @@ public final class PathVariableSelectionDialog extends SelectionDialog { private static final int EXTEND_ID = IDialogConstants.CLIENT_ID + 1; - private PathVariablesGroup pathVariablesGroup; + private final PathVariablesGroup pathVariablesGroup; private IResource currentResource = null; - private int variableType; + private final int variableType; /** * Creates a path variable selection dialog. @@ -101,9 +101,10 @@ protected void buttonPressed(int buttonId) { // XXX This only works for variables that refer to local file // system locations IPath selectionPath = selection.path; - if (currentResource != null) + if (currentResource != null) { selectionPath = URIUtil.toPath(currentResource.getPathVariableManager() .resolveURI(URIUtil.toURI(selectionPath))); + } try { dialog.setInput(EFS.getStore(URIUtil.toURI(selectionPath))); } catch (CoreException e) { @@ -182,8 +183,9 @@ private void setExtensionResult( PathVariablesGroup.PathVariableElement variable, IFileStore extensionFile) { IPath extensionPath = IPath.fromOSString(extensionFile.toString()); IPath selectionPath = variable.path; - if (currentResource != null) + if (currentResource != null) { selectionPath = URIUtil.toPath(currentResource.getPathVariableManager().resolveURI(URIUtil.toURI(selectionPath))); + } int matchCount = extensionPath.matchingFirstSegments(selectionPath); IPath resultPath = IPath.fromOSString(variable.name); @@ -206,8 +208,9 @@ private void updateExtendButtonState() { } if (selection.length == 1) { IPath selectionPath = selection[0].path; - if (currentResource != null) + if (currentResource != null) { selectionPath = URIUtil.toPath(currentResource.getPathVariableManager().resolveURI(URIUtil.toURI(selectionPath))); + } IFileInfo info = IDEResourceInfoUtils.getFileInfo(selectionPath); // IPathVariable pathVariable = null; // if (currentResource != null) diff --git a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/ide/dialogs/ResourceEncodingFieldEditor.java b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/ide/dialogs/ResourceEncodingFieldEditor.java index a938b816331..cc94dc6c5a0 100644 --- a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/ide/dialogs/ResourceEncodingFieldEditor.java +++ b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/ide/dialogs/ResourceEncodingFieldEditor.java @@ -161,11 +161,13 @@ private boolean getStoredSeparateDerivedEncodingsValue() { // String path = projectName + IPath.SEPARATOR + ResourcesPlugin.PI_RESOURCES; // return node.nodeExists(path) ? node.node(path).getBoolean(ResourcesPlugin.PREF_SEPARATE_DERIVED_ENCODINGS, false) : false; // for now, take the long way - if (!node.nodeExists(projectName)) + if (!node.nodeExists(projectName)) { return DEFAULT_PREF_SEPARATE_DERIVED_ENCODINGS; + } node = node.node(projectName); - if (!node.nodeExists(ResourcesPlugin.PI_RESOURCES)) + if (!node.nodeExists(ResourcesPlugin.PI_RESOURCES)) { return DEFAULT_PREF_SEPARATE_DERIVED_ENCODINGS; + } node = node.node(ResourcesPlugin.PI_RESOURCES); return node.getBoolean( ResourcesPlugin.PREF_SEPARATE_DERIVED_ENCODINGS, @@ -243,10 +245,11 @@ protected int getShellStyle() { Preferences prefs = new ProjectScope((IProject) resource).getNode(ResourcesPlugin.PI_RESOURCES); boolean newValue = !getStoredSeparateDerivedEncodingsValue(); // Remove the pref if it's the default, otherwise store it. - if (newValue == DEFAULT_PREF_SEPARATE_DERIVED_ENCODINGS) + if (newValue == DEFAULT_PREF_SEPARATE_DERIVED_ENCODINGS) { prefs.remove(ResourcesPlugin.PREF_SEPARATE_DERIVED_ENCODINGS); - else + } else { prefs.putBoolean(ResourcesPlugin.PREF_SEPARATE_DERIVED_ENCODINGS, newValue); + } prefs.flush(); } return Status.OK_STATUS; @@ -291,8 +294,9 @@ public void loadDefault() { @Override protected void doLoadDefault() { super.doLoadDefault(); - if (separateDerivedEncodingsButton != null) + if (separateDerivedEncodingsButton != null) { separateDerivedEncodingsButton.setSelection(DEFAULT_PREF_SEPARATE_DERIVED_ENCODINGS); + } } @Override diff --git a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/ide/dialogs/ResourceTreeAndListGroup.java b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/ide/dialogs/ResourceTreeAndListGroup.java index 89a111f1e4c..8a6fae213b8 100644 --- a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/ide/dialogs/ResourceTreeAndListGroup.java +++ b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/ide/dialogs/ResourceTreeAndListGroup.java @@ -124,9 +124,9 @@ public void treeExpanded(TreeExpansionEvent event) { } } - private CheckListener checkListener = new CheckListener(); - private SelectionListener selectionListener = new SelectionListener(); - private TreeListener treeListener = new TreeListener(); + private final CheckListener checkListener = new CheckListener(); + private final SelectionListener selectionListener = new SelectionListener(); + private final TreeListener treeListener = new TreeListener(); private Object root; private Object currentTreeSelection; @@ -520,10 +520,12 @@ public boolean isEveryItemChecked() { //Iterate through the children of the root as the root is not in the store for (Object element : treeContentProvider.getChildren(root)) { if (!whiteCheckedTreeItems.contains(element)) { - if (!treeViewer.getGrayed(element)) + if (!treeViewer.getGrayed(element)) { return false; - if (!isEveryChildrenChecked(element)) + } + if (!isEveryChildrenChecked(element)) { return false; + } } } return true; @@ -540,15 +542,18 @@ private boolean isEveryChildrenChecked(Object treeElement) { List checked = checkedStateStore.get(treeElement); if (checked != null && (!checked.isEmpty())) { Object[] listItems = listContentProvider.getElements(treeElement); - if (listItems.length != checked.size()) + if (listItems.length != checked.size()) { return false; + } } for (Object element : treeContentProvider.getChildren(treeElement)) { if (!whiteCheckedTreeItems.contains(element)) { - if (!treeViewer.getGrayed(element)) + if (!treeViewer.getGrayed(element)) { return false; - if (!isEveryChildrenChecked(element)) + } + if (!isEveryChildrenChecked(element)) { return false; + } } } return true; diff --git a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/ide/undo/AbstractCopyOrMoveResourcesOperation.java b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/ide/undo/AbstractCopyOrMoveResourcesOperation.java index 7e3fc45925f..5a3671c5a4e 100644 --- a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/ide/undo/AbstractCopyOrMoveResourcesOperation.java +++ b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/ide/undo/AbstractCopyOrMoveResourcesOperation.java @@ -67,13 +67,15 @@ abstract class AbstractCopyOrMoveResourcesOperation extends IPath[] destinationPaths, String label) { super(resources, label); // Check for null arguments - if (this.resources == null || destinationPaths == null) + if (this.resources == null || destinationPaths == null) { throw new IllegalArgumentException("The resource and destination paths may not be null"); //$NON-NLS-1$ + } // Special case to flag descendants. Note this would fail on the next check // anyway, so we are first giving a more specific explanation. // See bug #176764 - if (this.resources.length != resources.length) + if (this.resources.length != resources.length) { throw new IllegalArgumentException("The resource list contained descendants that cannot be moved to separate destination paths"); //$NON-NLS-1$ + } // Check for destination paths corresponding for each resource if (this.resources.length != destinationPaths.length) { throw new IllegalArgumentException("The resource and destination paths must be the same length"); //$NON-NLS-1$ diff --git a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/ide/undo/AbstractResourcesOperation.java b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/ide/undo/AbstractResourcesOperation.java index 7e5f92d0f19..27275d03466 100644 --- a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/ide/undo/AbstractResourcesOperation.java +++ b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/ide/undo/AbstractResourcesOperation.java @@ -316,8 +316,9 @@ protected void setTargetResources(IResource[] targetResources) { Set subResources = new HashSet<>(); for (IResource subResource : targetResources) { for (IResource superResource : targetResources) { - if (isDescendantOf(subResource, superResource) && !subResources.contains(subResource)) + if (isDescendantOf(subResource, superResource) && !subResources.contains(subResource)) { subResources.add(subResource); + } } } IResource[] nestedResourcesRemoved = new IResource[targetResources.length - subResources.size()]; diff --git a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/ide/undo/CopyProjectOperation.java b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/ide/undo/CopyProjectOperation.java index 5dbc26951e6..5e80298f0fc 100644 --- a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/ide/undo/CopyProjectOperation.java +++ b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/ide/undo/CopyProjectOperation.java @@ -51,7 +51,7 @@ public class CopyProjectOperation extends AbstractCopyOrMoveResourcesOperation { private URI projectLocation; - private IProject originalProject; + private final IProject originalProject; private IResourceSnapshot originalProjectDescription; diff --git a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/ide/undo/UpdateMarkersOperation.java b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/ide/undo/UpdateMarkersOperation.java index 8c5b35109a0..27165228bb6 100644 --- a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/ide/undo/UpdateMarkersOperation.java +++ b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/ide/undo/UpdateMarkersOperation.java @@ -38,7 +38,7 @@ public class UpdateMarkersOperation extends AbstractMarkersOperation { // Whether attributes should be merged with existing attributes when // updated, or considered to be complete replacements. - private boolean mergeAttributes; + private final boolean mergeAttributes; /** * Create an undoable operation that can update the specified marker with diff --git a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/ide/undo/WorkspaceUndoUtil.java b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/ide/undo/WorkspaceUndoUtil.java index 971f91d019c..7174bf49cb8 100644 --- a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/ide/undo/WorkspaceUndoUtil.java +++ b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/ide/undo/WorkspaceUndoUtil.java @@ -339,8 +339,9 @@ static IResourceSnapshot[] copy(IResource[] resources, IPat && !source.isVirtual() && !existing.isVirtual())) { IResource[] children = ((IContainer) source).members(); // copy only linked resource children (267173) - if (source.isLinked() && source.getLocation().equals(existing.getLocation())) + if (source.isLinked() && source.getLocation().equals(existing.getLocation())) { children = filterNonLinkedResources(children); + } IResourceSnapshot[] overwritten = copy(children, destinationPath, resourcesAtDestination, iterationProgress, uiInfo, false, @@ -366,11 +367,13 @@ static IResourceSnapshot[] copy(IResource[] resources, IPat createVirtual, createLinks, relativeToVariable))); } - } else + } else { folder.createLink(createRelativePath(source.getLocationURI(), relativeToVariable, folder), 0, iterationProgress.split(100)); - } else + } + } else { source.copy(destinationPath, IResource.SHALLOW, iterationProgress.split(100)); + } // Record the copy resourcesAtDestination.add(getWorkspace().getRoot().findMember(destinationPath)); overwrittenResources.addAll(Arrays.asList(deleted)); @@ -402,10 +405,11 @@ static IResourceSnapshot[] copy(IResource[] resources, IPat resourcesAtDestination, iterationProgress.split(99), uiInfo, false, createVirtual, createLinks, relativeToVariable))); } - } else + } else { folder.createLink( createRelativePath(source.getLocationURI(), relativeToVariable, folder), 0, iterationProgress.split(100)); + } } resourcesAtDestination.add(getWorkspace().getRoot() .findMember(destinationPath)); @@ -457,13 +461,15 @@ static IResourceSnapshot[] copy(IResource[] resources, IPat resourcesAtDestination, iterationProgress.split(99), uiInfo, false, createVirtual, createLinks, relativeToVariable))); } - } else + } else { folder.createLink( createRelativePath(source.getLocationURI(), relativeToVariable, folder), 0, iterationProgress.split(100)); + } } - } else + } else { source.copy(destinationPath, IResource.SHALLOW, iterationProgress.split(100)); + } // Record the copy. If we had to generate a parent // folder, that should be recorded as part of the copy if (generatedParent == null) { @@ -487,8 +493,9 @@ static IResourceSnapshot[] copy(IResource[] resources, IPat * @return an URI that was made relative to a variable */ static private URI createRelativePath(URI locationURI, String relativeVariable, IResource resource) { - if (relativeVariable == null) + if (relativeVariable == null) { return locationURI; + } IPath location = URIUtil.toPath(locationURI); IPath result; try { @@ -556,8 +563,9 @@ static IResourceSnapshot[] move(IResource[] resources, IPat if (resource.isLinked() == existing.isLinked()) { IResource[] children = ((IContainer) resource).members(); // move only linked resource children (267173) - if (resource.isLinked() && resource.getLocation().equals(existing.getLocation())) + if (resource.isLinked() && resource.getLocation().equals(existing.getLocation())) { children = filterNonLinkedResources(children); + } IResourceSnapshot[] overwritten = move(children, destinationPath, resourcesAtDestination, reverseDestinations, iterationProgress.split(90), uiInfo, false); @@ -642,8 +650,9 @@ static IResourceSnapshot[] move(IResource[] resources, IPat private static IResource[] filterNonLinkedResources(IResource[] resources) { List result = new ArrayList<>(); for (IResource resource : resources) { - if (resource.isLinked()) + if (resource.isLinked()) { result.add(resource); + } } return result.toArray(new IResource[0]); } @@ -749,10 +758,9 @@ static IResourceSnapshot delete(IResource resourceToDelete, private static IResourceSnapshot copyOverExistingResource( IResource source, IResource existing, IProgressMonitor monitor, IAdaptable uiInfo, boolean deleteSourceFile) throws CoreException { - if (!(source instanceof IFile && existing instanceof IFile)) { + if (!(source instanceof IFile file && existing instanceof IFile)) { return null; } - IFile file = (IFile) source; IFile existingFile = (IFile) existing; SubMonitor subMonitor = SubMonitor.convert(monitor, UndoMessages.AbstractResourcesOperation_CopyingResourcesProgress, deleteSourceFile ? 3 : 2); diff --git a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/ChooseWorkspaceDialog.java b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/ChooseWorkspaceDialog.java index e8807e90963..78701c3ece1 100644 --- a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/ChooseWorkspaceDialog.java +++ b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/ChooseWorkspaceDialog.java @@ -89,7 +89,7 @@ public class ChooseWorkspaceDialog extends TitleAreaDialog { private static final String DIALOG_SETTINGS_SECTION = "ChooseWorkspaceDialogSettings"; //$NON-NLS-1$ - private ChooseWorkspaceData launchData; + private final ChooseWorkspaceData launchData; private Combo pathCombo; diff --git a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/ChooseWorkspaceWithSettingsDialog.java b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/ChooseWorkspaceWithSettingsDialog.java index accc45df991..0955fae4425 100644 --- a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/ChooseWorkspaceWithSettingsDialog.java +++ b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/ChooseWorkspaceWithSettingsDialog.java @@ -82,7 +82,7 @@ public class ChooseWorkspaceWithSettingsDialog extends ChooseWorkspaceDialog { private static final String ATT_ID = "id"; //$NON-NLS-1$ private static final String ATT_HELP_CONTEXT = "helpContext"; //$NON-NLS-1$ - private Collection selectedSettings = new HashSet<>(); + private final Collection selectedSettings = new HashSet<>(); /** * Open a new instance of the receiver. @@ -151,8 +151,9 @@ public void expansionStateChanging(ExpansionEvent e) { Composite sectionClient = toolkit.createComposite(copySettingsExpandable); sectionClient.setBackground(workArea.getBackground()); - if (createButtons(toolkit, sectionClient)) + if (createButtons(toolkit, sectionClient)) { copySettingsExpandable.setExpanded(true); + } copySettingsExpandable.setClient(sectionClient); @@ -189,8 +190,9 @@ private boolean createButtons(FormToolkit toolkit, Composite sectionClient) { String helpId = settingsTransfer.getAttribute(ATT_HELP_CONTEXT); - if (helpId != null) + if (helpId != null) { PlatformUI.getWorkbench().getHelpSystem().setHelp(button, helpId); + } if (enabledSettings != null && enabledSettings.length > 0) { @@ -241,8 +243,9 @@ private void toggleDecoForSettingsImportButtons(Button button, ControlDecoration */ private String[] getEnabledSettings(IDialogSettings section) { - if (section == null) + if (section == null) { return null; + } return section.getArray(ENABLED_TRANSFERS); @@ -290,9 +293,10 @@ private void saveSettings(String[] selectionIDs) { .getDialogSettings(); IDialogSettings settings = dialogSettings.getSection(WORKBENCH_SETTINGS); - if (settings == null) + if (settings == null) { settings = dialogSettings .addNewSection(WORKBENCH_SETTINGS); + } settings.put(ENABLED_TRANSFERS, selectionIDs); } @@ -335,8 +339,9 @@ public void handleException(Throwable exception) { } }); - if (exceptions[0] != null) + if (exceptions[0] != null) { return exceptions[0]; + } return Status.OK_STATUS; diff --git a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/ContentTypeDecorator.java b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/ContentTypeDecorator.java index b9791731247..158aa95469a 100644 --- a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/ContentTypeDecorator.java +++ b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/ContentTypeDecorator.java @@ -42,19 +42,22 @@ public class ContentTypeDecorator implements ILightweightLabelDecorator { @Override public void decorate(Object element, IDecoration decoration) { - if (!(element instanceof IFile)) + if (!(element instanceof IFile)) { return; + } IWorkbench workbench = PlatformUI.getWorkbench(); - if (workbench.isClosing()) + if (workbench.isClosing()) { return; + } IFile file = (IFile) element; ImageDescriptor image = null; if (hasEditorAssociationOverrides()) { IEditorDescriptor d = IDE.getDefaultEditor(file); - if (d != null) + if (d != null) { image = d.getImageDescriptor(); + } } else { IContentDescription contentDescription= null; try { @@ -81,13 +84,15 @@ public void decorate(Object element, IDecoration decoration) { // add the image descriptor as a session property so that it will be // picked up by the workbench label provider upon the next update. try { - if (file.getSessionProperty(WorkbenchFile.IMAGE_CACHE_KEY) != image) + if (file.getSessionProperty(WorkbenchFile.IMAGE_CACHE_KEY) != image) { file.setSessionProperty(WorkbenchFile.IMAGE_CACHE_KEY, image); + } } catch (CoreException e) { // ignore - not being able to cache the image is not fatal } - if (image != null) + if (image != null) { decoration.addOverlay(image); + } } @Override diff --git a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/DirectoryProposalContentAssist.java b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/DirectoryProposalContentAssist.java index f37dd937efd..8c450506f7c 100644 --- a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/DirectoryProposalContentAssist.java +++ b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/DirectoryProposalContentAssist.java @@ -158,8 +158,8 @@ public void openProposalPopup() { private static class DirectoryProposalAutoCompleteField { - private FileNameSubstringMatchContentProposalProvider proposalProvider; - private OpenableContentProposalAdapter adapter; + private final FileNameSubstringMatchContentProposalProvider proposalProvider; + private final OpenableContentProposalAdapter adapter; public DirectoryProposalAutoCompleteField(Control control, IControlContentAdapter controlContentAdapter) { proposalProvider = new FileNameSubstringMatchContentProposalProvider(); @@ -204,7 +204,7 @@ public void refreshProposals(List proposals, boolean openProposalPopup) * after the proposals have been updated by the asynchronous job. */ private boolean popupActivated = false; - private List> proposalUpdateFutures = Collections.synchronizedList(new ArrayList<>()); + private final List> proposalUpdateFutures = Collections.synchronizedList(new ArrayList<>()); /** * Applies auto-completion to a Combo that is intended to be used to choose a diff --git a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/EditorAreaDropAdapter.java b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/EditorAreaDropAdapter.java index 70f46940d7d..46b5fafefab 100644 --- a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/EditorAreaDropAdapter.java +++ b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/EditorAreaDropAdapter.java @@ -48,7 +48,7 @@ * and ResourceTransfer. */ public class EditorAreaDropAdapter extends DropTargetAdapter { - private IWorkbenchWindow window; + private final IWorkbenchWindow window; /** * Constructs a new EditorAreaDropAdapter. @@ -115,11 +115,10 @@ else if (MarkerTransfer.getInstance().isSupportedType(event.currentDataType)) { else if (ResourceTransfer.getInstance().isSupportedType(event.currentDataType)) { Assert.isTrue(event.data instanceof IResource[]); for (IResource resource : (IResource[]) event.data) { - if (resource instanceof IFile) { - IFile file = (IFile) resource; - - if (!file.isPhantom()) + if (resource instanceof IFile file) { + if (!file.isPhantom()) { openNonExternalEditor(page, file); + } } } } diff --git a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/EditorAssociationOverrideDescriptor.java b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/EditorAssociationOverrideDescriptor.java index 21ac6064710..9d5288740c4 100644 --- a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/EditorAssociationOverrideDescriptor.java +++ b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/EditorAssociationOverrideDescriptor.java @@ -46,7 +46,7 @@ public final class EditorAssociationOverrideDescriptor { private static final String DESCRIPTION_ATTRIBUTE= "description"; //$NON-NLS-1$ private static final String CLASS_ATTRIBUTE= "class"; //$NON-NLS-1$ - private IConfigurationElement fElement; + private final IConfigurationElement fElement; /** @@ -102,8 +102,9 @@ public void handleException(Throwable ex) { SafeRunner.run(code); - if (exception[0] == null) + if (exception[0] == null) { return result[0]; + } throw new CoreException(new Status(IStatus.ERROR, IDEWorkbenchPlugin.IDE_WORKBENCH, IStatus.OK, message, exception[0])); } @@ -139,8 +140,9 @@ public String getDescription() { @Override public boolean equals(Object obj) { - if (obj == null || !obj.getClass().equals(this.getClass()) || getId() == null) + if (obj == null || !obj.getClass().equals(this.getClass()) || getId() == null) { return false; + } return getId().equals(((EditorAssociationOverrideDescriptor)obj).getId()); } diff --git a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/IDESelectionConversionService.java b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/IDESelectionConversionService.java index c8b541eaf17..86e61ef2cd4 100644 --- a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/IDESelectionConversionService.java +++ b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/IDESelectionConversionService.java @@ -53,8 +53,9 @@ public IStructuredSelection convertToResources( ResourceMapping mapping = ResourceUtil .getResourceMapping(currentElement); - if (mapping == null) + if (mapping == null) { continue; + } ResourceTraversal[] traversals = null; try { @@ -74,8 +75,9 @@ public IStructuredSelection convertToResources( } } - } else + } else { result.add(resource); + } } // all that can be converted are done, answer new selection diff --git a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/IDEWorkbenchActivityHelper.java b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/IDEWorkbenchActivityHelper.java index 55b48d58036..b5d21f97045 100644 --- a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/IDEWorkbenchActivityHelper.java +++ b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/IDEWorkbenchActivityHelper.java @@ -51,13 +51,13 @@ public class IDEWorkbenchActivityHelper { * Resource listener that reacts to new projects (and associated natures) * coming into the workspace. */ - private IResourceChangeListener listener; + private final IResourceChangeListener listener; /** * Mapping from composite nature ID to IPluginContribution. Used for proper * activity mapping of natures. */ - private Map natureMap; + private final Map natureMap; /** * Lock for the list of nature ids to be processed. @@ -72,7 +72,7 @@ public class IDEWorkbenchActivityHelper { /** * The collection of natures to process. */ - private HashSet fPendingNatureUpdates = new HashSet<>(); + private final HashSet fPendingNatureUpdates = new HashSet<>(); /** * Singleton instance. diff --git a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/IDEWorkbenchErrorHandler.java b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/IDEWorkbenchErrorHandler.java index 8b6b0640e6d..b7ab1b1b8a6 100644 --- a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/IDEWorkbenchErrorHandler.java +++ b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/IDEWorkbenchErrorHandler.java @@ -53,7 +53,7 @@ public class IDEWorkbenchErrorHandler extends WorkbenchErrorHandler { private boolean closing = false; - private IWorkbenchConfigurer workbenchConfigurer; + private final IWorkbenchConfigurer workbenchConfigurer; // Pre-load all Strings trying to run as light as possible in case of fatal // errors. @@ -234,8 +234,9 @@ private void closeWorkbench() { dialog.close(); } //@see WorkbenchAdvisor#getWorkbenchConfigurer() - if (workbenchConfigurer != null) + if (workbenchConfigurer != null) { workbenchConfigurer.emergencyClose(); + } } catch (RuntimeException re) { // Workbench may be in such bad shape (no OS handles left, out of // memory, etc) diff --git a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/IDEWorkbenchPlugin.java b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/IDEWorkbenchPlugin.java index a53e3942cf6..89f8facadeb 100644 --- a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/IDEWorkbenchPlugin.java +++ b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/IDEWorkbenchPlugin.java @@ -336,8 +336,9 @@ public ResourceManager getResourceManager() { @Override public void stop(BundleContext context) throws Exception { super.stop(context); - if (resourceManager != null) + if (resourceManager != null) { resourceManager.dispose(); + } } @Override @@ -356,8 +357,9 @@ private void createProblemsViews() { @Override public void run() { IWorkbench workbench = PlatformUI.isWorkbenchRunning() ? PlatformUI.getWorkbench() : null; - if (workbench != null && (workbench.getDisplay().isDisposed() || workbench.isClosing())) + if (workbench != null && (workbench.getDisplay().isDisposed() || workbench.isClosing())) { return; + } if (workbench == null || workbench.isStarting()) { Display.getCurrent().timerExec(PROBLEMS_VIEW_CREATION_DELAY, this); @@ -374,15 +376,17 @@ public void run() { } for (IWorkbenchWindow window : workbench.getWorkbenchWindows()) { IWorkbenchPage activePage= window.getActivePage(); - if (activePage == null) + if (activePage == null) { continue; + } for (IViewReference viewReference : activePage.getViewReferences()) { - if (IPageLayout.ID_PROBLEM_VIEW.equals(viewReference.getId())) + if (IPageLayout.ID_PROBLEM_VIEW.equals(viewReference.getId())) { try { activePage.showView(viewReference.getId(), viewReference.getSecondaryId(), IWorkbenchPage.VIEW_CREATE); } catch (PartInitException e) { log("Could not create Problems view", e.getStatus()); //$NON-NLS-1$ } + } } } } diff --git a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/LineDelimiterEditor.java b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/LineDelimiterEditor.java index f119a024d84..35e08703083 100644 --- a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/LineDelimiterEditor.java +++ b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/LineDelimiterEditor.java @@ -55,7 +55,7 @@ public class LineDelimiterEditor { * will be used to edit project preferences. If project is null, then we * are editing workspace preferences. */ - private IProject project; + private final IProject project; private Group group; @@ -190,8 +190,9 @@ private String getKeyForValue(String value) { private String getStoredValue(Preferences node) { try { // be careful looking up for our node so not to create any nodes as side effect - if (node.nodeExists(Platform.PI_RUNTIME)) + if (node.nodeExists(Platform.PI_RUNTIME)) { return node.node(Platform.PI_RUNTIME).get(Platform.PREF_LINE_SEPARATOR, null); + } } catch (BackingStoreException e) { // ignore } diff --git a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/LinkedResourceDecorator.java b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/LinkedResourceDecorator.java index 63f9c8b1332..f4dd754bd00 100644 --- a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/LinkedResourceDecorator.java +++ b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/LinkedResourceDecorator.java @@ -94,10 +94,9 @@ public void removeListener(ILabelProviderListener listener) { @Override public void decorate(Object element, IDecoration decoration) { - if (!(element instanceof IResource)) { + if (!(element instanceof IResource resource)) { return; } - IResource resource = (IResource) element; if (resource.isLinked() && !resource.isVirtual()) { IFileInfo fileInfo = null; URI location = resource.getLocationURI(); diff --git a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/Policy.java b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/Policy.java index 2174500936e..6c673b49490 100644 --- a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/Policy.java +++ b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/Policy.java @@ -66,9 +66,10 @@ private static boolean getDebugOption(String option) { */ public static void handle(CoreException exception) { // Only log if in debug mode - if (DEBUG_CORE_EXCEPTIONS) + if (DEBUG_CORE_EXCEPTIONS) { StatusManager.getManager().handle(exception, IDEWorkbenchPlugin.IDE_WORKBENCH); + } } } diff --git a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/ResourceDragAndDropEditor.java b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/ResourceDragAndDropEditor.java index 061fb9914fb..cb9af357de6 100644 --- a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/ResourceDragAndDropEditor.java +++ b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/ResourceDragAndDropEditor.java @@ -71,8 +71,9 @@ public void doLoad() { } private void updateState(String value) { for (int i = 0; i < labels.length; i++) { - if (value.equals(buttons[i].getData())) + if (value.equals(buttons[i].getData())) { buttons[i].setSelection(true); + } } } @@ -88,8 +89,9 @@ public void loadDefault() { */ public String getStoredValue(boolean useDefault) { IPreferenceStore store = IDEWorkbenchPlugin.getDefault().getPreferenceStore(); - if (useDefault) + if (useDefault) { return store.getDefaultString(preferenceKey); + } return store.getString(preferenceKey); } @@ -98,8 +100,9 @@ public String getStoredValue(boolean useDefault) { */ private String getSelection() { for (int i = 0; i < labels.length; i++) { - if (buttons[i].getSelection()) + if (buttons[i].getSelection()) { return (String) buttons[i].getData(); + } } return values[0]; } @@ -112,8 +115,9 @@ public void store() { public void setEnabled(boolean enableLinking) { group.setEnabled(enableLinking); for (int i = 0; i < labels.length; i++) { - if (buttons[i] != null && !buttons[i].isDisposed()) + if (buttons[i] != null && !buttons[i].isDisposed()) { buttons[i].setEnabled(enableLinking); + } } } diff --git a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/ResourceFilterDecorator.java b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/ResourceFilterDecorator.java index 0be77368a72..a27c896ffcf 100644 --- a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/ResourceFilterDecorator.java +++ b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/ResourceFilterDecorator.java @@ -39,16 +39,16 @@ public ResourceFilterDecorator() { @Override public void decorate(Object element, IDecoration decoration) { - if (!(element instanceof IContainer)) { + if (!(element instanceof IContainer container)) { return; } - IContainer container = (IContainer) element; IResourceFilterDescription[] filters = null; try { filters = container.getFilters(); - if ((filters.length > 0) && (descriptorImage != null)) + if ((filters.length > 0) && (descriptorImage != null)) { decoration .addOverlay(descriptorImage, IDecoration.BOTTOM_RIGHT); + } } catch (CoreException e) { } } diff --git a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/ResourceWorkingSetUpdater.java b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/ResourceWorkingSetUpdater.java index 0ef1265bb9b..f8cffbfc8c7 100644 --- a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/ResourceWorkingSetUpdater.java +++ b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/ResourceWorkingSetUpdater.java @@ -40,9 +40,9 @@ public class ResourceWorkingSetUpdater implements IWorkingSetUpdater, * Utility class used to help process incoming resource deltas. */ private static class WorkingSetDelta { - private IWorkingSet fWorkingSet; + private final IWorkingSet fWorkingSet; - private List fElements; + private final List fElements; private boolean fChanged; @@ -105,7 +105,7 @@ public void process() { } } - private List fWorkingSets; + private final List fWorkingSets; /** * Create a new instance of this updater. @@ -212,11 +212,9 @@ private void checkElementExistence(IWorkingSet workingSet) { for (Iterator iter = elements.iterator(); iter.hasNext();) { IAdaptable element = iter.next(); boolean remove = false; - if (element instanceof IProject) { - IProject project = (IProject) element; + if (element instanceof IProject project) { remove = !project.exists(); - } else if (element instanceof IResource) { - IResource resource = (IResource) element; + } else if (element instanceof IResource resource) { IProject project = resource.getProject(); remove = (project != null ? project.isOpen() : true) && !resource.exists(); diff --git a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/WorkbenchActionBuilder.java b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/WorkbenchActionBuilder.java index ef6ad835c19..fdfb801c83a 100644 --- a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/WorkbenchActionBuilder.java +++ b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/WorkbenchActionBuilder.java @@ -657,8 +657,9 @@ private MenuManager createWindowMenu() { sep.setVisible(!Util.isMac()); menu.add(sep); - if(Util.isCocoa()) + if(Util.isCocoa()) { menu.add(arrangeWindowsItem); + } // See the comment for quit in createFileMenu ActionContributionItem openPreferencesItem = new ActionContributionItem(openPreferencesAction); @@ -671,8 +672,9 @@ private MenuManager createWindowMenu() { private void addMacWindowMenuItems(MenuManager windowMenu) { - if (!Util.isCocoa()) + if (!Util.isCocoa()) { return; + } windowMenu.add(minimizeItem); windowMenu.add(zoomItem); @@ -1329,12 +1331,11 @@ public void run() { .getCoolBarManager(); IContributionItem cbItem = coolBarManager .find(IWorkbenchActionConstants.TOOLBAR_FILE); - if (!(cbItem instanceof IToolBarContributionItem)) { + if (!(cbItem instanceof IToolBarContributionItem toolBarItem)) { // This should not happen IDEWorkbenchPlugin.log("File toolbar contribution item is missing"); //$NON-NLS-1$ return; } - IToolBarContributionItem toolBarItem = (IToolBarContributionItem) cbItem; IToolBarManager toolBarManager = toolBarItem.getToolBarManager(); if (toolBarManager == null) { // error if this happens, file toolbar assumed to always exist @@ -1386,13 +1387,12 @@ void updatePinActionToolbar() { .getCoolBarManager(); IContributionItem cbItem = coolBarManager .find(IWorkbenchActionConstants.TOOLBAR_NAVIGATE); - if (!(cbItem instanceof IToolBarContributionItem)) { + if (!(cbItem instanceof IToolBarContributionItem toolBarItem)) { // This should not happen IDEWorkbenchPlugin .log("Navigation toolbar contribution item is missing"); //$NON-NLS-1$ return; } - IToolBarContributionItem toolBarItem = (IToolBarContributionItem) cbItem; IToolBarManager toolBarManager = toolBarItem.getToolBarManager(); if (toolBarManager == null) { // error if this happens, navigation toolbar assumed to always exist diff --git a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/actions/BuildSetAction.java b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/actions/BuildSetAction.java index c2ad96565b0..4e07f125fbd 100644 --- a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/actions/BuildSetAction.java +++ b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/actions/BuildSetAction.java @@ -34,11 +34,11 @@ public class BuildSetAction extends Action { public static BuildSetAction lastBuilt; - private IWorkingSet workingSet; + private final IWorkingSet workingSet; - private IWorkbenchWindow window; + private final IWorkbenchWindow window; - private IActionBarConfigurer actionBars; + private final IActionBarConfigurer actionBars; /** * Creates a new action that builds the provided working set when run diff --git a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/actions/BuildSetMenu.java b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/actions/BuildSetMenu.java index 19d89b1d589..70e58fa5cb8 100644 --- a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/actions/BuildSetMenu.java +++ b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/actions/BuildSetMenu.java @@ -38,7 +38,7 @@ public class BuildSetMenu extends ContributionItem { boolean dirty = true; - private IMenuListener menuListener = manager -> { + private final IMenuListener menuListener = manager -> { manager.markDirty(); dirty = true; }; diff --git a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/actions/BuildUtilities.java b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/actions/BuildUtilities.java index 8c1c32e4bda..228ade50bc4 100644 --- a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/actions/BuildUtilities.java +++ b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/actions/BuildUtilities.java @@ -103,8 +103,7 @@ public static IProject[] findSelectedProjects(IWorkbenchWindow window) { if (selection != null && !selection.isEmpty() && selection instanceof IStructuredSelection) { selected = extractProjects(((IStructuredSelection) selection).toArray()); } else //see if we can extract a selected project from the active editor - if (activePart instanceof IEditorPart) { - IEditorPart editor= (IEditorPart)activePart; + if (activePart instanceof IEditorPart editor) { IFile file = ResourceUtil.getFile(editor.getEditorInput()); if (file != null) { selected = new IProject[] {file.getProject()}; diff --git a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/actions/OpenLocalFileAction.java b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/actions/OpenLocalFileAction.java index d0591a68e06..5304c01e6c9 100644 --- a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/actions/OpenLocalFileAction.java +++ b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/actions/OpenLocalFileAction.java @@ -99,8 +99,9 @@ public void run() { MessageDialog.open(MessageDialog.ERROR,workbenchWindow.getShell(), IDEWorkbenchMessages.OpenLocalFileAction_title, msg, SWT.SHEET); } } else { - if (++numberOfFilesNotFound > 1) + if (++numberOfFilesNotFound > 1) { notFound.append('\n'); + } notFound.append(fileStore.getName()); } } diff --git a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/actions/OpenWorkspaceAction.java b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/actions/OpenWorkspaceAction.java index 41cc44f8778..742864e2918 100644 --- a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/actions/OpenWorkspaceAction.java +++ b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/actions/OpenWorkspaceAction.java @@ -70,9 +70,9 @@ public void run() { */ class WorkspaceMRUAction extends Action { - private ChooseWorkspaceData data; + private final ChooseWorkspaceData data; - private String location; + private final String location; WorkspaceMRUAction(String location, ChooseWorkspaceData data) { this.location = location; // preserve the location directly - diff --git a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/actions/SelectBuildWorkingSetAction.java b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/actions/SelectBuildWorkingSetAction.java index 462bfdea9f0..4e27fcdf9b2 100644 --- a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/actions/SelectBuildWorkingSetAction.java +++ b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/actions/SelectBuildWorkingSetAction.java @@ -30,7 +30,7 @@ */ public class SelectBuildWorkingSetAction extends Action implements ActionFactory.IWorkbenchAction { - private IWorkbenchWindow window; + private final IWorkbenchWindow window; private IActionBarConfigurer actionBars; diff --git a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/commands/CopyBuildIdToClipboardHandler.java b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/commands/CopyBuildIdToClipboardHandler.java index ffdc52023fe..d7b6dfb7d52 100644 --- a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/commands/CopyBuildIdToClipboardHandler.java +++ b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/commands/CopyBuildIdToClipboardHandler.java @@ -64,8 +64,9 @@ public class CopyBuildIdToClipboardHandler extends AbstractHandler { public Object execute(ExecutionEvent event) throws ExecutionException { final IProduct product = Platform.getProduct(); - if (product == null ) + if (product == null ) { throw new ExecutionException("No product is defined."); //$NON-NLS-1$ + } String aboutText = ProductProperties.getAboutText(product); String lines[] = aboutText.split("\\r?\\n"); //$NON-NLS-1$ diff --git a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/commands/ResourcePathConverter.java b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/commands/ResourcePathConverter.java index 6650598eb72..b817237f8bb 100644 --- a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/commands/ResourcePathConverter.java +++ b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/commands/ResourcePathConverter.java @@ -49,11 +49,10 @@ public final Object convertToObject(final String parameterValue) @Override public final String convertToString(final Object parameterValue) throws ParameterValueConversionException { - if (!(parameterValue instanceof IResource)) { + if (!(parameterValue instanceof final IResource resource)) { throw new ParameterValueConversionException( "parameterValue must be an IResource"); //$NON-NLS-1$ } - final IResource resource = (IResource) parameterValue; return resource.getFullPath().toString(); } } diff --git a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/dialogs/AutoSavePreferencePage.java b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/dialogs/AutoSavePreferencePage.java index 81454451a98..9450c97f7af 100644 --- a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/dialogs/AutoSavePreferencePage.java +++ b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/dialogs/AutoSavePreferencePage.java @@ -61,7 +61,7 @@ public class AutoSavePreferencePage extends PreferencePage implements IWorkbench private Label noteMessage; - private IPropertyChangeListener validityChangeListener = event -> { + private final IPropertyChangeListener validityChangeListener = event -> { if (event.getProperty().equals(FieldEditor.IS_VALID)) { updateValidState(); } diff --git a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/dialogs/BuildOrderPreferencePage.java b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/dialogs/BuildOrderPreferencePage.java index 390514e15a5..99eeb08ff03 100644 --- a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/dialogs/BuildOrderPreferencePage.java +++ b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/dialogs/BuildOrderPreferencePage.java @@ -114,7 +114,7 @@ public class BuildOrderPreferencePage extends PreferencePage implements private Button autoSaveAllButton; - private IPropertyChangeListener validityChangeListener = event -> { + private final IPropertyChangeListener validityChangeListener = event -> { if (event.getProperty().equals(FieldEditor.IS_VALID)) { updateValidState(); } diff --git a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/dialogs/CleanDialog.java b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/dialogs/CleanDialog.java index e7e2f942415..6f46e31ea78 100644 --- a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/dialogs/CleanDialog.java +++ b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/dialogs/CleanDialog.java @@ -100,10 +100,10 @@ protected List getSelectedResources() { private Object[] selection; - private IWorkbenchWindow window; + private final IWorkbenchWindow window; private Text filterText; - private SearchPattern searchPattern = new SearchPattern(); + private final SearchPattern searchPattern = new SearchPattern(); /** * Gets the text of the clean dialog, depending on whether the @@ -310,10 +310,9 @@ private void createProjectSelectionTable(Composite parent) { private final IProject[] projectHolder = new IProject[1]; @Override public boolean select(Viewer viewer, Object parentElement, Object element) { - if (!(element instanceof IProject)) { + if (!(element instanceof IProject project)) { return false; } - IProject project = (IProject) element; boolean isProjectNameMatchingPattern = searchPattern.matches(project.getName()); if (!project.isAccessible() || !isProjectNameMatchingPattern) { if (!filterText.getText().equals(IDEWorkbenchMessages.CleanDialog_typeFilterText)) { diff --git a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/dialogs/ConfigurationLogUpdateSection.java b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/dialogs/ConfigurationLogUpdateSection.java index 8cc663759ea..d1326511034 100644 --- a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/dialogs/ConfigurationLogUpdateSection.java +++ b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/dialogs/ConfigurationLogUpdateSection.java @@ -44,8 +44,9 @@ public class ConfigurationLogUpdateSection implements ISystemSummarySection { private void writeInstalledIUs(PrintWriter writer) { ServiceCaller.callOnce(getClass(), IProfileRegistry.class, (registry) -> { IProfile profile = registry.getProfile(IProfileRegistry.SELF); - if (profile == null) + if (profile == null) { return; + } writer.println(IDEWorkbenchMessages.ConfigurationLogUpdateSection_installConfiguration); writer.println(" " + NLS.bind(IDEWorkbenchMessages.ConfigurationLogUpdateSection_lastChangedOn, DateFormat.getDateInstance().format(new Date(profile.getTimestamp())))); //$NON-NLS-1$ @@ -63,8 +64,9 @@ private void writeInstalledIUs(PrintWriter writer) { if (!sorted.isEmpty()) { writer.println(IDEWorkbenchMessages.ConfigurationLogUpdateSection_IUHeader); writer.println(); - for (String string : sorted) + for (String string : sorted) { writer.println(string); + } } }); } @@ -80,16 +82,18 @@ private void writeBundles(PrintWriter writer) { SortedSet sorted = new TreeSet<>(); for (Bundle bundle : bundleContext.getBundles()) { String name = bundle.getSymbolicName(); - if (name == null) + if (name == null) { name = bundle.getLocation(); - String message = NLS.bind(IDEWorkbenchMessages.ConfigurationLogUpdateSection_bundle, new Object[] {name, bundle.getVersion(), bundle.getLocation()}); + } + String message = NLS.bind(IDEWorkbenchMessages.ConfigurationLogUpdateSection_bundle, name, bundle.getVersion(), bundle.getLocation()); sorted.add(message); } if (!sorted.isEmpty()) { writer.println(IDEWorkbenchMessages.ConfigurationLogUpdateSection_bundleHeader); writer.println(); - for (String string : sorted) + for (String string : sorted) { writer.println(string); + } } } diff --git a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/dialogs/CreateLinkedResourceGroup.java b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/dialogs/CreateLinkedResourceGroup.java index 23275681291..2f9f223069a 100644 --- a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/dialogs/CreateLinkedResourceGroup.java +++ b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/dialogs/CreateLinkedResourceGroup.java @@ -64,11 +64,11 @@ * @since 2.1 */ public class CreateLinkedResourceGroup { - private Listener listener; + private final Listener listener; private String linkTarget = ""; //$NON-NLS-1$ - private int type; + private final int type; private boolean createLink = false; @@ -223,8 +223,9 @@ public void setEnabled(boolean value) { variablesButton.setEnabled(createLink); // Set the required field color if the field is enabled linkTargetField.setEnabled(createLink); - if (fileSystemSelectionArea != null) + if (fileSystemSelectionArea != null) { fileSystemSelectionArea.setEnabled(createLink); + } if (listener != null) { listener.handleEvent(new Event()); @@ -419,8 +420,9 @@ public void dispose() { * chose not to create a link. */ public URI getLinkTargetURI() { - if (!createLink) + if (!createLink) { return null; + } // linkTarget can contain either: // 1) a URI, ex: foo://bar/file.txt // 2) A path, ex: c:\foo\bar\file.txt @@ -428,8 +430,9 @@ public URI getLinkTargetURI() { URI uri; try { IPath path = IPath.fromOSString(linkTarget); - if (path != null && path.toFile().exists()) + if (path != null && path.toFile().exists()) { return URIUtil.toURI(path); + } uri = new URI(linkTarget); URI resolved = getPathVariableManager().resolveURI(uri); @@ -483,8 +486,9 @@ private void handleLinkTargetBrowseButtonPressed() { } else { URI uri = config.getContributor().browseFileSystem(linkTarget, linkTargetField.getShell()); - if (uri != null) + if (uri != null) { selection = uri.toString(); + } } } else { String filterPath = null; @@ -503,17 +507,20 @@ private void handleLinkTargetBrowseButtonPressed() { .getShell(), SWT.SHEET); dialog .setMessage(IDEWorkbenchMessages.CreateLinkedResourceGroup_targetSelectionLabel); - if (filterPath != null) + if (filterPath != null) { dialog.setFilterPath(filterPath); + } selection = dialog.open(); } else { String initialPath = IDEResourceInfoUtils.EMPTY_STRING; - if (filterPath != null) + if (filterPath != null) { initialPath = filterPath; + } URI uri = config.getContributor().browseFileSystem(initialPath, linkTargetField.getShell()); - if (uri != null) + if (uri != null) { selection = uri.toString(); + } } } if (selection != null) { @@ -535,8 +542,9 @@ private boolean isDefaultConfigurationSelected() { * @return FileSystemConfiguration or null */ private FileSystemConfiguration getSelectedConfiguration() { - if (fileSystemSelectionArea == null) + if (fileSystemSelectionArea == null) { return null; + } return fileSystemSelectionArea.getSelectedConfiguration(); } @@ -601,10 +609,11 @@ private void resolveVariable() { } URI resolvedURI = pathVariableManager.resolveURI(uri); String resolvedString; - if (isURL) + if (isURL) { resolvedString = resolvedURI.toString(); - else + } else { resolvedString = URIUtil.toPath(resolvedURI).toOSString(); + } if (linkTarget.equals(resolvedString)) { resolvedPathLabelText.setVisible(false); @@ -621,8 +630,9 @@ private void resolveVariable() { */ private IPathVariableManager getPathVariableManager() { if (updatableResourceName != null - && updatableResourceName.getResource() != null) + && updatableResourceName.getResource() != null) { return updatableResourceName.getResource().getPathVariableManager(); + } return ResourcesPlugin.getWorkspace().getPathVariableManager(); } diff --git a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/dialogs/FileFolderSelectionDialog.java b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/dialogs/FileFolderSelectionDialog.java index 1cc824b2eb3..018bfd1b67d 100644 --- a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/dialogs/FileFolderSelectionDialog.java +++ b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/dialogs/FileFolderSelectionDialog.java @@ -51,8 +51,7 @@ private static class FileLabelProvider extends LabelProvider { @Override public Image getImage(Object element) { - if (element instanceof IFileStore) { - IFileStore curr = (IFileStore) element; + if (element instanceof IFileStore curr) { if (curr.fetchInfo().isDirectory()) { return IMG_FOLDER; } @@ -153,9 +152,9 @@ public int category(Object element) { */ private static class FileSelectionValidator implements ISelectionStatusValidator { - private boolean multiSelect; + private final boolean multiSelect; - private boolean acceptFolders; + private final boolean acceptFolders; /** * Creates a new instance of the receiver. @@ -182,8 +181,7 @@ public IStatus validate(Object[] selection) { IDEResourceInfoUtils.EMPTY_STRING, null); } for (Object currentSelection : selection) { - if (currentSelection instanceof IFileStore) { - IFileStore file = (IFileStore) currentSelection; + if (currentSelection instanceof IFileStore file) { if (!acceptFolders && file.fetchInfo().isDirectory()) { return new Status(IStatus.ERROR, pluginId, IStatus.ERROR, diff --git a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/dialogs/FileStatesPage.java b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/dialogs/FileStatesPage.java index 39c40c92142..ed5678d1600 100644 --- a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/dialogs/FileStatesPage.java +++ b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/dialogs/FileStatesPage.java @@ -64,12 +64,12 @@ public class FileStatesPage extends PreferencePage implements private Button keepDerivedStateButton; - private ArrayList dependentControls = new ArrayList<>(); + private final ArrayList dependentControls = new ArrayList<>(); //Choose a maximum to prevent OutOfMemoryErrors - private int FILE_STATES_MAXIMUM = 10000; + private final int FILE_STATES_MAXIMUM = 10000; - private long STATE_SIZE_MAXIMUM = 100; + private final long STATE_SIZE_MAXIMUM = 100; private static final int INDENT = 20; @@ -127,8 +127,9 @@ private void checkState() { boolean newState= applyPolicyButton.getSelection(); Iterator iter = dependentControls.iterator(); - while (iter.hasNext()) + while (iter.hasNext()) { iter.next().setEnabled(newState); + } if (validateLongTextEntry(longevityText, DAY_LENGTH) == FAILED_VALUE) { setValid(false); @@ -347,8 +348,9 @@ private long validateLongTextEntry(Text text, long scale) { try { String string = text.getText(); value = Long.parseLong(string); - if (value * scale / scale != value) + if (value * scale / scale != value) { throw new NumberFormatException(string); + } } catch (NumberFormatException exception) { setErrorMessage(MessageFormat.format(IDEWorkbenchMessages.FileHistory_invalid, diff --git a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/dialogs/FileSystemSelectionArea.java b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/dialogs/FileSystemSelectionArea.java index 430aacce804..e9e1f4045e7 100644 --- a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/dialogs/FileSystemSelectionArea.java +++ b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/dialogs/FileSystemSelectionArea.java @@ -80,8 +80,7 @@ public String getText(Object element) { public FileSystemConfiguration getSelectedConfiguration() { ISelection selection = fileSystems.getSelection(); - if (selection instanceof IStructuredSelection) { - IStructuredSelection structured = (IStructuredSelection) selection; + if (selection instanceof IStructuredSelection structured) { if (structured.size() == 1) { return (FileSystemConfiguration) structured.getFirstElement(); } diff --git a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/dialogs/IDEResourceInfoUtils.java b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/dialogs/IDEResourceInfoUtils.java index 0f090365b7f..f4ae439a064 100644 --- a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/dialogs/IDEResourceInfoUtils.java +++ b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/dialogs/IDEResourceInfoUtils.java @@ -178,8 +178,9 @@ public static IFileInfo getFileInfo(String pathName) { * @return String or null */ public static IFileInfo getFileInfo(URI location) { - if (location.getScheme() == null) + if (location.getScheme() == null) { return null; + } IFileStore store = getFileStore(location); if (store == null) { return null; @@ -224,8 +225,9 @@ public static IFileStore getFileStore(URI uri) { * @return String the text to display the location */ public static String getLocationText(IResource resource) { - if (resource.isVirtual()) + if (resource.isVirtual()) { return VIRTUAL_FOLDER_TEXT; + } if (!resource.isLocal(IResource.DEPTH_ZERO)) { return NOT_LOCAL_TEXT; } @@ -240,8 +242,9 @@ public static String getLocationText(IResource resource) { return NOT_EXIST_TEXT; } - if (resolvedLocation.getScheme() == null) + if (resolvedLocation.getScheme() == null) { return location.toString(); + } IFileStore store = getFileStore(resolvedLocation); // don't access the file system for closed projects (bug 151089) @@ -287,8 +290,9 @@ public static String getResolvedLocationText(IResource resource) { return NOT_EXIST_TEXT; } - if (location.getScheme() == null) + if (location.getScheme() == null) { return UNKNOWN_LABEL; + } IFileStore store = getFileStore(location); if (store == null) { diff --git a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/dialogs/InternalErrorDialog.java b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/dialogs/InternalErrorDialog.java index 1012cc5a189..d048db5d25c 100644 --- a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/dialogs/InternalErrorDialog.java +++ b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/dialogs/InternalErrorDialog.java @@ -37,7 +37,7 @@ */ public class InternalErrorDialog extends MessageDialog { - private Throwable detail; + private final Throwable detail; private int detailButtonID = -1; diff --git a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/dialogs/LinkedResourceEditor.java b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/dialogs/LinkedResourceEditor.java index 30f219fcb54..4ffe1f145ed 100644 --- a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/dialogs/LinkedResourceEditor.java +++ b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/dialogs/LinkedResourceEditor.java @@ -249,8 +249,9 @@ public Control createContents(Composite parent) { fTree.getTree().addMouseListener(new MouseAdapter() { @Override public void mouseDoubleClick(MouseEvent e) { - if (getSelectedResource().length == 1) + if (getSelectedResource().length == 1) { editLocation(); + } } }); fTree.getTree().addKeyListener(new KeyAdapter() { @@ -258,8 +259,9 @@ public void mouseDoubleClick(MouseEvent e) { public void keyPressed(KeyEvent e) { if (e.keyCode == SWT.DEL) { e.doit = false; - if (getSelectedResource().length > 0) + if (getSelectedResource().length > 0) { removeSelection(); + } } } }); @@ -291,20 +293,21 @@ public LabelProvider() { @Override public String getColumnText(Object obj, int index) { - if (obj instanceof IResource) { - IResource resource = (IResource) obj; - if (index == NAME_COLUMN) + if (obj instanceof IResource resource) { + if (index == NAME_COLUMN) { return resource.getName(); - else if (index == PATH_COLUMN) + } else if (index == PATH_COLUMN) { return resource.getParent() .getProjectRelativePath().toPortableString(); - else { + } else { IPath rawLocation = resource.getRawLocation(); - if (rawLocation != null) + if (rawLocation != null) { return resource.getPathVariableManager().convertToUserEditableFormat(rawLocation.toOSString(), true); + } } - } else if ((obj instanceof String) && index == 0) + } else if ((obj instanceof String) && index == 0) { return (String) obj; + } return null; } @@ -312,10 +315,12 @@ else if (index == PATH_COLUMN) public Image getColumnImage(Object obj, int index) { if (index == NAME_COLUMN) { if (obj instanceof String) { - if (obj.equals(BROKEN)) + if (obj.equals(BROKEN)) { return brokenImg; - if (obj.equals(ABSOLUTE)) + } + if (obj.equals(ABSOLUTE)) { return absoluteImg; + } return fixedImg; } return stockProvider.getImage(obj); @@ -369,15 +374,18 @@ public Object[] getChildren(Object parentElement) { Object[] objs = { BROKEN, ABSOLUTE, FIXED }; for (Object obj : objs) { Object[] children = getChildren(obj); - if (children != null && children.length > 0) + if (children != null && children.length > 0) { list.add(obj); + } } return list.toArray(new Object[0]); } else if (parentElement instanceof String) { - if (((String) parentElement).equals(BROKEN)) + if (((String) parentElement).equals(BROKEN)) { return fBrokenResources.values().toArray(); - if (((String) parentElement).equals(ABSOLUTE)) + } + if (((String) parentElement).equals(ABSOLUTE)) { return fAbsoluteResources.values().toArray(); + } return fFixedResources.values().toArray(); } return null; @@ -388,13 +396,16 @@ public Object getParent(Object element) { if (element instanceof IResource) { String fullPath = ((IResource) element).getFullPath() .toPortableString(); - if (fBrokenResources.containsKey(fullPath)) + if (fBrokenResources.containsKey(fullPath)) { return BROKEN; - if (fAbsoluteResources.containsKey(fullPath)) + } + if (fAbsoluteResources.containsKey(fullPath)) { return ABSOLUTE; + } return FIXED; - } else if (element instanceof String) + } else if (element instanceof String) { return this; + } return null; } @@ -403,10 +414,12 @@ public boolean hasChildren(Object element) { if (element instanceof LinkedResourceEditor) { return true; } else if (element instanceof String) { - if (((String) element).equals(BROKEN)) + if (((String) element).equals(BROKEN)) { return !fBrokenResources.isEmpty(); - if (((String) element).equals(ABSOLUTE)) + } + if (((String) element).equals(ABSOLUTE)) { return !fAbsoluteResources.isEmpty(); + } return !fFixedResources.isEmpty(); } return false; @@ -424,8 +437,9 @@ void refreshContent() { final LinkedList resources = new LinkedList<>(); try { fProject.accept(resource -> { - if (resource.isLinked() && !resource.isVirtual()) + if (resource.isLinked() && !resource.isVirtual()) { resources.add(resource); + } return true; }); } catch (CoreException e) { @@ -447,12 +461,14 @@ void refreshContent() { String fullPath = resource.getFullPath().toPortableString(); try { if (exists(resource)) { - if (isAbsolute(resource)) + if (isAbsolute(resource)) { fAbsoluteResources.put(fullPath, resource); - else + } else { fFixedResources.put(fullPath, resource); - } else + } + } else { fBrokenResources.put(fullPath, resource); + } } catch (CoreException e) { fBrokenResources.put(fullPath, resource); } @@ -493,8 +509,9 @@ void updateSelection() { boolean areFixed(IResource[] res) { for (IResource resource : res) { String fullPath = resource.getFullPath().toPortableString(); - if (!fFixedResources.containsKey(fullPath)) + if (!fFixedResources.containsKey(fullPath)) { return false; + } } return true; } @@ -522,10 +539,11 @@ private void convertLocation() { ArrayList resources = new ArrayList<>(); IResource[] selectedResources = getSelectedResource(); resources.addAll(Arrays.asList(selectedResources)); - if (areFixed(selectedResources)) + if (areFixed(selectedResources)) { convertToAbsolute(resources, selectedResources); - else + } else { convertToRelative(resources, selectedResources); + } } } @@ -574,8 +592,7 @@ private void convertToAbsolute(ArrayList resources, try { setLinkLocation(res, location); report.add(NLS.bind(IDEWorkbenchMessages.LinkedResourceEditor_changedTo, - new Object[] { res.getProjectRelativePath().toPortableString(), - res.getRawLocation().toOSString(), location.toOSString() })); + res.getProjectRelativePath().toPortableString(), res.getRawLocation().toOSString(), location.toOSString())); } catch (CoreException e) { report.add(NLS.bind(IDEWorkbenchMessages.LinkedResourceEditor_unableToSetLinkLocationForResource, res.getProjectRelativePath().toPortableString())); @@ -589,12 +606,14 @@ private void convertToAbsolute(ArrayList resources, } private void setLinkLocation(IResource res, IPath location) throws CoreException { - if (res.getType() == IResource.FILE) + if (res.getType() == IResource.FILE) { ((IFile)res).createLink(location, IResource.REPLACE, new NullProgressMonitor()); - if (res.getType() == IResource.FOLDER) + } + if (res.getType() == IResource.FOLDER) { ((IFolder)res).createLink(location, IResource.REPLACE, new NullProgressMonitor()); + } } private void reportResult(IResource[] selectedResources, @@ -603,8 +622,9 @@ private void reportResult(IResource[] selectedResources, Iterator stringIt = report.iterator(); while (stringIt.hasNext()) { message.append(stringIt.next()); - if (stringIt.hasNext()) + if (stringIt.hasNext()) { message.append("\n"); //$NON-NLS-1$ + } } final String resultMessage = message.toString(); MessageDialog dialog = new MessageDialog(fConvertAbsoluteButton.getShell(), title, null, @@ -661,13 +681,12 @@ private void convertToRelative(ArrayList resources, IPath location = res.getLocation(); try { IPath newLocation = URIUtil.toPath(res.getPathVariableManager().convertToRelative(URIUtil.toURI(location), true, null)); - if (newLocation == null || newLocation.equals(location)) + if (newLocation == null || newLocation.equals(location)) { remaining.add(res); - else { + } else { setLinkLocation(res, newLocation); report.add(NLS.bind(IDEWorkbenchMessages.LinkedResourceEditor_changedTo, - new Object[] { res.getProjectRelativePath().toPortableString(), location.toOSString(), - newLocation.toOSString() })); + res.getProjectRelativePath().toPortableString(), location.toOSString(), newLocation.toOSString())); } } catch (CoreException e) { remaining.add(res); @@ -709,13 +728,10 @@ private void convertToRelative(ArrayList resources, .add(NLS .bind( IDEWorkbenchMessages.LinkedResourceEditor_changedTo, - new Object[] { - res - .getProjectRelativePath() - .toPortableString(), - location.toOSString(), - newLocation - .toOSString() })); + res + .getProjectRelativePath() + .toPortableString(), location.toOSString(), newLocation + .toOSString())); } catch (CoreException e) { variable = -1; } @@ -736,17 +752,19 @@ private void convertToRelative(ArrayList resources, IResource res = it.next(); IPath location = res.getLocation(); - if (commonPath == null) + if (commonPath == null) { commonPath = location; - else { + } else { int count = commonPath.matchingFirstSegments(location); - if (count < commonPath.segmentCount()) + if (count < commonPath.segmentCount()) { commonPath = commonPath.removeLastSegments(commonPath .segmentCount() - count); + } } - if (commonPath.segmentCount() == 0) + if (commonPath.segmentCount() == 0) { break; + } } if (commonPath.segmentCount() > 1) { String variableName = getSuitablePathVariable(commonPath); @@ -775,14 +793,11 @@ private void convertToRelative(ArrayList resources, .add(NLS .bind( IDEWorkbenchMessages.LinkedResourceEditor_changedTo, - new Object[] { - res - .getProjectRelativePath() - .toPortableString(), - location - .toOSString(), - newLocation - .toOSString() })); + res + .getProjectRelativePath() + .toPortableString(), location + .toOSString(), newLocation + .toOSString())); } catch (CoreException e) { report .add(NLS @@ -826,11 +841,8 @@ private void convertToRelative(ArrayList resources, .add(NLS .bind( IDEWorkbenchMessages.LinkedResourceEditor_changedTo, - new Object[] { - res.getProjectRelativePath() - .toPortableString(), - location.toOSString(), - newLocation.toOSString() })); + res.getProjectRelativePath() + .toPortableString(), location.toOSString(), newLocation.toOSString())); } catch (CoreException e) { report .add(NLS @@ -850,18 +862,20 @@ private String getSuitablePathVariable(IPath commonPath) { String variableName = commonPath.lastSegment(); if (variableName == null) { variableName = commonPath.getDevice(); - if (variableName == null) + if (variableName == null) { variableName = "ROOT"; //$NON-NLS-1$ - else + } else { variableName = variableName.substring(0, variableName.length() -1); // remove the tailing ':' + } } StringBuilder buf = new StringBuilder(); for (int i = 0; i < variableName.length(); i++) { char c = variableName.charAt(i); - if (Character.isLetterOrDigit(c) || (c == '_')) + if (Character.isLetterOrDigit(c) || (c == '_')) { buf.append(c); - else + } else { buf.append('_'); + } } int index = 1; @@ -881,8 +895,9 @@ void editLocation() { fConvertAbsoluteButton.getShell(), PathVariableDialog.EDIT_LINK_LOCATION, resource.getType(), resource.getPathVariableManager(), null); - if (location != null) + if (location != null) { dialog.setLinkLocation(location); + } dialog.setResource(resource); if (dialog.open() == Window.CANCEL) { return; @@ -907,12 +922,13 @@ void reparent(IResource[] resources) { isBroken = true; } TreeMap container = null; - if (isBroken) + if (isBroken) { container = fBrokenResources; - else if (isAbsolute(resource)) + } else if (isAbsolute(resource)) { container = fAbsoluteResources; - else + } else { container = fFixedResources; + } String fullPath = resource.getFullPath().toPortableString(); if (!container.containsKey(fullPath)) { @@ -924,8 +940,9 @@ else if (isAbsolute(resource)) changed = true; } } - if (changed) + if (changed) { fTree.refresh(); + } } boolean initialized = false; diff --git a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/dialogs/LinkedResourcesPreferencePage.java b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/dialogs/LinkedResourcesPreferencePage.java index 303d6a5c58f..d5bdfe91cbb 100644 --- a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/dialogs/LinkedResourcesPreferencePage.java +++ b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/dialogs/LinkedResourcesPreferencePage.java @@ -51,7 +51,7 @@ public class LinkedResourcesPreferencePage extends PreferencePage implements public static String PREF_ID = "org.eclipse.ui.preferencePages.LinkedResources"; //$NON-NLS-1$ - private PathVariablesGroup pathVariablesGroup; + private final PathVariablesGroup pathVariablesGroup; private ResourceDragAndDropEditor dragAndDropHandlingEditor; diff --git a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/dialogs/OpenFilesystemQuickAccessComputer.java b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/dialogs/OpenFilesystemQuickAccessComputer.java index 07c8b846b38..58432503a42 100644 --- a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/dialogs/OpenFilesystemQuickAccessComputer.java +++ b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/dialogs/OpenFilesystemQuickAccessComputer.java @@ -36,7 +36,7 @@ public class OpenFilesystemQuickAccessComputer implements IQuickAccessComputerEx private static class FileElement extends QuickAccessElement { - private File file; + private final File file; public FileElement(File file) { this.file = file; diff --git a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/dialogs/PathVariableDialog.java b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/dialogs/PathVariableDialog.java index e676060c574..3747939b44d 100644 --- a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/dialogs/PathVariableDialog.java +++ b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/dialogs/PathVariableDialog.java @@ -81,13 +81,13 @@ public class PathVariableDialog extends TitleAreaDialog { * This dialog type: NEW_VARIABLE or * EXISTING_VARIABLE. */ - private int type; + private final int type; /** * The type of variable that can be edited in this dialog. * IResource.FILE or IResource.FOLDER */ - private int variableType; + private final int variableType; /** * The name of the variable being edited. @@ -115,13 +115,13 @@ public class PathVariableDialog extends TitleAreaDialog { * Reference to the path variable manager. It is used for validating * variable names. */ - private IPathVariableManager pathVariableManager; + private final IPathVariableManager pathVariableManager; /** * 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 final Set namesInUse; /** * The current validation status. Its value can be one of the following:
    @@ -396,8 +396,9 @@ public void widgetSelected(SelectionEvent e) { } private IPathVariableManager getPathVariableManager() { - if (currentResource != null) + if (currentResource != null) { return currentResource.getPathVariableManager(); + } return ResourcesPlugin.getWorkspace().getPathVariableManager(); } @@ -454,8 +455,9 @@ private void variableValueModified() { validationStatus = IMessageProvider.NONE; okButton.setEnabled(validateVariableValue() && validateVariableName()); locationEntered = true; - if (variableResolvedValueField != null) + if (variableResolvedValueField != null) { variableResolvedValueField.setText(TextProcessor.process(getVariableResolvedValue())); + } } /** @@ -537,8 +539,9 @@ protected void createButtonsForButtonBar(Composite parent) { private boolean validateVariableName() { boolean allowFinish = false; - if (operationMode == EDIT_LINK_LOCATION) + if (operationMode == EDIT_LINK_LOCATION) { return true; + } // if the current validationStatus is ERROR, no additional validation applies if (validationStatus == IMessageProvider.ERROR) { @@ -629,10 +632,11 @@ private boolean validateVariableValue() { (!info.isDirectory() && ((variableType & IResource.FILE) == 0))){ allowFinish = false; newValidationStatus = IMessageProvider.ERROR; - if (((variableType & IResource.FOLDER) != 0)) + if (((variableType & IResource.FOLDER) != 0)) { message = IDEWorkbenchMessages.PathVariableDialog_variableValueIsWrongTypeFolder; - else + } else { message = IDEWorkbenchMessages.PathVariableDialog_variableValueIsWrongTypeFile; + } } } } else if (!IPath.EMPTY.isValidPath(variableValue)) { diff --git a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/dialogs/PathVariableEditDialog.java b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/dialogs/PathVariableEditDialog.java index b50108510d7..2f37a469f37 100644 --- a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/dialogs/PathVariableEditDialog.java +++ b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/dialogs/PathVariableEditDialog.java @@ -34,7 +34,7 @@ */ public class PathVariableEditDialog extends SelectionDialog { - private PathVariablesGroup pathVariablesGroup; + private final PathVariablesGroup pathVariablesGroup; /** * Creates a path variable selection dialog. diff --git a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/dialogs/PathVariablesGroup.java b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/dialogs/PathVariablesGroup.java index 32e17f3c8b1..d15dd14f2a9 100644 --- a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/dialogs/PathVariablesGroup.java +++ b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/dialogs/PathVariablesGroup.java @@ -117,10 +117,10 @@ public static class PathVariableElement { private FontMetrics fontMetrics; // create a multi select table - private boolean multiSelect; + private final boolean multiSelect; // IResource.FILE and/or IResource.FOLDER - private int variableType; + private final int variableType; // External listener called when the table selection changes private Listener selectionListener; @@ -251,12 +251,13 @@ public Control createContents(Composite parent) { // layout the table & its buttons variableLabel = new Label(pageComponent, SWT.LEFT); - if (currentResource == null) + if (currentResource == null) { variableLabel.setText(IDEWorkbenchMessages.PathVariablesBlock_variablesLabel); - else + } else { variableLabel.setText(NLS.bind( IDEWorkbenchMessages.PathVariablesBlock_variablesLabelForResource, currentResource.getName())); + } data = new GridData(); data.horizontalAlignment = GridData.FILL; @@ -313,8 +314,9 @@ public void widgetSelected(SelectionEvent e) { @Override public void mouseDoubleClick(MouseEvent e) { int itemsSelectedCount = variableTable.getTable().getSelectionCount(); - if (itemsSelectedCount == 1 && canChangeSelection()) + if (itemsSelectedCount == 1 && canChangeSelection()) { editSelectedVariable(); + } } @Override public void mouseDown(MouseEvent e) { } @@ -369,10 +371,11 @@ public void update(ViewerCell cell) { URI resolvedURI = pathVariableManager.resolveURI(URIUtil.toURI(value)); IPath resolvedValue = URIUtil.toPath(resolvedURI); IFileInfo file = IDEResourceInfoUtils.getFileInfo(resolvedValue); - if (!isBuiltInVariable(varName)) + if (!isBuiltInVariable(varName)) { cell.setImage(file.exists() ? (file.isDirectory() ? FOLDER_IMG : FILE_IMG) : imageUnknown); - else + } else { cell.setImage(BUILTIN_IMG); + } } } @@ -589,8 +592,9 @@ private void initTemporaryState() { tempPathVariables.clear(); for (String varName : pathVariableManager.getPathVariableNames()) { // hide the PARENT variable - if (varName.equals(PARENT_VARIABLE_NAME)) + if (varName.equals(PARENT_VARIABLE_NAME)) { continue; + } try { URI uri = pathVariableManager.getURIValue(varName); // the value may not exist any more @@ -659,8 +663,9 @@ public boolean performOk() { for (Entry entry : tempPathVariables.entrySet()) { String variableName = entry.getKey(); IPath variableValue = entry.getValue(); - if (!isBuiltInVariable(variableName)) + if (!isBuiltInVariable(variableName)) { pathVariableManager.setURIValue(variableName, URIUtil.toURI(variableValue)); + } } // re-initialize temporary state initTemporaryState(); @@ -692,8 +697,9 @@ private boolean canChangeSelection() { for (int selectedIndex : variableTable.getTable().getSelectionIndices()) { TableItem selectedItem = variableTable.getTable().getItem(selectedIndex); String varName = (String) selectedItem.getData(); - if (isBuiltInVariable(varName)) + if (isBuiltInVariable(varName)) { return false; + } } return true; } @@ -761,10 +767,11 @@ private void updateWidgetState() { public void setResource(IResource resource) { currentResource = resource; - if (resource != null) + if (resource != null) { pathVariableManager = resource.getPathVariableManager(); - else + } else { pathVariableManager = ResourcesPlugin.getWorkspace().getPathVariableManager(); + } removedVariableNames = new HashSet<>(); tempPathVariables = new TreeMap<>(); // initialize internal model @@ -778,7 +785,8 @@ public void reloadContent() { removedVariableNames = new HashSet<>(); tempPathVariables = new TreeMap<>(); initTemporaryState(); - if (variableTable != null) + if (variableTable != null) { updateWidgetState(); + } } } diff --git a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/dialogs/ProjectContentsLocationArea.java b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/dialogs/ProjectContentsLocationArea.java index 341a2cf150c..0901170e908 100644 --- a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/dialogs/ProjectContentsLocationArea.java +++ b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/dialogs/ProjectContentsLocationArea.java @@ -85,7 +85,7 @@ public interface IErrorMessageReporter { private Button browseButton; - private IErrorMessageReporter errorReporter; + private final IErrorMessageReporter errorReporter; private String projectName = IDEResourceInfoUtils.EMPTY_STRING; @@ -304,8 +304,9 @@ private void handleLocationBrowseButtonPressed() { IFileInfo info; info = IDEResourceInfoUtils.getFileInfo(dirName); - if (info == null || !(info.exists())) + if (info == null || !(info.exists())) { dirName = IDEResourceInfoUtils.EMPTY_STRING; + } } else { String value = getDialogSettings().get(SAVED_LOCATION_ATTR); if (value != null) { @@ -329,8 +330,9 @@ private void handleLocationBrowseButtonPressed() { } else { URI uri = getSelectedConfiguration().getContributor() .browseFileSystem(dirName, browseButton.getShell()); - if (uri != null) + if (uri != null) { selectedDirectory = uri.toString(); + } } if (selectedDirectory != null) { diff --git a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/dialogs/ProjectLinkedResourcePage.java b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/dialogs/ProjectLinkedResourcePage.java index 3c2b4d42532..721006e677f 100644 --- a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/dialogs/ProjectLinkedResourcePage.java +++ b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/dialogs/ProjectLinkedResourcePage.java @@ -47,8 +47,8 @@ public class ProjectLinkedResourcePage extends PropertyPage implements private Label topLabel; - private PathVariablesGroup pathVariablesGroup; - private LinkedResourceEditor linkedResourceEditor; + private final PathVariablesGroup pathVariablesGroup; + private final LinkedResourceEditor linkedResourceEditor; public ProjectLinkedResourcePage() { pathVariablesGroup = new PathVariablesGroup(true, IResource.FILE | IResource.FOLDER); @@ -91,10 +91,11 @@ protected Control createContents(Composite parent) { @Override public void widgetSelected(SelectionEvent e) { CTabFolder source = (CTabFolder) e.getSource(); - if (source.getSelectionIndex() == 1) + if (source.getSelectionIndex() == 1) { switchToLinkedResources(); - else + } else { switchToPathVariables(); + } } }); diff --git a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/dialogs/ProjectNaturesPage.java b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/dialogs/ProjectNaturesPage.java index 354efdb6db9..d3d33020f4d 100644 --- a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/dialogs/ProjectNaturesPage.java +++ b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/dialogs/ProjectNaturesPage.java @@ -201,8 +201,8 @@ public void widgetSelected(SelectionEvent e) { } private static class NatureLabelProvider extends LabelProvider { - private IWorkspace workspace; - private Map natureImages; + private final IWorkspace workspace; + private final Map natureImages; public NatureLabelProvider(IWorkspace workspace) { this.workspace = workspace; @@ -214,8 +214,7 @@ public String getText(Object element) { IProjectNatureDescriptor nature = null; if (element instanceof IProjectNatureDescriptor) { nature = (IProjectNatureDescriptor) element; - } else if (element instanceof String) { - String natureId = (String) element; + } else if (element instanceof String natureId) { nature = this.workspace.getNatureDescriptor(natureId); if (nature == null) { return getMissingNatureLabel(natureId); @@ -259,8 +258,9 @@ protected String getMissingNatureLabel(String natureId) { protected String getNatureDescriptorLabel( IProjectNatureDescriptor natureDescriptor) { String label = natureDescriptor.getLabel(); - if (label.trim().isEmpty()) + if (label.trim().isEmpty()) { return natureDescriptor.getNatureId(); + } return label; } diff --git a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/dialogs/ProjectReferencePage.java b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/dialogs/ProjectReferencePage.java index 817d3ea571c..e5375fff6b9 100644 --- a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/dialogs/ProjectReferencePage.java +++ b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/dialogs/ProjectReferencePage.java @@ -76,8 +76,9 @@ protected Control createContents(Composite parent) { listViewer = CheckboxTableViewer.newCheckList(composite, SWT.TOP | SWT.BORDER); - if(!project.isOpen()) + if(!project.isOpen()) { listViewer.getControl().setEnabled(false); + } listViewer.setLabelProvider(WorkbenchLabelProvider .getDecoratingWorkbenchLabelProvider()); diff --git a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/dialogs/RelativePathVariableGroup.java b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/dialogs/RelativePathVariableGroup.java index a514c546a72..c3d2923dec0 100644 --- a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/dialogs/RelativePathVariableGroup.java +++ b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/dialogs/RelativePathVariableGroup.java @@ -46,7 +46,7 @@ public class RelativePathVariableGroup { private Shell shell; - private IModel content; + private final IModel content; private String label; @@ -57,7 +57,7 @@ public interface IModel { String getVariable(); } - + public RelativePathVariableGroup(IModel content) { this.content = content; } @@ -109,17 +109,19 @@ private void selectRelativeCombo() { variableCombo.addSelectionListener(new SelectionListener() { @Override public void widgetDefaultSelected(SelectionEvent e) { - if (variableCombo.getSelectionIndex() == (variableCombo.getItemCount() -1)) + if (variableCombo.getSelectionIndex() == (variableCombo.getItemCount() -1)) { editVariables(); - else + } else { selectVariable(variableCombo.getItem(variableCombo.getSelectionIndex())); + } } @Override public void widgetSelected(SelectionEvent e) { - if (variableCombo.getSelectionIndex() == (variableCombo.getItemCount() -1)) + if (variableCombo.getSelectionIndex() == (variableCombo.getItemCount() -1)) { editVariables(); - else + } else { selectVariable(variableCombo.getItem(variableCombo.getSelectionIndex())); + } } }); setupVariableContent(); @@ -129,15 +131,17 @@ public void widgetSelected(SelectionEvent e) { public void setupVariableContent() { IPathVariableManager pathVariableManager; - if (content.getResource() != null) + if (content.getResource() != null) { pathVariableManager = content.getResource().getPathVariableManager(); - else + } else { pathVariableManager = ResourcesPlugin.getWorkspace().getPathVariableManager(); + } ArrayList items = new ArrayList<>(); for (String variableName : pathVariableManager.getPathVariableNames()) { - if (variableName.equals("PARENT")) //$NON-NLS-1$ + if (variableName.equals("PARENT")) { //$NON-NLS-1$ continue; + } items.add(variableName); } items.add(IDEWorkbenchMessages.ImportTypeDialog_editVariables); @@ -146,10 +150,11 @@ public void setupVariableContent() { private void setupVariableCheckboxToolTip() { if (variableCheckbox != null) { - if (variableCheckbox.getSelection()) + if (variableCheckbox.getSelection()) { variableCheckbox.setToolTipText(IDEWorkbenchMessages.ImportTypeDialog_importElementsAsTooltipSet); - else + } else { variableCheckbox.setToolTipText(IDEWorkbenchMessages.ImportTypeDialog_importElementsAsTooltip); + } } } @@ -229,13 +234,14 @@ public static String getPreferredVariable(IPath[] paths, IPath commonRoot = null; for (IPath path : paths) { if (path != null) { - if (commonRoot == null) + if (commonRoot == null) { commonRoot = path; - else { + } else { int count = commonRoot.matchingFirstSegments(path); int remainingSegments = commonRoot.segmentCount() - count; - if (remainingSegments <= 0) + if (remainingSegments <= 0) { return null; + } commonRoot = commonRoot.removeLastSegments(remainingSegments); } } @@ -277,8 +283,9 @@ public static String getPreferredVariable(IPath[] paths, } if (mostAppropriate == null) { - if (mostAppropriateToParent == null) + if (mostAppropriateToParent == null) { return "PROJECT_LOC"; //$NON-NLS-1$ + } return mostAppropriateToParent; } return mostAppropriate; diff --git a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/dialogs/ResourceComparator.java b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/dialogs/ResourceComparator.java index 513ced6c4b9..3288635ec2a 100644 --- a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/dialogs/ResourceComparator.java +++ b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/dialogs/ResourceComparator.java @@ -47,7 +47,7 @@ public class ResourceComparator extends ViewerComparator { */ public static final int TYPE = 2; - private int criteria; + private final int criteria; /** * Creates a resource sorter that will use the given sort criteria. @@ -84,10 +84,9 @@ public int compare(Viewer viewer, Object o1, Object o2) { //have to deal with non-resources in navigator //if one or both objects are not resources, returned a comparison //based on class. - if (!(o1 instanceof IResource && o2 instanceof IResource)) { + if (!(o1 instanceof IResource r1 && o2 instanceof IResource)) { return compareClass(o1, o2); } - IResource r1 = (IResource) o1; IResource r2 = (IResource) o2; if (r1 instanceof IContainer && r2 instanceof IContainer) { diff --git a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/dialogs/ResourceFilterEditDialog.java b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/dialogs/ResourceFilterEditDialog.java index 687a859163b..50f9ff41319 100755 --- a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/dialogs/ResourceFilterEditDialog.java +++ b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/dialogs/ResourceFilterEditDialog.java @@ -32,7 +32,7 @@ */ public class ResourceFilterEditDialog extends SelectionDialog { - private ResourceFilterGroup resourceFilterGroup; + private final ResourceFilterGroup resourceFilterGroup; /** * Creates a resource filter edit dialog. @@ -114,8 +114,9 @@ public void setFilters(IResourceFilterDescription[] filters) { protected void okPressed() { // Sets the dialog result to the selected path variable name(s). try { - if (resourceFilterGroup.performOk()) + if (resourceFilterGroup.performOk()) { super.okPressed(); + } } catch (Throwable t) { IDEWorkbenchPlugin.log(t.getMessage(), t); } diff --git a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/dialogs/ResourceFilterGroup.java b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/dialogs/ResourceFilterGroup.java index 3db3ce67fe0..0d8c3d90d5b 100644 --- a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/dialogs/ResourceFilterGroup.java +++ b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/dialogs/ResourceFilterGroup.java @@ -154,7 +154,7 @@ public class ResourceFilterGroup { private Image inheritableIcon; private boolean tableViewCellEditorAdequatlyUsable; private Shell shell; - private IContainer nonExistantResource = getNonExistantResource(); + private final IContainer nonExistantResource = getNonExistantResource(); private IContainer resource = nonExistantResource; public ResourceFilterGroup() { @@ -175,10 +175,12 @@ public ResourceFilterGroup() { } Image getImage(String string, int i) { - if (string.equals(FilterTypeUtil.MODE)) + if (string.equals(FilterTypeUtil.MODE)) { return new Image[] { includeIcon, excludeIcon, inheritableIcon }[i]; - if (string.equals(FilterTypeUtil.TARGET)) + } + if (string.equals(FilterTypeUtil.TARGET)) { return new Image[] { fileIcon, folderIcon, fileFolderIcon }[i]; + } return null; } @@ -225,16 +227,18 @@ public Filters(IContainer resource) { public Filters(IResourceFilterDescription filters[]) { children = new LinkedList<>(); if (filters != null) { - for (IResourceFilterDescription filter : filters) + for (IResourceFilterDescription filter : filters) { addChild(new FilterCopy(UIResourceFilterDescription.wrap(filter))); + } } } public Filters(UIResourceFilterDescription filters[]) { children = new LinkedList<>(); if (filters != null) { - for (UIResourceFilterDescription filter : filters) + for (UIResourceFilterDescription filter : filters) { addChild(new FilterCopy(filter)); + } } } @@ -248,8 +252,9 @@ public void add(FilterCopy newFilter) { public void remove(FilterCopy filter) { super.removeChild(filter); - if (filter.original != null) + if (filter.original != null) { trash.add(filter); + } changed = true; } @@ -291,26 +296,30 @@ protected void argumentsChanged() { @Override public boolean hasChanged() { - if (changed) + if (changed) { return true; + } Iterator it = children.iterator(); while (it.hasNext()) { FilterCopy filter = it.next(); - if (filter.hasChanged()) + if (filter.hasChanged()) { return true; + } } return false; } public boolean isFirst(FilterCopy o) { - if (children.size() > 0) + if (children.size() > 0) { return children.getFirst().equals(o); + } return false; } public boolean isLast(FilterCopy o) { - if (children.size() > 0) + if (children.size() > 0) { return children.getLast().equals(o); + } return false; } @@ -332,8 +341,9 @@ class TreeContentProvider implements ITreeContentProvider { @Override public Object[] getChildren(Object parentElement) { if (parentElement == filters) { - if (filters.getChildren().length > 0) + if (filters.getChildren().length > 0) { return new Object[] {includeOnlyGroup, excludeAllGroup}; + } return new Object[0]; } if (parentElement instanceof String) { @@ -341,24 +351,27 @@ public Object[] getChildren(Object parentElement) { int mask = parentElement.equals(includeOnlyGroup) ? IResourceFilterDescription.INCLUDE_ONLY: IResourceFilterDescription.EXCLUDE_ALL; for (FilterCopy filterCopy : filters.getChildren()) { - if ((filterCopy.getType() & mask) != 0) + if ((filterCopy.getType() & mask) != 0) { list.add(filterCopy); + } } return list.toArray(); } - if (parentElement instanceof FilterCopy) + if (parentElement instanceof FilterCopy) { return ((FilterCopy) parentElement).getChildren(); + } return null; } @Override public Object getParent(Object element) { - if (element instanceof String) + if (element instanceof String) { return filters; - if (element instanceof FilterCopy) { - FilterCopy filterCopy = (FilterCopy) element; - if (filterCopy.getParent() != null && filterCopy.getParent() != filters) + } + if (element instanceof FilterCopy filterCopy) { + if (filterCopy.getParent() != null && filterCopy.getParent() != filters) { return filterCopy.getParent(); + } return ((filterCopy.getType() & IResourceFilterDescription.INCLUDE_ONLY) != 0) ? includeOnlyGroup: excludeAllGroup; } return null; @@ -415,8 +428,9 @@ public void applyStyles(TextStyle textStyle) { ICustomFilterArgumentUI getUI(String descriptorID) { ICustomFilterArgumentUI result = customfilterArgumentMap.get(descriptorID); - if (result == null) + if (result == null) { return result = customfilterArgumentMap.get(""); //default ui //$NON-NLS-1$ + } return result; } @@ -441,10 +455,11 @@ public void update(ViewerCell cell) { cell.setImage(getImage(FilterTypeUtil.MODE, element.equals(includeOnlyGroup) ? 0:1)); } if (column.equals(FilterTypeUtil.MODE)) { - if (element.equals(includeOnlyGroup)) + if (element.equals(includeOnlyGroup)) { cell.setText(IDEWorkbenchMessages.ResourceFilterPage_includeOnlyColumn); - else + } else { cell.setText(IDEWorkbenchMessages.ResourceFilterPage_excludeAllColumn); + } } } else { @@ -454,8 +469,9 @@ public void update(ViewerCell cell) { StyledString styledString = getStyleColumnText(filter); if (!isPartialFilter(filter)) { Object isInheritable = FilterTypeUtil.getValue(filter, FilterTypeUtil.INHERITABLE); - if (((Boolean)isInheritable).booleanValue()) + if (((Boolean)isInheritable).booleanValue()) { styledString.append(" " + IDEWorkbenchMessages.ResourceFilterPage_recursive); //$NON-NLS-1$ + } } cell.setText(styledString.toString()); @@ -494,8 +510,9 @@ private StyledString getStyleColumnText(FilterCopy filter) { } } if (children.length < 2 && !isUnaryOperator) { - if (children.length == 1) + if (children.length == 1) { buffer.append(whiteSpace, fPlainStyler); + } buffer.append(expression, fBoldStyler); } buffer.append(")", fBoldStyler); //$NON-NLS-1$ @@ -513,8 +530,9 @@ protected void measure(Event event, Object element) { private String getFilterTypeName(FilterCopy filter) { IFilterMatcherDescriptor desc = FilterTypeUtil.getDescriptor(filter .getId()); - if (desc != null) + if (desc != null) { return desc.getName(); + } return ""; //$NON-NLS-1$ } } @@ -524,8 +542,9 @@ class CellModifier implements ICellModifier { public boolean canModify(Object element, String property) { FilterCopy filter = (FilterCopy) element; if (property.equals(FilterTypeUtil.ARGUMENTS) - && !filter.hasStringArguments()) + && !filter.hasStringArguments()) { return false; + } return true; } @@ -563,10 +582,11 @@ public Control createContents(Composite parent) { return label; } - if (resource == nonExistantResource) + if (resource == nonExistantResource) { filters = new Filters(initialFilters); - else + } else { filters = new Filters(resource); + } Composite composite = new Composite(parent, SWT.NONE); GridLayout layout = new GridLayout(); @@ -782,8 +802,7 @@ public boolean isEnabled() { private void handleAdd(boolean createGroupOnly) { Object selectedObject = null; ISelection selection = filterView.getSelection(); - if (selection instanceof IStructuredSelection) { - IStructuredSelection structuredSelection = ((IStructuredSelection) selection); + if (selection instanceof IStructuredSelection structuredSelection) { selectedObject = structuredSelection.getFirstElement(); } handleAdd(selectedObject, createGroupOnly); @@ -799,8 +818,7 @@ private void handleAdd(Object selection, boolean createGroupOnly) { refreshAndSelect(newFilter); } } - else if (selection instanceof FilterCopy) { - FilterCopy filter = (FilterCopy) selection; + else if (selection instanceof FilterCopy filter) { if (filter.getChildrenLimit() > 0) { FilterCopy newFilter = new FilterCopy(); newFilter.setParent(filter); @@ -840,14 +858,15 @@ private void refreshAndSelect(FilterCopy newFilter) { } private boolean isAddEnabled(Object selection) { - if (selection == null) + if (selection == null) { return true; - if (selection instanceof FilterCopy) { - FilterCopy filter = (FilterCopy) selection; + } + if (selection instanceof FilterCopy filter) { return filter.getChildrenLimit() > 0; } - if (selection instanceof String) + if (selection instanceof String) { return true; + } return false; } @@ -856,8 +875,9 @@ private void addToTopLevelFilters(FilterCopy newFilter) { Object[] existingChildren = filterViewContentProvider.getChildren(value == 0? includeOnlyGroup:excludeAllGroup); filters.add(newFilter); filterView.refresh(); - if (existingChildren.length == 0) + if (existingChildren.length == 0) { filterView.setExpandedState(newFilter, true); + } } Action addSubGroupFilterAction = new AddSubFilterAction(true); @@ -870,26 +890,31 @@ protected FilterCopyDrop(Viewer viewer) { @Override public boolean performDrop(Object data) { Object target = getCurrentTarget(); - if (target == null) + if (target == null) { target = filters; + } FilterCopy[] toDrop = (FilterCopy[]) data; if (target instanceof FilterCopy) { - for (FilterCopy filterToDrop : toDrop) + for (FilterCopy filterToDrop : toDrop) { if (filterToDrop.equals(target) - || ((FilterCopy) target).hasParent(filterToDrop)) + || ((FilterCopy) target).hasParent(filterToDrop)) { return false; + } + } } for (FilterCopy filterToDrop : toDrop) { - if (target instanceof Filters) + if (target instanceof Filters) { filters.add(filterToDrop); + } if (target instanceof String) { FilterTypeUtil.setValue(filterToDrop, FilterTypeUtil.MODE, target.equals(includeOnlyGroup) ? 0 : 1); addToTopLevelFilters(filterToDrop); } - if (target instanceof FilterCopy) + if (target instanceof FilterCopy) { ((FilterCopy) target).addChild(filterToDrop); + } filterView.refresh(); filterView.reveal(filterToDrop); } @@ -900,8 +925,9 @@ public boolean performDrop(Object data) { public boolean validateDrop(Object target, int operation, TransferData transferType) { if (filterCopyTransfer.isSupportedType(transferType)) { - if (target instanceof FilterCopy) + if (target instanceof FilterCopy) { return ((FilterCopy) target).canAcceptDrop(); + } return true; } return false; @@ -926,8 +952,9 @@ public void dragSetData(DragSourceEvent event) { @Override public void dragStart(DragSourceEvent event) { - if (getFilterCopySelection().length == 0) + if (getFilterCopySelection().length == 0) { event.doit = false; + } } } @@ -996,21 +1023,24 @@ private void refreshEnablement() { if (addButton != null) { ISelection selection = filterView.getSelection(); IStructuredSelection structuredSelection = null; - if (selection instanceof IStructuredSelection) + if (selection instanceof IStructuredSelection) { structuredSelection = ((IStructuredSelection) selection); + } removeButton.setEnabled(structuredSelection != null && structuredSelection.size() > 0 && !(structuredSelection.getFirstElement() instanceof String)); editButton.setEnabled(structuredSelection != null && structuredSelection.size() == 1 && (structuredSelection.getFirstElement() instanceof FilterCopy)); - if (upButton != null) + if (upButton != null) { upButton.setEnabled(structuredSelection != null && (structuredSelection.size() > 0) && !isFirst(structuredSelection.getFirstElement())); - if (downButton != null) + } + if (downButton != null) { downButton.setEnabled(structuredSelection != null && (structuredSelection.size() > 0) && !isLast(structuredSelection.getFirstElement())); + } } } @@ -1031,8 +1061,7 @@ private boolean handleEdit() { handleAdd(firstElement, false); return true; } - if (firstElement instanceof FilterCopy) { - FilterCopy filter = (FilterCopy) firstElement; + if (firstElement instanceof FilterCopy filter) { FilterCopy copy = new FilterCopy(filter); copy.setParent(filter.getParent()); boolean isGroup = filter.getChildrenLimit() > 0; @@ -1066,16 +1095,16 @@ private void handleRemove() { ISelection selection = filterView.getSelection(); if (selection instanceof IStructuredSelection) { for (Object element : (IStructuredSelection) selection) { - if (element instanceof FilterCopy) { - FilterCopy filter = (FilterCopy) element; + if (element instanceof FilterCopy filter) { filter.getParent().removeChild(filter); } else { int mask = element.equals(includeOnlyGroup) ? IResourceFilterDescription.INCLUDE_ONLY: IResourceFilterDescription.EXCLUDE_ALL; for (FilterCopy filterCopy : filters.getChildren()) { - if ((filterCopy.getType() & mask) != 0) + if ((filterCopy.getType() & mask) != 0) { filters.removeChild(filterCopy); + } } } } @@ -1112,8 +1141,9 @@ private static int getButtonWidthHint(Button button) { * Apply the default state of the resource. */ public void performDefaults() { - if (resource == null) + if (resource == null) { return; + } filters = new Filters(resource); filters.removeAll(); filterView.setInput(filters); @@ -1132,8 +1162,9 @@ public UIResourceFilterDescription[] getFilters() { public void setFilters(IResourceFilterDescription[] filters) { initialFilters = new UIResourceFilterDescription[filters.length]; - for (int i = 0; i < filters.length; i++) + for (int i = 0; i < filters.length; i++) { initialFilters[i] = UIResourceFilterDescription.wrap(filters[i]); + } } public void setFilters(UIResourceFilterDescription[] filters) { @@ -1202,7 +1233,7 @@ private void disposeIcons() { } } - private FilterCopyTransfer filterCopyTransfer = new FilterCopyTransfer(); + private final FilterCopyTransfer filterCopyTransfer = new FilterCopyTransfer(); class FilterCopyTransfer extends ByteArrayTransfer { @@ -1211,17 +1242,18 @@ private FilterCopyTransfer() { @Override public void javaToNative(Object object, TransferData transferData) { - if (object == null || !(object instanceof FilterCopy[])) + if (object == null || !(object instanceof FilterCopy[] myTypes)) { return; + } if (isSupportedType(transferData)) { - FilterCopy[] myTypes = (FilterCopy[]) object; try { ByteArrayOutputStream out = new ByteArrayOutputStream(); byte[] buffer; try (DataOutputStream writeOut = new DataOutputStream(out)) { writeOut.writeInt(myTypes.length); - for (FilterCopy myType : myTypes) + for (FilterCopy myType : myTypes) { writeOut.writeInt(myType.getSerialNumber()); + } buffer = out.toByteArray(); } super.javaToNative(buffer, transferData); @@ -1234,8 +1266,9 @@ public void javaToNative(Object object, TransferData transferData) { public Object nativeToJava(TransferData transferData) { if (isSupportedType(transferData)) { byte[] buffer = (byte[]) super.nativeToJava(transferData); - if (buffer == null) + if (buffer == null) { return null; + } FilterCopy[] myData; try { ByteArrayInputStream in = new ByteArrayInputStream(buffer); @@ -1247,8 +1280,9 @@ public Object nativeToJava(TransferData transferData) { int serialNumber = readIn.readInt(); FilterCopy tmp = filters .findBySerialNumber(serialNumber); - if (tmp != null) - droppedFilters.add(tmp); + if (tmp != null) { + droppedFilters.add(tmp); + } } myData = droppedFilters .toArray(new FilterCopy[0]); @@ -1298,38 +1332,45 @@ public static void setValue(FilterCopy filter, String property, Object value) { if (value instanceof Integer) { int selection = ((Integer) value).intValue(); descriptor = FilterTypeUtil.getDescriptorFromIndex(selection); - } else + } else { descriptor = FilterTypeUtil.getDescriptorByName((String) value); - if (descriptor != null) + } + if (descriptor != null) { filter.setId(descriptor.getId()); + } } if (property.equals(FilterTypeUtil.MODE)) { int selection = ((Integer) value).intValue(); int type = filter.getType() & ~(IResourceFilterDescription.INCLUDE_ONLY | IResourceFilterDescription.EXCLUDE_ALL); - if (selection == 0) + if (selection == 0) { filter.setType(type | IResourceFilterDescription.INCLUDE_ONLY); - else + } else { filter.setType(type | IResourceFilterDescription.EXCLUDE_ALL); + } } if (property.equals(FilterTypeUtil.TARGET)) { int selection = ((Integer) value).intValue(); int type = filter.getType() & ~(IResourceFilterDescription.FILES | IResourceFilterDescription.FOLDERS); - if (selection == 0) + if (selection == 0) { filter.setType(type | IResourceFilterDescription.FILES); - if (selection == 1) + } + if (selection == 1) { filter.setType(type | IResourceFilterDescription.FOLDERS); - if (selection == 2) + } + if (selection == 2) { filter.setType(type | IResourceFilterDescription.FILES | IResourceFilterDescription.FOLDERS); + } } if (property.equals(FilterTypeUtil.INHERITABLE)) { int type = filter.getType() & ~IResourceFilterDescription.INHERITABLE; - if (((Boolean) value).booleanValue()) + if (((Boolean) value).booleanValue()) { filter.setType(type | IResourceFilterDescription.INHERITABLE); - else + } else { filter.setType(type); + } } if (property.equals(FilterTypeUtil.ARGUMENTS)) { filter.setArguments(value.equals("") ? null : value); //$NON-NLS-1$ @@ -1340,8 +1381,9 @@ static IFilterMatcherDescriptor getDescriptor(String id) { IFilterMatcherDescriptor[] descriptors = ResourcesPlugin.getWorkspace() .getFilterMatcherDescriptors(); for (IFilterMatcherDescriptor descriptor : descriptors) { - if (descriptor.getId().equals(id)) + if (descriptor.getId().equals(id)) { return descriptor; + } } return null; } @@ -1350,8 +1392,9 @@ static int getDescriptorIndex(String id) { IFilterMatcherDescriptor descriptors[] = ResourcesPlugin.getWorkspace() .getFilterMatcherDescriptors(); for (int i = 0; i < descriptors.length; i++) { - if (descriptors[i].getId().equals(id)) + if (descriptors[i].getId().equals(id)) { return i; + } } return -1; } @@ -1362,26 +1405,32 @@ static Object getValue(UIResourceFilterDescription filter, String property) { return getDescriptorIndex(id); } if (property.equals(MODE)) { - if ((filter.getType() & IResourceFilterDescription.INCLUDE_ONLY) != 0) + if ((filter.getType() & IResourceFilterDescription.INCLUDE_ONLY) != 0) { return 0; + } return 1; } if (property.equals(TARGET)) { boolean includeFiles = (filter.getType() & IResourceFilterDescription.FILES) != 0; boolean includeFolders = (filter.getType() & IResourceFilterDescription.FOLDERS) != 0; - if (includeFiles && includeFolders) + if (includeFiles && includeFolders) { return 2; - if (includeFiles) + } + if (includeFiles) { return 0; - if (includeFolders) + } + if (includeFolders) { return 1; + } } - if (property.equals(INHERITABLE)) + if (property.equals(INHERITABLE)) { return Boolean.valueOf( (filter.getType() & IResourceFilterDescription.INHERITABLE) != 0); + } - if (property.equals(ARGUMENTS)) + if (property.equals(ARGUMENTS)) { return filter.getFileInfoMatcherDescription().getArguments() != null ? filter.getFileInfoMatcherDescription().getArguments() : ""; //$NON-NLS-1$ + } return null; } @@ -1398,26 +1447,31 @@ static String[] getFilterNames(boolean groupOnly) { LinkedList names = new LinkedList<>(); for (IFilterMatcherDescriptor descriptor : descriptors) { // remove legacy filters - if (descriptor.getId().equals(DefaultCustomFilterArgumentUI.REGEX_FILTER_ID)) + if (descriptor.getId().equals(DefaultCustomFilterArgumentUI.REGEX_FILTER_ID)) { continue; - if (descriptor.getId().equals(StringFileInfoMatcher.ID)) + } + if (descriptor.getId().equals(StringFileInfoMatcher.ID)) { continue; + } boolean isGroup = descriptor.getArgumentType().equals( IFilterMatcherDescriptor.ARGUMENT_TYPE_FILTER_MATCHER) || descriptor.getArgumentType().equals( IFilterMatcherDescriptor.ARGUMENT_TYPE_FILTER_MATCHERS); - if (isGroup == groupOnly) + if (isGroup == groupOnly) { names.add(descriptor.getName()); + } } return names.toArray(new String[0]); } private static void sortDescriptors(IFilterMatcherDescriptor[] descriptors) { Arrays.sort(descriptors, (arg0, arg1) -> { - if (arg0.getId().equals(FileInfoAttributesMatcher.ID)) + if (arg0.getId().equals(FileInfoAttributesMatcher.ID)) { return -1; - if (arg1.getId().equals(FileInfoAttributesMatcher.ID)) + } + if (arg1.getId().equals(FileInfoAttributesMatcher.ID)) { return 1; + } return arg0.getId().compareTo(arg1.getId()); }); } @@ -1428,8 +1482,9 @@ static String getDefaultFilterID() { sortDescriptors(descriptors); for (IFilterMatcherDescriptor descriptor : descriptors) { if (descriptor.getArgumentType().equals( - IFilterMatcherDescriptor.ARGUMENT_TYPE_STRING)) + IFilterMatcherDescriptor.ARGUMENT_TYPE_STRING)) { return descriptor.getId(); + } } return descriptors[0].getId(); } @@ -1444,8 +1499,9 @@ static IFilterMatcherDescriptor getDescriptorByName(String name) { IFilterMatcherDescriptor[] descriptors = ResourcesPlugin.getWorkspace() .getFilterMatcherDescriptors(); for (IFilterMatcherDescriptor descriptor : descriptors) { - if (descriptor.getName().equals(name)) + if (descriptor.getName().equals(name)) { return descriptor; + } } return null; } @@ -1490,8 +1546,9 @@ public void removeAll() { Iterator it = children.iterator(); while (it.hasNext()) { FilterCopy child = it.next(); - if (child.parent == this) + if (child.parent == this) { child.parent = null; + } } children.clear(); serializeChildren(); @@ -1513,8 +1570,9 @@ public boolean canAcceptDrop() { public boolean hasParent(FilterCopy filterCopy) { FilterCopy filter = this; do { - if (filter.equals(filterCopy)) + if (filter.equals(filterCopy)) { return true; + } filter = filter.getParent(); } while (filter != null); return false; @@ -1536,11 +1594,11 @@ private void internalCopy(UIResourceFilterDescription filter) { project = filter.getProject(); type = filter.getType(); arguments = filter.getFileInfoMatcherDescription().getArguments(); - if (arguments instanceof FileInfoMatcherDescription[]) { - FileInfoMatcherDescription[] descs = (FileInfoMatcherDescription[]) arguments; + if (arguments instanceof FileInfoMatcherDescription[] descs) { FilterCopy [] tmp = new FilterCopy[descs.length]; - for (int i = 0; i < tmp.length; i++) + for (int i = 0; i < tmp.length; i++) { tmp[i] = new FilterCopy(this, descs[i]); + } arguments = tmp; } } @@ -1569,11 +1627,11 @@ public FilterCopy(FilterCopy parent, FileInfoMatcherDescription description) { project = parent.getProject(); type = parent.getType(); arguments = description.getArguments(); - if (arguments instanceof FileInfoMatcherDescription[]) { - FileInfoMatcherDescription[] descs = (FileInfoMatcherDescription[]) arguments; + if (arguments instanceof FileInfoMatcherDescription[] descs) { FilterCopy [] tmp = new FilterCopy[descs.length]; - for (int i = 0; i < tmp.length; i++) + for (int i = 0; i < tmp.length; i++) { tmp[i] = new FilterCopy(parent, descs[i]); + } arguments = tmp; } } @@ -1624,9 +1682,10 @@ public void setType(int type) { public boolean hasStringArguments() { IFilterMatcherDescriptor descriptor = FilterTypeUtil.getDescriptor(id); - if (descriptor != null) + if (descriptor != null) { return descriptor.getArgumentType().equals( IFilterMatcherDescriptor.ARGUMENT_TYPE_STRING); + } return false; } @@ -1634,20 +1693,22 @@ public int getChildrenLimit() { IFilterMatcherDescriptor descriptor = FilterTypeUtil.getDescriptor(id); if (descriptor != null) { if (descriptor.getArgumentType().equals( - IFilterMatcherDescriptor.ARGUMENT_TYPE_FILTER_MATCHER)) + IFilterMatcherDescriptor.ARGUMENT_TYPE_FILTER_MATCHER)) { return 1; + } if (descriptor.getArgumentType().equals( - IFilterMatcherDescriptor.ARGUMENT_TYPE_FILTER_MATCHERS)) + IFilterMatcherDescriptor.ARGUMENT_TYPE_FILTER_MATCHERS)) { return Integer.MAX_VALUE; + } } return 0; } @Override public boolean equals(Object o) { - if (!(o instanceof FilterCopy)) + if (!(o instanceof FilterCopy filter)) { return false; - FilterCopy filter = (FilterCopy) o; + } return serialNumber == filter.serialNumber; } @@ -1666,11 +1727,13 @@ public FilterCopy findBySerialNumber(int number) { while (!pending.isEmpty()) { FilterCopy filter = pending.getFirst(); pending.removeFirst(); - if (filter.serialNumber == number) + if (filter.serialNumber == number) { return filter; + } FilterCopy[] tmp = filter.getChildren(); - if (tmp != null) + if (tmp != null) { pending.addAll(Arrays.asList(tmp)); + } } return null; } @@ -1695,12 +1758,13 @@ protected void initializeChildren() { } } if (getArguments() instanceof FilterCopy[] filters) { - if (filters != null) + if (filters != null) { for (FilterCopy filter : filters) { FilterCopy child = filter; child.parent = this; children.add(child); } + } } } } @@ -1708,8 +1772,9 @@ protected void initializeChildren() { protected void addChild(FilterCopy child) { initializeChildren(); - if (child.getParent() != null) + if (child.getParent() != null) { child.getParent().removeChild(child); + } children.add(child); child.parent = this; serializeChildren(); @@ -1718,8 +1783,9 @@ protected void addChild(FilterCopy child) { protected void removeChild(FilterCopy child) { initializeChildren(); children.remove(child); - if (child.parent == this) + if (child.parent == this) { child.parent = null; + } serializeChildren(); } @@ -1730,8 +1796,9 @@ protected void serializeChildren() { protected void argumentsChanged() { initializeChildren(); - if (children != null) + if (children != null) { arguments = children.toArray(new FilterCopy[0]); + } FilterCopy up = parent; while (up != null) { up.serializeChildren(); @@ -1743,8 +1810,9 @@ public boolean isUnderAGroupFilter() { // a partial filter is a filter that is located under a group, but not // the root group if (parent != null) { - if ((parent.getChildrenLimit() > 0) && (parent.getParent() != null)) + if ((parent.getChildrenLimit() > 0) && (parent.getParent() != null)) { return true; + } } return false; } @@ -1754,11 +1822,11 @@ public FileInfoMatcherDescription getFileInfoMatcherDescription() { Object arg = FilterCopy.this.getArguments(); - if (arg instanceof FilterCopy []) { - FilterCopy [] filterCopies = (FilterCopy []) arg; + if (arg instanceof FilterCopy [] filterCopies) { FileInfoMatcherDescription[] descriptions = new FileInfoMatcherDescription[filterCopies.length]; - for (int i = 0; i < descriptions.length; i++) + for (int i = 0; i < descriptions.length; i++) { descriptions[i] = filterCopies[i].getFileInfoMatcherDescription(); + } arg = descriptions; } @@ -1768,7 +1836,7 @@ public FileInfoMatcherDescription getFileInfoMatcherDescription() { class FilterEditDialog extends TrayDialog { - private FilterCopy filter; + private final FilterCopy filter; protected Button filesButton; protected Button foldersButton; @@ -2027,8 +2095,9 @@ private void createMatcherCombo(Composite composite, Font font) { public void widgetSelected(SelectionEvent e) { FilterTypeUtil.setValue(filter, FilterTypeUtil.ID, idCombo .getItem(idCombo.getSelectionIndex())); - if (filter.hasStringArguments()) + if (filter.hasStringArguments()) { filter.setArguments(""); //$NON-NLS-1$ + } setupPatternLine(); currentCustomFilterArgumentUI.selectionChanged(); getShell().layout(true); @@ -2049,8 +2118,9 @@ public void widgetSelected(SelectionEvent e) { ICustomFilterArgumentUI getUI(String descriptorID) { ICustomFilterArgumentUI result = customfilterArgumentMap.get(descriptorID); - if (result == null) + if (result == null) { return result = customfilterArgumentMap.get(""); //default ui //$NON-NLS-1$ + } return result; } @@ -2059,9 +2129,9 @@ private void setupPatternLine() { if (createGroupOnly) { String item = idCombo.getItem(idCombo.getSelectionIndex()); descriptor = FilterTypeUtil.getDescriptorByName(item); - } - else + } else { descriptor = FilterTypeUtil.getDescriptor(filter.getId()); + } Font font = idComposite.getFont(); ICustomFilterArgumentUI customFilterArgumentUI = getUI(descriptor.getId()); if (!currentCustomFilterArgumentUI.getID().equals(customFilterArgumentUI.getID())) { @@ -2173,10 +2243,11 @@ protected Control createContents(Composite parent) { public void updateFinishControls() { if (getButton(OK) != null) { - if (currentCustomFilterArgumentUI != null) + if (currentCustomFilterArgumentUI != null) { getButton(OK).setEnabled(currentCustomFilterArgumentUI.validate() == null); - else + } else { getButton(OK).setEnabled(true); + } } } @Override @@ -2188,13 +2259,14 @@ protected boolean isResizable() { protected void configureShell(Shell newShell) { String title = null; if (creatingNewFilter) { - if (resource.getType() == IResource.PROJECT) + if (resource.getType() == IResource.PROJECT) { title = NLS.bind(IDEWorkbenchMessages.ResourceFilterPage_newFilterDialogTitleProject, resource.getName()); - else + } else { title = NLS.bind(IDEWorkbenchMessages.ResourceFilterPage_newFilterDialogTitleFolder, resource.getName()); - } - else + } + } else { title = IDEWorkbenchMessages.ResourceFilterPage_editFilterDialogTitle; + } newShell.setText(title); super.configureShell(newShell); } @@ -2401,8 +2473,9 @@ private void setupDescriptionText(String errorString) { BufferedReader reader = new BufferedReader(new StringReader(errorString)); try { String tmp = reader.readLine(); - if (tmp != null) + if (tmp != null) { errorString = tmp; + } } catch (IOException e) { } @@ -2416,14 +2489,16 @@ private void setupDescriptionText(String errorString) { selectedOperator); description.setText(""); //$NON-NLS-1$ if (selectedKeyOperatorType.equals(String.class)) { - if (!argumentsRegularExpresion.getSelection()) + if (!argumentsRegularExpresion.getSelection()) { description.setText(IDEWorkbenchMessages.ResourceFilterPage_multiMatcher_Matcher); + } } if (selectedKeyOperatorType.equals(Integer.class)) { - if (selectedKey.equals(FileInfoAttributesMatcher.KEY_LAST_MODIFIED) || selectedKey.equals(FileInfoAttributesMatcher.KEY_CREATED)) + if (selectedKey.equals(FileInfoAttributesMatcher.KEY_LAST_MODIFIED) || selectedKey.equals(FileInfoAttributesMatcher.KEY_CREATED)) { description.setText(IDEWorkbenchMessages.ResourceFilterPage_multiMatcher_TimeInterval); - else + } else { description.setText(IDEWorkbenchMessages.ResourceFilterPage_multiMatcher_FileLength); + } } } shell.layout(true, true); @@ -2485,10 +2560,11 @@ public void widgetSelected(SelectionEvent e) { FileInfoAttributesMatcher.Argument argument = FileInfoAttributesMatcher.decodeArguments((String) filter.getArguments()); String local = MultiMatcherLocalization.getLocalMultiMatcherKey(argument.key); int index = multiKey.indexOf(local); - if (index != -1) + if (index != -1) { multiKey.select(index); - else + } else { multiKey.select(0); + } setupMultiOperatorAndField(true); } @@ -2502,10 +2578,11 @@ private void setupMultiOperatorAndField(boolean updateOperator) { FileInfoAttributesMatcher.Argument argument = FileInfoAttributesMatcher.decodeArguments((String) filter.getArguments()); String local = MultiMatcherLocalization.getLocalMultiMatcherKey(argument.operator); int index = multiOperator.indexOf(local); - if (index != -1) + if (index != -1) { multiOperator.select(index); - else + } else { multiOperator.select(0); + } } String selectedOperator = MultiMatcherLocalization.getMultiMatcherKey(multiOperator.getText()); @@ -2552,8 +2629,9 @@ private void setupMultiOperatorAndField(boolean updateOperator) { FileInfoAttributesMatcher.Argument argument = FileInfoAttributesMatcher.decodeArguments((String) filter.getArguments()); valueCache.put(intiantiatedKeyOperatorType.getName(), argument.pattern); argument.pattern = valueCache.get(selectedKeyOperatorType.getName()); - if (argument.pattern == null) + if (argument.pattern == null) { argument.pattern = ""; //$NON-NLS-1$ + } filter.setArguments(FileInfoAttributesMatcher.encodeArguments(argument)); } @@ -2619,8 +2697,9 @@ private void setupMultiOperatorAndField(boolean updateOperator) { public void widgetSelected(SelectionEvent e) { setupDescriptionText(null); storeMultiSelection(); - if (fContentAssistField != null) + if (fContentAssistField != null) { fContentAssistField.setEnabled(argumentsRegularExpresion.getSelection()); + } } }); argumentsCaseSensitive.addSelectionListener(new SelectionAdapter() { @@ -2651,10 +2730,11 @@ public void widgetSelected(SelectionEvent e) { if (filter.hasStringArguments()) { FileInfoAttributesMatcher.Argument argument = FileInfoAttributesMatcher.decodeArguments((String) filter.getArguments()); - if (selectedKey.equals(FileInfoAttributesMatcher.KEY_LAST_MODIFIED) || selectedKey.equals(FileInfoAttributesMatcher.KEY_CREATED)) + if (selectedKey.equals(FileInfoAttributesMatcher.KEY_LAST_MODIFIED) || selectedKey.equals(FileInfoAttributesMatcher.KEY_CREATED)) { arguments.setText(convertToEditableTimeInterval(argument.pattern)); - else + } else { arguments.setText(convertToEditableLength(argument.pattern)); + } } arguments.addModifyListener(e -> storeMultiSelection()); @@ -2704,16 +2784,18 @@ public void widgetSelected(SelectionEvent e) { }); if (filter.hasStringArguments()) { FileInfoAttributesMatcher.Argument argument = FileInfoAttributesMatcher.decodeArguments((String) filter.getArguments()); - if (argument.pattern.isEmpty()) + if (argument.pattern.isEmpty()) { argumentsBoolean.select(0); - else + } else { argumentsBoolean.select(Boolean.parseBoolean(argument.pattern) ? 0:1); + } } } intiantiatedKeyOperatorType = selectedKeyOperatorType; - if (fContentAssistField != null) + if (fContentAssistField != null) { fContentAssistField.setEnabled(isUsingRegularExpression); + } shell.layout(true, true); if (initializationComplete) { @@ -2721,8 +2803,9 @@ public void widgetSelected(SelectionEvent e) { Point shellSize = shell.getSize(); size.x = Math.max(size.x, shellSize.x); size.y = Math.max(size.y, shellSize.y); - if ((size.x > shellSize.x) || (size.y > shellSize.y)) + if ((size.x > shellSize.x) || (size.y > shellSize.y)) { shell.setSize(size); + } } shell.redraw(); setupDescriptionText(null); @@ -2732,32 +2815,37 @@ public void widgetSelected(SelectionEvent e) { private static final long[] TIME_INTERVAL_SCALE = { 60, 60, 24 }; private String convertToEditableTimeInterval(String string) { - if (string.isEmpty()) + if (string.isEmpty()) { return string; + } long value; try { value = Long.parseLong(string); } catch (NumberFormatException e) { value = 0; } - if (value == 0) + if (value == 0) { return Long.toString(0); + } for (int i = 0; i < TIME_INTERVAL_PREFIXES.length - 1; i++) { - if (value % TIME_INTERVAL_SCALE[i] != 0) + if (value % TIME_INTERVAL_SCALE[i] != 0) { return Long.toString(value) + TIME_INTERVAL_PREFIXES[i]; + } value /= TIME_INTERVAL_SCALE[i]; } return Long.toString(value) + TIME_INTERVAL_PREFIXES[TIME_INTERVAL_PREFIXES.length - 1]; } private String convertFromEditableTimeInterval(String string) { - if (string.isEmpty()) + if (string.isEmpty()) { return string; + } for (int i = 1; i < TIME_INTERVAL_PREFIXES.length; i++) { if (string.endsWith(TIME_INTERVAL_PREFIXES[i])) { long value = Long.parseLong(string.substring(0, string.length() - 1)); - for (int j = 0; j < i; j++) + for (int j = 0; j < i; j++) { value *= TIME_INTERVAL_SCALE[j]; + } return Long.toString(value); } } @@ -2770,29 +2858,34 @@ private String convertFromEditableTimeInterval(String string) { // converts "32768" to "32k" private String convertToEditableLength(String string) { - if (string.isEmpty()) + if (string.isEmpty()) { return string; + } long value; try { value = Long.parseLong(string); } catch (NumberFormatException e) { value = 0; } - if (value == 0) + if (value == 0) { return Long.toString(0); + } for (int i = 0; i < METRIC_PREFIXES.length; i++) { - if (value % 1024 != 0) + if (value % 1024 != 0) { return Long.toString(value) + METRIC_PREFIXES[i]; - if ((i + 1) < METRIC_PREFIXES.length) + } + if ((i + 1) < METRIC_PREFIXES.length) { value /= 1024; + } } return Long.toString(value) + METRIC_PREFIXES[METRIC_PREFIXES.length - 1]; } // converts "32k" to "32768" private String convertFromEditableLength(String string) throws NumberFormatException { - if (string.isEmpty()) + if (string.isEmpty()) { return string; + } for (int i = 1; i < METRIC_PREFIXES.length; i++) { if (string.endsWith(METRIC_PREFIXES[i])) { long value = Long.parseLong(string.substring(0, string.length() - 1)); @@ -2843,23 +2936,27 @@ private void storeMultiSelection() { } if (intiantiatedKeyOperatorType.equals(String.class) && arguments != null) { argument.pattern = arguments.getText(); - if (argumentsRegularExpresion != null) + if (argumentsRegularExpresion != null) { argument.regularExpression = argumentsRegularExpresion.getSelection(); - if (argumentsCaseSensitive != null) + } + if (argumentsCaseSensitive != null) { argument.caseSensitive = argumentsCaseSensitive.getSelection(); + } } if (intiantiatedKeyOperatorType.equals(Integer.class) && arguments != null) { try { - if (selectedKey.equals(FileInfoAttributesMatcher.KEY_LAST_MODIFIED) || selectedKey.equals(FileInfoAttributesMatcher.KEY_CREATED)) + if (selectedKey.equals(FileInfoAttributesMatcher.KEY_LAST_MODIFIED) || selectedKey.equals(FileInfoAttributesMatcher.KEY_CREATED)) { argument.pattern = convertFromEditableTimeInterval(arguments.getText()); - else + } else { argument.pattern = convertFromEditableLength(arguments.getText()); + } } catch (NumberFormatException e) { argument.pattern = arguments.getText(); } } - if (intiantiatedKeyOperatorType.equals(Boolean.class) && argumentsBoolean != null) + if (intiantiatedKeyOperatorType.equals(Boolean.class) && argumentsBoolean != null) { argument.pattern = MultiMatcherLocalization.getMultiMatcherKey(argumentsBoolean.getText()); + } String encodedArgument = FileInfoAttributesMatcher.encodeArguments(argument); FilterTypeUtil.setValue(filter, FilterTypeUtil.ARGUMENTS, encodedArgument); } @@ -2868,8 +2965,9 @@ private void storeMultiSelection() { private String[] getLocalOperatorsForKey(String key) { String [] operators = FileInfoAttributesMatcher.getOperatorsForKey(key); String[] result = new String[operators.length]; - for (int i = 0; i < operators.length; i++) + for (int i = 0; i < operators.length; i++) { result[i] = MultiMatcherLocalization.getLocalMultiMatcherKey(operators[i]); + } return result; } @@ -2879,12 +2977,14 @@ private String[] getMultiMatcherKeys() { list.add(MultiMatcherLocalization.getLocalMultiMatcherKey(FileInfoAttributesMatcher.KEY_PROPJECT_RELATIVE_PATH)); list.add(MultiMatcherLocalization.getLocalMultiMatcherKey(FileInfoAttributesMatcher.KEY_LOCATION)); list.add(MultiMatcherLocalization.getLocalMultiMatcherKey(FileInfoAttributesMatcher.KEY_LAST_MODIFIED)); - if (FileInfoAttributesMatcher.supportCreatedKey()) + if (FileInfoAttributesMatcher.supportCreatedKey()) { list.add(MultiMatcherLocalization.getLocalMultiMatcherKey(FileInfoAttributesMatcher.KEY_CREATED)); + } list.add(MultiMatcherLocalization.getLocalMultiMatcherKey(FileInfoAttributesMatcher.KEY_LENGTH)); list.add(MultiMatcherLocalization.getLocalMultiMatcherKey(FileInfoAttributesMatcher.KEY_IS_READONLY)); - if (!Platform.getOS().equals(Platform.OS_WIN32)) + if (!Platform.getOS().equals(Platform.OS_WIN32)) { list.add(MultiMatcherLocalization.getLocalMultiMatcherKey(FileInfoAttributesMatcher.KEY_IS_SYMLINK)); + } return list.toArray(new String[0]); } @@ -2910,10 +3010,12 @@ public String validate() { if (intiantiatedKeyOperatorType.equals(String.class) && arguments != null) { argument.pattern = arguments.getText(); - if (argumentsRegularExpresion != null) + if (argumentsRegularExpresion != null) { argument.regularExpression = argumentsRegularExpresion.getSelection(); - if (argumentsCaseSensitive != null) + } + if (argumentsCaseSensitive != null) { argument.caseSensitive = argumentsCaseSensitive.getSelection(); + } String encodedArgument = FileInfoAttributesMatcher.encodeArguments(argument); FilterCopy copy = new FilterCopy(filter); FilterTypeUtil.setValue(copy, FilterTypeUtil.ARGUMENTS, encodedArgument); @@ -2969,18 +3071,22 @@ private String formatMultiMatcherArgument(FilterCopy filterCopy) { builder.append(MultiMatcherLocalization.getLocalMultiMatcherKey(argument.operator)); builder.append(' '); Class type = FileInfoAttributesMatcher.getTypeForKey(argument.key, argument.operator); - if (type.equals(String.class)) + if (type.equals(String.class)) { builder.append(argument.pattern); - if (type.equals(Boolean.class)) + } + if (type.equals(Boolean.class)) { builder.append(MultiMatcherLocalization.getLocalMultiMatcherKey(argument.pattern)); + } if (type.equals(Integer.class)) { - if (argument.key.equals(FileInfoAttributesMatcher.KEY_LAST_MODIFIED) || argument.key.equals(FileInfoAttributesMatcher.KEY_CREATED)) + if (argument.key.equals(FileInfoAttributesMatcher.KEY_LAST_MODIFIED) || argument.key.equals(FileInfoAttributesMatcher.KEY_CREATED)) { builder.append(convertToEditableTimeInterval(argument.pattern)); - else + } else { builder.append(convertToEditableLength(argument.pattern)); + } } - if (type.equals(Date.class)) + if (type.equals(Date.class)) { builder.append(DateFormat.getDateInstance().format(new Date(Long.parseLong(argument.pattern)))); + } return builder.toString(); } @@ -3033,13 +3139,15 @@ public void create(Composite argumentComposite, Font font) { GridData data = new GridData(SWT.FILL, SWT.FILL, true, true); argumentComposite.setLayoutData(data); argumentComposite.setFont(font); - if (filter.hasStringArguments()) + if (filter.hasStringArguments()) { createArgumentsArea(font, argumentComposite); + } createDescriptionArea(font, argumentComposite); - if (fContentAssistField != null) + if (fContentAssistField != null) { fContentAssistField.setEnabled(filter.getId().equals(REGEX_FILTER_ID)); + } argumentComposite.layout(true); } @@ -3052,9 +3160,10 @@ private void createArgumentsArea(Font font, Composite composite) { arguments.setFont(font); arguments.addModifyListener(e -> FilterTypeUtil.setValue(filter, FilterTypeUtil.ARGUMENTS, arguments.getText())); - if (filter.hasStringArguments()) + if (filter.hasStringArguments()) { arguments.setText((String) FilterTypeUtil.getValue(filter, FilterTypeUtil.ARGUMENTS)); + } arguments.setEnabled(filter.hasStringArguments()); setArgumentLabelEnabled(); @@ -3091,11 +3200,13 @@ Label addLabel(Composite composite, String text) { @Override public void selectionChanged() { - if (arguments != null) + if (arguments != null) { arguments.setEnabled(filter.hasStringArguments()); + } setArgumentLabelEnabled(); - if (fContentAssistField != null) + if (fContentAssistField != null) { fContentAssistField.setEnabled(filter.getId().equals(REGEX_FILTER_ID)); + } description.setText(FilterTypeUtil .getDescriptor(filter.getId()).getDescription()); } @@ -3151,16 +3262,18 @@ class MultiMatcherLocalization { static public String getLocalMultiMatcherKey(String key) { for (String[] matcherKey : multiMatcherKey) { - if (matcherKey[0].equals(key)) + if (matcherKey[0].equals(key)) { return matcherKey[1]; + } } return null; } static public String getMultiMatcherKey(String local) { for (String[] matcherKey : multiMatcherKey) { - if (matcherKey[1].equals(local)) + if (matcherKey[1].equals(local)) { return matcherKey[0]; + } } return null; } diff --git a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/dialogs/ResourceFilterPage.java b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/dialogs/ResourceFilterPage.java index 7f9fd4621c0..475af567152 100644 --- a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/dialogs/ResourceFilterPage.java +++ b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/dialogs/ResourceFilterPage.java @@ -42,7 +42,7 @@ protected Control createContents(Composite parent) { IIDEHelpContextIds.RESOURCE_FILTER_PROPERTY_PAGE); IResource resource = Adapters.adapt(getElement(), IResource.class); - IContainer container = resource instanceof IContainer ? (IContainer) resource + IContainer container = resource instanceof IContainer i ? i : null; groupWidget.setContainer(container); diff --git a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/dialogs/ResourceInfoPage.java b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/dialogs/ResourceInfoPage.java index 15fd4a3e95d..41b9f72d8a7 100644 --- a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/dialogs/ResourceInfoPage.java +++ b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/dialogs/ResourceInfoPage.java @@ -440,20 +440,22 @@ private void refreshLinkLocation() { if (!IDEResourceInfoUtils.exists(resolved.toOSString())) { resolvedLocationValue .setText(IDEWorkbenchMessages.ResourceInfo_undefinedPathVariable); - if (sizeValue != null) + if (sizeValue != null) { sizeValue.setText(IDEWorkbenchMessages.ResourceInfo_notExist); + } } else { resolvedLocationValue.setText(resolved.toPortableString()); if (sizeValue != null) { IFileInfo info = IDEResourceInfoUtils.getFileInfo(resolved .toPortableString()); - if (info != null) + if (info != null) { sizeValue.setText(NLS.bind( IDEWorkbenchMessages.ResourceInfo_bytes, Long .toString(info.getLength()))); - else + } else { sizeValue .setText(IDEWorkbenchMessages.ResourceInfo_unknown); + } } } } @@ -500,8 +502,9 @@ protected Control createContents(Composite parent) { if (resource.getType() != IResource.PROJECT) { createSeparator(composite); int fsAttributes = getFileSystemAttributes(resource); - if (isPermissionsSupport(fsAttributes)) + if (isPermissionsSupport(fsAttributes)) { previousPermissionsValue = fetchPermissions(resource); + } createStateGroup(composite, resource, fsAttributes); if (isPermissionsSupport(fsAttributes)) { createSeparator(composite); @@ -572,9 +575,10 @@ private int getDefaulPermissions(boolean folder) { int permissions = EFS.ATTRIBUTE_OWNER_READ | EFS.ATTRIBUTE_OWNER_WRITE | EFS.ATTRIBUTE_GROUP_READ | EFS.ATTRIBUTE_GROUP_WRITE | EFS.ATTRIBUTE_OTHER_READ; - if (folder) + if (folder) { permissions |= EFS.ATTRIBUTE_OWNER_EXECUTE | EFS.ATTRIBUTE_GROUP_EXECUTE | EFS.ATTRIBUTE_OTHER_EXECUTE; + } return permissions; } @@ -588,8 +592,9 @@ private void setPermissionsSelection(int permissions) { permissionBoxes[6].setSelection((permissions & EFS.ATTRIBUTE_OTHER_READ) != 0); permissionBoxes[7].setSelection((permissions & EFS.ATTRIBUTE_OTHER_WRITE) != 0); permissionBoxes[8].setSelection((permissions & EFS.ATTRIBUTE_OTHER_EXECUTE) != 0); - if (immutableBox != null) + if (immutableBox != null) { immutableBox.setSelection((permissions & EFS.ATTRIBUTE_IMMUTABLE) != 0); + } } private int getPermissionsSelection() { @@ -603,8 +608,9 @@ private int getPermissionsSelection() { permissions |= permissionBoxes[6].getSelection() ? EFS.ATTRIBUTE_OTHER_READ : 0; permissions |= permissionBoxes[7].getSelection() ? EFS.ATTRIBUTE_OTHER_WRITE : 0; permissions |= permissionBoxes[8].getSelection() ? EFS.ATTRIBUTE_OTHER_EXECUTE : 0; - if (immutableBox != null) + if (immutableBox != null) { permissions |= immutableBox.getSelection() ? EFS.ATTRIBUTE_IMMUTABLE : 0; + } return permissions; } @@ -616,8 +622,9 @@ private boolean putPermissions(IResource resource, int permissions) { return false; } IFileInfo fileInfo = store.fetchInfo(); - if (!fileInfo.exists()) + if (!fileInfo.exists()) { return false; + } fileInfo.setAttribute(EFS.ATTRIBUTE_OWNER_READ, (permissions & EFS.ATTRIBUTE_OWNER_READ) != 0); fileInfo.setAttribute(EFS.ATTRIBUTE_OWNER_WRITE, (permissions & EFS.ATTRIBUTE_OWNER_WRITE) != 0); fileInfo.setAttribute(EFS.ATTRIBUTE_OWNER_EXECUTE, (permissions & EFS.ATTRIBUTE_OWNER_EXECUTE) != 0); @@ -727,10 +734,11 @@ private void createDerivedButton(Composite composite, IResource resource) { this.derivedBox = new Button(composite, SWT.CHECK | SWT.RIGHT); this.derivedBox.setAlignment(SWT.LEFT); - if (resource.getParent().isDerived(IResource.CHECK_ANCESTORS)) + if (resource.getParent().isDerived(IResource.CHECK_ANCESTORS)) { this.derivedBox.setText(DERIVED_HAS_DERIVED_ANCESTOR); - else + } else { this.derivedBox.setText(DERIVED); + } this.derivedBox.setSelection(this.previousDerivedValue); } @@ -775,20 +783,25 @@ private void createStateGroup(Composite parent, IResource resource, int fsAttrib if (!resource.isVirtual()) { if ((fsAttributes & EFS.ATTRIBUTE_READ_ONLY) != 0 - && !isPermissionsSupport(fsAttributes)) + && !isPermissionsSupport(fsAttributes)) { createEditableButton(composite); + } if ((fsAttributes & EFS.ATTRIBUTE_EXECUTABLE) != 0 - && !isPermissionsSupport(fsAttributes)) + && !isPermissionsSupport(fsAttributes)) { createExecutableButton(composite); - if ((fsAttributes & EFS.ATTRIBUTE_ARCHIVE) != 0) + } + if ((fsAttributes & EFS.ATTRIBUTE_ARCHIVE) != 0) { createArchiveButton(composite); - if ((fsAttributes & EFS.ATTRIBUTE_IMMUTABLE) != 0) + } + if ((fsAttributes & EFS.ATTRIBUTE_IMMUTABLE) != 0) { createImmutableButton(composite); + } } createDerivedButton(composite, resource); // create warning for executable flag - if (executableBox != null && resource.getType() == IResource.FOLDER) + if (executableBox != null && resource.getType() == IResource.FOLDER) { createExecutableWarning(composite, font); + } } private void createPermissionsGroup(Composite parent) { @@ -875,8 +888,9 @@ private Composite createExecutableWarning(Composite composite, Font font) { private int getFileSystemAttributes(IResource resource) { URI location = resource.getLocationURI(); - if (location == null || location.getScheme() == null) + if (location == null || location.getScheme() == null) { return 0; + } IFileSystem fs; try { fs = EFS.getFileSystem(location.getScheme()); @@ -892,8 +906,9 @@ private boolean isPermissionsSupport(int fsAttributes) { | EFS.ATTRIBUTE_GROUP_READ | EFS.ATTRIBUTE_GROUP_WRITE | EFS.ATTRIBUTE_GROUP_EXECUTE | EFS.ATTRIBUTE_OTHER_READ | EFS.ATTRIBUTE_OTHER_WRITE | EFS.ATTRIBUTE_OTHER_EXECUTE; - if ((fsAttributes & unixPermissions) == unixPermissions) + if ((fsAttributes & unixPermissions) == unixPermissions) { return true; + } return false; } @@ -921,8 +936,9 @@ protected void performDefaults() { IResource resource = Adapters.adapt(getElement(), IResource.class); - if (resource == null) + if (resource == null) { return; + } if (newResourceLocation != null) { newResourceLocation = null; @@ -934,8 +950,9 @@ protected void performDefaults() { .getLocationText(resource)); locationValue.setText(locationStr); - if (sizeValue != null) + if (sizeValue != null) { sizeValue.setText(IDEResourceInfoUtils.getSizeString(resource)); + } } // Nothing to update if we never made the box @@ -992,15 +1009,18 @@ private IResourceChange getAttributesChange(final boolean changedAttrs[], @Override public String getMessage() { String message = ""; //$NON-NLS-1$ - if (changedAttrs[0]) + if (changedAttrs[0]) { message += getSimpleChangeName(finalAttrs[0], IDEWorkbenchMessages.ResourceInfo_readOnly); - if (changedAttrs[1]) + } + if (changedAttrs[1]) { message += getSimpleChangeName(finalAttrs[1], IDEWorkbenchMessages.ResourceInfo_executable); - if (changedAttrs[2]) + } + if (changedAttrs[2]) { message += getSimpleChangeName(finalAttrs[2], IDEWorkbenchMessages.ResourceInfo_archive); + } return message; } @@ -1008,12 +1028,15 @@ public String getMessage() { public void performChange(IResource resource) throws CoreException { ResourceAttributes attrs = resource.getResourceAttributes(); if (attrs != null) { - if (changedAttrs[0]) + if (changedAttrs[0]) { attrs.setReadOnly(finalAttrs[0]); - if (changedAttrs[1]) + } + if (changedAttrs[1]) { attrs.setExecutable(finalAttrs[1]); - if (changedAttrs[2]) + } + if (changedAttrs[2]) { attrs.setArchive(finalAttrs[2]); + } resource.setResourceAttributes(attrs); } } @@ -1045,17 +1068,19 @@ public String getMessage() { IDEWorkbenchMessages.ResourceInfo_execute }; StringBuilder message = new StringBuilder(""); //$NON-NLS-1$ - if ((changedPermissions & EFS.ATTRIBUTE_IMMUTABLE) != 0) + if ((changedPermissions & EFS.ATTRIBUTE_IMMUTABLE) != 0) { message.append(getSimpleChangeName( (finalPermissions & EFS.ATTRIBUTE_IMMUTABLE) != 0, IDEWorkbenchMessages.ResourceInfo_locked)); + } for (int j = 0; j < 3; j++) { for (int i = 0; i < 3; i++) { - if ((changedPermissions & permissionMasks[j][i]) != 0) + if ((changedPermissions & permissionMasks[j][i]) != 0) { message.append(getSimpleChangeName( (finalPermissions & permissionMasks[j][i]) != 0, groupNames[j] + " " + permissionNames[i])); //$NON-NLS-1$ + } } } return message.toString(); @@ -1154,8 +1179,9 @@ public boolean performOk() { IResource resource = Adapters.adapt(getElement(), IResource.class); - if (resource == null) + if (resource == null) { return true; + } if (lineDelimiterEditor != null) { lineDelimiterEditor.store(); @@ -1163,12 +1189,14 @@ public boolean performOk() { try { if (newResourceLocation != null) { - if (resource.getType() == IResource.FILE) + if (resource.getType() == IResource.FILE) { ((IFile)resource).createLink(newResourceLocation, IResource.REPLACE, new NullProgressMonitor()); - if (resource.getType() == IResource.FOLDER) + } + if (resource.getType() == IResource.FOLDER) { ((IFolder)resource).createLink(newResourceLocation, IResource.REPLACE, new NullProgressMonitor()); + } } List changes = new ArrayList<>(); @@ -1237,8 +1265,9 @@ public boolean performOk() { } } - if (shouldPerformRecursiveChanges(changes)) + if (shouldPerformRecursiveChanges(changes)) { scheduleRecursiveChangesJob(resource, changes); + } // Nothing to update if we never made the box if (this.derivedBox != null) { diff --git a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/dialogs/ResourceWorkingSetPage.java b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/dialogs/ResourceWorkingSetPage.java index f58913e4ea3..6c8cae1e18a 100644 --- a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/dialogs/ResourceWorkingSetPage.java +++ b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/dialogs/ResourceWorkingSetPage.java @@ -359,10 +359,9 @@ private void initializeCheckedState() { } tree.setCheckedElements(items); for (Object i : items) { - if (!(i instanceof IAdaptable)) { + if (!(i instanceof IAdaptable item)) { continue; } - IAdaptable item = (IAdaptable) i; IContainer container = Adapters.adapt(item, IContainer.class); if (container != null) { diff --git a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/dialogs/WelcomeEditor.java b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/dialogs/WelcomeEditor.java index 6d8ad9796de..545cb5e07c4 100644 --- a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/dialogs/WelcomeEditor.java +++ b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/dialogs/WelcomeEditor.java @@ -83,9 +83,9 @@ public class WelcomeEditor extends EditorPart { private WelcomeParser parser; - private ArrayList hyperlinkRanges = new ArrayList<>(); + private final ArrayList hyperlinkRanges = new ArrayList<>(); - private ArrayList texts = new ArrayList<>(); + private final ArrayList texts = new ArrayList<>(); private ScrolledComposite scrolledComposite; @@ -101,7 +101,7 @@ public class WelcomeEditor extends EditorPart { private boolean nextTabAbortTraversal, previousTabAbortTraversal = false; - private WelcomeEditorCopyAction copyAction; + private final WelcomeEditorCopyAction copyAction; /** * Create a new instance of the welcome editor diff --git a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/dialogs/WelcomeEditorCopyAction.java b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/dialogs/WelcomeEditorCopyAction.java index 3d0cb606bef..e8c593d9733 100644 --- a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/dialogs/WelcomeEditorCopyAction.java +++ b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/dialogs/WelcomeEditorCopyAction.java @@ -21,7 +21,7 @@ * Global copy action for the welcome editor. */ public class WelcomeEditorCopyAction extends Action { - private WelcomeEditor editorPart; + private final WelcomeEditor editorPart; public WelcomeEditorCopyAction(WelcomeEditor editor) { editorPart = editor; diff --git a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/dialogs/WelcomeEditorInput.java b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/dialogs/WelcomeEditorInput.java index 0593e6cc61c..226faeb8600 100644 --- a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/dialogs/WelcomeEditorInput.java +++ b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/dialogs/WelcomeEditorInput.java @@ -26,7 +26,7 @@ * A simple editor input for the welcome editor */ public class WelcomeEditorInput implements IEditorInput { - private AboutInfo aboutInfo; + private final AboutInfo aboutInfo; private static final String FACTORY_ID = "org.eclipse.ui.internal.dialogs.WelcomeEditorInputFactory"; //$NON-NLS-1$ diff --git a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/dialogs/WelcomeItem.java b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/dialogs/WelcomeItem.java index 7c6203754e2..80f7efffdc6 100644 --- a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/dialogs/WelcomeItem.java +++ b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/dialogs/WelcomeItem.java @@ -26,21 +26,21 @@ * Holds the information for an item appearing in the welcome editor */ public class WelcomeItem { - private String text; + private final String text; - private int[][] boldRanges; + private final int[][] boldRanges; - private int[][] helpRanges; + private final int[][] helpRanges; - private String[] helpIds; + private final String[] helpIds; - private String[] helpHrefs; + private final String[] helpHrefs; - private int[][] actionRanges; + private final int[][] actionRanges; - private String[] actionPluginIds; + private final String[] actionPluginIds; - private String[] actionClasses; + private final String[] actionClasses; /** * Creates a new welcome item diff --git a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/dialogs/WelcomeParser.java b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/dialogs/WelcomeParser.java index f390ed72b1f..d1f69bc0ba2 100644 --- a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/dialogs/WelcomeParser.java +++ b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/dialogs/WelcomeParser.java @@ -67,13 +67,13 @@ public class WelcomeParser extends DefaultHandler { private static final char DELIMITER = '\n'; // sax parser replaces crlf with lf - private SAXParser parser; + private final SAXParser parser; private String title; private WelcomeItem introItem; - private ArrayList items = new ArrayList<>(); + private final ArrayList items = new ArrayList<>(); private String format; @@ -158,23 +158,23 @@ public void startElement(String namespaceURI, String localName, } private class ItemHandler extends WelcomeContentHandler { - private ArrayList boldRanges = new ArrayList<>(); + private final ArrayList boldRanges = new ArrayList<>(); protected ArrayList wrapRanges = new ArrayList<>(); - private ArrayList actionRanges = new ArrayList<>(); + private final ArrayList actionRanges = new ArrayList<>(); - private ArrayList pluginIds = new ArrayList<>(); + private final ArrayList pluginIds = new ArrayList<>(); - private ArrayList classes = new ArrayList<>(); + private final ArrayList classes = new ArrayList<>(); - private ArrayList helpRanges = new ArrayList<>(); + private final ArrayList helpRanges = new ArrayList<>(); - private ArrayList helpIds = new ArrayList<>(); + private final ArrayList helpIds = new ArrayList<>(); - private ArrayList helpHrefs = new ArrayList<>(); + private final ArrayList helpHrefs = new ArrayList<>(); - private StringBuilder text = new StringBuilder(); + private final StringBuilder text = new StringBuilder(); protected int offset = 0; diff --git a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/filesystem/FileSystemConfiguration.java b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/filesystem/FileSystemConfiguration.java index f115e9e07a1..f15b90f266a 100644 --- a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/filesystem/FileSystemConfiguration.java +++ b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/filesystem/FileSystemConfiguration.java @@ -28,7 +28,7 @@ public class FileSystemConfiguration { FileSystemContributor contributor; - private String scheme; + private final String scheme; /** diff --git a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/filesystem/FileSystemStructureProvider.java b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/filesystem/FileSystemStructureProvider.java index 52d2b3399dd..5a4ea201173 100644 --- a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/filesystem/FileSystemStructureProvider.java +++ b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/filesystem/FileSystemStructureProvider.java @@ -45,8 +45,9 @@ public List getChildren(Object element) { for (int i = 0; i < childrenLength; i++) { File file = new File(folder, children[i]); - if(isRecursiveLink(file)) + if(isRecursiveLink(file)) { continue; + } result.add(file); } @@ -109,7 +110,8 @@ public boolean isFolder(Object element) { * Clears the visited dir information */ public void clearVisitedDirs() { - if(visitedDirs!=null) + if(visitedDirs!=null) { visitedDirs.clear(); + } } } diff --git a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/filesystem/FileSystemSupportRegistry.java b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/filesystem/FileSystemSupportRegistry.java index be8f4fc20c5..0a23c81fe2c 100644 --- a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/filesystem/FileSystemSupportRegistry.java +++ b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/filesystem/FileSystemSupportRegistry.java @@ -69,7 +69,7 @@ public static FileSystemSupportRegistry getInstance() { return singleton; } - private Collection registeredContributions = new HashSet<>(0); + private final Collection registeredContributions = new HashSet<>(0); FileSystemConfiguration defaultConfiguration = new FileSystemConfiguration( FileSystemMessages.DefaultFileSystem_name, new FileSystemContributor() { diff --git a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/handlers/BuildProjectHandler.java b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/handlers/BuildProjectHandler.java index 2576a8c11fb..7573928ec70 100644 --- a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/handlers/BuildProjectHandler.java +++ b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/handlers/BuildProjectHandler.java @@ -80,8 +80,7 @@ private BuildAction newBuildAction(IWorkbenchWindow window) { @Override public void setEnabled(Object evaluationContext) { boolean enabled = false; - if ((evaluationContext instanceof IEvaluationContext)) { - IEvaluationContext context = (IEvaluationContext) evaluationContext; + if ((evaluationContext instanceof IEvaluationContext context)) { Object object = context.getVariable(ISources.ACTIVE_WORKBENCH_WINDOW_NAME); if (object instanceof IWorkbenchWindow) { BuildAction buildAction = newBuildAction((IWorkbenchWindow) object); diff --git a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/handlers/EditorInputPropertyTester.java b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/handlers/EditorInputPropertyTester.java index 4d918d541c0..03fdf0d6eba 100644 --- a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/handlers/EditorInputPropertyTester.java +++ b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/handlers/EditorInputPropertyTester.java @@ -37,10 +37,9 @@ public class EditorInputPropertyTester extends PropertyTester { @Override public boolean test(Object receiver, String property, Object[] args, Object expectedValue) { - if (!(receiver instanceof IEditorPart)) { + if (!(receiver instanceof IEditorPart editor)) { return false; } - IEditorPart editor = (IEditorPart) receiver; IEditorInput input = editor.getEditorInput(); if (input instanceof IFileEditorInput) { return true; diff --git a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/handlers/PagePropertyTester.java b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/handlers/PagePropertyTester.java index c5abde1ac22..2af0042c7ba 100644 --- a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/handlers/PagePropertyTester.java +++ b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/handlers/PagePropertyTester.java @@ -30,14 +30,12 @@ public class PagePropertyTester extends PropertyTester { @Override public boolean test(Object receiver, String property, Object[] args, Object expectedValue) { - if (receiver instanceof Shell) { - Shell shell = (Shell) receiver; + if (receiver instanceof Shell shell) { if (shell.isDisposed()) { return false; } Object shellData = shell.getData(); - if (shellData instanceof FilteredPreferenceDialog) { - FilteredPreferenceDialog propertyDialog = (FilteredPreferenceDialog) shellData; + if (shellData instanceof FilteredPreferenceDialog propertyDialog) { IPreferencePage currentPage = propertyDialog.getCurrentPage(); if (currentPage != null) { return currentPage.getClass().getName().equals(expectedValue); diff --git a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/handlers/ShowInSystemExplorerHandler.java b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/handlers/ShowInSystemExplorerHandler.java index 87b7b1c5ff7..f2d6e1e43bb 100644 --- a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/handlers/ShowInSystemExplorerHandler.java +++ b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/handlers/ShowInSystemExplorerHandler.java @@ -202,8 +202,9 @@ private String quotePath(String path) { */ private File getSystemExplorerPath(IResource resource) throws IOException { IPath location = resource.getLocation(); - if (location == null) + if (location == null) { return null; + } return location.toFile(); } diff --git a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/misc/AndFileInfoMatcher.java b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/misc/AndFileInfoMatcher.java index 4fc784ce676..c392418da82 100755 --- a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/misc/AndFileInfoMatcher.java +++ b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/misc/AndFileInfoMatcher.java @@ -28,8 +28,9 @@ public class AndFileInfoMatcher extends CompoundFileInfoMatcher { @Override public boolean matches(IContainer parent, IFileInfo fileInfo) throws CoreException { for (AbstractFileInfoMatcher matcher : matchers) { - if (!matcher.matches(parent, fileInfo)) + if (!matcher.matches(parent, fileInfo)) { return false; + } } return true; } diff --git a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/misc/CheckboxTreeAndListGroup.java b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/misc/CheckboxTreeAndListGroup.java index 35e8757d775..c4caf1f61c8 100644 --- a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/misc/CheckboxTreeAndListGroup.java +++ b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/misc/CheckboxTreeAndListGroup.java @@ -57,23 +57,23 @@ public class CheckboxTreeAndListGroup extends EventManager implements private Object currentTreeSelection; - private List expandedTreeNodes = new ArrayList<>(); + private final List expandedTreeNodes = new ArrayList<>(); - private Map> checkedStateStore = new HashMap<>(9); + private final Map> checkedStateStore = new HashMap<>(9); - private List whiteCheckedTreeItems = new ArrayList<>(); + private final List whiteCheckedTreeItems = new ArrayList<>(); - private ITreeContentProvider treeContentProvider; + private final ITreeContentProvider treeContentProvider; - private IStructuredContentProvider listContentProvider; + private final IStructuredContentProvider listContentProvider; - private ILabelProvider treeLabelProvider; + private final ILabelProvider treeLabelProvider; - private ILabelProvider listLabelProvider; + private final ILabelProvider listLabelProvider; - private ViewerComparator treeComparator; + private final ViewerComparator treeComparator; - private ViewerComparator listComparator; + private final ViewerComparator listComparator; // widgets private CheckboxTreeViewer treeViewer; diff --git a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/misc/ContainerContentProvider.java b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/misc/ContainerContentProvider.java index dd1a236c524..9c75cdf1f13 100644 --- a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/misc/ContainerContentProvider.java +++ b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/misc/ContainerContentProvider.java @@ -60,8 +60,7 @@ public Object[] getChildren(Object element) { } } return accessibleProjects.toArray(); - } else if (element instanceof IContainer) { - IContainer container = (IContainer) element; + } else if (element instanceof IContainer container) { if (container.isAccessible()) { try { List children = new ArrayList<>(); diff --git a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/misc/ContainerSelectionGroup.java b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/misc/ContainerSelectionGroup.java index 7844d90fe33..bbc5f33a411 100644 --- a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/misc/ContainerSelectionGroup.java +++ b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/misc/ContainerSelectionGroup.java @@ -47,7 +47,7 @@ */ public class ContainerSelectionGroup extends Composite { // The listener to notify of events - private Listener listener; + private final Listener listener; // Enable user to type in new container name private boolean allowNewContainerName = true; @@ -303,8 +303,9 @@ public IPath getContainerFullPath() { return (IPath.fromOSString(TextProcessor.deprocess(pathName))).makeAbsolute(); } - if (selectedContainer == null) + if (selectedContainer == null) { return null; + } return selectedContainer.getFullPath(); } diff --git a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/misc/FileInfoAttributesMatcher.java b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/misc/FileInfoAttributesMatcher.java index 65a2e3c56ab..b62e391c1f6 100644 --- a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/misc/FileInfoAttributesMatcher.java +++ b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/misc/FileInfoAttributesMatcher.java @@ -67,30 +67,38 @@ public class FileInfoAttributesMatcher extends AbstractFileInfoMatcher { public static String[] getOperatorsForKey(String key) { - if (key.equals(KEY_NAME) || key.equals(KEY_PROPJECT_RELATIVE_PATH) || key.equals(KEY_LOCATION)) - return new String[] {OPERATOR_MATCHES}; - if (key.equals(KEY_IS_SYMLINK) || key.equals(KEY_IS_READONLY)) + if (key.equals(KEY_NAME) || key.equals(KEY_PROPJECT_RELATIVE_PATH) || key.equals(KEY_LOCATION)) { + return new String[] {OPERATOR_MATCHES}; + } + if (key.equals(KEY_IS_SYMLINK) || key.equals(KEY_IS_READONLY)) { return new String[] {OPERATOR_EQUALS}; - if (key.equals(KEY_LAST_MODIFIED) || key.equals(KEY_CREATED)) + } + if (key.equals(KEY_LAST_MODIFIED) || key.equals(KEY_CREATED)) { return new String[] {OPERATOR_EQUALS, OPERATOR_BEFORE, OPERATOR_AFTER, OPERATOR_WITHIN}; - if (key.equals(KEY_LENGTH)) + } + if (key.equals(KEY_LENGTH)) { return new String[] {OPERATOR_EQUALS, OPERATOR_LARGER_THAN, OPERATOR_SMALLER_THAN}; + } return new String[] {OPERATOR_NONE}; } public static Class getTypeForKey(String key, String operator) { - if (key.equals(KEY_NAME) || key.equals(KEY_PROPJECT_RELATIVE_PATH) || key.equals(KEY_LOCATION)) + if (key.equals(KEY_NAME) || key.equals(KEY_PROPJECT_RELATIVE_PATH) || key.equals(KEY_LOCATION)) { return String.class; - if (key.equals(KEY_IS_SYMLINK) || key.equals(KEY_IS_READONLY)) + } + if (key.equals(KEY_IS_SYMLINK) || key.equals(KEY_IS_READONLY)) { return Boolean.class; + } if (key.equals(KEY_LAST_MODIFIED) || key.equals(KEY_CREATED)) { - if (operator.equals(OPERATOR_WITHIN)) + if (operator.equals(OPERATOR_WITHIN)) { return Integer.class; + } return Date.class; } - if (key.equals(KEY_LENGTH)) + if (key.equals(KEY_LENGTH)) { return Integer.class; + } return String.class; } @@ -124,43 +132,50 @@ public static String encodeArguments(Argument argument) { public static Argument decodeArguments(String argument) { Argument result = new Argument(); - if (argument == null) + if (argument == null) { return result; + } int index = argument.indexOf(DELIMITER); - if (index == -1) + if (index == -1) { return result; + } String version = argument.substring(0, index); argument = argument.substring(index + 1); - if (!version.equals(VERSION_IMPLEMENTATION)) + if (!version.equals(VERSION_IMPLEMENTATION)) { return result; + } index = argument.indexOf(DELIMITER); - if (index == -1) + if (index == -1) { return result; + } result.key = argument.substring(0, index); argument = argument.substring(index + 1); index = argument.indexOf(DELIMITER); - if (index == -1) + if (index == -1) { return result; + } result.operator = argument.substring(0, index); argument = argument.substring(index + 1); index = argument.indexOf(DELIMITER); - if (index == -1) + if (index == -1) { return result; + } result.caseSensitive = Boolean.parseBoolean(argument.substring(0, index)); argument = argument.substring(index + 1); index = argument.indexOf(DELIMITER); - if (index == -1) + if (index == -1) { return result; + } result.regularExpression = Boolean.parseBoolean(argument.substring(0, index)); result.pattern = argument.substring(index + 1); @@ -187,17 +202,18 @@ private static long getFileCreationTime(String fullPath) { } MatcherCache matcher = null; - private boolean fSupportsCreatedKey; + private final boolean fSupportsCreatedKey; class MatcherCache { public MatcherCache(String arguments) { argument = decodeArguments(arguments); type = getTypeForKey(argument.key, argument.operator); if (type.equals(String.class)) { - if (!argument.regularExpression) + if (!argument.regularExpression) { stringMatcher = new StringMatcher(argument.pattern, !argument.caseSensitive, false); - else + } else { regExPattern = Pattern.compile(argument.pattern, argument.caseSensitive ? 0:Pattern.CASE_INSENSITIVE); + } } } @@ -210,15 +226,19 @@ public MatcherCache(String arguments) { public boolean match(IContainer parent, IFileInfo fileInfo) { if (type.equals(String.class)) { String value = ""; //$NON-NLS-1$ - if (argument.key.equals(KEY_NAME)) + if (argument.key.equals(KEY_NAME)) { value = fileInfo.getName(); - if (argument.key.equals(KEY_PROPJECT_RELATIVE_PATH)) + } + if (argument.key.equals(KEY_PROPJECT_RELATIVE_PATH)) { value = parent.getProjectRelativePath().append(fileInfo.getName()).toPortableString(); - if (argument.key.equals(KEY_LOCATION)) + } + if (argument.key.equals(KEY_LOCATION)) { value = parent.getLocation().append(fileInfo.getName()).toOSString(); + } - if (stringMatcher != null) + if (stringMatcher != null) { return stringMatcher.match(value); + } if (regExPattern != null) { Matcher m = regExPattern.matcher(value); return m.matches(); @@ -236,13 +256,15 @@ public boolean match(IContainer parent, IFileInfo fileInfo) { long time = 0; if (argument.key.equals(KEY_LAST_MODIFIED)) { IFileInfo info = fetchInfo(parent, fileInfo); - if (!info.exists()) + if (!info.exists()) { return false; + } time = info.getLastModified(); } if (argument.key.equals(KEY_CREATED)) { - if (!fSupportsCreatedKey) + if (!fSupportsCreatedKey) { return false; + } time = getFileCreationTime(parent.getLocation().append(fileInfo.getName()).toOSString()); } GregorianCalendar gc = new GregorianCalendar(); @@ -253,14 +275,18 @@ public boolean match(IContainer parent, IFileInfo fileInfo) { } if (argument.key.equals(KEY_LENGTH)) { IFileInfo info = fetchInfo(parent, fileInfo); - if (!info.exists()) + if (!info.exists()) { return false; - if (argument.operator.equals(OPERATOR_EQUALS)) + } + if (argument.operator.equals(OPERATOR_EQUALS)) { return info.getLength() == amount; - if (argument.operator.equals(OPERATOR_LARGER_THAN)) + } + if (argument.operator.equals(OPERATOR_LARGER_THAN)) { return info.getLength() > amount; - if (argument.operator.equals(OPERATOR_SMALLER_THAN)) + } + if (argument.operator.equals(OPERATOR_SMALLER_THAN)) { return info.getLength() < amount; + } } } if (type.equals(Date.class)) { @@ -269,37 +295,44 @@ public boolean match(IContainer parent, IFileInfo fileInfo) { long time = 0; if (argument.key.equals(KEY_LAST_MODIFIED)) { IFileInfo info = fetchInfo(parent, fileInfo); - if (!info.exists()) + if (!info.exists()) { return false; + } time = info.getLastModified(); } if (argument.key.equals(KEY_CREATED)) { - if (!fSupportsCreatedKey) + if (!fSupportsCreatedKey) { return false; + } time = getFileCreationTime(parent.getLocation().append(fileInfo.getName()).toOSString()); } Date when = new Date(parameter); Date then = new Date(time); - if (argument.operator.equals(OPERATOR_EQUALS)) + if (argument.operator.equals(OPERATOR_EQUALS)) { return roundToOneDay(time) == roundToOneDay(parameter); - if (argument.operator.equals(OPERATOR_BEFORE)) + } + if (argument.operator.equals(OPERATOR_BEFORE)) { return then.before(when); - if (argument.operator.equals(OPERATOR_AFTER)) + } + if (argument.operator.equals(OPERATOR_AFTER)) { return then.after(when); + } } } if (type.equals(Boolean.class)) { boolean parameter = Boolean.parseBoolean(argument.pattern); if (argument.key.equals(KEY_IS_READONLY)) { IFileInfo info = fetchInfo(parent, fileInfo); - if (!info.exists()) + if (!info.exists()) { return false; + } return info.getAttribute(EFS.ATTRIBUTE_READ_ONLY) == parameter; } if (argument.key.equals(KEY_IS_SYMLINK)) { IFileInfo info = fetchInfo(parent, fileInfo); - if (!info.exists()) + if (!info.exists()) { return false; + } return info.getAttribute(EFS.ATTRIBUTE_SYMLINK) == parameter; } } @@ -331,8 +364,9 @@ public FileInfoAttributesMatcher() { @Override public void initialize(IProject project, Object arguments) throws CoreException { try { - if ((arguments instanceof String) && ((String) arguments).length() > 0) + if ((arguments instanceof String) && ((String) arguments).length() > 0) { matcher = new MatcherCache((String) arguments); + } } catch (PatternSyntaxException | NumberFormatException e) { throw new CoreException(new Status(IStatus.ERROR, PlatformUI.PLUGIN_ID, Platform.PLUGIN_ERROR, e.getMessage(), e)); } diff --git a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/misc/NotFileInfoMatcher.java b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/misc/NotFileInfoMatcher.java index b9b29b56610..29aaad70729 100755 --- a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/misc/NotFileInfoMatcher.java +++ b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/misc/NotFileInfoMatcher.java @@ -28,8 +28,9 @@ public class NotFileInfoMatcher extends CompoundFileInfoMatcher { @Override public boolean matches(IContainer parent, IFileInfo fileInfo) throws CoreException { for (AbstractFileInfoMatcher matcher : matchers) { - if (matcher.matches(parent, fileInfo)) + if (matcher.matches(parent, fileInfo)) { return false; + } } return true; } diff --git a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/misc/OrFileInfoMatcher.java b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/misc/OrFileInfoMatcher.java index 5af4af8055e..1fc0d2b2205 100755 --- a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/misc/OrFileInfoMatcher.java +++ b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/misc/OrFileInfoMatcher.java @@ -29,8 +29,9 @@ public class OrFileInfoMatcher extends CompoundFileInfoMatcher { public boolean matches(IContainer parent, IFileInfo fileInfo) throws CoreException { if (matchers.length > 0) { for (AbstractFileInfoMatcher matcher : matchers) { - if (matcher.matches(parent, fileInfo)) + if (matcher.matches(parent, fileInfo)) { return true; + } } return false; } diff --git a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/misc/ResourceAndContainerGroup.java b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/misc/ResourceAndContainerGroup.java index 9fdba941fb9..fc434b559f9 100644 --- a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/misc/ResourceAndContainerGroup.java +++ b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/misc/ResourceAndContainerGroup.java @@ -87,7 +87,7 @@ public class ResourceAndContainerGroup implements Listener { public static final int PROBLEM_PATH_OCCUPIED = 8; // the client to notify of changes - private Listener client; + private final Listener client; // whether to allow existing resources private boolean allowExistingResources = false; diff --git a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/misc/StringFileInfoMatcher.java b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/misc/StringFileInfoMatcher.java index 37698da377f..554a462c1aa 100755 --- a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/misc/StringFileInfoMatcher.java +++ b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/misc/StringFileInfoMatcher.java @@ -36,14 +36,16 @@ public StringFileInfoMatcher() { @Override public void initialize(IProject project, Object arguments) { - if ((arguments instanceof String) && ((String) arguments).length() > 0) + if ((arguments instanceof String) && ((String) arguments).length() > 0) { matcher = new StringMatcher((String) arguments, true, false); + } } @Override public boolean matches(IContainer parent, IFileInfo fileInfo) { - if (matcher != null) + if (matcher != null) { return matcher.match(fileInfo.getName()); + } return false; } } diff --git a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/model/FileStoreInputAdapterFactory.java b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/model/FileStoreInputAdapterFactory.java index f7ad545b697..a5257416a82 100644 --- a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/model/FileStoreInputAdapterFactory.java +++ b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/model/FileStoreInputAdapterFactory.java @@ -28,8 +28,7 @@ public class FileStoreInputAdapterFactory implements IAdapterFactory { @Override public T getAdapter(Object adaptableObject, Class adapterType) { - if (adaptableObject instanceof FileStoreEditorInput && adapterType.isAssignableFrom(IFileStore.class)) { - FileStoreEditorInput editorInput = (FileStoreEditorInput) adaptableObject; + if (adaptableObject instanceof FileStoreEditorInput editorInput && adapterType.isAssignableFrom(IFileStore.class)) { try { return adapterType.cast(EFS.getStore(editorInput.getURI())); } catch (CoreException e) { diff --git a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/model/StandardPropertiesAdapterFactory.java b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/model/StandardPropertiesAdapterFactory.java index 17d9897929b..146896de5a9 100644 --- a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/model/StandardPropertiesAdapterFactory.java +++ b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/model/StandardPropertiesAdapterFactory.java @@ -36,8 +36,7 @@ public T getAdapter(Object o, Class adapterType) { return adapterType.cast(o); } if (adapterType == IPropertySource.class) { - if (o instanceof IResource) { - IResource resource = (IResource) o; + if (o instanceof IResource resource) { if (resource.getType() == IResource.FILE) { return adapterType.cast(new FilePropertySource((IFile) o)); } diff --git a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/model/WorkbenchAdapterFactory.java b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/model/WorkbenchAdapterFactory.java index 539aedf6de1..459c0e75745 100644 --- a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/model/WorkbenchAdapterFactory.java +++ b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/model/WorkbenchAdapterFactory.java @@ -36,21 +36,21 @@ */ public class WorkbenchAdapterFactory implements IAdapterFactory { - private WorkbenchWorkspace workspaceAdapter = new WorkbenchWorkspace(); + private final WorkbenchWorkspace workspaceAdapter = new WorkbenchWorkspace(); - private WorkbenchRootResource rootAdapter = new WorkbenchRootResource(); + private final WorkbenchRootResource rootAdapter = new WorkbenchRootResource(); - private WorkbenchProject projectAdapter = new WorkbenchProject(); + private final WorkbenchProject projectAdapter = new WorkbenchProject(); - private WorkbenchFolder folderAdapter = new WorkbenchFolder(); + private final WorkbenchFolder folderAdapter = new WorkbenchFolder(); - private WorkbenchFile fileAdapter = new WorkbenchFile(); + private final WorkbenchFile fileAdapter = new WorkbenchFile(); - private WorkbenchMarker markerAdapter = new WorkbenchMarker(); + private final WorkbenchMarker markerAdapter = new WorkbenchMarker(); - private ResourceFactory resourceFactory = new ResourceFactory(); + private final ResourceFactory resourceFactory = new ResourceFactory(); - private WorkspaceFactory workspaceFactory = new WorkspaceFactory(); + private final WorkspaceFactory workspaceFactory = new WorkspaceFactory(); /** * Returns the IActionFilter for an object. diff --git a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/model/WorkbenchFile.java b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/model/WorkbenchFile.java index e962648e540..fcca45d1864 100644 --- a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/model/WorkbenchFile.java +++ b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/model/WorkbenchFile.java @@ -48,8 +48,7 @@ public class WorkbenchFile extends WorkbenchResource { protected ImageDescriptor getBaseImage(IResource resource) { IContentType contentType = null; // do we need to worry about checking here? - if (resource instanceof IFile) { - IFile file = (IFile)resource; + if (resource instanceof IFile file) { // cached images come from ContentTypeDecorator ImageDescriptor cached; try { diff --git a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/model/WorkbenchProject.java b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/model/WorkbenchProject.java index 051734815f7..836f0b30cf3 100644 --- a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/model/WorkbenchProject.java +++ b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/model/WorkbenchProject.java @@ -98,10 +98,9 @@ public Object[] getChildren(Object o) { */ @Override public boolean testAttribute(Object target, String name, String value) { - if (!(target instanceof IProject)) { + if (!(target instanceof IProject proj)) { return false; } - IProject proj = (IProject) target; if (name.equals(NATURE)) { try { return proj.isAccessible() && proj.hasNature(value); diff --git a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/model/WorkbenchResource.java b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/model/WorkbenchResource.java index 44d6c879284..e7438d2a9b5 100644 --- a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/model/WorkbenchResource.java +++ b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/model/WorkbenchResource.java @@ -84,10 +84,9 @@ protected IResource getResource(Object o) { */ @Override public boolean testAttribute(Object target, String name, String value) { - if (!(target instanceof IResource)) { + if (!(target instanceof IResource res)) { return false; } - IResource res = (IResource) target; switch (name) { case NAME: return SimpleWildcardTester.testWildcardIgnoreCase(value, res @@ -142,11 +141,10 @@ private final boolean testContentTypeProperty(final IResource resource, final String contentTypeId) { final String expectedValue = contentTypeId.trim(); - if (!(resource instanceof IFile)) { + if (!(resource instanceof final IFile file)) { return false; } - final IFile file = (IFile) resource; String actualValue = null; try { diff --git a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/model/WorkingSetAdapterFactory.java b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/model/WorkingSetAdapterFactory.java index b0f1285b9c7..3db4106f417 100644 --- a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/model/WorkingSetAdapterFactory.java +++ b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/model/WorkingSetAdapterFactory.java @@ -38,8 +38,7 @@ static class ContributorResourceAdapter implements IContributorResourceAdapter2 @Override public ResourceMapping getAdaptedResourceMapping(IAdaptable adaptable) { - if (adaptable instanceof IWorkingSet) { - IWorkingSet workingSet = (IWorkingSet) adaptable; + if (adaptable instanceof IWorkingSet workingSet) { for (IAdaptable currentAdaptable : workingSet.getElements()) { ResourceMapping mapping = getContributedResourceMapping(currentAdaptable); if (mapping == null) { @@ -65,8 +64,7 @@ static class WorkbenchAdapter implements IWorkbenchAdapter { @Override public Object[] getChildren(Object o) { - if (o instanceof IWorkingSet) { - IWorkingSet set = (IWorkingSet) o; + if (o instanceof IWorkingSet set) { return set.getElements(); } return null; @@ -74,8 +72,7 @@ public Object[] getChildren(Object o) { @Override public ImageDescriptor getImageDescriptor(Object o) { - if (o instanceof IWorkingSet) { - IWorkingSet set = (IWorkingSet) o; + if (o instanceof IWorkingSet set) { return set.getImageDescriptor(); } return null; @@ -83,8 +80,7 @@ public ImageDescriptor getImageDescriptor(Object o) { @Override public String getLabel(Object o) { - if (o instanceof IWorkingSet) { - IWorkingSet set = (IWorkingSet) o; + if (o instanceof IWorkingSet set) { return set.getLabel(); } return null; @@ -97,13 +93,13 @@ public Object getParent(Object o) { } - private IContributorResourceAdapter2 contributorResourceAdapter = new ContributorResourceAdapter(); + private final IContributorResourceAdapter2 contributorResourceAdapter = new ContributorResourceAdapter(); - private IWorkbenchAdapter workbenchAdapter = new WorkbenchAdapter(); + private final IWorkbenchAdapter workbenchAdapter = new WorkbenchAdapter(); @Override public T getAdapter(Object adaptableObject, Class adapterType) { - if (adaptableObject instanceof IWorkingSet) { + if (adaptableObject instanceof IWorkingSet workingSet) { if (adapterType == IContributorResourceAdapter.class) { return adapterType.cast(contributorResourceAdapter); } @@ -111,7 +107,6 @@ public T getAdapter(Object adaptableObject, Class adapterType) { return adapterType.cast(workbenchAdapter); } if (adapterType == ResourceMapping.class) { - IWorkingSet workingSet = (IWorkingSet) adaptableObject; for (IAdaptable adaptable : workingSet.getElements()) { ResourceMapping mapping = getResourceMapping(adaptable); if (mapping != null) { @@ -148,9 +143,8 @@ static ResourceMapping getResourceMapping(Object o) { static ResourceMapping getContributedResourceMapping(IAdaptable element) { IContributorResourceAdapter resourceAdapter = Adapters.adapt(element, IContributorResourceAdapter.class); if (resourceAdapter != null) { - if (resourceAdapter instanceof IContributorResourceAdapter2) { + if (resourceAdapter instanceof IContributorResourceAdapter2 mappingAdapter) { // First, use the mapping contributor adapter to get the mapping - IContributorResourceAdapter2 mappingAdapter = (IContributorResourceAdapter2) resourceAdapter; ResourceMapping mapping = mappingAdapter.getAdaptedResourceMapping(element); if (mapping != null) { return mapping; diff --git a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/model/WorkingSetResourceMapping.java b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/model/WorkingSetResourceMapping.java index c480eaa8c22..c8e6b593ad3 100644 --- a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/model/WorkingSetResourceMapping.java +++ b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/model/WorkingSetResourceMapping.java @@ -36,7 +36,7 @@ */ public class WorkingSetResourceMapping extends ResourceMapping { - private IWorkingSet set; + private final IWorkingSet set; /** * Create the resource mapping diff --git a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/registry/MarkerHelpRegistry.java b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/registry/MarkerHelpRegistry.java index c1f217a5b7f..c6b52ce1cbe 100644 --- a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/registry/MarkerHelpRegistry.java +++ b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/registry/MarkerHelpRegistry.java @@ -55,7 +55,7 @@ public class MarkerHelpRegistry implements IMarkerHelpRegistry { /** * Table of queries for marker F1 help. */ - private Map>> helpQueries; + private final Map>> helpQueries; /** * Sorted list of help queries. Used to ensure that the "most specific" @@ -66,7 +66,7 @@ public class MarkerHelpRegistry implements IMarkerHelpRegistry { /** * Table of queries for marker resolutions */ - private Map>> resolutionQueries; + private final Map>> resolutionQueries; /** * Help context id attribute in configuration element @@ -112,12 +112,12 @@ public String getHelpContextForMarker(IMarker marker) { /** * Map of known marker resolution generators */ - private Map generatorMap; + private final Map generatorMap; /** * Map of known marker help context providers */ - private Map helpProviderMap; + private final Map helpProviderMap; /** * Resolution class attribute name in configuration element diff --git a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/registry/MarkerImageProviderRegistry.java b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/registry/MarkerImageProviderRegistry.java index 3bf9e0043f0..f7d3209fe41 100644 --- a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/registry/MarkerImageProviderRegistry.java +++ b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/registry/MarkerImageProviderRegistry.java @@ -45,7 +45,7 @@ public class MarkerImageProviderRegistry { private static final String TAG_PROVIDER = "imageprovider";//$NON-NLS-1$ - private ArrayList descriptors = new ArrayList<>(); + private final ArrayList descriptors = new ArrayList<>(); static class Descriptor { String id; diff --git a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/registry/MarkerQuery.java b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/registry/MarkerQuery.java index 8cb79d545a2..3e4986c8c69 100644 --- a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/registry/MarkerQuery.java +++ b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/registry/MarkerQuery.java @@ -32,19 +32,19 @@ public class MarkerQuery { * The marker type targetted by this query. * May be null. */ - private String type; + private final String type; /** * A sorted list of the attributes targetted by this query. * The list is sorted from least to greatest according to * Sting.compare */ - private String[] attributes; + private final String[] attributes; /** * Whether this query also targets all children of {@link #type}. */ - private boolean matchTypeChildren; + private final boolean matchTypeChildren; /** * Cached hash code value diff --git a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/registry/MarkerQueryResult.java b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/registry/MarkerQueryResult.java index f0de14a4acc..ce5fc54770f 100644 --- a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/registry/MarkerQueryResult.java +++ b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/registry/MarkerQueryResult.java @@ -25,7 +25,7 @@ public class MarkerQueryResult { /** * An ordered collection of marker attribute values. */ - private String[] values; + private final String[] values; /** * Cached hash code value diff --git a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/registry/ProjectImageRegistry.java b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/registry/ProjectImageRegistry.java index 8c30144464c..e3822d7840f 100644 --- a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/registry/ProjectImageRegistry.java +++ b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/registry/ProjectImageRegistry.java @@ -24,7 +24,7 @@ */ public class ProjectImageRegistry { - private Map map = new HashMap<>(10); + private final Map map = new HashMap<>(10); /** * Returns the image for the given nature id or diff --git a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/undo/WorkspaceUndoMonitor.java b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/undo/WorkspaceUndoMonitor.java index 54b73484b23..ccfcc339413 100644 --- a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/undo/WorkspaceUndoMonitor.java +++ b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/ide/undo/WorkspaceUndoMonitor.java @@ -85,13 +85,13 @@ public static WorkspaceUndoMonitor getInstance() { * Resource listener used to determine how often to validate the workspace * undo history. */ - private IResourceChangeListener resourceListener; + private final IResourceChangeListener resourceListener; /** * Operation history listener used to determine whether there is an undoable * operation in progress. */ - private IOperationHistoryListener historyListener; + private final IOperationHistoryListener historyListener; /** * Construct an instance. Should only be called by {@link #getInstance()} diff --git a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/views/helpers/EmptyWorkspaceHelper.java b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/views/helpers/EmptyWorkspaceHelper.java index 19c1f38a7ba..f1431acc993 100644 --- a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/views/helpers/EmptyWorkspaceHelper.java +++ b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/views/helpers/EmptyWorkspaceHelper.java @@ -297,7 +297,7 @@ private IAction getAction(IWizardRegistry registry, String id) { return action; } - private Runnable switchTopControlRunnable = () -> { + private final Runnable switchTopControlRunnable = () -> { if (switchTopControl()) { displayArea.requestLayout(); } diff --git a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/views/markers/AddTaskHandler.java b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/views/markers/AddTaskHandler.java index dddfd0e718c..c86edf885b4 100644 --- a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/views/markers/AddTaskHandler.java +++ b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/views/markers/AddTaskHandler.java @@ -29,8 +29,9 @@ public class AddTaskHandler extends MarkerViewHandler { public Object execute(ExecutionEvent event) { final ExtendedMarkersView view = getView(event); - if (view == null) + if (view == null) { return this; + } DialogTaskProperties dialog = new DialogTaskProperties(view.getSite() .getShell(), MarkerMessages.addGlobalTaskDialog_title); diff --git a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/views/markers/AllMarkersSeverityAndDescriptionFieldFilter.java b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/views/markers/AllMarkersSeverityAndDescriptionFieldFilter.java index c017478ab89..ed492f30ede 100644 --- a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/views/markers/AllMarkersSeverityAndDescriptionFieldFilter.java +++ b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/views/markers/AllMarkersSeverityAndDescriptionFieldFilter.java @@ -43,11 +43,13 @@ public boolean select(MarkerItem item) { if (filterOnSeverity) { IMarker marker = item.getMarker(); - if (marker == null) + if (marker == null) { return false; + } - if (!checkSeverity(item.getAttributeValue(IMarker.SEVERITY, -1))) + if (!checkSeverity(item.getAttributeValue(IMarker.SEVERITY, -1))) { return false; + } } return super.select(item); } @@ -74,8 +76,9 @@ public void loadSettings(IMemento memento) { super.loadSettings(memento); Boolean filtering = memento.getBoolean(FILTER_ON_SEVERITY); - if (filtering != null) + if (filtering != null) { filterOnSeverity = filtering.booleanValue(); + } } @Override diff --git a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/views/markers/CachedMarkerBuilder.java b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/views/markers/CachedMarkerBuilder.java index 71ac1d522a3..3c3484e44a7 100644 --- a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/views/markers/CachedMarkerBuilder.java +++ b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/views/markers/CachedMarkerBuilder.java @@ -47,9 +47,9 @@ public class CachedMarkerBuilder { private MarkerContentGenerator generator; private MarkerUpdateJob updateJob; private MarkersChangeListener markerListener; - private MarkerUpdateScheduler scheduler; + private final MarkerUpdateScheduler scheduler; - private Markers markers; + private final Markers markers; private Markers markersClone; final Object MARKER_INCREMENTAL_UPDATE_FAMILY = new Object(); @@ -62,7 +62,7 @@ public class CachedMarkerBuilder { private MarkerComparator comparator; - private boolean[] changeFlags; + private final boolean[] changeFlags; private IPropertyChangeListener workingSetListener; diff --git a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/views/markers/CompatibilityMarkerFieldFilterGroup.java b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/views/markers/CompatibilityMarkerFieldFilterGroup.java index 90f496230f7..896e2d48680 100644 --- a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/views/markers/CompatibilityMarkerFieldFilterGroup.java +++ b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/views/markers/CompatibilityMarkerFieldFilterGroup.java @@ -58,8 +58,9 @@ MarkerFieldFilterGroup makeWorkingCopy() { CompatibilityMarkerFieldFilterGroup clone = new CompatibilityMarkerFieldFilterGroup( this.problemFilter, this.generator); - if (populateClone(clone)) + if (populateClone(clone)) { return clone; + } return null; } @@ -69,8 +70,9 @@ protected void calculateFilters() { super.calculateFilters(); // Now initialize with the ProblemFilter for (MarkerFieldFilter fieldFilter : fieldFilters) { - if (fieldFilter instanceof CompatibilityFieldFilter) + if (fieldFilter instanceof CompatibilityFieldFilter) { ((CompatibilityFieldFilter) fieldFilter).initialize(problemFilter); + } } } diff --git a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/views/markers/CompletionConfigurationArea.java b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/views/markers/CompletionConfigurationArea.java index d1afed804ab..3469a32ad66 100644 --- a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/views/markers/CompletionConfigurationArea.java +++ b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/views/markers/CompletionConfigurationArea.java @@ -82,10 +82,11 @@ public void widgetSelected(SelectionEvent e) { */ void updateCompletion(int constant, boolean enabled) { - if (enabled) + if (enabled) { completionState = constant | completionState; - else + } else { completionState = constant ^ completionState; + } } diff --git a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/views/markers/CompletionFieldFilter.java b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/views/markers/CompletionFieldFilter.java index 6d44e970e75..f865bb9a3c0 100644 --- a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/views/markers/CompletionFieldFilter.java +++ b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/views/markers/CompletionFieldFilter.java @@ -46,8 +46,9 @@ public CompletionFieldFilter() { @Override public void loadSettings(IMemento memento) { Integer completionValue = memento.getInteger(COMPLETION_ATTRIBUTE); - if (completionValue == null) + if (completionValue == null) { return; + } completion = completionValue.intValue(); } @@ -79,12 +80,14 @@ public void saveSettings(IMemento memento) { @Override public boolean select(MarkerItem item) { - if (completion == ALL_SELECTED) + if (completion == ALL_SELECTED) { return true; + } if (item.getAttributeValue(IMarker.USER_EDITABLE, true)) { - if (item.getAttributeValue(IMarker.DONE, false)) + if (item.getAttributeValue(IMarker.DONE, false)) { return (completion & COMPLETED) > 0; + } return (completion & NOT_COMPLETED) > 0; } diff --git a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/views/markers/ConfigureColumnsHandler.java b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/views/markers/ConfigureColumnsHandler.java index 839edab775e..7641f60a159 100644 --- a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/views/markers/ConfigureColumnsHandler.java +++ b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/views/markers/ConfigureColumnsHandler.java @@ -28,8 +28,9 @@ public class ConfigureColumnsHandler extends MarkerViewHandler implements IHandl @Override public Object execute(ExecutionEvent event) { ExtendedMarkersView view = getView(event); - if (view == null) + if (view == null) { return this; + } new MarkersViewColumnsDialog(view).open(); return this; } diff --git a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/views/markers/ConfigureContentsDialogHandler.java b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/views/markers/ConfigureContentsDialogHandler.java index dd50fd57098..75e55f94d46 100644 --- a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/views/markers/ConfigureContentsDialogHandler.java +++ b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/views/markers/ConfigureContentsDialogHandler.java @@ -28,8 +28,9 @@ public class ConfigureContentsDialogHandler extends MarkerViewHandler implements @Override public Object execute(ExecutionEvent event) { ExtendedMarkersView view = getView(event); - if (view == null) + if (view == null) { return this; + } view.openFiltersDialog(); return this; } diff --git a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/views/markers/DeleteCompletedHandler.java b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/views/markers/DeleteCompletedHandler.java index a4af4e1efac..197c91f1b43 100644 --- a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/views/markers/DeleteCompletedHandler.java +++ b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/views/markers/DeleteCompletedHandler.java @@ -38,8 +38,9 @@ public class DeleteCompletedHandler extends MarkerViewHandler { public Object execute(ExecutionEvent event) { ExtendedMarkersView view = getView(event); - if (view == null) + if (view == null) { return this; + } final List completed = getCompletedTasks(view); // Check if there is anything to do diff --git a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/views/markers/DeleteHandler.java b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/views/markers/DeleteHandler.java index 287fe7c98ff..535e18d74ca 100644 --- a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/views/markers/DeleteHandler.java +++ b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/views/markers/DeleteHandler.java @@ -40,8 +40,9 @@ public class DeleteHandler extends MarkerViewHandler { public Object execute(ExecutionEvent event) { final MarkerSupportView view = getView(event); - if (view == null) + if (view == null) { return this; + } final IMarker[] selected = getSelectedMarkers(event); diff --git a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/views/markers/DescriptionConfigurationArea.java b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/views/markers/DescriptionConfigurationArea.java index 73ab15bd17e..367dfa0a1f9 100644 --- a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/views/markers/DescriptionConfigurationArea.java +++ b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/views/markers/DescriptionConfigurationArea.java @@ -48,11 +48,12 @@ public DescriptionConfigurationArea() { @Override public void apply(MarkerFieldFilter filter) { DescriptionFieldFilter desc = (DescriptionFieldFilter) filter; - if (descriptionCombo.getSelectionIndex() == 0) + if (descriptionCombo.getSelectionIndex() == 0) { desc.setContainsModifier(MarkerSupportConstants.CONTAINS_KEY); - else + } else { desc .setContainsModifier(MarkerSupportConstants.DOES_NOT_CONTAIN_KEY); + } desc.setContainsText(descriptionText.getText()); } @@ -66,10 +67,11 @@ public void createContents(Composite parent) { public void initialize(MarkerFieldFilter filter) { DescriptionFieldFilter desc = (DescriptionFieldFilter) filter; if (desc.getContainsModifier().equals( - MarkerSupportConstants.CONTAINS_KEY)) + MarkerSupportConstants.CONTAINS_KEY)) { descriptionCombo.select(0); - else + } else { descriptionCombo.select(1); + } descriptionText.setText(desc.getContainsText()); diff --git a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/views/markers/DescriptionFieldFilter.java b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/views/markers/DescriptionFieldFilter.java index 90c9cbb85e4..cfc68eb6174 100644 --- a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/views/markers/DescriptionFieldFilter.java +++ b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/views/markers/DescriptionFieldFilter.java @@ -45,11 +45,13 @@ public DescriptionFieldFilter() { @Override public void loadSettings(IMemento memento) { String modifier = memento.getString(TAG_CONTAINS_MODIFIER); - if (modifier == null) + if (modifier == null) { return; + } String contains = memento.getString(TAG_CONTAINS_TEXT); - if (contains == null) + if (contains == null) { return; + } containsText = contains; containsModifier = modifier; @@ -83,12 +85,14 @@ public void saveSettings(IMemento memento) { @Override public boolean select(MarkerItem item) { - if (containsText.isEmpty()) + if (containsText.isEmpty()) { return true; + } String value = getField().getValue(item); - if (containsModifier.equals(MarkerSupportConstants.CONTAINS_KEY)) + if (containsModifier.equals(MarkerSupportConstants.CONTAINS_KEY)) { return value.contains(containsText); + } return !value.contains(containsText); } diff --git a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/views/markers/ExtendedMarkersView.java b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/views/markers/ExtendedMarkersView.java index fae0d8d85b0..2a3fdb661a0 100644 --- a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/views/markers/ExtendedMarkersView.java +++ b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/views/markers/ExtendedMarkersView.java @@ -239,8 +239,9 @@ void addExpandedCategory(MarkerCategory category) { * {@link Collection} of {@link IMarker} */ private void addMarkers(MarkerSupportItem markerItem, Collection allMarkers) { - if (markerItem.getMarker() != null) + if (markerItem.getMarker() != null) { allMarkers.add(markerItem.getMarker()); + } MarkerSupportItem[] children = markerItem.getChildren(); for (MarkerSupportItem element : children) { addMarkers(element, allMarkers); @@ -292,9 +293,9 @@ private void createColumns(TreeColumn[] currentColumns, int[] widths) { for (int i = 0; i < fields.length; i++) { MarkerField markerField = fields[i]; TreeViewerColumn column = null; - if (i < currentColumns.length) + if (i < currentColumns.length) { column = new TreeViewerColumn(viewer, currentColumns[i]); - else { + } else { column = new TreeViewerColumn(viewer, SWT.NONE); column.getColumn().setResizable(true); column.getColumn().setMoveable(true); @@ -310,11 +311,13 @@ private void createColumns(TreeColumn[] currentColumns, int[] widths) { column.getColumn().setImage(markerField.getColumnHeaderImage()); EditingSupport support = markerField.getEditingSupport(viewer); - if (support != null) + if (support != null) { column.setEditingSupport(support); + } - if (builder.getPrimarySortField().equals(markerField)) + if (builder.getPrimarySortField().equals(markerField)) { updateDirectionIndicator(column.getColumn(), markerField); + } IMemento columnWidths = null; if (memento != null){ @@ -332,11 +335,12 @@ private void createColumns(TreeColumn[] currentColumns, int[] widths) { } // Take trim into account if we are using the default value, but not // if it is restored. - if (columnWidth < 0) + if (columnWidth < 0) { layout.addColumnData(new ColumnPixelData(markerField .getDefaultColumnWidth(tree), true, true)); - else + } else { layout.addColumnData(new ColumnPixelData(columnWidth, true)); + } } // Remove extra columns @@ -392,8 +396,9 @@ int getFieldWidth(MarkerField markerField, int preferredWidth, boolean considerU .getConfigurationElement().getAttribute( MarkerSupportInternalUtilities.ATTRIBUTE_ID)); // Make sure we get a useful value - if (value != null && value.intValue() >= 0) + if (value != null && value.intValue() >= 0) { preferredWidth = value.intValue(); + } } } if (preferredWidth <= 0) { @@ -465,8 +470,7 @@ private void startView() { private void addDoubleClickListener() { viewer.addDoubleClickListener(event -> { ISelection selection = event.getSelection(); - if(selection instanceof ITreeSelection) { - ITreeSelection ss = (ITreeSelection) selection; + if(selection instanceof ITreeSelection ss) { if(ss.size() == 1) { Object obj = ss.getFirstElement(); if(viewer.isExpandable(obj)) { @@ -501,8 +505,9 @@ private void addHelpListener() { // Set help on the view itself viewer.getControl().addHelpListener(e -> { IContextProvider provider = Adapters.adapt(ExtendedMarkersView.this, IContextProvider.class); - if (provider == null) + if (provider == null) { return; + } IContext context = provider.getContext(viewer.getControl()); PlatformUI.getWorkbench().getHelpSystem().displayHelp(context); @@ -585,10 +590,12 @@ public void dispose() { builder.dispose(); generator.dispose(); - if (instanceCount > 1) + if (instanceCount > 1) { instanceCount--; - if (clipboard != null) + } + if (clipboard != null) { clipboard.dispose(); + } getSite().getPage().removePostSelectionListener(pageSelectionListener); getSite().getPage().removePartListener(partListener); @@ -924,7 +931,7 @@ private String getStatusMessage(Markers markers, Integer[] counts) { return message; } return NLS.bind(MarkerMessages.problem_filter_matchedMessage, - new Object[] { message, filteredCount, totalCount }); + message, filteredCount, totalCount); } /** @@ -1626,8 +1633,7 @@ public void selectionChanged(IWorkbenchPart part, ISelection selection) { // get Objects to adapt List objectsToAdapt = new ArrayList<>(); - if (part instanceof IEditorPart) { - IEditorPart editor = (IEditorPart) part; + if (part instanceof IEditorPart editor) { objectsToAdapt.add(editor.getEditorInput()); } else if (selection instanceof IStructuredSelection) { for (Object object : (IStructuredSelection) selection) { diff --git a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/views/markers/FileMarkerPropertyTester.java b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/views/markers/FileMarkerPropertyTester.java index a3251dcf030..f32cb5aa9db 100644 --- a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/views/markers/FileMarkerPropertyTester.java +++ b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/views/markers/FileMarkerPropertyTester.java @@ -38,8 +38,9 @@ public FileMarkerPropertyTester() { public boolean test(Object receiver, String property, Object[] args, Object expectedValue) { if (property.equals(FILE_MARKER)) { - if (((MarkerEntry) receiver).getMarker().getResource().getType() == IResource.FILE) + if (((MarkerEntry) receiver).getMarker().getResource().getType() == IResource.FILE) { return true; + } } return false; } diff --git a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/views/markers/FiltersConfigurationDialog.java b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/views/markers/FiltersConfigurationDialog.java index 87eebc88c7a..111f7157efd 100644 --- a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/views/markers/FiltersConfigurationDialog.java +++ b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/views/markers/FiltersConfigurationDialog.java @@ -78,13 +78,13 @@ public class FiltersConfigurationDialog extends TrayDialog { private static final String PREV_SELECTED_ELEMENTS = "PREV_SELECTED_ELEMENTS"; //$NON-NLS-1$ private static int DEFAULTS_BUTTON_ID = 25; - private Collection filterGroups; + private final Collection filterGroups; private CheckboxTableViewer configsTable; private MarkerFieldFilterGroup selectedFilterGroup; - private MarkerContentGenerator generator; + private final MarkerContentGenerator generator; private boolean andFilters = false; @@ -96,7 +96,7 @@ public class FiltersConfigurationDialog extends TrayDialog { private Button limitButton; private Text limitText; - private GroupFilterConfigurationArea scopeArea = createScopeArea(); + private final GroupFilterConfigurationArea scopeArea = createScopeArea(); private ScrolledForm form; private Collection configAreas; @@ -216,8 +216,9 @@ private void updateRadioButtonsFromTable() { } private void updateConfigComposite(boolean enabled) { - if (enabled) + if (enabled) { updateButtonEnablement(getSelectionFromTable()); + } } /** Update the enablement of limitText */ diff --git a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/views/markers/FiltersContribution.java b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/views/markers/FiltersContribution.java index 595301a47d1..0f42dcac921 100644 --- a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/views/markers/FiltersContribution.java +++ b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/views/markers/FiltersContribution.java @@ -72,8 +72,9 @@ public void fill(Menu menu, int index) { private Listener getMenuItemListener(final MarkerFieldFilterGroup filter, final ExtendedMarkersView extendedView) { return event -> { - if (extendedView != null) + if (extendedView != null) { extendedView.toggleFilter(filter); + } }; } }; diff --git a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/views/markers/MarkerCategory.java b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/views/markers/MarkerCategory.java index eb564d29e90..de3ee02e1c8 100644 --- a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/views/markers/MarkerCategory.java +++ b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/views/markers/MarkerCategory.java @@ -98,14 +98,12 @@ String getDescription() { int limit = generator.getMarkerLimits(); if (limitsEnabled && size > limit) { - return NLS.bind(MarkerMessages.Category_Limit_Label, new Object[] { - name, - String.valueOf(limit), - String.valueOf(getChildrenCount()) }); + return NLS.bind(MarkerMessages.Category_Limit_Label, name, String.valueOf(limit), String.valueOf(getChildrenCount())); } - if (size == 1) + if (size == 1) { return NLS.bind(MarkerMessages.Category_One_Item_Label, new Object[] { name }); + } return NLS.bind(MarkerMessages.Category_Label, new Object[] { name, String.valueOf(size) }); @@ -118,16 +116,19 @@ String getDescription() { * @return int */ int getHighestSeverity() { - if (severity >= 0) + if (severity >= 0) { return severity; + } severity = 0;// Reset to info for (MarkerSupportItem supportItem : getChildren()) { if (supportItem.isConcrete()) { int elementSeverity = supportItem.getAttributeValue(IMarker.SEVERITY, -1); - if (elementSeverity > severity) + if (elementSeverity > severity) { severity = elementSeverity; - if (severity == IMarker.SEVERITY_ERROR)// As bad as it gets + } + if (severity == IMarker.SEVERITY_ERROR) { // As bad as it gets return severity; + } } } return severity; @@ -173,12 +174,15 @@ public int hashCode() { @Override public boolean equals(Object obj) { - if (this == obj) + if (this == obj) { return true; - if (obj == null) + } + if (obj == null) { return false; - if (getClass() != obj.getClass()) + } + if (getClass() != obj.getClass()) { return false; + } MarkerCategory other = (MarkerCategory) obj; return Objects.equals(markers, other.markers) && Objects.equals(name, other.name); } diff --git a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/views/markers/MarkerColumnLabelProvider.java b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/views/markers/MarkerColumnLabelProvider.java index a7a926c7279..3429a4cb4f3 100644 --- a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/views/markers/MarkerColumnLabelProvider.java +++ b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/views/markers/MarkerColumnLabelProvider.java @@ -30,7 +30,7 @@ public class MarkerColumnLabelProvider extends ColumnLabelProvider { MarkerField field; - private ResourceManager imageManager; + private final ResourceManager imageManager; /** * Create a MarkerViewLabelProvider on a field. diff --git a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/views/markers/MarkerCompletionField.java b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/views/markers/MarkerCompletionField.java index 35f32ce74f3..b1cf9c1bcb4 100644 --- a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/views/markers/MarkerCompletionField.java +++ b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/views/markers/MarkerCompletionField.java @@ -37,7 +37,7 @@ public class MarkerCompletionField extends MarkerField { private static class CompletionEditingSupport extends EditingSupport { - private CheckboxCellEditor editor; + private final CheckboxCellEditor editor; /** * Create a new instance of the receiver. @@ -50,9 +50,10 @@ public CompletionEditingSupport(ColumnViewer viewer) { @Override protected boolean canEdit(Object element) { - if (element instanceof MarkerEntry) + if (element instanceof MarkerEntry) { return ((MarkerEntry) element).getAttributeValue( IMarker.USER_EDITABLE, false); + } return false; } diff --git a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/views/markers/MarkerContentGenerator.java b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/views/markers/MarkerContentGenerator.java index 0c3f1758c6e..ac2aff459f5 100644 --- a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/views/markers/MarkerContentGenerator.java +++ b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/views/markers/MarkerContentGenerator.java @@ -75,7 +75,7 @@ public class MarkerContentGenerator { private final Collection FILTERS_CHANGED = Collections.emptySet(); //Carries the description for the generator, as coded in the given extension point - private ContentGeneratorDescriptor generatorDescriptor; + private final ContentGeneratorDescriptor generatorDescriptor; // fields private MarkerField[] visibleFields; @@ -268,8 +268,9 @@ Collection createFilterConfigurationFields() { for (MarkerField visibleField : visibleFields) { FilterConfigurationArea area = MarkerSupportInternalUtilities .generateFilterArea(visibleField); - if (area != null) + if (area != null) { result.add(area); + } } return result; diff --git a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/views/markers/MarkerCopyHandler.java b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/views/markers/MarkerCopyHandler.java index ee6b78a8f35..a6659fff74b 100644 --- a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/views/markers/MarkerCopyHandler.java +++ b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/views/markers/MarkerCopyHandler.java @@ -34,8 +34,9 @@ public class MarkerCopyHandler extends MarkerViewHandler { @Override public Object execute(ExecutionEvent event) { ExtendedMarkersView view = getView(event); - if (view == null) + if (view == null) { return null; + } setClipboard(view); return this; diff --git a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/views/markers/MarkerCreationTimeField.java b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/views/markers/MarkerCreationTimeField.java index ed01817e194..ccebf0cb607 100644 --- a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/views/markers/MarkerCreationTimeField.java +++ b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/views/markers/MarkerCreationTimeField.java @@ -28,12 +28,13 @@ */ public class MarkerCreationTimeField extends MarkerField { - private DateFormat dateFormat=DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.SHORT); + private final DateFormat dateFormat=DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.SHORT); @Override public String getValue(MarkerItem item) { long creationTime = ((MarkerSupportItem) item).getCreationTime(); - if (creationTime < 0) + if (creationTime < 0) { return MarkerSupportInternalUtilities.EMPTY_STRING; + } return String.valueOf(creationTime); } diff --git a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/views/markers/MarkerDescriptionField.java b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/views/markers/MarkerDescriptionField.java index 91f8b126ca4..7825cda709a 100644 --- a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/views/markers/MarkerDescriptionField.java +++ b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/views/markers/MarkerDescriptionField.java @@ -36,7 +36,7 @@ public class MarkerDescriptionField extends MarkerField { private static class DescriptionEditingSupport extends EditingSupport { - private TextCellEditor editor; + private final TextCellEditor editor; /** * Create a new instance of the receiver. @@ -48,14 +48,14 @@ public DescriptionEditingSupport(ColumnViewer viewer) { @Override protected boolean canEdit(Object element) { - if (element instanceof MarkerEntry) { + if (element instanceof MarkerEntry entry) { - MarkerEntry entry = (MarkerEntry) element; // Bookmarks are a special case try { if (entry.getMarker() != null - && entry.getMarker().isSubtypeOf(IMarker.BOOKMARK)) + && entry.getMarker().isSubtypeOf(IMarker.BOOKMARK)) { return true; + } } catch (CoreException e) { Policy.handle(e); return false; @@ -112,9 +112,10 @@ public int getDefaultColumnWidth(Control control) { * @return CollationKey */ private CollationKey getDescriptionKey(Object element) { - if (element instanceof MarkerEntry) + if (element instanceof MarkerEntry) { return ((MarkerEntry) element).getCollationKey(IMarker.MESSAGE, MarkerSupportInternalUtilities.UNKNOWN_ATRRIBTE_VALUE_STRING); + } return MarkerSupportInternalUtilities.EMPTY_COLLATION_KEY; } diff --git a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/views/markers/MarkerEntry.java b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/views/markers/MarkerEntry.java index 3df3a543ffd..09890af9947 100644 --- a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/views/markers/MarkerEntry.java +++ b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/views/markers/MarkerEntry.java @@ -404,10 +404,9 @@ public boolean equals(Object obj) { if (this == obj) { return true; } - if (!(obj instanceof MarkerEntry)) { + if (!(obj instanceof MarkerEntry other)) { return false; } - MarkerEntry other = (MarkerEntry) obj; return Objects.equals(marker, other.marker); } diff --git a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/views/markers/MarkerFieldFilterGroup.java b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/views/markers/MarkerFieldFilterGroup.java index 3bc4fef8f0f..380469249a8 100644 --- a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/views/markers/MarkerFieldFilterGroup.java +++ b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/views/markers/MarkerFieldFilterGroup.java @@ -105,7 +105,7 @@ public class MarkerFieldFilterGroup { private IConfigurationElement element; - private Map EMPTY_MAP = new HashMap<>(); + private final Map EMPTY_MAP = new HashMap<>(); private boolean enabled = true; protected MarkerFieldFilter[] fieldFilters; private int scope; diff --git a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/views/markers/MarkerGoToHandler.java b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/views/markers/MarkerGoToHandler.java index 796a5c7e6fc..50c429ed446 100644 --- a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/views/markers/MarkerGoToHandler.java +++ b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/views/markers/MarkerGoToHandler.java @@ -25,8 +25,9 @@ public class MarkerGoToHandler extends MarkerViewHandler { @Override public Object execute(ExecutionEvent event) { ExtendedMarkersView view = getView(event); - if(view == null) + if(view == null) { return this; + } view.openSelectedMarkers(); return this; } diff --git a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/views/markers/MarkerHelpAdapterFactory.java b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/views/markers/MarkerHelpAdapterFactory.java index 1a654625398..fa81bef1e09 100644 --- a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/views/markers/MarkerHelpAdapterFactory.java +++ b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/views/markers/MarkerHelpAdapterFactory.java @@ -32,12 +32,10 @@ public class MarkerHelpAdapterFactory implements IAdapterFactory { @Override public T getAdapter(Object adaptableObject, Class adapterType) { - if (!(adaptableObject instanceof ExtendedMarkersView)) { + if (!(adaptableObject instanceof final ExtendedMarkersView view)) { return null; } - final ExtendedMarkersView view = (ExtendedMarkersView) adaptableObject; - return adapterType.cast(new IContextProvider() { @Override diff --git a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/views/markers/MarkerPriorityField.java b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/views/markers/MarkerPriorityField.java index 8c32c1d7f75..b02f96ad017 100644 --- a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/views/markers/MarkerPriorityField.java +++ b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/views/markers/MarkerPriorityField.java @@ -40,7 +40,7 @@ public class MarkerPriorityField extends MarkerField { private static class PriorityEditingSupport extends EditingSupport { - private ComboBoxCellEditor editor; + private final ComboBoxCellEditor editor; /** * Create a new instance of the receiver. @@ -53,9 +53,10 @@ public PriorityEditingSupport(ColumnViewer viewer) { @Override protected boolean canEdit(Object element) { - if (element instanceof MarkerEntry) + if (element instanceof MarkerEntry) { return ((MarkerEntry) element).getAttributeValue( IMarker.USER_EDITABLE, false); + } return false; } diff --git a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/views/markers/MarkerProblemSeverityAndMessageField.java b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/views/markers/MarkerProblemSeverityAndMessageField.java index f30de0880c2..ee07427024f 100644 --- a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/views/markers/MarkerProblemSeverityAndMessageField.java +++ b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/views/markers/MarkerProblemSeverityAndMessageField.java @@ -51,16 +51,19 @@ private Image getImage(MarkerItem item) { MarkerSupportItem supportItem = (MarkerSupportItem) item; int severity = -1; - if (supportItem.isConcrete()) + if (supportItem.isConcrete()) { severity = MarkerSupportInternalUtilities.getSeverity(item); - else + } else { severity = ((MarkerCategory) supportItem).getHighestSeverity(); + } - if (severity >= 0) + if (severity >= 0) { return MarkerSupportInternalUtilities.getSeverityImage(severity); + } try { - if (supportItem.isConcrete()) + if (supportItem.isConcrete()) { return null; + } return JFaceResources .getResources() .createImageWithDefault( diff --git a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/views/markers/MarkerResourceField.java b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/views/markers/MarkerResourceField.java index d0a7f652c1a..a6ce49723b6 100644 --- a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/views/markers/MarkerResourceField.java +++ b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/views/markers/MarkerResourceField.java @@ -28,8 +28,9 @@ public class MarkerResourceField extends MarkerField { @Override public String getValue(MarkerItem item) { - if (item.getMarker() == null) + if (item.getMarker() == null) { return MarkerSupportInternalUtilities.EMPTY_STRING; + } return TextProcessor.process(item.getAttributeValue(MarkerViewUtil.NAME_ATTRIBUTE, item.getMarker().getResource().getName())); diff --git a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/views/markers/MarkerSelectAllHandler.java b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/views/markers/MarkerSelectAllHandler.java index 9a2aaa2a67e..f4aa5d18980 100644 --- a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/views/markers/MarkerSelectAllHandler.java +++ b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/views/markers/MarkerSelectAllHandler.java @@ -27,8 +27,9 @@ public class MarkerSelectAllHandler extends MarkerViewHandler implements @Override public Object execute(ExecutionEvent event) { ExtendedMarkersView view = getView(event); - if(view != null) + if(view != null) { view.selectAll(); + } return this; } diff --git a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/views/markers/MarkerSeverityAndDescriptionField.java b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/views/markers/MarkerSeverityAndDescriptionField.java index 89f6a9c6228..c9453d160cb 100644 --- a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/views/markers/MarkerSeverityAndDescriptionField.java +++ b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/views/markers/MarkerSeverityAndDescriptionField.java @@ -53,8 +53,9 @@ public int compare(MarkerItem item1, MarkerItem item2) { private Image getImage(MarkerItem item) { if (item.getMarker() == null) { int severity = ((MarkerCategory) item).getHighestSeverity(); - if (severity >= IMarker.SEVERITY_WARNING) + if (severity >= IMarker.SEVERITY_WARNING) { return MarkerSupportInternalUtilities.getSeverityImage(severity); + } return null; } int severity = MarkerSupportInternalUtilities.getSeverity(item); diff --git a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/views/markers/MarkerShowInAdapter.java b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/views/markers/MarkerShowInAdapter.java index 167070c1e44..2952348b47a 100644 --- a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/views/markers/MarkerShowInAdapter.java +++ b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/views/markers/MarkerShowInAdapter.java @@ -36,12 +36,10 @@ public class MarkerShowInAdapter implements IAdapterFactory { @Override public T getAdapter(Object adaptableObject, Class adapterType) { - if (!(adaptableObject instanceof ExtendedMarkersView)) { + if (!(adaptableObject instanceof final ExtendedMarkersView view)) { return null; } - final ExtendedMarkersView view = (ExtendedMarkersView) adaptableObject; - return adapterType.cast((IShowInSource) () -> { Collection resources = new HashSet<>(); for (IMarker marker : view.getSelectedMarkers()) { diff --git a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/views/markers/MarkerSortUtil.java b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/views/markers/MarkerSortUtil.java index ca09a75f8a3..b45070d6634 100644 --- a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/views/markers/MarkerSortUtil.java +++ b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/views/markers/MarkerSortUtil.java @@ -137,8 +137,9 @@ private static int leafSearch(MarkerEntry[] array, int first, int position, // while (childOffset < len) { if (comparator.compare(array[first + childOffset], array[first - + (childOffset - 1)]) < 0) + + (childOffset - 1)]) < 0) { --childOffset; + } array[first + holeOffset] = array[first + childOffset]; holeOffset = childOffset++; childOffset *= 2; @@ -228,12 +229,13 @@ private static int bottomUpSearch(MarkerEntry[] array, int first, int fromIndex, */ private static void heapify(MarkerEntry[] array, int first, int last, Comparator comparator) { - if (last - first < 2) + if (last - first < 2) { return; + } int parent = (last - first - 2) / 2; - do + do { adjustHeap(array, first, first + parent, last, comparator); - while (parent-- != 0); + } while (parent-- != 0); } /** @@ -275,8 +277,9 @@ public static void sortStartingKElement(MarkerEntry[] entries, // check range valid int last = from + k-1; if (entries.length == 0 || from < 0 || from >= to || last < from - || last > to || to > entries.length - 1 || to < 0) + || last > to || to > entries.length - 1 || to < 0) { return; + } int n=to-from+1; if (BATCH_SIZE == Integer.MAX_VALUE || (n <= BATCH_SIZE && (((float) n / k) <= MERGE_OR_HEAP_SWITCH)) /*|| ((float) n / k) <= MERGE_OR_HEAP_SWITCH*/) { diff --git a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/views/markers/MarkerSupportInternalUtilities.java b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/views/markers/MarkerSupportInternalUtilities.java index afc26741767..183ab00fb6d 100644 --- a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/views/markers/MarkerSupportInternalUtilities.java +++ b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/views/markers/MarkerSupportInternalUtilities.java @@ -144,8 +144,9 @@ public class MarkerSupportInternalUtilities { static final Image createImage(String completeImagePath, ResourceManager manager) { URL url = BundleUtility.find(IDEWorkbenchPlugin.getDefault() .getBundle().getSymbolicName(), completeImagePath); - if (url == null) + if (url == null) { return null; + } return manager.createImageWithDefault(ImageDescriptor.createFromURL(url)); } @@ -172,12 +173,14 @@ static final MarkerFieldFilter generateFilter(MarkerField field) { IConfigurationElement configurationElement = field .getConfigurationElement(); try { - if (configurationElement.getAttribute(ATTRIBUTE_FILTER_CLASS) == null) + if (configurationElement.getAttribute(ATTRIBUTE_FILTER_CLASS) == null) { return null; + } Object filter = IDEWorkbenchPlugin.createExtension( configurationElement, ATTRIBUTE_FILTER_CLASS); - if (filter == null) + if (filter == null) { return null; + } MarkerFieldFilter fieldFilter = (MarkerFieldFilter) filter; fieldFilter.setField(field); return fieldFilter; @@ -199,13 +202,15 @@ static final FilterConfigurationArea generateFilterArea(MarkerField field) { .getConfigurationElement(); try { if (configurationElement - .getAttribute(ATTRIBUTE_FILTER_CONFIGURATION_CLASS) == null) + .getAttribute(ATTRIBUTE_FILTER_CONFIGURATION_CLASS) == null) { return null; + } FilterConfigurationArea area = (FilterConfigurationArea) IDEWorkbenchPlugin .createExtension(configurationElement, ATTRIBUTE_FILTER_CONFIGURATION_CLASS); - if (area != null) + if (area != null) { area.setField(field); + } return area; } catch (CoreException e) { Policy.handle(e); @@ -244,8 +249,9 @@ public static final int getFontWidth(Control control) { * @return String */ public static final String getGroupValue(MarkerGroup group, MarkerItem item) { - if (item.getMarker() == null) + if (item.getMarker() == null) { return ((MarkerSupportItem) item).getDescription(); + } try { MarkerGroupingEntry groupingEntry = group.findGroupValue(item .getMarker().getType(), item.getMarker()); @@ -263,8 +269,7 @@ public static final String getGroupValue(MarkerGroup group, MarkerItem item) { * @return the severity */ public static final int getHighestSeverity(MarkerItem markerItem) { - if (markerItem instanceof MarkerCategory) { - MarkerCategory category = (MarkerCategory) markerItem; + if (markerItem instanceof MarkerCategory category) { return category.getHighestSeverity(); } IMarker marker = markerItem.getMarker(); @@ -356,9 +361,8 @@ public static boolean showMarker(IViewPart view, IMarker marker) { * otherwise */ public static boolean showMarkers(IViewPart view, IMarker[] markers) { - if (view instanceof ExtendedMarkersView) { + if (view instanceof ExtendedMarkersView markerView) { StructuredSelection selection = new StructuredSelection(markers); - ExtendedMarkersView markerView = (ExtendedMarkersView) view; markerView.setSelection(selection, true); return true; } @@ -394,10 +398,11 @@ public static void handleViewError(Exception exception, int handlingMethod) { status = ((CoreException) exception).getStatus(); } - if (status == null) + if (status == null) { StatusManager.getManager().handle(StatusUtil.newError(exception), handlingMethod); - else + } else { StatusManager.getManager().handle(status, handlingMethod); + } return; } StatusManager.getManager().handle(StatusUtil.newError(exception), handlingMethod); diff --git a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/views/markers/MarkerSupportItem.java b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/views/markers/MarkerSupportItem.java index fc3bdea19bf..fa1e1c1def9 100644 --- a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/views/markers/MarkerSupportItem.java +++ b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/views/markers/MarkerSupportItem.java @@ -33,8 +33,9 @@ abstract class MarkerSupportItem extends MarkerItem { @Override public String getAttributeValue(String attribute, String defaultValue) { // All items have messages - if (attribute == IMarker.MESSAGE) + if (attribute == IMarker.MESSAGE) { return getDescription(); + } return super.getAttributeValue(attribute, defaultValue); } diff --git a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/views/markers/MarkerViewerContentProvider.java b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/views/markers/MarkerViewerContentProvider.java index 12ee08c81ff..12ba8a487a7 100644 --- a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/views/markers/MarkerViewerContentProvider.java +++ b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/views/markers/MarkerViewerContentProvider.java @@ -68,8 +68,9 @@ private Object[] getLimitedChildren(Object[] children) { boolean limitsEnabled = markersView.getGenerator().isMarkerLimitsEnabled(); int limits = markersView.getGenerator().getMarkerLimits(); - if (!limitsEnabled || limits <= 0 || limits > children.length) + if (!limitsEnabled || limits <= 0 || limits > children.length) { return children; + } Object[] newChildren = new Object[limits]; System.arraycopy(children, 0, newChildren, 0, limits); @@ -82,8 +83,9 @@ public Object getParent(Object element) { if (element instanceof MarkerSupportItem markerItem) { parent = markerItem.getParent(); } - if (parent == null) + if (parent == null) { return input; + } return parent; } diff --git a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/views/markers/Markers.java b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/views/markers/Markers.java index 16d48a3095e..cb28a0e9cac 100644 --- a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/views/markers/Markers.java +++ b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/views/markers/Markers.java @@ -52,7 +52,7 @@ class Markers { // the categories private volatile MarkerCategory[] categories = EMPTY_CATEGORY_ARRAY; - private CachedMarkerBuilder builder; + private final CachedMarkerBuilder builder; private volatile boolean inChange; @@ -402,10 +402,9 @@ public boolean equals(Object obj) { if (this == obj) { return true; } - if (!(obj instanceof Markers)) { + if (!(obj instanceof Markers other)) { return false; } - Markers other = (Markers) obj; return Objects.equals(builder, other.builder); } } diff --git a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/views/markers/MarkersChangeListener.java b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/views/markers/MarkersChangeListener.java index e08a3e44b1b..7c9d204c756 100644 --- a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/views/markers/MarkersChangeListener.java +++ b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/views/markers/MarkersChangeListener.java @@ -34,8 +34,8 @@ */ class MarkersChangeListener implements IResourceChangeListener { - private ExtendedMarkersView view; - private CachedMarkerBuilder builder; + private final ExtendedMarkersView view; + private final CachedMarkerBuilder builder; private String[] listeningTypes; private boolean receiving; @@ -466,15 +466,15 @@ class MarkerUpdateScheduler { static final int LONG_DELAY = 10000; static final long TIME_OUT = 30000; - private CachedMarkerBuilder builder; - private ExtendedMarkersView view; + private final CachedMarkerBuilder builder; + private final ExtendedMarkersView view; private MarkerUpdateJob updateJob; private UIUpdateJob uiUpdateJob; private final Object schedulingLock; - private MarkerUpdateTimer updateTimer; + private final MarkerUpdateTimer updateTimer; public MarkerUpdateScheduler(ExtendedMarkersView view, CachedMarkerBuilder builder) { this.view = view; diff --git a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/views/markers/MarkersContribution.java b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/views/markers/MarkersContribution.java index a67a35a361f..d47aadf4028 100644 --- a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/views/markers/MarkersContribution.java +++ b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/views/markers/MarkersContribution.java @@ -50,14 +50,17 @@ public MarkersContribution(String id) { ExtendedMarkersView getView() { IWorkbenchWindow active = PlatformUI.getWorkbench() .getActiveWorkbenchWindow(); - if (active == null) + if (active == null) { return null; + } IWorkbenchPage page = active.getActivePage(); - if (page == null) + if (page == null) { return null; + } IWorkbenchPart part = page.getActivePart(); - if (!(part instanceof ExtendedMarkersView)) + if (!(part instanceof ExtendedMarkersView)) { return null; + } return (ExtendedMarkersView) part; } diff --git a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/views/markers/MarkersTreeViewer.java b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/views/markers/MarkersTreeViewer.java index d9e083571dd..0a1aa02e89b 100644 --- a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/views/markers/MarkersTreeViewer.java +++ b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/views/markers/MarkersTreeViewer.java @@ -64,8 +64,9 @@ protected void doUpdateItem(Item item, Object element) { * For performance reasons clear cache of the item used in updating UI. */ if (element instanceof MarkerSupportItem cellItem) { - if (cellItem.isConcrete()) + if (cellItem.isConcrete()) { cellItem.clearCache(); + } } } diff --git a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/views/markers/MarkersViewColumnsDialog.java b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/views/markers/MarkersViewColumnsDialog.java index 61d287bb25a..3e7e5453d08 100644 --- a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/views/markers/MarkersViewColumnsDialog.java +++ b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/views/markers/MarkersViewColumnsDialog.java @@ -38,7 +38,7 @@ */ public class MarkersViewColumnsDialog extends ViewerColumnsDialog { - private ExtendedMarkersView extendedView; + private final ExtendedMarkersView extendedView; /** * Create a new instance of the receiver. diff --git a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/views/markers/MarkersViewPropertyTester.java b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/views/markers/MarkersViewPropertyTester.java index eb118524897..86399115640 100644 --- a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/views/markers/MarkersViewPropertyTester.java +++ b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/views/markers/MarkersViewPropertyTester.java @@ -43,17 +43,19 @@ public MarkersViewPropertyTester() { public boolean test(Object receiver, String property, Object[] args, Object expectedValue) { - if (!(receiver instanceof ExtendedMarkersView)) + if (!(receiver instanceof ExtendedMarkersView view)) { return false; + } - ExtendedMarkersView view = (ExtendedMarkersView) receiver; - - if (property.equals(ATTRIBUTE_CONTENT_GENERATOR)) + if (property.equals(ATTRIBUTE_CONTENT_GENERATOR)) { return testContentGenerator(view, args); - if (property.equals(ATTRIBUTE_HAS_FILTERS)) + } + if (property.equals(ATTRIBUTE_HAS_FILTERS)) { return view.getAllFilters().size() > 0; - if (property.equals(ATTRIBUTE_HAS_GROUPS)) + } + if (property.equals(ATTRIBUTE_HAS_GROUPS)) { return view.getBuilder().getGenerator().getMarkerGroups().size() > 0; + } return false; } @@ -67,12 +69,14 @@ private boolean testContentGenerator(ExtendedMarkersView view, Object[] args) { String currentGenerator = view.getBuilder().getGenerator().getId(); for (Object arg : args) { - if (arg.equals(currentGenerator)) + if (arg.equals(currentGenerator)) { return true; + } // The value 'any' works for any content generator - if (arg.equals(ANY_CONTENT_GENERATOR)) + if (arg.equals(ANY_CONTENT_GENERATOR)) { return true; + } } return false; } diff --git a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/views/markers/OpenMarkersViewHandler.java b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/views/markers/OpenMarkersViewHandler.java index 3cc85bfde20..2080b341d75 100644 --- a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/views/markers/OpenMarkersViewHandler.java +++ b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/views/markers/OpenMarkersViewHandler.java @@ -36,8 +36,9 @@ public class OpenMarkersViewHandler extends MarkerViewHandler { @Override public Object execute(ExecutionEvent event) throws ExecutionException { ExtendedMarkersView part = getView(event); - if (part == null) + if (part == null) { return null; + } try { String count = ExtendedMarkersView.newSecondaryID(part); String defaultName = NLS.bind(MarkerMessages.newViewTitle, @@ -50,8 +51,9 @@ public Object execute(ExecutionEvent event) throws ExecutionException { MarkerMessages.NewViewHandler_dialogMessage, defaultName, getValidator()); - if (dialog.open() != Window.OK) + if (dialog.open() != Window.OK) { return this; + } IViewPart newPart = part.getSite().getPage() .showView(part.getSite().getId(), count, @@ -74,8 +76,9 @@ public Object execute(ExecutionEvent event) throws ExecutionException { */ private IInputValidator getValidator() { return newText -> { - if (newText.length() > 0) + if (newText.length() > 0) { return null; + } return MarkerMessages.MarkerFilterDialog_emptyMessage; }; } diff --git a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/views/markers/PriorityConfigurationArea.java b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/views/markers/PriorityConfigurationArea.java index 3a287965dab..dfdd26fa102 100644 --- a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/views/markers/PriorityConfigurationArea.java +++ b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/views/markers/PriorityConfigurationArea.java @@ -91,10 +91,11 @@ public void widgetSelected(SelectionEvent e) { */ void updatePriorities(int constant, boolean enabled) { - if (enabled) + if (enabled) { priorities = constant | priorities; - else + } else { priorities = constant ^ priorities; + } } diff --git a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/views/markers/PriorityMarkerFieldFilter.java b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/views/markers/PriorityMarkerFieldFilter.java index 382d6510731..026e0b23528 100644 --- a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/views/markers/PriorityMarkerFieldFilter.java +++ b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/views/markers/PriorityMarkerFieldFilter.java @@ -50,8 +50,9 @@ public PriorityMarkerFieldFilter() { @Override public void loadSettings(IMemento memento) { Integer priority = memento.getInteger(TAG_SELECTED_PRIORITIES); - if (priority == null) + if (priority == null) { return; + } selectedPriorities = priority.intValue(); } @@ -86,11 +87,13 @@ public void saveSettings(IMemento memento) { @Override public boolean select(MarkerItem item) { - if (selectedPriorities == 0) + if (selectedPriorities == 0) { return true; + } IMarker marker = item.getMarker(); - if (marker == null) + if (marker == null) { return false; + } int markerPriority = 1 << marker.getAttribute(IMarker.PRIORITY, IMarker.PRIORITY_NORMAL); diff --git a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/views/markers/ProblemsSeverityAndDescriptionFieldFilter.java b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/views/markers/ProblemsSeverityAndDescriptionFieldFilter.java index 8103f7ebc61..6aafca1eb8c 100644 --- a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/views/markers/ProblemsSeverityAndDescriptionFieldFilter.java +++ b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/views/markers/ProblemsSeverityAndDescriptionFieldFilter.java @@ -33,14 +33,17 @@ public class ProblemsSeverityAndDescriptionFieldFilter extends public boolean select(MarkerItem item) { IMarker marker = item.getMarker(); - if (marker == null) + if (marker == null) { return false; + } int markerSeverity = item.getAttributeValue(IMarker.SEVERITY, -1); - if (markerSeverity < 0) + if (markerSeverity < 0) { return false; - if (checkSeverity(markerSeverity)) + } + if (checkSeverity(markerSeverity)) { return super.select(item); + } return false; } @@ -61,7 +64,8 @@ void loadLegacySettings(IMemento memento, MarkerContentGenerator generator) { @Override public void initialize(ProblemFilter problemFilter) { super.initialize(problemFilter); - if (problemFilter.getSeverity() > 0) + if (problemFilter.getSeverity() > 0) { selectedSeverities = problemFilter.getSeverity(); + } } } diff --git a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/views/markers/QuickFixHandler.java b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/views/markers/QuickFixHandler.java index 7783004d549..8781476748c 100644 --- a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/views/markers/QuickFixHandler.java +++ b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/views/markers/QuickFixHandler.java @@ -72,8 +72,9 @@ public QuickFixWizardDialog(Shell parentShell, IWizard newWizard) { public Object execute(ExecutionEvent event) throws ExecutionException { final ExtendedMarkersView view = getView(event); - if (view == null) + if (view == null) { return this; + } final Map> resolutionsMap = new LinkedHashMap<>(); final IMarker[] selectedMarkers = view.getSelectedMarkers(); diff --git a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/views/markers/QuickFixPage.java b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/views/markers/QuickFixPage.java index 5e69330e723..28fc27ce6a9 100644 --- a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/views/markers/QuickFixPage.java +++ b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/views/markers/QuickFixPage.java @@ -68,11 +68,11 @@ */ public class QuickFixPage extends WizardPage { - private Map> resolutions; + private final Map> resolutions; private TableViewer resolutionsList; private CheckboxTableViewer markersTable; - private IMarker[] selectedMarkers; + private final IMarker[] selectedMarkers; private final Consumer showMarkers; private final Consumer bindHelp; @@ -217,7 +217,7 @@ public String getText(Object element) { @Override public Image getImage(Object element) { - return element instanceof IMarkerResolution2 ? ((IMarkerResolution2)element).getImage() : null; + return element instanceof IMarkerResolution2 i ? i.getImage() : null; } }); @@ -307,8 +307,9 @@ public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { @Override public Image getColumnImage(Object element, int columnIndex) { - if (columnIndex == 0) + if (columnIndex == 0) { return Util.getImage(((IMarker) element).getAttribute(IMarker.SEVERITY, -1)); + } return null; } @@ -326,11 +327,12 @@ public String getColumnText(Object element, int columnIndex) { // No override so use line number int lineNumber = marker.getAttribute(IMarker.LINE_NUMBER, -1); String lineNumberString=null; - if (lineNumber < 0) + if (lineNumber < 0) { lineNumberString = MarkerMessages.Unknown; - else + } else { lineNumberString = NLS.bind(MarkerMessages.label_lineNumber, Integer.toString(lineNumber)); + } return lineNumberString; } @@ -397,8 +399,9 @@ public IMarker getSelectedMarker() { IStructuredSelection selection = markersTable.getStructuredSelection(); if (!selection.isEmpty()) { IStructuredSelection struct = selection; - if (struct.size() == 1) + if (struct.size() == 1) { return (IMarker) struct.getFirstElement(); + } } return null; } diff --git a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/views/markers/QuickFixPropertyTester.java b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/views/markers/QuickFixPropertyTester.java index a0e22ee2f08..7d00aee971d 100644 --- a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/views/markers/QuickFixPropertyTester.java +++ b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/views/markers/QuickFixPropertyTester.java @@ -35,9 +35,10 @@ public QuickFixPropertyTester() { @Override public boolean test(Object receiver, String property, Object[] args, Object expectedValue) { - if (property.equals(QUICK_FIX)) + if (property.equals(QUICK_FIX)) { return IDE.getMarkerHelpRegistry().hasResolutions( ((MarkerEntry) receiver).getMarker()); + } return false; } diff --git a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/views/markers/QuickFixWizard.java b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/views/markers/QuickFixWizard.java index acd0afcac7f..d394f5db526 100644 --- a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/views/markers/QuickFixWizard.java +++ b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/views/markers/QuickFixWizard.java @@ -42,9 +42,9 @@ */ class QuickFixWizard extends Wizard { - private IMarker[] selectedMarkers; - private Map> resolutionMap; - private String description; + private final IMarker[] selectedMarkers; + private final Map> resolutionMap; + private final String description; private final Consumer showMarkers; private final Consumer bindHelp; private final Consumer reporter; diff --git a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/views/markers/SeverityAndDescriptionConfigurationArea.java b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/views/markers/SeverityAndDescriptionConfigurationArea.java index 2261c422ea7..f119289b804 100644 --- a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/views/markers/SeverityAndDescriptionConfigurationArea.java +++ b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/views/markers/SeverityAndDescriptionConfigurationArea.java @@ -133,10 +133,11 @@ public void initialize(MarkerFieldFilter filter) { * one of {@link IMarker#SEVERITY_ERROR},{@link IMarker#SEVERITY_WARNING},{@link IMarker#SEVERITY_INFO} */ private void updateSeverities(int constant, boolean enabled) { - if (enabled) + if (enabled) { severities = constant | severities; - else + } else { severities = constant ^ severities; + } } diff --git a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/views/markers/SeverityAndDescriptionFieldFilter.java b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/views/markers/SeverityAndDescriptionFieldFilter.java index f59516d6f61..2ee1c98a04b 100644 --- a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/views/markers/SeverityAndDescriptionFieldFilter.java +++ b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/views/markers/SeverityAndDescriptionFieldFilter.java @@ -48,13 +48,15 @@ public void initialize(Map values) { } Object modifier = values .get(MarkerSupportInternalUtilities.CONTAINS_MODIFIER_TOKEN); - if (modifier != null && modifier instanceof String) + if (modifier != null && modifier instanceof String) { containsModifier = (String) modifier; + } Object text = values .get(MarkerSupportInternalUtilities.CONTAINS_TEXT_TOKEN); - if (text != null && text instanceof String) + if (text != null && text instanceof String) { containsText = (String) text; + } } diff --git a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/views/markers/ShowMarkers.java b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/views/markers/ShowMarkers.java index 29d854d9a10..cbda5280bad 100644 --- a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/views/markers/ShowMarkers.java +++ b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/views/markers/ShowMarkers.java @@ -51,10 +51,9 @@ protected void linkToEditor(ISelection selection) { protected void open(ISelection selection, boolean activate) { IStructuredSelection structured = (IStructuredSelection) selection; Object first = structured.getFirstElement(); - if (!(first instanceof IMarker)) { + if (!(first instanceof IMarker marker)) { return; } - IMarker marker = (IMarker) first; if (marker.getResource() instanceof IFile) { try { IDE.openEditor(partSite.getPage(), marker, activate); diff --git a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/views/markers/SortFieldContribution.java b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/views/markers/SortFieldContribution.java index d77205ceaf8..1aced544044 100644 --- a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/views/markers/SortFieldContribution.java +++ b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/views/markers/SortFieldContribution.java @@ -46,13 +46,15 @@ public SortFieldContribution(String id) { @Override protected IContributionItem[] getContributionItems() { ExtendedMarkersView view = getView(); - if (view == null) + if (view == null) { return new IContributionItem[0]; + } MarkerField[] fields = view.getVisibleFields(); - if (fields.length == 0) + if (fields.length == 0) { return new IContributionItem[0]; + } IContributionItem[] items = new IContributionItem[fields.length + 2]; @@ -81,12 +83,14 @@ public void fill(Menu menu, int index) { final ExtendedMarkersView view = getView(); item.addListener(SWT.Selection, event -> { - if (view != null) + if (view != null) { view.toggleSortDirection(); + } }); - if (view != null) + if (view != null) { item.setSelection(view.getSortAscending()); + } } @@ -110,8 +114,9 @@ public void fill(Menu menu, int index) { item.addListener(SWT.Selection, getMenuItemListener(field, view)); - if (view != null) + if (view != null) { item.setSelection(view.isPrimarySortField(field)); + } } @@ -126,8 +131,9 @@ private Listener getMenuItemListener(final MarkerField markerField, MenuItem item = (MenuItem) event.widget; - if (item.getSelection() && view != null) + if (item.getSelection() && view != null) { view.setPrimarySortField(markerField); + } }; } }; diff --git a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/views/markers/TypesConfigurationArea.java b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/views/markers/TypesConfigurationArea.java index 0c48109e96d..fac5ca69a26 100644 --- a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/views/markers/TypesConfigurationArea.java +++ b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/views/markers/TypesConfigurationArea.java @@ -53,8 +53,8 @@ public class TypesConfigurationArea extends GroupFilterConfigurationArea { private static class CategoryEntry extends TypesEntry { - private Collection children = new ArrayList<>(); - private String name; + private final Collection children = new ArrayList<>(); + private final String name; /** * Create a new instance of the receiver. @@ -105,7 +105,7 @@ public boolean hasChildren() { private static class MarkerTypeEntry extends TypesEntry { private CategoryEntry category; - private MarkerType markerType; + private final MarkerType markerType; /** * Create an instance of the receiver. @@ -198,7 +198,7 @@ private abstract static class TypesEntry { private static Collection EMPTY_COLLECTION = new HashSet<>(); - private HashMap> models = new HashMap<>(0); + private final HashMap> models = new HashMap<>(0); private CheckboxTreeViewer typesViewer; diff --git a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/views/markers/UIUpdateJob.java b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/views/markers/UIUpdateJob.java index eca30fe18e7..2efb05818d0 100644 --- a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/views/markers/UIUpdateJob.java +++ b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/views/markers/UIUpdateJob.java @@ -32,7 +32,7 @@ */ class UIUpdateJob extends WorkbenchJob { - private ExtendedMarkersView view; + private final ExtendedMarkersView view; private boolean updating; @@ -72,13 +72,15 @@ public IStatus runInUIThread(IProgressMonitor monitor) { if (view.getBuilder().isShowingHierarchy() && view.getCategoriesToExpand().isEmpty()) { MarkerCategory[] categories = clone.getCategories(); - if (categories != null && categories.length == 1) + if (categories != null && categories.length == 1) { view.getCategoriesToExpand().add( categories[0].getDescription()); + } } - if (monitor.isCanceled()) + if (monitor.isCanceled()) { return Status.CANCEL_STATUS; + } /* * always use a clone for Thread safety. We avoid setting the clone * as new input as we would offset the benefits of optimization in diff --git a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/views/markers/ViewerColumnsDialog.java b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/views/markers/ViewerColumnsDialog.java index 022478e4c29..31c252aa113 100644 --- a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/views/markers/ViewerColumnsDialog.java +++ b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/views/markers/ViewerColumnsDialog.java @@ -707,10 +707,9 @@ public boolean equals(Object obj) { if (this == obj) { return true; } - if (!(obj instanceof TestData)) { + if (!(obj instanceof TestData other)) { return false; } - TestData other = (TestData) obj; return Objects.equals(key, other.key) && keyIndex == other.keyIndex; } diff --git a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/wizards/datatransfer/ArchiveFileExportOperation.java b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/wizards/datatransfer/ArchiveFileExportOperation.java index 62aa5b1cb30..dd23066247b 100644 --- a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/wizards/datatransfer/ArchiveFileExportOperation.java +++ b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/wizards/datatransfer/ArchiveFileExportOperation.java @@ -42,7 +42,7 @@ public class ArchiveFileExportOperation implements IRunnableWithProgress { private IFileExporter exporter; - private String destinationFilename; + private final String destinationFilename; private IProgressMonitor monitor; @@ -50,7 +50,7 @@ public class ArchiveFileExportOperation implements IRunnableWithProgress { private IResource resource; - private List errorTable = new ArrayList<>(1); // IStatus + private final List errorTable = new ArrayList<>(1); // IStatus private boolean useCompression = true; diff --git a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/wizards/datatransfer/CouldNotImportProjectException.java b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/wizards/datatransfer/CouldNotImportProjectException.java index 9bc819a37b3..9d60a3b88ae 100644 --- a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/wizards/datatransfer/CouldNotImportProjectException.java +++ b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/wizards/datatransfer/CouldNotImportProjectException.java @@ -23,7 +23,7 @@ public class CouldNotImportProjectException extends Exception { private static final long serialVersionUID = 5207202862271299462L; - private File location; + private final File location; public CouldNotImportProjectException(File location, Exception cause) { super("Could not import project located at " + location.getAbsolutePath(), cause); //$NON-NLS-1$ diff --git a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/wizards/datatransfer/DelegateProgressMonitorInUIThreadAndPreservingFocus.java b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/wizards/datatransfer/DelegateProgressMonitorInUIThreadAndPreservingFocus.java index 1e28405cc31..e775b9cfc89 100644 --- a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/wizards/datatransfer/DelegateProgressMonitorInUIThreadAndPreservingFocus.java +++ b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/wizards/datatransfer/DelegateProgressMonitorInUIThreadAndPreservingFocus.java @@ -30,8 +30,8 @@ * @since 3.12 */ class DelegateProgressMonitorInUIThreadAndPreservingFocus implements IProgressMonitor { - private ProgressMonitorPart delegate; - private Display display; + private final ProgressMonitorPart delegate; + private final Display display; public DelegateProgressMonitorInUIThreadAndPreservingFocus(ProgressMonitorPart delegate) { this.delegate = delegate; diff --git a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/wizards/datatransfer/FileSystemExportOperation.java b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/wizards/datatransfer/FileSystemExportOperation.java index accbf14b74d..8ad019e454b 100644 --- a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/wizards/datatransfer/FileSystemExportOperation.java +++ b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/wizards/datatransfer/FileSystemExportOperation.java @@ -43,15 +43,15 @@ public class FileSystemExportOperation implements IRunnableWithProgress { private IProgressMonitor monitor; - private FileSystemExporter exporter = new FileSystemExporter(); + private final FileSystemExporter exporter = new FileSystemExporter(); private List resourcesToExport; - private IOverwriteQuery overwriteCallback; + private final IOverwriteQuery overwriteCallback; - private IResource resource; + private final IResource resource; - private List errorTable = new ArrayList<>(1); + private final List errorTable = new ArrayList<>(1); //The constants for the overwrite 3 state private static final int OVERWRITE_NOT_SET = 0; diff --git a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/wizards/datatransfer/ProjectConfiguratorExtensionManager.java b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/wizards/datatransfer/ProjectConfiguratorExtensionManager.java index fa90082849b..e7b35c93707 100644 --- a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/wizards/datatransfer/ProjectConfiguratorExtensionManager.java +++ b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/wizards/datatransfer/ProjectConfiguratorExtensionManager.java @@ -45,9 +45,9 @@ public class ProjectConfiguratorExtensionManager { private static final String EXTENSION_POINT_ID = IDEWorkbenchPlugin.IDE_WORKBENCH + ".projectConfigurators"; //$NON-NLS-1$ - private IConfigurationElement[] extensions; - private ExpressionConverter expressionConverter; - private Map configuratorsByExtension = new HashMap<>(); + private final IConfigurationElement[] extensions; + private final ExpressionConverter expressionConverter; + private final Map configuratorsByExtension = new HashMap<>(); /** * Each instance of this class will have it's own internal registry, that will load (maximum) once each extension class, diff --git a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/wizards/datatransfer/SmartImportJob.java b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/wizards/datatransfer/SmartImportJob.java index e01f8f710d7..8fd1ba72da3 100644 --- a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/wizards/datatransfer/SmartImportJob.java +++ b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/wizards/datatransfer/SmartImportJob.java @@ -67,12 +67,12 @@ public class SmartImportJob extends Job { /* * Input parameters */ - private File rootDirectory; + private final File rootDirectory; private Set directoriesToImport; private Set excludedDirectories; private boolean discardRootProject; private boolean deepChildrenDetection; - private boolean configureProjects; + private final boolean configureProjects; private boolean closeProjectsAfterImport; private boolean reconfigureEclipseProjects; private IWorkingSet[] workingSets; @@ -81,15 +81,15 @@ public class SmartImportJob extends Job { * working fields */ private IProject rootProject; - private IWorkspaceRoot workspaceRoot; + private final IWorkspaceRoot workspaceRoot; private ProjectConfiguratorExtensionManager configurationManager; private RecursiveImportListener listener; protected Map> importProposals; - private Map> report; - private Map errors; + private final Map> report; + private final Map errors; - private JobGroup crawlerJobGroup; + private final JobGroup crawlerJobGroup; /** * Builds a new instance of the job diff --git a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/wizards/datatransfer/SmartImportRootWizardPage.java b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/wizards/datatransfer/SmartImportRootWizardPage.java index 09c7bf71e96..1e6ae8b7c28 100644 --- a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/wizards/datatransfer/SmartImportRootWizardPage.java +++ b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/wizards/datatransfer/SmartImportRootWizardPage.java @@ -165,7 +165,7 @@ public ProgressMonitorPart get() { private Job refreshProposalsJob; private JobMonitor jobMonitor; private DelegateProgressMonitorInUIThreadAndPreservingFocus delegateMonitor; - private SelectionListener cancelWorkListener = new SelectionAdapter() { + private final SelectionListener cancelWorkListener = new SelectionAdapter() { @Override public void widgetSelected(SelectionEvent e) { stopAndDisconnectCurrentWork(); diff --git a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/wizards/datatransfer/SmartImportWizard.java b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/wizards/datatransfer/SmartImportWizard.java index 9655a574d21..aed6fca7d5f 100644 --- a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/wizards/datatransfer/SmartImportWizard.java +++ b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/wizards/datatransfer/SmartImportWizard.java @@ -66,8 +66,8 @@ public class SmartImportWizard extends Wizard implements IImportWizard { * @since 3.12 */ private static final class ExpandArchiveIntoFilesystemOperation implements IRunnableWithProgress { - private File archive; - private File destination; + private final File archive; + private final File destination; private ExpandArchiveIntoFilesystemOperation(File archive, File destination) { this.archive = archive; diff --git a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/wizards/datatransfer/SubdirectoryOrSameNameSchedulingRule.java b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/wizards/datatransfer/SubdirectoryOrSameNameSchedulingRule.java index 81d4e1acb74..ca9e44b4ba4 100644 --- a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/wizards/datatransfer/SubdirectoryOrSameNameSchedulingRule.java +++ b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/wizards/datatransfer/SubdirectoryOrSameNameSchedulingRule.java @@ -61,8 +61,7 @@ public boolean contains(ISchedulingRule rule) { @Override public boolean isConflicting(ISchedulingRule rule) { - if (rule instanceof SubdirectoryOrSameNameSchedulingRule) { - SubdirectoryOrSameNameSchedulingRule otherRule = (SubdirectoryOrSameNameSchedulingRule)rule; + if (rule instanceof SubdirectoryOrSameNameSchedulingRule otherRule) { return otherRule.path.startsWith(this.path) || otherRule.name.equals(this.name); } else if (rule instanceof IResource) { diff --git a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/wizards/datatransfer/TarEntry.java b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/wizards/datatransfer/TarEntry.java index 70b01ef0c94..103b7cc602d 100644 --- a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/wizards/datatransfer/TarEntry.java +++ b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/wizards/datatransfer/TarEntry.java @@ -20,7 +20,7 @@ */ public class TarEntry implements Cloneable { - private String name; + private final String name; private long mode, time, size; private int type; long filepos; diff --git a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/wizards/datatransfer/TarLeveledStructureProvider.java b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/wizards/datatransfer/TarLeveledStructureProvider.java index 5bc9aee0d56..dd21e874ba5 100644 --- a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/wizards/datatransfer/TarLeveledStructureProvider.java +++ b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/wizards/datatransfer/TarLeveledStructureProvider.java @@ -36,13 +36,13 @@ */ public class TarLeveledStructureProvider implements ILeveledImportStructureProvider { - private TarFile tarFile; + private final TarFile tarFile; - private TarEntry root = new TarEntry("/");//$NON-NLS-1$ + private final TarEntry root = new TarEntry("/");//$NON-NLS-1$ private Map> children; - private Map directoryEntryCache = new HashMap<>(); + private final Map directoryEntryCache = new HashMap<>(); private int stripLevel; diff --git a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/wizards/datatransfer/WizardArchiveFileResourceImportPage1.java b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/wizards/datatransfer/WizardArchiveFileResourceImportPage1.java index 52db25ea3d4..925189a319d 100644 --- a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/wizards/datatransfer/WizardArchiveFileResourceImportPage1.java +++ b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/wizards/datatransfer/WizardArchiveFileResourceImportPage1.java @@ -217,8 +217,7 @@ protected ITreeContentProvider getFileProvider() { return new WorkbenchContentProvider() { @Override public Object[] getChildren(Object o) { - if (o instanceof MinimizedFileSystemElement) { - MinimizedFileSystemElement element = (MinimizedFileSystemElement) o; + if (o instanceof MinimizedFileSystemElement element) { AdaptableList l = element.getFiles(structureProvider); return l.getChildren(element); } @@ -275,8 +274,7 @@ protected ITreeContentProvider getFolderProvider() { return new WorkbenchContentProvider() { @Override public Object[] getChildren(Object o) { - if (o instanceof MinimizedFileSystemElement) { - MinimizedFileSystemElement element = (MinimizedFileSystemElement) o; + if (o instanceof MinimizedFileSystemElement element) { AdaptableList l = element.getFolders(structureProvider); return l.getChildren(element); } @@ -285,8 +283,7 @@ public Object[] getChildren(Object o) { @Override public boolean hasChildren(Object o) { - if (o instanceof MinimizedFileSystemElement) { - MinimizedFileSystemElement element = (MinimizedFileSystemElement) o; + if (o instanceof MinimizedFileSystemElement element) { if (element.isPopulated()) { return getChildren(element).length > 0; } diff --git a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/wizards/datatransfer/WizardFileSystemResourceExportPage1.java b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/wizards/datatransfer/WizardFileSystemResourceExportPage1.java index 01afa39d0c2..8c02a8be39c 100644 --- a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/wizards/datatransfer/WizardFileSystemResourceExportPage1.java +++ b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/wizards/datatransfer/WizardFileSystemResourceExportPage1.java @@ -470,12 +470,13 @@ protected boolean validateDestinationGroup() { if (conflictingContainer == null) { // no error message, but warning may exists String threatenedContainer = getOverlappingProjectName(destinationValue); - if(threatenedContainer == null) + if(threatenedContainer == null) { setMessage(null); - else + } else { setMessage( NLS.bind(DataTransferMessages.FileExport_damageWarning, threatenedContainer), WARNING); + } } else { setErrorMessage(NLS.bind(DataTransferMessages.FileExport_conflictingContainer, conflictingContainer)); @@ -519,14 +520,16 @@ protected String getConflictingContainerNameFor(String targetDirectory) { IPath rootPath = ResourcesPlugin.getWorkspace().getRoot().getLocation(); IPath testPath = IPath.fromOSString(targetDirectory); // cannot export into workspace root - if(testPath.equals(rootPath)) + if(testPath.equals(rootPath)) { return rootPath.lastSegment(); + } //Are they the same? if(testPath.matchingFirstSegments(rootPath) == rootPath.segmentCount()){ String firstSegment = testPath.removeFirstSegments(rootPath.segmentCount()).segment(0); - if(!Character.isLetterOrDigit(firstSegment.charAt(0))) + if(!Character.isLetterOrDigit(firstSegment.charAt(0))) { return firstSegment; + } } return null; diff --git a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/wizards/datatransfer/WizardFileSystemResourceImportPage1.java b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/wizards/datatransfer/WizardFileSystemResourceImportPage1.java index 00892ee9f07..230e96f114a 100644 --- a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/wizards/datatransfer/WizardFileSystemResourceImportPage1.java +++ b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/wizards/datatransfer/WizardFileSystemResourceImportPage1.java @@ -108,7 +108,7 @@ public class WizardFileSystemResourceImportPage1 extends WizardResourceImportPag //A boolean to indicate if the user has typed anything private boolean entryChanged = false; - private FileSystemStructureProvider fileSystemStructureProvider = new FileSystemStructureProvider(); + private final FileSystemStructureProvider fileSystemStructureProvider = new FileSystemStructureProvider(); // dialog store id constants private static final String STORE_SOURCE_NAMES_ID = "WizardFileSystemResourceImportPage1.STORE_SOURCE_NAMES_ID";//$NON-NLS-1$ @@ -387,8 +387,9 @@ public void widgetSelected(SelectionEvent e) { @Override public IResource getResource() { IPath path = getContainerFullPath(); - if (path != null) + if (path != null) { return ResourcesPlugin.getWorkspace().getRoot().findMember(path); + } return null; } @Override @@ -674,8 +675,7 @@ protected ITreeContentProvider getFileProvider() { return new WorkbenchContentProvider() { @Override public Object[] getChildren(Object o) { - if (o instanceof MinimizedFileSystemElement) { - MinimizedFileSystemElement element = (MinimizedFileSystemElement) o; + if (o instanceof MinimizedFileSystemElement element) { return element.getFiles( fileSystemStructureProvider).getChildren( element); @@ -710,8 +710,7 @@ protected ITreeContentProvider getFolderProvider() { return new WorkbenchContentProvider() { @Override public Object[] getChildren(Object o) { - if (o instanceof MinimizedFileSystemElement) { - MinimizedFileSystemElement element = (MinimizedFileSystemElement) o; + if (o instanceof MinimizedFileSystemElement element) { return element.getFolders( fileSystemStructureProvider).getChildren( element); @@ -721,8 +720,7 @@ public Object[] getChildren(Object o) { @Override public boolean hasChildren(Object o) { - if (o instanceof MinimizedFileSystemElement) { - MinimizedFileSystemElement element = (MinimizedFileSystemElement) o; + if (o instanceof MinimizedFileSystemElement element) { if (element.isPopulated()) { return getChildren(element).length > 0; } @@ -855,17 +853,19 @@ protected boolean importResources(List fileSystemObjects) { (createVirtualFoldersButton != null && !createVirtualFoldersButton.getSelection()); File sourceDirectory = getSourceDirectory(); - if (createTopLevelFolderCheckbox.getSelection() && sourceDirectory.getParentFile() != null) + if (createTopLevelFolderCheckbox.getSelection() && sourceDirectory.getParentFile() != null) { sourceDirectory = sourceDirectory.getParentFile(); + } - if (shouldImportTopLevelFoldersRecursively) + if (shouldImportTopLevelFoldersRecursively) { operation = new ImportOperation(getContainerFullPath(), sourceDirectory, fileSystemStructureProvider, this, Arrays.asList(getSourceDirectory())); - else + } else { operation = new ImportOperation(getContainerFullPath(), sourceDirectory, fileSystemStructureProvider, this, fileSystemObjects); + } operation.setContext(getShell()); return executeImportOperation(operation); @@ -882,8 +882,9 @@ protected void handleContainerBrowseButtonPressed() { relativePathVariableGroup.setupVariableContent(); String preferedVariable = RelativePathVariableGroup.getPreferredVariable( new IPath[] { IPath.fromOSString(file.getAbsolutePath()) }, (IContainer) target); - if (preferedVariable != null) + if (preferedVariable != null) { relativePathVariableGroup.selectVariable(preferedVariable); + } } } updateWidgetEnablements(); @@ -900,8 +901,9 @@ protected void initializeOperation(ImportOperation op) { op.setCreateLinks(true); op.setVirtualFolders(createVirtualFoldersButton .getSelection()); - if (relativePathVariableGroup.getSelection()) + if (relativePathVariableGroup.getSelection()) { op.setRelativeVariable(pathVariable); + } } } @@ -944,8 +946,9 @@ protected void resetSelection() { if (target != null) { String variable = RelativePathVariableGroup.getPreferredVariable( new IPath[] { IPath.fromOSString(sourceDirectory.getAbsolutePath()) }, (IContainer) target); - if (variable != null) + if (variable != null) { relativePathVariableGroup.selectVariable(variable); + } } } } @@ -992,8 +995,9 @@ protected void restoreWidgetValues() { relativePathVariableGroup.setSelection(pathVariableSelected); pathVariable = settings.get(STORE_PATH_VARIABLE_NAME_ID); - if (pathVariable != null) + if (pathVariable != null) { relativePathVariableGroup.selectVariable(pathVariable); + } } updateWidgetEnablements(); } @@ -1212,8 +1216,9 @@ protected void updateWidgetEnablements() { IPath path = getContainerFullPath(); if (path != null && relativePathVariableGroup != null) { IResource target = ResourcesPlugin.getWorkspace().getRoot().findMember(path); - if (target != null && target.isVirtual()) + if (target != null && target.isVirtual()) { createVirtualFoldersButton.setSelection(true); + } } relativePathVariableGroup.setEnabled(createLinksInWorkspaceButton.getSelection()); createVirtualFoldersButton.setEnabled(createLinksInWorkspaceButton.getSelection()); diff --git a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/wizards/datatransfer/WizardProjectsImportPage.java b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/wizards/datatransfer/WizardProjectsImportPage.java index 19d484004ae..46f7570b782 100644 --- a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/wizards/datatransfer/WizardProjectsImportPage.java +++ b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/wizards/datatransfer/WizardProjectsImportPage.java @@ -373,10 +373,10 @@ public boolean select(Viewer viewer, Object parentElement, private WorkingSetGroup workingSetGroup; - private IStructuredSelection currentSelection; + private final IStructuredSelection currentSelection; - private ConflictingProjectFilter conflictingProjectsFilter = new ConflictingProjectFilter(); + private final ConflictingProjectFilter conflictingProjectsFilter = new ConflictingProjectFilter(); /** * Prevent handling focus lost events during other events which trigger diff --git a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/wizards/datatransfer/ZipFileExporter.java b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/wizards/datatransfer/ZipFileExporter.java index ce69631cea3..b7745b8c55a 100644 --- a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/wizards/datatransfer/ZipFileExporter.java +++ b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/wizards/datatransfer/ZipFileExporter.java @@ -30,11 +30,11 @@ * Exports resources to a .zip file */ public class ZipFileExporter implements IFileExporter { - private ZipOutputStream outputStream; + private final ZipOutputStream outputStream; private boolean useCompression = true; - private boolean resolveLinks; + private final boolean resolveLinks; /** * Create an instance of this class. @@ -91,8 +91,9 @@ private void write(ZipEntry entry, IFile contents) throws IOException, CoreExcep // set the timestamp long localTimeStamp = contents.getLocalTimeStamp(); - if(localTimeStamp != IResource.NULL_STAMP) + if(localTimeStamp != IResource.NULL_STAMP) { entry.setTime(localTimeStamp); + } outputStream.putNextEntry(entry); try (InputStream contentStream = contents.getContents(false)) { diff --git a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/wizards/datatransfer/ZipLeveledStructureProvider.java b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/wizards/datatransfer/ZipLeveledStructureProvider.java index 5cb6204859c..4503ea7cbe0 100644 --- a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/wizards/datatransfer/ZipLeveledStructureProvider.java +++ b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/wizards/datatransfer/ZipLeveledStructureProvider.java @@ -40,17 +40,17 @@ */ public class ZipLeveledStructureProvider implements ILeveledImportStructureProvider { - private ZipFile zipFile; + private final ZipFile zipFile; - private ZipEntry root = new ZipEntry("/");//$NON-NLS-1$ + private final ZipEntry root = new ZipEntry("/");//$NON-NLS-1$ private Map> children; - private Map directoryEntryCache = new HashMap<>(); + private final Map directoryEntryCache = new HashMap<>(); private int stripLevel; - private Set invalidEntries = new HashSet<>(); + private final Set invalidEntries = new HashSet<>(); /** * Creates a ZipFileStructureProvider, which will operate on diff --git a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/wizards/datatransfer/expressions/HasFileRecursivelyExpression.java b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/wizards/datatransfer/expressions/HasFileRecursivelyExpression.java index 651032974e8..4b367ef84aa 100644 --- a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/wizards/datatransfer/expressions/HasFileRecursivelyExpression.java +++ b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/wizards/datatransfer/expressions/HasFileRecursivelyExpression.java @@ -39,7 +39,7 @@ public class HasFileRecursivelyExpression extends Expression { */ public static final String TAG = "hasFileRecursively"; //$NON-NLS-1$ - private String filename; + private final String filename; /** * Build expression with a filename. diff --git a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/wizards/datatransfer/expressions/HasFileWithSuffixRecursivelyExpression.java b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/wizards/datatransfer/expressions/HasFileWithSuffixRecursivelyExpression.java index c9b13b0d5eb..9e726af9bff 100644 --- a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/wizards/datatransfer/expressions/HasFileWithSuffixRecursivelyExpression.java +++ b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/wizards/datatransfer/expressions/HasFileWithSuffixRecursivelyExpression.java @@ -36,7 +36,7 @@ public class HasFileWithSuffixRecursivelyExpression extends Expression { */ public static final String TAG = "hasFileWithSuffixRecursively"; //$NON-NLS-1$ - private String suffix; + private final String suffix; /** * Build expression with a suffix. diff --git a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/views/framelist/FrameAction.java b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/views/framelist/FrameAction.java index bb9c9b7f782..261e01e261a 100644 --- a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/views/framelist/FrameAction.java +++ b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/views/framelist/FrameAction.java @@ -23,9 +23,9 @@ * accordingly. */ public abstract class FrameAction extends Action { - private FrameList frameList; + private final FrameList frameList; - private IPropertyChangeListener propertyChangeListener = FrameAction.this::handlePropertyChange; + private final IPropertyChangeListener propertyChangeListener = FrameAction.this::handlePropertyChange; /** * Constructs a new action for the specified frame list. diff --git a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/views/framelist/FrameList.java b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/views/framelist/FrameList.java index 9d1e17c1c5a..1a4575ee3fb 100644 --- a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/views/framelist/FrameList.java +++ b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/views/framelist/FrameList.java @@ -38,9 +38,9 @@ public class FrameList extends EventManager { /** Property name constant for the current frame. */ public static final String P_CURRENT_FRAME = "currentFrame"; //$NON-NLS-1$ - private IFrameSource source; + private final IFrameSource source; - private List frames; + private final List frames; private int current; diff --git a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/views/framelist/TreeFrame.java b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/views/framelist/TreeFrame.java index 7d521ae95a9..72eda895c2c 100644 --- a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/views/framelist/TreeFrame.java +++ b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/views/framelist/TreeFrame.java @@ -43,7 +43,7 @@ public class TreeFrame extends Frame { private static final String TAG_FACTORY_ID = "factoryID"; //$NON-NLS-1$ - private AbstractTreeViewer viewer; + private final AbstractTreeViewer viewer; private Object input; diff --git a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/views/framelist/TreeViewerFrameSource.java b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/views/framelist/TreeViewerFrameSource.java index 4da9961f0f2..a6dc4744825 100644 --- a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/views/framelist/TreeViewerFrameSource.java +++ b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/views/framelist/TreeViewerFrameSource.java @@ -26,7 +26,7 @@ */ public class TreeViewerFrameSource implements IFrameSource { - private AbstractTreeViewer viewer; + private final AbstractTreeViewer viewer; /** * Constructs a new tree viewer frame source for the specified tree viewer. diff --git a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/views/markers/MarkerField.java b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/views/markers/MarkerField.java index 2874cd8f777..88dbea4d5e2 100644 --- a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/views/markers/MarkerField.java +++ b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/views/markers/MarkerField.java @@ -50,7 +50,7 @@ public abstract class MarkerField { private IConfigurationElement configurationElement; private ResourceManager imageManager; - private boolean helpContextAvailabilityCheck; + private final boolean helpContextAvailabilityCheck; public MarkerField() { helpContextAvailabilityCheck = Platform.getPreferencesService().getBoolean(IDEWorkbenchPlugin.IDE_WORKBENCH, @@ -76,9 +76,9 @@ public Image annotateImage(MarkerItem item, Image image) { if (marker != null) { String contextId = IDE.getMarkerHelpRegistry().getHelp(marker); if (contextId != null && (!helpContextAvailabilityCheck || HelpSystem.getContext(contextId) != null)) { - if (image == null) + if (image == null) { image = JFaceResources.getImage(Dialog.DLG_IMG_HELP); - else { + } else { descriptors[IDecoration.TOP_RIGHT] = IDEWorkbenchPlugin .getIDEImageDescriptor(MarkerSupportInternalUtilities.IMG_MARKERS_HELP_DECORATION_PATH); } @@ -99,8 +99,9 @@ public Image annotateImage(MarkerItem item, Image image) { image = sharedImages.getImage(IDEInternalWorkbenchImages.IMG_ELCL_QUICK_FIX_ENABLED); } } - if (descriptors[IDecoration.TOP_RIGHT] != null || descriptors[IDecoration.BOTTOM_RIGHT] != null) + if (descriptors[IDecoration.TOP_RIGHT] != null || descriptors[IDecoration.BOTTOM_RIGHT] != null) { image = getImageManager().create(new DecorationOverlayIcon(image, descriptors)); + } } } return image; @@ -134,12 +135,14 @@ public int compare(MarkerItem item1, MarkerItem item2) { public Image getColumnHeaderImage() { String path = configurationElement .getAttribute(MarkerSupportInternalUtilities.ATTRIBUTE_ICON); - if (path == null) + if (path == null) { return null; + } URL url = BundleUtility.find(configurationElement.getContributor() .getName(), path); - if (url == null) + if (url == null) { return null; + } return getImageManager().createImageWithDefault( ImageDescriptor.createFromURL(url)); } @@ -214,8 +217,9 @@ public EditingSupport getEditingSupport(ColumnViewer viewer) { * @return ResourceManager */ protected ResourceManager getImageManager() { - if (imageManager == null) + if (imageManager == null) { return IDEWorkbenchPlugin.getDefault().getResourceManager(); + } return imageManager; } diff --git a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/views/markers/MarkerViewHandler.java b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/views/markers/MarkerViewHandler.java index 5d2b805bf93..4b746c9f3a6 100644 --- a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/views/markers/MarkerViewHandler.java +++ b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/views/markers/MarkerViewHandler.java @@ -48,8 +48,9 @@ public abstract class MarkerViewHandler extends AbstractHandler { */ public MarkerSupportView getView(ExecutionEvent event) { IWorkbenchPart part = HandlerUtil.getActivePart(event); - if (!(part instanceof MarkerSupportView)) + if (!(part instanceof MarkerSupportView)) { return null; + } return (MarkerSupportView) part; } @@ -96,8 +97,9 @@ public void execute(IUndoableOperation operation, String title, */ public IMarker[] getSelectedMarkers(ExecutionEvent event) { final MarkerSupportView view = getView(event); - if (view == null) + if (view == null) { return EMPTY_MARKER_ARRAY; + } final IMarker[][] result = new IMarker[1][]; view.getSite().getShell().getDisplay().syncExec(() -> result[0] = view.getSelectedMarkers()); diff --git a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/views/markers/MarkerViewUtil.java b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/views/markers/MarkerViewUtil.java index c10c8450b8a..48fb04e0503 100644 --- a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/views/markers/MarkerViewUtil.java +++ b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/views/markers/MarkerViewUtil.java @@ -115,19 +115,22 @@ public static boolean showMarker(IWorkbenchPage page, IMarker marker, */ public static boolean showMarkers(IWorkbenchPage page, IMarker[] markers, boolean showView) { - if (null == markers || 0 == markers.length || null == markers[0]) + if (null == markers || 0 == markers.length || null == markers[0]) { return false; + } boolean returnValue = false; try { String viewId = getViewId(markers[0]); IMarker[] markersSameView = getMarkersOfView(viewId, markers); - if (viewId == null) // Use the problem view by default + if (viewId == null) { // Use the problem view by default viewId = IPageLayout.ID_PROBLEM_VIEW; + } IViewPart view = showView ? page.showView(viewId) : page .findView(viewId); - if (view != null) + if (view != null) { returnValue = MarkerSupportInternalUtilities.showMarkers(view, markersSameView); + } } catch (CoreException e) { Policy.handle(e); } @@ -147,13 +150,15 @@ public static boolean showMarkers(IWorkbenchPage page, IMarker[] markers, boolea * if an exception occurs testing the type of the marker */ private static IMarker[] getMarkersOfView(String viewId, IMarker[] markers) throws CoreException { - if (null == viewId) // all markers should be shown + if (null == viewId) { // all markers should be shown return markers; + } ArrayList markersOfView = new ArrayList<>(); for (IMarker marker : markers) { - if (null != marker && viewId.equals(getViewId(marker))) + if (null != marker && viewId.equals(getViewId(marker))) { markersOfView.add(marker); + } } return markersOfView.toArray(new IMarker[markersOfView.size()]); } diff --git a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/views/markers/internal/AttributeMarkerGrouping.java b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/views/markers/internal/AttributeMarkerGrouping.java index fbd5860ca33..a5988b9ba9b 100644 --- a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/views/markers/internal/AttributeMarkerGrouping.java +++ b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/views/markers/internal/AttributeMarkerGrouping.java @@ -34,16 +34,16 @@ public class AttributeMarkerGrouping { private static final String ATTRIBUTE = "attribute"; //$NON-NLS-1$ - private String attribute; + private final String attribute; - private String markerType; + private final String markerType; - private String defaultGroupingEntry; + private final String defaultGroupingEntry; - private IConfigurationElement element; + private final IConfigurationElement element; // A list of groups we are associated with for unloading - private Collection groups = new HashSet<>(); + private final Collection groups = new HashSet<>(); /** * Create a new instance of the receiver from element. diff --git a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/views/markers/internal/ConcreteMarker.java b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/views/markers/internal/ConcreteMarker.java index 64ebd0cba87..39a67f8001e 100644 --- a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/views/markers/internal/ConcreteMarker.java +++ b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/views/markers/internal/ConcreteMarker.java @@ -51,7 +51,7 @@ public class ConcreteMarker extends MarkerNode{ private String type; - private IMarker marker; + private final IMarker marker; /** * Cache for the marker ID. @@ -169,12 +169,10 @@ public IMarker getMarker() { @Override public boolean equals(Object object) { - if (!(object instanceof ConcreteMarker)) { + if (!(object instanceof ConcreteMarker other)) { return false; } - ConcreteMarker other = (ConcreteMarker) object; - return other.getMarker().equals(getMarker()); } diff --git a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/views/markers/internal/ContentGeneratorDescriptor.java b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/views/markers/internal/ContentGeneratorDescriptor.java index 5a9e453b8cb..ab3bfc5f925 100644 --- a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/views/markers/internal/ContentGeneratorDescriptor.java +++ b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/views/markers/internal/ContentGeneratorDescriptor.java @@ -44,7 +44,7 @@ public class ContentGeneratorDescriptor { private static final String ELEMENT_MARKER_FIELD_CONFIGURATION = "markerFieldConfiguration"; //$NON-NLS-1$; private static final String MARKER_FIELD_REFERENCE = "markerFieldReference"; //$NON-NLS-1$ - private IConfigurationElement configurationElement; + private final IConfigurationElement configurationElement; private MarkerField[] allFields; private MarkerField[] allFieldsWithExtensions; private Collection markerTypes; diff --git a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/views/markers/internal/FieldCategory.java b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/views/markers/internal/FieldCategory.java index 8c242a9648d..40c3013ca33 100644 --- a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/views/markers/internal/FieldCategory.java +++ b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/views/markers/internal/FieldCategory.java @@ -45,12 +45,11 @@ public Image getColumnHeaderImage() { @Override public String getValue(Object obj) { - if (obj instanceof ConcreteMarker) { - ConcreteMarker marker = (ConcreteMarker) obj; - + if (obj instanceof ConcreteMarker marker) { if (marker.getGroup() == null) { - if (!marker.getMarker().exists()) + if (!marker.getMarker().exists()) { return MarkerMessages.FieldCategory_Uncategorized; + } String groupName = MarkerSupportRegistry.getInstance() .getCategory(marker.getMarker()); if (groupName == null) { diff --git a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/views/markers/internal/MarkerFilter.java b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/views/markers/internal/MarkerFilter.java index 839fb064cc4..941b70ede0d 100644 --- a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/views/markers/internal/MarkerFilter.java +++ b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/views/markers/internal/MarkerFilter.java @@ -114,7 +114,7 @@ public class MarkerFilter implements Cloneable { private Set cachedWorkingSet; // The human readable name for the filter - private String name; + private final String name; /** * Create a new instance of the receiver. @@ -225,8 +225,7 @@ private Set getWorkingSetAsSetOfPaths() { private void addResourcesAndChildren(HashSet result, IResource[] resources) { for (IResource currentResource : resources) { result.add(currentResource.getFullPath().toString()); - if (currentResource instanceof IContainer) { - IContainer cont = (IContainer) currentResource; + if (currentResource instanceof IContainer cont) { try { addResourcesAndChildren(result, cont.members()); } catch (CoreException e) { diff --git a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/views/markers/internal/MarkerGroup.java b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/views/markers/internal/MarkerGroup.java index f1c875c3345..639e02bc666 100644 --- a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/views/markers/internal/MarkerGroup.java +++ b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/views/markers/internal/MarkerGroup.java @@ -261,9 +261,9 @@ public String getName() { protected MarkerField markerField; - private Map> typesToMappings = new LinkedHashMap<>(); + private final Map> typesToMappings = new LinkedHashMap<>(); - private IConfigurationElement configurationElement; + private final IConfigurationElement configurationElement; private String id; diff --git a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/views/markers/internal/MarkerGroupingEntry.java b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/views/markers/internal/MarkerGroupingEntry.java index 5bb314ea170..9615a238179 100644 --- a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/views/markers/internal/MarkerGroupingEntry.java +++ b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/views/markers/internal/MarkerGroupingEntry.java @@ -29,9 +29,9 @@ public class MarkerGroupingEntry { private static final String PRIORITY = "priority"; //$NON-NLS-1$ private MarkerGroup markerGroup; - private String label; + private final String label; private String id; - private int sortPriority; + private final int sortPriority; /** * Create a new instance of the receiver from element. diff --git a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/views/markers/internal/MarkerSupportRegistry.java b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/views/markers/internal/MarkerSupportRegistry.java index 2c47e633396..72a1823598a 100644 --- a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/views/markers/internal/MarkerSupportRegistry.java +++ b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/views/markers/internal/MarkerSupportRegistry.java @@ -183,19 +183,19 @@ public static synchronized MarkerSupportRegistry getInstance() { return singleton; } - private Map registeredFilters = new HashMap<>(); + private final Map registeredFilters = new HashMap<>(); - private Map markerGroups = new HashMap<>(); + private final Map markerGroups = new HashMap<>(); - private Map categories = new HashMap<>(); + private final Map categories = new HashMap<>(); - private Map hierarchyOrders = new HashMap<>(); + private final Map hierarchyOrders = new HashMap<>(); private MarkerType rootType; - private Map generators = new HashMap<>(); + private final Map generators = new HashMap<>(); - private Map fields = new HashMap<>(); + private final Map fields = new HashMap<>(); /** * Create a new instance of the receiver and read the registry. @@ -604,14 +604,12 @@ public void removeExtension(IExtension extension, Object[] objects) { continue; } - if (object instanceof MarkerGroupingEntry) { - MarkerGroupingEntry entry = (MarkerGroupingEntry) object; + if (object instanceof MarkerGroupingEntry entry) { entry.getMarkerGroup().remove(entry); continue; } - if (object instanceof AttributeMarkerGrouping) { - AttributeMarkerGrouping entry = (AttributeMarkerGrouping) object; + if (object instanceof AttributeMarkerGrouping entry) { entry.unmap(); continue; } @@ -631,8 +629,7 @@ public void removeExtension(IExtension extension, Object[] objects) { continue; } - if (object instanceof IConfigurationElement) { - IConfigurationElement element = (IConfigurationElement) object; + if (object instanceof IConfigurationElement element) { ContentGeneratorDescriptor generatorDesc = generators.get(element.getAttribute(ATTRIBUTE_GENERATOR_ID)); generatorDesc.removeExtension(element); continue; diff --git a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/views/markers/internal/MarkerType.java b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/views/markers/internal/MarkerType.java index 56a16f5ca81..338de892231 100644 --- a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/views/markers/internal/MarkerType.java +++ b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/views/markers/internal/MarkerType.java @@ -21,13 +21,13 @@ * Represents a marker type. */ public class MarkerType { - private MarkerTypesModel model; + private final MarkerTypesModel model; - private String id; + private final String id; - private String label; + private final String label; - private String[] supertypeIds; + private final String[] supertypeIds; /** * Creates a new marker type. diff --git a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/views/markers/internal/MarkerTypesModel.java b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/views/markers/internal/MarkerTypesModel.java index 598785f6b74..0f9fb3a5a8f 100644 --- a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/views/markers/internal/MarkerTypesModel.java +++ b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/views/markers/internal/MarkerTypesModel.java @@ -46,7 +46,7 @@ public static MarkerTypesModel getInstance(){ /** * Maps from marker type id to MarkerType. */ - private HashMap types; + private final HashMap types; /** * Creates a new marker types model. diff --git a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/views/markers/internal/ProblemFilter.java b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/views/markers/internal/ProblemFilter.java index b1df5219788..ea6ffffe8cd 100644 --- a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/views/markers/internal/ProblemFilter.java +++ b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/views/markers/internal/ProblemFilter.java @@ -109,12 +109,10 @@ public ProblemFilter(String filterName) { @Override public boolean selectMarker(ConcreteMarker marker) { - if (!(marker instanceof ProblemMarker)) { + if (!(marker instanceof ProblemMarker problemMarker)) { return false; } - ProblemMarker problemMarker = (ProblemMarker) marker; - return !isEnabled() || (super.selectMarker(problemMarker) && selectByDescription(problemMarker) && selectBySeverity(problemMarker)); diff --git a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/views/markers/internal/ProjectEncodingMarkerResolutionGenerator.java b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/views/markers/internal/ProjectEncodingMarkerResolutionGenerator.java index 32f120fbb40..7be3ec9124a 100644 --- a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/views/markers/internal/ProjectEncodingMarkerResolutionGenerator.java +++ b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/views/markers/internal/ProjectEncodingMarkerResolutionGenerator.java @@ -110,11 +110,9 @@ public void run(IMarker marker) { return; } IResource resource = marker.getResource(); - if (resource instanceof IProject) { - IProject project = (IProject) resource; + if (resource instanceof IProject project) { IWorkspace workspace = ResourcesPlugin.getWorkspace(); - if (workspace instanceof Workspace) { - Workspace ws = (Workspace) workspace; + if (workspace instanceof Workspace ws) { CharsetManager charsetManager = ws.getCharsetManager(); try { charsetManager.setCharsetFor(project.getFullPath(), charset); diff --git a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/views/markers/internal/TypeMarkerGroup.java b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/views/markers/internal/TypeMarkerGroup.java index 32d24ac26d5..6f366f7d07e 100644 --- a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/views/markers/internal/TypeMarkerGroup.java +++ b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/views/markers/internal/TypeMarkerGroup.java @@ -31,7 +31,7 @@ */ public class TypeMarkerGroup extends MarkerGroup { - private Map entries=new HashMap<>(); + private final Map entries=new HashMap<>(); /** * TypeMarkerField is the MarkerField used for MarkerGroupungs * @@ -52,8 +52,9 @@ public String getValue(MarkerItem item) { if (item.getMarker() != null) { IMarker marker = item.getMarker(); - if (marker == null || !marker.exists()) + if (marker == null || !marker.exists()) { return MarkerMessages.FieldCategory_Uncategorized; + } String groupName = MarkerSupportRegistry.getInstance() .getCategory(marker); if (groupName == null) { @@ -82,7 +83,7 @@ public int compare(MarkerItem item1, MarkerItem item2) { } - private String name; + private final String name; /** * Create a new instance of the receiver. diff --git a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/views/markers/internal/Util.java b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/views/markers/internal/Util.java index 76d63d7de0f..8ef168ce438 100644 --- a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/views/markers/internal/Util.java +++ b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/views/markers/internal/Util.java @@ -107,8 +107,9 @@ public static String getCreationTime(IMarker marker) { */ public static String getContainerName(IMarker marker) { - if (!marker.exists()) + if (!marker.exists()) { return Util.EMPTY_STRING; + } try { Object pathAttribute = marker diff --git a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/views/navigator/ResourceComparator.java b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/views/navigator/ResourceComparator.java index b432740a730..d0277b3da24 100644 --- a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/views/navigator/ResourceComparator.java +++ b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/views/navigator/ResourceComparator.java @@ -86,10 +86,9 @@ public int compare(Viewer viewer, Object o1, Object o2) { // have to deal with non-resources in navigator // if one or both objects are not resources, returned a comparison // based on class. - if (!(o1 instanceof IResource && o2 instanceof IResource)) { + if (!(o1 instanceof IResource r1 && o2 instanceof IResource)) { return compareClass(o1, o2); } - IResource r1 = (IResource) o1; IResource r2 = (IResource) o2; if (r1 instanceof IContainer && r2 instanceof IContainer) { diff --git a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/views/properties/ResourcePropertySource.java b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/views/properties/ResourcePropertySource.java index 9c8fa9e83ee..ee80b19a2b9 100644 --- a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/views/properties/ResourcePropertySource.java +++ b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/views/properties/ResourcePropertySource.java @@ -170,13 +170,15 @@ public Object getPropertyValue(Object name) { return IDEPropertiesMessages.ResourceProperty_true; } if (name.equals(IResourcePropertyConstants.P_DERIVED_RES)) { - if (element.isDerived()) + if (element.isDerived()) { return IDEPropertiesMessages.ResourceProperty_true; + } return IDEPropertiesMessages.ResourceProperty_false; } if (name.equals(IResourcePropertyConstants.P_LINKED_RES)) { - if (element.isLinked()) + if (element.isLinked()) { return IDEPropertiesMessages.ResourceProperty_true; + } return IDEPropertiesMessages.ResourceProperty_false; } if (name.equals(IResourcePropertyConstants.P_LOCATION_RES)) { diff --git a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/wizards/datatransfer/ImportOperation.java b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/wizards/datatransfer/ImportOperation.java index 7eb4b7bf43a..60ad2b4d0e3 100644 --- a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/wizards/datatransfer/ImportOperation.java +++ b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/wizards/datatransfer/ImportOperation.java @@ -70,7 +70,7 @@ public class ImportOperation extends WorkspaceModifyOperation { private Object source; - private IPath destinationPath; + private final IPath destinationPath; private IContainer destinationContainer; @@ -78,19 +78,19 @@ public class ImportOperation extends WorkspaceModifyOperation { private List rejectedFiles; - private IImportStructureProvider provider; + private final IImportStructureProvider provider; protected IOverwriteQuery overwriteCallback; private Shell context; - private List errorTable = new ArrayList<>(); + private final List errorTable = new ArrayList<>(); private boolean createVirtualFolder = false; private boolean createLinks = false; - private boolean createLinkFilesOnly = false; + private final boolean createLinkFilesOnly = false; private String relativeVariable = null; @@ -318,14 +318,15 @@ IContainer createContainersFor(IPath path) throws CoreException { for (int i = 0; i < segmentCount; i++) { currentFolder = currentFolder.getFolder(IPath.fromOSString(path.segment(i))); if (!currentFolder.exists()) { - if (createVirtualFolder) + if (createVirtualFolder) { ((IFolder) currentFolder).create(IResource.VIRTUAL, true, null); - else if (createLinks) + } else if (createLinks) { ((IFolder) currentFolder).createLink(createRelativePath( path, currentFolder), 0, null); - else + } else { ((IFolder) currentFolder).create(false, true, null); + } } } @@ -539,8 +540,9 @@ void importFile(Object fileObject, int policy, IProgressMonitor mon) { } if (createVirtualFolder || createLinks || createLinkFilesOnly) { - if (targetResource.exists()) + if (targetResource.exists()) { targetResource.delete(true, subMonitor.split(50)); + } targetResource.createLink( createRelativePath(IPath.fromOSString(provider.getFullPath(fileObject)), targetResource), 0, subMonitor.split(50)); @@ -548,10 +550,12 @@ void importFile(Object fileObject, int policy, IProgressMonitor mon) { if (targetResource.isLinked()) { targetResource.delete(true, subMonitor.split(50)); targetResource.create(contentStream, false, subMonitor.split(50)); - } else + } else { targetResource.setContents(contentStream, IResource.KEEP_HISTORY, subMonitor.split(100)); - } else + } + } else { targetResource.create(contentStream, false, subMonitor.split(100)); + } setResourceAttributes(targetResource, fileObject); if (provider instanceof TarLeveledStructureProvider) { @@ -613,8 +617,9 @@ private void setResourceAttributes(IFile targetResource, Object fileObject) { } }else if (fileObject instanceof ZipEntry) { long zipTimeStamp = ((ZipEntry)fileObject).getTime(); - if(zipTimeStamp != -1) + if(zipTimeStamp != -1) { timeStamp = zipTimeStamp; + } } if(timeStamp!= 0) { @@ -701,22 +706,24 @@ int importFolder(Object folderObject, int policy, IProgressMonitor monitor) thro IFolder folder = workspace.getRoot().getFolder(resourcePath); if (createVirtualFolder || createLinks || folder.isVirtual() || folder.isLinked()) { folder.delete(true, null); - } else + } else { return POLICY_FORCE_OVERWRITE; + } } try { - if (createVirtualFolder) + if (createVirtualFolder) { workspace.getRoot().getFolder(resourcePath).create( IResource.VIRTUAL, true, null); - else if (createLinks) { + } else if (createLinks) { IFolder newFolder = workspace.getRoot().getFolder(resourcePath); newFolder.createLink( createRelativePath(IPath.fromOSString(provider.getFullPath(folderObject)), newFolder), 0, null); policy = POLICY_SKIP_CHILDREN; - } else + } else { workspace.getRoot().getFolder(resourcePath).create(false, true, null); + } } catch (CoreException e) { errorTable.add(e.getStatus()); } @@ -732,10 +739,12 @@ else if (createLinks) { * @return an URI that was made relative to a variable */ private IPath createRelativePath(IPath location, IResource resource) { - if (relativeVariable == null) + if (relativeVariable == null) { return location; - if (relativeVariable.equals(ABSOLUTE_PATH)) + } + if (relativeVariable.equals(ABSOLUTE_PATH)) { return location; + } IPathVariableManager pathVariableManager = resource.getPathVariableManager(); try { return URIUtil.toPath(pathVariableManager.convertToRelative(URIUtil.toURI(location), true, relativeVariable)); diff --git a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/wizards/datatransfer/RecursiveFileFinder.java b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/wizards/datatransfer/RecursiveFileFinder.java index 2d7682e4c18..a809a7db441 100644 --- a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/wizards/datatransfer/RecursiveFileFinder.java +++ b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/wizards/datatransfer/RecursiveFileFinder.java @@ -31,9 +31,9 @@ public class RecursiveFileFinder implements IResourceVisitor { private IFile firstFoundFile = null; - private Set foundFiles = new HashSet<>(); - private String fileName; - private Set ignoredDirectories; + private final Set foundFiles = new HashSet<>(); + private final String fileName; + private final Set ignoredDirectories; /** * diff --git a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/wizards/datatransfer/WizardExternalProjectImportPage.java b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/wizards/datatransfer/WizardExternalProjectImportPage.java index 51c1c1e2998..35d0db3a6d4 100644 --- a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/wizards/datatransfer/WizardExternalProjectImportPage.java +++ b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/wizards/datatransfer/WizardExternalProjectImportPage.java @@ -68,7 +68,7 @@ */ public class WizardExternalProjectImportPage extends WizardPage { - private FileFilter projectFilter = pathName -> pathName.getName().equals(IProjectDescription.DESCRIPTION_FILE_NAME); + private final FileFilter projectFilter = pathName -> pathName.getName().equals(IProjectDescription.DESCRIPTION_FILE_NAME); // Keep track of the directory that we browsed to last time // the wizard was invoked. @@ -83,7 +83,7 @@ public class WizardExternalProjectImportPage extends WizardPage { private IProjectDescription description; - private Listener locationModifyListener = e -> setPageComplete(validatePage()); + private final Listener locationModifyListener = e -> setPageComplete(validatePage()); // constants private static final int SIZING_TEXT_FIELD_WIDTH = 250; diff --git a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/wizards/datatransfer/ZipFileStructureProvider.java b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/wizards/datatransfer/ZipFileStructureProvider.java index f9244de8d05..367fdf53ffc 100644 --- a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/wizards/datatransfer/ZipFileStructureProvider.java +++ b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/wizards/datatransfer/ZipFileStructureProvider.java @@ -34,15 +34,15 @@ * content of specified zip file entry objects. */ public class ZipFileStructureProvider implements IImportStructureProvider { - private ZipFile zipFile; + private final ZipFile zipFile; - private ZipEntry root = new ZipEntry("/");//$NON-NLS-1$ + private final ZipEntry root = new ZipEntry("/");//$NON-NLS-1$ private Map> children; - private Map directoryEntryCache = new HashMap<>(); + private final Map directoryEntryCache = new HashMap<>(); - private Set invalidEntries = new HashSet<>(); + private final Set invalidEntries = new HashSet<>(); /** * Creates a ZipFileStructureProvider, which will operate diff --git a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/wizards/newresource/BasicNewProjectResourceWizard.java b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/wizards/newresource/BasicNewProjectResourceWizard.java index 67d01fc82c1..bb4aa1d4a0a 100644 --- a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/wizards/newresource/BasicNewProjectResourceWizard.java +++ b/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/wizards/newresource/BasicNewProjectResourceWizard.java @@ -440,8 +440,7 @@ public static void updatePerspective(IConfigurationElement configElement) { // activities other than those that the wizard itself maps to. IPerspectiveDescriptor finalPersp = reg .findPerspectiveWithId(finalPerspId); - if (finalPersp != null && finalPersp instanceof IPluginContribution) { - IPluginContribution contribution = (IPluginContribution) finalPersp; + if (finalPersp != null && finalPersp instanceof IPluginContribution contribution) { if (contribution.getPluginId() != null) { IWorkbenchActivitySupport workbenchActivitySupport = PlatformUI.getWorkbench().getActivitySupport(); IActivityManager activityManager = workbenchActivitySupport.getActivityManager(); @@ -558,13 +557,14 @@ private static boolean confirmPerspectiveSwitch(IWorkbenchWindow window, } String desc = finalPersp.getDescription(); String message; - if (desc == null || desc.isEmpty()) + if (desc == null || desc.isEmpty()) { message = NLS.bind(ResourceMessages.NewProject_perspSwitchMessage, finalPersp.getLabel()); - else + } else { message = NLS.bind( ResourceMessages.NewProject_perspSwitchMessageWithDesc, new String[] { finalPersp.getLabel(), desc }); + } LinkedHashMap buttonLabelToId = new LinkedHashMap<>(); buttonLabelToId.put(ResourceMessages.NewProject_perspSwitchButtonLabel, IDialogConstants.YES_ID);