mirror of
https://gitee.com/jmix/cuba.git
synced 2024-12-03 03:38:33 +08:00
Different behaviour of setEnabled method of desktop and web containers #PL-2869
This commit is contained in:
parent
eab9a2fe1d
commit
2d8bd17158
@ -94,6 +94,10 @@ public abstract class DesktopAbstractBox
|
||||
|
||||
DesktopContainerHelper.assignContainer(component, this);
|
||||
|
||||
if (component instanceof DesktopAbstractComponent && !isEnabledWithParent()) {
|
||||
((DesktopAbstractComponent) component).setParentEnabled(false);
|
||||
}
|
||||
|
||||
requestRepaint();
|
||||
}
|
||||
|
||||
@ -154,6 +158,10 @@ public abstract class DesktopAbstractBox
|
||||
|
||||
DesktopContainerHelper.assignContainer(component, this);
|
||||
|
||||
if (component instanceof DesktopAbstractComponent && !isEnabledWithParent()) {
|
||||
((DesktopAbstractComponent) component).setParentEnabled(false);
|
||||
}
|
||||
|
||||
requestRepaint();
|
||||
}
|
||||
|
||||
@ -181,6 +189,10 @@ public abstract class DesktopAbstractBox
|
||||
expandedComponent = null;
|
||||
}
|
||||
|
||||
if (component instanceof DesktopAbstractComponent && !isEnabledWithParent()) {
|
||||
((DesktopAbstractComponent) component).setParentEnabled(true);
|
||||
}
|
||||
|
||||
requestRepaint();
|
||||
}
|
||||
|
||||
@ -326,4 +338,23 @@ public abstract class DesktopAbstractBox
|
||||
public void setExpanded(boolean expanded) {
|
||||
layoutAdapter.setExpandLayout(expanded);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setEnabled(boolean enabled) {
|
||||
if (isEnabled() != enabled) {
|
||||
super.setEnabled(enabled);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateEnabled() {
|
||||
super.updateEnabled();
|
||||
|
||||
boolean resultEnabled = isEnabledWithParent();
|
||||
for (Component component : ownComponents) {
|
||||
if (component instanceof DesktopAbstractComponent) {
|
||||
((DesktopAbstractComponent) component).setParentEnabled(resultEnabled);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -30,6 +30,9 @@ public abstract class DesktopAbstractComponent<C extends JComponent>
|
||||
implements
|
||||
DesktopComponent, Component.Wrapper, Component.HasXmlDescriptor, Component.BelongToFrame {
|
||||
|
||||
public static final String SWING_PROPERTY_CLASS = "cubaClass";
|
||||
public static final String SWING_PROPERTY_ID = "cubaId";
|
||||
|
||||
protected C impl;
|
||||
|
||||
protected DesktopContainer container;
|
||||
@ -45,18 +48,19 @@ public abstract class DesktopAbstractComponent<C extends JComponent>
|
||||
|
||||
protected Log log = LogFactory.getLog(getClass());
|
||||
|
||||
protected static final String swingPropertyId = "cubaId";
|
||||
public static final String swingPropertyClass = "cubaClass";
|
||||
protected boolean visible = true;
|
||||
protected boolean enabled = true;
|
||||
|
||||
public boolean visible = true;
|
||||
private String debugId;
|
||||
protected boolean parentEnabled = true;
|
||||
|
||||
protected String debugId;
|
||||
|
||||
protected C getImpl() {
|
||||
return impl;
|
||||
}
|
||||
|
||||
protected String getSwingPropertyId() {
|
||||
return swingPropertyId;
|
||||
return SWING_PROPERTY_ID;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@ -116,7 +120,7 @@ public abstract class DesktopAbstractComponent<C extends JComponent>
|
||||
}
|
||||
|
||||
protected void assignClassDebugProperty(JComponent c) {
|
||||
c.putClientProperty(swingPropertyClass, getClass().getSimpleName());
|
||||
c.putClientProperty(SWING_PROPERTY_CLASS, getClass().getSimpleName());
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -131,16 +135,26 @@ public abstract class DesktopAbstractComponent<C extends JComponent>
|
||||
|
||||
@Override
|
||||
public boolean isEnabled() {
|
||||
return impl.isEnabled();
|
||||
return DesktopComponentsHelper.isRecursivelyEnabled(getComposition());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setEnabled(boolean enabled) {
|
||||
getComposition().setEnabled(enabled);
|
||||
this.enabled = enabled;
|
||||
|
||||
updateEnabled();
|
||||
}
|
||||
|
||||
protected void updateEnabled() {
|
||||
getComposition().setEnabled(isEnabledWithParent());
|
||||
|
||||
requestContainerUpdate();
|
||||
}
|
||||
|
||||
protected boolean isEnabledWithParent() {
|
||||
return enabled && parentEnabled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isVisible() {
|
||||
return DesktopComponentsHelper.isRecursivelyVisible(getComposition());
|
||||
@ -258,6 +272,16 @@ public abstract class DesktopAbstractComponent<C extends JComponent>
|
||||
public void setExpanded(boolean expanded) {
|
||||
}
|
||||
|
||||
public boolean isParentEnabled() {
|
||||
return parentEnabled;
|
||||
}
|
||||
|
||||
public void setParentEnabled(boolean parentEnabled) {
|
||||
this.parentEnabled = parentEnabled;
|
||||
|
||||
updateEnabled();
|
||||
}
|
||||
|
||||
/**
|
||||
* Default formatter for {@link DesktopLabel} and {@link DesktopTextField}
|
||||
*/
|
||||
|
@ -1569,9 +1569,19 @@ public abstract class DesktopAbstractTable<C extends JXTable>
|
||||
|
||||
@Override
|
||||
public void setEnabled(boolean enabled) {
|
||||
impl.setEnabled(enabled);
|
||||
if (isEnabled() != enabled) {
|
||||
super.setEnabled(enabled);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateEnabled() {
|
||||
super.updateEnabled();
|
||||
|
||||
impl.setEnabled(isEnabledWithParent());
|
||||
|
||||
if (buttonsPanel != null) {
|
||||
buttonsPanel.setEnabled(enabled);
|
||||
((DesktopButtonsPanel)buttonsPanel).setParentEnabled(isEnabledWithParent());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -52,7 +52,6 @@ public abstract class DesktopAbstractTextField<T extends JTextComponent> extends
|
||||
protected MetaPropertyPath metaPropertyPath;
|
||||
|
||||
protected boolean editable = true;
|
||||
protected boolean enabled = true;
|
||||
|
||||
protected int maxLength;
|
||||
protected boolean trimming = true;
|
||||
@ -112,17 +111,12 @@ public abstract class DesktopAbstractTextField<T extends JTextComponent> extends
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEnabled() {
|
||||
return enabled;
|
||||
}
|
||||
public void updateEnabled() {
|
||||
super.updateEnabled();
|
||||
|
||||
@Override
|
||||
public void setEnabled(boolean enabled) {
|
||||
this.enabled = enabled;
|
||||
if (impl != null) {
|
||||
impl.setEnabled(enabled);
|
||||
impl.setEnabled(isEnabledWithParent());
|
||||
}
|
||||
requestContainerUpdate();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -77,7 +77,7 @@ public class DesktopButton extends DesktopAbstractComponent<JButton> implements
|
||||
setDescription(description);
|
||||
}
|
||||
|
||||
impl.setEnabled(action.isEnabled());
|
||||
setEnabled(action.isEnabled());
|
||||
setVisible(action.isVisible());
|
||||
|
||||
if (action.getIcon() != null) {
|
||||
|
@ -5,13 +5,10 @@
|
||||
|
||||
package com.haulmont.cuba.desktop.gui.components;
|
||||
|
||||
import com.haulmont.cuba.gui.components.Button;
|
||||
import com.haulmont.cuba.gui.components.ButtonsPanel;
|
||||
import com.haulmont.cuba.gui.components.Component;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
|
||||
/**
|
||||
* @author krivopustov
|
||||
@ -23,17 +20,12 @@ public class DesktopButtonsPanel extends DesktopHBox implements ButtonsPanel {
|
||||
setSpacing(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setEnabled(boolean enabled) {
|
||||
Collection<Component> components = getComponents();
|
||||
for (Component button : components) {
|
||||
button.setEnabled(enabled);
|
||||
}
|
||||
}
|
||||
|
||||
public void setFocusableForAllButtons(boolean focusable) {
|
||||
for (Component button : getComponents()) {
|
||||
JComponent jButton = DesktopComponentsHelper.unwrap(button);
|
||||
if (button instanceof DesktopButton) {
|
||||
((DesktopButton) button).setShouldBeFocused(focusable);
|
||||
}
|
||||
jButton.setFocusable(focusable);
|
||||
}
|
||||
}
|
||||
|
@ -37,7 +37,6 @@ public class DesktopCheckBox extends DesktopAbstractField<JCheckBox> implements
|
||||
protected Object prevValue;
|
||||
|
||||
protected boolean editable = true;
|
||||
protected boolean enabled = true;
|
||||
|
||||
public DesktopCheckBox() {
|
||||
impl = new JCheckBox();
|
||||
@ -181,18 +180,13 @@ public class DesktopCheckBox extends DesktopAbstractField<JCheckBox> implements
|
||||
@Override
|
||||
public void setEditable(boolean editable) {
|
||||
this.editable = editable;
|
||||
impl.setEnabled(editable && enabled);
|
||||
|
||||
updateEnabled();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setEnabled(boolean enabled) {
|
||||
this.enabled = enabled;
|
||||
impl.setEnabled(editable && enabled);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEnabled() {
|
||||
return enabled;
|
||||
public void updateEnabled() {
|
||||
impl.setEnabled(editable && isEnabledWithParent());
|
||||
}
|
||||
|
||||
protected void updateInstance() {
|
||||
|
@ -303,6 +303,32 @@ public class DesktopComponentsHelper {
|
||||
return component.isVisible() && (component.getParent() == null || isRecursivelyVisible(component.getParent()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines whether component will be displayed on the screen.
|
||||
*
|
||||
* @param component component
|
||||
* @return true if the component and all of its ancestors are visible
|
||||
*/
|
||||
public static boolean isRecursivelyEnabled(java.awt.Component component) {
|
||||
if (component.getParent() instanceof JTabbedPane) {
|
||||
JTabbedPane jTabbedPane = (JTabbedPane) component.getParent();
|
||||
|
||||
boolean tabVisible = false;
|
||||
for (java.awt.Component childComponent : jTabbedPane.getComponents()) {
|
||||
if (childComponent == component) {
|
||||
tabVisible = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!tabVisible) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return component.isEnabled() && (component.getParent() == null || isRecursivelyEnabled(component.getParent()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines real size of HTML label with text on screen.
|
||||
*
|
||||
|
@ -383,14 +383,11 @@ public class DesktopDateField extends DesktopAbstractField<JPanel> implements Da
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEnabled() {
|
||||
return datePicker.isEnabled();
|
||||
}
|
||||
public void updateEnabled() {
|
||||
super.updateEnabled();
|
||||
|
||||
@Override
|
||||
public void setEnabled(boolean enabled) {
|
||||
datePicker.setEnabled(enabled);
|
||||
timeField.setEnabled(enabled);
|
||||
datePicker.setEnabled(isEnabledWithParent());
|
||||
timeField.setEnabled(isEnabledWithParent());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -44,8 +44,9 @@ public class DesktopFieldGroup extends DesktopAbstractComponent<JPanel> implemen
|
||||
protected Datasource datasource;
|
||||
protected int rows;
|
||||
protected int cols = 1;
|
||||
|
||||
protected boolean editable = true;
|
||||
protected boolean enabled = true;
|
||||
|
||||
protected boolean borderVisible = false;
|
||||
|
||||
protected Map<String, FieldConfig> fields = new LinkedHashMap<>();
|
||||
@ -258,7 +259,7 @@ public class DesktopFieldGroup extends DesktopAbstractComponent<JPanel> implemen
|
||||
((Editable) component).setEditable(editable);
|
||||
}
|
||||
if (fieldLabels.containsKey(field)) {
|
||||
fieldLabels.get(field).setEnabled(editable);
|
||||
fieldLabels.get(field).setEnabled(editable && isEnabledWithParent());
|
||||
}
|
||||
}
|
||||
|
||||
@ -298,6 +299,16 @@ public class DesktopFieldGroup extends DesktopAbstractComponent<JPanel> implemen
|
||||
if (component != null) {
|
||||
component.setEnabled(enabled);
|
||||
}
|
||||
if (fieldLabels.containsKey(field)) {
|
||||
fieldLabels.get(field).setEnabled(enabled && isEnabledWithParent());
|
||||
}
|
||||
}
|
||||
|
||||
protected void doSetParentEnabled(FieldConfig field, boolean enabled) {
|
||||
Component component = fieldComponents.get(field);
|
||||
if (component instanceof DesktopAbstractComponent) {
|
||||
((DesktopAbstractComponent) component).setParentEnabled(enabled);
|
||||
}
|
||||
if (fieldLabels.containsKey(field)) {
|
||||
fieldLabels.get(field).setEnabled(enabled);
|
||||
}
|
||||
@ -319,16 +330,18 @@ public class DesktopFieldGroup extends DesktopAbstractComponent<JPanel> implemen
|
||||
|
||||
@Override
|
||||
public void setEnabled(boolean enabled) {
|
||||
this.enabled = enabled;
|
||||
|
||||
for (FieldConfig field : fields.values()) {
|
||||
doSetEnabled(field, enabled && !disabledFields.contains(field));
|
||||
if (isEnabled() != enabled) {
|
||||
super.setEnabled(enabled);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEnabled() {
|
||||
return enabled;
|
||||
public void updateEnabled() {
|
||||
super.updateEnabled();
|
||||
|
||||
for (FieldConfig field : fields.values()) {
|
||||
doSetParentEnabled(field, parentEnabled && enabled && !disabledFields.contains(field));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -692,6 +705,11 @@ public class DesktopFieldGroup extends DesktopAbstractComponent<JPanel> implemen
|
||||
jComponent.putClientProperty(getSwingPropertyId(), fieldConfig.getId());
|
||||
impl.add(jComponent, cell);
|
||||
|
||||
if (fieldComponent instanceof DesktopAbstractComponent && !isEnabledWithParent()) {
|
||||
((DesktopAbstractComponent) fieldComponent).setParentEnabled(false);
|
||||
label.setEnabled(false);
|
||||
}
|
||||
|
||||
if (repaintRequired) {
|
||||
impl.validate();
|
||||
impl.repaint();
|
||||
|
@ -115,6 +115,10 @@ public class DesktopGridLayout extends DesktopAbstractComponent<JPanel> implemen
|
||||
|
||||
DesktopContainerHelper.assignContainer(component, this);
|
||||
|
||||
if (component instanceof DesktopAbstractComponent && !isEnabledWithParent()) {
|
||||
((DesktopAbstractComponent) component).setParentEnabled(false);
|
||||
}
|
||||
|
||||
requestRepaint();
|
||||
}
|
||||
|
||||
@ -176,6 +180,10 @@ public class DesktopGridLayout extends DesktopAbstractComponent<JPanel> implemen
|
||||
|
||||
DesktopContainerHelper.assignContainer(component, this);
|
||||
|
||||
if (component instanceof DesktopAbstractComponent && !isEnabledWithParent()) {
|
||||
((DesktopAbstractComponent) component).setParentEnabled(false);
|
||||
}
|
||||
|
||||
requestRepaint();
|
||||
}
|
||||
|
||||
@ -215,6 +223,10 @@ public class DesktopGridLayout extends DesktopAbstractComponent<JPanel> implemen
|
||||
|
||||
DesktopContainerHelper.assignContainer(component, null);
|
||||
|
||||
if (component instanceof DesktopAbstractComponent && !isEnabledWithParent()) {
|
||||
((DesktopAbstractComponent) component).setParentEnabled(true);
|
||||
}
|
||||
|
||||
requestRepaint();
|
||||
}
|
||||
|
||||
@ -288,4 +300,23 @@ public class DesktopGridLayout extends DesktopAbstractComponent<JPanel> implemen
|
||||
|
||||
requestContainerUpdate();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setEnabled(boolean enabled) {
|
||||
if (isEnabled() != enabled) {
|
||||
super.setEnabled(enabled);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateEnabled() {
|
||||
super.updateEnabled();
|
||||
|
||||
boolean resultEnabled = isEnabledWithParent();
|
||||
for (Component component : ownComponents) {
|
||||
if (component instanceof DesktopAbstractComponent) {
|
||||
((DesktopAbstractComponent) component).setParentEnabled(resultEnabled);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -66,7 +66,6 @@ public class DesktopLookupField extends DesktopAbstractOptionsField<JComponent>
|
||||
protected JPanel composition;
|
||||
|
||||
protected DefaultValueFormatter valueFormatter;
|
||||
protected boolean enabled = true;
|
||||
protected String inputPrompt;
|
||||
|
||||
public DesktopLookupField() {
|
||||
@ -489,22 +488,20 @@ public class DesktopLookupField extends DesktopAbstractOptionsField<JComponent>
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setEnabled(boolean enabled) {
|
||||
this.enabled = enabled;
|
||||
comboBox.setEnabled(enabled);
|
||||
textField.setEnabled(enabled);
|
||||
public void updateEnabled() {
|
||||
super.updateEnabled();
|
||||
|
||||
comboBox.setFocusable(enabled);
|
||||
textField.setFocusable(enabled);
|
||||
boolean resultEnabled = isEnabledWithParent();
|
||||
|
||||
comboBox.setEnabled(resultEnabled);
|
||||
textField.setEnabled(resultEnabled);
|
||||
|
||||
comboBox.setFocusable(resultEnabled);
|
||||
textField.setFocusable(resultEnabled);
|
||||
|
||||
updateMissingValueState();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEnabled() {
|
||||
return enabled;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getAlternativeDebugId() {
|
||||
if (id != null) {
|
||||
|
@ -130,9 +130,10 @@ public class DesktopLookupPickerField extends DesktopLookupField implements Look
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setEnabled(boolean enabled){
|
||||
super.setEnabled(enabled);
|
||||
pickerField.setEnabled(enabled);
|
||||
public void updateEnabled() {
|
||||
super.updateEnabled();
|
||||
|
||||
pickerField.setParentEnabled(isEnabledWithParent());
|
||||
}
|
||||
|
||||
private class Picker extends com.haulmont.cuba.desktop.sys.vcl.Picker {
|
||||
|
@ -342,14 +342,11 @@ public class DesktopOptionsGroup
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEnabled() {
|
||||
return enabled;
|
||||
}
|
||||
public void updateEnabled() {
|
||||
super.updateEnabled();
|
||||
|
||||
@Override
|
||||
public void setEnabled(boolean enabled) {
|
||||
this.enabled = enabled;
|
||||
for (JToggleButton button : items.values())
|
||||
button.setEnabled(enabled && editable);
|
||||
for (JToggleButton button : items.values()) {
|
||||
button.setEnabled(enabled && editable && parentEnabled);
|
||||
}
|
||||
}
|
||||
}
|
@ -52,6 +52,7 @@ public class DesktopPickerField extends DesktopAbstractField<Picker> implements
|
||||
protected boolean editable = true;
|
||||
|
||||
protected java.util.List<Action> actionsOrder = new LinkedList<>();
|
||||
protected java.util.Set<DesktopButton> buttons = new HashSet<>();
|
||||
|
||||
protected int modifiersMask;
|
||||
protected Map<Action, List<KeyStroke>> keyStrokesMap = new HashMap<>();
|
||||
@ -388,20 +389,19 @@ public class DesktopPickerField extends DesktopAbstractField<Picker> implements
|
||||
}
|
||||
updateMissingValueState();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setEnabled(boolean enabled) {
|
||||
super.setEnabled(enabled);
|
||||
|
||||
for (Action action : actionsOrder) {
|
||||
if (action instanceof StandardAction) {
|
||||
action.setEnabled(isEnabled());
|
||||
}
|
||||
@Override
|
||||
public void updateEnabled() {
|
||||
super.updateEnabled();
|
||||
|
||||
boolean resultEnabled = isEnabledWithParent();
|
||||
for (DesktopButton button : buttons) {
|
||||
button.setParentEnabled(resultEnabled);
|
||||
}
|
||||
|
||||
if (impl.getEditor() instanceof JTextComponent) {
|
||||
JTextComponent editor = (JTextComponent) impl.getEditor();
|
||||
editor.setFocusable(enabled);
|
||||
editor.setFocusable(resultEnabled);
|
||||
}
|
||||
}
|
||||
|
||||
@ -411,8 +411,9 @@ public class DesktopPickerField extends DesktopAbstractField<Picker> implements
|
||||
|
||||
// get button for old action
|
||||
JButton oldButton = null;
|
||||
DesktopButton oldActionButton = null;
|
||||
if (oldAction != null && oldAction.getOwner() != null && oldAction.getOwner() instanceof DesktopButton) {
|
||||
DesktopButton oldActionButton = (DesktopButton) oldAction.getOwner();
|
||||
oldActionButton = (DesktopButton) oldAction.getOwner();
|
||||
oldButton = oldActionButton.getImpl();
|
||||
}
|
||||
|
||||
@ -424,6 +425,7 @@ public class DesktopPickerField extends DesktopAbstractField<Picker> implements
|
||||
}
|
||||
|
||||
final DesktopButton dButton = new DesktopButton();
|
||||
dButton.setParentEnabled(isEnabledWithParent());
|
||||
dButton.setShouldBeFocused(false);
|
||||
dButton.setAction(action);
|
||||
dButton.getImpl().setFocusable(false);
|
||||
@ -431,8 +433,11 @@ public class DesktopPickerField extends DesktopAbstractField<Picker> implements
|
||||
|
||||
if (oldButton == null) {
|
||||
impl.addButton(dButton.getImpl());
|
||||
buttons.add(dButton);
|
||||
} else {
|
||||
impl.replaceButton(oldButton, dButton.getImpl());
|
||||
buttons.remove(oldActionButton);
|
||||
buttons.add(dButton);
|
||||
}
|
||||
|
||||
// apply Editable after action owner is set
|
||||
|
@ -138,12 +138,23 @@ public class DesktopScrollBoxLayout extends DesktopAbstractComponent<JScrollPane
|
||||
}
|
||||
}
|
||||
|
||||
if (component instanceof DesktopAbstractComponent && !isEnabledWithParent()) {
|
||||
((DesktopAbstractComponent) component).setParentEnabled(false);
|
||||
}
|
||||
|
||||
adjustViewPreferredSize();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void remove(Component component) {
|
||||
components.remove(component);
|
||||
content.remove(component);
|
||||
|
||||
if (component instanceof DesktopAbstractComponent && !isEnabledWithParent()) {
|
||||
((DesktopAbstractComponent) component).setParentEnabled(true);
|
||||
}
|
||||
|
||||
adjustViewPreferredSize();
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -284,4 +295,23 @@ public class DesktopScrollBoxLayout extends DesktopAbstractComponent<JScrollPane
|
||||
public void updateComponent(Component child) {
|
||||
adjustViewPreferredSize();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setEnabled(boolean enabled) {
|
||||
if (isEnabled() != enabled) {
|
||||
super.setEnabled(enabled);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateEnabled() {
|
||||
super.updateEnabled();
|
||||
|
||||
boolean resultEnabled = isEnabledWithParent();
|
||||
for (Component component : components) {
|
||||
if (component instanceof DesktopAbstractComponent) {
|
||||
((DesktopAbstractComponent) component).setParentEnabled(resultEnabled);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -49,7 +49,6 @@ public class DesktopSearchField extends DesktopAbstractOptionsField<JComponent>
|
||||
protected boolean disableActionListener = false;
|
||||
|
||||
protected boolean editable = true;
|
||||
protected boolean enabled = true;
|
||||
|
||||
protected Mode mode = Mode.CASE_SENSITIVE;
|
||||
|
||||
@ -581,22 +580,20 @@ public class DesktopSearchField extends DesktopAbstractOptionsField<JComponent>
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setEnabled(boolean enabled) {
|
||||
this.enabled = enabled;
|
||||
comboBox.setEnabled(enabled);
|
||||
textField.setEnabled(enabled);
|
||||
public void updateEnabled() {
|
||||
super.updateEnabled();
|
||||
|
||||
comboBox.setFocusable(enabled);
|
||||
textField.setFocusable(enabled);
|
||||
boolean resultEnabled = isEnabledWithParent();
|
||||
|
||||
comboBox.setEnabled(resultEnabled);
|
||||
textField.setEnabled(resultEnabled);
|
||||
|
||||
comboBox.setFocusable(resultEnabled);
|
||||
textField.setFocusable(resultEnabled);
|
||||
|
||||
updateMissingValueState();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEnabled() {
|
||||
return enabled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setMinSearchStringLength(int searchStringLength) {
|
||||
this.minSearchStringLength = searchStringLength;
|
||||
|
@ -130,9 +130,10 @@ public class DesktopSearchPickerField extends DesktopSearchField implements Sear
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setEnabled(boolean enabled) {
|
||||
super.setEnabled(enabled);
|
||||
pickerField.setEnabled(enabled);
|
||||
public void updateEnabled() {
|
||||
super.updateEnabled();
|
||||
|
||||
pickerField.setParentEnabled(isEnabledWithParent());
|
||||
}
|
||||
|
||||
private class Picker extends com.haulmont.cuba.desktop.sys.vcl.Picker {
|
||||
|
@ -135,6 +135,10 @@ public class DesktopSplitPanel extends DesktopAbstractComponent<JSplitPane> impl
|
||||
}
|
||||
}
|
||||
|
||||
if (component instanceof DesktopAbstractComponent && !isEnabledWithParent()) {
|
||||
((DesktopAbstractComponent) component).setParentEnabled(false);
|
||||
}
|
||||
|
||||
ownComponents.add(component);
|
||||
}
|
||||
|
||||
@ -143,6 +147,10 @@ public class DesktopSplitPanel extends DesktopAbstractComponent<JSplitPane> impl
|
||||
JComponent jComponent = DesktopComponentsHelper.getComposition(component);
|
||||
impl.remove(jComponent);
|
||||
|
||||
if (component instanceof DesktopAbstractComponent && !isEnabledWithParent()) {
|
||||
((DesktopAbstractComponent) component).setParentEnabled(true);
|
||||
}
|
||||
|
||||
if (component.getId() != null) {
|
||||
componentByIds.remove(component.getId());
|
||||
}
|
||||
@ -225,4 +233,23 @@ public class DesktopSplitPanel extends DesktopAbstractComponent<JSplitPane> impl
|
||||
e.addAttribute("value", String.valueOf(location));
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setEnabled(boolean enabled) {
|
||||
if (isEnabled() != enabled) {
|
||||
super.setEnabled(enabled);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateEnabled() {
|
||||
super.updateEnabled();
|
||||
|
||||
boolean resultEnabled = isEnabledWithParent();
|
||||
for (Component component : ownComponents) {
|
||||
if (component instanceof DesktopAbstractComponent) {
|
||||
((DesktopAbstractComponent) component).setParentEnabled(resultEnabled);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -116,6 +116,10 @@ public class DesktopTabSheet extends DesktopAbstractComponent<JTabbedPane> imple
|
||||
|
||||
DesktopContainerHelper.assignContainer(component, this);
|
||||
|
||||
if (component instanceof DesktopAbstractComponent && !isEnabledWithParent()) {
|
||||
((DesktopAbstractComponent) component).setParentEnabled(false);
|
||||
}
|
||||
|
||||
JComponent comp = DesktopComponentsHelper.getComposition(component);
|
||||
|
||||
impl.addTab("", comp);
|
||||
@ -204,6 +208,10 @@ public class DesktopTabSheet extends DesktopAbstractComponent<JTabbedPane> imple
|
||||
|
||||
DesktopContainerHelper.assignContainer(tabContent, this);
|
||||
|
||||
if (!isEnabledWithParent()) {
|
||||
tabContent.setParentEnabled(false);
|
||||
}
|
||||
|
||||
final JComponent comp = DesktopComponentsHelper.getComposition(tabContent);
|
||||
|
||||
impl.addTab("", comp);
|
||||
@ -256,8 +264,14 @@ public class DesktopTabSheet extends DesktopAbstractComponent<JTabbedPane> imple
|
||||
@Override
|
||||
public void removeTab(String name) {
|
||||
TabImpl tab = getTabImpl(name);
|
||||
components.remove(tab.getComponent());
|
||||
impl.remove(DesktopComponentsHelper.getComposition(tab.getComponent()));
|
||||
Component component = tab.getComponent();
|
||||
components.remove(component);
|
||||
impl.remove(DesktopComponentsHelper.getComposition(component));
|
||||
|
||||
DesktopContainerHelper.assignContainer(component, null);
|
||||
if (component instanceof DesktopAbstractComponent && !isEnabledWithParent()) {
|
||||
((DesktopAbstractComponent) component).setParentEnabled(true);
|
||||
}
|
||||
}
|
||||
|
||||
protected TabImpl getTabImpl(String name) {
|
||||
@ -364,6 +378,10 @@ public class DesktopTabSheet extends DesktopAbstractComponent<JTabbedPane> imple
|
||||
lti.tabContent.add(comp);
|
||||
lti.tabContent.expand(comp, "", "");
|
||||
|
||||
if (comp instanceof DesktopAbstractComponent && !isEnabledWithParent()) {
|
||||
((DesktopAbstractComponent) comp).setParentEnabled(false);
|
||||
}
|
||||
|
||||
final Window window = ComponentsHelper.getWindow(DesktopTabSheet.this);
|
||||
if (window != null) {
|
||||
ComponentsHelper.walkComponents(
|
||||
@ -503,8 +521,10 @@ public class DesktopTabSheet extends DesktopAbstractComponent<JTabbedPane> imple
|
||||
if (impl.getSelectedIndex() == tabIndex && isLazy() && enabled) {
|
||||
initLazyTab(DesktopComponentsHelper.getComposition(component));
|
||||
}
|
||||
} else {
|
||||
component.setVisible(enabled);
|
||||
}
|
||||
|
||||
if (component instanceof DesktopAbstractComponent) {
|
||||
((DesktopAbstractComponent) component).setParentEnabled(enabled);
|
||||
}
|
||||
}
|
||||
|
||||
@ -715,4 +735,25 @@ public class DesktopTabSheet extends DesktopAbstractComponent<JTabbedPane> imple
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setEnabled(boolean enabled) {
|
||||
if (isEnabled() != enabled) {
|
||||
super.setEnabled(enabled);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateEnabled() {
|
||||
super.updateEnabled();
|
||||
|
||||
for (Component component : components.keySet()) {
|
||||
if (component instanceof DesktopAbstractComponent) {
|
||||
JComponent composition = DesktopComponentsHelper.getComposition(component);
|
||||
TabImpl tab = tabContents.get(composition);
|
||||
|
||||
((DesktopAbstractComponent) component).setParentEnabled(tab.isEnabled() && isEnabledWithParent());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -425,6 +425,18 @@ public class DesktopTokenList extends DesktopAbstractField<DesktopTokenList.Toke
|
||||
impl.refreshComponent();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void updateEnabled() {
|
||||
super.updateEnabled();
|
||||
|
||||
if (lookupPickerField != null) {
|
||||
lookupPickerField.setParentEnabled(isEnabledWithParent());
|
||||
}
|
||||
if (addButton != null) {
|
||||
addButton.setParentEnabled(isEnabledWithParent());
|
||||
}
|
||||
}
|
||||
|
||||
protected String instanceCaption(Instance instance) {
|
||||
if (instance == null) {
|
||||
return "";
|
||||
|
@ -672,6 +672,10 @@ public class DesktopWindow implements Window, Component.Disposable,
|
||||
|
||||
DesktopContainerHelper.assignContainer(component, this);
|
||||
|
||||
if (component instanceof DesktopAbstractComponent && !isEnabled()) {
|
||||
((DesktopAbstractComponent) component).setParentEnabled(false);
|
||||
}
|
||||
|
||||
requestRepaint();
|
||||
}
|
||||
|
||||
@ -728,6 +732,10 @@ public class DesktopWindow implements Window, Component.Disposable,
|
||||
|
||||
DesktopContainerHelper.assignContainer(component, this);
|
||||
|
||||
if (component instanceof DesktopAbstractComponent && !isEnabled()) {
|
||||
((DesktopAbstractComponent) component).setParentEnabled(false);
|
||||
}
|
||||
|
||||
requestRepaint();
|
||||
}
|
||||
|
||||
@ -750,6 +758,11 @@ public class DesktopWindow implements Window, Component.Disposable,
|
||||
ownComponents.remove(component);
|
||||
|
||||
DesktopContainerHelper.assignContainer(component, null);
|
||||
|
||||
if (component instanceof DesktopAbstractComponent && !isEnabled()) {
|
||||
((DesktopAbstractComponent) component).setParentEnabled(true);
|
||||
}
|
||||
|
||||
if (expandedComponent == component) {
|
||||
expandedComponent = null;
|
||||
}
|
||||
@ -825,9 +838,20 @@ public class DesktopWindow implements Window, Component.Disposable,
|
||||
|
||||
@Override
|
||||
public void setEnabled(boolean enabled) {
|
||||
panel.setEnabled(enabled);
|
||||
if (isEnabled() != enabled) {
|
||||
panel.setEnabled(enabled);
|
||||
|
||||
updateEnabled();
|
||||
}
|
||||
}
|
||||
|
||||
public void updateEnabled() {
|
||||
for (Component component : ownComponents) {
|
||||
if (component instanceof DesktopAbstractComponent) {
|
||||
((DesktopAbstractComponent) component).setParentEnabled(isEnabled());
|
||||
}
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public boolean isVisible() {
|
||||
return true;
|
||||
|
Loading…
Reference in New Issue
Block a user