Search in sources :

Example 36 with ILanguageKit

use of org.whole.lang.reflect.ILanguageKit in project whole by wholeplatform.

the class ActionRegistry method registerKeyActions.

public void registerKeyActions(AbstractKeyHandler keyHandler) {
    keyHandler.put(KeySequence.getInstance(KeyStroke.getInstance(SWT.F2)), true, actionFactory.createDirectEditAction());
    for (IEditorKit editorKit : ReflectionFactory.getEditorKits()) {
        for (ILanguageKit lk : ReflectionFactory.getLanguageKits(false)) {
            if (!editorKit.canApply(lk))
                continue;
            for (Object[] textAction : E4Utils.textActionsFor(lk, ((IGEFEditorKit) editorKit).getActionFactory().textActions())) {
                KeySequence keySequence = (KeySequence) textAction[0];
                Class<IUpdatableAction> actionClass = (Class<IUpdatableAction>) textAction[2];
                try {
                    IUpdatableAction action = actionClass.getConstructor(IEclipseContext.class).newInstance(context);
                    keyHandler.put(editorKit, keySequence, true, action);
                } catch (Exception e) {
                }
            }
        }
    }
}
Also used : IEclipseContext(org.eclipse.e4.core.contexts.IEclipseContext) IGEFEditorKit(org.whole.lang.ui.editor.IGEFEditorKit) IEditorKit(org.whole.lang.reflect.IEditorKit) IUpdatableAction(org.whole.lang.ui.actions.IUpdatableAction) KeySequence(org.eclipse.jface.bindings.keys.KeySequence) ILanguageKit(org.whole.lang.reflect.ILanguageKit)

Example 37 with ILanguageKit

use of org.whole.lang.reflect.ILanguageKit in project whole by wholeplatform.

the class E4Utils method createErrorStatusContents.

public static IEntity createErrorStatusContents(String error, String cause) {
    ILanguageKit languageKit = ReflectionFactory.getLanguageKit(CoreMetaModelsDeployer.STATUS_URI, false, null);
    FeatureDescriptorEnum fdEnum = languageKit.getFeatureDescriptorEnum();
    IEntity statusModel = createErrorStatusContents();
    statusModel.wGet(fdEnum.valueOf("error")).wSetValue(error);
    statusModel.wGet(fdEnum.valueOf("cause")).wSetValue(cause);
    return statusModel;
}
Also used : FeatureDescriptorEnum(org.whole.lang.reflect.FeatureDescriptorEnum) IEntity(org.whole.lang.model.IEntity) ILanguageKit(org.whole.lang.reflect.ILanguageKit)

Example 38 with ILanguageKit

use of org.whole.lang.reflect.ILanguageKit in project whole by wholeplatform.

the class EntityAssistCompositeContributionItem method fillExtendedEntityAssistMenu.

protected boolean fillExtendedEntityAssistMenu(IItemContainer<MenuManager, ImageDescriptor> container, IEntity focusEntity, ILanguageKit targetLanguageKit) {
    List<MenuManager> menus = new ArrayList<MenuManager>();
    IResourceRegistry<ILanguageKit> registry = ReflectionFactory.getLanguageKitRegistry();
    for (ILanguageKit languageKit : registry.getResources(false, ResourceUtils.SIMPLE_COMPARATOR)) {
        if (languageKit.equals(targetLanguageKit))
            continue;
        String label = ResourceUtils.SIMPLE_NAME_PROVIDER.toString(registry, languageKit);
        MenuManager languageMenu = new MenuManager(label, languageIcon, null);
        if (fillEntityAssistMenu(ActionContainer.create(languageMenu), focusEntity, languageKit))
            menus.add(languageMenu);
    }
    HierarchicalFillMenuStrategy.instance(FullMenuNameStrategy.instance()).fillMenu(container, MenuManagerSet.create(menus.toArray(new MenuManager[menus.size()])), 0, menus.size());
    return menus.size() > 0;
}
Also used : MenuManager(org.eclipse.jface.action.MenuManager) ArrayList(java.util.ArrayList) ILanguageKit(org.whole.lang.reflect.ILanguageKit)

Example 39 with ILanguageKit

use of org.whole.lang.reflect.ILanguageKit in project whole by wholeplatform.

the class AbstractWizardWholeModelImportPage method initOptionsGroup.

private void initOptionsGroup() {
    ILanguageKit languageKit = ReflectionFactory.getLanguageKit(PojoLanguageKit.URI, false, null);
    setFilename("ModelExample" + filenameCount + "." + languageKit.getDefaultFileExtension());
    persistenceKits = new ArrayList<IPersistenceKit>(languageKit.getPersistenceKits());
    Iterator<IPersistenceKit> iterator = persistenceKits.iterator();
    presistenceTypes.setItems(new String[0]);
    while (iterator.hasNext()) presistenceTypes.add(iterator.next().getDescription());
    int selectionIndex = persistenceKits.indexOf(languageKit.getDefaultPersistenceKit());
    presistenceTypes.select(selectionIndex);
    presistenceTypes.addSelectionListener(new SelectionListener() {

        public void widgetDefaultSelected(SelectionEvent e) {
        }

        public void widgetSelected(SelectionEvent e) {
            String name = getFilename();
            name = StringUtils.replaceExtension(name, getPersistenceKit(presistenceTypes).getFileExtension());
            setFilename(name);
        }
    });
}
Also used : SelectionEvent(org.eclipse.swt.events.SelectionEvent) IPersistenceKit(org.whole.lang.codebase.IPersistenceKit) ILanguageKit(org.whole.lang.reflect.ILanguageKit) SelectionListener(org.eclipse.swt.events.SelectionListener)

Example 40 with ILanguageKit

use of org.whole.lang.reflect.ILanguageKit in project whole by wholeplatform.

the class FactoriesTest method testDynamicFactory.

@Test
public void testDynamicFactory() {
    TypeRelations typeRelations = ModelsEntityFactory.instance.createTypeRelations();
    IEntityFactory ef = GenericEntityFactory.instance(RegistryConfigurations.CUSTOM);
    InterpreterOperation.interpret(new ModelsModel().create());
    ILanguageKit lk = ReflectionFactory.getLanguageKit("http://lang.whole.org/Models");
    EntityDescriptorEnum edEnum = lk.getEntityDescriptorEnum();
    typeRelations.wAdd(ef.create(edEnum.valueOf("TypeAliasOf")));
    // PrettyPrinterOperation.prettyPrint(typeRelations);
    Assert.assertFalse(typeRelations.wIsAdapter());
    ReflectionFactory.deploy(new ModelsLanguageDynamicTestDeployer());
    IEntity e1 = ef.create(ModelsEntityDescriptorEnum.TypeRelations, ef.create(ModelsEntityDescriptorEnum.TypeAliasOf), ef.create(ModelsEntityDescriptorEnum.SubtypesOf).wGetAdaptee(false));
    PrettyPrinterOperation.prettyPrint(e1);
    Assert.assertTrue(e1.wIsAdapter());
}
Also used : PropertiesEntityDescriptorEnum(org.whole.lang.properties.reflect.PropertiesEntityDescriptorEnum) ModelsEntityDescriptorEnum(org.whole.lang.models.reflect.ModelsEntityDescriptorEnum) TestEntitiesEntityDescriptorEnum(org.whole.lang.testentities.reflect.TestEntitiesEntityDescriptorEnum) JavaEntityDescriptorEnum(org.whole.lang.java.reflect.JavaEntityDescriptorEnum) EntityDescriptorEnum(org.whole.lang.reflect.EntityDescriptorEnum) IEntity(org.whole.lang.model.IEntity) TypeRelations(org.whole.lang.models.model.TypeRelations) ModelsModel(org.whole.lang.models.codebase.ModelsModel) ILanguageKit(org.whole.lang.reflect.ILanguageKit) Test(org.junit.Test)

Aggregations

ILanguageKit (org.whole.lang.reflect.ILanguageKit)41 IEntity (org.whole.lang.model.IEntity)12 EntityDescriptorEnum (org.whole.lang.reflect.EntityDescriptorEnum)8 Actions (org.whole.lang.actions.model.Actions)7 GroupAction (org.whole.lang.actions.model.GroupAction)7 EntityDescriptor (org.whole.lang.reflect.EntityDescriptor)7 FeatureDescriptor (org.whole.lang.reflect.FeatureDescriptor)6 ArrayList (java.util.ArrayList)5 ActionsUIEntityFactory (org.whole.lang.actions.ui.factories.ActionsUIEntityFactory)5 Test (org.junit.Test)4 QueriesEntityFactory (org.whole.lang.queries.factories.QueriesEntityFactory)4 IVisitor (org.whole.lang.visitors.IVisitor)4 HashMap (java.util.HashMap)3 IBindingManager (org.whole.lang.bindings.IBindingManager)3 Grammar (org.whole.lang.grammars.model.Grammar)3 IDataTypeParser (org.whole.lang.parsers.IDataTypeParser)3 HashSet (java.util.HashSet)2 SelectionEvent (org.eclipse.swt.events.SelectionEvent)2 SelectionListener (org.eclipse.swt.events.SelectionListener)2 IPersistenceKit (org.whole.lang.codebase.IPersistenceKit)2