use of com.qcadoo.view.internal.api.InternalViewDefinition in project qcadoo by qcadoo.
the class ViewRibbonModule method enable.
@Override
public void enable() {
addedGroups = new HashMap<WindowComponentPattern, RibbonGroupsPack>();
InternalViewDefinition viewDefinition = viewDefinitionService.getWithoutSession(viewExtension.getPluginName(), viewExtension.getViewName());
if (viewDefinition == null) {
throw new ModuleException(pluginIdentifier, "view", "reference to view which not exists");
}
try {
for (Node groupNode : viewDefinitionParser.geElementChildren(viewExtension.getExtesionNode())) {
try {
InternalRibbonGroup group = viewDefinitionParser.parseRibbonGroup(groupNode, viewDefinition);
group.setExtensionPluginIdentifier(pluginIdentifier);
RibbonGroupsPack groupsPack = new SingleRibbonGroupPack(group);
WindowComponentPattern window = viewDefinition.getRootWindow();
window.getRibbon().addGroupsPack(groupsPack);
addedGroups.put(window, groupsPack);
} catch (ViewDefinitionParserNodeException e) {
throw ViewDefinitionParserException.forFileAndNode(fileName, e);
}
}
} catch (Exception e) {
throw new ModuleException(pluginIdentifier, "view-ribbon-group", e);
}
}
use of com.qcadoo.view.internal.api.InternalViewDefinition 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.api.InternalViewDefinition in project qcadoo by qcadoo.
the class ViewHookModule method getViewDefinition.
private InternalViewDefinition getViewDefinition() {
InternalViewDefinition extendsView = viewDefinitionService.getWithoutSession(extendsViewPlugin, extendsViewName);
Preconditions.checkNotNull(extendsView, String.format("extension from %s: refers to view which not exists (%s - %s)", pluginIdentifier, extendsViewPlugin, extendsViewName));
return extendsView;
}
use of com.qcadoo.view.internal.api.InternalViewDefinition 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.api.InternalViewDefinition 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