@Nullable
 @Override
 public JComponent createComponent() {
   myEnabled = new JBCheckBox("Enable EditorConfig support");
   final JPanel result = new JPanel();
   result.setLayout(new BoxLayout(result, BoxLayout.LINE_AXIS));
   final JPanel panel = new JPanel(new VerticalFlowLayout());
   result.setBorder(IdeBorderFactory.createTitledBorder("EditorConfig", false));
   panel.add(myEnabled);
   final JLabel warning = new JLabel("EditorConfig may override the IDE code style settings");
   warning.setFont(UIUtil.getLabelFont(UIUtil.FontSize.SMALL));
   warning.setBorder(IdeBorderFactory.createEmptyBorder(0, 20, 0, 0));
   panel.add(warning);
   panel.setAlignmentY(Component.TOP_ALIGNMENT);
   result.add(panel);
   final JButton export = new JButton("Export");
   export.addActionListener(
       (event) -> {
         final Component parent = UIUtil.findUltimateParent(result);
         if (parent instanceof IdeFrame) {
           Utils.export(((IdeFrame) parent).getProject());
         }
       });
   export.setAlignmentY(Component.TOP_ALIGNMENT);
   result.add(export);
   return result;
 }
 private static boolean hasMnemonicInBalloons(Container container, int code) {
   final Component parent = UIUtil.findUltimateParent(container);
   if (parent instanceof RootPaneContainer) {
     final JLayeredPane pane = ((RootPaneContainer) parent).getLayeredPane();
     for (Component component : pane.getComponents()) {
       if (component instanceof ComponentWithMnemonics
           && component instanceof Container
           && hasMnemonic((Container) component, code)) {
         return true;
       }
     }
   }
   return false;
 }
  @Nullable
  private static JRootPane findRoot(MouseEvent e) {
    final Component parent = UIUtil.findUltimateParent(e.getComponent());
    JRootPane root = null;

    if (parent instanceof JWindow) {
      root = ((JWindow) parent).getRootPane();
    } else if (parent instanceof JDialog) {
      root = ((JDialog) parent).getRootPane();
    } else if (parent instanceof JFrame) {
      root = ((JFrame) parent).getRootPane();
    }

    return root;
  }
  @Override
  public StatusBar getStatusBar(@NotNull Component c, @Nullable Project project) {
    Component parent = UIUtil.findUltimateParent(c);
    if (parent instanceof IdeFrame) {
      return ((IdeFrame) parent).getStatusBar().findChild(c);
    }

    IdeFrame frame = findFrameFor(project);
    if (frame != null) {
      return frame.getStatusBar().findChild(c);
    }

    assert false : "Cannot find status bar for " + c;

    return null;
  }
  public IdeFrame getIdeFrame(@Nullable final Project project) {
    if (project != null) {
      return getFrame(project);
    }
    final Window window = KeyboardFocusManager.getCurrentKeyboardFocusManager().getActiveWindow();
    final Component parent = UIUtil.findUltimateParent(window);
    if (parent instanceof IdeFrame) return (IdeFrame) parent;

    final Frame[] frames = Frame.getFrames();
    for (Frame each : frames) {
      if (each instanceof IdeFrame) {
        return (IdeFrame) each;
      }
    }

    return null;
  }
  public void showCenteredInCurrentWindow(@NotNull Project project) {
    Window window = null;

    Component focusedComponent = getWndManager().getFocusedComponent(project);
    if (focusedComponent != null) {
      Component parent = UIUtil.findUltimateParent(focusedComponent);
      if (parent instanceof Window) {
        window = (Window) parent;
      }
    }
    if (window == null) {
      window = KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusedWindow();
    }

    if (window != null) {
      showInCenterOf(window);
    }
  }
Exemplo n.º 7
0
  public boolean tryToApplyActivationState(boolean active, Window window) {
    final Component frame = UIUtil.findUltimateParent(window);

    if (frame instanceof IdeFrame) {
      final IdeFrame ideFrame = (IdeFrame) frame;
      if (isActive() != active) {
        myActive = Boolean.valueOf(active);
        System.setProperty("idea.active", Boolean.valueOf(myActive).toString());
        if (active) {
          myDispatcher.getMulticaster().applicationActivated(ideFrame);
        } else {
          myDispatcher.getMulticaster().applicationDeactivated(ideFrame);
        }
        return true;
      }
    }

    return false;
  }
  public boolean tryToApplyActivationState(boolean active, Window window) {
    final Component frame = UIUtil.findUltimateParent(window);

    if (frame instanceof IdeFrame) {
      final IdeFrame ideFrame = (IdeFrame) frame;
      if (isActive() != active) {
        myActive = Boolean.valueOf(active);
        System.setProperty("idea.active", myActive.toString());
        ApplicationActivationListener publisher =
            getMessageBus().syncPublisher(ApplicationActivationListener.TOPIC);
        if (active) {
          publisher.applicationActivated(ideFrame);
        } else {
          publisher.applicationDeactivated(ideFrame);
        }
        return true;
      }
    }

    return false;
  }