use of com.qcadoo.view.internal.ComponentDefinition in project qcadoo by qcadoo.
the class ViewTabModule method enable.
@Override
public void enable() {
addedTabs = ArrayListMultimap.create();
InternalViewDefinition viewDefinition = viewDefinitionService.getWithoutSession(viewExtension.getPluginName(), viewExtension.getViewName());
if (viewDefinition == null) {
throw new ModuleException(pluginIdentifier, "view", String.format("Reference to view which not exists: %s[%s]", viewExtension.getPluginName(), viewExtension.getViewName()));
}
try {
for (Node tabNode : viewDefinitionParser.geElementChildren(viewExtension.getExtesionNode())) {
WindowComponentPattern window = viewDefinition.getRootWindow();
ComponentDefinition tabDefinition = viewDefinitionParser.getComponentDefinition(tabNode, window, viewDefinition);
tabDefinition.setExtensionPluginIdentifier(pluginIdentifier);
ComponentPattern tabPattern = new WindowTabComponentPattern(tabDefinition);
try {
tabPattern.parse(tabNode, viewDefinitionParser);
} catch (ViewDefinitionParserNodeException e) {
throw ViewDefinitionParserException.forFileAndNode(fileName, e);
}
window.addChild(tabPattern);
addedTabs.put(window, tabPattern);
tabPattern.initializeAll();
tabPattern.registerViews(viewDefinitionService);
}
} catch (Exception e) {
throw new ModuleException(pluginIdentifier, "view-tab", e);
}
}
use of com.qcadoo.view.internal.ComponentDefinition in project qcadoo by qcadoo.
the class AwesomeDynamicListPattern method parse.
@Override
public void parse(final Node componentNode, final ViewDefinitionParser parser) throws ViewDefinitionParserNodeException {
super.parse(componentNode, parser);
NodeList childNodes = componentNode.getChildNodes();
for (int i = 0; i < childNodes.getLength(); i++) {
Node child = childNodes.item(i);
if ("components".equals(child.getNodeName())) {
innerFormPattern.parse(child, parser);
} else if ("header".equals(child.getNodeName())) {
ComponentDefinition formComponentDefinition = new ComponentDefinition();
formComponentDefinition.setName("header");
formComponentDefinition.setFieldPath(null);
formComponentDefinition.setSourceFieldPath(null);
formComponentDefinition.setTranslationService(getTranslationService());
formComponentDefinition.setViewDefinition(getViewDefinition());
formComponentDefinition.setParent(this);
formComponentDefinition.setContextualHelpService(getContextualHelpService());
headerFormPattern = new FlowLayoutPattern(formComponentDefinition);
headerFormPattern.parse(child, parser);
children.put(headerFormPattern.getName(), headerFormPattern);
}
}
}
use of com.qcadoo.view.internal.ComponentDefinition in project qcadoo by qcadoo.
the class SelectComponentStateTest method init.
@Before
public void init() {
MockitoAnnotations.initMocks(this);
DictionaryType dictionaryType = new DictionaryType(DICTIONARY_NAME, dictionaryService, false);
TranslationService translationService = mock(TranslationService.class);
FieldDefinition fieldDefinition = mock(FieldDefinition.class);
when(fieldDefinition.getType()).thenReturn(dictionaryType);
when(fieldDefinition.isRequired()).thenReturn(true);
when(fieldDefinition.getDefaultValue()).thenReturn("asd");
ComponentDefinition definition = new ComponentDefinition();
definition.setName("selectComponent");
definition.setViewDefinition(mock(InternalViewDefinition.class));
SelectComponentPattern pattern = new SelectComponentPattern(definition);
setField(pattern, "fieldDefinition", fieldDefinition);
setField(pattern, "translationService", translationService);
componentState = new SelectComponentState(pattern, Lists.newArrayList());
setField(componentState, "locale", Locale.ENGLISH);
setField(pattern, "defaultRequired", true);
}
use of com.qcadoo.view.internal.ComponentDefinition in project qcadoo by qcadoo.
the class GridComponentPatternTest method shouldHaveScopeFieldName.
@Test
public void shouldHaveScopeFieldName() throws Exception {
// given
DataDefinition dataDefinition = mock(DataDefinition.class);
BelongsToType belongsToFieldType = mock(BelongsToType.class);
FieldDefinition belongsToFieldDefinition = mock(FieldDefinition.class);
given(belongsToFieldDefinition.getName()).willReturn("joinName");
given(belongsToFieldDefinition.getType()).willReturn(belongsToFieldType);
given(belongsToFieldDefinition.getDataDefinition()).willReturn(dataDefinition);
HasManyType hasManyFieldType = mock(HasManyType.class);
given(hasManyFieldType.getJoinFieldName()).willReturn("joinName");
given(hasManyFieldType.getDataDefinition()).willReturn(dataDefinition);
FieldDefinition hasManyFieldDefinition = mock(FieldDefinition.class);
given(hasManyFieldDefinition.getName()).willReturn("fieldName");
given(hasManyFieldDefinition.getType()).willReturn(hasManyFieldType);
given(hasManyFieldDefinition.getDataDefinition()).willReturn(dataDefinition);
given(dataDefinition.getField("field")).willReturn(hasManyFieldDefinition);
given(dataDefinition.getField("joinName")).willReturn(belongsToFieldDefinition);
InternalViewDefinition viewDefinition = mock(InternalViewDefinition.class);
AbstractComponentPattern sourceComponent = new TextInputComponentPattern(getComponentDefinition("component", viewDefinition));
setField(sourceComponent, "dataDefinition", dataDefinition);
setField(sourceComponent, "initialized", true);
given(viewDefinition.getComponentByReference("component")).willReturn(sourceComponent);
ComponentDefinition componentDefinition = getComponentDefinition(QcadooViewConstants.L_GRID, null, "#{component}.field", null, viewDefinition);
componentDefinition.setTranslationService(translationService);
componentDefinition.setApplicationContext(applicationContext);
GridComponentPattern pattern = new GridComponentPattern(componentDefinition);
pattern.addOption(new ComponentOption("order", ImmutableMap.of("column", "name", "direction", "asc")));
// when
pattern.initialize();
// then
JSONObject options = getJsOptions(pattern);
assertEquals("joinName", options.getString("belongsToFieldName"));
}
use of com.qcadoo.view.internal.ComponentDefinition in project qcadoo by qcadoo.
the class GridComponentPatternTest method shouldBeFullscreen.
@Test
public void shouldBeFullscreen() throws Exception {
// given
DataDefinition dataDefinition = mock(DataDefinition.class);
InternalViewDefinition viewDefinition = mock(InternalViewDefinition.class);
given(viewDefinition.getDataDefinition()).willReturn(dataDefinition);
ComponentDefinition componentDefinition = getComponentDefinition(QcadooViewConstants.L_GRID, viewDefinition);
componentDefinition.setTranslationService(translationService);
componentDefinition.setApplicationContext(applicationContext);
GridComponentPattern pattern = new GridComponentPattern(componentDefinition);
pattern.addOption(new ComponentOption("fullscreen", ImmutableMap.of("value", "true")));
pattern.addOption(new ComponentOption("order", ImmutableMap.of("column", "name", "direction", "asc")));
// when
pattern.initialize();
// then
JSONObject options = getJsOptions(pattern);
assertTrue(options.getBoolean("fullscreen"));
assertEquals(0, options.getInt("width"));
assertEquals(0, options.getInt("height"));
}
Aggregations