当前位置: 首页>>代码示例>>Java>>正文


Java UndoConfirmationPolicy类代码示例

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


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

示例1: insertToEditor

import com.intellij.openapi.command.UndoConfirmationPolicy; //导入依赖的package包/类
public void insertToEditor(Project project, SearchResultElement element) {
    CommandProcessor.getInstance().executeCommand(project, () -> getApplication().runWriteAction(() -> {
        Editor editor = FileEditorManager.getInstance(project).getSelectedTextEditor();
        if (editor != null) {
            int offset = editor.getCaretModel().getOffset();
            Document document = editor.getDocument();
            String key = isXmlFile ?
                    "@" + element.getTag() + "/" + element.getName()
                    : "R." + element.getTag() + "." + element.getName();
            if (key != null) {
                document.insertString(offset, key);
                editor.getCaretModel().moveToOffset(offset + key.length());
            }
        }
    }), "InsertResultToEditor", "", UndoConfirmationPolicy.DO_NOT_REQUEST_CONFIRMATION);
}
 
开发者ID:hoai265,项目名称:SearchResourcePlugin,代码行数:17,代码来源:SearchResourcesAction.java

示例2: performAnswerPlaceholderAction

import com.intellij.openapi.command.UndoConfirmationPolicy; //导入依赖的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

示例3: insertToEditor

import com.intellij.openapi.command.UndoConfirmationPolicy; //导入依赖的package包/类
private void insertToEditor(final Project project, final StringElement stringElement) {
    CommandProcessor.getInstance().executeCommand(project, new Runnable() {
        @Override
        public void run() {
            getApplication().runWriteAction(new Runnable() {
                @Override
                public void run() {
                    Editor editor = FileEditorManager.getInstance(project).getSelectedTextEditor();
                    if (editor != null) {
                        int offset = editor.getCaretModel().getOffset();
                        Document document = editor.getDocument();
                        String key = stringElement.getName();
                        if (key != null) {
                            document.insertString(offset, key);
                            editor.getCaretModel().moveToOffset(offset + key.length());
                        }
                    }
                }
            });
        }
    }, "WriteStringKeyCommand", "", UndoConfirmationPolicy.DO_NOT_REQUEST_CONFIRMATION);
}
 
开发者ID:konifar,项目名称:android-strings-search-plugin,代码行数:23,代码来源:SearchStringsAction.java

示例4: actionPerformed

import com.intellij.openapi.command.UndoConfirmationPolicy; //导入依赖的package包/类
public final void actionPerformed(final Editor editor, @NotNull final DataContext dataContext) {
  if (editor == null) return;

  final EditorActionHandler handler = getHandler();
  Runnable command = new Runnable() {
    @Override
    public void run() {
      handler.execute(editor, null, getProjectAwareDataContext(editor, dataContext));
    }
  };

  if (!handler.executeInCommand(editor, dataContext)) {
    command.run();
    return;
  }

  String commandName = getTemplatePresentation().getText();
  if (commandName == null) commandName = "";
  CommandProcessor.getInstance().executeCommand(editor.getProject(),
                                                command,
                                                commandName,
                                                handler.getCommandGroupId(editor),
                                                UndoConfirmationPolicy.DEFAULT,
                                                editor.getDocument());
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:26,代码来源:EditorAction.java

示例5: UndoableGroup

import com.intellij.openapi.command.UndoConfirmationPolicy; //导入依赖的package包/类
public UndoableGroup(String commandName,
                     boolean isGlobal,
                     UndoManagerImpl manager,
                     EditorAndState stateBefore,
                     EditorAndState stateAfter,
                     List<UndoableAction> actions,
                     UndoConfirmationPolicy confirmationPolicy,
                     boolean transparent,
                     boolean valid) {
  myCommandName = commandName;
  myGlobal = isGlobal;
  myCommandTimestamp = manager.nextCommandTimestamp();
  myActions = actions;
  myProject = manager.getProject();
  myStateBefore = stateBefore;
  myStateAfter = stateAfter;
  myConfirmationPolicy = confirmationPolicy;
  myTransparent = transparent;
  myValid = valid;
  composeStartFinishGroup(manager.getUndoStacksHolder());
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:22,代码来源:UndoableGroup.java

示例6: setText

import com.intellij.openapi.command.UndoConfirmationPolicy; //导入依赖的package包/类
public void setText(@Nullable final String text) {
  ApplicationManager.getApplication().runWriteAction(new Runnable() {
    @Override
    public void run() {
      CommandProcessor.getInstance().executeCommand(getProject(), new Runnable() {
        @Override
        public void run() {
          myDocument.replaceString(0, myDocument.getTextLength(), text == null ? "" : text);
          if (myEditor != null) {
            final CaretModel caretModel = myEditor.getCaretModel();
            if (caretModel.getOffset() >= myDocument.getTextLength()) {
              caretModel.moveToOffset(myDocument.getTextLength());
            }
          }
        }
      }, null, null, UndoConfirmationPolicy.DEFAULT, getDocument());
    }
  });
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:20,代码来源:EditorTextField.java

示例7: startCommand

import com.intellij.openapi.command.UndoConfirmationPolicy; //导入依赖的package包/类
@Override
@Nullable
public Object startCommand(final Project project,
                           @Nls final String name,
                           final Object groupId,
                           final UndoConfirmationPolicy undoConfirmationPolicy) {
  ApplicationManager.getApplication().assertIsDispatchThread();
  if (project != null && project.isDisposed()) return null;

  if (CommandLog.LOG.isDebugEnabled()) {
    CommandLog.LOG.debug("startCommand: name = " + name + ", groupId = " + groupId);
  }

  if (myCurrentCommand != null) {
    return null;
  }

  Document document = groupId instanceof Ref && ((Ref)groupId).get() instanceof Document ? (Document)((Ref)groupId).get() : null;
  myCurrentCommand = new CommandDescriptor(EmptyRunnable.INSTANCE, project, name, groupId, undoConfirmationPolicy, document);
  fireCommandStarted();
  return myCurrentCommand;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:23,代码来源:CoreCommandProcessor.java

示例8: testXHTMLRangeMarkers2

import com.intellij.openapi.command.UndoConfirmationPolicy; //导入依赖的package包/类
public void testXHTMLRangeMarkers2() throws Exception {
  XmlTag tag = createTag("file.xhtml", "<a>xyz</a>");
  PsiFile psiFile = tag.getContainingFile();
  Document document = PsiDocumentManager.getInstance(psiFile.getProject()).getDocument(psiFile);
  RangeMarker rangeMarker = document.createRangeMarker(5, 5);
  final XmlText text = (XmlText) tag.getValue().getChildren()[0];

  ApplicationManager.getApplication().runWriteAction(new Runnable() {
    @Override
    public void run() {
      CommandProcessor.getInstance().executeCommand(getProject(), new Runnable() {
        @Override
        public void run() {
          try{
            text.removeText(2, 3);
          }
          catch(IncorrectOperationException ioe){}
        }
      }, "", null, UndoConfirmationPolicy.DO_NOT_REQUEST_CONFIRMATION);
    }
  });

  assertEquals(5, rangeMarker.getStartOffset());
  assertEquals(5, rangeMarker.getEndOffset());
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:26,代码来源:XmlTagTest.java

示例9: test2

import com.intellij.openapi.command.UndoConfirmationPolicy; //导入依赖的package包/类
public void test2() throws Exception {
  XmlFile file = (XmlFile)createFile("file.xml", "<a>x y</a>");
  XmlTag tag = file.getDocument().getRootTag();
  final XmlText xmlText = tag.getValue().getTextElements()[0];

  ApplicationManager.getApplication().runWriteAction(new Runnable() {
    @Override
    public void run() {
      CommandProcessor.getInstance().executeCommand(getProject(), new Runnable() {
        @Override
        public void run() {
          try {
            xmlText.insertText("z", 1);
          }
          catch (IncorrectOperationException e) {
            throw new RuntimeException(e);
          }
        }
      }, "", null, UndoConfirmationPolicy.DO_NOT_REQUEST_CONFIRMATION);
    }
  });
  assertEquals("<a>xz y</a>", tag.getText());
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:24,代码来源:XmlTagTest.java

示例10: doFix

import com.intellij.openapi.command.UndoConfirmationPolicy; //导入依赖的package包/类
@Override
protected void doFix(Project project, ProblemDescriptor descriptor) {
  final PsiElement element = descriptor.getPsiElement();
  if (!(element instanceof XmlFile)) {
    return;
  }
  final XmlFile xmlFile = (XmlFile)element;
  new WriteCommandAction.Simple(project, InspectionGadgetsBundle.message("package.dot.html.delete.command"), xmlFile) {
    @Override
    protected void run() throws Throwable {
      element.delete();
    }

    @Override
    protected UndoConfirmationPolicy getUndoConfirmationPolicy() {
      return UndoConfirmationPolicy.REQUEST_CONFIRMATION;
    }
  }.execute();
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:20,代码来源:PackageDotHtmlMayBePackageInfoInspection.java

示例11: actionPerformed

import com.intellij.openapi.command.UndoConfirmationPolicy; //导入依赖的package包/类
@Override
public void actionPerformed(AnActionEvent e) {
  final Editor editor = CommonDataKeys.EDITOR.getData(e.getDataContext());
  PsiFile file = CommonDataKeys.PSI_FILE.getData(e.getDataContext());
  if (editor == null || file == null) return;
  final Project project = file.getProject();
  CommandProcessorEx commandProcessor = (CommandProcessorEx)CommandProcessorEx.getInstance();
  Object commandToken = commandProcessor.startCommand(project, e.getPresentation().getText(), e.getPresentation().getText(), UndoConfirmationPolicy.DEFAULT);
  AccessToken token = ApplicationManager.getApplication().acquireWriteActionLock(getClass());
  try {
    final SelectionModel selectionModel = editor.getSelectionModel();
    int[] starts = selectionModel.getBlockSelectionStarts();
    int[] ends = selectionModel.getBlockSelectionEnds();

    int startOffset = starts.length == 0? 0 : starts[0];
    int endOffset = ends.length == 0? editor.getDocument().getTextLength() : ends[ends.length - 1];

    perform(project, editor.getDocument(), startOffset, endOffset);
  }
  finally {
    token.finish();
    commandProcessor.finishCommand(project, commandToken, null);
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:25,代码来源:ToggleHighlightingMarkupAction.java

示例12: actionPerformed

import com.intellij.openapi.command.UndoConfirmationPolicy; //导入依赖的package包/类
@Override
public void actionPerformed(AnActionEvent e) {
  final Editor editor = CommonDataKeys.EDITOR.getData(e.getDataContext());
  PsiFile file = CommonDataKeys.PSI_FILE.getData(e.getDataContext());
  if (editor == null || file == null) return;
  final Project project = file.getProject();
  CommandProcessorEx commandProcessor = (CommandProcessorEx)CommandProcessorEx.getInstance();
  Object commandToken = commandProcessor.startCommand(project, e.getPresentation().getText(), e.getPresentation().getText(), UndoConfirmationPolicy.DEFAULT);
  AccessToken token = ApplicationManager.getApplication().acquireWriteActionLock(getClass());
  try {
    shuffleIds(file, editor);
  }
  finally {
    token.finish();
    commandProcessor.finishCommand(project, commandToken, null);
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:18,代码来源:ShuffleNamesAction.java

示例13: replaceSelection

import com.intellij.openapi.command.UndoConfirmationPolicy; //导入依赖的package包/类
public void replaceSelection(@Nonnull final String clipboardText) {
  ApplicationManager.getApplication().runWriteAction(new Runnable() {
    @Override
    public void run() {
      CommandProcessor.getInstance().executeCommand(getProject(), new Runnable() {
        @Override
        public void run() {
          final SelectionModel model = Assertions.assertNotNull(getEditor()).getSelectionModel();
          final int start = model.getSelectionStart();
          final int end = model.getSelectionEnd();
          getDocument().replaceString(start, end, "");
          getDocument().insertString(start, clipboardText);
        }
      },null, null, UndoConfirmationPolicy.DEFAULT, getDocument());
    }
  });
}
 
开发者ID:raydac,项目名称:netbeans-mmd-plugin,代码行数:18,代码来源:PlainTextEditor.java

示例14: updateRawHtmlText

import com.intellij.openapi.command.UndoConfirmationPolicy; //导入依赖的package包/类
protected void updateRawHtmlText(final String htmlTxt) {
    final DocumentEx myDocument = myTextViewer.getDocument();

    if (project.isDisposed()) return;

    ApplicationManager.getApplication().runWriteAction(new Runnable() {
        @Override
        public void run() {
            if (project.isDisposed()) return;

            CommandProcessor.getInstance().executeCommand(project, new Runnable() {
                @Override
                public void run() {
                    if (project.isDisposed()) return;

                    myDocument.replaceString(0, myDocument.getTextLength(), htmlTxt);
                    final CaretModel caretModel = myTextViewer.getCaretModel();
                    if (caretModel.getOffset() >= myDocument.getTextLength()) {
                        caretModel.moveToOffset(myDocument.getTextLength());
                    }
                }
            }, null, null, UndoConfirmationPolicy.DEFAULT, myDocument);
        }
    });
}
 
开发者ID:vsch,项目名称:idea-multimarkdown,代码行数:26,代码来源:MultiMarkdownPreviewEditor.java

示例15: actionPerformed

import com.intellij.openapi.command.UndoConfirmationPolicy; //导入依赖的package包/类
public final void actionPerformed(final Editor editor, @NotNull final DataContext dataContext) {
  if (editor == null) return;

  final EditorActionHandler handler = getHandler();
  Runnable command = new Runnable() {
    @Override
    public void run() {
      handler.execute(editor, getProjectAwareDataContext(editor, dataContext));
    }
  };

  if (!handler.executeInCommand(editor, dataContext)) {
    command.run();
    return;
  }

  String commandName = getTemplatePresentation().getText();
  if (commandName == null) commandName = "";
  CommandProcessor.getInstance().executeCommand(editor.getProject(),
                                                command,
                                                commandName,
                                                handler.getCommandGroupId(editor),
                                                UndoConfirmationPolicy.DEFAULT,
                                                editor.getDocument());
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:26,代码来源:EditorAction.java


注:本文中的com.intellij.openapi.command.UndoConfirmationPolicy类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。