7
7
import com .chrisrm .idea .messages .MaterialThemeBundle ;
8
8
import com .chrisrm .idea .ui .*;
9
9
import com .chrisrm .idea .utils .UIReplacer ;
10
- import com .intellij .ide .AppLifecycleListener ;
11
10
import com .intellij .ide .ui .LafManager ;
12
11
import com .intellij .openapi .actionSystem .impl .ActionToolbarImpl ;
13
12
import com .intellij .openapi .application .Application ;
16
15
import com .intellij .openapi .components .ApplicationComponent ;
17
16
import com .intellij .openapi .fileTypes .ex .FileTypeManagerEx ;
18
17
import com .intellij .openapi .project .Project ;
18
+ import com .intellij .openapi .project .ProjectManager ;
19
+ import com .intellij .openapi .project .ProjectManagerListener ;
19
20
import com .intellij .openapi .ui .Messages ;
20
21
import com .intellij .openapi .wm .WindowManager ;
21
22
import com .intellij .openapi .wm .impl .status .IdeStatusBarImpl ;
@@ -59,7 +60,6 @@ public void initComponent() {
59
60
connect = ApplicationManager .getApplication ().getMessageBus ().connect ();
60
61
connect .subscribe (ConfigNotifier .CONFIG_TOPIC , this ::onSettingsChanged );
61
62
connect .subscribe (BeforeConfigNotifier .BEFORE_CONFIG_TOPIC , (this ::onBeforeSettingsChanged ));
62
-
63
63
}
64
64
65
65
/**
@@ -72,18 +72,20 @@ public static void hackTitleLabel() {
72
72
ClassPool cp = new ClassPool (true );
73
73
cp .insertClassPath (new ClassClassPath (CaptionPanel .class ));
74
74
CtClass ctClass = cp .get ("com.intellij.ui.TitlePanel" );
75
- CtConstructor declaredConstructor = ctClass .getDeclaredConstructor (new CtClass []{cp .get ("javax.swing.Icon" ), cp .get ("javax.swing" +
76
- ".Icon" )});
75
+ CtConstructor declaredConstructor = ctClass .getDeclaredConstructor (new CtClass [] {cp .get ("javax.swing.Icon" ), cp .get ("javax.swing" +
76
+ ".Icon" )});
77
77
declaredConstructor .instrument (new ExprEditor () {
78
78
@ Override
79
79
public void edit (MethodCall m ) throws CannotCompileException {
80
80
if (m .getMethodName ().equals ("empty" )) {
81
81
// Replace insets
82
82
m .replace ("{ $1 = 10; $2 = 10; $3 = 10; $4 = 10; $_ = $proceed($$); }" );
83
- } else if (m .getMethodName ().equals ("setHorizontalAlignment" )) {
83
+ }
84
+ else if (m .getMethodName ().equals ("setHorizontalAlignment" )) {
84
85
// Set title at the left
85
86
m .replace ("{ $1 = javax.swing.SwingConstants.LEFT; $_ = $proceed($$); }" );
86
- } else if (m .getMethodName ().equals ("setBorder" )) {
87
+ }
88
+ else if (m .getMethodName ().equals ("setBorder" )) {
87
89
// Bigger heading
88
90
m .replace ("{ $_ = $proceed($$); myLabel.setFont(myLabel.getFont().deriveFont(1, com.intellij.util.ui.JBUI.scale(16.0f))); }" );
89
91
}
@@ -96,7 +98,6 @@ public void edit(MethodCall m) throws CannotCompileException {
96
98
}
97
99
}
98
100
99
-
100
101
@ Override
101
102
public void disposeComponent () {
102
103
connect .disconnect ();
@@ -163,7 +164,8 @@ private void restartIde() {
163
164
Application application = ApplicationManager .getApplication ();
164
165
if (application instanceof ApplicationImpl ) {
165
166
((ApplicationImpl ) application ).restart (true );
166
- } else {
167
+ }
168
+ else {
167
169
application .restart ();
168
170
}
169
171
}
@@ -178,7 +180,7 @@ private static void hackSearchTextField() throws NotFoundException, CannotCompil
178
180
179
181
CtClass darculaClass = cp .get ("com.intellij.ide.ui.laf.darcula.ui.DarculaTextFieldUI" );
180
182
CtClass componentClass = cp .get ("javax.swing.JComponent" );
181
- CtMethod createUI = darculaClass .getDeclaredMethod ("createUI" , new CtClass []{componentClass });
183
+ CtMethod createUI = darculaClass .getDeclaredMethod ("createUI" , new CtClass [] {componentClass });
182
184
createUI .setBody ("{ return com.chrisrm.idea.ui.MTTextFieldFactory.newInstance($1); }" );
183
185
darculaClass .toClass ();
184
186
}
@@ -248,9 +250,10 @@ private void replaceStatusBar() {
248
250
MessageBusConnection connect = ApplicationManager .getApplication ().getMessageBus ().connect ();
249
251
250
252
// On app init, set the statusbar borders
251
- connect .subscribe (AppLifecycleListener .TOPIC , new AppLifecycleListener () {
253
+ connect .subscribe (ProjectManager .TOPIC , new ProjectManagerListener () {
254
+
252
255
@ Override
253
- public void appStarting (@ Nullable Project projectFromCommandLine ) {
256
+ public void projectOpened (@ Nullable Project projectFromCommandLine ) {
254
257
boolean compactSidebar = MTConfig .getInstance ().isCompactStatusBar ();
255
258
setStatusBarBorders (compactSidebar );
256
259
}
@@ -261,7 +264,6 @@ public void appStarting(@Nullable Project projectFromCommandLine) {
261
264
boolean compactSidebar = mtConfig .isCompactStatusBar ();
262
265
setStatusBarBorders (compactSidebar );
263
266
});
264
-
265
267
}
266
268
267
269
private void setStatusBarBorders (boolean compactSidebar ) {
0 commit comments