/*----------------------------------------------------------------------------
Copyright (c)2000 TogetherSoft Corporation. Patents pending. All rights reserved.
----------------------------------------------------------------------------*/

package com.togethersoft.modules.inspector.customproperties;

import com.togethersoft.openapi.ide.*;
import com.togethersoft.openapi.ide.inspector.*;
import com.togethersoft.openapi.rwi.*;

public class CustomPropertiesUtil {
  public static boolean checkPropertyName (IdeInspector inspector, String name) {
    if (name == null || name.equals("")) return false;

    if (RwiProperty.SHAPE_TYPE.equals("$" + name) ||
        "link".equals(name) ||
        "name".equals(name)) return false;
    IdeInspectorComponent[] components = inspector.getComponents();
    for (int i=0; i<components.length; i++) {
      IdeInspectorPropertySetComponent current = null;
      if (components[i] instanceof IdeInspectorPropertySetComponent) {
        current = (IdeInspectorPropertySetComponent)components[i];
        IdeInspectorProperty[] properties = current.getProperties();
        for (int j=0; j<properties.length; j++) {
          if (properties[j].getName().equals(name) ||
              properties[j].getName().equals("$" + name)) return false;
        }
      }
    }

    return true;
  }
}
