Skip to content

Commit

Permalink
Merge branch 'master' into master2
Browse files Browse the repository at this point in the history
# Conflicts:
#	src/main/resources/META-INF/plugin.xml
  • Loading branch information
mallowigi committed Jul 10, 2017
2 parents cfedaf1 + 85fdc65 commit ef01577
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 33 deletions.
Binary file modified Material Theme.zip
Binary file not shown.
40 changes: 20 additions & 20 deletions src/main/java/com/chrisrm/idea/MTConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,26 @@ public void loadState(MTConfig state) {
XmlSerializerUtil.copyBean(state, this);
}

/**
* Fire an event to the application bus that the settings have changed
*
* @param form
*/
public void fireBeforeChanged(MTForm form) {
ApplicationManager.getApplication().getMessageBus()
.syncPublisher(BeforeConfigNotifier.BEFORE_CONFIG_TOPIC)
.beforeConfigChanged(this, form);
}

/**
* Fire an event to the application bus that the settings have changed
*/
public void fireChanged() {
ApplicationManager.getApplication().getMessageBus()
.syncPublisher(ConfigNotifier.CONFIG_TOPIC)
.configChanged(this);
}

/**
* Get the set highlight color
*
Expand Down Expand Up @@ -240,26 +260,6 @@ public boolean isBoldTabsChanged(boolean isBoldTabs) {
return this.isBoldTabs != isBoldTabs;
}

/**
* Fire an event to the application bus that the settings have changed
*
* @param form
*/
public void fireBeforeChanged(MTForm form) {
ApplicationManager.getApplication().getMessageBus()
.syncPublisher(BeforeConfigNotifier.BEFORE_CONFIG_TOPIC)
.beforeConfigChanged(this, form);
}

/**
* Fire an event to the application bus that the settings have changed
*/
public void fireChanged() {
ApplicationManager.getApplication().getMessageBus()
.syncPublisher(ConfigNotifier.CONFIG_TOPIC)
.configChanged(this);
}

public boolean getIsBoldTabs() {
return isBoldTabs;
}
Expand Down
1 change: 1 addition & 0 deletions src/main/java/com/chrisrm/idea/MTTheme.java
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ public Color getDisabledColor() {
return ColorUtil.fromHex(properties.getProperty("material.disabled"));
}

@NotNull
public String getEditorColorsScheme() {
return editorColorsScheme;
}
Expand Down
26 changes: 14 additions & 12 deletions src/main/java/com/chrisrm/idea/themes/MTLafComponent.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import com.chrisrm.idea.messages.MaterialThemeBundle;
import com.chrisrm.idea.ui.*;
import com.chrisrm.idea.utils.UIReplacer;
import com.intellij.ide.AppLifecycleListener;
import com.intellij.ide.ui.LafManager;
import com.intellij.openapi.actionSystem.impl.ActionToolbarImpl;
import com.intellij.openapi.application.Application;
Expand All @@ -16,6 +15,8 @@
import com.intellij.openapi.components.ApplicationComponent;
import com.intellij.openapi.fileTypes.ex.FileTypeManagerEx;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.project.ProjectManager;
import com.intellij.openapi.project.ProjectManagerListener;
import com.intellij.openapi.ui.Messages;
import com.intellij.openapi.wm.WindowManager;
import com.intellij.openapi.wm.impl.status.IdeStatusBarImpl;
Expand Down Expand Up @@ -59,7 +60,6 @@ public void initComponent() {
connect = ApplicationManager.getApplication().getMessageBus().connect();
connect.subscribe(ConfigNotifier.CONFIG_TOPIC, this::onSettingsChanged);
connect.subscribe(BeforeConfigNotifier.BEFORE_CONFIG_TOPIC, (this::onBeforeSettingsChanged));

}

/**
Expand All @@ -72,18 +72,20 @@ public static void hackTitleLabel() {
ClassPool cp = new ClassPool(true);
cp.insertClassPath(new ClassClassPath(CaptionPanel.class));
CtClass ctClass = cp.get("com.intellij.ui.TitlePanel");
CtConstructor declaredConstructor = ctClass.getDeclaredConstructor(new CtClass[]{cp.get("javax.swing.Icon"), cp.get("javax.swing" +
".Icon")});
CtConstructor declaredConstructor = ctClass.getDeclaredConstructor(new CtClass[] {cp.get("javax.swing.Icon"), cp.get("javax.swing" +
".Icon")});
declaredConstructor.instrument(new ExprEditor() {
@Override
public void edit(MethodCall m) throws CannotCompileException {
if (m.getMethodName().equals("empty")) {
// Replace insets
m.replace("{ $1 = 10; $2 = 10; $3 = 10; $4 = 10; $_ = $proceed($$); }");
} else if (m.getMethodName().equals("setHorizontalAlignment")) {
}
else if (m.getMethodName().equals("setHorizontalAlignment")) {
// Set title at the left
m.replace("{ $1 = javax.swing.SwingConstants.LEFT; $_ = $proceed($$); }");
} else if (m.getMethodName().equals("setBorder")) {
}
else if (m.getMethodName().equals("setBorder")) {
// Bigger heading
m.replace("{ $_ = $proceed($$); myLabel.setFont(myLabel.getFont().deriveFont(1, com.intellij.util.ui.JBUI.scale(16.0f))); }");
}
Expand All @@ -96,7 +98,6 @@ public void edit(MethodCall m) throws CannotCompileException {
}
}


@Override
public void disposeComponent() {
connect.disconnect();
Expand Down Expand Up @@ -163,7 +164,8 @@ private void restartIde() {
Application application = ApplicationManager.getApplication();
if (application instanceof ApplicationImpl) {
((ApplicationImpl) application).restart(true);
} else {
}
else {
application.restart();
}
}
Expand All @@ -178,7 +180,7 @@ private static void hackSearchTextField() throws NotFoundException, CannotCompil

CtClass darculaClass = cp.get("com.intellij.ide.ui.laf.darcula.ui.DarculaTextFieldUI");
CtClass componentClass = cp.get("javax.swing.JComponent");
CtMethod createUI = darculaClass.getDeclaredMethod("createUI", new CtClass[]{componentClass});
CtMethod createUI = darculaClass.getDeclaredMethod("createUI", new CtClass[] {componentClass});
createUI.setBody("{ return com.chrisrm.idea.ui.MTTextFieldFactory.newInstance($1); }");
darculaClass.toClass();
}
Expand Down Expand Up @@ -248,9 +250,10 @@ private void replaceStatusBar() {
MessageBusConnection connect = ApplicationManager.getApplication().getMessageBus().connect();

// On app init, set the statusbar borders
connect.subscribe(AppLifecycleListener.TOPIC, new AppLifecycleListener() {
connect.subscribe(ProjectManager.TOPIC, new ProjectManagerListener() {

@Override
public void appStarting(@Nullable Project projectFromCommandLine) {
public void projectOpened(@Nullable Project projectFromCommandLine) {
boolean compactSidebar = MTConfig.getInstance().isCompactStatusBar();
setStatusBarBorders(compactSidebar);
}
Expand All @@ -261,7 +264,6 @@ public void appStarting(@Nullable Project projectFromCommandLine) {
boolean compactSidebar = mtConfig.isCompactStatusBar();
setStatusBarBorders(compactSidebar);
});

}

private void setStatusBarBorders(boolean compactSidebar) {
Expand Down
4 changes: 4 additions & 0 deletions src/main/java/com/chrisrm/idea/themes/MTThemeManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,10 @@ public void activate() {
* @param mtTheme
*/
public void activate(MTTheme mtTheme) {
if (mtTheme == null) {
mtTheme = MTTheme.DEFAULT;
}

MTConfig.getInstance().setSelectedTheme(mtTheme);

try {
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/META-INF/plugin.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<idea-plugin>
<id>com.chrisrm.idea.MaterialThemeUI</id>
<name>Material Theme UI</name>
<version>0.5.3.2</version>
<version>0.5.3.4</version>
<vendor email="[email protected]" url="https://hirvi.no">Hirvi AS</vendor>

<description><![CDATA[
Expand Down

0 comments on commit ef01577

Please sign in to comment.