use of com.qcadoo.view.api.components.WindowComponent in project mes by qcadoo.
the class NumberPatternDetailsHooks method onBeforeRender.
public void onBeforeRender(final ViewDefinitionState view) {
FormComponent form = (FormComponent) view.getComponentByReference(QcadooViewConstants.L_FORM);
Entity numberPattern = form.getPersistedEntityWithIncludedFormValues();
if (numberPattern.getBooleanField(NumberPatternFields.USED)) {
form.setFormEnabled(false);
GridComponent grid = (GridComponent) view.getComponentByReference("numberPatternElements");
grid.setEditable(false);
WindowComponent window = (WindowComponent) view.getComponentByReference(QcadooViewConstants.L_WINDOW);
RibbonGroup actions = window.getRibbon().getGroupByName("actions");
RibbonActionItem save = actions.getItemByName("save");
save.setEnabled(false);
save.requestUpdate(true);
RibbonActionItem saveBack = actions.getItemByName("saveBack");
saveBack.setEnabled(false);
saveBack.requestUpdate(true);
RibbonActionItem saveNew = actions.getItemByName("saveNew");
saveNew.setEnabled(false);
saveNew.requestUpdate(true);
window.requestRibbonRender();
}
}
use of com.qcadoo.view.api.components.WindowComponent in project mes by qcadoo.
the class EventHooks method toggleOldSolutionsButton.
private void toggleOldSolutionsButton(ViewDefinitionState view) {
WindowComponent windowComponent = (WindowComponent) view.getComponentByReference(QcadooViewConstants.L_WINDOW);
Ribbon ribbon = windowComponent.getRibbon();
RibbonGroup solutionsRibbonGroup = ribbon.getGroupByName("solutions");
RibbonActionItem showSolutionsRibbonActionItem = solutionsRibbonGroup.getItemByName("showSolutions");
FormComponent formComponent = (FormComponent) view.getComponentByReference(QcadooViewConstants.L_FORM);
Entity event = formComponent.getPersistedEntityWithIncludedFormValues();
showSolutionsRibbonActionItem.setEnabled(event.getId() != null);
showSolutionsRibbonActionItem.requestUpdate(true);
}
use of com.qcadoo.view.api.components.WindowComponent in project mes by qcadoo.
the class EventHooks method toggleRibbonButton.
private void toggleRibbonButton(final ViewDefinitionState view, String groupName, String itemName, boolean enabled) {
WindowComponent window = (WindowComponent) view.getComponentByReference(QcadooViewConstants.L_WINDOW);
Ribbon ribbon = window.getRibbon();
RibbonGroup group = ribbon.getGroupByName(groupName);
RibbonActionItem item = group.getItemByName(itemName);
item.setEnabled(enabled);
item.requestUpdate(true);
}
use of com.qcadoo.view.api.components.WindowComponent in project mes by qcadoo.
the class CostCalculationDetailsHooks method setButtonsEnabled.
private void setButtonsEnabled(ViewDefinitionState view) {
WindowComponent window = (WindowComponent) view.getComponentByReference(QcadooViewConstants.L_WINDOW);
RibbonActionItem saveNominalCosts = window.getRibbon().getGroupByName(CostCalculationFields.SAVE_COSTS).getItemByName(CostCalculationFields.NOMINAL_COSTS);
RibbonActionItem generate = window.getRibbon().getGroupByName("generate").getItemByName("generate");
RibbonActionItem pdfButton = window.getRibbon().getGroupByName("export").getItemByName("pdf");
RibbonActionItem xlsButton = window.getRibbon().getGroupByName("export").getItemByName("xls");
RibbonActionItem save = window.getRibbon().getGroupByName(ACTIONS).getItemByName("save");
RibbonActionItem saveBack = window.getRibbon().getGroupByName(ACTIONS).getItemByName("saveBack");
RibbonActionItem saveNew = window.getRibbon().getGroupByName(ACTIONS).getItemByName("saveNew");
RibbonActionItem copy = window.getRibbon().getGroupByName(ACTIONS).getItemByName("copy");
RibbonActionItem cancel = window.getRibbon().getGroupByName(ACTIONS).getItemByName("cancel");
FormComponent form = (FormComponent) view.getComponentByReference(QcadooViewConstants.L_FORM);
boolean pdf = form.getPersistedEntityWithIncludedFormValues().getBooleanField(CostCalculationFields.PDF);
boolean entityExists = form.getEntityId() != null;
if (entityExists) {
CheckBoxComponent generatedField = (CheckBoxComponent) view.getComponentByReference(CostCalculationFields.GENERATED);
int technologiesCount = ((GridComponent) view.getComponentByReference(CostCalculationFields.TECHNOLOGIES)).getEntities().size();
generate.setEnabled(technologiesCount > 0);
generate.requestUpdate(true);
saveNominalCosts.setEnabled(generatedField.isChecked());
saveNominalCosts.requestUpdate(true);
if (generatedField.isChecked()) {
if (pdf) {
pdfButton.setEnabled(true);
pdfButton.requestUpdate(true);
} else {
xlsButton.setEnabled(true);
xlsButton.requestUpdate(true);
}
generate.setEnabled(false);
generate.requestUpdate(true);
save.setEnabled(false);
save.setMessage(COST_CALCULATION_RIBBON_MESSAGE_RECORD_ALREADY_GENERATED);
save.requestUpdate(true);
saveNew.setEnabled(false);
saveNew.setMessage(COST_CALCULATION_RIBBON_MESSAGE_RECORD_ALREADY_GENERATED);
saveNew.requestUpdate(true);
saveBack.setEnabled(false);
saveBack.setMessage(COST_CALCULATION_RIBBON_MESSAGE_RECORD_ALREADY_GENERATED);
saveBack.requestUpdate(true);
cancel.setEnabled(false);
cancel.setMessage(COST_CALCULATION_RIBBON_MESSAGE_RECORD_ALREADY_GENERATED);
} else {
pdfButton.setEnabled(false);
pdfButton.setMessage("costCalculation.ribbon.message.recordNotGenerated");
pdfButton.requestUpdate(true);
xlsButton.setEnabled(false);
xlsButton.setMessage("costCalculation.ribbon.message.recordNotGenerated");
xlsButton.requestUpdate(true);
save.setEnabled(true);
save.requestUpdate(true);
cancel.setEnabled(true);
}
} else {
copy.setEnabled(false);
copy.setMessage(RECORD_NOT_CREATED);
copy.requestUpdate(true);
pdfButton.setEnabled(false);
pdfButton.setMessage(RECORD_NOT_CREATED);
pdfButton.requestUpdate(true);
xlsButton.setEnabled(false);
xlsButton.setMessage(RECORD_NOT_CREATED);
xlsButton.requestUpdate(true);
save.setEnabled(true);
save.requestUpdate(true);
cancel.setEnabled(true);
}
cancel.requestUpdate(true);
}
use of com.qcadoo.view.api.components.WindowComponent in project mes by qcadoo.
the class TechnologiesListHooksCC method toggleGenerateCostCalculationButton.
public void toggleGenerateCostCalculationButton(final ViewDefinitionState view) {
WindowComponent window = (WindowComponent) view.getComponentByReference(QcadooViewConstants.L_WINDOW);
RibbonActionItem generateCostCalculation = window.getRibbon().getGroupByName("costCalculation").getItemByName("createCostCalculation");
GridComponent grid = (GridComponent) view.getComponentByReference(QcadooViewConstants.L_GRID);
generateCostCalculation.setEnabled(!grid.getSelectedEntities().isEmpty());
generateCostCalculation.requestUpdate(true);
}
Aggregations