KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > autoupdate > DependencyChecker


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19
20 package org.netbeans.modules.autoupdate;
21
22 import java.util.*;
23 import java.util.logging.Level JavaDoc;
24 import java.util.logging.Logger JavaDoc;
25 import org.openide.DialogDisplayer;
26
27 import org.openide.util.NbBundle;
28 import org.openide.NotifyDescriptor;
29 import org.openide.modules.ModuleInfo;
30 import org.openide.modules.Dependency;
31 import org.openide.modules.SpecificationVersion;
32
33 /** Support class for checking dependencies between modules
34  *
35  * @author phrebejk
36  */

37 class DependencyChecker extends Object JavaDoc {
38
39     /** DependencyChecker is a singleton */
40     DependencyChecker() {
41     }
42     
43     private static final Logger JavaDoc err = Logger.getLogger("org.netbeans.modules.autoupdate"); // NOI18N
44

45     /** Gets collection of modules which have to be added to download list
46      * if we have to add the toAddModule.
47      */

48     Collection modulesToAdd( ModuleUpdate toAdd, Enumeration selected, List group, StringBuffer JavaDoc dontAddModuleName ) {
49         err.log(Level.FINE,
50                 "DO modulesToAdd: " + toAdd.getCodeNameBase() + "[L10N? " +
51                 (toAdd instanceof L10NUpdate) + "], group: " + group +
52                 ", dontAddModuleName: " + dontAddModuleName);
53         Collection result = new ArrayList();
54         checkDependencies( toAdd.getRemoteModule(), result, selected, group, dontAddModuleName, toAdd.getLocalModule() != null );
55         if (err.isLoggable(Level.FINE)) {
56             String JavaDoc res = "";
57             Iterator it = result.iterator ();
58             while (it.hasNext ()) {
59                 ModuleUpdate mu = (ModuleUpdate) it.next ();
60                 res = res + mu.getCodeNameBase () + "[L10N? " + (mu instanceof L10NUpdate) + "], ";
61                 err.log(Level.FINE,
62                         "modulesToAdd: " + toAdd.getCodeNameBase() +
63                         ", RETURNS: " + res);
64             }
65         }
66         
67         // add localization dependency
68
err.log(Level.FINE,
69                 "Do find localization for " + toAdd.getCodeNameBase() +
70                 " on locale " + Locale.getDefault());
71         checkFreeLocalizationDependency (toAdd, Locale.getDefault ().toString (), result, selected, group);
72
73         return result;
74     }
75
76     /** Gets collection of modules which we have to remove from download list
77      * if we have to remove the toRemove module.
78      */

79     Collection modulesToRemove( ModuleUpdate toRemove, ModuleUpdate toReplace ) {
80         Collection result = new ArrayList();
81         checkReverseDependencies( toRemove.getRemoteModule(), result, toReplace );
82         return result;
83     }
84
85     /** Builds Collection with modules which should be added
86      * into download list to satisfy module dependencies.
87      */

88     private boolean checkDependencies( ModuleInfo md, Collection result, Enumeration selected, List group,
89             StringBuffer JavaDoc dontAddModuleName, boolean isUpgrade ) {
90
91         // Get all module dependencies
92
Set depsS = md.getDependencies();
93         Dependency[] deps = (Dependency[])depsS.toArray(new Dependency[depsS.size()]);
94         // Array values say if the dependency is satisfied or not
95
boolean[] satisfied = new boolean [ deps.length ];
96
97         // All installed modules
98
ModuleInfo[] installedModules = Updates.getInstalledModules();
99         ModuleInfo[] installedPatches = Updates.getInstalledPatches();
100
101         // For all dependencies
102
for ( int j = 0; j < deps.length; j++ ) {
103             
104             // The module depends on other module
105
if (deps[j].getType() == Dependency.TYPE_MODULE || deps[j].getType() == Dependency.TYPE_REQUIRES) {
106
107                 boolean ok = false;
108
109                 // Try to figure out if the dependency is satisfied by installed modules
110
for (int i = 0; i < installedModules.length; i++) {
111                     ok = checkModuleDependency ( deps[j], installedModules[i] );
112
113                     if ( ok )
114                         break;
115                 }
116
117                 if ( !ok ) {
118                     // Try to figure out if the dependency is satisfied by installed patches
119
for (int i = 0; i < installedPatches.length; i++) {
120                         ok = checkModuleDependency ( deps[j], installedPatches[i] );
121                         if ( ok )
122                             break;
123                     }
124                 }
125                 
126                 // Dependency was not satisfied by other module let's try modules
127
// available for download
128
if ( !ok && selected != null ) {
129
130                     while ( selected.hasMoreElements() ) {
131                         ModuleUpdate mu = (ModuleUpdate)selected.nextElement();
132                         if (mu instanceof L10NUpdate) {
133                             continue;
134                         }
135
136                         ok = checkModuleDependency ( deps[j], mu.getRemoteModule() );
137
138                         if ( ok ) {
139                             if ( !result.contains( mu ) ) {
140                                 err.log(Level.FINE,
141                                         " ADDED[SELECTED]: " +
142                                         mu.getCodeNameBase() + "[L10N? " +
143                                         (mu instanceof L10NUpdate) + "]: DEP: " +
144                                         deps[j]);
145                                 result.add( mu );
146                             }
147                             break;
148                         }
149                     }
150                 }
151                 
152                 if ( !ok && group != null ) {
153
154                     Iterator it = group.iterator();
155                     while ( it.hasNext() ) {
156                         ModuleUpdate mu = (ModuleUpdate)it.next();
157                         if (mu instanceof L10NUpdate) {
158                             continue;
159                         }
160
161
162                         ok = checkModuleDependency ( deps[j], mu.getRemoteModule() );
163                         if ( ok ) {
164                             if ( !result.contains( mu ) ) {
165                                 err.log(Level.FINE,
166                                         " ADDED[GROUP]: " +
167                                         mu.getCodeNameBase() + "[L10N? " +
168                                         (mu instanceof L10NUpdate) + "]: DEP: " +
169                                         deps[j]);
170                                 result.add( mu );
171                             }
172                             break;
173                         }
174                     }
175                 }
176                 
177                 if ( !ok ) {
178
179                     Iterator it = Wizard.getAllModules().iterator();
180                     while ( it.hasNext() ) {
181                         ModuleUpdate mu = (ModuleUpdate)it.next();
182                         if (mu instanceof L10NUpdate) {
183                             continue;
184                         }
185
186
187                         ok = checkModuleDependency ( deps[j], mu.getRemoteModule() );
188
189                         if ( ok ) {
190                             if ( !result.contains( mu ) ) {
191                                 err.log(Level.FINE,
192                                         " ADDED[ALL]: " + mu.getCodeNameBase() +
193                                         "[L10N? " + (mu instanceof L10NUpdate) +
194                                         "]: DEP: " + deps[j]);
195                                 result.add( mu );
196                             }
197                             break;
198                         }
199                     }
200                 }
201
202                 if ( !ok )
203                     satisfied[j] = false;
204                 else
205                     satisfied[j] = true;
206             }
207             // Module depends on specific version of IDE
208
else if ( deps[j].getType() == Dependency.TYPE_IDE ) {
209                 // Try to figure out if the dependency is satisfied by installed ide
210
if ( checkIdeDependency ( deps[j], IdeDescription.getIdeDescription() ) ) {
211                     satisfied[j] = true;
212                 }
213                 else {
214                     // Try to find suitable IDE between the modules
215
Iterator it = Wizard.getAllModules().iterator();
216                     boolean ok = false;
217                     while ( it.hasNext() ) {
218                         ModuleUpdate mu = (ModuleUpdate)it.next();
219                         if (mu instanceof L10NUpdate) {
220                             continue;
221                         }
222
223
224                         ok = checkModuleDependency ( deps[j], mu.getRemoteModule() );
225                         if ( ok ) {
226                             if ( !result.contains( mu ) ) {
227                                 err.log(Level.FINE,
228                                         " ADDED[GROUP]: " +
229                                         mu.getCodeNameBase() + "[L10N? " +
230                                         (mu instanceof L10NUpdate) + "]: DEP: " +
231                                         deps[j]);
232                                 result.add( mu );
233                             }
234                             break;
235                         }
236                     }
237                     satisfied[j] = ok;
238                 }
239             }
240             else // XXX what about Java/VM dependencies?!
241
satisfied[j] = true;
242         }
243         
244         StringBuffer JavaDoc sb = new StringBuffer JavaDoc( 280 );
245         sb.append (getBundle ("MSG_NotSatisfied")); // NOI18N
246
sb.append (NbBundle.getMessage (DependencyChecker.class, "TXT_DependencyChecker_Module", md.getDisplayName (), md.getCodeName ())); // NOI18N
247

248         int notSatisfied = 0;
249
250         // For all dependencies
251
for ( int j = 0; j < deps.length; j++ ) {
252             if ( !satisfied[j] ) {
253                 sb.append( deps[j] + "\n"); // NOI18N
254
notSatisfied++;
255             }
256         }
257         
258         StringBuffer JavaDoc sbbroken = null;
259         if ( isUpgrade ) {
260             // Checking, if upgrade of module doesn't break dependency of already
261
// installed modules on it's certain implementation version
262
List brokenlist = checkBrokenImplDependency( md, result );
263             if ( brokenlist.size() > 0 ) {
264                 sbbroken = new StringBuffer JavaDoc( 280 );
265                 sbbroken.append (NbBundle.getMessage (DependencyChecker.class, "TXT_BrokenDependencyChecker_Module", md.getDisplayName (), md.getCodeName ())); // NOI18N
266
sbbroken.append( getBundle( "MSG_BadsList" ) ); // NOI18N
267
Iterator it = brokenlist.iterator();
268                 while ( it.hasNext() ) {
269                     sbbroken.append (((ModuleInfo) it.next()).getCodeName() + "\n"); // NOI18N
270
}
271                 sbbroken.append( getBundle( "MSG_IncludeBadsAnyway" ) ); // NOI18N
272
}
273         }
274         
275         if ( notSatisfied == 0 && sbbroken == null )
276             return true;
277
278         if ( notSatisfied > 0 ) {
279             sb.append( getBundle( "MSG_IncludeAnyway" ) ); // NOI18N
280
NotifyDescriptor.Confirmation nd = new NotifyDescriptor.Confirmation(
281                                               sb.toString(),
282                                               NotifyDescriptor.YES_NO_OPTION,
283                                               NotifyDescriptor.ERROR_MESSAGE );
284
285             if ( ! DialogDisplayer.getDefault().notify( nd ).equals( NotifyDescriptor.YES_OPTION ) ) {
286                 dontAddModuleName.append( md.getDisplayName() );
287                 return false;
288             }
289         }
290         if ( sbbroken != null ) {
291             NotifyDescriptor.Confirmation nd = new NotifyDescriptor.Confirmation(
292                                               sbbroken.toString(),
293                                               NotifyDescriptor.YES_NO_OPTION,
294                                               NotifyDescriptor.ERROR_MESSAGE );
295
296             if ( ! DialogDisplayer.getDefault().notify( nd ).equals( NotifyDescriptor.YES_OPTION ) )
297                 dontAddModuleName.append( md.getDisplayName() );
298         }
299
300         return false;
301     }
302
303
304     /** Builds Collection with modules which should be removed
305      * from download list to satisfy module dependencies.
306      */

307     boolean checkReverseDependencies( ModuleInfo module, Collection result, ModuleUpdate toReplace ) {
308
309         //ArrayList dependentModules = new ArrayList();
310
ModuleInfo[] installedModules = Updates.getInstalledModules();
311         ModuleInfo[] installedPatches = Updates.getInstalledPatches();
312
313         // All listed modules
314
Iterator it = Wizard.getAllModules().iterator();
315         while ( it.hasNext() ) {
316             ModuleUpdate mu = (ModuleUpdate)it.next();
317
318
319             //if ( !info.update() ) We have to check all modules
320
// continue;
321

322             ModuleInfo md = mu.getRemoteModule();
323             Set depsS = md.getDependencies();
324             Dependency[] deps = (Dependency[])depsS.toArray(new Dependency[depsS.size()]);
325
326             // All dependencies of module
327
boolean moduleOk = true;
328             for ( int j = 0; j < deps.length; j++ ) {
329
330
331
332                 if ( (deps[j].getType() == Dependency.TYPE_MODULE &&
333                          (deps[j].getName() + "/").startsWith( module.getCodeNameBase() + "/" )) || // NOI18N
334
(deps[j].getType() == Dependency.TYPE_REQUIRES &&
335                          Arrays.asList(module.getProvides()).contains(deps[j].getName())) ) {
336
337                     boolean ok = false;
338
339                     // Check if not satisfied by installed modules
340
for (int k = 0; k < installedModules.length; k++) {
341                         ok = checkModuleDependency ( deps[j], installedModules[k] );
342                         if ( ok )
343                             break;
344                     }
345                     
346                     // Check if not satisfied by replacing module
347
if ( !ok && toReplace != null )
348                         ok = checkModuleDependency ( deps[j], toReplace.getRemoteModule() );
349
350                     // Check if it is not stisfied by installed patches
351
if ( !ok )
352                         for (int k = 0; k < installedPatches.length; k++) {
353                             ok = checkModuleDependency ( deps[j], installedPatches[k] );
354                             if ( ok )
355                                 break;
356                         }
357
358
359                     // The module has unsatisfied dependency we have to remove it
360
if ( !ok ) {
361                         moduleOk = false;
362                         break;
363                     }
364                 }
365                 else if ( deps[j].getType() == Dependency.TYPE_IDE &&
366                           // XXX how can this be true?!
367
deps[j].getName().equals( module.getCodeName() ) ) {
368
369                     //Check if not satisfied by installed IDE
370
if ( !checkModuleDependency ( deps[j], IdeDescription.getIdeDescription() ) ) {
371                         moduleOk = false;
372                         break;
373                     }
374                 }
375             }
376
377             if ( !moduleOk ) {
378                 if ( ! result.contains( mu ) ) {
379                     result.add( mu );
380                     //checkReverseDependencies( mu.getRemoteModule(), result );
381
}
382             }
383         }
384
385         return result.size() == 0;
386     }
387
388
389     /** Tests if the dependency on module is satisfied by the otherModule
390      */

391     static boolean checkModuleDependency ( Dependency dep,
392                                     ModuleInfo otherModule ) {
393
394         if (dep.getType() == Dependency.TYPE_REQUIRES) {
395             return Arrays.asList(otherModule.getProvides()).contains(dep.getName());
396         }
397
398         String JavaDoc depName = dep.getName();
399
400         if ( depName.equals (otherModule.getCodeName ())) {
401             if ( dep.getComparison() == Dependency.COMPARE_ANY) {
402                 return true;
403             }
404             else if (dep.getComparison() == Dependency.COMPARE_SPEC) {
405                     if (otherModule.getSpecificationVersion() == null)
406                         return false;
407                     else if (new SpecificationVersion(dep.getVersion()).compareTo(otherModule.getSpecificationVersion()) > 0)
408                         return false;
409                     else
410                         return true;
411             }
412             else {
413                 // COMPARE_IMPL
414
if (otherModule.getImplementationVersion () == null)
415                     return false;
416                 else if (! otherModule.getImplementationVersion ().equals (dep.getVersion()))
417                     return false;
418                 else
419                     return true;
420             }
421         }
422
423         int dash = depName.indexOf('-'); // NOI18N
424
if (dash != -1) {
425             // Ranged major release version, cf. #19714.
426
int slash = depName.indexOf('/'); // NOI18N
427
String JavaDoc cnb = depName.substring(0, slash);
428             int relMin = Integer.parseInt(depName.substring(slash + 1, dash));
429             int relMax = Integer.parseInt(depName.substring(dash + 1));
430             if (cnb.equals(otherModule.getCodeNameBase()) &&
431                     relMin <= otherModule.getCodeNameRelease() &&
432                     relMax >= otherModule.getCodeNameRelease()) {
433                 if (dep.getComparison() == Dependency.COMPARE_ANY) {
434                     return true;
435                 } else {
436                     // COMPARE_SPEC; COMPARE_IMPL not allowed here
437
if (otherModule.getCodeNameRelease() > relMin) {
438                         // Great, skip the spec version.
439
return true;
440                     } else {
441                         // As usual.
442
if (otherModule.getSpecificationVersion() == null)
443                             return false;
444                         else if (new SpecificationVersion(dep.getVersion()).compareTo(otherModule.getSpecificationVersion()) > 0)
445                             return false;
446                         else
447                             return true;
448                     }
449                 }
450             }
451         }
452
453         return false;
454     }
455
456
457     /** Tests dependency on the IDE */
458     boolean checkIdeDependency( Dependency dep,
459                                 ModuleInfo ide ) {
460
461         String JavaDoc IDEName = ide.getCodeName();
462         SpecificationVersion IDESpecVersion = ide.getSpecificationVersion();
463         String JavaDoc IDEImplVersion = ide.getImplementationVersion();
464
465         // Not equal names
466
if ( !IDEName.equals ( dep.getName() ) )
467             return false;
468         //return ModuleDescription.getStringFormatted ("MSG_IDE_Name", name, IDEName); // NOI18N
469

470             if ( dep.getComparison() == Dependency.COMPARE_SPEC ) {
471                 return new SpecificationVersion(dep.getVersion()).compareTo(IDESpecVersion) <= 0;
472                 // ? null : ModuleDescription.getStringFormatted ("MSG_IDE_Spec", version, IDESpecVersion); // NOI18N
473
}
474             else if ( dep.getComparison() == Dependency.COMPARE_IMPL ) {
475                 return dep.getVersion().equals (IDEImplVersion);
476                 // ? null : ModuleDescription.getStringFormatted ("MSG_IDE_Impl", version, IDEImplVersion); // NOI18N
477
}
478             else {
479                 // COMPARE_ANY
480
throw new IllegalStateException JavaDoc("Cannot have COMPARE_ANY on IDE dependency"); // NOI18N
481
}
482     }
483     
484     private List checkBrokenImplDependency( ModuleInfo md, Collection result ) {
485         ModuleInfo[] installedModules = Updates.getInstalledModules();
486         
487         List brokenlist = new ArrayList();
488         Dependency dep, depR;
489         for (int i = 0; i < installedModules.length; i++) {
490             Iterator deps = installedModules[i].getDependencies().iterator();
491             while ( deps.hasNext() ) {
492                 dep = (Dependency) deps.next();
493                 if ( dep.getName().equals (md.getCodeName ())
494                         && dep.getComparison() == Dependency.COMPARE_IMPL ) {
495                     if ( ! dep.getVersion().equals( md.getImplementationVersion() ) ) {
496                         // Dependency ids broken, try to find if there is new version
497
// of module with proper implementation version
498
Iterator it = Wizard.getAllModules().iterator();
499                         boolean found = false;
500                         while ( it.hasNext() ) {
501                             ModuleUpdate mu = (ModuleUpdate)it.next();
502                             if ( mu.getRemoteModule().getCodeName().equals( installedModules[i].getCodeName() )
503                                 && mu.getRemoteModule().getSpecificationVersion().compareTo(
504                                 installedModules[i].getSpecificationVersion() ) > 0 )
505                             {
506                                 boolean maybeOK = true;
507                                 Iterator depsR = mu.getRemoteModule().getDependencies().iterator();
508                                 while ( depsR.hasNext() ) {
509                                     depR = (Dependency) depsR.next();
510                                     if ( depR.getName().equals (md.getCodeName ())
511                                             && depR.getComparison() == Dependency.COMPARE_IMPL
512                                             && !depR.getVersion().equals( md.getImplementationVersion() ) )
513                                     {
514                                         maybeOK = false;
515                                         break;
516                                     }
517                                 }
518                                 if ( maybeOK ) {
519                                     if ( !result.contains( mu ) ) {
520                                         result.add( mu );
521                                     }
522                                     found = true;
523                                     break;
524                                 }
525                             }
526                         }
527                         if ( !found ) {
528                             brokenlist.add( installedModules[i] );
529                         }
530                         break;
531                     }
532                     break;
533                 }
534             }
535         }
536
537         return brokenlist;
538     }
539     
540     static boolean checkPlatformDependency (ModuleInfo module) {
541         Set/*<Dependency>*/ deps = module.getDependencies ();
542         Iterator/*<Dependency>*/ it = deps.iterator ();
543         //err.log (Level.FINE, "do checkPlatformDependency of module " + module.getDisplayName ());
544
boolean res = true;
545         while (it.hasNext ()) {
546             Dependency d = (Dependency) it.next ();
547             if (Dependency.TYPE_REQUIRES == d.getType ()) {
548                 //err.log ("Dependency: NAME: " + d.getName () + ", TYPE: " + d.getType () + ": " + d.toString ());
549
if (d.getName ().startsWith ("org.openide.modules.os")) { // NOI18N
550
res = false;
551                     ModuleInfo[] installedModules = Updates.getInstalledModules ();
552                     for (int i = 0; ! res && (i < installedModules.length); i++) {
553                         res = checkModuleDependency (d, installedModules [i]);
554                     }
555                     err.log(Level.FINE,
556                             "checkPlatformDependency on module " +
557                             module.getCodeNameBase() + " which requires " + d +
558                             " returns " + res);
559                 }
560             }
561         }
562         //err.log (Level.FINE, "done checkPlatformDependency. returns " + res);
563
return res;
564     }
565     
566     private static boolean checkFreeLocalizationDependency (ModuleUpdate baseModule, String JavaDoc locale, Collection result, Enumeration selected, List group) {
567         boolean ok = false;
568         
569         if (baseModule instanceof L10NUpdate) {
570             // can ignore; useless find a localization for L10NUpdate
571
return false;
572         }
573         
574         if (selected != null) {
575
576             while ( selected.hasMoreElements() ) {
577                 ModuleUpdate mu = (ModuleUpdate) selected.nextElement ();
578                 if (mu instanceof L10NUpdate) {
579                     L10NUpdate lu = (L10NUpdate) mu;
580
581                     ok = locale.equals (lu.getLangcode ()) && lu.getCodeNameBase ().equals (baseModule.getCodeNameBase ());
582
583                     if ( ok ) {
584                         if ( !result.contains (lu) ) {
585                             err.log(Level.FINE,
586                                     " ADDED[SELECTED]: " + lu.getCodeNameBase() +
587                                     "[" + lu.getLangcode() + "]");
588                             result.add (lu);
589                         }
590                         break;
591                     }
592                 }
593             }
594         }
595
596         if ( !ok && group != null ) {
597             Iterator it = group.iterator();
598             while ( it.hasNext() ) {
599                 ModuleUpdate mu = (ModuleUpdate)it.next();
600                 if (mu instanceof L10NUpdate) {
601                     L10NUpdate lu = (L10NUpdate) mu;
602
603                     ok = locale.equals (lu.getLangcode ()) && lu.getCodeNameBase ().equals (baseModule.getCodeNameBase ());
604
605                     if ( ok ) {
606                         if ( !result.contains (lu) ) {
607                             err.log(Level.FINE,
608                                     " ADDED[GROUP]: " + lu.getCodeNameBase() +
609                                     "[" + lu.getLangcode() + "]");
610                             result.add (lu);
611                         }
612                         break;
613                     }
614                 }
615             }
616         }
617
618         if ( !ok ) {
619
620             Iterator it = Wizard.getAllModules().iterator();
621             while ( it.hasNext() ) {
622                 ModuleUpdate mu = (ModuleUpdate)it.next();
623                 if (mu instanceof L10NUpdate) {
624                     L10NUpdate lu = (L10NUpdate) mu;
625
626                     ok = locale.equals (lu.getLangcode ()) && lu.getCodeNameBase ().equals (baseModule.getCodeNameBase ());
627
628                     if ( ok ) {
629                         if ( !result.contains (lu) ) {
630                             err.log(Level.FINE,
631                                     " ADDED[ALL]: " + lu.getCodeNameBase() +
632                                     "[" + lu.getLangcode() + "]");
633                             result.add (lu);
634                         }
635                         break;
636                     }
637                 }
638             }
639         }
640
641         return ok;
642     }
643     
644     private String JavaDoc getBundle( String JavaDoc key ) {
645         return NbBundle.getMessage( DependencyChecker.class, key );
646     }
647     
648 // static Comparator getModuleDependencyComparator() {
649
// return new ModuleDependencyComparator();
650
// }
651
//
652
// static class ModuleDependencyComparator implements Comparator {
653
//
654
// public int compare(Object obj, Object obj1) {
655
// if ( ! ( ( obj instanceof ModuleUpdate ) && ( obj1 instanceof ModuleUpdate ) ) )
656
// return 0;
657
// ModuleInfo modA = ((ModuleUpdate)obj).getRemoteModule();
658
// ModuleInfo modB = ((ModuleUpdate)obj1).getRemoteModule();
659
//
660
// if ( moduleDependsOnModule( modA, modB ) )
661
// return 1;
662
// else if ( moduleDependsOnModule( modB, modA ) )
663
// return -1;
664
// else
665
// return 0;
666
// }
667
//
668
// // returns true if modA depends on modB
669
// private boolean moduleDependsOnModule(ModuleInfo modA, ModuleInfo modB) {
670
// Set depsA = modA.getDependencies();
671
// Iterator it = depsA.iterator();
672
// while ( it.hasNext() ) {
673
// Dependency dep = (Dependency)(it.next());
674
// if (dep.getType() == Dependency.TYPE_MODULE || dep.getType() == Dependency.TYPE_REQUIRES) {
675
// if ( checkModuleDependency ( dep, modB ) )
676
// return true;
677
// }
678
// }
679
// return false;
680
// }
681
//
682
// }
683
}
684
Popular Tags