Beispiel #1
0
 @Override
 public void cancel(EditorRequest<JsonObject> request) {
   if (!handleServerInitiated(request)) {
     // No startRequest as we don't get (or need)
     // a confirmation from the server
     rpc.cancel(request.getRowIndex());
   }
 }
Beispiel #2
0
    /**
     * Used to handle the case where the editor calls us because it was invoked by the server via
     * RPC and not by the client. In that case, the request can be simply synchronously completed.
     *
     * @param request the request object
     * @return true if the request was originally triggered by the server, false otherwise
     */
    private boolean handleServerInitiated(EditorRequest<?> request) {
      assert request != null : "Cannot handle null request";
      assert currentRequest == null : "Earlier request not yet finished";

      if (serverInitiated) {
        serverInitiated = false;
        request.success();
        return true;
      } else {
        return false;
      }
    }
Beispiel #3
0
    private void endRequest(boolean succeeded, String errorMessage, List<String> errorColumnsIds) {
      assert currentRequest != null : "Current request was null";
      /*
       * Clear current request first to ensure the state is valid if
       * another request is made in the callback.
       */
      EditorRequest<JsonObject> request = currentRequest;
      currentRequest = null;
      if (succeeded) {
        request.success();
      } else {
        Collection<Column<?, JsonObject>> errorColumns;
        if (errorColumnsIds != null) {
          errorColumns = new ArrayList<Grid.Column<?, JsonObject>>();
          for (String colId : errorColumnsIds) {
            errorColumns.add(columnIdToColumn.get(colId));
          }
        } else {
          errorColumns = null;
        }

        request.failure(errorMessage, errorColumns);
      }
    }
Beispiel #4
0
 @Override
 public void save(EditorRequest<JsonObject> request) {
   startRequest(request);
   rpc.save(request.getRowIndex());
 }