Révision 1024
| tmp/org.txm.translate.rcp/.classpath (revision 1024) | ||
|---|---|---|
| 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="output" path="bin"/> |
|
| 11 |
</classpath> |
|
| 0 | 12 | |
| tmp/org.txm.translate.rcp/META-INF/MANIFEST.MF (revision 1024) | ||
|---|---|---|
| 1 |
Manifest-Version: 1.0 |
|
| 2 |
Bundle-ManifestVersion: 2 |
|
| 3 |
Bundle-Name: org.txm.translate.rcp |
|
| 4 |
Bundle-SymbolicName: org.txm.translate.rcp;singleton:=true |
|
| 5 |
Bundle-Version: 1.0.0.qualifier |
|
| 6 |
Automatic-Module-Name: org.txm.translate.rcp |
|
| 7 |
Bundle-RequiredExecutionEnvironment: JavaSE-1.7 |
|
| 8 |
Require-Bundle: org.txm.rcp;bundle-version="0.8.0" |
|
| 0 | 9 | |
| tmp/org.txm.translate.rcp/.project (revision 1024) | ||
|---|---|---|
| 1 |
<?xml version="1.0" encoding="UTF-8"?> |
|
| 2 |
<projectDescription> |
|
| 3 |
<name>org.txm.translate.rcp</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.translate.rcp/src/org/txm/rcp/translate/ExportTranslateProject.java (revision 1024) | ||
|---|---|---|
| 1 |
package org.txm.rcp.translate; |
|
| 2 |
|
|
| 3 |
import java.lang.reflect.InvocationTargetException; |
|
| 4 |
import java.util.ArrayList; |
|
| 5 |
|
|
| 6 |
import org.eclipse.core.commands.ExecutionEvent; |
|
| 7 |
import org.eclipse.core.commands.ExecutionException; |
|
| 8 |
import org.eclipse.core.commands.IHandler; |
|
| 9 |
import org.eclipse.core.commands.IHandlerListener; |
|
| 10 |
import org.eclipse.core.resources.IFile; |
|
| 11 |
import org.eclipse.core.resources.IFolder; |
|
| 12 |
import org.eclipse.core.resources.IProject; |
|
| 13 |
import org.eclipse.core.resources.IResource; |
|
| 14 |
import org.eclipse.core.resources.IWorkspace; |
|
| 15 |
import org.eclipse.core.resources.ResourcesPlugin; |
|
| 16 |
import org.eclipse.core.runtime.CoreException; |
|
| 17 |
import org.eclipse.ui.internal.wizards.datatransfer.ArchiveFileExportOperation; |
|
| 18 |
import org.txm.Toolbox; |
|
| 19 |
import org.txm.rcp.handlers.BaseAbstractHandler; |
|
| 20 |
import org.txm.stat.utils.ConsoleProgressBar; |
|
| 21 |
|
|
| 22 |
public class ExportTranslateProject extends BaseAbstractHandler {
|
|
| 23 |
|
|
| 24 |
@Override |
|
| 25 |
public Object execute(ExecutionEvent event) throws ExecutionException {
|
|
| 26 |
IWorkspace workspace = ResourcesPlugin.getWorkspace(); |
|
| 27 |
IProject newProject = workspace.getRoot().getProject("translate");
|
|
| 28 |
if (!newProject.exists()) {
|
|
| 29 |
System.out.println("You must create the translate project before.");
|
|
| 30 |
return null; |
|
| 31 |
} |
|
| 32 |
|
|
| 33 |
if (!newProject.isOpen()) {
|
|
| 34 |
System.out.println("You must open the translate project before.");
|
|
| 35 |
return null; |
|
| 36 |
} |
|
| 37 |
|
|
| 38 |
String path = Toolbox.getTxmHomePath()+"/translate.zip"; |
|
| 39 |
ArrayList propertiesFiles = new ArrayList<>(); |
|
| 40 |
try {
|
|
| 41 |
findPropertiesFile(newProject.getFolder("plugins"), propertiesFiles);
|
|
| 42 |
} catch (CoreException e1) {
|
|
| 43 |
// TODO Auto-generated catch block |
|
| 44 |
e1.printStackTrace(); |
|
| 45 |
return null; |
|
| 46 |
} |
|
| 47 |
|
|
| 48 |
ArchiveFileExportOperation exporter = new ArchiveFileExportOperation(null, propertiesFiles, path); |
|
| 49 |
exporter.setUseCompression(true); |
|
| 50 |
exporter.setIncludeLinkedResources(true); |
|
| 51 |
ConsoleProgressBar cbp = new ConsoleProgressBar(100); |
|
| 52 |
try {
|
|
| 53 |
System.out.println("Exporting translation to "+path);
|
|
| 54 |
exporter.run(cbp); |
|
| 55 |
} catch (Exception e) {
|
|
| 56 |
// TODO Auto-generated catch block |
|
| 57 |
e.printStackTrace(); |
|
| 58 |
} |
|
| 59 |
cbp.done(); |
|
| 60 |
return null; |
|
| 61 |
} |
|
| 62 |
|
|
| 63 |
public static ArrayList findPropertiesFile(IResource r, ArrayList propertiesFiles) throws CoreException {
|
|
| 64 |
if (r instanceof IFolder) {
|
|
| 65 |
IFolder dir = (IFolder)r; |
|
| 66 |
|
|
| 67 |
for (IResource s : dir.members()) {
|
|
| 68 |
findPropertiesFile(s, propertiesFiles); |
|
| 69 |
} |
|
| 70 |
} else if (r instanceof IFile) {
|
|
| 71 |
IFile file = (IFile)r; |
|
| 72 |
String name = file.getName(); |
|
| 73 |
if (name.endsWith(".properties") && (name.startsWith("bundle") || name.startsWith("messages"))) {
|
|
| 74 |
propertiesFiles.add(r); |
|
| 75 |
} |
|
| 76 |
} |
|
| 77 |
return propertiesFiles; |
|
| 78 |
} |
|
| 79 |
} |
|
| 0 | 80 | |
| tmp/org.txm.translate.rcp/src/org/txm/rcp/translate/CreateTranslateProject.java (revision 1024) | ||
|---|---|---|
| 1 |
package org.txm.rcp.translate; |
|
| 2 |
|
|
| 3 |
import java.util.ArrayList; |
|
| 4 |
|
|
| 5 |
import org.eclipse.core.commands.ExecutionEvent; |
|
| 6 |
import org.eclipse.core.commands.ExecutionException; |
|
| 7 |
import org.eclipse.core.resources.IFile; |
|
| 8 |
import org.eclipse.core.resources.IFolder; |
|
| 9 |
import org.eclipse.core.resources.IProject; |
|
| 10 |
import org.eclipse.core.resources.IProjectDescription; |
|
| 11 |
import org.eclipse.core.resources.IResource; |
|
| 12 |
import org.eclipse.core.resources.IWorkspace; |
|
| 13 |
import org.eclipse.core.resources.ProjectScope; |
|
| 14 |
import org.eclipse.core.resources.ResourcesPlugin; |
|
| 15 |
import org.eclipse.core.runtime.CoreException; |
|
| 16 |
import org.eclipse.core.runtime.IAdaptable; |
|
| 17 |
import org.eclipse.core.runtime.IPath; |
|
| 18 |
import org.eclipse.core.runtime.Path; |
|
| 19 |
import org.eclipse.core.runtime.preferences.IScopeContext; |
|
| 20 |
import org.eclipse.jface.viewers.StructuredSelection; |
|
| 21 |
import org.eclipse.ui.IViewPart; |
|
| 22 |
import org.eclipse.ui.IWorkbenchPage; |
|
| 23 |
import org.eclipse.ui.PartInitException; |
|
| 24 |
import org.eclipse.ui.PlatformUI; |
|
| 25 |
import org.eclipse.ui.internal.WorkingSet; |
|
| 26 |
import org.eclipse.ui.views.framelist.FrameList; |
|
| 27 |
import org.eclipse.ui.views.framelist.GoIntoAction; |
|
| 28 |
import org.eclipse.ui.views.navigator.ResourceNavigator; |
|
| 29 |
import org.txm.Toolbox; |
|
| 30 |
import org.txm.core.preferences.TXMPreferences; |
|
| 31 |
import org.txm.rcp.handlers.BaseAbstractHandler; |
|
| 32 |
import org.txm.stat.utils.ConsoleProgressBar; |
|
| 33 |
import org.txm.utils.logger.Log; |
|
| 34 |
|
|
| 35 |
public class CreateTranslateProject extends BaseAbstractHandler {
|
|
| 36 |
|
|
| 37 |
@Override |
|
| 38 |
public Object execute(ExecutionEvent event) throws ExecutionException {
|
|
| 39 |
IWorkspace workspace = ResourcesPlugin.getWorkspace(); |
|
| 40 |
|
|
| 41 |
IProject newProject = workspace.getRoot().getProject("translate");
|
|
| 42 |
IScopeContext projectScope = new ProjectScope(newProject); |
|
| 43 |
|
|
| 44 |
// ensure the project exists |
|
| 45 |
if (!newProject.exists()) {
|
|
| 46 |
IProjectDescription desc = workspace.newProjectDescription(newProject.getName()); |
|
| 47 |
desc.setComment("TXT translate project");
|
|
| 48 |
try {
|
|
| 49 |
newProject.create(desc, null); |
|
| 50 |
|
|
| 51 |
if (!newProject.isOpen()) {
|
|
| 52 |
ConsoleProgressBar cpb = new ConsoleProgressBar(2); |
|
| 53 |
newProject.open(cpb); |
|
| 54 |
|
|
| 55 |
cpb.done(); |
|
| 56 |
|
|
| 57 |
// set global encoding preferences |
|
| 58 |
projectScope.getNode("org.eclipse.core.resources/encoding").put("<project>", "UTF-8");
|
|
| 59 |
projectScope.getNode("org.eclipse.core.resources").flush();
|
|
| 60 |
projectScope.getNode("org.eclipse.core.runtime").put("line.separator", "\n");
|
|
| 61 |
projectScope.getNode("org.eclipse.core.runtime").flush();
|
|
| 62 |
|
|
| 63 |
// link to TXM plugins files |
|
| 64 |
cpb = new ConsoleProgressBar(2); |
|
| 65 |
IFolder srcFolder = newProject.getFolder("plugins");
|
|
| 66 |
IPath path = new Path(Toolbox.getInstallDirectory()+"/plugins"); |
|
| 67 |
srcFolder.createLink(path, IResource.ALLOW_MISSING_LOCAL, cpb); |
|
| 68 |
|
|
| 69 |
// set the encoding bundle=iso-8859-1, messages=utf-8 |
|
| 70 |
ArrayList<IResource> propertiesFiles = new ArrayList<>(); |
|
| 71 |
ExportTranslateProject.findPropertiesFile(srcFolder, propertiesFiles); |
|
| 72 |
for (IResource e : propertiesFiles) {
|
|
| 73 |
IFile f = (IFile)e; |
|
| 74 |
if (f.getName().startsWith("messages")) {
|
|
| 75 |
projectScope.getNode("org.eclipse.core.resources/encoding").put(f.getProjectRelativePath().toString(), "UTF-8");
|
|
| 76 |
} |
|
| 77 |
projectScope.getNode("org.eclipse.core.resources/encoding").flush();
|
|
| 78 |
} |
|
| 79 |
|
|
| 80 |
//TXMPreferences.put("org.eclipse.ui.workbench", "resourcetypes", "<?xml version\\=\"1.0\" encoding\\=\"UTF-8\"?>\\n<editors version\\=\"3.1\">\\n<info extension\\=\"shtml\" name\\=\"*\">\\n<editor id\\=\"org.eclipse.ui.browser.editorSupport\"/>\\n</info>\\n<info extension\\=\"htm\" name\\=\"*\">\\n<editor id\\=\"org.eclipse.ui.browser.editorSupport\"/>\\n</info>\\n<info extension\\=\"html\" name\\=\"*\">\\n<editor id\\=\"org.eclipse.ui.browser.editorSupport\"/>\\n</info>\\n<info extension\\=\"properties\" name\\=\"*\">\\n<editor id\\=\"com.essiembre.eclipse.rbe.ui.editor.ResourceBundleEditor\"/>\\n<editor id\\=\"org.eclipse.ui.DefaultTextEditor\"/>\\n<defaultEditor id\\=\"com.essiembre.eclipse.rbe.ui.editor.ResourceBundleEditor\"/>\\n<defaultEditor id\\=\"org.eclipse.ui.DefaultTextEditor\"/>\\n</info>\\n</editors>");
|
|
| 81 |
//TXMPreferences.put("org.eclipse.ui.workbench", "editors", "");
|
|
| 82 |
TXMPreferences.flush("org.eclipse.ui.workbench");
|
|
| 83 |
cpb.done(); |
|
| 84 |
} |
|
| 85 |
|
|
| 86 |
} catch (Exception e) {
|
|
| 87 |
System.out.println("Fail to create translation project: "+e);
|
|
| 88 |
e.printStackTrace(); |
|
| 89 |
} |
|
| 90 |
} |
|
| 91 |
|
|
| 92 |
// project should exists now, we can show it |
|
| 93 |
IViewPart view = openView(); |
|
| 94 |
if (view != null) {
|
|
| 95 |
ResourceNavigator navigator = (ResourceNavigator)view; |
|
| 96 |
try {
|
|
| 97 |
IFolder plugins = newProject.getFolder("plugins");
|
|
| 98 |
|
|
| 99 |
//focus on plugins in the plugins directory (link) |
|
| 100 |
navigator.getTreeViewer().setSelection(new StructuredSelection(plugins)); |
|
| 101 |
FrameList fm = navigator.getFrameList(); |
|
| 102 |
GoIntoAction a = new GoIntoAction(fm); |
|
| 103 |
a.run(); |
|
| 104 |
|
|
| 105 |
// show only the properties files |
|
| 106 |
ArrayList<IResource> propertiesFiles = new ArrayList<>(); |
|
| 107 |
ExportTranslateProject.findPropertiesFile(plugins, propertiesFiles); |
|
| 108 |
IResource[] elements = propertiesFiles.toArray(new IResource[propertiesFiles.size()]); |
|
| 109 |
|
|
| 110 |
navigator.setWorkingSet(new WorkingSet("Translate TXM", "Translate TXM", elements));
|
|
| 111 |
} catch (Exception e) {
|
|
| 112 |
// TODO Auto-generated catch block |
|
| 113 |
e.printStackTrace(); |
|
| 114 |
} |
|
| 115 |
} |
|
| 116 |
|
|
| 117 |
return null; |
|
| 118 |
} |
|
| 119 |
|
|
| 120 |
public static final String NAVIGATOR_ID = "org.eclipse.ui.views.ResourceNavigator"; |
|
| 121 |
public static IViewPart openView() {
|
|
| 122 |
// open Element View if not opened |
|
| 123 |
try {
|
|
| 124 |
IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(); |
|
| 125 |
IViewPart view = page.findView(NAVIGATOR_ID); |
|
| 126 |
if (view == null) {
|
|
| 127 |
view = page.showView(NAVIGATOR_ID); |
|
| 128 |
} |
|
| 129 |
|
|
| 130 |
return view; |
|
| 131 |
} catch (PartInitException e1) {
|
|
| 132 |
System.out.println("Part initialisation error: "+e1.getLocalizedMessage());
|
|
| 133 |
Log.printStackTrace(e1); |
|
| 134 |
} |
|
| 135 |
return null; |
|
| 136 |
} |
|
| 137 |
} |
|
| 0 | 138 | |
| tmp/org.txm.translate.rcp/build.properties (revision 1024) | ||
|---|---|---|
| 1 |
source.. = src/ |
|
| 2 |
output.. = bin/ |
|
| 3 |
bin.includes = META-INF/,\ |
|
| 4 |
.,\ |
|
| 5 |
plugin.xml |
|
| 0 | 6 | |
| tmp/org.txm.translate.rcp/plugin.xml (revision 1024) | ||
|---|---|---|
| 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 |
allPopups="false" |
|
| 8 |
locationURI="menu:org.eclipse.ui.main.menu"> |
|
| 9 |
<menu |
|
| 10 |
id="menu.translate" |
|
| 11 |
label="Translate"> |
|
| 12 |
<command |
|
| 13 |
commandId="org.txm.rcp.translate.CreateTranslateProject" |
|
| 14 |
label="Start translating"> |
|
| 15 |
</command> |
|
| 16 |
<command |
|
| 17 |
commandId="org.txm.rcp.translate.ExportTranslateProject" |
|
| 18 |
label="Export translation"> |
|
| 19 |
</command> |
|
| 20 |
</menu> |
|
| 21 |
</menuContribution> |
|
| 22 |
</extension> |
|
| 23 |
<extension |
|
| 24 |
point="org.eclipse.ui.commands"> |
|
| 25 |
<command |
|
| 26 |
defaultHandler="org.txm.rcp.translate.CreateTranslateProject" |
|
| 27 |
id="org.txm.rcp.translate.CreateTranslateProject" |
|
| 28 |
name="CreateTranslateProject"> |
|
| 29 |
</command> |
|
| 30 |
<command |
|
| 31 |
defaultHandler="org.txm.rcp.translate.ExportTranslateProject" |
|
| 32 |
id="org.txm.rcp.translate.ExportTranslateProject" |
|
| 33 |
name="ExportTranslateProject"> |
|
| 34 |
</command> |
|
| 35 |
</extension> |
|
| 36 |
|
|
| 37 |
</plugin> |
|
| 0 | 38 | |
| tmp/org.txm.translate.rcp/.settings/org.eclipse.jdt.core.prefs (revision 1024) | ||
|---|---|---|
| 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/org.txm.translate.feature/build.properties (revision 1024) | ||
|---|---|---|
| 1 |
bin.includes = feature.xml |
|
| 0 | 2 | |
| tmp/org.txm.translate.feature/feature.xml (revision 1024) | ||
|---|---|---|
| 1 |
<?xml version="1.0" encoding="UTF-8"?> |
|
| 2 |
<feature |
|
| 3 |
id="org.txm.translate.feature" |
|
| 4 |
label="org.txm.translate.feature" |
|
| 5 |
version="1.0.0.qualifier" |
|
| 6 |
provider-name="Textometrie.org"> |
|
| 7 |
|
|
| 8 |
<description url="http://www.example.com/description"> |
|
| 9 |
[Enter Feature Description here.] |
|
| 10 |
</description> |
|
| 11 |
|
|
| 12 |
<copyright url="http://www.example.com/copyright"> |
|
| 13 |
[Enter Copyright Description here.] |
|
| 14 |
</copyright> |
|
| 15 |
|
|
| 16 |
<license url="http://www.example.com/license"> |
|
| 17 |
[Enter License Description here.] |
|
| 18 |
</license> |
|
| 19 |
|
|
| 20 |
<requires> |
|
| 21 |
<import plugin="org.eclipse.ui"/> |
|
| 22 |
<import plugin="org.eclipse.core.runtime"/> |
|
| 23 |
<import plugin="org.eclipse.core.resources"/> |
|
| 24 |
<import plugin="org.eclipse.jface.text"/> |
|
| 25 |
<import plugin="org.eclipse.ui.workbench.texteditor"/> |
|
| 26 |
<import plugin="org.eclipse.ui.editors"/> |
|
| 27 |
<import plugin="org.eclipse.ui.ide"/> |
|
| 28 |
<import plugin="org.eclipse.ui.views"/> |
|
| 29 |
</requires> |
|
| 30 |
|
|
| 31 |
<plugin |
|
| 32 |
id="com.essiembre.eclipse.rbe" |
|
| 33 |
download-size="0" |
|
| 34 |
install-size="0" |
|
| 35 |
version="0.0.0" |
|
| 36 |
unpack="false"/> |
|
| 37 |
|
|
| 38 |
</feature> |
|
| 0 | 39 | |
| tmp/org.txm.translate.feature/.project (revision 1024) | ||
|---|---|---|
| 1 |
<?xml version="1.0" encoding="UTF-8"?> |
|
| 2 |
<projectDescription> |
|
| 3 |
<name>org.txm.translate.feature</name> |
|
| 4 |
<comment></comment> |
|
| 5 |
<projects> |
|
| 6 |
</projects> |
|
| 7 |
<buildSpec> |
|
| 8 |
<buildCommand> |
|
| 9 |
<name>org.eclipse.pde.FeatureBuilder</name> |
|
| 10 |
<arguments> |
|
| 11 |
</arguments> |
|
| 12 |
</buildCommand> |
|
| 13 |
</buildSpec> |
|
| 14 |
<natures> |
|
| 15 |
<nature>org.eclipse.pde.FeatureNature</nature> |
|
| 16 |
</natures> |
|
| 17 |
</projectDescription> |
|
| 0 | 18 | |
Formats disponibles : Unified diff