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

(-)a/autoupdate.ui/src/org/netbeans/modules/autoupdate/ui/Unit.java (-20 / +27 lines)
Lines 262-268 Link Here
262
        
262
        
263
        private UpdateElement installEl = null;
263
        private UpdateElement installEl = null;
264
        private UpdateElement backupEl = null;
264
        private UpdateElement backupEl = null;
265
        private boolean isUninstallAllowed ;
265
        private Boolean alternateMarked;
266
        
266
        
267
        public static boolean isOperationAllowed (UpdateUnit uUnit, UpdateElement element, OperationContainer<OperationSupport> container) {
267
        public static boolean isOperationAllowed (UpdateUnit uUnit, UpdateElement element, OperationContainer<OperationSupport> container) {
268
            return container.canBeAdded (uUnit, element);
268
            return container.canBeAdded (uUnit, element);
Lines 285-295 Link Here
285
            } else {
285
            } else {
286
                container = Containers.forUninstall ();
286
                container = Containers.forUninstall ();
287
            }
287
            }
288
            this.isUninstallAllowed = isOperationAllowed (this.updateUnit, installEl, container);
288
            if (isOperationAllowed (this.updateUnit, installEl, container)) {
289
                alternateMarked = null;
290
            } else {
291
                alternateMarked = false;
292
            }
289
            initState();
293
            initState();
294
        }
295
296
        public boolean isUninstallAllowed() {
297
            return alternateMarked == null;
290
        }
298
        }
291
        
299
        
292
        public boolean isMarked () {
300
        public boolean isMarked () {
301
            if (alternateMarked != null) {
302
                return alternateMarked;
303
            }
304
293
            OperationContainer container = null;
305
            OperationContainer container = null;
294
            if (UpdateManager.TYPE.CUSTOM_HANDLED_COMPONENT == updateUnit.getType ()) {
306
            if (UpdateManager.TYPE.CUSTOM_HANDLED_COMPONENT == updateUnit.getType ()) {
295
                container = Containers.forCustomUninstall ();
307
                container = Containers.forCustomUninstall ();
Lines 301-316 Link Here
301
        
313
        
302
        public void setMarked (boolean marked) {
314
        public void setMarked (boolean marked) {
303
            assert marked != isMarked ();
315
            assert marked != isMarked ();
304
            OperationContainer container = null;
316
            if (isUninstallAllowed()) {
305
            if (UpdateManager.TYPE.CUSTOM_HANDLED_COMPONENT == updateUnit.getType ()) {
317
                OperationContainer container = null;
306
                container = Containers.forCustomUninstall ();
318
                if (UpdateManager.TYPE.CUSTOM_HANDLED_COMPONENT == updateUnit.getType ()) {
319
                    container = Containers.forCustomUninstall ();
320
                } else {
321
                    container = Containers.forUninstall ();
322
                }
323
                if (marked) {
324
                    container.add (updateUnit, installEl);
325
                } else {
326
                    container.remove (installEl);
327
                }
307
            } else {
328
            } else {
308
                container = Containers.forUninstall ();
329
                alternateMarked = marked;
309
            }
310
            if (marked) {
311
                container.add (updateUnit, installEl);
312
            } else {
313
                container.remove (installEl);
314
            }
330
            }
315
        }
331
        }
316
        
332
        
Lines 340-354 Link Here
340
                return new SpecificationVersion (unit1.getInstalledVersion ()).compareTo (new SpecificationVersion (unit2.getInstalledVersion ()));
356
                return new SpecificationVersion (unit1.getInstalledVersion ()).compareTo (new SpecificationVersion (unit2.getInstalledVersion ()));
341
            }
357
            }
342
            return Unit.compareDisplayVersions (u1, u2);
358
            return Unit.compareDisplayVersions (u1, u2);
343
        }
344
        
345
        @Override
346
        public boolean canBeMarked () {
347
            if (super.canBeMarked ()) {
348
                return isUninstallAllowed ;
349
            } else {
350
                return false;
351
            }
352
        }
359
        }
353
        
360
        
354
        public String getInstalledVersion () {
361
        public String getInstalledVersion () {
(-)a/autoupdate.ui/src/org/netbeans/modules/autoupdate/ui/UnitTab.java (+19 lines)
Lines 1178-1183 Link Here
1178
                focusTable ();
1178
                focusTable ();
1179
            }
1179
            }
1180
        }
1180
        }
1181
1182
        @Override
1183
        public void tableDataChanged (Collection<Unit> units) {
1184
            if (units.size() == 0) {
1185
                setEnabled(false);
1186
                return;
1187
            }
1188
            for (Unit u : units) {
1189
                if (u instanceof Unit.Installed) {
1190
                    Unit.Installed inst = (Unit.Installed)u;
1191
                    if (!inst.isUninstallAllowed()) {
1192
                        setEnabled(false);
1193
                        return;
1194
                    }
1195
                }
1196
            }
1197
            setEnabled (true);
1198
        }
1199
1181
    }
1200
    }
1182
    
1201
    
1183
    private class UpdateAction extends TabAction {
1202
    private class UpdateAction extends TabAction {

Return to bug 166748