mirror of
https://github.com/hneemann/Digital.git
synced 2025-09-28 07:28:20 -04:00
Added + and - shortcut to modify the components input count.
This commit is contained in:
parent
f23abb6a7c
commit
5c010f8396
@ -237,7 +237,7 @@ public class ElementLibrary implements Iterable<ElementLibrary.ElementContainer>
|
||||
* If not found its tried to load it.
|
||||
*
|
||||
* @param elementName the elements name
|
||||
* @return the {@link ElementTypeDescription} ore null if not found
|
||||
* @return the {@link ElementTypeDescription}
|
||||
* @throws ElementNotFoundException ElementNotFoundException
|
||||
*/
|
||||
public ElementTypeDescription getElementType(String elementName) throws ElementNotFoundException {
|
||||
|
@ -165,6 +165,22 @@ public class CircuitComponent extends JComponent implements Circuit.ChangedListe
|
||||
}
|
||||
}.setAccelerator("D").enableAcceleratorIn(this);
|
||||
|
||||
new ToolTipAction("plus") {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
if (activeMouseController instanceof MouseControllerNormal)
|
||||
addToInputCount(getPosVector(lastMousePos.x, lastMousePos.y), 1);
|
||||
}
|
||||
}.setAccelerator("PLUS").enableAcceleratorIn(this);
|
||||
|
||||
new ToolTipAction("minus") {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
if (activeMouseController instanceof MouseControllerNormal)
|
||||
addToInputCount(getPosVector(lastMousePos.x, lastMousePos.y), -1);
|
||||
}
|
||||
}.setAccelerator("MINUS").enableAcceleratorIn(this);
|
||||
|
||||
new ToolTipAction(Lang.get("menu_programDiode")) {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
@ -304,6 +320,21 @@ public class CircuitComponent extends JComponent implements Circuit.ChangedListe
|
||||
}
|
||||
}
|
||||
|
||||
private void addToInputCount(Vector pos, int delta) {
|
||||
VisualElement ve = circuit.getElementAt(pos);
|
||||
if (ve != null) {
|
||||
try {
|
||||
if (library.getElementType(ve.getElementName()).hasAttribute(Keys.INPUT_COUNT)) {
|
||||
int number = ve.getElementAttributes().get(Keys.INPUT_COUNT) + delta;
|
||||
if (number >= Keys.INPUT_COUNT.getMin() && number <= Keys.INPUT_COUNT.getMax())
|
||||
modify(new ModifyAttribute<>(ve, Keys.INPUT_COUNT, number));
|
||||
}
|
||||
} catch (ElementNotFoundException e) {
|
||||
// do nothing on error
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Apply a modification
|
||||
*
|
||||
@ -890,7 +921,7 @@ public class CircuitComponent extends JComponent implements Circuit.ChangedListe
|
||||
}
|
||||
|
||||
void activate() {
|
||||
if (activeMouseController != null)
|
||||
if (activeMouseController != null && activeMouseController != this)
|
||||
activeMouseController.deactivate();
|
||||
activeMouseController = this;
|
||||
deleteAction.setActive(false);
|
||||
|
@ -251,5 +251,7 @@
|
||||
<shortcut key="ESC">Abbrechen der aktuellen Aktion.</shortcut>
|
||||
<shortcut key="Entfernen">Löschen der selektierten Elemente.</shortcut>
|
||||
<shortcut key="Rückschritt">Löschen der selektierten Elemente.</shortcut>
|
||||
<shortcut key="+">Erhöht die Anzahl der Eingänge in dem Element auf welches die Maus zeigt.</shortcut>
|
||||
<shortcut key="-">Erniedrigt die Anzahl der Eingänge in dem Element auf welches die Maus zeigt.</shortcut>
|
||||
</chapter>
|
||||
</root>
|
||||
|
@ -240,5 +240,7 @@
|
||||
<shortcut key="ESC">Abort the actual action.</shortcut>
|
||||
<shortcut key="Del">Removes the selected components.</shortcut>
|
||||
<shortcut key="Backspace">Removes the selected components.</shortcut>
|
||||
<shortcut key="+">Increases the number of inputs at the component the mouse points to.</shortcut>
|
||||
<shortcut key="-">Decreases the number of inputs at the component the mouse points to.</shortcut>
|
||||
</chapter>
|
||||
</root>
|
Loading…
x
Reference in New Issue
Block a user