Skip to content

Commit ef87232

Browse files
ptzieglerazoitl
authored andcommitted
Deprecate createFlyoutPreferences(Preferences) for removal
The Preferences class has been deprecated since forever with the IEclipsePreferences as its replacement. Instances of this type can be used via the ScopedPreferenceStore, but other implementations are also permitted.
1 parent 3c8c9e7 commit ef87232

File tree

3 files changed

+34
-12
lines changed

3 files changed

+34
-12
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222
## GEF
2323

2424
- When used with SWT 3.130.0 or newer, the `org.eclipse.swt.svg` bundle (or similar) is required.
25+
- FlyoutPaletteComposite: createFlyoutPreferences(Preferences) has been marked for removal.
26+
Please use createFlyoutPreferences(IPreferenceStore) instead.
2527

2628
## Zest
2729

org.eclipse.gef/src/org/eclipse/gef/ui/palette/FlyoutPaletteComposite.java

Lines changed: 31 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*******************************************************************************
2-
* Copyright (c) 2004, 2024 IBM Corporation and others.
2+
* Copyright (c) 2004, 2025 IBM Corporation and others.
33
*
44
* This program and the accompanying materials are made available under the
55
* terms of the Eclipse Public License 2.0 which is available at
@@ -15,6 +15,8 @@
1515
import java.beans.PropertyChangeSupport;
1616
import java.util.ArrayList;
1717
import java.util.List;
18+
import java.util.function.BiConsumer;
19+
import java.util.function.Function;
1820

1921
import org.eclipse.swt.SWT;
2022
import org.eclipse.swt.accessibility.ACC;
@@ -52,6 +54,7 @@
5254
import org.eclipse.jface.action.IAction;
5355
import org.eclipse.jface.action.IContributionItem;
5456
import org.eclipse.jface.action.MenuManager;
57+
import org.eclipse.jface.preference.IPreferenceStore;
5558
import org.eclipse.jface.resource.ImageDescriptor;
5659
import org.eclipse.jface.resource.JFaceResources;
5760
import org.eclipse.jface.util.IPropertyChangeListener;
@@ -264,10 +267,25 @@ private Control createFlyoutControlButton(Composite parent) {
264267
* @param prefs {@link Plugin#getPluginPreferences() a plugin's Preferences}
265268
* @return a default implementation of FlyoutPreferences that stores the
266269
* settings in the given Preferences
270+
* @deprecated Use {@link #createFlyoutPreferences(IPreferenceStore)} instead.
271+
* This method will be removed after the 2027-06 release.
267272
* @since 3.2
268273
*/
274+
@Deprecated(forRemoval = true, since = "3.22.0")
269275
public static FlyoutPreferences createFlyoutPreferences(Preferences prefs) {
270-
return new DefaultFlyoutPreferences(prefs);
276+
return new DefaultFlyoutPreferences(prefs::getInt, prefs::setValue);
277+
}
278+
279+
/**
280+
* This is a convenient method to get a default FlyoutPreferences object.
281+
*
282+
* @param prefs an {@link IPreferenceStore}
283+
* @return a default implementation of FlyoutPreferences that stores the
284+
* settings in the given Preferences
285+
* @since 3.22
286+
*/
287+
public static FlyoutPreferences createFlyoutPreferences(IPreferenceStore prefs) {
288+
return new DefaultFlyoutPreferences(prefs::getInt, prefs::setValue);
271289
}
272290

273291
private Composite createPaletteContainer() {
@@ -1505,40 +1523,42 @@ private static class DefaultFlyoutPreferences implements FlyoutPreferences {
15051523
private static final String PALETTE_SIZE = "org.eclipse.gef.psize"; //$NON-NLS-1$
15061524
private static final String PALETTE_STATE = "org.eclipse.gef.pstate"; //$NON-NLS-1$
15071525

1508-
private final Preferences prefs;
1526+
private final Function<String, Integer> getter;
1527+
private final BiConsumer<String, Integer> setter;
15091528

1510-
private DefaultFlyoutPreferences(Preferences preferences) {
1511-
prefs = preferences;
1529+
private DefaultFlyoutPreferences(Function<String, Integer> getter, BiConsumer<String, Integer> setter) {
1530+
this.getter = getter;
1531+
this.setter = setter;
15121532
}
15131533

15141534
@Override
15151535
public int getDockLocation() {
1516-
return prefs.getInt(PALETTE_DOCK_LOCATION);
1536+
return getter.apply(PALETTE_DOCK_LOCATION);
15171537
}
15181538

15191539
@Override
15201540
public int getPaletteState() {
1521-
return prefs.getInt(PALETTE_STATE);
1541+
return getter.apply(PALETTE_STATE);
15221542
}
15231543

15241544
@Override
15251545
public int getPaletteWidth() {
1526-
return prefs.getInt(PALETTE_SIZE);
1546+
return getter.apply(PALETTE_SIZE);
15271547
}
15281548

15291549
@Override
15301550
public void setDockLocation(int location) {
1531-
prefs.setValue(PALETTE_DOCK_LOCATION, location);
1551+
setter.accept(PALETTE_DOCK_LOCATION, location);
15321552
}
15331553

15341554
@Override
15351555
public void setPaletteState(int state) {
1536-
prefs.setValue(PALETTE_STATE, state);
1556+
setter.accept(PALETTE_STATE, state);
15371557
}
15381558

15391559
@Override
15401560
public void setPaletteWidth(int width) {
1541-
prefs.setValue(PALETTE_SIZE, width);
1561+
setter.accept(PALETTE_SIZE, width);
15421562
}
15431563
}
15441564

org.eclipse.gef/src/org/eclipse/gef/ui/parts/GraphicalEditorWithFlyoutPalette.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ protected Control getGraphicalControl() {
129129
*/
130130
@SuppressWarnings("static-method")
131131
protected FlyoutPreferences getPalettePreferences() {
132-
return FlyoutPaletteComposite.createFlyoutPreferences(InternalGEFPlugin.getDefault().getPluginPreferences());
132+
return FlyoutPaletteComposite.createFlyoutPreferences(InternalGEFPlugin.getDefault().getPreferenceStore());
133133
}
134134

135135
/**

0 commit comments

Comments
 (0)