|
What this is
Other links
The source code/* * Sun Public License Notice * * The contents of this file are subject to the Sun Public License * Version 1.0 (the "License"). You may not use this file except in * compliance with the License. A copy of the License is available at * http://www.sun.com/ * * The Original Code is NetBeans. The Initial Developer of the Original * Code is Sun Microsystems, Inc. Portions Copyright 1997-2003 Sun * Microsystems, Inc. All Rights Reserved. */ package org.netbeans.modules.java.ui.actions; import java.util.Arrays; import java.util.ResourceBundle; import java.awt.BorderLayout; import javax.swing.JLabel; import javax.swing.JPanel; import org.openide.cookies.SourceCookie; import org.openide.nodes.Node; import org.openide.explorer.ExplorerManager; import org.openide.util.HelpCtx; import org.openide.util.NbBundle; import org.openide.util.actions.CookieAction; import org.netbeans.modules.java.ui.NavigationView; /** * * @author sdedic * @version */ public class NavigateAction extends CookieAction { /** * Cookies required for this action to be activated. */ private static final Class[] REQUIRED_COOKIES = new Class[] { SourceCookie.Editor.class }; /* package private */ static String getString(String key) { return NbBundle.getMessage(NavigateAction.class, key); } public HelpCtx getHelpCtx() { return null; } /** * Return the display name for the action. */ public String getName() { return getString("LAB_NavigateAction"); // NOI18N } /** * The action accepts only one node with a java source on it. */ protected int mode() { return MODE_EXACTLY_ONE; } protected Class[] cookieClasses() { return REQUIRED_COOKIES; } /** * performAction will activate the associated choice navigation component. */ protected void performAction(Node[] activatedNodes) { // PENDING: activate the presenter -- what presenter ?? } public java.awt.Component getToolbarPresenter() { java.awt.Component c = new ToolbarPresenter(); return c; } private static class ToolbarPresenter extends JPanel implements ExplorerManager.Provider { private static final int FIXED_WIDTH = 220; NavigationView explorerView; JLabel comboLabel; ExplorerManager manager; ToolbarPresenter() { initComponents(); } public void addNotify() { if (manager == null) manager = ExplorerManager.find(this); super.addNotify(); } public ExplorerManager getExplorerManager() { return manager; } private void initComponents() { setLayout(new BorderLayout(12, 0)); explorerView = new NavigationView(); explorerView.setMaximumRowCount(15); char mnemChar = NavigateAction.getString("LAB_NavigationList_Mnem").charAt(0); explorerView.setToolTipText(NavigateAction.getString("HINT_NavigationList") + " (Alt+" + mnemChar + ')'); // NOI18N comboLabel = new JLabel(); // comboLabel.setText(NavigateAction.getString("LAB_NavigationList")); comboLabel.setDisplayedMnemonic(mnemChar); // comboLabel.setToolTipText(NavigateAction.getString("HINT_NavigationList")); comboLabel.setLabelFor(explorerView); add(explorerView, BorderLayout.CENTER); add(comboLabel, BorderLayout.WEST); } public java.awt.Dimension getMinimumSize() { // minimum width to prevent excessive horizontal shrinking return new java.awt.Dimension(FIXED_WIDTH, getPreferredSize().height); } public java.awt.Dimension getMaximumSize() { // minimum width to prevent moving of the remaining contents of the toolbar return new java.awt.Dimension(FIXED_WIDTH, getPreferredSize().height); } } } |
... this post is sponsored by my books ... | |
#1 New Release! |
FP Best Seller |
Copyright 1998-2021 Alvin Alexander, alvinalexander.com
All Rights Reserved.
A percentage of advertising revenue from
pages under the /java/jwarehouse
URI on this website is
paid back to open source projects.