private static void patchHiDPI(UIDefaults defaults) {
    if (!JBUI.isHiDPI()) return;

    List<String> myIntKeys = Arrays.asList("Tree.leftChildIndent", "Tree.rightChildIndent");
    List<String> patched = new ArrayList<String>();
    for (Map.Entry<Object, Object> entry : defaults.entrySet()) {
      Object value = entry.getValue();
      String key = entry.getKey().toString();
      if (value instanceof DimensionUIResource) {
        entry.setValue(JBUI.size((DimensionUIResource) value).asUIResource());
      } else if (value instanceof InsetsUIResource) {
        entry.setValue(JBUI.insets(((InsetsUIResource) value)).asUIResource());
      } else if (value instanceof Integer) {
        if (key.endsWith(".maxGutterIconWidth") || myIntKeys.contains(key)) {
          if (!"true".equals(defaults.get(key + ".hidpi.patched"))) {
            entry.setValue(Integer.valueOf(JBUI.scale((Integer) value)));
            patched.add(key);
          }
        }
      }
    }
    for (String key : patched) {
      defaults.put(key + ".hidpi.patched", "true");
    }
  }
 @Override
 public Insets getBorderInsets(Component c) {
   if (DarculaButtonUI.isSquare(c)) {
     return JBUI.insets(2, 0, 2, 0).asUIResource();
   }
   return JBUI.insets(8, 16, 8, 14).asUIResource();
 }
    private JComponent createLogo() {
      NonOpaquePanel panel = new NonOpaquePanel(new BorderLayout());
      ApplicationInfoEx app = ApplicationInfoEx.getInstanceEx();
      JLabel logo = new JLabel(IconLoader.getIcon(app.getWelcomeScreenLogoUrl()));
      logo.setBorder(JBUI.Borders.empty(30, 0, 10, 0));
      logo.setHorizontalAlignment(SwingConstants.CENTER);
      panel.add(logo, BorderLayout.NORTH);
      JLabel appName = new JLabel(ApplicationNamesInfo.getInstance().getFullProductName());
      Font font = getProductFont();
      appName.setForeground(JBColor.foreground());
      appName.setFont(font.deriveFont(JBUI.scale(36f)).deriveFont(Font.PLAIN));
      appName.setHorizontalAlignment(SwingConstants.CENTER);
      String appVersion = "Version " + app.getFullVersion();

      if (app.isEAP() && app.getBuild().getBuildNumber() < Integer.MAX_VALUE) {
        appVersion += " (" + app.getBuild().asString() + ")";
      }

      JLabel version = new JLabel(appVersion);
      version.setFont(getProductFont().deriveFont(JBUI.scale(16f)));
      version.setHorizontalAlignment(SwingConstants.CENTER);
      version.setForeground(Gray._128);

      panel.add(appName);
      panel.add(version, BorderLayout.SOUTH);
      panel.setBorder(JBUI.Borders.emptyBottom(20));
      return panel;
    }
  @Override
  protected void paintIcon(JComponent c, Graphics2D g, Rectangle viewRect, Rectangle iconRect) {
    int rad = JBUI.scale(4);

    // Paint the radio button
    final int x = iconRect.x + (rad - (rad % 2 == 1 ? 1 : 0)) / 2;
    final int y = iconRect.y + (rad - (rad % 2 == 1 ? 1 : 0)) / 2;
    final int w = iconRect.width - rad;
    final int h = iconRect.height - rad;
    final boolean enabled = c.isEnabled();
    Color color = enabled ? Gray.x50 : Gray.xD3;
    g.translate(x, y);
    // setup AA for lines
    final GraphicsConfig config = GraphicsUtil.setupAAPainting(g);
    g.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_PURE);
    final boolean selected = ((AbstractButton) c).isSelected();
    g.setPaint(color);
    g.drawOval(0, 0, w, h);

    if (selected) {
      g.setColor(color);
      g.fillOval(JBUI.scale(3), JBUI.scale(3), w - 2 * JBUI.scale(3), h - 2 * JBUI.scale(3));
    }
    config.restore();
    g.translate(-x, -y);
  }
  @Override
  public void paintBorder(Component c, Graphics g, int x, int y, int width, int height) {
    final Graphics2D g2d = (Graphics2D) g;
    final Insets ins = getBorderInsets(c);
    final int yOff = (ins.top + ins.bottom) / 4;
    final boolean square = DarculaButtonUI.isSquare(c);
    int offset = JBUI.scale(square ? 1 : getOffset());
    if (c.hasFocus()) {
      DarculaUIUtil.paintFocusRing(g2d, offset, yOff, width - 2 * offset, height - 2 * yOff);
    } else {
      final GraphicsConfig config = new GraphicsConfig(g);
      g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
      g2d.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_DEFAULT);
      g2d.setPaint(
          UIUtil.getGradientPaint(
              width / 2,
              y + yOff + 1,
              Gray._80.withAlpha(90),
              width / 2,
              height - 2 * yOff,
              Gray._90.withAlpha(90)));
      // g.drawRoundRect(x + offset + 1, y + yOff + 1, width - 2 * offset, height - 2*yOff, 5, 5);

      ((Graphics2D) g).setPaint(Gray._100.withAlpha(180));
      g.drawRoundRect(
          x + offset,
          y + yOff,
          width - 2 * offset,
          height - 2 * yOff,
          JBUI.scale(square ? 3 : 5),
          JBUI.scale(square ? 3 : 5));

      config.restore();
    }
  }
  private void createPropertiesPanel() {
    myPropertiesPanel = new JPanel(new BorderLayout());
    final JPanel emptyPanel = new JPanel();
    emptyPanel.setMinimumSize(JBUI.emptySize());
    emptyPanel.setPreferredSize(JBUI.emptySize());

    myPropertiesPanelWrapper = new JPanel(new CardLayout());
    myPropertiesPanel.setBorder(new CustomLineBorder(1, 0, 0, 0));
    myPropertiesPanelWrapper.add(EMPTY_CARD, emptyPanel);
    myPropertiesPanelWrapper.add(PROPERTIES_CARD, myPropertiesPanel);
  }
  public MavenProjectImportStep(WizardContext wizardContext) {
    super(wizardContext);

    myImportingSettingsForm =
        new MavenImportingSettingsForm(true, wizardContext.isCreatingNewProject()) {
          public String getDefaultModuleDir() {
            return myRootPathComponent.getPath();
          }
        };

    myRootPathComponent =
        new NamePathComponent(
            "",
            ProjectBundle.message("maven.import.label.select.root"),
            ProjectBundle.message("maven.import.title.select.root"),
            "",
            false,
            false);

    JButton envSettingsButton =
        new JButton(ProjectBundle.message("maven.import.environment.settings"));
    envSettingsButton.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            ShowSettingsUtil.getInstance()
                .editConfigurable(myPanel, new MavenEnvironmentConfigurable());
          }
        });

    myPanel = new JPanel(new GridBagLayout());
    myPanel.setBorder(BorderFactory.createEtchedBorder());

    GridBagConstraints c = new GridBagConstraints();
    c.gridx = 0;
    c.gridy = 0;
    c.weightx = 1;
    c.fill = GridBagConstraints.HORIZONTAL;
    c.insets = JBUI.insets(4, 4, 0, 4);

    myPanel.add(myRootPathComponent, c);

    c.gridy = 1;
    c.insets = JBUI.insets(4, 4, 0, 4);
    myPanel.add(myImportingSettingsForm.createComponent(), c);

    c.gridy = 2;
    c.fill = GridBagConstraints.NONE;
    c.anchor = GridBagConstraints.NORTHEAST;
    c.weighty = 1;
    c.insets = JBUI.insets(4 + envSettingsButton.getPreferredSize().height, 4, 4, 4);
    myPanel.add(envSettingsButton, c);

    myRootPathComponent.setNameComponentVisible(false);
  }
  @Override
  protected void init() {
    super.init();

    myPanel.setLayout(new GridBagLayout());
    initTables();

    myTreeTable = createOptionsTree(getSettings());
    myTreeTable.setBackground(UIUtil.getPanelBackground());
    myTreeTable.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 10));
    JBScrollPane scrollPane =
        new JBScrollPane(myTreeTable) {
          @Override
          public Dimension getMinimumSize() {
            return super.getPreferredSize();
          }
        };
    myPanel.add(
        scrollPane,
        new GridBagConstraints(
            0,
            0,
            1,
            1,
            0,
            1,
            GridBagConstraints.CENTER,
            GridBagConstraints.BOTH,
            JBUI.emptyInsets(),
            0,
            0));

    final JPanel previewPanel = createPreviewPanel();
    myPanel.add(
        previewPanel,
        new GridBagConstraints(
            1,
            0,
            1,
            1,
            1,
            1,
            GridBagConstraints.CENTER,
            GridBagConstraints.BOTH,
            JBUI.emptyInsets(),
            0,
            0));

    installPreviewPanel(previewPanel);
    addPanelToWatch(myPanel);

    isFirstUpdate = false;
    customizeSettings();
  }
  @Override
  public UIDefaults getDefaults() {
    try {
      final Method superMethod = BasicLookAndFeel.class.getDeclaredMethod("getDefaults");
      superMethod.setAccessible(true);
      final UIDefaults metalDefaults = (UIDefaults) superMethod.invoke(new MetalLookAndFeel());

      final UIDefaults defaults = (UIDefaults) superMethod.invoke(base);
      if (SystemInfo.isLinux) {
        if (!Registry.is("darcula.use.native.fonts.on.linux")) {
          Font font = findFont("DejaVu Sans");
          if (font != null) {
            for (Object key : defaults.keySet()) {
              if (key instanceof String && ((String) key).endsWith(".font")) {
                defaults.put(key, new FontUIResource(font.deriveFont(13f)));
              }
            }
          }
        } else if (Arrays.asList("CN", "JP", "KR", "TW")
            .contains(Locale.getDefault().getCountry())) {
          for (Object key : defaults.keySet()) {
            if (key instanceof String && ((String) key).endsWith(".font")) {
              final Font font = defaults.getFont(key);
              if (font != null) {
                defaults.put(key, new FontUIResource("Dialog", font.getStyle(), font.getSize()));
              }
            }
          }
        }
      }

      LafManagerImpl.initInputMapDefaults(defaults);
      initIdeaDefaults(defaults);
      patchStyledEditorKit(defaults);
      patchComboBox(metalDefaults, defaults);
      defaults.remove("Spinner.arrowButtonBorder");
      defaults.put("Spinner.arrowButtonSize", JBUI.size(16, 5).asUIResource());
      MetalLookAndFeel.setCurrentTheme(createMetalTheme());
      if (SystemInfo.isWindows && Registry.is("ide.win.frame.decoration")) {
        JFrame.setDefaultLookAndFeelDecorated(true);
        JDialog.setDefaultLookAndFeelDecorated(true);
      }
      if (SystemInfo.isLinux && JBUI.isHiDPI()) {
        applySystemFonts(defaults);
      }
      defaults.put("EditorPane.font", defaults.getFont("TextField.font"));
      return defaults;
    } catch (Exception e) {
      log(e);
    }
    return super.getDefaults();
  }
    private JComponent createActionPanel() {
      JPanel actions = new NonOpaquePanel();
      actions.setBorder(JBUI.Borders.emptyLeft(10));
      actions.setLayout(new BoxLayout(actions, BoxLayout.Y_AXIS));
      ActionManager actionManager = ActionManager.getInstance();
      ActionGroup quickStart =
          (ActionGroup) actionManager.getAction(IdeActions.GROUP_WELCOME_SCREEN_QUICKSTART);
      DefaultActionGroup group = new DefaultActionGroup();
      collectAllActions(group, quickStart);

      for (AnAction action : group.getChildren(null)) {
        JPanel button = new JPanel(new BorderLayout());
        button.setOpaque(false);
        button.setBorder(JBUI.Borders.empty(8, 20));
        AnActionEvent e =
            AnActionEvent.createFromAnAction(
                action,
                null,
                ActionPlaces.WELCOME_SCREEN,
                DataManager.getInstance().getDataContext(this));
        action.update(e);
        Presentation presentation = e.getPresentation();
        if (presentation.isVisible()) {
          String text = presentation.getText();
          if (text != null && text.endsWith("...")) {
            text = text.substring(0, text.length() - 3);
          }
          Icon icon = presentation.getIcon();
          if (icon.getIconHeight() != JBUI.scale(16) || icon.getIconWidth() != JBUI.scale(16)) {
            icon = JBUI.emptyIcon(16);
          }
          action = wrapGroups(action);
          ActionLink link = new ActionLink(text, icon, action, createUsageTracker(action));
          link.setPaintUnderline(false);
          link.setNormalColor(getLinkNormalColor());
          button.add(link);
          if (action instanceof WelcomePopupAction) {
            button.add(createArrow(link), BorderLayout.EAST);
          }
          installFocusable(button, action, KeyEvent.VK_UP, KeyEvent.VK_DOWN, true);
          actions.add(button);
        }
      }

      WelcomeScreenActionsPanel panel = new WelcomeScreenActionsPanel();
      panel.actions.add(actions);
      return panel.root;
    }
  private void updateSystemIcon() {
    Window window = getWindow();
    if (window == null) {
      mySystemIcon = null;
      return;
    }

    List<Image> icons = window.getIconImages();
    assert icons != null;

    if (icons.size() == 0) {
      mySystemIcon = null;
    } else if (icons.size() == 1) {
      mySystemIcon = icons.get(0);
    } else {
      final JBDimension size = JBUI.size(32);
      final Image image = icons.get(0);
      mySystemIcon =
          Scalr.resize(
              ImageUtil.toBufferedImage(image),
              Scalr.Method.ULTRA_QUALITY,
              size.width,
              size.height);
    }
  }
  ShortcutFilteringPanel() {
    super(new VerticalLayout(JBUI.scale(2)));

    myKeyboardPanel.myFirstStroke.setColumns(13);
    myKeyboardPanel.myFirstStroke.putClientProperty("JTextField.variant", "search");
    myKeyboardPanel.mySecondStroke.setColumns(13);
    myKeyboardPanel.mySecondStroke.putClientProperty("JTextField.variant", "search");
    myKeyboardPanel.mySecondStroke.setVisible(false);
    myKeyboardPanel.mySecondStrokeEnable.setText(
        KeyMapBundle.message("filter.enable.second.stroke.checkbox"));
    myKeyboardPanel.mySecondStrokeEnable.addChangeListener(myChangeListener);
    myKeyboardPanel.add(VerticalLayout.TOP, myKeyboardPanel.myFirstStroke);
    myKeyboardPanel.add(VerticalLayout.TOP, myKeyboardPanel.mySecondStrokeEnable);
    myKeyboardPanel.add(VerticalLayout.TOP, myKeyboardPanel.mySecondStroke);
    myKeyboardPanel.addPropertyChangeListener("shortcut", myPropertyListener);
    myKeyboardPanel.setBorder(JBUI.Borders.empty(4));

    JLabel label = new JLabel(KeyMapBundle.message("filter.mouse.pad.label"));
    label.setOpaque(false);
    label.setIcon(AllIcons.General.MouseShortcut);
    label.setForeground(MouseShortcutPanel.FOREGROUND);
    label.setBorder(JBUI.Borders.empty(14, 4));
    myMousePanel.add(BorderLayout.CENTER, label);
    myMousePanel.addPropertyChangeListener("shortcut", myPropertyListener);
    myMousePanel.setBorder(JBUI.Borders.customLine(MouseShortcutPanel.BORDER, 1, 0, 0, 0));

    add(VerticalLayout.TOP, myKeyboardPanel);
    add(VerticalLayout.TOP, myMousePanel);
    addPropertyChangeListener("shortcut", myPropertyListener);
  }
  public VcsLogGraphTable(
      @NotNull VcsLogUiImpl UI,
      @NotNull final VcsLogDataHolder logDataHolder,
      @NotNull VisiblePack initialDataPack) {
    super();
    myUI = UI;
    myLogDataHolder = logDataHolder;
    myGraphCommitCellRenderer = new GraphCommitCellRender(logDataHolder, myGraphCellPainter, this);

    setDefaultRenderer(VirtualFile.class, new RootCellRenderer(myUI));
    setDefaultRenderer(GraphCommitCell.class, myGraphCommitCellRenderer);
    setDefaultRenderer(String.class, new StringCellRenderer());

    setShowHorizontalLines(false);
    setIntercellSpacing(JBUI.emptySize());

    MouseAdapter mouseAdapter = new MyMouseAdapter();
    addMouseMotionListener(mouseAdapter);
    addMouseListener(mouseAdapter);
    MyHeaderMouseAdapter headerAdapter = new MyHeaderMouseAdapter();
    getTableHeader().addMouseListener(headerAdapter);
    getTableHeader().addMouseMotionListener(headerAdapter);

    getTableHeader().setReorderingAllowed(false);

    PopupHandler.installPopupHandler(
        this, VcsLogActionPlaces.POPUP_ACTION_GROUP, VcsLogActionPlaces.VCS_LOG_TABLE_PLACE);
    ScrollingUtil.installActions(this, false);

    GraphTableModel model = new GraphTableModel(initialDataPack, myLogDataHolder, myUI);
    setModel(model);
    initColumnSize();
  }
 private static void readFontSettings(
     @NotNull Element element, @NotNull FontPreferences preferences, boolean isDefaultScheme) {
   List children = element.getChildren(OPTION_ELEMENT);
   String fontFamily = null;
   int size = -1;
   for (Object child : children) {
     Element e = (Element) child;
     if (EDITOR_FONT_NAME.equals(e.getAttributeValue(NAME_ATTR))) {
       fontFamily = getValue(e);
     } else if (EDITOR_FONT_SIZE.equals(e.getAttributeValue(NAME_ATTR))) {
       try {
         size = Integer.parseInt(getValue(e));
         if (isDefaultScheme) {
           size = JBUI.scale(size);
         }
       } catch (NumberFormatException ex) {
         // ignore
       }
     }
   }
   if (fontFamily != null && size > 1) {
     preferences.register(fontFamily, size);
   } else if (fontFamily != null) {
     preferences.addFontFamily(fontFamily);
   }
 }
 private static int parseFontSize(String value, boolean isDefault) {
   int size = Integer.parseInt(value);
   if (isDefault) {
     size = JBUI.scaleFontSize(size);
   }
   return size;
 }
 private JComponent createRecentProjects() {
   JPanel panel = new JPanel(new BorderLayout());
   panel.add(new NewRecentProjectPanel(this), BorderLayout.CENTER);
   panel.setBackground(getProjectsBackground());
   panel.setBorder(new CustomLineBorder(getSeparatorColor(), JBUI.insetsRight(1)));
   return panel;
 }
 private void patchLafFonts(UIDefaults uiDefaults) {
   // if (JBUI.isHiDPI()) {
   //  HashMap<Object, Font> newFonts = new HashMap<Object, Font>();
   //  for (Object key : uiDefaults.keySet().toArray()) {
   //    Object val = uiDefaults.get(key);
   //    if (val instanceof Font) {
   //      newFonts.put(key, JBFont.create((Font)val));
   //    }
   //  }
   //  for (Map.Entry<Object, Font> entry : newFonts.entrySet()) {
   //    uiDefaults.put(entry.getKey(), entry.getValue());
   //  }
   // } else
   UISettings uiSettings = UISettings.getInstance();
   if (uiSettings.OVERRIDE_NONIDEA_LAF_FONTS) {
     storeOriginalFontDefaults(uiDefaults);
     JBUI.setScaleFactor(uiSettings.FONT_SIZE / 12f);
     initFontDefaults(
         uiDefaults,
         uiSettings.FONT_SIZE,
         new FontUIResource(uiSettings.FONT_FACE, Font.PLAIN, uiSettings.FONT_SIZE));
   } else {
     restoreOriginalFontDefaults(uiDefaults);
   }
 }
Beispiel #18
0
    @Override
    protected void paintComponent(Graphics g) {
      super.paintComponent(g);

      int count = getComponentCount() - 1;
      if (count > 0) {
        int x2 = getWidth() - JBUI.scale(16);
        int y = 0;

        g.setColor(new JBColor(0xD0D0D0, 0x717375));

        for (int i = 0; i < count; i++) {
          Dimension size = getComponent(i).getPreferredSize();
          y += size.height + 1;
          g.drawLine(JBUI.scale(16), y, x2, y);
        }
      }
    }
  private void paintCaret(Graphics2D g_) {
    EditorImpl.CaretRectangle[] locations = myEditor.getCaretLocations(true);
    if (locations == null) return;

    Graphics2D g = IdeBackgroundUtil.getOriginalGraphics(g_);
    int lineHeight = myView.getLineHeight();
    EditorSettings settings = myEditor.getSettings();
    Color caretColor = myEditor.getColorsScheme().getColor(EditorColors.CARET_COLOR);
    if (caretColor == null) caretColor = new JBColor(CARET_DARK, CARET_LIGHT);
    g.setColor(caretColor);
    for (EditorImpl.CaretRectangle location : locations) {
      int x = location.myPoint.x;
      int y = location.myPoint.y;
      Caret caret = location.myCaret;
      boolean isRtl = location.myIsRtl;
      if (myEditor.isInsertMode() != settings.isBlockCursor()) {
        int lineWidth = JBUI.scale(settings.getLineCursorWidth());
        g.fillRect(x, y, lineWidth, lineHeight);
        if (myDocument.getTextLength() > 0
            && caret != null
            && !myView.getLineLayout(caret.getLogicalPosition().line).isLtr()) {
          g.fillPolygon(
              new int[] {
                isRtl ? x + lineWidth : x,
                isRtl ? x + lineWidth - CARET_DIRECTION_MARK_SIZE : x + CARET_DIRECTION_MARK_SIZE,
                isRtl ? x + lineWidth : x
              },
              new int[] {y, y, y + CARET_DIRECTION_MARK_SIZE},
              3);
        }
      } else {
        int width = location.myWidth;
        int startX = Math.max(0, isRtl ? x - width : x);
        g.fillRect(startX, y, width, lineHeight - 1);
        if (myDocument.getTextLength() > 0 && caret != null) {
          int targetVisualColumn = caret.getVisualPosition().column;
          for (VisualLineFragmentsIterator.Fragment fragment :
              VisualLineFragmentsIterator.create(myView, caret.getVisualLineStart(), false)) {
            int startVisualColumn = fragment.getStartVisualColumn();
            int endVisualColumn = fragment.getEndVisualColumn();
            if (startVisualColumn < targetVisualColumn && endVisualColumn > targetVisualColumn
                || startVisualColumn == targetVisualColumn && !isRtl
                || endVisualColumn == targetVisualColumn && isRtl) {
              g.setColor(ColorUtil.isDark(caretColor) ? CARET_LIGHT : CARET_DARK);
              fragment.draw(
                  g,
                  startX,
                  y + myView.getAscent(),
                  targetVisualColumn - startVisualColumn - (isRtl ? 1 : 0),
                  targetVisualColumn - startVisualColumn + (isRtl ? 0 : 1));
              break;
            }
          }
        }
      }
    }
  }
 private void setFixedColumnWidth(final int columnIndex, String sampleText) {
   final TableColumn column =
       myEntryTable.getTableHeader().getColumnModel().getColumn(columnIndex);
   final FontMetrics fontMetrics = myEntryTable.getFontMetrics(myEntryTable.getFont());
   final int width = fontMetrics.stringWidth(" " + sampleText + " ") + JBUI.scale(4);
   column.setPreferredWidth(width);
   column.setMinWidth(width);
   column.setResizable(false);
 }
  protected JComponent createNorthPanel() {
    myNameField = new NameSuggestionsField(myProject);
    myNameChangedListener =
        new NameSuggestionsField.DataChanged() {
          public void dataChanged() {
            updateOkStatus();
          }
        };
    myNameField.addDataChangedListener(myNameChangedListener);

    JPanel panel = new JPanel(new GridBagLayout());
    GridBagConstraints gbConstraints = new GridBagConstraints();

    gbConstraints.insets = JBUI.insets(4);
    gbConstraints.anchor = GridBagConstraints.WEST;
    gbConstraints.fill = GridBagConstraints.BOTH;

    gbConstraints.gridwidth = 1;
    gbConstraints.weightx = 0;
    gbConstraints.weighty = 0;
    gbConstraints.gridx = 0;
    gbConstraints.gridy = 0;
    JLabel type = new JLabel(RefactoringBundle.message("variable.of.type"));
    panel.add(type, gbConstraints);

    gbConstraints.gridx++;
    myTypeSelector = myTypeSelectorManager.getTypeSelector();
    panel.add(myTypeSelector.getComponent(), gbConstraints);

    gbConstraints.gridwidth = 1;
    gbConstraints.weightx = 0;
    gbConstraints.weighty = 0;
    gbConstraints.gridx = 0;
    gbConstraints.gridy = 1;
    JLabel namePrompt = new JLabel(RefactoringBundle.message("name.prompt"));
    namePrompt.setLabelFor(myNameField.getComponent());
    panel.add(namePrompt, gbConstraints);

    gbConstraints.gridwidth = 1;
    gbConstraints.weightx = 1;
    gbConstraints.gridx = 1;
    gbConstraints.gridy = 1;
    panel.add(myNameField.getComponent(), gbConstraints);

    myNameSuggestionsManager =
        new NameSuggestionsManager(
            myTypeSelector,
            myNameField,
            new NameSuggestionsGenerator() {
              public SuggestedNameInfo getSuggestedNameInfo(PsiType type) {
                return IntroduceVariableBase.getSuggestedName(type, myExpression);
              }
            });
    myNameSuggestionsManager.setLabelsFor(type, namePrompt);

    return panel;
  }
 @Nullable
 public static Image loadFromResource(@NonNls @NotNull String path, @NotNull Class aClass) {
   return ImageDescList.create(
           path,
           aClass,
           UIUtil.isUnderDarcula(),
           UIUtil.isRetina() || JBUI.scale(1.0f) >= 1.5f,
           true)
       .load(ImageConverterChain.create().withRetina());
 }
 private void readSettings(Element childNode) {
   String name = childNode.getAttributeValue(NAME_ATTR);
   String value = getValue(childNode);
   if (LINE_SPACING.equals(name)) {
     myLineSpacing = Float.parseFloat(value);
   } else if (EDITOR_FONT_SIZE.equals(name)) {
     setEditorFontSize(JBUI.scale(Integer.parseInt(value)));
   } else if (EDITOR_FONT_NAME.equals(name)) {
     setEditorFontName(value);
   } else if (CONSOLE_LINE_SPACING.equals(name)) {
     setConsoleLineSpacing(Float.parseFloat(value));
   } else if (CONSOLE_FONT_SIZE.equals(name)) {
     setConsoleFontSize(JBUI.scale(Integer.parseInt(value)));
   } else if (CONSOLE_FONT_NAME.equals(name)) {
     setConsoleFontName(value);
   } else if (EDITOR_QUICK_JAVADOC_FONT_SIZE.equals(name)) {
     myQuickDocFontSize = FontSize.valueOf(value);
   }
 }
 private void restoreOriginalFontDefaults(UIDefaults defaults) {
   UIManager.LookAndFeelInfo lf = getCurrentLookAndFeel();
   HashMap<String, Object> lfDefaults = myStoredDefaults.get(lf);
   if (lfDefaults != null) {
     for (String resource : ourPatchableFontResources) {
       defaults.put(resource, lfDefaults.get(resource));
     }
   }
   JBUI.setScaleFactor(JBUI.Fonts.label().getSize() / 12f);
 }
  private JPanel createSignaturePanel() {
    mySignature = new GrMethodSignatureComponent("", myProject);
    myTable =
        new ParameterTablePanel() {
          @Override
          protected void updateSignature() {
            GrIntroduceParameterDialog.this.updateSignature();
          }

          @Override
          protected void doEnterAction() {
            clickDefaultButton();
          }

          @Override
          protected void doCancelAction() {
            GrIntroduceParameterDialog.this.doCancelAction();
          }
        };

    mySignature.setBorder(
        IdeBorderFactory.createTitledBorder(
            GroovyRefactoringBundle.message("signature.preview.border.title"), false));

    Splitter splitter = new Splitter(true);

    splitter.setFirstComponent(myTable);
    splitter.setSecondComponent(mySignature);

    mySignature.setPreferredSize(JBUI.size(500, 100));
    mySignature.setSize(JBUI.size(500, 100));

    splitter.setShowDividerIcon(false);

    final JPanel panel = new JPanel(new BorderLayout());
    panel.add(splitter, BorderLayout.CENTER);
    myForceReturnCheckBox =
        new JCheckBox(UIUtil.replaceMnemonicAmpersand("Use e&xplicit return statement"));
    panel.add(myForceReturnCheckBox, BorderLayout.NORTH);

    return panel;
  }
    private int computeHeight() {
      FontMetrics fm = myRootPane.getFontMetrics(getFont());
      int fontHeight = fm.getHeight();
      fontHeight += 7;
      int iconHeight = 0;
      if (getWindowDecorationStyle() == JRootPane.FRAME) {
        iconHeight = IMAGE_HEIGHT;
      }

      return Math.max(Math.max(fontHeight, iconHeight), JBUI.scale(myIdeMenu == null ? 28 : 36));
    }
  private static DialogBuilder createChangeInfoDialog(
      Project project, @NotNull CCNewProjectPanel panel) {
    DialogBuilder builder = new DialogBuilder(project);

    builder.setTitle(ACTION_TEXT);
    JPanel changeInfoPanel = panel.getMainPanel();
    changeInfoPanel.setMinimumSize(JBUI.size(400, 300));
    builder.setCenterPanel(changeInfoPanel);

    return builder;
  }
  @Override
  protected void paintCheckSign(Graphics2D g, boolean enabled, int w, int h) {
    g.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_PURE);
    g.setStroke(
        new BasicStroke(JBUI.scale(1) * 2.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND));

    g.setPaint(getShadowColor(enabled, true));
    final int x1 = JBUI.scale(5);
    final int y1 = JBUI.scale(9);
    final int x2 = JBUI.scale(7);
    final int y2 = JBUI.scale(11);
    g.drawLine(x1, y1, x2, y2);
    g.drawLine(x2, y2, w - JBUI.scale(2) - 1, JBUI.scale(5));
    g.setPaint(getCheckSignColor(enabled, true));
    g.drawLine(x1, y1 - 2, x2, y2 - 2);
    g.drawLine(x2, y2 - 2, w - JBUI.scale(2) - 1, JBUI.scale(5) - 2);
  }
  private void updateViewerForSelection() {
    if (myAllContents.isEmpty()) return;
    String fullString = getSelectedText();

    if (myViewer != null) {
      EditorFactory.getInstance().releaseEditor(myViewer);
    }

    if (myUseIdeaEditor) {
      myViewer = createIdeaEditor(fullString);
      JComponent component = myViewer.getComponent();
      component.setPreferredSize(JBUI.size(300, 500));
      mySplitter.setSecondComponent(component);
    } else {
      final JTextArea textArea = new JTextArea(fullString);
      textArea.setRows(3);
      textArea.setWrapStyleWord(true);
      textArea.setLineWrap(true);
      textArea.setSelectionStart(0);
      textArea.setSelectionEnd(textArea.getText().length());
      textArea.setEditable(false);
      mySplitter.setSecondComponent(ScrollPaneFactory.createScrollPane(textArea));
    }
    mySplitter.revalidate();
  }
 private void paintTextEffect(
     Graphics2D g, float xFrom, float xTo, int y, Color effectColor, EffectType effectType) {
   int xStart = (int) xFrom;
   int xEnd = (int) xTo;
   g.setColor(effectColor);
   if (effectType == EffectType.LINE_UNDERSCORE) {
     UIUtil.drawLine(g, xStart, y + 1, xEnd, y + 1);
   } else if (effectType == EffectType.BOLD_LINE_UNDERSCORE) {
     int height = JBUI.scale(Registry.intValue("editor.bold.underline.height", 2));
     g.fillRect(xStart, y, xEnd - xStart, height);
   } else if (effectType == EffectType.STRIKEOUT) {
     int y1 = y - myView.getCharHeight() / 2;
     UIUtil.drawLine(g, xStart, y1, xEnd, y1);
   } else if (effectType == EffectType.WAVE_UNDERSCORE) {
     UIUtil.drawWave(g, new Rectangle(xStart, y + 1, xEnd - xStart, myView.getDescent() - 1));
   } else if (effectType == EffectType.BOLD_DOTTED_LINE) {
     UIUtil.drawBoldDottedLine(
         g,
         xStart,
         xEnd,
         SystemInfo.isMac ? y : y + 1,
         myEditor.getBackgroundColor(),
         g.getColor(),
         false);
   }
 }