com.intellij.ui.JBColor Java Examples

The following examples show how to use com.intellij.ui.JBColor. 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: YiiStormSettingsPage.java    From yiistorm with MIT License 6 votes vote down vote up
public void checkYiiAppParams() {

        ConfigParser parser = new ConfigParser(YiiStormProjectComponent.getInstance(project));
        if (yiiLitePath.getText().length() > 0) {
            if (parser.testYiiLitePath(yiiLitePath.getText())) {
                yiiLitePath.setBackground(JBColor.GREEN);
                if (yiiConfigPath.getText().length() > 0) {
                    if (parser.testYiiConfigPath(yiiConfigPath.getText())) {
                        yiiConfigPath.setBackground(JBColor.GREEN);
                    } else {
                        yiiConfigPath.setBackground(JBColor.PINK);
                    }
                } else {
                    yiiConfigPath.setBackground(JBColor.background());
                }
            } else {
                yiiLitePath.setBackground(JBColor.PINK);
            }
        } else {
            yiiLitePath.setBackground(JBColor.background());
        }
    }
 
Example #2
Source File: FlutterLogColors.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@NotNull
public static Color forCategory(@NotNull String category) {
  if (category.equals(ERROR_CATEGORY)) {
    return JBColor.red;
  }
  if (category.startsWith("flutter.")) {
    return JBColor.gray;
  }
  if (category.startsWith("runtime.")) {
    return UIUtil.isUnderDarcula() ? JBColor.magenta : JBColor.pink;
  }
  if (category.equals("http")) {
    return JBColor.blue;
  }

  // TODO(pq): add more presets.

  // Default.
  return JBColor.darkGray;
}
 
Example #3
Source File: SMTestRunnerResultsForm.java    From consulo with Apache License 2.0 6 votes vote down vote up
private void updateStatusLabel(final boolean testingFinished) {
  if (myFailedTestCount > 0) {
    myStatusLine.setStatusColor(ColorProgressBar.RED);
  }

  if (testingFinished) {
    if (myTotalTestCount == 0) {
      myStatusLine.setStatusColor(myTestsRootNode.wasLaunched() || !myTestsRootNode.isTestsReporterAttached() ? JBColor.LIGHT_GRAY : ColorProgressBar.RED);
    }
    // else color will be according failed/passed tests
  }

  // launchedAndFinished - is launched and not in progress. If we remove "launched' that onTestingStarted() before
  // initializing will be "launchedAndFinished"
  final boolean launchedAndFinished = myTestsRootNode.wasLaunched() && !myTestsRootNode.isInProgress();
  if (!TestsPresentationUtil.hasNonDefaultCategories(myMentionedCategories)) {
    myStatusLine.formatTestMessage(myTotalTestCount, myFinishedTestCount, myFailedTestCount, myIgnoredTestCount, myTestsRootNode.getDuration(), myEndTime);
  }
  else {
    myStatusLine.setText(TestsPresentationUtil.getProgressStatus_Text(myStartTime, myEndTime, myTotalTestCount, myFinishedTestCount, myFailedTestCount,
                                                                      myMentionedCategories, launchedAndFinished));
  }
}
 
Example #4
Source File: RunAnythingUtil.java    From consulo with Apache License 2.0 6 votes vote down vote up
static JComponent createTitle(@Nonnull String titleText, @Nonnull Color background) {
  JLabel titleLabel = new JLabel(StringUtil.capitalizeWords(titleText, true));
  titleLabel.setFont(getTitleFont());
  titleLabel.setForeground(UIUtil.getLabelDisabledForeground());

  SeparatorComponent separatorComponent = new SeparatorComponent(titleLabel.getPreferredSize().height / 2, new JBColor(Gray._220, Gray._80), null);

  JPanel panel = new JPanel(new BorderLayout());
  panel.add(titleLabel, BorderLayout.WEST);
  panel.add(separatorComponent, BorderLayout.CENTER);

  panel.setBorder(JBUI.Borders.empty(3));
  titleLabel.setBorder(JBUI.Borders.emptyRight(3));

  panel.setBackground(background);
  return panel;
}
 
Example #5
Source File: StringElementListCellRenderer.java    From android-strings-search-plugin with Apache License 2.0 6 votes vote down vote up
@Override
protected void customizeCellRenderer(JList list, Object value, int index, boolean selected, boolean hasFocus) {
    Color bgColor = UIUtil.getListBackground();
    setPaintFocusBorder(hasFocus && UIUtil.isToUseDottedCellBorder());

    if (value instanceof StringElement) {
        StringElement element = (StringElement) value;
        String stringKeyText = "(" + element.getName() + ")";
        String text = new StringEllipsisPolicy().ellipsizeText(element.getValue(), matcher);

        SimpleTextAttributes nameAttributes = new SimpleTextAttributes(Font.PLAIN, list.getForeground());
        SpeedSearchUtil.appendColoredFragmentForMatcher(text, this, nameAttributes, matcher, bgColor, selected);
        // TODO Change icon
        setIcon(AndroidIcons.EmptyFlag);

        append(" " + stringKeyText, new SimpleTextAttributes(Font.PLAIN, JBColor.GRAY));
    }

    setBackground(selected ? UIUtil.getListSelectionBackground() : bgColor);
}
 
Example #6
Source File: NotificationMessageElement.java    From consulo with Apache License 2.0 6 votes vote down vote up
protected void updateStyle(@Nonnull JEditorPane editorPane, @Nullable JTree tree, Object value, boolean selected, boolean hasFocus) {
  final HTMLDocument htmlDocument = (HTMLDocument)editorPane.getDocument();
  final Style style = htmlDocument.getStyleSheet().getStyle(MSG_STYLE);
  if (value instanceof LoadingNode) {
    StyleConstants.setForeground(style, JBColor.GRAY);
  }
  else {
    if (selected) {
      StyleConstants.setForeground(style, hasFocus ? UIUtil.getTreeSelectionForeground() : UIUtil.getTreeTextForeground());
    }
    else {
      StyleConstants.setForeground(style, UIUtil.getTreeTextForeground());
    }
  }

  if (UIUtil.isUnderGTKLookAndFeel() ||
      UIUtil.isUnderNimbusLookAndFeel() && selected && hasFocus ||
      tree != null && tree.getUI() instanceof WideSelectionTreeUI && ((WideSelectionTreeUI)tree.getUI()).isWideSelection()) {
    editorPane.setOpaque(false);
  }
  else {
    editorPane.setOpaque(selected && hasFocus);
  }

  htmlDocument.setCharacterAttributes(0, htmlDocument.getLength(), style, false);
}
 
Example #7
Source File: ProjectSettingsPanel.java    From consulo with Apache License 2.0 6 votes vote down vote up
public TableCellRenderer getRenderer(final ScopeSetting scopeSetting) {
  return new DefaultTableCellRenderer() {
    public Component getTableCellRendererComponent(JTable table,
                                                   Object value,
                                                   boolean isSelected,
                                                   boolean hasFocus,
                                                   int row,
                                                   int column) {
      final Component rendererComponent = super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
      if (!isSelected) {
        final CopyrightProfile profile = myProfilesModel.getAllProfiles().get(scopeSetting.getProfileName());
        setForeground(profile == null ? JBColor.RED : UIUtil.getTableForeground());
      }
      setText(scopeSetting.getProfileName());
      return rendererComponent;
    }
  };
}
 
Example #8
Source File: ConfigurationErrorsComponent.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Override
protected void paintComponent(Graphics g) {
  final Graphics2D g2d = (Graphics2D)g;

  final Rectangle bounds = getBounds();
  final Insets insets = getInsets();

  final GraphicsConfig cfg = new GraphicsConfig(g);
  cfg.setAntialiasing(true);

  final Shape shape = new RoundRectangle2D.Double(insets.left, insets.top, bounds.width - 1 - insets.left - insets.right,
                                                  bounds.height - 1 - insets.top - insets.bottom, 6, 6);
  g2d.setColor(JBColor.WHITE);
  g2d.fill(shape);

  Color bgColor = getBackground();

  g2d.setColor(bgColor);
  g2d.fill(shape);

  g2d.setColor(getBackground().darker());
  g2d.draw(shape);
  cfg.restore();

  super.paintComponent(g);
}
 
Example #9
Source File: HTMLTextPainter.java    From consulo with Apache License 2.0 6 votes vote down vote up
private void writeHeader(@NonNls Writer writer, String title) throws IOException {
  EditorColorsScheme scheme = EditorColorsManager.getInstance().getGlobalScheme();
  writer.write("<html>\r\n");
  writer.write("<head>\r\n");
  writer.write("<title>" + title + "</title>\r\n");
  writer.write("<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\">\r\n");
  writeStyles(writer);
  writer.write("</head>\r\n");
  Color color = scheme.getDefaultBackground();
  if (color==null) color = JBColor.GRAY;
  writer.write("<BODY BGCOLOR=\"#" + Integer.toString(color.getRGB() & 0xFFFFFF, 16) + "\">\r\n");
  writer.write("<TABLE CELLSPACING=0 CELLPADDING=5 COLS=1 WIDTH=\"100%\" BGCOLOR=\"#C0C0C0\" >\r\n");
  writer.write("<TR><TD><CENTER>\r\n");
  writer.write("<FONT FACE=\"Arial, Helvetica\" COLOR=\"#000000\">\r\n");
  writer.write(title + "</FONT>\r\n");
  writer.write("</center></TD></TR></TABLE>\r\n");
  writer.write("<pre>\r\n");
}
 
Example #10
Source File: Bookmark.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Nonnull
private static Image createMnemonicIcon(char cha) {
  int width = AllIcons.Actions.Checked.getWidth();
  int height = AllIcons.Actions.Checked.getHeight();

  return ImageEffects.canvas(width, height, c -> {
    // FIXME [VISTALL] make constant ??
    c.setFillStyle(TargetAWT.from(new JBColor(new Color(0xffffcc), new Color(0x675133))));
    c.fillRect(0, 0, width, height);

    c.setStrokeStyle(StandardColors.GRAY);
    c.rect(0, 0, width, height);
    c.stroke();

    c.setFillStyle(ComponentColors.TEXT);
    c.setFont(FontManager.get().createFont("Monospaced", 11, consulo.ui.font.Font.STYLE_BOLD));
    c.setTextAlign(Canvas2D.TextAlign.center);
    c.setTextBaseline(Canvas2D.TextBaseline.middle);

    c.fillText(Character.toString(cha), width / 2, height / 2 - 2);
  });
}
 
Example #11
Source File: ImageUtils.java    From markdown-image-kit with MIT License 6 votes vote down vote up
/**
 * http://stackoverflow.com/questions/665406/how-to-make-a-color-transparent-in-a-bufferedimage-and-save-as-png
 *
 * @param image the image
 * @return the image
 */
public static Image whiteToTransparent(@NotNull BufferedImage image) {
    ImageFilter filter = new RGBImageFilter() {
        int markerRGB = JBColor.WHITE.getRGB() | 0xFF000000;

        @Override
        public final int filterRGB(int x, int y, int rgb) {
            if ((rgb | 0xFF000000) == markerRGB) {
                // Mark the alpha bits as zero - transparent
                return 0x00FFFFFF & rgb;
            } else {
                // nothing to do
                return rgb;
            }
        }
    };

    ImageProducer ip = new FilteredImageSource(image.getSource(), filter);
    return Toolkit.getDefaultToolkit().createImage(ip);
}
 
Example #12
Source File: FlutterLogColors.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
@NotNull
public static Color forCategory(@NotNull String category) {
  if (category.equals(ERROR_CATEGORY)) {
    return JBColor.red;
  }
  if (category.startsWith("flutter.")) {
    return JBColor.gray;
  }
  if (category.startsWith("runtime.")) {
    return UIUtil.isUnderDarcula() ? JBColor.magenta : JBColor.pink;
  }
  if (category.equals("http")) {
    return JBColor.blue;
  }

  // TODO(pq): add more presets.

  // Default.
  return JBColor.darkGray;
}
 
Example #13
Source File: P4RootConfigPanel.java    From p4ic4idea with Apache License 2.0 6 votes vote down vote up
@Override
public Component getListCellRendererComponent(JList<? extends ConfigProblem> list, ConfigProblem problem,
        int index, boolean isSelected, boolean cellHasFocus) {
    cell.setForeground(problem.isError()
            ? JBColor.RED
            : UIUtil.getTextAreaForeground());

    // > v183 has nice API for this...
    cell.setBackground(
            isSelected
                ? cellHasFocus
                        ? UIUtil.getListUnfocusedSelectionBackground()
                        : UIUtil.getListSelectionBackground()
                : UIUtil.getListBackground()
    );
    cell.setText(problem.getMessage());
    return cell;
}
 
Example #14
Source File: FocusTracesDialog.java    From consulo with Apache License 2.0 6 votes vote down vote up
private void paintBorder() {
  final int row = FocusTracesDialog.this.myRequestsTable.getSelectedRow();
  if (row != -1) {
    final FocusRequestInfo info = FocusTracesDialog.this.myRequests.get(row);
    if (prev != null && prev != info.getComponent()) {
      prev.repaint();
    }
    prev = info.getComponent();
    if (prev != null && prev.isDisplayable()) {
      final Graphics g = prev.getGraphics();
      g.setColor(JBColor.RED);
      final Dimension sz = prev.getSize();
      UIUtil.drawDottedRectangle(g, 1, 1, sz.width - 2, sz.height - 2);
    }
  }
}
 
Example #15
Source File: ModuleDescriptionsComboBox.java    From consulo with Apache License 2.0 6 votes vote down vote up
@Override
public void customize(JList list, ModuleDescription moduleDescription, int index, boolean selected, boolean hasFocus) {
  if (moduleDescription == null) {
    setText(myEmptySelectionText);
  }
  else {
    if (moduleDescription instanceof LoadedModuleDescription) {
      setIcon(AllIcons.Nodes.Module);
      setForeground(null);
    }
    else {
      setIcon(AllIcons.Nodes.Module); //FIXME [VISTALL] another icon?
      setForeground(JBColor.RED);
    }
    setText(moduleDescription.getName());
  }
}
 
Example #16
Source File: ApplyPatchChange.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Nonnull
private Color getStatusColor() {
  switch (myStatus) {
    case ALREADY_APPLIED:
      return JBColor.YELLOW.darker();
    case EXACTLY_APPLIED:
      return new JBColor(new Color(0, 180, 5), new Color(0, 147, 5));
    case NOT_APPLIED:
      return JBColor.RED.darker();
    default:
      throw new IllegalStateException();
  }
}
 
Example #17
Source File: FlatWelcomePanel.java    From consulo with Apache License 2.0 5 votes vote down vote up
@RequiredUIAccess
@Override
@Nonnull
protected JComponent createRightComponent() {
  JPanel panel = new JPanel(new BorderLayout());
  JPanel logoPanel = new JPanel(new BorderLayout());
  logoPanel.setBorder(JBUI.Borders.empty(53, 66, 45, 0));
  AnimatedLogoLabel animatedLogoLabel = new AnimatedLogoLabel(8, false, true);
  animatedLogoLabel.setForeground(MorphColor.ofWithoutCache(() -> {
    if (ApplicationProperties.isInSandbox()) {
      if (StyleManager.get().getCurrentStyle().isDark()) {
        // FIXME [VISTALL] problem. darcula list background and panel background have same color
        return JBColor.LIGHT_GRAY;
      }
      return JBColor.WHITE;
    }
    else {
      return JBColor.GRAY;
    }
  }));
  logoPanel.add(animatedLogoLabel, BorderLayout.CENTER);

  panel.add(logoPanel, BorderLayout.NORTH);
  panel.add(createActionPanel(), BorderLayout.CENTER);
  panel.add(createSettingsAndDocs(), BorderLayout.SOUTH);
  return panel;
}
 
Example #18
Source File: MyCellRender.java    From svgtoandroid with MIT License 5 votes vote down vote up
@Override
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
    this.setText(value.toString());
    if (!dpis.contains(value.toString())) {
        this.setForeground(JBColor.GRAY);
    } else {
        this.setForeground(JBColor.BLACK);
    }
    return this;
}
 
Example #19
Source File: YiiStormSettingsPage.java    From yiistorm with MIT License 5 votes vote down vote up
public void useYiiCompleterDisabledToggle() {
    if (yiiLitePath.getText().length() > 0) {
        checkYiiAppParams();
    }
    boolean filled = !yiiLitePath.getText().isEmpty() && !yiiConfigPath.getText().isEmpty();
    if (filled) {
        filled = yiiLitePath.getBackground().equals(JBColor.GREEN) && yiiConfigPath.getBackground().equals(JBColor.GREEN);
    }
    useYiiCompleter.setEnabled(filled);
    if (!filled) {
        useYiiCompleter.setSelected(false);
    }
}
 
Example #20
Source File: DefaultColorGenerator.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Nonnull
private static JBColor calcColor(int indexColor) {
  int r = indexColor * 200 + 30;
  int g = indexColor * 130 + 50;
  int b = indexColor * 90 + 100;
  try {
    Color color = new Color(rangeFix(r), rangeFix(g), rangeFix(b));
    return new JBColor(color, color);
  }
  catch (IllegalArgumentException a) {
    throw new IllegalArgumentException("indexColor: " + indexColor + " " + r % 256 + " " + (g % 256) + " " + (b % 256));
  }
}
 
Example #21
Source File: CategoryCellRenderer.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Override
public final Component getTableCellRendererComponent(JTable table, @Nullable Object value,
                                                     boolean isSelected, boolean hasFocus, int row, int col) {
  final JPanel panel = new JPanel();
  panel.setLayout(new BoxLayout(panel, BoxLayout.X_AXIS));
  panel.setBackground(JBColor.background());

  if (value instanceof FlutterLogEntry) {
    final FlutterLogEntry entry = (FlutterLogEntry)value;
    final String category = entry.getCategory();
    final JLabel label = new JLabel(" " + category + " ");
    label.setBackground(FlutterLogColors.forCategory(category));
    label.setForeground(JBColor.background());
    label.setOpaque(true);
    panel.add(Box.createHorizontalGlue());
    panel.add(label);
    panel.add(Box.createHorizontalStrut(8));

    final SimpleTextAttributes style = entryModel.style(entry, STYLE_PLAIN);
    if (style.getBgColor() != null) {
      setBackground(style.getBgColor());
      panel.setBackground(style.getBgColor());
    }

    AbstractEntryCellRender.updateEntryBorder(panel, entry, row);
  }

  clear();
  setPaintFocusBorder(hasFocus && table.getCellSelectionEnabled());
  acquireState(table, isSelected, hasFocus, row, col);
  getCellState().updateRenderer(this);

  if (isSelected) {
    panel.setBackground(table.getSelectionBackground());
  }

  return panel;
}
 
Example #22
Source File: DefaultColorGenerator.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Nonnull
@Override
public JBColor getColor(int branchNumber) {
  JBColor color = ourColorMap.get(branchNumber);
  if (color == null) {
    color = calcColor(branchNumber);
    ourColorMap.put(branchNumber, color);
  }
  return color;
}
 
Example #23
Source File: ColorIconMaker.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public Icon getCustomIcon(Color color) {
  if (!iconCache.containsKey(color)) {
    final Icon icon = new Icon() {
      public void paintIcon(Component c, Graphics g, int x, int y) {
        final Graphics2D g2 = (Graphics2D)g.create();

        try {
          GraphicsUtil.setupAAPainting(g2);
          // draw a black and gray grid to use as the background to disambiguate
          // opaque colors from translucent colors.
          g2.setColor(JBColor.white);
          g2.fillRect(x + iconMargin, y + iconMargin, getIconWidth() - iconMargin * 2, getIconHeight() - iconMargin * 2);
          g2.setColor(JBColor.gray);
          g2.fillRect(x + iconMargin, y + iconMargin, getIconWidth() / 2 - iconMargin, getIconHeight() / 2 - iconMargin);
          g2.fillRect(x + getIconWidth() / 2, y + getIconHeight() / 2, getIconWidth() / 2 - iconMargin, getIconHeight() / 2 - iconMargin);
          g2.setColor(color);
          g2.fillRect(x + iconMargin, y + iconMargin, getIconWidth() - iconMargin * 2, getIconHeight() - iconMargin * 2);
          g2.setColor(JBColor.black);
          g2.drawRect(x + iconMargin, y + iconMargin, getIconWidth() - iconMargin * 2, getIconHeight() - iconMargin * 2);
        }
        finally {
          g2.dispose();
        }
      }

      public int getIconWidth() {
        return 22; // TODO(jacob): customize the icon height based on the font size.
      }

      public int getIconHeight() {
        return 22; // TODO(jacob): customize the icon height based on the font size.
      }
    };

    iconCache.put(color, icon);
  }

  return iconCache.get(color);
}
 
Example #24
Source File: SuppressedList.java    From IntelliJ-Key-Promoter-X with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Override
public Component getListCellRendererComponent(JList<? extends StatisticsItem> list, StatisticsItem value, int index, boolean isSelected, boolean cellHasFocus) {
    final Color foreground = list.getForeground();
    final Color background = list.getBackground();
    final String message = KeyPromoterBundle.message(
            "kp.list.suppressed.item",
            value.getShortcut(),
            value.description
    );
    if (isSelected) {
        setBackground(JBColor.GRAY);
    } else {
        setBackground(background);
    }

    setText(message);
    setForeground(foreground);
    setBorder(JBUI.Borders.empty(2, 10));
    if (value.ideaActionID != null && !"".equals(value.ideaActionID)) {
        final AnAction action = ActionManager.getInstance().getAction(value.ideaActionID);

        if (action != null) {
            final Icon icon = action.getTemplatePresentation().getIcon();
            if (icon != null) {
                setIcon(icon);
            } else {
                setIcon(KeyPromoterIcons.KP_ICON);
            }
        }
    }
    return this;
}
 
Example #25
Source File: FlutterProjectStep.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
private void updateSdkField(JTextComponent sdkEditor) {
  FlutterSdk current = FlutterSdk.forPath(sdkEditor.getText());
  Color color = sdkBackgroundColor;
  if (current == null) {
    if (ColorUtil.isDark(sdkBackgroundColor)) {
      color = ColorUtil.darker(JBColor.YELLOW, 5);
    }
    else {
      color = ColorUtil.desaturate(JBColor.YELLOW, 15);
    }
  }
  sdkEditor.setBackground(color);
}
 
Example #26
Source File: TargetExpressionListUi.java    From intellij with Apache License 2.0 5 votes vote down vote up
@Override
public Component getTableCellEditorComponent(
    JTable table, Object value, boolean isSelected, int row, int column) {
  textField =
      new TextFieldWithAutoCompletion<String>(
          project,
          new TargetCompletionProvider(project),
          /* showCompletionHint= */ true,
          /* text= */ (String) value) {
        @Override
        public void addNotify() {
          // base class ignores 'enter' keypress events, causing entire dialog to close without
          // committing changes... fix copied from upstream PsiClassTableCellEditor
          super.addNotify();
          Editor editor = getEditor();
          if (editor == null) {
            return;
          }
          JComponent c = editor.getContentComponent();
          c.getInputMap().put(KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0), "ENTER");
          c.getActionMap()
              .put(
                  "ENTER",
                  new AbstractAction() {
                    @Override
                    public void actionPerformed(ActionEvent e) {
                      stopCellEditing();
                    }
                  });
        }
      };
  textField.setBorder(BorderFactory.createLineBorder(JBColor.BLACK));
  return textField;
}
 
Example #27
Source File: FlutterProjectStep.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
private void updateSdkField(JTextComponent sdkEditor) {
  FlutterSdk current = FlutterSdk.forPath(sdkEditor.getText());
  Color color = sdkBackgroundColor;
  if (current == null) {
    if (ColorUtil.isDark(sdkBackgroundColor)) {
      color = ColorUtil.darker(JBColor.YELLOW, 5);
    }
    else {
      color = ColorUtil.desaturate(JBColor.YELLOW, 15);
    }
  }
  sdkEditor.setBackground(color);
}
 
Example #28
Source File: DialogWrapper.java    From consulo with Apache License 2.0 5 votes vote down vote up
private void appendError(String text) {
  errors.add(text);
  myLabel.setBounds(0, 0, 0, 0);
  StringBuilder sb = new StringBuilder("<html><font color='#" + ColorUtil.toHex(JBColor.RED) + "'>");
  errors.forEach(error -> sb.append("<left>").append(error).append("</left><br/>"));
  sb.append("</font></html>");
  myLabel.setText(sb.toString());
  setVisible(true);
  updateSize();
}
 
Example #29
Source File: LibraryDialog.java    From PackageTemplates with Apache License 2.0 5 votes vote down vote up
public void buildView() {
    setTitle(Localizer.get("title.LibraryDialog"));
    panel.setBackground(JBColor.BLUE);

    tabbedPane = new JBTabbedPane();
    panel.add(tabbedPane, new CC().push().grow());

    initBinaryFilesTab();
    initSecondTab();
}
 
Example #30
Source File: NixIDEASettings.java    From nix-idea with Apache License 2.0 5 votes vote down vote up
NixIDEASettings(@NotNull Project project) {
    this.projectProperties = PropertiesComponent.getInstance(project);

    settings = Arrays.asList((Setting) new ResettableEnvField("NIX_PATH", (TextFriend) new TextComponent(nixPath))
            , (Setting) new ResettableEnvField("NIX_PROFILES", (TextFriend) new TextComponent(nixProfiles))
            , (Setting) new ResettableEnvField("NIX_OTHER_STORES", (TextFriend) new TextComponent(nixOtherStores))
            , (Setting) new ResettableEnvField("NIX_REMOTE", (TextFriend) new TextComponent(nixRemote))
            , (Setting) new ResettableEnvField("NIXPKGS_CONFIG", (TextFriend) new TextComponent(nixPkgsConfig))
            , (Setting) new ResettableEnvField("NIX_CONF_DIR", (TextFriend) new TextComponent(nixConfDir))
            , (Setting) new ResettableEnvField("NIX_USER_PROFILE_DIR", (TextFriend) new TextComponent(nixUserProfileDir))
    );

    final Color originalBackground = nixPath.getBackground();
    nixPath.setInputVerifier(new InputVerifier() {
        @Override
        public boolean verify(JComponent input) {
            JTextField tf = (JTextField) input;
            NixPathVerifier npv = new NixPathVerifier(tf.getText());
            if (npv.verify()) {
                input.setBackground(originalBackground);
                return true;
            } else {
                //Some parts of the paths are inaccessible
                //TODO: change to individual path strikeout
                input.setBackground(JBColor.RED);
                return false;
            }
        }
    });
}