コード例 #1
0
  @Override
  public ActionCallback show() {
    LOG.assertTrue(
        EventQueue.isDispatchThread(), "Access is allowed from event dispatch thread only");
    if (myTypeAheadCallback != null) {
      IdeFocusManager.getInstance(myProject).typeAheadUntil(myTypeAheadCallback);
    }
    LOG.assertTrue(
        EventQueue.isDispatchThread(), "Access is allowed from event dispatch thread only");
    final ActionCallback result = new ActionCallback();

    final AnCancelAction anCancelAction = new AnCancelAction();
    final JRootPane rootPane = getRootPane();
    anCancelAction.registerCustomShortcutSet(
        new CustomShortcutSet(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0)), rootPane);
    myDisposeActions.add(
        new Runnable() {
          @Override
          public void run() {
            anCancelAction.unregisterCustomShortcutSet(rootPane);
          }
        });

    if (!myCanBeParent && myWindowManager != null) {
      myWindowManager.doNotSuggestAsParent(myDialog.getWindow());
    }

    final CommandProcessorEx commandProcessor =
        ApplicationManager.getApplication() != null
            ? (CommandProcessorEx) CommandProcessor.getInstance()
            : null;
    final boolean appStarted = commandProcessor != null;

    if (myDialog.isModal() && !isProgressDialog()) {
      if (appStarted) {
        commandProcessor.enterModal();
        LaterInvocator.enterModal(myDialog);
      }
    }

    if (appStarted) {
      hidePopupsIfNeeded();
    }

    try {
      myDialog.show();
    } finally {
      if (myDialog.isModal() && !isProgressDialog()) {
        if (appStarted) {
          commandProcessor.leaveModal();
          LaterInvocator.leaveModal(myDialog);
        }
      }

      myDialog.getFocusManager().doWhenFocusSettlesDown(result.createSetDoneRunnable());
    }

    return result;
  }
コード例 #2
0
  private void createDialog(
      @Nullable Window owner,
      boolean canBeParent,
      @NotNull DialogWrapper.IdeModalityType ideModalityType) {
    if (isHeadless()) {
      myDialog = new HeadlessDialog();
      return;
    }

    myDialog =
        new MyDialog(
            owner,
            myWrapper,
            myProject,
            myWindowFocusedCallback,
            myTypeAheadDone,
            myTypeAheadCallback);
    myDialog.setModalityType(ideModalityType.toAwtModality());

    myCanBeParent = canBeParent;
  }
コード例 #3
0
  public DialogWrapperPeerImpl(
      @NotNull final DialogWrapper wrapper,
      final Window owner,
      final boolean canBeParent,
      final DialogWrapper.IdeModalityType ideModalityType) {
    myWrapper = wrapper;
    myWindowManager = null;
    Application application = ApplicationManager.getApplication();
    if (application != null && application.hasComponent(WindowManager.class)) {
      myWindowManager = (WindowManagerEx) WindowManager.getInstance();
    }
    createDialog(owner, canBeParent);

    if (!isHeadless()) {
      Dialog.ModalityType modalityType = DialogWrapper.IdeModalityType.IDE.toAwtModality();
      if (Registry.is("ide.perProjectModality")) {
        modalityType = ideModalityType.toAwtModality();
      }
      myDialog.setModalityType(modalityType);
    }
  }
コード例 #4
0
  @Override
  @SuppressWarnings("SSBasedInspection")
  protected void dispose() {
    LOG.assertTrue(
        EventQueue.isDispatchThread(), "Access is allowed from event dispatch thread only");
    for (Runnable runnable : myDisposeActions) {
      runnable.run();
    }
    myDisposeActions.clear();
    final JRootPane root = myDialog.getRootPane();

    Runnable disposer =
        new Runnable() {
          @Override
          public void run() {
            myDialog.dispose();
            myProject = null;

            SwingUtilities.invokeLater(
                new Runnable() {
                  @Override
                  public void run() {
                    if (myDialog != null && root != null) {
                      myDialog.remove(root);
                    }
                  }
                });
          }
        };

    if (EventQueue.isDispatchThread()) {
      disposer.run();
    } else {
      SwingUtilities.invokeLater(disposer);
    }
  }
コード例 #5
0
 @Override
 public void setUndecorated(boolean undecorated) {
   myDialog.setUndecorated(undecorated);
 }
コード例 #6
0
 @Override
 public void setLocation(@NotNull Point p) {
   myDialog.setLocation(p);
 }
コード例 #7
0
 @Override
 public void setResizable(boolean resizable) {
   myDialog.setResizable(resizable);
 }
コード例 #8
0
 @Override
 public void setTitle(String title) {
   myDialog.setTitle(title);
 }
コード例 #9
0
 @Override
 public boolean isShowing() {
   return myDialog.isShowing();
 }
コード例 #10
0
 @Override
 public boolean isModal() {
   return myDialog.isModal();
 }
コード例 #11
0
 @Override
 @Nullable
 public Container getContentPane() {
   return getRootPane() != null ? myDialog.getContentPane() : null;
 }
コード例 #12
0
 @Override
 public void toBack() {
   myDialog.toBack();
 }
コード例 #13
0
 @Override
 public void toFront() {
   myDialog.toFront();
 }
コード例 #14
0
 @Override
 public void addKeyListener(KeyListener listener) {
   myDialog.addKeyListener(listener);
 }
コード例 #15
0
 @Override
 public void addMouseListener(MouseMotionListener listener) {
   myDialog.addMouseMotionListener(listener);
 }
コード例 #16
0
 @Override
 public Dimension getPreferredSize() {
   return myDialog.getPreferredSize();
 }
コード例 #17
0
 @Override
 public void setModal(boolean modal) {
   myDialog.setModal(modal);
 }
コード例 #18
0
 /** @see javax.swing.JDialog#validate */
 @Override
 public void validate() {
   myDialog.validate();
 }
コード例 #19
0
 @Override
 public boolean isVisible() {
   return myDialog.isVisible();
 }
コード例 #20
0
 /** @see javax.swing.JDialog#repaint */
 @Override
 public void repaint() {
   myDialog.repaint();
 }
コード例 #21
0
 @Override
 public void setSize(int width, int height) {
   myDialog.setSize(width, height);
 }
コード例 #22
0
 @Override
 public Window getOwner() {
   return myDialog.getOwner();
 }
コード例 #23
0
 @Override
 public void isResizable() {
   myDialog.isResizable();
 }
コード例 #24
0
 @Override
 public Window getWindow() {
   return myDialog.getWindow();
 }
コード例 #25
0
 @NotNull
 @Override
 public Point getLocation() {
   return myDialog.getLocation();
 }
コード例 #26
0
 @Override
 public JRootPane getRootPane() {
   return myDialog.getRootPane();
 }
コード例 #27
0
 @Override
 public void setLocation(int x, int y) {
   myDialog.setLocation(x, y);
 }
コード例 #28
0
 @Override
 public String getTitle() {
   return myDialog.getTitle();
 }
コード例 #29
0
 @Override
 public FocusTrackback getFocusTrackback() {
   return myDialog.getFocusTrackback();
 }
コード例 #30
0
 /** @see java.awt.Window#pack */
 @Override
 public void pack() {
   myDialog.pack();
 }