Ejemplo n.º 1
0
  /**
   * Gets the object that manages the content assist information read from the Web-CAT server.
   *
   * @return the content assist manager
   */
  public ContentAssistManager getContentAssistManager() {
    if (contentAssistManager == null) {
      Preferences prefs = DesignerActivator.getDefault().getPluginPreferences();
      String url = prefs.getString(IPreferencesConstants.SERVER_URL_KEY);
      String username = prefs.getString(IPreferencesConstants.USERNAME_KEY);
      String password = prefs.getString(IPreferencesConstants.PASSWORD_KEY);

      contentAssistManager = new ContentAssistManager();
      contentAssistManager.setServerCredentials(url, username, password);
    }

    return contentAssistManager;
  }
Ejemplo n.º 2
0
  /**
   * Gets the in-memory cache that stores the results of a preview query operation.
   *
   * @return the previewing result cache
   */
  public PreviewingResultCache getPreviewCache() {
    if (previewCache == null) {
      Preferences prefs = DesignerActivator.getDefault().getPluginPreferences();

      // Try to construct a previewing result set provider based on the
      // current preferences settings.
      String url = prefs.getString(IPreferencesConstants.SERVER_URL_KEY);
      String username = prefs.getString(IPreferencesConstants.USERNAME_KEY);
      String password = prefs.getString(IPreferencesConstants.PASSWORD_KEY);
      int maxRecords = 0;
      int timeout = 0;

      try {
        maxRecords = Integer.parseInt(prefs.getString(IPreferencesConstants.MAX_RECORDS_KEY));

        timeout = Integer.parseInt(prefs.getString(IPreferencesConstants.CONNECTION_TIMEOUT_KEY));
      } catch (NumberFormatException e) {
        // Do nothing; keep default value of 0.
      }

      if (url == null || url.trim().length() == 0) {
        MessageBox box =
            new MessageBox(
                PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(),
                SWT.OK | SWT.ICON_WARNING);

        box.setMessage(Messages.ACTIVATOR_SERVER_URL_NOT_SET);
        box.open();
      } else {
        previewCache = new PreviewingResultCache();
        previewCache.setServerCredentials(url, username, password);
        previewCache.setMaxRecords(maxRecords);
        previewCache.setTimeout(timeout);
      }
    }

    return previewCache;
  }