Uses 1068K of libraries. Click here for Pure Java version (1504L/10K/37K).
1 | !752 |
2 | !1003435 // RSyntaxTextArea |
3 | |
4 | import org.fife.ui.rtextarea.*; |
5 | import org.fife.ui.rsyntaxtextarea.*; |
6 | |
7 | static S snippetID = "#636"; |
8 | |
9 | static RSyntaxTextArea textArea; |
10 | static JLabel status; |
11 | static JButton btnSave; |
12 | |
13 | p { |
14 | if (args.length != 0) snippetID = args[0]; |
15 | |
16 | snippetID = formatSnippetID(snippetID); |
17 | JFrame frame = new JFrame(snippetID + " - " + getSnippetTitle(snippetID) + " [Edit]"); |
18 | JPanel panel = new JPanel(new BorderLayout()); |
19 | |
20 | textArea = new RSyntaxTextArea(20, 60); |
21 | textArea.setSyntaxEditingStyle(SyntaxConstants.SYNTAX_STYLE_JAVA); |
22 | textArea.setCodeFoldingEnabled(true); |
23 | textArea.setTabSize(2); |
24 | textArea.setTabsEmulated(true); // Spaces are MUCH better |
25 | RTextScrollPane sp = new RTextScrollPane(textArea); |
26 | |
27 | panel.add(BorderLayout.CENTER, sp); |
28 | |
29 | status = new JLabel("Loading..."); |
30 | btnSave = new JButton("Save " + snippetID); |
31 | btnSave.setEnabled(false); |
32 | textArea.setEditable(false); // still loading |
33 | |
34 | btnSave.addActionListener(actionListener { |
35 | saveSnippet(); |
36 | }); |
37 | |
38 | JPanel bottom = new JPanel(new BorderLayout); |
39 | bottom.add(BorderLayout.CENTER, status); |
40 | bottom.add(BorderLayout.EAST, btnSave); |
41 | |
42 | panel.add(BorderLayout.SOUTH, bottom); |
43 | |
44 | onUpdate(textArea, r { |
45 | btnSave.setEnabled(true); |
46 | }); |
47 | |
48 | thread { |
49 | final S s = loadSnippet(snippetID); |
50 | awt { |
51 | status.setText("Loaded " + s.length() + " chars."); |
52 | textArea.setText(s); |
53 | //textArea.scrollRectToVisible(new Rectangle(0, 0, 1, 1)); |
54 | textArea.setCaretPosition(0); |
55 | btnSave.setEnabled(false); |
56 | textArea.setEditable(true); |
57 | textArea.requestFocus(); |
58 | } |
59 | } |
60 | |
61 | frame.add(panel); |
62 | frame.setBounds(100, 100, 500, 400); |
63 | frame.setVisible(true); |
64 | exitOnFrameClose(frame); |
65 | } |
66 | |
67 | static void saveSnippet() { |
68 | final S text = textArea.getText(); |
69 | btnSave.setEnabled(false); |
70 | status.setText("Saving..."); |
71 | thread { |
72 | final S url = "http://tinybrain.de:8080/tb-int/update_snippet_text.php"; |
73 | S user = loadTextFile(new File(userHome(), ".tinybrain/username").getPath(), null); |
74 | S pass = loadTextFile(new File(userHome(), ".tinybrain/userpass").getPath(), null); |
75 | S query = "id=" + parseSnippetID(snippetID) + "&text=" + urlencode(text) + "&_user=" + urlencode(user) + "&_pass=" + urlencode(pass); |
76 | final S page = doPost(query, url); |
77 | |
78 | awt { |
79 | status.setText("Saved snippet: " + page); |
80 | } |
81 | } |
82 | } |
Began life as a copy of #1000894
download show line numbers debug dex old transpilations
Travelled to 16 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, ddnzoavkxhuk, gwrvuhgaqvyk, ishqpsrjomds, jtubtzbbkimh, lpdgvwnxivlt, mqqgnosmbjvj, onxytkatvevr, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt
No comments. add comment
Snippet ID: | #1003437 |
Snippet name: | Swing: Edit JavaX snippet |
Eternal ID of this version: | #1003437/1 |
Text MD5: | f5c05b42616f11bee461748d82f344f1 |
Transpilation MD5: | 9a6fc6930ac6152462770fa0f9b365ca |
Author: | stefan |
Category: | javax |
Type: | JavaX source code |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2016-07-03 15:52:40 |
Source code size: | 2458 bytes / 82 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 634 / 670 |
Referenced in: | [show references] |