Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/*
* Copyright (C) 2024 PekinSOFT Systems
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*
* *****************************************************************************
* Project : application-framework-api
* Class : ActionMapX.java
* Author : Sean Carrick
* Created : Jul 13, 2024
* Modified : Jul 13, 2024
*
* Purpose: See class JavaDoc for explanation
*
* Revision History:
*
* WHEN BY REASON
* ------------ ------------------- -----------------------------------------
* Jul 13, 2024 Sean Carrick Initial creation.
* *****************************************************************************
*/
package com.pekinsoft.framework;
import com.pekinsoft.api.Targetable;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.lang.System.Logger;
import java.lang.System.Logger.Level;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.*;
import javax.swing.Action;
import javax.swing.ActionMap;
/**
* {@code ActionMapX} is an extension of the
* {@link javax.swing.ActionMap ActionMap} that has been created to play nicely
* within the context of an Application Framework application, and with the
* {@link ActionX} actions.
*
* @author Sean Carrick <sean at pekinsoft dot com>
*
* @version 1.0
* @since 1.0
*/
public class ActionMapX extends ActionMap {
public ActionMapX(ApplicationContext context, Class actionsClass,
Object actionsObject, ResourceMap resourceMap) {
Objects.requireNonNull(context, "null ApplicationContext");
Objects.requireNonNull(actionsClass, "null actionsClass");
Objects.requireNonNull(actionsObject, "null actionsObject");
if (!(actionsClass.isInstance(actionsObject))) {
throw new IllegalArgumentException(
"actionsObject not an instance of "
+ "actionsClass");
}
this.context = context;
this.actionsClass = actionsClass;
this.actionsObject = actionsObject;
this.resourceMap = resourceMap;
this.proxyActions = new ArrayList<>();
addAnnotationActions(resourceMap);
maybeAddActionsPCL();
}
public final Class getActionsClass() {
return actionsClass;
}
public final Object getActionsObject() {
return actionsObject;
}
public ActionX addAction(ActionX action) {
return addAction(action.getValue(Action.ACTION_COMMAND_KEY), action);
}
/**
* Adds an {@link ActionX} to the {@code ActionMapX}.
*
* @param id the value of the action ID, which is the value of the
* {@link Action#ACTION_COMMAND_KEY}
* @param action the {@code ActionX} to be added
*
* @return the action that was added
*/
public ActionX addAction(Object id, ActionX action) {
put(id, action);
return action;
}
/**
* Retrieves the IDs for all of the managed actions.
*
* An action ID is a unique identifier which can be used to retrieve the
* corresponding Action from the {@code ActionMap}. This identifier can also
* be used to set the properties of the action through the ActionMap, like
* setting the state of the enabled or selected properties.
*
* If this {@code ActionMapX} contains no action IDs, an empty {@link Set}
* is returned. Guaranteed to not return {@code null}.
*
* @return a set which represents all the action IDs
*/
public Set