Skip to content

Commit

Permalink
Merge branch 'develop' into bugfix/3857-fix-return-of-FunctionUtil.ge…
Browse files Browse the repository at this point in the history
…tZoneRendererFromParam
  • Loading branch information
cwisniew authored Mar 28, 2023
2 parents 182b32e + 0596eca commit 7d66f58
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 49 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,62 +14,28 @@
*/
package net.rptools.maptool.client.ui.campaignproperties;

import java.awt.Color;
import java.awt.Component;
import java.awt.Graphics2D;
import java.awt.Rectangle;
import java.awt.Shape;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import java.io.File;
import java.io.IOException;
import java.text.ParseException;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.LinkedHashMap;
import java.util.*;
import java.util.List;
import java.util.Map;
import java.util.Set;
import javax.swing.*;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener;
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;
import javax.swing.event.*;
import javax.swing.filechooser.FileFilter;
import net.rptools.lib.MD5Key;
import net.rptools.maptool.client.AppConstants;
import net.rptools.maptool.client.AppPreferences;
import net.rptools.maptool.client.swing.AbeillePanel;
import net.rptools.maptool.client.swing.ColorWell;
import net.rptools.maptool.client.ui.PreviewPanelFileChooser;
import net.rptools.maptool.client.ui.token.AbstractTokenOverlay;
import net.rptools.maptool.client.ui.token.BooleanTokenOverlay;
import net.rptools.maptool.client.ui.token.ColorDotTokenOverlay;
import net.rptools.maptool.client.ui.token.CornerImageTokenOverlay;
import net.rptools.maptool.client.ui.token.CrossTokenOverlay;
import net.rptools.maptool.client.ui.token.DiamondTokenOverlay;
import net.rptools.maptool.client.ui.token.FlowColorDotTokenOverlay;
import net.rptools.maptool.client.ui.token.FlowColorSquareTokenOverlay;
import net.rptools.maptool.client.ui.token.FlowDiamondTokenOverlay;
import net.rptools.maptool.client.ui.token.FlowImageTokenOverlay;
import net.rptools.maptool.client.ui.token.FlowTriangleTokenOverlay;
import net.rptools.maptool.client.ui.token.FlowYieldTokenOverlay;
import net.rptools.maptool.client.ui.token.ImageTokenOverlay;
import net.rptools.maptool.client.ui.token.OTokenOverlay;
import net.rptools.maptool.client.ui.token.ShadedTokenOverlay;
import net.rptools.maptool.client.ui.token.TriangleTokenOverlay;
import net.rptools.maptool.client.ui.token.XTokenOverlay;
import net.rptools.maptool.client.ui.token.YieldTokenOverlay;
import net.rptools.maptool.client.ui.token.*;
import net.rptools.maptool.language.I18N;
import net.rptools.maptool.model.Asset;
import net.rptools.maptool.model.AssetManager;
import net.rptools.maptool.model.Campaign;
import net.rptools.maptool.model.CampaignProperties;
import net.rptools.maptool.model.Token;
import net.rptools.maptool.model.*;
import net.rptools.maptool.model.drawing.AbstractTemplate.Quadrant;
import net.rptools.maptool.util.StringUtil;

Expand Down Expand Up @@ -382,6 +348,7 @@ public void actionPerformed(ActionEvent e) {
// Change the enabled data components.
} else if (TYPE.equals(name)) {
enableDataComponents();
changedUpdate(null);

// Update the selected overlay
} else if (UPDATE.equals(name)) {
Expand Down Expand Up @@ -597,6 +564,7 @@ public void valueChanged(ListSelectionEvent e) {
// Set the type and change components
formPanel.getComboBox(TYPE).setSelectedIndex(type.ordinal());
enableDataComponents();
changedUpdate(null);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,7 @@
import com.google.gson.Gson;
import com.google.gson.JsonArray;
import com.google.gson.JsonObject;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
import java.util.*;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ConcurrentHashMap;
import java.util.stream.Collectors;
Expand Down Expand Up @@ -203,8 +196,7 @@ private DataValue setData(String type, String namespace, DataValue value) {
var dataMap =
namespaceDataMap.computeIfAbsent(
new PropertyTypeNamespace(type, namespace), k -> new ConcurrentHashMap<>());
if (existing == null) {

if (existing == null || existing.getDataType() == DataType.UNDEFINED) {
dataMap.put(value.getName(), value);
} else {
var newValue = DataType.convert(value, existing.getDataType());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1096,4 +1096,31 @@ void createNamespaceWithTypes() throws ExecutionException, InterruptedException
DataType.UNDEFINED,
mds.getPropertyDataType("testType2", "testNamespace3", "invalid").get()));
}

@Test
void emptyValueCanBeUpdated() throws ExecutionException, InterruptedException {
final String PROPERTY_TYPE = "pt";
final String NAMESPACE = "ns";
final String PROPERTY_NAME = "a";

var mdsWithUndefined = new MemoryDataStore();
mdsWithUndefined
.createNamespaceWithTypes(
PROPERTY_TYPE, NAMESPACE, Map.of(PROPERTY_NAME, DataType.UNDEFINED))
.get();
assertEquals(
DataType.UNDEFINED,
mdsWithUndefined.getProperty(PROPERTY_TYPE, NAMESPACE, PROPERTY_NAME).get().getDataType());

mdsWithUndefined
.setProperty(PROPERTY_TYPE, NAMESPACE, DataValueFactory.fromString(PROPERTY_NAME, "1"))
.get();

assertEquals(
DataType.STRING,
mdsWithUndefined.getProperty(PROPERTY_TYPE, NAMESPACE, PROPERTY_NAME).get().getDataType());
assertEquals(
"1",
mdsWithUndefined.getProperty(PROPERTY_TYPE, NAMESPACE, PROPERTY_NAME).get().asString());
}
}

0 comments on commit 7d66f58

Please sign in to comment.