コード例 #1
0
 /**
  * This service method overrides it's parent and removes all the database types other than native.
  */
 @Override
 public List<IDatabaseType> getDatabaseTypes() {
   List<IDatabaseType> databaseTypes = super.getDatabaseTypes();
   for (IDatabaseType type : databaseTypes) {
     Iterator<DatabaseAccessType> iter = type.getSupportedAccessTypes().iterator();
     while (iter.hasNext()) {
       DatabaseAccessType accessType = iter.next();
       if (accessType != DatabaseAccessType.NATIVE) {
         iter.remove();
       }
     }
   }
   return databaseTypes;
 }
コード例 #2
0
 private String getFragment(IDatabaseType database, String extension, String defaultFragment) {
   String fragment = database.getShortName().concat(extension).toLowerCase();
   if (!supportedFragments.contains(fragment)) {
     fragment = defaultFragment;
   }
   return fragment;
 }
コード例 #3
0
  private void afterOverlay(DataHandler dataHandler, IDatabaseType database) {
    XulTextbox portBox = (XulTextbox) document.getElementById("port-number-text"); // $NON-NLS-1$
    Object data = dataHandler.getData();
    String portValue = null;
    IDatabaseConnection databaseConnection = null;
    // Extract the stored value for port number in the model
    if (data instanceof IDatabaseConnection) {
      databaseConnection = (IDatabaseConnection) data;
      portValue = databaseConnection.getDatabasePort();
    }
    if (portBox != null) {
      // If the model has the port number use it other wise use the default one for the selected
      // database
      int port =
          (portValue != null && portValue.length() > 0)
              ? Integer.parseInt(portValue)
              : database.getDefaultDatabasePort();
      if (port > 0) {
        portBox.setValue(Integer.toString(port));
      }
    }

    if (dataHandler != null) {
      dataHandler.popCache();
    }

    GwtGroupBox box1 = (GwtGroupBox) document.getElementById("database-options-box");

    XulHbox box = (XulHbox) document.getElementById("connection-access-list-box");

    box1.layout();

    ((GwtHbox) box).layout();
  }
コード例 #4
0
  /**
   * This method handles the resource-like loading of the XUL fragment definitions based on
   * connection type and access method. If there is a common definition, and no connection specific
   * override definition, then the common definition is used. Connection specific definition
   * resources follow the naming pattern [connection type code]_[access method].xul.
   */
  public void refreshOptionsWithCallback(final IFragmentHandler.Callback callback) {

    connectionBox = (XulListbox) document.getElementById("connection-type-list"); // $NON-NLS-1$
    accessBox = (XulListbox) document.getElementById("access-type-list"); // $NON-NLS-1$

    String connectionKey = getSelectedString(connectionBox);
    if (connectionKey == null) {
      return;
    }
    //    DatabaseInterface database = DataHandler.connectionMap.get(connectionKey);
    IDatabaseType database = databaseTypeHelper.getDatabaseTypeByName(connectionKey);

    String accessKey = getSelectedString(accessBox);
    DatabaseAccessType access = DatabaseAccessType.getAccessTypeByName(accessKey);

    if (access == null) {
      return;
    }

    String fragment = null;

    DataHandler dataHandler = null;
    try {
      dataHandler = (DataHandler) xulDomContainer.getEventHandler("dataHandler"); // $NON-NLS-1$
      dataHandler.pushCache();
    } catch (XulException e) {
      // TODO not a critical function, but should log a problem...
    }

    switch (access) {
      case JNDI:
        fragment =
            getFragment(database, "_jndi.xul", "common_jndi.xul"); // $NON-NLS-1$ //$NON-NLS-2$
        break;
      case NATIVE:
        fragment =
            getFragment(database, "_native.xul", "common_native.xul"); // $NON-NLS-1$ //$NON-NLS-2$
        break;
      case OCI:
        fragment =
            getFragment(database, "_oci.xul", "common_native.xul"); // $NON-NLS-1$ //$NON-NLS-2$
        break;
      case ODBC:
        fragment =
            getFragment(database, "_odbc.xul", "common_odbc.xul"); // $NON-NLS-1$ //$NON-NLS-2$
        break;
      case PLUGIN:
        fragment =
            getFragment(database, "_plugin.xul", "common_native.xul"); // $NON-NLS-1$ //$NON-NLS-2$
        break;
    }

    try {
      loadDatabaseOptionsFragment(fragment.toLowerCase(), dataHandler, database, callback);
    } catch (XulException e) {
      // TODO should be reporting as an error dialog; need error dialog in XUL framework
      showMessage(
          messages.getString(
              "FragmentHandler.USER.CANT_LOAD_OPTIONS", database.getName()) // $NON-NLS-1$
          );
    }
  }