sorting_deduplicate.diff
| new/src/com/goldencode/p2j/ui/ControlSetConfig.java 2025-12-22 19:28:17 +0000 | ||
|---|---|---|
| 109 | 109 | |
| 110 | 110 |
package com.goldencode.p2j.ui; |
| 111 | 111 | |
| 112 |
import static com.goldencode.util.NativeTypeSerializer.*; |
|
| 112 |
import static com.goldencode.util.NativeTypeSerializer.*; |
|
| 113 | ||
| 113 | 114 |
import java.io.*; |
| 115 |
import java.util.*; |
|
| 116 | ||
| 117 |
import com.goldencode.p2j.ui.client.*; |
|
| 114 | 118 | |
| 115 | 119 |
/** |
| 116 | 120 |
* This class holds the common attributes for all widgets which have a set |
| ... | ... | |
| 339 | 343 |
} |
| 340 | 344 |
|
| 341 | 345 |
/** |
| 346 |
* Conditionally sort items on widget realize. |
|
| 347 |
* |
|
| 348 |
* @param csc |
|
| 349 |
* the control set component to sort items in |
|
| 350 |
*/ |
|
| 351 |
public final void sort(final ControlSetComponent csc) |
|
| 352 |
{
|
|
| 353 |
if (sort) |
|
| 354 |
{
|
|
| 355 |
// clone() only makes a shallow copy of the array (references are copied into a new array), |
|
| 356 |
// which is enough to check whether the item order has changed. |
|
| 357 |
ControlSetItem[] oldItems = items.clone(); |
|
| 358 |
Arrays.sort(items, (fst, snd) -> fst.getLabel().compareTo(snd.getLabel())); |
|
| 359 | ||
| 360 |
if (!Arrays.equals(oldItems, items)) |
|
| 361 |
{
|
|
| 362 |
csc.refreshItems(); |
|
| 363 |
ClientConfigManager.getInstance().addDirtyConfig(this, "items"); |
|
| 364 |
} |
|
| 365 |
} |
|
| 366 |
} |
|
| 367 |
|
|
| 368 |
/** |
|
| 342 | 369 |
* Initialize this config. |
| 343 | 370 |
*/ |
| 344 | 371 |
private void init() |
| new/src/com/goldencode/p2j/ui/client/ComboBox.java 2025-12-22 19:23:35 +0000 | ||
|---|---|---|
| 324 | 324 |
import org.roaringbitmap.*; |
| 325 | 325 | |
| 326 | 326 |
import com.goldencode.p2j.ui.*; |
| 327 |
import com.goldencode.p2j.ui.ComboBoxConfig.Mode;
|
|
| 328 |
import com.goldencode.p2j.ui.chui.ThinClient;
|
|
| 327 |
import com.goldencode.p2j.ui.ComboBoxConfig.*;
|
|
| 328 |
import com.goldencode.p2j.ui.chui.*;
|
|
| 329 | 329 |
import com.goldencode.p2j.ui.client.event.*; |
| 330 | 330 |
import com.goldencode.p2j.ui.client.event.listener.*; |
| 331 | 331 |
import com.goldencode.p2j.ui.client.format.*; |
| 332 |
import com.goldencode.p2j.ui.client.gui.ComboBoxGuiImpl;
|
|
| 332 |
import com.goldencode.p2j.ui.client.gui.*;
|
|
| 333 | 333 |
import com.goldencode.p2j.ui.client.model.*; |
| 334 | 334 |
import com.goldencode.p2j.ui.client.widget.*; |
| 335 | 335 |
import com.goldencode.p2j.util.*; |
| ... | ... | |
| 1224 | 1224 |
} |
| 1225 | 1225 |
} |
| 1226 | 1226 | |
| 1227 |
if (config.sort) |
|
| 1228 |
{
|
|
| 1229 |
// clone() only makes a shallow copy of the array (references are copied into a new array), |
|
| 1230 |
// which is enough to check whether the item order has changed. |
|
| 1231 |
ControlSetItem[] oldItems = config.items.clone(); |
|
| 1232 |
Arrays.sort(config.items, (fst, snd) -> fst.getLabel().compareTo(snd.getLabel())); |
|
| 1233 | ||
| 1234 |
if (!Arrays.equals(oldItems, config.items)) |
|
| 1235 |
{
|
|
| 1236 |
refreshItems(); |
|
| 1237 |
getConfigManager().addDirtyConfig(config, "items"); |
|
| 1238 |
} |
|
| 1239 |
} |
|
| 1227 |
config.sort(this); |
|
| 1240 | 1228 |
} |
| 1241 | 1229 | |
| 1242 | 1230 |
/** |
| new/src/com/goldencode/p2j/ui/client/RadioSet.java 2025-12-22 19:22:55 +0000 | ||
|---|---|---|
| 217 | 217 |
import java.util.*; |
| 218 | 218 | |
| 219 | 219 |
import com.goldencode.p2j.ui.*; |
| 220 |
import com.goldencode.p2j.ui.chui.ThinClient;
|
|
| 220 |
import com.goldencode.p2j.ui.chui.*;
|
|
| 221 | 221 |
import com.goldencode.p2j.ui.client.driver.*; |
| 222 | 222 |
import com.goldencode.p2j.ui.client.event.*; |
| 223 | 223 |
import com.goldencode.p2j.ui.client.event.listener.*; |
| ... | ... | |
| 796 | 796 |
@Override |
| 797 | 797 |
protected void widgetRealized() |
| 798 | 798 |
{
|
| 799 |
if (config.sort) |
|
| 800 |
{
|
|
| 801 |
// clone() only makes a shallow copy of the array (references are copied into a new array), |
|
| 802 |
// which is enough to check whether the item order has changed. |
|
| 803 |
ControlSetItem[] oldItems = config.items.clone(); |
|
| 804 |
Arrays.sort(config.items, (fst, snd) -> fst.getLabel().compareTo(snd.getLabel())); |
|
| 805 | ||
| 806 |
if (!Arrays.equals(oldItems, config.items)) |
|
| 807 |
{
|
|
| 808 |
refreshItems(); |
|
| 809 |
getConfigManager().addDirtyConfig(config, "items"); |
|
| 810 |
} |
|
| 811 |
} |
|
| 799 |
config.sort(this); |
|
| 812 | 800 |
} |
| 813 | 801 | |
| 814 | 802 |
/** |
| new/src/com/goldencode/p2j/ui/client/SelectionList.java 2025-12-22 19:24:23 +0000 | ||
|---|---|---|
| 147 | 147 |
import com.goldencode.p2j.ui.client.driver.*; |
| 148 | 148 |
import com.goldencode.p2j.ui.client.event.*; |
| 149 | 149 |
import com.goldencode.p2j.ui.client.event.listener.*; |
| 150 |
import com.goldencode.p2j.ui.client.model.ListSelectionModel;
|
|
| 150 |
import com.goldencode.p2j.ui.client.model.*;
|
|
| 151 | 151 |
import com.goldencode.p2j.ui.client.widget.*; |
| 152 | 152 |
import com.goldencode.p2j.util.*; |
| 153 | 153 | |
| ... | ... | |
| 188 | 188 |
* @param cfg |
| 189 | 189 |
* Configuration data. |
| 190 | 190 |
*/ |
| 191 |
@SuppressWarnings("unchecked")
|
|
| 192 | 191 |
public SelectionList(WidgetId id, SelectionListConfig cfg) |
| 193 | 192 |
{
|
| 194 | 193 |
// no-op |
| ... | ... | |
| 217 | 216 |
* @param cfg |
| 218 | 217 |
* The config used to initialize this widget. |
| 219 | 218 |
*/ |
| 220 |
@SuppressWarnings("unchecked")
|
|
| 221 | 219 |
@Override |
| 222 | 220 |
public void initialize(WidgetId id, SelectionListConfig cfg) |
| 223 | 221 |
{
|
| ... | ... | |
| 665 | 663 |
Keyboard.SE_DEFAULT_ACTION)); |
| 666 | 664 |
} |
| 667 | 665 | |
| 668 | ||
| 669 | 666 |
/** |
| 670 | 667 |
* Fired when the widget becomes realized. |
| 671 | 668 |
*/ |
| 672 | 669 |
@Override |
| 673 | 670 |
protected void widgetRealized() |
| 674 | 671 |
{
|
| 675 |
if (config.sort) |
|
| 676 |
{
|
|
| 677 |
// clone() only makes a shallow copy of the array (references are copied into a new array), |
|
| 678 |
// which is enough to check whether the item order has changed. |
|
| 679 |
ControlSetItem[] oldItems = config.items.clone(); |
|
| 680 |
Arrays.sort(config.items, (fst, snd) -> fst.getLabel().compareTo(snd.getLabel())); |
|
| 681 | ||
| 682 |
if (!Arrays.equals(oldItems, config.items)) |
|
| 683 |
{
|
|
| 684 |
refreshItems(); |
|
| 685 |
getConfigManager().addDirtyConfig(config, "items"); |
|
| 686 |
} |
|
| 687 |
} |
|
| 672 |
config.sort(this); |
|
| 688 | 673 |
} |
| 689 | 674 |
} |