From: <sh...@us...> - 2010-02-02 09:16:16
|
Revision: 17180 http://jedit.svn.sourceforge.net/jedit/?rev=17180&view=rev Author: shlomy Date: 2010-02-02 09:16:10 +0000 (Tue, 02 Feb 2010) Log Message: ----------- - Added "preset connections" - if the file "connections.txt" exists in the home directory, a list of connections is read from it, and the user can select any of them later. Each line should specify a single connection in the format: name:host:port (just like the "create connection" menu). - Added the connection info as a text box at the bottom right of the dockable. This is useful sometimes for copying the address. Modified Paths: -------------- plugins/ConsoleAutomation/trunk/ConsoleAutomation.props plugins/ConsoleAutomation/trunk/actions.xml plugins/ConsoleAutomation/trunk/src/automation/Connection.java plugins/ConsoleAutomation/trunk/src/automation/ConnectionWindow.java plugins/ConsoleAutomation/trunk/src/automation/ConsoleAutomationPlugin.java Modified: plugins/ConsoleAutomation/trunk/ConsoleAutomation.props =================================================================== --- plugins/ConsoleAutomation/trunk/ConsoleAutomation.props 2010-02-02 05:56:07 UTC (rev 17179) +++ plugins/ConsoleAutomation/trunk/ConsoleAutomation.props 2010-02-02 09:16:10 UTC (rev 17180) @@ -13,6 +13,8 @@ # action labels console-automation-connect.label=Create a connection console-automation-connect-headless.label=Create a headless connection +console-automation-select-connection.label=Connect to a preset connection +console-automation-select-connection-headless.label=Connect headlessly to a preset connection console-automation-close-current.label=Close the current connection console-automation-close-connection.label=Select a connection to close console-automation-reload-connections.label=Reload connections from properties @@ -25,6 +27,8 @@ console-automation-reload-connections-headless \ console-automation-connect \ console-automation-connect-headless \ + console-automation-select-connection \ + console-automation-select-connection-headless \ console-automation-close-current \ console-automation-close-connection \ console-automation-show-macros \ Modified: plugins/ConsoleAutomation/trunk/actions.xml =================================================================== --- plugins/ConsoleAutomation/trunk/actions.xml 2010-02-02 05:56:07 UTC (rev 17179) +++ plugins/ConsoleAutomation/trunk/actions.xml 2010-02-02 09:16:10 UTC (rev 17180) @@ -19,6 +19,22 @@ plugin.showConnectionDialog(true); </CODE> </ACTION> + <ACTION NAME="console-automation-select-connection" NO_REPEAT="TRUE"> + <CODE> + import automation.*; + ConsoleAutomationPlugin plugin = (ConsoleAutomationPlugin) + jEdit.getPlugin("automation.ConsoleAutomationPlugin"); + plugin.showSelectConnectionDialog(false); + </CODE> + </ACTION> + <ACTION NAME="console-automation-select-connection-headless" NO_REPEAT="TRUE"> + <CODE> + import automation.*; + ConsoleAutomationPlugin plugin = (ConsoleAutomationPlugin) + jEdit.getPlugin("automation.ConsoleAutomationPlugin"); + plugin.showSelectConnectionDialog(true); + </CODE> + </ACTION> <ACTION NAME="console-automation-close-current" NO_REPEAT="TRUE"> <CODE> import automation.*; Modified: plugins/ConsoleAutomation/trunk/src/automation/Connection.java =================================================================== --- plugins/ConsoleAutomation/trunk/src/automation/Connection.java 2010-02-02 05:56:07 UTC (rev 17179) +++ plugins/ConsoleAutomation/trunk/src/automation/Connection.java 2010-02-02 09:16:10 UTC (rev 17180) @@ -71,6 +71,14 @@ { return name; } + public String getHost() + { + return host; + } + public int getPort() + { + return port; + } public void connect() throws UnknownHostException, IOException { telnet = new TelnetClient(); Modified: plugins/ConsoleAutomation/trunk/src/automation/ConnectionWindow.java =================================================================== --- plugins/ConsoleAutomation/trunk/src/automation/ConnectionWindow.java 2010-02-02 05:56:07 UTC (rev 17179) +++ plugins/ConsoleAutomation/trunk/src/automation/ConnectionWindow.java 2010-02-02 09:16:10 UTC (rev 17180) @@ -16,6 +16,7 @@ import javax.swing.JOptionPane; import javax.swing.JPanel; import javax.swing.JScrollPane; +import javax.swing.JTextField; import javax.swing.JTextPane; import javax.swing.SwingUtilities; import javax.swing.text.BadLocationException; @@ -44,6 +45,7 @@ private StringBuilder currentOutput; private Object outputSync= new Object(); private int charsToRemove = 0; + private final JTextField connectionString; private final JLabel action; private int awtTaskCount = 0; private boolean setActionTextScheduled = false; @@ -85,8 +87,13 @@ ctrlC.addActionListener(this); output = new ArrayList<StringBuilder>(); output.add(currentOutput = new StringBuilder()); + JPanel bottomPanel = new JPanel(new BorderLayout()); + add(bottomPanel, BorderLayout.SOUTH); + connectionString = new JTextField(c.getHost() + ":" + c.getPort()); + connectionString.setEditable(false); + bottomPanel.add(connectionString, BorderLayout.EAST); action = new JLabel("<idle>"); - add(action, BorderLayout.SOUTH); + bottomPanel.add(action, BorderLayout.CENTER); c.setOutputHandler(this); c.setEventHandler(this); addFocusListener(new FocusAdapter() { Modified: plugins/ConsoleAutomation/trunk/src/automation/ConsoleAutomationPlugin.java =================================================================== --- plugins/ConsoleAutomation/trunk/src/automation/ConsoleAutomationPlugin.java 2010-02-02 05:56:07 UTC (rev 17179) +++ plugins/ConsoleAutomation/trunk/src/automation/ConsoleAutomationPlugin.java 2010-02-02 09:16:10 UTC (rev 17180) @@ -1,6 +1,8 @@ package automation; +import java.io.BufferedReader; import java.io.File; +import java.io.FileReader; import java.util.Arrays; import java.util.HashMap; import java.util.Map; @@ -22,15 +24,39 @@ private static final String GLOBAL_MACROS = "Global"; private static final String CONNECTION_DOCKABLE = "console-automation"; + private static final String CONNECTION_FILE = "connections.txt"; private static ConsoleAutomationPlugin instance = null; private final Map<String, Connection> connections = new HashMap<String, Connection>(); + private Vector<String> presetConnections = new Vector<String>(); public void start() { instance = this; + loadPresetConnections(); } + private void loadPresetConnections() + { + String connectionFile = System.getProperty("user.home") + + File.separator + CONNECTION_FILE; + File f = new File(connectionFile); + if (! f.exists()) + return; + try + { + BufferedReader br = new BufferedReader(new FileReader(connectionFile)); + String line; + while ((line = br.readLine()) != null) + presetConnections.add(line); + br.close(); + } + catch (Exception e) + { + e.printStackTrace(); + } + } + public void reloadConnections(boolean headless) { String configured = jEdit.getProperty("console.automation.connections"); @@ -220,6 +246,20 @@ closeConnection(connections.get(sel)); } } + public void showSelectConnectionDialog(boolean headless) + { + if (presetConnections.isEmpty()) + { + JOptionPane.showMessageDialog(null, "No preset connections exist"); + return; + } + Object sel = JOptionPane.showInputDialog(null, "Select connection", + "Connection Selection", JOptionPane.QUESTION_MESSAGE, null, + presetConnections.toArray(), presetConnections.get(0)); + if (sel == null) + return; + addConnection((String)sel, headless); + } public void showConnectionDialog(boolean headless) { String s; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |