diff --git a/tools/chrome-rdp/src/main/js/chrome/main.js b/tools/chrome-rdp/src/main/js/chrome/main.js index 7209a6969..555d7806a 100644 --- a/tools/chrome-rdp/src/main/js/chrome/main.js +++ b/tools/chrome-rdp/src/main/js/chrome/main.js @@ -1,8 +1,13 @@ debuggerAgentMap = {}; chrome.browserAction.onClicked.addListener(function(tab) { - new DebuggerAgent(tab, 2357).attach(); + chrome.storage.sync.get({ + port: 2357, + }, function(items) { + new DebuggerAgent(tab, items.port).attach(); + }); }); + function DebuggerAgent(tab, port) { this.pendingMessages = []; this.connection = null; diff --git a/tools/chrome-rdp/src/main/js/chrome/manifest.json b/tools/chrome-rdp/src/main/js/chrome/manifest.json index 5972d3972..b6c3301a9 100644 --- a/tools/chrome-rdp/src/main/js/chrome/manifest.json +++ b/tools/chrome-rdp/src/main/js/chrome/manifest.json @@ -5,7 +5,7 @@ "description": "TeaVM debugger agent, that sends RDP commands over WebSocket", "version": "0.6.0", - "permissions" : ["debugger", "activeTab", "tabs", "*://*/*"], + "permissions" : ["debugger", "activeTab", "tabs", "storage", "*://*/*"], "browser_action" : { "default_icon": "teavm-16.png", @@ -21,5 +21,10 @@ "matches": ["http://*/*", "https://*/*", "file://*/*"], "js": ["contentscript.js"] } - ] + ], + + "options_ui": { + "page": "options.html", + "open_in_tab": false + } } \ No newline at end of file diff --git a/tools/chrome-rdp/src/main/js/chrome/options.html b/tools/chrome-rdp/src/main/js/chrome/options.html new file mode 100644 index 000000000..10fe76ee4 --- /dev/null +++ b/tools/chrome-rdp/src/main/js/chrome/options.html @@ -0,0 +1,54 @@ + + + + + + TeaVM debug options + + + + +
+ + +
+ +
+ +
+ + + + \ No newline at end of file diff --git a/tools/chrome-rdp/src/main/js/chrome/options.js b/tools/chrome-rdp/src/main/js/chrome/options.js new file mode 100644 index 000000000..e2b211e31 --- /dev/null +++ b/tools/chrome-rdp/src/main/js/chrome/options.js @@ -0,0 +1,32 @@ +/* + * Copyright 2018 Alexey Andreev. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +function saveOptions() { + var port = document.getElementById("port").value; + chrome.storage.sync.set({ + port: port !== "" ? parseInt(port) : 2357, + }); +} + +function loadOptions() { + chrome.storage.sync.get({ + port: 2357, + }, function(items) { + document.getElementById("port").value = items.port; + }); +} +document.addEventListener("DOMContentLoaded", loadOptions); +document.getElementById("save").addEventListener('click', saveOptions); \ No newline at end of file diff --git a/tools/idea/plugin/src/main/java/org/teavm/idea/debug/ui/TeaVMDebugSettingsPanel.java b/tools/idea/plugin/src/main/java/org/teavm/idea/debug/ui/TeaVMDebugSettingsPanel.java index f9b5e4d02..66a642545 100644 --- a/tools/idea/plugin/src/main/java/org/teavm/idea/debug/ui/TeaVMDebugSettingsPanel.java +++ b/tools/idea/plugin/src/main/java/org/teavm/idea/debug/ui/TeaVMDebugSettingsPanel.java @@ -22,29 +22,34 @@ import java.awt.Font; import java.awt.GridBagConstraints; import java.awt.GridBagLayout; import javax.swing.JPanel; +import javax.swing.border.EmptyBorder; import org.teavm.idea.debug.TeaVMDebugConfiguration; class TeaVMDebugSettingsPanel extends JPanel { private final JBTextField portField = new JBTextField(); public TeaVMDebugSettingsPanel() { + setBorder(new EmptyBorder(10, 10, 10, 10)); + GridBagConstraints labelConstraints = new GridBagConstraints(); - labelConstraints.gridwidth = GridBagConstraints.REMAINDER; labelConstraints.anchor = GridBagConstraints.BASELINE_LEADING; - labelConstraints.weightx = 1; + labelConstraints.weightx = 0; labelConstraints.weighty = 1; labelConstraints.insets.left = 5; labelConstraints.insets.right = 5; - GridBagConstraints descriptionConstraints = (GridBagConstraints) labelConstraints.clone(); - descriptionConstraints.fill = GridBagConstraints.BOTH; - descriptionConstraints.anchor = GridBagConstraints.BASELINE_LEADING; - descriptionConstraints.insets.top = 3; + GridBagConstraints fieldConstraints = (GridBagConstraints) labelConstraints.clone(); + + fieldConstraints.gridwidth = GridBagConstraints.REMAINDER; + fieldConstraints.weightx = 1; + fieldConstraints.weighty = 1; + fieldConstraints.fill = GridBagConstraints.BOTH; + fieldConstraints.anchor = GridBagConstraints.BASELINE_LEADING; setLayout(new GridBagLayout()); add(bold(new JBLabel("Listen port:")), labelConstraints); - add(portField); + add(portField, fieldConstraints); } public void load(TeaVMDebugConfiguration runConfiguration) {