com.intellij.openapi.ui.DialogWrapper Java Examples

The following examples show how to use com.intellij.openapi.ui.DialogWrapper. 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: CreateIpaAction.java    From robovm-idea with GNU General Public License v2.0 6 votes vote down vote up
public void actionPerformed(final AnActionEvent e) {
    final CreateIpaDialog dialog = new CreateIpaDialog(e.getProject());
    dialog.show();
    if(dialog.getExitCode() == DialogWrapper.OK_EXIT_CODE) {
        // create IPA
        IpaConfig ipaConfig = dialog.getIpaConfig();
        CompileScope scope = CompilerManager.getInstance(e.getProject()).createModuleCompileScope(ipaConfig.module, true);
        scope.putUserData(IPA_CONFIG_KEY, ipaConfig);
        CompilerManager.getInstance(e.getProject()).compile(scope, new CompileStatusNotification() {
            @Override
            public void finished(boolean aborted, int errors, int warnings, CompileContext compileContext) {
                RoboVmPlugin.logInfo(e.getProject(), "IPA creation complete, %d errors, %d warnings", errors, warnings);
            }
        });
    }
}
 
Example #2
Source File: NewStoryboardAction.java    From robovm-idea with GNU General Public License v2.0 6 votes vote down vote up
public void actionPerformed(AnActionEvent e) {
    if(module == null) {
        return;
    }

    VirtualFile file = CommonDataKeys.VIRTUAL_FILE.getData(e.getDataContext());
    final NewStoryboardDialog dialog = new NewStoryboardDialog(e.getProject(), new File(file.getCanonicalPath()));
    dialog.show();
    if(dialog.getExitCode() == DialogWrapper.OK_EXIT_CODE) {
        IBIntegratorProxy proxy = IBIntegratorManager.getInstance().getProxy(module);
        if(proxy == null) {
            RoboVmPlugin.logError(e.getProject(), "Couldn't get interface builder integrator for module %s", module.getName());
        } else {
            File resourceDir = new File(file.getCanonicalPath());
            proxy.newIOSStoryboard(dialog.getStoryboardName(), resourceDir);
            VirtualFile vsfFile = VfsUtil.findFileByIoFile(resourceDir, true);
            vsfFile.refresh(false, true);
        }
    }
}
 
Example #3
Source File: ConfigureANTLRAction.java    From intellij-plugin-v4 with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@Override
public void actionPerformed(AnActionEvent e) {
	if ( e.getProject()==null ) {
		LOG.error("actionPerformed no project for "+e);
		return; // whoa!
	}
	VirtualFile grammarFile = MyActionUtils.getGrammarFileFromEvent(e);
	if ( grammarFile==null ) return;
	LOG.info("actionPerformed "+grammarFile);

	ConfigANTLRPerGrammar configDialog = ConfigANTLRPerGrammar.getDialogForm(e.getProject(), grammarFile.getPath());
	configDialog.getPeer().setTitle("Configure ANTLR Tool "+ Tool.VERSION+" for "+ grammarFile.getName());

	configDialog.show();

	if ( configDialog.getExitCode()==DialogWrapper.OK_EXIT_CODE ) {
		configDialog.saveValues(e.getProject(), grammarFile.getPath());
	}
}
 
Example #4
Source File: Panel.java    From GitCommitMessage with Apache License 2.0 6 votes vote down vote up
Panel(Project project) {

        String branch = CommitMessage.extractBranchName(project);
        if (branch != null) {
            // Branch name  matches Ticket Name
            setTextFieldsBasedOnBranch(branch, project);
        }

        changeTemplateButton.addActionListener(e -> {
            DialogWrapper dialog = createTemplateDialog(project);
            if (dialog.getExitCode() != DialogWrapper.OK_EXIT_CODE) {
                dialog.getExitCode();
            }

        });
    }
 
Example #5
Source File: CreatePatchFromChangesAction.java    From consulo with Apache License 2.0 6 votes vote down vote up
public static void createPatch(Project project, String commitMessage, List<Change> changeCollection) {
  project = project == null ? ProjectManager.getInstance().getDefaultProject() : project;
  final CreatePatchCommitExecutor executor = CreatePatchCommitExecutor.getInstance(project);
  CommitSession commitSession = executor.createCommitSession();
  if (commitSession instanceof CommitSessionContextAware) {
    ((CommitSessionContextAware)commitSession).setContext(new CommitContext());
  }
  DialogWrapper sessionDialog = new SessionDialog(executor.getActionText(),
                                                  project,
                                                  commitSession,
                                                  changeCollection,
                                                  commitMessage);
  sessionDialog.show();
  if (!sessionDialog.isOK()) {
    return;
  }
  preloadContent(project, changeCollection);

  commitSession.execute(changeCollection, commitMessage);
}
 
Example #6
Source File: GlassPaneDialogWrapperPeer.java    From consulo with Apache License 2.0 6 votes vote down vote up
private MyDialog(IdeGlassPaneEx pane, DialogWrapper wrapper, Project project) {
      setLayout(new BorderLayout());
      setOpaque(false);
      setBorder(BorderFactory.createEmptyBorder(AllIcons.Ide.Shadow.Top.getIconHeight(), AllIcons.Ide.Shadow.Left.getIconWidth(), AllIcons.Ide.Shadow.Bottom.getIconHeight(),
                                                AllIcons.Ide.Shadow.Right.getIconWidth()));

      myPane = pane;
      myDialogWrapper = new WeakReference<>(wrapper);
//      myProject = new WeakReference<Project>(project);

      myRootPane = new MyRootPane(this); // be careful with DialogWrapper.dispose()!
      Disposer.register(this, myRootPane);

      myContentPane = new JPanel();
      myContentPane.setOpaque(true);
      add(myContentPane, BorderLayout.CENTER);

      myTransparentPane = createTransparentPane();

      myWrapperPane = createWrapperPane();
      myWrapperPane.add(this);

      setFocusCycleRoot(true);
    }
 
Example #7
Source File: CreateFromTemplateDialog.java    From consulo with Apache License 2.0 6 votes vote down vote up
public PsiElement create() {
  if (ApplicationManager.getApplication().isUnitTestMode()) {
    doCreate(myTemplate.getName() + "." + myTemplate.getExtension());
    Disposer.dispose(getDisposable());
    return myCreatedElement;
  }
  if (myAttrPanel != null) {
    if (myAttrPanel.hasSomethingToAsk()) {
      show();
      return myCreatedElement;
    }
    doCreate(null);
  }
  close(DialogWrapper.OK_EXIT_CODE);
  return myCreatedElement;
}
 
Example #8
Source File: ArchiveDiffTool.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Override
public boolean canShow(DiffRequest request) {
  final DiffContent[] contents = request.getContents();
  final DialogWrapper instance = DialogWrapper.findInstance(IdeFocusManager.getInstance(request.getProject()).getFocusOwner());
  if (instance != null && instance.isModal()) return false;
  if (contents.length == 2) {
    final VirtualFile file1 = contents[0].getFile();
    final VirtualFile file2 = contents[1].getFile();
    if (file1 != null && file2 != null) {
      final FileType type1 = contents[0].getContentType();
      final FileType type2 = contents[1].getContentType();
      return type1 == type2 && type1 instanceof ArchiveFileType;
    }
  }
  return false;
}
 
Example #9
Source File: DesktopColorPicker.java    From consulo with Apache License 2.0 6 votes vote down vote up
public static void showDialog(Component parent,
                              String caption,
                              Color preselectedColor,
                              boolean enableOpacity,
                              ColorPickerListener[] listeners,
                              boolean opacityInPercent,
                              @Nonnull java.util.function.Consumer<Color> colorConsumer) {
  final ColorPickerDialog dialog = new ColorPickerDialog(parent, caption, preselectedColor, enableOpacity, listeners, opacityInPercent);
  SwingUtilities.invokeLater(() -> {
    dialog.show();

    if (dialog.getExitCode() == DialogWrapper.OK_EXIT_CODE) {
      colorConsumer.accept(dialog.getColor());
    }
    else {
      colorConsumer.accept(null);
    }
  });
}
 
Example #10
Source File: NavBarListener.java    From consulo with Apache License 2.0 6 votes vote down vote up
private void processFocusLost(FocusEvent e) {
  final Component opposite = e.getOppositeComponent();

  if (myPanel.isInFloatingMode() && opposite != null && DialogWrapper.findInstance(opposite) != null) {
    myPanel.hideHint();
    return;
  }

  final boolean nodePopupInactive = !myPanel.isNodePopupActive();
  boolean childPopupInactive = !JBPopupFactory.getInstance().isChildPopupFocused(myPanel);
  if (nodePopupInactive && childPopupInactive) {
    if (opposite != null && opposite != myPanel && !myPanel.isAncestorOf(opposite) && !e.isTemporary()) {
      myPanel.setContextComponent(null);
      myPanel.hideHint();
    }
  }

  myPanel.updateItems();
}
 
Example #11
Source File: GlassPaneDialogWrapperPeer.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
public Object getData(@Nonnull Key<?> dataId) {
  final DialogWrapper wrapper = myDialogWrapper.get();
  if (wrapper instanceof DataProvider) {
    return ((DataProvider)wrapper).getData(dataId);
  }
  else if (wrapper instanceof TypeSafeDataProvider) {
    TypeSafeDataProviderAdapter adapter = new TypeSafeDataProviderAdapter((TypeSafeDataProvider)wrapper);
    return adapter.getData(dataId);
  }
  return null;
}
 
Example #12
Source File: UiInspectorAction.java    From consulo with Apache License 2.0 5 votes vote down vote up
private static Window findWindow(Component component) {
  DialogWrapper dialogWrapper = DialogWrapper.findInstance(component);
  if (dialogWrapper != null) {
    return dialogWrapper.getPeer().getWindow();
  }
  return null;
}
 
Example #13
Source File: RNUpgradeAction.java    From react-native-console with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Override
public boolean beforeAction() {
    String exePath = RNPathUtil.getExecuteFileFullPath(EXEC);

    if (exePath == null || EXEC.equals(RNPathUtil.getExecuteFileFullPath(EXEC))) {
        int options = Messages.showIdeaMessageDialog(getProject(),
                "Would you like to install " + EXEC + " globally now?\n" +
                        "This might take one or two minutes without any console update, please wait for the final result.\n" +
                        "After that, you'll need to click this button again.",
                "Can Not Found " + EXEC, new String[]{"Yes", "No"}, 0,
                AllIcons.General.QuestionDialog, new DialogWrapper.DoNotAskOption.Adapter() {
                    @Override
                    public void rememberChoice(boolean b, int i) {

                    }
                });
        if (options == 0) {
            cmd = INSTALL_CMD;
            return true;
        } else {
            RNConsole consoleView = terminal.getRNConsole(getText(), getIcon());

            if (consoleView != null) {
                consoleView.clear();
                consoleView.print(
                        "Can't found " + EXEC + ", if you were first running this command, make sure you have " + EXEC + " installed globally.\n" +
                                "To install, please run in terminal with command: \n" +
                                INSTALL_CMD +
                                "\n\n",
                        ConsoleViewContentType.ERROR_OUTPUT);

            }
            return false;
        }

    }

    cmd = EXEC;
    return true;
}
 
Example #14
Source File: DialogWrapperPeerImpl.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
public Component getMostRecentFocusOwner() {
  if (!myOpened) {
    final DialogWrapper wrapper = getDialogWrapper();
    if (wrapper != null) {
      JComponent toFocus = wrapper.getPreferredFocusedComponent();
      if (toFocus != null) {
        return toFocus;
      }
    }
  }
  return super.getMostRecentFocusOwner();
}
 
Example #15
Source File: MergeRequestImpl.java    From consulo with Apache License 2.0 5 votes vote down vote up
private AllResolvedListener(MergePanel2 mergePanel, DialogWrapper dialogWrapper) {
  myMergePanel = mergePanel;
  myDialogWrapper = dialogWrapper;
  final ChangeCounter changeCounter = ChangeCounter.getOrCreate(myMergePanel.getMergeList());
  changeCounter.removeListener(this);
  changeCounter.addListener(this);
}
 
Example #16
Source File: GlassPaneDialogWrapperPeer.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
public void dispose() {
  remove(getContentPane());
  setVisible(false);
  DialogWrapper.unregisterKeyboardActions(myWrapperPane);
  myRootPane = null;
}
 
Example #17
Source File: ErrorReporter.java    From CppTools with Apache License 2.0 5 votes vote down vote up
/**
 * Reports a bug with given message
 *
 * @param message of bug description
 */
public static boolean reportBug(String message, Component comp) {
  final String to = "[email protected]";

  StringBuffer buf = new StringBuffer(message.length() + 50);

  buf.append("Idea version:");
  buf.append(ApplicationInfo.getInstance().getBuildNumber());
  buf.append('\n');

  buf.append("Plugin version:");
  buf.append(CppSupportSettings.getPluginVersion());
  buf.append('\n');

  buf.append(message);
  BugReportForm form = new BugReportForm(buf.toString(), comp);

  form.show();
  if (form.getExitCode() != DialogWrapper.OK_EXIT_CODE) return false;

  final BugReportModel model = new BugReportModel();

  model.to = to;
  model.mailserver = form.mailServer.getText();
  model.mailUser = form.mailUser.getText();
  model.cc = "[email protected]";
  model.message = form.bugReportText.getText();

  sendBugData(model);

  return true;
}
 
Example #18
Source File: ProgressDialog.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
public void copyPopupStateToWindow() {
  final DialogWrapper popup = myPopup;
  if (popup != null) {
    if (popup.isShowing()) {
      myWasShown = true;
    }
  }
}
 
Example #19
Source File: MergeRequestImpl.java    From consulo with Apache License 2.0 5 votes vote down vote up
public void setActions(final DialogBuilder builder, MergePanel2 mergePanel, final Convertor<DialogWrapper, Boolean> preOkHook) {
  builder.removeAllActions(); // otherwise dialog will get default actions (OK, Cancel)

  if (myOkButtonPresentation != null) {
    if (builder.getOkAction() == null) {
      builder.addOkAction();
    }

    configureAction(builder, builder.getOkAction(), myOkButtonPresentation);
    builder.setOkOperation(new Runnable() {
      @Override
      public void run() {
        if (preOkHook != null && !preOkHook.convert(builder.getDialogWrapper())) return;
        myOkButtonPresentation.run(builder.getDialogWrapper());
      }
    });
  }

  if (myCancelButtonPresentation != null) {
    if (builder.getCancelAction() == null) {
      builder.addCancelAction();
    }

    configureAction(builder, builder.getCancelAction(), myCancelButtonPresentation);
    builder.setCancelOperation(new Runnable() {
      @Override
      public void run() {
        myCancelButtonPresentation.run(builder.getDialogWrapper());
      }
    });
  }

  if (getMergeContent() != null && mergePanel.getMergeList() != null) {
    new AllResolvedListener(mergePanel, builder.getDialogWrapper());
  }
}
 
Example #20
Source File: HaxePullUpHandler.java    From intellij-haxe with Apache License 2.0 5 votes vote down vote up
@Override
public boolean checkConflicts(final HaxePullUpDialog dialog) {
  final List<MemberInfo> infos = dialog.getSelectedMemberInfos();
  final MemberInfo[] memberInfos = infos.toArray(new MemberInfo[infos.size()]);
  final PsiClass superClass = dialog.getSuperClass();
  if (!checkWritable(superClass, memberInfos)) return false;
  final MultiMap<PsiElement, String> conflicts = new MultiMap<PsiElement, String>();
  if (!ProgressManager.getInstance().runProcessWithProgressSynchronously(new Runnable() {
    @Override
    public void run() {
      ApplicationManager.getApplication().runReadAction(new Runnable() {
        @Override
        public void run() {
          //final PsiDirectory targetDirectory = superClass.getContainingFile().getContainingDirectory();
          //final PsiPackage targetPackage = targetDirectory != null ? JavaDirectoryService.getInstance().getPackage(targetDirectory) : null;
          //conflicts
          //  .putAllValues(PullUpConflictsUtil.checkConflicts(memberInfos, mySubclass, superClass, targetPackage, targetDirectory,
          //                                                   dialog.getContainmentVerifier()));
        }
      });
    }
  }, RefactoringBundle.message("detecting.possible.conflicts"), true, myProject)) return false;
  if (!conflicts.isEmpty()) {
    ConflictsDialog conflictsDialog = new ConflictsDialog(myProject, conflicts);
    conflictsDialog.show();
    final boolean ok = conflictsDialog.isOK();
    if (!ok && conflictsDialog.isShowConflicts()) dialog.close(DialogWrapper.CANCEL_EXIT_CODE);
    return ok;
  }
  return true;
}
 
Example #21
Source File: ConfirmingTrustManager.java    From consulo with Apache License 2.0 5 votes vote down vote up
private boolean confirmAndUpdate(final X509Certificate[] chain, boolean addToKeyStore, boolean askUser) {
  Application app = ApplicationManager.getApplication();
  final X509Certificate endPoint = chain[0];
  // IDEA-123467 and IDEA-123335 workaround
  String threadClassName = StringUtil.notNullize(Thread.currentThread().getClass().getCanonicalName());
  if (threadClassName.equals("sun.awt.image.ImageFetcher")) {
    LOG.debug("Image Fetcher thread is detected. Certificate check will be skipped.");
    return true;
  }
  CertificateManager.Config config = CertificateManager.getInstance().getState();
  if (app.isUnitTestMode() || app.isHeadlessEnvironment() || config.ACCEPT_AUTOMATICALLY) {
    LOG.debug("Certificate will be accepted automatically");
    if (addToKeyStore) {
      myCustomManager.addCertificate(endPoint);
    }
    return true;
  }
  boolean accepted = askUser && CertificateManager.showAcceptDialog(new Callable<DialogWrapper>() {
    @Override
    public DialogWrapper call() throws Exception {
      // TODO may be another kind of warning, if default trust store is missing
      return CertificateWarningDialog.createUntrustedCertificateWarning(endPoint);
    }
  });
  if (accepted) {
    LOG.info("Certificate was accepted by user");
    if (addToKeyStore) {
      myCustomManager.addCertificate(endPoint);
    }
  }
  return accepted;
}
 
Example #22
Source File: ConfirmingHostnameVerifier.java    From consulo with Apache License 2.0 5 votes vote down vote up
private static boolean accepted(final String host, final X509Certificate cert) {
  return CertificateManager.showAcceptDialog(new Callable<DialogWrapper>() {
    @Override
    public DialogWrapper call() throws Exception {
      return CertificateWarningDialog.createHostnameMismatchWarning(cert, host);
    }
  });
}
 
Example #23
Source File: HttpConfigurable.java    From consulo with Apache License 2.0 5 votes vote down vote up
public PasswordAuthentication getGenericPromptedAuthentication(final String prefix, final String host, final String prompt, final int port, final boolean remember) {
  if (ApplicationManager.getApplication().isUnitTestMode()) {
    return myTestGenericAuthRunnable.get();
  }

  final Ref<PasswordAuthentication> value = Ref.create();
  runAboveAll(() -> {
    if (isGenericPasswordCanceled(host, port)) {
      return;
    }

    PasswordAuthentication password = getGenericPassword(host, port);
    if (password != null) {
      value.set(password);
      return;
    }

    AuthenticationDialog dialog = new AuthenticationDialog(PopupUtil.getActiveComponent(), prefix + host, "Please enter credentials for: " + prompt, "", "", remember);
    dialog.show();
    if (dialog.getExitCode() == DialogWrapper.OK_EXIT_CODE) {
      AuthenticationPanel panel = dialog.getPanel();
      PasswordAuthentication passwordAuthentication = new PasswordAuthentication(panel.getLogin(), panel.getPassword());
      putGenericPassword(host, port, passwordAuthentication, remember && panel.isRememberPassword());
      value.set(passwordAuthentication);
    }
    else {
      setGenericPasswordCanceled(host, port);
    }
  });
  return value.get();
}
 
Example #24
Source File: AddModuleDependencyTabContext.java    From consulo with Apache License 2.0 5 votes vote down vote up
public final void processAddOrderEntries(DialogWrapper dialogWrapper) {
  ModifiableModuleRootLayer currentLayer = (ModifiableModuleRootLayer)myClasspathPanel.getRootModel().getCurrentLayer();

  List<OrderEntry> orderEntries = createOrderEntries(currentLayer, dialogWrapper);
  if(orderEntries.isEmpty()) {
    return;
  }

  List<ClasspathTableItem<?>> items = new ArrayList<ClasspathTableItem<?>>(orderEntries.size());
  for (OrderEntry orderEntry : orderEntries) {
    ClasspathTableItem<?> item = ClasspathTableItem.createItem(orderEntry, myContext);
    items.add(item);
  }
  myClasspathPanel.addItems(items);
}
 
Example #25
Source File: MacMessages.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Messages.YesNoCancelResult
public abstract int showYesNoCancelDialog(@Nonnull String title,
                                          String message,
                                          @Nonnull String defaultButton,
                                          String alternateButton,
                                          String otherButton,
                                          @Nullable Window window,
                                          @Nullable DialogWrapper.DoNotAskOption doNotAskOption);
 
Example #26
Source File: NavBarListener.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
public void focusLost(final FocusEvent e) {
  if (myPanel.getProject().isDisposed()) {
    myPanel.setContextComponent(null);
    myPanel.hideHint();
    return;
  }
  final DialogWrapper dialog = DialogWrapper.findInstance(e.getOppositeComponent());
  shouldFocusEditor =  dialog != null;
  if (dialog != null) {
    Disposer.register(dialog.getDisposable(), new Disposable() {
      @Override
      public void dispose() {
        if (dialog.getExitCode() == DialogWrapper.CANCEL_EXIT_CODE) {
          shouldFocusEditor = false;
        }
      }
    });
  }

  // required invokeLater since in current call sequence KeyboardFocusManager is not initialized yet
  // but future focused component
  //noinspection SSBasedInspection
  SwingUtilities.invokeLater(new Runnable() {
    @Override
    public void run() {
      processFocusLost(e);
    }
  });
}
 
Example #27
Source File: ActionButtonPresentation.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
public void run(DialogWrapper dialog) {
  if (Messages.showYesNoDialog(dialog.getRootPane(),
                               DiffBundle.message("merge.dialog.exit.without.applying.changes.confirmation.message"),
                               DiffBundle.message("cancel.visual.merge.dialog.title"),
                               Messages.getQuestionIcon()) == 0) {
    dialog.close(DialogWrapper.CANCEL_EXIT_CODE);
  }
}
 
Example #28
Source File: MergeWindow.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Nonnull
@Override
protected Action[] createActions() {
  MergeRequestProcessor.BottomActions bottomActions = myProcessor.getBottomActions();
  List<Action> actions = ContainerUtil.skipNulls(ContainerUtil.list(bottomActions.resolveAction, bottomActions.cancelAction));
  if (bottomActions.resolveAction != null) {
    bottomActions.resolveAction.putValue(DialogWrapper.DEFAULT_ACTION, true);
  }
  return actions.toArray(new Action[actions.size()]);
}
 
Example #29
Source File: LombokLoggerHandler.java    From lombok-intellij-plugin with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
private boolean checkLoggerField(@NotNull PsiField psiField, @NotNull String lombokLoggerName, boolean lombokLoggerIsStatic) {
  if (!isValidLoggerField(psiField, lombokLoggerName, lombokLoggerIsStatic)) {
    final String messageText = String.format("Logger field: \"%s\" Is not private %sfinal field named \"%s\". Refactor anyway?",
      psiField.getName(), lombokLoggerIsStatic ? "static " : "", lombokLoggerName);
    int result = Messages.showOkCancelDialog(messageText, "Attention!", Messages.getOkButton(), Messages.getCancelButton(), Messages.getQuestionIcon());
    return DialogWrapper.OK_EXIT_CODE == result;
  }
  return true;
}
 
Example #30
Source File: ClasspathPanelImpl.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
public void actionPerformed(AnActionEvent e) {
  final OrderEntry selectedEntry = getSelectedEntry();
  GlobalSearchScope targetScope;
  if (selectedEntry instanceof ModuleOrderEntry) {
    final Module module = ((ModuleOrderEntry)selectedEntry).getModule();
    LOG.assertTrue(module != null);
    targetScope = GlobalSearchScope.moduleScope(module);
  }
  else {
    Library library = ((LibraryOrderEntry)selectedEntry).getLibrary();
    LOG.assertTrue(library != null);
    targetScope = new LibraryScope(getProject(), library);
  }
  new AnalyzeDependenciesOnSpecifiedTargetHandler(getProject(), new AnalysisScope(myState.getRootModel().getModule()), targetScope) {
    @Override
    protected boolean canStartInBackground() {
      return false;
    }

    @Override
    protected boolean shouldShowDependenciesPanel(List<DependenciesBuilder> builders) {
      for (DependenciesBuilder builder : builders) {
        for (Set<PsiFile> files : builder.getDependencies().values()) {
          if (!files.isEmpty()) {
            Messages.showInfoMessage(myEntryTable, "Dependencies were successfully collected in \"" +
                                                   ToolWindowId.DEPENDENCIES + "\" toolwindow",
                                     FindBundle.message("find.pointcut.applications.not.found.title"));
            return true;
          }
        }
      }
      if (Messages.showOkCancelDialog(myEntryTable, "No code dependencies were found. Would you like to remove the dependency?",
                                      CommonBundle.getWarningTitle(), Messages.getWarningIcon()) == DialogWrapper.OK_EXIT_CODE) {
        removeSelectedItems(TableUtil.removeSelectedItems(myEntryTable));
      }
      return false;
    }
  }.analyze();
}