// This macro executes the 'svn commit' command in the Console plugin. It // first shows a dialog for the user to enter a commit comment. // file to work on String target = buffer.getPath(); // dialog to get commit comment final StringBuffer rtn = new StringBuffer(); String title = "Comment for " + target; final javax.swing.JDialog d = new javax.swing.JDialog(view); d.setModal(true); d.setTitle(title); java.awt.Container contents = d.getContentPane(); contents.setLayout(new java.awt.BorderLayout()); final javax.swing.JTextArea textArea = new javax.swing.JTextArea(6, 40); contents.add(new javax.swing.JScrollPane(textArea)); javax.swing.JPanel buttonPanel = new javax.swing.JPanel(); buttonPanel.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.RIGHT)); javax.swing.JButton okayButton = new javax.swing.JButton("OK"); javax.swing.JButton cancelButton = new javax.swing.JButton("Cancel"); okayButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent event) { rtn.append(textArea.getText()); d.setVisible(false); d.dispose(); } }); cancelButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent event) { rtn.append("___cancelled___"); d.setVisible(false); d.dispose(); } }); buttonPanel.add(okayButton); buttonPanel.add(cancelButton); contents.add(buttonPanel, java.awt.BorderLayout.SOUTH); d.setSize(400, 250); d.setVisible(true); String message = rtn.toString(); message = message.indexOf("___cancelled___") > -1 ? null : message; // null message means user cancelled if (message == null) { return; } // build svn command message = message.replaceAll("[\\n\\r]", " "); command = "svn commit -m \"" + message + "\" " + target; runInSystemShell(view, command); waitForConsole(view); buffer.reload(view);