diff --git a/TargetPlatform/launch/MongoDB IDE - Eclipse IDE.launch b/TargetPlatform/launch/NoSQL IDE - Eclipse IDE.launch similarity index 100% rename from TargetPlatform/launch/MongoDB IDE - Eclipse IDE.launch rename to TargetPlatform/launch/NoSQL IDE - Eclipse IDE.launch diff --git a/TargetPlatform/launch/MongoDB IDE - Eclipse MacOSX.launch b/TargetPlatform/launch/NoSQL IDE - Eclipse MacOSX.launch similarity index 93% rename from TargetPlatform/launch/MongoDB IDE - Eclipse MacOSX.launch rename to TargetPlatform/launch/NoSQL IDE - Eclipse MacOSX.launch index 042937f..6e441b3 100644 --- a/TargetPlatform/launch/MongoDB IDE - Eclipse MacOSX.launch +++ b/TargetPlatform/launch/NoSQL IDE - Eclipse MacOSX.launch @@ -1,32 +1,32 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/TargetPlatform/launch/MongoDB IDE - Eclipse RAP.launch b/TargetPlatform/launch/NoSQL IDE - Eclipse RAP.launch similarity index 56% rename from TargetPlatform/launch/MongoDB IDE - Eclipse RAP.launch rename to TargetPlatform/launch/NoSQL IDE - Eclipse RAP.launch index 3780b78..08fc8a9 100644 --- a/TargetPlatform/launch/MongoDB IDE - Eclipse RAP.launch +++ b/TargetPlatform/launch/NoSQL IDE - Eclipse RAP.launch @@ -18,7 +18,7 @@ - + @@ -33,9 +33,9 @@ - + - + diff --git a/TargetPlatform/launch/MongoDB IDE - Eclipse RCP (win32).launch b/TargetPlatform/launch/NoSQL IDE - Eclipse RCP (win32).launch similarity index 96% rename from TargetPlatform/launch/MongoDB IDE - Eclipse RCP (win32).launch rename to TargetPlatform/launch/NoSQL IDE - Eclipse RCP (win32).launch index 5efe774..565e091 100644 --- a/TargetPlatform/launch/MongoDB IDE - Eclipse RCP (win32).launch +++ b/TargetPlatform/launch/NoSQL IDE - Eclipse RCP (win32).launch @@ -1,7 +1,7 @@ - + diff --git a/TargetPlatform/mongodb-ide.target b/TargetPlatform/nosql-ide.target similarity index 100% rename from TargetPlatform/mongodb-ide.target rename to TargetPlatform/nosql-ide.target diff --git a/TargetPlatform/mongodb-rap.target b/TargetPlatform/nosql-rap.target similarity index 85% rename from TargetPlatform/mongodb-rap.target rename to TargetPlatform/nosql-rap.target index f21bf5f..3b28ab7 100644 --- a/TargetPlatform/mongodb-rap.target +++ b/TargetPlatform/nosql-rap.target @@ -1,7 +1,7 @@ - + diff --git a/TargetPlatform/mongodb-rcp.target b/TargetPlatform/nosql-rcp.target similarity index 100% rename from TargetPlatform/mongodb-rcp.target rename to TargetPlatform/nosql-rcp.target diff --git a/TargetPlatform/warproduct/demo/mongoide-rapdemo.war b/TargetPlatform/warproduct/demo/mongoide-rapdemo.war deleted file mode 100644 index f9dc9bb..0000000 Binary files a/TargetPlatform/warproduct/demo/mongoide-rapdemo.war and /dev/null differ diff --git a/TargetPlatform/warproduct/demo/mongodb_ide-rap-demo.warproduct b/TargetPlatform/warproduct/demo/nosql-rap-demo.warproduct similarity index 100% rename from TargetPlatform/warproduct/demo/mongodb_ide-rap-demo.warproduct rename to TargetPlatform/warproduct/demo/nosql-rap-demo.warproduct diff --git a/com.orientechnologies.orient/.classpath b/com.orientechnologies.orient/.classpath new file mode 100644 index 0000000..58ae65b --- /dev/null +++ b/com.orientechnologies.orient/.classpath @@ -0,0 +1,21 @@ + + + + + + + + + + + + + + + + + + + + + diff --git a/com.orientechnologies.orient/.project b/com.orientechnologies.orient/.project new file mode 100644 index 0000000..21d2a5d --- /dev/null +++ b/com.orientechnologies.orient/.project @@ -0,0 +1,28 @@ + + + com.orientechnologies.orient + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.pde.ManifestBuilder + + + + + org.eclipse.pde.SchemaBuilder + + + + + + org.eclipse.pde.PluginNature + org.eclipse.jdt.core.javanature + + diff --git a/com.orientechnologies.orient/.settings/org.eclipse.jdt.core.prefs b/com.orientechnologies.orient/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000..9e7156c --- /dev/null +++ b/com.orientechnologies.orient/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,8 @@ +#Mon Sep 03 12:17:40 CEST 2012 +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5 +org.eclipse.jdt.core.compiler.compliance=1.5 +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.5 diff --git a/com.orientechnologies.orient/META-INF/MANIFEST.MF b/com.orientechnologies.orient/META-INF/MANIFEST.MF new file mode 100644 index 0000000..77636b2 --- /dev/null +++ b/com.orientechnologies.orient/META-INF/MANIFEST.MF @@ -0,0 +1,151 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Name: Orient +Bundle-SymbolicName: com.orientechnologies.orient +Bundle-Version: 1.0.0.qualifier +Bundle-Vendor: ORIENTECHNOLOGIES +Bundle-RequiredExecutionEnvironment: J2SE-1.5 +Bundle-ClassPath: lib/hazelcast-2.1.2.jar, + lib/hibernate-jpa-2.0-api-1.0.0.Final.jar, + lib/javassist.jar, + lib/jna-3.4.0.jar, + lib/orient-commons-1.1.0.jar, + lib/orientdb-client-1.1.0.jar, + lib/orientdb-core-1.1.0.jar, + lib/orientdb-distributed-1.1.0.jar, + lib/orientdb-enterprise-1.1.0.jar, + lib/orientdb-nativeos-1.1.0.jar, + lib/orientdb-object-1.1.0.jar, + lib/orientdb-server-1.1.0.jar, + lib/orientdb-tools-1.1.0.jar, + lib/platform.jar, + . +Export-Package: com.orientechnologies.common.collection, + com.orientechnologies.common.comparator, + com.orientechnologies.common.concur, + com.orientechnologies.common.concur.lock, + com.orientechnologies.common.concur.resource, + com.orientechnologies.common.console, + com.orientechnologies.common.console.annotation, + com.orientechnologies.common.exception, + com.orientechnologies.common.factory, + com.orientechnologies.common.io, + com.orientechnologies.common.listener, + com.orientechnologies.common.log, + com.orientechnologies.common.parser, + com.orientechnologies.common.profiler, + com.orientechnologies.common.reflection, + com.orientechnologies.common.synch, + com.orientechnologies.common.test, + com.orientechnologies.common.thread, + com.orientechnologies.common.types, + com.orientechnologies.common.util, + com.orientechnologies.nio, + com.orientechnologies.orient.client.db, + com.orientechnologies.orient.client.remote, + com.orientechnologies.orient.console, + com.orientechnologies.orient.core, + com.orientechnologies.orient.core.annotation, + com.orientechnologies.orient.core.cache, + com.orientechnologies.orient.core.command, + com.orientechnologies.orient.core.command.script, + com.orientechnologies.orient.core.command.traverse, + com.orientechnologies.orient.core.config, + com.orientechnologies.orient.core.db, + com.orientechnologies.orient.core.db.document, + com.orientechnologies.orient.core.db.graph, + com.orientechnologies.orient.core.db.object, + com.orientechnologies.orient.core.db.raw, + com.orientechnologies.orient.core.db.record, + com.orientechnologies.orient.core.db.tool, + com.orientechnologies.orient.core.dictionary, + com.orientechnologies.orient.core.engine, + com.orientechnologies.orient.core.engine.local, + com.orientechnologies.orient.core.engine.memory, + com.orientechnologies.orient.core.entity, + com.orientechnologies.orient.core.exception, + com.orientechnologies.orient.core.fetch, + com.orientechnologies.orient.core.fetch.json, + com.orientechnologies.orient.core.fetch.remote, + com.orientechnologies.orient.core.hook, + com.orientechnologies.orient.core.id, + com.orientechnologies.orient.core.index, + com.orientechnologies.orient.core.intent, + com.orientechnologies.orient.core.iterator, + com.orientechnologies.orient.core.iterator.object, + com.orientechnologies.orient.core.memory, + com.orientechnologies.orient.core.metadata, + com.orientechnologies.orient.core.metadata.schema, + com.orientechnologies.orient.core.metadata.security, + com.orientechnologies.orient.core.query, + com.orientechnologies.orient.core.query.nativ, + com.orientechnologies.orient.core.record, + com.orientechnologies.orient.core.record.impl, + com.orientechnologies.orient.core.security, + com.orientechnologies.orient.core.serialization, + com.orientechnologies.orient.core.serialization.serializer, + com.orientechnologies.orient.core.serialization.serializer.binary, + com.orientechnologies.orient.core.serialization.serializer.binary.impl, + com.orientechnologies.orient.core.serialization.serializer.binary.impl.index, + com.orientechnologies.orient.core.serialization.serializer.object, + com.orientechnologies.orient.core.serialization.serializer.record, + com.orientechnologies.orient.core.serialization.serializer.record.string, + com.orientechnologies.orient.core.serialization.serializer.stream, + com.orientechnologies.orient.core.serialization.serializer.string, + com.orientechnologies.orient.core.sql, + com.orientechnologies.orient.core.sql.filter, + com.orientechnologies.orient.core.sql.functions, + com.orientechnologies.orient.core.sql.functions.coll, + com.orientechnologies.orient.core.sql.functions.geo, + com.orientechnologies.orient.core.sql.functions.math, + com.orientechnologies.orient.core.sql.functions.misc, + com.orientechnologies.orient.core.sql.operator, + com.orientechnologies.orient.core.sql.operator.math, + com.orientechnologies.orient.core.sql.query, + com.orientechnologies.orient.core.storage, + com.orientechnologies.orient.core.storage.fs, + com.orientechnologies.orient.core.storage.impl.local, + com.orientechnologies.orient.core.storage.impl.memory, + com.orientechnologies.orient.core.tx, + com.orientechnologies.orient.core.type, + com.orientechnologies.orient.core.type.tree, + com.orientechnologies.orient.core.type.tree.provider, + com.orientechnologies.orient.enterprise.channel, + com.orientechnologies.orient.enterprise.channel.binary, + com.orientechnologies.orient.enterprise.channel.text, + com.orientechnologies.orient.enterprise.command, + com.orientechnologies.orient.enterprise.command.script, + com.orientechnologies.orient.object.db, + com.orientechnologies.orient.object.db.graph, + com.orientechnologies.orient.object.dictionary, + com.orientechnologies.orient.object.enhancement, + com.orientechnologies.orient.object.entity, + com.orientechnologies.orient.object.enumerations, + com.orientechnologies.orient.object.fetch, + com.orientechnologies.orient.object.iterator, + com.orientechnologies.orient.object.iterator.graph, + com.orientechnologies.orient.object.jpa, + com.orientechnologies.orient.object.serialization, + com.orientechnologies.orient.server, + com.orientechnologies.orient.server.config, + com.orientechnologies.orient.server.db, + com.orientechnologies.orient.server.distributed, + com.orientechnologies.orient.server.distributed.conflict, + com.orientechnologies.orient.server.handler, + com.orientechnologies.orient.server.hazelcast, + com.orientechnologies.orient.server.journal, + com.orientechnologies.orient.server.managed, + com.orientechnologies.orient.server.network, + com.orientechnologies.orient.server.network.protocol, + com.orientechnologies.orient.server.network.protocol.binary, + com.orientechnologies.orient.server.network.protocol.http, + com.orientechnologies.orient.server.network.protocol.http.command, + com.orientechnologies.orient.server.network.protocol.http.command.all, + com.orientechnologies.orient.server.network.protocol.http.command.delete, + com.orientechnologies.orient.server.network.protocol.http.command.get, + com.orientechnologies.orient.server.network.protocol.http.command.options, + com.orientechnologies.orient.server.network.protocol.http.command.post, + com.orientechnologies.orient.server.network.protocol.http.command.put, + com.orientechnologies.orient.server.network.protocol.http.multipart, + com.orientechnologies.orient.server.task, + com.orientechnologies.orient.server.tx diff --git a/com.orientechnologies.orient/build.properties b/com.orientechnologies.orient/build.properties new file mode 100644 index 0000000..e161a75 --- /dev/null +++ b/com.orientechnologies.orient/build.properties @@ -0,0 +1,18 @@ +source.. = src/ +output.. = bin/ +bin.includes = META-INF/,\ + .,\ + lib/hazelcast-2.1.2.jar,\ + lib/hibernate-jpa-2.0-api-1.0.0.Final.jar,\ + lib/javassist.jar,\ + lib/jna-3.4.0.jar,\ + lib/orient-commons-1.1.0.jar,\ + lib/orientdb-client-1.1.0.jar,\ + lib/orientdb-core-1.1.0.jar,\ + lib/orientdb-distributed-1.1.0.jar,\ + lib/orientdb-enterprise-1.1.0.jar,\ + lib/orientdb-nativeos-1.1.0.jar,\ + lib/orientdb-object-1.1.0.jar,\ + lib/orientdb-server-1.1.0.jar,\ + lib/orientdb-tools-1.1.0.jar,\ + lib/platform.jar diff --git a/com.orientechnologies.orient/lib/hazelcast-2.1.2.jar b/com.orientechnologies.orient/lib/hazelcast-2.1.2.jar new file mode 100644 index 0000000..8916ca5 Binary files /dev/null and b/com.orientechnologies.orient/lib/hazelcast-2.1.2.jar differ diff --git a/com.orientechnologies.orient/lib/hibernate-jpa-2.0-api-1.0.0.Final.jar b/com.orientechnologies.orient/lib/hibernate-jpa-2.0-api-1.0.0.Final.jar new file mode 100644 index 0000000..4c9ac4e Binary files /dev/null and b/com.orientechnologies.orient/lib/hibernate-jpa-2.0-api-1.0.0.Final.jar differ diff --git a/com.orientechnologies.orient/lib/javassist.jar b/com.orientechnologies.orient/lib/javassist.jar new file mode 100644 index 0000000..e8abb19 Binary files /dev/null and b/com.orientechnologies.orient/lib/javassist.jar differ diff --git a/com.orientechnologies.orient/lib/jna-3.4.0.jar b/com.orientechnologies.orient/lib/jna-3.4.0.jar new file mode 100644 index 0000000..3b8fb4f Binary files /dev/null and b/com.orientechnologies.orient/lib/jna-3.4.0.jar differ diff --git a/com.orientechnologies.orient/lib/orient-commons-1.1.0.jar b/com.orientechnologies.orient/lib/orient-commons-1.1.0.jar new file mode 100644 index 0000000..a8747e7 Binary files /dev/null and b/com.orientechnologies.orient/lib/orient-commons-1.1.0.jar differ diff --git a/com.orientechnologies.orient/lib/orientdb-client-1.1.0.jar b/com.orientechnologies.orient/lib/orientdb-client-1.1.0.jar new file mode 100644 index 0000000..f6058f3 Binary files /dev/null and b/com.orientechnologies.orient/lib/orientdb-client-1.1.0.jar differ diff --git a/com.orientechnologies.orient/lib/orientdb-core-1.1.0.jar b/com.orientechnologies.orient/lib/orientdb-core-1.1.0.jar new file mode 100644 index 0000000..200f8f5 Binary files /dev/null and b/com.orientechnologies.orient/lib/orientdb-core-1.1.0.jar differ diff --git a/com.orientechnologies.orient/lib/orientdb-distributed-1.1.0.jar b/com.orientechnologies.orient/lib/orientdb-distributed-1.1.0.jar new file mode 100644 index 0000000..11e69ef Binary files /dev/null and b/com.orientechnologies.orient/lib/orientdb-distributed-1.1.0.jar differ diff --git a/com.orientechnologies.orient/lib/orientdb-enterprise-1.1.0.jar b/com.orientechnologies.orient/lib/orientdb-enterprise-1.1.0.jar new file mode 100644 index 0000000..e4a855a Binary files /dev/null and b/com.orientechnologies.orient/lib/orientdb-enterprise-1.1.0.jar differ diff --git a/com.orientechnologies.orient/lib/orientdb-nativeos-1.1.0.jar b/com.orientechnologies.orient/lib/orientdb-nativeos-1.1.0.jar new file mode 100644 index 0000000..8f10e36 Binary files /dev/null and b/com.orientechnologies.orient/lib/orientdb-nativeos-1.1.0.jar differ diff --git a/com.orientechnologies.orient/lib/orientdb-object-1.1.0.jar b/com.orientechnologies.orient/lib/orientdb-object-1.1.0.jar new file mode 100644 index 0000000..04628f5 Binary files /dev/null and b/com.orientechnologies.orient/lib/orientdb-object-1.1.0.jar differ diff --git a/com.orientechnologies.orient/lib/orientdb-server-1.1.0.jar b/com.orientechnologies.orient/lib/orientdb-server-1.1.0.jar new file mode 100644 index 0000000..e931c13 Binary files /dev/null and b/com.orientechnologies.orient/lib/orientdb-server-1.1.0.jar differ diff --git a/com.orientechnologies.orient/lib/orientdb-tools-1.1.0.jar b/com.orientechnologies.orient/lib/orientdb-tools-1.1.0.jar new file mode 100644 index 0000000..061b9f8 Binary files /dev/null and b/com.orientechnologies.orient/lib/orientdb-tools-1.1.0.jar differ diff --git a/com.orientechnologies.orient/lib/platform.jar b/com.orientechnologies.orient/lib/platform.jar new file mode 100644 index 0000000..2d9a0f2 Binary files /dev/null and b/com.orientechnologies.orient/lib/platform.jar differ diff --git a/fr.opensagres.nosql.ide.core/src/fr/opensagres/nosql/ide/core/IServerRuntimeManager.java b/fr.opensagres.nosql.ide.core/src/fr/opensagres/nosql/ide/core/IServerRuntimeManager.java index 365db34..6bb6242 100644 --- a/fr.opensagres.nosql.ide.core/src/fr/opensagres/nosql/ide/core/IServerRuntimeManager.java +++ b/fr.opensagres.nosql.ide.core/src/fr/opensagres/nosql/ide/core/IServerRuntimeManager.java @@ -16,4 +16,6 @@ public interface IServerRuntimeManager extends ISettingsManager { void removeRuntime(IServerRuntime runtime) throws Exception; IServerRuntime findRuntime(String runtimeId); + + void setRuntimes(IServerRuntime[] runtimes) throws Exception; } diff --git a/fr.opensagres.nosql.ide.core/src/fr/opensagres/nosql/ide/core/Platform.java b/fr.opensagres.nosql.ide.core/src/fr/opensagres/nosql/ide/core/Platform.java index 4152bb2..a2e5b8e 100644 --- a/fr.opensagres.nosql.ide.core/src/fr/opensagres/nosql/ide/core/Platform.java +++ b/fr.opensagres.nosql.ide.core/src/fr/opensagres/nosql/ide/core/Platform.java @@ -36,4 +36,5 @@ public static IServerRunnerRegistry getServerRunnerRegistry() { public static IShellCommandManagerRegistry getShellCommandManagerRegistry() { return ShellCommandManagerRegistry.getInstance(); } + } diff --git a/fr.opensagres.nosql.ide.core/src/fr/opensagres/nosql/ide/core/model/AbstractServerRuntime.java b/fr.opensagres.nosql.ide.core/src/fr/opensagres/nosql/ide/core/model/AbstractServerRuntime.java new file mode 100644 index 0000000..49ea7ef --- /dev/null +++ b/fr.opensagres.nosql.ide.core/src/fr/opensagres/nosql/ide/core/model/AbstractServerRuntime.java @@ -0,0 +1,59 @@ +package fr.opensagres.nosql.ide.core.model; + +import fr.opensagres.nosql.ide.core.Platform; +import fr.opensagres.nosql.ide.core.extensions.IServerType; + +public abstract class AbstractServerRuntime implements IServerRuntime { + + private final String id; + private String name; + private String installDir; + private final IServerType serverType; + + public AbstractServerRuntime(String serverTypeId, String name, String path) + throws Exception { + this(serverTypeId, String.valueOf(System.currentTimeMillis()), name, + path); + } + + public AbstractServerRuntime(String serverTypeId, String id, String name, + String path) throws Exception { + this.id = id; + setName(name); + setInstallDir(path); + serverType = Platform.getServerTypeRegistry().getType(serverTypeId); + } + + public String getId() { + return id; + } + + public String getName() { + return name; + } + + public String getLabel() { + return getName(); + } + + public void setName(String name) { + this.name = name; + } + + public String getInstallDir() { + return installDir; + } + + public void setInstallDir(String installDir) throws Exception { + validateInstallDir(installDir); + this.installDir = installDir; + } + + public final IServerType getServerType() { + return serverType; + } + + protected abstract void validateInstallDir(String installDir) + throws Exception; + +} diff --git a/fr.opensagres.nosql.ide.core/src/fr/opensagres/nosql/ide/core/model/IServerRuntime.java b/fr.opensagres.nosql.ide.core/src/fr/opensagres/nosql/ide/core/model/IServerRuntime.java index 4b6ff0d..f3999e5 100644 --- a/fr.opensagres.nosql.ide.core/src/fr/opensagres/nosql/ide/core/model/IServerRuntime.java +++ b/fr.opensagres.nosql.ide.core/src/fr/opensagres/nosql/ide/core/model/IServerRuntime.java @@ -6,4 +6,9 @@ public interface IServerRuntime extends IModelIdentity { IServerType getServerType(); + String getInstallDir(); + + void setInstallDir(String installDir) throws Exception; + + void setName(String name); } diff --git a/fr.opensagres.nosql.ide.core/src/fr/opensagres/nosql/ide/core/utils/CollectionUtils.java b/fr.opensagres.nosql.ide.core/src/fr/opensagres/nosql/ide/core/utils/CollectionUtils.java new file mode 100644 index 0000000..b2ba80b --- /dev/null +++ b/fr.opensagres.nosql.ide.core/src/fr/opensagres/nosql/ide/core/utils/CollectionUtils.java @@ -0,0 +1,13 @@ +package fr.opensagres.nosql.ide.core.utils; + +import java.util.Collection; + +public class CollectionUtils { + + public static E getFirstElement(Collection c) { + for (E e : c) { + return e; + } + return null; + } +} diff --git a/fr.opensagres.nosql.ide.mongodb.core/src/fr/opensagres/nosql/ide/mongodb/core/model/MongoServerRuntime.java b/fr.opensagres.nosql.ide.mongodb.core/src/fr/opensagres/nosql/ide/mongodb/core/model/MongoServerRuntime.java new file mode 100644 index 0000000..bc3f303 --- /dev/null +++ b/fr.opensagres.nosql.ide.mongodb.core/src/fr/opensagres/nosql/ide/mongodb/core/model/MongoServerRuntime.java @@ -0,0 +1,51 @@ +package fr.opensagres.nosql.ide.mongodb.core.model; + +import org.eclipse.core.runtime.Path; + +import com.mongodb.tools.process.MongoDBTools; +import com.mongodb.tools.process.MongoProcessFiles; + +import fr.opensagres.nosql.ide.core.model.AbstractServerRuntime; + +/** + * + * MongoRuntime stores an installation directory of a MongoDB dababase. It is + * used : + * + *
    + *
  • start/stop a local MongoDB server from ServerExplorer View with launch by + * calling INSTAL_DIR/bin/mongod.exe/sh process.
  • * * + *
  • start/stop a MongoDB Shell from ServerExplorer View (by selecting a + * database) with launch by calling INSTAL_DIR/bin/mongo.exe/sh process.
  • + *
+ * + */ +public class MongoServerRuntime extends AbstractServerRuntime { + + private Path mongoProcessLocation; + private Path mongodProcessLocation; + + public MongoServerRuntime(String name, String path) throws Exception { + super(MongoServer.TYPE_ID, name, path); + } + + public MongoServerRuntime(String id, String name, String path) + throws Exception { + super(MongoServer.TYPE_ID, id, name, path); + } + + @Override + protected void validateInstallDir(String installDir) throws Exception { + MongoProcessFiles files = MongoDBTools.validateMongoHomeDir(installDir); + this.mongoProcessLocation = new Path(files.getMongoFile().getPath()); + this.mongodProcessLocation = new Path(files.getMongodFile().getPath()); + } + + public Path getMongoProcessLocation() { + return mongoProcessLocation; + } + + public Path getMongodProcessLocation() { + return mongodProcessLocation; + } +} diff --git a/fr.opensagres.nosql.ide.mongodb.ui/META-INF/MANIFEST.MF b/fr.opensagres.nosql.ide.mongodb.ui/META-INF/MANIFEST.MF index d54d225..ace2875 100644 --- a/fr.opensagres.nosql.ide.mongodb.ui/META-INF/MANIFEST.MF +++ b/fr.opensagres.nosql.ide.mongodb.ui/META-INF/MANIFEST.MF @@ -19,6 +19,9 @@ Import-Package: com.mongodb, com.mongodb.gridfs, com.mongodb.tools.driver, com.mongodb.tools.driver.pagination, + com.mongodb.tools.process, + com.mongodb.tools.process.mongo, + com.mongodb.tools.process.mongod, com.mongodb.tools.shell, org.bson Bundle-Activator: fr.opensagres.nosql.ide.mongodb.ui.internal.Activator diff --git a/fr.opensagres.nosql.ide.mongodb.ui/plugin.xml b/fr.opensagres.nosql.ide.mongodb.ui/plugin.xml index 08c8842..beb3757 100644 --- a/fr.opensagres.nosql.ide.mongodb.ui/plugin.xml +++ b/fr.opensagres.nosql.ide.mongodb.ui/plugin.xml @@ -10,6 +10,15 @@ + + + + + { + + public MongoRuntimeDialog(Shell parentShell) { + super(parentShell); + } + + @Override + protected MongoProcessFiles validateInstallDir() { + // 1) validate install dir + if (StringUtils.isEmpty(installDir.getText())) { + setErrorMessage(Messages.errorInstallDirRequired); + return null; + } + try { + return MongoDBTools.validateMongoHomeDir(installDir.getText()); + } catch (InvalidMongoHomeDirException e) { + String errorMessage = null; + switch (e.getType()) { + case baseDirNotExists: + errorMessage = NLS.bind( + Messages.errorInstallDir_baseDirNotExists, e.getFile() + .getPath()); + break; + case baseDirNotDir: + errorMessage = NLS.bind(Messages.errorInstallDir_baseDirNotDir, + e.getFile().getPath()); + break; + case binDirNotExists: + errorMessage = NLS.bind( + Messages.errorInstallDir_binDirNotExists, e.getFile() + .getPath()); + break; + case processFileNotExists: + errorMessage = NLS.bind( + Messages.errorInstallDir_processFileNotExists, e + .getFile().getPath()); + break; + } + setErrorMessage(errorMessage); + return null; + } + } + + @Override + protected IServerRuntime createRuntime(String name, String installDir) + throws Exception { + return new MongoServerRuntime(name, installDir); + } + + @Override + protected String getGeneratedName(MongoProcessFiles files) throws Exception { + return MongodTools.getDBVersion(files.getMongodFile()); + } +} diff --git a/fr.opensagres.nosql.ide.mongodb.ui/src/fr/opensagres/nosql/ide/mongodb/ui/internal/Messages.java b/fr.opensagres.nosql.ide.mongodb.ui/src/fr/opensagres/nosql/ide/mongodb/ui/internal/Messages.java index 0e21cd7..2d27781 100644 --- a/fr.opensagres.nosql.ide.mongodb.ui/src/fr/opensagres/nosql/ide/mongodb/ui/internal/Messages.java +++ b/fr.opensagres.nosql.ide.mongodb.ui/src/fr/opensagres/nosql/ide/mongodb/ui/internal/Messages.java @@ -62,7 +62,7 @@ public class Messages extends NLS { public static String NewCollectionAction_toolTipText; public static String NewDocumentAction_text; public static String NewDocumentAction_toolTipText; - + // ****************** RefreshAction ****************** public static String RefreshAction_text; public static String RefreshAction_toolTipText; @@ -171,6 +171,14 @@ public class Messages extends NLS { public static String database_validation_required; public static String collection_validation_required; + // Runtime error + public static String errorRuntimeNameRequired; + public static String errorInstallDirRequired; + public static String errorInstallDir_baseDirNotExists; + public static String errorInstallDir_baseDirNotDir; + public static String errorInstallDir_binDirNotExists; + public static String errorInstallDir_processFileNotExists; + static { // load message values from bundle file NLS.initializeMessages(BUNDLE_NAME, Messages.class); diff --git a/fr.opensagres.nosql.ide.mongodb.ui/src/fr/opensagres/nosql/ide/mongodb/ui/internal/Messages.properties b/fr.opensagres.nosql.ide.mongodb.ui/src/fr/opensagres/nosql/ide/mongodb/ui/internal/Messages.properties index e1aec5c..3984dcc 100644 --- a/fr.opensagres.nosql.ide.mongodb.ui/src/fr/opensagres/nosql/ide/mongodb/ui/internal/Messages.properties +++ b/fr.opensagres.nosql.ide.mongodb.ui/src/fr/opensagres/nosql/ide/mongodb/ui/internal/Messages.properties @@ -181,4 +181,12 @@ columnMD5=MD5 server_validation_required=The server is required. server_validation_notConnected=The server ''{0}'' is not connected. database_validation_required=Database name field is required. -collection_validation_required=Collection name field is required. \ No newline at end of file +collection_validation_required=Collection name field is required. + +# Runtime Error Messages +errorRuntimeNameRequired=Name is required. +errorInstallDirRequired=Install directory is required. +errorInstallDir_baseDirNotExists=The MongoDB {0} base directory doesn't exist. +errorInstallDir_baseDirNotDir=The MongoDB {0} path is not a directory. +errorInstallDir_binDirNotExists=The MongoDB {0} directory doesn't exist. +errorInstallDir_processFileNotExists=The MongoDB {0} process file doesn't exist. diff --git a/fr.opensagres.nosql.ide.mongodb.ui/src/fr/opensagres/nosql/ide/mongodb/ui/internal/extension/MongoRuntimeDialogFactory.java b/fr.opensagres.nosql.ide.mongodb.ui/src/fr/opensagres/nosql/ide/mongodb/ui/internal/extension/MongoRuntimeDialogFactory.java new file mode 100644 index 0000000..8fcbe5e --- /dev/null +++ b/fr.opensagres.nosql.ide.mongodb.ui/src/fr/opensagres/nosql/ide/mongodb/ui/internal/extension/MongoRuntimeDialogFactory.java @@ -0,0 +1,14 @@ +package fr.opensagres.nosql.ide.mongodb.ui.internal.extension; + +import org.eclipse.jface.window.Window; +import org.eclipse.swt.widgets.Shell; + +import fr.opensagres.nosql.ide.mongodb.ui.dialogs.MongoRuntimeDialog; +import fr.opensagres.nosql.ide.ui.extensions.IDialogFactory; + +public class MongoRuntimeDialogFactory implements IDialogFactory { + + public Window create(Shell shell) { + return new MongoRuntimeDialog(shell); + } +} diff --git a/fr.opensagres.nosql.ide.orientdb.core/META-INF/MANIFEST.MF b/fr.opensagres.nosql.ide.orientdb.core/META-INF/MANIFEST.MF index 8c2ea78..57d411f 100644 --- a/fr.opensagres.nosql.ide.orientdb.core/META-INF/MANIFEST.MF +++ b/fr.opensagres.nosql.ide.orientdb.core/META-INF/MANIFEST.MF @@ -9,3 +9,7 @@ Bundle-RequiredExecutionEnvironment: J2SE-1.5 Bundle-ActivationPolicy: lazy Require-Bundle: fr.opensagres.nosql.ide.core;bundle-version="1.0.0" Export-Package: fr.opensagres.nosql.ide.orientdb.core.model +Import-Package: com.orientechnologies.orient.client.remote, + com.orientechnologies.orient.core.db, + com.orientechnologies.orient.core.db.document, + com.orientechnologies.orient.core.storage diff --git a/fr.opensagres.nosql.ide.orientdb.core/plugin.properties b/fr.opensagres.nosql.ide.orientdb.core/plugin.properties index d61829c..c308cef 100644 --- a/fr.opensagres.nosql.ide.orientdb.core/plugin.properties +++ b/fr.opensagres.nosql.ide.orientdb.core/plugin.properties @@ -11,4 +11,14 @@ pluginName=OrientDB IDE Core providerName=Opensagres -serverType.name=OrientDB \ No newline at end of file +serverType.name=OrientDB + +# Server runner +ExternalServerRunner.startName=Start external server +ExternalServerRunner.stopName=Stop external server +ExternalServerRunner.startDesc=start Orient 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 \ No newline at end of file diff --git a/fr.opensagres.nosql.ide.orientdb.core/plugin.xml b/fr.opensagres.nosql.ide.orientdb.core/plugin.xml index 140a284..95454ef 100644 --- a/fr.opensagres.nosql.ide.orientdb.core/plugin.xml +++ b/fr.opensagres.nosql.ide.orientdb.core/plugin.xml @@ -14,8 +14,21 @@ point="fr.opensagres.nosql.ide.core.serverFactories"> + class="fr.opensagres.nosql.ide.orientdb.core.internal.extensions.OrientServerFactory"> + + + + + diff --git a/fr.opensagres.nosql.ide.orientdb.core/src/fr/opensagres/nosql/ide/orientdb/core/internal/extensions/ConnectServerRunner.java b/fr.opensagres.nosql.ide.orientdb.core/src/fr/opensagres/nosql/ide/orientdb/core/internal/extensions/ConnectServerRunner.java new file mode 100644 index 0000000..5a2af0e --- /dev/null +++ b/fr.opensagres.nosql.ide.orientdb.core/src/fr/opensagres/nosql/ide/orientdb/core/internal/extensions/ConnectServerRunner.java @@ -0,0 +1,41 @@ +package fr.opensagres.nosql.ide.orientdb.core.internal.extensions; + +import fr.opensagres.nosql.ide.core.extensions.AbstractServerRunner; +import fr.opensagres.nosql.ide.core.model.IServer; +import fr.opensagres.nosql.ide.core.model.ServerState; + +public class ConnectServerRunner extends AbstractServerRunner { + + @Override + protected boolean doCanSupport(IServer server) { + return true; + } + + public void start(IServer server) throws Exception { + server.setServerState(ServerState.Connecting); + //server.getChildren(); + //if (server.getStatus() == NodeStatus.StartedWithError) { + // server.setServerState(ServerState.Disconnected); + //} + //else { + server.setServerState(ServerState.Connected); + //} +// // Try to connect +// try { +// MongoDriverHelper.tryConnection(((MongoServer) server).getMongo(), +// server.getDatabaseName()); +// server.setServerState(ServerState.Connected); +// } catch (Throwable e) { +// server.getChildren().add(new Error(e)); +// server.setServerState(ServerState.Disconnected); +// } + // MongoDriverHelper.tryConnection(getMongo()); + // Connection is OK, update the server state as connected. + + } + + public void stop(IServer server, boolean force) throws Exception { + server.setServerState(ServerState.Disconnected); + } + +} diff --git a/fr.opensagres.nosql.ide.orientdb.core/src/fr/opensagres/nosql/ide/orientdb/core/model/internal/OrientServerFactory.java b/fr.opensagres.nosql.ide.orientdb.core/src/fr/opensagres/nosql/ide/orientdb/core/internal/extensions/OrientServerFactory.java similarity index 85% rename from fr.opensagres.nosql.ide.orientdb.core/src/fr/opensagres/nosql/ide/orientdb/core/model/internal/OrientServerFactory.java rename to fr.opensagres.nosql.ide.orientdb.core/src/fr/opensagres/nosql/ide/orientdb/core/internal/extensions/OrientServerFactory.java index edbf377..e6da0d5 100644 --- a/fr.opensagres.nosql.ide.orientdb.core/src/fr/opensagres/nosql/ide/orientdb/core/model/internal/OrientServerFactory.java +++ b/fr.opensagres.nosql.ide.orientdb.core/src/fr/opensagres/nosql/ide/orientdb/core/internal/extensions/OrientServerFactory.java @@ -1,4 +1,4 @@ -package fr.opensagres.nosql.ide.orientdb.core.model.internal; +package fr.opensagres.nosql.ide.orientdb.core.internal.extensions; import java.net.URL; diff --git a/fr.opensagres.nosql.ide.orientdb.core/src/fr/opensagres/nosql/ide/orientdb/core/model/Database.java b/fr.opensagres.nosql.ide.orientdb.core/src/fr/opensagres/nosql/ide/orientdb/core/model/Database.java new file mode 100644 index 0000000..23188a9 --- /dev/null +++ b/fr.opensagres.nosql.ide.orientdb.core/src/fr/opensagres/nosql/ide/orientdb/core/model/Database.java @@ -0,0 +1,17 @@ +package fr.opensagres.nosql.ide.orientdb.core.model; + +import fr.opensagres.nosql.ide.core.model.AbstractDatabase; + +public class Database extends AbstractDatabase { + + public Database(String name) { + super(name); + } + + @Override + protected void doGetChildren() throws Exception { + // TODO Auto-generated method stub + + } + +} diff --git a/fr.opensagres.nosql.ide.orientdb.core/src/fr/opensagres/nosql/ide/orientdb/core/model/OrientServer.java b/fr.opensagres.nosql.ide.orientdb.core/src/fr/opensagres/nosql/ide/orientdb/core/model/OrientServer.java index 5c1200a..859ab87 100644 --- a/fr.opensagres.nosql.ide.orientdb.core/src/fr/opensagres/nosql/ide/orientdb/core/model/OrientServer.java +++ b/fr.opensagres.nosql.ide.orientdb.core/src/fr/opensagres/nosql/ide/orientdb/core/model/OrientServer.java @@ -2,12 +2,17 @@ import java.net.URL; +import com.orientechnologies.orient.client.remote.OServerAdmin; +import com.orientechnologies.orient.core.db.document.ODatabaseDocumentTx; +import com.orientechnologies.orient.core.storage.OStorageProxy; + import fr.opensagres.nosql.ide.core.model.AbstractServer; public class OrientServer extends AbstractServer { public static final String TYPE_ID = "fr.opensagres.nosql.ide.orientdb.core"; private URL url; + private OServerAdmin serverAdmin; public OrientServer(String name, URL url) { super(TYPE_ID, name); @@ -37,13 +42,29 @@ public String getDatabaseName() { @Override protected void loadDatabases() throws Exception { - // TODO Auto-generated method stub + // see + // http://code.google.com/p/orient/source/browse/trunk/tools/src/main/java/com/orientechnologies/orient/console/OConsoleDatabaseApp.java } @Override protected void loadDatabase(String databaseName) throws Exception { - // TODO Auto-generated method stub + // see + // http://code.google.com/p/orient/source/browse/trunk/tools/src/main/java/com/orientechnologies/orient/console/OConsoleDatabaseApp.java + ODatabaseDocumentTx currentDatabase = new ODatabaseDocumentTx("remote:127.0.0.1/demo"); + // if (currentDatabase == null) + // throw new OException("Database " + iURL + " not found"); + + // currentDatabase.registerListener(new OConsoleDatabaseListener(this)); + currentDatabase.open("admin", "admin"); + + // currentDatabaseName = currentDatabase.getName(); + if (currentDatabase.getStorage() instanceof OStorageProxy) + serverAdmin = new OServerAdmin(currentDatabase.getStorage() + .getURL()); + + Database database = new Database(databaseName); + super.addNode(database); } } diff --git a/fr.opensagres.nosql.ide.orientdb.ui/src/fr/opensagres/nosql/ide/orientdb/ui/wizards/server/NewServerWizardPage.java b/fr.opensagres.nosql.ide.orientdb.ui/src/fr/opensagres/nosql/ide/orientdb/ui/wizards/server/NewServerWizardPage.java index 6c608b1..f2f8c2c 100644 --- a/fr.opensagres.nosql.ide.orientdb.ui/src/fr/opensagres/nosql/ide/orientdb/ui/wizards/server/NewServerWizardPage.java +++ b/fr.opensagres.nosql.ide.orientdb.ui/src/fr/opensagres/nosql/ide/orientdb/ui/wizards/server/NewServerWizardPage.java @@ -275,6 +275,7 @@ private void updateURLField(Widget widget) { private void updateFieldsFromURL() { try { String host = null; + int portAsInt = -1; String port = null; String userName = null; String password = null; @@ -282,8 +283,14 @@ private void updateFieldsFromURL() { try { URL url = new URL(urlText.getText()); host = url.getHost(); - // port = url.getPort(); + portAsInt = url.getPort(); + port = portAsInt >= 0 ? String.valueOf(portAsInt) : null; databaseName = url.getPath(); + if (StringUtils.isNotEmpty(databaseName) + && databaseName.startsWith("/")) { + databaseName = databaseName.substring(1, + databaseName.length()); + } // MongoURI mongoURI = new MongoURI(mongoURIText.getText()); // Retrieve host and port fields from the MongoURI // List hosts = mongoURI.getHosts(); diff --git a/fr.opensagres.nosql.ide.ui/plugin.properties b/fr.opensagres.nosql.ide.ui/plugin.properties index 1674db3..1c6c539 100644 --- a/fr.opensagres.nosql.ide.ui/plugin.properties +++ b/fr.opensagres.nosql.ide.ui/plugin.properties @@ -13,6 +13,8 @@ providerName=Opensagres # Extension Point serverImagesContributionName=NoSQL Server images contribution. +serverViewersContributionName=NoSQL Server viewers contribution. +dialogFactoriesContributionName=Dialog Factories. # Perspective perspectiveName=NoSQL IDE @@ -20,4 +22,8 @@ perspectiveName=NoSQL IDE # Views NoSQL.category=NoSQL IDE ServersExplorer.name=NoSQL Servers -ShellCommandsView.name=Shell Commands \ No newline at end of file +ShellCommandsView.name=Shell Commands + +# Preferences +preferenceNoSQLTitle=NoSQL +preferenceRuntimesTitle=Server Runtimes \ No newline at end of file diff --git a/fr.opensagres.nosql.ide.ui/plugin.xml b/fr.opensagres.nosql.ide.ui/plugin.xml index 66050c7..dc6038a 100644 --- a/fr.opensagres.nosql.ide.ui/plugin.xml +++ b/fr.opensagres.nosql.ide.ui/plugin.xml @@ -4,7 +4,9 @@ - + + @@ -52,5 +54,22 @@ class="fr.opensagres.nosql.ide.ui.internal.views.ShellCommandsView" id="fr.opensagres.nosql.ide.ui.views.ShellCommandsView"> - + + + + + + + + + + + diff --git a/fr.opensagres.nosql.ide.ui/schema/dialogFactories.exsd b/fr.opensagres.nosql.ide.ui/schema/dialogFactories.exsd new file mode 100644 index 0000000..1e3c765 --- /dev/null +++ b/fr.opensagres.nosql.ide.ui/schema/dialogFactories.exsd @@ -0,0 +1,102 @@ + + + + + + + + + Extension point for dialog factories. + + + + + + + + + + + + + + + + + a fully-qualified name of the target extension point + + + + + + + an optional id + + + + + + + an optional name + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 2.0 + + + + + + + + + + + This plugin itself does not have any predefined builders. + + + + + diff --git a/fr.opensagres.nosql.ide.ui/schema/serverImages.exsd b/fr.opensagres.nosql.ide.ui/schema/serverImages.exsd index 8243dfb..a4a643f 100644 --- a/fr.opensagres.nosql.ide.ui/schema/serverImages.exsd +++ b/fr.opensagres.nosql.ide.ui/schema/serverImages.exsd @@ -1,9 +1,9 @@ - + - + Extension point for add NoSQL Server Images. diff --git a/fr.opensagres.nosql.ide.ui/schema/serverViewers.exsd b/fr.opensagres.nosql.ide.ui/schema/serverViewers.exsd new file mode 100644 index 0000000..c1c8aad --- /dev/null +++ b/fr.opensagres.nosql.ide.ui/schema/serverViewers.exsd @@ -0,0 +1,105 @@ + + + + + + + + + Extension point for add NoSQL Server LabelProvider and ContentProvider. + + + + + + + + + + + + + + + + + a fully-qualified name of the target extension point + + + + + + + an optional id + + + + + + + an optional name + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 2.0 + + + + + + + + + + + This plugin itself does not have any predefined builders. + + + + + diff --git a/fr.opensagres.nosql.ide.ui/src/fr/opensagres/nosql/ide/ui/PlatformUI.java b/fr.opensagres.nosql.ide.ui/src/fr/opensagres/nosql/ide/ui/PlatformUI.java index 803d513..5509768 100644 --- a/fr.opensagres.nosql.ide.ui/src/fr/opensagres/nosql/ide/ui/PlatformUI.java +++ b/fr.opensagres.nosql.ide.ui/src/fr/opensagres/nosql/ide/ui/PlatformUI.java @@ -1,6 +1,8 @@ package fr.opensagres.nosql.ide.ui; +import fr.opensagres.nosql.ide.ui.extensions.IDialogFactoryRegistry; import fr.opensagres.nosql.ide.ui.extensions.IServerImageRegistry; +import fr.opensagres.nosql.ide.ui.internal.extensions.DialogFactoryRegistry; import fr.opensagres.nosql.ide.ui.internal.extensions.ServerImageRegistry; public class PlatformUI { @@ -8,6 +10,10 @@ public class PlatformUI { private final static IServerImageRegistry SERVER_IMAGE_REGISTRY_INSTANCE = new ServerImageRegistry(); public static IServerImageRegistry getServerImageRegistry() { - return SERVER_IMAGE_REGISTRY_INSTANCE; + return ServerImageRegistry.getInstance(); + } + + public static IDialogFactoryRegistry getDialogFactoryRegistry() { + return DialogFactoryRegistry.getInstance(); } } diff --git a/fr.opensagres.nosql.ide.ui/src/fr/opensagres/nosql/ide/ui/dialogs/AbstractRuntimeDialog.java b/fr.opensagres.nosql.ide.ui/src/fr/opensagres/nosql/ide/ui/dialogs/AbstractRuntimeDialog.java new file mode 100644 index 0000000..f09ba51 --- /dev/null +++ b/fr.opensagres.nosql.ide.ui/src/fr/opensagres/nosql/ide/ui/dialogs/AbstractRuntimeDialog.java @@ -0,0 +1,184 @@ +package fr.opensagres.nosql.ide.ui.dialogs; + +import org.eclipse.jface.dialogs.Dialog; +import org.eclipse.jface.dialogs.IDialogConstants; +import org.eclipse.jface.dialogs.TitleAreaDialog; +import org.eclipse.swt.SWT; +import org.eclipse.swt.events.ModifyEvent; +import org.eclipse.swt.events.ModifyListener; +import org.eclipse.swt.events.SelectionAdapter; +import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Button; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Control; +import org.eclipse.swt.widgets.DirectoryDialog; +import org.eclipse.swt.widgets.Label; +import org.eclipse.swt.widgets.Shell; +import org.eclipse.swt.widgets.Text; + +import fr.opensagres.nosql.ide.core.model.IServerRuntime; +import fr.opensagres.nosql.ide.core.utils.StringUtils; +import fr.opensagres.nosql.ide.ui.internal.Messages; + +/** + * Dialog used to create and edit {@link IServerRuntime}. + * + */ +public abstract class AbstractRuntimeDialog extends TitleAreaDialog { + + public static final String DIALOG_TYPE = "runtimeDialog"; + + protected Text name; + protected Text installDir; + protected IServerRuntime runtime; + + public AbstractRuntimeDialog(Shell parentShell) { + super(parentShell); + this.runtime = null; + } + + public void setRuntime(IServerRuntime runtime) { + this.runtime = runtime; + } + + @Override + protected Control createDialogArea(Composite parent) { + + String title = runtime == null ? Messages.AddRuntimeDialog_title + : Messages.EditRuntimeDialog_title; + getShell().setText(title); + setTitle(title); + setMessage(Messages.AddRuntimeDialog_desc); + + Composite comp = (Composite) super.createDialogArea(parent); + GridLayout layout = new GridLayout(); + layout.numColumns = 2; + comp.setLayout(layout); + comp.setLayoutData(new GridData(GridData.FILL_BOTH)); + + // Installation directory field. + Label label = new Label(comp, SWT.NONE); + label.setText(Messages.AddRuntimeDialog_installDir); + GridData data = new GridData(); + data.horizontalSpan = 2; + label.setLayoutData(data); + + installDir = new Text(comp, SWT.BORDER); + if (runtime != null) { + installDir.setText(runtime.getInstallDir()); + } + data = new GridData(GridData.FILL_HORIZONTAL); + installDir.setLayoutData(data); + installDir.addModifyListener(new ModifyListener() { + public void modifyText(ModifyEvent e) { + E files = validate(); + if (files != null) { + if (StringUtils.isEmpty(name.getText())) { + try { + String generatedName = getGeneratedName(files); + if (generatedName != null) { + name.setText(generatedName); + } + } catch (Exception e1) { + e1.printStackTrace(); + } + } + } + } + }); + + Button browse = new Button(comp, SWT.NONE); + browse.setText(Messages.browseButton); + browse.addSelectionListener(new SelectionAdapter() { + public void widgetSelected(SelectionEvent se) { + DirectoryDialog dialog = new DirectoryDialog( + AbstractRuntimeDialog.this.getShell()); + dialog.setMessage(Messages.AddRuntimeDialog_selectInstallDir); + dialog.setFilterPath(installDir.getText()); + String selectedDirectory = dialog.open(); + if (selectedDirectory != null) + installDir.setText(selectedDirectory); + } + }); + + // Name field + label = new Label(comp, SWT.NONE); + label.setText(Messages.AddRuntimeDialog_runtimeName); + data = new GridData(); + data.horizontalSpan = 2; + label.setLayoutData(data); + + name = new Text(comp, SWT.BORDER); + if (runtime != null) { + name.setText(runtime.getName()); + } + data = new GridData(GridData.FILL_HORIZONTAL); + name.setLayoutData(data); + name.addModifyListener(new ModifyListener() { + public void modifyText(ModifyEvent e) { + validate(); + } + }); + + Dialog.applyDialogFont(comp); + return comp; + } + + @Override + protected Control createContents(Composite parent) { + Control contents = super.createContents(parent); + validate(); + return contents; + } + + protected E validate() { + E files = validateInstallDir(); + if (files == null) { + super.getButton(IDialogConstants.OK_ID).setEnabled(false); + return null; + } + // 2) validate name + if (StringUtils.isEmpty(name.getText())) { + super.getButton(IDialogConstants.OK_ID).setEnabled(false); + setErrorMessage(Messages.errorRuntimeNameRequired); + } else { + super.getButton(IDialogConstants.OK_ID).setEnabled(true); + setErrorMessage(null); + } + return files; + + } + + @Override + protected void okPressed() { + if (runtime == null) { + try { + runtime = createRuntime(name.getText(), installDir.getText()); + } catch (Exception e) { + e.printStackTrace(); + return; + } + } else { + runtime.setName(name.getText()); + try { + runtime.setInstallDir(installDir.getText()); + } catch (Exception e) { + e.printStackTrace(); + } + } + super.okPressed(); + } + + public IServerRuntime getRuntime() { + return runtime; + } + + protected abstract E validateInstallDir(); + + protected abstract IServerRuntime createRuntime(String name, + String installDir) throws Exception; + + protected abstract String getGeneratedName(E files) throws Exception; +} diff --git a/fr.opensagres.nosql.ide.ui/src/fr/opensagres/nosql/ide/ui/extensions/IDialogFactory.java b/fr.opensagres.nosql.ide.ui/src/fr/opensagres/nosql/ide/ui/extensions/IDialogFactory.java new file mode 100644 index 0000000..8f8a87b --- /dev/null +++ b/fr.opensagres.nosql.ide.ui/src/fr/opensagres/nosql/ide/ui/extensions/IDialogFactory.java @@ -0,0 +1,10 @@ +package fr.opensagres.nosql.ide.ui.extensions; + +import org.eclipse.jface.window.Window; +import org.eclipse.swt.widgets.Shell; + +public interface IDialogFactory { + + Window create(Shell shell); + +} diff --git a/fr.opensagres.nosql.ide.ui/src/fr/opensagres/nosql/ide/ui/extensions/IDialogFactoryRegistry.java b/fr.opensagres.nosql.ide.ui/src/fr/opensagres/nosql/ide/ui/extensions/IDialogFactoryRegistry.java new file mode 100644 index 0000000..3742347 --- /dev/null +++ b/fr.opensagres.nosql.ide.ui/src/fr/opensagres/nosql/ide/ui/extensions/IDialogFactoryRegistry.java @@ -0,0 +1,9 @@ +package fr.opensagres.nosql.ide.ui.extensions; + +import fr.opensagres.nosql.ide.core.extensions.IServerType; + +public interface IDialogFactoryRegistry { + + IDialogFactory getFactory(IServerType serverType, String dialogType); + +} diff --git a/fr.opensagres.nosql.ide.ui/src/fr/opensagres/nosql/ide/ui/internal/Messages.java b/fr.opensagres.nosql.ide.ui/src/fr/opensagres/nosql/ide/ui/internal/Messages.java new file mode 100644 index 0000000..dba9a70 --- /dev/null +++ b/fr.opensagres.nosql.ide.ui/src/fr/opensagres/nosql/ide/ui/internal/Messages.java @@ -0,0 +1,63 @@ +package fr.opensagres.nosql.ide.ui.internal; + +import org.eclipse.osgi.util.NLS; + +public class Messages extends NLS { + + private static final String BUNDLE_NAME = "fr.opensagres.nosql.ide.ui.internal.Messages";//$NON-NLS-1$ + + public static String browseButton; + public static String addButton; + public static String editButton; + public static String removeButton; + + // ****************** ServerLaunchConfigurationTab ****************** + + public static String ServerLaunchConfigurationTab_name; + + // ****************** MongoRuntimePreferencePage ****************** + public static String ServerRuntimePreferencePage_title; + public static String ServerRuntimePreferencePage_desc; + public static String ServerRuntimePreferencePage_serverType; + public static String InstalledRuntimesBlock_desc; + public static String InstalledRuntimesBlock_nameColumn; + public static String InstalledRuntimesBlock_installDirColumn; + + // ****************** AddRuntimeDialog ****************** + public static String AddRuntimeDialog_title; + public static String EditRuntimeDialog_title; + public static String AddRuntimeDialog_desc; + public static String AddRuntimeDialog_runtimeName; + public static String AddRuntimeDialog_installDir; + public static String AddRuntimeDialog_selectInstallDir; + + // MongodLaunchConfigurationTab + public static String jobStarting; + public static String jobRestarting; + public static String jobStopping; + public static String serverLaunchDescription; + public static String serverLaunchServer; + public static String serverLaunchHost; + public static String serverLaunchRuntime; + + // Server Error + public static String errorServerAlreadyRunning; + public static String errorInvalidServer; + public static String errorNoServerSelected; + public static String errorStartFailed; + public static String errorStartTimeout; + public static String errorStopFailed; + // Runtime error + public static String errorRuntimeNameRequired; + public static String errorInstallDirRequired; + public static String errorInstallDir_baseDirNotExists; + public static String errorInstallDir_baseDirNotDir; + public static String errorInstallDir_binDirNotExists; + public static String errorInstallDir_processFileNotExists; + + static { + // load message values from bundle file + NLS.initializeMessages(BUNDLE_NAME, Messages.class); + } + +} diff --git a/fr.opensagres.nosql.ide.ui/src/fr/opensagres/nosql/ide/ui/internal/Messages.properties b/fr.opensagres.nosql.ide.ui/src/fr/opensagres/nosql/ide/ui/internal/Messages.properties new file mode 100644 index 0000000..1bd2f7f --- /dev/null +++ b/fr.opensagres.nosql.ide.ui/src/fr/opensagres/nosql/ide/ui/internal/Messages.properties @@ -0,0 +1,55 @@ +browseButton=Browse... +addButton=Add... +editButton=Edit.. +removeButton=Remove + +################################################################# +# NewServerWizardPage +################################################################# +ServerLaunchConfigurationTab_name=Server + +################################################################# +# ServerRuntimePreferencePage +################################################################# +ServerRuntimePreferencePage_title=NoSQL Server Runtime Environments +ServerRuntimePreferencePage_desc=Add, remove, or edit Server runtime environments. +ServerRuntimePreferencePage_serverType=Server type (to add): +InstalledRuntimesBlock_desc=Server runtime e&nvironments: +InstalledRuntimesBlock_nameColumn=Name +InstalledRuntimesBlock_installDirColumn=Install directory + +################################################################# +# AddRuntimeDialog +################################################################# +AddRuntimeDialog_title=New MongoDB Runtime Environnment +EditRuntimeDialog_title=Edit MongoDB Runtime Environnment +AddRuntimeDialog_desc=Select the MongoDB installation directory. +AddRuntimeDialog_runtimeName=Name\: +AddRuntimeDialog_installDir=Installation directory: +AddRuntimeDialog_selectInstallDir=Select the MongoDB installation directory. + +# Server launch configuration tab +serverLaunchDescription=This launch configuration can be used to launch the local MongoDB server specified below. To access further options for configuring the server, open the server's editor from the MongoDB Explorer. +serverLaunchServer=Server: +serverLaunchRuntime=Runtime Environment: +serverLaunchHost=Host name: + +# Server Error Messages +errorServerAlreadyRunning=Server already running +errorNoServerSelected=No server selected +errorInvalidServer=The server is invalid or missing +errorStartTimeout=Server {0} was unable to start within {1} seconds. If the server requires more time, try increasing the timeout in the server editor. +errorStartFailed=Server {0} failed to start. +errorStopFailed=Server {0} failed to stop. + +# Runtime Error Messages +errorRuntimeNameRequired=Name is required. +errorInstallDirRequired=Install directory is required. +errorInstallDir_baseDirNotExists=The MongoDB {0} base directory doesn't exist. +errorInstallDir_baseDirNotDir=The MongoDB {0} path is not a directory. +errorInstallDir_binDirNotExists=The MongoDB {0} directory doesn't exist. +errorInstallDir_processFileNotExists=The MongoDB {0} process file doesn't exist. + +jobStarting=Starting {0} +jobStopping=Stopping {0} +jobRestarting=Restarting {0} diff --git a/fr.opensagres.nosql.ide.ui/src/fr/opensagres/nosql/ide/ui/internal/Trace.java b/fr.opensagres.nosql.ide.ui/src/fr/opensagres/nosql/ide/ui/internal/Trace.java new file mode 100644 index 0000000..fb63154 --- /dev/null +++ b/fr.opensagres.nosql.ide.ui/src/fr/opensagres/nosql/ide/ui/internal/Trace.java @@ -0,0 +1,145 @@ +package fr.opensagres.nosql.ide.ui.internal; + +import java.text.SimpleDateFormat; +import java.util.Date; +import java.util.HashSet; +import java.util.Set; + +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.Status; +import org.eclipse.osgi.service.debug.DebugOptions; +import org.eclipse.osgi.service.debug.DebugOptionsListener; + +/** + * Helper class to route trace output. + */ +public class Trace implements DebugOptionsListener { + + private static final SimpleDateFormat sdf = new SimpleDateFormat( + "dd/MM/yy HH:mm.ss.SSS"); //$NON-NLS-1$ + + private static Set logged = new HashSet(); + + // tracing enablement flags + public static boolean CONFIG = false; + public static boolean INFO = false; + public static boolean WARNING = false; + public static boolean SEVERE = false; + public static boolean FINER = false; + public static boolean FINEST = false; + public static boolean RESOURCES = false; + public static boolean EXTENSION_POINT = false; + public static boolean LISTENERS = false; + public static boolean RUNTIME_TARGET = false; + public static boolean PERFORMANCE = false; + public static boolean PUBLISHING = false; + + // tracing levels. One most exist for each debug option + public final static String STRING_CONFIG = "/config"; //$NON-NLS-1$ + public final static String STRING_INFO = "/info"; //$NON-NLS-1$ + public final static String STRING_WARNING = "/warning"; //$NON-NLS-1$ + public final static String STRING_SEVERE = "/severe"; //$NON-NLS-1$ + public final static String STRING_FINER = "/finer"; //$NON-NLS-1$ + public final static String STRING_FINEST = "/finest"; //$NON-NLS-1$ + public final static String STRING_RESOURCES = "/resources"; //$NON-NLS-1$ + public final static String STRING_EXTENSION_POINT = "/extension_point"; //$NON-NLS-1$ + public final static String STRING_LISTENERS = "/listeners"; //$NON-NLS-1$ + public final static String STRING_RUNTIME_TARGET = "/runtime_target"; //$NON-NLS-1$ + public final static String STRING_PERFORMANCE = "/performance"; //$NON-NLS-1$ + public final static String STRING_PUBLISHING = "/publishing"; //$NON-NLS-1$ + + /** + * Trace constructor. This should never be explicitly called by clients and + * is used to register this class with the {@link DebugOptions} service. + */ + public Trace() { + super(); + } + + /* + * (non-Javadoc) + * + * @see + * org.eclipse.osgi.service.debug.DebugOptionsListener#optionsChanged(org + * .eclipse.osgi.service.debug.DebugOptions) + */ + public void optionsChanged(DebugOptions options) { + Trace.CONFIG = options.getBooleanOption(Activator.PLUGIN_ID + + Trace.STRING_CONFIG, false); + Trace.INFO = options.getBooleanOption(Activator.PLUGIN_ID + + Trace.STRING_INFO, false); + Trace.WARNING = options.getBooleanOption(Activator.PLUGIN_ID + + Trace.STRING_WARNING, false); + Trace.SEVERE = options.getBooleanOption(Activator.PLUGIN_ID + + Trace.STRING_SEVERE, false); + Trace.FINER = options.getBooleanOption(Activator.PLUGIN_ID + + Trace.STRING_FINER, false); + Trace.FINEST = options.getBooleanOption(Activator.PLUGIN_ID + + Trace.STRING_FINEST, false); + Trace.RESOURCES = options.getBooleanOption(Activator.PLUGIN_ID + + Trace.STRING_RESOURCES, false); + Trace.EXTENSION_POINT = options.getBooleanOption(Activator.PLUGIN_ID + + Trace.STRING_EXTENSION_POINT, false); + Trace.LISTENERS = options.getBooleanOption(Activator.PLUGIN_ID + + Trace.STRING_LISTENERS, false); + Trace.RUNTIME_TARGET = options.getBooleanOption(Activator.PLUGIN_ID + + Trace.STRING_RUNTIME_TARGET, false); + Trace.PERFORMANCE = options.getBooleanOption(Activator.PLUGIN_ID + + Trace.STRING_PERFORMANCE, false); + Trace.PUBLISHING = options.getBooleanOption(Activator.PLUGIN_ID + + Trace.STRING_PUBLISHING, false); + } + + /** + * Trace the given message. + * + * @param level + * The tracing level. + * @param s + * The message to trace + */ + public static void trace(final String level, String s) { + + Trace.trace(level, s, null); + } + + /** + * Trace the given message and exception. + * + * @param level + * The tracing level. + * @param s + * The message to trace + * @param t + * A {@link Throwable} to trace + */ + public static void trace(final String level, String s, Throwable t) { + if (s == null) { + return; + } + if (Trace.STRING_SEVERE.equals(level)) { + if (!logged.contains(s)) { + Activator + .getDefault() + .getLog() + .log(new Status(IStatus.ERROR, Activator.PLUGIN_ID, s, + t)); + logged.add(s); + } + } + if (Activator.getDefault().isDebugging()) { + final StringBuffer sb = new StringBuffer(Activator.PLUGIN_ID); + sb.append(" "); //$NON-NLS-1$ + sb.append(level); + sb.append(" "); //$NON-NLS-1$ + sb.append(sdf.format(new Date())); + sb.append(" "); //$NON-NLS-1$ + sb.append(s); + System.out.println(sb.toString()); + if (t != null) { + t.printStackTrace(); + } + } + } + +} \ No newline at end of file diff --git a/fr.opensagres.nosql.ide.ui/src/fr/opensagres/nosql/ide/ui/internal/extensions/DialogFactoryRegistry.java b/fr.opensagres.nosql.ide.ui/src/fr/opensagres/nosql/ide/ui/internal/extensions/DialogFactoryRegistry.java new file mode 100644 index 0000000..e88f13c --- /dev/null +++ b/fr.opensagres.nosql.ide.ui/src/fr/opensagres/nosql/ide/ui/internal/extensions/DialogFactoryRegistry.java @@ -0,0 +1,155 @@ +/******************************************************************************* + * Copyright (C) 2012 Angelo Zerr , Pascal Leclercq + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Angelo ZERR - initial API and implementation + * Pascal Leclercq - initial API and implementation + *******************************************************************************/ +package fr.opensagres.nosql.ide.ui.internal.extensions; + +import java.util.Collection; +import java.util.HashMap; +import java.util.Map; + +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IConfigurationElement; +import org.eclipse.core.runtime.IExtensionDelta; +import org.eclipse.core.runtime.IExtensionRegistry; +import org.eclipse.core.runtime.Platform; + +import fr.opensagres.nosql.ide.core.extensions.AbstractRegistry; +import fr.opensagres.nosql.ide.core.extensions.IServerType; +import fr.opensagres.nosql.ide.ui.extensions.IDialogFactory; +import fr.opensagres.nosql.ide.ui.extensions.IDialogFactoryRegistry; +import fr.opensagres.nosql.ide.ui.internal.Activator; +import fr.opensagres.nosql.ide.ui.internal.Trace; + +/** + * Registry which holds instance of {@link IDialogFactory} created by the + * fr.opensagres.nosql.ide.core.dialogFactorys" extension point. + * + */ +public class DialogFactoryRegistry extends AbstractRegistry implements + IDialogFactoryRegistry { + + private static final IDialogFactoryRegistry INSTANCE = new DialogFactoryRegistry(); + + private static final String DIALOG_FACTORY_ELT = "dialogFactory"; + public static final String SERVER_TYPE_ATTR = "serverType"; + private static final String DIALOG_TYPE_ATTR = "dialogType"; + private static final String DIALOG_FACTORIES_EXTENSION_POINT = "dialogFactories"; + + public static IDialogFactoryRegistry getInstance() { + return INSTANCE; + } + + private Map dialogFactories = new HashMap(); + + /** + * Return the {@link IDialogFactory} retrieved by the given id. + * + * @param id + * @return + */ + public IDialogFactory getFactory(IServerType serverType, String dialogType) { + if (serverType == null || dialogType == null) { + throw new IllegalArgumentException(); + } + loadRegistryIfNedded(); + String key = getKey(serverType, dialogType); + return dialogFactories.get(key); + } + + private String getKey(IServerType serverType, String dialogType) { + return new StringBuilder(serverType.getId()).append("_").append(dialogType) + .toString(); + } + + /** + * Return the list of the {@link IDialogFactory}. + * + * @return + */ + public Collection getFactories() { + loadRegistryIfNedded(); + return dialogFactories.values(); + } + + @Override + protected void handleExtensionDelta(IExtensionDelta delta) { + if (delta.getKind() == IExtensionDelta.ADDED) { + IConfigurationElement[] cf = delta.getExtension() + .getConfigurationElements(); + parseDialogFactoryManagers(cf); + } else { + // TODO : remove references + } + + } + + protected synchronized void loadRegistry() { + if (isRegistryIntialized()) { + return; + } + IExtensionRegistry registry = Platform.getExtensionRegistry(); + if (registry != null) { + IConfigurationElement[] cf = registry.getConfigurationElementsFor( + getPluginId(), getExtensionPoint()); + parseDialogFactoryManagers(cf); + } + } + + /** + * Parse elements of the extension poit and create for each dialog element + * an instance of {@link IDialogFactory}. + * + *
+	 * 	  
+	 *    
+	 *    
+	 * 
+	 * 
+ * + * @param cf + */ + private void parseDialogFactoryManagers(IConfigurationElement[] cf) { + for (IConfigurationElement ce : cf) { + IServerType serverType = null; + String serverTypeId = null; + String dialogType = null; + IDialogFactory factory = null; + if (DIALOG_FACTORY_ELT.equals(ce.getName())) { + serverTypeId = ce.getAttribute(SERVER_TYPE_ATTR); + serverType = fr.opensagres.nosql.ide.core.Platform + .getServerTypeRegistry().getType(serverTypeId); + dialogType = ce.getAttribute(DIALOG_TYPE_ATTR); + try { + factory = (IDialogFactory) ce + .createExecutableExtension(CLASS_ATTR); + String key = getKey(serverType, dialogType); + dialogFactories.put(key, factory); + } catch (CoreException e) { + Trace.trace(Trace.STRING_SEVERE, e.getMessage()); + } + } + } + } + + @Override + protected String getPluginId() { + return Activator.PLUGIN_ID; + } + + @Override + protected String getExtensionPoint() { + return DIALOG_FACTORIES_EXTENSION_POINT; + } + +} diff --git a/fr.opensagres.nosql.ide.ui/src/fr/opensagres/nosql/ide/ui/internal/extensions/ServerImageRegistry.java b/fr.opensagres.nosql.ide.ui/src/fr/opensagres/nosql/ide/ui/internal/extensions/ServerImageRegistry.java index 160005c..24dbb0e 100644 --- a/fr.opensagres.nosql.ide.ui/src/fr/opensagres/nosql/ide/ui/internal/extensions/ServerImageRegistry.java +++ b/fr.opensagres.nosql.ide.ui/src/fr/opensagres/nosql/ide/ui/internal/extensions/ServerImageRegistry.java @@ -35,6 +35,8 @@ public class ServerImageRegistry extends AbstractUIRegistry implements IServerImageRegistry { + private static final IServerImageRegistry INSTANCE = new ServerImageRegistry(); + private static final String SERVER_IMAGE_ELT = "serverImage"; public static final String SERVER_TYPE_ATTR = "serverType"; @@ -42,6 +44,10 @@ public class ServerImageRegistry extends AbstractUIRegistry implements private Map serverImages = new HashMap(); + public static IServerImageRegistry getInstance() { + return INSTANCE; + } + /** * Return the {@link IServerImage} retrieved by the given id. * @@ -118,7 +124,7 @@ private void parseServerImageManagers(IConfigurationElement[] cf) { for (IConfigurationElement ce : cf) { String serverTypeId = null; Image icon = null; - if (SERVER_IMAGE_ELT.equals(ce.getName())) { + if (SERVER_IMAGE_ELT.equals(ce.getName())) { serverTypeId = ce.getAttribute(SERVER_TYPE_ATTR); IServerType serverType = fr.opensagres.nosql.ide.core.Platform .getServerTypeRegistry().getType(serverTypeId); diff --git a/fr.opensagres.nosql.ide.ui/src/fr/opensagres/nosql/ide/ui/internal/preferences/AbstractTableBlock.java b/fr.opensagres.nosql.ide.ui/src/fr/opensagres/nosql/ide/ui/internal/preferences/AbstractTableBlock.java new file mode 100644 index 0000000..cd88fc4 --- /dev/null +++ b/fr.opensagres.nosql.ide.ui/src/fr/opensagres/nosql/ide/ui/internal/preferences/AbstractTableBlock.java @@ -0,0 +1,84 @@ +/******************************************************************************* + * Copyright (c) 2007 Chase Technology Ltd - http://www.chasetechnology.co.uk + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Doug Satchwell (Chase Technology Ltd) - initial API and implementation + *******************************************************************************/ +package fr.opensagres.nosql.ide.ui.internal.preferences; + +import org.eclipse.jface.dialogs.IDialogSettings; +import org.eclipse.swt.widgets.Table; + +/** + * An AbstractLaunchConfigurationTab specialised for blocks that + * contain a table. This abstract class conveniently saves and restores the + * table's column settings. + * + * @author Doug Satchwell + * @since 1.0 + */ +public abstract class AbstractTableBlock { + private int fSortColumn; + + protected abstract Table getTable(); + + protected abstract IDialogSettings getDialogSettings(); + + protected abstract String getQualifier(); + + protected void setSortColumn(int column) { + fSortColumn = column; + } + + /** + * Persist table settings into the give dialog store, prefixed with the + * given key. + */ + public void saveColumnSettings() { + int columnCount = getTable().getColumnCount(); + for (int i = 0; i < columnCount; i++) { + getDialogSettings() + .put( + getQualifier() + ".columnWidth" + i, getTable().getColumn(i).getWidth()); //$NON-NLS-1$ + } + getDialogSettings().put(getQualifier() + ".sortColumn", fSortColumn); //$NON-NLS-1$ + } + + /** + * Restore table settings from the given dialog store using the given key. + */ + public void restoreColumnSettings() { + getTable().layout(true); + restoreColumnWidths(getDialogSettings(), getQualifier()); + int col = 0; + try { + col = getDialogSettings().getInt(getQualifier() + ".sortColumn"); //$NON-NLS-1$ + } catch (NumberFormatException e) { + col = 1; + } + setSortColumn(col); + } + + private void restoreColumnWidths(IDialogSettings settings, String qualifier) { + int columnCount = getTable().getColumnCount(); + for (int i = 0; i < columnCount; i++) { + int width = -1; + try { + width = settings.getInt(qualifier + ".columnWidth" + i); //$NON-NLS-1$ + } catch (NumberFormatException e) { + } + + if (width > 0) + getTable().getColumn(i).setWidth(width); + } + } + + public void dispose() { + if (getTable() != null && !getTable().isDisposed()) + saveColumnSettings(); + } +} diff --git a/fr.opensagres.nosql.ide.ui/src/fr/opensagres/nosql/ide/ui/internal/preferences/InstalledRuntimesBlock.java b/fr.opensagres.nosql.ide.ui/src/fr/opensagres/nosql/ide/ui/internal/preferences/InstalledRuntimesBlock.java new file mode 100644 index 0000000..296f1d7 --- /dev/null +++ b/fr.opensagres.nosql.ide.ui/src/fr/opensagres/nosql/ide/ui/internal/preferences/InstalledRuntimesBlock.java @@ -0,0 +1,575 @@ +package fr.opensagres.nosql.ide.ui.internal.preferences; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.Iterator; +import java.util.List; + +import org.eclipse.core.runtime.ListenerList; +import org.eclipse.jface.dialogs.IDialogSettings; +import org.eclipse.jface.layout.GridDataFactory; +import org.eclipse.jface.viewers.CheckStateChangedEvent; +import org.eclipse.jface.viewers.CheckboxTableViewer; +import org.eclipse.jface.viewers.ComboViewer; +import org.eclipse.jface.viewers.DoubleClickEvent; +import org.eclipse.jface.viewers.ICheckStateListener; +import org.eclipse.jface.viewers.IDoubleClickListener; +import org.eclipse.jface.viewers.ISelection; +import org.eclipse.jface.viewers.ISelectionChangedListener; +import org.eclipse.jface.viewers.ISelectionProvider; +import org.eclipse.jface.viewers.IStructuredContentProvider; +import org.eclipse.jface.viewers.IStructuredSelection; +import org.eclipse.jface.viewers.ITableLabelProvider; +import org.eclipse.jface.viewers.LabelProvider; +import org.eclipse.jface.viewers.SelectionChangedEvent; +import org.eclipse.jface.viewers.StructuredSelection; +import org.eclipse.jface.viewers.Viewer; +import org.eclipse.jface.viewers.ViewerSorter; +import org.eclipse.jface.window.Window; +import org.eclipse.swt.SWT; +import org.eclipse.swt.events.KeyAdapter; +import org.eclipse.swt.events.KeyEvent; +import org.eclipse.swt.events.SelectionAdapter; +import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.graphics.Font; +import org.eclipse.swt.graphics.Image; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Button; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Control; +import org.eclipse.swt.widgets.Event; +import org.eclipse.swt.widgets.Label; +import org.eclipse.swt.widgets.Listener; +import org.eclipse.swt.widgets.Shell; +import org.eclipse.swt.widgets.Table; +import org.eclipse.swt.widgets.TableColumn; + +import fr.opensagres.nosql.ide.core.Platform; +import fr.opensagres.nosql.ide.core.extensions.IServerType; +import fr.opensagres.nosql.ide.core.model.IServerRuntime; +import fr.opensagres.nosql.ide.core.utils.CollectionUtils; +import fr.opensagres.nosql.ide.ui.PlatformUI; +import fr.opensagres.nosql.ide.ui.dialogs.AbstractRuntimeDialog; +import fr.opensagres.nosql.ide.ui.extensions.IDialogFactory; +import fr.opensagres.nosql.ide.ui.internal.Activator; +import fr.opensagres.nosql.ide.ui.internal.Messages; +import fr.opensagres.nosql.ide.ui.viewers.ServerTypeContentProvider; +import fr.opensagres.nosql.ide.ui.viewers.ServerTypeLabelProvider; + +public class InstalledRuntimesBlock extends AbstractTableBlock implements + ISelectionProvider { + private Composite fControl; + private final List runtimes = new ArrayList(); + private CheckboxTableViewer tableViewer; + private Button fAddButton; + private Button fRemoveButton; + private Button fEditButton; + private final ListenerList fSelectionListeners = new ListenerList(); + private ISelection fPrevSelection = new StructuredSelection(); + private ComboViewer serverTypeViewer; + + public void addSelectionChangedListener(ISelectionChangedListener listener) { + fSelectionListeners.add(listener); + } + + public void removeSelectionChangedListener( + ISelectionChangedListener listener) { + fSelectionListeners.remove(listener); + } + + public ISelection getSelection() { + return new StructuredSelection(tableViewer.getCheckedElements()); + } + + public void setSelection(ISelection selection) { + if (selection instanceof IStructuredSelection) { + if (!selection.equals(fPrevSelection)) { + fPrevSelection = selection; + Object jre = ((IStructuredSelection) selection) + .getFirstElement(); + if (jre == null) { + tableViewer.setCheckedElements(new Object[0]); + } else { + tableViewer.setCheckedElements(new Object[] { jre }); + tableViewer.reveal(jre); + } + fireSelectionChanged(); + } + } + } + + public void createControl(Composite ancestor) { + + Composite parent = new Composite(ancestor, SWT.NULL); + GridLayout layout = new GridLayout(); + layout.numColumns = 2; + layout.marginHeight = 0; + layout.marginWidth = 0; + parent.setLayout(layout); + Font font = ancestor.getFont(); + parent.setFont(font); + fControl = parent; + + GridData data; + + // Server type combo + Composite p = new Composite(parent, SWT.NONE); + layout = new GridLayout(); + layout.numColumns = 2; + layout.marginHeight = 0; + layout.marginWidth = 0; + p.setLayout(layout); + data = new GridData(GridData.FILL_HORIZONTAL); + data.horizontalSpan = 2; + p.setLayoutData(data); + + Label serverTypeLabel = new Label(p, SWT.NONE); + serverTypeLabel + .setText(Messages.ServerRuntimePreferencePage_serverType); + serverTypeLabel.setFont(font); + + serverTypeViewer = new ComboViewer(p, SWT.READ_ONLY); + serverTypeViewer + .setLabelProvider(ServerTypeLabelProvider.getInstance()); + serverTypeViewer.setContentProvider(ServerTypeContentProvider + .getInstance()); + data = new GridData(GridData.FILL_HORIZONTAL); + data.horizontalSpan = 1; + serverTypeViewer.getControl().setLayoutData(data); + Collection serverTypes = Platform.getServerTypeRegistry() + .getTypes(); + serverTypeViewer.setInput(serverTypes); + serverTypeViewer.getCombo().addSelectionListener( + new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent e) { + fAddButton.setEnabled(true); + } + }); + IServerType firstServerType = CollectionUtils + .getFirstElement(serverTypes); + if (firstServerType != null) { + serverTypeViewer.setSelection(new StructuredSelection( + firstServerType)); + } + + // Description of the table + Label tableLabel = new Label(parent, SWT.NONE); + tableLabel.setText(Messages.InstalledRuntimesBlock_desc); + data = new GridData(); + data.horizontalSpan = 2; + tableLabel.setLayoutData(data); + tableLabel.setFont(font); + + // List of runtimes + Table fTable = new Table(parent, SWT.CHECK | SWT.BORDER + | SWT.FULL_SELECTION | SWT.V_SCROLL); + + data = new GridData(GridData.FILL_BOTH); + data.widthHint = 450; + fTable.setLayoutData(data); + fTable.setFont(font); + + fTable.setHeaderVisible(true); + fTable.setLinesVisible(true); + + // Name column + TableColumn column1 = new TableColumn(fTable, SWT.NONE); + column1.setWidth(180); + column1.setResizable(true); + column1.setText(Messages.InstalledRuntimesBlock_nameColumn); + column1.addSelectionListener(new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent e) { + sortByName(); + } + }); + + // Installation directory column + TableColumn column2 = new TableColumn(fTable, SWT.NONE); + column2.setWidth(180); + column2.setResizable(true); + column2.setText(Messages.InstalledRuntimesBlock_installDirColumn); + column2.addSelectionListener(new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent e) { + sortByInstallDir(); + } + }); + + tableViewer = new CheckboxTableViewer(fTable); + tableViewer.setLabelProvider(new RuntimesLabelProvider()); + tableViewer.setContentProvider(new RuntimesContentProvider()); + + tableViewer + .addSelectionChangedListener(new ISelectionChangedListener() { + public void selectionChanged(SelectionChangedEvent evt) { + enableButtons(); + } + }); + + tableViewer.addCheckStateListener(new ICheckStateListener() { + public void checkStateChanged(CheckStateChangedEvent event) { + if (event.getChecked()) { + setCheckedInstall((IServerRuntime) event.getElement()); + } else { + setCheckedInstall(null); + } + } + }); + + tableViewer.addDoubleClickListener(new IDoubleClickListener() { + public void doubleClick(DoubleClickEvent e) { + if (!tableViewer.getSelection().isEmpty()) { + editRuntime(); + } + } + }); + fTable.addKeyListener(new KeyAdapter() { + @Override + public void keyPressed(KeyEvent event) { + if (event.character == SWT.DEL && event.stateMask == 0) { + removeRuntimes(); + } + } + }); + + Composite buttons = new Composite(parent, SWT.NULL); + buttons.setLayoutData(new GridData(GridData.VERTICAL_ALIGN_BEGINNING)); + layout = new GridLayout(); + layout.marginHeight = 0; + layout.marginWidth = 0; + buttons.setLayout(layout); + buttons.setFont(font); + + fAddButton = createPushButton(buttons, Messages.addButton); + fAddButton.addListener(SWT.Selection, new Listener() { + public void handleEvent(Event evt) { + addRuntime(); + } + }); + fAddButton.setEnabled(false); + + fEditButton = createPushButton(buttons, Messages.editButton); + fEditButton.addListener(SWT.Selection, new Listener() { + public void handleEvent(Event evt) { + editRuntime(); + } + }); + + fRemoveButton = createPushButton(buttons, Messages.removeButton); + fRemoveButton.addListener(SWT.Selection, new Listener() { + public void handleEvent(Event evt) { + removeRuntimes(); + } + }); + + // copied from ListDialogField.CreateSeparator() + Label separator = new Label(buttons, SWT.NONE); + separator.setVisible(false); + GridData gd = new GridData(); + gd.horizontalAlignment = GridData.FILL; + gd.verticalAlignment = GridData.BEGINNING; + gd.heightHint = 4; + separator.setLayoutData(gd); + + fillWithWorkspaceRuntimes(); + enableButtons(); + + restoreColumnSettings(); + } + + protected void fillWithWorkspaceRuntimes() { + setRuntimes(Platform.getServerRuntimeManager().getRuntimes()); + } + + private void fireSelectionChanged() { + SelectionChangedEvent event = new SelectionChangedEvent(this, + getSelection()); + Object[] listeners = fSelectionListeners.getListeners(); + for (Object element : listeners) { + ISelectionChangedListener listener = (ISelectionChangedListener) element; + listener.selectionChanged(event); + } + } + + /** + * Sorts by type, and name within type. + */ + // private void sortByType() { + // tableViewer.setSorter(new ViewerSorter() { + // @Override + // public int compare(Viewer viewer, Object e1, Object e2) { + // IServerRuntime left = (IServerRuntime) e1; + // IServerRuntime right = (IServerRuntime) e2; + // return left + // .getRuntimeType() + // .getLabel() + // .compareToIgnoreCase( + // right.getRuntimeType().getLabel()); + // } + // + // @Override + // public boolean isSorterProperty(Object element, String property) { + // return true; + // } + // }); + // } + + private void sortByInstallDir() { + tableViewer.setSorter(new ViewerSorter() { + @Override + public int compare(Viewer viewer, Object e1, Object e2) { + IServerRuntime left = (IServerRuntime) e1; + IServerRuntime right = (IServerRuntime) e2; + return left.getInstallDir().compareToIgnoreCase( + right.getInstallDir()); + } + + @Override + public boolean isSorterProperty(Object element, String property) { + return true; + } + }); + } + + /** + * Sorts by name. + */ + private void sortByName() { + tableViewer.setSorter(new ViewerSorter() { + @Override + public int compare(Viewer viewer, Object e1, Object e2) { + if ((e1 instanceof IServerRuntime) + && (e2 instanceof IServerRuntime)) { + IServerRuntime left = (IServerRuntime) e1; + IServerRuntime right = (IServerRuntime) e2; + return left.getName().compareToIgnoreCase(right.getName()); + } + return super.compare(viewer, e1, e2); + } + + @Override + public boolean isSorterProperty(Object element, String property) { + return true; + } + }); + } + + private void enableButtons() { + IStructuredSelection selection = (IStructuredSelection) tableViewer + .getSelection(); + int selectionCount = selection.size(); + fEditButton.setEnabled(selectionCount == 1); + fRemoveButton.setEnabled(selectionCount == 1); + fAddButton.setEnabled(!serverTypeViewer.getSelection().isEmpty()); + // if (selectionCount > 0 + // && selectionCount < tableViewer.getTable().getItemCount()) { + // //Iterator iterator = selection.iterator(); + // // while (iterator.hasNext()) { + // // IServerRuntime install = (IServerRuntime) iterator.next(); + // // // if (install.isContributed()) { + // // fRemoveButton.setEnabled(false); + // // return; + // // // } + // // } + // fRemoveButton.setEnabled(true); + // } else { + // fRemoveButton.setEnabled(false); + // } + } + + protected Button createPushButton(Composite parent, String label) { + Button button = new Button(parent, SWT.PUSH); + button.setText(label); + button.setLayoutData(GridDataFactory.fillDefaults().create()); + return button; + } + + public Control getControl() { + return fControl; + } + + protected void setRuntimes(List vms) { + runtimes.clear(); + for (IServerRuntime element : vms) { + runtimes.add(element); + } + tableViewer.setInput(runtimes); + // tableViewer.refresh(); + } + + public IServerRuntime[] getRuntimes() { + return runtimes.toArray(new IServerRuntime[runtimes.size()]); + } + + private void addRuntime() { + IServerType serverType = (IServerType) ((IStructuredSelection) serverTypeViewer + .getSelection()).getFirstElement(); + AbstractRuntimeDialog dialog = createDialog(serverType, + fAddButton.getShell()); + if (dialog != null && dialog.open() == Window.OK) { + runtimeAdded(dialog.getRuntime()); + } + } + + public void runtimeAdded(IServerRuntime install) { + runtimes.add(install); + tableViewer.add(install); + tableViewer.setSelection(new StructuredSelection(install), true); + } + + public boolean isDuplicateName(String name) { + for (int i = 0; i < runtimes.size(); i++) { + IServerRuntime install = runtimes.get(i); + if (install.getName().equals(name)) { + return true; + } + } + return false; + } + + private void editRuntime() { + IStructuredSelection selection = (IStructuredSelection) tableViewer + .getSelection(); + IServerRuntime runtime = (IServerRuntime) selection.getFirstElement(); + if (runtime == null) { + return; + } + + AbstractRuntimeDialog dialog = createDialog(runtime.getServerType(), + fEditButton.getShell()); + if (dialog != null) { + dialog.setRuntime(runtime); + if (dialog.open() == Window.OK) { + // refresh viewer + tableViewer.refresh(runtime); + } + } + } + + private AbstractRuntimeDialog createDialog(IServerType serverType, + Shell parentShell) { + IDialogFactory factory = PlatformUI.getDialogFactoryRegistry() + .getFactory(serverType, AbstractRuntimeDialog.DIALOG_TYPE); + if (factory != null) { + return (AbstractRuntimeDialog) factory.create(parentShell); + } + return null; + } + + private void removeRuntimes() { + IStructuredSelection selection = (IStructuredSelection) tableViewer + .getSelection(); + IServerRuntime[] vms = new IServerRuntime[selection.size()]; + Iterator iter = selection.iterator(); + int i = 0; + while (iter.hasNext()) { + vms[i] = (IServerRuntime) iter.next(); + i++; + } + removeRuntimes(vms); + } + + public void removeRuntimes(IServerRuntime[] theInstalls) { + IStructuredSelection prev = (IStructuredSelection) getSelection(); + for (IServerRuntime element : theInstalls) { + runtimes.remove(element); + } + tableViewer.refresh(); + IStructuredSelection curr = (IStructuredSelection) getSelection(); + if (!curr.equals(prev)) { + IServerRuntime[] installs = getRuntimes(); + if (curr.size() == 0 && installs.length == 1) { + // pick a default install automatically + setSelection(new StructuredSelection(installs[0])); + } else { + fireSelectionChanged(); + } + } + } + + public void setCheckedInstall(IServerRuntime install) { + if (install == null) { + setSelection(new StructuredSelection()); + } else { + setSelection(new StructuredSelection(install)); + } + } + + public IServerRuntime getCheckedInstall() { + Object[] objects = tableViewer.getCheckedElements(); + if (objects.length == 0) { + return null; + } + return (IServerRuntime) objects[0]; + } + + @Override + protected void setSortColumn(int column) { + switch (column) { + case 1: + sortByName(); + break; + // case 2: + // sortByType(); + // break; + } + super.setSortColumn(column); + } + + @Override + protected Table getTable() { + return tableViewer.getTable(); + } + + @Override + protected IDialogSettings getDialogSettings() { + return Activator.getDefault().getDialogSettings(); + } + + private class RuntimesContentProvider implements IStructuredContentProvider { + public Object[] getElements(Object input) { + return runtimes.toArray(); + } + + public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { + } + + public void dispose() { + } + } + + private static class RuntimesLabelProvider extends LabelProvider implements + ITableLabelProvider { + public String getColumnText(Object element, int columnIndex) { + if (element instanceof IServerRuntime) { + IServerRuntime install = (IServerRuntime) element; + switch (columnIndex) { + case 0: + return install.getName(); + case 1: + return install.getInstallDir(); + // case 2: + // if (install.getDebugger() != null) + // { + // return install.getDebugger().getName(); + // } + // return Messages.InstalledRuntimesBlock_8; + } + } + return element.toString(); + } + + public Image getColumnImage(Object element, int columnIndex) { + return null; + } + + } + + @Override + protected String getQualifier() { + return ""; + } +} diff --git a/fr.opensagres.nosql.ide.ui/src/fr/opensagres/nosql/ide/ui/internal/preferences/NoSQLPreferencePage.java b/fr.opensagres.nosql.ide.ui/src/fr/opensagres/nosql/ide/ui/internal/preferences/NoSQLPreferencePage.java new file mode 100644 index 0000000..8cea598 --- /dev/null +++ b/fr.opensagres.nosql.ide.ui/src/fr/opensagres/nosql/ide/ui/internal/preferences/NoSQLPreferencePage.java @@ -0,0 +1,35 @@ +/******************************************************************************* + * Copyright (c) 2011 Angelo ZERR. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Angelo Zerr - adapt for XML Search. + * Code comes from org.eclipse.wst.xml.xpath.ui.internal.preferences.XPathPrefencePage but there is not Header license. + *******************************************************************************/ +package fr.opensagres.nosql.ide.ui.internal.preferences; + +import org.eclipse.jface.preference.PreferencePage; +import org.eclipse.swt.SWT; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Control; +import org.eclipse.ui.IWorkbench; +import org.eclipse.ui.IWorkbenchPreferencePage; + +public class NoSQLPreferencePage extends PreferencePage implements + IWorkbenchPreferencePage { + + @Override + protected Control createContents(Composite parent) { + // TODO Auto-generated method stub + return new Composite(parent, SWT.NONE); + } + + public void init(IWorkbench workbench) { + // TODO Auto-generated method stub + + } + +} diff --git a/fr.opensagres.nosql.ide.ui/src/fr/opensagres/nosql/ide/ui/internal/preferences/ServerRuntimePreferencePage.java b/fr.opensagres.nosql.ide.ui/src/fr/opensagres/nosql/ide/ui/internal/preferences/ServerRuntimePreferencePage.java new file mode 100644 index 0000000..b80f98b --- /dev/null +++ b/fr.opensagres.nosql.ide.ui/src/fr/opensagres/nosql/ide/ui/internal/preferences/ServerRuntimePreferencePage.java @@ -0,0 +1,130 @@ +/******************************************************************************* + * Copyright (c) 2010 Angelo ZERR. + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Angelo Zerr - initial API and implementation + *******************************************************************************/ +package fr.opensagres.nosql.ide.ui.internal.preferences; + +import org.eclipse.jface.preference.PreferencePage; +import org.eclipse.jface.viewers.ComboViewer; +import org.eclipse.jface.viewers.ISelectionChangedListener; +import org.eclipse.jface.viewers.SelectionChangedEvent; +import org.eclipse.swt.SWT; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Control; +import org.eclipse.swt.widgets.Label; +import org.eclipse.ui.IWorkbench; +import org.eclipse.ui.IWorkbenchPreferencePage; + +import fr.opensagres.nosql.ide.core.IServerRuntimeManager; +import fr.opensagres.nosql.ide.core.Platform; +import fr.opensagres.nosql.ide.core.model.IServerRuntime; +import fr.opensagres.nosql.ide.ui.internal.Activator; +import fr.opensagres.nosql.ide.ui.internal.Messages; +import fr.opensagres.nosql.ide.ui.viewers.ServerTypeContentProvider; +import fr.opensagres.nosql.ide.ui.viewers.ServerTypeLabelProvider; + +public class ServerRuntimePreferencePage extends PreferencePage implements + IWorkbenchPreferencePage { + + private InstalledRuntimesBlock runtimesBlock; + + public ServerRuntimePreferencePage() { + super(); + // only used when page is shown programatically + setTitle(Messages.ServerRuntimePreferencePage_title); + setDescription(Messages.ServerRuntimePreferencePage_desc); + } + + public void init(IWorkbench workbench) { + setPreferenceStore(Activator.getDefault().getPreferenceStore()); + } + + @Override + protected Control createContents(Composite parent) { + initializeDialogUnits(parent); + + noDefaultAndApplyButton(); + + GridLayout layout = new GridLayout(); + layout.numColumns = 1; + layout.marginHeight = 0; + layout.marginWidth = 0; + parent.setLayout(layout); + + runtimesBlock = new InstalledRuntimesBlock(); + runtimesBlock.createControl(parent); + Control control = runtimesBlock.getControl(); + GridData data = new GridData(GridData.FILL_BOTH); + data.horizontalSpan = 1; + control.setLayoutData(data); + + // TODO PlatformUI.getWorkbench().getHelpSystem().setHelp... + + initDefaultInstall(); + runtimesBlock + .addSelectionChangedListener(new ISelectionChangedListener() { + public void selectionChanged(SelectionChangedEvent event) { + IServerRuntime runtime = getCurrentDefaultRuntime(); + if (runtime == null) { + setValid(false); + // setErrorMessage(Messages.MongoRuntimePreferencePage_2); + } else { + setValid(true); + setErrorMessage(null); + } + } + }); + applyDialogFont(parent); + return parent; + } + + @Override + public boolean performOk() { + try { + IServerRuntimeManager manager = Platform.getServerRuntimeManager(); + manager.setRuntimes(runtimesBlock.getRuntimes()); + return true; + } catch (Exception e) { + e.printStackTrace(); + return false; + } + + // MongoRuntime runtimeType = getCurrentDefaultRuntime(); + // if (runtimeType == null) { + // setErrorMessage("Please select a XPath runtime"); + // return false; + // } + // runtimesBlock.saveColumnSettings(); + // MongoRuntimeManager.getDefault().setDefaultRuntime(runtimeType); + } + + private void initDefaultInstall() { + // MongoRuntime runtimeType = MongoRuntimeManager.getDefault() + // .getDefaultRuntime(); + // verifyDefaultVM(runtimeType); + + // IXPathEvaluatorType realDefault = JAXPRuntime.getDefaultRuntime(); + // if (realDefault != null) { + // IXPathEvaluatorType[] installs = runtimesBlock.getRuntimes(); + // for (IXPathEvaluatorType fakeInstall : installs) { + // if (fakeInstall.getId().equals(realDefault.getId())) { + // verifyDefaultVM(fakeInstall); + // break; + // } + // } + // } + } + + private IServerRuntime getCurrentDefaultRuntime() { + return runtimesBlock.getCheckedInstall(); + } + +} diff --git a/fr.opensagres.nosql.ide.ui/src/fr/opensagres/nosql/ide/ui/viewers/ServerTypeContentProvider.java b/fr.opensagres.nosql.ide.ui/src/fr/opensagres/nosql/ide/ui/viewers/ServerTypeContentProvider.java new file mode 100644 index 0000000..c63dd10 --- /dev/null +++ b/fr.opensagres.nosql.ide.ui/src/fr/opensagres/nosql/ide/ui/viewers/ServerTypeContentProvider.java @@ -0,0 +1,34 @@ +package fr.opensagres.nosql.ide.ui.viewers; + +import java.util.Collection; + +import org.eclipse.jface.viewers.IStructuredContentProvider; +import org.eclipse.jface.viewers.Viewer; + +public class ServerTypeContentProvider implements IStructuredContentProvider { + + private static ServerTypeContentProvider instance; + + public static ServerTypeContentProvider getInstance() { + synchronized (ServerTypeContentProvider.class) { + if (instance == null) { + instance = new ServerTypeContentProvider(); + } + return instance; + } + } + + public void dispose() { + // TODO Auto-generated method stub + + } + + public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { + // TODO Auto-generated method stub + + } + + public Object[] getElements(Object inputElement) { + return ((Collection)inputElement).toArray(); + } +} diff --git a/fr.opensagres.nosql.ide.ui/src/fr/opensagres/nosql/ide/ui/viewers/ServerTypeLabelProvider.java b/fr.opensagres.nosql.ide.ui/src/fr/opensagres/nosql/ide/ui/viewers/ServerTypeLabelProvider.java new file mode 100644 index 0000000..e8f48c5 --- /dev/null +++ b/fr.opensagres.nosql.ide.ui/src/fr/opensagres/nosql/ide/ui/viewers/ServerTypeLabelProvider.java @@ -0,0 +1,26 @@ +package fr.opensagres.nosql.ide.ui.viewers; + +import org.eclipse.jface.viewers.LabelProvider; + +import fr.opensagres.nosql.ide.core.extensions.IServerType; +import fr.opensagres.nosql.ide.core.model.IServerRuntime; + +public class ServerTypeLabelProvider extends LabelProvider { + + private static ServerTypeLabelProvider instance; + + public static ServerTypeLabelProvider getInstance() { + synchronized (ServerTypeLabelProvider.class) { + if (instance == null) { + instance = new ServerTypeLabelProvider(); + } + return instance; + } + } + + @Override + public String getText(Object element) { + return ((IServerType) element).getName(); + } + +}