Révision 288

tmp/CQP/src/cwbinstaller/Activator.java (revision 288)
1
package cwbinstaller;
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/CQP/src/cwbinstaller/commands/DoInstallStep.java (revision 288)
1
package cwbinstaller.commands;
2

  
3
import java.io.File;
4

  
5
import org.eclipse.core.commands.ExecutionEvent;
6
import org.eclipse.core.commands.ExecutionException;
7
import org.eclipse.jface.util.Util;
8
import org.osgi.framework.Version;
9
import org.txm.rcpapplication.TxmPreferences;
10
import org.txm.rcpapplication.preferences.CQPPreferencePage;
11
import org.txm.utils.BundleUtils;
12
import org.txm.utils.logger.Log;
13

  
14
public class DoInstallStep extends org.txm.rcpapplication.commands.TxmCommand {
15
	protected String name = "cwbbinaries.commands.DoInstallStep"; //$NON-NLS-1$
16
	public static final String VERSION = "cwbinstaller.commands.version";
17
	
18
	@Override
19
	public Object execute(ExecutionEvent event) throws ExecutionException {
20
		// TODO Auto-generated method stub
21
		return null;
22
	}
23

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

  
60
		File bundleDir = BundleUtils.getBundleFile(CQPFRAGMENT);
61
		if (bundleDir == null) {
62
			System.out.println("Error while retrieving TreeTaggerInstaller bundle directory.");
63
			return;
64
		}
65
		File cwbDir = new File(bundleDir, "res");
66
		File initFile = new File(cwbDir, "cqpserver.init");
67
		File OSDir = new File(cwbDir, os);
68
		File execFile = new File(OSDir, "cqpserver"+ext);
69

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

  
tmp/CQP/bin/cqpserver.init (revision 288)
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/CQP/res/cqpserver.init (revision 288)
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/CQP/build.properties (revision 288)
1
source.. = src/
2
output.. = bin/
3
bin.includes = plugin.xml,\
4
               META-INF/,\
5
               .,\
6
               icons/,\
7
               res/
0 8

  
tmp/CQP/plugin.xml (revision 288)
1
<?xml version="1.0" encoding="UTF-8"?>
2
<?eclipse version="3.4"?>
3
<plugin>
4
   <extension
5
         point="org.txm.rcp.extentionpoint.command">
6
      <installcommand
7
            class="cwbinstaller.commands.DoInstallStep">
8
      </installcommand>
9
   </extension>
10

  
11

  
12
</plugin>
0 13

  
tmp/CQP/.settings/org.eclipse.jdt.core.prefs (revision 288)
1
eclipse.preferences.version=1
2
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
3
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7
4
org.eclipse.jdt.core.compiler.compliance=1.7
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.7
0 8

  
tmp/CQP/.classpath (revision 288)
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.7"/>
4
	<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins">
5
		<accessrules>
6
			<accessrule kind="accessible" pattern="**"/>
7
		</accessrules>
8
	</classpathentry>
9
	<classpathentry kind="src" path="src"/>
10
	<classpathentry kind="src" path="res"/>
11
	<classpathentry kind="output" path="bin"/>
12
</classpath>
0 13

  
tmp/CQP/META-INF/MANIFEST.MF (revision 288)
1
Manifest-Version: 1.0
2
Bundle-ManifestVersion: 2
3
Bundle-Name: CQP
4
Bundle-SymbolicName: CQP;singleton:=true
5
Bundle-Version: 1.1.0.qualifier
6
Bundle-Activator: cwbinstaller.Activator
7
Require-Bundle: org.eclipse.ui,
8
 org.eclipse.core.runtime,
9
 org.txm.rcp;bundle-version="0.7.8",
10
 org.txm.core;bundle-version="0.7.0"
11
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
12
Bundle-ClassPath: res/,
13
 .
14
Bundle-Vendor: Textometrie.org
15
Export-Package: cwbinstaller,
16
 cwbinstaller.commands
17
Bundle-ActivationPolicy: lazy
0 18

  
tmp/CQP/.project (revision 288)
1
<?xml version="1.0" encoding="UTF-8"?>
2
<projectDescription>
3
	<name>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

  

Formats disponibles : Unified diff