Incorrect disabled mode of components #PL-5992

This commit is contained in:
Gleb Gorelov 2015-09-30 14:22:38 +00:00
parent 4521dd995b
commit ba385a9430
5 changed files with 60 additions and 6 deletions

View File

@ -9,6 +9,7 @@ import com.google.gwt.dom.client.Style;
import com.google.gwt.user.client.DOM;
import com.google.gwt.dom.client.Element;
import com.google.gwt.user.client.Event;
import com.google.gwt.user.client.ui.HasEnabled;
import com.haulmont.cuba.web.toolkit.ui.client.Tools;
import com.vaadin.client.ui.VPanel;
@ -16,7 +17,7 @@ import com.vaadin.client.ui.VPanel;
* @author artamonov
* @version $Id$
*/
public class CubaGroupBoxWidget extends VPanel {
public class CubaGroupBoxWidget extends VPanel implements HasEnabled {
public static final String CLASSNAME = "cuba-groupbox";
@ -24,6 +25,8 @@ public class CubaGroupBoxWidget extends VPanel {
protected boolean collapsable = false;
private boolean enabled = true;
protected ExpandHandler expandHandler;
public Element captionWrap;
@ -117,9 +120,21 @@ public class CubaGroupBoxWidget extends VPanel {
this.collapsable = collapsable;
}
@Override
public boolean isEnabled() {
return enabled;
}
@Override
public void setEnabled(boolean enabled) {
if (isEnabled() != enabled) {
this.enabled = enabled;
}
}
@Override
public void onBrowserEvent(Event event) {
if (collapsable && DOM.eventGetType(event) == Event.ONCLICK
if (collapsable && DOM.eventGetType(event) == Event.ONCLICK && isEnabled()
&& (DOM.eventGetTarget(event) == expander || DOM.eventGetTarget(event) == captionNode.getChild(1))) {
toggleExpanded(event);
} else {

View File

@ -32,7 +32,7 @@ import static com.haulmont.cuba.web.toolkit.ui.client.Tools.isAnyModifierKeyPres
* @author devyatkin
* @version $Id$
*/
public class CubaScrollTableWidget extends VScrollTable implements ShortcutActionHandler.ShortcutActionHandlerOwner {
public class CubaScrollTableWidget extends VScrollTable implements ShortcutActionHandler.ShortcutActionHandlerOwner, HasEnabled {
public static final String CUBA_TABLE_CLICKABLE_CELL_STYLE = "cuba-table-clickable-cell";
public static final String CUBA_TABLE_CLICKABLE_TEXT_STYLE = "cuba-table-clickable-text";
@ -297,6 +297,18 @@ public class CubaScrollTableWidget extends VScrollTable implements ShortcutActio
}
}
@Override
public boolean isEnabled() {
return enabled;
}
@Override
public void setEnabled(boolean enabled) {
if (this.isEnabled() != enabled) {
this.enabled = enabled;
}
}
protected class CubaScrollTableHead extends TableHead {
protected final SimplePanel presentationsEditIcon = GWT.create(SimplePanel.class);
@ -316,7 +328,7 @@ public class CubaScrollTableWidget extends VScrollTable implements ShortcutActio
public void onBrowserEvent(Event event) {
super.onBrowserEvent(event);
if (event.getEventTarget().cast() == presentationsEditIcon.getElement()) {
if (event.getEventTarget().cast() == presentationsEditIcon.getElement() && isEnabled()) {
presentationsEditorPopup = new VOverlay();
presentationsEditorPopup.setStyleName("cuba-table-presentations-editor");
presentationsEditorPopup.setOwner(CubaScrollTableWidget.this);

View File

@ -34,7 +34,7 @@ import static com.haulmont.cuba.web.toolkit.ui.client.table.CubaScrollTableWidge
* @author artamonov
* @version $Id$
*/
public class CubaTreeTableWidget extends VTreeTable implements ShortcutActionHandler.ShortcutActionHandlerOwner {
public class CubaTreeTableWidget extends VTreeTable implements ShortcutActionHandler.ShortcutActionHandlerOwner, HasEnabled {
protected static final String WIDGET_CELL_CLASSNAME = "widget-container";
@ -288,6 +288,18 @@ public class CubaTreeTableWidget extends VTreeTable implements ShortcutActionHan
}
}
@Override
public boolean isEnabled() {
return enabled;
}
@Override
public void setEnabled(boolean enabled) {
if (this.isEnabled() != enabled) {
this.enabled = enabled;
}
}
protected class CubaTreeTableTableHead extends TableHead {
protected final SimplePanel presentationsEditIcon = GWT.create(SimplePanel.class);
@ -307,7 +319,7 @@ public class CubaTreeTableWidget extends VTreeTable implements ShortcutActionHan
public void onBrowserEvent(Event event) {
super.onBrowserEvent(event);
if (event.getEventTarget().cast() == presentationsEditIcon.getElement()) {
if (event.getEventTarget().cast() == presentationsEditIcon.getElement() && isEnabled()) {
presentationsEditorPopup = new VOverlay();
presentationsEditorPopup.setStyleName("cuba-table-presentations-editor");
presentationsEditorPopup.setOwner(CubaTreeTableWidget.this);

View File

@ -88,6 +88,17 @@
white-space: nowrap;
}
.#{$primary-stylename}.v-disabled {
@include opacity($v-disabled-opacity);
.#{$primary-stylename}-expander {
cursor: default;
}
.#{$primary-stylename}-caption-text {
cursor: default;
}
}
.#{$primary-stylename}-caption-end-deco {
display: inline-block;
height: round(2*$v-unit-size/3 + $v-unit-size/10);

View File

@ -140,6 +140,10 @@
}
}
.#{$primary-stylename}.v-disabled {
@include opacity($v-disabled-opacity);
}
.cuba-table-cell-textcut .cuba-table-clickable-cell {
cursor: $v-link-cursor;
color: $v-link-font-color;