• 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏吧

Java BasicUndoableAction类的典型用法和代码示例

java 1次浏览

本文整理汇总了Java中com.intellij.openapi.command.undo.BasicUndoableAction的典型用法代码示例。如果您正苦于以下问题:Java BasicUndoableAction类的具体用法?Java BasicUndoableAction怎么用?Java BasicUndoableAction使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。

BasicUndoableAction类属于com.intellij.openapi.command.undo包,在下文中一共展示了BasicUndoableAction类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: performAnswerPlaceholderAction

点赞 3

import com.intellij.openapi.command.undo.BasicUndoableAction; //导入依赖的package包/类
@Override
protected void performAnswerPlaceholderAction(@NotNull CCState state) {
  AnswerPlaceholder placeholder = state.getAnswerPlaceholder();
  if (placeholder == null) {
    return;
  }
  EduUtils.runUndoableAction(state.getProject(), getName(), new BasicUndoableAction(state.getEditor().getDocument()) {
    @Override
    public void undo() throws UnexpectedUndoException {
      setVisible(placeholder, isVisible(), state);
    }

    @Override
    public void redo() throws UnexpectedUndoException {
      setVisible(placeholder, !isVisible(), state);
    }
  }, UndoConfirmationPolicy.REQUEST_CONFIRMATION);
}
 

开发者ID:medvector,
项目名称:educational-plugin,
代码行数:19,
代码来源:CCChangePlaceholderVisibility.java

示例2: doRename

点赞 3

import com.intellij.openapi.command.undo.BasicUndoableAction; //导入依赖的package包/类
public static void doRename(final PsiElement element, String newName, UsageInfo[] usages, final Project project,
                            @Nullable final RefactoringElementListener listener) throws IncorrectOperationException{
  final RenamePsiElementProcessor processor = RenamePsiElementProcessor.forElement(element);
  final String fqn = element instanceof PsiFile ? ((PsiFile)element).getVirtualFile().getPath() : CopyReferenceAction.elementToFqn(element);
  if (fqn != null) {
    UndoableAction action = new BasicUndoableAction() {
      @Override
      public void undo() throws UnexpectedUndoException {
        if (listener instanceof UndoRefactoringElementListener) {
          ((UndoRefactoringElementListener)listener).undoElementMovedOrRenamed(element, fqn);
        }
      }

      @Override
      public void redo() throws UnexpectedUndoException {
      }
    };
    UndoManager.getInstance(project).undoableActionPerformed(action);
  }
  processor.renameElement(element, newName, usages, listener);
}
 

开发者ID:jskierbi,
项目名称:intellij-ce-playground,
代码行数:22,
代码来源:RenameUtil.java

示例3: doFix

点赞 3

import com.intellij.openapi.command.undo.BasicUndoableAction; //导入依赖的package包/类
@Override
protected void doFix(final Project project, ProblemDescriptor descriptor) {
  addRemoveTestsScope(project, true);
  final VirtualFile vFile = descriptor.getPsiElement().getContainingFile().getVirtualFile();
  UndoManager.getInstance(project).undoableActionPerformed(new BasicUndoableAction(vFile) {
    @Override
    public void undo() throws UnexpectedUndoException {
      addRemoveTestsScope(project, false);
    }

    @Override
    public void redo() throws UnexpectedUndoException {
      addRemoveTestsScope(project, true);
    }
  });
}
 

开发者ID:jskierbi,
项目名称:intellij-ce-playground,
代码行数:17,
代码来源:SuppressForTestsScopeFix.java

示例4: doRename

点赞 3

import com.intellij.openapi.command.undo.BasicUndoableAction; //导入依赖的package包/类
public static void doRename(final PsiElement element, String newName, UsageInfo[] usages, final Project project,
                            @Nullable final RefactoringElementListener listener) throws IncorrectOperationException{
  final RenamePsiElementProcessor processor = RenamePsiElementProcessor.forElement(element);
  final String fqn = element instanceof PsiFile ? ((PsiFile)element).getVirtualFile().getPath() : QualifiedNameProviders.elementToFqn(element);
  if (fqn != null) {
    UndoableAction action = new BasicUndoableAction() {
      @Override
      public void undo() throws UnexpectedUndoException {
        if (listener instanceof UndoRefactoringElementListener) {
          ((UndoRefactoringElementListener)listener).undoElementMovedOrRenamed(element, fqn);
        }
      }

      @Override
      public void redo() throws UnexpectedUndoException {
      }
    };
    UndoManager.getInstance(project).undoableActionPerformed(action);
  }
  processor.renameElement(element, newName, usages, listener);
}
 

开发者ID:consulo,
项目名称:consulo,
代码行数:22,
代码来源:RenameUtil.java

示例5: doFix

点赞 3

import com.intellij.openapi.command.undo.BasicUndoableAction; //导入依赖的package包/类
@Override
protected void doFix(final Project project, ProblemDescriptor descriptor)
{
	addRemoveTestsScope(project, true);
	final VirtualFile vFile = descriptor.getPsiElement().getContainingFile().getVirtualFile();
	UndoManager.getInstance(project).undoableActionPerformed(new BasicUndoableAction(vFile)
	{
		@Override
		public void undo()
		{
			addRemoveTestsScope(project, false);
		}

		@Override
		public void redo()
		{
			addRemoveTestsScope(project, true);
		}
	});
}
 

开发者ID:consulo,
项目名称:consulo-java
代码行数:21,
代码来源:SuppressForTestsScopeFix.java

示例6: performAnswerPlaceholderAction

点赞 2

import com.intellij.openapi.command.undo.BasicUndoableAction; //导入依赖的package包/类
@Override
public void performAnswerPlaceholderAction(@NotNull CCState state) {
  Editor editor = state.getEditor();
  final int offset = editor.getCaretModel().getOffset();
  TaskFile taskFile = state.getTaskFile();
  final Task task = state.getTaskFile().getTask();
  if (!(task instanceof TaskWithSubtasks)) return;

  int subtaskIndex = ((TaskWithSubtasks)task).getActiveSubtaskIndex();
  AnswerPlaceholder existingPlaceholder = StudyUtils.getAnswerPlaceholder(offset, taskFile.getAnswerPlaceholders());
  if (existingPlaceholder == null) {
    return;
  }
  AnswerPlaceholderSubtaskInfo info = getInfo(state, subtaskIndex, existingPlaceholder);
  if (info == null) {
    return;
  }
  EduUtils.runUndoableAction(state.getProject(), getTitle(), new BasicUndoableAction(state.getEditor().getDocument()) {
    @Override
    public void undo() throws UnexpectedUndoException {
      undoAction(existingPlaceholder, subtaskIndex, info);
      StudyUtils.drawAllAnswerPlaceholders(editor, taskFile);
    }

    @Override
    public void redo() throws UnexpectedUndoException {
      redoAction(existingPlaceholder, subtaskIndex, info);
      StudyUtils.drawAllAnswerPlaceholders(editor, taskFile);
    }
  });
}
 

开发者ID:medvector,
项目名称:educational-plugin,
代码行数:32,
代码来源:CCSubtaskPlaceholderAction.java

示例7: flushCurrentCommand

点赞 2

import com.intellij.openapi.command.undo.BasicUndoableAction; //导入依赖的package包/类
public void flushCurrentCommand() {
  if (hasActions()) {
    if (!myAdditionalAffectedDocuments.isEmpty()) {
      DocumentReference[] refs = myAdditionalAffectedDocuments.toArray(new DocumentReference[myAdditionalAffectedDocuments.size()]);
      myCurrentActions.add(new BasicUndoableAction(refs) {
        @Override
        public void undo() {
        }

        @Override
        public void redo() {
        }
      });
    }

    myManager.getUndoStacksHolder().addToStacks(new UndoableGroup(myCommandName,
                                                                  isGlobal(),
                                                                  myManager,
                                                                  myStateBefore,
                                                                  myStateAfter,
                                                                  myCurrentActions,
                                                                  myUndoConfirmationPolicy,
                                                                  isTransparent(),
                                                                  myValid));
  }

  reset();
}
 

开发者ID:jskierbi,
项目名称:intellij-ce-playground,
代码行数:29,
代码来源:CommandMerger.java

示例8: flushCurrentCommand

点赞 2

import com.intellij.openapi.command.undo.BasicUndoableAction; //导入依赖的package包/类
void flushCurrentCommand() {
  if (hasActions()) {
    if (!myAdditionalAffectedDocuments.isEmpty()) {
      DocumentReference[] refs = myAdditionalAffectedDocuments.toArray(new DocumentReference[myAdditionalAffectedDocuments.size()]);
      myCurrentActions.add(new BasicUndoableAction(refs) {
        @Override
        public void undo() {
        }

        @Override
        public void redo() {
        }
      });
    }

    myManager.getUndoStacksHolder().addToStacks(new UndoableGroup(myCommandName,
                                                                  isGlobal(),
                                                                  myManager,
                                                                  myStateBefore,
                                                                  myStateAfter,
                                                                  myCurrentActions,
                                                                  myUndoConfirmationPolicy,
                                                                  isTransparent(),
                                                                  myValid));
  }

  reset();
}
 

开发者ID:consulo,
项目名称:consulo,
代码行数:29,
代码来源:CommandMerger.java

示例9: doFix

点赞 2

import com.intellij.openapi.command.undo.BasicUndoableAction; //导入依赖的package包/类
@Override
protected void doFix(Project project, ProblemDescriptor descriptor)
{
	if(!myIgnoredClasses.add(myQualifiedName))
	{
		return;
	}
	//InspectionProjectProfileManager.getInstance(project).fireProfileChanged();
	final VirtualFile vFile = descriptor.getPsiElement().getContainingFile().getVirtualFile();
	UndoManager.getInstance(project).undoableActionPerformed(new BasicUndoableAction(vFile)
	{
		@Override
		public void undo()
		{
			myIgnoredClasses.remove(myQualifiedName);
			//ProjectInspectionProfileManager.getInstance(project).fireProfileChanged();
		}

		@Override
		public void redo()
		{
			myIgnoredClasses.add(myQualifiedName);
			//ProjectInspectionProfileManager.getInstance(project).fireProfileChanged();
		}

		@Override
		public boolean isGlobal()
		{
			return true;
		}
	});
}
 

开发者ID:consulo,
项目名称:consulo-java
代码行数:33,
代码来源:IgnoreClassFix.java

示例10: annotateExternally

点赞 2

import com.intellij.openapi.command.undo.BasicUndoableAction; //导入依赖的package包/类
private void annotateExternally(@NotNull final VirtualFile root,
                                @NotNull final PsiModifierListOwner listOwner,
                                @NotNull final Project project,
                                @NotNull final String packageName,
                                @NotNull final String annotationFQName,
                                @NotNull final PsiFile fromFile,
                                @Nullable final PsiNameValuePair[] value) {
  List<XmlFile> xmlFiles = findExternalAnnotationsXmlFiles(listOwner);

  final XmlFile existingXml = findXmlFileInRoot(xmlFiles, root);
  if (existingXml != null && !FileModificationService.getInstance().preparePsiElementForWrite(existingXml)) {
    notifyAfterAnnotationChanging(listOwner, annotationFQName, false);
    return;
  }

  final Set<PsiFile> annotationFiles = xmlFiles == null ? new THashSet<PsiFile>() : new THashSet<PsiFile>(xmlFiles);

  new WriteCommandAction(project) {
    @Override
    protected void run(@NotNull final Result result) throws Throwable {
      if (existingXml != null) {
        annotateExternally(listOwner, annotationFQName, existingXml, fromFile, value);
      }
      else {
        XmlFile newXml = createAnnotationsXml(root, packageName);
        if (newXml == null) {
          notifyAfterAnnotationChanging(listOwner, annotationFQName, false);
        }
        else {
          annotationFiles.add(newXml);
          cacheExternalAnnotations(packageName, fromFile, new SmartList<PsiFile>(annotationFiles));
          annotateExternally(listOwner, annotationFQName, newXml, fromFile, value);
        }
      }

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

        @Override
        public void redo() {
          dropCache();
          notifyChangedExternally();
        }
      });
    }
  }.execute();
}
 

开发者ID:jskierbi,
项目名称:intellij-ce-playground,
代码行数:52,
代码来源:ExternalAnnotationsManagerImpl.java

示例11: annotateExternally

点赞 2

import com.intellij.openapi.command.undo.BasicUndoableAction; //导入依赖的package包/类
private void annotateExternally(@NotNull final VirtualFile root,
                                @NotNull final PsiModifierListOwner listOwner,
                                @NotNull final Project project,
                                @NotNull final String packageName,
                                @NotNull final String annotationFQName,
                                @NotNull final PsiFile fromFile,
                                @Nullable final PsiNameValuePair[] value) {
  List<XmlFile> xmlFiles = findExternalAnnotationsXmlFiles(listOwner);

  final XmlFile existingXml = findXmlFileInRoot(xmlFiles, root);
  if (existingXml != null && !FileModificationService.getInstance().preparePsiElementForWrite(existingXml)) {
    notifyAfterAnnotationChanging(listOwner, annotationFQName, false);
    return;
  }

  final Set<PsiFile> annotationFiles = xmlFiles == null ? new THashSet<PsiFile>() : new THashSet<PsiFile>(xmlFiles);

  new WriteCommandAction(project) {
    @Override
    protected void run(final Result result) throws Throwable {
      if (existingXml != null) {
        annotateExternally(listOwner, annotationFQName, existingXml, fromFile, value);
      }
      else {
        XmlFile newXml = createAnnotationsXml(root, packageName);
        if (newXml == null) {
          notifyAfterAnnotationChanging(listOwner, annotationFQName, false);
        }
        else {
          annotationFiles.add(newXml);
          cacheExternalAnnotations(packageName, fromFile, new SmartList<PsiFile>(annotationFiles));
          annotateExternally(listOwner, annotationFQName, newXml, fromFile, value);
        }
      }

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

        @Override
        public void redo() {
          dropCache();
          notifyChangedExternally();
        }
      });
    }
  }.execute();
}
 

开发者ID:lshain-android-source,
项目名称:tools-idea,
代码行数:52,
代码来源:ExternalAnnotationsManagerImpl.java

示例12: annotateExternally

点赞 2

import com.intellij.openapi.command.undo.BasicUndoableAction; //导入依赖的package包/类
private void annotateExternally(@NotNull final VirtualFile root,
		@NotNull final PsiModifierListOwner listOwner,
		@NotNull final Project project,
		@NotNull final String packageName,
		@NotNull final String annotationFQName,
		@NotNull final PsiFile fromFile,
		@Nullable final PsiNameValuePair[] value)
{
	List<XmlFile> xmlFiles = findExternalAnnotationsXmlFiles(listOwner);

	final XmlFile existingXml = findXmlFileInRoot(xmlFiles, root);
	if(existingXml != null && !FileModificationService.getInstance().preparePsiElementForWrite(existingXml))
	{
		notifyAfterAnnotationChanging(listOwner, annotationFQName, false);
		return;
	}

	final Set<PsiFile> annotationFiles = xmlFiles == null ? new THashSet<PsiFile>() : new THashSet<PsiFile>(xmlFiles);

	new WriteCommandAction(project)
	{
		@Override
		protected void run(@NotNull final Result result) throws Throwable
		{
			if(existingXml != null)
			{
				annotateExternally(listOwner, annotationFQName, existingXml, fromFile, value);
			}
			else
			{
				XmlFile newXml = createAnnotationsXml(root, packageName);
				if(newXml == null)
				{
					notifyAfterAnnotationChanging(listOwner, annotationFQName, false);
				}
				else
				{
					annotationFiles.add(newXml);
					cacheExternalAnnotations(packageName, fromFile, new SmartList<PsiFile>(annotationFiles));
					annotateExternally(listOwner, annotationFQName, newXml, fromFile, value);
				}
			}

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

				@Override
				public void redo()
				{
					dropCache();
					notifyChangedExternally();
				}
			});
		}
	}.execute();
}
 

开发者ID:consulo,
项目名称:consulo-java
代码行数:63,
代码来源:ExternalAnnotationsManagerImpl.java


版权声明:本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系管理员进行删除。
喜欢 (0)