This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

View | Details | Raw Unified | Return to bug 170019
Collapse All | Expand All

(-)FileStatusCache.java (-6 / +20 lines)
Lines 180-193 Link Here
180
     *
180
     *
181
     * @param context context to examine
181
     * @param context context to examine
182
     * @param includeStatus limit returned files to those having one of supplied statuses
182
     * @param includeStatus limit returned files to those having one of supplied statuses
183
     * @param changed if null than the full scan of modified files will be performed,
184
     * otherwise returns cached files and changed[0] contains a flag denoting if the cached values are accurate
183
     * @return File [] array of interesting files
185
     * @return File [] array of interesting files
184
     */
186
     */
185
    public File [] listFiles(Context context, int includeStatus) {
187
    public File [] listFiles(Context context, int includeStatus, boolean changed[]) {
186
        Set<File> set = new HashSet<File>();
188
        Set<File> set = new HashSet<File>();
187
        Map allFiles = cacheProvider.getAllModifiedValues();
189
        Map<File, FileInformation> allFiles;
188
        for (Iterator i = allFiles.keySet().iterator(); i.hasNext();) {
190
        if (changed != null) {
189
            File file = (File) i.next();                                   
191
            // cached variant of the method is required
190
            FileInformation info = (FileInformation) allFiles.get(file);
192
            assert changed.length > 0;
193
            changed[0] = cacheProvider.modifiedFilesChanged();
194
            if (changed[0]) {
195
                // modified values are changed, there's no need to continue evaluating
196
                return new File[] {};
197
            }
198
            allFiles = cacheProvider.getCachedValues();
199
        } else {
200
            allFiles = cacheProvider.getAllModifiedValues();
201
        }
202
        for (Map.Entry<File, FileInformation> e : allFiles.entrySet()) {
203
            File file = e.getKey();
204
            FileInformation info = e.getValue();
191
            if ((info != null && (info.getStatus() & includeStatus) == 0)) continue;
205
            if ((info != null && (info.getStatus() & includeStatus) == 0)) continue;
192
            File [] roots = context.getRootFiles();
206
            File [] roots = context.getRootFiles();
193
            for (int j = 0; j < roots.length; j++) {
207
            for (int j = 0; j < roots.length; j++) {
Lines 359-365 Link Here
359
     * @param ctx context to refresh
373
     * @param ctx context to refresh
360
     */ 
374
     */ 
361
    public void refreshCached(Context ctx) {
375
    public void refreshCached(Context ctx) {
362
        File [] files = listFiles(ctx, ~0);
376
        File [] files = listFiles(ctx, ~0, null);
363
        for (int i = 0; i < files.length; i++) {
377
        for (int i = 0; i < files.length; i++) {
364
            File file = files[i];
378
            File file = files[i];
365
            refresh(file, REPOSITORY_STATUS_UNKNOWN);
379
            refresh(file, REPOSITORY_STATUS_UNKNOWN);
(-)ui/commit/CommitAction.java (-18 / +45 lines)
Lines 96-110 Link Here
96
96
97
    @Override
97
    @Override
98
    protected boolean enable(Node[] nodes) {
98
    protected boolean enable(Node[] nodes) {
99
        if (!super.enable(nodes)) {
100
            // only for managed files
101
            return false;
102
        }
99
        if(isDeepRefresh()) {
103
        if(isDeepRefresh()) {
100
            // allway true as we have will accept and check for external changes
104
            // allway true as we have will accept and check for external changes
101
            // and we don't about them yet
105
            // and we don't about them yet
102
            return true;
106
            return true;
103
        }
107
        }
104
        // XXX could be a performace issue, maybe a msg box in commit would be enough
105
        FileStatusCache cache = Subversion.getInstance().getStatusCache();
108
        FileStatusCache cache = Subversion.getInstance().getStatusCache();
106
        File[] files = cache.listFiles(getCachedContext(nodes), FileInformation.STATUS_LOCAL_CHANGE);
109
        boolean changed[] = new boolean[1];
107
        return files.length > 0;
110
        File[] files = cache.listFiles(getCachedContext(nodes), FileInformation.STATUS_LOCAL_CHANGE, changed);
111
        return changed[0] || files.length > 0;
108
    }
112
    }
109
113
110
    /** Run commit action. Shows UI */
114
    /** Run commit action. Shows UI */
Lines 134-155 Link Here
134
     */
138
     */
135
    public static void commitKnownChanges(String contentTitle, final Context ctx) {
139
    public static void commitKnownChanges(String contentTitle, final Context ctx) {
136
140
137
        // get files list
138
        List<File> fileList = getFiles(ctx);
139
        if(fileList.size() == 0) {
140
            return;
141
        }
142
143
        // show commit dialog
144
        final CommitPanel panel = new CommitPanel();
141
        final CommitPanel panel = new CommitPanel();
145
        List<SvnHook> hooks = Subversion.getInstance().getHooks();
146
        panel.setHooks(hooks, new SvnHookContext(new File[] { fileList.get(0) }, null, null));
147
        final CommitTable data = new CommitTable(panel.filesLabel, CommitTable.COMMIT_COLUMNS, new String[] { CommitTableModel.COLUMN_NAME_PATH });
142
        final CommitTable data = new CommitTable(panel.filesLabel, CommitTable.COMMIT_COLUMNS, new String[] { CommitTableModel.COLUMN_NAME_PATH });
148
        panel.setCommitTable(data);
143
        panel.setCommitTable(data);
144
        final JButton commitButton = new JButton();
149
145
150
        data.setNodes(getFileNodes(fileList));
146
        // start backround prepare
147
        SVNUrl repository = null;
148
        try {
149
            repository = getSvnUrl(ctx);
150
        } catch (SVNClientException ex) {
151
            SvnClientExceptionHandler.notifyException(ex, true, true);
152
        }
153
        final List<SvnHook> hooks = Subversion.getInstance().getHooks();
154
        panel.setHooks(hooks);
155
        SvnProgressSupport prepareSupport = new SvnProgressSupport() {
156
            public void perform() {
157
                try {
158
                    List<File> fileList = getFiles(ctx);
159
                    if (fileList.size() == 0) {
160
                        return;
161
                    }
162
                    data.setNodes(getFileNodes(fileList));
163
                } finally {
164
                    commitButton.setEnabled(containsCommitable(data));
151
165
152
        final JButton commitButton = new JButton();
166
                    panel.addVersioningListener(new VersioningListener() {
167
                        public void versioningEvent(VersioningEvent event) {
168
                            refreshCommitDialog(panel, data, commitButton);
169
                        }
170
                    });
171
                    data.getTableModel().addTableModelListener(new TableModelListener() {
172
                        public void tableChanged(TableModelEvent e) {
173
                            refreshCommitDialog(panel, data, commitButton);
174
                        }
175
                    });
176
                }
177
            }
178
        };
179
        RequestProcessor rp = Subversion.getInstance().getRequestProcessor(repository);
180
        prepareSupport.start(rp, repository, org.openide.util.NbBundle.getMessage(CommitAction.class, "BK1009")); // NOI18N
153
        if (showCommitDialog(panel, data, commitButton, contentTitle, ctx) == commitButton) {
181
        if (showCommitDialog(panel, data, commitButton, contentTitle, ctx) == commitButton) {
154
            // if OK setup sequence of add, remove and commit calls
182
            // if OK setup sequence of add, remove and commit calls
155
            startCommitTask(panel, data, ctx, hooks);
183
            startCommitTask(panel, data, ctx, hooks);
Lines 169-176 Link Here
169
197
170
        final CommitPanel panel = new CommitPanel();
198
        final CommitPanel panel = new CommitPanel();
171
        List<SvnHook> hooks = Subversion.getInstance().getHooks();
199
        List<SvnHook> hooks = Subversion.getInstance().getHooks();
172
        File file = ctx.getRootFiles()[0];
200
        panel.setHooks(hooks);
173
        panel.setHooks(hooks, new SvnHookContext(new File[] { file }, null, null));
174
201
175
        final CommitTable data = new CommitTable(panel.filesLabel, CommitTable.COMMIT_COLUMNS, new String[] { CommitTableModel.COLUMN_NAME_PATH });
202
        final CommitTable data = new CommitTable(panel.filesLabel, CommitTable.COMMIT_COLUMNS, new String[] { CommitTableModel.COLUMN_NAME_PATH });
176
        panel.setCommitTable(data);
203
        panel.setCommitTable(data);
Lines 230-236 Link Here
230
            contextFiles = split[c];
257
            contextFiles = split[c];
231
            boolean recursive = c == 1;
258
            boolean recursive = c == 1;
232
            if (recursive) {
259
            if (recursive) {
233
                File[] files = cache.listFiles(ctx, FileInformation.STATUS_LOCAL_CHANGE);
260
                File[] files = cache.listFiles(ctx, FileInformation.STATUS_LOCAL_CHANGE, null);
234
                for (int i= 0; i < files.length; i++) {
261
                for (int i= 0; i < files.length; i++) {
235
                    for(int r = 0; r < contextFiles.length; r++) {
262
                    for(int r = 0; r < contextFiles.length; r++) {
236
                        if( SvnUtils.isParentOrEqual(contextFiles[r], files[i]) ) {
263
                        if( SvnUtils.isParentOrEqual(contextFiles[r], files[i]) ) {
Lines 410-416 Link Here
410
                        contextFiles = split[c];
437
                        contextFiles = split[c];
411
                        boolean recursive = c == 1;
438
                        boolean recursive = c == 1;
412
                        if (recursive) {
439
                        if (recursive) {
413
                            File[] files = cache.listFiles(ctx, FileInformation.STATUS_LOCAL_CHANGE);
440
                            File[] files = cache.listFiles(ctx, FileInformation.STATUS_LOCAL_CHANGE, null);
414
                            for (int i= 0; i < files.length; i++) {
441
                            for (int i= 0; i < files.length; i++) {
415
                                for(int r = 0; r < contextFiles.length; r++) {
442
                                for(int r = 0; r < contextFiles.length; r++) {
416
                                    if( SvnUtils.isParentOrEqual(contextFiles[r], files[i]) ) {
443
                                    if( SvnUtils.isParentOrEqual(contextFiles[r], files[i]) ) {
(-)ui/commit/CommitPanel.java (-39 / +1 lines)
Lines 71-83 Link Here
71
import javax.swing.JLabel;
71
import javax.swing.JLabel;
72
import javax.swing.JPanel;
72
import javax.swing.JPanel;
73
import javax.swing.JScrollPane;
73
import javax.swing.JScrollPane;
74
import javax.swing.JTabbedPane;
75
import javax.swing.JTextArea;
74
import javax.swing.JTextArea;
76
import javax.swing.JTree;
75
import javax.swing.JTree;
77
import javax.swing.SwingUtilities;
76
import javax.swing.SwingUtilities;
78
import javax.swing.plaf.basic.BasicTreeUI;
77
import javax.swing.plaf.basic.BasicTreeUI;
79
import org.jdesktop.layout.LayoutStyle;
78
import org.jdesktop.layout.LayoutStyle;
80
import org.netbeans.modules.subversion.hooks.spi.SvnHookContext;
81
import org.netbeans.modules.versioning.util.AutoResizingPanel;
79
import org.netbeans.modules.versioning.util.AutoResizingPanel;
82
import org.netbeans.modules.versioning.util.PlaceholderPanel;
80
import org.netbeans.modules.versioning.util.PlaceholderPanel;
83
import org.netbeans.modules.versioning.util.VerticallyNonResizingPanel;
81
import org.netbeans.modules.versioning.util.VerticallyNonResizingPanel;
Lines 116-122 Link Here
116
114
117
    private CommitTable commitTable;
115
    private CommitTable commitTable;
118
    private List<SvnHook> hooks = Collections.emptyList();
116
    private List<SvnHook> hooks = Collections.emptyList();
119
    private SvnHookContext hookContext;
120
117
121
    /** Creates new form CommitPanel */
118
    /** Creates new form CommitPanel */
122
    public CommitPanel() {
119
    public CommitPanel() {
Lines 124-135 Link Here
124
        initInteraction();
121
        initInteraction();
125
    }
122
    }
126
123
127
    void setHooks(List<SvnHook> hooks, SvnHookContext context) {
124
    void setHooks(List<SvnHook> hooks) {
128
        if (hooks == null) {
125
        if (hooks == null) {
129
            hooks = Collections.emptyList();
126
            hooks = Collections.emptyList();
130
        }
127
        }
131
        this.hooks = hooks;
128
        this.hooks = hooks;
132
        this.hookContext = context;
133
    }
129
    }
134
130
135
    void setCommitTable(CommitTable commitTable) {
131
    void setCommitTable(CommitTable commitTable) {
Lines 235-274 Link Here
235
        }
231
        }
236
    }
232
    }
237
233
238
    private void initFilesPanel() {
239
240
        /* this method is called using reflection from 'invokeInitPanelMethod()' */
241
242
        filesPanel.add(commitTable.getComponent());
243
        filesPanel.setPreferredSize(new Dimension(0, 2 * messageTextArea.getPreferredSize().height));
244
245
        filesSectionPanel.setLayout(new BoxLayout(filesSectionPanel, Y_AXIS));
246
        filesSectionPanel.add(filesLabel);
247
        filesSectionPanel.add(makeVerticalStrut(filesLabel, filesPanel, RELATED));
248
        filesSectionPanel.add(filesPanel);
249
250
        filesLabel.setAlignmentX(LEFT_ALIGNMENT);
251
        filesPanel.setAlignmentX(LEFT_ALIGNMENT);
252
    }
253
254
    private void initHooksPanel() {
255
256
        /* this method is called using reflection from 'invokeInitPanelMethod()' */
257
258
        assert !hooks.isEmpty();
259
260
        if (hooks.size() == 1) {
261
            hooksSectionPanel.add(hooks.get(0).createComponent(hookContext));
262
        } else {
263
            JTabbedPane hooksTabbedPane = new JTabbedPane();
264
            for (SvnHook hook : hooks) {
265
                hooksTabbedPane.add(hook.createComponent(hookContext),
266
                                    hook.getDisplayName());
267
            }
268
            hooksSectionPanel.add(hooksTabbedPane);
269
        }
270
    }
271
272
    String getCommitMessage() {
234
    String getCommitMessage() {
273
        return messageTextArea.getText();
235
        return messageTextArea.getText();
274
    }
236
    }

Return to bug 170019