mirror of
https://gitee.com/jmix/cuba.git
synced 2024-12-03 03:38:33 +08:00
Components which are placed on invisible tabs should be considered invisible #PL-4972
This commit is contained in:
parent
006c5eb5a4
commit
7ff754a502
@ -143,10 +143,7 @@ public abstract class DesktopAbstractComponent<C extends JComponent>
|
||||
|
||||
@Override
|
||||
public boolean isVisible() {
|
||||
if (container != null)
|
||||
return visible && container.isVisible();
|
||||
else
|
||||
return visible;
|
||||
return DesktopComponentsHelper.isRecursivelyVisible(getComposition());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -284,6 +284,22 @@ public class DesktopComponentsHelper {
|
||||
* @return true if the component and all of its ancestors are visible
|
||||
*/
|
||||
public static boolean isRecursivelyVisible(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.isVisible() && (component.getParent() == null || isRecursivelyVisible(component.getParent()));
|
||||
}
|
||||
|
||||
|
@ -25,6 +25,7 @@ import com.vaadin.shared.ui.datefield.Resolution;
|
||||
import com.vaadin.ui.*;
|
||||
import com.vaadin.ui.Button;
|
||||
import com.vaadin.ui.Component;
|
||||
import com.vaadin.ui.TabSheet;
|
||||
import com.vaadin.ui.Table;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
@ -345,6 +346,14 @@ public class WebComponentsHelper {
|
||||
* @return component visibility
|
||||
*/
|
||||
public static boolean isComponentVisible(Component child) {
|
||||
if (child.getParent() instanceof TabSheet) {
|
||||
TabSheet tabSheet = (TabSheet) child.getParent();
|
||||
TabSheet.Tab tab = tabSheet.getTab(child);
|
||||
if (!tab.isVisible()) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return child.isVisible() && (child.getParent() == null || isComponentVisible(child.getParent()));
|
||||
}
|
||||
|
||||
@ -355,6 +364,14 @@ public class WebComponentsHelper {
|
||||
* @return component enabled state
|
||||
*/
|
||||
public static boolean isComponentEnabled(Component child) {
|
||||
if (child.getParent() instanceof TabSheet) {
|
||||
TabSheet tabSheet = (TabSheet) child.getParent();
|
||||
TabSheet.Tab tab = tabSheet.getTab(child);
|
||||
if (!tab.isEnabled()) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return child.isEnabled() && (child.getParent() == null || isComponentEnabled(child.getParent())) &&
|
||||
isComponentVisible(child);
|
||||
}
|
||||
|
@ -103,7 +103,7 @@ public class WebAbstractComponent<T extends com.vaadin.ui.Component>
|
||||
|
||||
@Override
|
||||
public boolean isEnabled() {
|
||||
return getComposition().isEnabled();
|
||||
return WebComponentsHelper.isComponentEnabled(getComposition());
|
||||
}
|
||||
|
||||
/**
|
||||
@ -127,7 +127,7 @@ public class WebAbstractComponent<T extends com.vaadin.ui.Component>
|
||||
|
||||
@Override
|
||||
public boolean isVisible() {
|
||||
return getComposition().isVisible();
|
||||
return WebComponentsHelper.isComponentVisible(getComposition());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -6,7 +6,6 @@ package com.haulmont.cuba.web.gui.components;
|
||||
|
||||
import com.haulmont.cuba.gui.components.*;
|
||||
import com.haulmont.cuba.gui.components.Formatter;
|
||||
import com.haulmont.cuba.gui.components.Table;
|
||||
import com.haulmont.cuba.web.App;
|
||||
import com.haulmont.cuba.web.toolkit.VersionedThemeResource;
|
||||
import com.haulmont.cuba.web.toolkit.data.AggregationContainer;
|
||||
@ -20,6 +19,7 @@ import com.vaadin.terminal.Resource;
|
||||
import com.vaadin.ui.*;
|
||||
import com.vaadin.ui.Button;
|
||||
import com.vaadin.ui.Component;
|
||||
import com.vaadin.ui.TabSheet;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
|
||||
import java.io.File;
|
||||
@ -128,6 +128,43 @@ public class WebComponentsHelper {
|
||||
|| (layout instanceof HorizontalActionsLayout);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests if component visible and its container visible.
|
||||
*
|
||||
* @param child component
|
||||
* @return component visibility
|
||||
*/
|
||||
public static boolean isComponentVisible(Component child) {
|
||||
if (child.getParent() instanceof TabSheet) {
|
||||
TabSheet tabSheet = (TabSheet) child.getParent();
|
||||
TabSheet.Tab tab = tabSheet.getTab(child);
|
||||
if (!tab.isVisible()) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return ((AbstractComponent)child).isComponentVisible() && (child.getParent() == null || isComponentVisible(child.getParent()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests if component enabled and visible and its container enabled.
|
||||
*
|
||||
* @param child component
|
||||
* @return component enabled state
|
||||
*/
|
||||
public static boolean isComponentEnabled(Component child) {
|
||||
if (child.getParent() instanceof TabSheet) {
|
||||
TabSheet tabSheet = (TabSheet) child.getParent();
|
||||
TabSheet.Tab tab = tabSheet.getTab(child);
|
||||
if (!tab.isEnabled()) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return ((AbstractComponent)child).isComponentEnabled() && (child.getParent() == null || isComponentEnabled(child.getParent())) &&
|
||||
isComponentVisible(child);
|
||||
}
|
||||
|
||||
public static Alignment convertAlignment(com.haulmont.cuba.gui.components.Component.Alignment alignment) {
|
||||
if (alignment == null) return null;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user