Skip to content

Commit 6385ed9

Browse files
eclipse-platform-botakurtakov
authored andcommitted
Perform clean code of bundles/org.eclipse.ui.ide.application
1 parent 28f12e7 commit 6385ed9

File tree

5 files changed

+45
-31
lines changed

5 files changed

+45
-31
lines changed

bundles/org.eclipse.ui.ide.application/src/org/eclipse/ui/internal/ide/application/DelayedEventsProcessor.java

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,8 @@ public class DelayedEventsProcessor implements Listener {
7878
private static final String TEXTEDITOR_BUNDLE_NAME = "org.eclipse.ui.workbench.texteditor"; //$NON-NLS-1$
7979
private static final String TEXTEDITOR_CLASS_NAME = "org.eclipse.ui.texteditor.ITextEditor"; //$NON-NLS-1$
8080

81-
private ArrayList<String> filesToOpen = new ArrayList<>(1);
82-
private ArrayList<Event> urlsToOpen = new ArrayList<>(1);
81+
private final ArrayList<String> filesToOpen = new ArrayList<>(1);
82+
private final ArrayList<Event> urlsToOpen = new ArrayList<>(1);
8383

8484
/**
8585
* Constructor.
@@ -94,8 +94,9 @@ public DelayedEventsProcessor(Display display) {
9494
@Override
9595
public void handleEvent(Event event) {
9696
final String path = event.text;
97-
if (path == null)
97+
if (path == null) {
9898
return;
99+
}
99100
// If we start supporting events that can arrive on a non-UI thread, the
100101
// following lines will need to be in a "synchronized" block:
101102
if (event.type == SWT.OpenUrl) {
@@ -111,8 +112,9 @@ public void handleEvent(Event event) {
111112
* @param display display associated with the workbench
112113
*/
113114
public void catchUp(Display display) {
114-
if (filesToOpen.isEmpty() && urlsToOpen.isEmpty())
115+
if (filesToOpen.isEmpty() && urlsToOpen.isEmpty()) {
115116
return;
117+
}
116118

117119
// If we start supporting events that can arrive on a non-UI thread, the
118120
// following
@@ -195,8 +197,9 @@ public static void openFile(Display display, final String initialPath) {
195197
@Override
196198
public void run() {
197199
IWorkbenchWindow window = PlatformUI.getWorkbench().getActiveWorkbenchWindow();
198-
if (window == null)
200+
if (window == null) {
199201
return;
202+
}
200203
FileLocationDetails details = FileLocationDetails.resolve(initialPath);
201204
if (details == null || !details.fileInfo.exists()) {
202205
String msg = NLS.bind(IDEWorkbenchMessages.OpenDelayedFileAction_message_fileNotFound, initialPath);
@@ -214,8 +217,9 @@ public void run() {
214217
}
215218
Shell shell = window.getShell();
216219
if (shell != null) {
217-
if (shell.getMinimized())
220+
if (shell.getMinimized()) {
218221
shell.setMinimized(false);
222+
}
219223
shell.forceActive();
220224
}
221225
try {

bundles/org.eclipse.ui.ide.application/src/org/eclipse/ui/internal/ide/application/IDEApplication.java

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -201,8 +201,9 @@ public Object start(IApplicationContext appContext) throws Exception {
201201
display.dispose();
202202
}
203203
Location instanceLoc = Platform.getInstanceLocation();
204-
if (instanceLoc != null)
204+
if (instanceLoc != null) {
205205
instanceLoc.release();
206+
}
206207
}
207208
}
208209

@@ -562,8 +563,9 @@ private static Path createLockInfoFile(URL workspaceUrl) throws Exception {
562563
@SuppressWarnings("rawtypes")
563564
private static boolean isDevLaunchMode(Map args) {
564565
// see org.eclipse.pde.internal.core.PluginPathFinder.isDevLaunchMode()
565-
if (Boolean.getBoolean("eclipse.pde.launch")) //$NON-NLS-1$
566+
if (Boolean.getBoolean("eclipse.pde.launch")) { //$NON-NLS-1$
566567
return true;
568+
}
567569
return args.containsKey("-pdelaunch"); //$NON-NLS-1$
568570
}
569571

@@ -917,12 +919,14 @@ protected static Version toMajorMinorVersion(Version version) {
917919
@Override
918920
public void stop() {
919921
final IWorkbench workbench = PlatformUI.getWorkbench();
920-
if (workbench == null)
922+
if (workbench == null) {
921923
return;
924+
}
922925
final Display display = workbench.getDisplay();
923926
display.syncExec(() -> {
924-
if (!display.isDisposed())
927+
if (!display.isDisposed()) {
925928
workbench.close();
929+
}
926930
});
927931
}
928932
}

bundles/org.eclipse.ui.ide.application/src/org/eclipse/ui/internal/ide/application/IDEWorkbenchAdvisor.java

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -160,8 +160,9 @@ public class IDEWorkbenchAdvisor extends WorkbenchAdvisor {
160160
private final Listener closeListener = event -> {
161161
boolean doExit = IDEWorkbenchWindowAdvisor.promptOnExit(null);
162162
event.doit = doExit;
163-
if (!doExit)
163+
if (!doExit) {
164164
event.type = SWT.None;
165+
}
165166
};
166167

167168
/**
@@ -298,8 +299,9 @@ protected void activateProxyService() {
298299
Object proxyService = null;
299300
if (bundle != null) {
300301
ServiceReference<IProxyService> ref = bundle.getBundleContext().getServiceReference(IProxyService.class);
301-
if (ref != null)
302+
if (ref != null) {
302303
proxyService = bundle.getBundleContext().getService(ref);
304+
}
303305
}
304306
if (proxyService == null) {
305307
IDEWorkbenchPlugin.log("Proxy service could not be found."); //$NON-NLS-1$
@@ -317,8 +319,9 @@ protected void initializeSettingsChangeListener() {
317319

318320
@Override
319321
public void handleEvent(org.eclipse.swt.widgets.Event event) {
320-
if (Display.getCurrent().getHighContrast() == currentHighContrast)
322+
if (Display.getCurrent().getHighContrast() == currentHighContrast) {
321323
return;
324+
}
322325

323326
currentHighContrast = !currentHighContrast;
324327

@@ -444,8 +447,7 @@ protected void refreshFromLocal() {
444447

445448
// We should try to use RefreshManager which avoids multiple refresh requests
446449
// for same objects
447-
if (workspace instanceof Workspace) {
448-
Workspace wsp = (Workspace) workspace;
450+
if (workspace instanceof Workspace wsp) {
449451
if (!wsp.isCrashed()) {
450452
// Only refresh if no crash happened before: the workspace itself
451453
// triggers refresh in that case, see Workspace.open()
@@ -467,7 +469,7 @@ public IStatus runInWorkspace(IProgressMonitor monitor) throws CoreException {
467469
protected static class CancelableProgressMonitorWrapper extends
468470
ProgressMonitorWrapper {
469471
private double total = 0;
470-
private ProgressMonitorJobsDialog dialog;
472+
private final ProgressMonitorJobsDialog dialog;
471473

472474
CancelableProgressMonitorWrapper(IProgressMonitor monitor,
473475
ProgressMonitorJobsDialog dialog) {
@@ -549,8 +551,9 @@ protected void disconnectFromWorkspace() {
549551

550552
IRunnableWithProgress runnable = monitor -> {
551553
try {
552-
if (applyPolicy)
554+
if (applyPolicy) {
553555
monitor = new CancelableProgressMonitorWrapper(monitor, p);
556+
}
554557

555558
status.merge(((Workspace) ResourcesPlugin.getWorkspace()).save(true, true, monitor));
556559
} catch (CoreException e) {
@@ -681,14 +684,17 @@ protected Map<String, AboutInfo> createNewBundleGroupsMap() {
681684
protected static void setWorkspaceNameDefault() {
682685
IPreferenceStore preferences = IDEWorkbenchPlugin.getDefault().getPreferenceStore();
683686
String workspaceNameDefault = preferences.getDefaultString(IDEInternalPreferences.WORKSPACE_NAME);
684-
if (workspaceNameDefault != null && !workspaceNameDefault.isEmpty())
687+
if (workspaceNameDefault != null && !workspaceNameDefault.isEmpty()) {
685688
return; // Default is set in a plugin customization file - don't change it.
689+
}
686690
IPath workspaceDir = Platform.getLocation();
687-
if (workspaceDir == null)
691+
if (workspaceDir == null) {
688692
return;
693+
}
689694
String workspaceName = workspaceDir.lastSegment();
690-
if (workspaceName == null)
695+
if (workspaceName == null) {
691696
return;
697+
}
692698
preferences.setDefault(IDEInternalPreferences.WORKSPACE_NAME, workspaceName);
693699
}
694700

@@ -970,8 +976,9 @@ public synchronized AbstractStatusHandler getWorkbenchErrorHandler() {
970976

971977
@Override
972978
public void eventLoopIdle(Display display) {
973-
if (delayedEventsProcessor != null)
979+
if (delayedEventsProcessor != null) {
974980
delayedEventsProcessor.catchUp(display);
981+
}
975982
super.eventLoopIdle(display);
976983
}
977984
}

bundles/org.eclipse.ui.ide.application/src/org/eclipse/ui/internal/ide/application/IDEWorkbenchWindowAdvisor.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -97,15 +97,15 @@ public class IDEWorkbenchWindowAdvisor extends WorkbenchWindowAdvisor {
9797

9898
private static final String WELCOME_EDITOR_ID = "org.eclipse.ui.internal.ide.dialogs.WelcomeEditor"; //$NON-NLS-1$
9999

100-
private IDEWorkbenchAdvisor wbAdvisor;
100+
private final IDEWorkbenchAdvisor wbAdvisor;
101101
private boolean editorsAndIntrosOpened = false;
102102
private IEditorPart lastActiveEditor = null;
103103
private IPerspectiveDescriptor lastPerspective = null;
104104

105105
private IWorkbenchPage lastActivePage;
106-
private String lastEditorTitleTooltip = ""; //$NON-NLS-1$
106+
private final String lastEditorTitleTooltip = ""; //$NON-NLS-1$
107107

108-
private IPropertyListener editorPropertyListener = (source, propId) -> {
108+
private final IPropertyListener editorPropertyListener = (source, propId) -> {
109109
if (propId == IWorkbenchPartConstants.PROP_TITLE) {
110110
if (lastActiveEditor != null) {
111111
String newTitle = lastActiveEditor.getTitleToolTip();
@@ -125,7 +125,7 @@ public class IDEWorkbenchWindowAdvisor extends WorkbenchWindowAdvisor {
125125
*/
126126
private IPropertyChangeListener propertyChangeListener;
127127

128-
private TitlePathUpdater titlePathUpdater;
128+
private final TitlePathUpdater titlePathUpdater;
129129

130130
/**
131131
* Crates a new IDE workbench window advisor.

bundles/org.eclipse.ui.ide.application/src/org/eclipse/ui/internal/ide/application/dialogs/UriSchemeHandlerPreferencePage.java

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -344,8 +344,7 @@ public Image getColumnImage(Object element, int columnIndex) {
344344

345345
@Override
346346
public String getColumnText(Object element, int columnIndex) {
347-
if (element instanceof UiSchemeInformation) {
348-
UiSchemeInformation schemeInfo = (UiSchemeInformation) element;
347+
if (element instanceof UiSchemeInformation schemeInfo) {
349348
switch (columnIndex) {
350349
case 0:
351350
return schemeInfo.getName();
@@ -354,9 +353,9 @@ public String getColumnText(Object element, int columnIndex) {
354353
return schemeInfo.getDescription();
355354
case 2:
356355
String text = ""; //$NON-NLS-1$
357-
if (UrlHandlerPreferencePage_LoadingText.equals(schemeInfo.getHandlerInstanceLocation()))
356+
if (UrlHandlerPreferencePage_LoadingText.equals(schemeInfo.getHandlerInstanceLocation())) {
358357
text = schemeInfo.getHandlerInstanceLocation();
359-
else if (schemeInfo.isChecked()) {
358+
} else if (schemeInfo.isChecked()) {
360359
text = UrlHandlerPreferencePage_Column_Handler_Text_Current_Application;
361360
} else if (schemeInfo.information.schemeIsHandledByOther()) {
362361
text = UrlHandlerPreferencePage_Column_Handler_Text_Other_Application;
@@ -377,7 +376,7 @@ public boolean isLabelProperty(Object element, String property) {
377376

378377
static class UiSchemeInformation {
379378
private boolean checked;
380-
private ISchemeInformation information;
379+
private final ISchemeInformation information;
381380

382381
public UiSchemeInformation(boolean checked, ISchemeInformation information) {
383382
this.checked = checked;
@@ -403,7 +402,7 @@ public boolean isChecked() {
403402

404403
static final class LoadingSchemeInformation extends UiSchemeInformation {
405404

406-
private IScheme scheme;
405+
private final IScheme scheme;
407406

408407
public LoadingSchemeInformation(IScheme scheme) {
409408
super(false, null);

0 commit comments

Comments
 (0)