private void updateDetailsBorder(@Nullable VcsFullCommitDetails data) { if (data == null || !myColorManager.isMultipleRoots()) { myMainContentPanel.setBorder(BorderFactory.createEmptyBorder()); } else { Color color = VcsLogGraphTable.getRootBackgroundColor(data.getRoot(), myColorManager); myMainContentPanel.setBorder(new CompoundBorder(new MatteBorder(0, VcsLogGraphTable.ROOT_INDICATOR_COLORED_WIDTH, 0, 0, color), new MatteBorder(0, VcsLogGraphTable.ROOT_INDICATOR_WHITE_WIDTH, 0, 0, new JBColor(new NotNullProducer<Color>() { @NotNull @Override public Color produce() { return getDetailsBackground(); } })))); } }
@NotNull public static TextFieldWithHistoryWithBrowseButton createTextFieldWithHistoryWithBrowseButton(@Nullable Project project, @NotNull String browseDialogTitle, @NotNull FileChooserDescriptor fileChooserDescriptor, @Nullable NotNullProducer<List<String>> historyProvider) { TextFieldWithHistoryWithBrowseButton textFieldWithHistoryWithBrowseButton = new TextFieldWithHistoryWithBrowseButton(); TextFieldWithHistory textFieldWithHistory = textFieldWithHistoryWithBrowseButton.getChildComponent(); textFieldWithHistory.setHistorySize(-1); textFieldWithHistory.setMinimumAndPreferredWidth(0); if (historyProvider != null) { addHistoryOnExpansion(textFieldWithHistory, historyProvider); } installFileCompletionAndBrowseDialog( project, textFieldWithHistoryWithBrowseButton, browseDialogTitle, fileChooserDescriptor ); return textFieldWithHistoryWithBrowseButton; }
@Override public void paintIcon(Component c, Graphics g, int x, int y) { g.setColor(new JBColor(new NotNullProducer<Color>() { @NotNull @Override public Color produce() { //noinspection UseJBColor return !darkBackground() ? new Color(0xffffcc) : new Color(0x675133); } })); g.fillRect(x, y, getIconWidth(), getIconHeight()); g.setColor(JBColor.GRAY); g.drawRect(x, y, getIconWidth(), getIconHeight()); g.setColor(EditorColorsManager.getInstance().getGlobalScheme().getDefaultForeground()); final Font oldFont = g.getFont(); g.setFont(MNEMONIC_FONT); ((Graphics2D)g).drawString(Character.toString(myMnemonic), x + 3, y + getIconHeight() - 1.5F); g.setFont(oldFont); }
@Nonnull public static BuiltInServer startNioOrOio(int workerCount, int firstPort, int portsCount, boolean tryAnyPort, @Nullable NotNullProducer<ChannelHandler> handler) throws Exception { BuiltInServerThreadFactory threadFactory = new BuiltInServerThreadFactory(); NioEventLoopGroup nioEventLoopGroup; try { nioEventLoopGroup = new NioEventLoopGroup(workerCount, threadFactory); } catch (IllegalStateException e) { Logger.getInstance(BuiltInServer.class).warn(e); return start(new OioEventLoopGroup(1, threadFactory), true, 6942, 50, false, handler); } return start(nioEventLoopGroup, true, firstPort, portsCount, tryAnyPort, handler); }
private void configLintBinField() { configWithDefaults(sasslintBinField); SwingHelper.addHistoryOnExpansion(sasslintBinField.getChildComponent(), new NotNullProducer<List<String>>() { @NotNull public List<String> produce() { List<File> newFiles = SassLintFinder.searchForSassLintExe(getProjectPath()); return FileUtils.toAbsolutePath(newFiles); } }); SwingHelper.installFileCompletionAndBrowseDialog(project, sasslintBinField, "Select Sass Lint Exe", FileChooserDescriptorFactory.createSingleFileNoJarsDescriptor()); }
private void configConfigFileField() { TextFieldWithHistory textFieldWithHistory = configWithDefaults(sassLintConfigFile); SwingHelper.addHistoryOnExpansion(textFieldWithHistory, new NotNullProducer<List<String>>() { @NotNull public List<String> produce() { return SassLintFinder.searchForConfigFiles(getProjectPath()); } }); SwingHelper.installFileCompletionAndBrowseDialog(project, sassLintConfigFile, "Select Sass Lint Config", FileChooserDescriptorFactory.createSingleFileNoJarsDescriptor()); }
private void configNodeField() { TextFieldWithHistory textFieldWithHistory = configWithDefaults(nodeInterpreterField); SwingHelper.addHistoryOnExpansion(textFieldWithHistory, new NotNullProducer<List<String>>() { @NotNull public List<String> produce() { List<File> newFiles = NodeDetectionUtil.listAllPossibleNodeInterpreters(); return FileUtils.toAbsolutePath(newFiles); } }); SwingHelper.installFileCompletionAndBrowseDialog(project, nodeInterpreterField, "Select Node Interpreter", FileChooserDescriptorFactory.createSingleFileNoJarsDescriptor()); }
public HyperlinkLabel(String text) { this(text, PlatformColors.BLUE, new JBColor(new NotNullProducer<Color>() { @NotNull @Override public Color produce() { return UIUtil.getLabelBackground(); } }), PlatformColors.BLUE); }
private JBColor jbColor(final Color regular, final Color dark) { return new JBColor(new NotNullProducer<Color>() { @NotNull @Override public Color produce() { return isDark() ? dark : regular; } }); }
private void paintMacThumb(Graphics g, Rectangle thumbBounds) { if (isMacScrollbarHiddenAndXcodeLikeScrollbar()) return; thumbBounds = getMacScrollBarBounds(thumbBounds, true); Graphics2D g2d = (Graphics2D)g; RenderingHints oldHints = g2d.getRenderingHints(); g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); JBColor baseColor = new JBColor(new NotNullProducer<Color>() { @NotNull @Override public Color produce() { return !isDark() ? Gray._0 : Gray._128; } }); int arc = Math.min(thumbBounds.width, thumbBounds.height); if (alwaysPaintThumb()) { //noinspection UseJBColor g2d.setColor(new Color(baseColor.getRed(), baseColor.getGreen(), baseColor.getBlue(), isDark() ? 100 : 40)); g2d.fillRoundRect(thumbBounds.x, thumbBounds.y, thumbBounds.width, thumbBounds.height, arc, arc); //g2d.drawRoundRect(thumbBounds.x, thumbBounds.y, thumbBounds.width, thumbBounds.height, arc, arc); } if (!myMacScrollbarHidden) { g2d.setColor(adjustColor(baseColor)); g2d.fillRoundRect(thumbBounds.x, thumbBounds.y, thumbBounds.width, thumbBounds.height, arc, arc); } g2d.setRenderingHints(oldHints); }
@NotNull public static JBColor getBackgroundColor(@NotNull final Color baseRootColor) { return new JBColor(new NotNullProducer<Color>() { @NotNull @Override public Color produce() { return ColorUtil.mix(baseRootColor, UIUtil.getTableBackground(), 0.75); } }); }
@NotNull public static JBColor getIndicatorColor(@NotNull final Color baseRootColor) { if (Registry.is("vcs.log.square.labels")) return getBackgroundColor(baseRootColor); return new JBColor(new NotNullProducer<Color>() { @NotNull @Override public Color produce() { if (UIUtil.isUnderDarcula()) return baseRootColor; return ColorUtil.darker(ColorUtil.softer(baseRootColor), 2); } }); }
@NotNull public static BuiltInServer start(int workerCount, int firstPort, int portsCount, boolean tryAnyPort, @Nullable NotNullProducer<ChannelHandler> handler) throws Exception { return start(new NioEventLoopGroup(workerCount, PooledThreadExecutor.INSTANCE), true, firstPort, portsCount, tryAnyPort, handler); }
@NotNull public static BuiltInServer start(@NotNull EventLoopGroup eventLoopGroup, boolean isEventLoopGroupOwner, int firstPort, int portsCount, boolean tryAnyPort, @Nullable NotNullProducer<ChannelHandler> handler) throws Exception { ChannelRegistrar channelRegistrar = new ChannelRegistrar(); ServerBootstrap bootstrap = NettyUtil.nioServerBootstrap(eventLoopGroup); configureChildHandler(bootstrap, channelRegistrar, handler); int port = bind(firstPort, portsCount, tryAnyPort, bootstrap, channelRegistrar); return new BuiltInServer(eventLoopGroup, port, channelRegistrar, isEventLoopGroupOwner); }
static void configureChildHandler(@NotNull ServerBootstrap bootstrap, @NotNull final ChannelRegistrar channelRegistrar, final @Nullable NotNullProducer<ChannelHandler> channelHandler) { final PortUnificationServerHandler portUnificationServerHandler = channelHandler == null ? new PortUnificationServerHandler() : null; bootstrap.childHandler(new ChannelInitializer() { @Override protected void initChannel(Channel channel) throws Exception { channel.pipeline().addLast(channelRegistrar, channelHandler == null ? portUnificationServerHandler : channelHandler.produce()); } }); }
@NotNull public ActivateStatus lock(@NotNull final String[] args) throws Exception { log("enter: lock(config=%s system=%s)", myConfigPath, mySystemPath); return underLocks(new Callable<ActivateStatus>() { @Override public ActivateStatus call() throws Exception { File portMarkerC = new File(myConfigPath, PORT_FILE); File portMarkerS = new File(mySystemPath, PORT_FILE); MultiMap<Integer, String> portToPath = MultiMap.createSmart(); addExistingPort(portMarkerC, myConfigPath, portToPath); addExistingPort(portMarkerS, mySystemPath, portToPath); if (!portToPath.isEmpty()) { for (Map.Entry<Integer, Collection<String>> entry : portToPath.entrySet()) { ActivateStatus status = tryActivate(entry.getKey(), entry.getValue(), args); if (status != ActivateStatus.NO_INSTANCE) { return status; } } } final String[] lockedPaths = {myConfigPath, mySystemPath}; myServer = BuiltInServer.start(1, 6942, 50, false, new NotNullProducer<ChannelHandler>() { @NotNull @Override public ChannelHandler produce() { return new MyChannelInboundHandler(lockedPaths, myActivateListener); } }); byte[] portBytes = Integer.toString(myServer.getPort()).getBytes(CharsetToolkit.UTF8_CHARSET); FileUtil.writeToFile(portMarkerC, portBytes); FileUtil.writeToFile(portMarkerS, portBytes); log("exit: lock(): succeed"); return ActivateStatus.NO_INSTANCE; } }); }
@Override public Color brighter() { if (func != null) { return new JBColor(new NotNullProducer<Color>() { @NotNull @Override public Color produce() { return func.produce().brighter(); } }); } return new JBColor(super.brighter(), getDarkVariant().brighter()); }
@Override public Color darker() { if (func != null) { return new JBColor(new NotNullProducer<Color>() { @NotNull @Override public Color produce() { return func.produce().darker(); } }); } return new JBColor(super.darker(), getDarkVariant().darker()); }
public static Color foreground() { return new JBColor(new NotNullProducer<Color>() { @NotNull @Override public Color produce() { return UIUtil.getLabelForeground(); } }); }
public static Color background() { return new JBColor(new NotNullProducer<Color>() { @NotNull @Override public Color produce() { return UIUtil.getListBackground(); } }); }
public static Color border() { return new JBColor(new NotNullProducer<Color>() { @NotNull @Override public Color produce() { //noinspection deprecation return UIUtil.getBorderColor(); } }); }
public static TextAttributes getNormalAttributes() { TextAttributes attributes = EditorColorsManager.getInstance().getGlobalScheme().getAttributes(DebuggerColors.INLINED_VALUES); if (attributes == null || attributes.getForegroundColor() == null) { return new TextAttributes(new JBColor(new NotNullProducer<Color>() { @SuppressWarnings("UseJBColor") @NotNull @Override public Color produce() { return isDarkEditor() ? new Color(0x3d8065) : Gray._135; } }), null, null, null, Font.ITALIC); } return attributes; }
public static TextAttributes getChangedAttributes() { TextAttributes attributes = EditorColorsManager.getInstance().getGlobalScheme().getAttributes(DebuggerColors.INLINED_VALUES_MODIFIED); if (attributes == null || attributes.getForegroundColor() == null) { return new TextAttributes(new JBColor(new NotNullProducer<Color>() { @SuppressWarnings("UseJBColor") @NotNull @Override public Color produce() { return isDarkEditor() ? new Color(0xa1830a) : new Color(0xca8021); } }), null, null, null, Font.ITALIC); } return attributes; }
public static JBColor getGutterColor() { return new JBColor(new NotNullProducer<Color>() { @NotNull @Override public Color produce() { Color color = EditorColorsManager.getInstance().getGlobalScheme().getColor(EditorColors.GUTTER_BACKGROUND); return color == null ? UIUtil.getPanelBackground() : color; } }); }
private void configRTBinField() { configWithDefaults(rtBinField); SwingHelper.addHistoryOnExpansion(rtBinField.getChildComponent(), new NotNullProducer<List<String>>() { @NotNull public List<String> produce() { List<File> newFiles = RTFinder.searchForRTBin(getProjectPath()); return FileUtils.toAbsolutePath(newFiles); } }); SwingHelper.installFileCompletionAndBrowseDialog(project, rtBinField, "Select React-Templates Cli", FileChooserDescriptorFactory.createSingleFileNoJarsDescriptor()); }
private void configRTBinField() { configWithDefaults(rtBinField); SwingHelper.addHistoryOnExpansion(rtBinField.getChildComponent(), new NotNullProducer<List<String>>() { @NotNull public List<String> produce() { List<File> newFiles = VueFinder.searchForRTBin(getProjectPath()); return FileUtils.toAbsolutePath(newFiles); } }); SwingHelper.installFileCompletionAndBrowseDialog(project, rtBinField, "Select vue cli", FileChooserDescriptorFactory.createSingleFileNoJarsDescriptor()); }
private void configNodeField() { TextFieldWithHistory textFieldWithHistory = configWithDefaults(nodeInterpreterField); SwingHelper.addHistoryOnExpansion(textFieldWithHistory, new NotNullProducer<List<String>>() { @NotNull public List<String> produce() { List<File> newFiles = NodeDetectionUtil.listAllPossibleNodeInterpreters(); return FileUtils.toAbsolutePath(newFiles); } }); SwingHelper.installFileCompletionAndBrowseDialog(project, nodeInterpreterField, "Select Node interpreter", FileChooserDescriptorFactory.createSingleFileNoJarsDescriptor()); }
private void configLintBinField() { configWithDefaults(coffeelintBinField); SwingHelper.addHistoryOnExpansion(coffeelintBinField.getChildComponent(), new NotNullProducer<List<String>>() { @NotNull public List<String> produce() { List<File> newFiles = CoffeeLintFinder.searchForCoffeeLintExe(getProjectPath()); return FileUtils.toAbsolutePath(newFiles); } }); SwingHelper.installFileCompletionAndBrowseDialog(project, coffeelintBinField, "Select CoffeeLint cli", FileChooserDescriptorFactory.createSingleFileNoJarsDescriptor()); }
private void configConfigFileField() { TextFieldWithHistory textFieldWithHistory = configWithDefaults(eslintrcFile); SwingHelper.addHistoryOnExpansion(textFieldWithHistory, new NotNullProducer<List<String>>() { @NotNull public List<String> produce() { return CoffeeLintFinder.searchForConfigFiles(getProjectPath()); } }); SwingHelper.installFileCompletionAndBrowseDialog(project, eslintrcFile, "Select CoffeeLint config", FileChooserDescriptorFactory.createSingleFileNoJarsDescriptor()); }
private void configBinField() { configWithDefaults(jscsBinField); SwingHelper.addHistoryOnExpansion(jscsBinField.getChildComponent(), new NotNullProducer<List<String>>() { @NotNull public List<String> produce() { List<File> newFiles = JscsFinder.searchForJscsBin(getProjectPath()); return FileUtils.toAbsolutePath(newFiles); } }); SwingHelper.installFileCompletionAndBrowseDialog(project, jscsBinField, "Select jscs.js cli", FileChooserDescriptorFactory.createSingleFileNoJarsDescriptor()); }
private void configJscsRcField() { TextFieldWithHistory textFieldWithHistory = configWithDefaults(jscsrcFile); SwingHelper.addHistoryOnExpansion(textFieldWithHistory, new NotNullProducer<List<String>>() { @NotNull public List<String> produce() { return JscsFinder.searchForJscsRCFiles(getProjectPath()); } }); SwingHelper.installFileCompletionAndBrowseDialog(project, jscsrcFile, "Select JSCS config", FileChooserDescriptorFactory.createSingleFileNoJarsDescriptor()); }
private void configESLintBinField() { configWithDefaults(eslintBinField2); SwingHelper.addHistoryOnExpansion(eslintBinField2.getChildComponent(), new NotNullProducer<List<String>>() { @NotNull public List<String> produce() { List<File> newFiles = ESLintFinder.searchForESLintBin(getProjectPath()); return FileUtils.toAbsolutePath(newFiles); } }); SwingHelper.installFileCompletionAndBrowseDialog(project, eslintBinField2, "Select ESLint.js cli", FileChooserDescriptorFactory.createSingleFileNoJarsDescriptor()); }
private void configESLintRulesField() { TextFieldWithHistory textFieldWithHistory = rulesPathField.getChildComponent(); SwingHelper.addHistoryOnExpansion(textFieldWithHistory, new NotNullProducer<List<String>>() { @NotNull public List<String> produce() { return ESLintFinder.tryFindRulesAsString(getProjectPath()); } }); SwingHelper.installFileCompletionAndBrowseDialog(project, rulesPathField, "Select Built in rules", FileChooserDescriptorFactory.createSingleFileNoJarsDescriptor()); }
private void configESLintRcField() { TextFieldWithHistory textFieldWithHistory = configWithDefaults(eslintrcFile); SwingHelper.addHistoryOnExpansion(textFieldWithHistory, new NotNullProducer<List<String>>() { @NotNull public List<String> produce() { return ESLintFinder.searchForESLintRCFiles(getProjectPath()); } }); SwingHelper.installFileCompletionAndBrowseDialog(project, eslintrcFile, "Select ESLint config", FileChooserDescriptorFactory.createSingleFileNoJarsDescriptor()); }