diff --git a/CHANGELOG.md b/CHANGELOG.md index 825e3ddb9..1d855ebb7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,45 @@ # Changelog +## 0.9.4 +- Improvements of Lighter Theme. Now Lighter Theme extends IntelliJ Look And Feel instead of Darcula. +- Fix issues with No Material Theme that triggered some NPEs +- Changed Tree foreground color for Lighter Theme +- Added more UI Icons + +## 0.9.3 +- Fix issue with projects open (https://github.com/mallowigi/material-theme-jetbrains-eap/issues/145) +- Possibly fix issue with 100% CPU (https://github.com/mallowigi/material-theme-jetbrains-eap/issues/143) +- Fix import icon size (https://github.com/mallowigi/material-theme-jetbrains-eap/issues/147) +- Change deprecated color (https://github.com/mallowigi/material-theme-jetbrains-eap/issues/151) +- Improve Disabled Material Theme + +## 0.9.2 +- Fix issue with File colors for Psi Icons +- Fix issue with CPU 100% usage +- Fix issue with breakpoint icon size + +## 0.9.1.2 +- Fix issue with tool window icons in retina +- Add more ui icons + +## 0.9.1 +- Remove uppercase bold tabs as a default and fix issue with project settings persistence +- Revert fix of debugger tab height as it breaks other tabs + +## 0.9.0 +- Add custom accent color configuration +- Add Uppercase bold tabs to look more like MDTabs +- Add Compact Sidebar height configuration +- Reduce minimal length of tabs to 18 +- Add a border to the editor when tabs placement is left or right +- More UI Icons + +## 0.8.1 +- Fix issue with Contrast action button not working +- Fix issues with not themed popups +- Add accent color to non-themed search bars +- Add background color to search result + ## 0.8.0.2 - Fix issue with custom file statuses not being colorable - Themed Material Combobox Action button diff --git a/README.md b/README.md index af7039d05..add6d92cc 100644 --- a/README.md +++ b/README.md @@ -185,18 +185,17 @@ You can customize some plugin features in a Settings Panel under **Settings** -> Active Tab Settings: - *Active Tab Highlight*: Customize active tab indicator color and thickness (works also for the Project View selected row) -- *Bold directories*: Set bold font weight for directories in the Project View - *Tabs Height*: Set a custom height for tabs (between 25 and 60 pixels) +- *Uppercase Bold Tabs*: Set the Editor Tabs in Bold Upper Case Panel Settings: - *Contrast Mode*: Add contrast to some of the IDE's components (currently only the Tabs and Tree) - *Hide Icons*: Hide file icons (you must have Material Icons options on) -- *Compact Sidebar*: Reduce line height between list items in sidebars +- *Custom Sidebar Height*: Set custom line height in Project View (min: 18, max: 30) - *Custom Tree Indent*: Increase or reduce indentation in the sidebar (min: 2, max: 8) +- *Bold directories*: Set bold font weight for directories in the Project View - *Compact Status Bar*: Reduce the height of the status bar (this is the default height) - -Custom Accents: -- *X Accent*: Change the accent color. See section above for details about accents. +- *Custom Accent Color*: Set a custom color for accent color Component Settings: - *Custom Wallpaper*: Set a custom wallpaper for the "no files opened" page @@ -264,6 +263,17 @@ Twitter: [@crmag](https://twitter.com/crmag) **Thanks to [@equinusocio](https://github.com/equinusocio/material-theme) for the inspiration.** +# YourKit + +Performance issues are troubleshooted using: + +[![YourKit](https://www.yourkit.com/images/yklogo.png)](https://www.yourkit.com/java/profiler/) + +YourKit supports open source projects with its full-featured Java Profiler. +YourKit, LLC is the creator of YourKit Java Profiler +and YourKit .NET Profiler, +innovative and intelligent tools for profiling Java and .NET applications. + ## Icon Reference - All file icons have been built using the tools provided by [A File Icon](https://github.com/ihodev/a-file-icon). Great thanks to them! diff --git a/build.gradle b/build.gradle index 613490261..8e5c7dd07 100644 --- a/build.gradle +++ b/build.gradle @@ -83,8 +83,8 @@ intellij { pluginName 'Material Theme' version ideaVersion type 'IU' - downloadSources Boolean.valueOf(sources) - sameSinceUntilBuild Boolean.valueOf(isEAP) + downloadSources false + sameSinceUntilBuild true alternativeIdePath idePath updateSinceUntilBuild = false plugins = ['com.jetbrains.php:172.3317.83', 'yaml','properties', 'CSS', 'JavaScriptLanguage', 'com.jetbrains.twig:172' + diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index b9df82a68..1d3823d5c 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,4 +1,4 @@ -#Thu Jul 20 19:13:56 IDT 2017 +#Wed Aug 30 18:35:42 IDT 2017 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME diff --git a/src/main/java/com/chrisrm/idea/MTConfig.java b/src/main/java/com/chrisrm/idea/MTConfig.java index eea206618..6f769d68a 100644 --- a/src/main/java/com/chrisrm/idea/MTConfig.java +++ b/src/main/java/com/chrisrm/idea/MTConfig.java @@ -52,9 +52,10 @@ public class MTConfig implements PersistentStateComponent { public static final String DEFAULT_BG = "https://raw.githubusercontent" + ".com/mallowigi/material-theme-jetbrains-eap/master/src/main/resources/themes/wall.jpg,60"; + public static final String ACCENT_COLOR = "80CBC4"; // They are public so they can be serialized public MTTheme selectedTheme = MTTheme.DEFAULT; - public String highlightColor; + public String highlightColor = ACCENT_COLOR; public boolean highlightColorEnabled = false; public Integer highlightThickness; public boolean isContrastMode = false; @@ -63,7 +64,7 @@ public class MTConfig implements PersistentStateComponent { public boolean isCustomTreeIndentEnabled = false; public Integer customTreeIndent = 6; - public String accentColor = "80CBC4"; + public String accentColor = ACCENT_COLOR; public String wallpaper = DEFAULT_BG; public boolean wallpaperSet = true; @@ -76,9 +77,11 @@ public class MTConfig implements PersistentStateComponent { public Integer tabsHeight = 42; public boolean isMaterialTheme = true; public boolean themedScrollbars = true; - public boolean isCompactStatusBar; + public boolean isCompactStatusBar = false; public String defaultBackground; + public boolean upperCaseTabs = false; + public int customSidebarHeight = 18; public MTConfig() { final MTTheme theme = this.selectedTheme; @@ -318,6 +321,10 @@ public String getAccentColor() { public void setAccentColor(final String accentColor) { this.accentColor = accentColor; } + + public boolean isAccentColorChanged(final Color customAccentColor) { + return !Objects.equals(this.accentColor, customAccentColor); + } //endregion //region Wallpapers @@ -401,6 +408,18 @@ public void setCompactSidebar(final boolean compactSidebar) { public boolean isCompactSidebarChanged(final boolean compactSidebar) { return this.compactSidebar != compactSidebar; } + + public int getCustomSidebarHeight() { + return customSidebarHeight; + } + + public boolean customSidebarHeightChanged(final Integer customSidebarHeight) { + return this.customSidebarHeight != customSidebarHeight; + } + + public void setCustomSidebarHeight(final Integer customSidebarHeight) { + this.customSidebarHeight = customSidebarHeight; + } //endregion //region Statusbar indicator @@ -471,7 +490,6 @@ public boolean isCustomTreeIndentChanged(final boolean customTreeIndentEnabled) } //endregion - //region Themed Scrollbars public boolean isThemedScrollbars() { return themedScrollbars; @@ -504,7 +522,24 @@ public String getDefaultBackground() { return defaultBackground; } - public void setDefaultBackground(String defaultBackground) { + public void setDefaultBackground(final String defaultBackground) { this.defaultBackground = defaultBackground; } + + //region Uppercase tabs + public boolean isUpperCaseTabs() { + return upperCaseTabs; + } + + public void setIsUpperCaseTabs(final boolean isUpperCaseTabs) { + this.upperCaseTabs = isUpperCaseTabs; + } + + public boolean isUpperCaseTabsChanged(final boolean upperCaseTabs) { + return this.upperCaseTabs != upperCaseTabs; + } + + //endregion + + } diff --git a/src/main/java/com/chrisrm/idea/themes/MTLafComponent.java b/src/main/java/com/chrisrm/idea/MTLafComponent.java similarity index 87% rename from src/main/java/com/chrisrm/idea/themes/MTLafComponent.java rename to src/main/java/com/chrisrm/idea/MTLafComponent.java index 5744ef3e5..07d654522 100644 --- a/src/main/java/com/chrisrm/idea/themes/MTLafComponent.java +++ b/src/main/java/com/chrisrm/idea/MTLafComponent.java @@ -24,9 +24,8 @@ * */ -package com.chrisrm.idea.themes; +package com.chrisrm.idea; -import com.chrisrm.idea.MTConfig; import com.chrisrm.idea.config.BeforeConfigNotifier; import com.chrisrm.idea.config.ConfigNotifier; import com.chrisrm.idea.config.ui.MTForm; @@ -45,9 +44,7 @@ import com.intellij.ui.CaptionPanel; import com.intellij.ui.components.JBPanel; import com.intellij.util.messages.MessageBusConnection; -import com.intellij.util.ui.ScrollUtil; import javassist.*; -import javassist.expr.ConstructorCall; import javassist.expr.ExprEditor; import javassist.expr.MethodCall; import org.jetbrains.annotations.NotNull; @@ -63,7 +60,6 @@ public final class MTLafComponent extends JBPanel implements ApplicationComponen private boolean willRestartIde = false; static { - // patchUIUtil(); hackTitleLabel(); hackIdeaActionButton(); } @@ -87,31 +83,6 @@ public void initComponent() { connect.subscribe(BeforeConfigNotifier.BEFORE_CONFIG_TOPIC, (this::onBeforeSettingsChanged)); } - public static void patchUIUtil() { - // Hack method - try { - final ClassPool cp = new ClassPool(true); - cp.insertClassPath(new ClassClassPath(ScrollUtil.class)); - final CtClass ctClass = cp.get("com.intellij.util.ui.UIUtil"); - final CtMethod ctMethod = ctClass.getDeclaredMethod("drawHeader"); - ctMethod.instrument(new ExprEditor() { - @Override - public void edit(final ConstructorCall c) throws CannotCompileException { - try { - if (c.getConstructor().getLongName().equals("java.awt.Color")) { - c.replace("{ $_ = javax.swing.UIManager.getColor(\"activeCaption\"); }"); - } - } catch (final NotFoundException e) { - e.printStackTrace(); - } - } - }); - ctClass.writeFile(); - } catch (final Exception e) { - e.printStackTrace(); - } - } - /** * For better dialog titles (since I have no idea how to know when dialogs appear, I can't attach events so I'm directly hacking * the source code). I hate doing this. @@ -196,6 +167,23 @@ public void edit(final MethodCall m) throws CannotCompileException { }); ctClass.toClass(); + + final CtClass comboBoxActionButtonClass = cp.get("com.intellij.openapi.actionSystem.ex.ComboBoxAction$ComboBoxButton"); + final CtMethod paint = comboBoxActionButtonClass.getDeclaredMethod("paint"); + paint.instrument(new ExprEditor() { + @Override + public void edit(final MethodCall m) throws CannotCompileException { + if (m.getMethodName().equals("drawRoundRect")) { + m.replace("{ $2 = $4; $5 = 0; $6 = 0; $_ = $proceed($$); }"); + } else if (m.getMethodName().equals("setPaint") && m.getLineNumber() > 454 && m.getLineNumber() < 460) { + final String color = "javax.swing.UIManager.getColor(\"TextField.selectedSeparatorColor\")"; + m.replace("{ $1 = myMouseInside ? " + color + " : com.intellij.ui.Gray._95; $_ = $proceed($$); }"); + } + } + }); + + comboBoxActionButtonClass.toClass(); + } catch (final Exception e) { e.printStackTrace(); } @@ -257,20 +245,6 @@ private void restartIdeIfNecessary(final MTConfig mtConfig, final MTForm form) { } } - /** - * Hack SearchTextField to override SDK's createUI - */ - private static void hackSearchTextField() throws NotFoundException, CannotCompileException { - final ClassPool cp = ClassPool.getDefault(); - cp.insertClassPath(new ClassClassPath(MTTextFieldUI.class)); - - final CtClass darculaClass = cp.get("com.intellij.ide.ui.laf.darcula.ui.DarculaTextFieldUI"); - final CtClass componentClass = cp.get("javax.swing.JComponent"); - final CtMethod createUI = darculaClass.getDeclaredMethod("createUI", new CtClass[]{componentClass}); - createUI.setBody("{ return com.chrisrm.idea.ui.MTTextFieldFactory.newInstance($1); }"); - darculaClass.toClass(); - } - /** * Replace Table headers */ diff --git a/src/main/java/com/chrisrm/idea/MTLightLaf.java b/src/main/java/com/chrisrm/idea/MTLightLaf.java new file mode 100644 index 000000000..f4bf4105a --- /dev/null +++ b/src/main/java/com/chrisrm/idea/MTLightLaf.java @@ -0,0 +1,60 @@ +/* + * The MIT License (MIT) + * + * Copyright (c) 2017 Chris Magnussen and Elior Boukhobza + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + * + */ + +package com.chrisrm.idea; + +import com.chrisrm.idea.utils.PropertiesParser; +import com.intellij.ide.ui.laf.IntelliJLaf; +import org.jetbrains.annotations.NotNull; + +public class MTLightLaf extends IntelliJLaf { + + private final MTTheme theme; + + public MTLightLaf(@NotNull final MTTheme theme) { + super(); + this.theme = theme; + } + + /** + * Get Theme Prefix + */ + @Override + protected String getPrefix() { + return theme.getId(); + } + + /** + * Parse properties value + * + * @param key + * @param value + */ + @Override + protected Object parseValue(final String key, @NotNull final String value) { + return PropertiesParser.parseValue(key, value); + } +} diff --git a/src/main/java/com/chrisrm/idea/MTTheme.java b/src/main/java/com/chrisrm/idea/MTTheme.java index f69cc6e5d..d7e2fdc86 100644 --- a/src/main/java/com/chrisrm/idea/MTTheme.java +++ b/src/main/java/com/chrisrm/idea/MTTheme.java @@ -26,11 +26,13 @@ package com.chrisrm.idea; +import com.chrisrm.idea.utils.MTUiUtils; +import com.intellij.ui.ColorUtil; import com.intellij.util.ObjectUtils; import org.jetbrains.annotations.NotNull; import javax.swing.*; -import javax.swing.plaf.ColorUIResource; +import javax.swing.plaf.*; import java.awt.*; public enum MTTheme { @@ -58,7 +60,11 @@ public int getTreeIndent() { */ @NotNull public Color getBackgroundColor() { - return ObjectUtils.notNull(UIManager.getColor("material.tab.backgroundColor"), new ColorUIResource(0x263238)); + final Color defaultValue = MTUiUtils.getColor( + new ColorUIResource(0x263238), + ObjectUtils.notNull(UIManager.getColor("darcula.background"), new ColorUIResource(0x3c3f41)), + ObjectUtils.notNull(UIManager.getColor("intellijlaf.background"), new ColorUIResource(0xe8e8e8))); + return ObjectUtils.notNull(UIManager.getColor("material.tab.backgroundColor"), defaultValue); } /** @@ -81,7 +87,11 @@ public int getBorderThickness() { */ @NotNull public Color getContrastColor() { - return ObjectUtils.notNull(UIManager.getColor("material.contrast"), new ColorUIResource(0x1E272C)); + final Color defaultValue = MTUiUtils.getColor( + new ColorUIResource(0x1E272C), + ColorUtil.withAlpha(new Color(0x262626), .5), + ColorUtil.withAlpha(new Color(0x262626), .2)); + return ObjectUtils.notNull(UIManager.getColor("material.contrast"), defaultValue); } @NotNull diff --git a/src/main/java/com/chrisrm/idea/themes/MTThemeManager.java b/src/main/java/com/chrisrm/idea/MTThemeManager.java similarity index 83% rename from src/main/java/com/chrisrm/idea/themes/MTThemeManager.java rename to src/main/java/com/chrisrm/idea/MTThemeManager.java index 169dcef75..a1f1e1701 100644 --- a/src/main/java/com/chrisrm/idea/themes/MTThemeManager.java +++ b/src/main/java/com/chrisrm/idea/MTThemeManager.java @@ -24,20 +24,20 @@ * */ -package com.chrisrm.idea.themes; +package com.chrisrm.idea; -import com.chrisrm.idea.MTConfig; -import com.chrisrm.idea.MTLaf; -import com.chrisrm.idea.MTTheme; import com.chrisrm.idea.messages.MaterialThemeBundle; import com.chrisrm.idea.utils.MTUiUtils; import com.chrisrm.idea.utils.UIReplacer; import com.google.common.collect.ImmutableList; import com.intellij.ide.plugins.PluginManager; +import com.intellij.ide.ui.LafManager; import com.intellij.ide.ui.UISettings; import com.intellij.ide.ui.laf.IntelliJLaf; +import com.intellij.ide.ui.laf.IntelliJLookAndFeelInfo; import com.intellij.ide.ui.laf.darcula.DarculaInstaller; import com.intellij.ide.ui.laf.darcula.DarculaLaf; +import com.intellij.ide.ui.laf.darcula.DarculaLookAndFeelInfo; import com.intellij.ide.util.PropertiesComponent; import com.intellij.openapi.actionSystem.impl.ActionToolbarImpl; import com.intellij.openapi.application.ApplicationManager; @@ -57,9 +57,8 @@ import sun.awt.AppContext; import javax.swing.*; -import javax.swing.plaf.FontUIResource; -import javax.swing.text.html.HTMLEditorKit; -import javax.swing.text.html.StyleSheet; +import javax.swing.plaf.*; +import javax.swing.text.html.*; import java.awt.*; import java.lang.reflect.Field; import java.net.URL; @@ -67,11 +66,12 @@ import java.util.Collection; import java.util.List; +import static com.chrisrm.idea.tabs.MTTabsPainterPatcherComponent.BOLD_TABS; import static com.chrisrm.idea.tabs.MTTabsPainterPatcherComponent.TABS_HEIGHT; public final class MTThemeManager { - private static final String[] FONT_RESOURCES = new String[]{ + private static final String[] FONT_RESOURCES = new String[] { "Button.font", "ToggleButton.font", "RadioButton.font", @@ -107,7 +107,7 @@ public final class MTThemeManager { "ToolTip.font", "Tree.font"}; - private static final String[] CONTRASTED_RESOURCES = new String[]{ + private static final String[] CONTRASTED_RESOURCES = new String[] { "Tree.background", "Tree.textBackground", // "Table.background", @@ -152,8 +152,7 @@ public final class MTThemeManager { "ActionToolbar.background" }; - - public static final String[] ACCENT_RESOURCES = new String[]{ + public static final String[] ACCENT_RESOURCES = new String[] { "link.foreground", "ProgressBar.foreground", "RadioButton.darcula.selectionEnabledColor", @@ -172,6 +171,13 @@ public final class MTThemeManager { "Focus.color", "material.tab.borderColor" }; + public static final int DEFAULT_SIDEBAR_HEIGHT = 28; + public static final int DEFAULT_TAB_HEIGHT = 24; + public static final boolean DEFAULT_IS_BOLD_TABS = false; + public static final int DEFAULT_INDENT = 6; + public static final int DEFAULT_FONT_SIZE = 12; + public static final String DEFAULT_FONT = "Roboto"; + public static final int DEFAULT_STATUSBAR_PADDING = 8; private final List editorColorsSchemes; @@ -192,7 +198,6 @@ private static String getSettingsPrefix() { return pluginId == null ? "com.chrisrm.idea.MaterialThemeUI" : pluginId.getIdString(); } - //region Action Toggles public void toggleMaterialDesign() { final MTConfig mtConfig = MTConfig.getInstance(); @@ -250,6 +255,12 @@ public void toggleMaterialIcons() { this.updateFileIcons(); } + public void toggleUpperCaseTabs() { + final MTConfig mtConfig = MTConfig.getInstance(); + mtConfig.setIsUpperCaseTabs(!mtConfig.isUpperCaseTabs()); + mtConfig.fireChanged(); + } + public void toggleStatusBarIndicator() { final MTConfig mtConfig = MTConfig.getInstance(); mtConfig.setIsStatusBarTheme(!mtConfig.isStatusBarTheme()); @@ -280,7 +291,7 @@ public void setStatusBarBorders() { if (component != null) { final IdeStatusBarImpl ideStatusBar = UIUtil.findComponentOfType(component, IdeStatusBarImpl.class); if (ideStatusBar != null) { - ideStatusBar.setBorder(compactSidebar ? JBUI.Borders.empty() : JBUI.Borders.empty(8, 0)); + ideStatusBar.setBorder(compactSidebar ? JBUI.Borders.empty() : JBUI.Borders.empty(DEFAULT_STATUSBAR_PADDING, 0)); } } }); @@ -316,7 +327,14 @@ public void activate(final MTTheme mtTheme) { MTConfig.getInstance().setSelectedTheme(newTheme); try { - UIManager.setLookAndFeel(new MTLaf(newTheme)); + if (newTheme.isDark()) { + LafManager.getInstance().setCurrentLookAndFeel(new DarculaLookAndFeelInfo()); + UIManager.setLookAndFeel(new MTLaf(newTheme)); + } + else { + LafManager.getInstance().setCurrentLookAndFeel(new IntelliJLookAndFeelInfo()); + UIManager.setLookAndFeel(new MTLightLaf(newTheme)); + } JBColor.setDark(newTheme.isDark()); IconLoader.setUseDarkIcons(newTheme.isDark()); @@ -339,10 +357,14 @@ public void activate(final MTTheme mtTheme) { final EditorColorsScheme scheme = EditorColorsManager.getInstance().getScheme(makeActiveScheme); // We need this to update parts of the UI that do not change - DarculaInstaller.uninstall(); - if (newTheme.isDark()) { + if (UIUtil.isUnderDarcula()) { + DarculaInstaller.uninstall(); DarculaInstaller.install(); } + else { + DarculaInstaller.uninstall(); + } + LafManager.getInstance().updateUI(); if (scheme != null) { EditorColorsManager.getInstance().setGlobalScheme(scheme); @@ -365,12 +387,12 @@ public void applyAccents(final boolean reloadUI) { // override for transparency UIManager.put("Focus.color", ColorUtil.toAlpha(accentColorColor, 70)); - if (reloadUI) { - reloadUI(); - } + // if (reloadUI) { + // final MTTheme mtTheme = MTConfig.getInstance().getSelectedTheme(); + // reloadUI(mtTheme); + // } } - private void askForRestart() { final String title = MaterialThemeBundle.message("mt.restartDialog.title"); final String message = MaterialThemeBundle.message("mt.restartDialog.content"); @@ -381,7 +403,6 @@ private void askForRestart() { } } - /** * Completely remove theme * @@ -391,9 +412,10 @@ private void removeTheme(final MTTheme mtTheme) { try { resetContrast(); - if (mtTheme.isDark()) { + if (UIUtil.isUnderDarcula()) { UIManager.setLookAndFeel(new DarculaLaf()); - } else { + } + else { UIManager.setLookAndFeel(new IntelliJLaf()); } @@ -402,11 +424,15 @@ private void removeTheme(final MTTheme mtTheme) { PropertiesComponent.getInstance().unsetValue(getSettingsPrefix() + ".theme"); // We need this to update parts of the UI that do not change - DarculaInstaller.uninstall(); - if (mtTheme.isDark()) { + if (UIUtil.isUnderDarcula()) { + DarculaInstaller.uninstall(); DarculaInstaller.install(); } - } catch (final UnsupportedLookAndFeelException e) { + else { + DarculaInstaller.uninstall(); + } + } + catch (final UnsupportedLookAndFeelException e) { e.printStackTrace(); } } @@ -440,10 +466,11 @@ private void applyFonts() { if (uiSettings.getOverrideLafFonts()) { applyCustomFonts(lookAndFeelDefaults, uiSettings.getFontFace(), uiSettings.getFontSize()); - } else { - final Font roboto = MTUiUtils.findFont("Roboto"); + } + else { + final Font roboto = MTUiUtils.findFont(DEFAULT_FONT); if (roboto != null) { - applyCustomFonts(lookAndFeelDefaults, "Roboto", JBUI.scale(12)); + applyCustomFonts(lookAndFeelDefaults, DEFAULT_FONT, JBUI.scale(DEFAULT_FONT_SIZE)); } } } @@ -465,7 +492,7 @@ private void applyContrast(final boolean reloadUI) { } if (reloadUI) { - reloadUI(); + reloadUI(mtTheme); } } @@ -486,12 +513,12 @@ private void resetContrast() { */ private void applyCustomTreeIndent() { final MTConfig mtConfig = MTConfig.getInstance(); - final int defaultIndent = 6; if (mtConfig.isCustomTreeIndentEnabled) { UIManager.put("Tree.rightChildIndent", mtConfig.customTreeIndent); - } else { - UIManager.put("Tree.rightChildIndent", defaultIndent); + } + else { + UIManager.put("Tree.rightChildIndent", DEFAULT_INDENT); } } //endregion @@ -502,19 +529,20 @@ private void applyCustomTreeIndent() { * Use compact sidebar option */ private void applyCompactSidebar(final boolean reloadUI) { - final boolean compactSidebar = MTConfig.getInstance().isCompactSidebar(); - final int rowHeight = compactSidebar ? JBUI.scale(18) : JBUI.scale(28); + final boolean isCustomSidebarHeight = MTConfig.getInstance().isCompactSidebar(); + final int customSidebarHeight = MTConfig.getInstance().getCustomSidebarHeight(); + final int rowHeight = isCustomSidebarHeight ? JBUI.scale(customSidebarHeight) : JBUI.scale(DEFAULT_SIDEBAR_HEIGHT); UIManager.put("Tree.rowHeight", rowHeight); if (reloadUI) { - reloadUI(); + final MTTheme mtTheme = MTConfig.getInstance().getSelectedTheme(); + reloadUI(mtTheme); } } //endregion //region Accents supports - /** * Override patch style editor kit for custom accent support */ @@ -536,14 +564,15 @@ private void patchStyledEditorKit() { final Field keyField = HTMLEditorKit.class.getDeclaredField("DEFAULT_STYLES_KEY"); keyField.setAccessible(true); AppContext.getAppContext().put(keyField.get(null), styleSheet); - } catch (final Exception ignored) { + } + catch (final Exception ignored) { } } //endregion //region Tabs Height support public void setTabsHeight() { - PropertiesComponent.getInstance().setValue(TABS_HEIGHT, MTConfig.getInstance().getTabsHeight(), 24); + PropertiesComponent.getInstance().setValue(TABS_HEIGHT, MTConfig.getInstance().getTabsHeight(), DEFAULT_TAB_HEIGHT); } public void setTabsHeight(final int newTabsHeight) { @@ -552,33 +581,33 @@ public void setTabsHeight(final int newTabsHeight) { } public void setBoldTabs() { - // Project[] openProjects = ProjectManager.getInstance().getOpenProjects(); - // boolean isBoldTabs = MTConfig.getInstance().getIsBoldTabs(); - // - // for (Project openProject : openProjects) { - // final FileEditorManagerEx manager = FileEditorManagerEx.getInstanceEx(openProject); - // for (final EditorWindow editorWindow : manager.getWindows()) { - // EditorTabbedContainer tabbedPane = editorWindow.getTabbedPane(); - // if (tabbedPane != null) { - // JBTabs tabs = tabbedPane.getTabs(); - // for (int i = 0; i < tabs.getTabCount(); i++) { - // TabInfo tabAt = tabs.getTabAt(i); - // tabAt.setDefaultStyle(isBoldTabs ? SimpleTextAttributes.STYLE_BOLD : SimpleTextAttributes.STYLE_PLAIN); - // } - // } - // } - // } + PropertiesComponent.getInstance().setValue(BOLD_TABS, MTConfig.getInstance().isUpperCaseTabs(), DEFAULT_IS_BOLD_TABS); } //endregion /** * Trigger a reloadUI event + * + * @param mtTheme */ - private void reloadUI() { + private void reloadUI(final MTTheme mtTheme) { try { - UIManager.setLookAndFeel(new MTLaf(MTConfig.getInstance().getSelectedTheme())); + if (mtTheme.isDark()) { + LafManager.getInstance().setCurrentLookAndFeel(new DarculaLookAndFeelInfo()); + UIManager.setLookAndFeel(new MTLaf(mtTheme)); + } + else { + LafManager.getInstance().setCurrentLookAndFeel(new IntelliJLookAndFeelInfo()); + UIManager.setLookAndFeel(new MTLightLaf(mtTheme)); + } applyFonts(); - } catch (final UnsupportedLookAndFeelException e) { + + DarculaInstaller.uninstall(); + if (UIUtil.isUnderDarcula()) { + DarculaInstaller.install(); + } + } + catch (final UnsupportedLookAndFeelException e) { e.printStackTrace(); } } diff --git a/src/main/java/com/chrisrm/idea/actions/MTAbstractTheme.java b/src/main/java/com/chrisrm/idea/actions/MTAbstractThemeAction.java similarity index 58% rename from src/main/java/com/chrisrm/idea/actions/MTAbstractTheme.java rename to src/main/java/com/chrisrm/idea/actions/MTAbstractThemeAction.java index b60f72b51..3b7fb5a24 100644 --- a/src/main/java/com/chrisrm/idea/actions/MTAbstractTheme.java +++ b/src/main/java/com/chrisrm/idea/actions/MTAbstractThemeAction.java @@ -30,24 +30,7 @@ import com.intellij.openapi.actionSystem.AnActionEvent; import com.intellij.openapi.actionSystem.ToggleAction; -public abstract class MTAbstractTheme extends ToggleAction { - public static final String BACKGROUND = ""; // 38, 50, 56 - public static final String FOREGROUND = ""; // 176, 190, 197 - public static final String CARET = ""; // 255, 204, 0 - public static final String BORDER = ""; // 34, 45, 51 - public static final String TEXT = ""; // 96, 125, 139 - public static final String SELECTION_BACKGROUND = ""; // 84, 110, 122 - public static final String SELECTION_FOREGROUND = ""; - public static final String LABEL = ""; // 176, 190, 197 - public static final String SUB_LABEL = ""; // 84, 110, 122 - public static final String DISABLED = ""; // 65, 89, 103 - public static final String SIDEBAR_HEADING = ""; // 207, 216, 220 - public static final String STATUS_LABEL = ""; // 120, 144, 156 - public static final String INPUT_BORDER = ""; //55, 71, 79 - public static final String BUTTON_BACKGROUND = ""; // 44, 60, 65 - public static final String BUTTON_FOREGROUND = ""; // 96, 125, 139 - public static final String BUTTON_SELECTED = ""; // 49, 69, 73 - public static final String ACCENT_COLOR = ""; // 128, 203, 196 +public abstract class MTAbstractThemeAction extends ToggleAction { /** * Set button disabled if material theme is disabled diff --git a/src/main/java/com/chrisrm/idea/actions/MTBiggerTabsAction.java b/src/main/java/com/chrisrm/idea/actions/MTBiggerTabsAction.java index 5eb9fb829..d590027f6 100644 --- a/src/main/java/com/chrisrm/idea/actions/MTBiggerTabsAction.java +++ b/src/main/java/com/chrisrm/idea/actions/MTBiggerTabsAction.java @@ -26,7 +26,7 @@ package com.chrisrm.idea.actions; -import com.chrisrm.idea.themes.MTThemeManager; +import com.chrisrm.idea.MTThemeManager; import com.intellij.openapi.actionSystem.AnAction; import com.intellij.openapi.actionSystem.AnActionEvent; diff --git a/src/main/java/com/chrisrm/idea/actions/MTCompactSidebarAction.java b/src/main/java/com/chrisrm/idea/actions/MTCompactSidebarAction.java index efde6cc71..7b494ca03 100644 --- a/src/main/java/com/chrisrm/idea/actions/MTCompactSidebarAction.java +++ b/src/main/java/com/chrisrm/idea/actions/MTCompactSidebarAction.java @@ -27,7 +27,7 @@ package com.chrisrm.idea.actions; import com.chrisrm.idea.MTConfig; -import com.chrisrm.idea.themes.MTThemeManager; +import com.chrisrm.idea.MTThemeManager; import com.intellij.openapi.actionSystem.AnActionEvent; import com.intellij.openapi.actionSystem.ToggleAction; diff --git a/src/main/java/com/chrisrm/idea/actions/MTCompactStatusBarAction.java b/src/main/java/com/chrisrm/idea/actions/MTCompactStatusBarAction.java index 408ce3e22..2e9232184 100644 --- a/src/main/java/com/chrisrm/idea/actions/MTCompactStatusBarAction.java +++ b/src/main/java/com/chrisrm/idea/actions/MTCompactStatusBarAction.java @@ -27,7 +27,7 @@ package com.chrisrm.idea.actions; import com.chrisrm.idea.MTConfig; -import com.chrisrm.idea.themes.MTThemeManager; +import com.chrisrm.idea.MTThemeManager; import com.intellij.openapi.actionSystem.AnActionEvent; import com.intellij.openapi.actionSystem.ToggleAction; diff --git a/src/main/java/com/chrisrm/idea/actions/MTContrastAction.java b/src/main/java/com/chrisrm/idea/actions/MTContrastAction.java index bdf037683..6f631b633 100644 --- a/src/main/java/com/chrisrm/idea/actions/MTContrastAction.java +++ b/src/main/java/com/chrisrm/idea/actions/MTContrastAction.java @@ -27,7 +27,7 @@ package com.chrisrm.idea.actions; import com.chrisrm.idea.MTConfig; -import com.chrisrm.idea.themes.MTThemeManager; +import com.chrisrm.idea.MTThemeManager; import com.intellij.openapi.actionSystem.AnActionEvent; import com.intellij.openapi.actionSystem.ToggleAction; diff --git a/src/main/java/com/chrisrm/idea/actions/MTDarkerThemeAction.java b/src/main/java/com/chrisrm/idea/actions/MTDarkerThemeAction.java new file mode 100644 index 000000000..b531b5e40 --- /dev/null +++ b/src/main/java/com/chrisrm/idea/actions/MTDarkerThemeAction.java @@ -0,0 +1,44 @@ +/* + * The MIT License (MIT) + * + * Copyright (c) 2017 Chris Magnussen and Elior Boukhobza + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + * + */ + +package com.chrisrm.idea.actions; + +import com.chrisrm.idea.MTConfig; +import com.chrisrm.idea.MTTheme; +import com.chrisrm.idea.MTThemeManager; +import com.intellij.openapi.actionSystem.AnActionEvent; + +public final class MTDarkerThemeAction extends MTAbstractThemeAction { + @Override + public boolean isSelected(final AnActionEvent e) { + return MTConfig.getInstance().getSelectedTheme() == MTTheme.DARKER; + } + + @Override + public void setSelected(final AnActionEvent e, final boolean state) { + MTThemeManager.getInstance().activate(MTTheme.DARKER); + } +} diff --git a/src/main/java/com/chrisrm/idea/actions/MTDefaultThemeAction.java b/src/main/java/com/chrisrm/idea/actions/MTDefaultThemeAction.java new file mode 100644 index 000000000..b6ea303f0 --- /dev/null +++ b/src/main/java/com/chrisrm/idea/actions/MTDefaultThemeAction.java @@ -0,0 +1,44 @@ +/* + * The MIT License (MIT) + * + * Copyright (c) 2017 Chris Magnussen and Elior Boukhobza + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + * + */ + +package com.chrisrm.idea.actions; + +import com.chrisrm.idea.MTConfig; +import com.chrisrm.idea.MTTheme; +import com.chrisrm.idea.MTThemeManager; +import com.intellij.openapi.actionSystem.AnActionEvent; + +public final class MTDefaultThemeAction extends MTAbstractThemeAction { + @Override + public boolean isSelected(final AnActionEvent e) { + return MTConfig.getInstance().getSelectedTheme() == MTTheme.DEFAULT; + } + + @Override + public void setSelected(final AnActionEvent e, final boolean state) { + MTThemeManager.getInstance().activate(MTTheme.DEFAULT); + } +} diff --git a/src/main/java/com/chrisrm/idea/actions/MTDisableComponentsAction.java b/src/main/java/com/chrisrm/idea/actions/MTDisableComponentsAction.java index 8dc3154c8..545ced5cc 100644 --- a/src/main/java/com/chrisrm/idea/actions/MTDisableComponentsAction.java +++ b/src/main/java/com/chrisrm/idea/actions/MTDisableComponentsAction.java @@ -27,7 +27,7 @@ package com.chrisrm.idea.actions; import com.chrisrm.idea.MTConfig; -import com.chrisrm.idea.themes.MTThemeManager; +import com.chrisrm.idea.MTThemeManager; import com.intellij.openapi.actionSystem.AnActionEvent; import com.intellij.openapi.actionSystem.ToggleAction; diff --git a/src/main/java/com/chrisrm/idea/actions/MTDisableThemeAction.java b/src/main/java/com/chrisrm/idea/actions/MTDisableThemeAction.java index 2e5eef28c..7fdc0d048 100644 --- a/src/main/java/com/chrisrm/idea/actions/MTDisableThemeAction.java +++ b/src/main/java/com/chrisrm/idea/actions/MTDisableThemeAction.java @@ -27,7 +27,7 @@ package com.chrisrm.idea.actions; import com.chrisrm.idea.MTConfig; -import com.chrisrm.idea.themes.MTThemeManager; +import com.chrisrm.idea.MTThemeManager; import com.intellij.openapi.actionSystem.AnActionEvent; import com.intellij.openapi.actionSystem.ToggleAction; diff --git a/src/main/java/com/chrisrm/idea/actions/MTHideFileIconsAction.java b/src/main/java/com/chrisrm/idea/actions/MTHideFileIconsAction.java index b94f24141..d0bcf9658 100644 --- a/src/main/java/com/chrisrm/idea/actions/MTHideFileIconsAction.java +++ b/src/main/java/com/chrisrm/idea/actions/MTHideFileIconsAction.java @@ -27,7 +27,7 @@ package com.chrisrm.idea.actions; import com.chrisrm.idea.MTConfig; -import com.chrisrm.idea.themes.MTThemeManager; +import com.chrisrm.idea.MTThemeManager; import com.intellij.openapi.actionSystem.AnActionEvent; import com.intellij.openapi.actionSystem.ToggleAction; diff --git a/src/main/java/com/chrisrm/idea/actions/MTLighterThemeAction.java b/src/main/java/com/chrisrm/idea/actions/MTLighterThemeAction.java new file mode 100644 index 000000000..7f9cdf317 --- /dev/null +++ b/src/main/java/com/chrisrm/idea/actions/MTLighterThemeAction.java @@ -0,0 +1,44 @@ +/* + * The MIT License (MIT) + * + * Copyright (c) 2017 Chris Magnussen and Elior Boukhobza + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + * + */ + +package com.chrisrm.idea.actions; + +import com.chrisrm.idea.MTConfig; +import com.chrisrm.idea.MTTheme; +import com.chrisrm.idea.MTThemeManager; +import com.intellij.openapi.actionSystem.AnActionEvent; + +public final class MTLighterThemeAction extends MTAbstractThemeAction { + @Override + public boolean isSelected(final AnActionEvent e) { + return MTConfig.getInstance().getSelectedTheme() == MTTheme.LIGHTER; + } + + @Override + public void setSelected(final AnActionEvent e, final boolean state) { + MTThemeManager.getInstance().activate(MTTheme.LIGHTER); + } +} diff --git a/src/main/java/com/chrisrm/idea/actions/MTMaterialIconsAction.java b/src/main/java/com/chrisrm/idea/actions/MTMaterialIconsAction.java index 54ba34447..44f116ea0 100644 --- a/src/main/java/com/chrisrm/idea/actions/MTMaterialIconsAction.java +++ b/src/main/java/com/chrisrm/idea/actions/MTMaterialIconsAction.java @@ -27,7 +27,7 @@ package com.chrisrm.idea.actions; import com.chrisrm.idea.MTConfig; -import com.chrisrm.idea.themes.MTThemeManager; +import com.chrisrm.idea.MTThemeManager; import com.intellij.openapi.actionSystem.AnActionEvent; import com.intellij.openapi.actionSystem.ToggleAction; diff --git a/src/main/java/com/chrisrm/idea/actions/MTPalenightThemeAction.java b/src/main/java/com/chrisrm/idea/actions/MTPalenightThemeAction.java new file mode 100644 index 000000000..6752fce92 --- /dev/null +++ b/src/main/java/com/chrisrm/idea/actions/MTPalenightThemeAction.java @@ -0,0 +1,44 @@ +/* + * The MIT License (MIT) + * + * Copyright (c) 2017 Chris Magnussen and Elior Boukhobza + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + * + */ + +package com.chrisrm.idea.actions; + +import com.chrisrm.idea.MTConfig; +import com.chrisrm.idea.MTTheme; +import com.chrisrm.idea.MTThemeManager; +import com.intellij.openapi.actionSystem.AnActionEvent; + +public final class MTPalenightThemeAction extends MTAbstractThemeAction { + @Override + public boolean isSelected(final AnActionEvent e) { + return MTConfig.getInstance().getSelectedTheme() == MTTheme.PALENIGHT; + } + + @Override + public void setSelected(final AnActionEvent e, final boolean state) { + MTThemeManager.getInstance().activate(MTTheme.PALENIGHT); + } +} diff --git a/src/main/java/com/chrisrm/idea/actions/MTToggleProjectViewDecoratorsAction.java b/src/main/java/com/chrisrm/idea/actions/MTToggleProjectViewDecoratorsAction.java index 5e4e939e7..cdbe6eaa3 100644 --- a/src/main/java/com/chrisrm/idea/actions/MTToggleProjectViewDecoratorsAction.java +++ b/src/main/java/com/chrisrm/idea/actions/MTToggleProjectViewDecoratorsAction.java @@ -27,7 +27,7 @@ package com.chrisrm.idea.actions; import com.chrisrm.idea.MTConfig; -import com.chrisrm.idea.themes.MTThemeManager; +import com.chrisrm.idea.MTThemeManager; import com.intellij.openapi.actionSystem.AnActionEvent; import com.intellij.openapi.actionSystem.ToggleAction; diff --git a/src/main/java/com/chrisrm/idea/actions/MTToggleStatusbarIndicatorAction.java b/src/main/java/com/chrisrm/idea/actions/MTToggleStatusbarIndicatorAction.java index 2a157e03f..1958717cd 100644 --- a/src/main/java/com/chrisrm/idea/actions/MTToggleStatusbarIndicatorAction.java +++ b/src/main/java/com/chrisrm/idea/actions/MTToggleStatusbarIndicatorAction.java @@ -27,7 +27,7 @@ package com.chrisrm.idea.actions; import com.chrisrm.idea.MTConfig; -import com.chrisrm.idea.themes.MTThemeManager; +import com.chrisrm.idea.MTThemeManager; import com.intellij.openapi.actionSystem.AnActionEvent; import com.intellij.openapi.actionSystem.ToggleAction; diff --git a/src/main/java/com/chrisrm/idea/actions/MTUpperCaseTabsAction.java b/src/main/java/com/chrisrm/idea/actions/MTUpperCaseTabsAction.java new file mode 100644 index 000000000..0f13ac162 --- /dev/null +++ b/src/main/java/com/chrisrm/idea/actions/MTUpperCaseTabsAction.java @@ -0,0 +1,45 @@ +/* + * The MIT License (MIT) + * + * Copyright (c) 2017 Chris Magnussen and Elior Boukhobza + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + * + */ + +package com.chrisrm.idea.actions; + +import com.chrisrm.idea.MTConfig; +import com.chrisrm.idea.MTThemeManager; +import com.intellij.openapi.actionSystem.AnActionEvent; +import com.intellij.openapi.actionSystem.ToggleAction; + +public final class MTUpperCaseTabsAction extends ToggleAction { + @Override + public boolean isSelected(final AnActionEvent e) { + return MTConfig.getInstance().isUpperCaseTabs(); + } + + @Override + public void setSelected(final AnActionEvent e, final boolean state) { + MTThemeManager.getInstance().toggleUpperCaseTabs(); + + } +} diff --git a/src/main/java/com/chrisrm/idea/actions/accents/MTAbstractAccentAction.java b/src/main/java/com/chrisrm/idea/actions/accents/MTAbstractAccentAction.java index 308019fa2..a7d3949d5 100644 --- a/src/main/java/com/chrisrm/idea/actions/accents/MTAbstractAccentAction.java +++ b/src/main/java/com/chrisrm/idea/actions/accents/MTAbstractAccentAction.java @@ -27,7 +27,7 @@ package com.chrisrm.idea.actions.accents; import com.chrisrm.idea.MTConfig; -import com.chrisrm.idea.themes.MTThemeManager; +import com.chrisrm.idea.MTThemeManager; import com.chrisrm.idea.utils.IconReplacer; import com.intellij.icons.AllIcons; import com.intellij.openapi.actionSystem.AnAction; diff --git a/src/main/java/com/chrisrm/idea/config/MTConfigTopHitProvider.java b/src/main/java/com/chrisrm/idea/config/MTConfigTopHitProvider.java index 2d79a0c73..2912ad127 100644 --- a/src/main/java/com/chrisrm/idea/config/MTConfigTopHitProvider.java +++ b/src/main/java/com/chrisrm/idea/config/MTConfigTopHitProvider.java @@ -51,6 +51,8 @@ public final class MTConfigTopHitProvider extends OptionsTopHitProvider { option(messageIde("mt.materialdesign"), "getIsMaterialDesign", "setIsMaterialDesign"), option(messageIde("mt.boldtabs"), "getIsBoldTabs", "setIsBoldTabs"), option(messageIde("mt.iswallpaperset"), "isWallpaperSet", "setIsWallpaperSet"), + option(messageIde("MTForm.isUpperCaseTabsCheckbox.text"), "isUpperCaseTabs", "setIsUpperCaseTabs"), + option(messageIde("MTForm.customTreeIndentCheckbox.text"), "isCustomTreeIndent", "setIsCustomTreeIndent"), diff --git a/src/main/java/com/chrisrm/idea/config/MTConfigurable.java b/src/main/java/com/chrisrm/idea/config/MTConfigurable.java index 8e91119ae..7e26a3425 100644 --- a/src/main/java/com/chrisrm/idea/config/MTConfigurable.java +++ b/src/main/java/com/chrisrm/idea/config/MTConfigurable.java @@ -30,6 +30,7 @@ import com.chrisrm.idea.config.ui.MTForm; import com.chrisrm.idea.messages.MaterialThemeBundle; import com.intellij.openapi.options.SearchableConfigurable; +import com.intellij.ui.ColorUtil; import org.jetbrains.annotations.Nls; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -82,6 +83,7 @@ protected void setFormState(final MTForm mtForm, final MTConfig mtConfig) { getForm().setCustomWallpaper(mtConfig.getWallpaper()); getForm().setIsCustomTreeIndent(mtConfig.isCustomTreeIndent()); getForm().setCustomTreeIndent(mtConfig.getCustomTreeIndent()); + getForm().setIsUpperCaseTabs(mtConfig.isUpperCaseTabs()); getForm().setIsUseMaterialIcons(mtConfig.isUseMaterialIcons()); getForm().setUseProjectViewDecorators(mtConfig.isUseProjectViewDecorators()); @@ -90,9 +92,12 @@ protected void setFormState(final MTForm mtForm, final MTConfig mtConfig) { getForm().setIsCompactStatusBar(mtConfig.isCompactStatusBar()); getForm().setIsStatusBarTheme(mtConfig.isStatusBarTheme()); getForm().setIsMaterialTheme(mtConfig.isMaterialTheme()); + getForm().setCustomSidebarHeight(mtConfig.getCustomSidebarHeight()); getForm().setIsThemedScrollbars(mtConfig.isThemedScrollbars()); + getForm().setCustomAccentColor(ColorUtil.fromHex(mtConfig.getAccentColor())); + getForm().afterStateSet(); } @@ -111,6 +116,7 @@ protected void doApply(final MTForm mtForm, final MTConfig mtConfig) { mtConfig.setWallpaper(getForm().getWallpaper()); mtConfig.setIsCustomTreeIndent(getForm().isCustomTreeIndent()); mtConfig.setCustomTreeIndent(getForm().getCustomTreeIndent()); + mtConfig.setIsUpperCaseTabs(getForm().isUpperCaseTabs()); mtConfig.setUseMaterialIcons(getForm().isUseMaterialIcons()); mtConfig.setUseProjectViewDecorators(getForm().getUseProjectViewDecorators()); @@ -119,8 +125,10 @@ protected void doApply(final MTForm mtForm, final MTConfig mtConfig) { mtConfig.setIsStatusBarTheme(getForm().isStatusBarTheme()); mtConfig.setIsCompactStatusBar(getForm().isCompactStatusBar()); mtConfig.setIsMaterialTheme(getForm().getIsMaterialTheme()); + mtConfig.setCustomSidebarHeight(getForm().getCustomSidebarHeight()); mtConfig.setThemedScrollbars(getForm().isThemedScrollbars()); + mtConfig.setAccentColor(ColorUtil.toHex(getForm().getCustomAccentColor())); mtConfig.fireChanged(); } @@ -139,6 +147,7 @@ protected boolean checkModified(final MTForm mtForm, final MTConfig mtConfig) { modified = modified || mtConfig.isCustomTreeIndentChanged(getForm().isCustomTreeIndent()); modified = modified || mtConfig.customTreeIndentChanged(getForm().getCustomTreeIndent()); + modified = modified || mtConfig.isUpperCaseTabsChanged(getForm().isUpperCaseTabs()); modified = modified || mtConfig.isMaterialIconsChanged(getForm().isUseMaterialIcons()); modified = modified || mtConfig.isUseProjectViewDecoratorsChanged(getForm().getUseProjectViewDecorators()); @@ -147,8 +156,10 @@ protected boolean checkModified(final MTForm mtForm, final MTConfig mtConfig) { modified = modified || mtConfig.isCompactStatusBarChanged(getForm().isCompactStatusBar()); modified = modified || mtConfig.isStatusBarThemeChanged(getForm().isStatusBarTheme()); modified = modified || mtConfig.isMaterialThemeChanged(getForm().getIsMaterialTheme()); + modified = modified || mtConfig.customSidebarHeightChanged(getForm().getCustomSidebarHeight()); modified = modified || mtConfig.isThemedScrollbarsChanged(getForm().isThemedScrollbars()); + modified = modified || mtConfig.isAccentColorChanged(getForm().getCustomAccentColor()); return modified; diff --git a/src/main/java/com/chrisrm/idea/config/MTOptionContributor.java b/src/main/java/com/chrisrm/idea/config/MTOptionContributor.java index 47a1c8c6e..454877423 100644 --- a/src/main/java/com/chrisrm/idea/config/MTOptionContributor.java +++ b/src/main/java/com/chrisrm/idea/config/MTOptionContributor.java @@ -48,6 +48,8 @@ public void processOptions(@NotNull final SearchableOptionProcessor processor) { displayName, true); processor.addOptions(MaterialThemeBundle.message("mt.boldtabs"), null, displayName, MTConfigurable.ID, displayName, true); + processor.addOptions(MaterialThemeBundle.message("MTForm.isUpperCaseTabsCheckbox.text"), null, displayName, MTConfigurable.ID, + displayName, true); processor.addOptions(MaterialThemeBundle.message("MTForm.tabHeight"), null, displayName, MTConfigurable.ID, displayName, true); processor.addOptions(MaterialThemeBundle.message("mt.iswallpaperset"), null, displayName, MTConfigurable.ID, diff --git a/src/main/java/com/chrisrm/idea/config/scope/MTScopeComponent.java b/src/main/java/com/chrisrm/idea/config/scope/MTScopeComponent.java index af7c698fb..646ebd78b 100644 --- a/src/main/java/com/chrisrm/idea/config/scope/MTScopeComponent.java +++ b/src/main/java/com/chrisrm/idea/config/scope/MTScopeComponent.java @@ -26,10 +26,10 @@ package com.chrisrm.idea.config.scope; -import com.chrisrm.idea.actions.MTDarkerTheme; -import com.chrisrm.idea.actions.MTDefaultTheme; -import com.chrisrm.idea.actions.MTLighterTheme; -import com.chrisrm.idea.actions.MTPalenightTheme; +import com.chrisrm.idea.themes.MTDarkerTheme; +import com.chrisrm.idea.themes.MTDefaultTheme; +import com.chrisrm.idea.themes.MTLighterTheme; +import com.chrisrm.idea.themes.MTPalenightTheme; import com.intellij.openapi.components.AbstractProjectComponent; import com.intellij.openapi.components.ProjectComponent; import com.intellij.openapi.project.Project; @@ -56,7 +56,7 @@ public void initComponent() { * Note: If the scope has changed somehow (by changing the name or the color), it will add a duplicate. */ private void addDisabledFileColors() { - FileColorManager manager = FileColorManager.getInstance(myProject); + final FileColorManager manager = FileColorManager.getInstance(myProject); manager.addScopeColor(MTDefaultNonProjectScope.NAME, MTDefaultTheme.DISABLED, false); manager.addScopeColor(MTDarkerNonProjectScope.NAME, MTDarkerTheme.DISABLED, false); manager.addScopeColor(MTLighterNonProjectScope.NAME, MTLighterTheme.DISABLED, false); diff --git a/src/main/java/com/chrisrm/idea/config/ui/MTForm.java b/src/main/java/com/chrisrm/idea/config/ui/MTForm.java index 678ca69b3..e67a1da6f 100644 --- a/src/main/java/com/chrisrm/idea/config/ui/MTForm.java +++ b/src/main/java/com/chrisrm/idea/config/ui/MTForm.java @@ -50,6 +50,8 @@ public class MTForm implements MTFormUI { private SpinnerModel highlightSpinnerModel; private SpinnerModel tabsHeightSpinnerModel; private SpinnerModel customTreeIndentModel; + private SpinnerModel customSidebarHeightModel; + @Override public JComponent getContent() { @@ -94,19 +96,30 @@ public Integer getCustomTreeIndent() { return (Integer) customTreeIndentModel.getValue(); } - public void setCustomTreeIndent(Integer customTreeIndent) { + public void setCustomTreeIndent(final Integer customTreeIndent) { customTreeIndentModel.setValue(customTreeIndent); } + public Integer getCustomSidebarHeight() { + return (Integer) customSidebarHeightModel.getValue(); + } + + public void setCustomSidebarHeight(final Integer customSidebarHeight) { + customSidebarHeightModel.setValue(customSidebarHeight); + } + + @Override public void init() { - MTConfig config = MTConfig.getInstance(); + final MTConfig config = MTConfig.getInstance(); highlightSpinnerModel = new SpinnerNumberModel(config.getHighlightThickness(), 1, 5, 1); highlightSpinner.setModel(highlightSpinnerModel); - tabsHeightSpinnerModel = new SpinnerNumberModel(config.getTabsHeight(), 25, 60, 1); + tabsHeightSpinnerModel = new SpinnerNumberModel(config.getTabsHeight(), 18, 60, 1); tabHeightSpinner.setModel(tabsHeightSpinnerModel); customTreeIndentModel = new SpinnerNumberModel(config.getCustomTreeIndent(), 2, 8, 2); customIndentSpinner.setModel(customTreeIndentModel); + customSidebarHeightModel = new SpinnerNumberModel(config.getCustomSidebarHeight(), 18, 30, 2); + customSidebarSpinner.setModel(customSidebarHeightModel); } public boolean getIsContrastMode() { @@ -207,14 +220,18 @@ public void setTabsHeight(int tabsHeight) { private ColorPanel activeTabHighlightColor; private JSpinner highlightSpinner; private JButton resetTabDefaultsBtn; - private JCheckBox boldTabs; + private JCheckBox isUpperCaseTabsCheckbox; private JSpinner tabHeightSpinner; private JCheckBox isContrastModeCheckbox; private JCheckBox hideFileIconsCheckbox; private JCheckBox isCompactSidebarCheckbox; + private JSpinner customSidebarSpinner; private JCheckBox customTreeIndentCheckbox; private JSpinner customIndentSpinner; private JCheckBox isCompactStatusbarCheckbox; + private JCheckBox boldTabs; + private JLabel customAccentColorLabel; + private ColorPanel customAccentColorChooser; private JCheckBox isWallpaperSetCheckbox; private JLabel customBgLabel; private TextFieldWithBrowseButton customBgChooser; @@ -254,6 +271,7 @@ public MTForm() { public void setIsCompactSidebar(boolean compactSidebar) { this.isCompactSidebarCheckbox.setSelected(compactSidebar); + enableDisableCustomSidebarHeight(compactSidebar); } public boolean isCompactSidebar() { @@ -280,28 +298,49 @@ public boolean getIsMaterialTheme() { return this.materialThemeCheckbox.isSelected(); } - public void setIsMaterialTheme(boolean materialTheme) { + public void setIsMaterialTheme(final boolean materialTheme) { this.materialThemeCheckbox.setSelected(materialTheme); } - private void enableDisableCustomBg(boolean isWallpaperSet) { + public void setIsUpperCaseTabs(final boolean upperCaseTabs) { + this.isUpperCaseTabsCheckbox.setSelected(upperCaseTabs); + } + + public boolean isUpperCaseTabs() { + return this.isUpperCaseTabsCheckbox.isSelected(); + } + + public void setCustomAccentColor(Color customAccentColor) { + this.customAccentColorChooser.setSelectedColor(customAccentColor); + } + + public Color getCustomAccentColor() { + return this.customAccentColorChooser.getSelectedColor(); + } + + private void enableDisableCustomBg(final boolean isWallpaperSet) { this.customBgLabel.setEnabled(isWallpaperSet); this.customBgChooser.setEnabled(isWallpaperSet); this.customBgRestoreButton.setEnabled(isWallpaperSet); } - private void enableDisableFileIcons(boolean isMaterialIconsSet) { + private void enableDisableFileIcons(final boolean isMaterialIconsSet) { this.hideFileIconsCheckbox.setEnabled(isMaterialIconsSet); } - private void enableDisableCustomTreeIndent(boolean isCustomTreeIndent) { + private void enableDisableCustomTreeIndent(final boolean isCustomTreeIndent) { this.customIndentSpinner.setEnabled(isCustomTreeIndent); } - private void enableDisableActiveTabColor(boolean isCustomTreeIndent) { + private void enableDisableActiveTabColor(final boolean isCustomTreeIndent) { this.activeTabHighlightColor.setEnabled(isCustomTreeIndent); } + private void enableDisableCustomSidebarHeight(final boolean isCustomSidebarHeight) { + this.customSidebarSpinner.setEnabled(isCustomSidebarHeight); + } + + //region Events - Actions Listeners /** @@ -328,6 +367,10 @@ private void customTreeIndentCheckboxActionPerformed(ActionEvent e) { private void activeTabHighlightCheckboxActionPerformed(ActionEvent e) { enableDisableActiveTabColor(this.activeTabHighlightCheckbox.isSelected()); } + + private void isCompactSidebarCheckboxActionPerformed(ActionEvent e) { + enableDisableCustomSidebarHeight(this.isCompactSidebarCheckbox.isSelected()); + } //endregion private void initComponents() { @@ -341,7 +384,7 @@ private void initComponents() { JLabel label1 = new JLabel(); highlightSpinner = new JSpinner(); resetTabDefaultsBtn = new JButton(); - boldTabs = new JCheckBox(); + isUpperCaseTabsCheckbox = new JCheckBox(); JLabel tabHeight = new JLabel(); tabHeightSpinner = new JSpinner(); Spacer vSpacer2 = new Spacer(); @@ -350,9 +393,13 @@ private void initComponents() { Spacer hSpacer2 = new Spacer(); hideFileIconsCheckbox = new JCheckBox(); isCompactSidebarCheckbox = new JCheckBox(); + customSidebarSpinner = new JSpinner(); customTreeIndentCheckbox = new JCheckBox(); customIndentSpinner = new JSpinner(); isCompactStatusbarCheckbox = new JCheckBox(); + boldTabs = new JCheckBox(); + customAccentColorLabel = new JLabel(); + customAccentColorChooser = new ColorPanel(); JPanel panel3 = new JPanel(); isWallpaperSetCheckbox = new JCheckBox(); customBgLabel = new JLabel(); @@ -391,10 +438,8 @@ private void initComponents() { activeTabHighlightCheckbox.addActionListener(e -> activeTabHighlightCheckboxActionPerformed(e)); panel1.add(activeTabHighlightCheckbox, new GridConstraints(0, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, - GridConstraints.SIZEPOLICY_CAN_SHRINK | - GridConstraints.SIZEPOLICY_CAN_GROW, - GridConstraints.SIZEPOLICY_CAN_SHRINK | - GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null)); panel1.add(activeTabHighlightColor, new GridConstraints(0, 1, 1, 1, GridConstraints.ANCHOR_EAST, GridConstraints.FILL_NONE, @@ -427,14 +472,13 @@ private void initComponents() { GridConstraints.SIZEPOLICY_FIXED, null, null, null)); - //---- boldTabs ---- - boldTabs.setLabel(bundle.getString("mt.boldtabs")); - boldTabs.setText(bundle.getString("mt.boldtabs")); - boldTabs.setToolTipText(bundle.getString("mt.boldtabs.tooltip")); - panel1.add(boldTabs, new GridConstraints(3, 0, 1, 1, + //---- isUpperCaseTabsCheckbox ---- + isUpperCaseTabsCheckbox.setText(bundle.getString("MTForm.isUpperCaseTabsCheckbox.text")); + isUpperCaseTabsCheckbox.setToolTipText(bundle.getString("MTForm.isUpperCaseTabsCheckbox.toolTipText")); + panel1.add(isUpperCaseTabsCheckbox, new GridConstraints(3, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, - GridConstraints.SIZEPOLICY_FIXED, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null)); //---- tabHeight ---- @@ -467,7 +511,7 @@ private void initComponents() { //======== panel2 ======== { panel2.setBorder(new TitledBorder(new EtchedBorder(), bundle.getString("mt.panels.section"))); - panel2.setLayout(new GridLayoutManager(5, 2, new Insets(0, 0, 0, 0), -1, -1)); + panel2.setLayout(new GridLayoutManager(7, 2, new Insets(0, 0, 0, 0), -1, -1)); //---- isContrastModeCheckbox ---- isContrastModeCheckbox.setLabel(bundle.getString("mt.contrast")); @@ -496,24 +540,29 @@ private void initComponents() { //---- isCompactSidebarCheckbox ---- isCompactSidebarCheckbox.setText(bundle.getString("MTForm.isCompactSidebarCheckbox.text")); isCompactSidebarCheckbox.setToolTipText(bundle.getString("MTForm.isCompactSidebarCheckbox.toolTipText")); + isCompactSidebarCheckbox.addActionListener(e -> isCompactSidebarCheckboxActionPerformed(e)); panel2.add(isCompactSidebarCheckbox, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, - GridConstraints.SIZEPOLICY_CAN_SHRINK | - GridConstraints.SIZEPOLICY_CAN_GROW, - GridConstraints.SIZEPOLICY_CAN_SHRINK | - GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null)); + //---- customSidebarSpinner ---- + customSidebarSpinner.setToolTipText(bundle.getString("MTForm.customSidebarSpinner.toolTipText")); + panel2.add(customSidebarSpinner, new GridConstraints(2, 1, 1, 1, + GridConstraints.ANCHOR_EAST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + null, new Dimension(89, 29), null)); + //---- customTreeIndentCheckbox ---- customTreeIndentCheckbox.setText(bundle.getString("MTForm.customTreeIndentCheckbox.text")); customTreeIndentCheckbox.setToolTipText(bundle.getString("MTForm.customTreeIndentCheckbox.toolTipText")); customTreeIndentCheckbox.addActionListener(e -> customTreeIndentCheckboxActionPerformed(e)); panel2.add(customTreeIndentCheckbox, new GridConstraints(3, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, - GridConstraints.SIZEPOLICY_CAN_SHRINK | - GridConstraints.SIZEPOLICY_CAN_GROW, - GridConstraints.SIZEPOLICY_CAN_SHRINK | - GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null)); //---- customIndentSpinner ---- @@ -522,7 +571,9 @@ private void initComponents() { GridConstraints.ANCHOR_EAST, GridConstraints.FILL_NONE, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, - null, new Dimension(89, 29), null));//---- isCompactStatusbarCheckbox ---- + null, new Dimension(89, 29), null)); + + //---- isCompactStatusbarCheckbox ---- isCompactStatusbarCheckbox.setText(bundle.getString("MTForm.isCompactStatusbarCheckbox.text")); isCompactStatusbarCheckbox.setToolTipText(bundle.getString("MTForm.isCompactStatusBar.tooltip")); panel2.add(isCompactStatusbarCheckbox, new GridConstraints(4, 0, 1, 1, @@ -530,6 +581,30 @@ private void initComponents() { GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null)); + + //---- boldTabs ---- + boldTabs.setLabel(bundle.getString("mt.boldtabs")); + boldTabs.setText(bundle.getString("mt.boldtabs")); + boldTabs.setToolTipText(bundle.getString("mt.boldtabs.tooltip")); + panel2.add(boldTabs, new GridConstraints(5, 0, 1, 1, + GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_FIXED, + null, null, null)); + + //---- customAccentColorLabel ---- + customAccentColorLabel.setText(bundle.getString("MTForm.customAccentColorLabel.text")); + customAccentColorLabel.setToolTipText(bundle.getString("MTForm.customAccentColorLabel.toolTipText")); + panel2.add(customAccentColorLabel, new GridConstraints(6, 0, 1, 1, + GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + null, null, null, 2)); + panel2.add(customAccentColorChooser, new GridConstraints(6, 1, 1, 1, + GridConstraints.ANCHOR_EAST, GridConstraints.FILL_NONE, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + null, null, null)); } content.add(panel2, new GridConstraints(1, 0, 1, 1, GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH, @@ -585,8 +660,7 @@ private void initComponents() { isMaterialDesignCheckbox.setToolTipText(bundle.getString("MTForm.isMaterialDesignCheckbox.toolTipText")); panel3.add(isMaterialDesignCheckbox, new GridConstraints(2, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, - GridConstraints.SIZEPOLICY_CAN_SHRINK | - GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, GridConstraints.SIZEPOLICY_FIXED, null, null, null)); @@ -605,10 +679,8 @@ private void initComponents() { isProjectViewDecoratorsCheckbox.setToolTipText(bundle.getString("MTForm.projectViewDecorators.tooltip")); panel3.add(isProjectViewDecoratorsCheckbox, new GridConstraints(4, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, - GridConstraints.SIZEPOLICY_CAN_SHRINK | - GridConstraints.SIZEPOLICY_CAN_GROW, - GridConstraints.SIZEPOLICY_CAN_SHRINK | - GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null)); //---- materialThemeCheckbox ---- @@ -634,10 +706,8 @@ private void initComponents() { themedScrollbarsCheckbox.setToolTipText(bundle.getString("MTForm.themedScrollbarsCheckbox.toolTipText")); panel3.add(themedScrollbarsCheckbox, new GridConstraints(7, 0, 1, 1, GridConstraints.ANCHOR_WEST, GridConstraints.FILL_NONE, - GridConstraints.SIZEPOLICY_CAN_SHRINK | - GridConstraints.SIZEPOLICY_CAN_GROW, - GridConstraints.SIZEPOLICY_CAN_SHRINK | - GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, + GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW, null, null, null)); } content.add(panel3, new GridConstraints(2, 0, 1, 1, diff --git a/src/main/java/com/chrisrm/idea/config/ui/MTForm.jfd b/src/main/java/com/chrisrm/idea/config/ui/MTForm.jfd index 32265ae27..c13e169c0 100644 --- a/src/main/java/com/chrisrm/idea/config/ui/MTForm.jfd +++ b/src/main/java/com/chrisrm/idea/config/ui/MTForm.jfd @@ -1,4 +1,4 @@ -JFDML JFormDesigner: "6.0.1.0.112" Java: "1.8.0_112-release" encoding: "UTF-8" +JFDML JFormDesigner: "6.0.2.0.116" Java: "1.8.0_152-release" encoding: "UTF-8" new FormModel { "i18n.bundlePackage": "messages" @@ -73,14 +73,12 @@ new FormModel { "vSizePolicy": 0 } ) add( new FormComponent( "javax.swing.JCheckBox" ) { - name: "boldTabs" - "label": new FormMessage( null, "mt.boldtabs" ) - "text": new FormMessage( null, "mt.boldtabs" ) - "toolTipText": new FormMessage( null, "mt.boldtabs.tooltip" ) + name: "isUpperCaseTabsCheckbox" + "text": new FormMessage( null, "MTForm.isUpperCaseTabsCheckbox.text" ) + "toolTipText": new FormMessage( null, "MTForm.isUpperCaseTabsCheckbox.toolTipText" ) }, new FormLayoutConstraints( class com.intellij.uiDesigner.core.GridConstraints ) { "row": 3 "anchor": 8 - "vSizePolicy": 0 } ) add( new FormComponent( "javax.swing.JLabel" ) { name: "tabHeight" @@ -123,7 +121,7 @@ new FormModel { } ) add( new FormContainer( "javax.swing.JPanel", new FormLayoutManager( class com.intellij.uiDesigner.core.GridLayoutManager ) { "$columnCount": 2 - "$rowCount": 5 + "$rowCount": 7 } ) { name: "panel2" "border": new javax.swing.border.TitledBorder( #EtchedBorder0, "i18nKey=mt.panels.section" ) @@ -155,17 +153,27 @@ new FormModel { "text": new FormMessage( null, "MTForm.hideFileIcons" ) "toolTipText": new FormMessage( null, "MTForm.hideFileIcons.tooltip" ) }, new FormLayoutConstraints( class com.intellij.uiDesigner.core.GridConstraints ) { - "row": 1 "anchor": 8 + "row": 1 } ) add( new FormComponent( "javax.swing.JCheckBox" ) { name: "isCompactSidebarCheckbox" "text": new FormMessage( null, "MTForm.isCompactSidebarCheckbox.text" ) "toolTipText": new FormMessage( null, "MTForm.isCompactSidebarCheckbox.toolTipText" ) + addEvent( new FormEvent( "java.awt.event.ActionListener", "actionPerformed", "isCompactSidebarCheckboxActionPerformed", true ) ) }, new FormLayoutConstraints( class com.intellij.uiDesigner.core.GridConstraints ) { "row": 2 "anchor": 8 } ) + add( new FormComponent( "javax.swing.JSpinner" ) { + name: "customSidebarSpinner" + "toolTipText": new FormMessage( null, "MTForm.customSidebarSpinner.toolTipText" ) + }, new FormLayoutConstraints( class com.intellij.uiDesigner.core.GridConstraints ) { + "row": 2 + "anchor": 4 + "preferredSize": #Dimension1 + "column": 1 + } ) add( new FormComponent( "javax.swing.JCheckBox" ) { name: "customTreeIndentCheckbox" "text": new FormMessage( null, "MTForm.customTreeIndentCheckbox.text" ) @@ -192,6 +200,32 @@ new FormModel { "row": 4 "anchor": 8 } ) + add( new FormComponent( "javax.swing.JCheckBox" ) { + name: "boldTabs" + "label": new FormMessage( null, "mt.boldtabs" ) + "text": new FormMessage( null, "mt.boldtabs" ) + "toolTipText": new FormMessage( null, "mt.boldtabs.tooltip" ) + }, new FormLayoutConstraints( class com.intellij.uiDesigner.core.GridConstraints ) { + "row": 5 + "anchor": 8 + "vSizePolicy": 0 + } ) + add( new FormComponent( "javax.swing.JLabel" ) { + name: "customAccentColorLabel" + "text": new FormMessage( null, "MTForm.customAccentColorLabel.text" ) + "toolTipText": new FormMessage( null, "MTForm.customAccentColorLabel.toolTipText" ) + }, new FormLayoutConstraints( class com.intellij.uiDesigner.core.GridConstraints ) { + "row": 6 + "anchor": 8 + "indent": 2 + } ) + add( new FormComponent( "com.intellij.ui.ColorPanel" ) { + name: "customAccentColorChooser" + }, new FormLayoutConstraints( class com.intellij.uiDesigner.core.GridConstraints ) { + "anchor": 4 + "row": 6 + "column": 1 + } ) }, new FormLayoutConstraints( class com.intellij.uiDesigner.core.GridConstraints ) { "row": 1 "fill": 3 diff --git a/src/main/java/com/chrisrm/idea/themes/MTFrameComponentExtension.java b/src/main/java/com/chrisrm/idea/panes/MTFrameComponentExtension.java similarity index 99% rename from src/main/java/com/chrisrm/idea/themes/MTFrameComponentExtension.java rename to src/main/java/com/chrisrm/idea/panes/MTFrameComponentExtension.java index 5d02a3124..cb8f64dc4 100644 --- a/src/main/java/com/chrisrm/idea/themes/MTFrameComponentExtension.java +++ b/src/main/java/com/chrisrm/idea/panes/MTFrameComponentExtension.java @@ -24,7 +24,7 @@ * */ -package com.chrisrm.idea.themes; +package com.chrisrm.idea.panes; import com.intellij.ide.ui.UISettings; import com.intellij.openapi.project.Project; diff --git a/src/main/java/com/chrisrm/idea/themes/MTIdePanePanel.java b/src/main/java/com/chrisrm/idea/panes/MTIdePanePanel.java similarity index 97% rename from src/main/java/com/chrisrm/idea/themes/MTIdePanePanel.java rename to src/main/java/com/chrisrm/idea/panes/MTIdePanePanel.java index 907fc3265..6b832b5e1 100644 --- a/src/main/java/com/chrisrm/idea/themes/MTIdePanePanel.java +++ b/src/main/java/com/chrisrm/idea/panes/MTIdePanePanel.java @@ -24,7 +24,7 @@ * */ -package com.chrisrm.idea.themes; +package com.chrisrm.idea.panes; import com.intellij.openapi.wm.impl.IdePanePanel; diff --git a/src/main/java/com/chrisrm/idea/schemes/MTThemesComponent.java b/src/main/java/com/chrisrm/idea/schemes/MTThemesComponent.java index a890430c3..f3d164a6a 100644 --- a/src/main/java/com/chrisrm/idea/schemes/MTThemesComponent.java +++ b/src/main/java/com/chrisrm/idea/schemes/MTThemesComponent.java @@ -26,8 +26,8 @@ package com.chrisrm.idea.schemes; +import com.chrisrm.idea.MTThemeManager; import com.chrisrm.idea.config.ConfigNotifier; -import com.chrisrm.idea.themes.MTThemeManager; import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.components.ApplicationComponent; import org.jetbrains.annotations.NotNull; diff --git a/src/main/java/com/chrisrm/idea/tabs/MTEditorTabColor.java b/src/main/java/com/chrisrm/idea/tabs/MTEditorTabColor.java index d2232d4d4..9a63d38b2 100644 --- a/src/main/java/com/chrisrm/idea/tabs/MTEditorTabColor.java +++ b/src/main/java/com/chrisrm/idea/tabs/MTEditorTabColor.java @@ -31,33 +31,16 @@ import com.intellij.openapi.fileEditor.impl.EditorTabColorProvider; import com.intellij.openapi.project.Project; import com.intellij.openapi.vfs.VirtualFile; -import com.intellij.ui.JBColor; import org.jetbrains.annotations.NotNull; -import org.jetbrains.annotations.Nullable; import java.awt.*; public final class MTEditorTabColor implements EditorTabColorProvider { - private static final Color COLOR_DARKER = new JBColor(new Color(33, 33, 33, 255), new Color(33, 33, 33, 255)); - private static final Color COLOR_DEFAULT = new JBColor(new Color(38, 50, 56, 255), new Color(38, 50, 56, 255)); - private static final Color COLOR_PALENIGHT = new JBColor(new Color(41, 45, 62, 255), new Color(41, 45, 62, 255)); - private static final Color COLOR_LIGHTER = new JBColor(new Color(250, 250, 250, 255), new Color(250, 250, 250, 255)); - - @Nullable @Override public Color getEditorTabColor(@NotNull final Project project, @NotNull final VirtualFile virtualFile) { final MTTheme mtTheme = MTConfig.getInstance().getSelectedTheme(); - switch (mtTheme) { - case DARKER: - return COLOR_DARKER; - case PALENIGHT: - return COLOR_PALENIGHT; - case LIGHTER: - return COLOR_LIGHTER; - default: - return COLOR_DEFAULT; - } + return mtTheme.getBackgroundColor(); } } diff --git a/src/main/java/com/chrisrm/idea/tabs/MTEditorUpperTabs.java b/src/main/java/com/chrisrm/idea/tabs/MTEditorUpperTabs.java new file mode 100644 index 000000000..4161ef194 --- /dev/null +++ b/src/main/java/com/chrisrm/idea/tabs/MTEditorUpperTabs.java @@ -0,0 +1,45 @@ +/* + * The MIT License (MIT) + * + * Copyright (c) 2017 Chris Magnussen and Elior Boukhobza + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + * + */ + +package com.chrisrm.idea.tabs; + +import com.chrisrm.idea.MTConfig; +import com.intellij.openapi.fileEditor.impl.EditorTabTitleProvider; +import com.intellij.openapi.project.Project; +import com.intellij.openapi.vfs.VirtualFile; +import com.intellij.psi.codeStyle.NameUtil; +import org.jetbrains.annotations.Nullable; + +public final class MTEditorUpperTabs implements EditorTabTitleProvider { + @Nullable + @Override + public String getEditorTabTitle(final Project project, final VirtualFile file) { + if (MTConfig.getInstance().isUpperCaseTabs()) { + return NameUtil.splitWords(file.getPresentableName(), ' ', String::toUpperCase); + } + return null; + } +} diff --git a/src/main/java/com/chrisrm/idea/tabs/MTTabsEditorAdapter.java b/src/main/java/com/chrisrm/idea/tabs/MTTabsEditorAdapter.java index dc91a38d2..54b73c7d1 100644 --- a/src/main/java/com/chrisrm/idea/tabs/MTTabsEditorAdapter.java +++ b/src/main/java/com/chrisrm/idea/tabs/MTTabsEditorAdapter.java @@ -67,6 +67,13 @@ public void selectionChanged(@NotNull final FileEditorManagerEvent event) { } } + /** + * Execute actions on the active tab + * + * @param fileStatusManager the project's file status manager + * @param file the current edited file + * @param editorWindow the current window + */ private void processActiveTab(@NotNull final FileStatusManager fileStatusManager, @NotNull final VirtualFile file, @NotNull final EditorWindow editorWindow) { @@ -85,6 +92,13 @@ private void processActiveTab(@NotNull final FileStatusManager fileStatusManager } } + /** + * Set tab font bold + * Does not work on edited files because Jetbrains remove the BOLD attributes + * + * @param file the edited file + * @param editorWindow the current window + */ private void setBoldTabs(@NotNull final VirtualFile file, @NotNull final EditorWindow editorWindow) { final EditorWithProviderComposite fileComposite = editorWindow.findFileComposite(file); @@ -98,28 +112,45 @@ private void setBoldTabs(@NotNull final VirtualFile file, if (tabbedPane != null) { try { tabbedPane.getTabs() - .getTabAt(editorIndex) - .setDefaultStyle(isBoldTabs ? SimpleTextAttributes.STYLE_BOLD : SimpleTextAttributes.STYLE_PLAIN); - } - catch (IndexOutOfBoundsException ignored) { + .getTabAt(editorIndex) + .setDefaultStyle(isBoldTabs ? SimpleTextAttributes.STYLE_BOLD : SimpleTextAttributes.STYLE_PLAIN); + } catch (final IndexOutOfBoundsException ignored) { } } } } + /** + * Process unselected tab + * + * @param fileStatusManager the file status manager + * @param fileColorManager the file color manager + * @param file the current file + * @param editorWindow the editor window + */ private void processOldTab(@NotNull final FileStatusManager fileStatusManager, @NotNull final FileColorManager fileColorManager, @NotNull final VirtualFile file, @NotNull final EditorWindow editorWindow) { - FileStatus status = fileStatusManager.getStatus(file); + final FileStatus status = fileStatusManager.getStatus(file); setTabColor(fileColorManager.getFileColor(file), file, editorWindow, status); } - private void setTabColor(final Color fileColor, + /** + * Set current tab's background and foreground color + *

+ * TODO file status color + * + * @param bgColor the background color + * @param file the file + * @param editorWindow the editor window + * @param status the file status + */ + private void setTabColor(final Color bgColor, @NotNull final VirtualFile file, @NotNull final EditorWindow editorWindow, - FileStatus status) { + final FileStatus status) { final EditorWithProviderComposite fileComposite = editorWindow.findFileComposite(file); // Find the tab of the selected file @@ -130,8 +161,8 @@ private void setTabColor(final Color fileColor, if (tabbedPane != null) { tabbedPane.getTabs() - .getPresentation() - .setActiveTabFillIn(fileColor); + .getPresentation() + .setActiveTabFillIn(bgColor); // try { // if (statusColor != null) { @@ -147,6 +178,13 @@ private void setTabColor(final Color fileColor, } } + /** + * Get index of given fileComposite + * + * @param editorWindow the editor window + * @param fileComposite the edited file + * @return + */ private int getEditorIndex(@NotNull final EditorWindow editorWindow, final EditorWithProviderComposite fileComposite) { int index = 0; for (final EditorWithProviderComposite editorWithProviderComposite : editorWindow.getEditors()) { diff --git a/src/main/java/com/chrisrm/idea/tabs/MTTabsPainterPatcherComponent.java b/src/main/java/com/chrisrm/idea/tabs/MTTabsPainterPatcherComponent.java index dc7a91586..c699585c0 100644 --- a/src/main/java/com/chrisrm/idea/tabs/MTTabsPainterPatcherComponent.java +++ b/src/main/java/com/chrisrm/idea/tabs/MTTabsPainterPatcherComponent.java @@ -28,8 +28,8 @@ import com.chrisrm.idea.MTConfig; import com.chrisrm.idea.MTTheme; +import com.chrisrm.idea.MTThemeManager; import com.chrisrm.idea.config.ConfigNotifier; -import com.chrisrm.idea.themes.MTThemeManager; import com.intellij.ide.util.PropertiesComponent; import com.intellij.openapi.application.ex.ApplicationManagerEx; import com.intellij.openapi.components.ApplicationComponent; @@ -55,6 +55,8 @@ import net.sf.cglib.proxy.MethodInterceptor; import org.jetbrains.annotations.NotNull; +import javax.swing.border.*; +import javax.swing.plaf.*; import java.awt.*; import java.lang.reflect.Field; @@ -66,6 +68,8 @@ public final class MTTabsPainterPatcherComponent implements ApplicationComponent { public static final String TABS_HEIGHT = "MTTabsHeight"; + public static final String BOLD_TABS = "MTBoldTabs"; + private final MTTheme theme; private final MTConfig config; @@ -74,6 +78,8 @@ public MTTabsPainterPatcherComponent() { theme = config.getSelectedTheme(); PropertiesComponent.getInstance().setValue(TABS_HEIGHT, 25, 24); + PropertiesComponent.getInstance().setValue(BOLD_TABS, false, false); + } /** @@ -94,6 +100,29 @@ public void edit(final MethodCall m) throws CannotCompileException { } }); ctClass.toClass(); + + final CtClass ctClass1 = cp.get("com.intellij.ui.tabs.impl.JBEditorTabs"); + final CtMethod useBoldLabels = ctClass1.getDeclaredMethod("useBoldLabels"); + useBoldLabels.instrument(new ExprEditor() { + @Override + public void edit(final FieldAccess f) throws CannotCompileException { + if (f.getFieldName().equals("isMac")) { + f.replace("{ $_ = true; }"); + } + } + + @Override + public void edit(final MethodCall m) throws CannotCompileException { + if (m.getMethodName().equals("is")) { + final String code = String.format("com.intellij.ide.util.PropertiesComponent.getInstance().getBoolean(\"%s\", false)", + BOLD_TABS); + m.replace("{ $_ = " + code + "; }"); + } + } + }); + + ctClass1.toClass(); + } catch (final Exception e) { e.printStackTrace(); } @@ -115,7 +144,8 @@ private void hackTabsGetHeight() throws public void edit(final MethodCall m) throws CannotCompileException { if (m.getClassName().equals("com.intellij.ui.tabs.TabsUtil") && m.getMethodName().equals("getTabsHeight")) { final String code = String.format("com.intellij.ide.util.PropertiesComponent.getInstance().getInt(\"%s\", 25)", TABS_HEIGHT); - m.replace("{ $_ = com.intellij.util.ui.JBUI.scale(myCentered ? " + code + " : 25); }"); + final String isDebugTab = "myInfo.getTabActionPlace() != null ? myInfo.getTabActionPlace().contains(\"debugger\") : true"; + m.replace(String.format("{ $_ = com.intellij.util.ui.JBUI.scale(%s); }", code)); } } }); diff --git a/src/main/java/com/chrisrm/idea/themes/LafTheme.java b/src/main/java/com/chrisrm/idea/themes/LafTheme.java new file mode 100644 index 000000000..a73e2284e --- /dev/null +++ b/src/main/java/com/chrisrm/idea/themes/LafTheme.java @@ -0,0 +1,5 @@ +package com.chrisrm.idea.themes; + +public interface LafTheme { + String getDisabled(); +} diff --git a/src/main/java/com/chrisrm/idea/actions/MTDarkerTheme.java b/src/main/java/com/chrisrm/idea/themes/MTDarkerTheme.java similarity index 81% rename from src/main/java/com/chrisrm/idea/actions/MTDarkerTheme.java rename to src/main/java/com/chrisrm/idea/themes/MTDarkerTheme.java index c0770873d..68a97268e 100644 --- a/src/main/java/com/chrisrm/idea/actions/MTDarkerTheme.java +++ b/src/main/java/com/chrisrm/idea/themes/MTDarkerTheme.java @@ -24,14 +24,9 @@ * */ -package com.chrisrm.idea.actions; +package com.chrisrm.idea.themes; -import com.chrisrm.idea.MTConfig; -import com.chrisrm.idea.MTTheme; -import com.chrisrm.idea.themes.MTThemeManager; -import com.intellij.openapi.actionSystem.AnActionEvent; - -public final class MTDarkerTheme extends MTAbstractTheme { +public final class MTDarkerTheme implements LafTheme { public static final String BACKGROUND = "212121"; // 33, 33, 33 public static final String FOREGROUND = "B0BEC5"; // 176, 190, 197 public static final String CARET = "FFCC00"; // 255, 204, 0 @@ -54,12 +49,7 @@ public final class MTDarkerTheme extends MTAbstractTheme { public static final String ACCENT_COLOR = "80CBC4"; // 128, 203, 196 @Override - public boolean isSelected(final AnActionEvent e) { - return MTConfig.getInstance().getSelectedTheme() == MTTheme.DARKER; - } - - @Override - public void setSelected(final AnActionEvent e, final boolean state) { - MTThemeManager.getInstance().activate(MTTheme.DARKER); + public String getDisabled() { + return DISABLED; } } diff --git a/src/main/java/com/chrisrm/idea/actions/MTDefaultTheme.java b/src/main/java/com/chrisrm/idea/themes/MTDefaultTheme.java similarity index 81% rename from src/main/java/com/chrisrm/idea/actions/MTDefaultTheme.java rename to src/main/java/com/chrisrm/idea/themes/MTDefaultTheme.java index eb3f0e8d3..4cd7a6dbe 100644 --- a/src/main/java/com/chrisrm/idea/actions/MTDefaultTheme.java +++ b/src/main/java/com/chrisrm/idea/themes/MTDefaultTheme.java @@ -24,14 +24,9 @@ * */ -package com.chrisrm.idea.actions; +package com.chrisrm.idea.themes; -import com.chrisrm.idea.MTConfig; -import com.chrisrm.idea.MTTheme; -import com.chrisrm.idea.themes.MTThemeManager; -import com.intellij.openapi.actionSystem.AnActionEvent; - -public final class MTDefaultTheme extends MTAbstractTheme { +public final class MTDefaultTheme implements LafTheme { public static final String BACKGROUND = "263238"; // 38, 50, 56 public static final String FOREGROUND = "B0BEC5"; // 176, 190, 197 public static final String CARET = "FFCC00"; // 255, 204, 0 @@ -51,12 +46,7 @@ public final class MTDefaultTheme extends MTAbstractTheme { public static final String ACCENT_COLOR = "80CBC4"; // 128, 203, 196 @Override - public boolean isSelected(final AnActionEvent e) { - return MTConfig.getInstance().getSelectedTheme() == MTTheme.DEFAULT; - } - - @Override - public void setSelected(final AnActionEvent e, final boolean state) { - MTThemeManager.getInstance().activate(MTTheme.DEFAULT); + public String getDisabled() { + return DISABLED; } } diff --git a/src/main/java/com/chrisrm/idea/actions/MTLighterTheme.java b/src/main/java/com/chrisrm/idea/themes/MTLighterTheme.java similarity index 81% rename from src/main/java/com/chrisrm/idea/actions/MTLighterTheme.java rename to src/main/java/com/chrisrm/idea/themes/MTLighterTheme.java index d2dd35210..06b747d26 100644 --- a/src/main/java/com/chrisrm/idea/actions/MTLighterTheme.java +++ b/src/main/java/com/chrisrm/idea/themes/MTLighterTheme.java @@ -24,14 +24,9 @@ * */ -package com.chrisrm.idea.actions; +package com.chrisrm.idea.themes; -import com.chrisrm.idea.MTConfig; -import com.chrisrm.idea.MTTheme; -import com.chrisrm.idea.themes.MTThemeManager; -import com.intellij.openapi.actionSystem.AnActionEvent; - -public final class MTLighterTheme extends MTAbstractTheme { +public final class MTLighterTheme implements LafTheme { public static final String BACKGROUND = "FAFAFA"; // 250, 250, 250 public static final String FOREGROUND = "A7ADB0"; // 167, 173, 176 public static final String CARET = "FFCC00"; // 255, 204, 0 @@ -54,12 +49,7 @@ public final class MTLighterTheme extends MTAbstractTheme { public static final String ACCENT_COLOR = "80CBC4"; // 128, 203, 196 @Override - public boolean isSelected(final AnActionEvent e) { - return MTConfig.getInstance().getSelectedTheme() == MTTheme.LIGHTER; - } - - @Override - public void setSelected(final AnActionEvent e, final boolean state) { - MTThemeManager.getInstance().activate(MTTheme.LIGHTER); + public String getDisabled() { + return DISABLED; } } diff --git a/src/main/java/com/chrisrm/idea/actions/MTPalenightTheme.java b/src/main/java/com/chrisrm/idea/themes/MTPalenightTheme.java similarity index 81% rename from src/main/java/com/chrisrm/idea/actions/MTPalenightTheme.java rename to src/main/java/com/chrisrm/idea/themes/MTPalenightTheme.java index bb46a63e6..4a8c057e9 100644 --- a/src/main/java/com/chrisrm/idea/actions/MTPalenightTheme.java +++ b/src/main/java/com/chrisrm/idea/themes/MTPalenightTheme.java @@ -24,14 +24,9 @@ * */ -package com.chrisrm.idea.actions; +package com.chrisrm.idea.themes; -import com.chrisrm.idea.MTConfig; -import com.chrisrm.idea.MTTheme; -import com.chrisrm.idea.themes.MTThemeManager; -import com.intellij.openapi.actionSystem.AnActionEvent; - -public final class MTPalenightTheme extends MTAbstractTheme { +public final class MTPalenightTheme implements LafTheme { public static final String BACKGROUND = "292D3E"; // 41, 45, 62 public static final String FOREGROUND = "B0BEC5"; // 176, 190, 197 public static final String CARET = "FFCC00"; // 255, 204, 0 @@ -54,12 +49,7 @@ public final class MTPalenightTheme extends MTAbstractTheme { public static final String ACCENT_COLOR = "80CBC4"; // 128, 203, 196 @Override - public boolean isSelected(final AnActionEvent e) { - return MTConfig.getInstance().getSelectedTheme() == MTTheme.PALENIGHT; - } - - @Override - public void setSelected(final AnActionEvent e, final boolean state) { - MTThemeManager.getInstance().activate(MTTheme.PALENIGHT); + public String getDisabled() { + return DISABLED; } } diff --git a/src/main/java/com/chrisrm/idea/tree/MTProjectViewNodeDecorator.java b/src/main/java/com/chrisrm/idea/tree/MTProjectViewNodeDecorator.java index 961ef9e05..7ef777e7f 100644 --- a/src/main/java/com/chrisrm/idea/tree/MTProjectViewNodeDecorator.java +++ b/src/main/java/com/chrisrm/idea/tree/MTProjectViewNodeDecorator.java @@ -64,16 +64,18 @@ public void decorate(final PackageDependenciesNode node, final ColoredTreeCellRe @Override public void decorate(final ProjectViewNode node, final PresentationData data) { final VirtualFile file = node.getVirtualFile(); - if (file == null) { - return; - } final Project project = node.getProject(); // Color file status - colorFileStatus(data, file, project); + if (file != null) { + colorFileStatus(data, file, project); - if (MTConfig.getInstance().isUseProjectViewDecorators()) { - setOpenOrClosedIcon(data, file, project); + if (MTConfig.getInstance().isUseProjectViewDecorators()) { + setOpenOrClosedIcon(data, file, project); + } + } + else { + colorFileStatus(data, node, project); } } @@ -130,6 +132,14 @@ private void colorFileStatus(final PresentationData data, final VirtualFile file } } + private void colorFileStatus(final PresentationData data, final ProjectViewNode file, final Project project) { + final FileStatus status = file.getFileStatus(); + final Color colorFromStatus = getColorFromStatus(status); + if (colorFromStatus != null) { + data.setForcedTextForeground(colorFromStatus); + } + } + private Color getColorFromStatus(final FileStatus status) { return MTFileColors.get(status); } diff --git a/src/main/java/com/chrisrm/idea/ui/MTButtonUI.java b/src/main/java/com/chrisrm/idea/ui/MTButtonUI.java index aae2239a3..091967dfc 100644 --- a/src/main/java/com/chrisrm/idea/ui/MTButtonUI.java +++ b/src/main/java/com/chrisrm/idea/ui/MTButtonUI.java @@ -27,6 +27,7 @@ package com.chrisrm.idea.ui; import com.chrisrm.idea.utils.ColorCycle; +import com.chrisrm.idea.utils.MTUiUtils; import com.intellij.icons.AllIcons; import com.intellij.ide.ui.laf.darcula.DarculaLaf; import com.intellij.ide.ui.laf.darcula.ui.DarculaButtonUI; @@ -36,17 +37,15 @@ import com.intellij.util.ui.GraphicsUtil; import com.intellij.util.ui.JBUI; import com.intellij.util.ui.UIUtil; +import org.jetbrains.annotations.NotNull; import sun.swing.SwingUtilities2; import javax.swing.*; -import javax.swing.border.Border; -import javax.swing.plaf.ColorUIResource; -import javax.swing.plaf.ComponentUI; -import javax.swing.plaf.UIResource; -import javax.swing.plaf.basic.BasicArrowButton; -import javax.swing.plaf.basic.BasicButtonListener; +import javax.swing.border.*; +import javax.swing.plaf.*; +import javax.swing.plaf.basic.*; import java.awt.*; -import java.awt.event.MouseEvent; +import java.awt.event.*; public class MTButtonUI extends DarculaButtonUI { @SuppressWarnings("MethodOverridesStaticMethodOfSuperclass") @@ -73,7 +72,7 @@ public final void update(final Graphics g, final JComponent c) { @Override protected void installDefaults(final AbstractButton b) { super.installDefaults(b); - final Color background = ObjectUtils.notNull(UIManager.getColor("Button.mt.background"), new ColorUIResource(0x3C3F41)); + final Color background = buttonBackground(); b.setBackground(background); b.setFont(b.getFont().deriveFont(Font.BOLD, JBUI.scale(13.0f))); } @@ -132,10 +131,10 @@ private void highlightButton(final MouseEvent e) { final Component component = e.getComponent(); colorCycle.setC((JComponent) component); - final Color hoverColor = ObjectUtils.notNull(UIManager.getColor("Button.mt.selection.color1"), new ColorUIResource(0x384f6b)); - final Color preHoverColor = ObjectUtils.notNull(UIManager.getColor("Button.mt.selection.color2"), new ColorUIResource(0x233143)); - final Color textColor = ObjectUtils.notNull(UIManager.getColor("Button.mt.selectedButtonForeground"), - new ColorUIResource(0xbbbbbb)); + + final Color hoverColor = buttonSelectColor1(); + final Color preHoverColor = buttonSelectColor2(); + final Color textColor = buttonSelectFg(); component.setForeground(textColor); colorCycle.start(preHoverColor, hoverColor); @@ -146,9 +145,10 @@ private void removeHighlight(final MouseEvent e) { final Component component = e.getComponent(); colorCycle.setC((JComponent) component); - final Color notHoverColor = ObjectUtils.notNull(UIManager.getColor("Button.mt.color1"), new ColorUIResource(0x555a5c)); - final Color preNotHoverColor = ObjectUtils.notNull(UIManager.getColor("Button.mt.color2"), new ColorUIResource(0x414648)); - final Color textColor = ObjectUtils.notNull(UIManager.getColor("Button.mt.foreground"), new ColorUIResource(0xbbbbbb)); + + final Color notHoverColor = buttonColor1(); + final Color preNotHoverColor = buttonColor2(); + final Color textColor = buttonFg(); component.setForeground(textColor); colorCycle.start(preNotHoverColor, notHoverColor); @@ -156,6 +156,57 @@ private void removeHighlight(final MouseEvent e) { }; } + @NotNull + private Color buttonBackground() { + return MTUiUtils.getColor(UIManager.getColor("Button.mt.background"), + ObjectUtils.notNull(UIManager.getColor("Button.darcula.color1"), new ColorUIResource(0x555a5c)), + ObjectUtils.notNull(UIManager.getColor("Button.darcula.color1"), new ColorUIResource(0xeeeeee))); + } + + @NotNull + private Color buttonColor1() { + return MTUiUtils.getColor(UIManager.getColor("Button.mt.color1"), + ObjectUtils.notNull(UIManager.getColor("Button.darcula.color1"), new ColorUIResource(0x555a5c)), + ObjectUtils.notNull(UIManager.getColor("Button.darcula.color1"), new ColorUIResource(0xeeeeee))); + } + + @NotNull + private Color buttonColor2() { + return MTUiUtils.getColor(UIManager.getColor("Button.mt.color2"), + ObjectUtils.notNull(UIManager.getColor("Button.darcula.color2"), new ColorUIResource(0x414648)), + ObjectUtils.notNull(UIManager.getColor("Button.darcula.color2"), new ColorUIResource(0xc0c0c0))); + } + + @NotNull + private Color buttonFg() { + return MTUiUtils.getColor(UIManager.getColor("Button.mt.foreground"), + ObjectUtils.notNull(UIManager.getColor("Button.darcula.foreground"), new ColorUIResource(0xbbbbbb)), + ObjectUtils.notNull(UIManager.getColor("Button.darcula.foreground"), new ColorUIResource(0x000000))); + } + + @NotNull + private Color buttonSelectFg() { + return MTUiUtils.getColor(UIManager.getColor("Button.mt.selectedForeground"), + ObjectUtils.notNull(UIManager.getColor("Button.darcula.selectedButtonForeground"), + new ColorUIResource(0xbbbbbb)), + ObjectUtils.notNull(UIManager.getColor("Button.darcula.selectedButtonForeground"), + new ColorUIResource(0xf0f0f0))); + } + + @NotNull + private Color buttonSelectColor1() { + return MTUiUtils.getColor(UIManager.getColor("Button.mt.selection.color1"), + ObjectUtils.notNull(UIManager.getColor("Button.darcula.selection.color1"), new ColorUIResource(0x384f6b)), + ObjectUtils.notNull(UIManager.getColor("Button.darcula.selection.color1"), new ColorUIResource(0x4985e4))); + } + + @NotNull + private Color buttonSelectColor2() { + return MTUiUtils.getColor(UIManager.getColor("Button.mt.selection.color2"), + ObjectUtils.notNull(UIManager.getColor("Button.darcula.selection.color2"), new ColorUIResource(0x233143)), + ObjectUtils.notNull(UIManager.getColor("Button.darcula.selection.color2"), new ColorUIResource(0x4074c9))); + } + /** * Paints additional buttons decorations * @@ -168,12 +219,11 @@ protected boolean paintDecorations(final Graphics2D g, final JComponent c) { final int w = c.getWidth(); final int h = c.getHeight(); final Color background = c.getBackground(); - final Color buttonColor1 = ObjectUtils.notNull(UIManager.getColor("Button.darcula.color1"), new ColorUIResource(0x555a5c)); - final Color buttonColor2 = ObjectUtils.notNull(UIManager.getColor("Button.darcula.color2"), new ColorUIResource(0x414648)); - final Color primaryButtonColor = ObjectUtils.notNull(UIManager.getColor("Button.darcula.selection.color1"), - new ColorUIResource(0x384f6b)); - final Color focusedButtonColor = ObjectUtils.notNull(UIManager.getColor("Button.darcula.selection.color2"), - new ColorUIResource(0x233143)); + + final Color buttonColor1 = buttonColor1(); + final Color buttonColor2 = buttonColor2(); + final Color primaryButtonColor = buttonSelectColor1(); + final Color focusedButtonColor = buttonSelectColor2(); if (isHelpButton(c)) { g.setPaint(UIUtil.getGradientPaint(0, 0, buttonColor1, 0, h, buttonColor2)); diff --git a/src/main/java/com/chrisrm/idea/ui/MTCheckBoxUI.java b/src/main/java/com/chrisrm/idea/ui/MTCheckBoxUI.java index 5879d650e..41731014a 100644 --- a/src/main/java/com/chrisrm/idea/ui/MTCheckBoxUI.java +++ b/src/main/java/com/chrisrm/idea/ui/MTCheckBoxUI.java @@ -35,9 +35,9 @@ import sun.swing.SwingUtilities2; import javax.swing.*; -import javax.swing.plaf.*; -import javax.swing.plaf.basic.*; -import javax.swing.text.*; +import javax.swing.plaf.ComponentUI; +import javax.swing.plaf.basic.BasicHTML; +import javax.swing.text.View; import java.awt.*; /** @@ -192,7 +192,7 @@ protected void drawText(final JComponent c, protected void paintCheckSign(final Graphics2D g, final boolean enabled, final int w, final int h) { g.setRenderingHint(RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_PURE); g.setStroke(new BasicStroke(1 * JBUI.scale(2.0f), BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND)); - g.setPaint(getShadowColor(enabled, true)); + g.setPaint(getCheckSignColor(enabled, true)); final int x1 = JBUI.scale(3); final int y1 = JBUI.scale(7); final int x2 = JBUI.scale(7); diff --git a/src/main/java/com/chrisrm/idea/ui/MTComboBoxUI.java b/src/main/java/com/chrisrm/idea/ui/MTComboBoxUI.java index f0acac992..32c121846 100644 --- a/src/main/java/com/chrisrm/idea/ui/MTComboBoxUI.java +++ b/src/main/java/com/chrisrm/idea/ui/MTComboBoxUI.java @@ -25,8 +25,11 @@ */ package com.chrisrm.idea.ui; +import com.chrisrm.idea.MTConfig; +import com.chrisrm.idea.utils.MTUiUtils; import com.intellij.ide.ui.laf.darcula.ui.DarculaComboBoxUI; import com.intellij.openapi.ui.GraphicsConfig; +import com.intellij.ui.ColorUtil; import com.intellij.ui.JBColor; import com.intellij.util.ObjectUtils; import com.intellij.util.ui.JBInsets; @@ -35,14 +38,11 @@ import sun.swing.DefaultLookup; import javax.swing.*; -import javax.swing.border.Border; -import javax.swing.plaf.ComponentUI; -import javax.swing.plaf.DimensionUIResource; -import javax.swing.plaf.InsetsUIResource; -import javax.swing.plaf.basic.BasicArrowButton; +import javax.swing.border.*; +import javax.swing.plaf.*; +import javax.swing.plaf.basic.*; import java.awt.*; -import java.awt.geom.Path2D; -import java.awt.geom.Rectangle2D; +import java.awt.geom.*; /** * @author Konstantin Bulenkov @@ -191,7 +191,8 @@ public void paintBorder(final Component c, final Graphics g2, final int x, final } private Color getSelectedBorderColor() { - return UIManager.getColor("TextField.selectedSeparatorColor"); + final Color defaultValue = ColorUtil.fromHex(MTConfig.getInstance().getAccentColor()); + return ObjectUtils.notNull(UIManager.getColor("TextField.selectedSeparatorColor"), defaultValue); } @Override @@ -271,7 +272,10 @@ protected Color getArrowButtonFillColor(final Color defaultColor) { // : UIManager.getColor("ComboBox.darcula.arrowFillColor"); // return color == null ? defaultColor : comboBox != null && !comboBox.isEnabled() ? new JBColor(getBorderColor(), UIUtil // .getControlColor()) : color; - return ObjectUtils.notNull(UIManager.getColor("ComboBox.arrowFillColor"), UIManager.getColor("control")); + return MTUiUtils.getColor( + UIManager.getColor("ComboBox.arrowFillColor"), + ObjectUtils.notNull(UIManager.getColor("ComboBox.darcula.arrowFillColor"), new ColorUIResource(0x457dd7)), + ObjectUtils.notNull(UIManager.getColor("ComboBox.darcula.arrowFillColor"), new ColorUIResource(0x457dd7))); } @Override @@ -340,9 +344,16 @@ protected Dimension getSizeForComponent(final Component comp) { } private Color getBorderColor() { + final Color defaultValue = MTUiUtils.getColor(UIManager.getColor("Separator.foreground"), + new ColorUIResource(0x515151), + new ColorUIResource(0xcdcdcd)); + final Color defaultDisabled = MTUiUtils.getColor(UIManager.getColor("ComboBox.disabledBackground"), + new ColorUIResource(0x3c3f41), + new ColorUIResource(0xe8e8e8)); + if (comboBox != null && myComboBox.isEnabled()) { - return UIManager.getColor("TextField.separatorColor"); + return ObjectUtils.notNull(UIManager.getColor("TextField.separatorColor"), defaultValue); } - return UIManager.getColor("TextField.separatorColorDisabled"); + return ObjectUtils.notNull(UIManager.getColor("TextField.separatorColorDisabled"), defaultDisabled); } } diff --git a/src/main/java/com/chrisrm/idea/utils/MTUiUtils.java b/src/main/java/com/chrisrm/idea/utils/MTUiUtils.java index 1836e2024..4c0b6b6da 100644 --- a/src/main/java/com/chrisrm/idea/utils/MTUiUtils.java +++ b/src/main/java/com/chrisrm/idea/utils/MTUiUtils.java @@ -26,10 +26,15 @@ package com.chrisrm.idea.utils; +import com.chrisrm.idea.MTConfig; +import com.intellij.ide.ui.LafManager; import com.intellij.openapi.application.Application; import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.application.impl.ApplicationImpl; +import com.intellij.util.ObjectUtils; import com.intellij.util.ui.JBUI; +import com.intellij.util.ui.UIUtil; +import org.jetbrains.annotations.NotNull; import java.awt.*; import java.awt.font.*; @@ -49,15 +54,15 @@ private MTUiUtils() { static { MTUiUtils.setHints(new RenderingHints(RenderingHints.KEY_ALPHA_INTERPOLATION, - RenderingHints.VALUE_ALPHA_INTERPOLATION_SPEED)); + RenderingHints.VALUE_ALPHA_INTERPOLATION_SPEED)); MTUiUtils.getHints().put(RenderingHints.KEY_ANTIALIASING, - RenderingHints.VALUE_ANTIALIAS_ON); + RenderingHints.VALUE_ANTIALIAS_ON); MTUiUtils.getHints().put(RenderingHints.KEY_RENDERING, - RenderingHints.VALUE_RENDER_SPEED); + RenderingHints.VALUE_RENDER_SPEED); MTUiUtils.getHints().put(RenderingHints.KEY_TEXT_ANTIALIASING, - RenderingHints.VALUE_TEXT_ANTIALIAS_ON); + RenderingHints.VALUE_TEXT_ANTIALIAS_ON); MTUiUtils.getHints().put(RenderingHints.KEY_FRACTIONALMETRICS, - RenderingHints.VALUE_FRACTIONALMETRICS_ON); + RenderingHints.VALUE_FRACTIONALMETRICS_ON); } public static Font findFont(final String name) { @@ -69,6 +74,17 @@ public static Font findFont(final String name) { return null; } + public static Color getColor(final Color mtColor, @NotNull final Color darculaColor, @NotNull final Color intellijColor) { + Color defaultColor = UIUtil.isUnderDarcula() ? darculaColor : intellijColor; + if (MTConfig.getInstance().isMaterialTheme()) { + return ObjectUtils.notNull(mtColor, defaultColor); + } + return defaultColor; + } + + public static boolean isDarcula() { + return LafManager.getInstance().getCurrentLookAndFeel().equals("Darcula"); + } public static Font getWidgetFont() { final GraphicsEnvironment e = GraphicsEnvironment.getLocalGraphicsEnvironment(); @@ -82,7 +98,6 @@ public static Font getWidgetFont() { attributes.put(TextAttribute.SIZE, JBUI.scale(11)); return f.deriveFont(attributes); - } } return JBUI.Fonts.label(12); diff --git a/src/main/java/com/chrisrm/idea/utils/UIReplacer.java b/src/main/java/com/chrisrm/idea/utils/UIReplacer.java index 0bc4bfbeb..f15607483 100644 --- a/src/main/java/com/chrisrm/idea/utils/UIReplacer.java +++ b/src/main/java/com/chrisrm/idea/utils/UIReplacer.java @@ -31,6 +31,7 @@ import com.intellij.codeInsight.hint.ParameterInfoComponent; import com.intellij.codeInsight.lookup.impl.LookupCellRenderer; import com.intellij.icons.AllIcons; +import com.intellij.ide.ui.laf.darcula.DarculaUIUtil; import com.intellij.lang.parameterInfo.ParameterInfoUIContextEx; import com.intellij.notification.impl.NotificationsManagerImpl; import com.intellij.openapi.options.newEditor.SettingsTreeView; @@ -46,7 +47,7 @@ import com.intellij.vcs.log.ui.highlighters.MergeCommitsHighlighter; import javax.swing.*; -import javax.swing.plaf.*; +import javax.swing.plaf.ColorUIResource; import java.awt.*; import java.lang.reflect.Constructor; import java.lang.reflect.Field; @@ -77,58 +78,74 @@ public static void patchUI() { static final class Patcher { static void patchTables() throws Exception { - StaticPatcher.setFinalStatic(UIUtil.class, "DECORATED_ROW_BG_COLOR", UIManager.get("Table.stripedBackground")); + if (MTConfig.getInstance().isMaterialTheme()) { + StaticPatcher.setFinalStatic(UIUtil.class, "DECORATED_ROW_BG_COLOR", UIManager.get("Table.stripedBackground")); + } } static void patchStatusBar() throws Exception { - // Replace Gray with a clear and transparent color - final Gray gray = Gray._85; - final Color alphaGray = gray.withAlpha(1); - StaticPatcher.setFinalStatic(Gray.class, "_85", alphaGray); - StaticPatcher.setFinalStatic(Gray.class, "_40", alphaGray); - StaticPatcher.setFinalStatic(Gray.class, "_145", alphaGray); - StaticPatcher.setFinalStatic(Gray.class, "_255", alphaGray); - StaticPatcher.setFinalStatic(Gray.class, "_201", alphaGray); - - // Quick info border - StaticPatcher.setFinalStatic(Gray.class, "_90", gray.withAlpha(25)); - - // tool window color - final boolean dark = MTConfig.getInstance().getSelectedTheme().isDark(); - StaticPatcher.setFinalStatic(Gray.class, "_15", dark ? Gray._15.withAlpha(255) : Gray._200.withAlpha(15)); - // This thing doesnt work on compiled jars... - final Class clazz = Class.forName("com.intellij.openapi.wm.impl.status.StatusBarUI$BackgroundPainter"); - - StaticPatcher.setFinalStatic(clazz, "BORDER_TOP_COLOR", UIManager.getColor("StatusBar.topColor").brighter().brighter()); - StaticPatcher.setFinalStatic(clazz, "BORDER2_TOP_COLOR", UIManager.getColor("StatusBar.topColor2")); - StaticPatcher.setFinalStatic(clazz, "BORDER_BOTTOM_COLOR", UIManager.getColor("StatusBar.bottomColor")); - StaticPatcher.setFinalStatic(SettingsTreeView.class, "FOREGROUND", UIManager.getColor("Tree.foreground")); - + if (MTConfig.getInstance().isMaterialTheme()) { + // Replace Gray with a clear and transparent color + final Gray gray = Gray._85; + final Color alphaGray = gray.withAlpha(1); + StaticPatcher.setFinalStatic(Gray.class, "_85", alphaGray); + StaticPatcher.setFinalStatic(Gray.class, "_40", alphaGray); + StaticPatcher.setFinalStatic(Gray.class, "_145", alphaGray); + StaticPatcher.setFinalStatic(Gray.class, "_255", alphaGray); + StaticPatcher.setFinalStatic(Gray.class, "_201", alphaGray); + + // Quick info border + StaticPatcher.setFinalStatic(Gray.class, "_90", gray.withAlpha(25)); + + // tool window color + final boolean dark = MTConfig.getInstance().getSelectedTheme().isDark(); + StaticPatcher.setFinalStatic(Gray.class, "_15", dark ? Gray._15.withAlpha(255) : Gray._200.withAlpha(15)); + // This thing doesnt work on compiled jars... + final Class clazz = Class.forName("com.intellij.openapi.wm.impl.status.StatusBarUI$BackgroundPainter"); + + StaticPatcher.setFinalStatic(clazz, "BORDER_TOP_COLOR", UIManager.getColor("StatusBar.topColor").brighter().brighter()); + StaticPatcher.setFinalStatic(clazz, "BORDER2_TOP_COLOR", UIManager.getColor("StatusBar.topColor2")); + StaticPatcher.setFinalStatic(clazz, "BORDER_BOTTOM_COLOR", UIManager.getColor("StatusBar.bottomColor")); + StaticPatcher.setFinalStatic(SettingsTreeView.class, "FOREGROUND", UIManager.getColor("Tree.foreground")); + } } static void patchPanels() throws Exception { - final Object color = UIManager.getColor("Panel.background"); - StaticPatcher.setFinalStatic(UIUtil.class, "CONTRAST_BORDER_COLOR", color); - StaticPatcher.setFinalStatic(UIUtil.class, "BORDER_COLOR", color); - StaticPatcher.setFinalStatic(UIUtil.class, "AQUA_SEPARATOR_FOREGROUND_COLOR", color); - } - - static void patchMemoryIndicator() throws Exception { - final Object usedColor = UIManager.getColor("MemoryIndicator.usedColor"); - final Object unusedColor = UIManager.getColor("MemoryIndicator.unusedColor"); - if (usedColor == null || unusedColor == null) { - return; + if (MTConfig.getInstance().isMaterialTheme()) { + final Color color = UIManager.getColor("Panel.background"); + StaticPatcher.setFinalStatic(UIUtil.class, "CONTRAST_BORDER_COLOR", ColorUtil.withAlpha(color, .05)); + StaticPatcher.setFinalStatic(UIUtil.class, "BORDER_COLOR", color); + StaticPatcher.setFinalStatic(UIUtil.class, "AQUA_SEPARATOR_FOREGROUND_COLOR", color); } - StaticPatcher.setFinalStatic(MemoryUsagePanel.class, "USED_COLOR", usedColor); - StaticPatcher.setFinalStatic(MemoryUsagePanel.class, "UNUSED_COLOR", unusedColor); - - final Field[] fields = MemoryUsagePanel.class.getDeclaredFields(); + final Field[] fields = DarculaUIUtil.class.getDeclaredFields(); final Object[] objects = Arrays.stream(fields) - .filter(f -> f.getType().equals(Color.class)) + .filter(f -> f.getType().equals(JBColor.class)) .toArray(); - StaticPatcher.setFinalStatic((Field) objects[0], usedColor); - StaticPatcher.setFinalStatic((Field) objects[1], unusedColor); + final Color accentColor = ColorUtil.fromHex(MTConfig.getInstance().getAccentColor()); + final JBColor accentJBColor = new JBColor(accentColor, accentColor); + StaticPatcher.setFinalStatic((Field) objects[0], accentJBColor); + StaticPatcher.setFinalStatic((Field) objects[1], accentJBColor); + } + + static void patchMemoryIndicator() throws Exception { + if (MTConfig.getInstance().isMaterialTheme()) { + final Object usedColor = UIManager.getColor("MemoryIndicator.usedColor"); + final Object unusedColor = UIManager.getColor("MemoryIndicator.unusedColor"); + if (usedColor == null || unusedColor == null) { + return; + } + + StaticPatcher.setFinalStatic(MemoryUsagePanel.class, "USED_COLOR", usedColor); + StaticPatcher.setFinalStatic(MemoryUsagePanel.class, "UNUSED_COLOR", unusedColor); + + final Field[] fields = MemoryUsagePanel.class.getDeclaredFields(); + final Object[] objects = Arrays.stream(fields) + .filter(f -> f.getType().equals(Color.class)) + .toArray(); + StaticPatcher.setFinalStatic((Field) objects[0], usedColor); + StaticPatcher.setFinalStatic((Field) objects[1], unusedColor); + } } static void patchQuickInfo() throws Exception { @@ -149,7 +166,8 @@ static void patchAutocomplete() throws Exception { final String accentColor = MTConfig.getInstance().getAccentColor(); final JBColor jbAccentColor = new JBColor(ColorUtil.fromHex(accentColor), ColorUtil.fromHex(accentColor)); - final Color backgroundSelectedColor = UIManager.getColor("Autocomplete.selectionbackground"); + final Color defaultValue = UIUtil.getListSelectionBackground(); + final Color backgroundSelectedColor = ObjectUtils.notNull(UIManager.getColor("Autocomplete.selectionbackground"), defaultValue); final Field[] fields = LookupCellRenderer.class.getDeclaredFields(); final Object[] objects = Arrays.stream(fields) @@ -169,6 +187,10 @@ static void patchAutocomplete() throws Exception { } static void patchNotifications() throws Exception { + if (!MTConfig.getInstance().isMaterialTheme()) { + return; + } + final Color notifBg = UIManager.getColor("Notifications.background"); final Color notifBorder = UIManager.getColor("Notifications.borderColor"); if (notifBg == null || notifBorder == null) { @@ -185,6 +207,10 @@ static void patchNotifications() throws Exception { } private static void replaceToolBalloons() throws Exception { + if (!MTConfig.getInstance().isMaterialTheme()) { + return; + } + final Constructor declaredConstructor = MessageType.class.getDeclaredConstructor(Icon.class, Color.class, Color.class); declaredConstructor.setAccessible(true); final Color errorBackground = UIManager.getColor("Notifications.errorBackground"); @@ -213,6 +239,10 @@ private static void replaceToolBalloons() throws Exception { } private static void patchDialogs() throws Exception { + if (!MTConfig.getInstance().isMaterialTheme()) { + return; + } + Color color = UIManager.getColor("Dialog.titleColor"); if (color == null) { color = Gray._55; @@ -242,15 +272,17 @@ static void patchScrollbars() throws Exception { } public static void patchVCS() throws Exception { - final Color color = ObjectUtils.notNull(UIManager.getColor("material.mergeCommits"), new ColorUIResource(0x00000000)); - final Color commitsColor = new JBColor(color, color); + if (MTConfig.getInstance().isMaterialTheme()) { + final Color color = ObjectUtils.notNull(UIManager.getColor("material.mergeCommits"), new ColorUIResource(0x00000000)); + final Color commitsColor = new JBColor(color, color); - final Field[] fields = CurrentBranchHighlighter.class.getDeclaredFields(); - final Object[] objects = Arrays.stream(fields) - .filter(f -> f.getType().equals(JBColor.class)) - .toArray(); + final Field[] fields = CurrentBranchHighlighter.class.getDeclaredFields(); + final Object[] objects = Arrays.stream(fields) + .filter(f -> f.getType().equals(JBColor.class)) + .toArray(); - StaticPatcher.setFinalStatic((Field) objects[0], commitsColor); + StaticPatcher.setFinalStatic((Field) objects[0], commitsColor); + } final Field[] fields2 = MergeCommitsHighlighter.class.getDeclaredFields(); final Object[] objects2 = Arrays.stream(fields2) diff --git a/src/main/java/com/chrisrm/idea/themes/MTWallpaperComponent.java b/src/main/java/com/chrisrm/idea/wallpaper/MTWallpaperComponent.java similarity index 99% rename from src/main/java/com/chrisrm/idea/themes/MTWallpaperComponent.java rename to src/main/java/com/chrisrm/idea/wallpaper/MTWallpaperComponent.java index e9c3b677c..687d37f42 100644 --- a/src/main/java/com/chrisrm/idea/themes/MTWallpaperComponent.java +++ b/src/main/java/com/chrisrm/idea/wallpaper/MTWallpaperComponent.java @@ -24,7 +24,7 @@ * */ -package com.chrisrm.idea.themes; +package com.chrisrm.idea.wallpaper; import com.chrisrm.idea.MTConfig; import com.chrisrm.idea.config.ConfigNotifier; diff --git a/src/main/resources/META-INF/plugin.xml b/src/main/resources/META-INF/plugin.xml index d243e3a62..bd5e84f58 100644 --- a/src/main/resources/META-INF/plugin.xml +++ b/src/main/resources/META-INF/plugin.xml @@ -27,7 +27,7 @@ com.chrisrm.idea.MaterialThemeUI Material Theme UI - 0.8.2 + 0.9.4 Hirvi AS @@ -53,7 +53,7 @@ - + + @@ -80,7 +81,7 @@ - com.chrisrm.idea.themes.MTLafComponent + com.chrisrm.idea.MTLafComponent com.chrisrm.idea.schemes.MTThemesComponent @@ -95,7 +96,7 @@ com.chrisrm.idea.icons.MTIconReplacerComponent - com.chrisrm.idea.themes.MTWallpaperComponent + com.chrisrm.idea.wallpaper.MTWallpaperComponent @@ -116,19 +117,19 @@ icon="/icons/actions/material-theme.png"> - - - - @@ -153,6 +154,9 @@ text="Toggle Compact Status Bar" description="Toggle Compact Status Bar" icon="/icons/actions/compactStatusBar.png"> + +

0.9.4

+
    +
  • Improvements of Lighter Theme. Now Lighter Theme extends IntelliJ Look And Feel instead of Darcula.
  • +
  • Fix issues with No Material Theme that triggered some NPEs
  • +
  • Changed Tree foreground color for Lighter Theme
  • +
  • Added more UI Icons
  • +
+ 0.9.3 +
    +
  • Fix Project Open bug
  • +
  • Fix import icon size
  • +
  • Hopefully fix issue with 100% CPU
  • +
  • Change deprecated color
  • +
  • Improvements of disabled material theme
  • +
+ 0.9.2 +
    +
  • Fix issue with File colors for PSI icons
  • +
  • Fix issue with breakpoint icon size
  • +
  • Fix issue with CPU taking 100%
  • +
  • Another set of UI Icons
  • +
+ + 0.9.1 +
    +
  • Set Uppercase bold tabs to Spaced Case Bold Tabs
  • +
  • Unset Uppercase Bold Tabs to be as default
  • +
  • Fix issue with IDE Tabs not working
  • +
  • Fix issue with changing custom accent resetting settings to defaults
  • +
  • Revert back xdebug listening icon to be like the default one
  • +
+ 0.9.0 +
    +
  • Add custom accent color configuration
  • +
  • Add Uppercase bold tabs to look more like MDTabs
  • +
  • Add Compact Sidebar height configuration
  • +
  • Reduce minimal length of tabs to 18
  • +
  • Add a border to the editor when tabs placement is left or right
  • +
+ + + 0.8.1 +
    +
  • Set accent color to non-customizable search boxes
  • +
  • Fix issues with Elements not being themed
  • +
  • Fix action buttons not working
  • +
  • Add background color to search result
  • +
+ 0.8.0
  • Allow customization of file status colors
  • diff --git a/src/main/resources/colors/Material Theme - Darker.xml b/src/main/resources/colors/Material Theme - Darker.xml index 07828e393..18bcca70f 100644 --- a/src/main/resources/colors/Material Theme - Darker.xml +++ b/src/main/resources/colors/Material Theme - Darker.xml @@ -2805,7 +2805,7 @@