blob: 1b775bfc3f186b8a6949814bd3a89160c6df9e1c [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 v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Rushan R. Gilmullin - initial API and implementation
*******************************************************************************/
package org.eclipse.osbp.vaaclipse.presentation.renderers;
import org.eclipse.e4.ui.model.application.ui.MElementContainer;
import org.eclipse.e4.ui.model.application.ui.MUIElement;
import org.eclipse.e4.ui.model.application.ui.menu.MMenuSeparator;
import com.vaadin.ui.MenuBar.MenuItem;
/**
* @author rushan
*
*/
public class MenuSeparatorRenderer extends VaadinRenderer {
@Override
public void createWidget(MUIElement element,
MElementContainer<MUIElement> parent) {
if (!(element instanceof MMenuSeparator))
return;
MUIElement nextRenderableAndVisible = findNextRendarableAndVisible(
element, parent);
MenuItem separator = null;
if (nextRenderableAndVisible == null)
separator = ((MenuItem) parent.getWidget()).addSeparator();
else
separator = ((MenuItem) parent.getWidget())
.addSeparatorBefore((MenuItem) nextRenderableAndVisible
.getWidget());
element.setWidget(separator);
}
@Override
public void setVisible(MUIElement changedElement, boolean visible) {
((MenuItem) changedElement.getWidget()).setVisible(visible);
}
}