mirror of
https://github.com/hneemann/Digital.git
synced 2025-09-25 22:18:48 -04:00
better tooltips for undo and redo
This commit is contained in:
parent
0e50d5fbfd
commit
a20247d9b2
@ -1,8 +1,9 @@
|
||||
package de.neemann.digital.draw.elements;
|
||||
|
||||
import de.neemann.digital.core.element.ElementTypeDescription;
|
||||
import de.neemann.digital.gui.components.CircuitComponent;
|
||||
import de.neemann.digital.gui.components.ElementOrderer;
|
||||
import de.neemann.digital.gui.components.modification.Modification;
|
||||
import de.neemann.digital.gui.components.modification.Modifications;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
@ -15,30 +16,17 @@ import java.util.ArrayList;
|
||||
public class ElementOrder implements ElementOrderer.OrderInterface<String> {
|
||||
|
||||
private final ArrayList<Entry> entries;
|
||||
private final ArrayList<VisualElement> elements;
|
||||
private final CircuitComponent circuitComponent;
|
||||
|
||||
/**
|
||||
* Creates a new instance
|
||||
*
|
||||
* @param circuitComponent the circuit witch components are to order
|
||||
* @param description the description of the elements to order
|
||||
*/
|
||||
public ElementOrder(CircuitComponent circuitComponent, ElementTypeDescription description) {
|
||||
this(circuitComponent, element -> {
|
||||
return element.equalsDescription(description);
|
||||
});
|
||||
}
|
||||
private final Modifications.Builder modifications;
|
||||
|
||||
/**
|
||||
* Creates a new instance
|
||||
*
|
||||
* @param circuitComponent the circuitComponent witch components are to order
|
||||
* @param filter the filter to select the entries to order
|
||||
* @param name name of modification
|
||||
*/
|
||||
public ElementOrder(CircuitComponent circuitComponent, ElementFilter filter) {
|
||||
this.circuitComponent = circuitComponent;
|
||||
this.elements = circuitComponent.getCircuit().getElements();
|
||||
public ElementOrder(CircuitComponent circuitComponent, ElementFilter filter, String name) {
|
||||
ArrayList<VisualElement> elements = circuitComponent.getCircuit().getElements();
|
||||
entries = new ArrayList<>();
|
||||
for (int i = 0; i < elements.size(); i++)
|
||||
if (filter.accept(elements.get(i))) {
|
||||
@ -46,6 +34,7 @@ public class ElementOrder implements ElementOrderer.OrderInterface<String> {
|
||||
if (n != null && n.length() > 0)
|
||||
entries.add(new Entry(i, n));
|
||||
}
|
||||
modifications = new Modifications.Builder(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -71,13 +60,21 @@ public class ElementOrder implements ElementOrderer.OrderInterface<String> {
|
||||
entries.set(i, entries.get(j));
|
||||
entries.set(j, x);
|
||||
|
||||
circuitComponent.modify(circuit -> {
|
||||
modifications.add(circuit -> {
|
||||
ArrayList<VisualElement> elements = circuit.getElements();
|
||||
VisualElement y = elements.get(index1);
|
||||
elements.set(index1, elements.get(index2));
|
||||
elements.set(index2, y);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the modification
|
||||
*/
|
||||
public Modification getModifications() {
|
||||
return modifications.build();
|
||||
}
|
||||
|
||||
private final static class Entry {
|
||||
private int i;
|
||||
private final String name;
|
||||
|
@ -27,6 +27,7 @@ import de.neemann.digital.gui.components.data.DataSetDialog;
|
||||
import de.neemann.digital.gui.components.expression.ExpressionDialog;
|
||||
import de.neemann.digital.gui.components.modification.Modifications;
|
||||
import de.neemann.digital.gui.components.modification.ModifyAttribute;
|
||||
import de.neemann.digital.gui.components.modification.ModifyMeasurementOrdering;
|
||||
import de.neemann.digital.gui.components.table.TableDialog;
|
||||
import de.neemann.digital.gui.components.testing.TestResultDialog;
|
||||
import de.neemann.digital.gui.components.tree.LibraryTreeModel;
|
||||
@ -509,8 +510,10 @@ public final class Main extends JFrame implements ClosingWindowListener.ConfirmS
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
ElementOrder o = new ElementOrder(circuitComponent,
|
||||
element -> element.equalsDescription(In.DESCRIPTION)
|
||||
|| element.equalsDescription(Clock.DESCRIPTION));
|
||||
new ElementOrderer<>(Main.this, Lang.get("menu_orderInputs"), o).showDialog();
|
||||
|| element.equalsDescription(Clock.DESCRIPTION),
|
||||
Lang.get("menu_orderInputs"));
|
||||
if (new ElementOrderer<>(Main.this, Lang.get("menu_orderInputs"), o).addOkButton().showDialog())
|
||||
circuitComponent.modify(o.getModifications());
|
||||
}
|
||||
}.setToolTip(Lang.get("menu_orderInputs_tt"));
|
||||
|
||||
@ -519,8 +522,10 @@ public final class Main extends JFrame implements ClosingWindowListener.ConfirmS
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
ElementOrder o = new ElementOrder(circuitComponent,
|
||||
element -> element.equalsDescription(Out.DESCRIPTION)
|
||||
|| element.equalsDescription(Out.LEDDESCRIPTION));
|
||||
new ElementOrderer<>(Main.this, Lang.get("menu_orderOutputs"), o).showDialog();
|
||||
|| element.equalsDescription(Out.LEDDESCRIPTION),
|
||||
Lang.get("menu_orderOutputs"));
|
||||
if (new ElementOrderer<>(Main.this, Lang.get("menu_orderOutputs"), o).addOkButton().showDialog())
|
||||
circuitComponent.modify(o.getModifications());
|
||||
}
|
||||
}.setToolTip(Lang.get("menu_orderOutputs_tt"));
|
||||
|
||||
@ -604,6 +609,9 @@ public final class Main extends JFrame implements ClosingWindowListener.ConfirmS
|
||||
}
|
||||
}.setToolTip(Lang.get("menu_insertAsNew_tt"));
|
||||
|
||||
edit.add(circuitComponent.getUndoAction().createJMenuItemNoIcon());
|
||||
edit.add(circuitComponent.getRedoAction().createJMenuItemNoIcon());
|
||||
edit.addSeparator();
|
||||
edit.add(editAttributes.createJMenuItem());
|
||||
edit.add(actualToDefault.createJMenuItem());
|
||||
edit.add(restoreAllFuses.createJMenuItem());
|
||||
@ -631,7 +639,7 @@ public final class Main extends JFrame implements ClosingWindowListener.ConfirmS
|
||||
if (!circuitComponent.isLocked()) {
|
||||
String prefix = showInputDialog(Lang.get("menu_addPrefix"));
|
||||
if (prefix != null && prefix.length() > 0) {
|
||||
Modifications.Builder builder = new Modifications.Builder();
|
||||
Modifications.Builder builder = new Modifications.Builder(Lang.get("menu_addPrefix"));
|
||||
for (Drawable d : circuitComponent.getHighLighted()) {
|
||||
if (d instanceof VisualElement) {
|
||||
VisualElement v = (VisualElement) d;
|
||||
@ -651,7 +659,7 @@ public final class Main extends JFrame implements ClosingWindowListener.ConfirmS
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent actionEvent) {
|
||||
if (!circuitComponent.isLocked()) {
|
||||
Modifications.Builder builder = new Modifications.Builder();
|
||||
Modifications.Builder builder = new Modifications.Builder(Lang.get("menu_removePrefix"));
|
||||
for (Drawable d : circuitComponent.getHighLighted()) {
|
||||
if (d instanceof VisualElement) {
|
||||
VisualElement v = (VisualElement) d;
|
||||
@ -678,7 +686,7 @@ public final class Main extends JFrame implements ClosingWindowListener.ConfirmS
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent actionEvent) {
|
||||
if (!circuitComponent.isLocked()) {
|
||||
Modifications.Builder builder = new Modifications.Builder();
|
||||
Modifications.Builder builder = new Modifications.Builder(Lang.get("menu_removePinNumbers"));
|
||||
for (VisualElement v : circuitComponent.getCircuit().getElements()) {
|
||||
if (v.equalsDescription(In.DESCRIPTION)
|
||||
|| v.equalsDescription(Clock.DESCRIPTION)
|
||||
@ -886,7 +894,7 @@ public final class Main extends JFrame implements ClosingWindowListener.ConfirmS
|
||||
if (new ElementOrderer<>(Main.this, Lang.get("menu_orderMeasurements"), o)
|
||||
.addOkButton()
|
||||
.showDialog()) {
|
||||
circuitComponent.modify(circuit -> circuit.setMeasurementOrdering(names));
|
||||
circuitComponent.modify(new ModifyMeasurementOrdering(names));
|
||||
}
|
||||
} catch (NodeException | PinException | ElementNotFoundException | RuntimeException e) {
|
||||
showErrorAndStopModel(Lang.get("msg_errorCreatingModel"), e);
|
||||
|
@ -146,14 +146,14 @@ public class CircuitComponent extends JComponent implements Circuit.ChangedListe
|
||||
public void actionPerformed(ActionEvent actionEvent) {
|
||||
undo();
|
||||
}
|
||||
}.setToolTip(Lang.get("menu_undo_tt")).setAcceleratorCTRLplus('Z').enableAcceleratorIn(this);
|
||||
}.setToolTipProvider(this::getUndoToolTip).setToolTip(Lang.get("menu_undo_tt")).setAcceleratorCTRLplus('Z').enableAcceleratorIn(this);
|
||||
|
||||
redoAction = new ToolTipAction(Lang.get("menu_redo"), ICON_REDO) {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent actionEvent) {
|
||||
redo();
|
||||
}
|
||||
}.setToolTip(Lang.get("menu_redo_tt")).setAcceleratorCTRLplus('Y').enableAcceleratorIn(this);
|
||||
}.setToolTipProvider(this::getRedoToolTip).setToolTip(Lang.get("menu_redo_tt")).setAcceleratorCTRLplus('Y').enableAcceleratorIn(this);
|
||||
|
||||
new ToolTipAction("Escape") {
|
||||
@Override
|
||||
@ -326,7 +326,7 @@ public class CircuitComponent extends JComponent implements Circuit.ChangedListe
|
||||
public void editCircuitAttributes(Component parent) {
|
||||
ElementAttributes modifiedAttributes = new AttributeDialog(parent, ATTR_LIST, circuit.getAttributes()).showDialog();
|
||||
if (modifiedAttributes != null)
|
||||
modify(circuit -> circuit.getAttributes().getValuesFrom(modifiedAttributes));
|
||||
modify(new ModifyCircuitAttributes(modifiedAttributes));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -386,6 +386,13 @@ public class CircuitComponent extends JComponent implements Circuit.ChangedListe
|
||||
}
|
||||
}
|
||||
|
||||
private String getUndoToolTip() {
|
||||
if (undoPosition > 0)
|
||||
return Lang.get("mod_undo_N", modifications.get(undoPosition - 1).toString());
|
||||
else
|
||||
return Lang.get("menu_undo_tt");
|
||||
}
|
||||
|
||||
/**
|
||||
* redo last undo
|
||||
*/
|
||||
@ -400,6 +407,12 @@ public class CircuitComponent extends JComponent implements Circuit.ChangedListe
|
||||
}
|
||||
}
|
||||
|
||||
private String getRedoToolTip() {
|
||||
if (undoPosition < modifications.size())
|
||||
return Lang.get("mod_redo_N", modifications.get(undoPosition).toString());
|
||||
else
|
||||
return Lang.get("menu_redo_tt");
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the main frame
|
||||
@ -873,7 +886,7 @@ public class CircuitComponent extends JComponent implements Circuit.ChangedListe
|
||||
*/
|
||||
public void actualToDefault() {
|
||||
if (!isLocked()) {
|
||||
Modifications.Builder builder = new Modifications.Builder();
|
||||
Modifications.Builder builder = new Modifications.Builder(Lang.get("menu_actualToDefault"));
|
||||
for (VisualElement ve : circuit.getElements())
|
||||
if (ve.equalsDescription(In.DESCRIPTION)) {
|
||||
ObservableValue ov = ((InputShape) ve.getShape()).getObservableValue();
|
||||
@ -892,7 +905,7 @@ public class CircuitComponent extends JComponent implements Circuit.ChangedListe
|
||||
* All fuses (diodes) are restored to "not programed" so that they are working again.
|
||||
*/
|
||||
public void restoreAllFuses() {
|
||||
Modifications.Builder builder = new Modifications.Builder();
|
||||
Modifications.Builder builder = new Modifications.Builder(Lang.get("menu_restoreAllFuses"));
|
||||
for (VisualElement ve : circuit.getElements())
|
||||
if (library.isProgrammable(ve.getElementName())) {
|
||||
if (ve.getElementAttributes().get(Keys.BLOWN))
|
||||
@ -1444,7 +1457,7 @@ public class CircuitComponent extends JComponent implements Circuit.ChangedListe
|
||||
if (e.getButton() == MouseEvent.BUTTON3)
|
||||
mouseNormal.activate();
|
||||
else {
|
||||
modify(new Modifications.Builder()
|
||||
modify(new Modifications.Builder(Lang.get("mod_insertWire"))
|
||||
.add(new ModifyInsertWire(wire1).checkIfLenZero())
|
||||
.add(new ModifyInsertWire(wire2).checkIfLenZero())
|
||||
.build());
|
||||
@ -1710,7 +1723,7 @@ public class CircuitComponent extends JComponent implements Circuit.ChangedListe
|
||||
@Override
|
||||
void clicked(MouseEvent e) {
|
||||
if (elements != null && e.getButton() == 1) {
|
||||
Modifications.Builder builder = new Modifications.Builder();
|
||||
Modifications.Builder builder = new Modifications.Builder(Lang.get("mod_insertCopied"));
|
||||
for (Movable m : elements) {
|
||||
if (m instanceof Wire)
|
||||
builder.add(new ModifyInsertWire((Wire) m));
|
||||
|
@ -9,7 +9,7 @@ import de.neemann.digital.draw.elements.Circuit;
|
||||
public interface Modification {
|
||||
|
||||
/**
|
||||
* Performes a modification on the given circuit
|
||||
* Performs a modification on the given circuit
|
||||
*
|
||||
* @param circuit the circuit to modify
|
||||
*/
|
||||
|
@ -12,26 +12,35 @@ import de.neemann.digital.draw.graphics.Vector;
|
||||
public abstract class ModificationOfVisualElement implements Modification {
|
||||
|
||||
private final Vector pos;
|
||||
private final String description;
|
||||
private final String name;
|
||||
|
||||
/**
|
||||
* Creates a new instance
|
||||
*
|
||||
* @param ve the element to modify
|
||||
* @param ve the element to modify
|
||||
* @param description description
|
||||
*/
|
||||
public ModificationOfVisualElement(VisualElement ve) {
|
||||
this(ve, ve.getPos());
|
||||
public ModificationOfVisualElement(VisualElement ve, String description) {
|
||||
this(ve, ve.getPos(), description);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new instance
|
||||
*
|
||||
* @param ve the element to modify
|
||||
* @param initialPos the initial position of the element
|
||||
* @param ve the element to modify
|
||||
* @param initialPos the initial position of the element
|
||||
* @param description description
|
||||
*/
|
||||
public ModificationOfVisualElement(VisualElement ve, Vector initialPos) {
|
||||
public ModificationOfVisualElement(VisualElement ve, Vector initialPos, String description) {
|
||||
name = ve.getElementName();
|
||||
pos = initialPos;
|
||||
this.description = description;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return description;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -12,28 +12,27 @@ import de.neemann.digital.draw.graphics.Vector;
|
||||
public abstract class ModificationOfWire implements Modification {
|
||||
|
||||
private final Vector p1;
|
||||
private final String description;
|
||||
private final Vector p2;
|
||||
|
||||
/**
|
||||
* Creates a new instance
|
||||
*
|
||||
* @param wire the wire to modify
|
||||
* @param wire the wire to modify
|
||||
* @param initialPos the initial position of the wire
|
||||
* @param description description of modification
|
||||
*/
|
||||
public ModificationOfWire(Wire wire) {
|
||||
this(wire, wire.p1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new instance
|
||||
*
|
||||
* @param wire the wire to modify
|
||||
* @param initialPos the initial position of the wire
|
||||
*/
|
||||
public ModificationOfWire(Wire wire, Vector initialPos) {
|
||||
public ModificationOfWire(Wire wire, Vector initialPos, String description) {
|
||||
this.description = description;
|
||||
p1 = initialPos;
|
||||
p2 = initialPos.add(wire.p2.sub(wire.p1));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return description;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the wire to modify
|
||||
*
|
||||
|
@ -10,9 +10,11 @@ import java.util.ArrayList;
|
||||
*/
|
||||
public final class Modifications implements Modification {
|
||||
private final ArrayList<Modification> modifications;
|
||||
private final String name;
|
||||
|
||||
private Modifications(ArrayList<Modification> modifications) {
|
||||
private Modifications(ArrayList<Modification> modifications, String name) {
|
||||
this.modifications = modifications;
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -21,16 +23,25 @@ public final class Modifications implements Modification {
|
||||
m.modify(circuit);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
* The builder to construct an instance
|
||||
*/
|
||||
public static final class Builder {
|
||||
private final ArrayList<Modification> list;
|
||||
private final String name;
|
||||
|
||||
/**
|
||||
* Creates a new instance
|
||||
*
|
||||
* @param name the name of this modification
|
||||
*/
|
||||
public Builder() {
|
||||
public Builder(String name) {
|
||||
this.name = name;
|
||||
list = new ArrayList<>();
|
||||
}
|
||||
|
||||
@ -58,7 +69,7 @@ public final class Modifications implements Modification {
|
||||
if (list.size() == 1)
|
||||
return list.get(0);
|
||||
else
|
||||
return new Modifications(list);
|
||||
return new Modifications(list, name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -3,6 +3,7 @@ package de.neemann.digital.gui.components.modification;
|
||||
import de.neemann.digital.core.element.Key;
|
||||
import de.neemann.digital.draw.elements.Circuit;
|
||||
import de.neemann.digital.draw.elements.VisualElement;
|
||||
import de.neemann.digital.lang.Lang;
|
||||
|
||||
/**
|
||||
* Modifies an attribute.
|
||||
@ -23,7 +24,7 @@ public class ModifyAttribute<VALUE> extends ModificationOfVisualElement {
|
||||
* @param value the new value
|
||||
*/
|
||||
public ModifyAttribute(VisualElement ve, Key<VALUE> key, VALUE value) {
|
||||
super(ve);
|
||||
super(ve, Lang.get("mod_setKey_N0_in_element", key.getName()));
|
||||
this.key = key;
|
||||
this.value = value;
|
||||
}
|
||||
|
@ -3,6 +3,7 @@ package de.neemann.digital.gui.components.modification;
|
||||
import de.neemann.digital.core.element.ElementAttributes;
|
||||
import de.neemann.digital.draw.elements.Circuit;
|
||||
import de.neemann.digital.draw.elements.VisualElement;
|
||||
import de.neemann.digital.lang.Lang;
|
||||
|
||||
/**
|
||||
* Sets all attributes of an element
|
||||
@ -19,7 +20,7 @@ public class ModifyAttributes extends ModificationOfVisualElement {
|
||||
* @param modified the new attributes
|
||||
*/
|
||||
public ModifyAttributes(VisualElement ve, ElementAttributes modified) {
|
||||
super(ve);
|
||||
super(ve, Lang.get("mod_setAttributes"));
|
||||
attributes = modified;
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,32 @@
|
||||
package de.neemann.digital.gui.components.modification;
|
||||
|
||||
import de.neemann.digital.core.element.ElementAttributes;
|
||||
import de.neemann.digital.draw.elements.Circuit;
|
||||
import de.neemann.digital.lang.Lang;
|
||||
|
||||
/**
|
||||
* Sets all attributes of a circuit
|
||||
* Created by hneemann on 30.05.17.
|
||||
*/
|
||||
public class ModifyCircuitAttributes implements Modification {
|
||||
private final ElementAttributes attributes;
|
||||
|
||||
/**
|
||||
* Creates a new instance
|
||||
*
|
||||
* @param attributes the attributes to set
|
||||
*/
|
||||
public ModifyCircuitAttributes(ElementAttributes attributes) {
|
||||
this.attributes = attributes;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void modify(Circuit circuit) {
|
||||
circuit.getAttributes().getValuesFrom(attributes);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return Lang.get("mod_circuitAttrModified");
|
||||
}
|
||||
}
|
@ -3,6 +3,7 @@ package de.neemann.digital.gui.components.modification;
|
||||
import de.neemann.digital.draw.elements.Circuit;
|
||||
import de.neemann.digital.draw.elements.VisualElement;
|
||||
import de.neemann.digital.draw.graphics.Vector;
|
||||
import de.neemann.digital.lang.Lang;
|
||||
|
||||
/**
|
||||
* Modifier which deletes an element
|
||||
@ -17,7 +18,7 @@ public class ModifyDeleteElement extends ModificationOfVisualElement {
|
||||
* @param initialPos its initial position
|
||||
*/
|
||||
public ModifyDeleteElement(VisualElement ve, Vector initialPos) {
|
||||
super(ve, initialPos);
|
||||
super(ve, initialPos, Lang.get("mod_deletedElement"));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -2,6 +2,7 @@ package de.neemann.digital.gui.components.modification;
|
||||
|
||||
import de.neemann.digital.draw.elements.Circuit;
|
||||
import de.neemann.digital.draw.graphics.Vector;
|
||||
import de.neemann.digital.lang.Lang;
|
||||
|
||||
/**
|
||||
* Modifier to delete all elements in a given rectangle
|
||||
@ -26,4 +27,9 @@ public class ModifyDeleteRect implements Modification {
|
||||
public void modify(Circuit circuit) {
|
||||
circuit.delete(min, max);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return Lang.get("mod_deletedSelection");
|
||||
}
|
||||
}
|
||||
|
@ -3,6 +3,7 @@ package de.neemann.digital.gui.components.modification;
|
||||
import de.neemann.digital.draw.elements.Circuit;
|
||||
import de.neemann.digital.draw.elements.Wire;
|
||||
import de.neemann.digital.draw.graphics.Vector;
|
||||
import de.neemann.digital.lang.Lang;
|
||||
|
||||
/**
|
||||
* Modifier to delete a wire
|
||||
@ -17,7 +18,7 @@ public class ModifyDeleteWire extends ModificationOfWire {
|
||||
* @param initialPos its initial position
|
||||
*/
|
||||
public ModifyDeleteWire(Wire wire, Vector initialPos) {
|
||||
super(wire, initialPos);
|
||||
super(wire, initialPos, Lang.get("mod_wireDeleted"));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -2,6 +2,7 @@ package de.neemann.digital.gui.components.modification;
|
||||
|
||||
import de.neemann.digital.draw.elements.Circuit;
|
||||
import de.neemann.digital.draw.elements.VisualElement;
|
||||
import de.neemann.digital.lang.Lang;
|
||||
|
||||
/**
|
||||
* Modifier to insert an element
|
||||
@ -23,4 +24,9 @@ public class ModifyInsertElement implements Modification {
|
||||
public void modify(Circuit circuit) {
|
||||
circuit.add(new VisualElement(element));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return Lang.get("mod_insertedElement");
|
||||
}
|
||||
}
|
||||
|
@ -3,6 +3,7 @@ package de.neemann.digital.gui.components.modification;
|
||||
import de.neemann.digital.draw.elements.Circuit;
|
||||
import de.neemann.digital.draw.elements.Wire;
|
||||
import de.neemann.digital.draw.graphics.Vector;
|
||||
import de.neemann.digital.lang.Lang;
|
||||
|
||||
/**
|
||||
* Modifier to insert a wire.
|
||||
@ -36,4 +37,9 @@ public class ModifyInsertWire implements Modification {
|
||||
else
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return Lang.get("mod_insertedWire");
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,33 @@
|
||||
package de.neemann.digital.gui.components.modification;
|
||||
|
||||
import de.neemann.digital.draw.elements.Circuit;
|
||||
import de.neemann.digital.lang.Lang;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
/**
|
||||
* Modifies the measurement ordering
|
||||
* Created by hneemann on 30.05.17.
|
||||
*/
|
||||
public class ModifyMeasurementOrdering implements Modification {
|
||||
private final ArrayList<String> names;
|
||||
|
||||
/**
|
||||
* Creates a new instance
|
||||
*
|
||||
* @param names the new ordering
|
||||
*/
|
||||
public ModifyMeasurementOrdering(ArrayList<String> names) {
|
||||
this.names = names;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void modify(Circuit circuit) {
|
||||
circuit.setMeasurementOrdering(names);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return Lang.get("mod_modifiedMeasurementOrdering");
|
||||
}
|
||||
}
|
@ -3,6 +3,7 @@ package de.neemann.digital.gui.components.modification;
|
||||
import de.neemann.digital.draw.elements.Circuit;
|
||||
import de.neemann.digital.draw.elements.VisualElement;
|
||||
import de.neemann.digital.draw.graphics.Vector;
|
||||
import de.neemann.digital.lang.Lang;
|
||||
|
||||
/**
|
||||
* Modifier to move and rotate a single visual element
|
||||
@ -19,7 +20,7 @@ public class ModifyMoveAndRotElement extends ModificationOfVisualElement {
|
||||
* @param initialPos its initial position
|
||||
*/
|
||||
public ModifyMoveAndRotElement(VisualElement ve, Vector initialPos) {
|
||||
super(ve, initialPos);
|
||||
super(ve, initialPos, Lang.get("mod_movedOrRotatedElement"));
|
||||
pos = ve.getPos();
|
||||
rotation = ve.getRotate();
|
||||
}
|
||||
|
@ -7,6 +7,7 @@ import de.neemann.digital.draw.elements.Wire;
|
||||
import de.neemann.digital.draw.graphics.Transform;
|
||||
import de.neemann.digital.draw.graphics.TransformRotate;
|
||||
import de.neemann.digital.draw.graphics.Vector;
|
||||
import de.neemann.digital.lang.Lang;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
@ -81,4 +82,8 @@ public class ModifyMoveSelected implements Modification {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return Lang.get("mod_movedSelected");
|
||||
}
|
||||
}
|
||||
|
@ -3,6 +3,7 @@ package de.neemann.digital.gui.components.modification;
|
||||
import de.neemann.digital.draw.elements.Circuit;
|
||||
import de.neemann.digital.draw.elements.Wire;
|
||||
import de.neemann.digital.draw.graphics.Vector;
|
||||
import de.neemann.digital.lang.Lang;
|
||||
|
||||
/**
|
||||
* Modifier to move a wire
|
||||
@ -18,7 +19,7 @@ public class ModifyMoveWire extends ModificationOfWire {
|
||||
* @param initialPos its initial position
|
||||
*/
|
||||
public ModifyMoveWire(Wire wire, Vector initialPos) {
|
||||
super(wire, initialPos);
|
||||
super(wire, initialPos, Lang.get("mod_movedWire"));
|
||||
delta = wire.getPos().sub(initialPos);
|
||||
}
|
||||
|
||||
|
@ -10,6 +10,7 @@ import java.awt.*;
|
||||
public abstract class ToolTipAction extends AbstractAction {
|
||||
private Icon icon;
|
||||
private String toolTipText;
|
||||
private ToolTipProvider toolTipProvider;
|
||||
private KeyStroke accelerator;
|
||||
|
||||
/**
|
||||
@ -60,6 +61,17 @@ public abstract class ToolTipAction extends AbstractAction {
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets a tool tip provider
|
||||
*
|
||||
* @param toolTipProvider the tool tip provider
|
||||
* @return this for call chaining
|
||||
*/
|
||||
public ToolTipAction setToolTipProvider(ToolTipProvider toolTipProvider) {
|
||||
this.toolTipProvider = toolTipProvider;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets an accelerator to the action
|
||||
*
|
||||
@ -131,11 +143,22 @@ public abstract class ToolTipAction extends AbstractAction {
|
||||
* @return a JButton associated with this action, contains only the icon
|
||||
*/
|
||||
public JButton createJButtonNoText() {
|
||||
JButton b = new JButton(this);
|
||||
if (toolTipText != null) {
|
||||
b.setToolTipText(toolTipText);
|
||||
JButton b;
|
||||
if (toolTipProvider == null) {
|
||||
b = new JButton(this);
|
||||
if (toolTipText != null) {
|
||||
b.setToolTipText(toolTipText);
|
||||
} else {
|
||||
b.setToolTipText(b.getText());
|
||||
}
|
||||
} else {
|
||||
b.setToolTipText(b.getText());
|
||||
b = new JButton(this) {
|
||||
@Override
|
||||
public String getToolTipText() {
|
||||
return toolTipProvider.getToolTip();
|
||||
}
|
||||
};
|
||||
ToolTipManager.sharedInstance().registerComponent(b);
|
||||
}
|
||||
b.setText(null);
|
||||
return b;
|
||||
@ -154,12 +177,22 @@ public abstract class ToolTipAction extends AbstractAction {
|
||||
* @return a JMenuItem associated with this action
|
||||
*/
|
||||
public JMenuItem createJMenuItem() {
|
||||
JMenuItem i = new JMenuItem(this);
|
||||
JMenuItem i;
|
||||
if (toolTipProvider == null) {
|
||||
i = new JMenuItem(this);
|
||||
if (toolTipText != null)
|
||||
i.setToolTipText(toolTipText);
|
||||
} else {
|
||||
i = new JMenuItem(this) {
|
||||
@Override
|
||||
public String getToolTipText() {
|
||||
return toolTipProvider.getToolTip();
|
||||
}
|
||||
};
|
||||
ToolTipManager.sharedInstance().registerComponent(i);
|
||||
}
|
||||
if (accelerator != null)
|
||||
i.setAccelerator(accelerator);
|
||||
if (toolTipText != null) {
|
||||
i.setToolTipText(toolTipText);
|
||||
}
|
||||
return i;
|
||||
}
|
||||
|
||||
|
12
src/main/java/de/neemann/gui/ToolTipProvider.java
Normal file
12
src/main/java/de/neemann/gui/ToolTipProvider.java
Normal file
@ -0,0 +1,12 @@
|
||||
package de.neemann.gui;
|
||||
|
||||
/**
|
||||
* Provides a dynamic tool tip
|
||||
* Created by hneemann on 30.05.17.
|
||||
*/
|
||||
public interface ToolTipProvider {
|
||||
/**
|
||||
* @return the tooltip
|
||||
*/
|
||||
String getToolTip();
|
||||
}
|
@ -645,6 +645,23 @@ Sind evtl. die Namen der Variablen nicht eindeutig?</string>
|
||||
<string name="key_defTreeSelect">Baumansicht beim Start aktivieren.</string>
|
||||
<string name="key_defTreeSelect_tt">Wenn gesetzt, wird die Baumansicht beim Start automatisch aktiviert.</string>
|
||||
|
||||
<string name="mod_insertWire">Leitung 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_setAttributes">Attribute in Element verändert.</string>
|
||||
<string name="mod_wireDeleted">Leitung gelöscht.</string>
|
||||
<string name="mod_movedOrRotatedElement">Element verschoben oder rotiert.</string>
|
||||
<string name="mod_movedWire">Leitung verschoben.</string>
|
||||
<string name="mod_deletedSelection">Auswahl gelöscht.</string>
|
||||
<string name="mod_insertedElement">Element eingefügt.</string>
|
||||
<string name="mod_deletedElement">Element entfernt.</string>
|
||||
<string name="mod_insertedWire">Leitung eingefügt.</string>
|
||||
<string name="mod_movedSelected">Auswahl verschoben.</string>
|
||||
<string name="mod_undo_N">Rückgängig: {0}</string>
|
||||
<string name="mod_redo_N">Wiederherstellen: {0}</string>
|
||||
<string name="mod_circuitAttrModified">Schaltungsattribute verändert.</string>
|
||||
<string name="mod_modifiedMeasurementOrdering">Reihenfolge der Messwerte verändert.</string>
|
||||
|
||||
<string name="lib_Logic">Logisch</string>
|
||||
<string name="lib_arithmetic">Arithmetik</string>
|
||||
<string name="lib_flipFlops">FlipFlops</string>
|
||||
|
@ -635,6 +635,23 @@ The names of the variables may not be unique.</string>
|
||||
<string name="key_defTreeSelect">Component tree view is visible at startup.</string>
|
||||
<string name="key_defTreeSelect_tt">If set, the component tree view is enabled at startup.</string>
|
||||
|
||||
<string name="mod_insertWire">Inserted wire.</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_setAttributes">Attributes of component modified.</string>
|
||||
<string name="mod_wireDeleted">Wire deleted.</string>
|
||||
<string name="mod_movedOrRotatedElement">Component moved or rotated.</string>
|
||||
<string name="mod_movedWire">Wire moved.</string>
|
||||
<string name="mod_deletedSelection">Selection deleted.</string>
|
||||
<string name="mod_insertedElement">Component inserted.</string>
|
||||
<string name="mod_deletedElement">Component deleted.</string>
|
||||
<string name="mod_insertedWire">Wire inserted.</string>
|
||||
<string name="mod_movedSelected">Selection moved.</string>
|
||||
<string name="mod_undo_N">Undo: {0}</string>
|
||||
<string name="mod_redo_N">Redo: {0}</string>
|
||||
<string name="mod_circuitAttrModified">Modified circuit attributes.</string>
|
||||
<string name="mod_modifiedMeasurementOrdering">Ordered measurements.</string>
|
||||
|
||||
<string name="lib_Logic">Logic</string>
|
||||
<string name="lib_arithmetic">Arithmetic</string>
|
||||
<string name="lib_flipFlops">FlipFlops</string>
|
||||
|
Loading…
x
Reference in New Issue
Block a user