本文整理汇总了Java中com.intellij.history.LocalHistoryAction类的典型用法代码示例。如果您正苦于以下问题:Java LocalHistoryAction类的具体用法?Java LocalHistoryAction怎么用?Java LocalHistoryAction使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
LocalHistoryAction类属于com.intellij.history包,在下文中一共展示了LocalHistoryAction类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: deleteElement
import com.intellij.history.LocalHistoryAction; //导入依赖的package包/类
@Override
public void deleteElement(@NotNull DataContext dataContext) {
List<PsiDirectory> allElements = Arrays.asList(getSelectedDirectories());
List<PsiElement> validElements = new ArrayList<PsiElement>();
for (PsiElement psiElement : allElements) {
if (psiElement != null && psiElement.isValid()) validElements.add(psiElement);
}
final PsiElement[] elements = PsiUtilCore.toPsiElementArray(validElements);
LocalHistoryAction a = LocalHistory.getInstance().startAction(IdeBundle.message("progress.deleting"));
try {
DeleteHandler.deletePsiElement(elements, myProject);
}
finally {
a.finish();
}
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:18,代码来源:PackageViewPane.java
示例2: performRefactoring
import com.intellij.history.LocalHistoryAction; //导入依赖的package包/类
protected void performRefactoring(@NotNull UsageInfo[] usages) {
final PsiMigration psiMigration = PsiMigrationManager.getInstance(myProject).startMigration();
LocalHistoryAction a = LocalHistory.getInstance().startAction(getCommandName());
try {
for (int i = 0; i < myMigrationMap.getEntryCount(); i++) {
MigrationMapEntry entry = myMigrationMap.getEntryAt(i);
if (entry.getType() == MigrationMapEntry.PACKAGE) {
MigrationUtil.doPackageMigration(myProject, psiMigration, entry.getNewName(), usages);
}
if (entry.getType() == MigrationMapEntry.CLASS) {
MigrationUtil.doClassMigration(myProject, psiMigration, entry.getNewName(), usages);
}
}
for(RefactoringHelper helper: Extensions.getExtensions(RefactoringHelper.EP_NAME)) {
Object preparedData = helper.prepareOperation(usages);
//noinspection unchecked
helper.performOperation(myProject, preparedData);
}
}
finally {
a.finish();
psiMigration.finish();
}
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:27,代码来源:MigrationProcessor.java
示例3: doRefactoring
import com.intellij.history.LocalHistoryAction; //导入依赖的package包/类
private void doRefactoring() throws IncorrectOperationException {
LocalHistoryAction a = LocalHistory.getInstance().startAction(getCommandName());
final PsiClass anInterface;
try {
anInterface = extractInterface(myTargetDir, myClass, myInterfaceName, mySelectedMembers, myJavaDocPolicy);
}
finally {
a.finish();
}
if (anInterface != null) {
final SmartPsiElementPointer<PsiClass> classPointer = SmartPointerManager.getInstance(myProject).createSmartPsiElementPointer(myClass);
final SmartPsiElementPointer<PsiClass> interfacePointer = SmartPointerManager.getInstance(myProject).createSmartPsiElementPointer(anInterface);
final Runnable turnRefsToSuperRunnable = new Runnable() {
@Override
public void run() {
ExtractClassUtil.askAndTurnRefsToSuper(myProject, classPointer, interfacePointer);
}
};
SwingUtilities.invokeLater(turnRefsToSuperRunnable);
}
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:23,代码来源:ExtractInterfaceHandler.java
示例4: performRefactoring
import com.intellij.history.LocalHistoryAction; //导入依赖的package包/类
protected void performRefactoring(@NotNull UsageInfo[] usages) {
RangeMarker position = null;
if (myEditor != null) {
final int offset = myEditor.getCaretModel().getOffset();
position = myEditor.getDocument().createRangeMarker(offset, offset + 1);
}
LocalHistoryAction a = LocalHistory.getInstance().startAction(getCommandName());
try {
doRefactoring(usages);
}
finally {
a.finish();
}
if (position != null) {
if (position.isValid()) {
myEditor.getCaretModel().moveToOffset(position.getStartOffset());
}
position.dispose();
}
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:23,代码来源:InlineMethodProcessor.java
示例5: undoOrRedo
import com.intellij.history.LocalHistoryAction; //导入依赖的package包/类
private void undoOrRedo(boolean isUndo) {
LocalHistoryAction action;
if (myProject != null && isGlobal()) {
String actionName = CommonBundle.message(isUndo ? "local.vcs.action.name.undo.command" : "local.vcs.action.name.redo.command", myCommandName);
action = LocalHistory.getInstance().startAction(actionName);
}
else {
action = LocalHistoryAction.NULL;
}
try {
doUndoOrRedo(isUndo);
}
finally {
action.finish();
}
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:18,代码来源:UndoableGroup.java
示例6: testSavingDocumentBeforeAndAfterAction
import com.intellij.history.LocalHistoryAction; //导入依赖的package包/类
public void testSavingDocumentBeforeAndAfterAction() throws Exception {
VirtualFile f = createFile("f.txt", "file1");
loadContent(f);
setContent(f, "file2");
setDocumentTextFor(f, "doc1");
LocalHistoryAction a = LocalHistory.getInstance().startAction("name");
setDocumentTextFor(f, "doc2");
a.finish();
List<Revision> rr = getRevisionsFor(f);
assertEquals(5, rr.size());
assertContent("doc2", rr.get(0).findEntry());
assertEquals("name", rr.get(1).getChangeSetName());
assertContent("doc1", rr.get(1).findEntry());
assertContent("file2", rr.get(2).findEntry());
assertContent("file1", rr.get(3).findEntry());
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:20,代码来源:ActionsTest.java
示例7: testActionInsideCommand
import com.intellij.history.LocalHistoryAction; //导入依赖的package包/类
/**
* <strong>This is very important test.</strong>
* Almost all actions are performed inside surrounding command.
* Therefore we have to correctly handle such situations.
*/
public void testActionInsideCommand() throws Exception {
final VirtualFile f = createFile("f.txt");
setContent(f, "file");
setDocumentTextFor(f, "doc1");
CommandProcessor.getInstance().executeCommand(myProject, new Runnable() {
@Override
public void run() {
LocalHistoryAction a = LocalHistory.getInstance().startAction("action");
setDocumentTextFor(f, "doc2");
a.finish();
}
}, "command", null);
List<Revision> rr = getRevisionsFor(f);
assertEquals(5, rr.size());
assertContent("doc2", rr.get(0).findEntry());
assertEquals("command", rr.get(1).getChangeSetName());
assertContent("doc1", rr.get(1).findEntry());
assertContent("file", rr.get(2).findEntry());
assertContent("", rr.get(3).findEntry());
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:28,代码来源:ActionsTest.java
示例8: deleteElement
import com.intellij.history.LocalHistoryAction; //导入依赖的package包/类
@Override
public void deleteElement(@NotNull DataContext dataContext) {
List<PsiElement> allElements = Arrays.asList(getElementsToDelete());
List<PsiElement> validElements = new ArrayList<PsiElement>();
for (PsiElement psiElement : allElements) {
if (psiElement != null && psiElement.isValid()) validElements.add(psiElement);
}
final PsiElement[] elements = PsiUtilCore.toPsiElementArray(validElements);
LocalHistoryAction a = LocalHistory.getInstance().startAction(IdeBundle.message("progress.deleting"));
try {
DeleteHandler.deletePsiElement(elements, myProject);
}
finally {
a.finish();
}
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:18,代码来源:ProjectViewImpl.java
示例9: deleteElement
import com.intellij.history.LocalHistoryAction; //导入依赖的package包/类
@Override
public void deleteElement(@NotNull DataContext dataContext) {
List<PsiElement> allElements = Arrays.asList(getSelectedPsiElements());
ArrayList<PsiElement> validElements = new ArrayList<PsiElement>();
for (PsiElement psiElement : allElements) {
if (psiElement != null && psiElement.isValid()) validElements.add(psiElement);
}
final PsiElement[] elements = PsiUtilCore.toPsiElementArray(validElements);
LocalHistoryAction a = LocalHistory.getInstance().startAction(IdeBundle.message("progress.deleting"));
try {
DeleteHandler.deletePsiElement(elements, myProject);
}
finally {
a.finish();
}
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:18,代码来源:ScopeTreeViewPanel.java
示例10: doRefactoring
import com.intellij.history.LocalHistoryAction; //导入依赖的package包/类
private void doRefactoring() throws IncorrectOperationException {
LocalHistoryAction a = LocalHistory.getInstance().startAction(getCommandName());
final PsiClass anInterface;
try {
anInterface = extractInterface(myTargetDir, myClass, myInterfaceName, mySelectedMembers, myJavaDocPolicy);
}
finally {
a.finish();
}
if (anInterface != null) {
final SmartPsiElementPointer<PsiClass> classPointer =
SmartPointerManager.getInstance(myProject).createSmartPsiElementPointer(myClass);
final SmartPsiElementPointer<PsiClass> interfacePointer =
SmartPointerManager.getInstance(myProject).createSmartPsiElementPointer(anInterface);
final Runnable turnRefsToSuperRunnable = new Runnable() {
@Override
public void run() {
ExtractClassUtil.askAndTurnRefsToSuper(myProject, classPointer, interfacePointer);
}
};
SwingUtilities.invokeLater(turnRefsToSuperRunnable);
}
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:26,代码来源:GrExtractInterfaceHandler.java
示例11: beforeMerge
import com.intellij.history.LocalHistoryAction; //导入依赖的package包/类
@NotNull
public MergeState beforeMerge() {
//record the starting revision number
GitRevisionNumber start;
try {
start = GitRevisionNumber.resolve(project, root, "HEAD");
} catch (Exception e) {
//we failed to get a revision number, that shouldn't stop us from updating the branch
start = null;
}
final String beforeLabel = getBeforeLocalHistoryLabel();
Label before = LocalHistory.getInstance().putSystemLabel(project, beforeLabel);
LocalHistoryAction myLocalHistoryAction = LocalHistory.getInstance().startAction(beforeLabel);
//keep track of all updated files
UpdatedFiles updatedFiles = UpdatedFiles.create();
return new MergeState(project, root, repoName, localBranchName, remoteBranchName,
start, before, myLocalHistoryAction, updatedFiles);
}
开发者ID:JChrist,项目名称:gitextender,代码行数:21,代码来源:BeforeMergeHandler.java
示例12: performRefactoring
import com.intellij.history.LocalHistoryAction; //导入依赖的package包/类
protected void performRefactoring(UsageInfo[] usages) {
final PsiMigration psiMigration = PsiMigrationManager.getInstance(myProject).startMigration();
LocalHistoryAction a = LocalHistory.getInstance().startAction(getCommandName());
try {
for (int i = 0; i < myMigrationMap.getEntryCount(); i++) {
MigrationMapEntry entry = myMigrationMap.getEntryAt(i);
if (entry.getType() == MigrationMapEntry.PACKAGE) {
MigrationUtil.doPackageMigration(myProject, psiMigration, entry.getNewName(), usages);
}
if (entry.getType() == MigrationMapEntry.CLASS) {
MigrationUtil.doClassMigration(myProject, psiMigration, entry.getNewName(), usages);
}
}
for(RefactoringHelper helper: Extensions.getExtensions(RefactoringHelper.EP_NAME)) {
Object preparedData = helper.prepareOperation(usages);
//noinspection unchecked
helper.performOperation(myProject, preparedData);
}
}
finally {
a.finish();
psiMigration.finish();
}
}
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:27,代码来源:MigrationProcessor.java
示例13: testSavingDocumentBeforeAndAfterAction
import com.intellij.history.LocalHistoryAction; //导入依赖的package包/类
public void testSavingDocumentBeforeAndAfterAction() throws Exception {
VirtualFile f = createFile("f.txt", "file1");
setContent(f, "file2");
setDocumentTextFor(f, "doc1");
LocalHistoryAction a = LocalHistory.getInstance().startAction("name");
setDocumentTextFor(f, "doc2");
a.finish();
List<Revision> rr = getRevisionsFor(f);
assertEquals(5, rr.size());
assertContent("doc2", rr.get(0).findEntry());
assertEquals("name", rr.get(1).getChangeSetName());
assertContent("doc1", rr.get(1).findEntry());
assertContent("file2", rr.get(2).findEntry());
assertContent("file1", rr.get(3).findEntry());
}
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:19,代码来源:ActionsTest.java
示例14: testActionInsideCommand
import com.intellij.history.LocalHistoryAction; //导入依赖的package包/类
public void testActionInsideCommand() throws Exception {
// This is very important test. Mostly all actions are performed
// inside surrounding command. Therefore we have to correctly
// handle such situation.
final VirtualFile f = createFile("f.txt");
setContent(f, "file");
setDocumentTextFor(f, "doc1");
CommandProcessor.getInstance().executeCommand(myProject, new Runnable() {
@Override
public void run() {
LocalHistoryAction a = LocalHistory.getInstance().startAction("action");
setDocumentTextFor(f, "doc2");
a.finish();
}
}, "command", null);
List<Revision> rr = getRevisionsFor(f);
assertEquals(5, rr.size());
assertContent("doc2", rr.get(0).findEntry());
assertEquals("command", rr.get(1).getChangeSetName());
assertContent("doc1", rr.get(1).findEntry());
assertContent("file", rr.get(2).findEntry());
assertContent("", rr.get(3).findEntry());
}
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:26,代码来源:ActionsTest.java
示例15: executeCommand
import com.intellij.history.LocalHistoryAction; //导入依赖的package包/类
@Nullable
private Exception executeCommand(String commandName, ThrowableRunnable<Exception> invokeCreate) {
final Exception[] exception = new Exception[1];
CommandProcessor.getInstance().executeCommand(myProject, () -> {
LocalHistoryAction action = LocalHistory.getInstance().startAction(commandName);
try {
invokeCreate.run();
}
catch (Exception ex) {
exception[0] = ex;
}
finally {
action.finish();
}
}, commandName, null, UndoConfirmationPolicy.REQUEST_CONFIRMATION);
return exception[0];
}
开发者ID:consulo,项目名称:consulo,代码行数:18,代码来源:ElementCreator.java
示例16: refreshFile
import com.intellij.history.LocalHistoryAction; //导入依赖的package包/类
private void refreshFile(VcsFileRevision revision) {
Runnable refresh = null;
final VirtualFile vf = getVirtualFile();
if (vf == null) {
final LocalHistoryAction action = startLocalHistoryAction(revision);
final VirtualFile vp = myFilePath.getVirtualFileParent();
if (vp != null) {
refresh = () -> vp.refresh(false, true, action::finish);
}
}
else {
refresh = () -> vf.refresh(false, false);
}
if (refresh != null) {
ProgressManager.getInstance().runProcessWithProgressSynchronously(refresh, "Refreshing Files...", false, myVcs.getProject());
}
}
开发者ID:consulo,项目名称:consulo,代码行数:18,代码来源:FileHistoryPanelImpl.java
示例17: deleteElement
import com.intellij.history.LocalHistoryAction; //导入依赖的package包/类
@Override
public void deleteElement(@Nonnull DataContext dataContext) {
List<PsiElement> allElements = Arrays.asList(getElementsToDelete());
List<PsiElement> validElements = new ArrayList<>();
for (PsiElement psiElement : allElements) {
if (psiElement != null && psiElement.isValid()) validElements.add(psiElement);
}
final PsiElement[] elements = PsiUtilCore.toPsiElementArray(validElements);
LocalHistoryAction a = LocalHistory.getInstance().startAction(IdeBundle.message("progress.deleting"));
try {
DeleteHandler.deletePsiElement(elements, myProject);
}
finally {
a.finish();
}
}
开发者ID:consulo,项目名称:consulo,代码行数:18,代码来源:FavoritesTreeViewPanel.java
示例18: deleteElement
import com.intellij.history.LocalHistoryAction; //导入依赖的package包/类
@Override
public void deleteElement(@Nonnull DataContext dataContext) {
List<PsiDirectory> allElements = Arrays.asList(getSelectedDirectories());
List<PsiElement> validElements = new ArrayList<PsiElement>();
for (PsiElement psiElement : allElements) {
if (psiElement != null && psiElement.isValid()) validElements.add(psiElement);
}
final PsiElement[] elements = PsiUtilCore.toPsiElementArray(validElements);
LocalHistoryAction a = LocalHistory.getInstance().startAction(IdeBundle.message("progress.deleting"));
try {
DeleteHandler.deletePsiElement(elements, myProject);
}
finally {
a.finish();
}
}
开发者ID:consulo,项目名称:consulo,代码行数:18,代码来源:PackageViewPane.java
示例19: deleteElement
import com.intellij.history.LocalHistoryAction; //导入依赖的package包/类
@Override
public void deleteElement(@Nonnull DataContext dataContext) {
List<PsiElement> allElements = Arrays.asList(getSelectedPsiElements());
ArrayList<PsiElement> validElements = new ArrayList<PsiElement>();
for (PsiElement psiElement : allElements) {
if (psiElement != null && psiElement.isValid()) validElements.add(psiElement);
}
final PsiElement[] elements = PsiUtilBase.toPsiElementArray(validElements);
LocalHistoryAction a = LocalHistory.getInstance().startAction(IdeBundle.message("progress.deleting"));
try {
DeleteHandler.deletePsiElement(elements, myProject);
}
finally {
a.finish();
}
}
开发者ID:consulo,项目名称:consulo,代码行数:18,代码来源:ScopeTreeViewPanel.java
示例20: applyRunnable
import com.intellij.history.LocalHistoryAction; //导入依赖的package包/类
private static Runnable applyRunnable(final Project project, final Computable<UsageInfo[]> computable) {
return new Runnable() {
@Override
public void run() {
final LocalHistoryAction action = LocalHistory.getInstance().startAction(INFER_NULLITY_ANNOTATIONS);
try {
new WriteCommandAction(project, INFER_NULLITY_ANNOTATIONS) {
@Override
protected void run(@NotNull Result result) throws Throwable {
final UsageInfo[] infos = computable.compute();
if (infos.length > 0) {
final Set<PsiElement> elements = new LinkedHashSet<PsiElement>();
for (UsageInfo info : infos) {
final PsiElement element = info.getElement();
if (element != null) {
ContainerUtil.addIfNotNull(elements, element.getContainingFile());
}
}
if (!FileModificationService.getInstance().preparePsiElementsForWrite(elements)) return;
final SequentialModalProgressTask progressTask = new SequentialModalProgressTask(project, INFER_NULLITY_ANNOTATIONS, false);
progressTask.setMinIterationTime(200);
progressTask.setTask(new AnnotateTask(project, progressTask, infos));
ProgressManager.getInstance().run(progressTask);
} else {
NullityInferrer.nothingFoundMessage(project);
}
}
}.execute();
}
finally {
action.finish();
}
}
};
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:38,代码来源:InferNullityAnnotationsAction.java
注:本文中的com.intellij.history.LocalHistoryAction类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论