當前位置: 首頁>>代碼示例>>Java>>正文


Java UndoConstants類代碼示例

本文整理匯總了Java中com.intellij.openapi.command.undo.UndoConstants的典型用法代碼示例。如果您正苦於以下問題:Java UndoConstants類的具體用法?Java UndoConstants怎麽用?Java UndoConstants使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


UndoConstants類屬於com.intellij.openapi.command.undo包,在下文中一共展示了UndoConstants類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: reformatTemplateText

import com.intellij.openapi.command.undo.UndoConstants; //導入依賴的package包/類
private static String reformatTemplateText(@NotNull final PsiFile file, @NotNull String templateText) {
  final PsiFile copy = PsiFileFactory.getInstance(file.getProject()).createFileFromText(file.getName(), file.getFileType(), templateText);
  VirtualFile vFile = copy.getVirtualFile();
  if (vFile != null) {
    vFile.putUserData(UndoConstants.DONT_RECORD_UNDO, Boolean.TRUE);
  }
  ApplicationManager.getApplication().runWriteAction(new Runnable() {
    @Override
    public void run() {
      CommandProcessor.getInstance().runUndoTransparentAction(new Runnable() {
        @Override
        public void run() {
          CodeStyleManager.getInstance(file.getProject()).reformat(copy);
        }
      });
    }
  });
  return copy.getText();
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:20,代碼來源:EmmetPreviewUtil.java

示例2: parseXmlFileInTemplate

import com.intellij.openapi.command.undo.UndoConstants; //導入依賴的package包/類
@NotNull
private static XmlFile parseXmlFileInTemplate(@NotNull TemplateImpl template, @NotNull CustomTemplateCallback callback,
                                              @NotNull Map<String, String> attributes) {
  XmlTag dummyRootTag = null;
  String templateString = template.getString();
  final PsiFileFactory psiFileFactory = PsiFileFactory.getInstance(callback.getProject());
  if (!containsAttrsVar(template)) {
    XmlFile dummyFile = (XmlFile)psiFileFactory.createFileFromText("dummy.html", HTMLLanguage.INSTANCE, templateString, false, true);
    dummyRootTag = dummyFile.getRootTag();
    if (dummyRootTag != null) {
      addMissingAttributes(dummyRootTag, attributes);
    }
  }

  templateString = dummyRootTag != null ? dummyRootTag.getContainingFile().getText() : templateString;
  XmlFile xmlFile =
    (XmlFile)psiFileFactory.createFileFromText("dummy.xml", StdFileTypes.XML, templateString, LocalTimeCounter.currentTime(), true);
  VirtualFile vFile = xmlFile.getVirtualFile();
  if (vFile != null) {
    vFile.putUserData(UndoConstants.DONT_RECORD_UNDO, Boolean.TRUE);
  }
  return xmlFile;
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:24,代碼來源:TemplateToken.java

示例3: parseXmlFileInTemplate

import com.intellij.openapi.command.undo.UndoConstants; //導入依賴的package包/類
@NotNull
private static XmlFile parseXmlFileInTemplate(TemplateImpl template,
                                              CustomTemplateCallback callback,
                                              List<Pair<String, String>> attributes) {
  XmlTag dummyRootTag = null;
  String templateString = template.getString();
  final PsiFileFactory psiFileFactory = PsiFileFactory.getInstance(callback.getProject());
  if (!containsAttrsVar(template)) {
    XmlFile dummyFile = (XmlFile)psiFileFactory.createFileFromText("dummy.xml", StdFileTypes.XML, templateString);
    dummyRootTag = dummyFile.getRootTag();
    if (dummyRootTag != null) {
      addMissingAttributes(dummyRootTag, attributes);
    }
  }

  templateString = dummyRootTag != null ? dummyRootTag.getContainingFile().getText() : templateString;
  XmlFile xmlFile = (XmlFile)psiFileFactory.createFileFromText("dummy.xml", StdFileTypes.XML, templateString, LocalTimeCounter.currentTime(), true);
  VirtualFile vFile = xmlFile.getVirtualFile();
  if (vFile != null) {
    vFile.putUserData(UndoConstants.DONT_RECORD_UNDO, Boolean.TRUE);
  }
  return xmlFile;
}
 
開發者ID:lshain-android-source,項目名稱:tools-idea,代碼行數:24,代碼來源:TemplateToken.java

示例4: LineStatusTrackerBase

import com.intellij.openapi.command.undo.UndoConstants; //導入依賴的package包/類
public LineStatusTrackerBase(@javax.annotation.Nullable final Project project,
                             @Nonnull final Document document) {
  myDocument = document;
  myProject = project;

  myApplication = ApplicationManager.getApplication();

  myDocumentListener = new MyDocumentListener();
  myDocument.addDocumentListener(myDocumentListener);

  myApplicationListener = new MyApplicationListener();
  myApplication.addApplicationListener(myApplicationListener);

  myVcsDocument = new DocumentImpl("", true);
  myVcsDocument.putUserData(UndoConstants.DONT_RECORD_UNDO, Boolean.TRUE);
}
 
開發者ID:consulo,項目名稱:consulo,代碼行數:17,代碼來源:LineStatusTrackerBase.java

示例5: clone

import com.intellij.openapi.command.undo.UndoConstants; //導入依賴的package包/類
@Override
public FileViewProvider clone() {
  final VirtualFile origFile = getVirtualFile();
  LightVirtualFile copy = new LightVirtualFile(origFile.getName(), myFileType, getContents(), origFile.getCharset(), getModificationStamp());
  copy.setOriginalFile(origFile);
  copy.putUserData(UndoConstants.DONT_RECORD_UNDO, Boolean.TRUE);
  copy.setCharset(origFile.getCharset());
  return createCopy(copy);
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:10,代碼來源:SingleRootFileViewProvider.java

示例6: copyFile

import com.intellij.openapi.command.undo.UndoConstants; //導入依賴的package包/類
@NotNull
public static PsiFile copyFile(@NotNull PsiFile file, @NotNull StringBuilder fileContentWithoutKey) {
  final PsiFileFactory psiFileFactory = PsiFileFactory.getInstance(file.getProject());
  PsiFile copy = psiFileFactory.createFileFromText(file.getName(), file.getFileType(), fileContentWithoutKey);
  VirtualFile vFile = copy.getVirtualFile();
  if (vFile != null) {
    vFile.putUserData(UndoConstants.DONT_RECORD_UNDO, Boolean.TRUE);
  }
  return copy;
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:11,代碼來源:PostfixLiveTemplate.java

示例7: updateDocumentFromPropertyValue

import com.intellij.openapi.command.undo.UndoConstants; //導入依賴的package包/類
private void updateDocumentFromPropertyValue(final String value,
                                             final Document document,
                                             final PropertiesFile propertiesFile) {
  @NonNls String text = value;
  if (myBackSlashPressed.contains(propertiesFile)) {
    text += "\\";
  }
  document.putUserData(UndoConstants.DONT_RECORD_UNDO, Boolean.TRUE);
  document.replaceString(0, document.getTextLength(), text);
  document.putUserData(UndoConstants.DONT_RECORD_UNDO, Boolean.FALSE);
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:12,代碼來源:ResourceBundleEditor.java

示例8: clone

import com.intellij.openapi.command.undo.UndoConstants; //導入依賴的package包/類
@Override
public FileViewProvider clone() {
  final VirtualFile origFile = getVirtualFile();
  LightVirtualFile copy = new LightVirtualFile(origFile.getName(), origFile.getFileType(), getContents(), origFile.getCharset(), getModificationStamp());
  copy.setOriginalFile(origFile);
  copy.putUserData(UndoConstants.DONT_RECORD_UNDO, Boolean.TRUE);
  copy.setCharset(origFile.getCharset());
  return createCopy(copy);
}
 
開發者ID:lshain-android-source,項目名稱:tools-idea,代碼行數:10,代碼來源:SingleRootFileViewProvider.java

示例9: LineStatusTracker

import com.intellij.openapi.command.undo.UndoConstants; //導入依賴的package包/類
private LineStatusTracker(final Document document, final Document upToDateDocument, final Project project, final VirtualFile virtualFile) {
  myVirtualFile = virtualFile;
  myApplication = ApplicationManager.getApplication();
  myDocument = document;
  myUpToDateDocument = upToDateDocument;
  myUpToDateDocument.putUserData(UndoConstants.DONT_RECORD_UNDO, Boolean.TRUE);
  myProject = project;
  myBaseLoaded = BaseLoadState.LOADING;
  synchronized (myLock) {
    myRanges = new ArrayList<Range>();
  }
  myAnathemaThrown = false;
  myFileEditorManager = FileEditorManager.getInstance(myProject);
}
 
開發者ID:lshain-android-source,項目名稱:tools-idea,代碼行數:15,代碼來源:LineStatusTracker.java

示例10: setConsoleText

import com.intellij.openapi.command.undo.UndoConstants; //導入依賴的package包/類
protected void setConsoleText(final String command, final boolean storeUserText, final boolean regularMode) {
  if (regularMode && myMultiline && StringUtil.isEmptyOrSpaces(command)) return;
  final Editor editor = myConsole.getCurrentEditor();
  final Document document = editor.getDocument();
  new WriteCommandAction.Simple(myConsole.getProject()) {
    @Override
    public void run() {
      if (storeUserText) {
        myHelper.setContent(document.getText());
      }
      String text = StringUtil.notNullize(command);
      int offset;
      if (regularMode) {
        if (myMultiline) {
          offset = insertTextMultiline(text, editor, document);
        }
        else {
          document.setText(text);
          offset = document.getTextLength();
        }
      }
      else {
        offset = 0;
        try {
          document.putUserData(UndoConstants.DONT_RECORD_UNDO, Boolean.TRUE);
          document.setText(text);
        }
        finally {
          document.putUserData(UndoConstants.DONT_RECORD_UNDO, null);
        }
      }
      editor.getCaretModel().moveToOffset(offset);
      editor.getScrollingModel().scrollToCaret(ScrollType.RELATIVE);
    }
  }.execute();
}
 
開發者ID:lshain-android-source,項目名稱:tools-idea,代碼行數:37,代碼來源:ConsoleHistoryController.java

示例11: isUndoable

import com.intellij.openapi.command.undo.UndoConstants; //導入依賴的package包/類
private boolean isUndoable(Document document) {
  DocumentReference ref = DocumentReferenceManager.getInstance().create(document);
  VirtualFile file = ref.getFile();

  // Allow undo even from refresh if requested
  if (file != null && file.getUserData(UndoConstants.FORCE_RECORD_UNDO) == Boolean.TRUE) {
    return true;
  }
  return !UndoManagerImpl.isRefresh() || getUndoManager().isUndoOrRedoAvailable(ref);
}
 
開發者ID:consulo,項目名稱:consulo,代碼行數:11,代碼來源:DocumentUndoProvider.java

示例12: clone

import com.intellij.openapi.command.undo.UndoConstants; //導入依賴的package包/類
@SuppressWarnings("MethodDoesntCallSuperMethod")
@Override
public FileViewProvider clone() {
  VirtualFile origFile = getVirtualFile();
  LightVirtualFile copy = new LightVirtualFile(origFile.getName(), myFileType, getContents(), origFile.getCharset(), getModificationStamp());
  copy.setOriginalFile(origFile);
  copy.putUserData(UndoConstants.DONT_RECORD_UNDO, Boolean.TRUE);
  copy.setCharset(origFile.getCharset());

  return createCopy(copy);
}
 
開發者ID:consulo,項目名稱:consulo,代碼行數:12,代碼來源:AbstractFileViewProvider.java

示例13: copyFile

import com.intellij.openapi.command.undo.UndoConstants; //導入依賴的package包/類
@Nonnull
public static PsiFile copyFile(@Nonnull PsiFile file, @Nonnull StringBuilder fileContentWithoutKey) {
  final PsiFileFactory psiFileFactory = PsiFileFactory.getInstance(file.getProject());
  PsiFile copy = psiFileFactory.createFileFromText(file.getName(), file.getFileType(), fileContentWithoutKey);
  VirtualFile vFile = copy.getVirtualFile();
  if (vFile != null) {
    vFile.putUserData(UndoConstants.DONT_RECORD_UNDO, Boolean.TRUE);
  }
  return copy;
}
 
開發者ID:consulo,項目名稱:consulo,代碼行數:11,代碼來源:PostfixLiveTemplate.java

示例14: shouldRecordActions

import com.intellij.openapi.command.undo.UndoConstants; //導入依賴的package包/類
private boolean shouldRecordActions(final Document document) {
  if (document.getUserData(UndoConstants.DONT_RECORD_UNDO) == Boolean.TRUE) return false;

  final VirtualFile vFile = FileDocumentManager.getInstance().getFile(document);
  return vFile == null || vFile.getUserData(UndoConstants.DONT_RECORD_UNDO) != Boolean.TRUE;
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:7,代碼來源:DocumentUndoProvider.java

示例15: createOn

import com.intellij.openapi.command.undo.UndoConstants; //導入依賴的package包/類
public static LineStatusTracker createOn(@NotNull VirtualFile virtualFile, @NotNull final Document document, final Project project,
                                         @NotNull Mode mode) {
  final Document vcsDocument = new DocumentImpl("", true);
  vcsDocument.putUserData(UndoConstants.DONT_RECORD_UNDO, Boolean.TRUE);
  return new LineStatusTracker(document, vcsDocument, project, virtualFile, mode);
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:7,代碼來源:LineStatusTracker.java


注:本文中的com.intellij.openapi.command.undo.UndoConstants類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。