use of com.qcadoo.view.api.ribbon.RibbonGroup in project mes by qcadoo.
the class ActionListHooks method disableActionsWhenDefault.
private void disableActionsWhenDefault(final ViewDefinitionState view) {
WindowComponent window = (WindowComponent) view.getComponentByReference(QcadooViewConstants.L_WINDOW);
RibbonGroup actions = window.getRibbon().getGroupByName("actions");
RibbonActionItem copyButton = actions.getItemByName("copy");
RibbonActionItem deleteButton = actions.getItemByName("delete");
GridComponent grid = (GridComponent) view.getComponentByReference(QcadooViewConstants.L_GRID);
List<Entity> selectedFaults = grid.getSelectedEntities();
for (Entity selectedFault : selectedFaults) {
if (selectedFault.getBooleanField("isDefault")) {
copyButton.setEnabled(false);
deleteButton.setEnabled(false);
copyButton.requestUpdate(true);
deleteButton.requestUpdate(true);
return;
}
}
boolean enabled = !selectedFaults.isEmpty();
copyButton.setEnabled(enabled);
deleteButton.setEnabled(enabled);
copyButton.requestUpdate(true);
deleteButton.requestUpdate(true);
}
use of com.qcadoo.view.api.ribbon.RibbonGroup in project mes by qcadoo.
the class EventHooks method enableFromRibbonGroup.
private void enableFromRibbonGroup(final ViewDefinitionState view, final boolean enable, final String groupName, String... items) {
WindowComponent window = (WindowComponent) view.getComponentByReference(QcadooViewConstants.L_WINDOW);
Ribbon ribbon = window.getRibbon();
RibbonGroup ribbonGroup = ribbon.getGroupByName(groupName);
if (ribbonGroup != null) {
for (String item : items) {
RibbonActionItem ribbonItem = ribbonGroup.getItemByName(item);
if (ribbonItem != null) {
ribbonItem.setEnabled(enable);
ribbonItem.requestUpdate(true);
}
}
}
}
use of com.qcadoo.view.api.ribbon.RibbonGroup in project mes by qcadoo.
the class PlannedEventDetailsHooks method toggleAddMultipleActions.
private void toggleAddMultipleActions(ViewDefinitionState view, FieldsForType fieldsForType, Entity plannedEvent) {
WindowComponent window = (WindowComponent) view.getComponentByReference(QcadooViewConstants.L_WINDOW);
Ribbon ribbon = window.getRibbon();
RibbonGroup actionsGroup = ribbon.getGroupByName("actionsGroup");
RibbonActionItem addActionsItem = actionsGroup.getItemByName("addActions");
String state = plannedEvent.getStringField(PlannedEventFields.STATE);
List<String> statesToDisable = Arrays.asList(PlannedEventStateStringValues.REALIZED, PlannedEventStateStringValues.CANCELED);
boolean enableAddActions = plannedEvent.getId() != null && !statesToDisable.contains(state) && !fieldsForType.getHiddenTabs().contains(PlannedEventFields.ACTIONS_TAB);
addActionsItem.setEnabled(enableAddActions);
addActionsItem.requestUpdate(true);
}
use of com.qcadoo.view.api.ribbon.RibbonGroup in project mes by qcadoo.
the class PlannedEventDetailsHooks method lockView.
private void lockView(final ViewDefinitionState view) {
FormComponent plannedEventForm = (FormComponent) view.getComponentByReference(QcadooViewConstants.L_FORM);
WindowComponent window = (WindowComponent) view.getComponentByReference(QcadooViewConstants.L_WINDOW);
Ribbon ribbon = window.getRibbon();
RibbonGroup actionsRibbonGroup = ribbon.getGroupByName(L_ACTIONS);
RibbonGroup statusRibbonGroup = ribbon.getGroupByName(L_STATUS);
List<RibbonActionItem> ribbonActionItems = actionsRibbonGroup.getItems();
ribbonActionItems.addAll(statusRibbonGroup.getItems());
for (RibbonActionItem ribbonActionItem : ribbonActionItems) {
ribbonActionItem.setEnabled(false);
ribbonActionItem.requestUpdate(true);
}
for (String referenceName : L_GRIDS) {
lockGrid(view, referenceName);
}
plannedEventForm.setFormEnabled(false);
}
use of com.qcadoo.view.api.ribbon.RibbonGroup in project mes by qcadoo.
the class PlannedEventDetailsHooks method enableFromRibbonGroup.
private void enableFromRibbonGroup(final ViewDefinitionState view, final boolean enable, final String groupName, String... items) {
WindowComponent window = (WindowComponent) view.getComponentByReference(QcadooViewConstants.L_WINDOW);
Ribbon ribbon = window.getRibbon();
RibbonGroup ribbonGroup = ribbon.getGroupByName(groupName);
if (ribbonGroup != null) {
for (String item : items) {
RibbonActionItem ribbonActionItem = ribbonGroup.getItemByName(item);
if (ribbonActionItem != null) {
ribbonActionItem.setEnabled(enable);
ribbonActionItem.requestUpdate(true);
}
}
}
}
Aggregations