generated from JetBrains/intellij-platform-plugin-template
-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(extensionPoints): 1.18 Support 2020.1 set JBR with JCEF | 支持 202…
…0.1 设置 JCEF 的 JBR
- Loading branch information
Showing
49 changed files
with
315 additions
and
287 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 14 additions & 41 deletions
55
src/main/java/com/github/linwancen/plugin/graph/ui/webview/Browser.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,55 +1,28 @@ | ||
package com.github.linwancen.plugin.graph.ui.webview; | ||
|
||
import com.github.linwancen.plugin.graph.ui.DrawGraphBundle; | ||
import com.intellij.openapi.project.Project; | ||
import com.intellij.openapi.startup.StartupActivity; | ||
import com.intellij.ui.components.JBTextArea; | ||
import org.jetbrains.annotations.NotNull; | ||
import org.jetbrains.annotations.Nullable; | ||
|
||
import javax.swing.*; | ||
import java.awt.*; | ||
import java.util.HashMap; | ||
import java.util.Map; | ||
import java.lang.reflect.Method; | ||
|
||
public abstract class Browser implements StartupActivity.RequiredForSmartMode { | ||
@Override | ||
public void runActivity(@NotNull Project project) {} | ||
public abstract class Browser { | ||
|
||
@NotNull | ||
static Map<String, Class<? extends Browser>> map = new HashMap<>(); | ||
public Class<?> clazz; | ||
|
||
static { | ||
// ensure load | ||
map.put(BrowserJcef.class.getName(), BrowserJcef.class); | ||
} | ||
public abstract void addImpl(@NotNull JPanel out, Project project); | ||
|
||
public abstract void loadImpl(String html); | ||
|
||
@Nullable | ||
public static Browser of(@NotNull JPanel out, Project project) { | ||
out.removeAll(); | ||
out.setLayout(new BorderLayout()); | ||
@NotNull StringBuilder errMsg = new StringBuilder(); | ||
for (@NotNull Class<? extends Browser> c : map.values()) { | ||
try { | ||
@NotNull Browser browser = c.getConstructor().newInstance(); | ||
@Nullable String s = browser.add(out, project); | ||
if (s == null) { | ||
return browser; | ||
} | ||
errMsg.append(s).append("\n"); | ||
} catch (Exception e) { | ||
errMsg.append(e).append("\n"); | ||
public String load(String html) { | ||
try { | ||
if (html != null) { | ||
Method method = clazz.getDeclaredMethod("loadImpl", String.class); | ||
method.invoke(this, html); | ||
} | ||
return null; | ||
} catch (Throwable e) { | ||
return e.toString(); | ||
} | ||
errMsg.insert(0, DrawGraphBundle.message("web.load.err.msg")); | ||
@NotNull JBTextArea errTip = new JBTextArea(); | ||
errTip.setText(errMsg.toString()); | ||
out.add(errTip); | ||
return null; | ||
} | ||
|
||
@Nullable | ||
abstract String add(JPanel out, Project project); | ||
|
||
public abstract String load(String html); | ||
} |
34 changes: 34 additions & 0 deletions
34
src/main/java/com/github/linwancen/plugin/graph/ui/webview/BrowserFactory.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
package com.github.linwancen.plugin.graph.ui.webview; | ||
|
||
import com.github.linwancen.plugin.graph.ui.DrawGraphBundle; | ||
import com.github.linwancen.plugin.graph.ui.webview.extension.BrowserExtensionPoint; | ||
import com.intellij.openapi.project.Project; | ||
import com.intellij.ui.components.JBTextArea; | ||
import org.jetbrains.annotations.NotNull; | ||
import org.jetbrains.annotations.Nullable; | ||
|
||
import javax.swing.*; | ||
import java.awt.*; | ||
import java.util.List; | ||
|
||
public class BrowserFactory { | ||
@Nullable | ||
public static Browser of(@NotNull JPanel out, Project project) { | ||
List<BrowserExtensionPoint> browsers = BrowserExtensionPoint.BROWSER_EPN.getExtensionList(); | ||
out.removeAll(); | ||
out.setLayout(new BorderLayout()); | ||
@NotNull StringBuilder errMsg = new StringBuilder(); | ||
for (BrowserExtensionPoint browser : browsers) { | ||
try { | ||
return browser.add(out, project); | ||
} catch (Throwable e) { | ||
errMsg.append(e).append("\n"); | ||
} | ||
} | ||
errMsg.insert(0, DrawGraphBundle.message("web.load.err.msg")); | ||
@NotNull JBTextArea errTip = new JBTextArea(); | ||
errTip.setText(errMsg.toString()); | ||
out.add(errTip); | ||
return null; | ||
} | ||
} |
Oops, something went wrong.