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);
  }
 /** Restores currently selected archive */
 boolean restoreArchive() {
   String archivePath = (String) historyList.getSelectedValue();
   if (archivePath == null) {
     TopManager.getDefault()
         .notify(
             new NotifyDescriptor.Message(
                 NbBundle.getBundle(HistoryPanel.class).getString("MSG_NoSelection"),
                 NotifyDescriptor.ERROR_MESSAGE));
     return false;
   }
   HistoryModel.HistoryEntry foundEntry = historyData.getEntry(archivePath);
   File contentFile = new File(foundEntry.contentPath);
   // return if content not found
   if (!contentFile.exists()) {
     TopManager.getDefault()
         .notify(
             new NotifyDescriptor.Message(
                 MessageFormat.format(
                     NbBundle.getBundle(HistoryPanel.class).getString("FMT_NotExist"),
                     new Object[] {archivePath}),
                 NotifyDescriptor.ERROR_MESSAGE));
     return false;
   }
   // read jar content, if it's possible
   JarContent jc = null;
   try {
     ObjectInputStream ois =
         new ObjectInputStream(new BufferedInputStream(new FileInputStream(contentFile)));
     try {
       jc = new JarContent();
       jc.readContent(ois);
     } finally {
       ois.close();
     }
   } catch (IOException exc) {
     exc.printStackTrace();
     return false;
   } catch (ClassNotFoundException exc) {
     exc.printStackTrace();
     return false;
   }
   // set the content if everything goes well
   PackagingView.getPackagingView().setJarContent(jc);
   return true;
 }
  /** Update views. */
  protected void updateViews() {
    ptmodel.fireTableDataChanged();
    hmodel.fireTableDataChanged();
    //		if(ptmodel.getRowCount()>0)
    //			((ResizeableTableHeader)threads.getTableHeader()).resizeAllColumns();
    //		if(hmodel.getRowCount()>0)
    //			((ResizeableTableHeader)history.getTableHeader()).resizeAllColumns();
    threads.repaint();
    history.repaint();

    if (bpp != null) {
      List sel_bps = new ArrayList();
      for (int i = 0; i < threads_clone.length; i++) {
        if (threads_clone[i].getActivity() != null)
          sel_bps.add(threads_clone[i].getActivity().getBreakpointId());
      }
      bpp.setSelectedBreakpoints((String[]) sel_bps.toArray(new String[sel_bps.size()]));
    }
  }
Exemple #4
0
  /**
   * Invokes the specified action, repeating and recording it as necessary.
   *
   * @param action The action
   */
  @Override
  public void invokeAction(EditAction action) {
    JEditBuffer buffer = view.getBuffer();

    /* if(buffer.insideCompoundEdit())
    buffer.endCompoundEdit(); */

    // remember the last executed action
    if (!action.noRememberLast()) {
      HistoryModel.getModel("action").addItem(action.getName());
      if (lastAction == action) lastActionCount++;
      else {
        lastAction = action;
        lastActionCount = 1;
      }
    }

    // remember old values, in case action changes them
    int _repeatCount = repeatCount;

    // execute the action
    if (action.noRepeat() || _repeatCount == 1) action.invoke(view);
    else {
      // stop people doing dumb stuff like C+ENTER 100 C+n
      if (_repeatCount > REPEAT_COUNT_THRESHOLD) {
        String label = action.getLabel();
        if (label == null) label = action.getName();
        else label = GUIUtilities.prettifyMenuLabel(label);

        Object[] pp = {label, _repeatCount};

        if (GUIUtilities.confirm(
                view,
                "large-repeat-count",
                pp,
                JOptionPane.WARNING_MESSAGE,
                JOptionPane.YES_NO_OPTION)
            != JOptionPane.YES_OPTION) {
          repeatCount = 1;
          view.getStatus().setMessage(null);
          return;
        }
      }

      try {
        buffer.beginCompoundEdit();

        for (int i = 0; i < _repeatCount; i++) action.invoke(view);
      } finally {
        buffer.endCompoundEdit();
      }
    }

    Macros.Recorder recorder = view.getMacroRecorder();

    if (recorder != null && !action.noRecord()) recorder.record(_repeatCount, action.getCode());

    // If repeat was true originally, clear it
    // Otherwise it might have been set by the action, etc
    if (_repeatCount != 1) {
      // first of all, if this action set a
      // readNextChar, do not clear the repeat
      if (readNextChar != null) return;

      repeatCount = 1;
      view.getStatus().setMessage(null);
    }
  } // }}}