# This patch file was generated by NetBeans IDE # Following Index: paths are relative to: /export/home/padraigo/netbeansFROMHG/main/mercurial # This patch can be applied using context Tools: Patch action on respective folder. # It uses platform neutral UTF-8 encoding and \n newlines. # Above lines and this line are ignored by the patching process. Index: src/org/netbeans/modules/mercurial/Bundle.properties --- src/org/netbeans/modules/mercurial/Bundle.properties Base (BASE) +++ src/org/netbeans/modules/mercurial/Bundle.properties Locally Modified (Based On LOCAL) @@ -150,3 +150,7 @@ MSG_Fetch_50_Revisions = Fetch up to 50 Revisions... MSG_Fetch_All_Revisions = Fetch All Revisions... MSG_Fetching_Revisions = Fetching Revisions... + +# Exception Handler +CTL_Action_OK = OK +CTL_ActionCanceled_Title = Action cancelled Index: src/org/netbeans/modules/mercurial/HgProgressSupport.java --- src/org/netbeans/modules/mercurial/HgProgressSupport.java Base (BASE) +++ src/org/netbeans/modules/mercurial/HgProgressSupport.java Locally Modified (Based On LOCAL) @@ -41,9 +41,13 @@ package org.netbeans.modules.mercurial; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; import java.text.DateFormat; import java.util.Date; import java.util.logging.Level; +import javax.swing.JComponent; +import javax.swing.JButton; import org.netbeans.api.progress.ProgressHandle; import org.netbeans.api.progress.ProgressHandleFactory; import org.openide.util.Cancellable; @@ -67,6 +71,20 @@ private String repositoryRoot; private RequestProcessor.Task task; + public HgProgressSupport() { + } + + public HgProgressSupport(String displayName, JButton cancel) { + this.displayName = displayName; + if(cancel != null) { + cancel.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + cancel(); + } + }); + } + } + public RequestProcessor.Task start(RequestProcessor rp, String repositoryRoot, String displayName) { setDisplayName(displayName); this.repositoryRoot = repositoryRoot; @@ -81,6 +99,17 @@ return task; } + public RequestProcessor.Task start(RequestProcessor rp) { + startProgress(); + task = rp.post(this); + return task; + } + + public JComponent getProgressComponent() { + return ProgressHandleFactory.createProgressComponent(getProgressHandle() +); + } + public void setRepositoryRoot(String repositoryRoot) { this.repositoryRoot = repositoryRoot; logger = null; Index: src/org/netbeans/modules/mercurial/ui/commit/Bundle.properties --- src/org/netbeans/modules/mercurial/ui/commit/Bundle.properties Base (BASE) +++ src/org/netbeans/modules/mercurial/ui/commit/Bundle.properties Locally Modified (Based On LOCAL) @@ -87,3 +87,5 @@ ACSD_CommitDialog=This dialog lets you review list files to commit, exclude or include individual files and write commit message describing your changes. ACSN_CommitForm_Message=Commit Message ACSD_CommitForm_Message=Message describing your commit + +Progress_Preparing_Commit=Preparing Commit... Index: src/org/netbeans/modules/mercurial/ui/commit/CommitAction.java --- src/org/netbeans/modules/mercurial/ui/commit/CommitAction.java Base (BASE) +++ src/org/netbeans/modules/mercurial/ui/commit/CommitAction.java Locally Modified (Based On LOCAL) @@ -52,6 +52,7 @@ import org.netbeans.modules.mercurial.HgFileNode; import org.netbeans.modules.mercurial.HgModuleConfig; import org.netbeans.modules.mercurial.ui.actions.ContextAction; +import org.netbeans.modules.mercurial.ui.status.StatusAction; import org.netbeans.modules.mercurial.util.HgUtils; import org.netbeans.modules.mercurial.util.HgRepositoryContextCache; import org.netbeans.modules.mercurial.util.HgProjectUtils; @@ -63,8 +64,10 @@ import javax.swing.*; import java.awt.*; import java.io.File; +import java.util.logging.Level; import java.util.ArrayList; import java.util.List; +import java.util.Set; import java.util.Iterator; import java.util.Map; import javax.swing.event.TableModelEvent; @@ -99,8 +102,10 @@ } public boolean isEnabled () { - FileStatusCache cache = Mercurial.getInstance().getFileStatusCache(); - return cache.containsFileOfStatus(context, FileInformation.STATUS_LOCAL_CHANGE); + Set ctxFiles = context != null? context.getRootFiles(): null; + if(HgUtils.getRootFile(context) == null || ctxFiles == null || ctxFiles.size() == 0) + return false; + return true; } public void performAction(ActionEvent e) { @@ -125,12 +130,6 @@ } public static void commit(String contentTitle, final VCSContext ctx) { - FileStatusCache cache = Mercurial.getInstance().getFileStatusCache(); - File[] roots = ctx.getRootFiles().toArray(new File[ctx.getRootFiles().size()]); - if (roots == null || roots.length == 0) { - return; - } - final File repository = HgUtils.getRootFile(ctx); if (repository == null) return; String projName = HgProjectUtils.getProjectName(repository); @@ -140,53 +139,12 @@ } final String prjName = projName; - File[][] split = Utils.splitFlatOthers(roots); - List fileList = new ArrayList(); - for (int c = 0; c < split.length; c++) { - roots = split[c]; - boolean recursive = c == 1; - if (recursive) { - File[] files = cache.listFiles(ctx, FileInformation.STATUS_LOCAL_CHANGE); - for (int i= 0; i < files.length; i++) { - for(int r = 0; r < roots.length; r++) { - if( HgUtils.isParentOrEqual(roots[r], files[i]) ) { - if(!fileList.contains(files[i])) { - fileList.add(files[i]); - } - } - } - } - } else { - File[] files = HgUtils.flatten(roots, FileInformation.STATUS_LOCAL_CHANGE); - for (int i= 0; i nodesList = new ArrayList(fileList.size()); - - for (Iterator it = fileList.iterator(); it.hasNext();) { - File file = it.next(); - HgFileNode node = new HgFileNode(file); - nodesList.add(node); - } - nodes = nodesList.toArray(new HgFileNode[fileList.size()]); - data.setNodes(nodes); - JComponent component = data.getComponent(); panel.filesPanel.setLayout(new BorderLayout()); panel.filesPanel.add(component, BorderLayout.CENTER); @@ -202,6 +160,7 @@ cancelButton.getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getMessage(CommitAction.class, "ACSN_Commit_Action_Cancel")); cancelButton.getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(CommitAction.class, "ACSD_Commit_Action_Cancel")); + computeNodes(data, panel, ctx, repository, cancelButton); commitButton.setEnabled(false); dd.setOptions(new Object[] {commitButton, cancelButton}); dd.setHelpCtx(new HelpCtx(CommitAction.class)); @@ -241,6 +200,67 @@ } } + private static void computeNodes(final CommitTable table, final CommitPanel panel, final VCSContext ctx, final File repository, JButton cancel) { + RequestProcessor rp = Mercurial.getInstance().getRequestProcessor(repository); + final HgProgressSupport support = new HgProgressSupport(NbBundle.getMessage(CommitAction.class, "Progress_Preparing_Commit"), cancel) { + public void perform() { + try { + panel.progressPanel.setVisible(true); + // Ensure that cache is uptodate + StatusAction.executeStatus(ctx, this); + + FileStatusCache cache = Mercurial.getInstance().getFileStatusCache(); + File[] roots = ctx.getRootFiles().toArray(new File[ctx.getRootFiles().size()]); + + File[][] split = Utils.splitFlatOthers(roots); + List fileList = new ArrayList(); + for (int c = 0; c < split.length; c++) { + roots = split[c]; + boolean recursive = c == 1; + if (recursive) { + File[] files = cache.listFiles(ctx, FileInformation.STATUS_LOCAL_CHANGE); + for (int i= 0; i < files.length; i++) { + for(int r = 0; r < roots.length; r++) { + if( HgUtils.isParentOrEqual(roots[r], files[i]) ) { + if(!fileList.contains(files[i])) { + fileList.add(files[i]); + } + } + } + } + } else { + File[] files = HgUtils.flatten(roots, FileInformation.STATUS_LOCAL_CHANGE); + for (int i= 0; i nodesList = new ArrayList(fileList.size()); + + for (Iterator it = fileList.iterator(); it.hasNext();) { + File file = it.next(); + HgFileNode node = new HgFileNode(file); + nodesList.add(node); + } + nodes = nodesList.toArray(new HgFileNode[fileList.size()]); + table.setNodes(nodes); + } finally { + panel.progressPanel.setVisible(false); + } + } + }; + panel.barPanel.add(support.getProgressComponent(), BorderLayout.CENTER); + panel.barPanel.setVisible(true); + support.start(rp); + } + private static boolean containsCommitable(CommitTable data) { Map map = data.getCommitFiles(); for(CommitOptions co : map.values()) { Index: src/org/netbeans/modules/mercurial/ui/commit/CommitPanel.form --- src/org/netbeans/modules/mercurial/ui/commit/CommitPanel.form Base (BASE) +++ src/org/netbeans/modules/mercurial/ui/commit/CommitPanel.form Locally Modified (Based On LOCAL) @@ -31,18 +31,26 @@ + + + + + + - - + + - + + + @@ -60,8 +68,10 @@ - + + + @@ -125,12 +135,12 @@ - + - + @@ -147,5 +157,52 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Index: src/org/netbeans/modules/mercurial/ui/commit/CommitPanel.java --- src/org/netbeans/modules/mercurial/ui/commit/CommitPanel.java Base (BASE) +++ src/org/netbeans/modules/mercurial/ui/commit/CommitPanel.java Locally Modified (Based On LOCAL) @@ -158,31 +158,59 @@ filesPanel.setLayout(filesPanelLayout); filesPanelLayout.setHorizontalGroup( filesPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) - .add(0, 626, Short.MAX_VALUE) + .add(0, 637, Short.MAX_VALUE) ); filesPanelLayout.setVerticalGroup( filesPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) - .add(0, 196, Short.MAX_VALUE) + .add(0, 181, Short.MAX_VALUE) ); recentLink.setIcon(new javax.swing.ImageIcon(getClass().getResource("/org/netbeans/modules/mercurial/resources/icons/recent_messages.png"))); // NOI18N recentLink.setToolTipText(org.openide.util.NbBundle.getMessage(CommitPanel.class, "CTL_CommitForm_RecentMessages")); // NOI18N + barPanel.setLayout(new java.awt.BorderLayout()); + + org.openide.awt.Mnemonics.setLocalizedText(jLabel3, org.openide.util.NbBundle.getMessage(CommitPanel.class, "Progress_Preparing_Commit")); // NOI18N + + org.jdesktop.layout.GroupLayout progressPanelLayout = new org.jdesktop.layout.GroupLayout(progressPanel); + progressPanel.setLayout(progressPanelLayout); + progressPanelLayout.setHorizontalGroup( + progressPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) + .add(progressPanelLayout.createSequentialGroup() + .add(jLabel3, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 142, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) + .addContainerGap(223, Short.MAX_VALUE)) + .add(progressPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) + .add(progressPanelLayout.createSequentialGroup() + .add(140, 140, 140) + .add(barPanel, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 225, Short.MAX_VALUE))) + ); + progressPanelLayout.setVerticalGroup( + progressPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) + .add(jLabel3, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 30, Short.MAX_VALUE) + .add(progressPanelLayout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) + .add(barPanel, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 30, Short.MAX_VALUE)) + ); + org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(this); this.setLayout(layout); layout.setHorizontalGroup( layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING) .add(org.jdesktop.layout.GroupLayout.TRAILING, layout.createSequentialGroup() + .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING) + .add(org.jdesktop.layout.GroupLayout.LEADING, layout.createSequentialGroup() + .add(284, 284, 284) + .add(progressPanel, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) + .add(layout.createSequentialGroup() .addContainerGap() .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING) - .add(org.jdesktop.layout.GroupLayout.LEADING, filesPanel, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 626, Short.MAX_VALUE) - .add(org.jdesktop.layout.GroupLayout.LEADING, jScrollPane1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 626, Short.MAX_VALUE) + .add(filesPanel, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 637, Short.MAX_VALUE) + .add(org.jdesktop.layout.GroupLayout.LEADING, jScrollPane1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 637, Short.MAX_VALUE) .add(org.jdesktop.layout.GroupLayout.LEADING, layout.createSequentialGroup() .add(jLabel1) - .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, 508, Short.MAX_VALUE) + .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, 496, Short.MAX_VALUE) .add(recentLink)) .add(org.jdesktop.layout.GroupLayout.LEADING, filesLabel) - .add(org.jdesktop.layout.GroupLayout.LEADING, jLabel2)) + .add(org.jdesktop.layout.GroupLayout.LEADING, jLabel2)))) .addContainerGap()) ); layout.setVerticalGroup( @@ -197,8 +225,10 @@ .add(15, 15, 15) .add(filesLabel) .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) - .add(filesPanel, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 196, Short.MAX_VALUE) + .add(filesPanel, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 181, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED) + .add(progressPanel, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .add(jLabel2) .addContainerGap()) ); @@ -217,12 +247,15 @@ } // Variables declaration - do not modify//GEN-BEGIN:variables + final javax.swing.JPanel barPanel = new javax.swing.JPanel(); final javax.swing.JLabel filesLabel = new javax.swing.JLabel(); final javax.swing.JPanel filesPanel = new javax.swing.JPanel(); final javax.swing.JLabel jLabel1 = new javax.swing.JLabel(); final javax.swing.JLabel jLabel2 = new javax.swing.JLabel(); + final javax.swing.JLabel jLabel3 = new javax.swing.JLabel(); final javax.swing.JScrollPane jScrollPane1 = new javax.swing.JScrollPane(); final javax.swing.JTextArea messageTextArea = new javax.swing.JTextArea(); + final javax.swing.JPanel progressPanel = new javax.swing.JPanel(); final javax.swing.JLabel recentLink = new javax.swing.JLabel(); // End of variables declaration//GEN-END:variables Index: src/org/netbeans/modules/mercurial/ui/diff/DiffAction.java --- src/org/netbeans/modules/mercurial/ui/diff/DiffAction.java Base (BASE) +++ src/org/netbeans/modules/mercurial/ui/diff/DiffAction.java Locally Modified (Based On LOCAL) @@ -46,6 +46,7 @@ import javax.swing.*; import java.awt.event.ActionEvent; import java.io.File; +import java.util.Set; import org.netbeans.modules.mercurial.FileInformation; import org.netbeans.modules.mercurial.FileStatusCache; @@ -97,8 +98,11 @@ } public boolean isEnabled() { - FileStatusCache cache = Mercurial.getInstance().getFileStatusCache(); - return cache.containsFileOfStatus(context, FileInformation.STATUS_LOCAL_CHANGE); + Set ctxFiles = context != null? context.getRootFiles(): null; + if(HgUtils.getRootFile(context) == null || ctxFiles == null || ctxFiles. +size() == 0) + return false; + return true; } public static void diff(VCSContext ctx, int type, String contextName) { Index: src/org/netbeans/modules/mercurial/ui/diff/MultiDiffPanel.java --- src/org/netbeans/modules/mercurial/ui/diff/MultiDiffPanel.java Base (BASE) +++ src/org/netbeans/modules/mercurial/ui/diff/MultiDiffPanel.java Locally Modified (Based On LOCAL) @@ -143,6 +143,7 @@ refreshSetups(); refreshComponents(); refreshTask = org.netbeans.modules.versioning.util.Utils.createTask(new RefreshViewTask()); + refreshStatuses(); } /** @@ -373,6 +374,10 @@ } private void onRefreshButton() { + refreshStatuses(); + } + + private void refreshStatuses() { if (context == null || context.getRootFiles().size() == 0) { return; }