⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 uiutility.java

📁 国外的一套开源CRM
💻 JAVA
📖 第 1 页 / 共 3 页
字号:

        return entityFindMap;
    }

    /**
     * Instantiates UIDropDown or one of its descendant classes.
     *
     * @param className The class to be instantiated
     *
     * @return Object of class specified by className parameter
     *
     * @see com.sourcetap.sfa.ui.UIDropDown
     */
    public static UIDropDown getUIDropDown(String className) {
        Class uiDropDownClass = null;
        UIDropDown uiDropdown = null;

        if ((className.length() > 0) && !className.equals("null")) {
            try {
                uiDropDownClass = Class.forName(className);
            } catch (ClassNotFoundException e) {
                Debug.logError("[UIUtility.getUIDropDown] Class \"" +
                    className +
                    "\" specified in display object could not be found.", module);
                Debug.logError(e, module);

                return null;
            }

            try {
                uiDropdown = (UIDropDown) uiDropDownClass.newInstance();
            } catch (IllegalAccessException e) {
                Debug.logError(
                    "[UIUtility.getUIDropDown]  Drop Down class \"" +
                    className + "\" could not be instantiated because " +
                    "the class or initializer is not accessible.", module);
                Debug.logError(e, module);

                return null;
            } catch (InstantiationException e) {
                Debug.logError("[UIUtility.getUIDropDown] Drop Down class \"" +
                    className + "\" cannot be instantiated because it is an " +
                    "abstract class, an interface, an array class, a primitive type, or void.", module);
                Debug.logError(e, module);

                return null;
            }
        } else {
            // Class name was not specified in the display object. Use the default class.
            uiDropdown = new UIDropDown();
        }

        // Return the new instance of UIDropDown.
        return uiDropdown;
    }

    /**
	 * Instantiates GenericEventProcessor or one of its descendant classes.
	 *
	 * @param className The class to be instantiated
	 *
	 * @return Object of class specified by className parameter
	 *
	 * @see com.sourcetap.sfa.ui.UIDropDown
	 */
	public static GenericEventProcessor getEventProcessor(String className) {
		Class eventProcessorClass = null;
		GenericEventProcessor eventProcessor = null;

		if ((className != null ) && (className.length() > 0) && !className.equals("null")) {
			try {
				eventProcessorClass = Class.forName(className);
			} catch (ClassNotFoundException e) {
				Debug.logError("[UIUtility.getEventProcessor] Class \"" +
					className +
					"\" specified in section.eventProcessorClass could not be found.", module);
				Debug.logError(e, module);

				return null;
			}

			try {
				eventProcessor = (GenericEventProcessor) eventProcessorClass.newInstance();
			} catch (IllegalAccessException e) {
				Debug.logError(
					"[UIUtility.getEventProcessor]  EventProcessor class \"" +
					className + "\" could not be instantiated because " +
					"the class or initializer is not accessible.", module);
				Debug.logError(e, module);

				return null;
			} catch (InstantiationException e) {
				Debug.logError("[UIUtility.getEventProcessor] EventProcessor class \"" +
					className + "\" cannot be instantiated because it is an " +
					"abstract class, an interface, an array class, a primitive type, or void.", module);
				Debug.logError(e, module);

				return null;
			}
		} else {
			// Class name was not specified in the display object. Use the default class.
			eventProcessor = new GenericEventProcessor();
		}

		// Return the new instance of UIDropDown.
		return eventProcessor;
	}

    /**
     * Instantiates UISearchField or one of its descendant classes.
     *
     * @param className The class to be instantiated
     *
     * @return Object of class specified by className parameter
     *
     * @see com.sourcetap.sfa.ui.UISearchField
     */
    public static UISearchField getUISearchField(String className) {
        Class UISearchFieldClass = null;
        UISearchField uiSearchField = null;

        if ((className.length() > 0) && !className.equals("null")) {
            // Class name was specified in the display object.  Need to instantiate that class.
            try {
                UISearchFieldClass = Class.forName(className);
            } catch (ClassNotFoundException e) {
                Debug.logError("[UIUtility.getUISearchField] Class \"" +
                    className +
                    "\" specified in display object could not be found.", module);
                Debug.logError(e, module);

                return null;
            }

            try {
                uiSearchField = (UISearchField) UISearchFieldClass.newInstance();
            } catch (IllegalAccessException e) {
                Debug.logError(
                    "[UIUtility.getUISearchField] Search field class \"" +
                    className + "\" could not be instantiated because " +
                    "the class or initializer is not accessible.", module);
                Debug.logError(e, module);

                return null;
            } catch (InstantiationException e) {
                Debug.logError(
                    "[UIUtility.getUISearchField] Search field class \"" +
                    className + "\" cannot be instantiated because it is an " +
                    "abstract class, an interface, an array class, a primitive type, or void.", module);
                Debug.logError(e, module);

                return null;
            }
        } else {
            // Class name was not specified in the display object. Use the default class.
            uiSearchField = new UISearchField();
        }

        // Return the new instance of UISearchField.
        return uiSearchField;
    }

    /**
     * DOCUMENT ME!
     *
     * @param delegator 
     * @param searchAttribName 
     * @param searchEntityName 
     *
     * @return 
     *
     * @throws GenericEntityException 
     */
    public static String getAttributeId(GenericDelegator delegator,
        String searchAttribName, String searchEntityName)
        throws GenericEntityException {
        // Figure out the attribute ID for the UiAttribute this parameter corresponds to so we can
        // save the query.
        // select * from UiAttribute a, UIEntity e where e.entity_id = a.entity_id and a.attribute_name = <searchAttrName> and e.entityName = <searchEntityName>
        
        DynamicViewEntity dve = EntityHelper.createDynamicViewEntity( delegator, "UiAttribute"); 
		dve.addMemberEntity("UiEntity", "UiEntity");
		dve.addViewLink("UiAttribute", "UiEntity", Boolean.FALSE, UtilMisc.toList(new ModelKeyMap("entityId", "entityId")));
		dve.addAlias("UiEntity", "entityName", null, null, null, null, null);
     
		EntityCondition condition = new EntityConditionList(UtilMisc.toList(
				new EntityExpr("attributeName", EntityOperator.EQUALS, searchAttribName),
				new EntityExpr("entityName", EntityOperator.EQUALS, searchEntityName)),
				EntityOperator.AND);
        
        List queryGVL = EntityHelper.findByCondition( delegator, dve, condition, null );

        if (queryGVL.size() == 0) {
            throw new GenericEntityException(
                "No UI Attribute found for entity name \"" + searchEntityName +
                "\" and attribute name \"" + searchAttribName + "\"");
        }

        GenericValue uiAttributeGV = (GenericValue) queryGVL.iterator().next();
        String attributeId = uiAttributeGV.getString("attributeId");

        return attributeId;
    }

    /**
     * DOCUMENT ME!
     *
     * @param entityDetailsVector 
     * @param entityName 
     *
     * @return 
     */
    public static GenericValue getEntityValue(Vector entityDetailsVector,
        String entityName) {
        // Get the specified entity from the vector.
        Iterator entityDetailsIterator = entityDetailsVector.iterator();

        while (entityDetailsIterator.hasNext()) {
            GenericValue testEntity = (GenericValue) entityDetailsIterator.next();

            if (testEntity.getEntityName().equals(entityName)) {
                return testEntity;
            }
        }

        return null;
    }

    /**
     * DOCUMENT ME!
     *
     * @param entityDetailsVector 
     * @param entityName 
     * @param attributeName 
     *
     * @return 
     */
    public static String getAttributeValue(Vector entityDetailsVector,
        String entityName, String attributeName) {
        GenericValue entityGV = UIUtility.getEntityValue(entityDetailsVector,
                entityName);

        if (entityGV == null) {
            return null;
        }

        try {
            String attribValue = String.valueOf(entityGV.get(attributeName));

            return attribValue;
        } catch (IllegalArgumentException e) {
            Debug.logError(
                "[UIUtility.getAttributeValue]: Problem getting entity atribute definition " +
                entityName + "." + attributeName, module);
            Debug.logError(e.getMessage(), module);
        }

        return null;
    }

    /**
     * DOCUMENT ME!
     *
     * @param selectedEntityPKL 
     * @param eligibleEntityL 
     *
     * @return 
     */
    public static List removeSelectedEligibleEntities(List selectedEntityPKL,
        List eligibleEntityL) {
        Debug.logVerbose("[activityContactSelectAvailable] Start", module);

        Debug.logVerbose(
                "[activityContactSelectAvailable] selectedEntityPKL: " +
                selectedEntityPKL, module);

        Iterator eligibleEntityI = eligibleEntityL.iterator();

        while (eligibleEntityI.hasNext()) {
            GenericValue eligibleGV = (GenericValue) eligibleEntityI.next();

            // Look through the assigned keys to see if this key is already selected.
            Iterator selectedEntityPKI = selectedEntityPKL.iterator();

            while (selectedEntityPKI.hasNext()) {
                GenericPK selectedEntityPK = (GenericPK) selectedEntityPKI.next();

                if (selectedEntityPK.equals(eligibleGV.getPrimaryKey())) {
                    Debug.logVerbose(
                            "[activityContactSelectAvailable] Removing a selected item for PK " +
                            selectedEntityPK.toString(), module);

                    // This entity has already been selected. Remove it from the eligible list.
                    eligibleEntityI.remove();

                    break;
                }
            }
        }

        Debug.logVerbose(
                "[activityContactSelectAvailable] eligibleEntityL after removing selected items: " +
                eligibleEntityL, module);
        Debug.logVerbose("[activityContactSelectAvailable] End", module);

        return eligibleEntityL;
    }

    /**
     * DOCUMENT ME!
     *
     * @param action 
     * @param fieldInfo 
     *
     * @return 
     */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -