Search in sources :

Example 71 with RibbonGroup

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);
}
Also used : Entity(com.qcadoo.model.api.Entity) RibbonGroup(com.qcadoo.view.api.ribbon.RibbonGroup) WindowComponent(com.qcadoo.view.api.components.WindowComponent) GridComponent(com.qcadoo.view.api.components.GridComponent) RibbonActionItem(com.qcadoo.view.api.ribbon.RibbonActionItem)

Example 72 with RibbonGroup

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);
            }
        }
    }
}
Also used : RibbonGroup(com.qcadoo.view.api.ribbon.RibbonGroup) WindowComponent(com.qcadoo.view.api.components.WindowComponent) Ribbon(com.qcadoo.view.api.ribbon.Ribbon) RibbonActionItem(com.qcadoo.view.api.ribbon.RibbonActionItem)

Example 73 with RibbonGroup

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);
}
Also used : RibbonGroup(com.qcadoo.view.api.ribbon.RibbonGroup) Ribbon(com.qcadoo.view.api.ribbon.Ribbon) RibbonActionItem(com.qcadoo.view.api.ribbon.RibbonActionItem)

Example 74 with RibbonGroup

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);
}
Also used : RibbonGroup(com.qcadoo.view.api.ribbon.RibbonGroup) Ribbon(com.qcadoo.view.api.ribbon.Ribbon) RibbonActionItem(com.qcadoo.view.api.ribbon.RibbonActionItem)

Example 75 with RibbonGroup

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);
            }
        }
    }
}
Also used : RibbonGroup(com.qcadoo.view.api.ribbon.RibbonGroup) Ribbon(com.qcadoo.view.api.ribbon.Ribbon) RibbonActionItem(com.qcadoo.view.api.ribbon.RibbonActionItem)

Aggregations

RibbonGroup (com.qcadoo.view.api.ribbon.RibbonGroup)92 RibbonActionItem (com.qcadoo.view.api.ribbon.RibbonActionItem)86 WindowComponent (com.qcadoo.view.api.components.WindowComponent)75 Ribbon (com.qcadoo.view.api.ribbon.Ribbon)37 FormComponent (com.qcadoo.view.api.components.FormComponent)36 Entity (com.qcadoo.model.api.Entity)34 GridComponent (com.qcadoo.view.api.components.GridComponent)23 FieldComponent (com.qcadoo.view.api.components.FieldComponent)9 ViewDefinitionState (com.qcadoo.view.api.ViewDefinitionState)3 LookupComponent (com.qcadoo.view.api.components.LookupComponent)3 JSONObject (org.json.JSONObject)3 AssignmentToShiftState (com.qcadoo.mes.assignmentToShift.states.constants.AssignmentToShiftState)2 DataDefinition (com.qcadoo.model.api.DataDefinition)2 CheckBoxComponent (com.qcadoo.view.api.components.CheckBoxComponent)2 QcadooViewConstants (com.qcadoo.view.constants.QcadooViewConstants)2 Optional (com.google.common.base.Optional)1 HashMultimap (com.google.common.collect.HashMultimap)1 Lists (com.google.common.collect.Lists)1 Maps (com.google.common.collect.Maps)1 Multimap (com.google.common.collect.Multimap)1