use of com.qcadoo.view.internal.api.InternalViewDefinition in project qcadoo by qcadoo.
the class RibbonUtils method translateRibbonAction.
public static String translateRibbonAction(final String action, final ViewDefinition viewDefinition) {
if (action == null) {
return null;
}
if (viewDefinition == null) {
return action;
}
Pattern p = Pattern.compile("#\\{([^\\}]+)\\}");
Matcher m = p.matcher(action);
String translateAction = action;
while (m.find()) {
ComponentPattern actionComponentPattern = ((InternalViewDefinition) viewDefinition).getComponentByReference(m.group(1));
if (actionComponentPattern == null) {
throw new IllegalStateException("Cannot find component '" + m.group(1) + "' for action: " + action);
}
translateAction = translateAction.replace("#{" + m.group(1) + "}", "#{" + actionComponentPattern.getPath() + "}");
}
return translateAction;
}
use of com.qcadoo.view.internal.api.InternalViewDefinition in project qcadoo by qcadoo.
the class ViewListenerModule method getComponent.
private ComponentPattern getComponent() {
InternalViewDefinition extendsView = viewDefinitionService.getWithoutSession(extendsViewPlugin, extendsViewName);
Preconditions.checkNotNull(extendsView, String.format("extension in %s: referes to view which not exists (%s - %s)", pluginIdentifier, extendsViewPlugin, extendsViewName));
ComponentPattern component = extendsView.getComponentByReference(extendsComponentName);
Preconditions.checkNotNull(component, String.format("extension in %s: component '%s' not exists in view (%s - %s)", pluginIdentifier, extendsComponentName, extendsViewPlugin, extendsViewName));
return component;
}
use of com.qcadoo.view.internal.api.InternalViewDefinition in project qcadoo by qcadoo.
the class ViewModule method disable.
@Override
public void disable() {
InternalViewDefinition viewDefinition = viewDefinitionParser.parseViewXml(xmlFile, pluginIdentifier);
viewDefinitionService.delete(viewDefinition);
}
use of com.qcadoo.view.internal.api.InternalViewDefinition in project qcadoo by qcadoo.
the class ViewModule method enable.
@Override
public void enable() {
try {
InternalViewDefinition viewDefinition = viewDefinitionParser.parseViewXml(xmlFile, pluginIdentifier);
viewDefinitionService.save(viewDefinition);
} catch (Exception e) {
throw new ModuleException(pluginIdentifier, "view", e);
}
}
use of com.qcadoo.view.internal.api.InternalViewDefinition in project qcadoo by qcadoo.
the class CrudServiceImpl method prepareView.
@Override
public ModelAndView prepareView(final String pluginIdentifier, final String viewName, final Map<String, String> arguments, final Locale locale) {
InternalViewDefinition viewDefinition = (InternalViewDefinition) viewDefinitionService.get(pluginIdentifier, viewName);
Preconditions.checkState(viewDefinition != null, String.format("Can't find view '%s/%s'", pluginIdentifier, viewName));
ModelAndView modelAndView = new ModelAndView("crud/crudView");
String context = viewDefinition.translateContextReferences(arguments.get("context"));
JSONObject jsonContext = new JSONObject();
if (StringUtils.hasText(context)) {
try {
jsonContext = new JSONObject(context);
viewDefinition.setJsonContext(jsonContext);
} catch (JSONException e) {
throw new IllegalStateException(e.getMessage(), e);
}
}
modelAndView.addObject("model", viewDefinition.prepareView(jsonContext, locale));
modelAndView.addObject("viewName", viewName);
modelAndView.addObject("pluginIdentifier", pluginIdentifier);
modelAndView.addObject("context", context);
boolean popup = false;
if (arguments.containsKey("popup")) {
popup = Boolean.parseBoolean(arguments.get("popup"));
}
modelAndView.addObject("popup", popup);
modelAndView.addObject("locale", locale.getLanguage());
return modelAndView;
}
Aggregations