Exemplo n.º 1
0
  /**
   * Creates jobs grid.
   *
   * @param myJobsColumnModel column model used for jobs grid
   * @return grid with jobs
   */
  private Grid<MyJobsModel> createJobsGrid(ColumnModel<MyJobsModel> myJobsColumnModel) {
    final Grid<MyJobsModel> myJobsGrid = new Grid<MyJobsModel>(myJobsStore, myJobsColumnModel);
    myJobsGrid.setBorders(false);
    myJobsGrid.setHideHeaders(true);
    myJobsGrid.getView().setStripeRows(true);
    myJobsGrid.getView().setColumnLines(false);
    myJobsGrid.getView().setForceFit(true);
    myJobsGrid.getSelectionModel().setSelectionMode(SelectionMode.SINGLE);

    myJobsGrid.addStyleName("eppic-default-font");

    myJobsGrid.setContextMenu(new JobsPanelContextMenu(myJobsGrid));

    myJobsGrid.addCellClickHandler(
        new CellClickHandler() {

          @Override
          public void onCellClick(CellClickEvent event) {
            History.newItem("id/" + myJobsStore.get(event.getRowIndex()).getJobid());
          }
        });

    myJobsGrid
        .getSelectionModel()
        .addSelectionHandler(
            new SelectionHandler<MyJobsModel>() {

              @Override
              public void onSelection(SelectionEvent<MyJobsModel> event) {
                if (event.getSelectedItem() != null) {
                  History.newItem("id/" + event.getSelectedItem().getJobid());
                }
              }
            });

    new KeyNav(myJobsGrid) {
      @Override
      public void onDelete(NativeEvent event) {
        MyJobsModel selectedItem = myJobsGrid.getSelectionModel().getSelectedItem();
        if (selectedItem != null) {
          CrkWebServiceProvider.getServiceController().deleteJob(selectedItem.getJobid());
        }
      }
    };

    QuickTip gridQT = new QuickTip(myJobsGrid);
    // Bug-Fix in GXt 3.0.1
    // To fix the issue of blank Tooltips we set the delay
    gridQT.setQuickShowInterval(0);
    gridQT.getToolTipConfig().setShowDelay(0);

    return myJobsGrid;
  }
Exemplo n.º 2
0
  @Test
  public void testEditToolDetails_saveEvent() {

    ToolAdminViewImpl spy = spy(uut);

    /** CALL METHOD UNDER TEST * */
    spy.editToolDetails(toolMock);
    verify(toolDetailsDialogMock).get(asyncCallbackDialogCaptor.capture());

    AsyncCallback<ToolAdminDetailsDialog> asyncCallback = asyncCallbackDialogCaptor.getValue();
    ToolAdminDetailsDialog resultMock = mock(ToolAdminDetailsDialog.class);

    /** CALL METHOD UNDER TEST * */
    asyncCallback.onSuccess(resultMock);
    verify(resultMock).show(eq(toolMock));
    verify(resultMock)
        .addSaveToolSelectedEventHandler(saveToolSelectedEventHandlerArgumentCaptor.capture());

    SaveToolSelectedEvent.SaveToolSelectedEventHandler saveHandlerMock =
        saveToolSelectedEventHandlerArgumentCaptor.getValue();
    SaveToolSelectedEvent saveEventMock = mock(SaveToolSelectedEvent.class);

    /** CALL METHOD UNDER TEST * */
    saveHandlerMock.onSaveToolSelected(saveEventMock);

    verify(spy).fireEvent(isA(SaveToolSelectedEvent.class));
    verify(resultMock).hide();
    verify(toolGridMock.getSelectionModel()).deselect(eq(toolMock));
  }
Exemplo n.º 3
0
  @Before
  public void setUp() {
    when(gridSelectionModelMock.getSelectedItem()).thenReturn(toolMock);
    when(toolGridMock.getSelectionModel()).thenReturn(gridSelectionModelMock);

    /** CALL METHOD UNDER TEST * */
    uut = new ToolAdminViewImpl(appearanceMock, toolPropertiesMock, toolListStoreMock);

    uut.grid = toolGridMock;
    uut.toolDetailsDialog = toolDetailsDialogMock;
  }
Exemplo n.º 4
0
  @Inject
  AppsGridViewImpl(
      final AppsGridView.AppsGridAppearance appearance, @Assisted final ListStore<App> listStore) {
    this.appearance = appearance;
    this.listStore = listStore;

    setWidget(ourUiBinder.createAndBindUi(this));
    this.acm = (AppColumnModel) cm;
    grid.getSelectionModel().addSelectionChangedHandler(this);

    new QuickTip(grid).getToolTipConfig().setTrackMouse(true);
  }
Exemplo n.º 5
0
  /**
   * Selects correct job before removal.
   *
   * @param jobToStop identifier of the job which was removed
   */
  private void selectPrevious(String jobToRemove) {
    List<MyJobsModel> currentJobs = myJobsStore.getAll();

    boolean found = false;
    int jobNr = 0;

    while ((jobNr < currentJobs.size()) && (!found)) {
      if (currentJobs.get(jobNr).getJobid().equals(jobToRemove)) {
        found = true;
      }

      jobNr++;
    }

    jobNr -= 2;

    if (jobNr >= 0) {
      myJobsGrid.getSelectionModel().select(currentJobs.get(jobNr), false);
    } else if (myJobsStore.getAll().size() > 1) {
      myJobsGrid.getSelectionModel().select(currentJobs.get(1), false);
    } else {
      History.newItem("");
    }
  }
Exemplo n.º 6
0
 public void deleteVolume() {
   ToolVolume deleteVolume = grid.getSelectionModel().getSelectedItem();
   if (deleteVolume != null) {
     listStore.remove(listStore.findModelWithKey(getVolumeTag(deleteVolume)));
   }
 }
Exemplo n.º 7
0
  /**
   * Adds jobs to grid.
   *
   * @param jobs jobs to display
   * @param selectedJobId current job
   */
  private void setJobs(List<ProcessingInProgressData> jobs, String selectedJobId) {
    MyJobsModel itemToSelect = null;
    int itemToSelectIndex = 0;

    if (jobs != null) {
      int i = 0;

      for (int ii = 0; ii < myJobsStore.size(); ii++) {
        MyJobsModel model = myJobsStore.get(ii);
        boolean found = false;
        int j = 0;

        while ((j < jobs.size()) && (!found)) {
          if (jobs.get(j).getJobId().equals(model.getJobid())) {
            found = true;
            break;
          }

          j++;
        }

        if (!found) {
          myJobsStore.remove(ii);
        }
      }

      for (ProcessingInProgressData statusData : jobs) {
        MyJobsModel myJobsModel =
            new MyJobsModel(statusData.getJobId(), statusData.getStatus(), statusData.getInput());

        if ((selectedJobId != null) && (statusData.getJobId().equals(selectedJobId))) {
          itemToSelect = myJobsModel;
          itemToSelectIndex = i;
        }

        MyJobsModel existingModel = myJobsStore.findModel(myJobsModel);

        if (existingModel != null) {
          existingModel.setStatus(statusData.getStatus());
          existingModel.setInput(statusData.getInput());
          myJobsStore.update(existingModel);
        } else {
          myJobsStore.add(myJobsModel);
        }

        i++;
      }
    }

    myJobsStore.commitChanges();

    if ((selectedJobId != null) && (myJobsStore.size() > 0)) {
      myJobsGrid.getSelectionModel().select(itemToSelect, false);

      if (isJobsListFirstTimeLoaded) {
        myJobsGrid.getView().focusRow(itemToSelectIndex);
        isJobsListFirstTimeLoaded = false;
      }
      EventBusManager.EVENT_BUS.fireEvent(new ShowJobsPanelEvent());
    } else {
      EventBusManager.EVENT_BUS.fireEvent(new HideJobsPanelEvent());
    }
  }