mirror of
https://github.com/hneemann/Digital.git
synced 2025-09-16 08:25:09 -04:00
implements a new tunnel naming feature
This commit is contained in:
parent
0856515b28
commit
d74741e6c8
@ -136,6 +136,7 @@ public class CircuitComponent extends JComponent implements ChangedListener, Lib
|
||||
private TutorialListener tutorialListener;
|
||||
private boolean toolTipHighlighted = false;
|
||||
private NetList toolTipNetList;
|
||||
private String lastUsedTunnelName;
|
||||
|
||||
/**
|
||||
* Creates a new instance
|
||||
@ -791,6 +792,18 @@ public class CircuitComponent extends JComponent implements ChangedListener, Lib
|
||||
* @param element the element to insert
|
||||
*/
|
||||
public void setPartToInsert(VisualElement element) {
|
||||
if (element.equalsDescription(Tunnel.DESCRIPTION)) {
|
||||
if (lastUsedTunnelName != null) {
|
||||
CopiedElementLabelRenamer.LabelInstance li =
|
||||
CopiedElementLabelRenamer.LabelInstance.
|
||||
create(Tunnel.DESCRIPTION.getName(), lastUsedTunnelName);
|
||||
if (li != null) {
|
||||
lastUsedTunnelName = li.getLabel(1);
|
||||
}
|
||||
element.setAttribute(Keys.NETNAME, lastUsedTunnelName);
|
||||
}
|
||||
}
|
||||
|
||||
parent.ensureModelIsStopped();
|
||||
mouseInsertElement.activate(element);
|
||||
Point point = MouseInfo.getPointerInfo().getLocation();
|
||||
@ -1168,6 +1181,10 @@ public class CircuitComponent extends JComponent implements ChangedListener, Lib
|
||||
attributeDialog.disableOk();
|
||||
|
||||
ElementAttributes modified = attributeDialog.showDialog();
|
||||
if (elementType == Tunnel.DESCRIPTION) {
|
||||
if (modified.contains(Keys.NETNAME))
|
||||
lastUsedTunnelName = modified.get(Keys.NETNAME);
|
||||
}
|
||||
if (modified != null && !locked) {
|
||||
Modification<Circuit> mod = new ModifyAttributes(element, modified);
|
||||
modify(checkNetRename(element, modified, mod));
|
||||
|
@ -95,7 +95,12 @@ public class CopiedElementLabelRenamer {
|
||||
static final class LabelInstance {
|
||||
|
||||
static LabelInstance create(VisualElement ve) {
|
||||
String fullLabel = ve.getElementAttributes().getLabel();
|
||||
return create(ve.getElementName(), ve.getElementAttributes().getLabel());
|
||||
}
|
||||
|
||||
static LabelInstance create(String elementName, String fullLabel) {
|
||||
if (fullLabel == null)
|
||||
return null;
|
||||
|
||||
int pos = fullLabel.length();
|
||||
if (pos == 0)
|
||||
@ -113,7 +118,7 @@ public class CopiedElementLabelRenamer {
|
||||
}
|
||||
|
||||
String label = fullLabel.substring(0, pos);
|
||||
LabelClass lc = new LabelClass(ve.getElementName(), label);
|
||||
LabelClass lc = new LabelClass(elementName, label);
|
||||
|
||||
return new LabelInstance(lc, number);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user