public void disableCreateButton(final ViewDefinitionState view) {
    WindowComponent window = (WindowComponent) view.getComponentByReference(L_WINDOW);

    RibbonGroup operationalTasks = window.getRibbon().getGroupByName(L_OPERATIONAL_TASKS);
    RibbonActionItem createOperationalTasks =
        operationalTasks.getItemByName(L_CREATE_OPERATIONAL_TASKS);

    if (isGenerated(view) && orderHasTechnologyAndCorrectState(view)) {
      createOperationalTasks.setEnabled(true);
    } else {
      createOperationalTasks.setEnabled(false);
    }

    createOperationalTasks.requestUpdate(true);
  }
  private void enableAddButton(ViewDefinitionState view) {
    FormComponent form = (FormComponent) view.getComponentByReference(L_FORM);
    Entity multiAssignment = form.getPersistedEntityWithIncludedFormValues();

    GridComponent workersComponent = (GridComponent) view.getComponentByReference("workers");
    WindowComponent window = (WindowComponent) view.getComponentByReference("window");
    RibbonGroup add = (RibbonGroup) window.getRibbon().getGroupByName("add");
    RibbonActionItem addMany = (RibbonActionItem) add.getItemByName("addManyWorkers");
    if (workersComponent.getEntities().isEmpty() || !multiAssignment.isValid()) {
      addMany.setEnabled(false);
      addMany.requestUpdate(true);
    } else {
      addMany.setEnabled(true);
      addMany.requestUpdate(true);
    }
  }
Ejemplo n.º 3
0
  @Test
  public final void shouldBuildFromViewDefinitionState() {
    // given
    ViewDefinitionState viewDefinitionState = mock(ViewDefinitionState.class);
    given(viewDefinitionState.getComponentByReference("window")).willReturn(windowComponent);
    Ribbon ribbon = mock(Ribbon.class);
    given((windowComponent).getRibbon()).willReturn(ribbon);
    RibbonGroup actionsRibbonGroup = mock(RibbonGroup.class);
    given(ribbon.getGroupByName("actions")).willReturn(actionsRibbonGroup);
    given(actionsRibbonGroup.getItemByName("delete")).willReturn(deleteButton);

    given(viewDefinitionState.getComponentByReference("grid")).willReturn(workPlansGrid);

    // when
    WorkPlansListView workPlansListView = WorkPlansListView.from(viewDefinitionState);
    workPlansListView.setUpDeleteButton(true, null);
    workPlansListView.getSelectedWorkPlans();

    // then
    verify(deleteButton).setEnabled(anyBoolean());
    verify(workPlansGrid).getSelectedEntities();
  }