blob: 6ea9889769a7593440b5c64e27c13c64649ad6fc [file] [log] [blame]
/*******************************************************************************
* Copyright (c) 2012 Rushan R. Gilmullin and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* Rushan R. Gilmullin - initial API and implementation
*******************************************************************************/
package org.eclipse.osbp.vaaclipse.presentation.widgets;
import com.vaadin.ui.Alignment;
import com.vaadin.ui.Component;
import com.vaadin.ui.GridLayout;
import com.vaadin.ui.HorizontalLayout;
import com.vaadin.ui.MenuBar;
import com.vaadin.ui.VerticalLayout;
/**
* @author rushan
*
*/
public class TrimmedWindowContent extends VerticalLayout {
private VerticalLayout windowBody;
private VerticalLayout windowCenterArea;
private HorizontalLayout helperLayout;
private GridLayout topContainerPanel;
private VerticalLayout leftBarContainer = new VerticalLayout();
private VerticalLayout rightBarContainer = new VerticalLayout();
private VerticalLayout topBarContainer = new VerticalLayout();
private HorizontalLayout bottomBarContainer = new HorizontalLayout();
private boolean boundsValide = false;
public TrimmedWindowContent() {
leftBarContainer.setWidth(-1, Unit.PIXELS);
leftBarContainer.setHeight("100%");
rightBarContainer.setWidth(-1, Unit.PIXELS);
rightBarContainer.setHeight("100%");
topBarContainer.setHeight(-1, Unit.PIXELS);
topBarContainer.setWidth("100%");
topBarContainer.setMargin(false);
// bottomBarContainer.setSizeFull();
bottomBarContainer.setHeight(-1, Unit.PIXELS);
bottomBarContainer.setWidth("100%");
bottomBarContainer.setMargin(false);
this.setSizeFull();
windowBody = new VerticalLayout();
windowBody.setSizeFull();
this.addComponent(windowBody);
this.setExpandRatio(windowBody, 100);
windowCenterArea = new VerticalLayout();
windowCenterArea.setSizeFull();
helperLayout = new HorizontalLayout();
helperLayout.setSizeFull();
// Top panel - it contains the top trimbar and the perspective stack
// panel
topContainerPanel = new GridLayout(2, 1);
topContainerPanel.setColumnExpandRatio(0, 0);
topContainerPanel.setColumnExpandRatio(1, 100);
topContainerPanel.setSizeUndefined();
topContainerPanel.setWidth("100%");
windowBody.addComponent(topContainerPanel);
// ------------------------
helperLayout.addComponent(leftBarContainer);
helperLayout.addComponent(windowCenterArea);
helperLayout.addComponent(rightBarContainer);
helperLayout.setExpandRatio(windowCenterArea, 100);
windowBody.addComponent(topBarContainer);
windowBody.addComponent(helperLayout);
windowBody.setExpandRatio(helperLayout, 100);
windowBody.addComponent(bottomBarContainer);
// -------------------------------------------------------------------
}
public VerticalLayout getClientArea() {
return windowCenterArea;
}
public void setMenuBar(MenuBar menuBar) {
for (int i = 0; i < this.getComponentCount(); i++) {
Component c = this.getComponent(i);
if (c instanceof MenuBar)
this.removeComponent(c);
}
menuBar.setWidth("100%");
this.addComponent(menuBar, 0);
}
public HorizontalLayout getPerspectiveStackPanel() {
return (HorizontalLayout) topContainerPanel.getComponent(0, 0);
}
public void setPerspectiveStackPanel(HorizontalLayout perspectiveStackPanel) {
if (perspectiveStackPanel == null) {
this.topContainerPanel.removeComponent(0, 0);
} else {
perspectiveStackPanel.setSizeUndefined();
this.topContainerPanel.addComponent(perspectiveStackPanel, 0, 0);
}
}
public void setLeftBar(Component bar) {
if (bar == null) {
leftBarContainer.removeAllComponents();
return;
}
leftBarContainer.removeAllComponents();
leftBarContainer.addComponent(bar);
}
public void setRightBar(Component bar) {
if (bar == null) {
rightBarContainer.removeAllComponents();
return;
}
rightBarContainer.removeAllComponents();
rightBarContainer.addComponent(bar);
}
public void setBottomBar(Component bar) {
if (bar == null) {
bottomBarContainer.removeAllComponents();
return;
}
bottomBarContainer.removeAllComponents();
bottomBarContainer.addComponent(bar);
}
public void setTopBar(Component bar) {
if (bar == null) {
this.topContainerPanel.removeComponent(1, 0);
return;
}
if (this.topContainerPanel.getComponent(1, 0) != null) {
this.topContainerPanel.removeComponent(1, 0);
}
HorizontalLayout topBarWrapper = new HorizontalLayout();
topBarWrapper.setWidth("100%");
topBarWrapper.addComponent(bar);
topBarWrapper.setComponentAlignment(bar, Alignment.MIDDLE_RIGHT);
bar.setSizeUndefined();
this.topContainerPanel.addComponent(topBarWrapper, 1, 0);
}
public Component getTopbar() {
return this.topContainerPanel.getComponent(1, 0);
}
// -----------------------------------
// -----------------------------------
public boolean isBoundsValid() {
return this.boundsValide;
}
public void invalidateBounds() {
this.boundsValide = false;
}
}