private JComponent createSettingsPanel() {
    JPanel result = new JPanel(new FlowLayout(FlowLayout.RIGHT, 3, 0));
    result.add(new JLabel(ApplicationBundle.message("label.font.size")));
    myFontSizeSlider = new JSlider(JSlider.HORIZONTAL, 0, FontSize.values().length - 1, 3);
    myFontSizeSlider.setMinorTickSpacing(1);
    myFontSizeSlider.setPaintTicks(true);
    myFontSizeSlider.setPaintTrack(true);
    myFontSizeSlider.setSnapToTicks(true);
    UIUtil.setSliderIsFilled(myFontSizeSlider, true);
    result.add(myFontSizeSlider);
    result.setBorder(BorderFactory.createLineBorder(UIUtil.getBorderColor(), 1));

    myFontSizeSlider.addChangeListener(
        new ChangeListener() {
          @Override
          public void stateChanged(ChangeEvent e) {
            if (myIgnoreFontSizeSliderChange) {
              return;
            }
            EditorColorsManager colorsManager = EditorColorsManager.getInstance();
            EditorColorsScheme scheme = colorsManager.getGlobalScheme();
            scheme.setQuickDocFontSize(FontSize.values()[myFontSizeSlider.getValue()]);
            applyFontSize();
          }
        });

    String tooltipText = ApplicationBundle.message("quickdoc.tooltip.font.size.by.wheel");
    result.setToolTipText(tooltipText);
    myFontSizeSlider.setToolTipText(tooltipText);
    result.setVisible(false);
    result.setOpaque(true);
    myFontSizeSlider.setOpaque(true);
    return result;
  }
 @Override
 protected void paintComponent(Graphics g) {
   if (showEmptyText()) {
     Graphics2D gg = IdeBackgroundUtil.withFrameBackground(g, this);
     super.paintComponent(gg);
     g.setColor(UIUtil.isUnderDarcula() ? UIUtil.getBorderColor() : new Color(0, 0, 0, 50));
     g.drawLine(0, 0, getWidth(), 0);
   }
 }
  @Override
  protected void paintComponent(Graphics g) {
    super.paintComponent(g);

    if (myCurrentWindow == null || myCurrentWindow.getFiles().length == 0) {
      g.setColor(UIUtil.isUnderDarcula() ? UIUtil.getBorderColor() : new Color(0, 0, 0, 50));
      g.drawLine(0, 0, getWidth(), 0);
    }

    if (showEmptyText()) {
      UIUtil.applyRenderingHints(g);
      g.setColor(new JBColor(Gray._100, Gray._160));
      g.setFont(UIUtil.getLabelFont().deriveFont(UIUtil.isUnderDarcula() ? 24f : 18f));

      final UIUtil.TextPainter painter =
          new UIUtil.TextPainter().withShadow(true).withLineSpacing(1.4f);
      painter.appendLine("No files are open").underlined(new JBColor(Gray._150, Gray._100));

      if (!isProjectViewVisible()) {
        painter
            .appendLine(
                "Open Project View with "
                    + KeymapUtil.getShortcutText(
                        new KeyboardShortcut(
                            KeyStroke.getKeyStroke((SystemInfo.isMac ? "meta" : "alt") + " 1"),
                            null)))
            .smaller()
            .withBullet();
      }

      painter
          .appendLine("Open a file by name with " + getActionShortcutText("GotoFile"))
          .smaller()
          .withBullet()
          .appendLine(
              "Open Recent files with " + getActionShortcutText(IdeActions.ACTION_RECENT_FILES))
          .smaller()
          .withBullet()
          .appendLine("Open Navigation Bar with " + getActionShortcutText("ShowNavBar"))
          .smaller()
          .withBullet()
          .appendLine("Drag'n'Drop file(s) here from " + ShowFilePathAction.getFileManagerName())
          .smaller()
          .withBullet()
          .draw(
              g,
              new PairFunction<Integer, Integer, Pair<Integer, Integer>>() {
                @Override
                public Pair<Integer, Integer> fun(Integer width, Integer height) {
                  final Dimension s = getSize();
                  return Pair.create((s.width - width) / 2, (s.height - height) / 2);
                }
              });
    }
  }
  private void initConsoleUI(Process process) {
    // Init console view
    myConsoleView = createConsoleView();
    myConsoleView.setBorder(new SideBorder(UIUtil.getBorderColor(), SideBorder.LEFT));

    myProcessHandler = createProcessHandler(process, myProvider.getCommandLineString());

    myConsoleExecuteActionHandler = createConsoleExecuteActionHandler();

    ProcessTerminatedListener.attach(myProcessHandler);

    myProcessHandler.addProcessListener(
        new ProcessAdapter() {
          @Override
          public void processTerminated(ProcessEvent event) {
            finishConsole();
          }
        });

    // Attach to process
    myConsoleView.attachToProcess(myProcessHandler);

    // Runner creating
    final Executor defaultExecutor =
        ExecutorRegistry.getInstance().getExecutorById(DefaultRunExecutor.EXECUTOR_ID);
    final DefaultActionGroup toolbarActions = new DefaultActionGroup();
    final ActionToolbar actionToolbar =
        ActionManager.getInstance()
            .createActionToolbar(ActionPlaces.UNKNOWN, toolbarActions, false);

    // Runner creating
    final JPanel panel = new JPanel(new BorderLayout());
    panel.add(actionToolbar.getComponent(), BorderLayout.WEST);
    panel.add(myConsoleView.getComponent(), BorderLayout.CENTER);

    actionToolbar.setTargetComponent(panel);

    final RunContentDescriptor contentDescriptor =
        new RunContentDescriptor(
            myConsoleView, myProcessHandler, panel, constructConsoleTitle(myConsoleTitle));

    // tool bar actions
    final List<AnAction> actions =
        fillToolBarActions(toolbarActions, defaultExecutor, contentDescriptor);
    registerActionShortcuts(actions, getLanguageConsole().getConsoleEditor().getComponent());
    registerActionShortcuts(actions, panel);
    panel.updateUI();
    showConsole(defaultExecutor, contentDescriptor);

    // Run
    myProcessHandler.startNotify();
  }
  @Override
  protected void paintComponent(final Graphics g) {
    super.paintComponent(g);

    if (myToolbar != null
        && myToolbar.getParent() == this
        && myContent != null
        && myContent.getParent() == this) {
      g.setColor(UIUtil.getBorderColor());
      if (myVertical) {
        final int y = (int) myToolbar.getBounds().getMaxY();
        g.drawLine(0, y, getWidth(), y);
      } else {
        int x = (int) myToolbar.getBounds().getMaxX();
        g.drawLine(x, 0, x, getHeight());
      }
    }
  }
Exemplo n.º 6
0
  private JComponent createTableWithButtons() {
    final boolean isAnalyzeShown = false;

    final ClasspathPanelAction removeAction =
        new ClasspathPanelAction(this) {
          @Override
          public void run() {
            removeSelectedItems(TableUtil.removeSelectedItems(myEntryTable));
          }
        };

    final AnActionButton analyzeButton =
        new AnActionButton(
            ProjectBundle.message("classpath.panel.analyze"), null, IconUtil.getAnalyzeIcon()) {
          @Override
          public void actionPerformed(AnActionEvent e) {
            AnalyzeDependenciesDialog.show(getRootModel().getModule());
          }
        };

    // addButton.setShortcut(CustomShortcutSet.fromString("alt A", "INSERT"));
    // removeButton.setShortcut(CustomShortcutSet.fromString("alt DELETE"));
    // upButton.setShortcut(CustomShortcutSet.fromString("alt UP"));
    // downButton.setShortcut(CustomShortcutSet.fromString("alt DOWN"));
    myEntryTable.setBorder(new LineBorder(UIUtil.getBorderColor()));

    // we need to register our listener before ToolbarDecorator registers its own. Otherwise
    myEntryTable
        .getSelectionModel()
        .addListSelectionListener(
            new ListSelectionListener() {
              @Override
              public void valueChanged(ListSelectionEvent e) {
                if (e.getValueIsAdjusting()) {
                  return;
                }
                updateButtons();
              }
            });

    final ToolbarDecorator decorator = ToolbarDecorator.createDecorator(myEntryTable);
    decorator
        .setAddAction(
            new AnActionButtonRunnable() {
              @Override
              public void run(AnActionButton button) {
                initPopupActions();
                final JBPopup popup =
                    JBPopupFactory.getInstance()
                        .createListPopup(
                            new BaseListPopupStep<AddItemPopupAction<?>>(null, myPopupActions) {
                              @Override
                              public Icon getIconFor(AddItemPopupAction<?> aValue) {
                                return aValue.getIcon();
                              }

                              @Override
                              public boolean hasSubstep(AddItemPopupAction<?> selectedValue) {
                                return selectedValue.hasSubStep();
                              }

                              @Override
                              public boolean isMnemonicsNavigationEnabled() {
                                return true;
                              }

                              @Override
                              public PopupStep onChosen(
                                  final AddItemPopupAction<?> selectedValue,
                                  final boolean finalChoice) {
                                if (selectedValue.hasSubStep()) {
                                  return selectedValue.createSubStep();
                                }
                                return doFinalStep(
                                    new Runnable() {
                                      @Override
                                      public void run() {
                                        selectedValue.execute();
                                      }
                                    });
                              }

                              @Override
                              @NotNull
                              public String getTextFor(AddItemPopupAction<?> value) {
                                return "&" + value.getIndex() + "  " + value.getTitle();
                              }
                            });
                popup.show(button.getPreferredPopupPoint());
              }
            })
        .setRemoveAction(
            new AnActionButtonRunnable() {
              @Override
              public void run(AnActionButton button) {
                removeAction.actionPerformed(null);
              }
            })
        .setMoveUpAction(
            new AnActionButtonRunnable() {
              @Override
              public void run(AnActionButton button) {
                moveSelectedRows(-1);
              }
            })
        .setMoveDownAction(
            new AnActionButtonRunnable() {
              @Override
              public void run(AnActionButton button) {
                moveSelectedRows(+1);
              }
            })
        .addExtraAction(myEditButton);
    if (isAnalyzeShown) {
      decorator.addExtraAction(analyzeButton);
    }

    final JPanel panel = decorator.createPanel();
    myRemoveButton = ToolbarDecorator.findRemoveButton(panel);
    return panel;
  }
    private void doPaint(Graphics g) {
      GraphicsUtil.setupAntialiasing(g);

      final boolean isEmpty = getIcon() == null && StringUtil.isEmpty(getText());
      final Dimension size = getSize();
      if (isSmallVariant()) {
        final Graphics2D g2 = (Graphics2D) g;
        g2.setColor(UIUtil.getControlColor());
        final int w = getWidth();
        final int h = getHeight();
        if (getModel().isArmed() && getModel().isPressed()) {
          g2.setPaint(
              new GradientPaint(
                  0,
                  0,
                  UIUtil.getControlColor(),
                  0,
                  h,
                  ColorUtil.shift(UIUtil.getControlColor(), 0.8)));
        } else {
          g2.setPaint(
              new GradientPaint(
                  0,
                  0,
                  ColorUtil.shift(UIUtil.getControlColor(), 1.1),
                  0,
                  h,
                  ColorUtil.shift(UIUtil.getControlColor(), 0.9)));
        }
        g2.fillRect(2, 0, w - 2, h);
        GraphicsUtil.setupAntialiasing(g2);
        if (!myMouseInside) {
          g2.setPaint(
              new GradientPaint(
                  0, 0, UIUtil.getBorderColor(), 0, h, UIUtil.getBorderColor().darker()));
          // g2.setColor(UIUtil.getBorderColor());
        } else {
          g2.setPaint(
              new GradientPaint(
                  0,
                  0,
                  UIUtil.getBorderColor().darker(),
                  0,
                  h,
                  UIUtil.getBorderColor().darker().darker()));
        }
        g2.drawRect(2, 0, w - 3, h - 1);
        final Icon icon = getIcon();
        int x = 7;
        if (icon != null) {
          icon.paintIcon(null, g, x, (size.height - icon.getIconHeight()) / 2);
          x += icon.getIconWidth() + 3;
        }
        if (!StringUtil.isEmpty(getText())) {
          final Font font = getFont();
          g2.setFont(font);
          g2.setColor(UIManager.getColor("Panel.foreground"));
          g2.drawString(getText(), x, (size.height + font.getSize()) / 2 - 1);
        }
      } else {
        super.paintComponent(g);
      }
      final Insets insets = super.getInsets();
      final Icon icon = isEnabled() ? ARROW_ICON : DISABLED_ARROW_ICON;
      final int x;
      if (isEmpty) {
        x = (size.width - icon.getIconWidth()) / 2;
      } else {
        if (isSmallVariant()) {
          x = size.width - icon.getIconWidth() - insets.right + 1;
        } else {
          x =
              size.width
                  - icon.getIconWidth()
                  - insets.right
                  + (UIUtil.isUnderNimbusLookAndFeel() ? -3 : 2);
        }
      }
      if (UIUtil.isUnderDarcula()) {
        g.setXORMode(new Color(208, 188, 159));
      }
      icon.paintIcon(null, g, x, (size.height - icon.getIconHeight()) / 2);
      g.setPaintMode();
    }
 private static Color getBorderColor() {
   return UIUtil.getBorderColor();
 }