Révision 396

tmp/org.txm.libs.cqp/res/cqpserver.init (revision 396)
1
host *;               # allow access from any host (including localhost)
2

  
3
# users must login with name "anonymous" and explicit "" as password!
4
user anonymous "";
tmp/org.txm.libs.cqp/build.properties (revision 396)
1
source.. = src/
2
output.. = bin/
3
bin.includes = META-INF/,\
4
               .,\
5
               plugin.xml
0 6

  
tmp/org.txm.libs.cqp/plugin.xml (revision 396)
1
<?xml version="1.0" encoding="UTF-8"?>
2
<?eclipse version="3.4"?>
3
<plugin>
4
   <extension
5
         point="org.txm.postinstallationstep">
6
      <PostInstallationStep
7
            class="org.txm.libs.cqp.DoInstallStep"
8
            description="Set CQP preferences"
9
            name="org.txm.libs.cqp.DoInstallStep">
10
      </PostInstallationStep>
11
   </extension>
12

  
13
</plugin>
0 14

  
tmp/org.txm.libs.cqp/.settings/org.eclipse.jdt.core.prefs (revision 396)
1
eclipse.preferences.version=1
2
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
3
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
4
org.eclipse.jdt.core.compiler.compliance=1.6
5
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
6
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
7
org.eclipse.jdt.core.compiler.source=1.6
0 8

  
tmp/org.txm.libs.cqp/.classpath (revision 396)
1
<?xml version="1.0" encoding="UTF-8"?>
2
<classpath>
3
	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
4
	<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
5
	<classpathentry kind="src" path="src"/>
6
	<classpathentry kind="src" path="res"/>
7
	<classpathentry kind="output" path="bin"/>
8
</classpath>
0 9

  
tmp/org.txm.libs.cqp/META-INF/MANIFEST.MF (revision 396)
1
Manifest-Version: 1.0
2
Bundle-ManifestVersion: 2
3
Bundle-Name: CQP libs
4
Bundle-SymbolicName: org.txm.libs.cqp;singleton:=true
5
Bundle-Version: 1.0.0.qualifier
6
Bundle-Activator: org.txm.libs.cqp.Activator
7
Require-Bundle: org.eclipse.core.runtime,
8
 org.txm.core,
9
 org.eclipse.ui.workbench,
10
 org.eclipse.jface
11
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
12
Bundle-ActivationPolicy: lazy
13
Export-Package: org.txm.libs.cqp
0 14

  
tmp/org.txm.libs.cqp/.project (revision 396)
1
<?xml version="1.0" encoding="UTF-8"?>
2
<projectDescription>
3
	<name>org.txm.libs.cqp</name>
4
	<comment></comment>
5
	<projects>
6
	</projects>
7
	<buildSpec>
8
		<buildCommand>
9
			<name>org.eclipse.jdt.core.javabuilder</name>
10
			<arguments>
11
			</arguments>
12
		</buildCommand>
13
		<buildCommand>
14
			<name>org.eclipse.pde.ManifestBuilder</name>
15
			<arguments>
16
			</arguments>
17
		</buildCommand>
18
		<buildCommand>
19
			<name>org.eclipse.pde.SchemaBuilder</name>
20
			<arguments>
21
			</arguments>
22
		</buildCommand>
23
	</buildSpec>
24
	<natures>
25
		<nature>org.eclipse.pde.PluginNature</nature>
26
		<nature>org.eclipse.jdt.core.javanature</nature>
27
	</natures>
28
</projectDescription>
0 29

  
tmp/org.txm.libs.cqp/src/org/txm/libs/cqp/Activator.java (revision 396)
1
package org.txm.libs.cqp;
2

  
3
import org.eclipse.jface.resource.ImageDescriptor;
4
import org.eclipse.ui.plugin.AbstractUIPlugin;
5
import org.osgi.framework.BundleContext;
6

  
7
/**
8
 * The activator class controls the plug-in life cycle
9
 */
10
public class Activator extends AbstractUIPlugin {
11

  
12
	// The plug-in ID
13
	public static final String PLUGIN_ID = "CQP"; //$NON-NLS-1$
14

  
15
	// The shared instance
16
	private static Activator plugin;
17
	
18
	/**
19
	 * The constructor
20
	 */
21
	public Activator() {
22
	}
23

  
24
	/*
25
	 * (non-Javadoc)
26
	 * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
27
	 */
28
	public void start(BundleContext context) throws Exception {
29
		super.start(context);
30
		plugin = this;
31
	}
32

  
33
	/*
34
	 * (non-Javadoc)
35
	 * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
36
	 */
37
	public void stop(BundleContext context) throws Exception {
38
		plugin = null;
39
		super.stop(context);
40
	}
41

  
42
	/**
43
	 * Returns the shared instance
44
	 *
45
	 * @return the shared instance
46
	 */
47
	public static Activator getDefault() {
48
		return plugin;
49
	}
50

  
51
	/**
52
	 * Returns an image descriptor for the image file at the given
53
	 * plug-in relative path
54
	 *
55
	 * @param path the path
56
	 * @return the image descriptor
57
	 */
58
	public static ImageDescriptor getImageDescriptor(String path) {
59
		return imageDescriptorFromPlugin(PLUGIN_ID, path);
60
	}
61
}
0 62

  
tmp/org.txm.libs.cqp/src/org/txm/libs/cqp/CQPPreferences.java (revision 396)
1
package org.txm.libs.cqp;
2

  
3
import org.eclipse.core.runtime.preferences.DefaultScope;
4
import org.osgi.service.prefs.Preferences;
5
import org.txm.core.preferences.TXMPreferences;
6

  
7
public class CQPPreferences extends TXMPreferences {
8

  
9
	public static final String PREFERENCES_NODE = "cwbinstaller";
10
	
11
	public static final String VERSION = "cwbinstaller.commands.version";
12

  
13
	@Override
14
	public void initializeDefaultPreferences() {
15
		Preferences preferences = DefaultScope.INSTANCE.getNode(PREFERENCES_NODE);
16
		preferences.put(VERSION, "0.0");
17
	}
18
}
0 19

  
tmp/org.txm.libs.cqp/src/org/txm/libs/cqp/DoInstallStep.java (revision 396)
1
package org.txm.libs.cqp;
2

  
3
import java.io.File;
4

  
5
import org.eclipse.jface.util.Util;
6
import org.osgi.framework.Version;
7
import org.txm.PostInstallationStep;
8
import org.txm.core.preferences.TBXPreferences;
9
import org.txm.core.preferences.TXMPreferences;
10
import org.txm.utils.BundleUtils;
11
import org.txm.utils.logger.Log;
12

  
13
public class DoInstallStep extends PostInstallationStep {
14
	
15
	protected String name = "corg.txm.libs.cqp.DoInstallStep"; //$NON-NLS-1$
16

  
17
	@Override
18
	public void install() {	
19
		// nothing to do
20
	}
21
	
22
	@Override
23
	public void preInstall() {
24
		
25
		String CQPFRAGMENT = "CQP."+System.getProperty("osgi.os");
26
		
27
		Log.info("CQP.DoInstallStep.install()");
28
		String saved = TXMPreferences.getString(CQPPreferences.PREFERENCES_NODE, CQPPreferences.VERSION, "");
29
		Version currentVersion = BundleUtils.getBundleVersion(CQPFRAGMENT); // the CQPFRAGMENT plugin contains the right version
30
		
31
		if (saved != null && saved.length() > 0) {
32
			Version savedVersion = new Version(saved);
33
			if (currentVersion.compareTo(savedVersion) <= 0) {
34
				Log.info("No post-installation of CQP to do");
35
				return; // nothing to do
36
			}
37
		}
38
		System.out.println("Updating CWB preferences for CQP version="+currentVersion);
39
		
40
		String os = "win";
41
		String ext = "";
42
		if (Util.isWindows()) { //$NON-NLS-1$
43
			if (System.getProperty("os.arch").contains("64")) { os = "win64"; } 
44
			else { os = "win32"; }
45
			ext = ".exe";
46
		} else if (Util.isMac()) { //$NON-NLS-1$
47
			os = "macosx";
48
		} else {
49
			os = "linux32";
50
			if (System.getProperty("os.arch").contains("64")) 
51
				os = "linux64";
52
		}
53

  
54
		File bundleDir = BundleUtils.getBundleFile(CQPFRAGMENT);
55
		if (bundleDir == null) {
56
			System.out.println("Error while retrieving TreeTaggerInstaller bundle directory.");
57
			return;
58
		}
59
		File cwbDir = new File(bundleDir, "res");
60
		File initFile = new File(cwbDir, "cqpserver.init");
61
		File OSDir = new File(cwbDir, os);
62
		File execFile = new File(OSDir, "cqpserver"+ext);
63

  
64
		TXMPreferences.putString(TBXPreferences.PREFERENCES_NODE, TBXPreferences.CQI_SERVER_PATH_TO_CQPLIB, OSDir.getAbsolutePath());
65
		TXMPreferences.putString(TBXPreferences.PREFERENCES_NODE, TBXPreferences.CQI_SERVER_PATH_TO_INIT_FILE, initFile.getAbsolutePath());
66
		TXMPreferences.putString(TBXPreferences.PREFERENCES_NODE, TBXPreferences.CQI_SERVER_PATH_TO_EXECUTABLE, execFile.getAbsolutePath());
67
		if (!Util.isWindows()) { 
68
			try {
69
				Log.info("Setting execution file rights to: "+OSDir.getAbsolutePath());
70
				Runtime.getRuntime().exec("chmod -R +x "+OSDir.getAbsolutePath()).waitFor();
71
			} catch (Exception e) {
72
				System.out.println("Error while setting execution file rights to: "+OSDir.getAbsolutePath());
73
				e.printStackTrace();
74
			}
75
		}
76
	
77
		if (!execFile.canExecute()) {
78
			System.out.println("File right setting error, cannot execute: "+execFile);
79
		}
80
		Log.warning("SearchEngine preferences set with: "+OSDir.getAbsolutePath()+ ", "+initFile.getAbsolutePath()+ " and "+execFile.getAbsolutePath());
81
		TXMPreferences.putString(CQPPreferences.PREFERENCES_NODE, CQPPreferences.VERSION, currentVersion.toString());
82
	}
83
}
0 84

  

Formats disponibles : Unified diff