Skip to content

Commit 97d97a3

Browse files
authored
Merge pull request #231 from shuzijun/gradle
Modify JCEF
2 parents 21e011c + ad4c7e2 commit 97d97a3

File tree

8 files changed

+155
-145
lines changed

8 files changed

+155
-145
lines changed

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ dependencies {
2222
}
2323
compile 'org.scilab.forge:jlatexmath:1.0.7'
2424
compile 'org.apache.commons:commons-lang3:3.9'
25-
compile fileTree(dir: 'src/main/resources/lib', include: ['*.jar'])
25+
//compile fileTree(dir: 'src/main/resources/lib', include: ['*.jar'])
2626

2727
}
2828

src/main/java/com/shuzijun/leetcode/plugin/actions/toolbar/LoginAction.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,6 @@ public void actionPerformed(AnActionEvent anActionEvent, Config config) {
6969
public void run() {
7070
LoginFrame loginFrame = new LoginFrame(anActionEvent.getProject(), tree);
7171
loginFrame.loadComponent();
72-
loginFrame.show();
7372
}
7473
});
7574
}
@@ -79,7 +78,6 @@ public void run() {
7978
public void run() {
8079
LoginFrame loginFrame = new LoginFrame(anActionEvent.getProject(), tree);
8180
loginFrame.loadComponent();
82-
loginFrame.show();
8381
}
8482
});
8583
}

src/main/java/com/shuzijun/leetcode/plugin/model/Config.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,11 @@ public class Config {
8585
*/
8686
private String levelColour = Constant.LEVEL_COLOUR;
8787

88+
/**
89+
* 使用jcef渲染
90+
*/
91+
private Boolean jcef = false;
92+
8893
private List<String> favoriteList;
8994

9095
public String getId() {
@@ -295,6 +300,13 @@ public void setEnglishContent(Boolean englishContent) {
295300
this.englishContent = englishContent;
296301
}
297302

303+
public Boolean getJcef() {
304+
return jcef;
305+
}
306+
307+
public void setJcef(Boolean jcef) {
308+
this.jcef = jcef;
309+
}
298310

299311
public boolean isModified(Config config){
300312
if(config ==null){
@@ -314,6 +326,8 @@ public boolean isModified(Config config){
314326
return false;
315327
if (customTemplate != null ? !customTemplate.equals(config.customTemplate) : config.customTemplate != null)
316328
return false;
329+
if (jcef != null ? !jcef.equals(config.jcef) : config.jcef != null)
330+
return false;
317331
return levelColour != null ? levelColour.equals(config.levelColour) : config.levelColour == null;
318332
}
319333

src/main/java/com/shuzijun/leetcode/plugin/setting/SettingUI.form

Lines changed: 23 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="com.shuzijun.leetcode.plugin.setting.SettingUI">
3-
<grid id="27dc6" binding="mainPanel" layout-manager="GridLayoutManager" row-count="12" column-count="11" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
3+
<grid id="27dc6" binding="mainPanel" layout-manager="GridLayoutManager" row-count="11" column-count="11" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
44
<margin top="10" left="10" bottom="10" right="10"/>
55
<constraints>
66
<xy x="20" y="20" width="972" height="750"/>
@@ -20,7 +20,7 @@
2020
</component>
2121
<vspacer id="75cf7">
2222
<constraints>
23-
<grid row="11" column="0" row-span="1" col-span="1" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
23+
<grid row="10" column="0" row-span="1" col-span="1" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
2424
</constraints>
2525
</vspacer>
2626
<component id="d0e55" class="javax.swing.JLabel">
@@ -68,36 +68,17 @@
6868
<text value="TempFilePath:"/>
6969
</properties>
7070
</component>
71-
<component id="540b9" class="javax.swing.JLabel">
72-
<constraints>
73-
<grid row="5" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
74-
</constraints>
75-
<properties>
76-
<text value="JCEFFilePath:"/>
77-
</properties>
78-
</component>
79-
<component id="8a26f" class="javax.swing.JTextField" binding="JCEFFileField">
80-
<constraints>
81-
<grid row="5" column="1" row-span="1" col-span="10" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false">
82-
<preferred-size width="150" height="-1"/>
83-
</grid>
84-
</constraints>
85-
<properties>
86-
<enabled value="false"/>
87-
<visible value="true"/>
88-
</properties>
89-
</component>
9071
<component id="ead03" class="javax.swing.JCheckBox" binding="customCodeBox">
9172
<constraints>
92-
<grid row="6" column="1" row-span="1" col-span="2" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
73+
<grid row="5" column="1" row-span="1" col-span="2" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
9374
</constraints>
9475
<properties>
9576
<text value="Custom Template"/>
9677
</properties>
9778
</component>
9879
<component id="d8719" class="javax.swing.JCheckBox" binding="updateCheckBox">
9980
<constraints>
100-
<grid row="6" column="3" row-span="1" col-span="2" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
81+
<grid row="5" column="3" row-span="1" col-span="2" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
10182
</constraints>
10283
<properties>
10384
<selected value="true"/>
@@ -106,7 +87,7 @@
10687
</component>
10788
<component id="1b718" class="javax.swing.JLabel" binding="templateConfigHelp">
10889
<constraints>
109-
<grid row="7" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
90+
<grid row="6" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
11091
</constraints>
11192
<properties>
11293
<background color="-12828863"/>
@@ -116,7 +97,7 @@
11697
</component>
11798
<component id="8672f" class="javax.swing.JLabel">
11899
<constraints>
119-
<grid row="8" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
100+
<grid row="7" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
120101
</constraints>
121102
<properties>
122103
<text value="CodeFileName:"/>
@@ -125,15 +106,15 @@
125106
</component>
126107
<component id="8aeca" class="javax.swing.JLabel">
127108
<constraints>
128-
<grid row="9" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="9" fill="0" indent="0" use-parent-layout="false"/>
109+
<grid row="8" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="9" fill="0" indent="0" use-parent-layout="false"/>
129110
</constraints>
130111
<properties>
131112
<text value="CodeTemplate:"/>
132113
</properties>
133114
</component>
134115
<component id="c84c8" class="javax.swing.JLabel">
135116
<constraints>
136-
<grid row="10" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="9" fill="0" indent="0" use-parent-layout="false"/>
117+
<grid row="9" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="9" fill="0" indent="0" use-parent-layout="false"/>
137118
</constraints>
138119
<properties>
139120
<text value="TemplateConstant:"/>
@@ -266,7 +247,7 @@
266247
</component>
267248
<component id="cb2ec" class="javax.swing.JCheckBox" binding="proxyCheckBox">
268249
<constraints>
269-
<grid row="6" column="7" row-span="1" col-span="2" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
250+
<grid row="5" column="7" row-span="1" col-span="2" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
270251
</constraints>
271252
<properties>
272253
<enabled value="false"/>
@@ -276,31 +257,31 @@
276257
</component>
277258
<component id="396f1" class="javax.swing.JCheckBox" binding="englishContentBox">
278259
<constraints>
279-
<grid row="6" column="9" row-span="1" col-span="2" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
260+
<grid row="5" column="9" row-span="1" col-span="2" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
280261
</constraints>
281262
<properties>
282263
<text value="English Content"/>
283264
</properties>
284265
</component>
285266
<component id="eace7" class="javax.swing.JSeparator">
286267
<constraints>
287-
<grid row="7" column="1" row-span="1" col-span="10" vsize-policy="3" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false">
268+
<grid row="6" column="1" row-span="1" col-span="10" vsize-policy="3" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false">
288269
<minimum-size width="-1" height="2"/>
289270
</grid>
290271
</constraints>
291272
<properties/>
292273
</component>
293274
<grid id="d2885" binding="codeFileName" layout-manager="BorderLayout" hgap="0" vgap="0">
294275
<constraints>
295-
<grid row="8" column="1" row-span="1" col-span="10" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
276+
<grid row="7" column="1" row-span="1" col-span="10" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
296277
</constraints>
297278
<properties/>
298279
<border type="none"/>
299280
<children/>
300281
</grid>
301282
<grid id="3dd05" binding="codeTemplate" layout-manager="BorderLayout" hgap="0" vgap="0">
302283
<constraints>
303-
<grid row="9" column="1" row-span="1" col-span="10" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false">
284+
<grid row="8" column="1" row-span="1" col-span="10" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false">
304285
<preferred-size width="-1" height="200"/>
305286
<maximum-size width="-1" height="200"/>
306287
</grid>
@@ -311,7 +292,7 @@
311292
</grid>
312293
<grid id="df455" binding="templateConstant" layout-manager="BorderLayout" hgap="0" vgap="0">
313294
<constraints>
314-
<grid row="10" column="1" row-span="1" col-span="10" vsize-policy="0" hsize-policy="0" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
295+
<grid row="9" column="1" row-span="1" col-span="10" vsize-policy="0" hsize-policy="0" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
315296
</constraints>
316297
<properties/>
317298
<border type="none"/>
@@ -347,6 +328,15 @@
347328
<toolTipText value="Click change settings"/>
348329
</properties>
349330
</component>
331+
<component id="b4dc2" class="javax.swing.JCheckBox" binding="jcefCheckBox">
332+
<constraints>
333+
<grid row="5" column="5" row-span="1" col-span="2" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
334+
</constraints>
335+
<properties>
336+
<text value="JCEF"/>
337+
<toolTipText value="Version 2020.2+ is supported"/>
338+
</properties>
339+
</component>
350340
</children>
351341
</grid>
352342
</form>

src/main/java/com/shuzijun/leetcode/plugin/setting/SettingUI.java

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
import com.intellij.ide.BrowserUtil;
44
import com.intellij.openapi.application.ApplicationManager;
5-
import com.intellij.openapi.application.PathManager;
65
import com.intellij.openapi.editor.Editor;
76
import com.intellij.openapi.editor.EditorFactory;
87
import com.intellij.openapi.editor.EditorSettings;
@@ -14,6 +13,7 @@
1413
import com.intellij.ui.components.JBPasswordField;
1514
import com.intellij.ui.components.JBScrollPane;
1615
import com.intellij.ui.components.JBTextField;
16+
import com.intellij.ui.jcef.JBCefApp;
1717
import com.intellij.util.net.HttpConfigurable;
1818
import com.shuzijun.leetcode.plugin.listener.ColorListener;
1919
import com.shuzijun.leetcode.plugin.listener.DonateListener;
@@ -46,7 +46,6 @@ public class SettingUI {
4646
private JLabel mediumLabel;
4747
private JLabel hardLabel;
4848
private TextFieldWithBrowseButton fileFolderBtn;
49-
private JTextField JCEFFileField;
5049
private JCheckBox customCodeBox;
5150
private JCheckBox updateCheckBox;
5251
private JCheckBox proxyCheckBox;
@@ -56,6 +55,7 @@ public class SettingUI {
5655
private JPanel codeFileName;
5756
private JPanel codeTemplate;
5857
private JPanel templateConstant;
58+
private JCheckBox jcefCheckBox;
5959

6060

6161
private Editor fileNameEditor = null;
@@ -82,8 +82,6 @@ public void initUI() {
8282
fileFolderBtn.addBrowseFolderListener(new TextBrowseFolderListener(FileChooserDescriptorFactory.createSingleFileOrFolderDescriptor()) {
8383
});
8484

85-
JCEFFileField.setText(PathManager.getPluginsPath() + File.separator + "leetcode-editor" + File.separator + "natives" + File.separator);
86-
8785
customCodeBox.addActionListener(new DonateListener(customCodeBox));
8886
proxyCheckBox.setSelected(HttpConfigurable.getInstance().USE_HTTP_PROXY || HttpConfigurable.getInstance().USE_PROXY_PAC);
8987
proxyCheckBox.addMouseListener(new MouseAdapter(){
@@ -94,6 +92,15 @@ public void mouseClicked(MouseEvent e) {
9492
}
9593
}
9694
});
95+
Boolean jcefSupported;
96+
try {
97+
jcefSupported = JBCefApp.isSupported();
98+
}catch (Exception e){
99+
jcefSupported = false;
100+
}
101+
if(!jcefSupported){
102+
proxyCheckBox.setEnabled(true);
103+
}
97104

98105
templateConfigHelp.addMouseListener(new MouseAdapter() {
99106
@Override
@@ -183,6 +190,7 @@ private void loadSetting() {
183190
mediumLabel.setForeground(colors[1]);
184191
hardLabel.setForeground(colors[2]);
185192

193+
jcefCheckBox.setSelected(config.getJcef());
186194
} else {
187195
Color[] colors = new Config().getFormatLevelColour();
188196
easyLabel.setForeground(colors[0]);
@@ -249,6 +257,7 @@ public void process(Config config) {
249257
config.setCustomTemplate(templateEditor.getDocument().getText());
250258
config.setFormatLevelColour(easyLabel.getForeground(), mediumLabel.getForeground(), hardLabel.getForeground());
251259
config.setEnglishContent(englishContentBox.isSelected());
260+
config.setJcef(jcefCheckBox.isSelected());
252261
}
253262

254263

@@ -270,5 +279,4 @@ public void disposeUIResources() {
270279
this.templateHelpEditor = null;
271280
}
272281
}
273-
274282
}

0 commit comments

Comments
 (0)