Skip to content

Commit

Permalink
Merge branch 'master' into master2
Browse files Browse the repository at this point in the history
# Conflicts:
#	CHANGELOG.md
#	src/main/resources/META-INF/plugin.xml
  • Loading branch information
mallowigi committed Jun 9, 2017
2 parents c641db9 + acf73e7 commit e5dda06
Show file tree
Hide file tree
Showing 21 changed files with 421 additions and 19 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# Changelog

## 0.4.1
- Change behavior of custom wallpaper to not disable the background if the user unchecks the option, allowing to set custom wallpaper with the IDE
- Add Disable option for the current theme indicator in the status bar
- Fix issue with SQLite icon
- Theme notification popups
- Add Indicator in Status Bar for current theme
- Fix some filelist icons

## 0.4.0
- A lot more file icons!
- Fix partly syntax highlight for HOCON, Groovy, ERB, Scala, Kotlin and Hibernate
Expand Down
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,16 @@ Component Settings:
- *Material Icons*: Enable/Disable the Material Theme icons to the original ones
- *Project View Decorators*: Enable/Disable the Project View Decorators such as "current opened folders" indicators

## Custom Wallpaper

*Custom Wallpaper* is not a feature made by the plugin but instead make use of one of the features of the IDE to set a background image.
You can find it by opening the action panel (`Cmd-shift-a`) and type *Set background image*. The plugin option mainly make use of this feature unknown by many users.

Therefore some things need to be known:
- If you rather want to use the IDE's feature, turn off the option in the Material Theme completely. This will prevent the background to be changed at start.
- If you want to disable the background completely, set the custom wallpaper path to be empty and the checkbox on, then click Apply, and finally uncheck the option and save.
- And same if you want to disable the plugin, it will not revert back the blank wallpaper, you will have to open the IDE's dialog.

More features are to come!

## Development
Expand Down
17 changes: 15 additions & 2 deletions src/main/java/com/chrisrm/idea/MTConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
)
public class MTConfig implements PersistentStateComponent<MTConfig> {
public static final String DEFAULT_BG = "https://raw.githubusercontent" +
".com/mallowigi/material-theme-jetbrains-extended/master/src/main/resources/themes/wall.jpg";
private MTTheme selectedTheme = MTTheme.DEFAULT;
".com/mallowigi/material-theme-jetbrains-eap/master/src/main/resources/themes/wall.jpg,60";
public MTTheme selectedTheme = MTTheme.DEFAULT;
public String highlightColor;
public boolean highlightColorEnabled = false;
public Integer highlightThickness;
Expand All @@ -39,6 +39,7 @@ public class MTConfig implements PersistentStateComponent<MTConfig> {
public boolean useProjectViewDecorators = true;
public boolean hideFileIcons = false;
public boolean compactSidebar = false;
public boolean statusBarTheme = true;

public MTConfig() {
MTTheme theme = this.selectedTheme;
Expand Down Expand Up @@ -317,4 +318,16 @@ public void setCompactSidebar(boolean compactSidebar) {
public boolean isCompactSidebarChanged(boolean compactSidebar) {
return this.compactSidebar != compactSidebar;
}

public boolean isStatusBarTheme() {
return statusBarTheme;
}

public void setIsStatusBarTheme(boolean isStatusBarTheme) {
this.statusBarTheme = isStatusBarTheme;
}

public boolean isStatusBarThemeChanged(boolean statusBarTheme) {
return this.statusBarTheme != statusBarTheme;
}
}
3 changes: 3 additions & 0 deletions src/main/java/com/chrisrm/idea/config/MTConfigurable.java
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ protected void setFormState(MTForm mtForm, MTConfig mtConfig) {
form.setUseProjectViewDecorators(mtConfig.isUseProjectViewDecorators());
form.setHideFileIcons(mtConfig.getHideFileIcons());
form.setIsCompactSidebar(mtConfig.isCompactSidebar());
form.setIsStatusBarTheme(mtConfig.isStatusBarTheme());
form.afterStateSet();
}

Expand All @@ -72,6 +73,7 @@ protected void doApply(MTForm mtForm, MTConfig mtConfig) throws ConfigurationExc
mtConfig.setUseProjectViewDecorators(form.getUseProjectViewDecorators());
mtConfig.setHideFileIcons(form.getHideFileIcons());
mtConfig.setCompactSidebar(form.isCompactSidebar());
mtConfig.setIsStatusBarTheme(form.isStatusBarTheme());
mtConfig.fireChanged();
}

Expand All @@ -89,6 +91,7 @@ protected boolean checkModified(MTForm mtForm, MTConfig mtConfig) {
modified = modified || mtConfig.isUseProjectViewDecoratorsChanged(form.getUseProjectViewDecorators());
modified = modified || mtConfig.isHideFileIconsChanged(form.getHideFileIcons());
modified = modified || mtConfig.isCompactSidebarChanged(form.isCompactSidebar());
modified = modified || mtConfig.isStatusBarThemeChanged(form.isStatusBarTheme());

return modified;
}
Expand Down
21 changes: 20 additions & 1 deletion src/main/java/com/chrisrm/idea/config/ui/MTForm.java
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ public void setIsWallpaperSet(boolean isWallpaperSet) {
private JCheckBox isMaterialDesignCheckbox;
private JCheckBox isMaterialIconsCheckbox;
private JCheckBox isProjectViewDecoratorsCheckbox;
private JCheckBox isThemeInStatusCheckbox;
// JFormDesigner - End of variables declaration //GEN-END:variables

public MTForm() {
Expand Down Expand Up @@ -193,6 +194,14 @@ public boolean isCompactSidebar() {
return this.isCompactSidebarCheckbox.isSelected();
}

public void setIsStatusBarTheme(boolean statusBarTheme) {
this.isThemeInStatusCheckbox.setSelected(statusBarTheme);
}

public boolean isStatusBarTheme() {
return this.isThemeInStatusCheckbox.isSelected();
}

private void enableDisableCustomBg(boolean isWallpaperSet) {
this.customBgLabel.setEnabled(isWallpaperSet);
this.customBgChooser.setEnabled(isWallpaperSet);
Expand Down Expand Up @@ -260,6 +269,7 @@ private void initComponents() {
isMaterialDesignCheckbox = new JCheckBox();
isMaterialIconsCheckbox = new JCheckBox();
isProjectViewDecoratorsCheckbox = new JCheckBox();
isThemeInStatusCheckbox = new JCheckBox();

//======== content ========
{
Expand Down Expand Up @@ -399,7 +409,7 @@ private void initComponents() {
//======== panel3 ========
{
panel3.setBorder(new TitledBorder(new EtchedBorder(), bundle.getString("MTForm.panel3.border")));
panel3.setLayout(new GridLayoutManager(5, 3, new Insets(0, 0, 0, 0), -1, -1));
panel3.setLayout(new GridLayoutManager(6, 3, new Insets(0, 0, 0, 0), -1, -1));

//---- isWallpaperSetCheckbox ----
isWallpaperSetCheckbox.setLabel(bundle.getString("MTForm.isWallpaperSetCheckbox.label"));
Expand Down Expand Up @@ -466,6 +476,15 @@ private void initComponents() {
GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW,
GridConstraints.SIZEPOLICY_CAN_SHRINK | GridConstraints.SIZEPOLICY_CAN_GROW,
null, null, null));

//---- isThemeInStatusCheckbox ----
isThemeInStatusCheckbox.setText(bundle.getString("MTForm.themeStatus"));
isThemeInStatusCheckbox.setToolTipText(bundle.getString("MTForm.themeStatus.tooltip"));
panel3.add(isThemeInStatusCheckbox, new GridConstraints(5, 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));
}
content.add(panel3, new GridConstraints(2, 0, 1, 1,
GridConstraints.ANCHOR_CENTER, GridConstraints.FILL_BOTH,
Expand Down
10 changes: 9 additions & 1 deletion src/main/java/com/chrisrm/idea/config/ui/MTForm.jfd
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ new FormModel {
} )
add( new FormContainer( "javax.swing.JPanel", new FormLayoutManager( class com.intellij.uiDesigner.core.GridLayoutManager ) {
"$columnCount": 3
"$rowCount": 5
"$rowCount": 6
} ) {
name: "panel3"
"border": new javax.swing.border.TitledBorder( #EtchedBorder0, "i18nKey=MTForm.panel3.border" )
Expand Down Expand Up @@ -255,6 +255,14 @@ new FormModel {
"row": 4
"anchor": 8
} )
add( new FormComponent( "javax.swing.JCheckBox" ) {
name: "isThemeInStatusCheckbox"
"text": new FormMessage( null, "MTForm.themeStatus" )
"toolTipText": new FormMessage( null, "MTForm.themeStatus.tooltip" )
}, new FormLayoutConstraints( class com.intellij.uiDesigner.core.GridConstraints ) {
"row": 5
"anchor": 8
} )
}, new FormLayoutConstraints( class com.intellij.uiDesigner.core.GridConstraints ) {
"row": 2
"fill": 3
Expand Down
41 changes: 41 additions & 0 deletions src/main/java/com/chrisrm/idea/status/MTStatusBarComponent.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
package com.chrisrm.idea.status;

import com.intellij.openapi.components.AbstractProjectComponent;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.wm.StatusBar;
import com.intellij.openapi.wm.WindowManager;
import org.jetbrains.annotations.NotNull;

public class MTStatusBarComponent extends AbstractProjectComponent {
private MTStatusBarManager statusBarWidget;

public MTStatusBarComponent(@NotNull Project project) {
super(project);
}

@Override
public void initComponent() {
statusBarWidget = MTStatusBarManager.create(myProject);
}

@Override
public void disposeComponent() {
statusBarWidget.dispose();
}

@NotNull
@Override
public String getComponentName() {
return "MTStatusBarComponent";
}

@Override
public void projectOpened() {
statusBarWidget.install();
}

@Override
public void projectClosed() {
statusBarWidget.uninstall();
}
}
75 changes: 75 additions & 0 deletions src/main/java/com/chrisrm/idea/status/MTStatusBarManager.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
package com.chrisrm.idea.status;

import com.chrisrm.idea.MTConfig;
import com.chrisrm.idea.config.ConfigNotifier;
import com.intellij.openapi.Disposable;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.project.DumbAware;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.wm.StatusBar;
import com.intellij.openapi.wm.WindowManager;
import com.intellij.util.messages.MessageBusConnection;
import org.jetbrains.annotations.NotNull;

class MTStatusBarManager implements Disposable, DumbAware {

private final Project project;
private boolean statusEnabled;
private MTStatusWidget mtStatusWidget;
private final MessageBusConnection connect;

private MTStatusBarManager(@NotNull Project project) {
this.project = project;
this.mtStatusWidget = new MTStatusWidget();
this.statusEnabled = MTConfig.getInstance().isStatusBarTheme();

connect = project.getMessageBus().connect();
connect.subscribe(ConfigNotifier.CONFIG_TOPIC, this::refreshWidget);
}

public static MTStatusBarManager create(@NotNull Project project) {
return new MTStatusBarManager(project);
}

private void refreshWidget(MTConfig mtConfig) {
if (mtConfig.isStatusBarThemeChanged(this.statusEnabled)) {
statusEnabled = mtConfig.isStatusBarTheme();

if (statusEnabled){
this.install();
} else {
this.uninstall();
}
}

mtStatusWidget.refresh();
}

void install() {
StatusBar statusBar = WindowManager.getInstance().getStatusBar(project);
if (statusBar != null) {
statusBar.addWidget(mtStatusWidget, "before Position", project);
}
}


void uninstall() {
StatusBar statusBar = WindowManager.getInstance().getStatusBar(project);
if (statusBar != null) {
statusBar.removeWidget(mtStatusWidget.ID());
}
}

@Override
public void dispose() {
if (!ApplicationManager.getApplication().isHeadlessEnvironment()) {
if (mtStatusWidget != null) {
uninstall();
mtStatusWidget = null;
}
}
connect.disconnect();
}


}
Loading

0 comments on commit e5dda06

Please sign in to comment.