com.intellij.openapi.command.UndoConfirmationPolicy Java Examples

The following examples show how to use com.intellij.openapi.command.UndoConfirmationPolicy. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: DiffUtil.java    From consulo with Apache License 2.0 6 votes vote down vote up
@RequiredUIAccess
public static void executeWriteCommand(@Nullable Project project,
                                       @Nonnull Document document,
                                       @Nullable String commandName,
                                       @Nullable String commandGroupId,
                                       @Nonnull UndoConfirmationPolicy confirmationPolicy,
                                       boolean underBulkUpdate,
                                       @Nonnull Runnable task) {
  if (!makeWritable(project, document)) {
    VirtualFile file = FileDocumentManager.getInstance().getFile(document);
    LOG.warn("Document is read-only" + (file != null ? ": " + file.getPresentableName() : ""));
    return;
  }

  ApplicationManager.getApplication().runWriteAction(() -> {
    CommandProcessor.getInstance().executeCommand(project, () -> {
      if (underBulkUpdate) {
        DocumentUtil.executeInBulk(document, true, task);
      }
      else {
        task.run();
      }
    }, commandName, commandGroupId, confirmationPolicy, document);
  });
}
 
Example #2
Source File: ElementCreator.java    From consulo with Apache License 2.0 6 votes vote down vote up
@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];
}
 
Example #3
Source File: EditorAction.java    From consulo with Apache License 2.0 6 votes vote down vote up
public final void actionPerformed(final Editor editor, @Nonnull final DataContext dataContext) {
  if (editor == null) return;

  final EditorActionHandler handler = getHandler();
  Runnable command = () -> 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());
}
 
Example #4
Source File: SearchStringsAction.java    From android-strings-search-plugin with Apache License 2.0 6 votes vote down vote up
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);
}
 
Example #5
Source File: PlainTextEditor.java    From netbeans-mmd-plugin with Apache License 2.0 6 votes vote down vote up
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());
    }
  });
}
 
Example #6
Source File: DesktopEditorImpl.java    From consulo with Apache License 2.0 6 votes vote down vote up
private static void removeDraggedOutFragment(DesktopEditorImpl editor) {
  if (!FileDocumentManager.getInstance().requestWriting(editor.getDocument(), editor.getProject())) {
    return;
  }
  CommandProcessor.getInstance().executeCommand(editor.myProject, () -> ApplicationManager.getApplication().runWriteAction(() -> {
    Document doc = editor.getDocument();
    doc.startGuardedBlockChecking();
    try {
      doc.deleteString(editor.myDraggedRange.getStartOffset(), editor.myDraggedRange.getEndOffset());
    }
    catch (ReadOnlyFragmentModificationException e) {
      EditorActionManager.getInstance().getReadonlyFragmentModificationHandler(doc).handle(e);
    }
    finally {
      doc.stopGuardedBlockChecking();
    }
  }), EditorBundle.message("move.selection.command.name"), DND_COMMAND_KEY, UndoConfirmationPolicy.DEFAULT, editor.getDocument());
}
 
Example #7
Source File: UndoManagerImpl.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Override
public void undoableActionPerformed(@Nonnull UndoableAction action) {
  ApplicationManager.getApplication().assertIsWriteThread();
  if (myProject != null && myProject.isDisposed()) return;

  if (myCurrentOperationState != OperationState.NONE) return;

  if (myCommandLevel == 0) {
    LOG.assertTrue(action instanceof NonUndoableAction,
                   "Undoable actions allowed inside commands only (see com.intellij.openapi.command.CommandProcessor.executeCommand())");
    commandStarted(UndoConfirmationPolicy.DEFAULT, false);
    myCurrentMerger.addAction(action);
    commandFinished("", null);
    return;
  }

  if (isRefresh()) myOriginatorReference = null;

  myCurrentMerger.addAction(action);
}
 
Example #8
Source File: UndoableGroup.java    From consulo with Apache License 2.0 6 votes vote down vote up
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());
}
 
Example #9
Source File: DesktopEditorImpl.java    From consulo with Apache License 2.0 5 votes vote down vote up
private void runMouseReleasedCommand(@Nonnull final MouseEvent e) {
  myMultiSelectionInProgress = false;
  myDragOnGutterSelectionStartLine = -1;
  myScrollingTimer.stop();

  if (e.isConsumed()) {
    return;
  }

  EditorMouseEvent event = new EditorMouseEvent(DesktopEditorImpl.this, e, getMouseEventArea(e));
  for (EditorMouseListener listener : myMouseListeners) {
    listener.mouseReleased(event);
    if (isReleased || event.isConsumed()) {
      return;
    }
  }

  invokePopupIfNeeded(event);
  if (event.isConsumed()) {
    return;
  }

  if (myCommandProcessor != null) {
    Runnable runnable = () -> processMouseReleased(e);
    myCommandProcessor.executeCommand(myProject, runnable, "", DocCommandGroupId.noneGroupId(getDocument()), UndoConfirmationPolicy.DEFAULT, getDocument());
  }
  else {
    processMouseReleased(e);
  }
}
 
Example #10
Source File: DiffUtil.java    From consulo with Apache License 2.0 5 votes vote down vote up
@RequiredUIAccess
public static void executeWriteCommand(@Nonnull final Document document,
                                       @Nullable final Project project,
                                       @Nullable final String commandName,
                                       @Nonnull final Runnable task) {
  executeWriteCommand(project, document, commandName, null, UndoConfirmationPolicy.DEFAULT, false, task);
}
 
Example #11
Source File: DesktopEditorErrorPanel.java    From consulo with Apache License 2.0 5 votes vote down vote up
@RequiredUIAccess
public void mouseClicked(final MouseEvent e) {
  CommandProcessor.getInstance().executeCommand(myEditor.getProject(), new Runnable() {
    @Override
    @RequiredUIAccess
    public void run() {
      doMouseClicked(e);
    }
  }, EditorBundle.message("move.caret.command.name"), DocCommandGroupId.noneGroupId(myEditor.getDocument()), UndoConfirmationPolicy.DEFAULT, myEditor.getDocument());
}
 
Example #12
Source File: UndoManagerImpl.java    From consulo with Apache License 2.0 5 votes vote down vote up
private void onCommandStarted(final Project project, UndoConfirmationPolicy undoConfirmationPolicy, boolean recordOriginalReference) {
  if (myCommandLevel == 0) {
    for (UndoProvider undoProvider : myUndoProviders) {
      undoProvider.commandStarted(project);
    }
    myCurrentActionProject = project;
  }

  commandStarted(undoConfirmationPolicy, myProject == project && recordOriginalReference);

  LOG.assertTrue(myCommandLevel == 0 || !(myCurrentActionProject instanceof DummyProject));
}
 
Example #13
Source File: UndoManagerImpl.java    From consulo with Apache License 2.0 5 votes vote down vote up
private void commandStarted(UndoConfirmationPolicy undoConfirmationPolicy, boolean recordOriginalReference) {
  if (myCommandLevel == 0) {
    myCurrentMerger = new CommandMerger(this, CommandProcessor.getInstance().isUndoTransparentActionInProgress());

    if (recordOriginalReference && myProject != null) {
      Editor editor = null;
      final Application application = ApplicationManager.getApplication();
      if (application.isUnitTestMode() || application.isHeadlessEnvironment()) {
        editor = DataManager.getInstance().getDataContext().getData(CommonDataKeys.EDITOR);
      }
      else {
        Component component = WindowManagerEx.getInstanceEx().getFocusedComponent(myProject);
        if (component != null) {
          editor = DataManager.getInstance().getDataContext(component).getData(CommonDataKeys.EDITOR);
        }
      }

      if (editor != null) {
        Document document = editor.getDocument();
        VirtualFile file = FileDocumentManager.getInstance().getFile(document);
        if (file != null && file.isValid()) {
          myOriginatorReference = DocumentReferenceManager.getInstance().create(file);
        }
      }
    }
  }
  LOG.assertTrue(myCurrentMerger != null, String.valueOf(myCommandLevel));
  myCurrentMerger.setBeforeState(getCurrentState());
  myCurrentMerger.mergeUndoConfirmationPolicy(undoConfirmationPolicy);

  myCommandLevel++;

}
 
Example #14
Source File: CommandMerger.java    From consulo with Apache License 2.0 5 votes vote down vote up
void mergeUndoConfirmationPolicy(UndoConfirmationPolicy undoConfirmationPolicy) {
  if (myUndoConfirmationPolicy == UndoConfirmationPolicy.DEFAULT) {
    myUndoConfirmationPolicy = undoConfirmationPolicy;
  }
  else if (myUndoConfirmationPolicy == UndoConfirmationPolicy.DO_NOT_REQUEST_CONFIRMATION) {
    if (undoConfirmationPolicy == UndoConfirmationPolicy.REQUEST_CONFIRMATION) {
      myUndoConfirmationPolicy = UndoConfirmationPolicy.REQUEST_CONFIRMATION;
    }
  }
}
 
Example #15
Source File: CommandMerger.java    From consulo with Apache License 2.0 5 votes vote down vote up
private void reset() {
  myCurrentActions = new ArrayList<>();
  myAllAffectedDocuments = new THashSet<>();
  myAdditionalAffectedDocuments = new THashSet<>();
  myLastGroupId = null;
  myForcedGlobal = false;
  myTransparent = false;
  myCommandName = null;
  myValid = true;
  myStateAfter = null;
  myStateBefore = null;
  myUndoConfirmationPolicy = UndoConfirmationPolicy.DEFAULT;
}
 
Example #16
Source File: TestFeature.java    From PackageTemplates with Apache License 2.0 5 votes vote down vote up
private void runTest() {
        ArrayList<SimpleAction> simpleActions = new ArrayList<>();
        TestDeleteFileAction action = new TestDeleteFileAction(project, new File(virtualFile.getPath()));
        simpleActions.add(action);

        ActionRequest actionRequest = new ActionRequestBuilder()
                .setProject(project)
                .setActions(simpleActions)
                .setActionLabel("Test Feature Action")
                .setAccessPrivileges(AccessPrivileges.WRITE)
                .setUndoable(true)
                .setConfirmationPolicy(UndoConfirmationPolicy.REQUEST_CONFIRMATION)
                .setActionListener(new ActionRequest.ActionFinishListener() {
                    @Override
                    public void onFinish() {
                        Logger.log("onFinish");
                    }

                    @Override
                    public void onFail() {
                        Logger.log("onFail");
                    }
                })
                .build();

        ActionExecutor.runAsTransaction(actionRequest);

//        String commandId = "testId";
//        CommandProcessor.getInstance().executeCommand(project, () ->
//                        ApplicationManager.getApplication().runWriteAction(this::execute),
//                commandId, commandId);
    }
 
Example #17
Source File: EditorComponentImpl.java    From consulo with Apache License 2.0 5 votes vote down vote up
/** Inserts, removes or replaces the given text at the given offset */
private void editDocumentSafely(final int offset, final int length, @Nullable final String text) {
  final Project project = myEditor.getProject();
  final Document document = myEditor.getDocument();
  if (!FileDocumentManager.getInstance().requestWriting(document, project)) {
    return;
  }
  CommandProcessor.getInstance().executeCommand(project,
                                                () -> ApplicationManager.getApplication().runWriteAction(new DocumentRunnable(document, project) {
                                                  @Override
                                                  public void run() {
                                                    document.startGuardedBlockChecking();
                                                    try {
                                                      if (text == null) {
                                                        // remove
                                                        document.deleteString(offset, offset + length);
                                                      } else if (length == 0) {
                                                        // insert
                                                        document.insertString(offset, text);
                                                      } else {
                                                        document.replaceString(offset, offset + length, text);
                                                      }
                                                    }
                                                    catch (ReadOnlyFragmentModificationException e) {
                                                      EditorActionManager.getInstance().getReadonlyFragmentModificationHandler(document).handle(e);
                                                    }
                                                    finally {
                                                      document.stopGuardedBlockChecking();
                                                    }
                                                  }
                                                }), "", document, UndoConfirmationPolicy.DEFAULT, document);
}
 
Example #18
Source File: DefaultRawTypedHandler.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
public void execute(@Nonnull final Editor editor, final char charTyped, @Nonnull final DataContext dataContext) {
  CommandProcessorEx commandProcessorEx = (CommandProcessorEx)CommandProcessor.getInstance();
  Project project = dataContext.getData(CommonDataKeys.PROJECT);
  if (myCurrentCommandToken != null) {
    throw new IllegalStateException("Unexpected reentrancy of DefaultRawTypedHandler");
  }
  myCurrentCommandToken = commandProcessorEx.startCommand(project, "", editor.getDocument(), UndoConfirmationPolicy.DEFAULT);
  myInOuterCommand = myCurrentCommandToken == null;
  try {
    if (!EditorModificationUtil.requestWriting(editor)) {
      return;
    }
    ApplicationManager.getApplication().runWriteAction(new DocumentRunnable(editor.getDocument(), editor.getProject()) {
      @Override
      public void run() {
        Document doc = editor.getDocument();
        doc.startGuardedBlockChecking();
        try {
          myAction.getHandler().execute(editor, charTyped, dataContext);
        }
        catch (ReadOnlyFragmentModificationException e) {
          EditorActionManager.getInstance().getReadonlyFragmentModificationHandler(doc).handle(e);
        }
        finally {
          doc.stopGuardedBlockChecking();
        }
      }
    });
  }
  finally {
    if (!myInOuterCommand) {
      commandProcessorEx.finishCommand(myCurrentCommandToken, null);
      myCurrentCommandToken = null;
    }
    myInOuterCommand = false;
  }
}
 
Example #19
Source File: DefaultRawTypedHandler.java    From consulo with Apache License 2.0 5 votes vote down vote up
public void beginUndoablePostProcessing() {
  if (myInOuterCommand) {
    return;
  }
  if (myCurrentCommandToken == null) {
    throw new IllegalStateException("Not in a typed action at this time");
  }
  CommandProcessorEx commandProcessorEx = (CommandProcessorEx)CommandProcessor.getInstance();
  Project project = myCurrentCommandToken.getProject();
  commandProcessorEx.finishCommand(myCurrentCommandToken, null);
  myCurrentCommandToken = commandProcessorEx.startCommand(project, "", null, UndoConfirmationPolicy.DEFAULT);
}
 
Example #20
Source File: EditorTextField.java    From consulo with Apache License 2.0 5 votes vote down vote up
public void setText(@Nullable final String text) {
  ApplicationManager.getApplication().runWriteAction(() -> CommandProcessor.getInstance().executeCommand(getProject(), () -> {
    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()));
}
 
Example #21
Source File: MockCommandProcessor.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
public void executeCommand(Project project,
                           @Nonnull Runnable runnable,
                           String name,
                           Object groupId,
                           @Nonnull UndoConfirmationPolicy confirmationPolicy) {

}
 
Example #22
Source File: MockCommandProcessor.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
public void executeCommand(@Nullable Project project,
                           @Nonnull Runnable command,
                           @Nullable String name,
                           @Nullable Object groupId,
                           @Nonnull UndoConfirmationPolicy confirmationPolicy,
                           boolean shouldRecordCommandForActiveDocument) {
}
 
Example #23
Source File: BuildifierAutoFormatter.java    From buck with Apache License 2.0 5 votes vote down vote up
@Override
public void initComponent() {
  mMessageBusConnection = ApplicationManager.getApplication().getMessageBus().connect(this);
  mMessageBusConnection.subscribe(
      FileEditorManagerListener.FILE_EDITOR_MANAGER,
      new FileEditorManagerListener() {
        @Override
        public void selectionChanged(@NotNull FileEditorManagerEvent event) {
          Project project = event.getManager().getProject();
          if (!BuckProjectSettingsProvider.getInstance(project).isAutoFormatOnBlur()) {
            return;
          }
          FileEditor newFileEditor = event.getNewEditor();
          FileEditor oldFileEditor = event.getOldEditor();
          if (oldFileEditor == null || oldFileEditor.equals(newFileEditor)) {
            return; // still editing same file
          }
          VirtualFile virtualFile = oldFileEditor.getFile();
          Document document = FileDocumentManager.getInstance().getDocument(virtualFile);
          if (document == null) {
            return; // couldn't find document
          }
          PsiFile psiFile = PsiDocumentManager.getInstance(project).getPsiFile(document);
          if (!BuckFileType.INSTANCE.equals(psiFile.getFileType())) {
            return; // file type isn't a Buck file
          }
          Runnable runnable = () -> BuildifierUtil.doReformat(project, virtualFile);
          LOGGER.info("Autoformatting " + virtualFile.getPath());
          CommandProcessor.getInstance()
              .executeCommand(
                  project,
                  runnable,
                  null,
                  null,
                  UndoConfirmationPolicy.DO_NOT_REQUEST_CONFIRMATION,
                  document);
        }
      });
}
 
Example #24
Source File: BuildifierExternalFormatAction.java    From buck with Apache License 2.0 5 votes vote down vote up
@Nullable
private Runnable selectAction(@NotNull AnActionEvent anActionEvent) {
  Project project = anActionEvent.getProject();
  if (project == null || project.isDefault()) {
    return null;
  }
  BuckExecutableSettingsProvider executableSettings =
      BuckExecutableSettingsProvider.getInstance(project);
  String buildifierExecutable = executableSettings.resolveBuildifierExecutable();
  if (buildifierExecutable == null) {
    return null;
  }
  DataContext dataContext = anActionEvent.getDataContext();
  Editor editor = dataContext.getData(CommonDataKeys.EDITOR);
  if (editor == null) {
    return null;
  }
  Document document = editor.getDocument();
  PsiFile psiFile = dataContext.getData(CommonDataKeys.PSI_FILE);
  if (psiFile == null) {
    psiFile = PsiDocumentManager.getInstance(project).getPsiFile(document);
  }
  if (psiFile == null) {
    return null;
  }
  if (!BuckFileType.INSTANCE.equals(psiFile.getFileType())) {
    return null;
  }
  return () -> {
    Runnable runnable = () -> BuildifierUtil.doReformat(project, document);
    CommandProcessor.getInstance()
        .executeCommand(
            project,
            runnable,
            null,
            null,
            UndoConfirmationPolicy.DO_NOT_REQUEST_CONFIRMATION,
            document);
  };
}
 
Example #25
Source File: MergeModelBase.java    From consulo with Apache License 2.0 5 votes vote down vote up
public void executeMergeCommand(@javax.annotation.Nullable String commandName,
                                @javax.annotation.Nullable String commandGroupId,
                                @Nonnull UndoConfirmationPolicy confirmationPolicy,
                                boolean underBulkUpdate,
                                @javax.annotation.Nullable TIntArrayList affectedChanges,
                                @Nonnull Runnable task) {
  TIntArrayList allAffectedChanges = affectedChanges != null ? collectAffectedChanges(affectedChanges) : null;
  DiffUtil.executeWriteCommand(myProject, myDocument, commandName, commandGroupId, confirmationPolicy, underBulkUpdate, () -> {
    LOG.assertTrue(!myInsideCommand);

    // We should restore states after changes in document (by DocumentUndoProvider) to avoid corruption by our onBeforeDocumentChange()
    // Undo actions are performed in backward order, while redo actions are performed in forward order.
    // Thus we should register two UndoableActions.

    myInsideCommand = true;
    enterBulkChangeUpdateBlock();
    registerUndoRedo(true, allAffectedChanges);
    try {
      task.run();
    }
    finally {
      registerUndoRedo(false, allAffectedChanges);
      exitBulkChangeUpdateBlock();
      myInsideCommand = false;
    }
  });
}
 
Example #26
Source File: Action.java    From dummytext-plugin with Apache License 2.0 5 votes vote down vote up
/**
 * Insert or replace selection with random dummy text
 *
 * @param event ActionSystem event
 */
public void actionPerformed(final AnActionEvent event) {
    Project currentProject = event.getData(PlatformDataKeys.PROJECT);

    CommandProcessor.getInstance().executeCommand(currentProject, () -> ApplicationManager.getApplication().runWriteAction(() -> {
        String genreCode  = PluginPreferences.getGenreCode();
        new ActionPerformer(genreCode).write(event);
    }), StaticTexts.HISTORY_INSERT_DUMMY_TEXT, UndoConfirmationPolicy.DO_NOT_REQUEST_CONFIRMATION);
}
 
Example #27
Source File: NewPackageTemplateAction.java    From PackageTemplates with Apache License 2.0 5 votes vote down vote up
private static void collectAndExecuteActions(Project project, VirtualFile virtualFile, PackageTemplateWrapper ptWrapper) {
    List<SimpleAction> listSimpleAction = new ArrayList<>();

    ptWrapper.collectSimpleActions(project, virtualFile, listSimpleAction);
    ptWrapper.collectInjectionActions(project, listSimpleAction);

    ActionRequest actionRequest = new ActionRequestBuilder()
            .setProject(project)
            .setActions(listSimpleAction)
            .setActionLabel("Execute PackageTemplate")
            .setAccessPrivileges(AccessPrivileges.WRITE)
            .setConfirmationPolicy(UndoConfirmationPolicy.REQUEST_CONFIRMATION)
            .setActionListener(new ActionRequest.ActionFinishListener() {
                @Override
                public void onFinish() {
                    if (ptWrapper.getPackageTemplate().shouldShowReport()) {
                        showReportDialog(project);
                    }
                    ReportHelper.reset();

                }

                @Override
                public void onFail() {
                    showReportDialog(project);
                    ReportHelper.reset();
                }
            })
            .build();

    //todo pre transaction Validation

    ActionExecutor.runAsTransaction(actionRequest);
}
 
Example #28
Source File: ActionRequestBuilder.java    From PackageTemplates with Apache License 2.0 5 votes vote down vote up
public ActionRequestBuilder() {
    //defaults
    request = new ActionRequest();
    request.project = null;
    request.actions = new ArrayList<>();
    request.actionLabel = "actionLabel";
    request.groupId = null;
    request.accessPrivileges = AccessPrivileges.NONE;
    request.confirmationPolicy = UndoConfirmationPolicy.DEFAULT;
    request.isUndoable = true;
}
 
Example #29
Source File: GlobalVariableQuickfix.java    From BashSupport with Apache License 2.0 5 votes vote down vote up
@Override
public void invoke(@NotNull Project project, @NotNull final PsiFile file, Editor editor, @NotNull PsiElement startElement, @NotNull PsiElement endElement) {
    BashVar variable = (BashVar) startElement;
    String variableName = variable.getReference().getReferencedName();

    UndoConfirmationPolicy mode = ApplicationManager.getApplication().isUnitTestMode()
            ? UndoConfirmationPolicy.DO_NOT_REQUEST_CONFIRMATION
            : UndoConfirmationPolicy.DEFAULT;

    CommandProcessor.getInstance().executeCommand(project, new GlobalVarRegistryAction(project, variableName, register), getText(), null, mode);
}
 
Example #30
Source File: BaseRefactoringProcessor.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Nonnull
protected UndoConfirmationPolicy getUndoConfirmationPolicy() {
  return UndoConfirmationPolicy.DEFAULT;
}