Example usage for javax.swing Action getClass

List of usage examples for javax.swing Action getClass

Introduction

In this page you can find the example usage for javax.swing Action getClass.

Prototype

@HotSpotIntrinsicCandidate
public final native Class<?> getClass();

Source Link

Document

Returns the runtime class of this Object .

Usage

From source file:com.willwinder.ugs.nbp.lib.services.ActionRegistrationService.java

/**
 * Registers an action with the platform along with optional shortcuts and
 * menu items.//from  ww w . j av a 2 s  .c o m
 *
 * @param id The unique id of the action
 * @param name Display name of the action.
 * @param category Category in the Keymap tool.
 * @param shortcut Default shortcut, use an empty string or null for none.
 * @param menuPath Menu location starting with "Menu", like "Menu/Head/Hats"
 * @param localMenu Localized menu location starting with "Menu", like "Menu/Cabeza/Sombreros"
 * @param action an action object to attach to the action entry.
 * @throws IOException 
 */
public void registerAction(String id, String name, String category, String localCategory, String shortcut,
        String menuPath, String localMenu, Action action) throws IOException {
    ///////////////////////
    // Add/Update Action //
    ///////////////////////
    String originalFile = "Actions/" + category + "/" + id + ".instance";
    FileObject root = FileUtil.getConfigRoot();
    FileObject in = FileUtil.createFolder(root, "Actions/" + category);
    //in.setAttribute("displayName", localCategory);
    //in.setAttribute("SystemFileSystem.localizingBundle", localCategory + "lkhaglk");
    //in.setAttribute("SystemFileSystem.localizingBundle", localCategory);
    in.refresh();

    FileObject obj = in.getFileObject(id, "instance");
    if (obj == null) {
        obj = in.createData(id, "instance");
    }
    action.putValue(Action.NAME, name);
    obj.setAttribute("instanceCreate", action);
    obj.setAttribute("instanceClass", action.getClass().getName());

    /////////////////////
    // Add/Update Menu //
    /////////////////////
    if (StringUtils.isNotEmpty(menuPath) && StringUtils.isNotEmpty(id)) {
        in = createAndLocalizeFullMenu(menuPath, localMenu);

        obj = in.getFileObject(id, SHADOW);
        // Create if missing.
        if (obj == null) {
            obj = in.createData(id, SHADOW);
            obj.setAttribute("originalFile", originalFile);
        }
    }

    /////////////////////////
    // Add/Update Shortcut //
    /////////////////////////
    if (shortcut != null && shortcut.length() > 0) {
        in = FileUtil.createFolder(root, "Shortcuts");
        obj = in.getFileObject(shortcut, SHADOW);
        if (obj == null) {
            obj = in.createData(shortcut, SHADOW);
            obj.setAttribute("originalFile", originalFile);
        }
    }
}

From source file:org.pentaho.reporting.designer.core.xul.ActionSwingMenuitem.java

public void setAction(final Action action) {
    if (this.action != null) {
        this.action.removePropertyChangeListener(actionChangeHandler);
        uninstallAction(this.action);
    }//w  w w  .  j  a va2s .c  o m
    if (action != null) {
        this.actionClass = action.getClass().getName();
        this.action = action;
    } else {
        this.actionClass = null;
        this.action = null;
    }
    if (this.action != null) {
        this.action.addPropertyChangeListener(actionChangeHandler);
        installAction(this.action);
    }
}