Skip to content

Commit a13de75

Browse files
eclipse-platform-botakurtakov
authored andcommitted
Perform clean code of bundles/org.eclipse.ui.workbench
1 parent 8b0bfa8 commit a13de75

File tree

503 files changed

+2650
-2330
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

503 files changed

+2650
-2330
lines changed

bundles/org.eclipse.ui.workbench/eclipseui/org/eclipse/e4/ui/workbench/addons/perspectiveswitcher/PerspectiveSwitcher.java

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -194,12 +194,10 @@ void handleToBeRenderedEvent(@UIEventTopic(UIEvents.UIElement.TOPIC_TOBERENDERED
194194
void handleLabelEvent(@UIEventTopic(UIEvents.UILabel.TOPIC_ALL) Event event) {
195195

196196
Object changedObj = event.getProperty(UIEvents.EventTags.ELEMENT);
197-
if (!(changedObj instanceof MPerspective) || (ignoreEvent(changedObj))) {
197+
if (!(changedObj instanceof MPerspective perspective) || (ignoreEvent(changedObj))) {
198198
return;
199199
}
200200

201-
MPerspective perspective = (MPerspective) changedObj;
202-
203201
if (!perspective.isToBeRendered())
204202
{
205203
return;
@@ -222,12 +220,10 @@ void handleLabelEvent(@UIEventTopic(UIEvents.UILabel.TOPIC_ALL) Event event) {
222220
void handleSelectionEvent(@UIEventTopic(UIEvents.ElementContainer.TOPIC_SELECTEDELEMENT) Event event) {
223221

224222
Object changedObj = event.getProperty(UIEvents.EventTags.ELEMENT);
225-
if (!(changedObj instanceof MPerspectiveStack) || (ignoreEvent(changedObj))) {
223+
if (!(changedObj instanceof MPerspectiveStack perspStack) || (ignoreEvent(changedObj))) {
226224
return;
227225
}
228226

229-
MPerspectiveStack perspStack = (MPerspectiveStack) changedObj;
230-
231227
if (!perspStack.isToBeRendered()) {
232228
return;
233229
}
@@ -259,8 +255,7 @@ void createWidget(Composite parent, MToolControl toolControl) {
259255
perspSwitcherToolControl = toolControl;
260256
MUIElement meParent = perspSwitcherToolControl.getParent();
261257
int orientation = SWT.HORIZONTAL;
262-
if (meParent instanceof MTrimBar) {
263-
MTrimBar bar = (MTrimBar) meParent;
258+
if (meParent instanceof MTrimBar bar) {
264259
if (bar.getSide() == SideValue.RIGHT || bar.getSide() == SideValue.LEFT) {
265260
orientation = SWT.VERTICAL;
266261
}

bundles/org.eclipse.ui.workbench/eclipseui/org/eclipse/ui/ActiveShellExpression.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,7 @@ protected int computeHashCode() {
7878

7979
@Override
8080
public boolean equals(final Object object) {
81-
if (object instanceof ActiveShellExpression) {
82-
final ActiveShellExpression that = (ActiveShellExpression) object;
81+
if (object instanceof final ActiveShellExpression that) {
8382
return equals(this.activeShell, that.activeShell);
8483
}
8584

bundles/org.eclipse.ui.workbench/eclipseui/org/eclipse/ui/BasicWorkingSetElementAdapter.java

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,9 @@ public IAdaptable[] adaptElements(IWorkingSet ws, IAdaptable[] elements) {
9393
List<IAdaptable> adaptedElements = new ArrayList<>();
9494
for (IAdaptable element : elements) {
9595
IAdaptable adaptable = adapt(element);
96-
if (adaptable != null)
96+
if (adaptable != null) {
9797
adaptedElements.add(adaptable);
98+
}
9899
}
99100

100101
return adaptedElements.toArray(new IAdaptable[adaptedElements.size()]);
@@ -111,8 +112,9 @@ public IAdaptable[] adaptElements(IWorkingSet ws, IAdaptable[] elements) {
111112
private IAdaptable adapt(IAdaptable adaptable) {
112113
for (Type preferredType : preferredTypes) {
113114
IAdaptable adaptedAdaptable = adapt(preferredType, adaptable);
114-
if (adaptedAdaptable != null)
115+
if (adaptedAdaptable != null) {
115116
return adaptedAdaptable;
117+
}
116118
}
117119
return null;
118120
}
@@ -129,14 +131,16 @@ private IAdaptable adapt(Type type, IAdaptable adaptable) {
129131
IAdapterManager adapterManager = Platform.getAdapterManager();
130132
Class<?>[] directClasses = adapterManager.computeClassOrder(adaptable.getClass());
131133
for (Class<?> clazz : directClasses) {
132-
if (clazz.getName().equals(type.className))
134+
if (clazz.getName().equals(type.className)) {
133135
return adaptable;
136+
}
134137
}
135138

136139
if ((type.flags & Type.ADAPT) != 0) {
137140
Object adapted = adapterManager.getAdapter(adaptable, type.className);
138-
if (adapted instanceof IAdaptable)
141+
if (adapted instanceof IAdaptable) {
139142
return (IAdaptable) adapted;
143+
}
140144

141145
PackageAdmin admin = getPackageAdmin();
142146
if (admin != null) {
@@ -155,8 +159,9 @@ private IAdaptable adapt(Type type, IAdaptable adaptable) {
155159
// object directly
156160
adapted = adaptable
157161
.getAdapter(packages[0].getExportingBundle().loadClass(type.className));
158-
if (adapted instanceof IAdaptable)
162+
if (adapted instanceof IAdaptable) {
159163
return (IAdaptable) adapted;
164+
}
160165

161166
} catch (ClassNotFoundException e) {
162167
WorkbenchPlugin.log(e);
@@ -171,8 +176,9 @@ private IAdaptable adapt(Type type, IAdaptable adaptable) {
171176

172177
@Override
173178
public void dispose() {
174-
if (packageTracker != null)
179+
if (packageTracker != null) {
175180
packageTracker.close();
181+
}
176182
}
177183

178184
@Override
@@ -200,9 +206,9 @@ public void setInitializationData(IConfigurationElement config, String propertyN
200206
private void parseOptions(String classNameAndOptions, Type record) {
201207
for (StringTokenizer toker = new StringTokenizer(classNameAndOptions, ";"); toker.hasMoreTokens();) { //$NON-NLS-1$
202208
String token = toker.nextToken();
203-
if (record.className == null)
209+
if (record.className == null) {
204210
record.className = token;
205-
else {
211+
} else {
206212
for (StringTokenizer pair = new StringTokenizer(token, "="); pair.hasMoreTokens();) {//$NON-NLS-1$
207213
if (pair.countTokens() == 2) {
208214
String param = pair.nextToken();

bundles/org.eclipse.ui.workbench/eclipseui/org/eclipse/ui/LegacyHandlerSubmissionExpression.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,8 +104,7 @@ protected int computeHashCode() {
104104

105105
@Override
106106
public boolean equals(final Object object) {
107-
if (object instanceof LegacyHandlerSubmissionExpression) {
108-
final LegacyHandlerSubmissionExpression that = (LegacyHandlerSubmissionExpression) object;
107+
if (object instanceof final LegacyHandlerSubmissionExpression that) {
109108
return equals(this.activePartId, that.activePartId) && equals(this.activeShell, that.activeShell)
110109
&& equals(this.activeSite, that.activeSite);
111110
}

bundles/org.eclipse.ui.workbench/eclipseui/org/eclipse/ui/MultiPartInitException.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@
2323
*/
2424
public class MultiPartInitException extends WorkbenchException {
2525

26-
private IWorkbenchPartReference[] references;
27-
private PartInitException[] exceptions;
26+
private final IWorkbenchPartReference[] references;
27+
private final PartInitException[] exceptions;
2828

2929
/**
3030
* Creates a new exception object. Note that as of 3.5, this constructor expects
@@ -65,8 +65,9 @@ public PartInitException[] getExceptions() {
6565

6666
private static int findFirstException(PartInitException[] exceptions) {
6767
for (int i = 0; i < exceptions.length; i++) {
68-
if (exceptions[i] != null)
68+
if (exceptions[i] != null) {
6969
return i;
70+
}
7071
}
7172
throw new IllegalArgumentException();
7273
}

bundles/org.eclipse.ui.workbench/eclipseui/org/eclipse/ui/NavigationLocation.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
*/
2222
public abstract class NavigationLocation implements INavigationLocation {
2323

24-
private IWorkbenchPage page;
24+
private final IWorkbenchPage page;
2525

2626
private IEditorInput input;
2727

bundles/org.eclipse.ui.workbench/eclipseui/org/eclipse/ui/OpenAndLinkWithEditorHelper.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
*/
3333
public abstract class OpenAndLinkWithEditorHelper {
3434

35-
private StructuredViewer viewer;
35+
private final StructuredViewer viewer;
3636

3737
private boolean isLinkingEnabled;
3838

@@ -51,15 +51,17 @@ public void open(OpenEvent event) {
5151
@Override
5252
public void selectionChanged(SelectionChangedEvent event) {
5353
final ISelection selection = event.getSelection();
54-
if (isLinkingEnabled && !selection.equals(lastOpenSelection) && viewer.getControl().isFocusControl())
54+
if (isLinkingEnabled && !selection.equals(lastOpenSelection) && viewer.getControl().isFocusControl()) {
5555
linkToEditor(selection);
56+
}
5657
lastOpenSelection = null;
5758
}
5859

5960
@Override
6061
public void doubleClick(DoubleClickEvent event) {
61-
if (!OpenStrategy.activateOnOpen())
62+
if (!OpenStrategy.activateOnOpen()) {
6263
activate(event.getSelection());
64+
}
6365
}
6466

6567
}

bundles/org.eclipse.ui.workbench/eclipseui/org/eclipse/ui/SaveablesLifecycleEvent.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,11 +53,11 @@ public class SaveablesLifecycleEvent extends EventObject {
5353
*/
5454
public static final int DIRTY_CHANGED = 4;
5555

56-
private int eventType;
56+
private final int eventType;
5757

58-
private Saveable[] saveables;
58+
private final Saveable[] saveables;
5959

60-
private boolean force;
60+
private final boolean force;
6161

6262
private boolean veto = false;
6363

bundles/org.eclipse.ui.workbench/eclipseui/org/eclipse/ui/SelectionEnabler.java

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -219,8 +219,7 @@ public SelectionEnabler(IConfigurationElement configElement) {
219219

220220
@Override
221221
public boolean equals(final Object object) {
222-
if (object instanceof SelectionEnabler) {
223-
final SelectionEnabler that = (SelectionEnabler) object;
222+
if (object instanceof final SelectionEnabler that) {
224223
return Objects.equals(this.classes, that.classes)
225224
&& Objects.equals(this.enablementExpression, that.enablementExpression)
226225
&& this.mode == that.mode;
@@ -268,8 +267,7 @@ private boolean isEnabledFor(ISelection sel) {
268267
if (classes.isEmpty()) {
269268
return true;
270269
}
271-
if (obj instanceof IAdaptable) {
272-
IAdaptable element = (IAdaptable) obj;
270+
if (obj instanceof IAdaptable element) {
273271
if (!verifyElement(element)) {
274272
return false;
275273
}
@@ -327,8 +325,7 @@ private boolean isEnabledFor(IStructuredSelection ssel) {
327325
return true;
328326
}
329327
for (Object obj : ssel) {
330-
if (obj instanceof IAdaptable) {
331-
IAdaptable element = (IAdaptable) obj;
328+
if (obj instanceof IAdaptable element) {
332329
if (!verifyElement(element)) {
333330
return false;
334331
}

bundles/org.eclipse.ui.workbench/eclipseui/org/eclipse/ui/SubActionBars.java

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ public final void collectExpressionInfo(final ExpressionInfo info) {
8888

8989
private SubMenuManager menuMgr;
9090

91-
private IActionBars parent;
91+
private final IActionBars parent;
9292

9393
/**
9494
* A service locator appropriate for this action bar. This value is never
@@ -100,7 +100,7 @@ public final void collectExpressionInfo(final ExpressionInfo info) {
100100

101101
private SubToolBarManager toolBarMgr;
102102

103-
private Map<String, String> actionIdByCommandId = new HashMap<>();
103+
private final Map<String, String> actionIdByCommandId = new HashMap<>();
104104

105105
/**
106106
* Construct a new <code>SubActionBars</code> object. The service locator will
@@ -514,8 +514,7 @@ public void setGlobalActionHandler(String actionID, IAction handler) {
514514
activationsByActionIdByServiceLocator.put(serviceLocator, activationsByActionId);
515515
} else if (activationsByActionId.containsKey(actionID)) {
516516
final Object value = activationsByActionId.remove(actionID);
517-
if (value instanceof IHandlerActivation) {
518-
final IHandlerActivation activation = (IHandlerActivation) value;
517+
if (value instanceof final IHandlerActivation activation) {
519518
actionIdByCommandId.remove(activation.getCommandId());
520519
if (service != null) {
521520
service.deactivateHandler(activation);
@@ -524,8 +523,7 @@ public void setGlobalActionHandler(String actionID, IAction handler) {
524523
}
525524
} else if (commandId != null && actionIdByCommandId.containsKey(commandId)) {
526525
final Object value = activationsByActionId.remove(actionIdByCommandId.remove(commandId));
527-
if (value instanceof IHandlerActivation) {
528-
final IHandlerActivation activation = (IHandlerActivation) value;
526+
if (value instanceof final IHandlerActivation activation) {
529527
if (service != null) {
530528
service.deactivateHandler(activation);
531529
}
@@ -566,8 +564,7 @@ public void setGlobalActionHandler(String actionID, IAction handler) {
566564
.get(serviceLocator);
567565
if ((activationsByActionId != null) && (activationsByActionId.containsKey(actionID))) {
568566
final Object value = activationsByActionId.remove(actionID);
569-
if (value instanceof IHandlerActivation) {
570-
final IHandlerActivation activation = (IHandlerActivation) value;
567+
if (value instanceof final IHandlerActivation activation) {
571568
actionIdByCommandId.remove(activation.getCommandId());
572569
service.deactivateHandler(activation);
573570
activation.getHandler().dispose();

0 commit comments

Comments
 (0)