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

(-)a/autoupdate.services/apichanges.xml (+20 lines)
Lines 71-76 Link Here
71
            <class package="org.netbeans.spi.autoupdate" name="UpdateItem"/>
71
            <class package="org.netbeans.spi.autoupdate" name="UpdateItem"/>
72
            <issue number="162673"/>
72
            <issue number="162673"/>
73
        </change>
73
        </change>
74
        
75
        <change id="new-operation-container">
76
            <api name="general"/>
77
            <summary>New operation type introduced together with method for create appropriate container</summary>
78
            <version major="1" minor="11"/>
79
            <date day="19" month="8" year="2009"/>
80
            <author login="dlipin"/>
81
            <compatibility semantic="compatible"/>
82
            <description>
83
                <p>
84
                    New operation type - <code>OperationSupport.OperationType.INTERNAL_UPDATE</code> is introduced.
85
                    This operation can be used to find out elements which have updates and
86
                    which the particular element has the dependency on.
87
                </p>
88
            </description>
89
            <class package="org.netbeans.api.autoupdate" name="OperationSupport"/>
90
            <class package="org.netbeans.api.autoupdate" name="OperationContainer"/>
91
            <issue number="141714"/>
92
        </change>
93
74
    </changes>
94
    </changes>
75
95
76
    <!-- Now the surrounding HTML text and document structure: -->
96
    <!-- Now the surrounding HTML text and document structure: -->
(-)a/autoupdate.services/manifest.mf (-1 / +1 lines)
Lines 1-6 Link Here
1
Manifest-Version: 1.0
1
Manifest-Version: 1.0
2
OpenIDE-Module: org.netbeans.modules.autoupdate.services
2
OpenIDE-Module: org.netbeans.modules.autoupdate.services
3
OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/autoupdate/services/resources/Bundle.properties
3
OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/autoupdate/services/resources/Bundle.properties
4
OpenIDE-Module-Specification-Version: 1.10
4
OpenIDE-Module-Specification-Version: 1.11
5
AutoUpdate-Show-In-Client: false
5
AutoUpdate-Show-In-Client: false
6
AutoUpdate-Essential-Module: true
6
AutoUpdate-Essential-Module: true
(-)a/autoupdate.services/src/org/netbeans/api/autoupdate/OperationContainer.java (+12 lines)
Lines 97-102 Link Here
97
    }
97
    }
98
98
99
    /**
99
    /**
100
     * The factory method to construct instance of <code>OperationContainer</code> for internal update operation
101
     * @return newly constructed instance of <code>OperationContainer</code> for internal update operation
102
     * @since 1.11
103
     */
104
    public static OperationContainer<InstallSupport> createForInternalUpdate() {
105
        OperationContainer<InstallSupport> retval =
106
                new OperationContainer<InstallSupport>(OperationContainerImpl.createForInternalUpdate(), new InstallSupport());
107
        retval.getSupportInner ().setContainer(retval);
108
        return retval;
109
    }
110
111
    /**
100
     * The factory method to construct  instance of <code>OperationContainer</code> for install operation
112
     * The factory method to construct  instance of <code>OperationContainer</code> for install operation
101
     * @return newly constructed instance of <code>OperationContainer</code> for install operation
113
     * @return newly constructed instance of <code>OperationContainer</code> for install operation
102
     */
114
     */
(-)a/autoupdate.services/src/org/netbeans/api/autoupdate/OperationSupport.java (+3 lines)
Lines 151-156 Link Here
151
            case CUSTOM_UNINSTALL:
151
            case CUSTOM_UNINSTALL:
152
                impl = OperationSupportImpl.forCustomUninstall ();
152
                impl = OperationSupportImpl.forCustomUninstall ();
153
                break;
153
                break;
154
            case INTERNAL_UPDATE:
155
                impl = OperationSupportImpl.forInternalUpdate ();
156
                break;
154
            default:
157
            default:
155
                assert false : "Unknown OperationSupport for type " + type;
158
                assert false : "Unknown OperationSupport for type " + type;
156
        }
159
        }
(-)a/autoupdate.services/src/org/netbeans/modules/autoupdate/services/InstallSupportImpl.java (+26 lines)
Lines 82-87 Link Here
82
import org.netbeans.api.autoupdate.InstallSupport.Installer;
82
import org.netbeans.api.autoupdate.InstallSupport.Installer;
83
import org.netbeans.api.autoupdate.OperationSupport.Restarter;
83
import org.netbeans.api.autoupdate.OperationSupport.Restarter;
84
import org.netbeans.api.autoupdate.InstallSupport.Validator;
84
import org.netbeans.api.autoupdate.InstallSupport.Validator;
85
import org.netbeans.api.autoupdate.OperationContainer;
85
import org.netbeans.api.autoupdate.OperationContainer.OperationInfo;
86
import org.netbeans.api.autoupdate.OperationContainer.OperationInfo;
86
import org.netbeans.api.autoupdate.OperationException;
87
import org.netbeans.api.autoupdate.OperationException;
87
import org.netbeans.api.autoupdate.UpdateElement;
88
import org.netbeans.api.autoupdate.UpdateElement;
Lines 148-153 Link Here
148
                }
149
                }
149
150
150
                infos = support.getContainer ().listAll ();
151
                infos = support.getContainer ().listAll ();
152
                List <OperationInfo<?>> newInfos = new ArrayList <OperationInfo<?>>();
153
                for(OperationInfo <?> i : infos) {
154
                    if(i.getUpdateUnit().getInstalled()!=null &&
155
                            i.getUpdateUnit().getInstalled().equals(i.getUpdateElement())   ) {
156
                        //internal update, replace by required elements
157
                        for(UpdateElement e : i.getRequiredElements()) {
158
                            boolean add = true;
159
                            for(OperationInfo <?> in : newInfos) {
160
                                if(in.getUpdateElement().equals(e)) {
161
                                    add = false;
162
                                    break;
163
                                }
164
                            }
165
                            if(add) {
166
                                OperationContainer<InstallSupport> upd = OperationContainer.createForUpdate();
167
                                OperationInfo<?> ii = upd.add(e);
168
                                newInfos.add(ii);
169
                            }
170
                        }
171
                    } else {
172
                        newInfos.add(i);
173
                    }
174
                }
175
                infos = newInfos;
176
                
151
                int size = 0;
177
                int size = 0;
152
                for (OperationInfo info : infos) {
178
                for (OperationInfo info : infos) {
153
                    size += info.getUpdateElement().getDownloadSize();
179
                    size += info.getUpdateElement().getDownloadSize();
(-)a/autoupdate.services/src/org/netbeans/modules/autoupdate/services/OperationContainerImpl.java (-6 / +32 lines)
Lines 68-73 Link Here
68
    public static OperationContainerImpl<InstallSupport> createForInstall () {
68
    public static OperationContainerImpl<InstallSupport> createForInstall () {
69
        return new OperationContainerImpl<InstallSupport> (OperationType.INSTALL);
69
        return new OperationContainerImpl<InstallSupport> (OperationType.INSTALL);
70
    }
70
    }
71
    public static OperationContainerImpl<InstallSupport> createForInternalUpdate () {
72
        return new OperationContainerImpl<InstallSupport> (OperationType.INTERNAL_UPDATE);
73
    }
71
    public static OperationContainerImpl<InstallSupport> createForUpdate () {
74
    public static OperationContainerImpl<InstallSupport> createForUpdate () {
72
        return new OperationContainerImpl<InstallSupport> (OperationType.UPDATE);
75
        return new OperationContainerImpl<InstallSupport> (OperationType.UPDATE);
73
    }
76
    }
Lines 130-135 Link Here
130
                            " and " + updateElement + " cannot be same for operation " + type);
133
                            " and " + updateElement + " cannot be same for operation " + type);
131
                }
134
                }
132
                break;
135
                break;
136
            case INTERNAL_UPDATE:
137
                /*
138
                if (updateUnit.getInstalled () != updateElement) {
139
                    throw new IllegalArgumentException (updateUnit.getInstalled () +
140
                            " and " + updateElement + " must be same for operation " + type);
141
                }*/
142
                break;
133
            default:
143
            default:
134
                assert false : "Unknown type of operation " + type;
144
                assert false : "Unknown type of operation " + type;
135
            }
145
            }
Lines 180-197 Link Here
180
        return false;
190
        return false;
181
    }
191
    }
182
    
192
    
183
    public List<OperationInfo<Support>> listAll () {
193
    private List<OperationInfo<Support>> listAll () {
184
        return new ArrayList<OperationInfo<Support>>(operations);
194
        return new ArrayList<OperationInfo<Support>>(operations);
185
    }
195
    }
186
    
196
    
187
    synchronized public List<OperationInfo<Support>> listAllWithPossibleEager () {
197
    synchronized public List<OperationInfo<Support>> listAllWithPossibleEager () {
188
        if (upToDate) {
198
        if (upToDate) {
189
            return new ArrayList<OperationInfo<Support>>(operations);
199
            return listAll();
190
        }
200
        }
201
            
191
        clearCache ();
202
        clearCache ();
192
        // handle eager modules
203
        // handle eager modules
193
        
204
194
        if (type == OperationType.INSTALL || type == OperationType.UPDATE) {
205
        if (type == OperationType.INSTALL || type == OperationType.UPDATE || type==OperationType.INTERNAL_UPDATE) {
195
            Collection<UpdateElement> all = new HashSet<UpdateElement> (operations.size ());
206
            Collection<UpdateElement> all = new HashSet<UpdateElement> (operations.size ());
196
            Collection<ModuleInfo> allModuleInfos = new HashSet<ModuleInfo> (operations.size ());
207
            Collection<ModuleInfo> allModuleInfos = new HashSet<ModuleInfo> (operations.size ());
197
            for (OperationInfo<?> i : operations) {
208
            for (OperationInfo<?> i : operations) {
Lines 219-225 Link Here
219
                for(ModuleInfo mi: infos) {
230
                for(ModuleInfo mi: infos) {
220
                    Set<UpdateElement> reqs = new HashSet<UpdateElement> ();
231
                    Set<UpdateElement> reqs = new HashSet<UpdateElement> ();
221
                    for (Dependency dep : mi.getDependencies ()) {
232
                    for (Dependency dep : mi.getDependencies ()) {
222
                        UpdateElement req = Utilities.handleDependency (dep, Collections.singleton (mi), new HashSet<Dependency> (), false);
233
                        UpdateElement req = Utilities.handleDependency (eagerEl, dep, Collections.singleton (mi), new HashSet<Dependency> (), false);
223
                        if (req != null) {
234
                        if (req != null) {
224
                            reqs.add (req);
235
                            reqs.add (req);
225
                        }
236
                        }
Lines 250-256 Link Here
250
            LOGGER.log (Level.FINE, "== done. ==");
261
            LOGGER.log (Level.FINE, "== done. ==");
251
        }
262
        }
252
        upToDate = true;
263
        upToDate = true;
253
        return new ArrayList<OperationInfo<Support>>(operations);
264
        return listAll();
254
    }
265
    }
255
    
266
    
256
    public List<OperationInfo<Support>> listInvalid () {
267
    public List<OperationInfo<Support>> listInvalid () {
Lines 291-296 Link Here
291
                isValid = OperationValidator.isValidOperation (OperationType.INSTALL, updateUnit, updateElement);
302
                isValid = OperationValidator.isValidOperation (OperationType.INSTALL, updateUnit, updateElement);
292
            }
303
            }
293
            break;
304
            break;
305
        case INTERNAL_UPDATE:
306
            isValid = OperationValidator.isValidOperation (type, updateUnit, updateElement);
307
            // at least first add must pass and respect type of operation
308
            if (! isValid && operations.size () > 0) {
309
                // try Update
310
                isValid = OperationValidator.isValidOperation (OperationType.UPDATE, updateUnit, updateElement);
311
            }
312
            if (! isValid && operations.size () > 0) {
313
                // try Install
314
                isValid = OperationValidator.isValidOperation (OperationType.INSTALL, updateUnit, updateElement);
315
            }
316
            break;
317
294
        default:
318
        default:
295
            isValid = OperationValidator.isValidOperation (type, updateUnit, updateElement);
319
            isValid = OperationValidator.isValidOperation (type, updateUnit, updateElement);
296
        }
320
        }
Lines 382-387 Link Here
382
        INSTALL,
406
        INSTALL,
383
        /** Uninstall <code>UpdateElement</code> */
407
        /** Uninstall <code>UpdateElement</code> */
384
        UNINSTALL,
408
        UNINSTALL,
409
        /** Internally update installed <code>UpdateElement</code> without version increase */
410
        INTERNAL_UPDATE,
385
        /** Uninstall <code>UpdateElement</code> on-the-fly */
411
        /** Uninstall <code>UpdateElement</code> on-the-fly */
386
        DIRECT_UNINSTALL,
412
        DIRECT_UNINSTALL,
387
        /** Update installed <code>UpdateElement</code> to newer version. */
413
        /** Update installed <code>UpdateElement</code> to newer version. */
(-)a/autoupdate.services/src/org/netbeans/modules/autoupdate/services/OperationSupportImpl.java (+23 lines)
Lines 79-84 Link Here
79
    private static final OperationSupportImpl FOR_DIRECT_UNINSTALL = new ForDirectUninstall();
79
    private static final OperationSupportImpl FOR_DIRECT_UNINSTALL = new ForDirectUninstall();
80
    private static final OperationSupportImpl FOR_CUSTOM_INSTALL = new ForCustomInstall ();
80
    private static final OperationSupportImpl FOR_CUSTOM_INSTALL = new ForCustomInstall ();
81
    private static final OperationSupportImpl FOR_CUSTOM_UNINSTALL = new ForCustomUninstall ();
81
    private static final OperationSupportImpl FOR_CUSTOM_UNINSTALL = new ForCustomUninstall ();
82
    private static final OperationSupportImpl FOR_INTERNAL_UPDATE = new ForInternalUpdate();
82
    
83
    
83
    private static final Logger LOGGER = Logger.getLogger ("org.netbeans.modules.autoupdate.services.OperationSupportImpl");
84
    private static final Logger LOGGER = Logger.getLogger ("org.netbeans.modules.autoupdate.services.OperationSupportImpl");
84
    
85
    
Lines 109-114 Link Here
109
    public static OperationSupportImpl forCustomUninstall () {
110
    public static OperationSupportImpl forCustomUninstall () {
110
        return FOR_CUSTOM_UNINSTALL;
111
        return FOR_CUSTOM_UNINSTALL;
111
    }
112
    }
113
    public static OperationSupportImpl forInternalUpdate () {
114
        return FOR_INTERNAL_UPDATE;
115
    }
112
    
116
    
113
    public abstract Boolean doOperation(ProgressHandle progress/*or null*/, OperationContainer<?> container) throws OperationException;
117
    public abstract Boolean doOperation(ProgressHandle progress/*or null*/, OperationContainer<?> container) throws OperationException;
114
    public abstract void doCancel () throws OperationException;
118
    public abstract void doCancel () throws OperationException;
Lines 551-556 Link Here
551
        }
555
        }
552
        
556
        
553
    }
557
    }
558
559
    private static class ForInternalUpdate extends OperationSupportImpl {
560
        public synchronized Boolean doOperation(ProgressHandle progress,
561
                OperationContainer container) throws OperationException {
562
            throw new UnsupportedOperationException("Not supported yet.");
563
        }
564
        public void doCancel () throws OperationException {
565
            assert false : "Not supported yet";
566
        }
567
568
        public void doRestart (Restarter restarter, ProgressHandle progress) throws OperationException {
569
            throw new UnsupportedOperationException ("Not supported yet.");
570
        }
571
572
        public void doRestartLater (Restarter restarter) {
573
            throw new UnsupportedOperationException ("Not supported yet.");
574
        }
575
576
    }
554
    
577
    
555
    private static class ForCustomInstall extends OperationSupportImpl {
578
    private static class ForCustomInstall extends OperationSupportImpl {
556
        private Collection<UpdateElement> affectedModules = null;
579
        private Collection<UpdateElement> affectedModules = null;
(-)a/autoupdate.services/src/org/netbeans/modules/autoupdate/services/OperationValidator.java (+14 lines)
Lines 66-71 Link Here
66
 */
66
 */
67
abstract class OperationValidator {
67
abstract class OperationValidator {
68
    private final static OperationValidator FOR_INSTALL = new InstallValidator();
68
    private final static OperationValidator FOR_INSTALL = new InstallValidator();
69
    private final static OperationValidator FOR_INTERNAL_UPDATE = new InternalUpdateValidator();
69
    private final static OperationValidator FOR_UNINSTALL = new UninstallValidator();
70
    private final static OperationValidator FOR_UNINSTALL = new UninstallValidator();
70
    private final static OperationValidator FOR_UPDATE = new UpdateValidator();
71
    private final static OperationValidator FOR_UPDATE = new UpdateValidator();
71
    private final static OperationValidator FOR_ENABLE = new EnableValidator();
72
    private final static OperationValidator FOR_ENABLE = new EnableValidator();
Lines 86-91 Link Here
86
        case INSTALL:
87
        case INSTALL:
87
            isValid = FOR_INSTALL.isValidOperationImpl(updateUnit, updateElement);
88
            isValid = FOR_INSTALL.isValidOperationImpl(updateUnit, updateElement);
88
            break;
89
            break;
90
        case INTERNAL_UPDATE:
91
            isValid = FOR_INTERNAL_UPDATE.isValidOperationImpl(updateUnit, updateElement);
92
            break;
89
        case DIRECT_UNINSTALL:
93
        case DIRECT_UNINSTALL:
90
        case UNINSTALL:
94
        case UNINSTALL:
91
            isValid = FOR_UNINSTALL.isValidOperationImpl(updateUnit, updateElement);
95
            isValid = FOR_UNINSTALL.isValidOperationImpl(updateUnit, updateElement);
Lines 141-146 Link Here
141
        case CUSTOM_UNINSTALL:
145
        case CUSTOM_UNINSTALL:
142
            retval = FOR_CUSTOM_UNINSTALL.getRequiredElementsImpl(updateElement, moduleInfos, brokenDependencies);
146
            retval = FOR_CUSTOM_UNINSTALL.getRequiredElementsImpl(updateElement, moduleInfos, brokenDependencies);
143
            break;
147
            break;
148
        case INTERNAL_UPDATE:
149
            retval = FOR_INTERNAL_UPDATE.getRequiredElementsImpl(updateElement, moduleInfos, brokenDependencies);
150
            break;
144
        default:
151
        default:
145
            assert false;
152
            assert false;
146
        }
153
        }
Lines 164-169 Link Here
164
                break;
171
                break;
165
            case INSTALL :
172
            case INSTALL :
166
            case UPDATE :
173
            case UPDATE :
174
            case INTERNAL_UPDATE:
167
                getRequiredElements (type, updateElement, moduleInfos, broken);
175
                getRequiredElements (type, updateElement, moduleInfos, broken);
168
                break;
176
                break;
169
            case UNINSTALL :
177
            case UNINSTALL :
Lines 185-190 Link Here
185
            List<ModuleInfo> moduleInfos,
193
            List<ModuleInfo> moduleInfos,
186
            Collection<String> brokenDependencies);
194
            Collection<String> brokenDependencies);
187
    
195
    
196
    private static class InternalUpdateValidator extends InstallValidator {
197
        @Override
198
        boolean isValidOperationImpl(UpdateUnit unit, UpdateElement uElement) {
199
            return uElement.equals(unit.getInstalled()) || containsElement (uElement, unit);
200
        }
201
    }
188
    private static class InstallValidator extends OperationValidator {
202
    private static class InstallValidator extends OperationValidator {
189
        boolean isValidOperationImpl(UpdateUnit unit, UpdateElement uElement) {
203
        boolean isValidOperationImpl(UpdateUnit unit, UpdateElement uElement) {
190
            return unit.getInstalled() == null && containsElement (uElement, unit);
204
            return unit.getInstalled() == null && containsElement (uElement, unit);
(-)a/autoupdate.services/src/org/netbeans/modules/autoupdate/services/Utilities.java (-66 / +19 lines)
Lines 79-85 Link Here
79
import java.util.prefs.Preferences;
79
import java.util.prefs.Preferences;
80
import org.netbeans.Module;
80
import org.netbeans.Module;
81
import org.netbeans.ModuleManager;
81
import org.netbeans.ModuleManager;
82
import org.netbeans.api.autoupdate.InstallSupport;
83
import org.netbeans.api.autoupdate.OperationContainer;
84
import org.netbeans.api.autoupdate.OperationContainer.OperationInfo;
82
import org.netbeans.api.autoupdate.UpdateElement;
85
import org.netbeans.api.autoupdate.UpdateElement;
86
import org.netbeans.api.autoupdate.UpdateManager;
83
import org.netbeans.api.autoupdate.UpdateUnit;
87
import org.netbeans.api.autoupdate.UpdateUnit;
84
import org.netbeans.core.startup.Main;
88
import org.netbeans.core.startup.Main;
85
import org.netbeans.core.startup.TopLogging;
89
import org.netbeans.core.startup.TopLogging;
Lines 474-480 Link Here
474
            Set<Dependency> deps = new HashSet<Dependency> (((ModuleUpdateElementImpl) el).getModuleInfo ().getDependencies ());
478
            Set<Dependency> deps = new HashSet<Dependency> (((ModuleUpdateElementImpl) el).getModuleInfo ().getDependencies ());
475
            Set<ModuleInfo> availableInfos = new HashSet<ModuleInfo> (infos);
479
            Set<ModuleInfo> availableInfos = new HashSet<ModuleInfo> (infos);
476
            Set<Dependency> newones;
480
            Set<Dependency> newones;
477
            while (! (newones = processDependencies (deps, retval, availableInfos, brokenDependencies)).isEmpty ()) {
481
            while (! (newones = processDependencies (deps, retval, availableInfos, brokenDependencies, element)).isEmpty ()) {
478
                deps = newones;
482
                deps = newones;
479
            }
483
            }
480
            
484
            
Lines 570-576 Link Here
570
                                    Set<Dependency> deps = new HashSet<Dependency> (tryUpdated.getDependencies ());
574
                                    Set<Dependency> deps = new HashSet<Dependency> (tryUpdated.getDependencies ());
571
                                    Set<ModuleInfo> availableInfos = new HashSet<ModuleInfo> (forInstall);
575
                                    Set<ModuleInfo> availableInfos = new HashSet<ModuleInfo> (forInstall);
572
                                    Set<Dependency> newones;
576
                                    Set<Dependency> newones;
573
                                    while (! (newones = processDependencies (deps, moreRequested, availableInfos, brokenDependencies)).isEmpty ()) {
577
                                    while (! (newones = processDependencies (deps, moreRequested, availableInfos, brokenDependencies, tryUE)).isEmpty ()) {
574
                                        deps = newones;
578
                                        deps = newones;
575
                                    }
579
                                    }
576
                                    moreRequested.add (tryUE);
580
                                    moreRequested.add (tryUE);
Lines 587-596 Link Here
587
    private static Set<Dependency> processDependencies (final Set<Dependency> original,
591
    private static Set<Dependency> processDependencies (final Set<Dependency> original,
588
            Set<UpdateElement> retval,
592
            Set<UpdateElement> retval,
589
            Set<ModuleInfo> availableInfos,
593
            Set<ModuleInfo> availableInfos,
590
            Set<Dependency> brokenDependencies) {
594
            Set<Dependency> brokenDependencies,
595
            UpdateElement el) {
591
        Set<Dependency> res = new HashSet<Dependency> ();
596
        Set<Dependency> res = new HashSet<Dependency> ();
592
        for (Dependency dep : original) {
597
        for (Dependency dep : original) {
593
            UpdateElement req = handleDependency (dep, availableInfos, brokenDependencies, true);
598
            UpdateElement req = handleDependency (el, dep, availableInfos, brokenDependencies, true);
594
            if (req != null) {
599
            if (req != null) {
595
                ModuleUpdateElementImpl reqM = (ModuleUpdateElementImpl) Trampoline.API.impl (req);
600
                ModuleUpdateElementImpl reqM = (ModuleUpdateElementImpl) Trampoline.API.impl (req);
596
                availableInfos.add (reqM.getModuleInfo ());
601
                availableInfos.add (reqM.getModuleInfo ());
Lines 602-608 Link Here
602
        return res;
607
        return res;
603
    }
608
    }
604
    
609
    
605
    public static UpdateElement handleDependency (Dependency dep,
610
    public static UpdateElement handleDependency (UpdateElement el,
611
            Dependency dep,
606
            Collection<ModuleInfo> availableInfos,
612
            Collection<ModuleInfo> availableInfos,
607
            Set<Dependency> brokenDependencies,
613
            Set<Dependency> brokenDependencies,
608
            boolean aggressive) {
614
            boolean aggressive) {
Lines 621-685 Link Here
621
                break;
627
                break;
622
            case Dependency.TYPE_MODULE :
628
            case Dependency.TYPE_MODULE :
623
                UpdateUnit u = DependencyAggregator.getRequested (dep);
629
                UpdateUnit u = DependencyAggregator.getRequested (dep);
624
                
625
626
                //////////////////////////////////
627
                /*
628
                boolean matched = false;
629
                if (u == null) {
630
                    // last chance
631
                    for (ModuleInfo m : availableInfos) {
632
                        if (DependencyChecker.checkDependencyModule (dep, m)) {
633
                            matched = true;
634
                            break;
635
                        }
636
                    }
637
                    if (! matched) {
638
                        brokenDependencies.add (dep);
639
                    }
640
                } else {
641
                    if (u.getInstalled () != null) {
642
                        UpdateElementImpl reqElImpl = Trampoline.API.impl (u.getInstalled ());
643
                        matched = DependencyChecker.checkDependencyModule (dep, ((ModuleUpdateElementImpl) reqElImpl).getModuleInfo ());
644
                    }
645
                    if (! matched) {
646
                        // first chance
647
                        for (ModuleInfo m : availableInfos) {
648
                            if (DependencyChecker.checkDependencyModule (dep, m)) {
649
                                matched = true;
650
                                break;
651
                            }
652
                        }
653
                        if (! matched) {
654
                            UpdateElement reqEl = u.getAvailableUpdates ().isEmpty () ? null : u.getAvailableUpdates ().get (0);
655
                            if (reqEl == null) {
656
                                for (ModuleInfo m : availableInfos) {
657
                                    if (DependencyChecker.checkDependencyModule (dep, m)) {
658
                                        matched = true;
659
                                        break;
660
                                    }
661
                                }
662
                                if (! matched) {
663
                                    brokenDependencies.add (dep);
664
                                }
665
                            } else {
666
                                UpdateElementImpl reqElImpl = Trampoline.API.impl (reqEl);
667
                                ModuleUpdateElementImpl reqModuleImpl = (ModuleUpdateElementImpl) reqElImpl;
668
                                ModuleInfo info = reqModuleImpl.getModuleInfo ();
669
                                if (DependencyChecker.checkDependencyModule (dep, info)) {
670
                                    if (! availableInfos.contains (info)) {
671
                                        requested = reqEl;
672
                                    }
673
                                } else {
674
                                    brokenDependencies.add (dep);
675
                                }
676
                            }
677
                        }
678
                    }
679
                }
680
                */
681
                //////////////////////////////////
682
                
683
                boolean updateMatched = false;
630
                boolean updateMatched = false;
684
                boolean installMatched = false;
631
                boolean installMatched = false;
685
                boolean availableMatched = false;
632
                boolean availableMatched = false;
Lines 714-726 Link Here
714
                if(updateMatched && installMatched && !aggressive) {
661
                if(updateMatched && installMatched && !aggressive) {
715
                    requested = null;
662
                    requested = null;
716
                }
663
                }
664
                if (updateMatched && installMatched && aggressive) {
665
                    if (requested.getUpdateUnit().getType().equals(UpdateManager.TYPE.KIT_MODULE)) {
666
                        requested = null;
667
                    } else if (Trampoline.API.impl(el).isEager() &&
668
                            !el.getUpdateUnit().getType().equals(UpdateManager.TYPE.KIT_MODULE)) {
669
                        requested = null;
670
                    }
671
                }
717
                
672
                
718
                if (!installMatched && !availableMatched && !updateMatched) {
673
                if (!installMatched && !availableMatched && !updateMatched) {
719
                    brokenDependencies.add(dep);
674
                    brokenDependencies.add(dep);
720
                }
675
                }
721
                
722
676
723
                //////////////////////////////////
724
                break;
677
                break;
725
            case Dependency.TYPE_REQUIRES :
678
            case Dependency.TYPE_REQUIRES :
726
            case Dependency.TYPE_NEEDS :
679
            case Dependency.TYPE_NEEDS :
(-)1d736701d1bd (+359 lines)
Added Link Here
1
/*
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3
 *
4
 * Copyright 2009 Sun Microsystems, Inc. All rights reserved.
5
 *
6
 * The contents of this file are subject to the terms of either the GNU
7
 * General Public License Version 2 only ("GPL") or the Common
8
 * Development and Distribution License("CDDL") (collectively, the
9
 * "License"). You may not use this file except in compliance with the
10
 * License. You can obtain a copy of the License at
11
 * http://www.netbeans.org/cddl-gplv2.html
12
 * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
13
 * specific language governing permissions and limitations under the
14
 * License.  When distributing the software, include this License Header
15
 * Notice in each file and include the License file at
16
 * nbbuild/licenses/CDDL-GPL-2-CP.  Sun designates this
17
 * particular file as subject to the "Classpath" exception as provided
18
 * by Sun in the GPL Version 2 section of the License file that
19
 * accompanied this code. If applicable, add the following below the
20
 * License Header, with the fields enclosed by brackets [] replaced by
21
 * your own identifying information:
22
 * "Portions Copyrighted [year] [name of copyright owner]"
23
 *
24
 * If you wish your version of this file to be governed by only the CDDL
25
 * or only the GPL Version 2, indicate your decision by adding
26
 * "[Contributor] elects to include this software in this distribution
27
 * under the [CDDL or GPL Version 2] license." If you do not indicate a
28
 * single choice of license, a recipient has the option to distribute
29
 * your version of this file under either the CDDL, the GPL Version 2 or
30
 * to extend the choice of license to its licensees as provided above.
31
 * However, if you add GPL Version 2 code and therefore, elected the GPL
32
 * Version 2 license, then the option applies only if the new code is
33
 * made subject to such option by the copyright holder.
34
 *
35
 * Contributor(s):
36
 *
37
 * Portions Copyrighted 2009 Sun Microsystems, Inc.
38
 */
39
package org.netbeans.api.autoupdate;
40
41
import java.io.File;
42
import java.io.FileInputStream;
43
import java.io.FileNotFoundException;
44
import java.io.FileOutputStream;
45
import java.io.IOException;
46
import java.io.InputStream;
47
import java.io.OutputStream;
48
import java.io.OutputStreamWriter;
49
import java.io.PrintWriter;
50
import java.net.URL;
51
import java.util.ArrayList;
52
import java.util.List;
53
import java.util.Set;
54
import java.util.jar.Attributes;
55
import java.util.jar.JarOutputStream;
56
import java.util.jar.Manifest;
57
import java.util.zip.ZipEntry;
58
import org.netbeans.api.autoupdate.OperationContainer.OperationInfo;
59
import org.netbeans.api.autoupdate.OperationSupport.Restarter;
60
import org.netbeans.core.startup.MainLookup;
61
import org.netbeans.junit.NbTestCase;
62
import org.netbeans.modules.autoupdate.services.UpdateManagerImpl;
63
import org.netbeans.modules.autoupdate.updateprovider.AutoupdateCatalogProvider;
64
import org.openide.filesystems.FileUtil;
65
import org.openide.util.Lookup;
66
67
/**
68
 *
69
 * @author dlm198383
70
 */
71
public class InternalUpdatesTest extends NbTestCase {
72
73
    protected List<UpdateUnit> keepItNotToGC;
74
    private static File catalogFile;
75
    private static URL catalogURL;
76
    private File tmpDirectory;
77
    private List<File> nbms = new ArrayList<File>();
78
    private List<String> moduleElements = new ArrayList<String>();
79
80
    public InternalUpdatesTest(String testName) {
81
        super(testName);
82
    }
83
84
    public static class MyProvider extends AutoupdateCatalogProvider {
85
86
        public MyProvider() {
87
            super("test-updates-provider", "test-updates-provider", catalogURL, UpdateUnitProvider.CATEGORY.STANDARD);
88
        }
89
    }
90
91
    private String getModuleElement(boolean visible, String codeName, String moduleName, String distr, String specVersion, String dependency) {
92
        return "\n<module " +
93
                "\n     codenamebase='" + codeName + "' " +
94
                "\n     distribution='" + distr + "' " +
95
                "\n     downloadsize='0' " +
96
                "\n     homepage='' " +
97
                "\n     license='AD9FBBC9' " +
98
                "\n     moduleauthor='' " +
99
                "\n     needsrestart='false' " +
100
                "\n     releasedate='2007/01/30'>" +
101
                "\n    <manifest " +
102
                "\n       AutoUpdate-Show-In-Client='" + visible + "' " +
103
                "\n       OpenIDE-Module='" + codeName + "' " +
104
                "\n       OpenIDE-Module-Implementation-Version='070130' " +
105
                "\n       OpenIDE-Module-Java-Dependencies='Java &gt; 1.4' " +
106
                "\n       OpenIDE-Module-Name='" + moduleName + "' " +
107
                (dependency != null ? " OpenIDE-Module-Module-Dependencies=\"" + dependency.replace(">", "&gt;") + "\" " : "") +
108
                "\n       OpenIDE-Module-Requires='org.openide.modules.ModuleFormat1' " +
109
                "\n       OpenIDE-Module-Specification-Version='" + specVersion + "'/>" +
110
                "\n    <license name='AD9FBBC9'>[NO LICENSE SPECIFIED]" +
111
                "\n</license>" +
112
                "\n</module>\n";
113
    }
114
115
    private String createInfoXML(boolean visible, String codeName, String moduleName, String distr, String specVersion, String dependency) {
116
        String moduleElement = getModuleElement(visible, codeName, moduleName, distr, specVersion, dependency);
117
118
        moduleElements.add(moduleElement);
119
        return "<?xml version='1.0' encoding='UTF-8'?>" +
120
                "<!DOCTYPE module PUBLIC '-//NetBeans//DTD Autoupdate Module Info 2.5//EN' 'http://www.netbeans.org/dtds/autoupdate-info-2_5.dtd'>" +
121
                moduleElement;
122
    }
123
124
    private void writeCatalog() throws IOException {
125
        String res = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" +
126
                "<!DOCTYPE module_updates PUBLIC \"-//NetBeans//DTD Autoupdate Catalog 2.5//EN\" \"http://www.netbeans.org/dtds/autoupdate-catalog-2_5.dtd\">" +
127
                "<module_updates timestamp=\"00/00/19/08/03/2006\">\n";
128
        for (String element : moduleElements) {
129
            res += element;
130
        }
131
        res += "</module_updates>\n";
132
        if (catalogFile == null) {
133
            catalogFile = File.createTempFile("catalog-", ".xml", tmpDirectory);
134
            catalogURL = catalogFile.toURI().toURL();
135
        }
136
        PrintWriter pw = new PrintWriter(new OutputStreamWriter(new FileOutputStream(catalogFile), "UTF-8"));
137
        pw.write(res);
138
        pw.close();
139
    }
140
141
    private String getConfigXML(String codeName, String moduleFile, String specVersion) {
142
        return "<?xml version='1.0' encoding='UTF-8'?>" +
143
                " <!DOCTYPE module PUBLIC '-//NetBeans//DTD Module Status 1.0//EN'" +
144
                " 'http://www.netbeans.org/dtds/module-status-1_0.dtd'>" +
145
                " <module name='" + codeName + "'>" +
146
                " <param name='autoload'>false</param>" +
147
                " <param name='eager'>false</param>" +
148
                " <param name='enabled'>true</param>" +
149
                " <param name='jar'>modules/" + moduleFile + ".jar</param>" +
150
                " <param name='reloadable'>false</param>" +
151
                " <param name='specversion'>" + specVersion + "</param>" +
152
                " </module>";
153
    }
154
155
    private String getManifest(String codeName, String moduleDir, String specVersion, boolean visible, String dependency) {
156
        return "Manifest-Version: 1.0\n" +
157
                "Ant-Version: Apache Ant 1.7.0\n" +
158
                "Created-By: 1.6.0-b105 (Sun Microsystems Inc.)\n" +
159
                "OpenIDE-Module-Public-Packages: -\n" +
160
                "OpenIDE-Module-Java-Dependencies: Java > 1.4\n" +
161
                "OpenIDE-Module-Implementation-Version: 070130\n" +
162
                (dependency != null ? ("OpenIDE-Module-Module-Dependencies: " + dependency + "\n") : "") +
163
                "OpenIDE-Module: " + codeName + "\n" +
164
                "OpenIDE-Module-Localizing-Bundle: " + moduleDir + "Bundle.properties\n" +
165
                "OpenIDE-Module-Specification-Version: " + specVersion + "\n" +
166
                "OpenIDE-Module-Requires: org.openide.modules.ModuleFormat1\n" +
167
                "AutoUpdate-Show-In-Client: " + visible + "\n" +
168
                "\n";
169
    }
170
171
    private File prepareNBM(String codeName, String specVersion, boolean visible, String dependency) throws Exception {
172
        String moduleName = codeName.substring(codeName.lastIndexOf(".") + 1);
173
        String moduleFile = codeName.replace(".", "-");
174
        String moduleDir = codeName.replace(".", "/") + "/";
175
        File nbm = File.createTempFile(moduleFile + "-", ".nbm", tmpDirectory);
176
177
        final String MODULE_NAME_PROP = "OpenIDE-Module-Name";
178
179
        File jar = new File(tmpDirectory, "netbeans/modules/" + moduleFile + ".jar");
180
        jar.getParentFile().mkdirs();
181
        JarOutputStream jos = new JarOutputStream(new FileOutputStream(jar));
182
        int idx = moduleDir.indexOf("/");
183
        while (idx != -1) {
184
            jos.putNextEntry(new ZipEntry(moduleDir.substring(0, idx + 1)));
185
            idx = moduleDir.indexOf("/", idx + 1);
186
        }
187
188
        jos.putNextEntry(new ZipEntry(moduleDir + "Bundle.properties"));
189
        jos.write(new String(MODULE_NAME_PROP + "=" + moduleName).getBytes("UTF-8"));
190
        jos.putNextEntry(new ZipEntry("META-INF/"));
191
        jos.putNextEntry(new ZipEntry("META-INF/manifest.mf"));
192
        jos.write(getManifest(codeName, moduleDir, specVersion, visible, dependency).getBytes("UTF-8"));
193
        jos.close();
194
195
        Manifest mf = new Manifest();
196
        mf.getMainAttributes().put(Attributes.Name.MANIFEST_VERSION, "1.0");
197
        jos = new JarOutputStream(new FileOutputStream(nbm), mf);
198
        jos.putNextEntry(new ZipEntry("Info/"));
199
        jos.putNextEntry(new ZipEntry("Info/info.xml"));
200
        jos.write(createInfoXML(visible, codeName, moduleName, nbm.toURI().toURL().toString(), specVersion, dependency).getBytes("UTF-8"));
201
202
        jos.putNextEntry(new ZipEntry("netbeans/"));
203
        jos.putNextEntry(new ZipEntry("netbeans/modules/"));
204
        jos.putNextEntry(new ZipEntry("netbeans/config/"));
205
        jos.putNextEntry(new ZipEntry("netbeans/config/Modules/"));
206
        jos.putNextEntry(new ZipEntry("netbeans/config/Modules/" + moduleFile + ".xml"));
207
208
        jos.write(getConfigXML(codeName, moduleFile, specVersion).getBytes("UTF-8"));
209
210
211
        jos.putNextEntry(new ZipEntry("netbeans/modules/" + moduleFile + ".jar"));
212
213
        FileInputStream fis = new FileInputStream(jar);
214
        FileUtil.copy(fis, jos);
215
        fis.close();
216
        jar.delete();
217
        jos.close();
218
        nbms.add(nbm);
219
220
        return nbm;
221
    }
222
223
    protected void setUp() throws Exception {
224
        super.setUp();
225
        this.clearWorkDir();
226
        tmpDirectory = new File(getWorkDirPath(), "tmp");
227
        tmpDirectory.mkdirs();
228
229
        writeCatalog();
230
231
        TestUtils.setUserDir(getWorkDirPath());
232
        TestUtils.testInit();
233
234
        MainLookup.register(new MyProvider());
235
        assert Lookup.getDefault().lookup(MyProvider.class) != null;
236
        UpdateUnitProviderFactory.getDefault().refreshProviders(null, true);
237
    }
238
239
    public void testInternalUpdate() throws Exception {
240
        String dep = "org.yourorghere.dep.module";
241
        String main = "org.yourorghere.main.module";
242
243
        prepareNBM(dep, "1.0", false, null);
244
        prepareNBM(main, "1.0", true, dep + " > 1.0");
245
246
        writeCatalog();
247
        UpdateUnitProviderFactory.getDefault().refreshProviders(null, true);
248
249
        OperationContainer<InstallSupport> installContainer = OperationContainer.createForInstall();
250
251
        UpdateUnit engineUnit = getUpdateUnit(main);
252
        assertNull("cannot be installed", engineUnit.getInstalled());
253
        UpdateElement engineElement = getAvailableUpdate(engineUnit, 0);
254
        OperationInfo<InstallSupport> engineInfo = installContainer.add(engineElement);
255
        assertNotNull(engineInfo);
256
257
258
        UpdateUnit independentUnit = getUpdateUnit(dep);
259
260
        assertNull("cannot be installed", independentUnit.getInstalled());
261
        UpdateElement independentElement = getAvailableUpdate(independentUnit, 0);
262
        assertEquals(independentElement.getSpecificationVersion(), "1.0");
263
264
        OperationInfo<InstallSupport> independentInfo = installContainer.add(independentElement);
265
        assertNotNull(independentInfo);
266
267
        InstallSupport support = installContainer.getSupport();
268
        assertNotNull(support);
269
270
        InstallSupport.Validator v = support.doDownload(null, false);
271
        assertNotNull(v);
272
        InstallSupport.Installer i = support.doValidate(v, null);
273
        assertNotNull(i);
274
        Restarter r = null;
275
        try {
276
            r = support.doInstall(i, null);
277
        } catch (OperationException ex) {
278
            if (OperationException.ERROR_TYPE.INSTALL == ex.getErrorType()) {
279
                // can ingore
280
                // module system cannot load the module either
281
            } else {
282
                fail(ex.toString());
283
            }
284
        }
285
286
        assertTrue("element " + engineElement + " was not insetalled", engineUnit.getInstalled() != null);
287
        assertNull("Install update " + engineElement + " needs restart.", r);
288
289
290
        assertTrue("independent module was not installed together with the engine", independentUnit.getInstalled() != null);
291
        String specVersion = independentUnit.getInstalled().getSpecificationVersion();
292
293
        assertTrue("independent version " + specVersion + " was installed together with the engine but 1.0 expected", specVersion.equals("1.0"));
294
295
        prepareNBM(dep, "1.1", false, null);
296
        writeCatalog();
297
        UpdateUnitProviderFactory.getDefault().refreshProviders(null, true);
298
299
        independentUnit = getUpdateUnit(dep);
300
        assertEquals(1, independentUnit.getAvailableUpdates().size());
301
302
        OperationContainer<InstallSupport> internalUpdateContainer = OperationContainer.createForInternalUpdate();
303
        OperationInfo<InstallSupport> info = internalUpdateContainer.add(engineUnit.getInstalled());
304
        assertNotNull("Can`t add element " + engineUnit.getInstalled() + " to internal updates container", info);
305
306
        assertFalse("No internal updates available for " + engineUnit, internalUpdateContainer.listAll().isEmpty());
307
308
        Set<UpdateElement> required = info.getRequiredElements();
309
        //for(OperationInfo <InstallSupport> in : internalUpdateContainer.listAll()) {
310
        //            required.add(in.getUpdateElement());
311
        //        }
312
        assertFalse("Does not have internal update for " + engineUnit, required.isEmpty());
313
        assertTrue("Has move than one internal update for " + engineUnit, required.size() == 1);
314
        UpdateElement expectedRequired = independentUnit.getAvailableUpdates().get(0);
315
        assertTrue("Has other internal update than version 1.1 for " + engineUnit, required.contains(expectedRequired));
316
317
318
        InstallSupport os = internalUpdateContainer.getSupport();
319
        assertNotNull(os);
320
321
        internalUpdateContainer.add(required);
322
        // internalUpdateContainer.remove(info);
323
324
        v = os.doDownload(null, false);
325
        assertNotNull(v);
326
        i = os.doValidate(v, null);
327
        assertNotNull(i);
328
        r = null;
329
        try {
330
            r = os.doInstall(i, null);
331
        } catch (OperationException ex) {
332
            if (OperationException.ERROR_TYPE.INSTALL == ex.getErrorType()) {
333
                // can ingore
334
                // module system cannot load the module either
335
            } else {
336
                fail(ex.toString());
337
            }
338
        }
339
340
        assertNotNull("Installing update require restarting", r);
341
    }
342
343
    public UpdateUnit getUpdateUnit(String codeNameBase) {
344
        UpdateUnit uu = UpdateManagerImpl.getInstance().getUpdateUnit(codeNameBase);
345
        assertNotNull(uu);
346
        return uu;
347
    }
348
349
    public UpdateElement getAvailableUpdate(UpdateUnit updateUnit, int idx) {
350
        List<UpdateElement> available = updateUnit.getAvailableUpdates();
351
        assertTrue(available.size() > idx);
352
        return available.get(idx);
353
354
    }
355
356
    protected void tearDown() throws Exception {
357
        super.tearDown();
358
    }
359
}
(-)a/autoupdate.ui/manifest.mf (-1 / +1 lines)
Lines 3-8 Link Here
3
OpenIDE-Module-Install: org/netbeans/modules/autoupdate/ui/actions/Installer.class
3
OpenIDE-Module-Install: org/netbeans/modules/autoupdate/ui/actions/Installer.class
4
OpenIDE-Module-Layer: org/netbeans/modules/autoupdate/ui/resources/layer.xml
4
OpenIDE-Module-Layer: org/netbeans/modules/autoupdate/ui/resources/layer.xml
5
OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/autoupdate/ui/resources/Bundle.properties
5
OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/autoupdate/ui/resources/Bundle.properties
6
OpenIDE-Module-Specification-Version: 1.8
6
OpenIDE-Module-Specification-Version: 1.9
7
AutoUpdate-Show-In-Client: false
7
AutoUpdate-Show-In-Client: false
8
AutoUpdate-Essential-Module: true
8
AutoUpdate-Essential-Module: true
(-)a/autoupdate.ui/nbproject/project.xml (-1 / +1 lines)
Lines 28-34 Link Here
28
                    <build-prerequisite/>
28
                    <build-prerequisite/>
29
                    <compile-dependency/>
29
                    <compile-dependency/>
30
                    <run-dependency>
30
                    <run-dependency>
31
                        <specification-version>1.1</specification-version>
31
                        <specification-version>1.11</specification-version>
32
                    </run-dependency>
32
                    </run-dependency>
33
                </dependency>
33
                </dependency>
34
                <dependency>
34
                <dependency>
(-)a/autoupdate.ui/src/org/netbeans/modules/autoupdate/ui/Bundle.properties (+2 lines)
Lines 190-192 Link Here
190
UnitTab_Splitter_DefaultDividerLocation=390
190
UnitTab_Splitter_DefaultDividerLocation=390
191
#NOI18N
191
#NOI18N
192
SettingsTab_Splitter_DefaultDividerLocation=390
192
SettingsTab_Splitter_DefaultDividerLocation=390
193
Unit_InternalUpdates_Version=(Internal Updates)
194
Unit_InternalUpdates_Title=Internal Updates
(-)a/autoupdate.ui/src/org/netbeans/modules/autoupdate/ui/Containers.java (+15 lines)
Lines 53-58 Link Here
53
 */
53
 */
54
public class Containers {
54
public class Containers {
55
    private static Reference<OperationContainer<InstallSupport>> INSTALL;
55
    private static Reference<OperationContainer<InstallSupport>> INSTALL;
56
    private static Reference<OperationContainer<InstallSupport>> INTERNAL_UPDATE;
56
    private static Reference<OperationContainer<InstallSupport>> UPDATE;
57
    private static Reference<OperationContainer<InstallSupport>> UPDATE;
57
    private static Reference<OperationContainer<InstallSupport>> INSTALL_FOR_NBMS;   
58
    private static Reference<OperationContainer<InstallSupport>> INSTALL_FOR_NBMS;   
58
    private static Reference<OperationContainer<InstallSupport>> UPDATE_FOR_NBMS;
59
    private static Reference<OperationContainer<InstallSupport>> UPDATE_FOR_NBMS;
Lines 74-79 Link Here
74
            forDisable().removeAll();
75
            forDisable().removeAll();
75
            forCustomInstall().removeAll();
76
            forCustomInstall().removeAll();
76
            forCustomUninstall().removeAll();
77
            forCustomUninstall().removeAll();
78
            forInternalUpdate().removeAll();
77
        } catch (NullPointerException npe) {
79
        } catch (NullPointerException npe) {
78
            // doesn't matter, can ignore that
80
            // doesn't matter, can ignore that
79
        }
81
        }
Lines 197-200 Link Here
197
            return container;
199
            return container;
198
        }        
200
        }        
199
    }
201
    }
202
    public static OperationContainer<InstallSupport> forInternalUpdate () {
203
        synchronized (Containers.class) {
204
            OperationContainer<InstallSupport> container = null;
205
            if (INTERNAL_UPDATE != null) {
206
                container = INTERNAL_UPDATE.get ();
207
            }
208
            if(container == null) {
209
                container = OperationContainer.createForInternalUpdate();
210
                INTERNAL_UPDATE = new WeakReference<OperationContainer<InstallSupport>> (container);
211
            }
212
            return container;
213
        }
214
    }
200
}
215
}
(-)a/autoupdate.ui/src/org/netbeans/modules/autoupdate/ui/Unit.java (-3 / +88 lines)
Lines 44-51 Link Here
44
import java.text.Collator;
44
import java.text.Collator;
45
import java.text.DateFormat;
45
import java.text.DateFormat;
46
import java.text.ParseException;
46
import java.text.ParseException;
47
import java.util.ArrayList;
47
import java.util.Date;
48
import java.util.Date;
48
import java.util.Iterator;
49
import java.util.Iterator;
50
import java.util.List;
49
import java.util.Locale;
51
import java.util.Locale;
50
import java.util.Set;
52
import java.util.Set;
51
import java.util.logging.Level;
53
import java.util.logging.Level;
Lines 59-64 Link Here
59
import org.netbeans.api.autoupdate.UpdateUnitProvider.CATEGORY;
61
import org.netbeans.api.autoupdate.UpdateUnitProvider.CATEGORY;
60
import org.netbeans.modules.autoupdate.ui.UnitCategoryTableModel.Type;
62
import org.netbeans.modules.autoupdate.ui.UnitCategoryTableModel.Type;
61
import org.openide.modules.SpecificationVersion;
63
import org.openide.modules.SpecificationVersion;
64
import org.openide.util.NbBundle;
62
import org.openide.util.RequestProcessor;
65
import org.openide.util.RequestProcessor;
63
66
64
/**
67
/**
Lines 395-406 Link Here
395
        }
398
        }
396
        
399
        
397
    }
400
    }
401
402
    public static class InternalUpdate extends Unit.Update  {
403
        
404
        private List <UpdateUnit> internalUpdates;        
405
406
        public InternalUpdate(UpdateUnit updateUnit, String categoryName, boolean isNbms) {
407
            super(updateUnit, false, categoryName);
408
        }
409
410
        public List <UpdateUnit> getUpdateUnits() {
411
            if(internalUpdates == null) {
412
                internalUpdates = new ArrayList <UpdateUnit>();
413
            }
414
            return internalUpdates;
415
        }
416
        public UpdateUnit getVisibleUnit() {
417
            return updateUnit;
418
        }
419
        
420
        @Override
421
        public UpdateElement getRelevantElement() {
422
            return updateUnit.getInstalled();
423
        }
424
425
        @Override
426
        public boolean isMarked() {
427
            OperationContainer container = Containers.forUpdate ();
428
            for(UpdateUnit invisible : getUpdateUnits()) {
429
                if(!container.contains(invisible.getAvailableUpdates().get(0))) {
430
                    return false;
431
                }
432
            }
433
            return true;
434
        }
435
436
        @Override
437
        public String getAvailableVersion () {
438
            return getInstalledVersion() + " " + getBundle("Unit_InternalUpdates_Version");
439
        }
440
        @Override
441
        public void setMarked(boolean marked) {
442
            assert marked != isMarked();
443
            OperationContainer container = Containers.forUpdate();
444
            for (UpdateUnit invisible : getUpdateUnits()) {
445
                if (marked) {
446
                    if (container.canBeAdded(invisible, invisible.getAvailableUpdates().get(0))) {
447
                        container.add(invisible, invisible.getAvailableUpdates().get(0));
448
                    }
449
                } else {
450
                    container.remove(invisible.getAvailableUpdates().get(0));
451
                }
452
            }
453
        }
454
455
        @Override
456
        public int getCompleteSize() {
457
            if (size == -1) {
458
                size = 0;
459
                for (UpdateUnit u : getUpdateUnits()) {
460
                    size += u.getAvailableUpdates().get(0).getDownloadSize();
461
                }
462
463
            }
464
            return size;
465
        }
466
467
        public String getSize () {
468
            return Utilities.getDownloadSizeAsString (getCompleteSize());
469
        }
470
471
        @Override
472
        public Type getModelType() {
473
            return Type.UPDATE;
474
        }
475
        
476
    }
398
    
477
    
399
    public static class Update extends Unit {
478
    public static class Update extends Unit {
400
        private UpdateElement installEl = null;
479
        private UpdateElement installEl = null;
401
        private UpdateElement updateEl = null;
480
        private UpdateElement updateEl = null;
402
        private boolean isNbms;
481
        private boolean isNbms;
403
        private int size = -1;
482
        protected int size = -1;
404
        
483
        
405
        public Update (UpdateUnit unit, boolean isNbms,String categoryName) {
484
        public Update (UpdateUnit unit, boolean isNbms,String categoryName) {
406
            super (categoryName);
485
            super (categoryName);
Lines 408-415 Link Here
408
            this.updateUnit = unit;
487
            this.updateUnit = unit;
409
            this.installEl = unit.getInstalled ();
488
            this.installEl = unit.getInstalled ();
410
            assert installEl != null : "Updateable UpdateUnit " + unit + " has Installed UpdateElement.";
489
            assert installEl != null : "Updateable UpdateUnit " + unit + " has Installed UpdateElement.";
411
            this.updateEl = unit.getAvailableUpdates ().get (0);
490
            if(unit.getAvailableUpdates().size() > 0) {
412
            assert updateEl != null : "Updateable UpdateUnit " + unit + " has UpdateElement for update.";
491
                this.updateEl = unit.getAvailableUpdates ().get (0);
492
                assert updateEl != null : "Updateable UpdateUnit " + unit + " has UpdateElement for update.";
493
            }
413
            initState();
494
            initState();
414
        }
495
        }
415
        
496
        
Lines 599-603 Link Here
599
            return updateEl.getSourceCategory();
680
            return updateEl.getSourceCategory();
600
        }
681
        }
601
    }
682
    }
683
684
    private static String getBundle (String key) {
685
        return NbBundle.getMessage (Unit.class, key);
686
    }
602
    
687
    
603
}
688
}
(-)a/autoupdate.ui/src/org/netbeans/modules/autoupdate/ui/UnitDetails.java (-9 / +102 lines)
Lines 45-50 Link Here
45
import java.io.CharConversionException;
45
import java.io.CharConversionException;
46
import java.net.URL;
46
import java.net.URL;
47
import java.util.ArrayList;
47
import java.util.ArrayList;
48
import java.util.HashSet;
48
import java.util.LinkedHashSet;
49
import java.util.LinkedHashSet;
49
import java.util.List;
50
import java.util.List;
50
import java.util.Set;
51
import java.util.Set;
Lines 54-61 Link Here
54
import org.netbeans.api.autoupdate.InstallSupport;
55
import org.netbeans.api.autoupdate.InstallSupport;
55
import org.netbeans.api.autoupdate.OperationContainer;
56
import org.netbeans.api.autoupdate.OperationContainer;
56
import org.netbeans.api.autoupdate.OperationContainer.OperationInfo;
57
import org.netbeans.api.autoupdate.OperationContainer.OperationInfo;
58
import org.netbeans.api.autoupdate.OperationSupport;
57
import org.netbeans.api.autoupdate.UpdateElement;
59
import org.netbeans.api.autoupdate.UpdateElement;
58
import org.netbeans.api.autoupdate.UpdateManager;
60
import org.netbeans.api.autoupdate.UpdateManager;
61
import org.netbeans.api.autoupdate.UpdateUnit;
59
import org.netbeans.api.autoupdate.UpdateUnitProvider.CATEGORY;
62
import org.netbeans.api.autoupdate.UpdateUnitProvider.CATEGORY;
60
import org.openide.util.NbBundle;
63
import org.openide.util.NbBundle;
61
import org.openide.xml.XMLUtil;
64
import org.openide.xml.XMLUtil;
Lines 108-123 Link Here
108
                    Unit.Update uu = ((Unit.Update) u);
111
                    Unit.Update uu = ((Unit.Update) u);
109
                    text += "<b>" + getBundle ("UnitDetails_Plugin_InstalledVersion") + "</b>" + uu.getInstalledVersion () + "<br>"; // NOI18N
112
                    text += "<b>" + getBundle ("UnitDetails_Plugin_InstalledVersion") + "</b>" + uu.getInstalledVersion () + "<br>"; // NOI18N
110
                    text += "<b>" + getBundle ("UnitDetails_Plugin_AvailableVersion") + "</b>" + uu.getAvailableVersion () + "<br>"; // NOI18N
113
                    text += "<b>" + getBundle ("UnitDetails_Plugin_AvailableVersion") + "</b>" + uu.getAvailableVersion () + "<br>"; // NOI18N
114
                    if(!(u instanceof Unit.InternalUpdate)) {
115
                    OperationContainer<InstallSupport> container = OperationContainer.createForUpdate();
111
116
112
                    OperationContainer<InstallSupport> container = OperationContainer.createForUpdate();
117
                    container.add(u.updateUnit, uu.getRelevantElement());
113
                    OperationInfo<InstallSupport> info = container.add(u.updateUnit, uu.getRelevantElement());
114
                    Set<UpdateElement> reqs = info.getRequiredElements();
115
                    Set<UpdateElement> required = new LinkedHashSet<UpdateElement> ();
118
                    Set<UpdateElement> required = new LinkedHashSet<UpdateElement> ();
116
                    required.addAll(reqs);
119
117
                    for(OperationInfo i : container.listAll()) {
120
                    for (OperationInfo<InstallSupport> info : container.listAll()) {
121
                            Set<UpdateElement> reqs = info.getRequiredElements();
122
                            for (UpdateElement req : reqs) {
123
                                if (req.getUpdateUnit().getInstalled() != null) {
124
                                    for (UpdateElement e : OperationContainer.createForUpdate().add(req).getRequiredElements()) {
125
                                        if (!required.contains(e)) {
126
                                            required.add(e);
127
                                        }
128
                                    }
129
                                } else {
130
                                    //OperationContainer.createForInstall().
131
                                }
132
                            }
133
                            required.addAll(reqs);
134
                    }
135
                    
136
                    for(OperationInfo<InstallSupport> i : container.listAll()) {
118
                        if(!required.contains(i.getUpdateElement()) && !i.getUpdateUnit().equals(u.updateUnit)) {
137
                        if(!required.contains(i.getUpdateElement()) && !i.getUpdateUnit().equals(u.updateUnit)) {
119
                            required.add(i.getUpdateElement());
138
                            required.add(i.getUpdateElement());
120
                        }
139
                        }                        
121
                    }
140
                    }
122
141
123
142
Lines 128-135 Link Here
128
                                visibleRequirements.add(ue);
147
                                visibleRequirements.add(ue);
129
                            }
148
                            }
130
                        }
149
                        }
131
                        OperationContainer containerForVisibleUpdate = OperationContainer.createForUpdate();
150
                        OperationContainer<InstallSupport> containerForVisibleUpdate = OperationContainer.createForUpdate();
132
                        OperationContainer containerForVisibleInstall = OperationContainer.createForInstall();
151
                        OperationContainer<InstallSupport> containerForVisibleInstall = OperationContainer.createForInstall();
133
                        List<OperationInfo<InstallSupport>> infoList = new ArrayList<OperationInfo<InstallSupport>>();
152
                        List<OperationInfo<InstallSupport>> infoList = new ArrayList<OperationInfo<InstallSupport>>();
134
                        for (UpdateElement ue : visibleRequirements) {
153
                        for (UpdateElement ue : visibleRequirements) {
135
                            if (containerForVisibleUpdate.canBeAdded(ue.getUpdateUnit(), ue)) {
154
                            if (containerForVisibleUpdate.canBeAdded(ue.getUpdateUnit(), ue)) {
Lines 166-171 Link Here
166
                            }
185
                            }
167
                        }
186
                        }
168
                    }
187
                    }
188
                    } else {
189
                        Unit.InternalUpdate iu = (Unit.InternalUpdate) u;
190
                        desc = "";
191
                        
192
                        OperationContainer <InstallSupport> updContainer = OperationContainer.createForUpdate();
193
                        for(UpdateUnit inv : iu.getUpdateUnits()) {
194
                            updContainer.add(inv.getAvailableUpdates().get(0));
195
                        }
196
197
                        OperationContainer <InstallSupport> reiContainer = OperationContainer.createForInternalUpdate();
198
                        reiContainer.add(iu.getRelevantElement());
199
                        Set<UpdateElement> internalUpdates = new HashSet <UpdateElement> ();
200
201
                        for (OperationInfo<InstallSupport> info : updContainer.listAll()) {
202
                            internalUpdates.add(info.getUpdateElement());
203
                            for(UpdateElement r: info.getRequiredElements()) {
204
                                if(r.getUpdateUnit().getInstalled()!=null) {
205
                                    internalUpdates.add(r);
206
                                }
207
                                
208
                            }
209
                        }
210
                        for (OperationInfo<InstallSupport> info : reiContainer.listAll()) {
211
                            if(!info.getUpdateElement().equals(iu.updateUnit.getInstalled())) {
212
                                internalUpdates.add(info.getUpdateElement());
213
                            }
214
                            for(UpdateElement r: info.getRequiredElements()) {
215
                                if(r.getUpdateUnit().getInstalled()!=null) {
216
                                    internalUpdates.add(r);
217
                                }
218
                            }
219
                        }
220
                    
221
222
                        /*
223
                        for(UpdateElement e: container.add(u.getRelevantElement()).getRequiredElements()) {
224
                            if(!internalUpdates.contains(e.getUpdateUnit())) {
225
                                internalUpdates.add(e.getUpdateUnit());
226
                            }
227
                        }
228
                        for(OperationInfo <InstallSupport> info: container.listAll()) {
229
                            if(info.getUpdateUnit()!=u.updateUnit && !internalUpdates.contains(info.getUpdateUnit())) {
230
                                internalUpdates.add(info.getUpdateUnit());
231
                            }
232
                        }
233
                         */
234
                        /*
235
                        
236
237
                        for (UpdateUnit upd : iu.getUpdateUnits()) {                            
238
                            UpdateElement ue = upd.getAvailableUpdates().get(0);
239
                            for(UpdateElement e : OperationContainer.createForUpdate().add(ue).getRequiredElements()) {
240
                                if(!internalUpdates.contains(e.getUpdateUnit())) {
241
                                    internalUpdates.add(e.getUpdateUnit());
242
                                }
243
                            }
244
                        }*/
245
246
                        for (UpdateElement ue : internalUpdates) {
247
                            //UpdateElement ue = upd.getUgetAvailableUpdates().get(0);
248
                            desc += "&nbsp;&nbsp;&nbsp;&nbsp;" +
249
                                    ue.getDisplayName();
250
                            if (ue.getUpdateUnit().getInstalled() != null) {
251
                                desc += " [" + ue.getUpdateUnit().getInstalled().getSpecificationVersion() + "->";
252
                                } else {
253
                                desc += " <span color=\"red\">new!</span> [";
254
                            }
255
256
                            
257
                            desc += ue.getUpdateUnit().getAvailableUpdates().get(0).getSpecificationVersion();
258
                            desc += "]";
259
                            desc += "<br>";
260
                        }
261
                    }
169
                } else {
262
                } else {
170
                    text += "<b>" + getBundle ("UnitDetails_Plugin_Version") + "</b>" + u.getDisplayVersion() + "<br>"; // NOI18N
263
                    text += "<b>" + getBundle ("UnitDetails_Plugin_Version") + "</b>" + u.getDisplayVersion() + "<br>"; // NOI18N
171
                }
264
                }
Lines 193-199 Link Here
193
                    text += u.getDescription ();
286
                    text += u.getDescription ();
194
                }
287
                }
195
                if(desc!=null && desc.length() > 0) {
288
                if(desc!=null && desc.length() > 0) {
196
                    text += "<br><br><h4>" + "Internal Updates" + "</h4>"; // NOI18N
289
                    text += "<br><br><h4>" + getBundle ("Unit_InternalUpdates_Title") + "</h4>"; // NOI18N
197
                    text += desc;
290
                    text += desc;
198
                }
291
                }
199
            } catch (CharConversionException e) {
292
            } catch (CharConversionException e) {
(-)a/autoupdate.ui/src/org/netbeans/modules/autoupdate/ui/UpdateTableModel.java (-2 / +2 lines)
Lines 86-92 Link Here
86
            return ;
86
            return ;
87
        }
87
        }
88
        super.setValueAt(anValue, row, col);
88
        super.setValueAt(anValue, row, col);
89
        Unit.Update u = (Unit.Update) getUnitAtRow(row);
89
        Unit u = getUnitAtRow(row);
90
        assert anValue instanceof Boolean : anValue + " must be instanceof Boolean.";
90
        assert anValue instanceof Boolean : anValue + " must be instanceof Boolean.";
91
        boolean beforeMarked = u.isMarked();
91
        boolean beforeMarked = u.isMarked();
92
        u.setMarked(!beforeMarked);
92
        u.setMarked(!beforeMarked);
Lines 102-108 Link Here
102
    public Object getValueAt(int row, int col) {
102
    public Object getValueAt(int row, int col) {
103
        Object res = null;
103
        Object res = null;
104
        if (isExpansionControlAtRow(row)) return "";//NOI18N
104
        if (isExpansionControlAtRow(row)) return "";//NOI18N
105
        Unit.Update u = (Unit.Update) getUnitAtRow(row);
105
        Unit u = getUnitAtRow(row);
106
        switch (col) {
106
        switch (col) {
107
        case 0 :
107
        case 0 :
108
            res = u.isMarked() ? Boolean.TRUE : Boolean.FALSE;
108
            res = u.isMarked() ? Boolean.TRUE : Boolean.FALSE;
(-)a/autoupdate.ui/src/org/netbeans/modules/autoupdate/ui/Utilities.java (-1 / +145 lines)
Lines 52-59 Link Here
52
import java.util.Collections;
52
import java.util.Collections;
53
import java.util.Comparator;
53
import java.util.Comparator;
54
import java.util.Enumeration;
54
import java.util.Enumeration;
55
import java.util.HashMap;
55
import java.util.HashSet;
56
import java.util.HashSet;
56
import java.util.List;
57
import java.util.List;
58
import java.util.Set;
57
import java.util.StringTokenizer;
59
import java.util.StringTokenizer;
58
import java.util.logging.Level;
60
import java.util.logging.Level;
59
import java.util.logging.Logger;
61
import java.util.logging.Logger;
Lines 63-68 Link Here
63
import javax.swing.JLabel;
65
import javax.swing.JLabel;
64
import javax.swing.SwingConstants;
66
import javax.swing.SwingConstants;
65
import javax.swing.SwingUtilities;
67
import javax.swing.SwingUtilities;
68
import org.netbeans.api.autoupdate.InstallSupport;
69
import org.netbeans.api.autoupdate.OperationContainer;
70
import org.netbeans.api.autoupdate.OperationContainer.OperationInfo;
71
import org.netbeans.api.autoupdate.OperationSupport;
66
import org.netbeans.api.autoupdate.UpdateElement;
72
import org.netbeans.api.autoupdate.UpdateElement;
67
import org.netbeans.api.autoupdate.UpdateManager;
73
import org.netbeans.api.autoupdate.UpdateManager;
68
import org.netbeans.api.autoupdate.UpdateUnit;
74
import org.netbeans.api.autoupdate.UpdateUnit;
Lines 134-139 Link Here
134
        };
140
        };
135
141
136
    public static List<UnitCategory> makeUpdateCategories (final List<UpdateUnit> units, boolean isNbms) {
142
    public static List<UnitCategory> makeUpdateCategories (final List<UpdateUnit> units, boolean isNbms) {
143
        long start = System.currentTimeMillis();
137
        if (! isNbms && ! units.isEmpty ()) {
144
        if (! isNbms && ! units.isEmpty ()) {
138
            List<UnitCategory> fcCats = makeFirstClassUpdateCategories ();
145
            List<UnitCategory> fcCats = makeFirstClassUpdateCategories ();
139
            if (! fcCats.isEmpty ()) {
146
            if (! fcCats.isEmpty ()) {
Lines 143-149 Link Here
143
            }
150
            }
144
        }
151
        }
145
        List<UnitCategory> res = new ArrayList<UnitCategory> ();
152
        List<UnitCategory> res = new ArrayList<UnitCategory> ();
153
        if(units.isEmpty()) {
154
            return res;
155
        }
156
146
        List<String> names = new ArrayList<String> ();
157
        List<String> names = new ArrayList<String> ();
158
        Set<UpdateUnit> coveredByVisible = new HashSet <UpdateUnit> ();
159
147
        for (UpdateUnit u : units) {
160
        for (UpdateUnit u : units) {
148
            UpdateElement el = u.getInstalled ();
161
            UpdateElement el = u.getInstalled ();
149
            if (! u.isPending() && el != null) {
162
            if (! u.isPending() && el != null) {
Lines 151-156 Link Here
151
                if (updates.isEmpty()) {
164
                if (updates.isEmpty()) {
152
                    continue;
165
                    continue;
153
                }
166
                }
167
                coveredByVisible.add(u);
168
169
                OperationContainer<InstallSupport> container = OperationContainer.createForUpdate();
170
                OperationInfo<InstallSupport> info = container.add(updates.get(0));
171
                Set <UpdateElement> required = info.getRequiredElements();
172
                for(UpdateElement ue : required){
173
                    coveredByVisible.add(ue.getUpdateUnit());
174
                }
175
                for(OperationInfo <InstallSupport> i : container.listAll()) {
176
                    coveredByVisible.add((i.getUpdateUnit()));
177
                }
178
154
                String catName = el.getCategory();
179
                String catName = el.getCategory();
155
                if (names.contains (catName)) {
180
                if (names.contains (catName)) {
156
                    UnitCategory cat = res.get (names.indexOf (catName));
181
                    UnitCategory cat = res.get (names.indexOf (catName));
Lines 163-172 Link Here
163
                }
188
                }
164
            }
189
            }
165
        }
190
        }
166
        logger.log(Level.FINER, "makeUpdateCategories (" + units.size () + ") returns " + res.size ());
191
192
        // not covered by visible modules
193
194
        Collection<UpdateUnit> allUnits = UpdateManager.getDefault ().getUpdateUnits (UpdateManager.TYPE.MODULE);
195
        Set <UpdateUnit> otherUnits = new HashSet <UpdateUnit> ();
196
        for(UpdateUnit u : allUnits) {
197
            if(!coveredByVisible.contains(u) && 
198
                    u.getAvailableUpdates().size() > 0 &&
199
                    u.getInstalled()!=null &&
200
                    !u.isPending()) {
201
                otherUnits.add(u);
202
            }
203
        }
204
205
        List<Unit.InternalUpdate> internals = new ArrayList <Unit.InternalUpdate>();
206
        HashMap <UpdateUnit, List<UpdateElement>> map = getVisibleModulesDependecyMap(units);
207
        if(otherUnits.size() > 0 && !isNbms) {            
208
            for(UpdateUnit uu : otherUnits) {
209
                UpdateUnit u = getVisibleUnitForInvisibleModule(uu, map);
210
                if (u != null) {
211
                    boolean exist = false;
212
                    for(Unit.InternalUpdate internal : internals) {
213
                        if(internal.getVisibleUnit() == u) {
214
                            internal.getUpdateUnits().add(uu);
215
                            exist = true;
216
                        }
217
                    }
218
                    if(!exist) {
219
                        //all already determined "internal" visible updates does not contain just found one
220
                        String catName = u.getInstalled().getCategory();
221
                        Unit.InternalUpdate iu = new Unit.InternalUpdate(u, catName, false);
222
                        iu.getUpdateUnits().add(uu);
223
                        internals.add(iu);
224
                        UnitCategory cat = new UnitCategory(catName);
225
                        res.add(cat);
226
                        names.add(catName);
227
                        cat.addUnit(iu);
228
                    }
229
                } else {
230
                    // fallback, show module itself
231
                    String catName = uu.getAvailableUpdates().get(0).getCategory();
232
                    UnitCategory cat = null;
233
234
                    if (names.contains(catName)) {
235
                        cat = res.get(names.indexOf(catName));
236
                    } else {
237
                        cat = new UnitCategory(catName);
238
                        res.add(cat);
239
                        names.add(catName);
240
                    }
241
                    cat.addUnit(new Unit.Update(uu, isNbms, cat.getCategoryName()));
242
                }
243
            }            
244
        }
245
        for(Unit.InternalUpdate iu : internals) {
246
            iu.initState();
247
        }
248
        logger.log(Level.FINE, "makeUpdateCategories (" + units.size () + ") returns " + res.size () + ", took " + (System.currentTimeMillis()-start) + " ms");
249
167
        return res;
250
        return res;
168
    };
251
    };
169
252
253
    public static HashMap<UpdateUnit, List<UpdateElement>> getVisibleModulesDependecyMap(Collection<UpdateUnit> allUnits) {
254
        HashMap<UpdateUnit, List<UpdateElement>> result = new HashMap <UpdateUnit, List<UpdateElement>>();
255
        for (UpdateUnit u : allUnits) {
256
            if (u.getInstalled() != null && !u.isPending()) {
257
                OperationContainer<InstallSupport> container = OperationContainer.createForInternalUpdate();
258
                OperationInfo<InstallSupport> info = container.add(u, u.getInstalled());
259
260
                List<UpdateElement> list = new ArrayList<UpdateElement>();
261
262
                for (UpdateElement ur : info.getRequiredElements()) {
263
                    list.add(ur);
264
                }
265
                for (OperationInfo<InstallSupport> in : container.listAll()) {
266
                    UpdateUnit unit = in.getUpdateUnit();
267
                    if (unit != u) {
268
                        List<UpdateElement> updates = unit.getAvailableUpdates();
269
                        if (updates.size() > 0 && !list.contains(updates.get(0))) {
270
                            list.add(updates.get(0));
271
                        }
272
                    }
273
                }
274
                if(!list.isEmpty()) {
275
                    result.put(u, list);
276
                }
277
            }
278
        }
279
        return result;
280
    }
281
282
    public static UpdateUnit getVisibleUnitForInvisibleModule(UpdateUnit invisible, HashMap<UpdateUnit, List<UpdateElement>> map) {
283
        List <UpdateUnit> candidates = new ArrayList<UpdateUnit>();
284
285
        for(UpdateUnit unit : map.keySet()) {
286
            for (UpdateElement ue : map.get(unit)) {
287
                if (ue.getUpdateUnit().equals(invisible)) {
288
                    logger.log(Level.FINE,
289
                            "... found candidate visible module " + unit.getCodeName() + " for invisible " + invisible.getCodeName());
290
                    candidates.add(unit);
291
                }
292
            }
293
        }
294
295
        UpdateUnit result = null;
296
        if(candidates.size()==0) {
297
            logger.log(Level.FINE,
298
                    "Have not found visible module for invisible " + invisible.getCodeName());
299
        } else {
300
            result = candidates.get(0);
301
            for(UpdateUnit u : candidates) {
302
                if(u.getCodeName().endsWith(".kit")) {
303
                    result = u;break;
304
                }
305
            }
306
            logger.log(Level.FINE,
307
                    "Found visible module " + candidates.get(0).getCodeName() + " for invisible " + invisible.getCodeName());
308
        }
309
310
        return result;
311
    }
312
313
   
170
    public static long getTimeOfInitialization () {
314
    public static long getTimeOfInitialization () {
171
        return getPreferences ().getLong (TIME_OF_MODEL_INITIALIZATION, 0);
315
        return getPreferences ().getLong (TIME_OF_MODEL_INITIALIZATION, 0);
172
    }
316
    }
(-)a/autoupdate.ui/src/org/netbeans/modules/autoupdate/ui/actions/AutoupdateCheckScheduler.java (-12 / +24 lines)
Lines 44-49 Link Here
44
import java.awt.event.ActionEvent;
44
import java.awt.event.ActionEvent;
45
import java.awt.event.ActionListener;
45
import java.awt.event.ActionListener;
46
import java.io.IOException;
46
import java.io.IOException;
47
import java.util.ArrayList;
47
import java.util.Calendar;
48
import java.util.Calendar;
48
import java.util.Collection;
49
import java.util.Collection;
49
import java.util.Collections;
50
import java.util.Collections;
Lines 209-220 Link Here
209
        OperationContainer<InstallSupport> container = handleUpdates ?
210
        OperationContainer<InstallSupport> container = handleUpdates ?
210
            OperationContainer.createForUpdate () :
211
            OperationContainer.createForUpdate () :
211
            OperationContainer.createForInstall ();
212
            OperationContainer.createForInstall ();
213
214
215
        List<UpdateElement> elements = new ArrayList<UpdateElement>();
216
212
        for (UnitCategory cat : cats) {
217
        for (UnitCategory cat : cats) {
213
            for (Unit u : cat.getUnits ()) {
218
            for (Unit u : cat.getUnits ()) {        
214
                UpdateElement element = handleUpdates ?
219
                if(u instanceof Unit.Available) {
215
                    ((Unit.Update) u).getRelevantElement () :
220
                    elements.add(((Unit.Available) u).getRelevantElement ());
216
                    ((Unit.Available) u).getRelevantElement ();
221
                } else if (u instanceof Unit.InternalUpdate) {
217
                if (container.canBeAdded (element.getUpdateUnit (), element) && ! somePendingElements) {
222
                    for(UpdateUnit uu :((Unit.InternalUpdate) u).getUpdateUnits()) {
223
                        elements.add(uu.getAvailableUpdates().get(0));
224
                    }
225
                } else if (u instanceof Unit.Update) {
226
                    elements.add(((Unit.Update) u).getRelevantElement ());
227
                }
228
229
            }
230
        }
231
        for(UpdateElement element : elements) {
232
            if (! somePendingElements) {
233
                if(container.canBeAdded (element.getUpdateUnit (), element)) {
218
                    OperationInfo<InstallSupport> operationInfo = container.add (element);
234
                    OperationInfo<InstallSupport> operationInfo = container.add (element);
219
                    if (operationInfo == null) {
235
                    if (operationInfo == null) {
220
                        updates.add (element);
236
                        updates.add (element);
Lines 251-264 Link Here
251
        if (! somePendingElements && someBrokenDependencies) {
267
        if (! somePendingElements && someBrokenDependencies) {
252
            // 2. if some problem then try one by one
268
            // 2. if some problem then try one by one
253
            updates = new HashSet<UpdateElement> ();
269
            updates = new HashSet<UpdateElement> ();
254
            for (UnitCategory cat : cats) {
270
           for(UpdateElement element : elements) {
255
                for (Unit u : cat.getUnits ()) {
256
                    OperationContainer<InstallSupport> oc = handleUpdates ?
271
                    OperationContainer<InstallSupport> oc = handleUpdates ?
257
                        OperationContainer.createForUpdate () :
272
                        OperationContainer.createForUpdate () :
258
                        OperationContainer.createForInstall ();
273
                        OperationContainer.createForInstall ();
259
                    UpdateElement element = handleUpdates ?
274
                    
260
                        ((Unit.Update) u).getRelevantElement () :
261
                        ((Unit.Available) u).getRelevantElement ();
262
                    UpdateUnit unit = element.getUpdateUnit ();
275
                    UpdateUnit unit = element.getUpdateUnit ();
263
                    if (oc.canBeAdded (unit, element)) {
276
                    if (oc.canBeAdded (unit, element)) {
264
                        OperationInfo<InstallSupport> operationInfo = oc.add (element);
277
                        OperationInfo<InstallSupport> operationInfo = oc.add (element);
Lines 295-302 Link Here
295
                                        " cannot be installed, Install Container contains invalid elements " + oc.listInvalid ()); // NOI18N
308
                                        " cannot be installed, Install Container contains invalid elements " + oc.listInvalid ()); // NOI18N
296
                            }
309
                            }
297
                        }
310
                        }
298
                    }
311
                    }                
299
                }
300
            }
312
            }
301
        }
313
        }
302
314
(-)a/autoupdate.ui/src/org/netbeans/modules/autoupdate/ui/wizards/InstallStep.java (-3 / +4 lines)
Lines 551-562 Link Here
551
        if (installException == null) {
551
        if (installException == null) {
552
            component.setHeadAndContent (getBundle (HEAD_INSTALL_DONE), getBundle (CONTENT_INSTALL_DONE));
552
            component.setHeadAndContent (getBundle (HEAD_INSTALL_DONE), getBundle (CONTENT_INSTALL_DONE));
553
            panel.setBody (getBundle ("InstallStep_InstallDone_Text"),
553
            panel.setBody (getBundle ("InstallStep_InstallDone_Text"),
554
                    InstallUnitWizardModel.getVisibleUpdateElements (model.getAllUpdateElements (), false, model.getOperation ()));
554
                    model.getAllVisibleUpdateElements ());
555
        } else {
555
        } else {
556
            component.setHeadAndContent (getBundle (HEAD_INSTALL_UNSUCCESSFUL), getBundle (CONTENT_INSTALL_UNSUCCESSFUL));
556
            component.setHeadAndContent (getBundle (HEAD_INSTALL_UNSUCCESSFUL), getBundle (CONTENT_INSTALL_UNSUCCESSFUL));
557
            panel.setBody (getBundle ("InstallStep_InstallUnsuccessful_Text", installException.getLocalizedMessage ()),
557
            panel.setBody (getBundle ("InstallStep_InstallUnsuccessful_Text", installException.getLocalizedMessage ()),
558
                    InstallUnitWizardModel.getVisibleUpdateElements (model.getAllUpdateElements (), false, model.getOperation ()));
558
                    model.getAllVisibleUpdateElements ());
559
        }
559
        }
560
560
        panel.hideRunInBackground ();
561
        panel.hideRunInBackground ();
561
    }
562
    }
562
    
563
    
Lines 565-571 Link Here
565
        model.modifyOptionsForDoClose (wd, true);
566
        model.modifyOptionsForDoClose (wd, true);
566
        restarter = r;
567
        restarter = r;
567
        panel.setRestartButtonsVisible (true);
568
        panel.setRestartButtonsVisible (true);
568
        panel.setBody (getBundle ("InstallStep_InstallDone_Text"), InstallUnitWizardModel.getVisibleUpdateElements (model.getAllUpdateElements (), false, model.getOperation ()));
569
        panel.setBody (getBundle ("InstallStep_InstallDone_Text"), model.getAllVisibleUpdateElements ());
569
        panel.hideRunInBackground ();
570
        panel.hideRunInBackground ();
570
        if (runInBackground ()) {
571
        if (runInBackground ()) {
571
            InstallSupport support = model.getInstallSupport ();
572
            InstallSupport support = model.getInstallSupport ();
(-)a/autoupdate.ui/src/org/netbeans/modules/autoupdate/ui/wizards/OperationDescriptionStep.java (-10 / +100 lines)
Lines 44-49 Link Here
44
import java.awt.Component;
44
import java.awt.Component;
45
import java.util.ArrayList;
45
import java.util.ArrayList;
46
import java.util.Collections;
46
import java.util.Collections;
47
import java.util.HashMap;
47
import java.util.HashSet;
48
import java.util.HashSet;
48
import java.util.List;
49
import java.util.List;
49
import java.util.Set;
50
import java.util.Set;
Lines 55-65 Link Here
55
import javax.swing.SwingUtilities;
56
import javax.swing.SwingUtilities;
56
import javax.swing.event.ChangeEvent;
57
import javax.swing.event.ChangeEvent;
57
import javax.swing.event.ChangeListener;
58
import javax.swing.event.ChangeListener;
59
import org.netbeans.api.autoupdate.InstallSupport;
60
import org.netbeans.api.autoupdate.OperationContainer;
61
import org.netbeans.api.autoupdate.OperationContainer.OperationInfo;
58
import org.netbeans.api.autoupdate.OperationException;
62
import org.netbeans.api.autoupdate.OperationException;
63
import org.netbeans.api.autoupdate.OperationSupport;
59
import org.netbeans.api.autoupdate.UpdateElement;
64
import org.netbeans.api.autoupdate.UpdateElement;
60
import org.netbeans.api.autoupdate.UpdateManager;
65
import org.netbeans.api.autoupdate.UpdateManager;
61
import org.netbeans.api.autoupdate.UpdateUnit;
66
import org.netbeans.api.autoupdate.UpdateUnit;
62
import org.netbeans.modules.autoupdate.ui.Containers;
67
import org.netbeans.modules.autoupdate.ui.Containers;
68
import org.netbeans.modules.autoupdate.ui.Utilities;
63
import org.netbeans.modules.autoupdate.ui.wizards.OperationWizardModel.OperationType;
69
import org.netbeans.modules.autoupdate.ui.wizards.OperationWizardModel.OperationType;
64
import org.openide.WizardDescriptor;
70
import org.openide.WizardDescriptor;
65
import org.openide.modules.Dependency;
71
import org.openide.modules.Dependency;
Lines 155-164 Link Here
155
            }
161
            }
156
            body = new OperationDescriptionPanel (tableTitle,
162
            body = new OperationDescriptionPanel (tableTitle,
157
                    preparePluginsForShow (
163
                    preparePluginsForShow (
158
                        OperationWizardModel.getVisibleUpdateElements (
164
                    model.getPrimaryVisibleUpdateElements(),
159
                                model.getPrimaryUpdateElements (),
160
                                false,
161
                                model.getOperation ()),
162
                        model.getCustomHandledComponents (),
165
                        model.getCustomHandledComponents (),
163
                        model.getOperation ()),
166
                        model.getOperation ()),
164
                    "",
167
                    "",
Lines 192-207 Link Here
192
                } else {
195
                } else {
193
                    body = new OperationDescriptionPanel (tableTitle,
196
                    body = new OperationDescriptionPanel (tableTitle,
194
                            preparePluginsForShow (
197
                            preparePluginsForShow (
195
                                OperationWizardModel.getVisibleUpdateElements (
198
                                model.getPrimaryVisibleUpdateElements(),
196
                                    model.getPrimaryUpdateElements (), false, model.getOperation ()),
197
                                model.getCustomHandledComponents (),
199
                                model.getCustomHandledComponents (),
198
                                model.getOperation ()),
200
                                model.getOperation ()),
199
                            dependenciesTitle,
201
                            dependenciesTitle,
200
                            preparePluginsForShow (
202
                            preparePluginsForShow (
201
                                OperationWizardModel.getVisibleUpdateElements (model.getRequiredUpdateElements (), true, model.getOperation ()),
203
                                model.getRequiredVisibleUpdateElements(),
202
                                null,
204
                                null,
203
                                model.getOperation ()),
205
                                model.getOperation ()),
204
                            ! OperationWizardModel.getVisibleUpdateElements (model.getRequiredUpdateElements (), true, model.getOperation ()).isEmpty ());
206
                            ! model.getRequiredVisibleUpdateElements().isEmpty ());
205
                }
207
                }
206
                final JPanel finalPanel = body;
208
                final JPanel finalPanel = body;
207
                readyToGo = model != null && ! hasBrokenDependencies;
209
                readyToGo = model != null && ! hasBrokenDependencies;
Lines 357-365 Link Here
357
        return presentationName == null ? dep : presentationName;
359
        return presentationName == null ? dep : presentationName;
358
    }
360
    }
359
    
361
    
360
    private String preparePluginsForShow (Set<UpdateElement> plugins, Set<UpdateElement> customHandled, OperationType type) {
362
    private String preparePluginsForShow (Set<UpdateElement> allplugins, Set<UpdateElement> customHandled, OperationType type) {
361
        String s = new String ();
363
        String s = new String ();
362
        List<String> names = new ArrayList<String> ();
364
        List<String> names = new ArrayList<String> ();
365
        List <UpdateUnit> invisibleIncluded = new ArrayList <UpdateUnit>();
366
        List <UpdateUnit> units = new ArrayList <UpdateUnit>();
367
        List <UpdateElement> plugins = new ArrayList<UpdateElement>();
368
        for(UpdateElement el : allplugins) {
369
            boolean internal = false;
370
            if (OperationWizardModel.OperationType.UPDATE == type && el.getUpdateUnit ().getInstalled () != null) {
371
                 String oldVersion = el.getUpdateUnit ().getInstalled ().getSpecificationVersion ();
372
                 String newVersion = el.getSpecificationVersion ();
373
                 if(oldVersion.equals(newVersion) || !el.getUpdateUnit().getType().equals(UpdateManager.TYPE.KIT_MODULE) ) {
374
                     internal = true;
375
                 }
376
            }
377
            if(internal) {
378
                plugins.add(el);
379
            } else {
380
                plugins.add(0, el);
381
            }
382
        }
383
384
        for(UpdateElement p : plugins) {
385
            units.add(p.getUpdateUnit());
386
        }
387
        //HashMap <UpdateUnit, List<UpdateElement>> map = Utilities.getVisibleModulesDependecyMap(UpdateManager.getDefault().getUpdateUnits(Utilities.getUnitTypes()));
388
        HashMap <UpdateUnit, List<UpdateElement>> map = Utilities.getVisibleModulesDependecyMap(units);
389
363
        if (plugins != null && ! plugins.isEmpty ()) {
390
        if (plugins != null && ! plugins.isEmpty ()) {
364
            for (UpdateElement el : plugins) {
391
            for (UpdateElement el : plugins) {
365
                String updatename;
392
                String updatename;
Lines 367-373 Link Here
367
                if (OperationWizardModel.OperationType.UPDATE == type && el.getUpdateUnit ().getInstalled () != null) {
394
                if (OperationWizardModel.OperationType.UPDATE == type && el.getUpdateUnit ().getInstalled () != null) {
368
                    String oldVersion = el.getUpdateUnit ().getInstalled ().getSpecificationVersion ();
395
                    String oldVersion = el.getUpdateUnit ().getInstalled ().getSpecificationVersion ();
369
                    String newVersion = el.getSpecificationVersion ();
396
                    String newVersion = el.getSpecificationVersion ();
370
                    updatename += getBundle ("OperationDescriptionStep_UpdatePluginVersionFormat", oldVersion, newVersion);
397
                    OperationContainer<InstallSupport> container = OperationContainer.createForUpdate();
398
                    if (oldVersion.equals(newVersion)) {
399
                        //internal update
400
                        //updatename += getBundle ("OperationDescriptionStep_PluginVersionFormat", oldVersion);
401
                        OperationContainer<InstallSupport> internalUpdate = OperationContainer.createForInternalUpdate();
402
                        internalUpdate.add(el);
403
                        for (OperationInfo<InstallSupport> info : internalUpdate.listAll()) {
404
                            if (!info.getUpdateElement().equals(el)) {
405
                                if (!container.contains(info.getUpdateElement())) {
406
                                    container.add(info.getUpdateElement());
407
                                }
408
                            }
409
                            for (UpdateElement r : info.getRequiredElements()) {
410
                                if (!container.contains(r)) {
411
                                    container.add(r);
412
                                }
413
                            }
414
                        }
415
                    } else {
416
                        updatename += getBundle("OperationDescriptionStep_UpdatePluginVersionFormat", oldVersion, newVersion);
417
                        container.add(el);
418
                    }
419
420
                    
421
422
                    List<UpdateElement> list = new ArrayList<UpdateElement>();
423
                    for (OperationInfo<InstallSupport> info : container.listAll()) {
424
425
                        if(!info.getUpdateUnit().equals(el.getUpdateUnit()) &&
426
                                info.getUpdateUnit().getInstalled() != null) {
427
                            list.add(info.getUpdateElement());
428
                        }
429
                        for (UpdateElement upd : info.getRequiredElements()) {
430
                            if (upd.getUpdateUnit().getInstalled() != null) {
431
                                list.add(upd);
432
                            }
433
                        }
434
                    }                    
435
                    
436
                    for (UpdateElement upd : list) {
437
                        UpdateUnit unit = upd.getUpdateUnit();
438
                        if(unit.getType().equals(UpdateManager.TYPE.KIT_MODULE) || invisibleIncluded.contains(unit)) {
439
                            continue;
440
                        }
441
                        UpdateUnit visibleUnit = Utilities.getVisibleUnitForInvisibleModule(unit, map);
442
                        if(visibleUnit!=null && visibleUnit != el.getUpdateUnit()) {
443
                            continue;
444
                        }
445
                        if(!unit.getType().equals(UpdateManager.TYPE.KIT_MODULE)) {
446
                            invisibleIncluded.add(unit);
447
                        }
448
                        if(unit.getInstalled()!=null) {
449
                            updatename += "<br>&nbsp;&nbsp;&nbsp;&nbsp;" + upd.getDisplayName() +
450
                                " [" +
451
                                unit.getInstalled().getSpecificationVersion() + " -> " +
452
                                unit.getAvailableUpdates().get(0).getSpecificationVersion() +
453
                                "]";
454
                        } else {
455
                            updatename += "<br>&nbsp;&nbsp;&nbsp;&nbsp;" + upd.getDisplayName() +
456
                                " [" +
457
                                unit.getAvailableUpdates().get(0).getSpecificationVersion() +
458
                                "]";
459
                        }
460
                    }                    
371
                } else {
461
                } else {
372
                    updatename += getBundle ("OperationDescriptionStep_PluginVersionFormat",  // NOI18N
462
                    updatename += getBundle ("OperationDescriptionStep_PluginVersionFormat",  // NOI18N
373
                        el.getSpecificationVersion ());
463
                        el.getSpecificationVersion ());
(-)a/autoupdate.ui/src/org/netbeans/modules/autoupdate/ui/wizards/OperationPanel.java (-8 / +3 lines)
Lines 190-205 Link Here
190
    }
190
    }
191
    
191
    
192
    private JComponent getElementsComponent (List<UpdateElement> elements) {
192
    private JComponent getElementsComponent (List<UpdateElement> elements) {
193
        JTextPane area = new JTextPane ();
193
        StringBuilder body = new StringBuilder ();
194
        area.setEditable (false);
195
        area.setContentType ("text/html"); // NOI18N
196
        String body = new String ();
197
        for (UpdateElement el : elements) {
194
        for (UpdateElement el : elements) {
198
            body = body + el.getDisplayName () + "<br>"; // NOI18N
195
            body.append(el.getDisplayName () + "<br>"); // NOI18N
199
        }
196
        }
200
        area.setText (body);
197
        return getElementsComponent(body.toString());
201
        area.setOpaque (false);
202
        return area;
203
    }
198
    }
204
    
199
    
205
    private JComponent getElementsComponent (String msg) {
200
    private JComponent getElementsComponent (String msg) {
(-)a/autoupdate.ui/src/org/netbeans/modules/autoupdate/ui/wizards/OperationWizardModel.java (-2 / +67 lines)
Lines 56-67 Link Here
56
import java.util.logging.Logger;
56
import java.util.logging.Logger;
57
import javax.swing.JButton;
57
import javax.swing.JButton;
58
import javax.swing.SwingUtilities;
58
import javax.swing.SwingUtilities;
59
import org.netbeans.api.autoupdate.InstallSupport;
59
import org.netbeans.api.autoupdate.OperationContainer;
60
import org.netbeans.api.autoupdate.OperationContainer;
60
import org.netbeans.api.autoupdate.OperationContainer.OperationInfo;
61
import org.netbeans.api.autoupdate.OperationContainer.OperationInfo;
61
import org.netbeans.api.autoupdate.OperationException;
62
import org.netbeans.api.autoupdate.OperationException;
62
import org.netbeans.api.autoupdate.OperationSupport;
63
import org.netbeans.api.autoupdate.OperationSupport;
63
import org.netbeans.api.autoupdate.UpdateElement;
64
import org.netbeans.api.autoupdate.UpdateElement;
64
import org.netbeans.api.autoupdate.UpdateManager;
65
import org.netbeans.api.autoupdate.UpdateManager;
66
import org.netbeans.api.autoupdate.UpdateUnit;
65
import org.netbeans.modules.autoupdate.ui.Containers;
67
import org.netbeans.modules.autoupdate.ui.Containers;
66
import org.netbeans.modules.autoupdate.ui.Utilities;
68
import org.netbeans.modules.autoupdate.ui.Utilities;
67
import org.openide.WizardDescriptor;
69
import org.openide.WizardDescriptor;
Lines 256-272 Link Here
256
        }
258
        }
257
        return allElements;
259
        return allElements;
258
    }
260
    }
259
    
261
260
    public static Set<UpdateElement> getVisibleUpdateElements (Set<UpdateElement> all, boolean canBeEmpty, OperationType operationType) {
262
263
    public Set<UpdateElement> getAllVisibleUpdateElements () {
264
        Set <UpdateElement> all = getAllUpdateElements();
265
        Set <UpdateElement> visible = getVisibleUpdateElements(all, false, getOperation(), true);
266
        return visible;
267
    }
268
    public Set<UpdateElement> getPrimaryVisibleUpdateElements () {
269
        Set <UpdateElement> primary = getPrimaryUpdateElements();
270
        Set <UpdateElement> visible = getVisibleUpdateElements(primary, false, getOperation(), true);
271
        return visible;
272
    }
273
    public Set<UpdateElement> getRequiredVisibleUpdateElements () {
274
        Set <UpdateElement> required = getRequiredUpdateElements();
275
        Set <UpdateElement> visible = getVisibleUpdateElements(required, true, getOperation(), false);
276
        return visible;
277
    }
278
279
    private static Set<UpdateElement> getVisibleUpdateElements (Set<UpdateElement> all, boolean canBeEmpty, OperationType operationType, boolean checkInternalUpdates) {
261
        if (Utilities.modulesOnly () || OperationType.LOCAL_DOWNLOAD == operationType) {
280
        if (Utilities.modulesOnly () || OperationType.LOCAL_DOWNLOAD == operationType) {
262
            return all;
281
            return all;
263
        } else {
282
        } else {
264
            Set<UpdateElement> visible = new HashSet<UpdateElement> ();
283
            Set<UpdateElement> visible = new HashSet<UpdateElement> ();
284
            Set<UpdateUnit> visibleUnits = new HashSet<UpdateUnit> ();
285
            Set<UpdateElement> invisible = new HashSet<UpdateElement> ();
265
            for (UpdateElement el : all) {
286
            for (UpdateElement el : all) {
266
                if (UpdateManager.TYPE.KIT_MODULE == el.getUpdateUnit ().getType ()) {
287
                if (UpdateManager.TYPE.KIT_MODULE == el.getUpdateUnit ().getType ()) {
267
                    visible.add (el);
288
                    visible.add (el);
289
                    visibleUnits.add(el.getUpdateUnit());
290
                } else {
291
                    invisible.add(el);
268
                }
292
                }
269
            }
293
            }
294
            //filter out eager invisible modules, which are covered by visible
295
            List <UpdateElement> realInvisible = new ArrayList <UpdateElement> (invisible);
296
            for(UpdateElement v : visible) {
297
                OperationContainer <InstallSupport> container;
298
                if(v.getUpdateUnit().getInstalled()!=null) {
299
                    container = OperationContainer.createForUpdate();
300
                } else {
301
                    container = OperationContainer.createForInstall();
302
                }
303
                container.add(v);
304
                for(OperationInfo<InstallSupport> info : container.listAll()) {
305
                    realInvisible.remove(info.getUpdateElement());
306
                }
307
            }
308
            //filter out eager invisible modules, which are covered by other invisible
309
            for(UpdateElement v : invisible) {
310
                OperationContainer <InstallSupport> container = OperationContainer.createForUpdate();
311
                container.add(v);
312
                for(OperationInfo<InstallSupport> info : container.listAll()) {
313
                    if(info.getUpdateElement()!=v) {
314
                        realInvisible.remove(info.getUpdateElement());
315
                    }
316
                }
317
            }
318
319
320
            if(!realInvisible.isEmpty() && checkInternalUpdates) {
321
                HashMap <UpdateUnit, List<UpdateElement>> map = Utilities.getVisibleModulesDependecyMap(UpdateManager.getDefault().getUpdateUnits(Utilities.getUnitTypes()));
322
                //HashMap <UpdateUnit, List<UpdateElement>> map = Utilities.getVisibleModulesDependecyMap(visibleUnits);
323
                for(UpdateElement el : realInvisible) {
324
                    if(el.getUpdateUnit().getInstalled()!=null) {
325
                        UpdateUnit visibleUU = Utilities.getVisibleUnitForInvisibleModule(el.getUpdateUnit(), map);
326
                        if(visibleUU!=null) {
327
                            visible.add(visibleUU.getInstalled());
328
                        } else {
329
                            visible.add(el);
330
                        }
331
                    }
332
                }
333
            }
334
270
            if (visible.isEmpty () && ! canBeEmpty) {
335
            if (visible.isEmpty () && ! canBeEmpty) {
271
                // in Downloaded tab may become all NBMs are hidden
336
                // in Downloaded tab may become all NBMs are hidden
272
                visible = all;
337
                visible = all;
(-)a/autoupdate.ui/src/org/netbeans/modules/autoupdate/ui/wizards/UninstallStep.java (-8 / +8 lines)
Lines 216-228 Link Here
216
        model.modifyOptionsForDoClose (wd);
216
        model.modifyOptionsForDoClose (wd);
217
        switch (model.getOperation ()) {
217
        switch (model.getOperation ()) {
218
            case UNINSTALL :
218
            case UNINSTALL :
219
                panel.setBody (getBundle ("UninstallStep_UninstallDone_Text"), UninstallUnitWizardModel.getVisibleUpdateElements (model.getAllUpdateElements (), false, model.getOperation ()));
219
                panel.setBody (getBundle ("UninstallStep_UninstallDone_Text"), model.getAllVisibleUpdateElements ());
220
                break;
220
                break;
221
            case ENABLE :
221
            case ENABLE :
222
                panel.setBody (getBundle ("UninstallStep_ActivateDone_Text"), UninstallUnitWizardModel.getVisibleUpdateElements (model.getAllUpdateElements (), false, model.getOperation ()));
222
                panel.setBody (getBundle ("UninstallStep_ActivateDone_Text"), model.getAllVisibleUpdateElements ());
223
                break;
223
                break;
224
            case DISABLE :
224
            case DISABLE :
225
                panel.setBody (getBundle ("UninstallStep_DeactivateDone_Text"), UninstallUnitWizardModel.getVisibleUpdateElements (model.getAllUpdateElements (), false, model.getOperation ()));
225
                panel.setBody (getBundle ("UninstallStep_DeactivateDone_Text"), model.getAllVisibleUpdateElements ());
226
                break;
226
                break;
227
            default:
227
            default:
228
                assert false : "Unknown OperationType " + model.getOperation ();
228
                assert false : "Unknown OperationType " + model.getOperation ();
Lines 247-253 Link Here
247
        switch (model.getOperation ()) {
247
        switch (model.getOperation ()) {
248
            case UNINSTALL :
248
            case UNINSTALL :
249
                panel.setBody (getBundle ("UninstallStep_UninstallFailed_Text", ex.getLocalizedMessage ()),
249
                panel.setBody (getBundle ("UninstallStep_UninstallFailed_Text", ex.getLocalizedMessage ()),
250
                        UninstallUnitWizardModel.getVisibleUpdateElements(model.getAllUpdateElements(), false, model.getOperation()));
250
                        model.getAllVisibleUpdateElements ());
251
                break;
251
                break;
252
            case ENABLE :
252
            case ENABLE :
253
                panel.setBody (getBundle ("UninstallStep_ActivateFailed_Text",
253
                panel.setBody (getBundle ("UninstallStep_ActivateFailed_Text",
Lines 256-262 Link Here
256
                break;
256
                break;
257
            case DISABLE :
257
            case DISABLE :
258
                panel.setBody (getBundle ("UninstallStep_DeactivateFailed_Text", ex.getLocalizedMessage ()),
258
                panel.setBody (getBundle ("UninstallStep_DeactivateFailed_Text", ex.getLocalizedMessage ()),
259
                        UninstallUnitWizardModel.getVisibleUpdateElements(model.getAllUpdateElements(), false, model.getOperation()));
259
                        model.getAllVisibleUpdateElements ());
260
                break;
260
                break;
261
            default:
261
            default:
262
                assert false : "Unknown OperationType " + model.getOperation ();
262
                assert false : "Unknown OperationType " + model.getOperation ();
Lines 270-282 Link Here
270
        panel.setRestartButtonsVisible (true);
270
        panel.setRestartButtonsVisible (true);
271
        switch (model.getOperation ()) {
271
        switch (model.getOperation ()) {
272
            case UNINSTALL :
272
            case UNINSTALL :
273
                panel.setBody (getBundle ("UninstallStep_UninstallDone_Text"), UninstallUnitWizardModel.getVisibleUpdateElements (model.getAllUpdateElements (), false, model.getOperation ()));
273
                panel.setBody (getBundle ("UninstallStep_UninstallDone_Text"), model.getAllVisibleUpdateElements ());
274
                break;
274
                break;
275
            case ENABLE :
275
            case ENABLE :
276
                panel.setBody (getBundle ("UninstallStep_ActivateDone_Text"), UninstallUnitWizardModel.getVisibleUpdateElements (model.getAllUpdateElements (), false, model.getOperation ()));
276
                panel.setBody (getBundle ("UninstallStep_ActivateDone_Text"), model.getAllVisibleUpdateElements ());
277
                break;
277
                break;
278
            case DISABLE :
278
            case DISABLE :
279
                panel.setBody (getBundle ("UninstallStep_DeactivateDone_Text"), UninstallUnitWizardModel.getVisibleUpdateElements (model.getAllUpdateElements (), false, model.getOperation ()));
279
                panel.setBody (getBundle ("UninstallStep_DeactivateDone_Text"), model.getAllVisibleUpdateElements ());
280
                break;
280
                break;
281
            default:
281
            default:
282
                assert false : "Unknown OperationType " + model.getOperation ();
282
                assert false : "Unknown OperationType " + model.getOperation ();

Return to bug 141714