001/* 002 * This library is part of OpenCms - 003 * the Open Source Content Management System 004 * 005 * Copyright (c) Alkacon Software GmbH & Co. KG (http://www.alkacon.com) 006 * 007 * This library is free software; you can redistribute it and/or 008 * modify it under the terms of the GNU Lesser General Public 009 * License as published by the Free Software Foundation; either 010 * version 2.1 of the License, or (at your option) any later version. 011 * 012 * This library is distributed in the hope that it will be useful, 013 * but WITHOUT ANY WARRANTY; without even the implied warranty of 014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 015 * Lesser General Public License for more details. 016 * 017 * For further information about Alkacon Software, please see the 018 * company website: http://www.alkacon.com 019 * 020 * For further information about OpenCms, please see the 021 * project website: http://www.opencms.org 022 * 023 * You should have received a copy of the GNU Lesser General Public 024 * License along with this library; if not, write to the Free Software 025 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 026 */ 027 028package org.opencms.ui.client; 029 030import com.google.gwt.dom.client.Document; 031import com.google.gwt.dom.client.Element; 032import com.google.gwt.dom.client.Style.Unit; 033import com.vaadin.client.ui.VMenuBar; 034 035/** 036 * Extending the VAADIN menu bar only to add a corner element pointing at the opening button.<p> 037 */ 038public class CmsVMenuBar extends VMenuBar { 039 040 /** The pointy corner CSS class. */ 041 protected static final String CORNER_CLASS = "o-toolbar-menu-corner"; 042 043 /** The additional offset. */ 044 private static final int OFFSET = -4; 045 046 /** 047 * Constructor.<p> 048 */ 049 CmsVMenuBar() { 050 super(); 051 } 052 053 /** 054 * Constructor.<p> 055 * 056 * @param submenu if this is a sub-menu 057 * @param parentmenu the parent menu 058 */ 059 CmsVMenuBar(boolean submenu, VMenuBar parentmenu) { 060 super(submenu, parentmenu); 061 } 062 063 /** 064 * @see com.vaadin.client.ui.VMenuBar#showChildMenuAt(com.vaadin.client.ui.VMenuBar.CustomMenuItem, int, int) 065 */ 066 @Override 067 protected void showChildMenuAt(CustomMenuItem item, int top, int left) { 068 069 super.showChildMenuAt(item, top, left); 070 if (!subMenu) { 071 int popupLeft = popup.getPopupLeft(); 072 int dif = (left - popupLeft) + OFFSET; 073 Element corner = Document.get().createDivElement(); 074 corner.setClassName(CORNER_CLASS); 075 corner.getStyle().setLeft(dif, Unit.PX); 076 popup.getElement().appendChild(corner); 077 } 078 } 079}