Révision 784
| tmp/org.txm.statsengine.core/src/org/txm/statsengine/core/StatsEnginesManager.java (revision 784) | ||
|---|---|---|
| 1 | 1 |
package org.txm.statsengine.core; |
| 2 | 2 |
|
| 3 |
import org.eclipse.core.runtime.CoreException; |
|
| 4 |
import org.eclipse.core.runtime.IConfigurationElement; |
|
| 5 |
import org.eclipse.core.runtime.IProgressMonitor; |
|
| 6 |
import org.eclipse.core.runtime.Platform; |
|
| 7 |
import org.txm.Engine; |
|
| 8 |
import org.txm.EngineType; |
|
| 9 |
import org.txm.EnginesManager; |
|
| 10 | 3 |
import org.txm.Toolbox; |
| 11 |
import org.txm.utils.logger.Log; |
|
| 4 |
import org.txm.core.engines.EngineType; |
|
| 5 |
import org.txm.core.engines.EnginesManager; |
|
| 12 | 6 |
|
| 7 |
/** |
|
| 8 |
* Statistics engines manager. |
|
| 9 |
* |
|
| 10 |
* @author mdecorde |
|
| 11 |
* @author sjacquot |
|
| 12 |
* |
|
| 13 |
*/ |
|
| 13 | 14 |
public class StatsEnginesManager extends EnginesManager<StatsEngine> {
|
| 14 | 15 |
|
| 15 | 16 |
public static StatsEngine getREngine() {
|
| ... | ... | |
| 17 | 18 |
} |
| 18 | 19 |
|
| 19 | 20 |
@Override |
| 20 |
protected boolean fetchEngines() {
|
|
| 21 |
|
|
| 22 |
IConfigurationElement[] contributions = Platform.getExtensionRegistry().getConfigurationElementsFor(StatsEngine.EXTENSION_POINT_ID); |
|
| 23 |
|
|
| 24 |
Log.finest("Looking for stats engines contributions with extension point id " + StatsEngine.EXTENSION_POINT_ID + ".");
|
|
| 25 |
|
|
| 26 |
Log.finest(contributions.length + " stats engines found."); |
|
| 27 |
|
|
| 28 |
for (int i = 0; i < contributions.length; i++) {
|
|
| 29 |
try {
|
|
| 30 |
StatsEngine e = (StatsEngine)contributions[i].createExecutableExtension("class"); //$NON-NLS-1$
|
|
| 31 |
// register something with the SearchEngine ? |
|
| 32 |
engines.put(e.getName(), e); |
|
| 33 |
} catch(CoreException e) {
|
|
| 34 |
e.printStackTrace(); |
|
| 35 |
} |
|
| 36 |
} |
|
| 37 |
|
|
| 38 |
return engines.size() > 0; |
|
| 21 |
public boolean fetchEngines() {
|
|
| 22 |
return this.fetchEngines(StatsEngine.EXTENSION_POINT_ID); |
|
| 39 | 23 |
} |
| 40 | 24 |
|
| 41 | 25 |
@Override |
| ... | ... | |
| 43 | 27 |
return EngineType.STATS; |
| 44 | 28 |
} |
| 45 | 29 |
|
| 46 |
@Override |
|
| 47 |
public boolean startEngines(IProgressMonitor monitor) {
|
|
| 48 |
//System.out.println("StatEngines.startEngines: "+engines);
|
|
| 49 |
for (Engine e : engines.values()) {
|
|
| 50 |
|
|
| 51 |
StatsEngine se = (StatsEngine)e; |
|
| 52 |
if (monitor != null) monitor.subTask("Starting " + se.getName() + " statengine...");
|
|
| 53 |
try {
|
|
| 54 |
se.start(monitor); |
|
| 55 |
} catch (Exception e2) {
|
|
| 56 |
System.err.println("Error: fail to start stats engine: "+se.getName()+": "+e2.getLocalizedMessage());
|
|
| 57 |
e2.printStackTrace(); |
|
| 58 |
} |
|
| 59 |
|
|
| 60 |
} |
|
| 61 |
return true; |
|
| 62 |
} |
|
| 63 |
|
|
| 64 |
@Override |
|
| 65 |
public boolean stopEngines() {
|
|
| 66 |
|
|
| 67 |
for (Engine e : engines.values()) {
|
|
| 68 |
|
|
| 69 |
StatsEngine se = (StatsEngine)e; |
|
| 70 |
System.out.println("Stopping " + se.getName() + " stats engine...");
|
|
| 71 |
try {
|
|
| 72 |
se.stop(); |
|
| 73 |
} catch (Exception e2) {
|
|
| 74 |
System.err.println("Error: failed to stop stats engine: " + se.getName() + ": " + e2.getLocalizedMessage());
|
|
| 75 |
e2.printStackTrace(); |
|
| 76 |
} |
|
| 77 |
} |
|
| 78 |
return true; |
|
| 79 |
} |
|
| 80 | 30 |
} |
| tmp/org.txm.statsengine.core/src/org/txm/statsengine/core/StatsEngine.java (revision 784) | ||
|---|---|---|
| 1 | 1 |
package org.txm.statsengine.core; |
| 2 | 2 |
|
| 3 |
import org.txm.Engine; |
|
| 3 |
import org.txm.core.engines.Engine;
|
|
| 4 | 4 |
|
| 5 | 5 |
public abstract class StatsEngine implements Engine {
|
| 6 | 6 |
|
| tmp/org.txm.statsengine.core/plugin.xml (revision 784) | ||
|---|---|---|
| 3 | 3 |
<plugin> |
| 4 | 4 |
<extension-point id="org.txm.statsengine.core.StatsEngine" name="Stats Engine" schema="schema/org.txm.statsengine.exsd"/> |
| 5 | 5 |
<extension |
| 6 |
point="org.txm.EnginesManager"> |
|
| 6 |
point="org.txm.core.engines.EnginesManager">
|
|
| 7 | 7 |
<EngineManager |
| 8 | 8 |
class="org.txm.statsengine.core.StatsEnginesManager" |
| 9 | 9 |
description="Stats engines manager" |
| tmp/org.txm.searchengine.core/src/org/txm/searchengine/core/SearchEnginesManager.java (revision 784) | ||
|---|---|---|
| 1 | 1 |
package org.txm.searchengine.core; |
| 2 | 2 |
|
| 3 |
import org.eclipse.core.runtime.IConfigurationElement; |
|
| 4 |
import org.eclipse.core.runtime.IProgressMonitor; |
|
| 5 |
import org.eclipse.core.runtime.Platform; |
|
| 6 |
import org.txm.Engine; |
|
| 7 |
import org.txm.EngineType; |
|
| 8 |
import org.txm.EnginesManager; |
|
| 9 | 3 |
import org.txm.Toolbox; |
| 4 |
import org.txm.core.engines.EngineType; |
|
| 5 |
import org.txm.core.engines.EnginesManager; |
|
| 10 | 6 |
|
| 11 | 7 |
/** |
| 12 |
* |
|
| 8 |
* Search engines manager.
|
|
| 13 | 9 |
* @author mdecorde |
| 14 | 10 |
* |
| 15 | 11 |
*/ |
| ... | ... | |
| 32 | 28 |
} |
| 33 | 29 |
|
| 34 | 30 |
@Override |
| 35 |
protected boolean fetchEngines() {
|
|
| 36 |
|
|
| 37 |
IConfigurationElement[] contributions = Platform.getExtensionRegistry().getConfigurationElementsFor(SearchEngine.EXTENSION_POINT_ID); |
|
| 38 |
//System.out.println("search engine contributions: "+SearchEngine.EXTENSION_POINT_ID);
|
|
| 39 |
for (int i = 0; i < contributions.length; i++) {
|
|
| 40 |
try {
|
|
| 41 |
SearchEngine e = (SearchEngine)contributions[i].createExecutableExtension("class"); //$NON-NLS-1$
|
|
| 42 |
|
|
| 43 |
System.out.println("Initializing engine: " + e);
|
|
| 44 |
|
|
| 45 |
if (e.initialize()) {
|
|
| 46 |
engines.put(e.getName(), e); |
|
| 47 |
} |
|
| 48 |
else {
|
|
| 49 |
System.err.println("Failed to initialize " + e.getName() + " search engine.");
|
|
| 50 |
} |
|
| 51 |
} catch(Exception e) {
|
|
| 52 |
System.err.println("Error: failed to instantiate " + contributions[i].getName() + ": " + e.getLocalizedMessage());
|
|
| 53 |
e.printStackTrace(); |
|
| 54 |
} |
|
| 55 |
} |
|
| 56 |
|
|
| 57 |
return engines.size() > 0; |
|
| 31 |
public boolean fetchEngines() {
|
|
| 32 |
return this.fetchEngines(SearchEngine.EXTENSION_POINT_ID); |
|
| 58 | 33 |
} |
| 59 | 34 |
|
| 60 | 35 |
@Override |
| ... | ... | |
| 62 | 37 |
return EngineType.SEARCH; |
| 63 | 38 |
} |
| 64 | 39 |
|
| 65 |
@Override |
|
| 66 |
public boolean startEngines(IProgressMonitor monitor) {
|
|
| 67 |
|
|
| 68 |
for (Engine e : engines.values()) {
|
|
| 69 |
SearchEngine se = (SearchEngine)e; |
|
| 70 |
//System.out.println("Starting "+ se.getName()+" searchengine.");
|
|
| 71 |
if (monitor != null) {
|
|
| 72 |
monitor.subTask("Starting " + se.getName() + " searchengine.");
|
|
| 73 |
} |
|
| 74 |
try {
|
|
| 75 |
se.start(monitor); |
|
| 76 |
} catch (Exception e2) {
|
|
| 77 |
System.err.println("Error: failed to start SearchEngine: " + se.getName() + ": " + e2.getLocalizedMessage());
|
|
| 78 |
e2.printStackTrace(); |
|
| 79 |
} |
|
| 80 |
} |
|
| 81 |
return true; |
|
| 82 |
} |
|
| 83 |
|
|
| 84 |
@Override |
|
| 85 |
public boolean stopEngines() {
|
|
| 86 |
|
|
| 87 |
for (Engine e : engines.values()) {
|
|
| 88 |
|
|
| 89 |
SearchEngine se = (SearchEngine)e; |
|
| 90 |
System.out.println("Stopping "+ se.getName()+" searchengine.");
|
|
| 91 |
try {
|
|
| 92 |
se.stop(); |
|
| 93 |
} catch (Exception e2) {
|
|
| 94 |
System.err.println("Error: failed to stop SearchEngine: " + se.getName() + ": " + e2.getLocalizedMessage());
|
|
| 95 |
e2.printStackTrace(); |
|
| 96 |
} |
|
| 97 |
} |
|
| 98 |
return true; |
|
| 99 |
} |
|
| 100 | 40 |
} |
| tmp/org.txm.searchengine.core/src/org/txm/searchengine/core/SearchEngine.java (revision 784) | ||
|---|---|---|
| 1 | 1 |
package org.txm.searchengine.core; |
| 2 | 2 |
|
| 3 |
import org.txm.Engine; |
|
| 3 |
import org.txm.core.engines.Engine;
|
|
| 4 | 4 |
|
| 5 | 5 |
public abstract class SearchEngine implements Engine {
|
| 6 | 6 |
|
| tmp/org.txm.searchengine.core/plugin.xml (revision 784) | ||
|---|---|---|
| 3 | 3 |
<plugin> |
| 4 | 4 |
<extension-point id="org.txm.searchengine.core.SearchEngine" name="Search Engine" schema="schema/org.txm.searchengine.exsd"/> |
| 5 | 5 |
<extension |
| 6 |
point="org.txm.EnginesManager"> |
|
| 6 |
point="org.txm.core.engines.EnginesManager">
|
|
| 7 | 7 |
<EngineManager |
| 8 | 8 |
class="org.txm.searchengine.core.SearchEnginesManager" |
| 9 | 9 |
description="Manage the search engines" |
| tmp/org.txm.rcp/src/main/java/org/txm/rcp/testers/ToolboxTester.java (revision 784) | ||
|---|---|---|
| 1 | 1 |
package org.txm.rcp.testers; |
| 2 | 2 |
|
| 3 | 3 |
import org.eclipse.core.expressions.PropertyTester; |
| 4 |
import org.txm.EngineType; |
|
| 5 | 4 |
import org.txm.Toolbox; |
| 6 | 5 |
import org.txm.Toolbox; |
| 6 |
import org.txm.core.engines.EngineType; |
|
| 7 | 7 |
import org.txm.searchengine.cqp.CQPEngine; |
| 8 | 8 |
|
| 9 | 9 |
/** |
| tmp/org.txm.rcp/src/main/java/org/txm/rcp/commands/workspace/ConvertCorpus.java (revision 784) | ||
|---|---|---|
| 12 | 12 |
import org.eclipse.swt.widgets.DirectoryDialog; |
| 13 | 13 |
import org.eclipse.swt.widgets.Shell; |
| 14 | 14 |
import org.eclipse.ui.handlers.HandlerUtil; |
| 15 |
import org.txm.EngineType; |
|
| 16 | 15 |
import org.txm.Toolbox; |
| 17 | 16 |
import org.txm.Toolbox; |
| 17 |
import org.txm.core.engines.EngineType; |
|
| 18 | 18 |
import org.txm.core.preferences.TBXPreferences; |
| 19 | 19 |
import org.txm.importer.Convert5To6; |
| 20 | 20 |
import org.txm.objects.Base; |
| tmp/org.txm.rcp/src/main/java/org/txm/rcp/commands/workspace/LoadBinaryCorporaDirectory.java (revision 784) | ||
|---|---|---|
| 44 | 44 |
import org.eclipse.swt.widgets.FileDialog; |
| 45 | 45 |
import org.eclipse.swt.widgets.Shell; |
| 46 | 46 |
import org.eclipse.ui.handlers.HandlerUtil; |
| 47 |
import org.txm.EngineType; |
|
| 48 | 47 |
import org.txm.Toolbox; |
| 49 | 48 |
import org.txm.Toolbox; |
| 49 |
import org.txm.core.engines.EngineType; |
|
| 50 | 50 |
import org.txm.core.preferences.TBXPreferences; |
| 51 | 51 |
import org.txm.objects.Base; |
| 52 | 52 |
import org.txm.objects.Project; |
| tmp/org.txm.rcp/src/main/java/org/txm/rcp/commands/workspace/LoadBinaryCorpus.java (revision 784) | ||
|---|---|---|
| 42 | 42 |
import org.eclipse.swt.widgets.FileDialog; |
| 43 | 43 |
import org.eclipse.swt.widgets.Shell; |
| 44 | 44 |
import org.eclipse.ui.handlers.HandlerUtil; |
| 45 |
import org.txm.EngineType; |
|
| 46 | 45 |
import org.txm.Toolbox; |
| 46 |
import org.txm.core.engines.EngineType; |
|
| 47 | 47 |
import org.txm.objects.Base; |
| 48 | 48 |
import org.txm.objects.Project; |
| 49 | 49 |
import org.txm.objects.Workspace; |
| tmp/org.txm.rcp/src/main/java/org/txm/rcp/handlers/results/DeleteObject.java (revision 784) | ||
|---|---|---|
| 49 | 49 |
import org.eclipse.ui.IWorkbenchWindow; |
| 50 | 50 |
import org.eclipse.ui.handlers.HandlerUtil; |
| 51 | 51 |
import org.eclipse.ui.internal.Workbench; |
| 52 |
import org.txm.EngineType; |
|
| 53 | 52 |
import org.txm.Toolbox; |
| 53 |
import org.txm.core.engines.EngineType; |
|
| 54 | 54 |
import org.txm.core.preferences.TXMPreferences; |
| 55 | 55 |
import org.txm.core.results.TXMResult; |
| 56 | 56 |
import org.txm.objects.TxmObject; |
| tmp/org.txm.rcp/src/main/java/org/txm/rcp/handlers/scripts/ExecuteImportScript.java (revision 784) | ||
|---|---|---|
| 49 | 49 |
import org.eclipse.swt.widgets.FileDialog; |
| 50 | 50 |
import org.eclipse.swt.widgets.Shell; |
| 51 | 51 |
import org.eclipse.ui.handlers.HandlerUtil; |
| 52 |
import org.txm.EngineType; |
|
| 53 | 52 |
import org.txm.Toolbox; |
| 54 | 53 |
import org.txm.Toolbox; |
| 54 |
import org.txm.core.engines.EngineType; |
|
| 55 | 55 |
import org.txm.core.preferences.TBXPreferences; |
| 56 | 56 |
import org.txm.importer.ImportKeys; |
| 57 | 57 |
import org.txm.objects.Base; |
| tmp/org.txm.core/src/java/org/txm/EnginesManager.java (revision 784) | ||
|---|---|---|
| 1 |
package org.txm; |
|
| 2 |
|
|
| 3 |
import java.util.HashMap; |
|
| 4 |
|
|
| 5 |
import org.eclipse.core.runtime.IProgressMonitor; |
|
| 6 |
|
|
| 7 |
/** |
|
| 8 |
* Extension point for an Engine (eg. Search engine, Stats engine, etc.). It is a service that may be used by TXM commands. |
|
| 9 |
* The Toolbox will manage the engines life-cycle. |
|
| 10 |
* |
|
| 11 |
* @author mdecorde |
|
| 12 |
* |
|
| 13 |
*/ |
|
| 14 |
public abstract class EnginesManager<T extends Engine> {
|
|
| 15 |
|
|
| 16 |
public static final String ENGINES_MANAGER_EXTENSION_POINT_ID = EnginesManager.class.getName(); |
|
| 17 |
|
|
| 18 |
/** |
|
| 19 |
* Managed engines. |
|
| 20 |
*/ |
|
| 21 |
protected HashMap<String, T> engines = new HashMap<String, T>(); |
|
| 22 |
|
|
| 23 |
|
|
| 24 |
/** |
|
| 25 |
* Current engine. |
|
| 26 |
*/ |
|
| 27 |
protected T currentEngine = null; |
|
| 28 |
|
|
| 29 |
|
|
| 30 |
|
|
| 31 |
/** |
|
| 32 |
* Returns the current engine. |
|
| 33 |
* @return |
|
| 34 |
*/ |
|
| 35 |
public T getCurrentEngine() {
|
|
| 36 |
return this.currentEngine; |
|
| 37 |
} |
|
| 38 |
|
|
| 39 |
|
|
| 40 |
/** |
|
| 41 |
* Finds out the engines that matches this manager engines extension point. |
|
| 42 |
* |
|
| 43 |
* @return |
|
| 44 |
*/ |
|
| 45 |
protected abstract boolean fetchEngines(); |
|
| 46 |
|
|
| 47 |
/** |
|
| 48 |
* Initializes the engines. |
|
| 49 |
* @param monitor |
|
| 50 |
* |
|
| 51 |
* @return |
|
| 52 |
*/ |
|
| 53 |
public abstract boolean startEngines(IProgressMonitor monitor); |
|
| 54 |
|
|
| 55 |
/** |
|
| 56 |
* Stops the engines. |
|
| 57 |
* |
|
| 58 |
* @return |
|
| 59 |
*/ |
|
| 60 |
public abstract boolean stopEngines(); |
|
| 61 |
|
|
| 62 |
/** |
|
| 63 |
* Restarts the engines. |
|
| 64 |
* |
|
| 65 |
* @return |
|
| 66 |
*/ |
|
| 67 |
public boolean restartEngines() {
|
|
| 68 |
return stopEngines() && startEngines(null); |
|
| 69 |
} |
|
| 70 |
|
|
| 71 |
|
|
| 72 |
public abstract EngineType getEnginesType(); |
|
| 73 |
|
|
| 74 |
/** |
|
| 75 |
* Gets the available engines. |
|
| 76 |
* @return the available engines |
|
| 77 |
*/ |
|
| 78 |
public HashMap<String, T> getEngines() {
|
|
| 79 |
return engines; |
|
| 80 |
} |
|
| 81 |
|
|
| 82 |
/** |
|
| 83 |
* Gets an engine specified by its name. |
|
| 84 |
* @param name |
|
| 85 |
* @return an engine specified by its name if exists, otherwise null |
|
| 86 |
*/ |
|
| 87 |
public T getEngine(String name) {
|
|
| 88 |
return engines.get(name); |
|
| 89 |
} |
|
| 90 |
} |
|
| tmp/org.txm.core/src/java/org/txm/Engine.java (revision 784) | ||
|---|---|---|
| 1 |
package org.txm; |
|
| 2 |
|
|
| 3 |
import org.eclipse.core.runtime.IProgressMonitor; |
|
| 4 |
|
|
| 5 |
/** |
|
| 6 |
* An engine gives access to services. The user must know its implementation Class to access those services. |
|
| 7 |
* |
|
| 8 |
* @author mdecorde |
|
| 9 |
* |
|
| 10 |
*/ |
|
| 11 |
public abstract interface Engine {
|
|
| 12 |
/** |
|
| 13 |
* An engine must at least give its name (not null). |
|
| 14 |
* |
|
| 15 |
* @return the engine name |
|
| 16 |
*/ |
|
| 17 |
public String getName(); |
|
| 18 |
|
|
| 19 |
public abstract boolean getState(); |
|
| 20 |
|
|
| 21 |
public abstract boolean initialize() throws Exception; |
|
| 22 |
|
|
| 23 |
public abstract boolean start(IProgressMonitor monitor) throws Exception; |
|
| 24 |
|
|
| 25 |
public abstract boolean stop() throws Exception; |
|
| 26 |
|
|
| 27 |
} |
|
| tmp/org.txm.core/src/java/org/txm/EngineType.java (revision 784) | ||
|---|---|---|
| 1 |
package org.txm; |
|
| 2 |
|
|
| 3 |
public enum EngineType {
|
|
| 4 |
SEARCH, |
|
| 5 |
STATS, |
|
| 6 |
CHARTS, |
|
| 7 |
SCRIPT, |
|
| 8 |
ANNOTATION; |
|
| 9 |
} |
|
| tmp/org.txm.core/src/java/org/txm/core/engines/EnginesManager.java (revision 784) | ||
|---|---|---|
| 1 |
package org.txm.core.engines; |
|
| 2 |
|
|
| 3 |
import java.util.HashMap; |
|
| 4 |
|
|
| 5 |
import org.eclipse.core.runtime.IConfigurationElement; |
|
| 6 |
import org.eclipse.core.runtime.IProgressMonitor; |
|
| 7 |
import org.eclipse.core.runtime.RegistryFactory; |
|
| 8 |
import org.txm.utils.logger.Log; |
|
| 9 |
|
|
| 10 |
/** |
|
| 11 |
* Extension point for an Engine (eg. Search engine, Stats engine, etc.). It is a service that may be used by TXM commands. |
|
| 12 |
* The Toolbox will manage the engines life-cycle. |
|
| 13 |
* |
|
| 14 |
* @author mdecorde |
|
| 15 |
* |
|
| 16 |
*/ |
|
| 17 |
public abstract class EnginesManager<T extends Engine> {
|
|
| 18 |
|
|
| 19 |
public static final String ENGINES_MANAGER_EXTENSION_POINT_ID = EnginesManager.class.getName(); |
|
| 20 |
|
|
| 21 |
/** |
|
| 22 |
* Managed engines. |
|
| 23 |
*/ |
|
| 24 |
protected HashMap<String, T> engines = new HashMap<String, T>(); |
|
| 25 |
|
|
| 26 |
|
|
| 27 |
/** |
|
| 28 |
* Current engine. |
|
| 29 |
*/ |
|
| 30 |
protected T currentEngine = null; |
|
| 31 |
|
|
| 32 |
|
|
| 33 |
|
|
| 34 |
/** |
|
| 35 |
* Returns the current engine. |
|
| 36 |
* @return |
|
| 37 |
*/ |
|
| 38 |
public T getCurrentEngine() {
|
|
| 39 |
return this.currentEngine; |
|
| 40 |
} |
|
| 41 |
|
|
| 42 |
|
|
| 43 |
/** |
|
| 44 |
* Sets the current engine. |
|
| 45 |
* @param engine |
|
| 46 |
*/ |
|
| 47 |
public void setCurrentEngine(T engine) {
|
|
| 48 |
this.currentEngine = engine; |
|
| 49 |
} |
|
| 50 |
|
|
| 51 |
/** |
|
| 52 |
* Sets the current engine specified by its name. |
|
| 53 |
* @param name |
|
| 54 |
*/ |
|
| 55 |
public void setCurrentEngine(String name) {
|
|
| 56 |
this.setCurrentEngine(this.getEngine(name)); |
|
| 57 |
} |
|
| 58 |
|
|
| 59 |
/** |
|
| 60 |
* Finds out the engines that matches this manager engines extension point. |
|
| 61 |
* |
|
| 62 |
* @return |
|
| 63 |
*/ |
|
| 64 |
public abstract boolean fetchEngines(); |
|
| 65 |
|
|
| 66 |
|
|
| 67 |
|
|
| 68 |
/** |
|
| 69 |
* Creates and initializes the engines with the specified extension point id. |
|
| 70 |
* |
|
| 71 |
* @param engineExtensionPointId |
|
| 72 |
* @return true if at least one engine has been created otherwise false |
|
| 73 |
*/ |
|
| 74 |
protected boolean fetchEngines(String engineExtensionPointId) {
|
|
| 75 |
|
|
| 76 |
IConfigurationElement[] contributions = RegistryFactory.getRegistry().getConfigurationElementsFor(engineExtensionPointId); |
|
| 77 |
|
|
| 78 |
Log.finest("Looking for engines contributions with extension point id " + engineExtensionPointId + ".");
|
|
| 79 |
Log.finest(contributions.length + " engines found."); |
|
| 80 |
|
|
| 81 |
for (int i = 0; i < contributions.length; i++) {
|
|
| 82 |
try {
|
|
| 83 |
T e = (T)contributions[i].createExecutableExtension("class"); //$NON-NLS-1$
|
|
| 84 |
|
|
| 85 |
System.out.println("Initializing engine: " + e);
|
|
| 86 |
|
|
| 87 |
if (e.initialize()) {
|
|
| 88 |
this.engines.put(e.getName(), e); |
|
| 89 |
} |
|
| 90 |
else {
|
|
| 91 |
System.err.println("Failed to initialize " + e.getName() + " engine.");
|
|
| 92 |
} |
|
| 93 |
} catch(Exception e) {
|
|
| 94 |
Log.severe("Error: failed to instantiate " + contributions[i].getName() + ".");
|
|
| 95 |
e.printStackTrace(); |
|
| 96 |
} |
|
| 97 |
} |
|
| 98 |
|
|
| 99 |
return this.engines.size() > 0; |
|
| 100 |
} |
|
| 101 |
|
|
| 102 |
/** |
|
| 103 |
* Starts the engines. |
|
| 104 |
* @param monitor |
|
| 105 |
* @return |
|
| 106 |
*/ |
|
| 107 |
public boolean startEngines(IProgressMonitor monitor) {
|
|
| 108 |
for (Engine engine : this.engines.values()) {
|
|
| 109 |
|
|
| 110 |
String log = "Starting " + engine.getName() + " engine..."; |
|
| 111 |
Log.finest(log); |
|
| 112 |
|
|
| 113 |
if (monitor != null) {
|
|
| 114 |
monitor.subTask(log); |
|
| 115 |
} |
|
| 116 |
|
|
| 117 |
try {
|
|
| 118 |
engine.start(monitor); |
|
| 119 |
} catch (Exception e) {
|
|
| 120 |
Log.severe("Error: failed to start engine " + engine.getName() + ".");
|
|
| 121 |
e.printStackTrace(); |
|
| 122 |
} |
|
| 123 |
} |
|
| 124 |
return true; |
|
| 125 |
} |
|
| 126 |
|
|
| 127 |
/** |
|
| 128 |
* Stops the engines. |
|
| 129 |
* @return |
|
| 130 |
*/ |
|
| 131 |
public boolean stopEngines() {
|
|
| 132 |
for (Engine engine : this.engines.values()) {
|
|
| 133 |
|
|
| 134 |
Log.finest("Stopping " + engine.getName() + " engine...");
|
|
| 135 |
|
|
| 136 |
try {
|
|
| 137 |
engine.stop(); |
|
| 138 |
} catch (Exception e) {
|
|
| 139 |
Log.severe("Error: failed to stop engine: " + engine.getName() + ".");
|
|
| 140 |
e.printStackTrace(); |
|
| 141 |
} |
|
| 142 |
} |
|
| 143 |
return true; |
|
| 144 |
} |
|
| 145 |
|
|
| 146 |
|
|
| 147 |
/** |
|
| 148 |
* Restarts the engines. |
|
| 149 |
* |
|
| 150 |
* @return |
|
| 151 |
*/ |
|
| 152 |
public boolean restartEngines() {
|
|
| 153 |
Log.finest("Restarting the " + this.engines.size() + " engine(s).");
|
|
| 154 |
return stopEngines() && startEngines(null); |
|
| 155 |
} |
|
| 156 |
|
|
| 157 |
|
|
| 158 |
public abstract EngineType getEnginesType(); |
|
| 159 |
|
|
| 160 |
/** |
|
| 161 |
* Gets the available engines. |
|
| 162 |
* @return the available engines |
|
| 163 |
*/ |
|
| 164 |
public HashMap<String, T> getEngines() {
|
|
| 165 |
return engines; |
|
| 166 |
} |
|
| 167 |
|
|
| 168 |
/** |
|
| 169 |
* Gets an engine specified by its name. |
|
| 170 |
* @param name |
|
| 171 |
* @return an engine specified by its name if exists, otherwise null |
|
| 172 |
*/ |
|
| 173 |
public T getEngine(String name) {
|
|
| 174 |
return engines.get(name); |
|
| 175 |
} |
|
| 176 |
} |
|
| 0 | 177 | |
| tmp/org.txm.core/src/java/org/txm/core/engines/Engine.java (revision 784) | ||
|---|---|---|
| 1 |
package org.txm.core.engines; |
|
| 2 |
|
|
| 3 |
import org.eclipse.core.runtime.IProgressMonitor; |
|
| 4 |
|
|
| 5 |
/** |
|
| 6 |
* An engine gives access to services. The user must know its implementation Class to access those services. |
|
| 7 |
* |
|
| 8 |
* @author mdecorde |
|
| 9 |
* |
|
| 10 |
*/ |
|
| 11 |
public abstract interface Engine {
|
|
| 12 |
/** |
|
| 13 |
* An engine must at least give its name (not null). |
|
| 14 |
* |
|
| 15 |
* @return the engine name |
|
| 16 |
*/ |
|
| 17 |
public String getName(); |
|
| 18 |
|
|
| 19 |
public abstract boolean getState(); |
|
| 20 |
|
|
| 21 |
public abstract boolean initialize() throws Exception; |
|
| 22 |
|
|
| 23 |
public abstract boolean start(IProgressMonitor monitor) throws Exception; |
|
| 24 |
|
|
| 25 |
public abstract boolean stop() throws Exception; |
|
| 26 |
|
|
| 27 |
} |
|
| 0 | 28 | |
| tmp/org.txm.core/src/java/org/txm/core/engines/EngineType.java (revision 784) | ||
|---|---|---|
| 1 |
package org.txm.core.engines; |
|
| 2 |
|
|
| 3 |
public enum EngineType {
|
|
| 4 |
SEARCH, |
|
| 5 |
STATS, |
|
| 6 |
CHARTS, |
|
| 7 |
SCRIPT, |
|
| 8 |
ANNOTATION; |
|
| 9 |
} |
|
| 0 | 10 | |
| tmp/org.txm.core/src/java/org/txm/Toolbox.java (revision 784) | ||
|---|---|---|
| 50 | 50 |
import org.eclipse.core.runtime.preferences.IPreferencesService; |
| 51 | 51 |
import org.osgi.framework.Bundle; |
| 52 | 52 |
import org.osgi.framework.Version; |
| 53 |
import org.txm.core.engines.EngineType; |
|
| 54 |
import org.txm.core.engines.EnginesManager; |
|
| 53 | 55 |
import org.txm.core.messages.TXMCoreMessages; |
| 54 | 56 |
import org.txm.core.preferences.TBXPreferences; |
| 55 | 57 |
import org.txm.core.preferences.TXMPreferences; |
| ... | ... | |
| 69 | 71 |
*/ |
| 70 | 72 |
public class Toolbox {
|
| 71 | 73 |
|
| 72 |
private static LinkedHashMap<EngineType, EnginesManager<?>> engines = new LinkedHashMap<EngineType, EnginesManager<?>>(); |
|
| 74 |
private static LinkedHashMap<EngineType, EnginesManager<?>> enginesManagers = new LinkedHashMap<EngineType, EnginesManager<?>>();
|
|
| 73 | 75 |
|
| 74 | 76 |
private static boolean initializing = false; |
| 75 | 77 |
|
| ... | ... | |
| 84 | 86 |
* @param engine |
| 85 | 87 |
*/ |
| 86 | 88 |
private static void addEngineManager(EnginesManager<?> engine) {
|
| 87 |
engines.put(engine.getEnginesType(), engine); |
|
| 89 |
enginesManagers.put(engine.getEnginesType(), engine);
|
|
| 88 | 90 |
} |
| 89 | 91 |
|
| 90 | 92 |
/** |
| ... | ... | |
| 98 | 100 |
|
| 99 | 101 |
private static boolean fetchEngineManagers() {
|
| 100 | 102 |
Log.finest("Fetching engines managers...");
|
| 101 |
engines.clear(); |
|
| 103 |
enginesManagers.clear();
|
|
| 102 | 104 |
//System.out.println("Contributions of "+EnginesManager.ENGINEMANAGER_EXTENSION_POINT_ID);
|
| 103 | 105 |
//Platform.getExtensionRegistry().getExtensionPoints(); |
| 104 | 106 |
IConfigurationElement[] contributions = RegistryFactory.getRegistry().getConfigurationElementsFor(EnginesManager.ENGINES_MANAGER_EXTENSION_POINT_ID); |
| ... | ... | |
| 108 | 110 |
|
| 109 | 111 |
for (int i = 0; i < contributions.length; i++) {
|
| 110 | 112 |
try {
|
| 111 |
EnginesManager<?> engine = (EnginesManager<?>)contributions[i].createExecutableExtension("class"); //$NON-NLS-1$
|
|
| 113 |
EnginesManager<?> enginesManager = (EnginesManager<?>)contributions[i].createExecutableExtension("class"); //$NON-NLS-1$
|
|
| 112 | 114 |
|
| 113 |
Log.finest("Registering engines manager: " + engine);
|
|
| 115 |
Log.finest("Registering engines manager: " + enginesManager);
|
|
| 114 | 116 |
|
| 115 |
if (engine.fetchEngines()) {
|
|
| 117 |
if (enginesManager.fetchEngines()) {
|
|
| 116 | 118 |
//System.out.println("add engine: "+engine);
|
| 117 |
addEngineManager(engine); |
|
| 119 |
addEngineManager(enginesManager);
|
|
| 118 | 120 |
} |
| 119 | 121 |
else {
|
| 120 |
System.err.println("" + engine + " had no engine. Aborting its installation.");
|
|
| 122 |
System.err.println("No engine found for " + enginesManager + ", installation failed.");
|
|
| 121 | 123 |
} |
| 122 | 124 |
} catch(Throwable e) {
|
| 123 | 125 |
e.printStackTrace(); |
| ... | ... | |
| 149 | 151 |
|
| 150 | 152 |
public static EnginesManager<?> getEngineManager(EngineType et) {
|
| 151 | 153 |
|
| 152 |
if (engines == null) {
|
|
| 154 |
if (enginesManagers == null) {
|
|
| 153 | 155 |
return null; |
| 154 | 156 |
} |
| 155 |
return engines.get(et); |
|
| 157 |
return enginesManagers.get(et);
|
|
| 156 | 158 |
} |
| 157 | 159 |
|
| 158 | 160 |
/** |
| ... | ... | |
| 438 | 440 |
* @param engine |
| 439 | 441 |
*/ |
| 440 | 442 |
private static void removeEngineManager(EnginesManager<?> engine) {
|
| 441 |
engines.remove(engine.getClass()); |
|
| 443 |
enginesManagers.remove(engine.getClass());
|
|
| 442 | 444 |
} |
| 443 | 445 |
|
| 444 | 446 |
/** |
| ... | ... | |
| 523 | 525 |
|
| 524 | 526 |
fetchEngineManagers(); |
| 525 | 527 |
|
| 526 |
Log.info("Starting " + engines.keySet().size() + " engines managers...");
|
|
| 528 |
Log.info("Starting " + enginesManagers.keySet().size() + " engines managers...");
|
|
| 527 | 529 |
|
| 528 | 530 |
boolean result = true; |
| 529 |
for (EngineType et : engines.keySet()) {
|
|
| 531 |
for (EngineType et : enginesManagers.keySet()) {
|
|
| 530 | 532 |
try {
|
| 531 |
EnginesManager<?> e = engines.get(et); |
|
| 533 |
EnginesManager<?> e = enginesManagers.get(et);
|
|
| 532 | 534 |
Log.info("Starting engines manager: " + e.getClass());
|
| 533 | 535 |
result = e.startEngines(monitor) && result; // order is important |
| 534 | 536 |
} catch(Exception e) {
|
| ... | ... | |
| 617 | 619 |
|
| 618 | 620 |
private static boolean stopEngineManagers() {
|
| 619 | 621 |
|
| 620 |
if (engines == null) return true; |
|
| 621 |
if (engines.size() == 0) return true; |
|
| 622 |
if (enginesManagers == null) return true;
|
|
| 623 |
if (enginesManagers.size() == 0) return true;
|
|
| 622 | 624 |
|
| 623 | 625 |
boolean result = true; |
| 624 |
for (EngineType c : engines.keySet()) {
|
|
| 625 |
EnginesManager<?> e = engines.get(c); |
|
| 626 |
for (EngineType c : enginesManagers.keySet()) {
|
|
| 627 |
EnginesManager<?> e = enginesManagers.get(c);
|
|
| 626 | 628 |
Log.info("Disconnect&stop engine: "+e.getClass());
|
| 627 | 629 |
result = result && e.stopEngines(); |
| 628 | 630 |
removeEngineManager(e); // remove the engine anyway |
| tmp/org.txm.core/plugin.xml (revision 784) | ||
|---|---|---|
| 1 | 1 |
<?xml version="1.0" encoding="UTF-8"?> |
| 2 | 2 |
<?eclipse version="3.4"?> |
| 3 | 3 |
<plugin> |
| 4 |
<extension-point id="org.txm.EnginesManager" name="org.txm.EnginesManager" schema="schema/engine_manager.exsd"/>
|
|
| 4 |
<extension-point id="org.txm.core.engines.EnginesManager" name="org.txm.core.engines.EnginesManager" schema="schema/engine_manager.exsd"/>
|
|
| 5 | 5 |
<extension-point id="org.txm.functions.CommandsAPIDeclaration" name="CommandsAPIDeclaration" schema="schema/org.txm.commandapi.exsd"/> |
| 6 | 6 |
<extension-point id="org.txm.PostInstallationStep" name="Post installation step" schema="schema/org.txm.PostInstallationStep.exsd"/> |
| 7 | 7 |
<extension-point id="org.txm.PostTXMHOMEInstallationStep" name="Post TXMHome installation step" schema="schema/org.txm.org.txm.PostTXMHOMEInstallationStep.exsd"/> |
| tmp/org.txm.core/schema/engine_manager.exsd (revision 784) | ||
|---|---|---|
| 3 | 3 |
<schema targetNamespace="org.txm.core" xmlns="http://www.w3.org/2001/XMLSchema"> |
| 4 | 4 |
<annotation> |
| 5 | 5 |
<appinfo> |
| 6 |
<meta.schema plugin="org.txm.core" id="org.txm.EnginesManager" name="Engine"/> |
|
| 6 |
<meta.schema plugin="org.txm.core" id="org.txm.core.engines.EnginesManager" name="Engine"/>
|
|
| 7 | 7 |
</appinfo> |
| 8 | 8 |
<documentation> |
| 9 | 9 |
A service with a start, connect, disconnect and stop lifecycle |
| ... | ... | |
| 55 | 55 |
|
| 56 | 56 |
</documentation> |
| 57 | 57 |
<appinfo> |
| 58 |
<meta.attribute kind="java" basedOn="org.txm.EnginesManager:"/> |
|
| 58 |
<meta.attribute kind="java" basedOn="org.txm.core.engines.EnginesManager:"/>
|
|
| 59 | 59 |
</appinfo> |
| 60 | 60 |
</annotation> |
| 61 | 61 |
</attribute> |
| tmp/org.txm.core/META-INF/MANIFEST.MF (revision 784) | ||
|---|---|---|
| 226 | 226 |
org.sqlite.jdbc4, |
| 227 | 227 |
org.sqlite.util, |
| 228 | 228 |
org.txm, |
| 229 |
org.txm.core.engines, |
|
| 229 | 230 |
org.txm.core.messages, |
| 230 | 231 |
org.txm.core.preferences, |
| 231 | 232 |
org.txm.core.results, |
| tmp/org.txm.chartsengine.r.core/src/org/txm/chartsengine/r/core/RChartsEngine.java (revision 784) | ||
|---|---|---|
| 17 | 17 |
|
| 18 | 18 |
/** |
| 19 | 19 |
* Charts engine providing methods to create charts using R. |
| 20 |
* |
|
| 20 | 21 |
* @author sjacquot |
| 21 | 22 |
* |
| 22 | 23 |
*/ |
| ... | ... | |
| 53 | 54 |
* @param outputFormat |
| 54 | 55 |
*/ |
| 55 | 56 |
public RChartsEngine(String outputFormat) {
|
| 56 |
super(NAME, DESCRIPTION, outputFormat);
|
|
| 57 |
super(DESCRIPTION, outputFormat); |
|
| 57 | 58 |
this.directComputing = false; |
| 58 | 59 |
this.setOutputFormat(outputFormat); |
| 59 | 60 |
} |
| ... | ... | |
| 214 | 215 |
return false; |
| 215 | 216 |
} |
| 216 | 217 |
|
| 217 |
@Override |
|
| 218 |
public boolean initialize() throws Exception {
|
|
| 219 |
// TODO Auto-generated method stub |
|
| 220 |
return false; |
|
| 221 |
} |
|
| 222 | 218 |
|
| 223 | 219 |
@Override |
| 224 | 220 |
public boolean start(IProgressMonitor monitor) throws Exception {
|
| ... | ... | |
| 232 | 228 |
return false; |
| 233 | 229 |
} |
| 234 | 230 |
|
| 231 |
@Override |
|
| 232 |
public String getName() {
|
|
| 233 |
return RChartsEngine.NAME; |
|
| 234 |
} |
|
| 235 | 235 |
|
| 236 |
|
|
| 236 | 237 |
} |
| tmp/org.txm.statsengine.r.core/src/org/txm/statsengine/r/core/RStatsEngine.java (revision 784) | ||
|---|---|---|
| 43 | 43 |
if (monitor != null) monitor.subTask("Starting Statistics Engine...");
|
| 44 | 44 |
|
| 45 | 45 |
if (TXMPreferences.getBoolean(RPreferences.DISABLE, RPreferences.PREFERENCES_NODE)) {
|
| 46 |
System.err.println("Warning, Statistics Engine is disabled.");
|
|
| 46 |
Log.severe("Warning, Statistics Engine is disabled.");
|
|
| 47 | 47 |
return false; |
| 48 | 48 |
} |
| 49 | 49 |
|
| ... | ... | |
| 169 | 169 |
RStatsEngine.kill(); |
| 170 | 170 |
started = false; |
| 171 | 171 |
} catch (Exception e) {
|
| 172 |
Log.severe("Error while closing R: " + e.getLocalizedMessage());
|
|
| 172 |
Log.severe("Error while closing R.");
|
|
| 173 |
e.printStackTrace(); |
|
| 173 | 174 |
} |
| 174 | 175 |
} |
| 175 | 176 |
|
| tmp/org.txm.chartsengine.jfreechart.core/src/org/txm/chartsengine/jfreechart/core/JFCChartsEngine.java (revision 784) | ||
|---|---|---|
| 75 | 75 |
* @param outputFormat the output format for the chart, it can be a file or an UI object |
| 76 | 76 |
*/ |
| 77 | 77 |
public JFCChartsEngine(String outputFormat) {
|
| 78 |
super(NAME, DESCRIPTION, outputFormat);
|
|
| 78 |
super(DESCRIPTION, outputFormat); |
|
| 79 | 79 |
this.jfcTheme = new HighchartsDefaultTheme(this); |
| 80 | 80 |
|
| 81 | 81 |
// FIXME |
| ... | ... | |
| 1591 | 1591 |
|
| 1592 | 1592 |
|
| 1593 | 1593 |
|
| 1594 |
|
|
| 1594 | 1595 |
@Override |
| 1595 |
public boolean initialize() throws Exception {
|
|
| 1596 |
public boolean start(IProgressMonitor monitor) throws Exception {
|
|
| 1596 | 1597 |
// TODO Auto-generated method stub |
| 1597 | 1598 |
return false; |
| 1598 | 1599 |
} |
| ... | ... | |
| 1600 | 1601 |
|
| 1601 | 1602 |
|
| 1602 | 1603 |
@Override |
| 1603 |
public boolean start(IProgressMonitor monitor) throws Exception {
|
|
| 1604 |
public boolean stop() throws Exception {
|
|
| 1604 | 1605 |
// TODO Auto-generated method stub |
| 1605 | 1606 |
return false; |
| 1606 | 1607 |
} |
| ... | ... | |
| 1608 | 1609 |
|
| 1609 | 1610 |
|
| 1610 | 1611 |
@Override |
| 1611 |
public boolean stop() throws Exception {
|
|
| 1612 |
// TODO Auto-generated method stub |
|
| 1613 |
return false; |
|
| 1612 |
public String getName() {
|
|
| 1613 |
return JFCChartsEngine.NAME; |
|
| 1614 | 1614 |
} |
| 1615 | 1615 |
|
| 1616 | 1616 |
|
| tmp/org.txm.annotation.core/plugin.xml (revision 784) | ||
|---|---|---|
| 3 | 3 |
<plugin> |
| 4 | 4 |
<extension-point id="org.txm.annotation.core.AnnotationEngine" name="org.txm.annotation.core.AnnotationEngine" schema="schema/org.txm.annotation.core.AnnotationEngine.exsd"/> |
| 5 | 5 |
<extension |
| 6 |
point="org.txm.EnginesManager"> |
|
| 6 |
point="org.txm.core.engines.EnginesManager">
|
|
| 7 | 7 |
<EngineManager |
| 8 |
class="org.txm.annotation.core.AnnotationEngines" |
|
| 8 |
class="org.txm.annotation.core.AnnotationEnginesManager"
|
|
| 9 | 9 |
description="description" |
| 10 | 10 |
name="org.txm.annotation.core.AnnotationEngines"> |
| 11 | 11 |
</EngineManager> |
| tmp/org.txm.annotation.core/src/org/txm/annotation/core/AnnotationEngines.java (revision 784) | ||
|---|---|---|
| 1 |
package org.txm.annotation.core; |
|
| 2 |
|
|
| 3 |
import org.eclipse.core.runtime.IConfigurationElement; |
|
| 4 |
import org.eclipse.core.runtime.IProgressMonitor; |
|
| 5 |
import org.eclipse.core.runtime.Platform; |
|
| 6 |
import org.txm.EngineType; |
|
| 7 |
import org.txm.EnginesManager; |
|
| 8 |
|
|
| 9 |
public class AnnotationEngines extends EnginesManager<AnnotationEngine> {
|
|
| 10 |
|
|
| 11 |
public AnnotationEngines() {
|
|
| 12 |
|
|
| 13 |
} |
|
| 14 |
|
|
| 15 |
@Override |
|
| 16 |
public boolean startEngines(IProgressMonitor monitor) {
|
|
| 17 |
|
|
| 18 |
for (AnnotationEngine e : engines.values()) {
|
|
| 19 |
System.out.println(e); |
|
| 20 |
// AnnotationEngine se = (AnnotationEngine)e; |
|
| 21 |
// if (monitor != null) monitor.subTask("Starting "+ se.getName()+" annotation engine.");
|
|
| 22 |
// try {
|
|
| 23 |
// se.start(monitor); |
|
| 24 |
// } catch (Exception ex) {
|
|
| 25 |
// System.out.println("Error: failed to start annotation engine: "+se.getName()+": "+ex.getLocalizedMessage());
|
|
| 26 |
// } |
|
| 27 |
} |
|
| 28 |
return true; |
|
| 29 |
} |
|
| 30 |
|
|
| 31 |
@Override |
|
| 32 |
public boolean stopEngines() {
|
|
| 33 |
for (AnnotationEngine e : engines.values()) {
|
|
| 34 |
System.out.println(e); |
|
| 35 |
// AnnotationEngine se = (AnnotationEngine)e; |
|
| 36 |
// System.out.println("Stoping "+ se.getName()+" annotation engine.");
|
|
| 37 |
// try {
|
|
| 38 |
// se.stop(); |
|
| 39 |
// } catch (Exception ex) {
|
|
| 40 |
// System.out.println("Error: failed to stop annotation engine: "+se.getName()+": "+ex.getLocalizedMessage());
|
|
| 41 |
// } |
|
| 42 |
} |
|
| 43 |
return true; |
|
| 44 |
} |
|
| 45 |
|
|
| 46 |
@Override |
|
| 47 |
public EngineType getEnginesType() {
|
|
| 48 |
return EngineType.ANNOTATION; |
|
| 49 |
} |
|
| 50 |
|
|
| 51 |
@Override |
|
| 52 |
protected boolean fetchEngines() {
|
|
| 53 |
|
|
| 54 |
IConfigurationElement[] contributions = Platform.getExtensionRegistry().getConfigurationElementsFor(AnnotationEngine.EXTENSION_POINT_ID); |
|
| 55 |
//System.out.println("search engine contributions: "+SearchEngine.EXTENSION_POINT_ID);
|
|
| 56 |
for (int i = 0; i < contributions.length; i++) {
|
|
| 57 |
try {
|
|
| 58 |
AnnotationEngine e = (AnnotationEngine)contributions[i].createExecutableExtension("class"); //$NON-NLS-1$
|
|
| 59 |
if (e.initialize()) {
|
|
| 60 |
engines.put(e.getName(), e); |
|
| 61 |
} else {
|
|
| 62 |
System.out.println("Fail to initialize "+e.getName()+" annotation engine.");
|
|
| 63 |
} |
|
| 64 |
} catch(Exception e) {
|
|
| 65 |
System.out.println("Error: fail instanciate "+contributions[i].getName()+": "+e.getLocalizedMessage());
|
|
| 66 |
e.printStackTrace(); |
|
| 67 |
} |
|
| 68 |
} |
|
| 69 |
|
|
| 70 |
return engines.size() > 0; |
|
| 71 |
} |
|
| 72 |
} |
|
| tmp/org.txm.annotation.core/src/org/txm/annotation/core/AnnotationEngine.java (revision 784) | ||
|---|---|---|
| 1 | 1 |
package org.txm.annotation.core; |
| 2 | 2 |
|
| 3 |
import org.txm.Engine; |
|
| 3 |
import org.txm.core.engines.Engine;
|
|
| 4 | 4 |
|
| 5 | 5 |
public abstract class AnnotationEngine implements Engine {
|
| 6 | 6 |
|
| tmp/org.txm.annotation.core/src/org/txm/annotation/core/AnnotationManager.java (revision 784) | ||
|---|---|---|
| 11 | 11 |
import org.txm.annotation.core.repository.AnnotationType; |
| 12 | 12 |
import org.txm.annotation.core.repository.TypedValue; |
| 13 | 13 |
import org.txm.annotation.core.storage.temporary.TemporaryAnnotationManager; |
| 14 |
import org.txm.core.engines.Engine; |
|
| 14 | 15 |
import org.txm.searchengine.cqp.corpus.MainCorpus; |
| 15 | 16 |
import org.txm.searchengine.cqp.corpus.query.Match; |
| 16 | 17 |
import org.txm.utils.logger.Log; |
| 17 |
import org.txm.Engine; |
|
| 18 | 18 |
|
| 19 | 19 |
/** |
| 20 | 20 |
* Manage annotations and is able to return annotation saved in JPA |
| tmp/org.txm.annotation.core/src/org/txm/annotation/core/AnnotationEnginesManager.java (revision 784) | ||
|---|---|---|
| 1 |
package org.txm.annotation.core; |
|
| 2 |
|
|
| 3 |
import org.eclipse.core.runtime.IConfigurationElement; |
|
| 4 |
import org.eclipse.core.runtime.IProgressMonitor; |
|
| 5 |
import org.eclipse.core.runtime.Platform; |
|
| 6 |
import org.txm.core.engines.EngineType; |
|
| 7 |
import org.txm.core.engines.EnginesManager; |
|
| 8 |
|
|
| 9 |
public class AnnotationEnginesManager extends EnginesManager<AnnotationEngine> {
|
|
| 10 |
|
|
| 11 |
public AnnotationEnginesManager() {
|
|
| 12 |
|
|
| 13 |
} |
|
| 14 |
|
|
| 15 |
@Override |
|
| 16 |
public boolean startEngines(IProgressMonitor monitor) {
|
|
| 17 |
|
|
| 18 |
for (AnnotationEngine e : engines.values()) {
|
|
| 19 |
System.out.println(e); |
|
| 20 |
// AnnotationEngine se = (AnnotationEngine)e; |
|
| 21 |
// if (monitor != null) monitor.subTask("Starting "+ se.getName()+" annotation engine.");
|
|
| 22 |
// try {
|
|
| 23 |
// se.start(monitor); |
|
| 24 |
// } catch (Exception ex) {
|
|
| 25 |
// System.out.println("Error: failed to start annotation engine: "+se.getName()+": "+ex.getLocalizedMessage());
|
|
| 26 |
// } |
|
| 27 |
} |
|
| 28 |
return true; |
|
| 29 |
} |
|
| 30 |
|
|
| 31 |
@Override |
|
| 32 |
public boolean stopEngines() {
|
|
| 33 |
for (AnnotationEngine e : engines.values()) {
|
|
| 34 |
System.out.println(e); |
|
| 35 |
// AnnotationEngine se = (AnnotationEngine)e; |
|
| 36 |
// System.out.println("Stoping "+ se.getName()+" annotation engine.");
|
|
| 37 |
// try {
|
|
| 38 |
// se.stop(); |
|
| 39 |
// } catch (Exception ex) {
|
|
| 40 |
// System.out.println("Error: failed to stop annotation engine: "+se.getName()+": "+ex.getLocalizedMessage());
|
|
| 41 |
// } |
|
| 42 |
} |
|
| 43 |
return true; |
|
| 44 |
} |
|
| 45 |
|
|
| 46 |
@Override |
|
| 47 |
public EngineType getEnginesType() {
|
|
| 48 |
return EngineType.ANNOTATION; |
|
| 49 |
} |
|
| 50 |
|
|
| 51 |
@Override |
|
| 52 |
public boolean fetchEngines() {
|
|
| 53 |
|
|
| 54 |
IConfigurationElement[] contributions = Platform.getExtensionRegistry().getConfigurationElementsFor(AnnotationEngine.EXTENSION_POINT_ID); |
|
| 55 |
//System.out.println("search engine contributions: "+SearchEngine.EXTENSION_POINT_ID);
|
|
| 56 |
for (int i = 0; i < contributions.length; i++) {
|
|
| 57 |
try {
|
|
| 58 |
AnnotationEngine e = (AnnotationEngine)contributions[i].createExecutableExtension("class"); //$NON-NLS-1$
|
|
| 59 |
if (e.initialize()) {
|
|
| 60 |
engines.put(e.getName(), e); |
|
| 61 |
} else {
|
|
| 62 |
System.out.println("Fail to initialize "+e.getName()+" annotation engine.");
|
|
| 63 |
} |
|
| 64 |
} catch(Exception e) {
|
|
| 65 |
System.out.println("Error: fail instanciate "+contributions[i].getName()+": "+e.getLocalizedMessage());
|
|
| 66 |
e.printStackTrace(); |
|
| 67 |
} |
|
| 68 |
} |
|
| 69 |
|
|
| 70 |
return engines.size() > 0; |
|
| 71 |
} |
|
| 72 |
} |
|
| 0 | 73 | |
| tmp/org.txm.chartsengine.core/plugin.xml (revision 784) | ||
|---|---|---|
| 10 | 10 |
</initializer> |
| 11 | 11 |
</extension> |
| 12 | 12 |
<extension |
| 13 |
point="org.txm.EnginesManager"> |
|
| 13 |
point="org.txm.core.engines.EnginesManager">
|
|
| 14 | 14 |
<EngineManager |
| 15 | 15 |
class="org.txm.chartsengine.core.ChartsEnginesManager" |
| 16 | 16 |
description="Charts Engines Manager" |
| tmp/org.txm.chartsengine.core/src/org/txm/chartsengine/core/ChartsEnginesManager.java (revision 784) | ||
|---|---|---|
| 1 | 1 |
package org.txm.chartsengine.core; |
| 2 | 2 |
|
| 3 |
import org.eclipse.core.runtime.IProgressMonitor; |
|
| 4 |
import org.txm.EngineType; |
|
| 5 |
import org.txm.EnginesManager; |
|
| 3 |
import java.util.ArrayList; |
|
| 4 |
|
|
| 6 | 5 |
import org.txm.chartsengine.core.preferences.ChartsEnginePreferences; |
| 6 |
import org.txm.core.engines.EngineType; |
|
| 7 |
import org.txm.core.engines.EnginesManager; |
|
| 7 | 8 |
import org.txm.core.preferences.TXMPreferences; |
| 8 | 9 |
|
| 9 | 10 |
/** |
| ... | ... | |
| 16 | 17 |
public class ChartsEnginesManager extends EnginesManager<ChartsEngine> {
|
| 17 | 18 |
|
| 18 | 19 |
@Override |
| 19 |
protected boolean fetchEngines() {
|
|
| 20 |
try {
|
|
| 21 |
// creates charts engine |
|
| 22 |
ChartsEngine.createChartsEngines(); |
|
| 23 |
ChartsEngine.setCurrrentChartsEngine(TXMPreferences.getString(ChartsEnginePreferences.CURRENT_NAME, ChartsEnginePreferences.PREFERENCES_NODE)); |
|
| 24 |
|
|
| 25 |
TXMPreferences.alternativeNodesQualifiers.add(ChartsEnginePreferences.PREFERENCES_NODE); |
|
| 26 |
|
|
| 27 |
} catch (Throwable e) {
|
|
| 28 |
e.printStackTrace(); |
|
| 20 |
public boolean fetchEngines() {
|
|
| 21 |
|
|
| 22 |
if(!this.fetchEngines(ChartsEngine.EXTENSION_POINT_ID)) {
|
|
| 29 | 23 |
return false; |
| 30 | 24 |
} |
| 31 |
return true; |
|
| 32 |
} |
|
| 25 |
|
|
| 26 |
// FIXME: temporary solution to not break the charts engines but later need to stop to use |
|
| 27 |
// ChartsEngine.chartsEngines, ChartsEngine.currentChartsEngineIndex, getCurrent() etc. |
|
| 28 |
// and directly manage that in the Manager |
|
| 29 |
ChartsEngine.chartsEngines = new ArrayList<ChartsEngine>(); |
|
| 30 |
ChartsEngine.currentChartsEngineIndex = 0; |
|
| 33 | 31 |
|
| 34 |
@Override |
|
| 35 |
public boolean startEngines(IProgressMonitor monitor) {
|
|
| 36 |
// TODO Auto-generated method stub |
|
| 37 |
return false; |
|
| 38 |
} |
|
| 32 |
for (ChartsEngine engine : engines.values()) {
|
|
| 33 |
ChartsEngine.chartsEngines.add(engine); |
|
| 34 |
} |
|
| 35 |
|
|
| 36 |
//ChartsEngine.setCurrrentChartsEngine(this.getEngine(TXMPreferences.getString(ChartsEnginePreferences.CURRENT_NAME, ChartsEnginePreferences.PREFERENCES_NODE))); |
|
| 37 |
|
|
| 38 |
ChartsEngine.setCurrrentChartsEngine(TXMPreferences.getString(ChartsEnginePreferences.CURRENT_NAME, ChartsEnginePreferences.PREFERENCES_NODE)); |
|
| 39 |
|
|
| 40 |
this.setCurrentEngine(TXMPreferences.getString(ChartsEnginePreferences.CURRENT_NAME, ChartsEnginePreferences.PREFERENCES_NODE)); |
|
| 41 |
|
|
| 42 |
TXMPreferences.alternativeNodesQualifiers.add(ChartsEnginePreferences.PREFERENCES_NODE); |
|
| 39 | 43 |
|
| 40 |
@Override |
|
| 41 |
public boolean stopEngines() {
|
|
| 42 |
// TODO Auto-generated method stub |
|
| 43 |
return false; |
|
| 44 |
return true; |
|
| 44 | 45 |
} |
| 45 | 46 |
|
| 46 | 47 |
@Override |
| tmp/org.txm.chartsengine.core/src/org/txm/chartsengine/core/ChartsEngine.java (revision 784) | ||
|---|---|---|
| 10 | 10 |
import org.eclipse.core.runtime.IConfigurationElement; |
| 11 | 11 |
import org.eclipse.core.runtime.Platform; |
| 12 | 12 |
import org.eclipse.core.runtime.RegistryFactory; |
| 13 |
import org.txm.Engine; |
|
| 14 | 13 |
import org.txm.chartsengine.core.messages.ChartsEngineCoreMessages; |
| 15 | 14 |
import org.txm.chartsengine.core.preferences.ChartsEnginePreferences; |
| 16 | 15 |
import org.txm.chartsengine.core.results.ChartResult; |
| 16 |
import org.txm.core.engines.Engine; |
|
| 17 | 17 |
import org.txm.core.preferences.TBXPreferences; |
| 18 | 18 |
import org.txm.core.preferences.TXMPreferences; |
| 19 | 19 |
import org.txm.utils.logger.Log; |
| ... | ... | |
| 21 | 21 |
|
| 22 | 22 |
/** |
| 23 | 23 |
* Common charts engine. This is the superclass of all chart engine implementations. |
| 24 |
* This class provides methods to create charts from variable chart creator stored by type of result data such as CA, CAH, Singular values, etc. |
|
| 24 |
* This class provides methods to create charts from variable chart creators stored by type of result data such as CA, CAH, Singular values, etc.
|
|
| 25 | 25 |
* @author sjacquot |
| 26 | 26 |
* |
| 27 | 27 |
*/ |
| 28 | 28 |
public abstract class ChartsEngine implements Engine {
|
| 29 | 29 |
|
| 30 |
public final static String extensionPointId = "org.txm.chartsengine.chartsengine"; //$NON-NLS-1$
|
|
| 30 |
public final static String EXTENSION_POINT_ID = "org.txm.chartsengine.chartsengine"; //$NON-NLS-1$
|
|
| 31 | 31 |
|
| 32 | 32 |
/** |
| 33 | 33 |
* Constants for output formats and file extensions. |
| ... | ... | |
| 40 | 40 |
public final static int RENDERING_COLORS_MODE = 0, RENDERING_GRAYSCALE_MODE = 1, RENDERING_BLACK_AND_WHITE_MODE = 2, RENDERING_MONOCHROME_MODE = 3; |
| 41 | 41 |
|
| 42 | 42 |
/** |
| 43 |
* The engine name. |
|
| 44 |
*/ |
|
| 45 |
protected String name; |
|
| 46 |
|
|
| 47 |
/** |
|
| 48 | 43 |
* The engine description. |
| 49 | 44 |
*/ |
| 50 | 45 |
protected String description; |
| ... | ... | |
| 86 | 81 |
* @param description |
| 87 | 82 |
* @param outputFormat |
| 88 | 83 |
*/ |
| 89 |
protected ChartsEngine(String name, String description, String outputFormat) {
|
|
| 84 |
protected ChartsEngine(String description, String outputFormat) {
|
|
| 90 | 85 |
this.chartCreators = new HashMap<Class, HashMap<String,ChartCreator>>(); |
| 91 |
this.name = name; |
|
| 92 | 86 |
this.description = description; |
| 93 | 87 |
this.outputFormat = outputFormat; |
| 94 | 88 |
this.theme = new Theme(); |
| 95 | 89 |
//FIXME: this preference is not used at this time, see if it's useless or not. |
| 96 | 90 |
this.directComputing = true; |
| 97 |
Log.info("Starting Charts Engine: " + this + ".");
|
|
| 98 | 91 |
} |
| 99 | 92 |
|
| 100 | 93 |
/** |
| ... | ... | |
| 111 | 104 |
} |
| 112 | 105 |
|
| 113 | 106 |
if(chartCreator == null && showLogWarning) {
|
| 114 |
Log.warning(this.name + ": No chart creator can be found for result: " + result.getClass() + " and chart type: " + chartType);
|
|
| 107 |
Log.warning(this.getName() + ": No chart creator can be found for result: " + result.getClass() + " and chart type: " + chartType);
|
|
| 115 | 108 |
} |
| 116 | 109 |
return chartCreator; |
| 117 | 110 |
} |
| ... | ... | |
| 202 | 195 |
|
| 203 | 196 |
chartCreator.setChartsEngine(this); |
| 204 | 197 |
|
| 205 |
String log = this.name + ": Chart creator " + chartCreator.getClass().getSimpleName() + " added for result data type: " + resultDataType;
|
|
| 198 |
String log = this.getName() + ": Chart creator " + chartCreator.getClass().getSimpleName() + " added for result data type: " + resultDataType;
|
|
| 206 | 199 |
|
| 207 | 200 |
if(chartType != null) {
|
| 208 | 201 |
log += " (chart type: " + chartType + ")"; |
| ... | ... | |
| 220 | 213 |
*/ |
| 221 | 214 |
public static void createChartsEngines() {
|
| 222 | 215 |
|
| 223 |
Log.finest("Looking for charts engines contributions with extension point id " + ChartsEngine.extensionPointId + ".");
|
|
| 216 |
Log.finest("Looking for charts engines contributions with extension point id " + ChartsEngine.EXTENSION_POINT_ID + ".");
|
|
| 224 | 217 |
|
| 225 | 218 |
ChartsEngine.chartsEngines = new ArrayList<ChartsEngine>(); |
| 226 | 219 |
ChartsEngine.currentChartsEngineIndex = 0; |
| 227 | 220 |
|
| 228 |
IConfigurationElement[] contributions = RegistryFactory.getRegistry().getConfigurationElementsFor(ChartsEngine.extensionPointId);
|
|
| 221 |
IConfigurationElement[] contributions = RegistryFactory.getRegistry().getConfigurationElementsFor(ChartsEngine.EXTENSION_POINT_ID);
|
|
| 229 | 222 |
|
| 230 | 223 |
Log.finest(contributions.length + " charts engines found."); |
| 231 | 224 |
|
| ... | ... | |
| 337 | 330 |
return ChartsEngine.chartsEngines; |
| 338 | 331 |
} |
| 339 | 332 |
|
| 333 |
|
|
| 334 |
@Override |
|
| 335 |
public boolean initialize() throws Exception {
|
|
| 336 |
this.registerChartCreatorExtensions(); |
|
| 337 |
return true; |
|
| 338 |
} |
|
| 339 |
|
|
| 340 |
|
|
| 341 |
|
|
| 340 | 342 |
/** |
| 341 | 343 |
* Populates the chart creators from loaded extensions according to the specified chars engine name. |
| 342 | 344 |
* @param chartsEngineName |
| ... | ... | |
| 362 | 364 |
|
| 363 | 365 |
} |
| 364 | 366 |
} |
| 365 |
|
|
| 367 |
|
|
| 366 | 368 |
/** |
| 367 | 369 |
* Populates the chart creators from loaded extensions. |
| 368 | 370 |
*/ |
| ... | ... | |
| 498 | 500 |
return this.exportChart(chart, file, outputFormat, imageWidth, imageHeight, 0, 0, imageWidth, imageHeight); |
| 499 | 501 |
} |
| 500 | 502 |
|
| 501 |
/** |
|
| 502 |
* @return the name |
|
| 503 |
*/ |
|
| 504 |
public String getName() {
|
|
| 505 |
return name; |
|
| 506 |
} |
|
| 507 | 503 |
|
| 508 | 504 |
/** |
| 509 |
* @param name the name to set |
|
| 510 |
*/ |
|
| 511 |
public void setName(String name) {
|
|
| 512 |
this.name = name; |
|
| 513 |
} |
|
| 514 |
|
|
| 515 |
/** |
|
| 516 | 505 |
* Gets the current output format. |
| 517 | 506 |
* @return |
| 518 | 507 |
*/ |
| ... | ... | |
| 570 | 559 |
|
| 571 | 560 |
@Override |
| 572 | 561 |
public String toString() {
|
| 573 |
String str = this.name + " (description: " + this.description + ", output format: " + this.outputFormat;
|
|
| 562 |
String str = this.getName() + " (description: " + this.description + ", output format: " + this.outputFormat;
|
|
| 574 | 563 |
|
| 575 | 564 |
str += ", supported output display formats: " + this.getSupportedOutputDisplayFormats().toString().replaceAll("\\[|\\]", ""); //$NON-NLS-2$ //$NON-NLS-3$
|
| 576 | 565 |
str += ", supported output file formats: " + this.getSupportedOutputFileFormats().toString().replaceAll("\\[|\\]", ""); //$NON-NLS-2$ //$NON-NLS-3$
|
| tmp/org.txm.searchengine.cqp.core/src/org/txm/searchengine/cqp/CQPEngine.java (revision 784) | ||
|---|---|---|
| 8 | 8 |
import org.eclipse.core.runtime.IProgressMonitor; |
| 9 | 9 |
import org.eclipse.core.runtime.Platform; |
| 10 | 10 |
import org.osgi.framework.Bundle; |
| 11 |
import org.txm.EngineType; |
|
| 12 | 11 |
import org.txm.Toolbox; |
| 12 |
import org.txm.core.engines.EngineType; |
|
| 13 | 13 |
import org.txm.core.messages.TXMCoreMessages; |
| 14 | 14 |
import org.txm.core.preferences.TBXPreferences; |
| 15 | 15 |
import org.txm.core.preferences.TXMPreferences; |
| tmp/org.txm.statsengine.r.rcp/src/org/txm/statsengine/r/rcp/views/RConsole.java (revision 784) | ||
|---|---|---|
| 37 | 37 |
import org.eclipse.ui.IWorkbenchWindow; |
| 38 | 38 |
import org.eclipse.ui.PlatformUI; |
| 39 | 39 |
import org.eclipse.ui.part.ViewPart; |
| 40 |
import org.txm.EngineType; |
|
| 41 | 40 |
import org.txm.Toolbox; |
| 41 |
import org.txm.core.engines.EngineType; |
|
| 42 | 42 |
import org.txm.rcp.IImageKeys; |
| 43 | 43 |
import org.txm.statsengine.r.core.RWorkspace; |
| 44 | 44 |
import org.txm.statsengine.r.core.exceptions.RWorkspaceException; |
| tmp/org.txm.statsengine.r.rcp/src/org/txm/statsengine/r/rcp/handlers/CheckRPackages.java (revision 784) | ||
|---|---|---|
| 15 | 15 |
import org.rosuda.REngine.REXPInteger; |
| 16 | 16 |
import org.rosuda.REngine.REXPMismatchException; |
| 17 | 17 |
import org.rosuda.REngine.RList; |
| 18 |
import org.txm.EngineType; |
|
| 19 | 18 |
import org.txm.Toolbox; |
| 19 |
import org.txm.core.engines.EngineType; |
|
| 20 | 20 |
import org.txm.core.preferences.TBXPreferences; |
| 21 | 21 |
import org.txm.core.preferences.TXMPreferences; |
| 22 | 22 |
import org.txm.rcp.handlers.BaseAbstractHandler; |
Formats disponibles : Unified diff