Révision 679

tmp/org.txm.treetagger.core/build.properties (revision 679)
1
source.. = src/
2
output.. = bin/
3
bin.includes = META-INF/,\
4
               .,\
5
               plugin.xml
0 6

  
tmp/org.txm.treetagger.core/plugin.xml (revision 679)
1
<?xml version="1.0" encoding="UTF-8"?>
2
<?eclipse version="3.4"?>
3
<plugin>
4
   <extension
5
         point="org.eclipse.core.runtime.preferences">
6
      <initializer
7
            class="org.txm.treetagger.core.preferences.TreeTaggerPreferences">
8
      </initializer>
9
   </extension>
10

  
11
</plugin>
0 12

  
tmp/org.txm.treetagger.core/.settings/org.eclipse.jdt.core.prefs (revision 679)
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.treetagger.core/.classpath (revision 679)
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="output" path="bin"/>
7
</classpath>
0 8

  
tmp/org.txm.treetagger.core/META-INF/MANIFEST.MF (revision 679)
1
Manifest-Version: 1.0
2
Bundle-ManifestVersion: 2
3
Bundle-Name: TreeTagger Core
4
Bundle-SymbolicName: org.txm.treetagger.core;singleton:=true
5
Bundle-Version: 1.0.0.qualifier
6
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
7
Bundle-ActivationPolicy: lazy
8
Require-Bundle: org.txm.utils,
9
 org.eclipse.core.runtime;bundle-version="3.10.0",
10
 org.txm.core;bundle-version="0.8.0"
11
Export-Package: org.txm.treetagger.core.preferences
0 12

  
tmp/org.txm.treetagger.core/.project (revision 679)
1
<?xml version="1.0" encoding="UTF-8"?>
2
<projectDescription>
3
	<name>org.txm.treetagger.core</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.treetagger.core/src/org/txm/treetagger/core/preferences/TreeTaggerPreferences.java (revision 679)
1
package org.txm.treetagger.core.preferences;
2

  
3

  
4
import java.io.BufferedReader;
5
import java.io.File;
6
import java.io.FileNotFoundException;
7
import java.io.IOException;
8
import java.io.UnsupportedEncodingException;
9
import java.util.Properties;
10

  
11
import org.eclipse.core.runtime.preferences.DefaultScope;
12
import org.osgi.framework.FrameworkUtil;
13
import org.osgi.service.prefs.Preferences;
14
import org.txm.core.preferences.TXMPreferences;
15
import org.txm.utils.io.IOUtils;
16

  
17
/**
18
 * Default preferences initializer.
19
 * 
20
 * @author mdecorde
21
 * @author sjacquot
22
 *
23
 */
24
public class TreeTaggerPreferences extends TXMPreferences {
25

  
26

  
27
	// auto populate the preference node qualifier from the current bundle id
28
	public static final String PREFERENCES_NODE = FrameworkUtil.getBundle(TreeTaggerPreferences.class).getSymbolicName();
29
	
30
	public static final String PREFERENCES_PREFIX = "treetagger_"; //$NON-NLS-1$
31
	
32

  
33
	/**
34
	 * Installation path.
35
	 */
36
	public static final String INSTALL_PATH = PREFERENCES_PREFIX + "install_path"; //$NON-NLS-1$
37

  
38
	/**
39
	 * Models path.
40
	 */
41
	public static final String MODELS_PATH = PREFERENCES_PREFIX + "models_path"; //$NON-NLS-1$
42
	
43
	public static final String OPTIONS = PREFERENCES_PREFIX + "options"; //$NON-NLS-1$
44
	
45
	public static final String FIX_APOSTROPHES = PREFERENCES_PREFIX + "fix_apostrophes"; //$NON-NLS-1$
46

  
47

  
48
	
49
	@Override
50
	public void initializeDefaultPreferences() {
51

  
52
		// Default preferences
53
		Preferences preferences = DefaultScope.INSTANCE.getNode(PREFERENCES_NODE);
54
		
55
		String installPath = System.getProperty("osgi.user.area") + "/TXM/treetagger"; //$NON-NLS-1$ //$NON-NLS-2$
56
		
57
		preferences.put(INSTALL_PATH, installPath);
58
		preferences.put(MODELS_PATH, installPath + "/models"); //$NON-NLS-1$
59
		preferences.putBoolean(FIX_APOSTROPHES, false);
60

  
61
		
62
		// FIXME: need to validate this code + need to check if it's still useful
63
		
64
		// Restore previous TreeTagger preferences
65
		File previousPreferenceFile = new File(System.getProperty("java.io.tmpdir"), "org.txm.rcp.prefs"); //$NON-NLS-1$ //$NON-NLS-2$
66

  
67
		if (System.getProperty("os.name").indexOf("Mac") >= 0) { //$NON-NLS-1$ //$NON-NLS-2$
68
			previousPreferenceFile = new File("/tmp/org.txm.rcp.prefs"); //$NON-NLS-1$
69
		}
70

  
71
		if (previousPreferenceFile.exists()) {
72
			try {
73
				System.out.println("Restoring preferences (from " + previousPreferenceFile + ")."); //$NON-NLS-1$ //$NON-NLS-2$
74
				Properties previousProperties = new Properties();
75
				BufferedReader reader = IOUtils.getReader(previousPreferenceFile, "ISO-8859-1"); //$NON-NLS-1$
76
				previousProperties.load(reader);
77
				
78
				String [] keys= {INSTALL_PATH, MODELS_PATH, OPTIONS};
79
				for (String k : keys) {
80
					if (previousProperties.getProperty(k) != null) {
81
						TreeTaggerPreferences.put(PREFERENCES_NODE, k, previousProperties.getProperty(k));
82
					}
83
				}
84
			}
85
			catch (Exception e) {
86
				e.printStackTrace();
87
			}
88
		}
89

  
90
	}
91
	
92
}
0 93

  

Formats disponibles : Unified diff