# This patch file was generated by NetBeans IDE # Following Index: paths are relative to: /home/ondra/netbeans/cdev/subversion/src/org/netbeans/modules/subversion # 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: FileStatusCache.java --- FileStatusCache.java Base (BASE) +++ FileStatusCache.java Locally Modified (Based On LOCAL) @@ -180,14 +180,28 @@ * * @param context context to examine * @param includeStatus limit returned files to those having one of supplied statuses + * @param changed if null than the full scan of modified files will be performed, + * otherwise returns cached files and changed[0] contains a flag denoting if the cached values are accurate * @return File [] array of interesting files */ - public File [] listFiles(Context context, int includeStatus) { + public File [] listFiles(Context context, int includeStatus, boolean changed[]) { Set set = new HashSet(); - Map allFiles = cacheProvider.getAllModifiedValues(); - for (Iterator i = allFiles.keySet().iterator(); i.hasNext();) { - File file = (File) i.next(); - FileInformation info = (FileInformation) allFiles.get(file); + Map allFiles; + if (changed != null) { + // cached variant of the method is required + assert changed.length > 0; + changed[0] = cacheProvider.modifiedFilesChanged(); + if (changed[0]) { + // modified values are changed, there's no need to continue evaluating + return new File[] {}; + } + allFiles = cacheProvider.getCachedValues(); + } else { + allFiles = cacheProvider.getAllModifiedValues(); + } + for (Map.Entry e : allFiles.entrySet()) { + File file = e.getKey(); + FileInformation info = e.getValue(); if ((info != null && (info.getStatus() & includeStatus) == 0)) continue; File [] roots = context.getRootFiles(); for (int j = 0; j < roots.length; j++) { @@ -359,7 +373,7 @@ * @param ctx context to refresh */ public void refreshCached(Context ctx) { - File [] files = listFiles(ctx, ~0); + File [] files = listFiles(ctx, ~0, null); for (int i = 0; i < files.length; i++) { File file = files[i]; refresh(file, REPOSITORY_STATUS_UNKNOWN); Index: ui/commit/CommitAction.java --- ui/commit/CommitAction.java Base (BASE) +++ ui/commit/CommitAction.java Locally Modified (Based On LOCAL) @@ -96,15 +96,19 @@ @Override protected boolean enable(Node[] nodes) { + if (!super.enable(nodes)) { + // only for managed files + return false; + } if(isDeepRefresh()) { // allway true as we have will accept and check for external changes // and we don't about them yet return true; } - // XXX could be a performace issue, maybe a msg box in commit would be enough FileStatusCache cache = Subversion.getInstance().getStatusCache(); - File[] files = cache.listFiles(getCachedContext(nodes), FileInformation.STATUS_LOCAL_CHANGE); - return files.length > 0; + boolean changed[] = new boolean[1]; + File[] files = cache.listFiles(getCachedContext(nodes), FileInformation.STATUS_LOCAL_CHANGE, changed); + return changed[0] || files.length > 0; } /** Run commit action. Shows UI */ @@ -134,22 +138,46 @@ */ public static void commitKnownChanges(String contentTitle, final Context ctx) { - // get files list - List fileList = getFiles(ctx); - if(fileList.size() == 0) { - return; - } - - // show commit dialog final CommitPanel panel = new CommitPanel(); - List hooks = Subversion.getInstance().getHooks(); - panel.setHooks(hooks, new SvnHookContext(new File[] { fileList.get(0) }, null, null)); final CommitTable data = new CommitTable(panel.filesLabel, CommitTable.COMMIT_COLUMNS, new String[] { CommitTableModel.COLUMN_NAME_PATH }); panel.setCommitTable(data); + final JButton commitButton = new JButton(); - data.setNodes(getFileNodes(fileList)); + // start backround prepare + SVNUrl repository = null; + try { + repository = getSvnUrl(ctx); + } catch (SVNClientException ex) { + SvnClientExceptionHandler.notifyException(ex, true, true); + } + final List hooks = Subversion.getInstance().getHooks(); + panel.setHooks(hooks); + SvnProgressSupport prepareSupport = new SvnProgressSupport() { + public void perform() { + try { + List fileList = getFiles(ctx); + if (fileList.size() == 0) { + return; + } + data.setNodes(getFileNodes(fileList)); + } finally { + commitButton.setEnabled(containsCommitable(data)); - final JButton commitButton = new JButton(); + panel.addVersioningListener(new VersioningListener() { + public void versioningEvent(VersioningEvent event) { + refreshCommitDialog(panel, data, commitButton); + } + }); + data.getTableModel().addTableModelListener(new TableModelListener() { + public void tableChanged(TableModelEvent e) { + refreshCommitDialog(panel, data, commitButton); + } + }); + } + } + }; + RequestProcessor rp = Subversion.getInstance().getRequestProcessor(repository); + prepareSupport.start(rp, repository, org.openide.util.NbBundle.getMessage(CommitAction.class, "BK1009")); // NOI18N if (showCommitDialog(panel, data, commitButton, contentTitle, ctx) == commitButton) { // if OK setup sequence of add, remove and commit calls startCommitTask(panel, data, ctx, hooks); @@ -169,8 +197,7 @@ final CommitPanel panel = new CommitPanel(); List hooks = Subversion.getInstance().getHooks(); - File file = ctx.getRootFiles()[0]; - panel.setHooks(hooks, new SvnHookContext(new File[] { file }, null, null)); + panel.setHooks(hooks); final CommitTable data = new CommitTable(panel.filesLabel, CommitTable.COMMIT_COLUMNS, new String[] { CommitTableModel.COLUMN_NAME_PATH }); panel.setCommitTable(data); @@ -230,7 +257,7 @@ contextFiles = split[c]; boolean recursive = c == 1; if (recursive) { - File[] files = cache.listFiles(ctx, FileInformation.STATUS_LOCAL_CHANGE); + File[] files = cache.listFiles(ctx, FileInformation.STATUS_LOCAL_CHANGE, null); for (int i= 0; i < files.length; i++) { for(int r = 0; r < contextFiles.length; r++) { if( SvnUtils.isParentOrEqual(contextFiles[r], files[i]) ) { @@ -410,7 +437,7 @@ contextFiles = split[c]; boolean recursive = c == 1; if (recursive) { - File[] files = cache.listFiles(ctx, FileInformation.STATUS_LOCAL_CHANGE); + File[] files = cache.listFiles(ctx, FileInformation.STATUS_LOCAL_CHANGE, null); for (int i= 0; i < files.length; i++) { for(int r = 0; r < contextFiles.length; r++) { if( SvnUtils.isParentOrEqual(contextFiles[r], files[i]) ) { Index: ui/commit/CommitPanel.java --- ui/commit/CommitPanel.java Base (BASE) +++ ui/commit/CommitPanel.java Locally Modified (Based On LOCAL) @@ -71,13 +71,11 @@ import javax.swing.JLabel; import javax.swing.JPanel; import javax.swing.JScrollPane; -import javax.swing.JTabbedPane; import javax.swing.JTextArea; import javax.swing.JTree; import javax.swing.SwingUtilities; import javax.swing.plaf.basic.BasicTreeUI; import org.jdesktop.layout.LayoutStyle; -import org.netbeans.modules.subversion.hooks.spi.SvnHookContext; import org.netbeans.modules.versioning.util.AutoResizingPanel; import org.netbeans.modules.versioning.util.PlaceholderPanel; import org.netbeans.modules.versioning.util.VerticallyNonResizingPanel; @@ -116,7 +114,6 @@ private CommitTable commitTable; private List hooks = Collections.emptyList(); - private SvnHookContext hookContext; /** Creates new form CommitPanel */ public CommitPanel() { @@ -124,12 +121,11 @@ initInteraction(); } - void setHooks(List hooks, SvnHookContext context) { + void setHooks(List hooks) { if (hooks == null) { hooks = Collections.emptyList(); } this.hooks = hooks; - this.hookContext = context; } void setCommitTable(CommitTable commitTable) { @@ -235,40 +231,6 @@ } } - private void initFilesPanel() { - - /* this method is called using reflection from 'invokeInitPanelMethod()' */ - - filesPanel.add(commitTable.getComponent()); - filesPanel.setPreferredSize(new Dimension(0, 2 * messageTextArea.getPreferredSize().height)); - - filesSectionPanel.setLayout(new BoxLayout(filesSectionPanel, Y_AXIS)); - filesSectionPanel.add(filesLabel); - filesSectionPanel.add(makeVerticalStrut(filesLabel, filesPanel, RELATED)); - filesSectionPanel.add(filesPanel); - - filesLabel.setAlignmentX(LEFT_ALIGNMENT); - filesPanel.setAlignmentX(LEFT_ALIGNMENT); - } - - private void initHooksPanel() { - - /* this method is called using reflection from 'invokeInitPanelMethod()' */ - - assert !hooks.isEmpty(); - - if (hooks.size() == 1) { - hooksSectionPanel.add(hooks.get(0).createComponent(hookContext)); - } else { - JTabbedPane hooksTabbedPane = new JTabbedPane(); - for (SvnHook hook : hooks) { - hooksTabbedPane.add(hook.createComponent(hookContext), - hook.getDisplayName()); - } - hooksSectionPanel.add(hooksTabbedPane); - } - } - String getCommitMessage() { return messageTextArea.getText(); }