예제 #1
0
  private void addExtensionNodes() {

    String databaseProductName =
        getSession().getRoot().getDatabaseProductName().toLowerCase().trim();

    IExtensionRegistry registry = Platform.getExtensionRegistry();
    IExtensionPoint point = registry.getExtensionPoint("AsteriskSafletDesigner.diagram", "node");
    IExtension[] extensions = point.getExtensions();

    for (IExtension e : extensions) {

      IConfigurationElement[] ces = e.getConfigurationElements();

      for (IConfigurationElement ce : ces) {
        try {

          // include only nodes that are attachted to the schema
          // node..
          String parent = ce.getAttribute("parent-node");
          if (parent.indexOf("catalog") == -1) {
            continue;
          }

          boolean isValidProduct = false;
          String[] validProducts = ce.getAttribute("database-product-name").split(",");

          // include only nodes valid for this database
          for (String validProduct : validProducts) {

            String product = validProduct.toLowerCase().trim();

            if (product.length() == 0) {
              continue;
            }

            if (product.equals("*")) {
              isValidProduct = true;
              break;
            }

            String regex = TextUtil.replaceChar(product, '*', ".*");
            if (databaseProductName.matches(regex)) {
              isValidProduct = true;
              break;
            }
          }

          if (!isValidProduct) {
            continue;
          }

          String imagePath = ce.getAttribute("icon");
          String id = ce.getAttribute("id");
          String type = ce.getAttribute("table-type").trim();

          AbstractNode childNode = (AbstractNode) ce.createExecutableExtension("class");
          childNode.setParent(this);
          childNode.setSession(_session);
          childNode.setType(type);

          String fragmentId = id.substring(0, id.indexOf('.', 28));
          if (imagePath != null && imagePath.trim().length() != 0) {
            childNode.setImage(ImageUtil.getFragmentImage(fragmentId, imagePath));
          }

          _childNames.add(childNode.getLabelText());
          if (!isExcludedByFilter(childNode.getLabelText())) {
            addChildNode(childNode);
          }

        } catch (Throwable ex) {
          SQLExplorerPlugin.error("Could not create child node", ex);
        }
      }
    }
  }
예제 #2
0
  /**
   * Location extenstion nodes for a given tableType
   *
   * @param tableType for which to find extension node
   * @return INode or null if no extensions found
   */
  private INode findExtensionNode(String tableType) {

    String databaseProductName =
        getSession().getRoot().getDatabaseProductName().toLowerCase().trim();

    IExtensionRegistry registry = Platform.getExtensionRegistry();
    IExtensionPoint point = registry.getExtensionPoint("AsteriskSafletDesigner.diagram", "node");
    IExtension[] extensions = point.getExtensions();

    for (IExtension e : extensions) {

      IConfigurationElement[] ces = e.getConfigurationElements();

      for (IConfigurationElement ce : ces) {
        try {

          // include only nodes that are attachted to the schema
          // node..
          String parent = ce.getAttribute("parent-node");
          if (parent.indexOf("catalog") == -1) {
            continue;
          }

          boolean isValidProduct = false;
          String[] validProducts = ce.getAttribute("database-product-name").split(",");

          // include only nodes valid for this database
          for (String validProduct : validProducts) {

            String product = validProduct.toLowerCase().trim();

            if (product.length() == 0) {
              continue;
            }

            if (product.equals("*")) {
              isValidProduct = true;
              break;
            }

            String regex = TextUtil.replaceChar(product, '*', ".*");
            if (databaseProductName.matches(regex)) {
              isValidProduct = true;
              break;
            }
          }

          if (!isValidProduct) {
            continue;
          }

          // check if it is the correct type
          String type = ce.getAttribute("table-type").trim();
          if (!type.equalsIgnoreCase(tableType)) {
            continue;
          }

          AbstractNode childNode = (AbstractNode) ce.createExecutableExtension("class");
          childNode.setParent(this);
          childNode.setSession(_session);

          return childNode;

        } catch (Throwable ex) {
          SQLExplorerPlugin.error("Could not create child node", ex);
        }
      }
    }

    return null;
  }