a circuit can have a name different from the file name of the circuit

This commit is contained in:
hneemann 2020-04-01 14:35:47 +02:00
parent 823b77e117
commit 22a57d19be
2 changed files with 13 additions and 12 deletions

View File

@ -583,7 +583,7 @@ public class ElementLibrary implements Iterable<ElementLibrary.ElementContainer>
} }
ElementTypeDescriptionCustom description = createCustomDescription(file, circuit, this); ElementTypeDescriptionCustom description = createCustomDescription(file, circuit, this);
description.setShortName(createShortName(file)); description.setShortName(createShortName(file.getName(), circuit.getAttributes().getLabel()));
String descriptionText = Lang.evalMultilingualContent(circuit.getAttributes().get(Keys.DESCRIPTION)); String descriptionText = Lang.evalMultilingualContent(circuit.getAttributes().get(Keys.DESCRIPTION));
if (descriptionText != null && descriptionText.length() > 0) { if (descriptionText != null && descriptionText.length() > 0) {
@ -595,11 +595,8 @@ public class ElementLibrary implements Iterable<ElementLibrary.ElementContainer>
} }
} }
private String createShortName(File file) { private String createShortName(String name, String userDefined) {
return createShortName(file.getName()); if (userDefined.isEmpty()) {
}
private String createShortName(String name) {
if (name.endsWith(".dig")) return "\\" + name.substring(0, name.length() - 4); if (name.endsWith(".dig")) return "\\" + name.substring(0, name.length() - 4);
String transName = Lang.getNull("elem_" + name); String transName = Lang.getNull("elem_" + name);
@ -607,6 +604,9 @@ public class ElementLibrary implements Iterable<ElementLibrary.ElementContainer>
return name; return name;
else else
return transName; return transName;
} else {
return userDefined;
}
} }
/** /**

View File

@ -62,6 +62,7 @@ public class CircuitComponent extends JComponent implements ChangedListener, Lib
private static final ArrayList<Key> ATTR_LIST = new ArrayList<>(); private static final ArrayList<Key> ATTR_LIST = new ArrayList<>();
static { static {
ATTR_LIST.add(Keys.LABEL);
ATTR_LIST.add(Keys.WIDTH); ATTR_LIST.add(Keys.WIDTH);
ATTR_LIST.add(Keys.SHAPE_TYPE); ATTR_LIST.add(Keys.SHAPE_TYPE);
ATTR_LIST.add(Keys.CUSTOM_SHAPE); ATTR_LIST.add(Keys.CUSTOM_SHAPE);