allows to open the attribute dialog in locked mode, closes #291

This commit is contained in:
hneemann 2019-07-23 08:12:10 +02:00
parent 32835fcda3
commit a7228a8542
2 changed files with 20 additions and 8 deletions

View File

@ -40,6 +40,7 @@ public class AttributeDialog extends JDialog {
private final ElementAttributes modifiedAttributes;
private final JPanel buttonPanel;
private final ConstraintsBuilder constraints;
private final AbstractAction okAction;
private HashMap<Key, JCheckBox> checkBoxes;
private JComponent topMostTextComponent;
private VisualElement visualElement;
@ -163,7 +164,7 @@ public class AttributeDialog extends JDialog {
getContentPane().add(new JScrollPane(panel));
JButton okButton = new JButton(new AbstractAction(Lang.get("ok")) {
okAction = new AbstractAction(Lang.get("ok")) {
@Override
public void actionPerformed(ActionEvent e) {
try {
@ -172,7 +173,8 @@ public class AttributeDialog extends JDialog {
new ErrorMessage(Lang.get("msg_errorEditingValue")).addCause(err).show(AttributeDialog.this);
}
}
});
};
JButton okButton = new JButton(okAction);
final AbstractAction cancel = new AbstractAction(Lang.get("cancel")) {
@Override
@ -347,6 +349,14 @@ public class AttributeDialog extends JDialog {
return this;
}
/**
* Disables the ok button
*/
public void disableOk() {
okAction.setEnabled(false);
okPressed = false;
}
private static final class EditorHolder<T> {
private final Editor<T> e;
private final Key<T> key;

View File

@ -1069,8 +1069,12 @@ public class CircuitComponent extends JComponent implements ChangedListener, Lib
}
}.setToolTip(Lang.get("attr_help_tt")));
boolean locked = isLocked();
if (isLocked())
attributeDialog.disableOk();
ElementAttributes modified = attributeDialog.showDialog();
if (modified != null)
if (modified != null && !locked)
modify(new ModifyAttributes(element, modified));
}
} catch (ElementNotFoundException ex) {
@ -1435,11 +1439,9 @@ public class CircuitComponent extends JComponent implements ChangedListener, Lib
Vector pos = getPosVector(e);
if (mouse.isSecondaryClick(e)) {
if (!isLocked()) {
VisualElement vp = getVisualElement(pos, true);
if (vp != null)
editAttributes(vp, e);
}
VisualElement vp = getVisualElement(pos, true);
if (vp != null)
editAttributes(vp, e);
} else if (mouse.isPrimaryClick(e)) {
VisualElement vp = getVisualElement(pos, false);
if (vp != null) {