button.setCommandButtonKind(CommandButtonKind.POPUP_ONLY);
button.setPopupCallback(new PopupPanelCallback() {
public JPopupPanel getPopupPanel(JCommandButton commandButton) {
JCommandPopupMenu popupmenu = new JCommandPopupMenu();
final AttributeViewTypeAction showSelectedAttributesAction = (AttributeViewTypeAction) context.getBuilder().getMode().getAction("ShowSelectedAttributesAction");
final JCommandToggleMenuButton showSelectedAttributesButton = RibbonActionContributorFactory.createCommandToggleMenuButton(showSelectedAttributesAction);
popupmenu.addMenuButton(showSelectedAttributesButton);
showSelectedAttributesAction.setSelected();
showSelectedAttributesButton.getActionModel().setSelected(showSelectedAttributesAction.isSelected());
final AttributeViewTypeAction showAllAttributesAction = (AttributeViewTypeAction) context.getBuilder().getMode().getAction("ShowAllAttributesAction");
final JCommandToggleMenuButton showAllAttributesButton = RibbonActionContributorFactory.createCommandToggleMenuButton(showAllAttributesAction);
popupmenu.addMenuButton(showAllAttributesButton);
showAllAttributesAction.setSelected();
showAllAttributesButton.getActionModel().setSelected(showAllAttributesAction.isSelected());
final AttributeViewTypeAction hideAllAttributesAction = (AttributeViewTypeAction) context.getBuilder().getMode().getAction("HideAllAttributesAction");
final JCommandToggleMenuButton hideAllAttributesButton = RibbonActionContributorFactory.createCommandToggleMenuButton(hideAllAttributesAction);
popupmenu.addMenuButton(hideAllAttributesButton);
hideAllAttributesAction.setSelected();
hideAllAttributesButton.getActionModel().setSelected(hideAllAttributesAction.isSelected());
final SetBooleanMapPropertyAction showIconAction = (SetBooleanMapPropertyAction) context.getBuilder().getMode().getAction("SetBooleanMapPropertyAction.show_icon_for_attributes");
final JCommandToggleMenuButton toggleButton = RibbonActionContributorFactory.createCommandToggleMenuButton(showIconAction);
showIconAction.setSelected();
toggleButton.getActionModel().setSelected(showIconAction.isSelected());
popupmenu.addMenuButton(toggleButton);
context.getBuilder().getMapChangeAdapter().addListener(new IChangeObserver() {
public void updateState(CurrentState state) {
showSelectedAttributesAction.setSelected();
showSelectedAttributesButton.getActionModel().setSelected(showSelectedAttributesAction.isSelected());
showAllAttributesAction.setSelected();
showAllAttributesButton.getActionModel().setSelected(showAllAttributesAction.isSelected());
hideAllAttributesAction.setSelected();
hideAllAttributesButton.getActionModel().setSelected(hideAllAttributesAction.isSelected());
showIconAction.setSelected();
toggleButton.getActionModel().setSelected(showIconAction.isSelected());
}
});