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) {
}
}
}
}
}
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;
}
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;
}
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);
}
});
}
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());
}
Aggregations