Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix generics warnings #450

Merged
merged 1 commit into from
Feb 5, 2025
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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*******************************************************************************
* Copyright (c) 2015, 2023 Red Hat Inc. and others.
*
* Copyright (c) 2015, 2025 Red Hat Inc. and others.
*
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
* which is available at https://www.eclipse.org/legal/epl-2.0/
Expand All @@ -22,7 +22,7 @@
import org.eclipse.core.databinding.DataBindingContext;
import org.eclipse.core.databinding.beans.typed.BeanProperties;
import org.eclipse.core.databinding.observable.value.IObservableValue;
import org.eclipse.core.databinding.observable.value.IValueChangeListener;
import org.eclipse.core.databinding.observable.value.ValueChangeEvent;
import org.eclipse.core.databinding.validation.IValidator;
import org.eclipse.core.databinding.validation.ValidationStatus;
import org.eclipse.core.runtime.CoreException;
Expand Down Expand Up @@ -124,13 +124,13 @@ public void createControl(Composite parent) {
ImageRunSelectionModel.SELECTED_CONNECTION_NAME)
.observe(model);
connectionSelectionObservable
.addValueChangeListener(onConnectionSelectionChange());
.addValueChangeListener(this::connectionSelectionChange);
final IObservableValue imageSelectionObservable = BeanProperties
.value(ImageRunSelectionModel.class,
ImageRunSelectionModel.SELECTED_IMAGE_NAME)
.observe(model);
imageSelectionObservable
.addValueChangeListener(onImageSelectionChange());
.addValueChangeListener(this::imageSelectionChange);
}
setControl(container);
}
Expand Down Expand Up @@ -316,40 +316,36 @@ private IContentProposalProvider getImageNameContentProposalProvider(
};
}

private IValueChangeListener onImageSelectionChange() {
return event -> {
final IDockerImage selectedImage = model.getSelectedImage();
// skip if the selected image does not exist in the local Docker
// host
if (selectedImage == null) {
model.setExposedPorts(new ArrayList<>());
return;
}
findImageInfo(selectedImage);
volumesModel.setSelectedImage(selectedImage);
};
private void imageSelectionChange(@SuppressWarnings("unused") ValueChangeEvent<?> e) {
final IDockerImage selectedImage = model.getSelectedImage();
// skip if the selected image does not exist in the local Docker
// host
if (selectedImage == null) {
model.setExposedPorts(new ArrayList<>());
return;
}
findImageInfo(selectedImage);
volumesModel.setSelectedImage(selectedImage);
}

private IValueChangeListener onConnectionSelectionChange() {
return event -> {
// do this first as we might return and not reset connection
networkModel.setConnection(model.getSelectedConnection());
IDockerImage selectedImage = model.getSelectedImage();
// skip if the selected image does not exist in the local Docker
// host
if (selectedImage == null) {
List<String> imageNames = model.getImageNames();
if (imageNames.size() > 0) {
model.setSelectedImageName(imageNames.get(0));
selectedImage = model.getSelectedImage();
} else {
model.setExposedPorts(new ArrayList<>());
return;
}
private void connectionSelectionChange(ValueChangeEvent<?> e) {
// do this first as we might return and not reset connection
networkModel.setConnection(model.getSelectedConnection());
IDockerImage selectedImage = model.getSelectedImage();
// skip if the selected image does not exist in the local Docker
// host
if (selectedImage == null) {
List<String> imageNames = model.getImageNames();
if (imageNames.size() > 0) {
model.setSelectedImageName(imageNames.get(0));
selectedImage = model.getSelectedImage();
} else {
model.setExposedPorts(new ArrayList<>());
return;
}
findImageInfo(selectedImage);
volumesModel.setSelectedImage(selectedImage);
};
}
findImageInfo(selectedImage);
volumesModel.setSelectedImage(selectedImage);
}

private static final class FindImageInfoRunnable
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*******************************************************************************
* Copyright (c) 2017, 2019 Red Hat Inc. and others.
*
* Copyright (c) 2017, 2025 Red Hat Inc. and others.
*
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
* which is available at https://www.eclipse.org/legal/epl-2.0/
Expand Down Expand Up @@ -215,7 +215,7 @@ private void setOtherControl(Control containerControl) {
private Binding bindButton(final Button button, final String strValue) {
return dbc.bindValue(WidgetProperties.widgetSelection().observe(button),
BeanProperties.value(ImageRunNetworkModel.class, ImageRunNetworkModel.NETWORK_MODE).observe(model),
new UpdateValueStrategy() {
new UpdateValueStrategy<>() {
@Override
public Object convert(Object value) {
if (value.equals(Boolean.TRUE)) {
Expand All @@ -224,7 +224,7 @@ public Object convert(Object value) {
return null;
}

}, new UpdateValueStrategy() {
}, new UpdateValueStrategy<>() {
@Override
public Object convert(final Object value) {
return value.equals(strValue);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*******************************************************************************
* Copyright (c) 2015, 2019 Red Hat Inc. and others.
*
* Copyright (c) 2015, 2025 Red Hat Inc. and others.
*
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
* which is available at https://www.eclipse.org/legal/epl-2.0/
Expand Down Expand Up @@ -201,7 +201,7 @@ private Composite getContainer() {
/**
* Binds the given <code>cpuShares</code> value to the given {@link Button}
* when it is selected.
*
*
* @param button
* the {@link Button} to bind
* @param cpuShares
Expand All @@ -214,7 +214,7 @@ private Binding bindButton(final Button button, final long cpuShares) {
.value(ImageRunResourceVolumesVariablesModel.class,
ImageRunResourceVolumesVariablesModel.CPU_SHARE_WEIGHT)
.observe(model),
new UpdateValueStrategy() {
new UpdateValueStrategy<>() {
@Override
public Object convert(Object value) {
if (value.equals(Boolean.TRUE)) {
Expand All @@ -223,7 +223,7 @@ public Object convert(Object value) {
return 0l;
}

}, new UpdateValueStrategy() {
}, new UpdateValueStrategy<>() {
@Override
public Object convert(final Object value) {
return value.equals(cpuShares);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2015, 2023 Red Hat Inc. and others.
* Copyright (c) 2015, 2025 Red Hat Inc. and others.
*
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
Expand Down Expand Up @@ -205,7 +205,7 @@ private ICheckStateListener onCheckStateChanged() {
private void bind(final StructuredViewer viewer,
final IObservableList input,
final IBeanValueProperty[] labelProperties) {
final ObservableListContentProvider contentProvider = new ObservableListContentProvider();
final ObservableListContentProvider contentProvider = new ObservableListContentProvider<>();
if (viewer.getInput() != null) {
viewer.setInput(null);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2015, 2020 Red Hat Inc. and others.
* Copyright (c) 2015, 2025 Red Hat Inc. and others.
*
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
Expand Down Expand Up @@ -310,7 +310,7 @@ private Binding bindButton(final Button button, final MountType mountType,
return dbc.bindValue(WidgetProperties.widgetSelection().observe(button),
BeanProperties.value(DataVolumeModel.class,
DataVolumeModel.MOUNT_TYPE).observe(model),
new UpdateValueStrategy() {
new UpdateValueStrategy<>() {
@Override
public Object convert(Object value) {
if (value.equals(Boolean.TRUE)) {
Expand All @@ -327,7 +327,7 @@ private void setEnabled(final Control[] controls,
control.setEnabled(enabled);
}
}
}, new UpdateValueStrategy() {
}, new UpdateValueStrategy<>() {
@Override
public Object convert(final Object value) {
if (mountType.equals(value)) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*******************************************************************************
* Copyright (c) 2015, 2018 Red Hat Inc. and others.
*
* Copyright (c) 2015, 2025 Red Hat Inc. and others.
*
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
* which is available at https://www.eclipse.org/legal/epl-2.0/
Expand All @@ -15,7 +15,7 @@

import org.eclipse.core.databinding.DataBindingContext;
import org.eclipse.core.databinding.beans.typed.BeanProperties;
import org.eclipse.core.databinding.observable.value.IValueChangeListener;
import org.eclipse.core.databinding.observable.value.ValueChangeEvent;
import org.eclipse.jface.databinding.swt.ISWTObservableValue;
import org.eclipse.jface.databinding.swt.typed.WidgetProperties;
import org.eclipse.jface.dialogs.Dialog;
Expand Down Expand Up @@ -122,17 +122,13 @@ protected Control createDialogArea(Composite parent) {
EnvironmentVariableModel.VALUE).observe(model));

variableNameObservable
.addValueChangeListener(onEnvironmentVariableSettingsChanged());
.addValueChangeListener(this::validateInput);
variableValueObservable
.addValueChangeListener(onEnvironmentVariableSettingsChanged());
.addValueChangeListener(this::validateInput);
return container;
}

private IValueChangeListener onEnvironmentVariableSettingsChanged() {
return event -> validateInput();
}

private void validateInput() {
private void validateInput(@SuppressWarnings("unused") ValueChangeEvent<?> event) {
final String variableName = model.getName();
final String variableValue = model.getValue();
if (variableName == null || variableName.isEmpty()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*******************************************************************************
* Copyright (c) 2015, 2018 Red Hat Inc. and others.
*
* Copyright (c) 2015, 2025 Red Hat Inc. and others.
*
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
* which is available at https://www.eclipse.org/legal/epl-2.0/
Expand All @@ -15,7 +15,7 @@

import org.eclipse.core.databinding.DataBindingContext;
import org.eclipse.core.databinding.beans.typed.BeanProperties;
import org.eclipse.core.databinding.observable.value.IValueChangeListener;
import org.eclipse.core.databinding.observable.value.ValueChangeEvent;
import org.eclipse.jface.databinding.swt.ISWTObservableValue;
import org.eclipse.jface.databinding.swt.typed.WidgetProperties;
import org.eclipse.jface.dialogs.Dialog;
Expand Down Expand Up @@ -122,17 +122,13 @@ protected Control createDialogArea(Composite parent) {
LabelVariableModel.VALUE).observe(model));

variableNameObservable
.addValueChangeListener(onLabelVariableSettingsChanged());
.addValueChangeListener(this::validateInput);
variableValueObservable
.addValueChangeListener(onLabelVariableSettingsChanged());
.addValueChangeListener(this::validateInput);
return container;
}

private IValueChangeListener onLabelVariableSettingsChanged() {
return event -> validateInput();
}

private void validateInput() {
private void validateInput(@SuppressWarnings("unused") ValueChangeEvent<?> event) {
final String variableName = model.getName();
if (variableName == null || variableName.isEmpty()) {
} else {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*******************************************************************************
* Copyright (c) 2015, 2019 Red Hat Inc. and others.
*
* Copyright (c) 2015, 2025 Red Hat Inc. and others.
*
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
* which is available at https://www.eclipse.org/legal/epl-2.0/
Expand All @@ -19,7 +19,7 @@

import org.eclipse.core.databinding.DataBindingContext;
import org.eclipse.core.databinding.beans.typed.BeanProperties;
import org.eclipse.core.databinding.observable.value.IValueChangeListener;
import org.eclipse.core.databinding.observable.value.ValueChangeEvent;
import org.eclipse.jface.databinding.swt.ISWTObservableValue;
import org.eclipse.jface.databinding.swt.typed.WidgetProperties;
import org.eclipse.jface.dialogs.Dialog;
Expand Down Expand Up @@ -167,15 +167,11 @@ public void insertControlContents(Control control,

dbc.bindValue(containerAliasObservable, BeanProperties
.value(ContainerLinkDialogModel.class, ContainerLinkDialogModel.CONTAINER_ALIAS).observe(model));
containerNameObservable.addValueChangeListener(onContainerLinkSettingsChanged());
containerAliasObservable.addValueChangeListener(onContainerLinkSettingsChanged());
containerNameObservable.addValueChangeListener(this::validateInput);
containerAliasObservable.addValueChangeListener(this::validateInput);
return container;
}

private IValueChangeListener onContainerLinkSettingsChanged() {
return event -> validateInput();
}

public String getContainerName() {
return model.getContainerName();
}
Expand All @@ -187,7 +183,7 @@ public String getContainerAlias() {
/**
* Creates an {@link IContentProposalProvider} to propose
* {@link IDockerContainer} names based on the current text.
*
*
* @param items
* @return
*/
Expand All @@ -205,7 +201,7 @@ private IContentProposalProvider getContainerNameContentProposalProvider(
};
}

private void validateInput() {
private void validateInput(@SuppressWarnings("unused") ValueChangeEvent<?> e) {
final String selectedContainerName = model.getContainerName();
final Object[] containerNames = model.getContainerNames().toArray();
final String containerAlias = model.getContainerAlias();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*******************************************************************************
* Copyright (c) 2015, 2018 Red Hat Inc. and others.
*
* Copyright (c) 2015, 2025 Red Hat Inc. and others.
*
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
* which is available at https://www.eclipse.org/legal/epl-2.0/
Expand All @@ -15,7 +15,7 @@

import org.eclipse.core.databinding.DataBindingContext;
import org.eclipse.core.databinding.beans.typed.BeanProperties;
import org.eclipse.core.databinding.observable.value.IValueChangeListener;
import org.eclipse.core.databinding.observable.value.ValueChangeEvent;
import org.eclipse.jface.databinding.swt.ISWTObservableValue;
import org.eclipse.jface.databinding.swt.typed.WidgetProperties;
import org.eclipse.jface.dialogs.Dialog;
Expand Down Expand Up @@ -147,17 +147,13 @@ protected Control createDialogArea(Composite parent) {
dbc.bindValue(hostPortObservable, BeanProperties
.value(ContainerPortDialogModel.class, ContainerPortDialogModel.HOST_PORT).observe(model));

containerPortObservable.addValueChangeListener(onContainerPortSettingsChanged());
hostPortObservable.addValueChangeListener(onContainerPortSettingsChanged());
hostAddressObservable.addValueChangeListener(onContainerPortSettingsChanged());
containerPortObservable.addValueChangeListener(this::validateInput);
hostPortObservable.addValueChangeListener(this::validateInput);
hostAddressObservable.addValueChangeListener(this::validateInput);
return container;
}

private IValueChangeListener onContainerPortSettingsChanged() {
return event -> validateInput();
}

private void validateInput() {
private void validateInput(@SuppressWarnings("unused") ValueChangeEvent<?> e) {
final String containerPort = model.getContainerPort();
if (containerPort == null || containerPort.isEmpty()) {
setOkButtonEnabled(false);
Expand Down
Loading