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 209673
Collapse All | Expand All

(-)versioning.core/src/org/netbeans/modules/versioning/core/spi/VCSHistoryProvider.java (+67 lines)
Lines 41-46 Link Here
41
 */
41
 */
42
package org.netbeans.modules.versioning.core.spi;
42
package org.netbeans.modules.versioning.core.spi;
43
43
44
import java.io.File;
44
import java.io.IOException;
45
import java.io.IOException;
45
import java.util.Date;
46
import java.util.Date;
46
import javax.swing.Action;
47
import javax.swing.Action;
Lines 115-120 Link Here
115
        private Action[] actions;
116
        private Action[] actions;
116
        private RevisionProvider revisionProvider;
117
        private RevisionProvider revisionProvider;
117
        private MessageEditProvider mep;
118
        private MessageEditProvider mep;
119
        private ParentProvider parentProvider;        
118
        
120
        
119
        /**
121
        /**
120
         * Creates a new HistoryEntry instance.
122
         * Creates a new HistoryEntry instance.
Lines 188-193 Link Here
188
        }        
190
        }        
189
        
191
        
190
       /**
192
       /**
193
         * Creates a new HistoryEntry instance.
194
         * 
195
         * @param files involved files
196
         * @param dateTime the date and time when the versioning revision was created
197
         * @param message the message describing the versioning revision 
198
         * @param username full description of the user who created the versioning revision 
199
         * @param usernameShort short description of the user who created the versioning revision 
200
         * @param revision full description of the versioning revision
201
         * @param revisionShort short description of the versioning revision
202
         * @param actions actions which might be called in regard with this revision
203
         * @param revisionProvider a RevisionProvider to get access to a files contents in this revision
204
         * @param messageEditProvider a MessageEditProvider to change a revisions message
205
         * @param parentProvider a ParentProvider to provide this entries parent entry. Not necessary for VCS
206
         * where a revisions parent always is the time nearest previous revision.
207
         * 
208
         */
209
        public HistoryEntry(
210
                VCSFileProxy[] files, 
211
                Date dateTime, 
212
                String message, 
213
                String username, 
214
                String usernameShort, 
215
                String revision, 
216
                String revisionShort, 
217
                Action[] actions, 
218
                RevisionProvider revisionProvider,
219
                MessageEditProvider messageEditProvider,
220
                ParentProvider parentProvider) 
221
        {
222
            this(files, dateTime, message, username, usernameShort, revision, revisionShort, actions, revisionProvider, messageEditProvider);
223
            this.parentProvider = parentProvider;
224
        }
225
        
226
       /**
191
        * Determines if this HistoryEntry instance supports changes.
227
        * Determines if this HistoryEntry instance supports changes.
192
        * 
228
        * 
193
        * @return true if it is possible to access setter methods in this instance
229
        * @return true if it is possible to access setter methods in this instance
Lines 298-305 Link Here
298
                revisionProvider.getRevisionFile(originalFile, revisionFile);
334
                revisionProvider.getRevisionFile(originalFile, revisionFile);
299
            }
335
            }
300
        }
336
        }
337
        
338
        /**
339
         * Returns this revisions parent entry or null if not available.
340
         * 
341
         * @param file the file for whitch the parent HistoryEntry should be returned
342
         * @return this revisions parent entry
343
         */
344
        public HistoryEntry getParentEntry(VCSFileProxy file) {
345
            if(parentProvider != null) {
346
                return parentProvider.getParentEntry(file);
301
    }
347
    }
348
            return null;
349
        }
302
350
351
    }
352
303
    /**
353
    /**
304
     * Adds a listener for history change events.
354
     * Adds a listener for history change events.
305
     * 
355
     * 
Lines 357-362 Link Here
357
    }
407
    }
358
    
408
    
359
    /**
409
    /**
410
     * Implement and pass over to a {@link HistoryEntry} in case you want 
411
     * {@link HistoryEntry#getParentProvider()} to return relevant values.
412
     * 
413
     * @since 1.30
414
     */
415
    public interface ParentProvider {
416
        /**
417
         * Return a {@link HistoryEntry} representing the parent of the {@link HistoryEntry}
418
         * configured with this ParentProvider.
419
         * 
420
         * @param file the file for whitch the parent HistoryEntry should be returned
421
         * @return the parent HistoryEntry
422
         */
423
        HistoryEntry getParentEntry(VCSFileProxy file);
424
    }
425
    
426
    /**
360
     * Event notifying a change in the history of some files.
427
     * Event notifying a change in the history of some files.
361
     */    
428
     */    
362
    public static final class HistoryEvent {
429
    public static final class HistoryEvent {
(-)versioning.core/test/unit/src/org/netbeans/modules/versioning/core/spi/VCSHistoryTest.java (+59 lines)
Lines 117-122 Link Here
117
        assertTrue(provider.revisionprovided);
117
        assertTrue(provider.revisionprovided);
118
    }
118
    }
119
    
119
    
120
    public void testHistoryEntryProvidesParent() throws IOException {
121
        ParentProviderImpl provider = new ParentProviderImpl();
122
        VCSFileProxy file = VCSFileProxy.createFileProxy(new File(""));
123
        VCSHistoryProvider.HistoryEntry h =
124
                new VCSHistoryProvider.HistoryEntry(
125
                new VCSFileProxy[] {file},
126
                new Date(System.currentTimeMillis()),
127
                "msg",
128
                "user",
129
                "username",
130
                "12345",
131
                "1234567890",
132
                new Action[0],
133
                null,
134
                null,
135
                provider);
136
        HistoryEntry parent = h.getParentEntry(file);
137
        assertNotNull(parent);
138
        assertEquals(ParentProviderImpl.PARENT_MSG, parent.getMessage());
139
    }
140
120
    public void testHistoryEntryDoesntProvideRevision() throws IOException {
141
    public void testHistoryEntryDoesntProvideRevision() throws IOException {
121
        RevisionProviderImpl provider = new RevisionProviderImpl();
142
        RevisionProviderImpl provider = new RevisionProviderImpl();
122
        provider.revisionprovided = false;
143
        provider.revisionprovided = false;
Lines 135-140 Link Here
135
        // nothing happend
156
        // nothing happend
136
    }
157
    }
137
    
158
    
159
    public void testHistoryEntryDoesntProvideParent() throws IOException {
160
        RevisionProviderImpl provider = new RevisionProviderImpl();
161
        provider.revisionprovided = false;
162
        VCSFileProxy file = VCSFileProxy.createFileProxy(new File(""));
163
        VCSHistoryProvider.HistoryEntry h = 
164
                new VCSHistoryProvider.HistoryEntry(
165
                    new VCSFileProxy[] {file}, 
166
                    new Date(System.currentTimeMillis()), 
167
                    "msg", 
168
                    "user", 
169
                    "username", 
170
                    "12345", 
171
                    "1234567890", 
172
                    new Action[0], 
173
                    null);
174
        h.getParentEntry(file);
175
        // nothing happend
176
    }
177
    
138
    public void testHistoryEntryEditable() throws IOException {
178
    public void testHistoryEntryEditable() throws IOException {
139
        MessageEditProviderImpl provider = new MessageEditProviderImpl();
179
        MessageEditProviderImpl provider = new MessageEditProviderImpl();
140
        provider.message = null;
180
        provider.message = null;
Lines 231-234 Link Here
231
            this.message = message;
271
            this.message = message;
232
        }
272
        }
233
    }       
273
    }       
274
    
275
    private class ParentProviderImpl implements VCSHistoryProvider.ParentProvider {
276
        static final String PARENT_MSG = "im.the.parent";
277
        @Override
278
        public HistoryEntry getParentEntry(VCSFileProxy file) {
279
            return new HistoryEntry(
280
                    new VCSFileProxy[] {file}, 
281
                    new Date(System.currentTimeMillis()), 
282
                    PARENT_MSG, 
283
                    "user", 
284
                    "username", 
285
                    "12345", 
286
                    "1234567890", 
287
                    new Action[0], 
288
                    null,
289
                    null);
234
}
290
}
291
    }
292
293
}

Return to bug 209673