use of org.eclipse.e4.ui.model.application.ui.menu.MMenuItem in project portfolio by buchen.
the class NewTransactionHandler method execute.
@Execute
public void execute(MMenuItem menuItem, SelectionService selectionService) {
PortfolioPart part = (PortfolioPart) menuItem.getTransientData().get(PortfolioPart.class.getName());
@SuppressWarnings("unchecked") Class<? extends AbstractTransactionDialog> dialog = (Class<? extends AbstractTransactionDialog>) menuItem.getTransientData().get(AbstractTransactionDialog.class.getName());
Object transaction = menuItem.getTransientData().get(UIConstants.Parameter.NAME);
part.getCurrentView().ifPresent(view -> {
// $NON-NLS-1$
OpenDialogAction action = new OpenDialogAction(view, transaction.toString() + "...");
action.type(dialog);
if (Enum.class.isAssignableFrom(transaction.getClass()))
action.parameters(transaction);
selectionService.getSelection(part.getClient()).ifPresent(s -> action.with(s.getSecurity()));
action.run();
});
}
use of org.eclipse.e4.ui.model.application.ui.menu.MMenuItem in project portfolio by buchen.
the class SelectReportingCurrencyHandler method isVisible.
@CanExecute
boolean isVisible(MMenuItem menuItem) {
CurrencyUnit currency = (CurrencyUnit) menuItem.getTransientData().get(CurrencyUnit.class.getName());
PortfolioPart part = (PortfolioPart) menuItem.getTransientData().get(PortfolioPart.class.getName());
if (currency == null || part == null)
return false;
menuItem.setSelected(currency.getCurrencyCode().equals(part.getClient().getBaseCurrency()));
return true;
}
use of org.eclipse.e4.ui.model.application.ui.menu.MMenuItem in project portfolio by buchen.
the class SetCurrentViewAsInitialViewHandler method isVisible.
@CanExecute
boolean isVisible(@Named(IServiceConstants.ACTIVE_PART) MPart part, MMenuItem menuItem) {
if (!MenuHelper.getActiveClientInput(part, false).isPresent())
return false;
PortfolioPart portfolioPart = (PortfolioPart) part.getObject();
Optional<Navigation.Item> view = portfolioPart.getSelectedItem();
if (!view.isPresent())
return false;
menuItem.setLabel(MessageFormat.format(Messages.MenuSetCurrentViewAsInitialView, view.get().getLabel()));
menuItem.setSelected(portfolioPart.getClientInput().getNavigation().getIdentifier(view.get()).equals(part.getPersistedState().get(UIConstants.PersistedState.INITIAL_VIEW)));
return true;
}
use of org.eclipse.e4.ui.model.application.ui.menu.MMenuItem in project aero.minova.rcp by minova-afis.
the class IconRendering method subscribeTopicChildrenChanged.
@Inject
@Optional
void subscribeTopicChildrenChanged(@UIEventTopic(UIEvents.ElementContainer.TOPIC_CHILDREN) Event event) {
Object objElement = event.getProperty(UIEvents.EventTags.ELEMENT);
// only care of added elements
if (!UIEvents.isADD(event)) {
return;
}
// Ensure that this event is for a MMenuItem or MToolBar
if (!(objElement instanceof MMenuElement && !(objElement instanceof MPopupMenu)) && !(objElement instanceof MToolBar)) {
return;
}
// Ensure that it's a View part's menu or toolbar
MUIElement uiElement = (MUIElement) objElement;
MUIElement parent = modelService.getContainer(uiElement);
if (!(parent instanceof MPart)) {
return;
}
MPart part = (MPart) parent;
ImageUtil.updateIconsForPart(part);
if (uiElement instanceof MToolBar) {
MToolBar toolbar = (MToolBar) uiElement;
ImageUtil.updateIconsForToolbarItems(toolbar);
}
}
use of org.eclipse.e4.ui.model.application.ui.menu.MMenuItem in project eclipse.platform.ui by eclipse-platform.
the class RenderedElementUtil method createRenderedMenuItem.
/**
* Create a 'rendered' menu item instance
*
* @return the new instance
*/
public static MMenuItem createRenderedMenuItem() {
final MDirectMenuItem object = MMenuFactory.INSTANCE.createDirectMenuItem();
object.getTags().add(RENDERED_TAG);
return object;
}
Aggregations