use of com.vaadin.client.ComputedStyle in project cuba by cuba-platform.
the class CubaTabSheetWidget method updateContentNodeHeight.
@Override
public void updateContentNodeHeight() {
if (!isDynamicHeight()) {
ComputedStyle fullHeight = new ComputedStyle(getElement());
double contentHeight = fullHeight.getHeight();
ComputedStyle tabsCs = new ComputedStyle(tabs);
contentHeight -= tabsCs.getHeight();
contentHeight -= deco.getOffsetHeight();
ComputedStyle cs = new ComputedStyle(contentNode);
contentHeight -= cs.getPaddingHeight();
contentHeight -= cs.getBorderHeight();
if (contentHeight < 0) {
contentHeight = 0;
}
// Set proper values for content element
double ceilHeight = Math.ceil(contentHeight);
contentNode.getStyle().setHeight(ceilHeight, Style.Unit.PX);
} else {
contentNode.getStyle().clearHeight();
}
}
use of com.vaadin.client.ComputedStyle in project cuba by cuba-platform.
the class CubaFileUploadProgressWindow method constructDOM.
protected void constructDOM() {
setStyleName(CLASSNAME);
topTabStop = DOM.createDiv();
topTabStop.setTabIndex(0);
header = DOM.createDiv();
header.setClassName(CLASSNAME + "-outerheader");
headerText = DOM.createDiv();
headerText.setClassName(CLASSNAME + "-header");
contents = DOM.createDiv();
contents.setClassName(CLASSNAME + "-contents");
footer = DOM.createDiv();
footer.setClassName(CLASSNAME + "-footer");
resizeBox = DOM.createDiv();
resizeBox.setClassName(CLASSNAME + "-resizebox");
closeBox = DOM.createDiv();
closeBox.setClassName(CLASSNAME + "-closebox");
closeBox.setTabIndex(0);
DOM.appendChild(footer, resizeBox);
bottomTabStop = DOM.createDiv();
bottomTabStop.setTabIndex(0);
wrapper = DOM.createDiv();
wrapper.setClassName(CLASSNAME + "-wrap");
DOM.appendChild(wrapper, topTabStop);
DOM.appendChild(wrapper, header);
DOM.appendChild(header, closeBox);
DOM.appendChild(header, headerText);
DOM.appendChild(wrapper, contents);
DOM.appendChild(wrapper, footer);
DOM.appendChild(wrapper, bottomTabStop);
DOM.appendChild(super.getContainerElement(), wrapper);
sinkEvents(Event.ONDBLCLICK | Event.MOUSEEVENTS | Event.TOUCHEVENTS | Event.ONCLICK | Event.ONLOSECAPTURE);
currentFileLabel = new VLabel();
currentFileLabel.addStyleName("upload-file-label");
currentFileLabel.setWidth("100%");
progressBar = new VProgressBar();
progressBar.addStyleName("upload-progressbar");
progressBar.setIndeterminate(false);
progressBar.setState(0);
progressBar.setWidth("100%");
cancelButton = new VButton();
cancelButton.addStyleName("upload-cancel-button");
cancelButton.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
closeWindow();
}
});
contentPanel = new SimpleFocusablePanel();
contentPanel.setStyleName("content-pane");
contentPanel.addKeyDownHandler(this);
contentPanel.addKeyUpHandler(this);
setWidget(contentPanel);
final FlowPanel verticalPanel = new FlowPanel();
verticalPanel.setStyleName("vertical-panel");
verticalPanel.addStyleName("v-widget");
verticalPanel.addStyleName("v-has-width");
verticalPanel.addStyleName("v-has-height");
verticalPanel.add(currentFileLabel);
verticalPanel.add(progressBar);
verticalPanel.add(cancelButton);
contentPanel.setWidget(verticalPanel);
// do some calculations for window layout
Scheduler.get().scheduleDeferred(new Scheduler.ScheduledCommand() {
@Override
public void execute() {
Style contentStyle = contents.getStyle();
ComputedStyle headerCs = new ComputedStyle(header);
String headerHeight = headerCs.getProperty("height");
contentStyle.setProperty("paddingTop", headerHeight);
contentStyle.setProperty("marginTop", "-" + headerHeight);
ComputedStyle footerCs = new ComputedStyle(footer);
String footerHeight = footerCs.getProperty("height");
contentStyle.setProperty("paddingBottom", footerHeight);
contentStyle.setProperty("marginBottom", "-" + footerHeight);
}
});
// Make the closebox accessible for assistive devices
Roles.getButtonRole().set(closeBox);
Roles.getButtonRole().setAriaLabelProperty(closeBox, "close button");
// Provide the title to assistive devices
AriaHelper.ensureHasId(headerText);
Roles.getDialogRole().setAriaLabelledbyProperty(getElement(), Id.of(headerText));
// Handlers to Prevent tab to leave the window
// and backspace to cause browser navigation
topEventBlocker = new Event.NativePreviewHandler() {
@Override
public void onPreviewNativeEvent(Event.NativePreviewEvent event) {
NativeEvent nativeEvent = event.getNativeEvent();
if (nativeEvent.getEventTarget().cast() == topTabStop && nativeEvent.getKeyCode() == KeyCodes.KEY_TAB && nativeEvent.getShiftKey()) {
nativeEvent.preventDefault();
}
if (nativeEvent.getEventTarget().cast() == topTabStop && nativeEvent.getKeyCode() == KeyCodes.KEY_BACKSPACE) {
nativeEvent.preventDefault();
}
}
};
bottomEventBlocker = new Event.NativePreviewHandler() {
@Override
public void onPreviewNativeEvent(Event.NativePreviewEvent event) {
NativeEvent nativeEvent = event.getNativeEvent();
if (nativeEvent.getEventTarget().cast() == bottomTabStop && nativeEvent.getKeyCode() == KeyCodes.KEY_TAB && !nativeEvent.getShiftKey()) {
nativeEvent.preventDefault();
}
if (nativeEvent.getEventTarget().cast() == bottomTabStop && nativeEvent.getKeyCode() == KeyCodes.KEY_BACKSPACE) {
nativeEvent.preventDefault();
}
}
};
}
use of com.vaadin.client.ComputedStyle in project cuba by cuba-platform.
the class CubaResizableTextAreaWrapperWidget method releaseCapture.
protected void releaseCapture(Event event) {
if (event.getButton() == Event.BUTTON_LEFT && dragDrop) {
dragDrop = false;
DOM.releaseCapture(resizeElement);
if (resizeHandler != null) {
ComputedStyle cs = new ComputedStyle(getElement());
resizeHandler.sizeChanged(cs.getProperty("width"), cs.getProperty("height"));
resizeHandler.textChanged(getText());
}
}
}
use of com.vaadin.client.ComputedStyle in project cuba by cuba-platform.
the class CubaResizableTextAreaWrapperWidget method handleResize.
protected void handleResize(Event event) {
// calculate and set the new size
if (dragDrop) {
int mouseX = event.getClientX();
int mouseY = event.getClientY();
int absoluteLeft = getAbsoluteLeft();
int absoluteTop = getAbsoluteTop();
ComputedStyle cs = new ComputedStyle(getElement().getFirstChildElement());
// do not allow mirror-functionality
if (mouseY > absoluteTop + cs.getDoubleProperty("min-height") && mouseX > absoluteLeft + MINIMAL_WIDTH) {
int width = mouseX - absoluteLeft + 2;
int height = mouseY - absoluteTop + 2;
switch(resizableDirection) {
case BOTH:
setHeight(height + "px");
setWidth(width + "px");
break;
case VERTICAL:
setHeight(height + "px");
break;
case HORIZONTAL:
setWidth(width + "px");
break;
}
if (resizeHandler != null) {
resizeHandler.handleResize();
}
}
}
}
use of com.vaadin.client.ComputedStyle in project cuba by cuba-platform.
the class CubaResizableTextAreaWrapperWidget method captureEvents.
protected void captureEvents(Event event) {
event.preventDefault();
if (isEnabled() && event.getButton() == Event.BUTTON_LEFT) {
if (!dragDrop) {
dragDrop = true;
DOM.setCapture(resizeElement);
ComputedStyle cs = new ComputedStyle(getElement());
setWidth(cs.getProperty("width"));
setHeight(cs.getProperty("height"));
getTextArea().getStyle().setProperty("width", "100%");
getTextArea().getStyle().setProperty("height", "100%");
}
}
}
Aggregations