Skip to content

Commit c691ca9

Browse files
eclipse-platform-botakurtakov
authored andcommitted
Perform clean code of bundles/org.eclipse.e4.ui.workbench.swt
1 parent aa465ce commit c691ca9

19 files changed

+173
-137
lines changed

bundles/org.eclipse.e4.ui.workbench.swt/src/org/eclipse/e4/ui/internal/workbench/swt/AbstractPartRenderer.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,9 @@ public void activate(MPart element) {
9191
IEclipseContext curContext = getContext(element);
9292
if (curContext != null) {
9393
EPartService ps = curContext.get(EPartService.class);
94-
if (ps != null)
94+
if (ps != null) {
9595
ps.activate(element, requiresFocus(element));
96+
}
9697
}
9798
}
9899

@@ -107,9 +108,9 @@ public void removeGui(MUIElement element, Object widget) {
107108
}
108109

109110
public Object getUIContainer(MUIElement element) {
110-
if (element.getParent() != null)
111+
if (element.getParent() != null) {
111112
return element.getParent().getWidget();
112-
else {
113+
} else {
113114
Object value = element.getTransientData().get(IPresentationEngine.RENDERING_PARENT_KEY);
114115
if (value != null) {
115116
return value;

bundles/org.eclipse.e4.ui.workbench.swt/src/org/eclipse/e4/ui/internal/workbench/swt/CSSRenderingUtils.java

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -132,13 +132,15 @@ private void initDragHandleResource() {
132132
IPath path = IPath.fromOSString("$ws$/images/dragHandle.svg");
133133
URL url = FileLocator.find(bundle, path, null);
134134
ImageDescriptor desc = ImageDescriptor.createFromURL(url);
135-
if (desc != null)
135+
if (desc != null) {
136136
JFaceResources.getImageRegistry().put(DRAG_HANDLE, desc);
137+
}
137138
path = IPath.fromOSString("$ws$/images/dragHandle-rotated.svg");
138139
url = FileLocator.find(bundle, path, null);
139140
ImageDescriptor desc_rotated = ImageDescriptor.createFromURL(url);
140-
if (desc_rotated != null)
141+
if (desc_rotated != null) {
141142
JFaceResources.getImageRegistry().put(DRAG_HANDLE_ROTATED, desc_rotated);
143+
}
142144
}
143145

144146
private Image rotateImage(Display display, Image image, Integer[] frameInts) {
@@ -153,8 +155,9 @@ private Image rotateImage(Display display, Image image, Integer[] frameInts) {
153155
frameInts[3] = tmp;
154156
}
155157

156-
if (rotatedImageMap.get(image) != null)
158+
if (rotatedImageMap.get(image) != null) {
157159
return rotatedImageMap.get(image);
160+
}
158161

159162
// rotate 90 degrees,,,
160163
Rectangle bounds = image.getBounds();
@@ -206,14 +209,16 @@ public CSSValue getCSSValue(Control styleControl, String className,
206209
}
207210

208211
// super hack
209-
if (className != null)
212+
if (className != null) {
210213
WidgetElement.setCSSClass(styleControl, className);
214+
}
211215

212216
CSSStyleDeclaration styleDeclarations = csseng.getViewCSS()
213217
.getComputedStyle(tempEment, ""); //$NON-NLS-1$
214218

215-
if (styleDeclarations == null)
219+
if (styleDeclarations == null) {
216220
return null;
221+
}
217222

218223
return styleDeclarations.getPropertyCSSValue(attributeName);
219224
}
@@ -231,17 +236,20 @@ public Image createImage(Control styleControl, String classId,
231236
if (tempEment == null) {
232237
return null;
233238
}
234-
if (classId != null)
239+
if (classId != null) {
235240
WidgetElement.setCSSClass(styleControl, classId);
241+
}
236242

237243
CSSStyleDeclaration styleDeclarations = csseng.getViewCSS()
238244
.getComputedStyle(tempEment, "");
239-
if (styleDeclarations == null)
245+
if (styleDeclarations == null) {
240246
return null;
247+
}
241248

242249
CSSValue imagePath = styleDeclarations.getPropertyCSSValue(attName);
243-
if (imagePath == null)
250+
if (imagePath == null) {
244251
return null;
252+
}
245253

246254
if (imagePath.getCssValueType() == CSSValue.CSS_PRIMITIVE_VALUE) {
247255
// String imageString = ((CSSPrimitiveValue) imagePath)
@@ -255,8 +263,9 @@ public Image createImage(Control styleControl, String classId,
255263
.getPropertyCSSValue("frame-cuts"); //$NON-NLS-1$
256264
if (value.getCssValueType() == CSSValue.CSS_VALUE_LIST) {
257265
CSSValueList valueList = (CSSValueList) value;
258-
if (valueList.getLength() != 4)
266+
if (valueList.getLength() != 4) {
259267
return null;
268+
}
260269

261270
for (int i = 0; i < valueList.getLength(); i++) {
262271
CSSValue val = valueList.item(i);
@@ -283,11 +292,10 @@ private void addHandleImageDisposedListener(
283292
ImageBasedFrame imageBasedFrame, final Control toFrame,
284293
final String classId, final boolean vertical) {
285294
final Listener listener = event -> {
286-
if (!(event.widget instanceof ImageBasedFrame)) {
295+
if (!(event.widget instanceof ImageBasedFrame frame)) {
287296
return;
288297
}
289298

290-
ImageBasedFrame frame = (ImageBasedFrame) event.widget;
291299
if (!isImagesRefreshRequired(frame)) {
292300
return;
293301
}
@@ -315,11 +323,10 @@ private void addHandleImageDisposedListener(
315323
private void addFrameImageDisposedListener(ImageBasedFrame imageBasedFrame,
316324
final Control toFrame, final String classId, final boolean vertical) {
317325
final Listener listener = event -> {
318-
if (!(event.widget instanceof ImageBasedFrame)) {
326+
if (!(event.widget instanceof ImageBasedFrame frame)) {
319327
return;
320328
}
321329

322-
ImageBasedFrame frame = (ImageBasedFrame) event.widget;
323330
if (!isImagesRefreshRequired(frame)) {
324331
return;
325332
}

bundles/org.eclipse.e4.ui.workbench.swt/src/org/eclipse/e4/ui/internal/workbench/swt/DialogSettingsProvider.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ public final class DialogSettingsProvider implements IDialogSettingsProvider {
7171
*/
7272
private static final String KEY_DEFAULT_DIALOG_SETTINGS_ROOTURL = "default_dialog_settings_rootUrl"; //$NON-NLS-1$
7373

74-
private Bundle fBundle;
74+
private final Bundle fBundle;
7575

7676
private IDialogSettings fDialogSettings;
7777

bundles/org.eclipse.e4.ui.workbench.swt/src/org/eclipse/e4/ui/internal/workbench/swt/E4Application.java

Lines changed: 23 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
* Terry Parker <[email protected]> - Bug 416673
1818
* Christian Georgi (SAP) - Bug 432480
1919
* Simon Scholz <[email protected]> - Bug 478896
20-
* Christoph Läubrich - Bug 563459
20+
* Christoph Läubrich - Bug 563459
2121
******************************************************************************/
2222

2323
package org.eclipse.e4.ui.internal.workbench.swt;
@@ -158,8 +158,9 @@ public Object start(IApplicationContext applicationContext) throws Exception {
158158
// place it off so it's not visible
159159
shell.setLocation(0, 10000);
160160
}
161-
if (!checkInstanceLocation(instanceLocation, shell, workbench.getContext()))
161+
if (!checkInstanceLocation(instanceLocation, shell, workbench.getContext())) {
162162
return EXIT_OK;
163+
}
163164

164165
// Create and run the UI (if any)
165166
workbench.createAndRunUI(workbench.getApplication());
@@ -176,10 +177,12 @@ public Object start(IApplicationContext applicationContext) throws Exception {
176177

177178
return EXIT_OK;
178179
} finally {
179-
if (display != null)
180+
if (display != null) {
180181
display.dispose();
181-
if (instanceLocation != null)
182+
}
183+
if (instanceLocation != null) {
182184
instanceLocation.release();
185+
}
183186
}
184187
}
185188

@@ -410,18 +413,21 @@ private URI determineApplicationModelURI(IApplicationContext appContext) {
410413
*/
411414
private Optional<String> getArgValue(String argName, IApplicationContext appContext, boolean singledCmdArgValue) {
412415
// Is it in the arg list ?
413-
if (argName == null || argName.length() == 0)
416+
if (argName == null || argName.length() == 0) {
414417
return Optional.empty();
418+
}
415419

416420
if (singledCmdArgValue) {
417421
for (String arg : args) {
418-
if (("-" + argName).equals(arg))
422+
if (("-" + argName).equals(arg)) {
419423
return Optional.of("true");
424+
}
420425
}
421426
} else {
422427
for (int i = 0; i < args.length; i++) {
423-
if (("-" + argName).equals(args[i]) && i + 1 < args.length)
428+
if (("-" + argName).equals(args[i]) && i + 1 < args.length) {
424429
return Optional.of(args[i + 1]);
430+
}
425431
}
426432
}
427433

@@ -737,8 +743,9 @@ private static File getVersionFile(URL workspaceUrl, boolean create) {
737743
static public void initializeServices(MApplication appModel) {
738744
IEclipseContext appContext = appModel.getContext();
739745
// make sure we only add trackers once
740-
if (appContext.containsKey(CONTEXT_INITIALIZED))
746+
if (appContext.containsKey(CONTEXT_INITIALIZED)) {
741747
return;
748+
}
742749
appContext.set(CONTEXT_INITIALIZED, "true");
743750
initializeApplicationServices(appContext);
744751
List<MWindow> windows = appModel.getChildren();
@@ -748,10 +755,12 @@ static public void initializeServices(MApplication appModel) {
748755
((EObject) appModel).eAdapters().add(new AdapterImpl() {
749756
@Override
750757
public void notifyChanged(Notification notification) {
751-
if (notification.getFeatureID(MApplication.class) != UiPackageImpl.ELEMENT_CONTAINER__CHILDREN)
758+
if (notification.getFeatureID(MApplication.class) != UiPackageImpl.ELEMENT_CONTAINER__CHILDREN) {
752759
return;
753-
if (notification.getEventType() != Notification.ADD)
760+
}
761+
if (notification.getEventType() != Notification.ADD) {
754762
return;
763+
}
755764
MWindow childWindow = (MWindow) notification.getNewValue();
756765
initializeWindowServices(childWindow);
757766
}
@@ -792,17 +801,19 @@ static public void initializeWindowServices(MWindow childWindow) {
792801
((EObject) childWindow).eAdapters().add(new AdapterImpl() {
793802
@Override
794803
public void notifyChanged(Notification notification) {
795-
if (notification.getFeatureID(MWindow.class) != BasicPackageImpl.WINDOW__CONTEXT)
804+
if (notification.getFeatureID(MWindow.class) != BasicPackageImpl.WINDOW__CONTEXT) {
796805
return;
806+
}
797807
IEclipseContext windowContext = (IEclipseContext) notification.getNewValue();
798808
initWindowContext(windowContext);
799809
}
800810
});
801811
}
802812

803813
static private void initWindowContext(IEclipseContext windowContext) {
804-
if (windowContext == null)
814+
if (windowContext == null) {
805815
return;
816+
}
806817
SelectionAggregator selectionAggregator = ContextInjectionFactory.make(SelectionAggregator.class,
807818
windowContext);
808819
windowContext.set(SelectionAggregator.class, selectionAggregator);

bundles/org.eclipse.e4.ui.workbench.swt/src/org/eclipse/e4/ui/internal/workbench/swt/MenuService.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,9 @@ public class MenuService implements EMenuService {
3232

3333
@Override
3434
public boolean registerContextMenu(Object parent, String menuId) {
35-
if (!(parent instanceof Control)) {
35+
if (!(parent instanceof Control parentControl)) {
3636
return false;
3737
}
38-
Control parentControl = (Control) parent;
3938
for (MMenu mmenu : myPart.getMenus()) {
4039
if (menuId.equals(mmenu.getElementId())
4140
&& mmenu instanceof MPopupMenu) {

0 commit comments

Comments
 (0)