use of com.qcadoo.view.internal.components.window.WindowComponentPattern in project qcadoo by qcadoo.
the class LookupComponentPattern method initializeComponent.
@Override
protected void initializeComponent() throws JSONException {
super.initializeComponent();
for (ComponentOption option : getOptions()) {
if ("expression".equals(option.getType())) {
expression = option.getValue();
} else if ("fieldCode".equals(option.getType())) {
fieldCode = option.getValue();
} else if ("header".equals(option.getType())) {
header = Boolean.parseBoolean(option.getValue());
} else if ("prioritizable".equals(option.getType())) {
prioritizable = Boolean.parseBoolean(option.getValue());
} else if ("onlyActive".equals(option.getType())) {
onlyActive = Boolean.parseBoolean(option.getValue());
} else if ("textRepresentationOnDisabled".equals(option.getType())) {
textRepresentationOnDisabled = Boolean.parseBoolean(option.getValue());
} else if ("boldTextRepresentationOnDisabled".equals(option.getType())) {
Boolean optionValue = Boolean.parseBoolean(option.getValue());
textRepresentationOnDisabled = optionValue;
boldTextRepresentationOnDisabled = optionValue;
}
}
modalDimensions = ModalDimensions.parseFromOptions(getOptions());
checkState(hasText(fieldCode), "Missing fieldCode for lookup");
checkState(hasText(expression), "Missing expression for lookup");
String viewName = getViewName();
DataDefinition dataDefinition = getDataDefinition();
if (getScopeFieldDefinition() != null) {
dataDefinition = getScopeFieldDefinition().getDataDefinition();
}
lookupViewDefinition = new ViewDefinitionImpl(viewName, getViewDefinition().getPluginIdentifier(), dataDefinition, false, getTranslationService());
WindowComponentPattern window = createWindowComponentPattern(lookupViewDefinition);
GridComponentPattern grid = createGridComponentPattern(lookupViewDefinition, window);
for (ComponentOption option : getOptions()) {
if ("orderable".equals(option.getType())) {
Map<String, String> newAttributes = new HashMap<>();
newAttributes.put(L_VALUE, option.getValue() + ",lookupCode");
option = new ComponentOption("orderable", newAttributes);
grid.addOption(option);
} else if ("searchable".equals(option.getType())) {
Map<String, String> newAttributes = new HashMap<>();
newAttributes.put(L_VALUE, option.getValue() + ",lookupCode");
option = new ComponentOption("searchable", newAttributes);
grid.addOption(option);
} else if (!"expression".equals(option.getType()) && !"fieldCode".equals(option.getType()) && !"textRepresentationOnDisabled".equals(option.getType()) && !"labelWidth".equals(option.getType())) {
grid.addOption(option);
}
}
grid.addOption(new ComponentOption("lookup", Collections.singletonMap(L_VALUE, L_TRUE)));
window.addChild(grid);
lookupViewDefinition.addComponentPattern(window);
lookupViewDefinition.initialize();
}
use of com.qcadoo.view.internal.components.window.WindowComponentPattern 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.components.window.WindowComponentPattern 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.components.window.WindowComponentPattern in project qcadoo by qcadoo.
the class LookupComponentPattern method createWindowComponentPattern.
private WindowComponentPattern createWindowComponentPattern(final ViewDefinition lookupViewDefinition) {
ComponentDefinition windowComponentDefinition = new ComponentDefinition();
windowComponentDefinition.setName(QcadooViewConstants.L_WINDOW);
windowComponentDefinition.setTranslationService(getTranslationService());
windowComponentDefinition.setApplicationContext(getApplicationContext());
windowComponentDefinition.setViewDefinition(lookupViewDefinition);
windowComponentDefinition.setContextualHelpService(getContextualHelpService());
WindowComponentPattern window = new WindowComponentPattern(windowComponentDefinition);
window.setFixedHeight(true);
window.setHeader(header);
window.setRibbon(createRibbon());
return window;
}
use of com.qcadoo.view.internal.components.window.WindowComponentPattern in project qcadoo by qcadoo.
the class ComponentPatternTest method shouldHaveOptionsWhenAdded.
@Test
public void shouldHaveOptionsWhenAdded() throws Exception {
// given
AbstractComponentPattern pattern = new WindowComponentPattern(getComponentDefinition("testName", null));
// when
Map<String, Object> model = pattern.prepareView(Locale.ENGLISH);
// then
JSONObject options = (JSONObject) model.get("jsOptions");
assertTrue(options.getBoolean("hasRibbon"));
}
Aggregations