Skip to content

Commit 2d04c72

Browse files
eclipse-platform-botakurtakov
authored andcommitted
Perform clean code of bundles/org.eclipse.ui.win32
1 parent edc2b90 commit 2d04c72

File tree

1 file changed

+47
-25
lines changed
  • bundles/org.eclipse.ui.win32/src/org/eclipse/ui/internal/editorsupport/win32

1 file changed

+47
-25
lines changed

bundles/org.eclipse.ui.win32/src/org/eclipse/ui/internal/editorsupport/win32/OleEditor.java

Lines changed: 47 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -74,17 +74,19 @@ public class OleEditor extends EditorPart {
7474
* The resource listener updates the receiver when
7575
* a change has occurred.
7676
*/
77-
private IResourceChangeListener resourceListener = new IResourceChangeListener() {
77+
private final IResourceChangeListener resourceListener = new IResourceChangeListener() {
7878

7979
@Override
8080
public void resourceChanged(IResourceChangeEvent event) {
8181
IResourceDelta mainDelta = event.getDelta();
82-
if (mainDelta == null)
82+
if (mainDelta == null) {
8383
return;
84+
}
8485
IResourceDelta affectedElement = mainDelta.findMember(resource
8586
.getFullPath());
86-
if (affectedElement != null)
87+
if (affectedElement != null) {
8788
processDelta(affectedElement);
89+
}
8890
}
8991

9092
/*
@@ -115,8 +117,9 @@ private boolean processDelta(final IResourceDelta delta) {
115117
break;
116118
}
117119

118-
if (changeRunnable != null)
120+
if (changeRunnable != null) {
119121
update(changeRunnable);
122+
}
120123

121124
return true; // because we are sitting on files anyway
122125
}
@@ -191,8 +194,9 @@ public void createPartControl(Composite parent) {
191194

192195
private void createClientSite() {
193196
//If there was an OLE Error or nothing has been created yet
194-
if (clientFrame == null || clientFrame.isDisposed())
197+
if (clientFrame == null || clientFrame.isDisposed()) {
195198
return;
199+
}
196200
// Create a OLE client site.
197201
try {
198202
clientSite = new OleClientSite(clientFrame, SWT.NONE, source);
@@ -215,8 +219,9 @@ private void createClientSite() {
215219
*/
216220
private void displayErrorDialog(String title, String message) {
217221
Shell parent = null;
218-
if (getClientSite() != null)
222+
if (getClientSite() != null) {
219223
parent = getClientSite().getShell();
224+
}
220225
MessageDialog.openError(parent, title, message);
221226
}
222227

@@ -242,8 +247,9 @@ public void dispose() {
242247
* Print this object's contents
243248
*/
244249
public void doPrint() {
245-
if (clientSite == null)
250+
if (clientSite == null) {
246251
return;
252+
}
247253
BusyIndicator.showWhile(clientSite.getDisplay(),
248254
() -> clientSite.exec(OLE.OLECMDID_PRINT, OLE.OLECMDEXECOPT_PROMPTUSER, null, null));
249255
}
@@ -253,8 +259,9 @@ public void doPrint() {
253259
*/
254260
@Override
255261
public void doSave(final IProgressMonitor monitor) {
256-
if (clientSite == null)
262+
if (clientSite == null) {
257263
return;
264+
}
258265
BusyIndicator.showWhile(clientSite.getDisplay(), () -> {
259266

260267
// Do not try and use the component provided save if the source has
@@ -277,13 +284,15 @@ public void doSave(final IProgressMonitor monitor) {
277284
}
278285
if (saveFile(source)) {
279286
try {
280-
if (resource != null)
287+
if (resource != null) {
281288
resource.refreshLocal(IResource.DEPTH_ZERO, monitor);
289+
}
282290
} catch (CoreException ex2) {
283291
// Do nothing on a failed refresh
284292
}
285-
} else
293+
} else {
286294
displayErrorDialog(SAVE_ERROR_TITLE, SAVE_ERROR_MESSAGE + source.getName());
295+
}
287296
});
288297
}
289298

@@ -292,8 +301,9 @@ public void doSave(final IProgressMonitor monitor) {
292301
*/
293302
@Override
294303
public void doSaveAs() {
295-
if (clientSite == null)
304+
if (clientSite == null) {
296305
return;
306+
}
297307
WorkspaceModifyOperation op = saveNewFileOperation();
298308
Shell shell = clientSite.getShell();
299309
try {
@@ -375,18 +385,20 @@ public void init(IEditorSite site, IEditorInput input)
375385
private boolean validatePathEditorInput(IEditorInput input) throws PartInitException {
376386
// Check input type.
377387
IPathEditorInput pathEditorInput = Adapters.adapt(input, IPathEditorInput.class);
378-
if (pathEditorInput == null)
388+
if (pathEditorInput == null) {
379389
throw new PartInitException(OleMessages.format(
380390
"OleEditor.invalidInput", new Object[] { input })); //$NON-NLS-1$
391+
}
381392

382393
IPath path = pathEditorInput.getPath();
383394

384395
//Cannot create this with a file and no physical location
385-
if (!(new File(path.toOSString()).exists()))
396+
if (!(new File(path.toOSString()).exists())) {
386397
throw new PartInitException(
387398
OleMessages
388399
.format(
389400
"OleEditor.noFileInput", new Object[] { path.toOSString() })); //$NON-NLS-1$
401+
}
390402
return true;
391403
}
392404

@@ -395,8 +407,9 @@ private boolean validatePathEditorInput(IEditorInput input) throws PartInitExcep
395407
*/
396408
protected void initializeWorkbenchMenus() {
397409
//If there was an OLE Error or nothing has been created yet
398-
if (clientFrame == null || clientFrame.isDisposed())
410+
if (clientFrame == null || clientFrame.isDisposed()) {
399411
return;
412+
}
400413
// Get the browser menu bar. If one does not exist then
401414
// create it.
402415
Shell shell = clientFrame.getShell();
@@ -416,13 +429,14 @@ protected void initializeWorkbenchMenus() {
416429
for (int i = 0; i < menuBar.getItemCount(); i++) {
417430
MenuItem item = menuBar.getItem(i);
418431
String id = ""; //$NON-NLS-1$
419-
if (item.getData() instanceof IMenuManager)
432+
if (item.getData() instanceof IMenuManager) {
420433
id = ((IMenuManager) item.getData()).getId();
421-
if (id.equals(IWorkbenchActionConstants.M_FILE))
434+
}
435+
if (id.equals(IWorkbenchActionConstants.M_FILE)) {
422436
fileMenu[0] = item;
423-
else if (id.equals(IWorkbenchActionConstants.M_WINDOW))
437+
} else if (id.equals(IWorkbenchActionConstants.M_WINDOW)) {
424438
windowMenu[0] = item;
425-
else {
439+
} else {
426440
if (window.isApplicationMenu(id)) {
427441
containerItems.addElement(item);
428442
}
@@ -499,8 +513,9 @@ public void execute(final IProgressMonitor monitor)
499513
dialog.open();
500514

501515
IPath newPath = dialog.getResult();
502-
if (newPath == null)
516+
if (newPath == null) {
503517
return;
518+
}
504519

505520
if (dialog.getReturnCode() == Window.OK) {
506521
String projectName = newPath.segment(0);
@@ -531,8 +546,9 @@ public void execute(final IProgressMonitor monitor)
531546

532547
@Override
533548
public void setFocus() {
534-
if (clientSite != null)
549+
if (clientSite != null) {
535550
clientSite.setFocus();
551+
}
536552
}
537553

538554
/**
@@ -541,8 +557,9 @@ public void setFocus() {
541557
private void oleActivate() {
542558
//If there was an OLE Error or nothing has been created yet
543559
if (clientSite == null || clientFrame == null
544-
|| clientFrame.isDisposed())
560+
|| clientFrame.isDisposed()) {
545561
return;
562+
}
546563

547564
clientSite.doVerb(OLE.OLEIVERB_SHOW);
548565
String progId = clientSite.getProgramID();
@@ -554,12 +571,14 @@ private void oleActivate() {
554571
@Override
555572
protected void setInputWithNotify(IEditorInput input) {
556573
IPathEditorInput pathEditorInput = Adapters.adapt(input, IPathEditorInput.class);
557-
if (pathEditorInput != null)
574+
if (pathEditorInput != null) {
558575
source = new File(pathEditorInput.getPath().toOSString());
576+
}
559577

560578
if (input instanceof IFileEditorInput) {
561-
if (resource == null)
579+
if (resource == null) {
562580
ResourcesPlugin.getWorkspace().addResourceChangeListener(resourceListener);
581+
}
563582
resource = ((IFileEditorInput)input).getFile();
564583
} else if (resource != null) {
565584
ResourcesPlugin.getWorkspace().removeResourceChangeListener(resourceListener);
@@ -611,16 +630,19 @@ private void update(Runnable runnable) {
611630
if (windows != null && windows.length > 0) {
612631
Display display = windows[0].getShell().getDisplay();
613632
display.asyncExec(runnable);
614-
} else
633+
} else {
615634
runnable.run();
635+
}
616636
}
617637

618638
private boolean isDirty = false;
619639
private void updateDirtyFlag() {
620640
final Runnable dirtyFlagUpdater = new Runnable() {
621641
@Override
622642
public void run() {
623-
if (clientSite == null || resource == null) return;
643+
if (clientSite == null || resource == null) {
644+
return;
645+
}
624646
boolean dirty = isDirty();
625647
if (isDirty != dirty) {
626648
isDirty = dirty;

0 commit comments

Comments
 (0)