mirror of
https://github.com/hneemann/Digital.git
synced 2025-09-27 06:51:37 -04:00
disable editor fields in group edit mode
This commit is contained in:
parent
be49ce68e6
commit
a6116ca7b8
@ -68,8 +68,8 @@ public class AttributeDialog extends JDialog {
|
||||
* @param parent the parent
|
||||
* @param pos the position to pop up the dialog
|
||||
* @param list the list of keys which are to edit
|
||||
* @param elementAttributes the data stored
|
||||
* @param addCheckBoxes add checkboxes behind the attributes
|
||||
* @param elementAttributes the initial data to modify
|
||||
* @param addCheckBoxes th true check boxes behind the attributes are added
|
||||
*/
|
||||
public AttributeDialog(Component parent, Point pos, java.util.List<Key> list, ElementAttributes elementAttributes, boolean addCheckBoxes) {
|
||||
super(SwingUtilities.getWindowAncestor(parent), Lang.get("attr_dialogTitle"), ModalityType.APPLICATION_MODAL);
|
||||
@ -95,9 +95,11 @@ public class AttributeDialog extends JDialog {
|
||||
if (checkBoxes == null)
|
||||
checkBoxes = new HashMap<>();
|
||||
JCheckBox checkBox = new JCheckBox();
|
||||
checkBox.setSelected(true);
|
||||
checkBox.setToolTipText(Lang.get("msg_modifyThisAttribute"));
|
||||
checkBoxes.put(key, checkBox);
|
||||
panel.add(checkBox, constrains.x(2));
|
||||
checkBox.addChangeListener(event -> e.setEnabled(checkBox.isSelected()));
|
||||
}
|
||||
constrains.nextRow();
|
||||
|
||||
|
@ -23,7 +23,14 @@ public interface Editor<T> {
|
||||
* @param key the key which is to edit
|
||||
* @param elementAttributes the attributes
|
||||
* @param dialog the containing dialog
|
||||
* @param constrains the constrains used to place the components in the panel
|
||||
* @param constrains the constrains used to place the components in the panel
|
||||
*/
|
||||
void addToPanel(JPanel panel, Key key, ElementAttributes elementAttributes, AttributeDialog dialog, ConstrainsBuilder constrains);
|
||||
|
||||
/**
|
||||
* Used to enable/disable the component.
|
||||
*
|
||||
* @param enabled true enables the component
|
||||
*/
|
||||
void setEnabled(boolean enabled);
|
||||
}
|
||||
|
@ -95,14 +95,16 @@ public final class EditorFactory {
|
||||
public static abstract class LabelEditor<T> implements Editor<T> {
|
||||
private AttributeDialog attributeDialog;
|
||||
private boolean labelAtTop = false;
|
||||
private JComponent component;
|
||||
private JLabel label;
|
||||
|
||||
@Override
|
||||
public void addToPanel(JPanel panel, Key key, ElementAttributes elementAttributes, AttributeDialog attributeDialog, ConstrainsBuilder constrains) {
|
||||
this.attributeDialog = attributeDialog;
|
||||
JLabel label = new JLabel(key.getName() + ": ");
|
||||
label = new JLabel(key.getName() + ": ");
|
||||
final String description = new LineBreaker().toHTML().breakLines(key.getDescription());
|
||||
label.setToolTipText(description);
|
||||
JComponent component = getComponent(elementAttributes);
|
||||
component = getComponent(elementAttributes);
|
||||
component.setToolTipText(description);
|
||||
if (labelAtTop) {
|
||||
panel.add(label, constrains.width(2));
|
||||
@ -129,6 +131,12 @@ public final class EditorFactory {
|
||||
*/
|
||||
protected abstract JComponent getComponent(ElementAttributes elementAttributes);
|
||||
|
||||
@Override
|
||||
public void setEnabled(boolean enabled) {
|
||||
label.setEnabled(enabled);
|
||||
component.setEnabled(enabled);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the position of the label
|
||||
*
|
||||
@ -259,6 +267,11 @@ public final class EditorFactory {
|
||||
public void addToPanel(JPanel panel, Key key, ElementAttributes elementAttributes, AttributeDialog attributeDialog, ConstrainsBuilder constrains) {
|
||||
panel.add(bool, constrains.width(2));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setEnabled(boolean enabled) {
|
||||
bool.setEnabled(enabled);
|
||||
}
|
||||
}
|
||||
|
||||
private final static class ColorEditor extends LabelEditor<Color> {
|
||||
|
Loading…
x
Reference in New Issue
Block a user