5959import javax .swing .JLabel ;
6060import javax .swing .JPanel ;
6161import javax .swing .JPopupMenu ;
62+ import javax .swing .KeyStroke ;
6263import javax .swing .SwingConstants ;
6364import javax .swing .SwingUtilities ;
6465import javax .swing .UIManager ;
8283import org .openide .awt .ActionReference ;
8384import org .openide .awt .ActionReferences ;
8485import org .openide .awt .ActionRegistration ;
86+ import org .openide .awt .Actions ;
8587import org .openide .awt .StatusDisplayer ;
8688import org .openide .awt .UndoRedo ;
8789import org .openide .explorer .ExplorerManager ;
@@ -133,7 +135,7 @@ public class ProjectTab extends TopComponent
133135
134136 private static final Logger LOG = Logger .getLogger (ProjectTab .class .getName ());
135137
136- private static Map <String , ProjectTab > tabs = new HashMap <String , ProjectTab >();
138+ private static Map <String , ProjectTab > tabs = new HashMap <>();
137139
138140 private final transient ExplorerManager manager ;
139141 private transient Node rootNode ;
@@ -214,14 +216,29 @@ public ProjectTab() {
214216 public void setGroup (Group g ) {
215217 if (id .equals (ID_LOGICAL )) {
216218 if (g != null ) {
217- setName (NbBundle .getMessage (ProjectTab .class , "LBL_projectTabLogical_tc_with_group" , g .getName ()));
219+ setName (NbBundle .getMessage (ProjectTab .class , "LBL_projectTabLogical_tc_with_group" , g .getName ())); // NOI18N
220+ setToolTipText (NbBundle .getMessage (ProjectTab .class , "TT_projectTabLogical_tc_with_group" , g .getName (), getKeyStrokeString ())); // NOI18N
218221 } else {
219- setName (NbBundle .getMessage (ProjectTab .class , "LBL_projectTabLogical_tc" ));
222+ setName (NbBundle .getMessage (ProjectTab .class , "LBL_projectTabLogical_tc" )); // NOI18N
223+ setToolTipText (NbBundle .getMessage (ProjectTab .class , "TT_projectTabLogical_tc" , getKeyStrokeString ())); // NOI18N
220224 }
221225 } else {
222- setName (NbBundle .getMessage (ProjectTab .class , "LBL_projectTab_tc" ));
226+ setName (NbBundle .getMessage (ProjectTab .class , "LBL_projectTab_tc" )); // NOI18N
227+ if (g != null ) {
228+ setToolTipText (NbBundle .getMessage (ProjectTab .class , "TT_projectTab_tc_with_group" , g .getName (), getKeyStrokeString ())); // NOI18N
229+ } else {
230+ setToolTipText (NbBundle .getMessage (ProjectTab .class , "TT_projectTab_tc" , getKeyStrokeString ())); // NOI18N
231+ }
223232 }
224- // Seems to be useless: setToolTipText(getName());
233+ }
234+
235+ private String getKeyStrokeString () {
236+ Action action = id .equals (ID_LOGICAL )
237+ ? Actions .forID ("Window/SelectDocumentNode" , "org.netbeans.modules.project.ui.SelectInProjects" ) // NOI18N
238+ : Actions .forID ("Window/SelectDocumentNode" , "org.netbeans.modules.project.ui.SelectInFiles" ); // NOI18N
239+ return action != null && action .getValue (Action .ACCELERATOR_KEY ) instanceof KeyStroke ks
240+ ? Actions .keyStrokeToString (ks )
241+ : "" ; // NOI18N
225242 }
226243
227244 private void initValues () {
@@ -240,7 +257,7 @@ private void initValues() {
240257 }
241258 manager .setRootContext ( rootNode );
242259 }
243-
260+
244261 /** Explorer manager implementation
245262 */
246263 @ Override
@@ -386,7 +403,7 @@ public void writeExternal (ObjectOutput out) throws IOException {
386403 id = (String )in .readObject ();
387404 rootNode = ((Node .Handle )in .readObject ()).getNode ();
388405 final List <String []> exPaths = NbCollections .checkedListByCopy ((List <?>) in .readObject (), String [].class , true );
389- final List <String []> selPaths = new ArrayList <String [] >();
406+ final List <String []> selPaths = new ArrayList <>();
390407 try {
391408 selPaths .addAll (NbCollections .checkedListByCopy ((List <?>) in .readObject (), String [].class , true ));
392409 }
@@ -435,7 +452,7 @@ public void run() {
435452 LOG .log (Level .FINE , "{0}: expanding paths" , id );
436453 btv .expandNodes (exPaths );
437454 LOG .log (Level .FINE , "{0}: selecting paths" , id );
438- final List <Node > selectedNodes = new ArrayList <Node >();
455+ final List <Node > selectedNodes = new ArrayList <>();
439456 Node root = manager .getRootContext ();
440457 for (String [] sp : selPaths ) {
441458 LOG .log (Level .FINE , "{0}: selecting {1}" , new Object [] {id , Arrays .asList (sp )});
@@ -453,7 +470,7 @@ public void run() {
453470 EventQueue .invokeLater (new Runnable () {
454471 @ Override public void run () {
455472 try {
456- manager .setSelectedNodes (selectedNodes .toArray (new Node [0 ] ));
473+ manager .setSelectedNodes (selectedNodes .toArray (Node []:: new ));
457474 } catch (PropertyVetoException x ) {
458475 LOG .log (Level .FINE , null , x );
459476 }
@@ -649,7 +666,7 @@ void expandNode(Node node) {
649666 }
650667
651668 private List <String []> getSelectedPaths () {
652- List <String []> result = new ArrayList <String [] >();
669+ List <String []> result = new ArrayList <>();
653670 Node root = manager .getRootContext ();
654671 for (Node n : manager .getSelectedNodes ()) {
655672 String [] path = NodeOp .createPath (n , root );
@@ -728,7 +745,7 @@ public void run() {
728745
729746 public List <String []> getExpandedPaths () {
730747
731- List <String []> result = new ArrayList <String [] >();
748+ List <String []> result = new ArrayList <>();
732749
733750 TreeNode rtn = Visualizer .findVisualizer ( rootNode );
734751 TreePath tp = new TreePath ( rtn ); // Get the root
@@ -831,7 +848,7 @@ public void run() {
831848 // showing popup on right click in projects tab when label <No Project Open> is shown
832849 private class LabelPopupDisplayer extends MouseAdapter {
833850
834- private Component component ;
851+ private final Component component ;
835852
836853 public LabelPopupDisplayer (Component comp ) {
837854 component = comp ;
0 commit comments