author | Eugene Ostroukhov <eugeneo@symbian.org> |
Fri, 05 Feb 2010 09:17:58 -0800 | |
changeset 98 | b6d252d808df |
parent 55 | bb6160d0b6f2 |
child 104 | 58b323842de3 |
permissions | -rw-r--r-- |
55
bb6160d0b6f2
Added fallback to default browser if platform is Mac or XULRunner is not available
Eugene Ostroukhov <eostroukhov@gmail.com>
parents:
diff
changeset
|
1 |
package org.symbian.tools.wrttools.util; |
bb6160d0b6f2
Added fallback to default browser if platform is Mac or XULRunner is not available
Eugene Ostroukhov <eostroukhov@gmail.com>
parents:
diff
changeset
|
2 |
|
98
b6d252d808df
Nokia validation code is now integrated with WTP framework
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
55
diff
changeset
|
3 |
import java.text.MessageFormat; |
b6d252d808df
Nokia validation code is now integrated with WTP framework
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
55
diff
changeset
|
4 |
import java.util.regex.Matcher; |
b6d252d808df
Nokia validation code is now integrated with WTP framework
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
55
diff
changeset
|
5 |
import java.util.regex.Pattern; |
b6d252d808df
Nokia validation code is now integrated with WTP framework
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
55
diff
changeset
|
6 |
|
55
bb6160d0b6f2
Added fallback to default browser if platform is Mac or XULRunner is not available
Eugene Ostroukhov <eostroukhov@gmail.com>
parents:
diff
changeset
|
7 |
import org.eclipse.core.runtime.Platform; |
98
b6d252d808df
Nokia validation code is now integrated with WTP framework
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
55
diff
changeset
|
8 |
import org.eclipse.jface.text.IRegion; |
b6d252d808df
Nokia validation code is now integrated with WTP framework
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
55
diff
changeset
|
9 |
import org.eclipse.jface.text.Region; |
55
bb6160d0b6f2
Added fallback to default browser if platform is Mac or XULRunner is not available
Eugene Ostroukhov <eostroukhov@gmail.com>
parents:
diff
changeset
|
10 |
|
bb6160d0b6f2
Added fallback to default browser if platform is Mac or XULRunner is not available
Eugene Ostroukhov <eostroukhov@gmail.com>
parents:
diff
changeset
|
11 |
public class CoreUtil { |
98
b6d252d808df
Nokia validation code is now integrated with WTP framework
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
55
diff
changeset
|
12 |
public static final String PROPERTY_PATTERN = "<key>\\s*{0}\\s*</key>\\s*<string>\\s*(.*)\\s*</string>"; |
55
bb6160d0b6f2
Added fallback to default browser if platform is Mac or XULRunner is not available
Eugene Ostroukhov <eostroukhov@gmail.com>
parents:
diff
changeset
|
13 |
|
bb6160d0b6f2
Added fallback to default browser if platform is Mac or XULRunner is not available
Eugene Ostroukhov <eostroukhov@gmail.com>
parents:
diff
changeset
|
14 |
public static boolean isWindows() { |
bb6160d0b6f2
Added fallback to default browser if platform is Mac or XULRunner is not available
Eugene Ostroukhov <eostroukhov@gmail.com>
parents:
diff
changeset
|
15 |
return "windows".equals(Platform.getOS()); |
bb6160d0b6f2
Added fallback to default browser if platform is Mac or XULRunner is not available
Eugene Ostroukhov <eostroukhov@gmail.com>
parents:
diff
changeset
|
16 |
} |
bb6160d0b6f2
Added fallback to default browser if platform is Mac or XULRunner is not available
Eugene Ostroukhov <eostroukhov@gmail.com>
parents:
diff
changeset
|
17 |
|
bb6160d0b6f2
Added fallback to default browser if platform is Mac or XULRunner is not available
Eugene Ostroukhov <eostroukhov@gmail.com>
parents:
diff
changeset
|
18 |
public static boolean isMac() { |
bb6160d0b6f2
Added fallback to default browser if platform is Mac or XULRunner is not available
Eugene Ostroukhov <eostroukhov@gmail.com>
parents:
diff
changeset
|
19 |
return "macosx".equals(Platform.getOS()); |
bb6160d0b6f2
Added fallback to default browser if platform is Mac or XULRunner is not available
Eugene Ostroukhov <eostroukhov@gmail.com>
parents:
diff
changeset
|
20 |
} |
bb6160d0b6f2
Added fallback to default browser if platform is Mac or XULRunner is not available
Eugene Ostroukhov <eostroukhov@gmail.com>
parents:
diff
changeset
|
21 |
|
bb6160d0b6f2
Added fallback to default browser if platform is Mac or XULRunner is not available
Eugene Ostroukhov <eostroukhov@gmail.com>
parents:
diff
changeset
|
22 |
public static boolean isLinux() { |
bb6160d0b6f2
Added fallback to default browser if platform is Mac or XULRunner is not available
Eugene Ostroukhov <eostroukhov@gmail.com>
parents:
diff
changeset
|
23 |
return "linux".equals(Platform.getOS()); |
bb6160d0b6f2
Added fallback to default browser if platform is Mac or XULRunner is not available
Eugene Ostroukhov <eostroukhov@gmail.com>
parents:
diff
changeset
|
24 |
} |
98
b6d252d808df
Nokia validation code is now integrated with WTP framework
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
55
diff
changeset
|
25 |
|
b6d252d808df
Nokia validation code is now integrated with WTP framework
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
55
diff
changeset
|
26 |
public static String getIndexFileName(String buffer) { |
b6d252d808df
Nokia validation code is now integrated with WTP framework
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
55
diff
changeset
|
27 |
if (buffer != null) { |
b6d252d808df
Nokia validation code is now integrated with WTP framework
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
55
diff
changeset
|
28 |
Matcher matcher = getPropertyLookupPattern("MainHTML").matcher(buffer); |
b6d252d808df
Nokia validation code is now integrated with WTP framework
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
55
diff
changeset
|
29 |
if (matcher.find()) { |
b6d252d808df
Nokia validation code is now integrated with WTP framework
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
55
diff
changeset
|
30 |
return matcher.group(1); |
b6d252d808df
Nokia validation code is now integrated with WTP framework
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
55
diff
changeset
|
31 |
} |
b6d252d808df
Nokia validation code is now integrated with WTP framework
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
55
diff
changeset
|
32 |
} |
b6d252d808df
Nokia validation code is now integrated with WTP framework
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
55
diff
changeset
|
33 |
return null; |
b6d252d808df
Nokia validation code is now integrated with WTP framework
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
55
diff
changeset
|
34 |
} |
b6d252d808df
Nokia validation code is now integrated with WTP framework
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
55
diff
changeset
|
35 |
|
b6d252d808df
Nokia validation code is now integrated with WTP framework
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
55
diff
changeset
|
36 |
public static Pattern getPropertyLookupPattern(String propertyName) { |
b6d252d808df
Nokia validation code is now integrated with WTP framework
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
55
diff
changeset
|
37 |
return Pattern.compile(MessageFormat.format(PROPERTY_PATTERN, propertyName), Pattern.CASE_INSENSITIVE); |
b6d252d808df
Nokia validation code is now integrated with WTP framework
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
55
diff
changeset
|
38 |
} |
b6d252d808df
Nokia validation code is now integrated with WTP framework
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
55
diff
changeset
|
39 |
|
b6d252d808df
Nokia validation code is now integrated with WTP framework
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
55
diff
changeset
|
40 |
public static IRegion getIndexFileNameRegion(String string) { |
b6d252d808df
Nokia validation code is now integrated with WTP framework
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
55
diff
changeset
|
41 |
Matcher matcher = getPropertyLookupPattern("MainHTML").matcher(string); |
b6d252d808df
Nokia validation code is now integrated with WTP framework
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
55
diff
changeset
|
42 |
if (matcher.find()) { |
b6d252d808df
Nokia validation code is now integrated with WTP framework
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
55
diff
changeset
|
43 |
int start = matcher.start(1); |
b6d252d808df
Nokia validation code is now integrated with WTP framework
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
55
diff
changeset
|
44 |
return new Region(start, matcher.end(1) - start); |
b6d252d808df
Nokia validation code is now integrated with WTP framework
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
55
diff
changeset
|
45 |
} |
b6d252d808df
Nokia validation code is now integrated with WTP framework
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
55
diff
changeset
|
46 |
return null; |
b6d252d808df
Nokia validation code is now integrated with WTP framework
Eugene Ostroukhov <eugeneo@symbian.org>
parents:
55
diff
changeset
|
47 |
} |
55
bb6160d0b6f2
Added fallback to default browser if platform is Mac or XULRunner is not available
Eugene Ostroukhov <eostroukhov@gmail.com>
parents:
diff
changeset
|
48 |
} |