blob: 753de08ffc75022ee3025e87c51a32df16c01a3c [file] [log] [blame]
/*******************************************************************************
* Copyright (c) 2010 BSI Business Systems Integration AG.
* 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:
* BSI Business Systems Integration AG - initial API and implementation
******************************************************************************/
package org.eclipse.scout.rt.client.ui.action.menu.root.internal;
import java.beans.PropertyChangeEvent;
import java.util.List;
import org.eclipse.scout.rt.client.ui.action.menu.IMenu;
import org.eclipse.scout.rt.client.ui.action.menu.MenuUtility;
import org.eclipse.scout.rt.client.ui.action.menu.root.AbstractPropertyObserverContextMenu;
import org.eclipse.scout.rt.client.ui.action.menu.root.ICalendarContextMenu;
import org.eclipse.scout.rt.client.ui.basic.calendar.CalendarComponent;
import org.eclipse.scout.rt.client.ui.basic.calendar.ICalendar;
/**
* The invisible root menu node of any calendar. (internal usage only)
*/
public class CalendarContextMenu extends AbstractPropertyObserverContextMenu<ICalendar> implements ICalendarContextMenu {
/**
* @param owner
*/
public CalendarContextMenu(ICalendar owner, List<? extends IMenu> initialChildMenus) {
super(owner, initialChildMenus);
}
@Override
protected void initConfig() {
super.initConfig();
// set active filter
setCurrentMenuTypes(MenuUtility.getMenuTypesForCalendarSelection(getOwner().getSelectedComponent()));
calculateLocalVisibility();
}
@Override
public void callOwnerValueChanged() {
handleOwnerValueChanged();
}
/**
*
*/
protected void handleOwnerValueChanged() {
if (getOwner() != null) {
final CalendarComponent ownerValue = getOwner().getSelectedComponent();
setCurrentMenuTypes(MenuUtility.getMenuTypesForCalendarSelection(ownerValue));
acceptVisitor(new MenuOwnerChangedVisitor(ownerValue, getCurrentMenuTypes()));
calculateLocalVisibility();
}
}
@Override
protected void handleOwnerPropertyChanged(PropertyChangeEvent evt) {
if (ICalendar.PROP_SELECTED_COMPONENT.equals(evt.getPropertyName())) {
handleOwnerValueChanged();
}
}
}