use of org.entando.entando.aps.system.services.widgettype.WidgetType in project entando-core by entando.
the class WidgetTypeAction method edit.
/**
* Edit an exist widget type.
*
* @return The result code.
*/
public String edit() {
try {
String check = this.checkWidgetType();
if (null != check) {
return check;
}
this.setStrutsAction(ApsAdminSystemConstants.EDIT);
WidgetType type = this.getWidgetTypeManager().getWidgetType(this.getWidgetTypeCode());
ApsProperties titles = type.getTitles();
this.setItalianTitle(titles.getProperty("it"));
this.setEnglishTitle(titles.getProperty("en"));
String mainGroup = (StringUtils.isBlank(type.getMainGroup())) ? Group.FREE_GROUP_NAME : type.getMainGroup();
this.setMainGroup(mainGroup);
if (type.isLogic()) {
List<String> guiFragmentCodes = this.extractGuiFragmentCodes(this.getWidgetTypeCode());
for (int i = 0; i < guiFragmentCodes.size(); i++) {
String guiFragmentCode = guiFragmentCodes.get(i);
GuiFragment guiFragment = this.getGuiFragment(guiFragmentCode);
if (StringUtils.isNotEmpty(guiFragment.getGui())) {
String fieldName = type.getCode() + "_" + guiFragmentCode;
this.getGuis().setProperty(fieldName, guiFragment.getGui());
}
}
} else {
GuiFragment guiFragment = this.getGuiFragmentManager().getUniqueGuiFragmentByWidgetType(this.getWidgetTypeCode());
if (null != guiFragment) {
this.setGui(guiFragment.getGui());
}
}
} catch (Throwable t) {
_logger.error("error in edit", t);
return FAILURE;
}
return SUCCESS;
}
use of org.entando.entando.aps.system.services.widgettype.WidgetType in project entando-core by entando.
the class WidgetTypeAction method createCopiedWidget.
private WidgetType createCopiedWidget(Widget widgetToCopy) {
WidgetType type = this.createNewWidgetType();
WidgetType parentType = widgetToCopy.getType();
type.setParentType(parentType);
type.setConfig(widgetToCopy.getConfig());
return type;
}
use of org.entando.entando.aps.system.services.widgettype.WidgetType in project entando-core by entando.
the class WidgetTypeAction method createNewWidgetType.
private WidgetType createNewWidgetType() {
WidgetType type = new WidgetType();
type.setCode(this.getWidgetTypeCode());
ApsProperties titles = new ApsProperties();
titles.setProperty("it", this.getItalianTitle());
titles.setProperty("en", this.getEnglishTitle());
type.setTitles(titles);
type.setLocked(false);
return type;
}
use of org.entando.entando.aps.system.services.widgettype.WidgetType in project entando-core by entando.
the class SimpleWidgetConfigAction method createNewWidget.
protected Widget createNewWidget() {
if (this.getWidgetTypeCode() == null || this.getWidgetType(this.getWidgetTypeCode()) == null) {
_logger.error("Widget Code missin or invalid : " + this.getWidgetTypeCode());
// throw new Exception("Widget Code missin or invalid : " + this.getWidgetTypeCode());
return null;
}
Widget widget = new Widget();
WidgetType type = this.getWidgetType(this.getWidgetTypeCode());
widget.setType(type);
widget.setConfig(new ApsProperties());
return widget;
}
use of org.entando.entando.aps.system.services.widgettype.WidgetType in project entando-core by entando.
the class PageDAO method createWidget.
protected Widget createWidget(PageRecord page, int pos, ResultSet res, int startIndex) throws ApsSystemException, SQLException {
String typeCode = res.getString(startIndex++);
if (null == typeCode) {
return null;
}
Widget widget = new Widget();
WidgetType type = this.getWidgetTypeManager().getWidgetType(typeCode);
widget.setType(type);
ApsProperties config = new ApsProperties();
String configText = res.getString(startIndex++);
if (null != configText && configText.trim().length() > 0) {
try {
config.loadFromXml(configText);
} catch (Throwable t) {
_logger.error("IO error detected while parsing the configuration of the widget in position '{}' of the page '{}'", pos, page.getCode(), t);
String msg = "IO error detected while parsing the configuration of the widget in position " + pos + " of the page '" + page.getCode() + "'";
throw new ApsSystemException(msg, t);
}
} else {
config = type.getConfig();
}
widget.setConfig(config);
return widget;
}
Aggregations