Skip to content

Commit

Permalink
fix pb with rap
Browse files Browse the repository at this point in the history
  • Loading branch information
angelozerr committed Aug 7, 2012
1 parent 0ca0f81 commit 0b4033f
Show file tree
Hide file tree
Showing 88 changed files with 867 additions and 234 deletions.
Expand Up @@ -4,6 +4,7 @@
import java.util.List;
import java.util.Set;

import com.mongodb.CommandResult;
import com.mongodb.DB;
import com.mongodb.DBCollection;
import com.mongodb.DBObject;
Expand Down Expand Up @@ -232,4 +233,9 @@ public ShellContext createContext() {
return new ShellContext(this);
}

public CommandResult getDBCollectionGetStats(DBCollection collection) {
CommandResult result = collection.getStats();
return result;
}

}
@@ -0,0 +1,26 @@
package com.mongodb.tools.driver.pagination;

import java.io.File;
import java.io.IOException;

public class StartMongo {

public static void main(String[] args) {

File f = new File("D:\\MongoDB\\mongodb-win32-i386-2.0.7-rc0\\bin\\mongo.exe");
try {
//Process p = Runtime.getRuntime().exec("cmd.exe /c start " + f.toString());


String[] s ={"cmd.exe", "/c", "start", f.toString()};
Process p = new ProcessBuilder(s).start();

Thread.sleep(1000);
p.destroy();

} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
1 change: 1 addition & 0 deletions fr.opensagres.mongodb.ide.core/META-INF/MANIFEST.MF
Expand Up @@ -12,6 +12,7 @@ Bundle-RequiredExecutionEnvironment: J2SE-1.5
Export-Package: fr.opensagres.mongodb.ide.core,
fr.opensagres.mongodb.ide.core.extensions,
fr.opensagres.mongodb.ide.core.model,
fr.opensagres.mongodb.ide.core.model.stats,
fr.opensagres.mongodb.ide.core.utils
Import-Package: com.mongodb,
com.mongodb.tools.driver,
Expand Down
Binary file not shown.
3 changes: 2 additions & 1 deletion fr.opensagres.mongodb.ide.core/build.properties
Expand Up @@ -3,4 +3,5 @@ output.. = bin/
bin.includes = META-INF/,\
.,\
plugin.properties,\
schema/
schema/,\
plugin.xml
8 changes: 3 additions & 5 deletions fr.opensagres.mongodb.ide.core/plugin.properties
Expand Up @@ -18,15 +18,13 @@ shellRunnersContributionName=Shell runners contribution.
# Server runner
ExternalServerRunner.startName=Start external server
ExternalServerRunner.stopName=Stop external server
ExternalServerRunner.startDesc=Start server with cmd/sh
ExternalServerRunner.startDesc=start Mongo server by opening cmd/sh shell command.
ExternalServerRunner.stopDesc=
ConnectServerRunner.startName=Connect
ConnectServerRunner.stopName=Disconnect
ConnectServerRunner.startDesc=Connect to the server
ConnectServerRunner.stopDesc=Disconnect to the server

# Shell runner
ExternalShellRunner.startName=Start external shell
ExternalShellRunner.stopName=Stop external shell
ExternalShellRunner.startDesc=Start shell with cmd/sh
ExternalShellRunner.stopDesc=
ExternalShellRunner.startName=Start external console
ExternalShellRunner.startDesc=start Mongo console by opening cmd/sh shell command.
Expand Up @@ -17,6 +17,13 @@
*/
public interface IServerRunnerType {

/**
* Return the identifier of the runtime.
*
* @return
*/
String getId();

/**
* Return the start name of the server runner.
*
Expand Down
Expand Up @@ -24,14 +24,14 @@ public interface IShellRunner {
*
* @param database
*/
void startShell(Database database);
void startShell(Database database) throws Exception;

/**
* Stop the Mongo Shell Console for the given database.
*
* @param database
*/
void stopShell(Database database);
void stopShell(Database database) throws Exception;

/**
* Return true if the given database can support this shell runner and false
Expand All @@ -42,4 +42,12 @@ public interface IShellRunner {
*/
boolean canSupport(Database database);

/**
* Returns true if the shell runner support stop feature and false
* otherwise.
*
* @return
*/
boolean canSupportStop();

}
Expand Up @@ -17,6 +17,13 @@
*/
public interface IShellRunnerType {

/**
* Return the identifier of the runtime.
*
* @return
*/
String getId();

/**
* Return the start name of the shell runner.
*
Expand Down
@@ -0,0 +1,33 @@
package fr.opensagres.mongodb.ide.core.internal.extensions;

import java.io.IOException;

import org.eclipse.core.runtime.Platform;
import org.eclipse.osgi.service.environment.Constants;

public class CommandExecHelper {

public static void exec(String command) throws IOException {
String nativeCommand = null;
boolean isWin9xME = false; // see bug 50567
if (Platform.getOS().equals(Constants.OS_WIN32)) {
String osName = System.getProperty("os.name"); //$NON-NLS-1$
isWin9xME = osName != null
&& (osName.startsWith("Windows 9") || osName.startsWith("Windows ME")); //$NON-NLS-1$ //$NON-NLS-2$
if (isWin9xME) {
nativeCommand = "command.com /C start "; //$NON-NLS-1$
} else {
// Win NT, 2K, XP
nativeCommand = "cmd.exe /C start "; //$NON-NLS-1$
}
} else if (!Platform.getOS().equals(Constants.OS_UNKNOWN)) {
//nativeCommand = "env"; //$NON-NLS-1$
// TODO : manage linux shell command etc
}
if (nativeCommand == null) {
return;
}
nativeCommand = nativeCommand + command; //$NON-NLS-1$
Runtime.getRuntime().exec(nativeCommand);
}
}
Expand Up @@ -5,12 +5,20 @@

public class ExternalShellRunner extends AbstractShellRunner {

public void startShell(Database database) {
public void startShell(Database database) throws Exception {
// TODO : start cmd/sh shell.

String cmd = database.getMongoConsoleCommand(true);
CommandExecHelper.exec(cmd);

}

public void stopShell(Database database) throws Exception {
// Do Nothing
}

public void stopShell(Database database) {
// Do Nothing
public boolean canSupportStop() {
return false;
}

}
Expand Up @@ -128,7 +128,7 @@ private void parseServerRunnerManagers(IConfigurationElement[] cf) {
IServerRunner runner = (IServerRunner) ce
.createExecutableExtension(CLASS_ATTR);
runnerTypes.put(id,
new ServerRunnerType(startName, stopName,
new ServerRunnerType(id, startName, stopName,
startDescription, stopDescription, runner));
} catch (CoreException e) {
Trace.trace(Trace.STRING_SEVERE,
Expand Down
Expand Up @@ -20,21 +20,28 @@
*/
public class ServerRunnerType implements IServerRunnerType {

private final String id;
private final String startName;
private final String stopName;
private final String startDescription;
private final String stopDescription;
private final IServerRunner runner;

public ServerRunnerType(String startName, String stopName,
String startDescription, String stopDescription, IServerRunner runner) {
public ServerRunnerType(String id, String startName, String stopName,
String startDescription, String stopDescription,
IServerRunner runner) {
this.id = id;
this.startName = startName;
this.stopName = stopName;
this.startDescription = startDescription;
this.stopDescription = stopDescription;
this.runner = runner;
}

public String getId() {
return id;
}

public String getStartName() {
return startName;
}
Expand Down
Expand Up @@ -33,7 +33,8 @@
* fr.opensagres.mongodb.ide.core.shellRunners" extension point.
*
*/
public class ShellRunnerRegistry extends AbstractRegistry implements IShellRunnerRegistry {
public class ShellRunnerRegistry extends AbstractRegistry implements
IShellRunnerRegistry {

private static final String RUNNER_ELT = "runner";
public static final String START_NAME_ATTR = "startName";
Expand All @@ -45,7 +46,6 @@ public class ShellRunnerRegistry extends AbstractRegistry implements IShellRunne

private Map<String, IShellRunnerType> runnerTypes = new HashMap<String, IShellRunnerType>();


/**
* Return the {@link IShellRunnerType} retrieved by the given id.
*
Expand Down Expand Up @@ -128,7 +128,7 @@ private void parseShellRunnerManagers(IConfigurationElement[] cf) {
IShellRunner runner = (IShellRunner) ce
.createExecutableExtension(CLASS_ATTR);
runnerTypes.put(id,
new ShellRunnerType(startName, stopName,
new ShellRunnerType(id, startName, stopName,
startDescription, stopDescription, runner));
} catch (CoreException e) {
Trace.trace(Trace.STRING_SEVERE,
Expand Down
Expand Up @@ -20,21 +20,27 @@
*/
public class ShellRunnerType implements IShellRunnerType {

private final String id;
private final String startName;
private final String stopName;
private final String startDescription;
private final String stopDescription;
private final IShellRunner runner;

public ShellRunnerType(String startName, String stopName,
public ShellRunnerType(String id, String startName, String stopName,
String startDescription, String stopDescription, IShellRunner runner) {
this.id = id;
this.startName = startName;
this.stopName = stopName;
this.startDescription = startDescription;
this.stopDescription = stopDescription;
this.runner = runner;
}

public String getId() {
return id;
}

public String getStartName() {
return startName;
}
Expand Down
@@ -1,5 +1,7 @@
package fr.opensagres.mongodb.ide.core.model;

import java.util.ArrayList;
import java.util.List;
import java.util.Set;

import com.mongodb.DB;
Expand All @@ -9,17 +11,20 @@
public class CollectionsCategory extends TreeContainerNode<Database> {

private String id;
private final List<Collection> collections;

public CollectionsCategory() {

this.collections = new ArrayList<Collection>();
}

@Override
protected void doGetChildren() throws Exception {
this.collections.clear();
DB db = getParent().getDB();
Set<String> names = getShellCommandManager().showCollections(db);
for (String name : names) {
Collection collection = new Collection(name);
collections.add(collection);
super.addNode(collection);
}
}
Expand All @@ -44,4 +49,16 @@ public NodeType getType() {
return NodeType.CollectionsCategory;
}

public List<Collection> getCollections() {
// Compute if needed list of collection.
getChildren();
return collections;
}

@Override
public void clearNodes() {
super.clearNodes();
this.collections.clear();
}

}

0 comments on commit 0b4033f

Please sign in to comment.