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 (+65 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
         * @return this revisions parent entry
342
         */
343
        public HistoryEntry getParentEntry() {
344
            if(parentProvider != null) {
345
                return parentProvider.getParentEntry();
301
    }
346
    }
347
            return null;
348
        }
302
349
350
    }
351
303
    /**
352
    /**
304
     * Adds a listener for history change events.
353
     * Adds a listener for history change events.
305
     * 
354
     * 
Lines 357-362 Link Here
357
    }
406
    }
358
    
407
    
359
    /**
408
    /**
409
     * Implement and pass over to a {@link HistoryEntry} in case you want 
410
     * {@link HistoryEntry#getParentProvider()} to return relevant values.
411
     * 
412
     * @since 1.30
413
     */
414
    public interface ParentProvider {
415
        /**
416
         * Return a {@link HistoryEntry} representing the parent of the {@link HistoryEntry}
417
         * configured with this ParentProvider.
418
         * 
419
         * @return the parent HistoryEntry
420
         */
421
        HistoryEntry getParentEntry();
422
    }
423
    
424
    /**
360
     * Event notifying a change in the history of some files.
425
     * Event notifying a change in the history of some files.
361
     */    
426
     */    
362
    public static final class HistoryEvent {
427
    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
        VCSHistoryProvider.HistoryEntry h =
123
                new VCSHistoryProvider.HistoryEntry(
124
                new VCSFileProxy[] {VCSFileProxy.createFileProxy(new File(""))},
125
                new Date(System.currentTimeMillis()),
126
                "msg",
127
                "user",
128
                "username",
129
                "12345",
130
                "1234567890",
131
                new Action[0],
132
                null,
133
                null,
134
                provider);
135
        HistoryEntry parent = h.getParentEntry();
136
        assertNotNull(parent);
137
        assertEquals(ParentProviderImpl.PARENT_MSG, parent.getMessage());
138
    }
139
120
    public void testHistoryEntryDoesntProvideRevision() throws IOException {
140
    public void testHistoryEntryDoesntProvideRevision() throws IOException {
121
        RevisionProviderImpl provider = new RevisionProviderImpl();
141
        RevisionProviderImpl provider = new RevisionProviderImpl();
122
        provider.revisionprovided = false;
142
        provider.revisionprovided = false;
Lines 135-140 Link Here
135
        // nothing happend
155
        // nothing happend
136
    }
156
    }
137
    
157
    
158
    public void testHistoryEntryDoesntProvideParent() throws IOException {
159
        RevisionProviderImpl provider = new RevisionProviderImpl();
160
        provider.revisionprovided = false;
161
        VCSHistoryProvider.HistoryEntry h = 
162
                new VCSHistoryProvider.HistoryEntry(
163
                    new VCSFileProxy[] {VCSFileProxy.createFileProxy(new File(""))}, 
164
                    new Date(System.currentTimeMillis()), 
165
                    "msg", 
166
                    "user", 
167
                    "username", 
168
                    "12345", 
169
                    "1234567890", 
170
                    new Action[0], 
171
                    null);
172
        h.getParentEntry();
173
        // nothing happend
174
    }
175
    
138
    public void testHistoryEntryEditable() throws IOException {
176
    public void testHistoryEntryEditable() throws IOException {
139
        MessageEditProviderImpl provider = new MessageEditProviderImpl();
177
        MessageEditProviderImpl provider = new MessageEditProviderImpl();
140
        provider.message = null;
178
        provider.message = null;
Lines 231-234 Link Here
231
            this.message = message;
269
            this.message = message;
232
        }
270
        }
233
    }       
271
    }       
272
    
273
    private class ParentProviderImpl implements VCSHistoryProvider.ParentProvider {
274
        static final String PARENT_MSG = "im.the.parent";
275
        private HistoryEntry he = 
276
                new HistoryEntry(
277
                    new VCSFileProxy[] {VCSFileProxy.createFileProxy(new File(""))}, 
278
                    new Date(System.currentTimeMillis()), 
279
                    PARENT_MSG, 
280
                    "user", 
281
                    "username", 
282
                    "12345", 
283
                    "1234567890", 
284
                    new Action[0], 
285
                    null,
286
                    null);
287
        @Override
288
        public HistoryEntry getParentEntry() {
289
            return he;
234
}
290
}
291
    }
292
293
}

Return to bug 209673