Search in sources :

Example 6 with LanguageActionFactory

use of org.whole.lang.actions.model.LanguageActionFactory in project whole by wholeplatform.

the class ActionsVisibleWhen method isVisible.

@Override
public boolean isVisible(IBindingManager bm) {
    if (!HandlersBehavior.isValidEntityPartSelection(bm, false))
        return false;
    String languageURI = bm.wGet("self").wGetLanguageKit().getURI();
    IResourceRegistry<Resource> registry = ActionsRegistry.instance();
    for (IResource resource : registry.getResources(false)) {
        LanguageActionFactory actionsModule = resource.getEntity();
        URI targetLanguage = actionsModule.getTargetLanguage();
        if (DataTypeUtils.getDataKind(targetLanguage).isString() && !languageURI.equals(targetLanguage.getValue()))
            continue;
        IEntityIterator<GuardedAction> iterator = IteratorFactory.<GuardedAction>childMatcherIterator().withPattern(ActionsEntityDescriptorEnum.GuardedAction);
        iterator.reset(getActions(actionsModule));
        if (iterator.hasNext())
            return true;
    }
    return false;
}
Also used : LanguageActionFactory(org.whole.lang.actions.model.LanguageActionFactory) GuardedAction(org.whole.lang.actions.model.GuardedAction) Resource(org.whole.lang.resources.Resource) IResource(org.whole.lang.resources.IResource) URI(org.whole.lang.actions.model.URI) IResource(org.whole.lang.resources.IResource)

Aggregations

LanguageActionFactory (org.whole.lang.actions.model.LanguageActionFactory)6 ArrayList (java.util.ArrayList)2 GuardedAction (org.whole.lang.actions.model.GuardedAction)2 URI (org.whole.lang.actions.model.URI)2 IResource (org.whole.lang.resources.IResource)2 Resource (org.whole.lang.resources.Resource)2 HashMap (java.util.HashMap)1 ESelectionService (org.eclipse.e4.ui.workbench.modeling.ESelectionService)1 IAction (org.eclipse.jface.action.IAction)1 IContributionItem (org.eclipse.jface.action.IContributionItem)1 IBindingManager (org.whole.lang.bindings.IBindingManager)1 IEntity (org.whole.lang.model.IEntity)1 IUpdatableAction (org.whole.lang.ui.actions.IUpdatableAction)1