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

(-)a/core.ui/manifest.mf (-1 / +1 lines)
Lines 4-8 Link Here
4
OpenIDE-Module-Layer: org/netbeans/core/ui/resources/layer.xml
4
OpenIDE-Module-Layer: org/netbeans/core/ui/resources/layer.xml
5
AutoUpdate-Show-In-Client: false
5
AutoUpdate-Show-In-Client: false
6
AutoUpdate-Essential-Module: true
6
AutoUpdate-Essential-Module: true
7
OpenIDE-Module-Specification-Version: 1.23
7
OpenIDE-Module-Specification-Version: 1.24
8
8
(-)a/core.ui/src/org/netbeans/core/ui/resources/layer.xml (+9 lines)
Lines 824-829 Link Here
824
824
825
    </folder>
825
    </folder>
826
826
827
    <folder name="Editors">
828
        <folder name="TabActions">
829
            <file name="org-openide-actions-FileSystemAction.shadow">
830
                <attr name="originalFile" stringvalue="Actions/System/org-openide-actions-FileSystemAction.instance"/>
831
                <attr name="position" intvalue="200"/>
832
            </file>
833
        </folder>
834
    </folder>
835
827
    <folder name="OptionsExport">
836
    <folder name="OptionsExport">
828
        <folder name="General">
837
        <folder name="General">
829
            <attr name="displayName" bundlevalue="org.netbeans.core.ui.options.general.Bundle#General.Options.Export.Category.displayName"/>
838
            <attr name="displayName" bundlevalue="org.netbeans.core.ui.options.general.Bundle#General.Options.Export.Category.displayName"/>
(-)a/diff/nbproject/project.properties (-1 / +1 lines)
Lines 43-49 Link Here
43
javac.compilerargs=-Xlint:unchecked
43
javac.compilerargs=-Xlint:unchecked
44
javac.source=1.6
44
javac.source=1.6
45
45
46
spec.version.base=1.29.0
46
spec.version.base=1.30.0
47
javadoc.apichanges=${basedir}/apichanges.xml
47
javadoc.apichanges=${basedir}/apichanges.xml
48
javadoc.arch=${basedir}/arch.xml
48
javadoc.arch=${basedir}/arch.xml
49
49
(-)a/diff/nbproject/project.xml (-1 / +1 lines)
Lines 238-244 Link Here
238
                    <build-prerequisite/>
238
                    <build-prerequisite/>
239
                    <compile-dependency/>
239
                    <compile-dependency/>
240
                    <run-dependency>
240
                    <run-dependency>
241
                        <specification-version>6.16</specification-version>
241
                        <specification-version>6.32</specification-version>
242
                    </run-dependency>
242
                    </run-dependency>
243
                </dependency>
243
                </dependency>
244
                <dependency>
244
                <dependency>
(-)a/diff/src/org/netbeans/modules/diff/mf-layer.xml (+6 lines)
Lines 83-88 Link Here
83
    <folder name="Editors">
83
    <folder name="Editors">
84
        <file name="org-netbeans-modules-diff-builtin-visualizer-editable-DiffHighlightsLayerFactory.instance"/>
84
        <file name="org-netbeans-modules-diff-builtin-visualizer-editable-DiffHighlightsLayerFactory.instance"/>
85
        <file name="org-netbeans-modules-merge-builtin-visualizer-MergeHighlightsLayerFactory.instance"/>
85
        <file name="org-netbeans-modules-merge-builtin-visualizer-MergeHighlightsLayerFactory.instance"/>
86
        <folder name="TabActions">
87
              <file name="org-netbeans-modules-diff-DiffAction.shadow">
88
                  <attr name="originalFile" stringvalue="Actions/Tools/org-netbeans-modules-diff-DiffAction.instance"/>
89
                  <attr name="position" intvalue="300"/>
90
              </file>
91
        </folder>
86
        <folder name="UpToDateStatusProvider">
92
        <folder name="UpToDateStatusProvider">
87
            <file name="org-netbeans-modules-diff-builtin-visualizer-editable-DiffMarkProviderCreator.instance">
93
            <file name="org-netbeans-modules-diff-builtin-visualizer-editable-DiffMarkProviderCreator.instance">
88
                <attr name="instanceClass" stringvalue="org.netbeans.modules.diff.builtin.visualizer.editable.DiffMarkProviderCreator"/>                                                               
94
                <attr name="instanceClass" stringvalue="org.netbeans.modules.diff.builtin.visualizer.editable.DiffMarkProviderCreator"/>                                                               
(-)a/editor/nbproject/project.properties (-1 / +1 lines)
Lines 42-48 Link Here
42
42
43
javac.compilerargs=-Xlint:unchecked
43
javac.compilerargs=-Xlint:unchecked
44
javac.source=1.6
44
javac.source=1.6
45
spec.version.base=1.51.0
45
spec.version.base=1.52.0
46
is.autoload=true
46
is.autoload=true
47
47
48
javadoc.arch=${basedir}/arch.xml
48
javadoc.arch=${basedir}/arch.xml
(-)a/editor/src/org/netbeans/modules/editor/Bundle.properties (-1 lines)
Lines 53-59 Link Here
53
Templates/Services/IndentEngine/org-netbeans-modules-editor-html-LineWrapIndentEngine.settings=Line Wrapping Indentation Engine
53
Templates/Services/IndentEngine/org-netbeans-modules-editor-html-LineWrapIndentEngine.settings=Line Wrapping Indentation Engine
54
Menu/Source=&Source
54
Menu/Source=&Source
55
Menu/View/CodeFolds=&Code Folds
55
Menu/View/CodeFolds=&Code Folds
56
Editors/text/base/Popup/org-netbeans-modules-editor-NbSelectInPopupAction.instance=Select in
57
56
58
MSG_NegativeValue=Negative value is not allowed
57
MSG_NegativeValue=Negative value is not allowed
59
MSG_OutOfRange=Value is out of range
58
MSG_OutOfRange=Value is out of range
(-)a/editor/src/org/netbeans/modules/editor/NbSelectInPopupAction.java (-139 lines)
Lines 1-139 Link Here
1
/*
2
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
3
 *
4
 * Copyright 1997-2010 Oracle and/or its affiliates. All rights reserved.
5
 *
6
 * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
7
 * Other names may be trademarks of their respective owners.
8
 *
9
 * The contents of this file are subject to the terms of either the GNU
10
 * General Public License Version 2 only ("GPL") or the Common
11
 * Development and Distribution License("CDDL") (collectively, the
12
 * "License"). You may not use this file except in compliance with the
13
 * License. You can obtain a copy of the License at
14
 * http://www.netbeans.org/cddl-gplv2.html
15
 * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
16
 * specific language governing permissions and limitations under the
17
 * License.  When distributing the software, include this License Header
18
 * Notice in each file and include the License file at
19
 * nbbuild/licenses/CDDL-GPL-2-CP.  Oracle designates this
20
 * particular file as subject to the "Classpath" exception as provided
21
 * by Oracle in the GPL Version 2 section of the License file that
22
 * accompanied this code. If applicable, add the following below the
23
 * License Header, with the fields enclosed by brackets [] replaced by
24
 * your own identifying information:
25
 * "Portions Copyrighted [year] [name of copyright owner]"
26
 *
27
 * Contributor(s):
28
 *
29
 * The Original Software is NetBeans. The Initial Developer of the Original
30
 * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
31
 * Microsystems, Inc. All Rights Reserved.
32
 *
33
 * If you wish your version of this file to be governed by only the CDDL
34
 * or only the GPL Version 2, indicate your decision by adding
35
 * "[Contributor] elects to include this software in this distribution
36
 * under the [CDDL or GPL Version 2] license." If you do not indicate a
37
 * single choice of license, a recipient has the option to distribute
38
 * your version of this file under either the CDDL, the GPL Version 2 or
39
 * to extend the choice of license to its licensees as provided above.
40
 * However, if you add GPL Version 2 code and therefore, elected the GPL
41
 * Version 2 license, then the option applies only if the new code is
42
 * made subject to such option by the copyright holder.
43
 */
44
package org.netbeans.modules.editor;
45
46
import java.awt.event.ActionEvent;
47
import java.io.IOException;
48
import java.util.ArrayList;
49
import javax.swing.Action;
50
import javax.swing.JMenu;
51
import javax.swing.JMenuItem;
52
import javax.swing.JPopupMenu;
53
import javax.swing.JSeparator;
54
55
import org.openide.cookies.InstanceCookie;
56
import org.openide.filesystems.FileObject;
57
import org.openide.filesystems.FileUtil;
58
import org.openide.loaders.DataFolder;
59
import org.openide.loaders.DataObject;
60
import org.openide.util.HelpCtx;
61
import org.openide.util.NbBundle;
62
import org.openide.util.actions.Presenter;
63
import org.openide.util.actions.SystemAction;
64
65
66
/**
67
 *
68
 * @author Dusan Balek
69
 */
70
public final class NbSelectInPopupAction extends SystemAction implements Presenter.Popup {
71
72
    private ArrayList actions = null;
73
74
    public String getName() {
75
        return NbBundle.getMessage(NbSelectInPopupAction.class, "Editors/text/base/Popup/org-netbeans-modules-editor-NbSelectInPopupAction.instance"); // NOI18N
76
    }
77
    
78
    public void actionPerformed(ActionEvent ev) {
79
        // do nothing - should never be called
80
    }
81
82
    public HelpCtx getHelpCtx() {
83
        return HelpCtx.DEFAULT_HELP;
84
    }
85
    
86
    public javax.swing.JMenuItem getPopupPresenter() {
87
        return new SubMenu(getName());
88
    }
89
90
    public class SubMenu extends JMenu {
91
92
        public SubMenu(String s){
93
            super(s);
94
        }
95
        
96
        /** Gets popup menu. Overrides superclass. Adds lazy menu items creation. */
97
        public JPopupMenu getPopupMenu() {
98
            JPopupMenu pm = super.getPopupMenu();
99
            pm.removeAll();
100
            FileObject fo = FileUtil.getConfigFile("Actions/Window/SelectDocumentNode"); // NOI18N
101
            DataFolder df = fo != null ? DataFolder.findFolder(fo) : null;
102
            
103
            if (df != null) {
104
                DataObject actionObjects[] = df.getChildren();
105
                for (int i = 0; i < actionObjects.length; i++) {
106
                    InstanceCookie ic = (InstanceCookie) actionObjects[i].getCookie(InstanceCookie.class);
107
                    if (ic == null) continue;
108
                    Object instance;
109
                    try {
110
                        instance = ic.instanceCreate();
111
                    } catch (IOException e) {
112
                        // ignore
113
                        e.printStackTrace();
114
                        continue;
115
                    } catch (ClassNotFoundException e) {
116
                        // ignore
117
                        e.printStackTrace();
118
                        continue;
119
                    }
120
                    if (instance instanceof JSeparator) {
121
                        pm.add((JSeparator) instance);
122
                    } else if (instance instanceof Presenter.Popup) {    
123
                        pm.add(((Presenter.Popup)instance).getPopupPresenter());
124
                    } else if (instance instanceof Presenter.Menu) {    
125
                        JMenuItem temp = ((Presenter.Menu)instance).getMenuPresenter();
126
                        temp.setIcon(null);
127
                        pm.add(temp);
128
                    } else if (instance instanceof Action) {                        
129
                        JMenuItem temp = new JMenuItem((Action)instance);
130
                        temp.setIcon(null);
131
                        pm.add(temp);
132
                    }
133
                }
134
            }
135
            pm.pack();
136
            return pm;
137
        }
138
    }
139
}
(-)a/editor/src/org/netbeans/modules/editor/resources/layer.xml (-1 / +2 lines)
Lines 249-255 Link Here
249
                <attr name="originalFile" stringvalue="Actions/Edit/org-openide-actions-CutAction.instance"/>
249
                <attr name="originalFile" stringvalue="Actions/Edit/org-openide-actions-CutAction.instance"/>
250
                <attr name="position" intvalue="2000"/>
250
                <attr name="position" intvalue="2000"/>
251
            </file>
251
            </file>
252
            <file name="org-netbeans-modules-editor-NbSelectInPopupAction.instance">
252
            <file name="org-netbeans-modules-project-ui-SelectInProjects.shadow">
253
                <attr name="originalFile" stringvalue="Actions/Window/SelectDocumentNode/org-netbeans-modules-project-ui-SelectInProjects.instance"/>
253
                <attr name="position" intvalue="9000"/>
254
                <attr name="position" intvalue="9000"/>
254
            </file>
255
            </file>
255
            <file name="org-openide-actions-PasteAction.shadow">
256
            <file name="org-openide-actions-PasteAction.shadow">
(-)a/favorites/manifest.mf (-1 / +1 lines)
Lines 1-7 Link Here
1
Manifest-Version: 1.0
1
Manifest-Version: 1.0
2
OpenIDE-Module: org.netbeans.modules.favorites/1
2
OpenIDE-Module: org.netbeans.modules.favorites/1
3
OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/favorites/Bundle.properties
3
OpenIDE-Module-Localizing-Bundle: org/netbeans/modules/favorites/Bundle.properties
4
OpenIDE-Module-Specification-Version: 1.21
4
OpenIDE-Module-Specification-Version: 1.22
5
OpenIDE-Module-Layer: org/netbeans/modules/favorites/resources/layer.xml
5
OpenIDE-Module-Layer: org/netbeans/modules/favorites/resources/layer.xml
6
AutoUpdate-Show-In-Client: false
6
AutoUpdate-Show-In-Client: false
7
AutoUpdate-Essential-Module: true
7
AutoUpdate-Essential-Module: true
(-)a/favorites/src/org/netbeans/modules/favorites/Actions.java (-9 lines)
Lines 58-64 Link Here
58
import javax.swing.Action;
58
import javax.swing.Action;
59
import javax.swing.ImageIcon;
59
import javax.swing.ImageIcon;
60
import javax.swing.JFileChooser;
60
import javax.swing.JFileChooser;
61
import javax.swing.JMenuItem;
62
import javax.swing.SwingUtilities;
61
import javax.swing.SwingUtilities;
63
import org.netbeans.modules.favorites.api.Favorites;
62
import org.netbeans.modules.favorites.api.Favorites;
64
import org.openide.DialogDisplayer;
63
import org.openide.DialogDisplayer;
Lines 169-182 Link Here
169
            return NbBundle.getMessage(Select.class, "ACT_Select_Main_Menu"); // NOI18N
168
            return NbBundle.getMessage(Select.class, "ACT_Select_Main_Menu"); // NOI18N
170
        }
169
        }
171
170
172
        /** Overriden to have different title in popup menu, works but ugly a bit */
173
        @Override
174
        public JMenuItem getPopupPresenter() {
175
            JMenuItem mi = super.getPopupPresenter();
176
            mi.setText(NbBundle.getMessage(Select.class, "ACT_Select")); // NOI18N
177
            return mi;
178
        }
179
180
        @Override
171
        @Override
181
        protected String iconResource() {
172
        protected String iconResource() {
182
            return "org/netbeans/modules/favorites/resources/actionView.png"; // NOI18N
173
            return "org/netbeans/modules/favorites/resources/actionView.png"; // NOI18N
(-)a/favorites/src/org/netbeans/modules/favorites/Bundle.properties (-1 lines)
Lines 44-50 Link Here
44
ACT_AddOnFavoritesNode=&Add to Favorites...
44
ACT_AddOnFavoritesNode=&Add to Favorites...
45
ACT_Remove=&Remove from Favorites
45
ACT_Remove=&Remove from Favorites
46
ACT_View=Favor&ites
46
ACT_View=Favor&ites
47
ACT_Select=Favorites
48
ACT_Select_Main_Menu=Select in F&avorites
47
ACT_Select_Main_Menu=Select in F&avorites
49
48
50
Favorites=Favorites
49
Favorites=Favorites
(-)a/openide.text/apichanges.xml (+15 lines)
Lines 49-54 Link Here
49
<apidef name="text">Text API</apidef>
49
<apidef name="text">Text API</apidef>
50
</apidefs>
50
</apidefs>
51
<changes>
51
<changes>
52
    <change id="Editors-TabActions">
53
        <api name="text"/>
54
        <summary>Ability to inject actions into editor tab context menus</summary>
55
        <version major="6" minor="32"/>
56
        <date day="16" month="8" year="2010"/>
57
        <author login="jglick"/>
58
        <compatibility addition="yes"/>
59
        <description>
60
            <p>
61
                Actions may now be placed in <code>Editors/TabActions</code> to add
62
                them to the context menu of the tab of an editor window.
63
            </p>
64
        </description>
65
        <issue number="189320"/>
66
    </change>
52
    <change id="NbDocument-style-constants-deprecated">
67
    <change id="NbDocument-style-constants-deprecated">
53
        <api name="text"/>
68
        <api name="text"/>
54
        <summary>Deprecating style constants in NbDocument</summary>
69
        <summary>Deprecating style constants in NbDocument</summary>
(-)a/openide.text/arch.xml (-1 / +3 lines)
Lines 765-771 Link Here
765
        </question>
765
        </question>
766
-->
766
-->
767
<answer id="resources-read">
767
<answer id="resources-read">
768
No.
768
<api type="export" category="devel" group="layer" name="Editors-TabActions">
769
    Actions for the editor tab (window) context menu can be injected into <code>Editors/TabActions</code>.
770
</api>
769
</answer>
771
</answer>
770
772
771
<!--
773
<!--
(-)a/openide.text/manifest.mf (-1 / +1 lines)
Lines 1-7 Link Here
1
Manifest-Version: 1.0
1
Manifest-Version: 1.0
2
OpenIDE-Module: org.openide.text
2
OpenIDE-Module: org.openide.text
3
OpenIDE-Module-Install: org/netbeans/modules/openide/text/Installer.class
3
OpenIDE-Module-Install: org/netbeans/modules/openide/text/Installer.class
4
OpenIDE-Module-Specification-Version: 6.31
4
OpenIDE-Module-Specification-Version: 6.32
5
OpenIDE-Module-Localizing-Bundle: org/openide/text/Bundle.properties
5
OpenIDE-Module-Localizing-Bundle: org/openide/text/Bundle.properties
6
AutoUpdate-Essential-Module: true
6
AutoUpdate-Essential-Module: true
7
7
(-)a/openide.text/src/org/openide/text/CloneableEditor.java (-28 / +10 lines)
Lines 53-58 Link Here
53
import java.awt.event.ActionListener;
53
import java.awt.event.ActionListener;
54
import java.io.*;
54
import java.io.*;
55
import java.util.ArrayList;
55
import java.util.ArrayList;
56
import java.util.Arrays;
56
import java.util.Collections;
57
import java.util.Collections;
57
import java.util.List;
58
import java.util.List;
58
import java.util.concurrent.Callable;
59
import java.util.concurrent.Callable;
Lines 61-74 Link Here
61
import javax.swing.*;
62
import javax.swing.*;
62
import javax.swing.border.Border;
63
import javax.swing.border.Border;
63
import javax.swing.border.EmptyBorder;
64
import javax.swing.border.EmptyBorder;
64
import javax.swing.text.*;
65
import javax.swing.text.Caret;
66
import javax.swing.text.DefaultEditorKit;
67
import javax.swing.text.Document;
68
import javax.swing.text.EditorKit;
65
import org.netbeans.modules.openide.text.Installer;
69
import org.netbeans.modules.openide.text.Installer;
66
import org.openide.DialogDisplayer;
70
import org.openide.DialogDisplayer;
67
import org.openide.NotifyDescriptor;
71
import org.openide.NotifyDescriptor;
68
import org.openide.awt.UndoRedo;
72
import org.openide.awt.UndoRedo;
69
import org.openide.cookies.EditorCookie;
73
import org.openide.cookies.EditorCookie;
70
import org.openide.util.*;
74
import org.openide.util.*;
71
import org.openide.util.actions.SystemAction;
72
import org.openide.windows.*;
75
import org.openide.windows.*;
73
76
74
/** Cloneable top component to hold the editor kit.
77
/** Cloneable top component to hold the editor kit.
Lines 879-910 Link Here
879
882
880
    @Override
883
    @Override
881
    public Action[] getActions() {
884
    public Action[] getActions() {
882
        Action[] a = super.getActions();
885
        List<Action> actions = new ArrayList<Action>(Arrays.asList(super.getActions()));
883
886
        // XXX might be nice to use MimeLookup for type-specific actions, but this seems to provide no way to only look in a subfolder
884
        try {
887
        actions.add(null);
885
            ClassLoader l = Lookup.getDefault().lookup(ClassLoader.class);
888
        actions.addAll(Utilities.actionsForPath("Editors/TabActions"));
886
889
        return actions.toArray(new Action[actions.size()]);
887
            if (l == null) {
888
                l = getClass().getClassLoader();
889
            }
890
891
            Class<? extends SystemAction> c = Class.forName("org.openide.actions.FileSystemAction", true, l).asSubclass(SystemAction.class); // NOI18N
892
            SystemAction ra = SystemAction.findObject(c, true);
893
894
            Class<? extends SystemAction> c2 = Class.forName("org.netbeans.modules.diff.DiffAction", true, l).asSubclass(SystemAction.class); // NOI18N
895
            SystemAction ra2 = SystemAction.findObject(c2, true);           
896
            
897
            Action[] a2 = new Action[a.length + 2];
898
            System.arraycopy(a, 0, a2, 0, a.length);
899
            a2[a.length] = ra;
900
            a2[a.length + 1] = ra2;
901
902
            return a2;
903
        } catch (Exception ex) {
904
            // ok, we no action like this I guess
905
        }
906
907
        return a;
908
    }
890
    }
909
891
910
    /** Transfer the focus to the editor pane.
892
    /** Transfer the focus to the editor pane.
(-)a/projectui/nbproject/project.properties (-1 / +1 lines)
Lines 42-48 Link Here
42
42
43
javac.compilerargs=-Xlint:unchecked
43
javac.compilerargs=-Xlint:unchecked
44
javac.source=1.6
44
javac.source=1.6
45
spec.version.base=1.22.0
45
spec.version.base=1.23.0
46
46
47
javadoc.arch=${basedir}/arch.xml
47
javadoc.arch=${basedir}/arch.xml
48
javadoc.apichanges=${basedir}/apichanges.xml
48
javadoc.apichanges=${basedir}/apichanges.xml
(-)a/projectui/nbproject/project.xml (-1 / +1 lines)
Lines 180-186 Link Here
180
                    <build-prerequisite/>
180
                    <build-prerequisite/>
181
                    <compile-dependency/>
181
                    <compile-dependency/>
182
                    <run-dependency>
182
                    <run-dependency>
183
                        <specification-version>6.16</specification-version>
183
                        <specification-version>6.32</specification-version>
184
                    </run-dependency>
184
                    </run-dependency>
185
                </dependency>
185
                </dependency>
186
                <dependency>
186
                <dependency>
(-)a/projectui/src/org/netbeans/modules/project/ui/actions/Bundle.properties (-4 lines)
Lines 62-71 Link Here
62
MNE_RecentProjectsAction_Name=j
62
MNE_RecentProjectsAction_Name=j
63
LBL_SaveProjectAction_Name=Save Project
63
LBL_SaveProjectAction_Name=Save Project
64
LBL_SetAsMainProjectAction_Name=Set as Main Project
64
LBL_SetAsMainProjectAction_Name=Set as Main Project
65
LBL_SelectInProjectsAction_Name=Select Node in Projects
66
LBL_SelectInFilesAction_Name=Select Node in Files
67
LBL_SelectInProjectsAction_MenuName=Projects
68
LBL_SelectInFilesAction_MenuName=Files
69
LBL_SelectInProjectsAction_MainMenuName=Select in Pro&jects
65
LBL_SelectInProjectsAction_MainMenuName=Select in Pro&jects
70
LBL_SelectInFilesAction_MainMenuName=Sele&ct in Files
66
LBL_SelectInFilesAction_MainMenuName=Sele&ct in Files
71
67
(-)a/projectui/src/org/netbeans/modules/project/ui/actions/SelectNodeAction.java (-76 / +3 lines)
Lines 46-84 Link Here
46
46
47
import javax.swing.Action;
47
import javax.swing.Action;
48
import javax.swing.Icon;
48
import javax.swing.Icon;
49
import javax.swing.JMenuItem;
50
import org.netbeans.api.project.Project;
51
import org.netbeans.modules.project.ui.ProjectTab;
49
import org.netbeans.modules.project.ui.ProjectTab;
52
import org.netbeans.spi.project.ui.support.ProjectActionPerformer;
53
import org.openide.awt.Mnemonics;
54
import org.openide.filesystems.FileObject;
50
import org.openide.filesystems.FileObject;
55
import org.openide.loaders.DataObject;
51
import org.openide.loaders.DataObject;
56
import org.openide.util.ImageUtilities;
52
import org.openide.util.ImageUtilities;
57
import org.openide.util.Lookup;
53
import org.openide.util.Lookup;
58
import org.openide.util.NbBundle;
54
import org.openide.util.NbBundle;
59
import org.openide.util.actions.Presenter;
60
55
61
/** Action sensitive to current project
56
public class SelectNodeAction extends LookupSensitiveAction {
62
 * 
63
 * @author Pet Hrebejk 
64
 */
65
public class SelectNodeAction extends LookupSensitiveAction implements Presenter.Menu, Presenter.Popup {
66
    
57
    
67
    // XXX Better icons
68
    private static final Icon SELECT_IN_PROJECTS_ICON = ImageUtilities.loadImageIcon("org/netbeans/modules/project/ui/resources/projectTab.png", false); //NOI18N
58
    private static final Icon SELECT_IN_PROJECTS_ICON = ImageUtilities.loadImageIcon("org/netbeans/modules/project/ui/resources/projectTab.png", false); //NOI18N
69
    private static final Icon SELECT_IN_FILES_ICON = ImageUtilities.loadImageIcon("org/netbeans/modules/project/ui/resources/filesTab.png", false); //NOI18N
59
    private static final Icon SELECT_IN_FILES_ICON = ImageUtilities.loadImageIcon("org/netbeans/modules/project/ui/resources/filesTab.png", false); //NOI18N
70
    
60
    
71
    private static final String SELECT_IN_PROJECTS_NAME = NbBundle.getMessage( CloseProject.class, "LBL_SelectInProjectsAction_Name" ); // NOI18N
61
    private static final String SELECT_IN_PROJECTS_NAME = NbBundle.getMessage(CloseProject.class, "LBL_SelectInProjectsAction_MainMenuName"); // NOI18N
72
    private static final String SELECT_IN_FILES_NAME = NbBundle.getMessage( CloseProject.class, "LBL_SelectInFilesAction_Name" ); // NOI18N
62
    private static final String SELECT_IN_FILES_NAME = NbBundle.getMessage(CloseProject.class, "LBL_SelectInFilesAction_MainMenuName"); // NOI18N
73
    
74
    private static final String SELECT_IN_PROJECTS_NAME_MENU = NbBundle.getMessage( CloseProject.class, "LBL_SelectInProjectsAction_MenuName" ); // NOI18N
75
    private static final String SELECT_IN_FILES_NAME_MENU = NbBundle.getMessage( CloseProject.class, "LBL_SelectInFilesAction_MenuName" ); // NOI18N
76
    private static final String SELECT_IN_PROJECTS_NAME_MAIN_MENU = NbBundle.getMessage( CloseProject.class, "LBL_SelectInProjectsAction_MainMenuName" ); // NOI18N
77
    private static final String SELECT_IN_FILES_NAME_MAIN_MENU = NbBundle.getMessage( CloseProject.class, "LBL_SelectInFilesAction_MainMenuName" ); // NOI18N
78
    
79
    private String command;
80
    private ProjectActionPerformer performer;
81
    private String namePattern;
82
    
63
    
83
    private String findIn;
64
    private String findIn;
84
    
65
    
Lines 100-110 Link Here
100
        return a;
81
        return a;
101
    }
82
    }
102
    
83
    
103
    /** 
104
     * Constructor for global actions. E.g. actions in main menu which 
105
     * listen to the global context.
106
     *
107
     */
108
    public SelectNodeAction( Icon icon, String name ) {
84
    public SelectNodeAction( Icon icon, String name ) {
109
        this(icon, name, null);
85
        this(icon, name, null);
110
    }
86
    }
Lines 112-128 Link Here
112
        super( icon, lookup, new Class[] { DataObject.class, FileObject.class } );
88
        super( icon, lookup, new Class[] { DataObject.class, FileObject.class } );
113
        this.setDisplayName( name );
89
        this.setDisplayName( name );
114
    }
90
    }
115
    
116
    private SelectNodeAction(String command, ProjectActionPerformer performer, String namePattern, Icon icon, Lookup lookup) {
117
        super( icon, lookup, new Class[] { Project.class, DataObject.class, FileObject.class } );
118
        this.command = command;
119
        this.performer = performer;
120
        this.namePattern = namePattern;
121
        refresh(getLookup(), true);
122
    }
123
       
91
       
124
    protected void actionPerformed( Lookup context ) {
92
    protected void actionPerformed( Lookup context ) {
125
        
126
        FileObject fo = getFileFromLookup( context );
93
        FileObject fo = getFileFromLookup( context );
127
        if ( fo != null ) {
94
        if ( fo != null ) {
128
            ProjectTab pt  = ProjectTab.findDefault( findIn );      
95
            ProjectTab pt  = ProjectTab.findDefault( findIn );      
Lines 135-171 Link Here
135
        setEnabled( fo != null );        
102
        setEnabled( fo != null );        
136
    }
103
    }
137
    
104
    
138
    protected final String getCommand() {
139
        return command;
140
    }
141
    
142
    protected final String getNamePattern() {
143
        return namePattern;
144
    }
145
    
146
    // Presenter.Menu implementation ------------------------------------------
147
    
148
    public JMenuItem getMenuPresenter () {
149
        if (ProjectTab.ID_LOGICAL.equals (this.findIn)) {
150
            return buildPresenter(SELECT_IN_PROJECTS_NAME_MAIN_MENU);
151
        } else {
152
            return buildPresenter(SELECT_IN_FILES_NAME_MAIN_MENU);
153
        }
154
    }
155
156
    // Presenter.Popup implementation ------------------------------------------
157
    
158
    public JMenuItem getPopupPresenter() {
159
        if (ProjectTab.ID_LOGICAL.equals (this.findIn)) {
160
            return buildPresenter(SELECT_IN_PROJECTS_NAME_MENU);
161
        } else {
162
            return buildPresenter(SELECT_IN_FILES_NAME_MENU);
163
        }
164
    }
165
166
    
167
   // Private methods ---------------------------------------------------------
168
    
169
    private FileObject getFileFromLookup( Lookup context ) {
105
    private FileObject getFileFromLookup( Lookup context ) {
170
   
106
   
171
        FileObject fo = context.lookup(FileObject.class);     
107
        FileObject fo = context.lookup(FileObject.class);     
Lines 178-190 Link Here
178
        return dobj == null ? null : dobj.getPrimaryFile();
114
        return dobj == null ? null : dobj.getPrimaryFile();
179
    }
115
    }
180
    
116
    
181
    private JMenuItem buildPresenter (String title) {
182
        JMenuItem menuPresenter = new JMenuItem (this);
183
        Mnemonics.setLocalizedText(menuPresenter, title);
184
        menuPresenter.setIcon(null);
185
        
186
        return menuPresenter;
187
    }
188
189
    
190
}
117
}
(-)a/projectui/src/org/netbeans/modules/project/ui/resources/layer.xml (-9 / +7 lines)
Lines 186-206 Link Here
186
        <folder name="Window">
186
        <folder name="Window">
187
            <folder name="SelectDocumentNode">
187
            <folder name="SelectDocumentNode">
188
                <attr name="SystemFileSystem.localizingBundle" stringvalue="org.netbeans.modules.project.ui.Bundle"/>
188
                <attr name="SystemFileSystem.localizingBundle" stringvalue="org.netbeans.modules.project.ui.Bundle"/>
189
                <!-- Searching nodes in projects/files tab -->
190
                
191
                <file name="org-netbeans-modules-project-ui-SelectInProjects.instance">
189
                <file name="org-netbeans-modules-project-ui-SelectInProjects.instance">
192
                    <attr name="instanceCreate" methodvalue="org.netbeans.modules.project.ui.actions.SelectNodeAction.inProjects"/>
190
                    <attr name="instanceCreate" methodvalue="org.netbeans.modules.project.ui.actions.SelectNodeAction.inProjects"/>
193
                    <attr name="position" intvalue="100"/>
194
                </file>
191
                </file>
195
196
                
197
                
198
                <file name="org-netbeans-modules-project-ui-SelectInFiles.instance">
192
                <file name="org-netbeans-modules-project-ui-SelectInFiles.instance">
199
                    <attr name="instanceCreate" methodvalue="org.netbeans.modules.project.ui.actions.SelectNodeAction.inFiles"/>
193
                    <attr name="instanceCreate" methodvalue="org.netbeans.modules.project.ui.actions.SelectNodeAction.inFiles"/>
200
                    <attr name="position" intvalue="200"/>
201
                </file>
194
                </file>
202
                
195
            </folder>
203
                </folder>
204
        </folder>
196
        </folder>
205
        
197
        
206
    </folder>
198
    </folder>
Lines 581-586 Link Here
581
                    </folder>
573
                    </folder>
582
            </folder>
574
            </folder>
583
        </folder>
575
        </folder>
576
        <folder name="TabActions">
577
            <file name="org-netbeans-modules-project-ui-SelectInProjects.shadow">
578
                <attr name="originalFile" stringvalue="Actions/Window/SelectDocumentNode/org-netbeans-modules-project-ui-SelectInProjects.instance"/>
579
                <attr name="position" intvalue="100"/>
580
            </file>
581
        </folder>
584
    </folder>
582
    </folder>
585
    
583
    
586
    <folder name="Loaders">
584
    <folder name="Loaders">

Return to bug 189320