allows to create a concrete circuit from a generic one; see #543

This commit is contained in:
hneemann 2020-11-04 08:09:32 +01:00
parent 30ca4461c2
commit a55f86ed91
3 changed files with 58 additions and 8 deletions

View File

@ -1151,6 +1151,35 @@ public class CircuitComponent extends JComponent implements ChangedListener, Lib
}
}.setToolTip(Lang.get("attr_openCircuit_tt")));
}
if (elementType == GenericInitCode.DESCRIPTION && getCircuit().getAttributes().get(Keys.IS_GENERIC)) {
attributeDialog.addButton(Lang.get("attr_createConcreteCircuitLabel"), new ToolTipAction(Lang.get("attr_createConcreteCircuit")) {
@Override
public void actionPerformed(ActionEvent e) {
try {
attributeDialog.fireOk();
ElementAttributes modified = attributeDialog.getModifiedAttributes();
if (modified != null && !isLocked()) {
Modification<Circuit> mod = new ModifyAttributes(element, modified);
modify(checkNetRename(element, modified, mod));
}
Circuit concreteCircuit = new ResolveGenerics().resolveCircuit(element, getCircuit(), library).getCircuit();
for (VisualElement gic : concreteCircuit.getElements(v -> v.equalsDescription(GenericInitCode.DESCRIPTION)))
concreteCircuit.delete(gic);
concreteCircuit.getAttributes().set(Keys.IS_GENERIC, false);
new Main.MainBuilder()
.setParent(parent)
.setCircuit(concreteCircuit)
.setLibrary(library)
.denyMostFileActions()
.keepPrefMainFile()
.openLater();
} catch (NodeException | ElementNotFoundException | Editor.EditorParseException ex) {
new ErrorMessage(Lang.get("attr_createConcreteCircuitErr")).addCause(ex).show(parent);
}
}
}.setToolTip(Lang.get("attr_createConcreteCircuit_tt")));
}
attributeDialog.addButton(new ToolTipAction(Lang.get("attr_help")) {
@Override
public void actionPerformed(ActionEvent actionEvent) {

View File

@ -1146,9 +1146,13 @@ Sind evtl. die Namen der Variablen nicht eindeutig?</string>
<string name="key_Color">Farbe</string><!-- LED, LightBulb, Seven-Seg, Seven-Seg-Hex, LedMatrix -->
<string name="key_Color_tt">Die Farbe des Elementes.</string>
<string name="key_backgroundColor">Hintergrundfarbe</string>
<string name="key_backgroundColor_tt">Hintergrundfarbe der Schaltung, wenn sie eingebettet wird. Wird für DILs nicht verwendet.</string>
<string name="key_backgroundColor_tt">Hintergrundfarbe der Schaltung, wenn sie eingebettet wird. Wird für DILs nicht
verwendet.
</string>
<string name="key_Cycles">Timeout Zyklen</string><!-- Break -->
<string name="key_Cycles_tt">Wenn nach dieser Anzahl von Takten kein Break eingegangen ist, wird ein Fehler erzeugt</string>
<string name="key_Cycles_tt">Wenn nach dieser Anzahl von Takten kein Break eingegangen ist, wird ein Fehler
erzeugt
</string>
<string name="key_Data">Daten</string><!-- LookUpTable, ROM, EEPROM -->
<string name="key_Data_tt">Die Daten, welche in diesem Element gespeichert sind.</string>
<string name="key_Default">Vorgabe</string><!-- Demultiplexer, RS_FF, JK_FF, D_FF, T_FF, JK_FF_AS, D_FF_AS -->
@ -2014,6 +2018,12 @@ Stellen Sie sicher, dass der Flash-Vorgang abgeschlossen ist, bevor Sie diesen D
<string name="btn_help">Hilfe</string>
<string name="msg_keyAsGenericAttribute">Name in einer generischen Schaltung: {0}</string>
<string name="attr_createConcreteCircuitLabel">Konkrete Schaltung erzeugen</string>
<string name="attr_createConcreteCircuit">Erzeugen</string>
<string name="attr_createConcreteCircuit_tt">Erzeugt aus dieser generischen Schaltung eine konkrete Schaltung
unter Anwendung der in diesem Element angegebenen Parameter.
</string>
<string name="attr_createConcreteCircuitErr">Fehler bei der Erzeugung der konkreten Schaltung!</string>
<string name="win_romDialogHelpTitle">Zentrale ROM Inhalte</string>
<string name="msg_romDialogHelp"><![CDATA[

View File

@ -1156,9 +1156,12 @@
<string name="key_Color">Color</string><!-- LED, LightBulb, Seven-Seg, Seven-Seg-Hex, LedMatrix -->
<string name="key_Color_tt">The Color of the element.</string>
<string name="key_backgroundColor">Background color</string>
<string name="key_backgroundColor_tt">Background color of the circuit when it is embedded in another circuit. Is not used for DIL packages.</string>
<string name="key_backgroundColor_tt">Background color of the circuit when it is embedded in another circuit. Is not
used for DIL packages.
</string>
<string name="key_Cycles">Timeout cycles</string><!-- Break -->
<string name="key_Cycles_tt">If this amount of cycles is reached without a break signal, an error is created.</string>
<string name="key_Cycles_tt">If this amount of cycles is reached without a break signal, an error is created.
</string>
<string name="key_Data">Data</string><!-- LookUpTable, ROM, EEPROM -->
<string name="key_Data_tt">The values stored in this element.</string>
<string name="key_Default">Default</string><!-- Demultiplexer, RS_FF, JK_FF, D_FF, T_FF, JK_FF_AS, D_FF_AS -->
@ -1858,6 +1861,12 @@
<string name="stat_addrBits">Addr. Bits</string>
<string name="msg_keyAsGenericAttribute">Name to use in generic circuits: {0}</string>
<string name="attr_createConcreteCircuitLabel">Create Concrete Circuit</string>
<string name="attr_createConcreteCircuit">Create</string>
<string name="attr_createConcreteCircuit_tt">Creates a concrete circuit from this generic circuit using the
parameters specified in this element.
</string>
<string name="attr_createConcreteCircuitErr">Error while creating the concrete circuit!</string>
<string name="message">&lt;h1&gt;Digital&lt;/h1&gt;A simple simulator for digital circuits.
Written by H. Neemann in 2016-2020.
@ -1865,9 +1874,11 @@
The icons are taken from the &lt;a href=&quot;http://tango.freedesktop.org&quot;&gt;Tango Desktop Project&lt;/a&gt;.
Visit the project at &lt;a href=&quot;https://github.com/hneemann/[[name]]&quot;&gt;GitHub&lt;/a&gt;.
At Github you can also &lt;a href=&quot;https://github.com/hneemann/[[name]]/releases/latest&quot;&gt;download&lt;/a&gt; the latest release.
At Github you can also &lt;a href=&quot;https://github.com/hneemann/[[name]]/releases/latest&quot;&gt;download&lt;/a&gt;
the latest release.
There you also can file an &lt;a href=&quot;https://github.com/hneemann/[[name]]/issues/new?body=version:%20[[version]]&amp;labels=bug&quot;&gt;issue&lt;/a&gt; or suggest
There you also can file an &lt;a href=&quot;https://github.com/hneemann/[[name]]/issues/new?body=version:%20[[version]]&amp;labels=bug&quot;&gt;issue&lt;/a&gt;
or suggest
an &lt;a href=&quot;https://github.com/hneemann/[[name]]/issues/new?labels=enhancement&quot;&gt;enhancement&lt;/a&gt;.
</string>
<string name="msg_N_nodes">{0} nodes</string>