/**
   * Refreshes the undo/redo icons with the last action performed.
   *
   * @param oUndoManager, the manager to use to check for undo/redo possibilities.
   */
  public void refreshUndoRedo(UndoManager oUndoManager) {

    // refresh undo
    pbUndo.setToolTipText(oUndoManager.getUndoPresentationName());
    pbUndo.setEnabled(oUndoManager.canUndo());

    // refresh redo
    pbRedo.setToolTipText(oUndoManager.getRedoPresentationName());
    pbRedo.setEnabled(oUndoManager.canRedo());
  }
Example #2
0
 public void undoableEditHappened(UndoableEditEvent e) {
   UndoManager mgr = Undo.getCurrentUndoMgr();
   if (mgr != null && mgr.canRedo()) {
     setToolTipText(mgr.getRedoPresentationName());
     setEnabled(true);
   } else {
     setToolTipText(tipStr);
     setEnabled(false);
   }
 }
Example #3
0
 public void actionPerformed(ActionEvent e) {
   UndoManager undo = menu.getCurScoreObject().manager;
   try {
     undo.undo();
     menu.setCurSaveFlag(false);
     p.repaint();
   } catch (CannotUndoException ex) {
     // System.out.println("Unable to undo: " + ex);
     // ex.printStackTrace();
   }
 }
  private void annotateExternally(
      @NotNull final VirtualFile file,
      @NotNull final PsiModifierListOwner listOwner,
      @NotNull Project project,
      @NotNull final String packageName,
      final VirtualFile virtualFile,
      @NotNull final String annotationFQName,
      @NotNull final PsiFile fromFile,
      final PsiNameValuePair[] value) {
    final XmlFile[] annotationsXml = new XmlFile[1];
    List<XmlFile> xmlFiles = findExternalAnnotationsXmlFiles(listOwner);
    if (xmlFiles != null) {
      for (XmlFile xmlFile : xmlFiles) {
        final VirtualFile vXmlFile = xmlFile.getVirtualFile();
        assert vXmlFile != null;
        if (VfsUtilCore.isAncestor(file, vXmlFile, false)) {
          annotationsXml[0] = xmlFile;
          if (!CodeInsightUtilBase.preparePsiElementForWrite(xmlFile)) return;
        }
      }
    } else {
      xmlFiles = new ArrayList<XmlFile>();
    }

    final List<PsiFile> annotationFiles = new ArrayList<PsiFile>(xmlFiles);
    new WriteCommandAction(project) {
      @Override
      protected void run(final Result result) throws Throwable {
        if (annotationsXml[0] == null) {
          annotationsXml[0] = createAnnotationsXml(file, packageName);
        }
        if (annotationsXml[0] != null) {
          annotationFiles.add(annotationsXml[0]);
          myExternalAnnotations.put(getFQN(packageName, virtualFile), annotationFiles);
          annotateExternally(listOwner, annotationFQName, annotationsXml[0], fromFile, value);
        }
      }
    }.execute();

    UndoManager.getInstance(project)
        .undoableActionPerformed(
            new BasicUndoableAction() {
              @Override
              public void undo() throws UnexpectedUndoException {
                dropCache();
              }

              @Override
              public void redo() throws UnexpectedUndoException {
                dropCache();
              }
            });
  }
Example #5
0
 public void actionPerformed(ActionEvent e) {
   UndoManager mgr = Undo.getLastUndoMgr();
   if (mgr != null && mgr.canRedo()) mgr.redo();
 }