use of org.whole.lang.reflect.ILanguageKit in project whole by wholeplatform.
the class XsdMappingTest method testModelsToXmlSchemaXXX.
@Test
public void testModelsToXmlSchemaXXX() throws Exception {
IBindingManager bm = BindingManagerFactory.instance.createArguments();
PathExpression path = new ModelToXmlSchemaQuery().create();
Model model = (Model) ModelsTemplateManager.instance().create("Models model");
String uri = model.getUri().getValue();
ILanguageKit lk = ReflectionFactory.getLanguageKit(uri);
IEntity tuple = BehaviorUtils.evaluateFirstResult(path, model, bm);
Assert.assertNotNull(tuple);
InterpreterOperation.interpret(tuple.wGet(1));
ITemplateManager tm = lk.getTemplateManager();
IEntity entity = tm.create("Editors model");
IPersistenceProvider pp = new StringPersistenceProvider();
XsiPersistenceKit.instance().writeModel(entity, pp);
IEntity entity2 = XsiPersistenceKit.instance().readModel(pp);
boolean matches = Matcher.match(entity, entity2);
Assert.assertTrue(matches);
}
use of org.whole.lang.reflect.ILanguageKit in project whole by wholeplatform.
the class EntityAssistCompositeContributionItem method fillItems.
protected boolean fillItems(IItemContainer<MenuManager, ImageDescriptor> menuContainer, IItemContainer<IAction, ImageDescriptor> actionContainer, IBindingManager bm) {
IEntity focusEntity = bm.wGet("focusEntity");
IEntity targetEntity = getTargetEntity(focusEntity);
IEntity targetParent = targetEntity.wGetParent();
ILanguageKit targetLanguageKit = EntityUtils.isResolver(targetEntity) && !EntityUtils.isNull(targetParent) ? targetParent.wGetLanguageKit() : targetEntity.wGetLanguageKit();
boolean hasExtendedActions = fillExtendedEntityAssistMenu(menuContainer, focusEntity, targetLanguageKit);
actionContainer.addSeparator();
boolean hasActions = fillEntityAssistMenu(actionContainer, focusEntity, targetLanguageKit);
return hasExtendedActions || hasActions;
}
use of org.whole.lang.reflect.ILanguageKit in project whole by wholeplatform.
the class AbstractEntity method wGetEditorKit.
public IEditorKit wGetEditorKit() {
ILanguageKit languageKit = wGetEntityDescriptor().getLanguageKit();
IFragmentModel model = wGetActualModel();
if (model != NullFragmentModel.instance) {
IEditorKit editorKit = model.getEditorKit();
if (editorKit.canApply(languageKit))
return editorKit;
}
return languageKit.getDefaultEditorKit();
// return model != NullFragmentModel.instance ? model.getEditorKit() : languageKit.getDefaultEditorKit();
}
use of org.whole.lang.reflect.ILanguageKit in project whole by wholeplatform.
the class WorkflowsUIContentAssistVisitor method allEntityTypes.
protected boolean allEntityTypes(IEntity entity) {
if (!WorkflowsUtils.isEntityTypeInCreateEntity(entity))
return false;
ActionsUIEntityFactory aef = ActionsUIEntityFactory.instance;
GroupAction languagesGroup = aef.createGroupAction();
languagesGroup.setFillStrategy(aef.createHierarchical(aef.createDistinctPrefix(), aef.createSize(10)));
languagesGroup.getText().setValue("workflows.languages");
Actions actions = aef.createActions(0);
WorkflowsEntityFactory wef = WorkflowsEntityFactory.instance;
String actualLanguageURI = "";
String actualEntityName = "";
EntityDescriptor<?> actualED = null;
try {
if (Matcher.matchImpl(StringLiteral, entity)) {
StringLiteral literal = (StringLiteral) entity;
actualED = CommonsDataTypePersistenceParser.parseEntityDescriptor(literal.getValue());
actualLanguageURI = actualED.getLanguageKit().getURI();
actualEntityName = actualED.getName();
}
} catch (Exception e) {
}
IResourceRegistry<ILanguageKit> registry = ReflectionFactory.getLanguageKitRegistry();
for (ILanguageKit languageKit : registry.getResources(false, ResourceUtils.SIMPLE_COMPARATOR)) {
if (languageKit.getURI().equals(actualLanguageURI))
continue;
EntityDescriptorEnum edEnum = languageKit.getEntityDescriptorEnum();
EntityDescriptor<?> ed = null;
if (actualEntityName.length() > 0)
ed = edEnum.valueOf(actualEntityName);
if (ed == null)
ed = edEnum.valueOf(0);
StringLiteral prototype = wef.createStringLiteral(CommonsDataTypePersistenceParser.unparseEntityDescriptor(ed));
actions.wAdd(aef.createReplaceDifferentTemplateAction(prototype, ResourceUtils.SIMPLE_NAME_PROVIDER.toString(registry, languageKit), IActionConstants.SELECT_LANGUAGE_ICON));
}
languagesGroup.setActions(actions);
boolean adeddLanguages = EntityUtils.isResolver(entity) ? mergeResult(StringLiteral, languagesGroup) : mergeResult(languagesGroup);
if (actualED != null) {
GroupAction typenamesGroup = aef.createGroupAction();
typenamesGroup.setFillStrategy(aef.createHierarchical(aef.createDistinctPrefix(), aef.createSize(10)));
typenamesGroup.getText().setValue("workflows.typenames");
actions = aef.createActions(0);
EntityDescriptorEnum edEnum = actualED.getEntityDescriptorEnum();
List<EntityDescriptor<?>> eds = new ArrayList<EntityDescriptor<?>>(edEnum.values());
Collections.sort(eds, new Comparator<EntityDescriptor<?>>() {
public int compare(EntityDescriptor<?> ed1, EntityDescriptor<?> ed2) {
return ed1.getName().compareTo(ed2.getName());
}
});
for (EntityDescriptor<?> ed : eds) {
if (ed.equals(actualED))
continue;
StringLiteral prototype = wef.createStringLiteral(CommonsDataTypePersistenceParser.unparseEntityDescriptor(ed));
actions.wAdd(aef.createReplaceDifferentTemplateAction(prototype, ed.getName()));
}
typenamesGroup.setActions(actions);
adeddLanguages |= EntityUtils.isResolver(entity) ? mergeResult(StringLiteral, typenamesGroup) : mergeResult(typenamesGroup);
}
return adeddLanguages;
}
use of org.whole.lang.reflect.ILanguageKit in project whole by wholeplatform.
the class XsiDateTimeUtilsTest method testGregorianCalendar.
@Test
public void testGregorianCalendar() {
ILanguageKit languageKit = ReflectionFactory.getLanguageKit(DATATYPES_URI);
EntityDescriptorEnum edEnum = languageKit.getEntityDescriptorEnum();
IDataTypeParser dataTypeParser = languageKit.getDataTypeParser(DataTypeParsers.PERSISTENCE);
EntityDescriptor<?> dateTime = edEnum.valueOf("XSDateTime");
EntityDescriptor<?> date = edEnum.valueOf("XSDate");
EntityDescriptor<?> time = edEnum.valueOf("XSTime");
EntityDescriptor<?> gYearMonth = edEnum.valueOf("XSGYearMonth");
DateTime base = new DateTime(2001, 1, 1, 11, 22, 33, 444, DateTimeZone.UTC);
assertEquals(dataTypeParser, base, dateTime, "1990-11-30T12:30:43.999Z", "1990-11-30T12:30:43.999Z");
assertEquals(dataTypeParser, base, dateTime, "1990-11-30T12:30:43", "1990-11-30T12:30:43.000Z");
assertEquals(dataTypeParser, base, gYearMonth, "1990-11", "1990-11-01T11:22:33.444Z");
assertEquals(dataTypeParser, base, date, "1990-11-30", "1990-11-30T11:22:33.444Z");
assertEquals(dataTypeParser, base, date, "1990-11-30Z", "1990-11-30T00:00:00.000Z");
assertEquals(dataTypeParser, base, date, "1990-11-30+02:00", "1990-11-29T22:00:00.000Z");
assertEquals(dataTypeParser, base, time, "12:30:43", "2001-01-01T12:30:43.000Z");
assertEquals(dataTypeParser, base, time, "12:30:43.999Z", "1970-01-01T12:30:43.999Z");
}
Aggregations