Skip to content
Open
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,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2011 Google, Inc.
* Copyright (c) 2011, 2026 Google, 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
Expand Down Expand Up @@ -39,7 +39,10 @@
*
* @author scheglov_ke
* @coverage core.control
* @Deprecated Use the native {@link Spinner} directly. This class will be
* removed after the 2028-03 release.
*/
@Deprecated(since = "2026-03", forRemoval = true)
public class CSpinner extends Composite {
private static final Color COLOR_VALID = Display.getCurrent().getSystemColor(
SWT.COLOR_LIST_BACKGROUND);
Expand All @@ -66,6 +69,7 @@ public class CSpinner extends Composite {
// Constructor
//
////////////////////////////////////////////////////////////////////////////
@Deprecated
public CSpinner(Composite parent, int style) {
super(parent, style);
m_button = new Button(this, SWT.ARROW | SWT.DOWN);
Expand Down Expand Up @@ -165,6 +169,7 @@ public void widgetSelected(SelectionEvent e) {
// Access
//
////////////////////////////////////////////////////////////////////////////
@Deprecated
@Override
public void setEnabled(boolean enabled) {
super.setEnabled(enabled);
Expand All @@ -177,6 +182,7 @@ public void setEnabled(boolean enabled) {
* <p>
* See {@link Spinner#setDigits(int)}.
*/
@Deprecated
public void setDigits(int digits) {
m_formatPattern = "0.";
m_multiplier = 1;
Expand All @@ -191,6 +197,7 @@ public void setDigits(int digits) {
/**
* Sets minimum and maximum using single invocation.
*/
@Deprecated
public void setRange(int minimum, int maximum) {
setMinimum(minimum);
setMaximum(maximum);
Expand All @@ -199,13 +206,15 @@ public void setRange(int minimum, int maximum) {
/**
* @return the minimum value that the receiver will allow.
*/
@Deprecated
public int getMinimum() {
return m_minimum;
}

/**
* Sets the minimum value that the receiver will allow.
*/
@Deprecated
public void setMinimum(int minimum) {
m_minimum = minimum;
setSelection(Math.max(m_value, m_minimum));
Expand All @@ -214,6 +223,7 @@ public void setMinimum(int minimum) {
/**
* Sets the maximum value that the receiver will allow.
*/
@Deprecated
public void setMaximum(int maximum) {
m_maximum = maximum;
setSelection(Math.min(m_value, m_maximum));
Expand All @@ -223,6 +233,7 @@ public void setMaximum(int maximum) {
* Sets the amount that the receiver's value will be modified by when the up/down arrows are
* pressed to the argument, which must be at least one.
*/
@Deprecated
public void setIncrement(int increment) {
m_increment = increment;
}
Expand All @@ -232,6 +243,7 @@ public void setIncrement(int increment) {
* not within the range specified by minimum and maximum, it will be adjusted to fall within this
* range.
*/
@Deprecated
public void setSelection(int newValue) {
newValue = Math.min(Math.max(m_minimum, newValue), m_maximum);
if (newValue != m_value || m_text.getText().length() == 0) {
Expand All @@ -251,6 +263,7 @@ private void updateText() {
/**
* @return the <em>selection</em>, which is the receiver's position.
*/
@Deprecated
public int getSelection() {
return m_value;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2011 Google, Inc.
* Copyright (c) 2011, 2026 Google, 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
Expand All @@ -13,8 +13,6 @@
package org.eclipse.wb.core.controls;

import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Listener;

/**
Expand All @@ -23,52 +21,14 @@
* @author scheglov_ke
* @author lobas_av
* @coverage core.control
* @deprecated Use {@link SpinnerDeferredNotifier} instead. This class will be
* removed after the 2028-03 release.
*/
public final class CSpinnerDeferredNotifier {
private final CSpinner m_spinner;
private final Display m_display;
private final int m_timeout;
private final Listener m_listener;
@Deprecated(since = "2026-03", forRemoval = true)
public final class CSpinnerDeferredNotifier extends SpinnerDeferredNotifier {

////////////////////////////////////////////////////////////////////////////
//
// Constructor
//
////////////////////////////////////////////////////////////////////////////
public CSpinnerDeferredNotifier(CSpinner spinner, int timeout, Listener listener) {
m_spinner = spinner;
m_display = m_spinner.getDisplay();
m_timeout = timeout;
m_listener = listener;
addListener();
}

////////////////////////////////////////////////////////////////////////////
//
// Listener
//
////////////////////////////////////////////////////////////////////////////
private final int[] m_eventId = new int[1];

/**
* Handler for single {@link SWT#Selection} event.
*/
private void addListener() {
m_spinner.addListener(SWT.Selection, new Listener() {
@Override
public void handleEvent(final Event event) {
m_eventId[0]++;
m_display.timerExec(m_timeout, new Runnable() {
int m_id = m_eventId[0];

@Override
public void run() {
if (m_id == m_eventId[0]) {
m_listener.handleEvent(event);
}
}
});
}
});
@Deprecated
public CSpinnerDeferredNotifier(@SuppressWarnings("removal") CSpinner spinner, int timeout, Listener listener) {
super(spinner, timeout, listener);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
/*******************************************************************************
* Copyright (c) 2011, 2026 Google, 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.
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Google, Inc. - initial API and implementation
*******************************************************************************/
package org.eclipse.wb.core.controls;

import org.eclipse.swt.SWT;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Listener;
import org.eclipse.swt.widgets.Spinner;

/**
* Helper for sending single {@link SWT#Selection} event after some timeout.
*
* @author scheglov_ke
* @author lobas_av
* @coverage core.control
*/
@SuppressWarnings("removal")
public sealed class SpinnerDeferredNotifier permits CSpinnerDeferredNotifier {
private final Control m_spinner;
private final Display m_display;
private final int m_timeout;
private final Listener m_listener;

////////////////////////////////////////////////////////////////////////////
//
// Constructor
//
////////////////////////////////////////////////////////////////////////////
public SpinnerDeferredNotifier(Spinner spinner, int timeout, Listener listener) {
m_spinner = spinner;
m_display = m_spinner.getDisplay();
m_timeout = timeout;
m_listener = listener;
addListener();
}

/* package */ SpinnerDeferredNotifier(CSpinner spinner, int timeout, Listener listener) {
m_spinner = spinner;
m_display = m_spinner.getDisplay();
m_timeout = timeout;
m_listener = listener;
addListener();
}

////////////////////////////////////////////////////////////////////////////
//
// Listener
//
////////////////////////////////////////////////////////////////////////////
private final int[] m_eventId = new int[1];

/**
* Handler for single {@link SWT#Selection} event.
*/
private void addListener() {
m_spinner.addListener(SWT.Selection, new Listener() {
@Override
public void handleEvent(final Event event) {
m_eventId[0]++;
m_display.timerExec(m_timeout, new Runnable() {
int m_id = m_eventId[0];

@Override
public void run() {
if (m_id == m_eventId[0]) {
m_listener.handleEvent(event);
}
}
});
}
});
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2011 Google, Inc.
* Copyright (c) 2011, 2026 Google, 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
Expand Down Expand Up @@ -34,10 +34,14 @@
*
* @author scheglov_ke
* @coverage core.test
* @deprecated Obsolete. This class will be removed after the 2028-03 release.
*/
@Deprecated(since = "2026-03", forRemoval = true)
public class CSpinnerTest {
@Deprecated
protected Shell shell;

@Deprecated
public static void main(String[] args) {
try {
CSpinnerTest window = new CSpinnerTest();
Expand All @@ -47,6 +51,7 @@ public static void main(String[] args) {
}
}

@Deprecated
public void open() {
final Display display = Display.getDefault();
createContents();
Expand All @@ -59,6 +64,8 @@ public void open() {
}
}

@Deprecated
@SuppressWarnings("removal")
protected void createContents() {
shell = new Shell();
shell.setSize(500, 375);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2011, 2025 Google, Inc. and others.
* Copyright (c) 2011, 2026 Google, 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
Expand All @@ -12,8 +12,7 @@
*******************************************************************************/
package org.eclipse.wb.core.editor.actions.assistant;

import org.eclipse.wb.core.controls.CSpinner;
import org.eclipse.wb.core.controls.CSpinnerDeferredNotifier;
import org.eclipse.wb.core.controls.SpinnerDeferredNotifier;
import org.eclipse.wb.core.model.ObjectInfo;
import org.eclipse.wb.internal.core.DesignerPlugin;
import org.eclipse.wb.internal.core.model.property.Property;
Expand All @@ -35,6 +34,7 @@
import org.eclipse.swt.widgets.Group;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Listener;
import org.eclipse.swt.widgets.Spinner;
import org.eclipse.swt.widgets.Text;

import org.apache.commons.lang3.StringUtils;
Expand Down Expand Up @@ -735,7 +735,7 @@ protected final Group addStaticFieldsProperty(Composite parent,
* Adapter for <code>int</code> property.
*/
private final class IntegerPropertyInfo extends PropertyInfo {
private final CSpinner m_spinner;
private final Spinner m_spinner;
private final Listener m_listener = new Listener() {
@Override
public void handleEvent(Event event) {
Expand All @@ -750,10 +750,10 @@ public void handleEvent(Event event) {
// Constructor
//
////////////////////////////////////////////////////////////////////////////
public IntegerPropertyInfo(String property, CSpinner spinner) {
public IntegerPropertyInfo(String property, Spinner spinner) {
super(property);
m_spinner = spinner;
new CSpinnerDeferredNotifier(m_spinner, 500, m_listener);
new SpinnerDeferredNotifier(m_spinner, 500, m_listener);
}

////////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -787,7 +787,7 @@ protected final void addIntegerProperty(Composite parent,
int maxValue) {
new Label(parent, SWT.NONE).setText(title);
//
CSpinner spinner = new CSpinner(parent, SWT.BORDER);
Spinner spinner = new Spinner(parent, SWT.BORDER);
GridDataFactory.create(spinner).hintHC(10);
spinner.setMinimum(minValue);
spinner.setMaximum(maxValue);
Expand Down Expand Up @@ -873,7 +873,7 @@ protected final Group addIntegerProperties(Composite parent,
* Adapter for <code>double</code> property.
*/
private final class DoublePropertyInfo extends PropertyInfo {
private final CSpinner m_spinner;
private final Spinner m_spinner;
private final double m_multiplier;
private final Listener m_listener = new Listener() {
@Override
Expand All @@ -889,11 +889,11 @@ public void handleEvent(Event event) {
// Constructor
//
////////////////////////////////////////////////////////////////////////////
public DoublePropertyInfo(String property, CSpinner spinner, double multiplier) {
public DoublePropertyInfo(String property, Spinner spinner, double multiplier) {
super(property);
m_spinner = spinner;
m_multiplier = multiplier;
new CSpinnerDeferredNotifier(m_spinner, 500, m_listener);
new SpinnerDeferredNotifier(m_spinner, 500, m_listener);
}

////////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -929,7 +929,7 @@ protected final void addDoubleProperty(Composite parent,
int multiplier = (int) Math.pow(10, digits);
new Label(parent, SWT.NONE).setText(title);
//
CSpinner spinner = new CSpinner(parent, SWT.BORDER);
Spinner spinner = new Spinner(parent, SWT.BORDER);
GridDataFactory.create(spinner).hintHC(10);
spinner.setMinimum((int) (minValue * multiplier));
spinner.setMaximum((int) (maxValue * multiplier));
Expand Down
Loading
Loading