mirror of
https://github.com/OMGeeky/ATCS.git
synced 2026-01-25 04:35:36 +01:00
refactor to keep compatibility with old java version (openjdk-11 tested)
This commit is contained in:
@@ -13,18 +13,36 @@ public interface ListenerListModel<E> extends ListModel<E> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
default void notifyListeners(Object source, ChangeType event, int index0, int index1) {
|
default void notifyListeners(Object source, ChangeType event, int index0, int index1) {
|
||||||
int eventCode = switch (event) {
|
int eventCode;
|
||||||
case CHANGED -> ListDataEvent.CONTENTS_CHANGED;
|
switch (event) {
|
||||||
case ADDED -> ListDataEvent.INTERVAL_ADDED;
|
case CHANGED:
|
||||||
case REMOVED -> ListDataEvent.INTERVAL_REMOVED;
|
eventCode = ListDataEvent.CONTENTS_CHANGED;
|
||||||
};
|
break;
|
||||||
|
case ADDED:
|
||||||
|
eventCode = ListDataEvent.INTERVAL_ADDED;
|
||||||
|
break;
|
||||||
|
case REMOVED:
|
||||||
|
eventCode = ListDataEvent.INTERVAL_REMOVED;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
throw new IllegalArgumentException();
|
||||||
|
}
|
||||||
|
|
||||||
for (ListDataListener l : getListeners()) {
|
for (ListDataListener l : getListeners()) {
|
||||||
ListDataEvent e = new ListDataEvent(source, eventCode, index0, index1);
|
ListDataEvent e = new ListDataEvent(source, eventCode, index0, index1);
|
||||||
switch (event) {
|
switch (event) {
|
||||||
case CHANGED -> l.contentsChanged(e);
|
case CHANGED: {
|
||||||
case ADDED -> l.intervalAdded(e);
|
l.contentsChanged(e);
|
||||||
case REMOVED -> l.intervalRemoved(e);
|
break;
|
||||||
|
}
|
||||||
|
case ADDED: {
|
||||||
|
l.intervalAdded(e);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case REMOVED: {
|
||||||
|
l.intervalRemoved(e);
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -28,7 +28,8 @@ public class CommonEditor {
|
|||||||
@Override
|
@Override
|
||||||
public Component getListCellRendererComponent(@SuppressWarnings("rawtypes") JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
|
public Component getListCellRendererComponent(@SuppressWarnings("rawtypes") JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
|
||||||
Component c = super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
|
Component c = super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
|
||||||
if (c instanceof JLabel label) {
|
if (c instanceof JLabel) {
|
||||||
|
JLabel label = (JLabel) c;
|
||||||
Common.TimedActorConditionEffect effect = (Common.TimedActorConditionEffect) value;
|
Common.TimedActorConditionEffect effect = (Common.TimedActorConditionEffect) value;
|
||||||
|
|
||||||
if (effect.condition != null) {
|
if (effect.condition != null) {
|
||||||
@@ -69,7 +70,8 @@ public class CommonEditor {
|
|||||||
@Override
|
@Override
|
||||||
public Component getListCellRendererComponent(@SuppressWarnings("rawtypes") JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
|
public Component getListCellRendererComponent(@SuppressWarnings("rawtypes") JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
|
||||||
Component c = super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
|
Component c = super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
|
||||||
if (c instanceof JLabel label) {
|
if (c instanceof JLabel) {
|
||||||
|
JLabel label = (JLabel) c;
|
||||||
Common.ActorConditionEffect effect = (Common.ActorConditionEffect) value;
|
Common.ActorConditionEffect effect = (Common.ActorConditionEffect) value;
|
||||||
|
|
||||||
if (effect.condition != null) {
|
if (effect.condition != null) {
|
||||||
@@ -108,13 +110,13 @@ public class CommonEditor {
|
|||||||
@Override
|
@Override
|
||||||
protected void addFields(FieldUpdateListener listener, boolean writable) {
|
protected void addFields(FieldUpdateListener listener, boolean writable) {
|
||||||
super.addFields(listener, writable);
|
super.addFields(listener, writable);
|
||||||
hitReceivedEffectHPMinTarget = addIntegerField(effectPane, "HP bonus min%s: ".formatted(applyToTargetHint),
|
hitReceivedEffectHPMinTarget = addIntegerField(effectPane, String.format("HP bonus min%s: ", applyToTargetHint),
|
||||||
effect.target.hp_boost_min, true, writable, listener);
|
effect.target.hp_boost_min, true, writable, listener);
|
||||||
hitReceivedEffectHPMaxTarget = addIntegerField(effectPane, "HP bonus max%s: ".formatted(applyToTargetHint),
|
hitReceivedEffectHPMaxTarget = addIntegerField(effectPane, String.format("HP bonus max%s: ", applyToTargetHint),
|
||||||
effect.target.hp_boost_max, true, writable, listener);
|
effect.target.hp_boost_max, true, writable, listener);
|
||||||
hitReceivedEffectAPMinTarget = addIntegerField(effectPane, "AP bonus min%s: ".formatted(applyToTargetHint),
|
hitReceivedEffectAPMinTarget = addIntegerField(effectPane, String.format("AP bonus min%s: ", applyToTargetHint),
|
||||||
effect.target.ap_boost_min, true, writable, listener);
|
effect.target.ap_boost_min, true, writable, listener);
|
||||||
hitReceivedEffectAPMaxTarget = addIntegerField(effectPane, "AP bonus max%s: ".formatted(applyToTargetHint),
|
hitReceivedEffectAPMaxTarget = addIntegerField(effectPane, String.format("AP bonus max%s: ", applyToTargetHint),
|
||||||
effect.target.ap_boost_max, true, writable, listener);
|
effect.target.ap_boost_max, true, writable, listener);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -160,7 +162,7 @@ public class CommonEditor {
|
|||||||
if (applyToTargetHint == null || applyToTargetHint == "") {
|
if (applyToTargetHint == null || applyToTargetHint == "") {
|
||||||
this.applyToTargetHint = "";
|
this.applyToTargetHint = "";
|
||||||
} else {
|
} else {
|
||||||
this.applyToTargetHint = " (%s)".formatted(applyToTargetHint);
|
this.applyToTargetHint = String.format(" (%s)", applyToTargetHint);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -174,7 +176,7 @@ public class CommonEditor {
|
|||||||
protected void addLists(FieldUpdateListener listener, boolean writable) {
|
protected void addLists(FieldUpdateListener listener, boolean writable) {
|
||||||
super.addLists(listener, writable);
|
super.addLists(listener, writable);
|
||||||
|
|
||||||
String titleTarget = "Actor Conditions applied to the target%s: ".formatted(applyToTargetHint);
|
String titleTarget = String.format("Actor Conditions applied to the target%s: ", applyToTargetHint);
|
||||||
CommonEditor.TimedConditionsCellRenderer cellRendererTarget = new CommonEditor.TimedConditionsCellRenderer();
|
CommonEditor.TimedConditionsCellRenderer cellRendererTarget = new CommonEditor.TimedConditionsCellRenderer();
|
||||||
BasicLambdaWithArg<ELEMENT> selectedSetTarget = (value) -> hitTargetConditionPane.selectedCondition = value;
|
BasicLambdaWithArg<ELEMENT> selectedSetTarget = (value) -> hitTargetConditionPane.selectedCondition = value;
|
||||||
BasicLambdaWithReturn<ELEMENT> selectedGetTarget = () -> hitTargetConditionPane.selectedCondition;
|
BasicLambdaWithReturn<ELEMENT> selectedGetTarget = () -> hitTargetConditionPane.selectedCondition;
|
||||||
@@ -237,7 +239,7 @@ public class CommonEditor {
|
|||||||
if (applyToHint == null || applyToHint == "") {
|
if (applyToHint == null || applyToHint == "") {
|
||||||
this.applyToHint = "";
|
this.applyToHint = "";
|
||||||
} else {
|
} else {
|
||||||
this.applyToHint = " (%s)".formatted(applyToHint);
|
this.applyToHint = String.format(" (%s)", applyToHint);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -254,18 +256,18 @@ public class CommonEditor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected void addFields(FieldUpdateListener listener, boolean writable) {
|
protected void addFields(FieldUpdateListener listener, boolean writable) {
|
||||||
effectHPMin = addIntegerField(effectPane, "HP bonus min%s: ".formatted(applyToHint), effect.hp_boost_min,
|
effectHPMin = addIntegerField(effectPane, String.format("HP bonus min%s: ", applyToHint), effect.hp_boost_min,
|
||||||
true, writable, listener);
|
true, writable, listener);
|
||||||
effectHPMax = addIntegerField(effectPane, "HP bonus max%s: ".formatted(applyToHint), effect.hp_boost_max,
|
effectHPMax = addIntegerField(effectPane, String.format("HP bonus max%s: ", applyToHint), effect.hp_boost_max,
|
||||||
true, writable, listener);
|
true, writable, listener);
|
||||||
effectAPMin = addIntegerField(effectPane, "AP bonus min%s: ".formatted(applyToHint), effect.ap_boost_min,
|
effectAPMin = addIntegerField(effectPane, String.format("AP bonus min%s: ", applyToHint), effect.ap_boost_min,
|
||||||
true, writable, listener);
|
true, writable, listener);
|
||||||
effectAPMax = addIntegerField(effectPane, "AP bonus max%s: ".formatted(applyToHint), effect.ap_boost_max,
|
effectAPMax = addIntegerField(effectPane, String.format("AP bonus max%s: ", applyToHint), effect.ap_boost_max,
|
||||||
true, writable, listener);
|
true, writable, listener);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void addLists(FieldUpdateListener listener, boolean writable) {
|
protected void addLists(FieldUpdateListener listener, boolean writable) {
|
||||||
String titleSource = "Actor Conditions applied to the source%s: ".formatted(applyToHint);
|
String titleSource = String.format("Actor Conditions applied to the source%s: ", applyToHint);
|
||||||
TimedConditionsCellRenderer cellRendererSource = new TimedConditionsCellRenderer();
|
TimedConditionsCellRenderer cellRendererSource = new TimedConditionsCellRenderer();
|
||||||
BasicLambdaWithArg<ELEMENT> selectedSetSource = (value) -> sourceConditionPane.selectedCondition = value;
|
BasicLambdaWithArg<ELEMENT> selectedSetSource = (value) -> sourceConditionPane.selectedCondition = value;
|
||||||
BasicLambdaWithReturn<ELEMENT> selectedGetSource = () -> sourceConditionPane.selectedCondition;
|
BasicLambdaWithReturn<ELEMENT> selectedGetSource = () -> sourceConditionPane.selectedCondition;
|
||||||
|
|||||||
Reference in New Issue
Block a user