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

(-)ant/src/org/apache/tools/ant/module/resources/AntModuleLayer.xml (-1 / +1 lines)
Lines 22-28 Link Here
22
            <file name="SeparatorStopBuilding.instance">
22
            <file name="SeparatorStopBuilding.instance">
23
                <attr name="instanceClass" stringvalue="javax.swing.JSeparator"/>
23
                <attr name="instanceClass" stringvalue="javax.swing.JSeparator"/>
24
            </file>
24
            </file>
25
            <attr name="SeparatorStopBuilding.instance/org-netbeans-core-output2-NextOutJumpAction.instance" boolvalue="true"/>
25
            <attr name="SeparatorStopBuilding.instance/org-netbeans-core-actions-JumpNextAction.shadow" boolvalue="true"/>
26
        </folder>
26
        </folder>
27
    </folder>
27
    </folder>
28
28
(-)core/ide/src/org/netbeans/core/ide/resources/layer.xml (+18 lines)
Lines 40-45 Link Here
40
        </folder>
40
        </folder>
41
    </folder>
41
    </folder>
42
    
42
    
43
    <folder name="Menu" >
44
        <folder name="Edit" >
45
            <file name="Separator3.instance_hidden"  />
46
            <file name="org-netbeans-core-actions-JumpNextAction.shadow_hidden" />
47
            <file name="org-netbeans-core-actions-JumpPrevAction.shadow_hidden" />
48
        </folder>
49
        
50
        <folder name="BuildProject" >
51
            <file name="org-netbeans-core-actions-JumpNextAction.shadow" >
52
                <attr name="originalFile" stringvalue="Actions/System/org-netbeans-core-actions-JumpNextAction.instance" />
53
            </file>
54
            <attr name="org-netbeans-core-actions-JumpNextAction.shadow/org-netbeans-core-actions-JumpPrevAction.shadow" boolvalue="true" />
55
            <file name="org-netbeans-core-actions-JumpPrevAction.shadow" >
56
                <attr name="originalFile" stringvalue="Actions/System/org-netbeans-core-actions-JumpPrevAction.instance" />
57
            </file>
58
        </folder>
59
    </folder>
60
    
43
    <folder name="UI">
61
    <folder name="UI">
44
    <!-- settings categories UI presentation -->
62
    <!-- settings categories UI presentation -->
45
        <folder name="Services">
63
        <folder name="Services">
(-)core/output2/src/org/netbeans/core/output2/Bundle.properties (-7 lines)
Lines 15-22 Link Here
15
OpenIDE-Module-Long-Description=Output window based on a java.swing.text.Document over a \
15
OpenIDE-Module-Long-Description=Output window based on a java.swing.text.Document over a \
16
    ByteBuffer/CharBuffer
16
    ByteBuffer/CharBuffer
17
17
18
Actions/Build=Build
19
20
#Title for the output window
18
#Title for the output window
21
LBL_OUTPUT=Output
19
LBL_OUTPUT=Output
22
#Format for the output window title if it includes the name of the current tab
20
#Format for the output window title if it includes the name of the current tab
Lines 30-40 Link Here
30
LBL_SAVE=Save As...
28
LBL_SAVE=Save As...
31
TITLE_SAVE_DLG=Save Output As
29
TITLE_SAVE_DLG=Save Output As
32
30
33
#NextOutJumpAction
34
NextOutJump=Ne&xt Error
35
36
#PreviousOutJumpAction
37
PreviousOutJump=&Previous Error
38
31
39
#OutputWindowAction
32
#OutputWindowAction
40
OutputWindow=&Output
33
OutputWindow=&Output
(-)core/output2/src/org/netbeans/core/output2/Controller.java (-63 / +14 lines)
Lines 16-21 Link Here
16
import java.io.CharConversionException;
16
import java.io.CharConversionException;
17
import javax.swing.event.PopupMenuEvent;
17
import javax.swing.event.PopupMenuEvent;
18
import javax.swing.event.PopupMenuListener;
18
import javax.swing.event.PopupMenuListener;
19
import javax.swing.text.DefaultEditorKit;
19
import org.netbeans.core.output2.ui.AbstractOutputTab;
20
import org.netbeans.core.output2.ui.AbstractOutputTab;
20
import org.openide.ErrorManager;
21
import org.openide.ErrorManager;
21
import org.openide.actions.CopyAction;
22
import org.openide.actions.CopyAction;
Lines 82-88 Link Here
82
83
83
    //Package private for unit tests
84
    //Package private for unit tests
84
    Action copyAction = new ControllerAction (ACTION_COPY,
85
    Action copyAction = new ControllerAction (ACTION_COPY,
85
            "ACTION_COPY", CopyAction.class); //NOI18N
86
            "ACTION_COPY"); //NOI18N
86
    Action wrapAction = new ControllerAction (ACTION_WRAP,
87
    Action wrapAction = new ControllerAction (ACTION_WRAP,
87
            "ACTION_WRAP"); //NOI18N
88
            "ACTION_WRAP"); //NOI18N
88
    Action saveAsAction = new ControllerAction (ACTION_SAVEAS,
89
    Action saveAsAction = new ControllerAction (ACTION_SAVEAS,
Lines 90-102 Link Here
90
    Action closeAction = new ControllerAction (ACTION_CLOSE,
91
    Action closeAction = new ControllerAction (ACTION_CLOSE,
91
            "ACTION_CLOSE"); //NOI18N
92
            "ACTION_CLOSE"); //NOI18N
92
    Action nextErrorAction = new ControllerAction (ACTION_NEXTERROR,
93
    Action nextErrorAction = new ControllerAction (ACTION_NEXTERROR,
93
            "ACTION_NEXT_ERROR", NextOutJumpAction.class); //NOI18N
94
            "ACTION_NEXT_ERROR" ); //NOI18N
94
    Action prevErrorAction = new ControllerAction (ACTION_PREVERROR,
95
    Action prevErrorAction = new ControllerAction (ACTION_PREVERROR,
95
            "ACTION_PREV_ERROR", PreviousOutJumpAction.class); //NOI18N
96
            "ACTION_PREV_ERROR" ); //NOI18N
96
    Action selectAllAction = new ControllerAction (ACTION_SELECTALL,
97
    Action selectAllAction = new ControllerAction (ACTION_SELECTALL,
97
            "ACTION_SELECT_ALL"); //NOI18N
98
            "ACTION_SELECT_ALL"); //NOI18N
98
    Action findAction = new ControllerAction (ACTION_FIND,
99
    Action findAction = new ControllerAction (ACTION_FIND,
99
            "ACTION_FIND", FindAction.class); //NOI18N
100
            "ACTION_FIND"); //NOI18N
100
    Action findNextAction = new ControllerAction (ACTION_FINDNEXT,
101
    Action findNextAction = new ControllerAction (ACTION_FINDNEXT,
101
            "ACTION_FIND_NEXT"); //NOI18N
102
            "ACTION_FIND_NEXT"); //NOI18N
102
    Action findPreviousAction = new ControllerAction (ACTION_FINDPREVIOUS,
103
    Action findPreviousAction = new ControllerAction (ACTION_FINDPREVIOUS,
Lines 164-169 Link Here
164
            result = createAndInstallView (win, io);
165
            result = createAndInstallView (win, io);
165
        }
166
        }
166
        if (result != null) {
167
        if (result != null) {
168
            // install handlers to prev/next actions
169
            result.getActionMap ().put ("jumpPrev", this.prevErrorAction); // NOI18N
170
            result.getActionMap ().put ("jumpNext", this.nextErrorAction); // NOI18N
171
            result.getActionMap ().put (FindAction.class.getName (), this.findAction);
172
            result.getActionMap ().put (javax.swing.text.DefaultEditorKit.copyAction, this.copyAction);
173
        }
174
175
        if (result != null) {
167
            win.setSelectedTab(result);
176
            win.setSelectedTab(result);
168
        }
177
        }
169
        if (!activateContainer) {
178
        if (!activateContainer) {
Lines 171-176 Link Here
171
        } else {
180
        } else {
172
            win.requestActiveForNewTab();
181
            win.requestActiveForNewTab();
173
        }
182
        }
183
        
174
        return result;
184
        return result;
175
    }
185
    }
176
186
Lines 718-735 Link Here
718
        }
728
        }
719
    }
729
    }
720
730
721
    /**
722
     * Messaged when the container is deactivated in the netbeans window system
723
     */
724
    public void notifyDeactivated() {
725
        for (int i=0; i < popupItems.length; i++) {
726
            if (popupItems[i] instanceof Action && popupItems[i] != nextErrorAction && popupItems[i] != prevErrorAction) {
727
                ((ControllerAction) popupItems[i]).detachPerformer();
728
            }
729
        }
730
    }
731
732
    
733
    private boolean firstF12 = true;
731
    private boolean firstF12 = true;
734
    /**
732
    /**
735
     * Sends the caret in a tab to the nearest error line to its current position, selecting
733
     * Sends the caret in a tab to the nearest error line to its current position, selecting
Lines 1020-1026 Link Here
1020
                }
1018
                }
1021
                break;
1019
                break;
1022
            case IOEvent.CMD_SELECT :
1020
            case IOEvent.CMD_SELECT :
1023
1024
                if (tab == null) {
1021
                if (tab == null) {
1025
                    tab = createOutputTab(win, io, io.isFocusTaken(), value);
1022
                    tab = createOutputTab(win, io, io.isFocusTaken(), value);
1026
                }
1023
                }
Lines 1034-1040 Link Here
1034
                        win.add(tab);
1031
                        win.add(tab);
1035
                    }
1032
                    }
1036
                    win.setSelectedTab(tab);
1033
                    win.setSelectedTab(tab);
1037
                    win.requestVisible();
1038
                    updateName(win,tab);
1034
                    updateName(win,tab);
1039
                }
1035
                }
1040
                break;
1036
                break;
Lines 1155-1161 Link Here
1155
     */
1151
     */
1156
    private static class ControllerAction extends AbstractAction implements ActionPerformer {
1152
    private static class ControllerAction extends AbstractAction implements ActionPerformer {
1157
        private int id;
1153
        private int id;
1158
        private Class callbackActionClass = null;
1159
        /**
1154
        /**
1160
         * Create a ControllerAction with the specified action ID (constants defined in Controller),
1155
         * Create a ControllerAction with the specified action ID (constants defined in Controller),
1161
         * using the specified bundle key.  Expects the following contents in the bundle:
1156
         * using the specified bundle key.  Expects the following contents in the bundle:
Lines 1213-1231 Link Here
1213
            return Utilities.stringToKey(NbBundle.getMessage(Controller.class, key));
1208
            return Utilities.stringToKey(NbBundle.getMessage(Controller.class, key));
1214
        }
1209
        }
1215
1210
1216
        /**
1217
         * Create a controller which will also act as the action performer for a
1218
         * CallbackSystemAction.
1219
         *
1220
         * @param id The action ID
1221
         * @param name The bundle key for the action
1222
         * @param callbackActionClass
1223
         */
1224
        ControllerAction (int id, String name, Class callbackActionClass) {
1225
            this (id, name);
1226
            this.callbackActionClass = callbackActionClass;
1227
        }
1228
1229
        public int getID() {
1211
        public int getID() {
1230
            return id;
1212
            return id;
1231
        }
1213
        }
Lines 1271-1295 Link Here
1271
         */
1253
         */
1272
        public void setEnabled (boolean val) {
1254
        public void setEnabled (boolean val) {
1273
            super.setEnabled(val);
1255
            super.setEnabled(val);
1274
            if (callbackActionClass != null) {
1275
                updateActionPerformer();
1276
            }
1277
        }
1278
1279
        /**
1280
         * Update the state of the CallbackAction which is proxying this action.
1281
         */
1282
        private void updateActionPerformer() {
1283
            CallbackSystemAction action = (CallbackSystemAction) SystemAction.get(callbackActionClass);
1284
            boolean val = isEnabled();
1285
            if (!val && action.getActionPerformer() == this) {
1286
                if (log)
1287
                    log ("Clearing action performer for " + getValue(NAME));
1288
                action.setActionPerformer(null);
1289
            } else if( val ) {
1290
                if (log) log ("Setting action performer for " + getValue(NAME));
1291
                action.setActionPerformer(this);
1292
            }
1293
        }
1256
        }
1294
1257
1295
        /**
1258
        /**
Lines 1304-1321 Link Here
1304
            actionPerformed(ae);
1267
            actionPerformed(ae);
1305
        }
1268
        }
1306
1269
1307
        /**
1308
         * Resign this action from being the performer for its associated CallbackSystemAction.
1309
         */
1310
        public void detachPerformer() {
1311
            if (callbackActionClass != null) {
1312
                CallbackSystemAction action = (CallbackSystemAction) SystemAction.get(callbackActionClass);
1313
                if (action.getActionPerformer() == this) {
1314
                    if (log) log ("Detaching action performer for " + getValue(NAME));
1315
                    action.setActionPerformer(null);
1316
                }
1317
            }
1318
        }
1319
    }
1270
    }
1320
1271
1321
    /**
1272
    /**
(-)core/output2/src/org/netbeans/core/output2/IOEvent.java (-2 / +2 lines)
Lines 100-106 Link Here
100
     * XXX may not be supported - dispose of the default output window instance
100
     * XXX may not be supported - dispose of the default output window instance
101
     */
101
     */
102
    static final int CMD_DETACH = 11;
102
    static final int CMD_DETACH = 11;
103
103
    
104
    /**
104
    /**
105
     * Array of IDs for checking legal values and generating a string representing the event.
105
     * Array of IDs for checking legal values and generating a string representing the event.
106
     */
106
     */
Lines 116-122 Link Here
116
        CMD_STREAM_CLOSED,
116
        CMD_STREAM_CLOSED,
117
        CMD_RESET,
117
        CMD_RESET,
118
        CMD_SET_TOOLBAR_ACTIONS,
118
        CMD_SET_TOOLBAR_ACTIONS,
119
        CMD_DETACH
119
        CMD_DETACH,
120
    };
120
    };
121
121
122
    /**
122
    /**
(-)core/output2/src/org/netbeans/core/output2/NextOutJumpAction.java (-48 lines)
Removed Link Here
1
/*
2
 *                 Sun Public License Notice
3
 * 
4
 * The contents of this file are subject to the Sun Public License
5
 * Version 1.0 (the "License"). You may not use this file except in
6
 * compliance with the License. A copy of the License is available at
7
 * http://www.sun.com/
8
 * 
9
 * The Original Code is NetBeans. The Initial Developer of the Original
10
 * Code is Sun Microsystems, Inc. Portions Copyright 1997-2003 Sun
11
 * Microsystems, Inc. All Rights Reserved.
12
 */
13
14
package org.netbeans.core.output2;
15
16
import org.openide.util.HelpCtx;
17
import org.openide.util.NbBundle;
18
import org.openide.util.actions.CallbackSystemAction;
19
20
/** The action which invoke next "jump" getLine in output window (like next error)
21
*
22
* @author Petr Hamernik
23
*/
24
public class NextOutJumpAction extends CallbackSystemAction {
25
26
    protected void initialize() {
27
        super.initialize();
28
        // XXX revisit:
29
        setSurviveFocusChange(true);
30
    }
31
32
    protected String iconResource () {
33
        return null;//"org/netbeans/core/resources/actions/nextOutJump.gif"; // NOI18N
34
    }
35
36
    public HelpCtx getHelpCtx() {
37
        return new HelpCtx (NextOutJumpAction.class);
38
    }
39
40
    public String getName() {
41
        return NbBundle.getBundle(NextOutJumpAction.class).getString("NextOutJump");
42
    }
43
    
44
    protected boolean asynchronous() {
45
        return false;
46
    }
47
    
48
}
(-)core/output2/src/org/netbeans/core/output2/OutputWindow.java (-1 lines)
Lines 194-200 Link Here
194
        if (Controller.log) Controller.log("ComponentDeactivated");
194
        if (Controller.log) Controller.log("ComponentDeactivated");
195
        super.componentDeactivated();
195
        super.componentDeactivated();
196
        activated = false;
196
        activated = false;
197
        controller.notifyDeactivated ();
198
    }
197
    }
199
    
198
    
200
    protected void removed(AbstractOutputTab view) {
199
    protected void removed(AbstractOutputTab view) {
(-)core/output2/src/org/netbeans/core/output2/PreviousOutJumpAction.java (-49 lines)
Removed Link Here
1
/*
2
 *                 Sun Public License Notice
3
 * 
4
 * The contents of this file are subject to the Sun Public License
5
 * Version 1.0 (the "License"). You may not use this file except in
6
 * compliance with the License. A copy of the License is available at
7
 * http://www.sun.com/
8
 * 
9
 * The Original Code is NetBeans. The Initial Developer of the Original
10
 * Code is Sun Microsystems, Inc. Portions Copyright 1997-2003 Sun
11
 * Microsystems, Inc. All Rights Reserved.
12
 */
13
14
package org.netbeans.core.output2;
15
16
import org.openide.util.HelpCtx;
17
import org.openide.util.NbBundle;
18
import org.openide.util.actions.CallbackSystemAction;
19
20
/** The action which invoke previous "jump" line in output window
21
* (previous error)
22
*
23
* @author Petr Hamernik
24
*/
25
public class PreviousOutJumpAction extends CallbackSystemAction {
26
27
    protected void initialize() {
28
        super.initialize();
29
        // XXX revisit:
30
        setSurviveFocusChange(true);
31
    }
32
33
    protected String iconResource () {
34
        return null; //"org/netbeans/core/resources/actions/previousOutJump.gif"; // NOI18N
35
    }
36
37
    public HelpCtx getHelpCtx() {
38
        return new HelpCtx (PreviousOutJumpAction.class);
39
    }
40
41
    public String getName() {
42
        return NbBundle.getBundle(PreviousOutJumpAction.class).getString("PreviousOutJump");
43
    }
44
    
45
    protected boolean asynchronous() {
46
        return false;
47
    }
48
49
}
(-)core/output2/src/org/netbeans/core/output2/layer.xml (-17 lines)
Lines 15-36 Link Here
15
<filesystem>
15
<filesystem>
16
16
17
    <folder name="Actions">
17
    <folder name="Actions">
18
        <folder name="Build">
19
            <attr name="SystemFileSystem.localizingBundle" stringvalue="org.netbeans.core.output2.Bundle" />        
20
            <file name="org-netbeans-core-output2-NextOutJumpAction.instance"/>
21
            <file name="org-netbeans-core-output2-PreviousOutJumpAction.instance"/>
22
        </folder>
23
        <folder name="Window">
18
        <folder name="Window">
24
            <file name="org-netbeans-core-output2-OutputWindowAction.instance"/>
19
            <file name="org-netbeans-core-output2-OutputWindowAction.instance"/>
25
        </folder>
20
        </folder>
26
    </folder>
21
    </folder>
27
    <folder name="Menu">
22
    <folder name="Menu">
28
        <folder name="BuildProject">
29
            <attr name="Separator4.instance/org-netbeans-core-output2-NextOutJumpAction.instance" boolvalue="true" />
30
            <file name="org-netbeans-core-output2-NextOutJumpAction.instance"/>
31
            <attr name="org-netbeans-core-output2-NextOutJumpAction.instance/org-netbeans-core-output2-PreviousOutJumpAction.instance" boolvalue="true" />
32
            <file name="org-netbeans-core-output2-PreviousOutJumpAction.instance"/>
33
        </folder>
34
        <folder name="Window">
23
        <folder name="Window">
35
            <attr name="ViewFavoritesTabAction.shadow/org-netbeans-core-output2-OutputWindowAction.instance" boolvalue="true"/>
24
            <attr name="ViewFavoritesTabAction.shadow/org-netbeans-core-output2-OutputWindowAction.instance" boolvalue="true"/>
36
            <attr name="org-netbeans-core-output2-OutputWindowAction.instance/ViewRuntimeTabAction.shadow" boolvalue="true"/>
25
            <attr name="org-netbeans-core-output2-OutputWindowAction.instance/ViewRuntimeTabAction.shadow" boolvalue="true"/>
Lines 39-50 Link Here
39
        </folder>
28
        </folder>
40
    </folder>
29
    </folder>
41
    <folder name="Shortcuts">
30
    <folder name="Shortcuts">
42
        <file name="F12.instance">
43
	    <attr name="instanceClass" stringvalue="org.netbeans.core.output2.NextOutJumpAction"/>
44
	</file>
45
        <file name="S-F12.instance">
46
	    <attr name="instanceClass" stringvalue="org.netbeans.core.output2.PreviousOutJumpAction"/>
47
	</file>
48
        <file name="D-4.instance">
31
        <file name="D-4.instance">
49
	    <attr name="instanceClass" stringvalue="org.netbeans.core.output2.OutputWindowAction"/>
32
	    <attr name="instanceClass" stringvalue="org.netbeans.core.output2.OutputWindowAction"/>
50
	</file>
33
	</file>
(-)core/output2/src/org/netbeans/core/output2/ui/AbstractOutputTab.java (-5 lines)
Lines 10-20 Link Here
10
 * Code is Sun Microsystems, Inc. Portions Copyright 1997-2004 Sun
10
 * Code is Sun Microsystems, Inc. Portions Copyright 1997-2004 Sun
11
 * Microsystems, Inc. All Rights Reserved.
11
 * Microsystems, Inc. All Rights Reserved.
12
 */
12
 */
13
/*
14
 * AbstractOutputTab.java
15
 *
16
 * Created on May 14, 2004, 7:58 PM
17
 */
18
13
19
package org.netbeans.core.output2.ui;
14
package org.netbeans.core.output2.ui;
20
15
(-)core/output2/src/org/netbeans/core/output2/ui/AbstractOutputWindow.java (+2 lines)
Lines 192-197 Link Here
192
        if (pane.getParent() == this && op != pane.getSelectedComponent()) {
192
        if (pane.getParent() == this && op != pane.getSelectedComponent()) {
193
            pane.setSelectedComponent(op);
193
            pane.setSelectedComponent(op);
194
        }
194
        }
195
        
196
        getActionMap().setParent (op.getActionMap ());
195
    }
197
    }
196
198
197
    public void setTabTitle (AbstractOutputTab tab, String name) {
199
    public void setTabTitle (AbstractOutputTab tab, String name) {
(-)core/src/org/netbeans/core/actions/Bundle.properties (+4 lines)
Lines 65-67 Link Here
65
Actions/Window/SelectDocumentNode=Select Document in
65
Actions/Window/SelectDocumentNode=Select Document in
66
LBL_NextViewCallbackAction=Next Inner View
66
LBL_NextViewCallbackAction=Next Inner View
67
LBL_PreviousViewCallbackAction=Previous Inner View
67
LBL_PreviousViewCallbackAction=Previous Inner View
68
69
# jump next/prev actions
70
JumpNextAction=Ne&xt Error
71
JumpPrevAction=&Previous Error
(-)core/src/org/netbeans/core/actions/JumpNextAction.java (+58 lines)
Added Link Here
1
/*
2
 *                 Sun Public License Notice
3
 * 
4
 * The contents of this file are subject to the Sun Public License
5
 * Version 1.0 (the "License"). You may not use this file except in
6
 * compliance with the License. A copy of the License is available at
7
 * http://www.sun.com/
8
 * 
9
 * The Original Code is NetBeans. The Initial Developer of the Original
10
 * Code is Sun Microsystems, Inc. Portions Copyright 1997-2005 Sun
11
 * Microsystems, Inc. All Rights Reserved.
12
 */
13
14
package org.netbeans.core.actions;
15
16
import org.openide.util.HelpCtx;
17
import org.openide.util.NbBundle;
18
import org.openide.util.actions.CallbackSystemAction;
19
20
/** The action which invoke next "jump" getLine in output window (like next error)
21
*
22
* @author Petr Hamernik
23
*/
24
public class JumpNextAction extends CallbackSystemAction {
25
26
    protected void initialize() {
27
        super.initialize();
28
        setSurviveFocusChange(true);
29
        putProperty ("noIconInMenu", Boolean.TRUE); // NOI18N
30
    }
31
    
32
    public void setEnabled (boolean b) {
33
        super.setEnabled (b);
34
    }
35
36
    protected String iconResource () {
37
        return "org/netbeans/core/resources/actions/nextOutJump.gif"; // NOI18N
38
    }
39
40
    public HelpCtx getHelpCtx() {
41
        return new HelpCtx (JumpNextAction.class);
42
    }
43
44
    public String getName() {
45
        return NbBundle.getBundle(JumpNextAction.class).getString("JumpNextAction");
46
    }
47
    
48
    protected boolean asynchronous() {
49
        return false;
50
    }
51
    
52
    public void setActionPerformer (org.openide.util.actions.ActionPerformer performer) {
53
        throw new java.lang.UnsupportedOperationException ();
54
    }
55
    public Object getActionMapKey () {
56
        return "jumpNext"; // NOI18N
57
    }
58
}
(-)core/src/org/netbeans/core/actions/JumpPrevAction.java (+57 lines)
Added Link Here
1
/*
2
 *                 Sun Public License Notice
3
 * 
4
 * The contents of this file are subject to the Sun Public License
5
 * Version 1.0 (the "License"). You may not use this file except in
6
 * compliance with the License. A copy of the License is available at
7
 * http://www.sun.com/
8
 * 
9
 * The Original Code is NetBeans. The Initial Developer of the Original
10
 * Code is Sun Microsystems, Inc. Portions Copyright 1997-2003 Sun
11
 * Microsystems, Inc. All Rights Reserved.
12
 */
13
14
package org.netbeans.core.actions;
15
16
import org.openide.util.HelpCtx;
17
import org.openide.util.NbBundle;
18
import org.openide.util.actions.CallbackSystemAction;
19
20
/** The action which invoke previous "jump" line in output window
21
* (previous error)
22
*
23
* @author Petr Hamernik
24
*/
25
public class JumpPrevAction extends CallbackSystemAction {
26
27
    protected void initialize() {
28
        super.initialize();
29
        setSurviveFocusChange(true);
30
        putProperty ("noIconInMenu", Boolean.TRUE); // NOI18N
31
    }
32
33
    protected String iconResource () {
34
        return "org/netbeans/core/resources/actions/previousOutJump.gif"; // NOI18N
35
    }
36
37
    public HelpCtx getHelpCtx() {
38
        return new HelpCtx (JumpPrevAction.class);
39
    }
40
41
    public String getName() {
42
        return NbBundle.getBundle(JumpPrevAction.class).getString("JumpPrevAction");
43
    }
44
    
45
    protected boolean asynchronous() {
46
        return false;
47
    }
48
49
    public void setActionPerformer (org.openide.util.actions.ActionPerformer performer) {
50
        throw new java.lang.UnsupportedOperationException ();
51
    }
52
53
    public Object getActionMapKey () {
54
        return "jumpPrev"; // NOI18N
55
    }
56
57
}
(-)core/test/unit/src/org/netbeans/core/actions/ActionMapKeysTest.java (+47 lines)
Added Link Here
1
/*
2
 *                 Sun Public License Notice
3
 * 
4
 * The contents of this file are subject to the Sun Public License
5
 * Version 1.0 (the "License"). You may not use this file except in
6
 * compliance with the License. A copy of the License is available at
7
 * http://www.sun.com/
8
 * 
9
 * The Original Code is NetBeans. The Initial Developer of the Original
10
 * Code is Sun Microsystems, Inc. Portions Copyright 1997-2005 Sun
11
 * Microsystems, Inc. All Rights Reserved.
12
 */
13
14
package org.netbeans.core.actions;
15
16
import junit.framework.*;
17
import org.openide.util.HelpCtx;
18
import org.openide.util.NbBundle;
19
import org.openide.util.actions.CallbackSystemAction;
20
21
/** Checks that the keys defined in API are really working.
22
 *
23
 * @author Jaroslav Tulach
24
 */
25
public class ActionMapKeysTest extends TestCase {
26
    
27
    public ActionMapKeysTest (String testName) {
28
        super (testName);
29
    }
30
31
    protected void setUp () throws Exception {
32
    }
33
34
    protected void tearDown () throws Exception {
35
    }
36
37
    public void testJumpNextAction () {
38
        JumpNextAction a = (JumpNextAction)JumpNextAction.get (JumpNextAction.class);
39
        assertEquals ("jumpNext", a.getActionMapKey ());
40
    }
41
42
    public void testJumpPrevAction () {
43
        JumpPrevAction a = (JumpPrevAction)JumpPrevAction.get (JumpPrevAction.class);
44
        assertEquals ("jumpPrev", a.getActionMapKey ());
45
    }
46
    
47
}
(-)core/ui/src/org/netbeans/core/ui/resources/layer.xml (+23 lines)
Lines 67-72 Link Here
67
            <file name="org-openide-actions-NewTemplateAction.instance"/>
67
            <file name="org-openide-actions-NewTemplateAction.instance"/>
68
            <file name="org-netbeans-core-actions-SetupWizardAction.instance"/>
68
            <file name="org-netbeans-core-actions-SetupWizardAction.instance"/>
69
            <file name="org-netbeans-core-actions-RefreshAllFilesystemsAction.instance"/>
69
            <file name="org-netbeans-core-actions-RefreshAllFilesystemsAction.instance"/>
70
            <file name="org-netbeans-core-actions-JumpNextAction.instance">
71
            </file>
72
            <file name="org-netbeans-core-actions-JumpPrevAction.instance">
73
            </file>
74
            
70
        </folder>
75
        </folder>
71
        
76
        
72
        <folder name="View">
77
        <folder name="View">
Lines 153-158 Link Here
153
            <file name="org-openide-actions-ReplaceAction.instance"/>
158
            <file name="org-openide-actions-ReplaceAction.instance"/>
154
            <attr name="org-openide-actions-ReplaceAction.instance/org-openide-actions-GotoAction.instance" boolvalue="true" />
159
            <attr name="org-openide-actions-ReplaceAction.instance/org-openide-actions-GotoAction.instance" boolvalue="true" />
155
            <file name="org-openide-actions-GotoAction.instance"/>
160
            <file name="org-openide-actions-GotoAction.instance"/>
161
            <attr name="org-openide-actions-GotoAction.instance/Separator3.instance" boolvalue="true" />
162
            <file name="Separator3.instance">
163
		<attr name="instanceClass" stringvalue="javax.swing.JSeparator"/>
164
	    </file>
165
            <attr name="Separator3.instance/org-netbeans-core-actions-JumpNextAction.shadow" boolvalue="true" />
166
            <file name="org-netbeans-core-actions-JumpNextAction.shadow" >
167
                <attr name="originalFile" stringvalue="/Actions/System/org-netbeans-core-actions-JumpNextAction.instance" />
168
            </file>
169
            <attr name="org-netbeans-core-actions-JumpNextAction.shadow/org-netbeans-core-actions-JumpPrevAction.shadow" boolvalue="true" />
170
            <file name="org-netbeans-core-actions-JumpPrevAction.shadow" >
171
                <attr name="originalFile" stringvalue="/Actions/System/org-netbeans-core-actions-JumpPrevAction.instance" />
172
            </file>
156
        </folder>
173
        </folder>
157
        
174
        
158
        <attr name="Edit/View" boolvalue="true" />
175
        <attr name="Edit/View" boolvalue="true" />
Lines 334-339 Link Here
334
	</file>
351
	</file>
335
        <file name="DS-7.instance">
352
        <file name="DS-7.instance">
336
	    <attr name="instanceClass" stringvalue="org.netbeans.core.actions.GlobalPropertiesAction"/>
353
	    <attr name="instanceClass" stringvalue="org.netbeans.core.actions.GlobalPropertiesAction"/>
354
	</file>
355
        <file name="F12.shadow">
356
            <attr name="originalFile" stringvalue="Actions/System/org-netbeans-core-actions-JumpNextAction.instance" />
357
	</file>
358
        <file name="S-F12.shadow">
359
            <attr name="originalFile" stringvalue="Actions/System/org-netbeans-core-actions-JumpPrevAction.instance" />
337
	</file>
360
	</file>
338
    </folder>
361
    </folder>
339
    
362
    
(-)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.7
7
openide.specification.version=5.8
(-)openide/api/doc/changes/apichanges.xml (+19 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="jump-prev-next">
118
       <api name="actions"/>
119
       <summary>A way how to implement "Jump Next" and "Jump Prev" action handlers</summary>
120
       <version major="5" minor="8"/>
121
       <date day="24" month="3" year="2005"/>
122
       <author login="jtulach"/>
123
       <compatibility addition="yes" binary="compatible" semantic="compatible" source="compatible" />
124
       <description>
125
         Use
126
         <pre>
127
topComponent.getActionMap ().put ("jumpPrev", new YourPrevAction ()); // NOI18N
128
topComponent.getActionMap ().put ("jumpNext", new YourNextAction ()); // NOI18N
129
         </pre>
130
         if your component provides items and you want the user to jump 
131
         among them using standard next/prev actions.
132
       </description>
133
       <issue number="40185" />
134
     </change>
135
     
117
     <change id="item-separator-attribute-for-StringArrayPropertyEditor">
136
     <change id="item-separator-attribute-for-StringArrayPropertyEditor">
118
       <api name="explorer"/>
137
       <api name="explorer"/>
119
       <summary>One can specify separator for property editor for <code>String[]</code> </summary>
138
       <summary>One can specify separator for property editor for <code>String[]</code> </summary>
(-)openide/arch/arch-openide-actions.xml (-1 / +24 lines)
Lines 436-441 Link Here
436
        </api>
436
        </api>
437
    </li>
437
    </li>
438
</ul>
438
</ul>
439
440
<api name="ActionMapKeys" category="stable" group="property" type="export" >
441
<code>CallableSystemAction</code> uses its <code>getActionMapKey()</code> method
442
(usually overriden by subclasses) to get a key which is then searched in the
443
<code>ActionMap</code> obtained from the action's context. Other modules can
444
register their own action then: 
445
<pre>
446
topComponent.getActionMap ().put (theKey, new YourOwnSwingAction ());
447
</pre>
448
Here is the list of special keys:
449
<ul>
450
    <li><code>"cloneWindow"</code> - an action to be executed when a top component is to be cloned</li>
451
    <li><code>"closeWindow"</code> - an action when a view is about to be closed</li>
452
    <li><code>DefaultEditorKit.copyAction</code> - copy action handler</li>
453
    <li><code>DefaultEditorKit.cutAction</code> - cut action handler</li>
454
    <li><code>"delete"</code> - delete action handler</li>
455
    <li><code>DefaultEditorKit.pasteAction</code> - paste action handler</li>
456
    
457
    <!-- new since 5.8 -->
458
    <li><code>"jumpNext"</code> - when a next element shall be selected</li>
459
    <li><code>"jumpPrev"</code> - when a previous element shall be selected</li>
460
</ul>
461
439
</answer>
462
</answer>
440
463
441
464
Lines 571-577 Link Here
571
<answer id="lookup-lookup">
594
<answer id="lookup-lookup">
572
It uses <code>Lookup</code> as a representation of context in which are certain action
595
It uses <code>Lookup</code> as a representation of context in which are certain action
573
types <code>ContextAwareAction</code>s used. Current implementations
596
types <code>ContextAwareAction</code>s used. Current implementations
574
lookup in the context for <code>javax.swing.ActionMap</code>
597
lookup in the context for <code>>javax.swing.ActionMap</code>
575
or <code>org.openide.nodes.Node</code> or <code>org.openide.Node.Cookie</code>
598
or <code>org.openide.nodes.Node</code> or <code>org.openide.Node.Cookie</code>
576
instances.
599
instances.
577
</answer>
600
</answer>
(-)openide/src/org/openide/util/actions/CallbackSystemAction.java (-43 / +109 lines)
Lines 13-18 Link Here
13
13
14
package org.openide.util.actions;
14
package org.openide.util.actions;
15
15
16
import org.openide.ErrorManager;
16
import org.openide.util.WeakListeners;
17
import org.openide.util.WeakListeners;
17
import java.beans.*;
18
import java.beans.*;
18
import java.awt.Component;
19
import java.awt.Component;
Lines 73-79 Link Here
73
        setSurviveFocusChange(false);
74
        setSurviveFocusChange(false);
74
    }
75
    }
75
76
76
77
    /** Get the current action performer.
77
    /** Get the current action performer.
78
    * @return the current action performer, or <code>null</code> if there is currently no performer
78
    * @return the current action performer, or <code>null</code> if there is currently no performer
79
    */
79
    */
Lines 121-133 Link Here
121
    /** Updates the enabled state by checking performer and ActionMap
121
    /** Updates the enabled state by checking performer and ActionMap
122
     */
122
     */
123
    private void updateEnabled () {
123
    private void updateEnabled () {
124
        javax.swing.Action action = findGlobalContextAction ();
124
        javax.swing.Action action = GlobalManager.getDefault ().findGlobalAction (getActionMapKey (), getSurviveFocusChange ());
125
        if(action != null) {
125
        if(action != null) {
126
            setEnabled (action.isEnabled());
126
            setEnabled (action.isEnabled());
127
127
128
            synchronized (LISTENER) {
128
            synchronized (LISTENER) {
129
                ActionDelegateListener l = (ActionDelegateListener)getProperty(LISTENER);
129
                ActionDelegateListener l = (ActionDelegateListener)getProperty(LISTENER);
130
                if (l == null) {
130
                if (l == null || l.get () != this) {
131
                    l = new ActionDelegateListener (this, action);
131
                    l = new ActionDelegateListener (this, action);
132
                    putProperty (LISTENER, l);
132
                    putProperty (LISTENER, l);
133
                } else {
133
                } else {
Lines 163-169 Link Here
163
     */
163
     */
164
    public void actionPerformed(final ActionEvent ev) {
164
    public void actionPerformed(final ActionEvent ev) {
165
        // First try global context action.
165
        // First try global context action.
166
        final Action action = findGlobalContextAction ();
166
        final Action action = GlobalManager.getDefault ().findGlobalAction (getActionMapKey (), getSurviveFocusChange ());
167
        if (action != null) {
167
        if (action != null) {
168
            if (action.isEnabled()) {
168
            if (action.isEnabled()) {
169
                action.actionPerformed(ev);
169
                action.actionPerformed(ev);
Lines 186-204 Link Here
186
        Toolkit.getDefaultToolkit().beep();
186
        Toolkit.getDefaultToolkit().beep();
187
    }
187
    }
188
    
188
    
189
    /** Finds global context action (the one from activated component).
190
     * @return action for key of activated component or null
191
     */
192
    private javax.swing.Action findGlobalContextAction () {
193
        ActionMap map = GlobalManager.getDefault ().getActionMap ();
194
        if (map != null) {
195
            Object key = getActionMapKey();
196
            return map.get (key);
197
        }
198
        
199
        return null;
200
    }
201
202
    /** Perform the action.
189
    /** Perform the action.
203
    * This default implementation calls the assigned action performer if it
190
    * This default implementation calls the assigned action performer if it
204
    * exists, otherwise does nothing.
191
    * exists, otherwise does nothing.
Lines 295-310 Link Here
295
        it = actions.iterator ();
282
        it = actions.iterator ();
296
        while (it.hasNext ()) {
283
        while (it.hasNext ()) {
297
            CallbackSystemAction a = (CallbackSystemAction)it.next ();
284
            CallbackSystemAction a = (CallbackSystemAction)it.next ();
285
            if (errLog) {
286
                err.log ("updateEnabled: " + a); // NOI18N
287
            }
298
            a.updateEnabled ();
288
            a.updateEnabled ();
299
        }
289
        }
300
    }
290
    }
291
292
    /** logging */
293
    private static final ErrorManager err = ErrorManager.getDefault ().getInstance ("org.openide.util.actions.CallbackSystemAction"); // NOI18N
294
    private static final boolean errLog = err.isLoggable (err.INFORMATIONAL);
301
    
295
    
302
    /** Listener on a global context.
296
    /** Listener on a global context.
303
     */
297
     */
304
    private static final class GlobalManager implements LookupListener {
298
    private static final class GlobalManager implements LookupListener {
305
        private static GlobalManager instance;
299
        private static GlobalManager instance;
306
        private Lookup.Result result;
300
        private Lookup.Result result;
307
        private Reference actionMap;
301
        private Reference actionMap = new WeakReference (null);
302
        private final ActionMap survive = new ActionMap ();
308
        
303
        
309
        public synchronized static GlobalManager getDefault () {
304
        public synchronized static GlobalManager getDefault () {
310
            if (instance != null) return instance;
305
            if (instance != null) return instance;
Lines 317-362 Link Here
317
                new Lookup.Template (ActionMap.class)
312
                new Lookup.Template (ActionMap.class)
318
            );
313
            );
319
            result.addLookupListener(this);
314
            result.addLookupListener(this);
315
            resultChanged (null);
320
        }
316
        }
321
        
317
        
322
        public ActionMap getActionMap () {
318
        public Action findGlobalAction (Object key, boolean surviveFocusChange) {
323
            ActionMap a = (ActionMap)Utilities.actionsGlobalContext ().lookup (ActionMap.class);
319
            ActionMap map = (ActionMap)actionMap.get ();
324
            if (actionMap == null) {
320
            Action a = map == null ? null : map.get (key);
325
                actionMap = new WeakReference (a);
321
            
322
            if (surviveFocusChange) {
323
                if (a == null) {
324
                    a = survive.get (key);
325
                    if (a != null) {
326
                        a = ((WeakAction)a).getDelegate ();
327
                    }
328
                    if (errLog) {
329
                        err.log ("No action for key: " + key + " using delegate: " + a); // NOI18N
330
                    }
331
                } else {
332
                    if (errLog) {
333
                        err.log ("New action for key: " + key + " put: " + a);
334
                    }
335
                    
336
                    survive.put (key, new WeakAction (a));
337
                }
338
            }
339
            if (errLog) {
340
                err.log ("Action for key: " + key + " is: " + a); // NOI18N
326
            }
341
            }
327
            return a;
342
            return a;
328
        }
343
        }
329
        
344
        
330
        /** Change all that do not survive ActionMap change */
345
        /** Change all that do not survive ActionMap change */
331
        public void resultChanged(org.openide.util.LookupEvent ev) {
346
        public void resultChanged(org.openide.util.LookupEvent ev) {
332
            if (actionMap == null || actionMap.get () != getActionMap ()) {
347
            ActionMap a = (ActionMap)Utilities.actionsGlobalContext ().lookup (ActionMap.class);
333
                actionMap = null;
348
            if (errLog) {
334
                clearActionPerformers ();
349
                err.log ("changed map : " + a); // NOI18N
350
                err.log ("previous map: " + actionMap.get ()); // NOI18N
351
            }
352
            if (a == actionMap.get ()) {
353
                return;
354
            }
355
            actionMap = new WeakReference (a);
356
            if (errLog) {
357
                err.log ("clearActionPerformers"); // NOI18N
335
            }
358
            }
359
            clearActionPerformers ();
336
        }
360
        }
337
        
361
        
338
    } // end of LookupListener
362
    } // end of LookupListener
339
    
363
    
364
    /** An action that holds a weak reference to other action.
365
     */
366
    private static final class WeakAction extends WeakReference implements Action {
367
        public WeakAction (Action delegate) {
368
            super (delegate);
369
        }
370
        
371
        public Action getDelegate () {
372
            return (Action)super.get ();
373
        }
374
375
        public Object getValue (String key) {
376
            throw new UnsupportedOperationException ();
377
        }
378
379
        public void putValue (String key, Object value) {
380
            throw new UnsupportedOperationException ();
381
        }
382
383
        public void actionPerformed (ActionEvent e) {
384
            throw new UnsupportedOperationException ();
385
        }
386
387
        public void removePropertyChangeListener (PropertyChangeListener listener) {
388
            throw new UnsupportedOperationException ();
389
        }
390
391
        public void addPropertyChangeListener (PropertyChangeListener listener) {
392
            throw new UnsupportedOperationException ();
393
        }
394
395
        public void setEnabled (boolean b) {
396
            throw new UnsupportedOperationException ();
397
        }
398
399
        public boolean isEnabled () {
400
            throw new UnsupportedOperationException ();
401
        }
402
    }
403
    
340
    /** A class that listens on changes in enabled state of an action
404
    /** A class that listens on changes in enabled state of an action
341
     * and updates the state of the action according to it.
405
     * and updates the state of the action according to it.
342
     */
406
     */
343
    private static final class ActionDelegateListener extends Object
407
    private static final class ActionDelegateListener extends WeakReference
344
    implements PropertyChangeListener {
408
    implements PropertyChangeListener {
345
        private CallbackSystemAction action;
409
        private WeakReference delegate;
346
        private javax.swing.Action delegate;
347
        
348
        public ActionDelegateListener (CallbackSystemAction c, javax.swing.Action delegate) {
410
        public ActionDelegateListener (CallbackSystemAction c, javax.swing.Action delegate) {
349
            this.action = c;
411
            super (c);
350
            this.delegate = delegate;
412
            this.delegate = new WeakReference (delegate);
351
            
352
            
353
            delegate.addPropertyChangeListener(this);
413
            delegate.addPropertyChangeListener(this);
354
        }
414
        }
355
        
415
        
356
        public void clear () {
416
        public void clear () {
357
            javax.swing.Action a;
417
            javax.swing.Action a;
358
            
418
359
            a = delegate;
419
            WeakReference d = delegate;
420
            a = d == null ? null : (javax.swing.Action)d.get ();
360
            if (a == null) return;
421
            if (a == null) return;
361
            delegate = null;
422
            delegate = null;
362
            
423
            
Lines 364-389 Link Here
364
        }
425
        }
365
        
426
        
366
        public void attach (javax.swing.Action action) {
427
        public void attach (javax.swing.Action action) {
367
            if (delegate == action) {
428
            WeakReference d = delegate;
429
            if (d != null && d.get () == action) {
368
                return;
430
                return;
369
            }
431
            }
370
            
432
            Action prev = (Action)d.get ();
371
            // reattaches to different action
433
            // reattaches to different action
372
            if (this.delegate != null) {
434
            if (prev != null) {
373
                this.delegate.removePropertyChangeListener(this);
435
                prev.removePropertyChangeListener(this);
374
            }
436
            }
375
            
437
            
376
            this.delegate = action;
438
            this.delegate = new WeakReference (action);
377
            action.addPropertyChangeListener(this);
439
            action.addPropertyChangeListener(this);
378
        }
440
        }
379
            
441
            
380
        
442
        
381
        public void propertyChange(java.beans.PropertyChangeEvent evt) {
443
        public void propertyChange(java.beans.PropertyChangeEvent evt) {
382
            synchronized (LISTENER) {
444
            synchronized (LISTENER) {
383
                if (delegate == null) return;
445
                WeakReference d = delegate;
446
                if (d == null || d.get () == null) return;
447
            }
448
449
            CallbackSystemAction c = (CallbackSystemAction)get ();
450
            if (c != null) {
451
                c.updateEnabled();
384
            }
452
            }
385
            
386
            action.updateEnabled();
387
        }
453
        }
388
    }
454
    }
389
    
455
    
(-)openide/src/org/openide/windows/DelegateActionMap.java (+3 lines)
Lines 127-130 Link Here
127
        return delegate == null ? null : delegate.getParent ();
127
        return delegate == null ? null : delegate.getParent ();
128
    }
128
    }
129
129
130
    public String toString () {
131
        return super.toString () + " for " + this.component;
132
    }
130
}    
133
}    
(-)openide/src/org/openide/windows/TopComponent.java (+1 lines)
Lines 557-562 Link Here
557
     * unless it is in active mode already. */
557
     * unless it is in active mode already. */
558
    public void requestVisible () {
558
    public void requestVisible () {
559
        WindowManager.getDefault().topComponentRequestVisible(this);
559
        WindowManager.getDefault().topComponentRequestVisible(this);
560
        org.netbeans.modules.openide.windows.GlobalActionContextImpl.blickActionMap (getActionMap ());
560
    }
561
    }
561
    
562
    
562
    /**
563
    /**
(-)openide/test/unit/src/org/openide/util/actions/CallbackSystemActionTest.java (-4 / +65 lines)
Lines 13-18 Link Here
13
13
14
package org.openide.util.actions;
14
package org.openide.util.actions;
15
15
16
import java.lang.ref.WeakReference;
16
import javax.swing.ActionMap;
17
import javax.swing.ActionMap;
17
import org.netbeans.junit.*;
18
import org.netbeans.junit.*;
18
import junit.textui.TestRunner;
19
import junit.textui.TestRunner;
Lines 34-47 Link Here
34
        super(name);
35
        super(name);
35
    }
36
    }
36
    
37
    
37
    public static void main(String[] args) {
38
38
        TestRunner.run(new NbTestSuite(CallbackSystemActionTest.class));
39
    protected void setUp () throws Exception {
39
        // May have used AWT thread.
40
        super.setUp();
40
        System.exit(0);
41
    }
41
    }
42
42
43
    protected boolean runInEQ () {
43
    protected boolean runInEQ () {
44
        return true;
44
        return true;
45
    }
46
47
    public void testSurviveFocusChangeInTheNewWay () throws Exception {
48
        doSurviveFocusChangeInTheNewWay (false);
49
    }
50
    
51
    public void testSurviveFocusChangeInTheNewWayEvenActionIsGCed () throws Exception {
52
        doSurviveFocusChangeInTheNewWay (true);
53
    }
54
    
55
    private void doSurviveFocusChangeInTheNewWay (boolean doGC) throws Exception {
56
        class MyAction extends javax.swing.AbstractAction {
57
            public int cntEnabled;
58
            public int cntPerformed;
59
            
60
            public boolean isEnabled () {
61
                cntEnabled++;
62
                return true;
63
            }
64
            
65
            public void actionPerformed (java.awt.event.ActionEvent ev) {
66
                cntPerformed++;
67
            }
68
        }
69
        MyAction myAction = new MyAction ();
70
        
71
        TopComponent other = new TopComponent ();
72
        TopComponent tc = new TopComponent ();
73
        SurviveFocusChgCallbackAction a = (SurviveFocusChgCallbackAction)SurviveFocusChgCallbackAction.get (SurviveFocusChgCallbackAction.class);
74
        tc.getActionMap().put (a.getActionMapKey (), myAction);
75
        
76
        ActionsInfraHid.UT.setActivated(other);
77
        try {
78
            assertFalse ("Disabled on other component", a.isEnabled ());
79
            ActionsInfraHid.UT.setActivated (tc);
80
            assertTrue ("MyAction is enabled", a.isEnabled ());
81
            assertEquals ("isEnabled called once", 1, myAction.cntEnabled);
82
            
83
            if (doGC) {
84
                java.lang.ref.WeakReference ref = new java.lang.ref.WeakReference (a);
85
                a = null;
86
                assertGC ("Action can disappear", ref);
87
                a = (SurviveFocusChgCallbackAction)SurviveFocusChgCallbackAction.get (SurviveFocusChgCallbackAction.class);
88
            }
89
            
90
            ActionsInfraHid.UT.setActivated (other);
91
            assertTrue ("Still enabled", a.isEnabled ());
92
            assertEquals ("isEnabled called still only once (now it is called twice)", 2, myAction.cntEnabled);
93
        } finally {
94
            ActionsInfraHid.UT.setActivated (null);
95
        }
96
        
97
        WeakReference ref = new WeakReference (a);
98
        WeakReference ref2 = new WeakReference (myAction);
99
        WeakReference ref3 = new WeakReference (tc);
100
        a = null;
101
        myAction = null;
102
        tc = null;
103
        assertGC ("We are able to clear global action", ref);
104
        assertGC ("Even our action", ref2);
105
        assertGC ("Even our component", ref3);
45
    }
106
    }
46
    
107
    
47
    /** Make sure that the performer system works and controls enablement.
108
    /** Make sure that the performer system works and controls enablement.
(-)openide/test/unit/src/org/openide/windows/GlobalContextImplTest.java (+49 lines)
Lines 24-29 Link Here
24
import org.openide.nodes.FilterNode;
24
import org.openide.nodes.FilterNode;
25
import org.openide.nodes.Node;
25
import org.openide.nodes.Node;
26
import org.openide.util.Lookup;
26
import org.openide.util.Lookup;
27
import org.openide.util.LookupEvent;
27
import org.openide.util.lookup.AbstractLookup;
28
import org.openide.util.lookup.AbstractLookup;
28
import org.openide.util.lookup.InstanceContent;
29
import org.openide.util.lookup.InstanceContent;
29
30
Lines 106-111 Link Here
106
        assertEquals ("No change", 3, cnt);
107
        assertEquals ("No change", 3, cnt);
107
        
108
        
108
        assertEquals ("No items in lookup", 0, result.allItems ().size ());
109
        assertEquals ("No items in lookup", 0, result.allItems ().size ());
110
        assertActionMap ();
111
    }
112
    
113
    public void testRequestVisibleBlinksTheActionMapForAWhile () throws Exception {
114
        final org.openide.nodes.Node n = new org.openide.nodes.AbstractNode (org.openide.nodes.Children.LEAF);
115
        tc.setActivatedNodes(new Node[] { n });
116
        
117
        assertActionMap ();
118
        final Lookup.Result res = lookup.lookup (new Lookup.Template (ActionMap.class));
119
        assertEquals ("One action map", 1, res.allItems ().size ());
120
        
121
        class L implements org.openide.util.LookupListener {
122
            ArrayList maps = new ArrayList ();
123
            
124
            public void resultChanged (org.openide.util.LookupEvent ev) {
125
                assertEquals ("Still only one", 1, res.allItems ().size ());
126
                Lookup.Item i = (Lookup.Item)res.allItems ().iterator ().next ();
127
                assertNotNull (i);
128
                
129
                maps.add (i.getInstance ());
130
                
131
                assertNode ();
132
            }
133
            
134
            public void assertNode () {
135
                assertEquals ("The node is available", n, lookup.lookup (Node.class));
136
            }
137
        }
138
        L myListener = new L ();
139
        myListener.assertNode ();
140
        
141
        res.addLookupListener (myListener);
142
                
143
        TopComponent my = new TopComponent ();
144
        my.requestVisible ();
145
        
146
        if (myListener.maps.size () != 2) {
147
            fail ("Expected two changes in the ActionMaps: " + myListener.maps);
148
        }
149
150
        myListener.assertNode ();
151
152
        ActionMap m1 = (ActionMap)myListener.maps.get (0);
153
        ActionMap m2 = (ActionMap)myListener.maps.get (1);
154
        
155
        assertNull ("Our action is not in first map", m1.get (this));
156
        assertEquals ("Our action is in second map", sampleAction, m2.get (this));
157
109
        assertActionMap ();
158
        assertActionMap ();
110
    }
159
    }
111
    
160
    
(-)openide/windows/src/org/netbeans/modules/openide/windows/GlobalActionContextImpl.java (+34 lines)
Lines 15-20 Link Here
15
15
16
import org.openide.util.Lookup;
16
import org.openide.util.Lookup;
17
import org.openide.util.ContextGlobalProvider;
17
import org.openide.util.ContextGlobalProvider;
18
import org.openide.util.lookup.Lookups;
19
import org.openide.util.lookup.ProxyLookup;
18
import org.openide.windows.TopComponent;
20
import org.openide.windows.TopComponent;
19
21
20
/** An interface that can be registered in a lookup by subsystems
22
/** An interface that can be registered in a lookup by subsystems
Lines 35-40 Link Here
35
        this.registry = r;
37
        this.registry = r;
36
    }
38
    }
37
    
39
    
40
    /** the lookup to temporarily use */
41
    private static volatile Lookup temporary;
42
    /** Temporarily provides different action map in the lookup.
43
     */
44
    public static void blickActionMap (javax.swing.ActionMap map) {
45
        Object obj = Lookup.getDefault ().lookup (ContextGlobalProvider.class);
46
        if (obj instanceof GlobalActionContextImpl) {
47
            GlobalActionContextImpl g = (GlobalActionContextImpl)obj;
48
            
49
            Lookup[] arr = {
50
                Lookups.singleton (map),
51
                Lookups.exclude (g.getLookup (), new Class[] { javax.swing.ActionMap.class }),
52
            };
53
            
54
            Lookup prev = temporary;
55
            try {
56
                temporary = new ProxyLookup (arr);
57
                Object q = org.openide.util.Utilities.actionsGlobalContext ().lookup (javax.swing.ActionMap.class);
58
                assert q == map : "We really get map from the lookup. Map: " + map + " returned: " + q; // NOI18N
59
            } finally {
60
                temporary = prev;
61
                // fire the changes about return of the values back
62
                org.openide.util.Utilities.actionsGlobalContext ().lookup (javax.swing.ActionMap.class);
63
            }
64
        }
65
    }
66
    
38
    /** Let's create the proxy listener that delegates to currently 
67
    /** Let's create the proxy listener that delegates to currently 
39
     * selected top component.
68
     * selected top component.
40
     */
69
     */
Lines 45-50 Link Here
45
    
74
    
46
    /** The current component lookup */
75
    /** The current component lookup */
47
    public Lookup getLookup() {
76
    public Lookup getLookup() {
77
        Lookup l = temporary;
78
        if (l != null) {
79
            return l;
80
        }
81
        
48
        TopComponent tc = registry.getActivated();
82
        TopComponent tc = registry.getActivated();
49
        return tc == null ? Lookup.EMPTY : tc.getLookup();
83
        return tc == null ? Lookup.EMPTY : tc.getLookup();
50
    }
84
    }
(-)projects/projectui/src/org/netbeans/modules/project/ui/resources/layer.xml (-1 / +1 lines)
Lines 354-360 Link Here
354
                <attr name="instanceClass" stringvalue="javax.swing.JSeparator"/>
354
                <attr name="instanceClass" stringvalue="javax.swing.JSeparator"/>
355
            </file>
355
            </file>
356
            
356
            
357
            <attr name="SeparatorCompileSingle.instance/org-netbeans-core-output2-NextOutJumpAction.instance" boolvalue="true" />
357
            <attr name="SeparatorCompileSingle.instance/org-netbeans-core-actions-JumpNextAction.shadow" boolvalue="true" />
358
        </folder>
358
        </folder>
359
        
359
        
360
        <attr name="BuildProject/RunProject" boolvalue="true" />        
360
        <attr name="BuildProject/RunProject" boolvalue="true" />        
(-)refactoring/arch/arch-refactoring.xml (-1 / +4 lines)
Lines 664-670 Link Here
664
-->
664
-->
665
 <answer id="exec-component">
665
 <answer id="exec-component">
666
  <p>
666
  <p>
667
   No
667
    <api name="ActionMapKeys" category="stable" group="property" type="import" >
668
    the usages window defines <q>jumpNext</q> and <q>jumpPrev</q> action
669
    handlers in its <code>ActionMap</code>.
670
    </api>
668
  </p>
671
  </p>
669
 </answer>
672
 </answer>
670
673
(-)refactoring/nbproject/project.xml (-1 / +1 lines)
Lines 98-104 Link Here
98
                    <compile-dependency/>
98
                    <compile-dependency/>
99
                    <run-dependency>
99
                    <run-dependency>
100
                        <release-version>1</release-version>
100
                        <release-version>1</release-version>
101
                        <specification-version>3.36</specification-version>
101
                        <specification-version>5.8</specification-version>
102
                    </run-dependency>
102
                    </run-dependency>
103
                </dependency>
103
                </dependency>
104
                <dependency>
104
                <dependency>
(-)refactoring/src/org/netbeans/modules/refactoring/ui/CheckNodeListener.java (-1 / +1 lines)
Lines 141-147 Link Here
141
        }
141
        }
142
    }
142
    }
143
    
143
    
144
    private static void findInSource(CheckNode node) {        
144
    static void findInSource(CheckNode node) {        
145
        PositionBounds bounds = node.getPosition();
145
        PositionBounds bounds = node.getPosition();
146
        if (bounds == null)
146
        if (bounds == null)
147
            return;
147
            return;
(-)refactoring/src/org/netbeans/modules/refactoring/ui/RefactoringPanel.java (+42 lines)
Lines 851-859 Link Here
851
        }
851
        }
852
    }
852
    }
853
    
853
    
854
    void selectNextUsage() {
855
        selectNextPrev(true);
856
    }
857
    
858
    void selectPrevUsage() {
859
        selectNextPrev(false);
860
    }
861
    
862
    private void selectNextPrev(final boolean next) {
863
        int newRow = getSelectedRow();
864
        int maxcount = tree.getRowCount();
865
        CheckNode node;
866
        do {
867
            if (next) {
868
                newRow++;
869
                if (newRow>=maxcount)
870
                    newRow = 0;
871
            } else {
872
                newRow--;
873
                if (newRow<0)
874
                    newRow = maxcount-1;
875
            }
876
            TreePath path = tree.getPathForRow(newRow);
877
            node = (CheckNode) path.getLastPathComponent();
878
            if (!node.isLeaf()) {
879
                tree.expandRow(newRow);
880
                maxcount = tree.getRowCount();
881
            }
882
        }
883
        while (!node.isLeaf());
884
        tree.setSelectionRow(newRow);
885
        CheckNodeListener.findInSource(node);
886
    }
887
    
888
    private int getSelectedRow() {
889
        int[] rows = tree.getSelectionRows();
890
        if (rows == null || rows.length == 0)
891
            return 0;
892
        return rows[0];
893
    }
894
854
    ////////////////////////////////////////////////////////////////////////////
895
    ////////////////////////////////////////////////////////////////////////////
855
    // INNER CLASSES
896
    // INNER CLASSES
856
    ////////////////////////////////////////////////////////////////////////////
897
    ////////////////////////////////////////////////////////////////////////////
898
857
    private class ButtonL implements ActionListener {
899
    private class ButtonL implements ActionListener {
858
        public void actionPerformed(ActionEvent event) {
900
        public void actionPerformed(ActionEvent event) {
859
            Object o = event.getSource();
901
            Object o = event.getSource();
(-)refactoring/src/org/netbeans/modules/refactoring/ui/RefactoringPanelContainer.java (-3 / +42 lines)
Lines 16-25 Link Here
16
import java.awt.Image;
16
import java.awt.Image;
17
import java.awt.event.MouseEvent;
17
import java.awt.event.MouseEvent;
18
import java.beans.PropertyChangeListener;
18
import java.beans.PropertyChangeListener;
19
import java.text.MessageFormat;
19
import javax.swing.ActionMap;
20
import javax.swing.JLabel;
20
import javax.swing.JLabel;
21
import javax.swing.JPanel;
21
import javax.swing.JPanel;
22
import javax.swing.event.ChangeListener;
23
import org.openide.awt.MouseUtils;
22
import org.openide.awt.MouseUtils;
24
import org.openide.util.HelpCtx;
23
import org.openide.util.HelpCtx;
25
import org.openide.util.Utilities;
24
import org.openide.util.Utilities;
Lines 69-75 Link Here
69
        setFocusCycleRoot(true);
68
        setFocusCycleRoot(true);
70
        JLabel label = new JLabel(NbBundle.getMessage(RefactoringPanelContainer.class, "LBL_NoUsages"));
69
        JLabel label = new JLabel(NbBundle.getMessage(RefactoringPanelContainer.class, "LBL_NoUsages"));
71
        label.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
70
        label.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
72
        this.add(label, BorderLayout.CENTER);        
71
        this.add(label, BorderLayout.CENTER);
72
        initActions();
73
    }
73
    }
74
    
74
    
75
    void addPanel(JPanel panel) {
75
    void addPanel(JPanel panel) {
Lines 206-211 Link Here
206
    public int getPersistenceType() {
206
    public int getPersistenceType() {
207
        return PERSISTENCE_ALWAYS;
207
        return PERSISTENCE_ALWAYS;
208
    }
208
    }
209
    
210
    private void initActions() {
211
        ActionMap map = getActionMap();
212
213
        map.put("jumpNext", new PrevNextAction (false)); // NOI18N
214
        map.put("jumpPrev", new PrevNextAction (true)); // NOI18N
215
    }
216
    
217
    private RefactoringPanel getCurrentPanel() {
218
        Component comp = getComponent(0);
219
        if (comp instanceof JTabbedPane) {
220
            JTabbedPane tabs = (JTabbedPane) comp;
221
            return (RefactoringPanel) tabs.getSelectedComponent();
222
        } else {
223
            if (comp instanceof RefactoringPanel)
224
                return (RefactoringPanel) comp;
225
        }
226
        return null;
227
    }
228
    
229
    private final class PrevNextAction extends javax.swing.AbstractAction {
230
        private boolean prev;
231
        
232
        public PrevNextAction (boolean prev) {
233
            this.prev = prev;
234
        }
235
236
        public void actionPerformed (java.awt.event.ActionEvent actionEvent) {
237
            RefactoringPanel panel = getCurrentPanel();
238
            if (panel != null) {
239
                if (prev) {
240
                    panel.selectPrevUsage();
241
                } else {
242
                    panel.selectNextUsage(); 
243
                }
244
            }
245
        }
246
    }
247
    
209
    
248
    
210
    private class CloseListener implements PropertyChangeListener {
249
    private class CloseListener implements PropertyChangeListener {
211
        
250
        
(-)tasklist/arch/arch-tasklist-core.xml (-1 / +8 lines)
Lines 136-141 Link Here
136
        type="import"
136
        type="import"
137
        category="stable"
137
        category="stable"
138
        url="http://www.netbeans.org/download/dev/javadoc/OpenAPIs/"
138
        url="http://www.netbeans.org/download/dev/javadoc/OpenAPIs/"
139
        group="java"
139
    />
140
    />
140
    NetBeans OpenAPIs
141
    NetBeans OpenAPIs
141
</li>
142
</li>
Lines 145-150 Link Here
145
        type="import"
146
        type="import"
146
        category="private"
147
        category="private"
147
        url="http://www.netbeans.org/download/dev/javadoc/TaskListAPI/index.html"
148
        url="http://www.netbeans.org/download/dev/javadoc/TaskListAPI/index.html"
149
        group="java"
148
    />
150
    />
149
    Task List APIs
151
    Task List APIs
150
</li>
152
</li>
Lines 335-341 Link Here
335
        </question>
337
        </question>
336
-->
338
-->
337
<answer id="exec-component">
339
<answer id="exec-component">
338
No.
340
  <p>
341
    <api name="ActionMapKeys" category="stable" group="property" type="import" >
342
    the task list view defines <q>jumpNext</q> and <q>jumpPrev</q> action
343
    handlers in its <code>ActionMap</code>.
344
    </api>
345
  </p>
339
</answer>
346
</answer>
340
347
341
348
(-)tasklist/core/nbproject/project.xml (-1 / +1 lines)
Lines 24-30 Link Here
24
                    <compile-dependency/>
24
                    <compile-dependency/>
25
                    <run-dependency>
25
                    <run-dependency>
26
                        <release-version>1</release-version>
26
                        <release-version>1</release-version>
27
                        <specification-version>4.47</specification-version>
27
                        <specification-version>5.8</specification-version>
28
                    </run-dependency>
28
                    </run-dependency>
29
                </dependency>
29
                </dependency>
30
                <dependency>
30
                <dependency>
(-)tasklist/core/src/org/netbeans/modules/tasklist/core/TaskListView.java (-80 / +23 lines)
Lines 207-212 Link Here
207
            ExplorerUtils.actionPaste(manager));
207
            ExplorerUtils.actionPaste(manager));
208
        map.put("delete", ExplorerUtils.actionDelete(manager, true));  // NOI18N
208
        map.put("delete", ExplorerUtils.actionDelete(manager, true));  // NOI18N
209
209
210
        map.put("jumpNext", new PrevNextAction (false)); // NOI18N
211
        map.put("jumpPrev", new PrevNextAction (true)); // NOI18N
212
210
        // following line tells the top component which lookup should be associated with it
213
        // following line tells the top component which lookup should be associated with it
211
        associateLookup(ExplorerUtils.createLookup(manager, map));
214
        associateLookup(ExplorerUtils.createLookup(manager, map));
212
    }
215
    }
Lines 593-599 Link Here
593
        assert initialized : 
596
        assert initialized : 
594
            "#37438 dangling componentActivated event, no componentOpened()" + 
597
            "#37438 dangling componentActivated event, no componentOpened()" + 
595
            " called at " + this;
598
            " called at " + this;
596
        installJumpActions(true);
597
        ExplorerUtils.activateActions(manager, true);
599
        ExplorerUtils.activateActions(manager, true);
598
        RemoveFilterAction removeFilter =
600
        RemoveFilterAction removeFilter =
599
                (RemoveFilterAction) SystemAction.get(RemoveFilterAction.class);
601
                (RemoveFilterAction) SystemAction.get(RemoveFilterAction.class);
Lines 1360-1434 Link Here
1360
        return nodes;
1362
        return nodes;
1361
    }
1363
    }
1362
1364
1363
    private Class nextActionClz = null;
1364
    private Class prevActionClz = null;
1365
1366
    /**
1367
     * Assign the Next/Previous build actions to point to the
1368
     * task window
1369
     *
1370
     * @param install true = install, false = deinstall
1371
     */
1372
    private void installJumpActions(boolean install) {
1373
        // TODO - only install if the list is non empty (and call
1374
        // this method from SMI when the list becomes non-empty)
1375
        // In other words, the next action button shouldn't light
1376
        // up when there are no tasks to move to.
1377
1378
        // RFE #40185
1379
        // Make F12 jump to next task
1380
        if (nextActionClz == null) {
1381
            if (lookupAttempted) {
1382
                return;
1383
            }
1384
            lookupAttempted = true;
1385
            ClassLoader systemClassLoader = (ClassLoader) Lookup.getDefault().
1386
                    lookup(ClassLoader.class);
1387
            try {
1388
                nextActionClz = systemClassLoader.
1389
                        loadClass("org.netbeans.core.output2.NextOutJumpAction"); // NOI18N
1390
                prevActionClz = systemClassLoader.
1391
                        loadClass("org.netbeans.core.output2.PreviousOutJumpAction"); // NOI18N
1392
            } catch (Exception e) {
1393
                // Check if the old core/output is installed instead.
1394
                try {
1395
                    nextActionClz = systemClassLoader.
1396
                        loadClass("org.netbeans.core.output.NextOutJumpAction"); // NOI18N
1397
                    prevActionClz = systemClassLoader.
1398
                        loadClass("org.netbeans.core.output.PreviousOutJumpAction"); // NOI18N
1399
                } catch (Exception e2) {
1400
                    // Notify original error.
1401
                    ErrorManager.getDefault().notify(ErrorManager.INFORMATIONAL, e);
1402
                    return;
1403
                }
1404
            }
1405
        }
1406
1407
        CallbackSystemAction nextAction =
1408
                (CallbackSystemAction) SystemAction.get(nextActionClz);
1409
        CallbackSystemAction previousAction =
1410
                (CallbackSystemAction) SystemAction.get(prevActionClz);
1411
1412
        if (install) {
1413
            nextAction.setActionPerformer(new ActionPerformer() {
1414
                public void performAction(SystemAction action) {
1415
                    nextTask();
1416
                }
1417
            });
1418
            previousAction.setActionPerformer(new ActionPerformer() {
1419
                public void performAction(SystemAction action) {
1420
                    prevTask();
1421
                }
1422
            });
1423
1424
            nextCandidate = null;
1425
            prevCandidate = null;
1426
        } else {
1427
            nextAction.setActionPerformer(null);
1428
            previousAction.setActionPerformer(null);
1429
        }
1430
    }
1431
1432
    private boolean lookupAttempted = false;
1365
    private boolean lookupAttempted = false;
1433
1366
1434
    private static void invokeLater(Runnable runnable) {
1367
    private static void invokeLater(Runnable runnable) {
Lines 1695-1710 Link Here
1695
1628
1696
    protected void componentHidden() {
1629
    protected void componentHidden() {
1697
        hideTaskInEditor();
1630
        hideTaskInEditor();
1698
1699
        // Remove jump actions
1700
        // Cannot do this, because componentHidden can be called
1701
        // after another TaskListView is shown (for example when you
1702
        // switch from one tasklist view to another) so this would
1703
        // cripple the newly showing tasklist view.
1704
        //
1705
        // According to issue #37367 hidden and activated events works
1706
        // together smmothly to get desired result
1707
        installJumpActions(false);
1708
    }
1631
    }
1709
1632
1710
    /** Return true iff the given node is expanded */
1633
    /** Return true iff the given node is expanded */
Lines 1782-1786 Link Here
1782
            }
1705
            }
1783
        }
1706
        }
1784
        return (ColumnProperty[]) ret.toArray(new ColumnProperty[ret.size()]);
1707
        return (ColumnProperty[]) ret.toArray(new ColumnProperty[ret.size()]);
1708
    }
1709
    
1710
    /** Action to just to previous or next task.
1711
     */
1712
    private final class PrevNextAction extends javax.swing.AbstractAction {
1713
        private boolean prev;
1714
        
1715
        public PrevNextAction (boolean prev) {
1716
            this.prev = prev;
1717
        }
1718
1719
        public void actionPerformed (java.awt.event.ActionEvent actionEvent) {
1720
            if (prev) {
1721
                prevTask ();
1722
            } else {
1723
                nextTask ();
1724
            }
1725
        }
1726
        
1727
        
1785
    }
1728
    }
1786
}
1729
}

Return to bug 40185