Révision 1537
| tmp/org.txm.rcp/src/main/java/org/txm/rcp/Application.java (revision 1537) | ||
|---|---|---|
| 27 | 27 |
// |
| 28 | 28 |
package org.txm.rcp; |
| 29 | 29 |
|
| 30 |
import java.io.File; |
|
| 30 | 31 |
import java.util.Arrays; |
| 31 | 32 |
import java.util.List; |
| 32 | 33 |
import java.util.Map; |
| ... | ... | |
| 69 | 70 |
*/ |
| 70 | 71 |
@Override |
| 71 | 72 |
public Object start(IApplicationContext context) throws Exception {
|
| 73 |
|
|
| 74 |
// load JVM fonts in SWT env |
|
| 75 |
if (System.getProperty("os.name").contains("Linux")) { // $NON-NLS-1$ $NON-NLS-2$
|
|
| 76 |
File javaFontsPath = new File(System.getProperty("java.home")
|
|
| 77 |
+ System.getProperty("file.separator") + "lib"
|
|
| 78 |
+ System.getProperty("file.separator") + "fonts"
|
|
| 79 |
+ System.getProperty("file.separator"));
|
|
| 80 |
|
|
| 81 |
String[] fontFiles = javaFontsPath.list(); |
|
| 82 |
for (int i = 0; i < fontFiles.length; i++) {
|
|
| 83 |
if(fontFiles[i].endsWith(".ttf")) { //$NON-NLS-1$
|
|
| 84 |
File fontFile = new File(javaFontsPath, fontFiles[i]); |
|
| 85 |
Log.finest("Loading Java font to SWT Device from file " + fontFile + "...");
|
|
| 86 |
// Load the font in SWT |
|
| 87 |
Display.getDefault().loadFont(fontFile.getAbsolutePath()); |
|
| 88 |
} |
|
| 89 |
} |
|
| 90 |
} |
|
| 91 |
|
|
| 72 | 92 |
Map args = context.getArguments(); |
| 73 | 93 |
|
| 74 | 94 |
List<String> argsList = Arrays.asList((String[])(args.get("application.args"))); //$NON-NLS-1$
|
| 75 |
|
|
| 95 |
|
|
| 76 | 96 |
System.out.println(TXMCoreMessages.bind(TXMUIMessages.argsColon, argsList)); |
| 77 |
|
|
| 97 |
|
|
| 78 | 98 |
if (argsList.contains("-log")) { //$NON-NLS-1$
|
| 79 | 99 |
System.out.println(TXMUIMessages.logOptionDetected); |
| 80 | 100 |
Log.setPrintInConsole(true); |
| ... | ... | |
| 87 | 107 |
if (argsList.contains("-run")) { //$NON-NLS-1$
|
| 88 | 108 |
//System.out.println("Running TXM");
|
| 89 | 109 |
// FIXME: need to check that all has been well moved in Workspace class or build.properties |
| 90 |
// } else if (argsList.contains("-standalone")) { //$NON-NLS-1$
|
|
| 91 |
// File userhomeDirectory = new File("workspace").getAbsoluteFile(); // eclipse default workspace directory
|
|
| 92 |
// File defaultWorkspaceFile = new File("workspace/corpora/default.xml");
|
|
| 93 |
// if (!defaultWorkspaceFile.exists()) {
|
|
| 94 |
// System.out.println("Stand alone launch, creating minimal TXM user home directory in "+userhomeDirectory.getAbsolutePath());
|
|
| 95 |
// System.out.println("Sample corpora, scripts, import scripts and macros files are not yet installed.");
|
|
| 96 |
// |
|
| 97 |
// TBXPreferences.getInstance().put(TBXPreferences.USER_TXM_HOME, userhomeDirectory.getAbsolutePath()); |
|
| 98 |
// TBXPreferences.getInstance().put(TBXPreferences.INSTALL_DIR, userhomeDirectory.getParentFile().getAbsolutePath()); |
|
| 99 |
// |
|
| 100 |
// File corpusworkspaceDirectory = new File(userhomeDirectory, "workspaces"); |
|
| 101 |
// corpusworkspaceDirectory.mkdirs(); |
|
| 102 |
// |
|
| 103 |
// String createfolders[] = {
|
|
| 104 |
// "corpora", "clipboard", //$NON-NLS-1$ //$NON-NLS-2$ |
|
| 105 |
// "workspaces", "css", "scripts", "scripts/lib", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ |
|
| 106 |
// "scripts/macro", "scripts/user", "xsl", "samples", "schema", "R"}; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ |
|
| 107 |
// |
|
| 108 |
// for (String folder : createfolders) {
|
|
| 109 |
// new File(userhomeDirectory, folder).mkdir(); |
|
| 110 |
// } |
|
| 111 |
// |
|
| 112 |
// Workspace.createEmptyWorkspaceDefinition(new File(corpusworkspaceDirectory, "default.xml")); //$NON-NLS-1$ |
|
| 113 |
// BundleUtils.copyFiles("org.txm.core", "res", "org/txm", "css", new File(userhomeDirectory, "css"));
|
|
| 114 |
// BundleUtils.copyFiles("org.txm.core", "res", "org/txm/xml", "xsl", new File(userhomeDirectory, "xsl"));
|
|
| 115 |
// BundleUtils.copyFiles("org.txm.core", "res", "org/txm/xml", "schema", new File(userhomeDirectory, "schema"));
|
|
| 116 |
// File scriptsDirectory = new File(userhomeDirectory, "scripts"); |
|
| 117 |
// new File(scriptsDirectory, "user").mkdir(); |
|
| 118 |
// new File(scriptsDirectory, "import").mkdir(); |
|
| 119 |
// new File(scriptsDirectory, "lib").mkdir(); |
|
| 120 |
// new File(scriptsDirectory, "macro").mkdir(); |
|
| 121 |
// new File(scriptsDirectory, "samples").mkdir(); |
|
| 122 |
// } |
|
| 110 |
// } else if (argsList.contains("-standalone")) { //$NON-NLS-1$
|
|
| 111 |
// File userhomeDirectory = new File("workspace").getAbsoluteFile(); // eclipse default workspace directory
|
|
| 112 |
// File defaultWorkspaceFile = new File("workspace/corpora/default.xml");
|
|
| 113 |
// if (!defaultWorkspaceFile.exists()) {
|
|
| 114 |
// System.out.println("Stand alone launch, creating minimal TXM user home directory in "+userhomeDirectory.getAbsolutePath());
|
|
| 115 |
// System.out.println("Sample corpora, scripts, import scripts and macros files are not yet installed.");
|
|
| 116 |
//
|
|
| 117 |
// TBXPreferences.getInstance().put(TBXPreferences.USER_TXM_HOME, userhomeDirectory.getAbsolutePath());
|
|
| 118 |
// TBXPreferences.getInstance().put(TBXPreferences.INSTALL_DIR, userhomeDirectory.getParentFile().getAbsolutePath());
|
|
| 119 |
//
|
|
| 120 |
// File corpusworkspaceDirectory = new File(userhomeDirectory, "workspaces");
|
|
| 121 |
// corpusworkspaceDirectory.mkdirs();
|
|
| 122 |
//
|
|
| 123 |
// String createfolders[] = {
|
|
| 124 |
// "corpora", "clipboard", //$NON-NLS-1$ //$NON-NLS-2$
|
|
| 125 |
// "workspaces", "css", "scripts", "scripts/lib", //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
|
|
| 126 |
// "scripts/macro", "scripts/user", "xsl", "samples", "schema", "R"}; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
|
|
| 127 |
//
|
|
| 128 |
// for (String folder : createfolders) {
|
|
| 129 |
// new File(userhomeDirectory, folder).mkdir();
|
|
| 130 |
// }
|
|
| 131 |
//
|
|
| 132 |
// Workspace.createEmptyWorkspaceDefinition(new File(corpusworkspaceDirectory, "default.xml")); //$NON-NLS-1$
|
|
| 133 |
// BundleUtils.copyFiles("org.txm.core", "res", "org/txm", "css", new File(userhomeDirectory, "css"));
|
|
| 134 |
// BundleUtils.copyFiles("org.txm.core", "res", "org/txm/xml", "xsl", new File(userhomeDirectory, "xsl"));
|
|
| 135 |
// BundleUtils.copyFiles("org.txm.core", "res", "org/txm/xml", "schema", new File(userhomeDirectory, "schema"));
|
|
| 136 |
// File scriptsDirectory = new File(userhomeDirectory, "scripts");
|
|
| 137 |
// new File(scriptsDirectory, "user").mkdir();
|
|
| 138 |
// new File(scriptsDirectory, "import").mkdir();
|
|
| 139 |
// new File(scriptsDirectory, "lib").mkdir();
|
|
| 140 |
// new File(scriptsDirectory, "macro").mkdir();
|
|
| 141 |
// new File(scriptsDirectory, "samples").mkdir();
|
|
| 142 |
// }
|
|
| 123 | 143 |
} else {
|
| 124 | 144 |
System.err.println("TXM must be launch with the argument '-run' to start."); //$NON-NLS-1$
|
| 125 | 145 |
System.err.println(TXMUIMessages.thisFileIsNotMeantToRunTXMPleaseConsultTXMUserManual); |
| ... | ... | |
| 233 | 253 |
} |
| 234 | 254 |
} |
| 235 | 255 |
|
| 236 |
// /** |
|
| 237 |
// * Parses the command line. |
|
| 238 |
// * |
|
| 239 |
// * @return true, if successful |
|
| 240 |
// * @deprecated, parse the command line the list optionsForPreferences must |
|
| 241 |
// * be edited too add options |
|
| 242 |
// */ |
|
| 243 |
// private boolean parseCommandLine() {
|
|
| 244 |
// boolean exit = false; |
|
| 245 |
// String[] optionsForPreferences = {
|
|
| 246 |
// CQPLibPreferences.CQI_SERVER_PATH_TO_EXECUTABLE, |
|
| 247 |
// CQPLibPreferences.CQI_SERVER_PATH_TO_INIT_FILE, |
|
| 248 |
// // TBXPreferences.CQI_SERVER_PATH_TO_REGISTRY, |
|
| 249 |
// RPreferences.PATH_TO_EXECUTABLE, |
|
| 250 |
// TBXPreferences.INSTALL_DIR }; |
|
| 251 |
// String setPrefAndExit = "setPrefAndExit"; //$NON-NLS-1$ |
|
| 252 |
// |
|
| 253 |
// Options options = new Options(); |
|
| 254 |
// options.addOption(OptionBuilder.create("product")); //option passed here when run as an eclipse application. Recognized to prevent a UnrecognizedOptionException //$NON-NLS-1$
|
|
| 255 |
// options.addOption(OptionBuilder.create(setPrefAndExit)); |
|
| 256 |
// for (String preference : optionsForPreferences) |
|
| 257 |
// options.addOption(OptionBuilder.withValueSeparator().hasArgs() |
|
| 258 |
// .create(preference)); |
|
| 259 |
// |
|
| 260 |
// Parser parser = new GnuParser(); |
|
| 261 |
// CommandLine cl; |
|
| 262 |
// try {
|
|
| 263 |
// cl = parser.parse(options, Platform.getCommandLineArgs()); |
|
| 264 |
// } catch (ParseException e) {
|
|
| 265 |
// |
|
| 266 |
// System.err.println(NLS.bind(TXMUIMessages.FAILED_TO_PARSE_OPTIONS, |
|
| 267 |
// StringUtils.join(Platform.getCommandLineArgs(), " "), e)); //$NON-NLS-1$ |
|
| 268 |
// org.txm.rcp.utils.Logger.printStackTrace(e); |
|
| 269 |
// exit = true; |
|
| 270 |
// return exit; |
|
| 271 |
// } |
|
| 272 |
// |
|
| 273 |
// ScopedPreferenceStore preferences = new ScopedPreferenceStore( |
|
| 274 |
// org.eclipse.core.runtime.preferences.InstanceScope.INSTANCE, Application.PLUGIN_ID); |
|
| 275 |
// for (String preference : optionsForPreferences) |
|
| 276 |
// if (cl.hasOption(preference)) {
|
|
| 277 |
// preferences.setValue(preference, cl.getOptionValue(preference)); |
|
| 278 |
// } |
|
| 279 |
// |
|
| 280 |
// try {
|
|
| 281 |
// preferences.save(); |
|
| 282 |
// } catch (IOException e) {
|
|
| 283 |
// System.err.println(NLS.bind(TXMUIMessages.failedToSavePreferencesColonP0, e)); |
|
| 284 |
// exit = true; |
|
| 285 |
// return exit; |
|
| 286 |
// } |
|
| 287 |
// |
|
| 288 |
// if (cl.hasOption(setPrefAndExit)) |
|
| 289 |
// exit = true; |
|
| 290 |
// return exit; |
|
| 291 |
// } |
|
| 256 |
// /**
|
|
| 257 |
// * Parses the command line.
|
|
| 258 |
// *
|
|
| 259 |
// * @return true, if successful
|
|
| 260 |
// * @deprecated, parse the command line the list optionsForPreferences must
|
|
| 261 |
// * be edited too add options
|
|
| 262 |
// */
|
|
| 263 |
// private boolean parseCommandLine() {
|
|
| 264 |
// boolean exit = false;
|
|
| 265 |
// String[] optionsForPreferences = {
|
|
| 266 |
// CQPLibPreferences.CQI_SERVER_PATH_TO_EXECUTABLE,
|
|
| 267 |
// CQPLibPreferences.CQI_SERVER_PATH_TO_INIT_FILE,
|
|
| 268 |
// // TBXPreferences.CQI_SERVER_PATH_TO_REGISTRY,
|
|
| 269 |
// RPreferences.PATH_TO_EXECUTABLE,
|
|
| 270 |
// TBXPreferences.INSTALL_DIR };
|
|
| 271 |
// String setPrefAndExit = "setPrefAndExit"; //$NON-NLS-1$
|
|
| 272 |
//
|
|
| 273 |
// Options options = new Options();
|
|
| 274 |
// options.addOption(OptionBuilder.create("product")); //option passed here when run as an eclipse application. Recognized to prevent a UnrecognizedOptionException //$NON-NLS-1$
|
|
| 275 |
// options.addOption(OptionBuilder.create(setPrefAndExit));
|
|
| 276 |
// for (String preference : optionsForPreferences)
|
|
| 277 |
// options.addOption(OptionBuilder.withValueSeparator().hasArgs()
|
|
| 278 |
// .create(preference));
|
|
| 279 |
//
|
|
| 280 |
// Parser parser = new GnuParser();
|
|
| 281 |
// CommandLine cl;
|
|
| 282 |
// try {
|
|
| 283 |
// cl = parser.parse(options, Platform.getCommandLineArgs());
|
|
| 284 |
// } catch (ParseException e) {
|
|
| 285 |
//
|
|
| 286 |
// System.err.println(NLS.bind(TXMUIMessages.FAILED_TO_PARSE_OPTIONS,
|
|
| 287 |
// StringUtils.join(Platform.getCommandLineArgs(), " "), e)); //$NON-NLS-1$
|
|
| 288 |
// org.txm.rcp.utils.Logger.printStackTrace(e);
|
|
| 289 |
// exit = true;
|
|
| 290 |
// return exit;
|
|
| 291 |
// }
|
|
| 292 |
//
|
|
| 293 |
// ScopedPreferenceStore preferences = new ScopedPreferenceStore(
|
|
| 294 |
// org.eclipse.core.runtime.preferences.InstanceScope.INSTANCE, Application.PLUGIN_ID);
|
|
| 295 |
// for (String preference : optionsForPreferences)
|
|
| 296 |
// if (cl.hasOption(preference)) {
|
|
| 297 |
// preferences.setValue(preference, cl.getOptionValue(preference));
|
|
| 298 |
// }
|
|
| 299 |
//
|
|
| 300 |
// try {
|
|
| 301 |
// preferences.save();
|
|
| 302 |
// } catch (IOException e) {
|
|
| 303 |
// System.err.println(NLS.bind(TXMUIMessages.failedToSavePreferencesColonP0, e));
|
|
| 304 |
// exit = true;
|
|
| 305 |
// return exit;
|
|
| 306 |
// }
|
|
| 307 |
//
|
|
| 308 |
// if (cl.hasOption(setPrefAndExit))
|
|
| 309 |
// exit = true;
|
|
| 310 |
// return exit;
|
|
| 311 |
// }
|
|
| 292 | 312 |
} |
Formats disponibles : Unified diff