mirror of
https://gitflic.ru/project/openide/openide.git
synced 2025-12-15 02:59:33 +07:00
DBE-22735 Grid: Ignore custom number formats when copying cell value
GitOrigin-RevId: 93e07985496b358a6e89bdacbf3c79f64b6c9e93
This commit is contained in:
committed by
intellij-monorepo-bot
parent
7f41e0ccc5
commit
31d849260a
@@ -36,6 +36,11 @@ public class DatabaseObjectFormatterConfig implements ObjectFormatterConfig {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean supportsNumberFormats() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
@@ -67,6 +72,8 @@ public class DatabaseObjectFormatterConfig implements ObjectFormatterConfig {
|
||||
|
||||
private final DataGridSettings settings;
|
||||
|
||||
private final boolean supportsNumberFormats;
|
||||
|
||||
private boolean isAllowedShowBigObjects;
|
||||
|
||||
public DatabaseDisplayObjectFormatterConfig() {
|
||||
@@ -78,9 +85,20 @@ public class DatabaseObjectFormatterConfig implements ObjectFormatterConfig {
|
||||
boolean isModeDetectedAutomatically,
|
||||
@Nullable Set<BinaryDisplayType> allowedTypes,
|
||||
@Nullable DataGridSettings settings
|
||||
) {
|
||||
this(displayType, isModeDetectedAutomatically, true, allowedTypes, settings);
|
||||
}
|
||||
|
||||
private DatabaseDisplayObjectFormatterConfig(
|
||||
@Nullable DisplayType displayType,
|
||||
boolean isModeDetectedAutomatically,
|
||||
boolean supportsNumberFormats,
|
||||
@Nullable Set<BinaryDisplayType> allowedTypes,
|
||||
@Nullable DataGridSettings settings
|
||||
) {
|
||||
super(ObjectFormatterMode.DISPLAY);
|
||||
this.isAllowedShowBigObjects = false;
|
||||
this.supportsNumberFormats = supportsNumberFormats;
|
||||
this.displayType = displayType;
|
||||
this.isModeDetectedAutomatically = isModeDetectedAutomatically;
|
||||
this.allowedTypes = allowedTypes;
|
||||
@@ -114,6 +132,25 @@ public class DatabaseObjectFormatterConfig implements ObjectFormatterConfig {
|
||||
return this.isAllowedShowBigObjects;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean supportsNumberFormats() {
|
||||
return this.supportsNumberFormats;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public DatabaseDisplayObjectFormatterConfig adjustForExtraction() {
|
||||
if (supportsNumberFormats) {
|
||||
return new DatabaseDisplayObjectFormatterConfig(
|
||||
displayType,
|
||||
isModeDetectedAutomatically,
|
||||
false,
|
||||
allowedTypes,
|
||||
settings
|
||||
);
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
@@ -122,12 +159,13 @@ public class DatabaseObjectFormatterConfig implements ObjectFormatterConfig {
|
||||
DatabaseDisplayObjectFormatterConfig config = (DatabaseDisplayObjectFormatterConfig)o;
|
||||
return isModeDetectedAutomatically == config.isModeDetectedAutomatically &&
|
||||
displayType == config.displayType &&
|
||||
supportsNumberFormats == config.supportsNumberFormats &&
|
||||
Objects.equals(allowedTypes, config.allowedTypes);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(super.hashCode(), displayType, isModeDetectedAutomatically, allowedTypes);
|
||||
return Objects.hash(super.hashCode(), displayType, isModeDetectedAutomatically, supportsNumberFormats, allowedTypes);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -726,7 +726,7 @@ public class FormatterCreator {
|
||||
DecimalFormatSymbols symbols = format.getDecimalFormatSymbols();
|
||||
DataGridSettings settings = config != null ? config.getSettings() : null;
|
||||
String pattern = settings != null ? settings.getEffectiveNumberPattern() : null;
|
||||
if (settings != null) {
|
||||
if (settings != null && config.supportsNumberFormats()) {
|
||||
format.setGroupingUsed(settings.isNumberGroupingEnabled());
|
||||
symbols.setGroupingSeparator(settings.getNumberGroupingSeparator());
|
||||
symbols.setDecimalSeparator(settings.getDecimalSeparator());
|
||||
|
||||
@@ -13,4 +13,6 @@ public interface ObjectFormatterConfig {
|
||||
DataGridSettings getSettings();
|
||||
|
||||
boolean isAllowedShowBigObjects();
|
||||
|
||||
boolean supportsNumberFormats();
|
||||
}
|
||||
|
||||
@@ -608,14 +608,20 @@ public class GridUtil extends GridUtilCore {
|
||||
};
|
||||
}
|
||||
|
||||
public static @NotNull Function<Integer, ObjectFormatterConfig> getConfigProvider(@NotNull DataGrid dataGrid, boolean allowLongValues) {
|
||||
public static @NotNull Function<Integer, ObjectFormatterConfig> getConfigProvider(
|
||||
@NotNull DataGrid dataGrid,
|
||||
boolean allowLongValues,
|
||||
boolean extractionMode
|
||||
) {
|
||||
return num -> {
|
||||
ModelIndex<GridColumn> idx = ModelIndex.forColumn(dataGrid, num);
|
||||
if (!allowLongValues) {
|
||||
return createFormatterConfig(dataGrid, idx);
|
||||
}
|
||||
var config = createFormatterConfig(dataGrid, idx);
|
||||
config.allowShowBigObjects();
|
||||
if (allowLongValues) {
|
||||
config.allowShowBigObjects();
|
||||
}
|
||||
if (extractionMode) {
|
||||
config = config.adjustForExtraction();
|
||||
}
|
||||
return config;
|
||||
};
|
||||
}
|
||||
|
||||
@@ -108,7 +108,7 @@ public class GridCopyProvider implements CopyProvider {
|
||||
SelectionModel<GridRow, GridColumn> selectionModel = myGrid.getSelectionModel();
|
||||
if (selectionModel.getSelectedRowCount() == 1 &&
|
||||
selectionModel.getSelectedColumnCount() == 1) {
|
||||
return GridExtractorsUtilCore.getSingleValueExtractor(myGrid.getObjectFormatter(), GridUtil.getConfigProvider(myGrid, true));
|
||||
return GridExtractorsUtilCore.getSingleValueExtractor(myGrid.getObjectFormatter(), GridUtil.getConfigProvider(myGrid, true, true));
|
||||
}
|
||||
|
||||
DataExtractorFactory extractorFactory = DataExtractorFactories.getExtractorFactory(myGrid, GridUtil::suggestPlugin);
|
||||
|
||||
Reference in New Issue
Block a user