Archive

Posts Tagged ‘Action’

Toolbar buttons with label

2012-04-16 6 comments

As default, any action in a NetBeans toolbar is displayed with an icon only. If you want to show also a label for a desired action you have to implement a Presenter.TOOLBAR. If you don’t want do this for each action, register a custom org.openide.awt.Actions.ButtonActionConnector like this:

/**
 * @see org.openide.awt.Actions#connect(AbstractButton, Action)
 */
@ServiceProvider(service = ButtonActionConnector.class, position = 100)
public class MyButtonActionConnector implements ButtonActionConnector {

   @Override
   public boolean connect(AbstractButton button, Action action) {
      String text = (String)action.getValue("menuText"); // NOI18N
      if (text != null) {
         button.setAction(action);
         button.setText(Actions.cutAmpersand(text));
         String desc = (String)action.getValue(Action.SHORT_DESCRIPTION);
         if (desc != null) {
            button.setToolTipText(desc);
         } else {
            button.setToolTipText((String)action.getValue(Action.NAME));
         }
         return true;
      }
      return false;
   }

   @Override
   public boolean connect(JMenuItem item, Action action, boolean popup) {
      return false; // use default implementation
   }
}

If the property menuText is set, the the button is configured with icon and text. The basic use of the menuText Property is (copied from @ActionRegistration‘s javadoc):

Provides the JMenuItem text if one wants to use other than the name of the action returned by ActionRegistration.displayName().

With the custom ButtonActionConnector this property is “extended” to show a toolbar button text if supplied.

Provide a value for the @ActionRegistration’s menuText Attribute for the desired action(s):

@ActionRegistration(displayName = "#CTL_PwdChangeAction",
                    menuText = "#CTL_PwdChangeAction",
                    iconBase = "resources/key.png")
@ActionReference(path = "Toolbars/User")
@Messages("CTL_PwdChangeAction=Change Password…")
public final class PwdChangeAction implements ActionListener {
   ...
}

Result:

or

Tested with NetBeans 7.1.1 (see comments)

CoolEditorActions V1.1.19 released

2012-02-6 7 comments

This is a minor update of the CoolEditorActions NetBeans Plugin and includes the following changes:

New and noteworthy in V1.1.19

  • Update Center integration
  • Added new actions to the Project folder sub menu:
    CoolEditorActions Popup Menu
  • The “Open in System” behavior can be configured in the new Options Panel:
  • The NetBeans Default implementation of “Open in System” depends on the Java Desktop API. On the SunOS and Linux Platforms, this API is dependent on Gnome libraries. If those libraries are unavailable, the Desktop API is not available. But now you can define Custom Commands for opening files and folders! The Command of the general File Type “file” is used if no special command is set to the specific MIME Type of a file.

The Plugin is compatible with NetBeans 7.1 and can be downloaded from here:

Categories: Java, NetBeans Tags: , , ,

CoolEditorActions V1.0.5 released

I’ve been updated my CoolEditorActions NetBeans Plugin which is now compatible with NetBeans 7.1.

Other improvements:

  • The Button’s Popup Menu is lazy loaded
  • Improved Open & Select Project action
  • Added Close Project action
  • minor bug fixes

The Plugin can be downloaded from here:

Categories: Java, NetBeans Tags: , , ,

New plugin CoolEditorActions released

Today I released the first version of the CoolEditorActions NetBeans plugin. This plugin adds a drop down button to the editor’s toolbar. From the popup menu, some useful actions are available for all the file path objects:

The plugin can be downloaded from the Kenai Project site. Feel free to write me some feedback!

I will submit this plugin in the next few days also to the NetBeans Plugin Portal.

Categories: Java, NetBeans Tags: , , ,
Follow

Get every new post delivered to your Inbox.