use of com.vaadin.server.Page.BrowserWindowResizeEvent in project VaadinUtils by rlsutton1.
the class HelpSplitPanel method buildMainLayout.
private void buildMainLayout() {
addComponent((Component) component);
setExpandRatio((Component) component, 1);
helpPane = new Panel();
helpPane.setImmediate(false);
showHelpLoadingSplash();
helpSliderPanel = new SliderPanelBuilder(helpPane).expanded(false).mode(SliderMode.RIGHT).tabPosition(SliderTabPosition.MIDDLE).style(SliderPanelStyles.COLOR_BLUE).caption("Help").animationDuration(400).tabSize(30).autoCollapseSlider(true).fixedContentSize((int) (UI.getCurrent().getPage().getBrowserWindowWidth() * 0.75)).build();
helpLoader = new SlideOutLoader();
innerSecondPanel = new VerticalLayout();
innerSecondPanel.setSizeFull();
innerSecondPanel.setWidth("30");
innerSecondPanel.addComponent(helpSliderPanel);
innerSecondPanel.setComponentAlignment(helpSliderPanel, Alignment.MIDDLE_RIGHT);
addComponent(innerSecondPanel);
Page.getCurrent().addBrowserWindowResizeListener(new BrowserWindowResizeListener() {
private static final long serialVersionUID = -8548907013566961812L;
@Override
public void browserWindowResized(BrowserWindowResizeEvent event) {
helpSliderPanel.setFixedContentSize((int) (event.getWidth() * 0.75));
if (helpSliderPanel.isExpanded()) {
helpSliderPanel.collapse();
}
}
});
}
use of com.vaadin.server.Page.BrowserWindowResizeEvent in project opencms-core by alkacon.
the class CmsBasicDialog method enableMaxHeight.
/**
* Adds the max height extension to the dialog panel.<p>
*/
protected void enableMaxHeight() {
// use the window height minus an offset for the window header and some spacing
int maxHeight = calculateMaxHeight(A_CmsUI.get().getPage().getBrowserWindowHeight());
m_maxHeightExtension = new CmsMaxHeightExtension(this, maxHeight);
// only center window for height changes that exceed the maximum height since the last window resize
// (window resize handler resets this)
m_maxHeightExtension.addHeightChangeHandler(new CmsMaxHeightExtension.I_HeightChangeHandler() {
@SuppressWarnings("synthetic-access")
public void onChangeHeight(int height) {
boolean center = height > m_maxRecordedHeight;
m_maxRecordedHeight = Math.max(m_maxRecordedHeight, height);
Window wnd = CmsVaadinUtils.getWindow(CmsBasicDialog.this);
if ((wnd != null) && center) {
wnd.center();
}
}
});
addDetachListener(new DetachListener() {
private static final long serialVersionUID = 1L;
public void detach(DetachEvent event) {
if (m_resizeListenerRegistration != null) {
m_resizeListenerRegistration.remove();
m_resizeListenerRegistration = null;
}
}
});
m_windowResizeListener = new BrowserWindowResizeListener() {
private static final long serialVersionUID = 1L;
@SuppressWarnings("synthetic-access")
public void browserWindowResized(BrowserWindowResizeEvent event) {
m_maxRecordedHeight = Integer.MIN_VALUE;
int newHeight = event.getHeight();
m_maxHeightExtension.updateMaxHeight(calculateMaxHeight(newHeight));
}
};
m_resizeListenerRegistration = A_CmsUI.get().getPage().addBrowserWindowResizeListener(m_windowResizeListener);
}
Aggregations