use of com.qcadoo.view.internal.ribbon.model.RibbonActionItemImpl in project qcadoo by qcadoo.
the class RibbonTemplates method createFormDeactivateAction.
private InternalRibbonActionItem createFormDeactivateAction(final ViewDefinition viewDefinition) {
InternalRibbonActionItem ribbonDeactivateAction = new RibbonActionItemImpl();
ribbonDeactivateAction.setAction(RibbonUtils.translateRibbonAction("#{form}.performDeactivate;", viewDefinition));
ribbonDeactivateAction.setIcon("unactiveNotVisibleIcon.png");
ribbonDeactivateAction.setName("deactivate");
ribbonDeactivateAction.setEnabled(false);
ribbonDeactivateAction.setScript("var listener = {onSetValue: function(value) {if (!value || !value.content) return; if (value.content.entityId " + "&& value.content.isActive) {this.enable();} else {this.disable();}}}; #{form}.addOnChangeListener(listener);");
ribbonDeactivateAction.setType(RibbonActionItem.Type.SMALL_BUTTON);
return ribbonDeactivateAction;
}
use of com.qcadoo.view.internal.ribbon.model.RibbonActionItemImpl in project qcadoo by qcadoo.
the class RibbonTemplates method createGridExportCsvAction.
private InternalRibbonActionItem createGridExportCsvAction(final ViewDefinition viewDefinition) {
InternalRibbonActionItem ribbonExportCsvAction = new RibbonActionItemImpl();
ribbonExportCsvAction.setIcon("exportToCsvIcon16.png");
ribbonExportCsvAction.setName("csv");
ribbonExportCsvAction.setEnabled(true);
ribbonExportCsvAction.setScript("var listener = {onClick: function() {#{grid}.performEvent('exportToCsv', [], 'exportToCsv');}};" + " this.addOnChangeListener(listener);");
ribbonExportCsvAction.setType(RibbonActionItem.Type.SMALL_BUTTON);
return ribbonExportCsvAction;
}
use of com.qcadoo.view.internal.ribbon.model.RibbonActionItemImpl in project qcadoo by qcadoo.
the class RibbonTemplates method createFormDeleteAction.
private InternalRibbonActionItem createFormDeleteAction(final ViewDefinition viewDefinition) {
InternalRibbonActionItem ribbonDeleteAction = new RibbonActionItemImpl();
ribbonDeleteAction.setAction(RibbonUtils.translateRibbonAction("#{form}.performDelete;", viewDefinition));
ribbonDeleteAction.setIcon("deleteIcon16.png");
ribbonDeleteAction.setName("delete");
ribbonDeleteAction.setType(RibbonActionItem.Type.SMALL_BUTTON);
ribbonDeleteAction.setEnabled(false);
ribbonDeleteAction.setDefaultEnabled(false);
ribbonDeleteAction.setScript("var listener = {onSetValue: function(value) {if (!value || !value.content) return; if (value.content.entityId) {" + "this.enable();} else {this.disable();}}}; #{form}.addOnChangeListener(listener);");
return ribbonDeleteAction;
}
use of com.qcadoo.view.internal.ribbon.model.RibbonActionItemImpl in project qcadoo by qcadoo.
the class RibbonTemplates method createFormCancelAction.
private InternalRibbonActionItem createFormCancelAction(final ViewDefinition viewDefinition) {
InternalRibbonActionItem ribbonCancelAction = new RibbonActionItemImpl();
ribbonCancelAction.setAction(RibbonUtils.translateRibbonAction("#{form}.performCancel;", viewDefinition));
ribbonCancelAction.setIcon("cancelIcon16.png");
ribbonCancelAction.setName("cancel");
ribbonCancelAction.setEnabled(true);
ribbonCancelAction.setType(RibbonActionItem.Type.SMALL_BUTTON);
return ribbonCancelAction;
}
use of com.qcadoo.view.internal.ribbon.model.RibbonActionItemImpl in project qcadoo by qcadoo.
the class RibbonParserService method parseRibbonItem.
public InternalRibbonActionItem parseRibbonItem(final Node itemNode, final ViewDefinitionParser parser, final ViewDefinition viewDefinition) throws ViewDefinitionParserNodeException {
String stringType = itemNode.getNodeName();
RibbonActionItem.Type type = null;
if ("bigButtons".equals(stringType) || "bigButton".equals(stringType)) {
type = RibbonActionItem.Type.BIG_BUTTON;
} else if ("smallButtons".equals(stringType) || "smallButton".equals(stringType)) {
type = RibbonActionItem.Type.SMALL_BUTTON;
} else if ("combobox".equals(stringType)) {
type = RibbonActionItem.Type.COMBOBOX;
} else if ("smallEmptySpace".equals(stringType)) {
type = RibbonActionItem.Type.SMALL_EMPTY_SPACE;
} else {
throw new ViewDefinitionParserNodeException(itemNode, "Unsupported ribbon item type '" + stringType + "'");
}
InternalRibbonActionItem item = null;
if ("bigButtons".equals(stringType) || "smallButtons".equals(stringType)) {
item = new RibbonComboItemImpl();
} else if ("combobox".equals(stringType)) {
item = new RibbonComboBoxImpl();
} else {
item = new RibbonActionItemImpl();
}
item.setIcon(parser.getStringAttribute(itemNode, "icon"));
item.setName(parser.getStringAttribute(itemNode, NAME));
String accesskey = parser.getStringAttribute(itemNode, "accesskey");
if (accesskey != null) {
item.setAccesskey(accesskey);
}
item.setAction(RibbonUtils.translateRibbonAction(parser.getStringAttribute(itemNode, "action"), viewDefinition));
item.setType(type);
String state = parser.getStringAttribute(itemNode, "state");
if (state == null) {
item.setEnabled(true);
} else {
if ("enabled".equals(state)) {
item.setEnabled(true);
} else if ("disabled".equals(state)) {
item.setEnabled(false);
} else {
throw new ViewDefinitionParserNodeException(itemNode, "Unsupported ribbon item state : " + state);
}
}
item.setDefaultEnabled(item.isEnabled());
String message = parser.getStringAttribute(itemNode, "message");
if (message != null) {
item.setMessage(message);
}
NodeList childNodes = itemNode.getChildNodes();
for (int i = 0; i < childNodes.getLength(); i++) {
Node child = childNodes.item(i);
if (child.getNodeType() == Node.ELEMENT_NODE && "script".equals(child.getNodeName())) {
item.setScript(parser.getStringNodeContent(child));
}
}
if (item instanceof RibbonComboItem) {
for (int i = 0; i < childNodes.getLength(); i++) {
Node child = childNodes.item(i);
if (child.getNodeType() == Node.ELEMENT_NODE && !"script".equals(child.getNodeName())) {
((InternalRibbonComboItem) item).addItem(parseRibbonItem(child, parser, viewDefinition));
}
}
} else if (item instanceof RibbonComboBox) {
for (int i = 0; i < childNodes.getLength(); i++) {
Node child = childNodes.item(i);
if (child.getNodeType() == Node.ELEMENT_NODE && !"script".equals(child.getNodeName())) {
if (!"option".equals(child.getNodeName())) {
throw new ViewDefinitionParserNodeException(child, "ribbon combobox can only have 'option' elements");
}
((RibbonComboBox) item).addOption(parser.getStringAttribute(child, NAME));
}
}
} else {
(item).setAction(RibbonUtils.translateRibbonAction(parser.getStringAttribute(itemNode, "action"), viewDefinition));
}
return item;
}
Aggregations