Revision 472

tmp/org.txm.imports.metopes/src/org/txm/imports/metopes/Activator.java (revision 472)
1
package org.txm.imports.metopes;
2

  
3
import org.eclipse.ui.plugin.AbstractUIPlugin;
4
import org.osgi.framework.BundleContext;
5

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

  
11
	// The plug-in ID
12
	public static final String PLUGIN_ID = "org.txm.imports.metopes"; //$NON-NLS-1$
13

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

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

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

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

  
50
}
0 51

  
tmp/org.txm.imports.metopes/src/org/txm/imports/metopes/DoInstallStep.java (revision 472)
1
package org.txm.imports.metopes;
2

  
3
import java.io.File;
4

  
5
import org.osgi.framework.Version;
6
import org.txm.PostInstallationStep;
7
import org.txm.core.preferences.TBXPreferences;
8
import org.txm.core.preferences.TXMPreferences;
9
import org.txm.importer.metopes.preferences.MetopesPreferences;
10
import org.txm.utils.BundleUtils;
11
import org.txm.utils.logger.Log;
12

  
13
/**
14
 * Copy macros from bundle to TXM macro directory
15
 * 
16
 * @author mdecorde
17
 *
18
 */
19
public class DoInstallStep  extends PostInstallationStep {
20

  
21
	/** The ID. */
22
	public static String ID = "org.txm.imports.metopes.DoInstallStep"; //$NON-NLS-1$
23
	public static final String VERSION = "org.txm.imports.metopes.version";
24

  
25
	public DoInstallStep() { name = "Metopes"; }
26
	
27
	public void install() { // after the Toolbox is initialized
28
		
29
		Log.info("Metopes.DoInstallStep.install()");
30
		String saved = TXMPreferences.getString(MetopesPreferences.VERSION, MetopesPreferences.PREFERENCES_NODE);
31
		Version currentVersion = BundleUtils.getBundleVersion("org.txm.imports.metopes");
32
		
33
		if (saved != null && saved.length() > 0) {
34
			Version savedVersion = new Version(saved);
35
			if (currentVersion.compareTo(savedVersion) <= 0) {
36
				Log.info("No post-installation of Metopes to do");
37
				//System.out.println("No post-installation of Metopes to do");
38
				return; // nothing to do
39
			}
40
		}
41
		System.out.println("Post-installing Metopes version="+currentVersion);
42
		
43
		File macroDirectory = new File(TXMPreferences.getString(TBXPreferences.USER_TXM_HOME, TBXPreferences.PREFERENCES_NODE), "scripts/macro/org/txm/macro");
44
		macroDirectory.mkdirs();
45
		if (!BundleUtils.copyFiles("org.txm.imports.metopes", "src", "org/txm/macro/", "metopes", macroDirectory)) {
46
			System.out.println("Error while coping Metopes org/txm/macro/metopes in "+macroDirectory.getAbsolutePath());
47
			return;
48
		}
49
		
50
		File importDirectory = new File(TXMPreferences.getString(TBXPreferences.USER_TXM_HOME, TBXPreferences.PREFERENCES_NODE), "scripts/import");
51
		importDirectory.mkdirs();
52
		if (!BundleUtils.copyFiles("org.txm.imports.metopes", "src", "org/txm/importer/metopes", "metopesLoader.groovy", importDirectory)) {
53
			System.out.println("Error while coping Metopes org/txm/importer/metopes in "+importDirectory.getAbsolutePath());
54
			return;
55
		}
56
		
57
		File xslDirectory = new File(TXMPreferences.getString(TBXPreferences.USER_TXM_HOME, TBXPreferences.PREFERENCES_NODE), "xsl");
58
		xslDirectory.mkdirs();
59
		if (!BundleUtils.copyFiles("org.txm.imports.metopes", "res", "org/txm/xml/xsl", "metopes", xslDirectory)) {
60
			System.out.println("Error while coping Metopes org/txm/xml/xsl/metopes in "+xslDirectory.getAbsolutePath());
61
			return;
62
		}
63
		
64
		Log.warning("Metopes post-installation done.");
65
		TXMPreferences.put(MetopesPreferences.PREFERENCES_NODE, MetopesPreferences.VERSION, currentVersion.toString());
66
		return;
67
	}
68
}
0 69

  
tmp/org.txm.imports.metopes/src/org/txm/importer/metopes/preferences/MetopesPreferences.java (revision 472)
1
package org.txm.importer.metopes.preferences;
2

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

  
8
public class MetopesPreferences extends TXMPreferences{
9

  
10
	public static final String PREFERENCES_NODE = FrameworkUtil.getBundle(MetopesPreferences.class).getSymbolicName();
11
	public static final String VERSION = "metopes.version"; //$NON-NLS-1$
12
	
13
	@Override
14
	public void initializeDefaultPreferences() {
15
		Preferences preferences = DefaultScope.INSTANCE.getNode(PREFERENCES_NODE);
16
		preferences.put(VERSION, "");
17
	}
18
}
0 19

  
tmp/org.txm.imports.metopes/src/org/txm/importer/metopes/metopesLoader.groovy (revision 472)
1
package org.txm.importer.metopes
tmp/org.txm.imports.metopes/src/org/txm/macro/metopes/testMacro.groovy (revision 472)
1
package org.txm.macro.metopes
2

  
3
println "test"
tmp/org.txm.imports.metopes/build.properties (revision 472)
1
source.. = src/
2
output.. = bin/
3
bin.includes = META-INF/,\
4
               .,\
5
               plugin.xml
0 6

  
tmp/org.txm.imports.metopes/plugin.xml (revision 472)
1
<?xml version="1.0" encoding="UTF-8"?>
2
<?eclipse version="3.4"?>
3
<plugin>
4
   <extension
5
         point="org.eclipse.ui.menus">
6
      <menuContribution
7
            locationURI="menu:menu.file.import?before=menu.file.import.separator.software">
8
         <command
9
               commandId="org.txm.rcpapplication.commands.ExecuteScriptImport"
10
               label="XML-TEI Metopes"
11
               style="push"
12
               tooltip="Metopes">
13
            <parameter
14
                  name="org.txm.rcpapplication.commands.commandParameter3"
15
                  value="metopesLoader.groovy">
16
            </parameter>
17
         </command>
18
      </menuContribution>
19
   </extension>
20
   <extension
21
         point="org.txm.rcp.extentionpoint.command">
22
      <installcommand
23
            class="org.txm.imports.metopes.DoInstallStep">
24
      </installcommand>
25
   </extension>
26

  
27
</plugin>
0 28

  
tmp/org.txm.imports.metopes/.settings/org.eclipse.jdt.core.prefs (revision 472)
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.imports.metopes/.classpath (revision 472)
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
		<accessrules>
6
			<accessrule kind="accessible" pattern="**"/>
7
		</accessrules>
8
	</classpathentry>
9
	<classpathentry kind="src" path="src"/>
10
	<classpathentry kind="src" path="res"/>
11
	<classpathentry exported="true" kind="con" path="GROOVY_DSL_SUPPORT"/>
12
	<classpathentry kind="output" path="bin"/>
13
</classpath>
0 14

  
tmp/org.txm.imports.metopes/META-INF/MANIFEST.MF (revision 472)
1
Manifest-Version: 1.0
2
Bundle-ManifestVersion: 2
3
Bundle-Name: Metopes
4
Bundle-SymbolicName: org.txm.imports.metopes;singleton:=true
5
Bundle-Version: 1.0.1.qualifier
6
Bundle-Activator: org.txm.imports.metopes.Activator
7
Require-Bundle: org.txm.core;bundle-version="0.7.0",
8
 org.txm.rcp;bundle-version="0.7.8",
9
 org.eclipse.ui,
10
 org.eclipse.core.runtime
11
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
12
Bundle-ActivationPolicy: lazy
0 13

  
tmp/org.txm.imports.metopes/.project (revision 472)
1
<?xml version="1.0" encoding="UTF-8"?>
2
<projectDescription>
3
	<name>org.txm.imports.metopes</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.jdt.groovy.core.groovyNature</nature>
26
		<nature>org.eclipse.pde.PluginNature</nature>
27
		<nature>org.eclipse.jdt.core.javanature</nature>
28
	</natures>
29
</projectDescription>
0 30

  

Also available in: Unified diff