Skip to content

Commit 647256d

Browse files
ptzieglerakurtakov
authored andcommitted
Use varargs in FilteredList and AbstractElementListSelectionDialog
This adapts the signature of the following methods to accept a vararg parameter instead of a plain array: FilteredList: - setElements(Object[]) -> setElements(Object...) - setSelection(int[]) -> setSelection(int...) - setSelection(Object[]) -> setSelection(Object...) AbstractElementListSelectionDialog: - setListElements(Object[]) -> setListElements(Object...) - setSelection(Object[]) -> setSelection(Object...) This stops callers from having to explicitly create an array when e.g. selecting a single element. For example `filteredList.setSelection(new int[]{0})` can be simplified to `filteredList.setSelection(0)`.
1 parent 128b1f3 commit 647256d

2 files changed

Lines changed: 7 additions & 7 deletions

File tree

bundles/org.eclipse.ui.workbench/eclipseui/org/eclipse/ui/dialogs/AbstractElementListSelectionDialog.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*******************************************************************************
2-
* Copyright (c) 2000, 2015 IBM Corporation and others.
2+
* Copyright (c) 2000, 2026 IBM Corporation and others.
33
*
44
* This program and the accompanying materials
55
* are made available under the terms of the Eclipse Public License 2.0
@@ -186,7 +186,7 @@ public void setValidator(ISelectionStatusValidator validator) {
186186
*
187187
* @param elements the elements of the list.
188188
*/
189-
protected void setListElements(Object[] elements) {
189+
protected void setListElements(Object... elements) {
190190
Assert.isNotNull(fFilteredList);
191191
fFilteredList.setElements(elements);
192192
handleElementsChanged();
@@ -263,7 +263,7 @@ protected int getSelectionIndex() {
263263
*
264264
* @param selection the indices of the selection.
265265
*/
266-
protected void setSelection(Object[] selection) {
266+
protected void setSelection(Object... selection) {
267267
Assert.isNotNull(fFilteredList);
268268
fFilteredList.setSelection(selection);
269269
}

bundles/org.eclipse.ui.workbench/eclipseui/org/eclipse/ui/dialogs/FilteredList.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*******************************************************************************
2-
* Copyright (c) 2000, 2015 IBM Corporation and others.
2+
* Copyright (c) 2000, 2026 IBM Corporation and others.
33
*
44
* This program and the accompanying materials
55
* are made available under the terms of the Eclipse Public License 2.0
@@ -246,7 +246,7 @@ public FilteredList(Composite parent, int style, ILabelProvider labelProvider, b
246246
*
247247
* @param elements the elements to be shown in the list.
248248
*/
249-
public void setElements(Object[] elements) {
249+
public void setElements(Object... elements) {
250250
if (elements == null) {
251251
fElements = new Object[0];
252252
} else {
@@ -326,7 +326,7 @@ public void removeSelectionListener(SelectionListener listener) {
326326
*
327327
* @param selection an array of indices specifying the selection.
328328
*/
329-
public void setSelection(int[] selection) {
329+
public void setSelection(int... selection) {
330330
if (selection == null || selection.length == 0) {
331331
fList.deselectAll();
332332
} else // If there is no working update job, or the update job is ready to
@@ -365,7 +365,7 @@ public int getSelectionIndex() {
365365
*
366366
* @param elements the array of elements to be selected.
367367
*/
368-
public void setSelection(Object[] elements) {
368+
public void setSelection(Object... elements) {
369369
if (elements == null || elements.length == 0) {
370370
fList.deselectAll();
371371
return;

0 commit comments

Comments
 (0)