# HG changeset patch # User jrice@netbeans.org # Date 1203716802 0 # Node ID 018ee35f3612d2b51796dac5467548357b496579 # Parent e6edc0bf528841ff5fb0f609966252488b609954 #128097: adding Export Diff to Show History and Show Out on Changeset listing, beside Diff and Revert diff -r e6edc0bf5288 -r 018ee35f3612 mercurial/src/org/netbeans/modules/mercurial/ui/diff/Bundle.properties --- a/mercurial/src/org/netbeans/modules/mercurial/ui/diff/Bundle.properties Fri Feb 22 17:32:15 2008 +0000 +++ b/mercurial/src/org/netbeans/modules/mercurial/ui/diff/Bundle.properties Fri Feb 22 21:46:42 2008 +0000 @@ -71,6 +71,7 @@ LBL_ExportDiff_Progress=Exporting Patche LBL_ExportDiff_Progress=Exporting Patches CTL_Setup_NotCommitted = - not yet committed +LBL_EXPORT_INFO = (for contents of each changeset refer to Show History) ACSD_BrowseFolder = Lets you browse for directory for mercurial export file. Browse_title=Browse for the Export File Folders=Folders diff -r e6edc0bf5288 -r 018ee35f3612 mercurial/src/org/netbeans/modules/mercurial/ui/diff/ExportDiff.java --- a/mercurial/src/org/netbeans/modules/mercurial/ui/diff/ExportDiff.java Fri Feb 22 17:32:15 2008 +0000 +++ b/mercurial/src/org/netbeans/modules/mercurial/ui/diff/ExportDiff.java Fri Feb 22 21:46:42 2008 +0000 @@ -41,21 +41,16 @@ package org.netbeans.modules.mercurial.u package org.netbeans.modules.mercurial.ui.diff; import java.awt.Dialog; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeListener; -import java.net.MalformedURLException; import javax.swing.JButton; -import javax.swing.JRadioButton; import javax.swing.event.DocumentEvent; import javax.swing.event.DocumentListener; import org.openide.DialogDescriptor; import org.openide.DialogDisplayer; -import org.openide.ErrorManager; import org.openide.util.HelpCtx; import java.io.File; - +import org.netbeans.modules.mercurial.ui.log.RepositoryRevision; /** * * @author Padraig O'Briain @@ -66,11 +61,13 @@ public class ExportDiff implements Prope private JButton okButton; private JButton cancelButton; private final DocumentListener listener; + private RepositoryRevision repoRev; /** Creates a new instance of ExportDiff */ - public ExportDiff(File repository) { - panel = new ExportDiffPanel(repository); + public ExportDiff(File repository, RepositoryRevision repoRev) { + this.repoRev = repoRev; + panel = new ExportDiffPanel(repository, repoRev); okButton = new JButton(); org.openide.awt.Mnemonics.setLocalizedText(okButton, org.openide.util.NbBundle.getMessage(ExportDiff.class, "CTL_ExportForm_Action_Export")); // NOI18N okButton.getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getMessage(ExportDiff.class, "ACSN_ExportForm_Action_Export")); // NOI18N @@ -86,6 +83,9 @@ public class ExportDiff implements Prope }; panel.outputFileTextField.getDocument().addDocumentListener(listener); } + public ExportDiff(File repository) { + this(repository, null); + } public boolean showDialog() { DialogDescriptor dialogDescriptor = new DialogDescriptor(panel, org.openide.util.NbBundle.getMessage(ExportDiff.class, "CTL_ExportDialog")); // NOI18N diff -r e6edc0bf5288 -r 018ee35f3612 mercurial/src/org/netbeans/modules/mercurial/ui/diff/ExportDiffAction.java --- a/mercurial/src/org/netbeans/modules/mercurial/ui/diff/ExportDiffAction.java Fri Feb 22 17:32:15 2008 +0000 +++ b/mercurial/src/org/netbeans/modules/mercurial/ui/diff/ExportDiffAction.java Fri Feb 22 21:46:42 2008 +0000 @@ -55,6 +55,7 @@ import org.netbeans.modules.mercurial.ut import org.netbeans.modules.mercurial.util.HgUtils; import org.netbeans.modules.mercurial.util.HgCommand; import org.netbeans.modules.mercurial.ui.actions.ContextAction; +import org.netbeans.modules.mercurial.ui.log.RepositoryRevision; import org.openide.util.NbBundle; import org.openide.util.RequestProcessor; import org.openide.DialogDisplayer; @@ -112,6 +113,38 @@ public class ExportDiffAction extends Co support.start(rp, root.getAbsolutePath(), org.openide.util.NbBundle.getMessage(ExportDiffAction.class, "LBL_ExportDiff_Progress")); // NOI18N } + public static void exportDiffRevision(final RepositoryRevision repoRev) { + if(repoRev == null || repoRev.getRepositoryRootUrl() == null || repoRev.getRepositoryRootUrl().equals("")) + return; + final File root = new File(repoRev.getRepositoryRootUrl()); + ExportDiff ed = new ExportDiff(root, repoRev); + final String revStr = repoRev.getLog().getRevision(); + if (!ed.showDialog()) { + return; + } + final String outputFileName = ed.getOutputFileName(); + File destinationFile = new File(outputFileName); + if (destinationFile.exists()) { + NotifyDescriptor nd = new NotifyDescriptor.Confirmation(NbBundle.getMessage(ExportDiffAction.class, "BK3005", destinationFile.getAbsolutePath())); + nd.setOptionType(NotifyDescriptor.YES_NO_OPTION); + DialogDisplayer.getDefault().notify(nd); + if (nd.getValue().equals(NotifyDescriptor.OK_OPTION) == false) { + return; + } + } + + HgModuleConfig.getDefault().setExportFolder(destinationFile.getParent()); + RequestProcessor rp = Mercurial.getInstance().getRequestProcessor(root.getAbsolutePath()); + HgProgressSupport support = new HgProgressSupport() { + + public void perform() { + OutputLogger logger = getLogger(); + performExport(root, revStr, outputFileName, logger); + } + }; + support.start(rp, root.getAbsolutePath(), org.openide.util.NbBundle.getMessage(ExportDiffAction.class, "LBL_ExportDiff_Progress")); // NOI18N + } + private static void performExport(File repository, String revStr, String outputFileName, OutputLogger logger) { try { logger.outputInRed( diff -r e6edc0bf5288 -r 018ee35f3612 mercurial/src/org/netbeans/modules/mercurial/ui/diff/ExportDiffPanel.form --- a/mercurial/src/org/netbeans/modules/mercurial/ui/diff/ExportDiffPanel.form Fri Feb 22 17:32:15 2008 +0000 +++ b/mercurial/src/org/netbeans/modules/mercurial/ui/diff/ExportDiffPanel.form Fri Feb 22 21:46:42 2008 +0000 @@ -28,7 +28,10 @@ - + + + + @@ -43,7 +46,9 @@ - + + + @@ -109,5 +114,15 @@ + + + + + + + + + + diff -r e6edc0bf5288 -r 018ee35f3612 mercurial/src/org/netbeans/modules/mercurial/ui/diff/ExportDiffPanel.java --- a/mercurial/src/org/netbeans/modules/mercurial/ui/diff/ExportDiffPanel.java Fri Feb 22 17:32:15 2008 +0000 +++ b/mercurial/src/org/netbeans/modules/mercurial/ui/diff/ExportDiffPanel.java Fri Feb 22 21:46:42 2008 +0000 @@ -58,6 +58,7 @@ import org.netbeans.modules.versioning.u import org.netbeans.modules.versioning.util.AccessibleJFileChooser; import org.netbeans.modules.mercurial.util.HgCommand; import org.netbeans.modules.mercurial.HgModuleConfig; +import org.netbeans.modules.mercurial.ui.log.RepositoryRevision; /** * @@ -69,11 +70,12 @@ public class ExportDiffPanel extends jav private RequestProcessor.Task refreshViewTask; private Thread refreshViewThread; private static final RequestProcessor rp = new RequestProcessor("MercurialExportDiff", 1); // NOI18N - + private RepositoryRevision repoRev; private static final int HG_REVISION_TARGET_LIMIT = 100; /** Creates new form ExportDiffPanel */ - public ExportDiffPanel(File repo) { + public ExportDiffPanel(File repo, RepositoryRevision repoRev) { + this.repoRev = repoRev; repository = repo; refreshViewTask = rp.create(new RefreshViewTask()); initComponents(); @@ -109,6 +111,7 @@ public class ExportDiffPanel extends jav revisionsComboBox = new javax.swing.JComboBox(); fileLabel = new javax.swing.JLabel(); browseButton = new javax.swing.JButton(); + jLabel1 = new javax.swing.JLabel(); revisionsLabel.setLabelFor(revisionsComboBox); org.openide.awt.Mnemonics.setLocalizedText(revisionsLabel, org.openide.util.NbBundle.getMessage(ExportDiffPanel.class, "ExportDiffPanel.revisionsLabel.text")); // NOI18N @@ -117,6 +120,9 @@ public class ExportDiffPanel extends jav org.openide.awt.Mnemonics.setLocalizedText(fileLabel, org.openide.util.NbBundle.getMessage(ExportDiffPanel.class, "ExportDiffPanel.fileLabel.text")); // NOI18N org.openide.awt.Mnemonics.setLocalizedText(browseButton, org.openide.util.NbBundle.getMessage(ExportDiffPanel.class, "ExportDiffPanel.browseButtonl.text")); // NOI18N + + jLabel1.setForeground(java.awt.Color.gray); + org.openide.awt.Mnemonics.setLocalizedText(jLabel1, org.openide.util.NbBundle.getMessage(ExportDiffPanel.class, "LBL_EXPORT_INFO")); // NOI18N org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(this); this.setLayout(layout); @@ -134,7 +140,9 @@ public class ExportDiffPanel extends jav .add(layout.createSequentialGroup() .add(revisionsLabel) .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) - .add(revisionsComboBox, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 297, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))) + .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING, false) + .add(org.jdesktop.layout.GroupLayout.TRAILING, jLabel1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .add(org.jdesktop.layout.GroupLayout.TRAILING, revisionsComboBox, 0, 297, Short.MAX_VALUE)))) .addContainerGap(20, Short.MAX_VALUE)) ); layout.setVerticalGroup( @@ -144,7 +152,9 @@ public class ExportDiffPanel extends jav .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE) .add(revisionsLabel) .add(revisionsComboBox, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)) - .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, 27, Short.MAX_VALUE) + .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) + .add(jLabel1) + .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, 22, Short.MAX_VALUE) .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE) .add(fileLabel) .add(outputFileTextField, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) @@ -166,15 +176,25 @@ public class ExportDiffPanel extends jav final ProgressHandle ph = ProgressHandleFactory.createHandle(NbBundle.getMessage(ExportDiffPanel.class, "MSG_Fetching_Revisions")); // NOI18N try { Set initislRevsSet = new LinkedHashSet(); + ComboBoxModel targetsModel; + if(repoRev != null){ + initislRevsSet.add(repoRev.getLog().getRevision() + " (" + repoRev.getLog().getCSetShortID() + ")" ); // NOI18N + targetsModel = new DefaultComboBoxModel(new Vector(initislRevsSet)); + revisionsComboBox.setModel(targetsModel); + revisionsComboBox.setEditable(false); + refreshViewThread = Thread.currentThread(); + Thread.interrupted(); // clear interupted status + ph.start(); + }else{ + initislRevsSet.add(NbBundle.getMessage(ExportDiffPanel.class, "MSG_Fetching_Revisions")); // NOI18N + targetsModel = new DefaultComboBoxModel(new Vector(initislRevsSet)); + revisionsComboBox.setModel(targetsModel); + refreshViewThread = Thread.currentThread(); + Thread.interrupted(); // clear interupted status + ph.start(); - initislRevsSet.add(NbBundle.getMessage(ExportDiffPanel.class, "MSG_Fetching_Revisions")); // NOI18N - ComboBoxModel targetsModel = new DefaultComboBoxModel(new Vector(initislRevsSet)); - revisionsComboBox.setModel(targetsModel); - refreshViewThread = Thread.currentThread(); - Thread.interrupted(); // clear interupted status - ph.start(); - - refreshRevisions(); + refreshRevisions(); + } getDefaultOutputFile(); } finally { SwingUtilities.invokeLater(new Runnable() { @@ -252,6 +272,7 @@ public class ExportDiffPanel extends jav // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JButton browseButton; private javax.swing.JLabel fileLabel; + private javax.swing.JLabel jLabel1; final javax.swing.JTextField outputFileTextField = new javax.swing.JTextField(); private javax.swing.JComboBox revisionsComboBox; private javax.swing.JLabel revisionsLabel; diff -r e6edc0bf5288 -r 018ee35f3612 mercurial/src/org/netbeans/modules/mercurial/ui/log/Bundle.properties --- a/mercurial/src/org/netbeans/modules/mercurial/ui/log/Bundle.properties Fri Feb 22 17:32:15 2008 +0000 +++ b/mercurial/src/org/netbeans/modules/mercurial/ui/log/Bundle.properties Fri Feb 22 21:46:42 2008 +0000 @@ -133,7 +133,7 @@ MSG_SummaryView_DeadState = (state: dead CTL_Action_Revert = Revert CTL_Action_Diff = Diff - +CTL_Action_ExportDiffs = Export Diff CTL_Action_RollbackTo = Revert to {0} CTL_Action_RollbackChange = Rollback Changes CTL_Rollback_Title = Confirm Rollback diff -r e6edc0bf5288 -r 018ee35f3612 mercurial/src/org/netbeans/modules/mercurial/ui/log/RepositoryRevision.java --- a/mercurial/src/org/netbeans/modules/mercurial/ui/log/RepositoryRevision.java Fri Feb 22 17:32:15 2008 +0000 +++ b/mercurial/src/org/netbeans/modules/mercurial/ui/log/RepositoryRevision.java Fri Feb 22 21:46:42 2008 +0000 @@ -51,7 +51,7 @@ import org.netbeans.modules.mercurial.ut * * @author Maros Sandor */ -class RepositoryRevision { +public class RepositoryRevision { private HgLogMessage message; diff -r e6edc0bf5288 -r 018ee35f3612 mercurial/src/org/netbeans/modules/mercurial/ui/log/SummaryView.java --- a/mercurial/src/org/netbeans/modules/mercurial/ui/log/SummaryView.java Fri Feb 22 17:32:15 2008 +0000 +++ b/mercurial/src/org/netbeans/modules/mercurial/ui/log/SummaryView.java Fri Feb 22 21:46:42 2008 +0000 @@ -40,7 +40,6 @@ */ package org.netbeans.modules.mercurial.ui.log; -import org.openide.util.Exceptions; import org.openide.util.NbBundle; import org.openide.util.RequestProcessor; import org.openide.ErrorManager; @@ -56,11 +55,9 @@ import java.awt.*; import java.awt.*; import java.awt.geom.Rectangle2D; import java.util.*; -import java.util.List; import java.io.File; import java.io.IOException; import java.text.DateFormat; -import java.util.List; import java.util.List; import org.netbeans.api.editor.mimelookup.MimePath; import org.netbeans.modules.mercurial.ExceptionHandler; @@ -70,7 +67,7 @@ import org.netbeans.modules.mercurial.Me import org.netbeans.modules.mercurial.Mercurial; import org.netbeans.modules.mercurial.VersionsCache; import org.netbeans.modules.mercurial.ui.diff.DiffSetupSource; -import org.netbeans.modules.mercurial.ui.update.RevertModifications; +import org.netbeans.modules.mercurial.ui.diff.ExportDiffAction; import org.netbeans.modules.mercurial.ui.update.RevertModificationsAction; /** @@ -83,7 +80,9 @@ import org.netbeans.modules.mercurial.ui */ class SummaryView implements MouseListener, ComponentListener, MouseMotionListener, DiffSetupSource { + private static final String SUMMARY_DIFF_PROPERTY = "Summary-Diff-"; private static final String SUMMARY_REVERT_PROPERTY = "Summary-Revert-"; + private static final String SUMMARY_EXPORTDIFFS_PROPERTY = "Summary-ExportDiffs-"; private final SearchHistoryPanel master; @@ -156,7 +155,7 @@ class SummaryView implements MouseListen if (idx == -1) return; Rectangle rect = resultsList.getCellBounds(idx, idx); Point p = new Point(e.getX() - rect.x, e.getY() - rect.y); - Rectangle diffBounds = (Rectangle) resultsList.getClientProperty("Summary-Diff-" + idx); // NOI18N + Rectangle diffBounds = (Rectangle) resultsList.getClientProperty(SUMMARY_DIFF_PROPERTY + idx); // NOI18N if (diffBounds != null && diffBounds.contains(p)) { diffPrevious(idx); } @@ -164,8 +163,13 @@ class SummaryView implements MouseListen if (diffBounds != null && diffBounds.contains(p)) { revertModifications(new int [] { idx }); } + diffBounds = (Rectangle) resultsList.getClientProperty(SUMMARY_EXPORTDIFFS_PROPERTY + idx); // NOI18N + if (diffBounds != null && diffBounds.contains(p)) { + System.out.println("ExportDiffs: " + idx); // DEBUG + exportDiffs(idx); + } } - + public void mouseEntered(MouseEvent e) { // not interested } @@ -194,12 +198,17 @@ class SummaryView implements MouseListen if (idx == -1) return; Rectangle rect = resultsList.getCellBounds(idx, idx); Point p = new Point(e.getX() - rect.x, e.getY() - rect.y); - Rectangle diffBounds = (Rectangle) resultsList.getClientProperty("Summary-Diff-" + idx); // NOI18N + Rectangle diffBounds = (Rectangle) resultsList.getClientProperty(SUMMARY_DIFF_PROPERTY + idx); // NOI18N if (diffBounds != null && diffBounds.contains(p)) { resultsList.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); return; } diffBounds = (Rectangle) resultsList.getClientProperty(SUMMARY_REVERT_PROPERTY + idx); // NOI18N + if (diffBounds != null && diffBounds.contains(p)) { + resultsList.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); + return; + } + diffBounds = (Rectangle) resultsList.getClientProperty(SUMMARY_EXPORTDIFFS_PROPERTY + idx); // NOI18N if (diffBounds != null && diffBounds.contains(p)) { resultsList.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); return; @@ -499,6 +508,15 @@ class SummaryView implements MouseListen } } + private void exportDiffs(int idx) { + Object o = dispResults.get(idx); + if (o instanceof RepositoryRevision) { + RepositoryRevision repoRev = (RepositoryRevision) o; + ExportDiffAction.exportDiffRevision(repoRev); + } + } + + public JComponent getComponent() { return scrollPane; } @@ -534,6 +552,7 @@ class SummaryView implements MouseListen private int index; private HyperlinkLabel diffLink; private HyperlinkLabel revertLink; + private HyperlinkLabel exportDiffsLink; public SummaryCellRenderer() { selectedStyle = textPane.addStyle("selected", null); // NOI18N @@ -564,7 +583,11 @@ class SummaryView implements MouseListen actionsPane.add(diffLink); revertLink = new HyperlinkLabel(); + revertLink.setBorder(BorderFactory.createEmptyBorder(0, 0, 0, 8)); actionsPane.add(revertLink); + + exportDiffsLink = new HyperlinkLabel(); + actionsPane.add(exportDiffsLink); textPane.setBorder(null); } @@ -640,8 +663,9 @@ class SummaryView implements MouseListen actionsPane.setVisible(true); if(!master.isIncomingSearch()){ - diffLink.set(NbBundle.getMessage(SummaryView.class, "CTL_Action_Diff"), foregroundColor, backgroundColor); + diffLink.set(NbBundle.getMessage(SummaryView.class, "CTL_Action_Diff"), foregroundColor, backgroundColor);// NOI18N revertLink.set(NbBundle.getMessage(SummaryView.class, "CTL_Action_Revert"), foregroundColor, backgroundColor); // NOI18N + exportDiffsLink.set(NbBundle.getMessage(SummaryView.class, "CTL_Action_ExportDiffs"), foregroundColor, backgroundColor); // NOI18N } } @@ -705,12 +729,16 @@ class SummaryView implements MouseListen { Rectangle bounds = diffLink.getBounds(); bounds.setBounds(bounds.x, bounds.y + apb.y, bounds.width, bounds.height); - resultsList.putClientProperty("Summary-Diff-" + index, bounds); // NOI18N + resultsList.putClientProperty(SUMMARY_DIFF_PROPERTY + index, bounds); // NOI18N } Rectangle bounds = revertLink.getBounds(); bounds.setBounds(bounds.x, bounds.y + apb.y, bounds.width, bounds.height); resultsList.putClientProperty(SUMMARY_REVERT_PROPERTY + index, bounds); // NOI18N + + Rectangle edBounds = exportDiffsLink.getBounds(); + edBounds.setBounds(edBounds.x, edBounds.y + apb.y, edBounds.width, edBounds.height); + resultsList.putClientProperty(SUMMARY_EXPORTDIFFS_PROPERTY + index, edBounds); // NOI18N } }