use of com.qcadoo.view.api.components.WindowComponent in project qcadoo by qcadoo.
the class UserService method setupRibbonForAdmins.
public void setupRibbonForAdmins(final ViewDefinitionState state) {
WindowComponent window = (WindowComponent) state.getComponentByReference(QcadooViewConstants.L_WINDOW);
if (!securityService.hasCurrentUserRole("ROLE_SUPERADMIN") && securityService.hasCurrentUserRole("ROLE_ADMIN")) {
RibbonGroup actions = window.getRibbon().getGroupByName("actions");
for (RibbonActionItem actionItem : actions.getItems()) {
actionItem.setEnabled(false);
actionItem.requestUpdate(true);
}
}
}
use of com.qcadoo.view.api.components.WindowComponent in project mes by qcadoo.
the class TechnologyDetailsHooksPFTD method changeRibbonState.
private void changeRibbonState(final ViewDefinitionState view) {
FormComponent technologyForm = (FormComponent) view.getComponentByReference(QcadooViewConstants.L_FORM);
Long technologyId = technologyForm.getEntityId();
if (Objects.isNull(technologyId)) {
return;
}
Entity technology = technologyForm.getPersistedEntityWithIncludedFormValues();
WindowComponent window = (WindowComponent) view.getComponentByReference(QcadooViewConstants.L_WINDOW);
RibbonGroup flow = window.getRibbon().getGroupByName(L_PRODUCTS_FLOW);
RibbonActionItem fillLocationsInComponents = flow.getItemByName(L_FILL_LOCATIONS_IN_COMPONENTS);
RibbonGroup modelCard = window.getRibbon().getGroupByName(MODEL_CARD);
RibbonGroup productionLines = window.getRibbon().getGroupByName(PRODUCTION_LINES);
RibbonActionItem addMultipleProductionLines = productionLines.getItemByName(ADD_MULTIPLE_PRODUCTION_LINES);
String state = technology.getStringField(TechnologyFields.STATE);
boolean isTemplateAccepted = technology.getBooleanField(TechnologyFields.IS_TEMPLATE_ACCEPTED);
fillLocationsInComponents.setEnabled(!isTemplateAccepted && TechnologyState.DRAFT.getStringValue().equals(state));
fillLocationsInComponents.requestUpdate(true);
addMultipleProductionLines.setEnabled(!isTemplateAccepted && TechnologyState.DRAFT.getStringValue().equals(state));
addMultipleProductionLines.requestUpdate(true);
if (Objects.nonNull(modelCard)) {
RibbonActionItem createModelCard = modelCard.getItemByName(CREATE_MODEL_CARD);
createModelCard.setEnabled(TechnologyState.CHECKED.getStringValue().equals(state) || TechnologyState.ACCEPTED.getStringValue().equals(state));
createModelCard.requestUpdate(true);
}
window.requestRibbonRender();
}
use of com.qcadoo.view.api.components.WindowComponent in project mes by qcadoo.
the class ProductionTrackingDetailsHooks method updateRibbonState.
public void updateRibbonState(final ViewDefinitionState view) {
FormComponent productionTrackingForm = (FormComponent) view.getComponentByReference(QcadooViewConstants.L_FORM);
WindowComponent window = (WindowComponent) view.getComponentByReference(QcadooViewConstants.L_WINDOW);
RibbonGroup actionsRibbonGroup = window.getRibbon().getGroupByName(L_ACTIONS);
RibbonGroup productsQuantitiesRibbonGroup = window.getRibbon().getGroupByName(L_PRODUCTS_QUANTITIES);
RibbonGroup productionCountingQuantitiesRibbonGroup = window.getRibbon().getGroupByName(L_PRODUCTION_COUNTING_QUANTITIES);
RibbonGroup anomaliesRibbonGroup = window.getRibbon().getGroupByName(L_ANOMALIES);
RibbonActionItem copyRibbonActionItem = actionsRibbonGroup.getItemByName(L_COPY);
RibbonActionItem copyPlannedQuantityToUsedQuantityRibbonActionItem = productsQuantitiesRibbonGroup.getItemByName(L_COPY_PLANNED_QUANTITY_TO_USED_QUANTITY);
RibbonActionItem productionCountingQuantitiesRibbonActionItem = productionCountingQuantitiesRibbonGroup.getItemByName(L_PRODUCTION_COUNTING_QUANTITIES);
RibbonActionItem addToAnomaliesListRibbonActionItem = anomaliesRibbonGroup.getItemByName(L_ADD_TO_ANOMALIES_LIST);
if (Objects.isNull(productionTrackingForm.getEntityId())) {
return;
}
Entity productionTracking = productionTrackingForm.getEntity();
Entity order = productionTracking.getBelongsToField(ProductionTrackingFields.ORDER);
if (Objects.isNull(order)) {
return;
}
String state = productionTracking.getStringField(ProductionTrackingFields.STATE);
String orderState = order.getStringField(OrderFields.STATE);
boolean isInProgress = OrderStateStringValues.IN_PROGRESS.equals(orderState);
boolean isDraft = ProductionTrackingStateStringValues.DRAFT.equals(state);
boolean registerQuantityInProduct = order.getBooleanField(OrderFieldsPC.REGISTER_QUANTITY_IN_PRODUCT);
boolean registerQuantityOutProduct = order.getBooleanField(OrderFieldsPC.REGISTER_QUANTITY_OUT_PRODUCT);
copyRibbonActionItem.setEnabled(isInProgress);
String releaseOfMaterials = parameterService.getParameter().getStringField(ParameterFieldsPC.RELEASE_OF_MATERIALS);
if (ReleaseOfMaterials.MANUALLY_TO_ORDER_OR_GROUP.getStringValue().equals(releaseOfMaterials)) {
copyPlannedQuantityToUsedQuantityRibbonActionItem.setEnabled(false);
} else {
copyPlannedQuantityToUsedQuantityRibbonActionItem.setEnabled(isDraft && (registerQuantityInProduct || registerQuantityOutProduct));
}
productionCountingQuantitiesRibbonActionItem.setEnabled(isDraft && (registerQuantityInProduct || registerQuantityOutProduct));
addToAnomaliesListRibbonActionItem.setEnabled(isDraft && (registerQuantityInProduct || registerQuantityOutProduct));
copyRibbonActionItem.requestUpdate(true);
copyPlannedQuantityToUsedQuantityRibbonActionItem.requestUpdate(true);
productionCountingQuantitiesRibbonActionItem.requestUpdate(true);
addToAnomaliesListRibbonActionItem.requestUpdate(true);
}
use of com.qcadoo.view.api.components.WindowComponent in project mes by qcadoo.
the class ProductionTrackingsForProductGroupedListHooks method updateButtonsState.
public void updateButtonsState(final ViewDefinitionState view) {
GridComponent productionTrackingsForProductGroupedGrid = (GridComponent) view.getComponentByReference(QcadooViewConstants.L_GRID);
WindowComponent window = (WindowComponent) view.getComponentByReference(QcadooViewConstants.L_WINDOW);
Ribbon ribbon = window.getRibbon();
RibbonGroup showProductionTrackingsRibbonGroup = ribbon.getGroupByName(L_SHOW_PRODUCTION_TRACKINGS);
RibbonActionItem showProductionTrackingsForProductRibbonActionItem = showProductionTrackingsRibbonGroup.getItemByName(L_SHOW_PRODUCTION_TRACKINGS_FOR_PRODUCT);
boolean isSelected = !productionTrackingsForProductGroupedGrid.getSelectedEntities().isEmpty();
showProductionTrackingsForProductRibbonActionItem.setEnabled(isSelected);
showProductionTrackingsForProductRibbonActionItem.requestUpdate(true);
}
use of com.qcadoo.view.api.components.WindowComponent in project mes by qcadoo.
the class AnomalyProductionTrackingDetailsHooks method updateRibbon.
private void updateRibbon(final ViewDefinitionState view) {
try {
WindowComponent window = (WindowComponent) view.getComponentByReference(QcadooViewConstants.L_WINDOW);
RibbonGroup actions = window.getRibbon().getGroupByName(L_ACTIONS);
RibbonActionItem perform = actions.getItemByName("perform");
RibbonActionItem performAndAccept = actions.getItemByName("performAndAccept");
boolean performAndAcceptFlag = view.getJsonContext().getBoolean("window.mainTab.form.performAndAccept");
perform.setEnabled(!performAndAcceptFlag);
performAndAccept.setEnabled(performAndAcceptFlag);
perform.requestUpdate(true);
performAndAccept.requestUpdate(true);
} catch (JSONException e) {
}
}
Aggregations