Ejemplo n.º 1
0
  private static void init() {
    if (resources == null) {

      // initialize resources

      Bundle mainPlugin = SQLExplorerPlugin.getDefault().getBundle();
      Bundle[] fragments = Platform.getFragments(mainPlugin);

      if (fragments == null) {
        fragments = new Bundle[0];
      }

      resources = new ResourceBundle[fragments.length + 1];

      resources[0] = ResourceBundle.getBundle(mainPlugin.getSymbolicName() + BUNDLE_NAME);

      for (int i = 0; i < fragments.length; i++) {
        try {
          resources[i + 1] = ResourceBundle.getBundle(fragments[i].getSymbolicName() + BUNDLE_NAME);
        } catch (Exception ignored) {
          // ignore it
        }
      }
    }
  }
Ejemplo n.º 2
0
  /** Loads all the children for this node if they haven't been loaded yet. */
  public final void load() {

    if (!_childrenLoaded) {

      try {

        if (_logger.isDebugEnabled()) {
          _logger.debug("Loading child nodes for " + _name);
        }

        loadChildren();
        _childrenLoaded = true;

      } catch (AbstractMethodError e) {

        SQLExplorerPlugin.error("Could not load child nodes for " + _name, e);

      } catch (Throwable e) {

        SQLExplorerPlugin.error("Could not load child nodes for " + _name, e);
      }
    }
  }
Ejemplo n.º 3
0
  /**
   * Returns a list of all available tabs for a given node. These tabs can be standard or plugin
   * tabs.
   *
   * @param node for which to find tabs.
   * @return List of tabs
   */
  private static List<IDetailTab> createTabs(INode node) {

    if (_logger.isDebugEnabled()) {
      _logger.debug("Creating tabs for: " + node.getUniqueIdentifier());
    }

    ArrayList<IDetailTab> tabList = new ArrayList<IDetailTab>();

    // create connection info tab if needed
    if (node instanceof DatabaseNode) {

      IDetailTab dbTab = new ConnectionInfoTab();
      dbTab.setNode(node);
      tabList.add(dbTab);
    }

    // create our basic table tabs
    if (node instanceof TableNode) {

      IDetailTab tab1 = new ColumnInfoTab();
      IDetailTab tab2 = new TableInfoTab();
      IDetailTab tab3 = new PreviewTab();
      IDetailTab tab4 = new RowCountTab();
      IDetailTab tab5 = new PrimaryKeysTab();
      IDetailTab tab6 = new ExportedKeysTab();
      IDetailTab tab7 = new ImportedKeysTab();
      IDetailTab tab8 = new IndexesTab();
      IDetailTab tab9 = new PriviligesTab();
      IDetailTab tab10 = new ColumnPriviligesTab();
      IDetailTab tab11 = new RowIdsTab();
      IDetailTab tab12 = new VersionsTab();

      tab1.setNode(node);
      tab2.setNode(node);
      tab3.setNode(node);
      tab4.setNode(node);
      tab5.setNode(node);
      tab6.setNode(node);
      tab7.setNode(node);
      tab8.setNode(node);
      tab9.setNode(node);
      tab10.setNode(node);
      tab11.setNode(node);
      tab12.setNode(node);

      tabList.add(tab1);
      tabList.add(tab2);
      tabList.add(tab3);
      tabList.add(tab4);
      tabList.add(tab5);
      tabList.add(tab6);
      tabList.add(tab7);
      tabList.add(tab8);
      tabList.add(tab9);
      tabList.add(tab10);
      tabList.add(tab11);
      tabList.add(tab12);
    }

    // create extension point tabs
    String databaseProductName =
        node.getSession().getRoot().getDatabaseProductName().toLowerCase().trim();
    String nodeType = node.getType().toLowerCase().trim();

    IExtensionRegistry registry = Platform.getExtensionRegistry();
    IExtensionPoint point =
        registry.getExtensionPoint("net.sourceforge.sqlexplorer", "nodeDetailTab");
    IExtension[] extensions = point.getExtensions();

    for (int i = 0; i < extensions.length; i++) {

      IExtension e = extensions[i];

      IConfigurationElement[] ces = e.getConfigurationElements();

      for (int j = 0; j < ces.length; j++) {
        try {

          boolean isValidProduct = false;
          boolean isValidNodeType = false;

          String[] validProducts = ces[j].getAttribute("database-product-name").split(",");
          String[] validNodeTypes = ces[j].getAttribute("node-type").split(",");

          // check if tab is valid for current database product
          for (int k = 0; k < validProducts.length; k++) {

            String product = validProducts[k].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 tab is valid for current node type
          for (int k = 0; k < validNodeTypes.length; k++) {

            String type = validNodeTypes[k].toLowerCase().trim();

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

            if (type.equals("*")) {
              isValidNodeType = true;
              break;
            }

            String regex = TextUtil.replaceChar(type, '*', ".*");
            if (nodeType.matches(regex)) {
              isValidNodeType = true;
              break;
            }
          }

          if (!isValidNodeType) {
            continue;
          }

          // add tab to list
          IDetailTab tab = (IDetailTab) ces[j].createExecutableExtension("class");
          tab.setNode(node);

          tabList.add(tab);

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

    return tabList;
  }