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

(-)openide/api/doc/changes/apichanges.xml (+15 lines)
Lines 114-119 Link Here
114
114
115
<!-- ACTUAL CHANGES BEGIN HERE: -->
115
<!-- ACTUAL CHANGES BEGIN HERE: -->
116
<changes>
116
<changes>
117
    <change id="ExplorerActions.DeleteActionPerfomer">
118
        <api name="explorer"/>
119
        <summary>Nodes in explorer can supress default confirmation dialog during delete operation</summary>
120
        <version major="5" minor="6"/>
121
        <date day="11" month="3" year="2005"/>
122
        <author login="rkubacki"/>
123
        <compatibility modification="yes" semantic="compatible"/>
124
        <description>
125
            Nodes that need to supress default confirmation dialog shown during delete action
126
            can do this if they return <code>Boolean.TRUE</code> from <code>Node.getValue(String)</code> 
127
            for attribute customDelete.
128
        </description>
129
        <issue number="56256"/>
130
    </change>
131
117
    <change id="add-leaf-attribute-to-DialogDescriptor">
132
    <change id="add-leaf-attribute-to-DialogDescriptor">
118
      <api name="dialogs"/>
133
      <api name="dialogs"/>
119
      <summary>Added paramater <code>leaf</code> to <code>DialogDescriptor</code></summary>
134
      <summary>Added paramater <code>leaf</code> to <code>DialogDescriptor</code></summary>
(-)openide/arch/arch-openide-explorer.xml (-1 / +7 lines)
Lines 370-379 Link Here
370
        </question>
370
        </question>
371
-->
371
-->
372
<answer id="exec-property">
372
<answer id="exec-property">
373
    <api name="netbeans.dnd.enabled" group="property" category="private" type="export" url=""/>
373
    <api name="netbeans.dnd.enabled" group="property" category="private" type="export" url="">
374
    Checks by Drag &amp; Drop support for views. True is regard as default
374
    Checks by Drag &amp; Drop support for views. True is regard as default
375
    (no matter what jdk's version). False value disallows Drag &amp; Drop in
375
    (no matter what jdk's version). False value disallows Drag &amp; Drop in
376
    all views.
376
    all views.
377
    </api>
378
    <api name="customDelete" group="property" category="devel" type="export">
379
    Nodes returing Boolean.TRUE from getValue(&quot;customDelete&quot;) are assumed to
380
    provide their own confirmation dialog for delete action and explorer will not show
381
    default one when they are deleted.
382
    </api>
377
</answer>
383
</answer>
378
384
379
385
(-)openide/openide-spec-vers.properties (-1 / +1 lines)
Lines 4-7 Link Here
4
# Must always be numeric (numbers separated by '.', e.g. 4.11).
4
# Must always be numeric (numbers separated by '.', e.g. 4.11).
5
# See http://openide.netbeans.org/versioning-policy.html for more.
5
# See http://openide.netbeans.org/versioning-policy.html for more.
6
6
7
openide.specification.version=5.5
7
openide.specification.version=5.6
(-)openide/src/org/openide/explorer/ExplorerActions.java (+10 lines)
Lines 634-639 Link Here
634
        
634
        
635
        private boolean doConfirm(Node[] sel) {
635
        private boolean doConfirm(Node[] sel) {
636
            String message, title;
636
            String message, title;
637
            boolean customDelete = true;
638
            for (int i = 0; i < sel.length; i++) {
639
                if (!Boolean.TRUE.equals(sel[i].getValue("customDelete"))) { // NOI18N
640
                    customDelete = false;
641
                    break;
642
                }
643
            }
644
            if (customDelete) {
645
                return true;
646
            }
637
            if (sel.length == 1) {
647
            if (sel.length == 1) {
638
                /* Treatment of special cases removed
648
                /* Treatment of special cases removed
639
                 *
649
                 *
(-)openide/src/org/openide/explorer/ExplorerActionsImpl.java (+10 lines)
Lines 523-528 Link Here
523
        
523
        
524
        private boolean doConfirm(Node[] sel) {
524
        private boolean doConfirm(Node[] sel) {
525
            String message, title;
525
            String message, title;
526
            boolean customDelete = true;
527
            for (int i = 0; i < sel.length; i++) {
528
                if (!Boolean.TRUE.equals(sel[i].getValue("customDelete"))) { // NOI18N
529
                    customDelete = false;
530
                    break;
531
                }
532
            }
533
            if (customDelete) {
534
                return true;
535
            }
526
            if (sel.length == 1) {
536
            if (sel.length == 1) {
527
                /* Treatment of special cases removed
537
                /* Treatment of special cases removed
528
                 *
538
                 *
(-)openide/test/unit/src/org/openide/explorer/ExplorerActionsImplTest.java (-2 / +2 lines)
Lines 62-74 Link Here
62
62
63
    /** Creates a manager to operate on.
63
    /** Creates a manager to operate on.
64
     */
64
     */
65
    protected Object[] createManagerAndContext () {
65
    protected Object[] createManagerAndContext (boolean confirm) {
66
        ExplorerManager em = new ExplorerManager ();
66
        ExplorerManager em = new ExplorerManager ();
67
        ActionMap map = new ActionMap ();
67
        ActionMap map = new ActionMap ();
68
        map.put (DefaultEditorKit.copyAction, ExplorerUtils.actionCopy(em));
68
        map.put (DefaultEditorKit.copyAction, ExplorerUtils.actionCopy(em));
69
        map.put (DefaultEditorKit.cutAction, ExplorerUtils.actionCut(em));
69
        map.put (DefaultEditorKit.cutAction, ExplorerUtils.actionCut(em));
70
        map.put (DefaultEditorKit.pasteAction, ExplorerUtils.actionPaste(em));
70
        map.put (DefaultEditorKit.pasteAction, ExplorerUtils.actionPaste(em));
71
        map.put ("delete", ExplorerUtils.actionDelete(em, false));
71
        map.put ("delete", ExplorerUtils.actionDelete(em, confirm));
72
        
72
        
73
        return new Object[] { em, org.openide.util.lookup.Lookups.singleton(map) };
73
        return new Object[] { em, org.openide.util.lookup.Lookups.singleton(map) };
74
    }
74
    }
(-)openide/test/unit/src/org/openide/explorer/ExplorerPanelTest.java (-3 / +97 lines)
Lines 24-29 Link Here
24
import org.netbeans.junit.NbTestSuite;
24
import org.netbeans.junit.NbTestSuite;
25
25
26
import javax.swing.Action;
26
import javax.swing.Action;
27
import org.openide.DialogDisplayer;
28
import org.openide.NotifyDescriptor;
27
29
28
import org.openide.actions.CopyAction;
30
import org.openide.actions.CopyAction;
29
import org.openide.actions.CutAction;
31
import org.openide.actions.CutAction;
Lines 78-84 Link Here
78
    protected final void setUp () {
80
    protected final void setUp () {
79
        System.setProperty ("org.openide.util.Lookup", "org.openide.explorer.ExplorerPanelTest$Lkp");
81
        System.setProperty ("org.openide.util.Lookup", "org.openide.explorer.ExplorerPanelTest$Lkp");
80
        
82
        
81
        Object[] arr = createManagerAndContext ();
83
        Object[] arr = createManagerAndContext (false);
82
        manager = (ExplorerManager)arr[0];
84
        manager = (ExplorerManager)arr[0];
83
        context = (Lookup)arr[1];
85
        context = (Lookup)arr[1];
84
        
86
        
Lines 86-93 Link Here
86
    
88
    
87
    /** Creates a manager to operate on.
89
    /** Creates a manager to operate on.
88
     */
90
     */
89
    protected Object[] createManagerAndContext () {
91
    protected Object[] createManagerAndContext (boolean confirm) {
90
        ep = new ExplorerPanel (null, false);
92
        ep = new ExplorerPanel (null, confirm);
91
        return new Object[] { ep.getExplorerManager(), ep.getLookup() };
93
        return new Object[] { ep.getExplorerManager(), ep.getLookup() };
92
    }
94
    }
93
    
95
    
Lines 172-177 Link Here
172
        
174
        
173
    }
175
    }
174
176
177
    public void testDeleteConfirmAction () throws Exception {
178
        TestNode [] nodes = new TestNode [] {
179
            new TestNode(true, true, true),
180
            new TestNode(true, true, true, true),
181
            new TestNode(true, true, true),
182
            new TestNode(true, true, true, true),
183
            new TestNode(false, false, false)
184
        };
185
186
        YesDialogDisplayer ydd = (YesDialogDisplayer)Lookup.getDefault().lookup(YesDialogDisplayer.class);
187
        DialogDisplayer dd = (DialogDisplayer)Lookup.getDefault().lookup(DialogDisplayer.class);
188
        assertNotNull("Custom DialogDisplayer is not set", ydd);
189
        int notifyCount = ydd.getNotifyCount();
190
        assertEquals("YesDialogDisplayer is current DialogDisplayer", ydd, dd);
191
        
192
        Object[] arr = createManagerAndContext (true);
193
        
194
        ExplorerPanel delep = new ExplorerPanel ((ExplorerManager)arr[0], true);
195
        ExplorerManager delManager = delep.getExplorerManager();
196
        delManager.setRootContext(new TestRoot(
197
            nodes));
198
199
        Action delete = ((ContextAwareAction)SystemAction.get(org.openide.actions.DeleteAction.class)).createContextAwareInstance((Lookup)arr[1]);
200
201
        // delete should ask for confirmation
202
        delManager.setSelectedNodes (new Node[] { nodes[0] });
203
        assertTrue ("It gets enabled", delete.isEnabled ());
204
        
205
        delete.actionPerformed(new java.awt.event.ActionEvent (this, 0, "waitFinished"));
206
        
207
        assertEquals ("Destoy was called", 1, nodes[0].countDelete);
208
        
209
        assertEquals ("Confirm delete was called ", notifyCount+1, ydd.getNotifyCount());
210
        
211
        // but delete should not ask for confirmation if the node wants to perform handle delete 
212
        delManager.setSelectedNodes (new Node[] { nodes[1] });
213
        assertTrue ("It gets enabled", delete.isEnabled ());
214
        
215
        delete.actionPerformed(new java.awt.event.ActionEvent (this, 0, "waitFinished"));
216
        
217
        assertEquals ("Destoy was called", 1, nodes[1].countDelete);
218
        
219
        assertEquals ("Confirm delete was called ", notifyCount+1, ydd.getNotifyCount()); // no next dialog
220
        
221
        // anyway ask for confirmation if at least one node has default behaviour
222
        delManager.setSelectedNodes (new Node[] { nodes[2], nodes[3] });
223
        assertTrue ("It gets enabled", delete.isEnabled ());
224
        
225
        delete.actionPerformed(new java.awt.event.ActionEvent (this, 0, "waitFinished"));
226
        
227
        assertEquals ("Destoy was called", 1, nodes[2].countDelete);
228
        assertEquals ("Destoy was called", 1, nodes[3].countDelete);
229
        
230
        assertEquals ("Confirm delete was called ", notifyCount+2, ydd.getNotifyCount()); // no next dialog
231
        
232
    }
233
175
    public void testPasteAction () throws Exception {
234
    public void testPasteAction () throws Exception {
176
        TestNode enabledNode = new TestNode(true, true, true);
235
        TestNode enabledNode = new TestNode(true, true, true);
177
        TestNode disabledNode = new TestNode(false, false, false);
236
        TestNode disabledNode = new TestNode(false, false, false);
Lines 317-322 Link Here
317
        public boolean canCopy;
376
        public boolean canCopy;
318
        public boolean canCut;
377
        public boolean canCut;
319
        public boolean canDelete;
378
        public boolean canDelete;
379
        private boolean customDelete;
320
        public PasteType[] types = new PasteType[0];
380
        public PasteType[] types = new PasteType[0];
321
        public java.awt.datatransfer.Transferable lastTransferable;
381
        public java.awt.datatransfer.Transferable lastTransferable;
322
        
382
        
Lines 324-329 Link Here
324
        public int countCut;
384
        public int countCut;
325
        public int countDelete;
385
        public int countDelete;
326
        
386
        
387
        public TestNode(boolean canCopy, boolean canCut, boolean canDelete, boolean customDelete) {
388
            this (canCopy, canCut, canDelete);
389
            this.customDelete = customDelete;
390
        }
391
        
327
        public TestNode(boolean b, boolean c, boolean d) {
392
        public TestNode(boolean b, boolean c, boolean d) {
328
            super(Children.LEAF);
393
            super(Children.LEAF);
329
            canCopy = b;
394
            canCopy = b;
Lines 370-375 Link Here
370
            this.lastTransferable = t;
435
            this.lastTransferable = t;
371
            s.addAll (Arrays.asList (types));
436
            s.addAll (Arrays.asList (types));
372
        }
437
        }
438
439
        public Object getValue(String attributeName) {
440
            if (customDelete && "customDelete".equals(attributeName)) {
441
                return Boolean.TRUE;
442
            }
443
            return super.getValue(attributeName);
444
        }
373
        
445
        
374
    }
446
    }
375
447
Lines 416-421 Link Here
416
        private Lkp (org.openide.util.lookup.InstanceContent ic) {
488
        private Lkp (org.openide.util.lookup.InstanceContent ic) {
417
            super (ic);
489
            super (ic);
418
            ic.add (new Clb ("Testing clipboard"));
490
            ic.add (new Clb ("Testing clipboard"));
491
            ic.add (new YesDialogDisplayer());
419
        }
492
        }
420
    }
493
    }
421
    
494
    
Lines 431-436 Link Here
431
        public void setContents (Transferable t, ClipboardOwner o) {
504
        public void setContents (Transferable t, ClipboardOwner o) {
432
            super.setContents (t, o);
505
            super.setContents (t, o);
433
            fireClipboardChange ();
506
            fireClipboardChange ();
507
        }
508
    }
509
    
510
    private static final class YesDialogDisplayer extends DialogDisplayer {
511
        private int counter = 0;
512
        
513
        public YesDialogDisplayer() {
514
            super();
515
        }
516
        
517
        public Object notify(org.openide.NotifyDescriptor descriptor) {
518
            counter++;
519
            return NotifyDescriptor.YES_OPTION;
520
        }
521
522
        public java.awt.Dialog createDialog(org.openide.DialogDescriptor descriptor) {
523
            return null;
524
        }
525
        
526
        public int getNotifyCount() {
527
            return counter;
434
        }
528
        }
435
    }
529
    }
436
}
530
}

Return to bug 56256