package org.lorainelab.igb.context.menu.modelapi.quickstart;
import static com.google.common.base.Preconditions.checkNotNullaQute.bnd.annotation.component.Component;
import java.util.Optional;
import static comorg.googlelorainelab.commonigb.basecontext.Preconditionsmenu.checkStateAnnotationContextMenuProvider;
import comorg.lorainelab.googleigb.commoncontext.basemenu.StringsMenuSection;
import com.google.common.collect.ImmutableSetorg.lorainelab.igb.context.menu.model.AnnotationContextEvent;
import java.util.Optionalorg.lorainelab.igb.context.menu.model.ContextMenuItem;
import javaorg.utilslf4j.SetLogger;
import javaorg.utilslf4j.function.FunctionLoggerFactory;
/**
*
* @author dcnorris
*/
public@Component(immediate class ContextMenuItem {
private final String menuLabel;= true)
public class ContextMenuExtension implements AnnotationContextMenuProvider {
private MenuIconstatic menuIcon;
final private Function<Void, Void> action;
private Set<ContextMenuItem> subMenuItems;
private int weight = 0;
public ContextMenuItem(String menuLabel, Set<ContextMenuItem> subMenuItems) {Logger logger = LoggerFactory.getLogger(ContextMenuExtension.class);
checkNotNull(menuLabel);@Override
public Optional<ContextMenuItem> checkNotNull(subMenuItems);
checkState(!Strings.isNullOrEmpty(menuLabel));
checkState(!subMenuItems.isEmpty());buildMenuItem(AnnotationContextEvent event) {
this.menuLabel = menuLabel;
this.subMenuItems = ImmutableSet.copyOf(subMenuItems);
}
public ContextMenuItem(String menuLabel, Function<Void, Void> action)ContextMenuItem contextMenuItem = new ContextMenuItem("Log Selection ids", (Void t) -> {
checkNotNull(menuLabel);
checkState(!Strings.isNullOrEmpty(menuLabel));
checkNotNull(action);
this.menuLabel = menuLabel;
this.action = action;
subMenuItems = ImmutableSet.of(event.getSelectedItems().stream().map(selectedSym -> selectedSym.getID()).forEach(logger::info);
}
public String getMenuLabel() {
return menuLabelt;
}
public Function<Void, Void> getAction() {
return action});
}
public Set<ContextMenuItem> getSubMenuItems() {
return subMenuItems;
}
public void setWeight(int weight) {
this.weight = weightreturn Optional.ofNullable(contextMenuItem);
}
public void setMenuIcon(MenuIcon menuIcon) {@Override
this.menuIcon = menuIcon;
}
public Optional<MenuIcon>MenuSection getMenuIcongetMenuSection() {
return Optional.ofNullable(menuIcon)MenuSection.INFORMATION;
}
}
|