Package org.mongodb.meclipse.preferences

Examples of org.mongodb.meclipse.preferences.MongoInstance


   * This method is called when 'Finish' button is pressed in the wizard. We
   * will create an operation and run it using wizard as execution context.
   */
  public boolean performFinish() {
    // 1st, add the connection to our overall state:
    MongoInstance mongoInstance = new MongoInstance(page.getConnName());
    mongoInstance.setHost(page.getHost());
    mongoInstance.setPort(page.getPort());
    MeclipsePlugin.getDefault().addMongo(page.getConnName(), mongoInstance);

    return true;
  }
View Full Code Here


      reader = new CsvReader(new BufferedReader(new FileReader(file)));

      java.util.List<MongoInstance> savedServersList = new ArrayList<MongoInstance>();
      while (reader.readRecord()) {
        MongoInstance server = new MongoInstance(reader.get(0));
        server.setHost(reader.get(1));
        try {
          server.setPort(Integer.valueOf(reader.get(2)));
        } catch (NumberFormatException e) {
          System.out.println(e);
        }
        savedServersList.add(server);
      }
View Full Code Here

  public IStatus checkDuplicateConnection(String hostname, int port) {
    Iterator<String> it = mongoInstances.iterator();
    while (it.hasNext()) {
      String cur = it.next();
      MongoInstance instance = MeclipsePlugin.getDefault()
          .getMongoInstance(cur);
      if (instance.getPort() == port
          && instance.getHost().equals(hostname)) {
        return ValidationStatus.warning(String.format(
            getCaption("connectionWizard.warn.duplicate"), cur));
      }
    }
    return ValidationStatus.ok();
View Full Code Here

*/
public class ViewLabelProvider extends LabelProvider {

  public String getText(Object obj) {
    if (obj instanceof Connection) {
      MongoInstance mongoInstance = MeclipsePlugin.getDefault()
          .getMongoInstance(((Connection) obj).getName());
      return mongoInstance.getName() + " (" + mongoInstance.getHost()
          + ":" + mongoInstance.getPort() + ")";
    } else {
      return obj.toString();
    }
  }
View Full Code Here

   * request to see data obtained via the connection.
   *
   * @return
   */
  public Mongo getMongo() {
    MongoInstance mongoInstance = MeclipsePlugin.getDefault()
        .getMongoInstance(this.getName());
    Exception ex;
    if (mongoInstance.getMongo() == null) {
      Mongo mongo;
      try {
        mongo = new Mongo(mongoInstance.getHost(),
            mongoInstance.getPort());
        mongo.getDatabaseNames();
        mongoInstance.setMongo(mongo); // add the active Mongo instance
                        // to the plug-in's state
        isDown = false;
        return mongo;
        /* catch some possible exceptions */
      } catch (MongoException e) {
        ex = e;
      } catch (UnknownHostException e) {
        ex = e;
      }
      if (!isDown) {
        this.showMessage(String.format(
            getCaption("connection.connectionError"),
            this.getName(), mongoInstance.getHost(), ex));
        isDown = true;
      }
      return null;
    } else {
      return mongoInstance.getMongo();
    }
  }
View Full Code Here

TOP

Related Classes of org.mongodb.meclipse.preferences.MongoInstance

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.