Search in sources :

Example 1 with IEntityTransformer

use of org.whole.lang.util.IEntityTransformer in project whole by wholeplatform.

the class EntityAssistCompositeContributionItem method createWrapActions.

protected List<IAction> createWrapActions(ILanguageKit lk, IEntity targetEntity) {
    List<IAction> wrapActions = new ArrayList<IAction>();
    Set<EntityDescriptor<?>> wrapTypes = new HashSet<EntityDescriptor<?>>();
    IGEFEditorKit editorKit = (IGEFEditorKit) (targetEntity.wGetLanguageKit().equals(lk) ? ReflectionFactory.getEditorKit(targetEntity) : lk.getDefaultEditorKit());
    for (Object[] wrapAction : editorKit.getActionFactory().wrapActions()) {
        EntityDescriptor<?> ed = (EntityDescriptor<?>) wrapAction[1];
        if (isWrappable(targetEntity, ed, (IEnablerPredicate) wrapAction[0])) {
            String label = (String) wrapAction[2];
            IEntityTransformer transformer = (IEntityTransformer) wrapAction[3];
            wrapActions.add(contextProvider.getActionRegistry().getActionFactory().createPerformAction(label, WRAP_ICON_URI, QueriesEntityFactory.instance.createBooleanLiteral(true), getBehavior(ed, transformer)));
            wrapTypes.add(ed);
        }
    }
    for (EntityDescriptor<?> ed : lk.getEntityDescriptorEnum()) if (EntityUtils.isComposite(ed) && !wrapTypes.contains(ed) && isWrappable(targetEntity, ed, EnablerPredicateFactory.instance.assignableTo(ed.getEntityDescriptor(0)))) {
        String label = StringUtils.camelCaseToSpacedWords(ed.getName());
        wrapActions.add(contextProvider.getActionRegistry().getActionFactory().createPerformAction(label, WRAP_ICON_URI, QueriesEntityFactory.instance.createBooleanLiteral(true), getBehavior(ed, DefaultWrapInTransformer.instance)));
    }
    return wrapActions;
}
Also used : EntityDescriptor(org.whole.lang.reflect.EntityDescriptor) IAction(org.eclipse.jface.action.IAction) ArrayList(java.util.ArrayList) IGEFEditorKit(org.whole.lang.ui.editor.IGEFEditorKit) IEntityTransformer(org.whole.lang.util.IEntityTransformer) HashSet(java.util.HashSet)

Aggregations

ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1 IAction (org.eclipse.jface.action.IAction)1 EntityDescriptor (org.whole.lang.reflect.EntityDescriptor)1 IGEFEditorKit (org.whole.lang.ui.editor.IGEFEditorKit)1 IEntityTransformer (org.whole.lang.util.IEntityTransformer)1