Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
Original file line number Diff line number Diff line change
Expand Up @@ -194,12 +194,10 @@ void handleToBeRenderedEvent(@UIEventTopic(UIEvents.UIElement.TOPIC_TOBERENDERED
void handleLabelEvent(@UIEventTopic(UIEvents.UILabel.TOPIC_ALL) Event event) {

Object changedObj = event.getProperty(UIEvents.EventTags.ELEMENT);
if (!(changedObj instanceof MPerspective) || (ignoreEvent(changedObj))) {
if (!(changedObj instanceof MPerspective perspective) || (ignoreEvent(changedObj))) {
return;
}

MPerspective perspective = (MPerspective) changedObj;

if (!perspective.isToBeRendered())
{
return;
Expand All @@ -222,12 +220,10 @@ void handleLabelEvent(@UIEventTopic(UIEvents.UILabel.TOPIC_ALL) Event event) {
void handleSelectionEvent(@UIEventTopic(UIEvents.ElementContainer.TOPIC_SELECTEDELEMENT) Event event) {

Object changedObj = event.getProperty(UIEvents.EventTags.ELEMENT);
if (!(changedObj instanceof MPerspectiveStack) || (ignoreEvent(changedObj))) {
if (!(changedObj instanceof MPerspectiveStack perspStack) || (ignoreEvent(changedObj))) {
return;
}

MPerspectiveStack perspStack = (MPerspectiveStack) changedObj;

if (!perspStack.isToBeRendered()) {
return;
}
Expand Down Expand Up @@ -259,8 +255,7 @@ void createWidget(Composite parent, MToolControl toolControl) {
perspSwitcherToolControl = toolControl;
MUIElement meParent = perspSwitcherToolControl.getParent();
int orientation = SWT.HORIZONTAL;
if (meParent instanceof MTrimBar) {
MTrimBar bar = (MTrimBar) meParent;
if (meParent instanceof MTrimBar bar) {
if (bar.getSide() == SideValue.RIGHT || bar.getSide() == SideValue.LEFT) {
orientation = SWT.VERTICAL;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,7 @@ protected int computeHashCode() {

@Override
public boolean equals(final Object object) {
if (object instanceof ActiveShellExpression) {
final ActiveShellExpression that = (ActiveShellExpression) object;
if (object instanceof final ActiveShellExpression that) {
return equals(this.activeShell, that.activeShell);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,9 @@ public IAdaptable[] adaptElements(IWorkingSet ws, IAdaptable[] elements) {
List<IAdaptable> adaptedElements = new ArrayList<>();
for (IAdaptable element : elements) {
IAdaptable adaptable = adapt(element);
if (adaptable != null)
if (adaptable != null) {
adaptedElements.add(adaptable);
}
}

return adaptedElements.toArray(new IAdaptable[adaptedElements.size()]);
Expand All @@ -111,8 +112,9 @@ public IAdaptable[] adaptElements(IWorkingSet ws, IAdaptable[] elements) {
private IAdaptable adapt(IAdaptable adaptable) {
for (Type preferredType : preferredTypes) {
IAdaptable adaptedAdaptable = adapt(preferredType, adaptable);
if (adaptedAdaptable != null)
if (adaptedAdaptable != null) {
return adaptedAdaptable;
}
}
return null;
}
Expand All @@ -129,14 +131,16 @@ private IAdaptable adapt(Type type, IAdaptable adaptable) {
IAdapterManager adapterManager = Platform.getAdapterManager();
Class<?>[] directClasses = adapterManager.computeClassOrder(adaptable.getClass());
for (Class<?> clazz : directClasses) {
if (clazz.getName().equals(type.className))
if (clazz.getName().equals(type.className)) {
return adaptable;
}
}

if ((type.flags & Type.ADAPT) != 0) {
Object adapted = adapterManager.getAdapter(adaptable, type.className);
if (adapted instanceof IAdaptable)
if (adapted instanceof IAdaptable) {
return (IAdaptable) adapted;
}

PackageAdmin admin = getPackageAdmin();
if (admin != null) {
Expand All @@ -155,8 +159,9 @@ private IAdaptable adapt(Type type, IAdaptable adaptable) {
// object directly
adapted = adaptable
.getAdapter(packages[0].getExportingBundle().loadClass(type.className));
if (adapted instanceof IAdaptable)
if (adapted instanceof IAdaptable) {
return (IAdaptable) adapted;
}

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

@Override
public void dispose() {
if (packageTracker != null)
if (packageTracker != null) {
packageTracker.close();
}
}

@Override
Expand Down Expand Up @@ -200,9 +206,9 @@ public void setInitializationData(IConfigurationElement config, String propertyN
private void parseOptions(String classNameAndOptions, Type record) {
for (StringTokenizer toker = new StringTokenizer(classNameAndOptions, ";"); toker.hasMoreTokens();) { //$NON-NLS-1$
String token = toker.nextToken();
if (record.className == null)
if (record.className == null) {
record.className = token;
else {
} else {
for (StringTokenizer pair = new StringTokenizer(token, "="); pair.hasMoreTokens();) {//$NON-NLS-1$
if (pair.countTokens() == 2) {
String param = pair.nextToken();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,7 @@ protected int computeHashCode() {

@Override
public boolean equals(final Object object) {
if (object instanceof LegacyHandlerSubmissionExpression) {
final LegacyHandlerSubmissionExpression that = (LegacyHandlerSubmissionExpression) object;
if (object instanceof final LegacyHandlerSubmissionExpression that) {
return equals(this.activePartId, that.activePartId) && equals(this.activeShell, that.activeShell)
&& equals(this.activeSite, that.activeSite);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
*/
public class MultiPartInitException extends WorkbenchException {

private IWorkbenchPartReference[] references;
private PartInitException[] exceptions;
private final IWorkbenchPartReference[] references;
private final PartInitException[] exceptions;

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

private static int findFirstException(PartInitException[] exceptions) {
for (int i = 0; i < exceptions.length; i++) {
if (exceptions[i] != null)
if (exceptions[i] != null) {
return i;
}
}
throw new IllegalArgumentException();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
*/
public abstract class NavigationLocation implements INavigationLocation {

private IWorkbenchPage page;
private final IWorkbenchPage page;

private IEditorInput input;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
*/
public abstract class OpenAndLinkWithEditorHelper {

private StructuredViewer viewer;
private final StructuredViewer viewer;

private boolean isLinkingEnabled;

Expand All @@ -51,15 +51,17 @@ public void open(OpenEvent event) {
@Override
public void selectionChanged(SelectionChangedEvent event) {
final ISelection selection = event.getSelection();
if (isLinkingEnabled && !selection.equals(lastOpenSelection) && viewer.getControl().isFocusControl())
if (isLinkingEnabled && !selection.equals(lastOpenSelection) && viewer.getControl().isFocusControl()) {
linkToEditor(selection);
}
lastOpenSelection = null;
}

@Override
public void doubleClick(DoubleClickEvent event) {
if (!OpenStrategy.activateOnOpen())
if (!OpenStrategy.activateOnOpen()) {
activate(event.getSelection());
}
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,11 @@ public class SaveablesLifecycleEvent extends EventObject {
*/
public static final int DIRTY_CHANGED = 4;

private int eventType;
private final int eventType;

private Saveable[] saveables;
private final Saveable[] saveables;

private boolean force;
private final boolean force;

private boolean veto = false;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -219,8 +219,7 @@ public SelectionEnabler(IConfigurationElement configElement) {

@Override
public boolean equals(final Object object) {
if (object instanceof SelectionEnabler) {
final SelectionEnabler that = (SelectionEnabler) object;
if (object instanceof final SelectionEnabler that) {
return Objects.equals(this.classes, that.classes)
&& Objects.equals(this.enablementExpression, that.enablementExpression)
&& this.mode == that.mode;
Expand Down Expand Up @@ -268,8 +267,7 @@ private boolean isEnabledFor(ISelection sel) {
if (classes.isEmpty()) {
return true;
}
if (obj instanceof IAdaptable) {
IAdaptable element = (IAdaptable) obj;
if (obj instanceof IAdaptable element) {
if (!verifyElement(element)) {
return false;
}
Expand Down Expand Up @@ -327,8 +325,7 @@ private boolean isEnabledFor(IStructuredSelection ssel) {
return true;
}
for (Object obj : ssel) {
if (obj instanceof IAdaptable) {
IAdaptable element = (IAdaptable) obj;
if (obj instanceof IAdaptable element) {
if (!verifyElement(element)) {
return false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ public final void collectExpressionInfo(final ExpressionInfo info) {

private SubMenuManager menuMgr;

private IActionBars parent;
private final IActionBars parent;

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

private SubToolBarManager toolBarMgr;

private Map<String, String> actionIdByCommandId = new HashMap<>();
private final Map<String, String> actionIdByCommandId = new HashMap<>();

/**
* Construct a new <code>SubActionBars</code> object. The service locator will
Expand Down Expand Up @@ -514,8 +514,7 @@ public void setGlobalActionHandler(String actionID, IAction handler) {
activationsByActionIdByServiceLocator.put(serviceLocator, activationsByActionId);
} else if (activationsByActionId.containsKey(actionID)) {
final Object value = activationsByActionId.remove(actionID);
if (value instanceof IHandlerActivation) {
final IHandlerActivation activation = (IHandlerActivation) value;
if (value instanceof final IHandlerActivation activation) {
actionIdByCommandId.remove(activation.getCommandId());
if (service != null) {
service.deactivateHandler(activation);
Expand All @@ -524,8 +523,7 @@ public void setGlobalActionHandler(String actionID, IAction handler) {
}
} else if (commandId != null && actionIdByCommandId.containsKey(commandId)) {
final Object value = activationsByActionId.remove(actionIdByCommandId.remove(commandId));
if (value instanceof IHandlerActivation) {
final IHandlerActivation activation = (IHandlerActivation) value;
if (value instanceof final IHandlerActivation activation) {
if (service != null) {
service.deactivateHandler(activation);
}
Expand Down Expand Up @@ -566,8 +564,7 @@ public void setGlobalActionHandler(String actionID, IAction handler) {
.get(serviceLocator);
if ((activationsByActionId != null) && (activationsByActionId.containsKey(actionID))) {
final Object value = activationsByActionId.remove(actionID);
if (value instanceof IHandlerActivation) {
final IHandlerActivation activation = (IHandlerActivation) value;
if (value instanceof final IHandlerActivation activation) {
actionIdByCommandId.remove(activation.getCommandId());
service.deactivateHandler(activation);
activation.getHandler().dispose();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public class WorkbenchEncoding {

private static class EncodingsRegistryReader extends RegistryReader {

private List<String> encodings;
private final List<String> encodings;
/**
* Create a new instance of the receiver.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -242,8 +242,7 @@ public IMemento getChild(String type) {
// Find the first node which is a child of this node.
for (int nX = 0; nX < size; nX++) {
Node node = nodes.item(nX);
if (node instanceof Element) {
Element element = (Element) node;
if (node instanceof Element element) {
if (element.getNodeName().equals(type)) {
return new XMLMemento(factory, element);
}
Expand All @@ -268,8 +267,9 @@ public IMemento[] getChildren() {
ArrayList<Element> list = new ArrayList<>(size);
for (int nX = 0; nX < size; nX++) {
final Node node = nodes.item(nX);
if (node instanceof Element)
if (node instanceof Element) {
list.add((Element) node);
}
}

// Create a memento for each node.
Expand All @@ -295,8 +295,7 @@ public IMemento[] getChildren(String type) {
ArrayList<Element> list = new ArrayList<>(size);
for (int nX = 0; nX < size; nX++) {
Node node = nodes.item(nX);
if (node instanceof Element) {
Element element = (Element) node;
if (node instanceof Element element) {
if (element.getNodeName().equals(type)) {
list.add(element);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
*/
public abstract class CompoundContributionItem extends ContributionItem {

private IMenuListener menuListener = IMenuManager::markDirty;
private final IMenuListener menuListener = IMenuManager::markDirty;

private IContributionItem[] oldItems;

Expand Down Expand Up @@ -109,8 +109,7 @@ public void setParent(IContributionManager parent) {
IMenuManager menuMgr = (IMenuManager) getParent();
menuMgr.removeMenuListener(menuListener);
}
if (parent instanceof IMenuManager) {
IMenuManager menuMgr = (IMenuManager) parent;
if (parent instanceof IMenuManager menuMgr) {
menuMgr.addMenuListener(menuListener);
}
super.setParent(parent);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ public class NewWizardAction extends Action implements ActionFactory.IWorkbenchA
/**
* Tracks perspective activation, to update this action's enabled state.
*/
private PerspectiveTracker tracker;
private final PerspectiveTracker tracker;

/**
* Create a new instance of this class.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,13 @@ public class NewWizardDropDownAction extends Action implements ActionFactory.IWo
/**
* Tracks perspective activation, to update this action's enabled state.
*/
private PerspectiveTracker tracker;
private final PerspectiveTracker tracker;

private ActionFactory.IWorkbenchAction showDlgAction;
private final ActionFactory.IWorkbenchAction showDlgAction;

private IContributionItem newWizardMenu;
private final IContributionItem newWizardMenu;

private IMenuCreator menuCreator = new IMenuCreator() {
private final IMenuCreator menuCreator = new IMenuCreator() {

private MenuManager dropDownMenuMgr;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,6 @@ public String getLocalId() {

@Override
public String getPluginId() {
return descriptor instanceof IPluginContribution ? ((IPluginContribution) descriptor).getPluginId() : null;
return descriptor instanceof IPluginContribution i ? i.getPluginId() : null;
}
}
Loading
Loading