Java Code Examples for com.intellij.openapi.ui.DialogWrapper#findInstance()

The following examples show how to use com.intellij.openapi.ui.DialogWrapper#findInstance() . 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: 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 2
Source File: EditSourceForDialogAction.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Override
public void actionPerformed(AnActionEvent e) {
  final Navigatable[] navigatableArray = e.getData(CommonDataKeys.NAVIGATABLE_ARRAY);
  if (navigatableArray != null && navigatableArray.length > 0) {
    ApplicationManager.getApplication().invokeLater(new Runnable() {
      @Override
      public void run() {
        OpenSourceUtil.navigate(navigatableArray);
      }
    });
    DialogWrapper dialog = DialogWrapper.findInstance(mySourceComponent);
    if (dialog != null && dialog.isModal()) {
      dialog.doCancelAction();
    }
  }
}
 
Example 3
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 4
Source File: PopupChoiceAction.java    From StringManipulation with Apache License 2.0 5 votes vote down vote up
public static boolean isFromDialog(Project project) {
	final Component owner = IdeFocusManager.getInstance(project).getFocusOwner();
	if (owner != null) {
		final DialogWrapper instance = DialogWrapper.findInstance(owner);
		return instance != null;
	}
	return false;
}
 
Example 5
Source File: DirDiffManagerImpl.java    From consulo with Apache License 2.0 5 votes vote down vote up
public static boolean isFromModalDialog(Project project) {
  final Component owner = IdeFocusManager.getInstance(project).getFocusOwner();
  if (owner != null) {
    final DialogWrapper instance = DialogWrapper.findInstance(owner);
    return instance != null && instance.isModal();
  }
  return false;
}
 
Example 6
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 7
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 8
Source File: IdeKeyEventDispatcher.java    From consulo with Apache License 2.0 4 votes vote down vote up
private static boolean isControlEnterOnDialog(Component component, Shortcut sc) {
  return CONTROL_ENTER.equals(sc) && !IdeEventQueue.getInstance().isPopupActive() //avoid Control+Enter in completion
         && DialogWrapper.findInstance(component) != null;
}