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