added more information to undo/redo tool tips

This commit is contained in:
hneemann 2017-05-31 07:52:48 +02:00
parent 811429b8bd
commit 3ae68a36d5
9 changed files with 37 additions and 16 deletions

View File

@ -224,9 +224,12 @@ public class ElementAttributes {
/** /**
* Apply the given attributes to this set * Apply the given attributes to this set
* *
* @param elementAttributes the attributes to use * @param elementAttributes the attributes to copy, maybe null
*/ */
public void getValuesFrom(ElementAttributes elementAttributes) { public void getValuesFrom(ElementAttributes elementAttributes) {
if (elementAttributes == null)
return;
if (attributes != null) if (attributes != null)
attributes.clear(); attributes.clear();
else else

View File

@ -774,9 +774,9 @@ public final class Main extends JFrame implements ClosingWindowListener.ConfirmS
ToolTipAction editRunAttributes = new ToolTipAction(Lang.get("menu_editRunAttributes")) { ToolTipAction editRunAttributes = new ToolTipAction(Lang.get("menu_editRunAttributes")) {
@Override @Override
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
ElementAttributes modified = new AttributeDialog(Main.this, ATTR_LIST, settings).showDialog(); settings.getValuesFrom(
if (modified!=null) new AttributeDialog(Main.this, ATTR_LIST, settings)
settings.getValuesFrom(modified); .showDialog());
} }
}.setToolTip(Lang.get("menu_editRunAttributes_tt")); }.setToolTip(Lang.get("menu_editRunAttributes_tt"));

View File

@ -1,8 +1,10 @@
package de.neemann.digital.gui.components.modification; package de.neemann.digital.gui.components.modification;
import de.neemann.digital.core.element.Keys;
import de.neemann.digital.draw.elements.Circuit; import de.neemann.digital.draw.elements.Circuit;
import de.neemann.digital.draw.elements.VisualElement; import de.neemann.digital.draw.elements.VisualElement;
import de.neemann.digital.draw.graphics.Vector; import de.neemann.digital.draw.graphics.Vector;
import de.neemann.digital.lang.Lang;
/** /**
* A modification on a visual element. * A modification on a visual element.
@ -38,6 +40,20 @@ public abstract class ModificationOfVisualElement implements Modification {
this.description = description; this.description = description;
} }
/**
* Creates a translated name of the given element
*
* @param ve the element
* @return translated name
*/
public static String getTranslatedName(VisualElement ve) {
String s = Lang.get("elem_" + ve.getElementName());
String l = ve.getElementAttributes().get(Keys.LABEL);
if (l.length() > 0)
s += " ('" + l + "')";
return s;
}
@Override @Override
public String toString() { public String toString() {
return description; return description;

View File

@ -24,7 +24,7 @@ public class ModifyAttribute<VALUE> extends ModificationOfVisualElement {
* @param value the new value * @param value the new value
*/ */
public ModifyAttribute(VisualElement ve, Key<VALUE> key, VALUE value) { public ModifyAttribute(VisualElement ve, Key<VALUE> key, VALUE value) {
super(ve, Lang.get("mod_setKey_N0_in_element", key.getName())); super(ve, Lang.get("mod_setKey_N0_in_element_N1", key.getName(), getTranslatedName(ve)));
this.key = key; this.key = key;
this.value = value; this.value = value;
} }

View File

@ -18,7 +18,7 @@ public class ModifyDeleteElement extends ModificationOfVisualElement {
* @param initialPos its initial position * @param initialPos its initial position
*/ */
public ModifyDeleteElement(VisualElement ve, Vector initialPos) { public ModifyDeleteElement(VisualElement ve, Vector initialPos) {
super(ve, initialPos, Lang.get("mod_deletedElement")); super(ve, initialPos, Lang.get("mod_deletedElement_N", getTranslatedName(ve)));
} }
@Override @Override

View File

@ -4,6 +4,8 @@ import de.neemann.digital.draw.elements.Circuit;
import de.neemann.digital.draw.elements.VisualElement; import de.neemann.digital.draw.elements.VisualElement;
import de.neemann.digital.lang.Lang; import de.neemann.digital.lang.Lang;
import static de.neemann.digital.gui.components.modification.ModificationOfVisualElement.getTranslatedName;
/** /**
* Modifier to insert an element * Modifier to insert an element
* Created by hneemann on 26.05.17. * Created by hneemann on 26.05.17.
@ -27,6 +29,6 @@ public class ModifyInsertElement implements Modification {
@Override @Override
public String toString() { public String toString() {
return Lang.get("mod_insertedElement"); return Lang.get("mod_insertedElement_N", getTranslatedName(element));
} }
} }

View File

@ -20,7 +20,7 @@ public class ModifyMoveAndRotElement extends ModificationOfVisualElement {
* @param initialPos its initial position * @param initialPos its initial position
*/ */
public ModifyMoveAndRotElement(VisualElement ve, Vector initialPos) { public ModifyMoveAndRotElement(VisualElement ve, Vector initialPos) {
super(ve, initialPos, Lang.get("mod_movedOrRotatedElement")); super(ve, initialPos, Lang.get("mod_movedOrRotatedElement_N", getTranslatedName(ve)));
pos = ve.getPos(); pos = ve.getPos();
rotation = ve.getRotate(); rotation = ve.getRotate();
} }

View File

@ -647,14 +647,14 @@ Sind evtl. die Namen der Variablen nicht eindeutig?</string>
<string name="mod_insertWire">Leitung eingefügt.</string> <string name="mod_insertWire">Leitung eingefügt.</string>
<string name="mod_insertCopied">Aus Zwischenablage eingefügt.</string> <string name="mod_insertCopied">Aus Zwischenablage eingefügt.</string>
<string name="mod_setKey_N0_in_element">Wert ''{0}'' in Element verändert.</string> <string name="mod_setKey_N0_in_element_N1">Wert ''{0}'' in Element ''{1}'' verändert.</string>
<string name="mod_setAttributes">Attribute in Element verändert.</string> <string name="mod_setAttributes">Attribute in Element verändert.</string>
<string name="mod_wireDeleted">Leitung gelöscht.</string> <string name="mod_wireDeleted">Leitung gelöscht.</string>
<string name="mod_movedOrRotatedElement">Element verschoben oder rotiert.</string> <string name="mod_movedOrRotatedElement_N">Element ''{0}'' verschoben oder rotiert.</string>
<string name="mod_movedWire">Leitung verschoben.</string> <string name="mod_movedWire">Leitung verschoben.</string>
<string name="mod_deletedSelection">Auswahl gelöscht.</string> <string name="mod_deletedSelection">Auswahl gelöscht.</string>
<string name="mod_insertedElement">Element eingefügt.</string> <string name="mod_insertedElement_N">Element ''{0}'' eingefügt.</string>
<string name="mod_deletedElement">Element entfernt.</string> <string name="mod_deletedElement_N">Element ''{0}'' entfernt.</string>
<string name="mod_insertedWire">Leitung eingefügt.</string> <string name="mod_insertedWire">Leitung eingefügt.</string>
<string name="mod_movedSelected">Auswahl verschoben.</string> <string name="mod_movedSelected">Auswahl verschoben.</string>
<string name="mod_undo_N">Rückgängig: {0}</string> <string name="mod_undo_N">Rückgängig: {0}</string>

View File

@ -637,14 +637,14 @@ The names of the variables may not be unique.</string>
<string name="mod_insertWire">Inserted wire.</string> <string name="mod_insertWire">Inserted wire.</string>
<string name="mod_insertCopied">Insert from clipboard.</string> <string name="mod_insertCopied">Insert from clipboard.</string>
<string name="mod_setKey_N0_in_element">Value {0} in component modified.</string> <string name="mod_setKey_N0_in_element_N1">Value ''{0}'' in component ''{1}'' modified.</string>
<string name="mod_setAttributes">Attributes of component modified.</string> <string name="mod_setAttributes">Attributes of component modified.</string>
<string name="mod_wireDeleted">Wire deleted.</string> <string name="mod_wireDeleted">Wire deleted.</string>
<string name="mod_movedOrRotatedElement">Component moved or rotated.</string> <string name="mod_movedOrRotatedElement_N">Component ''{0}'' moved or rotated.</string>
<string name="mod_movedWire">Wire moved.</string> <string name="mod_movedWire">Wire moved.</string>
<string name="mod_deletedSelection">Selection deleted.</string> <string name="mod_deletedSelection">Selection deleted.</string>
<string name="mod_insertedElement">Component inserted.</string> <string name="mod_insertedElement_N">Component ''{0}'' inserted.</string>
<string name="mod_deletedElement">Component deleted.</string> <string name="mod_deletedElement_N">Component ''{0}'' deleted.</string>
<string name="mod_insertedWire">Wire inserted.</string> <string name="mod_insertedWire">Wire inserted.</string>
<string name="mod_movedSelected">Selection moved.</string> <string name="mod_movedSelected">Selection moved.</string>
<string name="mod_undo_N">Undo: {0}</string> <string name="mod_undo_N">Undo: {0}</string>