private void restoreFileVersion(FileVersion fileVersion) {
    // Set labels/status
    String shortFileName = shortenFileName(fileVersion.getPath());
    String versionStr = Long.toString(fileVersion.getVersion());

    restoreButton.setEnabled(false);
    restoreStatusIconComposite.setVisible(true);
    restoreStatusTextLabel.setVisible(true);

    restoreStatusIconComposite.setAnimatedImage(
        IMAGE_LOADING_SPINNER_RESOURCE, IMAGE_LOADING_SPINNER_FRAME_RATE);
    restoreStatusTextLabel.setText(
        I18n.getText(
            "org.syncany.gui.history.DetailPanel.label.fileRestoreOngoing",
            shortFileName,
            versionStr));
    restoreStatusTextLabel.setCursor(new Cursor(Display.getDefault(), SWT.CURSOR_ARROW));
    restoreStatusTextLabel.setToolTipText("");

    restoredFile = null;

    layout();

    // Send restore request
    RestoreOperationOptions restoreOptions = new RestoreOperationOptions();
    restoreOptions.setFileHistoryId(fileVersion.getFileHistoryId());
    restoreOptions.setFileVersion(fileVersion.getVersion().intValue());

    pendingRestoreRequest = new RestoreFolderRequest();
    pendingRestoreRequest.setRoot(historyModel.getSelectedRoot());
    pendingRestoreRequest.setOptions(restoreOptions);

    eventBus.post(pendingRestoreRequest);
  }
예제 #2
0
  private void handleRestoreRequest(RestoreRequest restoreRequest) {
    RestoreOperationOptions restoreOptions = new RestoreOperationOptions();

    restoreOptions.setFileHistoryId(FileHistoryId.parseFileId(restoreRequest.getFileHistoryId()));
    restoreOptions.setFileVersion(restoreRequest.getVersion());

    try {
      RestoreOperationResult restoreResult = new RestoreOperation(config, restoreOptions).execute();

      RestoreResponse restoreResponse =
          new RestoreResponse(restoreRequest.getId(), restoreResult.getTargetFile());
      eventBus.post(restoreResponse);
    } catch (Exception e) {
      logger.log(Level.WARNING, "BadRequestResponse: Cannot restore file.");
      eventBus.post(new BadRequestResponse(restoreRequest.getId(), "Cannot restore file."));
    }
  }