Skip to content

Commit 5171be7

Browse files
Perform clean code of ui/org.eclipse.pde.runtime
1 parent 4e00417 commit 5171be7

28 files changed

+318
-162
lines changed

ui/org.eclipse.pde.runtime/src/org/eclipse/pde/internal/runtime/MessageHelper.java

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,22 +21,26 @@
2121

2222
public class MessageHelper {
2323
public static String getResolutionFailureMessage(VersionConstraint unsatisfied) {
24-
if (unsatisfied.isResolved())
24+
if (unsatisfied.isResolved()) {
2525
throw new IllegalArgumentException();
26-
if (unsatisfied instanceof ImportPackageSpecification)
26+
}
27+
if (unsatisfied instanceof ImportPackageSpecification) {
2728
return NLS.bind(PDERuntimeMessages.MessageHelper_missing_imported_package, toString(unsatisfied));
28-
else if (unsatisfied instanceof BundleSpecification) {
29-
if (((BundleSpecification) unsatisfied).isOptional())
29+
} else if (unsatisfied instanceof BundleSpecification) {
30+
if (((BundleSpecification) unsatisfied).isOptional()) {
3031
return NLS.bind(PDERuntimeMessages.MessageHelper_missing_optional_required_bundle, toString(unsatisfied));
32+
}
3133
return NLS.bind(PDERuntimeMessages.MessageHelper_missing_required_bundle, toString(unsatisfied));
32-
} else
34+
} else {
3335
return NLS.bind(PDERuntimeMessages.MessageHelper_missing_host, toString(unsatisfied));
36+
}
3437
}
3538

3639
private static String toString(VersionConstraint constraint) {
3740
VersionRange versionRange = constraint.getVersionRange();
38-
if (versionRange == null)
41+
if (versionRange == null) {
3942
return constraint.getName();
43+
}
4044
return constraint.getName() + '_' + versionRange;
4145
}
4246

ui/org.eclipse.pde.runtime/src/org/eclipse/pde/internal/runtime/OverlayIcon.java

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -30,23 +30,26 @@ public class OverlayIcon extends CompositeImageDescriptor {
3030

3131
public OverlayIcon(ImageDescriptor base, ImageDescriptor[][] overlays) {
3232
fBase = base;
33-
if (fBase == null)
33+
if (fBase == null) {
3434
fBase = ImageDescriptor.getMissingImageDescriptor();
35+
}
3536
fOverlays = overlays;
3637
fSize = new Point(DEFAULT_WIDTH, DEFAULT_HEIGHT);
3738
}
3839

3940
public OverlayIcon(ImageDescriptor base, ImageDescriptor[][] overlays, Point size) {
4041
fBase = base;
41-
if (fBase == null)
42+
if (fBase == null) {
4243
fBase = ImageDescriptor.getMissingImageDescriptor();
44+
}
4345
fOverlays = overlays;
4446
fSize = size;
4547
}
4648

4749
protected void drawBottomLeft(ImageDescriptor[] overlays) {
48-
if (overlays == null)
50+
if (overlays == null) {
4951
return;
52+
}
5053
int length = overlays.length;
5154
int x = 0;
5255
for (int i = 0; i < 3; i++) {
@@ -59,8 +62,9 @@ protected void drawBottomLeft(ImageDescriptor[] overlays) {
5962
}
6063

6164
protected void drawBottomRight(ImageDescriptor[] overlays) {
62-
if (overlays == null)
65+
if (overlays == null) {
6366
return;
67+
}
6468
int length = overlays.length;
6569
int x = getSize().x;
6670
for (int i = 2; i >= 0; i--) {
@@ -78,23 +82,28 @@ protected void drawCompositeImage(int width, int height) {
7882
drawImage(bg, 0, 0);
7983

8084
if (fOverlays != null) {
81-
if (fOverlays.length > 0)
85+
if (fOverlays.length > 0) {
8286
drawTopRight(fOverlays[0]);
87+
}
8388

84-
if (fOverlays.length > 1)
89+
if (fOverlays.length > 1) {
8590
drawBottomRight(fOverlays[1]);
91+
}
8692

87-
if (fOverlays.length > 2)
93+
if (fOverlays.length > 2) {
8894
drawBottomLeft(fOverlays[2]);
95+
}
8996

90-
if (fOverlays.length > 3)
97+
if (fOverlays.length > 3) {
9198
drawTopLeft(fOverlays[3]);
99+
}
92100
}
93101
}
94102

95103
protected void drawTopLeft(ImageDescriptor[] overlays) {
96-
if (overlays == null)
104+
if (overlays == null) {
97105
return;
106+
}
98107
int length = overlays.length;
99108
int x = 0;
100109
for (int i = 0; i < 3; i++) {
@@ -107,8 +116,9 @@ protected void drawTopLeft(ImageDescriptor[] overlays) {
107116
}
108117

109118
protected void drawTopRight(ImageDescriptor[] overlays) {
110-
if (overlays == null)
119+
if (overlays == null) {
111120
return;
121+
}
112122
int length = overlays.length;
113123
int x = getSize().x;
114124
for (int i = 2; i >= 0; i--) {

ui/org.eclipse.pde.runtime/src/org/eclipse/pde/internal/runtime/PDERuntimePlugin.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,16 +106,18 @@ public State getState() {
106106
}
107107

108108
public static void log(Throwable e) {
109-
if (e instanceof InvocationTargetException)
109+
if (e instanceof InvocationTargetException) {
110110
e = ((InvocationTargetException) e).getTargetException();
111+
}
111112
IStatus status = null;
112113
if (e instanceof CoreException) {
113114
status = ((CoreException) e).getStatus();
114115
} else if (e.getMessage() != null) {
115116
status = Status.error(e.getMessage(), e);
116117
}
117-
if (status != null)
118+
if (status != null) {
118119
getDefault().getLog().log(status);
120+
}
119121
}
120122

121123
/**

ui/org.eclipse.pde.runtime/src/org/eclipse/pde/internal/runtime/PDERuntimePluginImages.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,8 +108,9 @@ private static ImageDescriptor create(String prefix, String name) {
108108
}
109109

110110
public static Image get(String key) {
111-
if (PLUGIN_REGISTRY == null)
111+
if (PLUGIN_REGISTRY == null) {
112112
initialize();
113+
}
113114
return PLUGIN_REGISTRY.get(key);
114115
}
115116

ui/org.eclipse.pde.runtime/src/org/eclipse/pde/internal/runtime/registry/RegistryBrowser.java

Lines changed: 52 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -143,12 +143,14 @@ public void run() {
143143
private final ViewerFilter fActiveFilter = new ViewerFilter() {
144144
@Override
145145
public boolean select(Viewer viewer, Object parentElement, Object element) {
146-
if (element instanceof ExtensionPoint)
146+
if (element instanceof ExtensionPoint) {
147147
element = Platform.getBundle(((ExtensionPoint) element).getNamespaceIdentifier());
148-
else if (element instanceof Extension)
148+
} else if (element instanceof Extension) {
149149
element = Platform.getBundle(((Extension) element).getNamespaceIdentifier());
150-
if (element instanceof Bundle)
150+
}
151+
if (element instanceof Bundle) {
151152
return ((Bundle) element).getState() == Bundle.ACTIVE;
153+
}
152154
return true;
153155
}
154156
};
@@ -207,23 +209,27 @@ public IStatus run(IProgressMonitor monitor) {
207209
@Override
208210
public void init(IViewSite site, IMemento memento) throws PartInitException {
209211
super.init(site, memento);
210-
if (memento == null)
212+
if (memento == null) {
211213
this.fMemento = XMLMemento.createWriteRoot("REGISTRYVIEW"); //$NON-NLS-1$
212-
else
214+
} else {
213215
this.fMemento = memento;
216+
}
214217
initializeMemento();
215218
}
216219

217220
private void initializeMemento() {
218221
// show all bundles by default (i.e. not just activated ones)
219-
if (fMemento.getString(SHOW_RUNNING_PLUGINS) == null)
222+
if (fMemento.getString(SHOW_RUNNING_PLUGINS) == null) {
220223
fMemento.putString(SHOW_RUNNING_PLUGINS, "false"); //$NON-NLS-1$
221-
if (fMemento.getInteger(GROUP_BY) == null)
224+
}
225+
if (fMemento.getInteger(GROUP_BY) == null) {
222226
fMemento.putInteger(GROUP_BY, BUNDLES);
227+
}
223228

224229
// default to not showing advanced options to users
225-
if (fMemento.getString(SHOW_ADVANCED_MODE) == null)
230+
if (fMemento.getString(SHOW_ADVANCED_MODE) == null) {
226231
fMemento.putString(SHOW_ADVANCED_MODE, "false"); //$NON-NLS-1$
232+
}
227233
}
228234

229235
@Override
@@ -286,17 +292,19 @@ public int compare(Viewer viewer, Object e1, Object e2) {
286292
return c1.compareTo(c2);
287293
}
288294

289-
if (e1 instanceof Folder && e2 instanceof Folder)
295+
if (e1 instanceof Folder && e2 instanceof Folder) {
290296
return ((Folder) e1).getId() - ((Folder) e2).getId();
297+
}
291298
if (e1 instanceof Bundle && e2 instanceof Bundle) {
292299
e1 = ((Bundle) e1).getSymbolicName();
293300
e2 = ((Bundle) e2).getSymbolicName();
294301
}
295302
return super.compare(viewer, e1, e2);
296303
}
297304
});
298-
if (fShowPluginsAction.isChecked())
305+
if (fShowPluginsAction.isChecked()) {
299306
fTreeViewer.addFilter(fActiveFilter);
307+
}
300308

301309
initializeModel();
302310

@@ -317,8 +325,9 @@ private void hookDoubleClickAction() {
317325
IStructuredSelection selection = fTreeViewer.getStructuredSelection();
318326
if (selection.size() == 1) {
319327
Object obj = selection.getFirstElement();
320-
if (obj instanceof Bundle)
328+
if (obj instanceof Bundle) {
321329
ManifestEditor.openPluginEditor(((Bundle) obj).getSymbolicName());
330+
}
322331
}
323332
});
324333
}
@@ -355,13 +364,16 @@ private void fillContextMenu(IMenuManager manager) {
355364
// check if we should enable advanced actions
356365
if (fShowAdvancedOperationsAction.isChecked() && isBundleSelected()) {
357366
// control bundle state actions
358-
if (selectedBundlesStopped())
367+
if (selectedBundlesStopped()) {
359368
manager.add(fStartAction);
360-
if (selectedBundlesStarted())
369+
}
370+
if (selectedBundlesStarted()) {
361371
manager.add(fStopAction);
372+
}
362373

363-
if (getSelectedBundles().size() == 1)
374+
if (getSelectedBundles().size() == 1) {
364375
manager.add(fDiagnoseAction);
376+
}
365377
}
366378

367379
manager.add(new Separator());
@@ -372,8 +384,9 @@ private void fillContextMenu(IMenuManager manager) {
372384

373385
@Override
374386
public void saveState(IMemento memento) {
375-
if (memento == null || fMemento == null || fTreeViewer == null)
387+
if (memento == null || fMemento == null || fTreeViewer == null) {
376388
return;
389+
}
377390
fMemento.putString(SHOW_RUNNING_PLUGINS, Boolean.toString(fShowPluginsAction.isChecked()));
378391
fMemento.putBoolean(SHOW_ADVANCED_MODE, fShowAdvancedOperationsAction.isChecked());
379392
memento.putMemento(fMemento);
@@ -530,8 +543,9 @@ public void updateTitle() {
530543
}
531544

532545
protected Tree getUndisposedTree() {
533-
if (fTreeViewer == null || fTreeViewer.getTree() == null || fTreeViewer.getTree().isDisposed())
546+
if (fTreeViewer == null || fTreeViewer.getTree() == null || fTreeViewer.getTree().isDisposed()) {
534547
return null;
548+
}
535549
return fTreeViewer.getTree();
536550
}
537551

@@ -555,8 +569,9 @@ public String getTitleSummary() {
555569
break;
556570
}
557571

558-
if (tree == null)
572+
if (tree == null) {
559573
return NLS.bind(PDERuntimeMessages.RegistryView_titleSummary, (new String[] { "0", "0", type })); //$NON-NLS-1$ //$NON-NLS-2$
574+
}
560575
return NLS.bind(PDERuntimeMessages.RegistryView_titleSummary, (new String[] {Integer.toString(tree.getItemCount()), Integer.toString(total), type}));
561576
}
562577

@@ -595,8 +610,9 @@ private boolean selectedBundlesStarted() {
595610
List<Bundle> bundles = getSelectedBundles();
596611
for (Iterator<Bundle> it = bundles.iterator(); it.hasNext();) {
597612
Bundle bundle = it.next();
598-
if (bundle.getState() != Bundle.ACTIVE)
613+
if (bundle.getState() != Bundle.ACTIVE) {
599614
return false;
615+
}
600616
}
601617
return true;
602618
}
@@ -608,8 +624,9 @@ private boolean selectedBundlesStopped() {
608624
List<Bundle> bundles = getSelectedBundles();
609625
for (Iterator<Bundle> it = bundles.iterator(); it.hasNext();) {
610626
Bundle bundle = it.next();
611-
if (bundle.getState() == Bundle.ACTIVE)
627+
if (bundle.getState() == Bundle.ACTIVE) {
612628
return false;
629+
}
613630
}
614631
return true;
615632
}
@@ -624,21 +641,25 @@ public void add(Object object) {
624641
}
625642

626643
protected void add(Object parent, Object object) {
627-
if (fTreeViewer.getTree().isDisposed())
644+
if (fTreeViewer.getTree().isDisposed()) {
628645
return;
646+
}
629647

630-
if (fDrillDownAdapter.canGoHome())
648+
if (fDrillDownAdapter.canGoHome()) {
631649
return;
650+
}
632651
fTreeViewer.refresh();
633652
updateTitle();
634653
}
635654

636655
public void remove(Object object) {
637-
if (fTreeViewer.getTree().isDisposed())
656+
if (fTreeViewer.getTree().isDisposed()) {
638657
return;
658+
}
639659

640-
if (fDrillDownAdapter.canGoHome())
660+
if (fDrillDownAdapter.canGoHome()) {
641661
return;
662+
}
642663
fTreeViewer.refresh();
643664
updateTitle();
644665
}
@@ -648,8 +669,9 @@ private boolean filtersEnabled() {
648669
}
649670

650671
private void deferredRefresh() {
651-
if (refreshThread != null)
672+
if (refreshThread != null) {
652673
return;
674+
}
653675

654676
long now = System.currentTimeMillis();
655677
if (now - lastRefresh > REFRESH_DELAY) {
@@ -664,8 +686,9 @@ private void deferredRefresh() {
664686
return;
665687
}
666688
refreshThread = null;
667-
if (fTreeViewer.getTree().isDisposed())
689+
if (fTreeViewer.getTree().isDisposed()) {
668690
return;
691+
}
669692

670693
fTreeViewer.getTree().getDisplay().asyncExec(() -> {
671694
if (!fTreeViewer.getTree().isDisposed()) {
@@ -680,8 +703,9 @@ private void deferredRefresh() {
680703
}
681704

682705
void refresh(Object[] objects) {
683-
if (fTreeViewer.getTree().isDisposed())
706+
if (fTreeViewer.getTree().isDisposed()) {
684707
return;
708+
}
685709

686710
if (filtersEnabled()) {
687711
deferredRefresh();
@@ -694,8 +718,9 @@ void refresh(Object[] objects) {
694718
}
695719

696720
void refresh(Object object) {
697-
if (fTreeViewer.getTree().isDisposed())
721+
if (fTreeViewer.getTree().isDisposed()) {
698722
return;
723+
}
699724

700725
if (filtersEnabled()) {
701726
deferredRefresh();

0 commit comments

Comments
 (0)