Browse Source

REPORT-33690 抽出方法

feature/big-screen
hades 4 years ago
parent
commit
f5a89c3de8
  1. 40
      designer-base/src/main/java/com/fr/design/javascript/JSContentPane.java

40
designer-base/src/main/java/com/fr/design/javascript/JSContentPane.java

@ -87,22 +87,14 @@ public class JSContentPane extends BasicPane {
contentTextArea.addFocusListener(new FocusListener() {
@Override
public void focusGained(FocusEvent e) {
if (ac == null) {
CompletionProvider provider = createCompletionProvider();
ac = new AutoCompletion(provider);
String shortCuts = DesignerEnvManager.getEnvManager().getAutoCompleteShortcuts();
ac.setTriggerKey(convert2KeyStroke(shortCuts));
ac.install(contentTextArea);
}
// 获得焦点时 安装
installAutoCompletion();
}
@Override
public void focusLost(FocusEvent e) {
if (ac != null) {
ac.uninstall();
ac = null;
}
// 失去焦点时 卸载
uninstallAutoCompletion();
}
});
@ -115,6 +107,30 @@ public class JSContentPane extends BasicPane {
return KeyStroke.getKeyStroke(ks.replace("+", "pressed"));
}
/**
* 注册安装 自动补全监听
*/
private void installAutoCompletion() {
if (ac == null) {
CompletionProvider provider = createCompletionProvider();
ac = new AutoCompletion(provider);
String shortCuts = DesignerEnvManager.getEnvManager().getAutoCompleteShortcuts();
ac.setTriggerKey(convert2KeyStroke(shortCuts));
ac.install(contentTextArea);
}
}
/**
* 卸载移除 自动补全监听
*/
private void uninstallAutoCompletion() {
if (ac != null) {
ac.uninstall();
ac = null;
}
}
@Override
protected String title4PopupWindow() {
return "JS";

Loading…
Cancel
Save