|
|
|
@ -21,6 +21,8 @@ import com.fr.general.IOUtils;
|
|
|
|
|
|
|
|
|
|
import javax.swing.*; |
|
|
|
|
import java.awt.*; |
|
|
|
|
import java.awt.event.FocusEvent; |
|
|
|
|
import java.awt.event.FocusListener; |
|
|
|
|
import java.awt.event.MouseAdapter; |
|
|
|
|
import java.awt.event.MouseEvent; |
|
|
|
|
import java.util.ArrayList; |
|
|
|
@ -82,6 +84,20 @@ public class JSContentPane extends BasicPane {
|
|
|
|
|
UIScrollPane sp = new UIScrollPane(contentTextArea); |
|
|
|
|
this.add(sp, BorderLayout.CENTER); |
|
|
|
|
|
|
|
|
|
contentTextArea.addFocusListener(new FocusListener() { |
|
|
|
|
@Override |
|
|
|
|
public void focusGained(FocusEvent e) { |
|
|
|
|
// 获得焦点时 安装
|
|
|
|
|
installAutoCompletion(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public void focusLost(FocusEvent e) { |
|
|
|
|
// 失去焦点时 卸载
|
|
|
|
|
uninstallAutoCompletion(); |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
UILabel funNameLabel2 = new UILabel(); |
|
|
|
|
funNameLabel2.setText("}"); |
|
|
|
|
this.add(funNameLabel2, BorderLayout.SOUTH); |
|
|
|
@ -91,12 +107,10 @@ public class JSContentPane extends BasicPane {
|
|
|
|
|
return KeyStroke.getKeyStroke(ks.replace("+", "pressed")); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
protected String title4PopupWindow() { |
|
|
|
|
return "JS"; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public void populate(String js) { |
|
|
|
|
/** |
|
|
|
|
* 注册安装 自动补全监听 |
|
|
|
|
*/ |
|
|
|
|
private void installAutoCompletion() { |
|
|
|
|
if (ac == null) { |
|
|
|
|
CompletionProvider provider = createCompletionProvider(); |
|
|
|
|
ac = new AutoCompletion(provider); |
|
|
|
@ -105,16 +119,28 @@ public class JSContentPane extends BasicPane {
|
|
|
|
|
ac.setTriggerKey(convert2KeyStroke(shortCuts)); |
|
|
|
|
ac.install(contentTextArea); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
this.contentTextArea.setText(js); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public String update() { |
|
|
|
|
/** |
|
|
|
|
* 卸载移除 自动补全监听 |
|
|
|
|
*/ |
|
|
|
|
private void uninstallAutoCompletion() { |
|
|
|
|
if (ac != null) { |
|
|
|
|
this.ac.uninstall(); |
|
|
|
|
ac.uninstall(); |
|
|
|
|
ac = null; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
protected String title4PopupWindow() { |
|
|
|
|
return "JS"; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public void populate(String js) { |
|
|
|
|
this.contentTextArea.setText(js); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public String update() { |
|
|
|
|
return this.contentTextArea.getText(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|