# HG changeset patch # User tasneems@symbian.org # Date 1265059574 28800 # Node ID fb430f25c33dda24a225d867fdf3f4fc0355ed8b # Parent 12372c19f1b0b57868e0e4a82ba3ebccb245c6a3# Parent 6bec0231e8d2d4175e4661e55b58fb6c50a8fb9b Added WRTKit. Merged. diff -r 12372c19f1b0 -r fb430f25c33d Chrome-Java5-Patch.txt --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Chrome-Java5-Patch.txt Mon Feb 01 13:26:14 2010 -0800 @@ -0,0 +1,181 @@ +### Eclipse Workspace Patch 1.0 +#P org.chromium.sdk +Index: src/org/chromium/sdk/ChromiumIOException.java +=================================================================== +--- src/org/chromium/sdk/ChromiumIOException.java (revision 0) ++++ src/org/chromium/sdk/ChromiumIOException.java (revision 0) +@@ -0,0 +1,23 @@ ++package org.chromium.sdk; ++ ++import java.io.IOException; ++ ++public class ChromiumIOException extends IOException { ++ private static final long serialVersionUID = 3412049732071131594L; ++ private final Throwable cause; ++ ++ public ChromiumIOException(Throwable cause) { ++ super(); ++ this.cause = cause; ++ } ++ ++ public ChromiumIOException(String message, Throwable cause) { ++ super(message); ++ this.cause = cause; ++ } ++ ++ @Override ++ public Throwable getCause() { ++ return cause; ++ } ++} +Index: src/org/chromium/sdk/internal/BrowserImpl.java +=================================================================== +--- src/org/chromium/sdk/internal/BrowserImpl.java (revision 306) ++++ src/org/chromium/sdk/internal/BrowserImpl.java (working copy) +@@ -17,6 +17,7 @@ + + import org.chromium.sdk.Browser; + import org.chromium.sdk.BrowserTab; ++import org.chromium.sdk.ChromiumIOException; + import org.chromium.sdk.TabDebugEventListener; + import org.chromium.sdk.UnsupportedVersionException; + import org.chromium.sdk.Version; +@@ -102,7 +103,7 @@ + try { + serverVersionString = devToolsHandler.version(OPERATION_TIMEOUT_MS); + } catch (TimeoutException e) { +- throw new IOException("Failed to get protocol version from remote", e); ++ throw new ChromiumIOException("Failed to get protocol version from remote", e); + } + if (serverVersionString == null) { + throw new UnsupportedVersionException(BrowserImpl.PROTOCOL_VERSION, null); +@@ -291,7 +292,7 @@ + ticket = connectInternal(); + } catch (UnsupportedVersionException e) { + // This exception should have happened on tab fetcher creation. +- throw new IOException("Unexpected version problem", e); ++ throw new ChromiumIOException("Unexpected version problem", e); + } + + Session session = ticket.getSession(); +Index: META-INF/MANIFEST.MF +=================================================================== +--- META-INF/MANIFEST.MF (revision 306) ++++ META-INF/MANIFEST.MF (working copy) +@@ -13,4 +13,5 @@ + org.chromium.sdk.internal.tools.v8.processor;x-internal:=true, + org.chromium.sdk.internal.tools.v8.request;x-internal:=true, + org.chromium.sdk.internal.transport;x-internal:=true +-Bundle-RequiredExecutionEnvironment: JavaSE-1.6 ++Bundle-RequiredExecutionEnvironment: J2SE-1.5, ++ JavaSE-1.6 +Index: src/org/chromium/sdk/internal/BrowserTabImpl.java +=================================================================== +--- src/org/chromium/sdk/internal/BrowserTabImpl.java (revision 306) ++++ src/org/chromium/sdk/internal/BrowserTabImpl.java (working copy) +@@ -8,6 +8,7 @@ + + import org.chromium.sdk.Browser; + import org.chromium.sdk.BrowserTab; ++import org.chromium.sdk.ChromiumIOException; + import org.chromium.sdk.DebugEventListener; + import org.chromium.sdk.TabDebugEventListener; + import org.chromium.sdk.internal.tools.ToolHandler; +@@ -89,7 +90,7 @@ + try { + result = devToolSessionManager.attachToTab(); + } catch (AttachmentFailureException e) { +- throw new IOException(e); ++ throw new ChromiumIOException(e); + } + if (Result.OK != result) { + throw new IOException("Failed to attach with result: " + result); +Index: src/org/chromium/sdk/internal/StandaloneVmImpl.java +=================================================================== +--- src/org/chromium/sdk/internal/StandaloneVmImpl.java (revision 306) ++++ src/org/chromium/sdk/internal/StandaloneVmImpl.java (working copy) +@@ -12,6 +12,7 @@ + import java.util.logging.Level; + import java.util.logging.Logger; + ++import org.chromium.sdk.ChromiumIOException; + import org.chromium.sdk.DebugEventListener; + import org.chromium.sdk.StandaloneVm; + import org.chromium.sdk.UnsupportedVersionException; +@@ -121,9 +122,9 @@ + } catch (InterruptedException e) { + throw new RuntimeException(e); + } catch (ExecutionException e) { +- throw new IOException("Failed to get version", e); ++ throw new ChromiumIOException("Failed to get version", e); + } catch (TimeoutException e) { +- throw new IOException("Timed out waiting for version", e); ++ throw new ChromiumIOException("Timed out waiting for version", e); + } + + String versionString = remoteInfo.getProtocolVersion(); +Index: src/org/chromium/sdk/internal/transport/Handshaker.java +=================================================================== +--- src/org/chromium/sdk/internal/transport/Handshaker.java (revision 306) ++++ src/org/chromium/sdk/internal/transport/Handshaker.java (working copy) +@@ -10,8 +10,8 @@ + import java.util.concurrent.ExecutionException; + import java.util.concurrent.Future; + import java.util.concurrent.FutureTask; +-import java.util.concurrent.RunnableFuture; + ++import org.chromium.sdk.ChromiumIOException; + import org.chromium.sdk.LineReader; + import org.chromium.sdk.internal.transport.Message.MalformedMessageException; + +@@ -85,7 +85,7 @@ + return runnableFuture; + } + +- private final RunnableFuture runnableFuture = ++ private final FutureTask runnableFuture = + new FutureTask(new HandshakeTaks()); + + private LineReader input = null; +@@ -100,7 +100,7 @@ + } catch (InterruptedException e) { + throw new RuntimeException(e); + } catch (ExecutionException e) { +- throw new IOException("Failed to perform handshake", e); ++ throw new ChromiumIOException("Failed to perform handshake", e); + } + + } +@@ -111,7 +111,7 @@ + try { + message = Message.fromBufferedReader(input); + } catch (MalformedMessageException e) { +- throw new IOException("Unrecognized handshake message from remote", e); ++ throw new ChromiumIOException("Unrecognized handshake message from remote", e); + } + if (message == null) { + throw new IOException("End of stream"); +#P org.chromium.debug.core +Index: META-INF/MANIFEST.MF +=================================================================== +--- META-INF/MANIFEST.MF (revision 306) ++++ META-INF/MANIFEST.MF (working copy) +@@ -20,4 +20,5 @@ + org.chromium.debug.core.model, + org.chromium.debug.core.util + Eclipse-LazyStart: true +-Bundle-RequiredExecutionEnvironment: JavaSE-1.6 ++Bundle-RequiredExecutionEnvironment: J2SE-1.5, ++ JavaSE-1.6 +#P org.chromium.debug.ui +Index: META-INF/MANIFEST.MF +=================================================================== +--- META-INF/MANIFEST.MF (revision 306) ++++ META-INF/MANIFEST.MF (working copy) +@@ -16,4 +16,5 @@ + org.chromium.debug.core;bundle-version="0.1.5", + org.chromium.sdk;bundle-version="0.1.5" + Bundle-ActivationPolicy: lazy +-Bundle-RequiredExecutionEnvironment: JavaSE-1.6 ++Bundle-RequiredExecutionEnvironment: J2SE-1.5, ++ JavaSE-1.6 diff -r 12372c19f1b0 -r fb430f25c33d org.chromium.debug.core/META-INF/MANIFEST.MF --- a/org.chromium.debug.core/META-INF/MANIFEST.MF Mon Feb 01 13:24:54 2010 -0800 +++ b/org.chromium.debug.core/META-INF/MANIFEST.MF Mon Feb 01 13:26:14 2010 -0800 @@ -20,4 +20,5 @@ org.chromium.debug.core.model, org.chromium.debug.core.util Eclipse-LazyStart: true -Bundle-RequiredExecutionEnvironment: JavaSE-1.6 +Bundle-RequiredExecutionEnvironment: J2SE-1.5, + JavaSE-1.6 diff -r 12372c19f1b0 -r fb430f25c33d org.chromium.debug.ui/META-INF/MANIFEST.MF --- a/org.chromium.debug.ui/META-INF/MANIFEST.MF Mon Feb 01 13:24:54 2010 -0800 +++ b/org.chromium.debug.ui/META-INF/MANIFEST.MF Mon Feb 01 13:26:14 2010 -0800 @@ -16,4 +16,5 @@ org.chromium.debug.core;bundle-version="0.1.5", org.chromium.sdk;bundle-version="0.1.5" Bundle-ActivationPolicy: lazy -Bundle-RequiredExecutionEnvironment: JavaSE-1.6 +Bundle-RequiredExecutionEnvironment: J2SE-1.5, + JavaSE-1.6 diff -r 12372c19f1b0 -r fb430f25c33d org.chromium.sdk/META-INF/MANIFEST.MF --- a/org.chromium.sdk/META-INF/MANIFEST.MF Mon Feb 01 13:24:54 2010 -0800 +++ b/org.chromium.sdk/META-INF/MANIFEST.MF Mon Feb 01 13:26:14 2010 -0800 @@ -13,4 +13,5 @@ org.chromium.sdk.internal.tools.v8.processor;x-internal:=true, org.chromium.sdk.internal.tools.v8.request;x-internal:=true, org.chromium.sdk.internal.transport;x-internal:=true -Bundle-RequiredExecutionEnvironment: JavaSE-1.6 +Bundle-RequiredExecutionEnvironment: J2SE-1.5, + JavaSE-1.6 diff -r 12372c19f1b0 -r fb430f25c33d org.chromium.sdk/src/org/chromium/sdk/ChromiumIOException.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/org.chromium.sdk/src/org/chromium/sdk/ChromiumIOException.java Mon Feb 01 13:26:14 2010 -0800 @@ -0,0 +1,23 @@ +package org.chromium.sdk; + +import java.io.IOException; + +public class ChromiumIOException extends IOException { + private static final long serialVersionUID = 1L; + + private final Throwable cause; + + public ChromiumIOException(Throwable cause) { + this.cause = cause; + } + + public ChromiumIOException(String message, Throwable cause) { + super(message); + this.cause = cause; + } + + @Override + public Throwable getCause() { + return cause; + } +} diff -r 12372c19f1b0 -r fb430f25c33d org.chromium.sdk/src/org/chromium/sdk/internal/BrowserImpl.java --- a/org.chromium.sdk/src/org/chromium/sdk/internal/BrowserImpl.java Mon Feb 01 13:24:54 2010 -0800 +++ b/org.chromium.sdk/src/org/chromium/sdk/internal/BrowserImpl.java Mon Feb 01 13:26:14 2010 -0800 @@ -17,6 +17,7 @@ import org.chromium.sdk.Browser; import org.chromium.sdk.BrowserTab; +import org.chromium.sdk.ChromiumIOException; import org.chromium.sdk.TabDebugEventListener; import org.chromium.sdk.UnsupportedVersionException; import org.chromium.sdk.Version; @@ -102,7 +103,7 @@ try { serverVersionString = devToolsHandler.version(OPERATION_TIMEOUT_MS); } catch (TimeoutException e) { - throw new IOException("Failed to get protocol version from remote", e); + throw new ChromiumIOException("Failed to get protocol version from remote", e); } if (serverVersionString == null) { throw new UnsupportedVersionException(BrowserImpl.PROTOCOL_VERSION, null); @@ -291,7 +292,7 @@ ticket = connectInternal(); } catch (UnsupportedVersionException e) { // This exception should have happened on tab fetcher creation. - throw new IOException("Unexpected version problem", e); + throw new ChromiumIOException("Unexpected version problem", e); } Session session = ticket.getSession(); diff -r 12372c19f1b0 -r fb430f25c33d org.chromium.sdk/src/org/chromium/sdk/internal/BrowserTabImpl.java --- a/org.chromium.sdk/src/org/chromium/sdk/internal/BrowserTabImpl.java Mon Feb 01 13:24:54 2010 -0800 +++ b/org.chromium.sdk/src/org/chromium/sdk/internal/BrowserTabImpl.java Mon Feb 01 13:26:14 2010 -0800 @@ -8,6 +8,7 @@ import org.chromium.sdk.Browser; import org.chromium.sdk.BrowserTab; +import org.chromium.sdk.ChromiumIOException; import org.chromium.sdk.DebugEventListener; import org.chromium.sdk.TabDebugEventListener; import org.chromium.sdk.internal.tools.ToolHandler; @@ -89,7 +90,7 @@ try { result = devToolSessionManager.attachToTab(); } catch (AttachmentFailureException e) { - throw new IOException(e); + throw new ChromiumIOException(e); } if (Result.OK != result) { throw new IOException("Failed to attach with result: " + result); diff -r 12372c19f1b0 -r fb430f25c33d org.chromium.sdk/src/org/chromium/sdk/internal/StandaloneVmImpl.java --- a/org.chromium.sdk/src/org/chromium/sdk/internal/StandaloneVmImpl.java Mon Feb 01 13:24:54 2010 -0800 +++ b/org.chromium.sdk/src/org/chromium/sdk/internal/StandaloneVmImpl.java Mon Feb 01 13:26:14 2010 -0800 @@ -12,6 +12,7 @@ import java.util.logging.Level; import java.util.logging.Logger; +import org.chromium.sdk.ChromiumIOException; import org.chromium.sdk.DebugEventListener; import org.chromium.sdk.StandaloneVm; import org.chromium.sdk.UnsupportedVersionException; @@ -121,9 +122,9 @@ } catch (InterruptedException e) { throw new RuntimeException(e); } catch (ExecutionException e) { - throw new IOException("Failed to get version", e); + throw new ChromiumIOException("Failed to get version", e); } catch (TimeoutException e) { - throw new IOException("Timed out waiting for version", e); + throw new ChromiumIOException("Timed out waiting for version", e); } String versionString = remoteInfo.getProtocolVersion(); diff -r 12372c19f1b0 -r fb430f25c33d org.chromium.sdk/src/org/chromium/sdk/internal/transport/Handshaker.java --- a/org.chromium.sdk/src/org/chromium/sdk/internal/transport/Handshaker.java Mon Feb 01 13:24:54 2010 -0800 +++ b/org.chromium.sdk/src/org/chromium/sdk/internal/transport/Handshaker.java Mon Feb 01 13:26:14 2010 -0800 @@ -10,8 +10,8 @@ import java.util.concurrent.ExecutionException; import java.util.concurrent.Future; import java.util.concurrent.FutureTask; -import java.util.concurrent.RunnableFuture; +import org.chromium.sdk.ChromiumIOException; import org.chromium.sdk.LineReader; import org.chromium.sdk.internal.transport.Message.MalformedMessageException; @@ -85,7 +85,7 @@ return runnableFuture; } - private final RunnableFuture runnableFuture = + private final FutureTask runnableFuture = new FutureTask(new HandshakeTaks()); private LineReader input = null; @@ -100,7 +100,7 @@ } catch (InterruptedException e) { throw new RuntimeException(e); } catch (ExecutionException e) { - throw new IOException("Failed to perform handshake", e); + throw new ChromiumIOException("Failed to perform handshake", e); } } @@ -111,7 +111,7 @@ try { message = Message.fromBufferedReader(input); } catch (MalformedMessageException e) { - throw new IOException("Unrecognized handshake message from remote", e); + throw new ChromiumIOException("Unrecognized handshake message from remote", e); } if (message == null) { throw new IOException("End of stream"); diff -r 12372c19f1b0 -r fb430f25c33d org.symbian.tools.wrttools.debug.core/.settings/org.eclipse.jdt.core.prefs --- a/org.symbian.tools.wrttools.debug.core/.settings/org.eclipse.jdt.core.prefs Mon Feb 01 13:24:54 2010 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,8 +0,0 @@ -#Thu Dec 17 15:43:16 EET 2009 -eclipse.preferences.version=1 -org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 -org.eclipse.jdt.core.compiler.compliance=1.6 -org.eclipse.jdt.core.compiler.problem.assertIdentifier=error -org.eclipse.jdt.core.compiler.problem.enumIdentifier=error -org.eclipse.jdt.core.compiler.source=1.6 diff -r 12372c19f1b0 -r fb430f25c33d org.symbian.tools.wrttools.debug.core/META-INF/MANIFEST.MF --- a/org.symbian.tools.wrttools.debug.core/META-INF/MANIFEST.MF Mon Feb 01 13:24:54 2010 -0800 +++ b/org.symbian.tools.wrttools.debug.core/META-INF/MANIFEST.MF Mon Feb 01 13:26:14 2010 -0800 @@ -17,5 +17,6 @@ org.eclipse.jface.text;bundle-version="3.5.0", org.symbian.tools.wrttools.previewer;bundle-version="1.0.0", org.symbian.tools.wrttools;bundle-version="1.0.0" -Bundle-RequiredExecutionEnvironment: JavaSE-1.6 +Bundle-RequiredExecutionEnvironment: J2SE-1.5, + JavaSE-1.6 Bundle-ActivationPolicy: lazy diff -r 12372c19f1b0 -r fb430f25c33d org.symbian.tools.wrttools.debug.core/src/org/symbian/tools/wrttools/debug/internal/ChromeDebugUtils.java --- a/org.symbian.tools.wrttools.debug.core/src/org/symbian/tools/wrttools/debug/internal/ChromeDebugUtils.java Mon Feb 01 13:24:54 2010 -0800 +++ b/org.symbian.tools.wrttools.debug.core/src/org/symbian/tools/wrttools/debug/internal/ChromeDebugUtils.java Mon Feb 01 13:26:14 2010 -0800 @@ -20,9 +20,7 @@ import java.io.File; -import org.eclipse.core.resources.IProject; -import org.eclipse.core.runtime.Platform; -import org.symbian.tools.wrttools.util.ProjectUtils; +import org.symbian.tools.wrttools.util.CoreUtil; public final class ChromeDebugUtils { public static String getExecutablePath(String folder) { @@ -38,9 +36,9 @@ private static String getExecutable() { // Add more ifs as we add support for new platforms - if (isMac()) { + if (CoreUtil.isMac()) { return "Google Chrome.app/Contents/MacOS/Google Chrome"; - } if (isLinux()) { + } else if (CoreUtil.isLinux()) { return "chrome"; } else { return "chrome.exe"; @@ -55,15 +53,4 @@ return getExecutablePath(Activator.getDefault().getPreferenceStore().getString(IConstants.PREF_NAME_CHROME_LOCATION)); } - public static boolean isWindows() { - return "windows".equals(Platform.getOS()); - } - - public static boolean isMac() { - return "macosx".equals(Platform.getOS()); - } - - public static boolean isLinux() { - return "linux".equals(Platform.getOS()); - } } diff -r 12372c19f1b0 -r fb430f25c33d org.symbian.tools.wrttools.debug.core/src/org/symbian/tools/wrttools/debug/internal/PreferenceInitializer.java --- a/org.symbian.tools.wrttools.debug.core/src/org/symbian/tools/wrttools/debug/internal/PreferenceInitializer.java Mon Feb 01 13:24:54 2010 -0800 +++ b/org.symbian.tools.wrttools.debug.core/src/org/symbian/tools/wrttools/debug/internal/PreferenceInitializer.java Mon Feb 01 13:26:14 2010 -0800 @@ -22,6 +22,7 @@ import org.eclipse.core.runtime.preferences.AbstractPreferenceInitializer; import org.eclipse.jface.preference.IPreferenceStore; +import org.symbian.tools.wrttools.util.CoreUtil; public class PreferenceInitializer extends AbstractPreferenceInitializer { private final static String DEFAULT_CHROME_LOCATION = "Local Settings/Application Data/Google/Chrome/Application"; @@ -37,9 +38,9 @@ } private File getDefaultFolder() { - if (ChromeDebugUtils.isMac()) { + if (CoreUtil.isMac()) { return new File("/Applications"); - } else if (ChromeDebugUtils.isLinux()) { + } else if (CoreUtil.isLinux()) { return new File("/opt/google/chrome"); } String property = System.getProperty("user.home"); diff -r 12372c19f1b0 -r fb430f25c33d org.symbian.tools.wrttools.debug.core/src/org/symbian/tools/wrttools/debug/internal/launch/DebugConnectionJob.java --- a/org.symbian.tools.wrttools.debug.core/src/org/symbian/tools/wrttools/debug/internal/launch/DebugConnectionJob.java Mon Feb 01 13:24:54 2010 -0800 +++ b/org.symbian.tools.wrttools.debug.core/src/org/symbian/tools/wrttools/debug/internal/launch/DebugConnectionJob.java Mon Feb 01 13:26:14 2010 -0800 @@ -64,7 +64,6 @@ target.fireTerminateEvent(); } - @Override public boolean browserRunning(URI uri) throws CoreException { JavascriptVmEmbedder.ConnectionToRemote remoteServer = createConnectionToRemote( port, launch, uri); diff -r 12372c19f1b0 -r fb430f25c33d org.symbian.tools.wrttools.debug.core/src/org/symbian/tools/wrttools/debug/internal/launch/WRTProjectWorkspaceBridge.java --- a/org.symbian.tools.wrttools.debug.core/src/org/symbian/tools/wrttools/debug/internal/launch/WRTProjectWorkspaceBridge.java Mon Feb 01 13:24:54 2010 -0800 +++ b/org.symbian.tools.wrttools.debug.core/src/org/symbian/tools/wrttools/debug/internal/launch/WRTProjectWorkspaceBridge.java Mon Feb 01 13:26:14 2010 -0800 @@ -32,19 +32,16 @@ this.project = project; } - @Override public WorkspaceBridge attachedToVm(DebugTargetImpl debugTargetImpl, JavascriptVm javascriptVm) { return new WRTProjectWorkspaceBridge(debugTargetImpl, javascriptVm, project); } - @Override public String getDebugModelIdentifier() { return DEBUG_MODEL_ID; } - @Override public JsLabelProvider getLabelProvider() { return new WrtLabelProvider(); } @@ -69,32 +66,26 @@ launch.setSourceLocator(sourceLocator); } - @Override public void beforeDetach() { // Do nothing } - @Override public BreakpointHandler getBreakpointHandler() { return breakpointHandler; } - @Override public IFile getScriptResource(Script script) { return resourceManager.getResource(script); } - @Override public void handleVmResetEvent() { resourceManager.clear(); } - @Override public void launchRemoved() { // Do nothing } - @Override public void reloadScriptsAtStart() { javascriptVm.getScripts(new ScriptsCallback() { public void failure(String errorMessage) { @@ -134,7 +125,6 @@ }); } - @Override public void scriptLoaded(Script newScript) { resourceManager.addScript(newScript); } diff -r 12372c19f1b0 -r fb430f25c33d org.symbian.tools.wrttools.debug.core/src/org/symbian/tools/wrttools/debug/internal/launch/WrtLabelProvider.java --- a/org.symbian.tools.wrttools.debug.core/src/org/symbian/tools/wrttools/debug/internal/launch/WrtLabelProvider.java Mon Feb 01 13:24:54 2010 -0800 +++ b/org.symbian.tools.wrttools.debug.core/src/org/symbian/tools/wrttools/debug/internal/launch/WrtLabelProvider.java Mon Feb 01 13:26:14 2010 -0800 @@ -12,7 +12,6 @@ public class WrtLabelProvider implements JsLabelProvider { - @Override public String getStackFrameLabel(StackFrame stackFrame) throws DebugException { CallFrame callFrame = stackFrame.getCallFrame(); @@ -32,13 +31,11 @@ return name; } - @Override public String getTargetLabel(DebugTargetImpl debugTarget) throws DebugException { return "WRT Runtime"; } - @Override public String getThreadLabel(JavascriptThread thread) throws DebugException { return NLS.bind("JavaScript Thread ({0})", (thread.isSuspended() ? "Suspended" : "Running")); //$NON-NLS-1$ //$NON-NLS-2$ diff -r 12372c19f1b0 -r fb430f25c33d org.symbian.tools.wrttools.feature/build.properties --- a/org.symbian.tools.wrttools.feature/build.properties Mon Feb 01 13:24:54 2010 -0800 +++ b/org.symbian.tools.wrttools.feature/build.properties Mon Feb 01 13:26:14 2010 -0800 @@ -1,1 +1,16 @@ -bin.includes = feature.xml +bin.includes = feature.xml +topLevelElementId = org.symbian.tools.wrttools +topLevelElementType = feature +buildDirectory=${basedir}/build028 archivePrefix=calDucks +configs="win32,win32,x86 & lunix, gtk, x86" +# sdk +base=/usr/eclipse/JEE/eclipse +# RCP IDE installation +eclipseLocation=/usr/eclipse +equinoxLauncherPluginVersion=3.5.1.R35x_20090820 +pdeBuildPluginVersion=1.0.201.R35x_v20090715 + +# javac +javacSource=1.5 +javacTarget=1.5 +javacVerbose=true diff -r 12372c19f1b0 -r fb430f25c33d org.symbian.tools.wrttools.feature/feature.xml --- a/org.symbian.tools.wrttools.feature/feature.xml Mon Feb 01 13:24:54 2010 -0800 +++ b/org.symbian.tools.wrttools.feature/feature.xml Mon Feb 01 13:26:14 2010 -0800 @@ -53,4 +53,32 @@ install-size="0" version="0.0.0"/> + + + + + + + + diff -r 12372c19f1b0 -r fb430f25c33d org.symbian.tools.wrttools.jseditors/.settings/org.eclipse.jdt.core.prefs --- a/org.symbian.tools.wrttools.jseditors/.settings/org.eclipse.jdt.core.prefs Mon Feb 01 13:24:54 2010 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,8 +0,0 @@ -#Wed Aug 26 17:30:15 PDT 2009 -eclipse.preferences.version=1 -org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 -org.eclipse.jdt.core.compiler.compliance=1.6 -org.eclipse.jdt.core.compiler.problem.assertIdentifier=error -org.eclipse.jdt.core.compiler.problem.enumIdentifier=error -org.eclipse.jdt.core.compiler.source=1.6 diff -r 12372c19f1b0 -r fb430f25c33d org.symbian.tools.wrttools.jseditors/META-INF/MANIFEST.MF --- a/org.symbian.tools.wrttools.jseditors/META-INF/MANIFEST.MF Mon Feb 01 13:24:54 2010 -0800 +++ b/org.symbian.tools.wrttools.jseditors/META-INF/MANIFEST.MF Mon Feb 01 13:26:14 2010 -0800 @@ -19,7 +19,8 @@ org.eclipse.jface, org.eclipse.ui.workbench Bundle-ActivationPolicy: lazy -Bundle-RequiredExecutionEnvironment: JavaSE-1.6 +Bundle-RequiredExecutionEnvironment: J2SE-1.5, + JavaSE-1.6 Bundle-ClassPath: net.sf.wdte.ui.jar, net.sf.wdte.core.jar, net.sf.wdte.js.core.jar, diff -r 12372c19f1b0 -r fb430f25c33d org.symbian.tools.wrttools.jseditors/build.properties --- a/org.symbian.tools.wrttools.jseditors/build.properties Mon Feb 01 13:24:54 2010 -0800 +++ b/org.symbian.tools.wrttools.jseditors/build.properties Mon Feb 01 13:26:14 2010 -0800 @@ -10,7 +10,9 @@ net.sf.wdte.core.jar,\ net.sf.wdte.js.core.jar,\ net.sf.wdte.js.ui.jar,\ - tk.eclipse.plugin.htmleditor_2.0.6.1.jar + tk.eclipse.plugin.htmleditor_2.0.6.1.jar,\ + license.html,\ + epl-v10.html source.net.sf.wdte.ui.jar = src/ source.net.sf.wdte.core.jar = src/ source.net.sf.wdte.js.core.jar = src/ diff -r 12372c19f1b0 -r fb430f25c33d org.symbian.tools.wrttools.previewer/.settings/org.eclipse.jdt.core.prefs --- a/org.symbian.tools.wrttools.previewer/.settings/org.eclipse.jdt.core.prefs Mon Feb 01 13:24:54 2010 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,8 +0,0 @@ -#Wed Jan 13 17:40:14 PST 2010 -eclipse.preferences.version=1 -org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 -org.eclipse.jdt.core.compiler.compliance=1.6 -org.eclipse.jdt.core.compiler.problem.assertIdentifier=error -org.eclipse.jdt.core.compiler.problem.enumIdentifier=error -org.eclipse.jdt.core.compiler.source=1.6 diff -r 12372c19f1b0 -r fb430f25c33d org.symbian.tools.wrttools.previewer/META-INF/MANIFEST.MF --- a/org.symbian.tools.wrttools.previewer/META-INF/MANIFEST.MF Mon Feb 01 13:24:54 2010 -0800 +++ b/org.symbian.tools.wrttools.previewer/META-INF/MANIFEST.MF Mon Feb 01 13:26:14 2010 -0800 @@ -8,13 +8,15 @@ org.eclipse.core.runtime, org.eclipse.core.resources;bundle-version="3.5.0", org.eclipse.core.net;bundle-version="1.2.0", - org.mozilla.xpcom;bundle-version="1.9.1", + org.mozilla.xpcom;bundle-version="1.9.1";resolution:=optional, org.eclipse.equinox.http.jetty;bundle-version="2.0.0", org.eclipse.wst.jsdt.core;bundle-version="1.0.200", org.eclipse.wst.jsdt.ui;bundle-version="1.0.200", - org.symbian.tools.wrttools;bundle-version="1.0.0" + org.symbian.tools.wrttools;bundle-version="1.0.0", + org.mozilla.xulrunner;bundle-version="1.9.1";resolution:=optional Bundle-ActivationPolicy: lazy -Bundle-RequiredExecutionEnvironment: JavaSE-1.6 +Bundle-RequiredExecutionEnvironment: J2SE-1.5, + JavaSE-1.6 Export-Package: org.symbian.tools.wrttools.previewer, org.symbian.tools.wrttools.previewer.http Import-Package: javax.servlet;version="2.5.0", diff -r 12372c19f1b0 -r fb430f25c33d org.symbian.tools.wrttools.previewer/src/org/symbian/tools/wrttools/previewer/jsdt/WrtContainerInitializer.java --- a/org.symbian.tools.wrttools.previewer/src/org/symbian/tools/wrttools/previewer/jsdt/WrtContainerInitializer.java Mon Feb 01 13:24:54 2010 -0800 +++ b/org.symbian.tools.wrttools.previewer/src/org/symbian/tools/wrttools/previewer/jsdt/WrtContainerInitializer.java Mon Feb 01 13:26:14 2010 -0800 @@ -8,7 +8,6 @@ public class WrtContainerInitializer extends JsGlobalScopeContainerInitializer { public static final String CONTAINER_ID = "org.symbian.wrt"; - @Override public LibraryLocation getLibraryLocation() { return new WrtLibraryLocation(); } diff -r 12372c19f1b0 -r fb430f25c33d org.symbian.tools.wrttools.previewer/src/org/symbian/tools/wrttools/previewer/jsdt/WrtLibraryLocation.java --- a/org.symbian.tools.wrttools.previewer/src/org/symbian/tools/wrttools/previewer/jsdt/WrtLibraryLocation.java Mon Feb 01 13:24:54 2010 -0800 +++ b/org.symbian.tools.wrttools.previewer/src/org/symbian/tools/wrttools/previewer/jsdt/WrtLibraryLocation.java Mon Feb 01 13:26:14 2010 -0800 @@ -21,18 +21,15 @@ "widget.js".toCharArray(), }; - @Override public char[][] getLibraryFileNames() { return FILE_NAMES; } - @Override public String getLibraryPath(String name) { System.out.println(name); return null; } - @Override public String getLibraryPath(char[] name) { URL entry = FileLocator.find(PreviewerPlugin.getDefault().getBundle(), LIBRARIES_PATH.append(new String(name)), null); if (entry != null) { @@ -47,12 +44,10 @@ return null; } - @Override public IPath getLibraryPathInPlugin() { return LIBRARIES_PATH; } - @Override public IPath getWorkingLibPath() { return new Path(getLibraryPath("")); } diff -r 12372c19f1b0 -r fb430f25c33d org.symbian.tools.wrttools.previewer/src/org/symbian/tools/wrttools/previewer/preview/AbstractPreviewPage.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/org.symbian.tools.wrttools.previewer/src/org/symbian/tools/wrttools/previewer/preview/AbstractPreviewPage.java Mon Feb 01 13:26:14 2010 -0800 @@ -0,0 +1,174 @@ +package org.symbian.tools.wrttools.previewer.preview; + +import java.net.URI; +import java.util.Collection; + +import org.eclipse.core.resources.IFile; +import org.eclipse.core.resources.IProject; +import org.eclipse.jface.action.Action; +import org.eclipse.jface.action.IAction; +import org.eclipse.jface.action.IToolBarManager; +import org.eclipse.jface.viewers.ISelection; +import org.eclipse.jface.viewers.ISelectionChangedListener; +import org.eclipse.jface.viewers.ISelectionProvider; +import org.eclipse.jface.viewers.StructuredSelection; +import org.eclipse.swt.browser.Browser; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Control; +import org.eclipse.ui.actions.ActionFactory; +import org.eclipse.ui.part.IPageSite; +import org.eclipse.ui.part.Page; +import org.symbian.tools.wrttools.previewer.Images; +import org.symbian.tools.wrttools.previewer.PreviewerPlugin; + +public abstract class AbstractPreviewPage extends Page implements IPreviewPage, ISelectionProvider { + private final IAction refreshAction = new Action("Refresh") { + public void run() { + refresh(); + }; + }; + private final IAction toggleRefresh = new Action("Toggle Refresh", IAction.AS_RADIO_BUTTON) { + public void run() { + toggleRefresh(); + }; + }; + + private final IProject project; + private Browser browser; + private boolean toggleState = true; + private final PreviewView previewView; + private boolean needsRefresh = false; + + public AbstractPreviewPage(IProject project, PreviewView previewView) { + this.project = project; + this.previewView = previewView; + } + + protected void toggleRefresh() { + toggleState = !toggleState; + toggleRefresh.setChecked(toggleState); + previewView.setProjectAutorefresh(project, toggleState); + toggleRefresh.setToolTipText(getToggleActionTooltip()); + if (toggleState && needsRefresh) { + refresh(); + } + } + + + @Override + public void createControl(Composite parent) { + browser = createBrowser(parent); + browser.setUrl(getURI().toASCIIString()); + } + + protected abstract Browser createBrowser(Composite parent); + + private URI getURI() { + return PreviewerPlugin.getDefault().getHttpPreviewer().previewProject(project); + } + + @Override + public Control getControl() { + return browser; + } + + @Override + public void setFocus() { + if (browser != null && !browser.isDisposed()) { + browser.setFocus(); + } + } + + private boolean refreshScheduled = false; + + public synchronized void process(Collection files) { + if (!refreshScheduled && needsRefresh(files)) { + asyncExec(new Runnable() { + public void run() { + if (toggleState) { + refresh(); + } else { + needsRefresh = true; + refreshAction.setImageDescriptor(PreviewerPlugin.getImageDescriptor(Images.RED_SYNC)); + refreshAction.setToolTipText("Refresh the preview browser (there are updated files)"); + } + } + }); + refreshScheduled = true; + } + } + + private void asyncExec(Runnable runnable) { + getControl().getDisplay().asyncExec(runnable); + } + + private boolean needsRefresh(Collection files) { + for (IFile iFile : files) { + if (iFile.getProject().equals(project)) { + return true; + } + } + return false; + } + + protected synchronized void refresh() { + try { + final Control focusControl = browser.getDisplay().getFocusControl(); + browser.refresh(); + refreshAction.setImageDescriptor(PreviewerPlugin + .getImageDescriptor(Images.GREEN_SYNC)); + if (focusControl != null) { + asyncExec(new Runnable() { + public void run() { + focusControl.setFocus(); + } + }); + } + refreshAction.setToolTipText("Refresh the preview browser"); + needsRefresh = false; + } finally { + refreshScheduled = false; + } + } + + @Override + public void init(IPageSite pageSite) { + super.init(pageSite); + IToolBarManager toolBar = pageSite.getActionBars().getToolBarManager(); + refreshAction.setImageDescriptor(PreviewerPlugin.getImageDescriptor(Images.GREEN_SYNC)); + refreshAction.setToolTipText("Refresh the preview browser"); + toolBar.add(refreshAction); + + toggleState = previewView.getProjectAutorefresh(project); + + toggleRefresh.setImageDescriptor(PreviewerPlugin.getImageDescriptor(Images.YELLOW_SYNC)); + toggleRefresh.setToolTipText(getToggleActionTooltip()); + toggleRefresh.setChecked(toggleState); + toolBar.add(toggleRefresh); + + pageSite.getActionBars().setGlobalActionHandler(ActionFactory.REFRESH.getId(), refreshAction); + getSite().setSelectionProvider(this); + } + + private String getToggleActionTooltip() { + return toggleState ? "Disable preview autorefresh" : "Enable preview autorefresh"; + } + + public void addSelectionChangedListener(ISelectionChangedListener listener) { + // Do nothing + } + + public ISelection getSelection() { + return new StructuredSelection(project); + } + + public void removeSelectionChangedListener( + ISelectionChangedListener listener) { + // Do nothing + } + + public void setSelection(ISelection selection) { + // Do nothing + } + +} diff -r 12372c19f1b0 -r fb430f25c33d org.symbian.tools.wrttools.previewer/src/org/symbian/tools/wrttools/previewer/preview/IPreviewPage.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/org.symbian.tools.wrttools.previewer/src/org/symbian/tools/wrttools/previewer/preview/IPreviewPage.java Mon Feb 01 13:26:14 2010 -0800 @@ -0,0 +1,10 @@ +package org.symbian.tools.wrttools.previewer.preview; + +import java.util.Collection; + +import org.eclipse.core.resources.IFile; +import org.eclipse.ui.part.IPageBookViewPage; + +public interface IPreviewPage extends IPageBookViewPage { + void process(Collection files); +} diff -r 12372c19f1b0 -r fb430f25c33d org.symbian.tools.wrttools.previewer/src/org/symbian/tools/wrttools/previewer/preview/MozillaPreviewPage.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/org.symbian.tools.wrttools.previewer/src/org/symbian/tools/wrttools/previewer/preview/MozillaPreviewPage.java Mon Feb 01 13:26:14 2010 -0800 @@ -0,0 +1,148 @@ +package org.symbian.tools.wrttools.previewer.preview; + +import java.io.File; +import java.io.IOException; +import java.net.URISyntaxException; +import java.net.URL; + +import org.eclipse.core.net.proxy.IProxyData; +import org.eclipse.core.net.proxy.IProxyService; +import org.eclipse.core.resources.IProject; +import org.eclipse.core.runtime.FileLocator; +import org.eclipse.core.runtime.Platform; +import org.eclipse.swt.SWT; +import org.eclipse.swt.browser.Browser; +import org.eclipse.swt.widgets.Composite; +import org.mozilla.interfaces.nsIPrefBranch; +import org.mozilla.interfaces.nsIServiceManager; +import org.mozilla.xpcom.Mozilla; +import org.osgi.framework.Bundle; +import org.symbian.tools.wrttools.previewer.PreviewerPlugin; +import org.symbian.tools.wrttools.previewer.http.WebAppInterface; +import org.symbian.tools.wrttools.previewer.http.WebappManager; + +public class MozillaPreviewPage extends AbstractPreviewPage { + public static final String XUL_RUNNER_BUNDLE = "org.mozilla.xulrunner"; + + private static final String XUL_RUNNER_PATH_PARAMETER = "org.eclipse.swt.browser.XULRunnerPath"; + private nsIPrefBranch mozillaPrefs; + + public MozillaPreviewPage(IProject project, PreviewView previewView) { + super(project, previewView); + } + + + private synchronized void initMozilla() { + if (System.getProperty(XUL_RUNNER_PATH_PARAMETER) == null) { + Bundle bundle = Platform.getBundle(XUL_RUNNER_BUNDLE); //$NON-NLS-1$ + if (bundle != null) { + URL resourceUrl = bundle.getResource("xulrunner"); //$NON-NLS-1$ + if (resourceUrl != null) { + try { + URL fileUrl = FileLocator.toFileURL(resourceUrl); + File file = new File(fileUrl.toURI()); + System.setProperty(XUL_RUNNER_PATH_PARAMETER, file + .getAbsolutePath()); //$NON-NLS-1$ + } catch (IOException e) { + // log the exception + } catch (URISyntaxException e) { + // log the exception + } + } + } + } + } + + @Override + protected Browser createBrowser(Composite parent) { + initMozilla(); + final Browser browser = new Browser(parent, SWT.MOZILLA); + bypassSameOriginPolicy(); + applyProxySettings(); + return browser; + } + + private void applyProxySettings() { + IProxyService px = PreviewerPlugin.getDefault().getProxyService(); + if(px != null){ + boolean proxyEnabled = px.isProxiesEnabled(); + + boolean systemProxy = px.isSystemProxiesEnabled(); + if( proxyEnabled && !systemProxy){ + IProxyData pd = px.getProxyData(IProxyData.HTTP_PROXY_TYPE); + if (pd !=null &&mozillaPrefs != null) { + String host= pd.getHost(); + int port = pd.getPort(); + if(host !=null && port != -1){ + mozillaPrefs.setIntPref("network.proxy.type", 1); + mozillaPrefs.setCharPref("network.proxy.http", host); + mozillaPrefs.setIntPref("network.proxy.http_port", port); + } + } + } + } + else{ + Exception e= new Exception(); + PreviewerPlugin.log("Proxy service returned null", e); + } + } + + private void bypassSameOriginPolicy() { + WebAppInterface.getInstance(); + try{ + nsIServiceManager servMgr = null; + try { + servMgr = Mozilla.getInstance().getServiceManager(); + if (servMgr == null) return; + } catch (Exception x) { + // known to throw NullPointException on Mac OS when you're not using + // Mozilla. We don't want to pollute the error log with this + return; + } + + mozillaPrefs = (nsIPrefBranch) servMgr.getServiceByContractID( + "@mozilla.org/preferences-service;1", + nsIPrefBranch.NS_IPREFBRANCH_IID ); + + mozillaPrefs.setBoolPref("signed.applets.codebase_principal_support", 1); + + mozillaPrefs.setCharPref("capability.policy.default.XMLDocument.getElementsByTagName", "allAccess"); + mozillaPrefs.setCharPref("capability.policy.default.CDATASection.nodeValue", "allAccess"); + + mozillaPrefs.setCharPref("capability.policy.default.HTMLCollection.length", "allAccess"); + mozillaPrefs.setCharPref("capability.policy.default.HTMLCollection.item", "allAccess"); + + mozillaPrefs.setCharPref("capability.policy.default.*.nodeValue", "allAccess"); + mozillaPrefs.setCharPref("capability.policy.default.*.nodeType", "allAccess"); + mozillaPrefs.setCharPref("capability.policy.default.*.nodeName", "allAccess"); + mozillaPrefs.setCharPref("capability.policy.default.*.nextSibling", "allAccess"); + mozillaPrefs.setCharPref("capability.policy.default.*.previousSibling", "allAccess"); + mozillaPrefs.setCharPref("capability.policy.default.*.attributes", "allAccess"); + mozillaPrefs.setCharPref("capability.policy.default.*.childNodes", "allAccess"); + mozillaPrefs.setCharPref("capability.policy.default.*.firstChild", "allAccess"); + mozillaPrefs.setCharPref("capability.policy.default.*.getAttribute", "allAccess"); + mozillaPrefs.setCharPref("capability.policy.default.*.getElementsByTagName", "allAccess"); + mozillaPrefs.setCharPref("capability.policy.default.*.lastChild", "allAccess"); + mozillaPrefs.setCharPref("capability.policy.default.*.parentNode", "allAccess"); + mozillaPrefs.setCharPref("capability.policy.default.*.tagName", "allAccess"); + + mozillaPrefs.setCharPref("capability.policy.default.XMLDocument.documentElement", "allAccess"); + mozillaPrefs.setCharPref("capability.policy.default.XMLDocument.getElementsByTagName", "allAccess"); + mozillaPrefs.setCharPref("capability.policy.default.XMLHttpRequest.channel", "allAccess"); + mozillaPrefs.setCharPref("capability.policy.default.XMLHttpRequest.open", "allAccess"); + mozillaPrefs.setCharPref("capability.policy.default.XMLHttpRequest.responseText", "allAccess"); + mozillaPrefs.setCharPref("capability.policy.default.XMLHttpRequest.responseXML", "allAccess"); + mozillaPrefs.setCharPref("capability.policy.default.XMLHttpRequest.send", "allAccess"); + mozillaPrefs.setCharPref("capability.policy.default.XMLHttpRequest.setRequestHeader", "allAccess"); + /* to over-ride the internet security dialog when preview browser tries to access local hard drive */ + mozillaPrefs.setCharPref("capability.principal.codebase.p0.granted", "UniversalXPConnect UniversalBrowserRead"); + String location = "http://127.0.0.1:" + WebappManager.getPort(); + mozillaPrefs.setCharPref("capability.principal.codebase.p0.id", location); + mozillaPrefs.setBoolPref("security.fileuri.strict_origin_policy", 0); + } catch (Exception e) { + PreviewerPlugin.log("Error getting preferences", e); + } + } + + +} diff -r 12372c19f1b0 -r fb430f25c33d org.symbian.tools.wrttools.previewer/src/org/symbian/tools/wrttools/previewer/preview/PreviewPage.java --- a/org.symbian.tools.wrttools.previewer/src/org/symbian/tools/wrttools/previewer/preview/PreviewPage.java Mon Feb 01 13:24:54 2010 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,301 +0,0 @@ -package org.symbian.tools.wrttools.previewer.preview; - -import java.io.File; -import java.io.IOException; -import java.net.URI; -import java.net.URISyntaxException; -import java.net.URL; -import java.util.Collection; - -import org.eclipse.core.net.proxy.IProxyData; -import org.eclipse.core.net.proxy.IProxyService; -import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.IProject; -import org.eclipse.core.runtime.FileLocator; -import org.eclipse.core.runtime.Platform; -import org.eclipse.jface.action.Action; -import org.eclipse.jface.action.IAction; -import org.eclipse.jface.action.IToolBarManager; -import org.eclipse.jface.viewers.ISelection; -import org.eclipse.jface.viewers.ISelectionChangedListener; -import org.eclipse.jface.viewers.ISelectionProvider; -import org.eclipse.jface.viewers.StructuredSelection; -import org.eclipse.swt.SWT; -import org.eclipse.swt.browser.Browser; -import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; -import org.eclipse.ui.actions.ActionFactory; -import org.eclipse.ui.part.IPageBookViewPage; -import org.eclipse.ui.part.IPageSite; -import org.eclipse.ui.part.Page; -import org.mozilla.interfaces.nsIPrefBranch; -import org.mozilla.interfaces.nsIServiceManager; -import org.mozilla.xpcom.Mozilla; -import org.osgi.framework.Bundle; -import org.symbian.tools.wrttools.previewer.PreviewerPlugin; -import org.symbian.tools.wrttools.previewer.Images; -import org.symbian.tools.wrttools.previewer.http.WebAppInterface; -import org.symbian.tools.wrttools.previewer.http.WebappManager; - -public class PreviewPage extends Page implements IPageBookViewPage, ISelectionProvider { - private static final String XUL_RUNNER_PATH_PARAMETER = "org.eclipse.swt.browser.XULRunnerPath"; - private nsIPrefBranch mozillaPrefs; - - private final IAction refreshAction = new Action("Refresh") { - public void run() { - refresh(); - }; - }; - private final IAction toggleRefresh = new Action("Toggle Refresh", IAction.AS_RADIO_BUTTON) { - public void run() { - toggleRefresh(); - }; - }; - - private final IProject project; - private Browser browser; - private boolean toggleState = true; - private final PreviewView previewView; - private boolean needsRefresh = false; - - public PreviewPage(IProject project, PreviewView previewView) { - this.project = project; - this.previewView = previewView; - } - - protected void toggleRefresh() { - toggleState = !toggleState; - toggleRefresh.setChecked(toggleState); - previewView.setProjectAutorefresh(project, toggleState); - toggleRefresh.setToolTipText(getToggleActionTooltip()); - if (toggleState && needsRefresh) { - refresh(); - } - } - - private synchronized void initMozilla() { - if (System.getProperty(XUL_RUNNER_PATH_PARAMETER) == null) { - Bundle bundle = Platform.getBundle("org.mozilla.xulrunner"); //$NON-NLS-1$ - if (bundle != null) { - URL resourceUrl = bundle.getResource("xulrunner"); //$NON-NLS-1$ - if (resourceUrl != null) { - try { - URL fileUrl = FileLocator.toFileURL(resourceUrl); - File file = new File(fileUrl.toURI()); - System.setProperty(XUL_RUNNER_PATH_PARAMETER, file - .getAbsolutePath()); //$NON-NLS-1$ - } catch (IOException e) { - // log the exception - } catch (URISyntaxException e) { - // log the exception - } - } - } - } - } - - - @Override - public void createControl(Composite parent) { - initMozilla(); - browser = new Browser(parent, SWT.MOZILLA); - bypassSameOriginPolicy(); - applyProxySettings(); - browser.setUrl(getURI().toASCIIString()); - } - - private URI getURI() { - return PreviewerPlugin.getDefault().getHttpPreviewer().previewProject(project); - } - - @Override - public Control getControl() { - return browser; - } - - @Override - public void setFocus() { - browser.setFocus(); - } - - private boolean refreshScheduled = false; - - public synchronized void process(Collection files) { - if (!refreshScheduled && needsRefresh(files)) { - asyncExec(new Runnable() { - @Override - public void run() { - if (toggleState) { - refresh(); - } else { - needsRefresh = true; - refreshAction.setImageDescriptor(PreviewerPlugin.getImageDescriptor(Images.RED_SYNC)); - refreshAction.setToolTipText("Refresh the preview browser (there are updated files)"); - } - } - }); - refreshScheduled = true; - } - } - - private void asyncExec(Runnable runnable) { - getControl().getDisplay().asyncExec(runnable); - } - - private boolean needsRefresh(Collection files) { - for (IFile iFile : files) { - if (iFile.getProject().equals(project)) { - return true; - } - } - return false; - } - - protected synchronized void refresh() { - try { - final Control focusControl = browser.getDisplay().getFocusControl(); - browser.refresh(); - refreshAction.setImageDescriptor(PreviewerPlugin - .getImageDescriptor(Images.GREEN_SYNC)); - if (focusControl != null) { - asyncExec(new Runnable() { - @Override - public void run() { - focusControl.setFocus(); - } - }); - } - refreshAction.setToolTipText("Refresh the preview browser"); - needsRefresh = false; - } finally { - refreshScheduled = false; - } - } - - @Override - public void init(IPageSite pageSite) { - super.init(pageSite); - IToolBarManager toolBar = pageSite.getActionBars().getToolBarManager(); - refreshAction.setImageDescriptor(PreviewerPlugin.getImageDescriptor(Images.GREEN_SYNC)); - refreshAction.setToolTipText("Refresh the preview browser"); - toolBar.add(refreshAction); - - toggleState = previewView.getProjectAutorefresh(project); - - toggleRefresh.setImageDescriptor(PreviewerPlugin.getImageDescriptor(Images.YELLOW_SYNC)); - toggleRefresh.setToolTipText(getToggleActionTooltip()); - toggleRefresh.setChecked(toggleState); - toolBar.add(toggleRefresh); - - pageSite.getActionBars().setGlobalActionHandler(ActionFactory.REFRESH.getId(), refreshAction); - getSite().setSelectionProvider(this); - } - - private String getToggleActionTooltip() { - return toggleState ? "Disable preview autorefresh" : "Enable preview autorefresh"; - } - - @Override - public void addSelectionChangedListener(ISelectionChangedListener listener) { - // Do nothing - } - - @Override - public ISelection getSelection() { - return new StructuredSelection(project); - } - - @Override - public void removeSelectionChangedListener( - ISelectionChangedListener listener) { - // Do nothing - } - - @Override - public void setSelection(ISelection selection) { - // Do nothing - } - - private void applyProxySettings() { - IProxyService px = PreviewerPlugin.getDefault().getProxyService(); - if(px != null){ - boolean proxyEnabled = px.isProxiesEnabled(); - - boolean systemProxy = px.isSystemProxiesEnabled(); - if( proxyEnabled && !systemProxy){ - IProxyData pd = px.getProxyData(IProxyData.HTTP_PROXY_TYPE); - if (pd !=null &&mozillaPrefs != null) { - String host= pd.getHost(); - int port = pd.getPort(); - if(host !=null && port != -1){ - mozillaPrefs.setIntPref("network.proxy.type", 1); - mozillaPrefs.setCharPref("network.proxy.http", host); - mozillaPrefs.setIntPref("network.proxy.http_port", port); - } - } - } - } - else{ - Exception e= new Exception(); - PreviewerPlugin.log("Proxy service returned null", e); - } - } - - private void bypassSameOriginPolicy() { - WebAppInterface.getInstance(); - try{ - nsIServiceManager servMgr = null; - try { - servMgr = Mozilla.getInstance().getServiceManager(); - if (servMgr == null) return; - } catch (Exception x) { - // known to throw NullPointException on Mac OS when you're not using - // Mozilla. We don't want to pollute the error log with this - return; - } - - mozillaPrefs = (nsIPrefBranch) servMgr.getServiceByContractID( - "@mozilla.org/preferences-service;1", - nsIPrefBranch.NS_IPREFBRANCH_IID ); - - mozillaPrefs.setBoolPref("signed.applets.codebase_principal_support", 1); - - mozillaPrefs.setCharPref("capability.policy.default.XMLDocument.getElementsByTagName", "allAccess"); - mozillaPrefs.setCharPref("capability.policy.default.CDATASection.nodeValue", "allAccess"); - - mozillaPrefs.setCharPref("capability.policy.default.HTMLCollection.length", "allAccess"); - mozillaPrefs.setCharPref("capability.policy.default.HTMLCollection.item", "allAccess"); - - mozillaPrefs.setCharPref("capability.policy.default.*.nodeValue", "allAccess"); - mozillaPrefs.setCharPref("capability.policy.default.*.nodeType", "allAccess"); - mozillaPrefs.setCharPref("capability.policy.default.*.nodeName", "allAccess"); - mozillaPrefs.setCharPref("capability.policy.default.*.nextSibling", "allAccess"); - mozillaPrefs.setCharPref("capability.policy.default.*.previousSibling", "allAccess"); - mozillaPrefs.setCharPref("capability.policy.default.*.attributes", "allAccess"); - mozillaPrefs.setCharPref("capability.policy.default.*.childNodes", "allAccess"); - mozillaPrefs.setCharPref("capability.policy.default.*.firstChild", "allAccess"); - mozillaPrefs.setCharPref("capability.policy.default.*.getAttribute", "allAccess"); - mozillaPrefs.setCharPref("capability.policy.default.*.getElementsByTagName", "allAccess"); - mozillaPrefs.setCharPref("capability.policy.default.*.lastChild", "allAccess"); - mozillaPrefs.setCharPref("capability.policy.default.*.parentNode", "allAccess"); - mozillaPrefs.setCharPref("capability.policy.default.*.tagName", "allAccess"); - - mozillaPrefs.setCharPref("capability.policy.default.XMLDocument.documentElement", "allAccess"); - mozillaPrefs.setCharPref("capability.policy.default.XMLDocument.getElementsByTagName", "allAccess"); - mozillaPrefs.setCharPref("capability.policy.default.XMLHttpRequest.channel", "allAccess"); - mozillaPrefs.setCharPref("capability.policy.default.XMLHttpRequest.open", "allAccess"); - mozillaPrefs.setCharPref("capability.policy.default.XMLHttpRequest.responseText", "allAccess"); - mozillaPrefs.setCharPref("capability.policy.default.XMLHttpRequest.responseXML", "allAccess"); - mozillaPrefs.setCharPref("capability.policy.default.XMLHttpRequest.send", "allAccess"); - mozillaPrefs.setCharPref("capability.policy.default.XMLHttpRequest.setRequestHeader", "allAccess"); - /* to over-ride the internet security dialog when preview browser tries to access local hard drive */ - mozillaPrefs.setCharPref("capability.principal.codebase.p0.granted", "UniversalXPConnect UniversalBrowserRead"); - String location = "http://127.0.0.1:" + WebappManager.getPort(); - mozillaPrefs.setCharPref("capability.principal.codebase.p0.id", location); - mozillaPrefs.setBoolPref("security.fileuri.strict_origin_policy", 0); - } catch (Exception e) { - PreviewerPlugin.log("Error getting preferences", e); - } - } - -} diff -r 12372c19f1b0 -r fb430f25c33d org.symbian.tools.wrttools.previewer/src/org/symbian/tools/wrttools/previewer/preview/PreviewView.java --- a/org.symbian.tools.wrttools.previewer/src/org/symbian/tools/wrttools/previewer/preview/PreviewView.java Mon Feb 01 13:24:54 2010 -0800 +++ b/org.symbian.tools.wrttools.previewer/src/org/symbian/tools/wrttools/previewer/preview/PreviewView.java Mon Feb 01 13:26:14 2010 -0800 @@ -24,6 +24,7 @@ import org.eclipse.core.resources.IWorkspaceRoot; import org.eclipse.core.resources.ResourcesPlugin; import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.Platform; import org.eclipse.jface.dialogs.IDialogConstants; import org.eclipse.jface.dialogs.MessageDialogWithToggle; import org.eclipse.jface.preference.IPreferenceStore; @@ -36,6 +37,7 @@ import org.eclipse.ui.part.PageBookView; import org.symbian.tools.wrttools.previewer.PreviewerPlugin; import org.symbian.tools.wrttools.previewer.IWrtEditingPreferences; +import org.symbian.tools.wrttools.util.CoreUtil; import org.symbian.tools.wrttools.util.ProjectUtils; public class PreviewView extends PageBookView { @@ -43,7 +45,6 @@ IResourceDeltaVisitor { public final Collection files = new HashSet(); - @Override public boolean visit(IResourceDelta delta) throws CoreException { if (isRelevantResource(delta.getResource())) { files.add((IFile) delta.getResource()); @@ -59,7 +60,6 @@ } private final IResourceChangeListener resourceListener = new IResourceChangeListener() { - @Override public void resourceChanged(IResourceChangeEvent event) { ChangedResourcesCollector visitor = new ChangedResourcesCollector(); try { @@ -71,7 +71,7 @@ } }; - private Map projectToPage = new HashMap(); + private Map projectToPage = new HashMap(); private boolean preferencesLoaded = false; private final Map autorefresh = new HashMap(); @@ -105,10 +105,10 @@ .getAdapter(IResource.class); IProject project = resource.getProject(); - PreviewPage page = projectToPage.get(project); + IPreviewPage page = projectToPage.get(project); if (page == null) { - page = new PreviewPage(project, this); + page = createPreviewPage(project); initPage(page); page.createControl(getPageBook()); projectToPage.put(project, page); @@ -117,6 +117,14 @@ return new PageRec(part, page); } + private IPreviewPage createPreviewPage(IProject project) { + if (Platform.getBundle(MozillaPreviewPage.XUL_RUNNER_BUNDLE) != null) { + return new MozillaPreviewPage(project, this); + } else { + return new SwtBrowserPreviewPage(project, this); + } + } + @Override protected void doDestroyPage(IWorkbenchPart part, PageRec pageRecord) { // We do not need to delete the page @@ -221,8 +229,8 @@ } protected void refreshPages(Collection files) { - Collection values = projectToPage.values(); - for (PreviewPage page : values) { + Collection values = projectToPage.values(); + for (IPreviewPage page : values) { page.process(files); } } diff -r 12372c19f1b0 -r fb430f25c33d org.symbian.tools.wrttools.previewer/src/org/symbian/tools/wrttools/previewer/preview/SwtBrowserPreviewPage.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/org.symbian.tools.wrttools.previewer/src/org/symbian/tools/wrttools/previewer/preview/SwtBrowserPreviewPage.java Mon Feb 01 13:26:14 2010 -0800 @@ -0,0 +1,20 @@ +package org.symbian.tools.wrttools.previewer.preview; + +import org.eclipse.core.resources.IProject; +import org.eclipse.swt.SWT; +import org.eclipse.swt.browser.Browser; +import org.eclipse.swt.widgets.Composite; + +public class SwtBrowserPreviewPage extends AbstractPreviewPage implements + IPreviewPage { + + public SwtBrowserPreviewPage(IProject project, PreviewView previewView) { + super(project, previewView); + } + + @Override + protected Browser createBrowser(Composite parent) { + return new Browser(parent, SWT.NONE); + } + +} diff -r 12372c19f1b0 -r fb430f25c33d org.symbian.tools.wrttools.product/.settings/org.eclipse.jdt.core.prefs --- a/org.symbian.tools.wrttools.product/.settings/org.eclipse.jdt.core.prefs Mon Feb 01 13:24:54 2010 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,8 +0,0 @@ -#Wed Jan 13 10:11:07 PST 2010 -eclipse.preferences.version=1 -org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 -org.eclipse.jdt.core.compiler.compliance=1.6 -org.eclipse.jdt.core.compiler.problem.assertIdentifier=error -org.eclipse.jdt.core.compiler.problem.enumIdentifier=error -org.eclipse.jdt.core.compiler.source=1.6 diff -r 12372c19f1b0 -r fb430f25c33d org.symbian.tools.wrttools.product/META-INF/MANIFEST.MF --- a/org.symbian.tools.wrttools.product/META-INF/MANIFEST.MF Mon Feb 01 13:24:54 2010 -0800 +++ b/org.symbian.tools.wrttools.product/META-INF/MANIFEST.MF Mon Feb 01 13:26:14 2010 -0800 @@ -15,5 +15,6 @@ org.eclipse.wst.css.ui;bundle-version="1.0.400", org.eclipse.wst.html.ui;bundle-version="1.0.400", org.eclipse.wst.xml.ui;bundle-version="1.1.0" -Bundle-RequiredExecutionEnvironment: JavaSE-1.6 +Bundle-RequiredExecutionEnvironment: J2SE-1.5, + JavaSE-1.6 Bundle-ActivationPolicy: lazy diff -r 12372c19f1b0 -r fb430f25c33d org.symbian.tools.wrttools.product/launch/WRT IDE (Product).launch --- a/org.symbian.tools.wrttools.product/launch/WRT IDE (Product).launch Mon Feb 01 13:24:54 2010 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,32 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff -r 12372c19f1b0 -r fb430f25c33d org.symbian.tools.wrttools.product/launch/WRT IDE Product (Mac OS X).launch --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/org.symbian.tools.wrttools.product/launch/WRT IDE Product (Mac OS X).launch Mon Feb 01 13:26:14 2010 -0800 @@ -0,0 +1,32 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff -r 12372c19f1b0 -r fb430f25c33d org.symbian.tools.wrttools.product/launch/WRT IDE Product (Windows).launch --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/org.symbian.tools.wrttools.product/launch/WRT IDE Product (Windows).launch Mon Feb 01 13:26:14 2010 -0800 @@ -0,0 +1,32 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff -r 12372c19f1b0 -r fb430f25c33d org.symbian.tools.wrttools.product/src/org/symbian/tools/wrttools/product/actions/NewCSSFileAction.java --- a/org.symbian.tools.wrttools.product/src/org/symbian/tools/wrttools/product/actions/NewCSSFileAction.java Mon Feb 01 13:24:54 2010 -0800 +++ b/org.symbian.tools.wrttools.product/src/org/symbian/tools/wrttools/product/actions/NewCSSFileAction.java Mon Feb 01 13:26:14 2010 -0800 @@ -18,24 +18,20 @@ return new NewCSSWizard(); } - @Override public void dispose() { // TODO Auto-generated method stub } - @Override public void init(IWorkbenchWindow window) { // TODO Auto-generated method stub } - @Override public void run(IAction action) { run(); } - @Override public void selectionChanged(IAction action, ISelection selection) { // TODO Auto-generated method stub diff -r 12372c19f1b0 -r fb430f25c33d org.symbian.tools.wrttools.product/src/org/symbian/tools/wrttools/product/actions/NewHTMLFileAction.java --- a/org.symbian.tools.wrttools.product/src/org/symbian/tools/wrttools/product/actions/NewHTMLFileAction.java Mon Feb 01 13:24:54 2010 -0800 +++ b/org.symbian.tools.wrttools.product/src/org/symbian/tools/wrttools/product/actions/NewHTMLFileAction.java Mon Feb 01 13:26:14 2010 -0800 @@ -18,24 +18,20 @@ return new NewHTMLWizard(); } - @Override public void dispose() { // TODO Auto-generated method stub } - @Override public void init(IWorkbenchWindow window) { // TODO Auto-generated method stub } - @Override public void run(IAction action) { run(); } - @Override public void selectionChanged(IAction action, ISelection selection) { // TODO Auto-generated method stub diff -r 12372c19f1b0 -r fb430f25c33d org.symbian.tools.wrttools.product/src/org/symbian/tools/wrttools/product/actions/NewJSFileAction.java --- a/org.symbian.tools.wrttools.product/src/org/symbian/tools/wrttools/product/actions/NewJSFileAction.java Mon Feb 01 13:24:54 2010 -0800 +++ b/org.symbian.tools.wrttools.product/src/org/symbian/tools/wrttools/product/actions/NewJSFileAction.java Mon Feb 01 13:26:14 2010 -0800 @@ -18,24 +18,20 @@ return new NewJSWizard(); } - @Override public void dispose() { // TODO Auto-generated method stub } - @Override public void init(IWorkbenchWindow window) { // TODO Auto-generated method stub } - @Override public void run(IAction action) { run(); } - @Override public void selectionChanged(IAction action, ISelection selection) { // TODO Auto-generated method stub diff -r 12372c19f1b0 -r fb430f25c33d org.symbian.tools.wrttools.product/src/org/symbian/tools/wrttools/product/actions/NewWRTProjectAction.java --- a/org.symbian.tools.wrttools.product/src/org/symbian/tools/wrttools/product/actions/NewWRTProjectAction.java Mon Feb 01 13:24:54 2010 -0800 +++ b/org.symbian.tools.wrttools.product/src/org/symbian/tools/wrttools/product/actions/NewWRTProjectAction.java Mon Feb 01 13:26:14 2010 -0800 @@ -13,18 +13,15 @@ public class NewWRTProjectAction extends AbstractOpenWizardAction implements IWorkbenchWindowActionDelegate { - @Override public void init(IWorkbenchWindow window) { // TODO Auto-generated method stub } - @Override public void run(IAction action) { run(); } - @Override public void selectionChanged(IAction action, ISelection selection) { // TODO Auto-generated method stub @@ -35,7 +32,6 @@ return new WrtWidgetWizard(); } - @Override public void dispose() { // TODO Auto-generated method stub diff -r 12372c19f1b0 -r fb430f25c33d org.symbian.tools.wrttools.product/src/org/symbian/tools/wrttools/product/perspective/WRTPerspective.java --- a/org.symbian.tools.wrttools.product/src/org/symbian/tools/wrttools/product/perspective/WRTPerspective.java Mon Feb 01 13:24:54 2010 -0800 +++ b/org.symbian.tools.wrttools.product/src/org/symbian/tools/wrttools/product/perspective/WRTPerspective.java Mon Feb 01 13:26:14 2010 -0800 @@ -11,7 +11,6 @@ public class WRTPerspective implements IPerspectiveFactory { - @Override public void createInitialLayout(IPageLayout layout) { String editorArea = layout.getEditorArea(); diff -r 12372c19f1b0 -r fb430f25c33d org.symbian.tools.wrttools.product/wrt-ide.product --- a/org.symbian.tools.wrttools.product/wrt-ide.product Mon Feb 01 13:24:54 2010 -0800 +++ b/org.symbian.tools.wrttools.product/wrt-ide.product Mon Feb 01 13:26:14 2010 -0800 @@ -1,303 +1,305 @@ - - - - - - - - - %productBlurb - - - - - - - - -os ${target.os} -ws ${target.ws} -arch ${target.arch} -nl ${target.nl} - -Xms128m -Xmx768m -XX:MaxPermSize=192m - -XstartOnFirstThread -Dorg.eclipse.swt.internal.carbon.smallFonts - - - - - - - - - - - - - - org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + %productBlurb + + + + + + + + -os ${target.os} -ws ${target.ws} -arch ${target.arch} -nl ${target.nl} + -Xms128m -Xmx768m -XX:MaxPermSize=192m + -XstartOnFirstThread -Dorg.eclipse.swt.internal.carbon.smallFonts + + + + + + + + + + + + + + + org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5 + org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff -r 12372c19f1b0 -r fb430f25c33d org.symbian.tools.wrttools/.settings/org.eclipse.jdt.core.prefs --- a/org.symbian.tools.wrttools/.settings/org.eclipse.jdt.core.prefs Mon Feb 01 13:24:54 2010 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,8 +0,0 @@ -#Thu Jan 07 13:06:13 PST 2010 -eclipse.preferences.version=1 -org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 -org.eclipse.jdt.core.compiler.compliance=1.6 -org.eclipse.jdt.core.compiler.problem.assertIdentifier=error -org.eclipse.jdt.core.compiler.problem.enumIdentifier=error -org.eclipse.jdt.core.compiler.source=1.6 diff -r 12372c19f1b0 -r fb430f25c33d org.symbian.tools.wrttools/META-INF/MANIFEST.MF --- a/org.symbian.tools.wrttools/META-INF/MANIFEST.MF Mon Feb 01 13:24:54 2010 -0800 +++ b/org.symbian.tools.wrttools/META-INF/MANIFEST.MF Mon Feb 01 13:26:14 2010 -0800 @@ -23,7 +23,8 @@ org.eclipse.wst.xml.core;bundle-version="1.1.400", org.eclipse.ui.navigator;bundle-version="3.4.0", org.eclipse.ui.navigator.resources;bundle-version="3.4.0" -Bundle-RequiredExecutionEnvironment: JavaSE-1.6 +Bundle-RequiredExecutionEnvironment: J2SE-1.5, + JavaSE-1.6 Bundle-ActivationPolicy: lazy Import-Package: org.apache.velocity;version="1.5.0", org.apache.velocity.app;version="1.5.0", diff -r 12372c19f1b0 -r fb430f25c33d org.symbian.tools.wrttools/build.properties --- a/org.symbian.tools.wrttools/build.properties Mon Feb 01 13:24:54 2010 -0800 +++ b/org.symbian.tools.wrttools/build.properties Mon Feb 01 13:26:14 2010 -0800 @@ -8,4 +8,7 @@ projecttemplates/,\ licenses/,\ icons/,\ - lib/jtidy-8.0-20060801.131059-3.jar + lib/,\ + epl-v10.html,\ + license.html,\ + schema/ diff -r 12372c19f1b0 -r fb430f25c33d org.symbian.tools.wrttools/plugin.xml --- a/org.symbian.tools.wrttools/plugin.xml Mon Feb 01 13:24:54 2010 -0800 +++ b/org.symbian.tools.wrttools/plugin.xml Mon Feb 01 13:26:14 2010 -0800 @@ -156,6 +156,13 @@ icon="icons/main16.gif" id="org.symbian.tools.wrttools.import.aptanaImport" name="Aptana IDE WRT Project"> + + @@ -443,9 +450,29 @@ - - + + + + + + + + + + + + + + + + diff -r 12372c19f1b0 -r fb430f25c33d org.symbian.tools.wrttools/src/org/symbian/tools/wrttools/builder/FavoriteItemType.java --- a/org.symbian.tools.wrttools/src/org/symbian/tools/wrttools/builder/FavoriteItemType.java Mon Feb 01 13:24:54 2010 -0800 +++ b/org.symbian.tools.wrttools/src/org/symbian/tools/wrttools/builder/FavoriteItemType.java Mon Feb 01 13:26:14 2010 -0800 @@ -55,7 +55,6 @@ public IFavoriteItem loadFavorite(String info) { return null; } - @Override public int compareTo(Object o) { // TODO Auto-generated method stub return 0; @@ -75,7 +74,6 @@ public IFavoriteItem loadFavorite(String info) { return FavoriteResource.loadFavorite(this, info); } - @Override public int compareTo(Object o) { // TODO Auto-generated method stub return 0; @@ -95,7 +93,6 @@ public IFavoriteItem loadFavorite(String info) { return FavoriteResource.loadFavorite(this, info); } - @Override public int compareTo(Object o) { // TODO Auto-generated method stub return 0; diff -r 12372c19f1b0 -r fb430f25c33d org.symbian.tools.wrttools/src/org/symbian/tools/wrttools/builder/FavoriteResource.java --- a/org.symbian.tools.wrttools/src/org/symbian/tools/wrttools/builder/FavoriteResource.java Mon Feb 01 13:24:54 2010 -0800 +++ b/org.symbian.tools.wrttools/src/org/symbian/tools/wrttools/builder/FavoriteResource.java Mon Feb 01 13:26:14 2010 -0800 @@ -36,43 +36,36 @@ // TODO Auto-generated constructor stub } - @Override public String getInfo() { // TODO Auto-generated method stub return null; } - @Override public String getLocation() { // TODO Auto-generated method stub return null; } - @Override public String getName() { // TODO Auto-generated method stub return null; } - @Override public FavoriteItemType getType() { // TODO Auto-generated method stub return null; } - @Override public boolean isFavoriteFor(Object obj) { // TODO Auto-generated method stub return false; } - @Override public void setName(String newName) { // TODO Auto-generated method stub } - @Override public Object getAdapter(Class adapter) { // TODO Auto-generated method stub return null; diff -r 12372c19f1b0 -r fb430f25c33d org.symbian.tools.wrttools/src/org/symbian/tools/wrttools/builder/FavoritesManager.java --- a/org.symbian.tools.wrttools/src/org/symbian/tools/wrttools/builder/FavoritesManager.java Mon Feb 01 13:24:54 2010 -0800 +++ b/org.symbian.tools.wrttools/src/org/symbian/tools/wrttools/builder/FavoritesManager.java Mon Feb 01 13:26:14 2010 -0800 @@ -148,7 +148,6 @@ } } - @Override public void resourceChanged(IResourceChangeEvent e) { // process events here } diff -r 12372c19f1b0 -r fb430f25c33d org.symbian.tools.wrttools/src/org/symbian/tools/wrttools/builder/Hashset.java --- a/org.symbian.tools.wrttools/src/org/symbian/tools/wrttools/builder/Hashset.java Mon Feb 01 13:24:54 2010 -0800 +++ b/org.symbian.tools.wrttools/src/org/symbian/tools/wrttools/builder/Hashset.java Mon Feb 01 13:26:14 2010 -0800 @@ -27,79 +27,66 @@ // TODO Auto-generated constructor stub } - @Override public boolean add(IFavoriteItem e) { // TODO Auto-generated method stub return false; } - @Override public boolean addAll(Collection c) { // TODO Auto-generated method stub return false; } - @Override public void clear() { // TODO Auto-generated method stub } - @Override public boolean contains(Object o) { // TODO Auto-generated method stub return false; } - @Override public boolean containsAll(Collection c) { // TODO Auto-generated method stub return false; } - @Override public boolean isEmpty() { // TODO Auto-generated method stub return false; } - @Override public Iterator iterator() { // TODO Auto-generated method stub return null; } - @Override public boolean remove(Object o) { // TODO Auto-generated method stub return false; } - @Override public boolean removeAll(Collection c) { // TODO Auto-generated method stub return false; } - @Override public boolean retainAll(Collection c) { // TODO Auto-generated method stub return false; } - @Override public int size() { // TODO Auto-generated method stub return 0; } - @Override public Object[] toArray() { // TODO Auto-generated method stub return null; } - @Override public T[] toArray(T[] a) { // TODO Auto-generated method stub return null; diff -r 12372c19f1b0 -r fb430f25c33d org.symbian.tools.wrttools/src/org/symbian/tools/wrttools/builder/MyResourceChangeReporter.java --- a/org.symbian.tools.wrttools/src/org/symbian/tools/wrttools/builder/MyResourceChangeReporter.java Mon Feb 01 13:24:54 2010 -0800 +++ b/org.symbian.tools.wrttools/src/org/symbian/tools/wrttools/builder/MyResourceChangeReporter.java Mon Feb 01 13:26:14 2010 -0800 @@ -31,7 +31,6 @@ public class MyResourceChangeReporter implements IResourceChangeListener { - @Override // TODO Auto-generated method stub public void resourceChanged(IResourceChangeEvent event) { IResource res = event.getResource(); @@ -84,7 +83,6 @@ class DeltaPrinter implements IResourceDeltaVisitor { - @Override public boolean visit(IResourceDelta delta) throws CoreException{ IResource res = delta.getResource(); switch (delta.getKind()) { diff -r 12372c19f1b0 -r fb430f25c33d org.symbian.tools.wrttools/src/org/symbian/tools/wrttools/builder/PropertiesAuditorNature.java --- a/org.symbian.tools.wrttools/src/org/symbian/tools/wrttools/builder/PropertiesAuditorNature.java Mon Feb 01 13:24:54 2010 -0800 +++ b/org.symbian.tools.wrttools/src/org/symbian/tools/wrttools/builder/PropertiesAuditorNature.java Mon Feb 01 13:26:14 2010 -0800 @@ -38,7 +38,6 @@ private IProject project; private static final String NATURE_ID = "org.eclipse.wst.jsdt.core.jsNature"; - @Override public void configure() throws CoreException { // TODO Auto-generated method stub PropertiesFileAuditor.addBuilderToProject(project); @@ -60,20 +59,17 @@ } - @Override public void deconfigure() throws CoreException { // TODO Auto-generated method stub PropertiesFileAuditor.removeBuilderFromProject(project); PropertiesFileAuditor.deleteAuditMarkers(project); } - @Override public IProject getProject() { // TODO Auto-generated method stub return project; } - @Override public void setProject(IProject project) { // TODO Auto-generated method stub this.project = project; diff -r 12372c19f1b0 -r fb430f25c33d org.symbian.tools.wrttools/src/org/symbian/tools/wrttools/navigator/WRTNavigatorContentProvider.java --- a/org.symbian.tools.wrttools/src/org/symbian/tools/wrttools/navigator/WRTNavigatorContentProvider.java Mon Feb 01 13:24:54 2010 -0800 +++ b/org.symbian.tools.wrttools/src/org/symbian/tools/wrttools/navigator/WRTNavigatorContentProvider.java Mon Feb 01 13:26:14 2010 -0800 @@ -62,7 +62,6 @@ .getFolder(p1); } - @Override public boolean visit(IResourceDelta delta) throws CoreException { if ((delta.getKind() & (IResourceDelta.ADDED | IResourceDelta.REMOVED)) != 0) { resource = getCommonAncestor(resource, delta.getResource() @@ -75,7 +74,6 @@ private static final class TreeElementsComparator implements Comparator { - @Override public int compare(Object o1, Object o2) { IResource res1 = getResource(o1); IResource res2 = getResource(o2); @@ -119,16 +117,19 @@ } private IResourceChangeListener listener = new IResourceChangeListener() { - @Override public void resourceChanged(IResourceChangeEvent event) { - RootResourceFinder visitor = new RootResourceFinder(); - try { - event.getDelta().accept(visitor); - } catch (CoreException e) { - Activator.log(e); - refreshViewer(null); + IResource refresh = null; + if (event.getDelta() != null) { + RootResourceFinder visitor = new RootResourceFinder(); + try { + event.getDelta().accept(visitor); + } catch (CoreException e) { + Activator.log(e); + refreshViewer(null); + } + refresh = visitor.resource; } - refreshViewer(visitor.resource); + refreshViewer(refresh); } }; private Viewer viewer; @@ -220,7 +221,6 @@ protected void refreshViewer(final IResource resource) { viewer.getControl().getDisplay().asyncExec(new Runnable() { - @Override public void run() { ((TreeViewer) viewer).refresh(resource); } diff -r 12372c19f1b0 -r fb430f25c33d org.symbian.tools.wrttools/src/org/symbian/tools/wrttools/util/CompoundValidator.java --- a/org.symbian.tools.wrttools/src/org/symbian/tools/wrttools/util/CompoundValidator.java Mon Feb 01 13:24:54 2010 -0800 +++ b/org.symbian.tools.wrttools/src/org/symbian/tools/wrttools/util/CompoundValidator.java Mon Feb 01 13:26:14 2010 -0800 @@ -38,7 +38,6 @@ System.arraycopy(validators, 0, this.validators, 1, validators.length); } - @Override public IStatus validate(Object value) { IStatus status = Status.OK_STATUS; diff -r 12372c19f1b0 -r fb430f25c33d org.symbian.tools.wrttools/src/org/symbian/tools/wrttools/util/CoreUtil.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/org.symbian.tools.wrttools/src/org/symbian/tools/wrttools/util/CoreUtil.java Mon Feb 01 13:26:14 2010 -0800 @@ -0,0 +1,18 @@ +package org.symbian.tools.wrttools.util; + +import org.eclipse.core.runtime.Platform; + +public class CoreUtil { + + public static boolean isWindows() { + return "windows".equals(Platform.getOS()); + } + + public static boolean isMac() { + return "macosx".equals(Platform.getOS()); + } + + public static boolean isLinux() { + return "linux".equals(Platform.getOS()); + } +} diff -r 12372c19f1b0 -r fb430f25c33d org.symbian.tools.wrttools/src/org/symbian/tools/wrttools/util/ProjectUtils.java --- a/org.symbian.tools.wrttools/src/org/symbian/tools/wrttools/util/ProjectUtils.java Mon Feb 01 13:24:54 2010 -0800 +++ b/org.symbian.tools.wrttools/src/org/symbian/tools/wrttools/util/ProjectUtils.java Mon Feb 01 13:26:14 2010 -0800 @@ -19,20 +19,28 @@ package org.symbian.tools.wrttools.util; import java.io.File; +import java.io.FileInputStream; import java.io.IOException; import java.net.URI; +import java.text.MessageFormat; +import java.util.zip.ZipEntry; import java.util.zip.ZipInputStream; import javax.swing.filechooser.FileSystemView; +import org.eclipse.core.resources.IContainer; import org.eclipse.core.resources.IFile; +import org.eclipse.core.resources.IFolder; import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IProjectDescription; +import org.eclipse.core.resources.IResource; import org.eclipse.core.resources.IWorkspace; import org.eclipse.core.resources.ResourcesPlugin; import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.NullProgressMonitor; +import org.eclipse.core.runtime.Path; import org.eclipse.core.runtime.SubProgressMonitor; import org.eclipse.wst.jsdt.internal.ui.wizards.buildpaths.BuildPathsBlock; import org.eclipse.wst.validation.ValidationFramework; @@ -45,9 +53,19 @@ public static final String PREVIEW_FRAME_FILE = "wrt_preview_frame.html"; public static final String PREVIEW_MAIN_FILE = "wrt_preview_main.html"; + private static boolean isDefaultProjectLocation(URI uri) { + File file = new File(uri); + IPath project = new Path(file.getAbsolutePath()); + IPath workspace = ResourcesPlugin.getWorkspace().getRoot() + .getLocation(); + return workspace.isPrefixOf(project); + } + @SuppressWarnings("restriction") public static IProject createWrtProject(String name, URI uri, IProgressMonitor monitor) throws CoreException { + uri = isDefaultProjectLocation(uri) ? null + : uri; monitor.beginTask("Create project resources", 20); IWorkspace workspace = ResourcesPlugin.getWorkspace(); IProject project = workspace.getRoot().getProject(name); @@ -129,16 +147,20 @@ File dotProjectFile = null; boolean hasPreviewer = false; boolean hasFrame = false; - + for (int i = 0; i < contents.length; i++) { File file = contents[i]; - if (file.isFile() && file.getName().equals(IProjectDescription.DESCRIPTION_FILE_NAME)) { + if (file.isFile() + && file.getName().equals( + IProjectDescription.DESCRIPTION_FILE_NAME)) { dotProjectFile = file; } - if (file.isFile() && PREVIEW_FRAME_FILE.equalsIgnoreCase(file.getName())) { + if (file.isFile() + && PREVIEW_FRAME_FILE.equalsIgnoreCase(file.getName())) { hasFrame = true; } - if (file.isDirectory() && PREVIEW_FOLDER.equalsIgnoreCase(file.getName())) { + if (file.isDirectory() + && PREVIEW_FOLDER.equalsIgnoreCase(file.getName())) { hasPreviewer = true; } } @@ -147,4 +169,35 @@ } return dotProjectFile; } + + public static void unzip(String archiveFile, IContainer location, int trimSegments, + IProgressMonitor progressMonitor) throws IOException, CoreException { + progressMonitor.beginTask(MessageFormat.format("Unpacking {0}", + archiveFile), IProgressMonitor.UNKNOWN); + ZipInputStream stream = new ZipInputStream(new FileInputStream( + archiveFile)); + + try { + ZipEntry nextEntry; + while ((nextEntry = stream.getNextEntry()) != null) { + IPath p = new Path(nextEntry.getName()).removeFirstSegments(trimSegments); + if (!nextEntry.isDirectory()) { + IFile file = location.getFile(p); + checkParent(file.getParent()); + file.create(new NonClosingStream(stream), false, + new SubProgressMonitor(progressMonitor, 1)); + } + } + } finally { + stream.close(); + } + progressMonitor.done(); + } + + private static void checkParent(IContainer parent) throws CoreException { + if (parent.getType() == IResource.FOLDER && !parent.exists()) { + checkParent(parent.getParent()); + ((IFolder) parent).create(false, true, new NullProgressMonitor()); + } + } } diff -r 12372c19f1b0 -r fb430f25c33d org.symbian.tools.wrttools/src/org/symbian/tools/wrttools/util/RegexpValidator.java --- a/org.symbian.tools.wrttools/src/org/symbian/tools/wrttools/util/RegexpValidator.java Mon Feb 01 13:24:54 2010 -0800 +++ b/org.symbian.tools.wrttools/src/org/symbian/tools/wrttools/util/RegexpValidator.java Mon Feb 01 13:26:14 2010 -0800 @@ -38,7 +38,6 @@ this.pattern = Pattern.compile(pattern); } - @Override public IStatus validate(Object value) { String string = value.toString(); Matcher matcher = pattern.matcher(string); diff -r 12372c19f1b0 -r fb430f25c33d org.symbian.tools.wrttools/src/org/symbian/tools/wrttools/wizards/AbstractDataBindingPage.java --- a/org.symbian.tools.wrttools/src/org/symbian/tools/wrttools/wizards/AbstractDataBindingPage.java Mon Feb 01 13:24:54 2010 -0800 +++ b/org.symbian.tools.wrttools/src/org/symbian/tools/wrttools/wizards/AbstractDataBindingPage.java Mon Feb 01 13:26:14 2010 -0800 @@ -49,7 +49,6 @@ this.propertyName = propertyName; } - @Override public IStatus validate(Object value) { if (isActive()) { if (value == null || value.toString().trim().length() == 0) { diff -r 12372c19f1b0 -r fb430f25c33d org.symbian.tools.wrttools/src/org/symbian/tools/wrttools/wizards/AptanaProjectsImportWizard.java --- a/org.symbian.tools.wrttools/src/org/symbian/tools/wrttools/wizards/AptanaProjectsImportWizard.java Mon Feb 01 13:24:54 2010 -0800 +++ b/org.symbian.tools.wrttools/src/org/symbian/tools/wrttools/wizards/AptanaProjectsImportWizard.java Mon Feb 01 13:26:14 2010 -0800 @@ -61,12 +61,10 @@ addPage(mainPage); } - @Override public void init(IWorkbench workbench, IStructuredSelection selection) { // Do nothing } - @Override public void setInitializationData(IConfigurationElement config, String propertyName, Object data) throws CoreException { this.config = config; diff -r 12372c19f1b0 -r fb430f25c33d org.symbian.tools.wrttools/src/org/symbian/tools/wrttools/wizards/FlickrProjectDetailsWizardPage.java --- a/org.symbian.tools.wrttools/src/org/symbian/tools/wrttools/wizards/FlickrProjectDetailsWizardPage.java Mon Feb 01 13:24:54 2010 -0800 +++ b/org.symbian.tools.wrttools/src/org/symbian/tools/wrttools/wizards/FlickrProjectDetailsWizardPage.java Mon Feb 01 13:26:14 2010 -0800 @@ -39,7 +39,6 @@ } public static final class Factory implements IWizardPageFactory { - @Override public WRTProjectDetailsWizardPage createPage(WizardContext context, DataBindingContext bindingContext) { return new FlickrProjectDetailsWizardPage(context, bindingContext); diff -r 12372c19f1b0 -r fb430f25c33d org.symbian.tools.wrttools/src/org/symbian/tools/wrttools/wizards/RssReaderProjectDetailsWizardPage.java --- a/org.symbian.tools.wrttools/src/org/symbian/tools/wrttools/wizards/RssReaderProjectDetailsWizardPage.java Mon Feb 01 13:24:54 2010 -0800 +++ b/org.symbian.tools.wrttools/src/org/symbian/tools/wrttools/wizards/RssReaderProjectDetailsWizardPage.java Mon Feb 01 13:26:14 2010 -0800 @@ -46,7 +46,6 @@ } public static final class Factory implements IWizardPageFactory { - @Override public WRTProjectDetailsWizardPage createPage(WizardContext context, DataBindingContext bindingContext) { return new RssReaderProjectDetailsWizardPage(context, bindingContext); diff -r 12372c19f1b0 -r fb430f25c33d org.symbian.tools.wrttools/src/org/symbian/tools/wrttools/wizards/WRTProjectDetailsWizardPage.java --- a/org.symbian.tools.wrttools/src/org/symbian/tools/wrttools/wizards/WRTProjectDetailsWizardPage.java Mon Feb 01 13:24:54 2010 -0800 +++ b/org.symbian.tools.wrttools/src/org/symbian/tools/wrttools/wizards/WRTProjectDetailsWizardPage.java Mon Feb 01 13:26:14 2010 -0800 @@ -40,7 +40,6 @@ // Subclasses will override } - @Override public void createControl(Composite parent) { Composite root = new Composite(parent, SWT.NONE); WizardPageSupport.create(this, bindingContext); diff -r 12372c19f1b0 -r fb430f25c33d org.symbian.tools.wrttools/src/org/symbian/tools/wrttools/wizards/WRTProjectFilesWizardPage.java --- a/org.symbian.tools.wrttools/src/org/symbian/tools/wrttools/wizards/WRTProjectFilesWizardPage.java Mon Feb 01 13:24:54 2010 -0800 +++ b/org.symbian.tools.wrttools/src/org/symbian/tools/wrttools/wizards/WRTProjectFilesWizardPage.java Mon Feb 01 13:26:14 2010 -0800 @@ -30,7 +30,6 @@ super(context, bindingContext, "WRTApplicationFiles", "New WRT Application Project", null, "Specify Symbian WRT application file names"); } - @Override public void createControl(Composite parent) { Composite root = new Composite(parent, SWT.NONE); WizardPageSupport.create(this, bindingContext); diff -r 12372c19f1b0 -r fb430f25c33d org.symbian.tools.wrttools/src/org/symbian/tools/wrttools/wizards/WRTProjectTemplateWizardPage.java --- a/org.symbian.tools.wrttools/src/org/symbian/tools/wrttools/wizards/WRTProjectTemplateWizardPage.java Mon Feb 01 13:24:54 2010 -0800 +++ b/org.symbian.tools.wrttools/src/org/symbian/tools/wrttools/wizards/WRTProjectTemplateWizardPage.java Mon Feb 01 13:26:14 2010 -0800 @@ -71,7 +71,6 @@ setDescription("Select template that will be used to populate your new project"); } - @Override public void createControl(Composite parent) { ProjectTemplate[] allTemplates = ProjectTemplate.getAllTemplates(); @@ -99,8 +98,6 @@ templatesData.bottom = new FormAttachment(70, 0); templates.getControl().setLayoutData(templatesData); templates.addSelectionChangedListener(new ISelectionChangedListener() { - - @Override public void selectionChanged(SelectionChangedEvent event) { IStructuredSelection selection = (IStructuredSelection)event.getSelection(); final ProjectTemplate @@ -109,7 +106,6 @@ } }); templates.addDoubleClickListener(new IDoubleClickListener() { - @Override public void doubleClick(DoubleClickEvent arg0) { switchWizardPage(); } @@ -143,7 +139,6 @@ protected void switchWizardPage() { Display display = getShell().getDisplay(); display.asyncExec(new Runnable() { - @Override public void run() { IWizardPage nextPage = getWizard().getNextPage(WRTProjectTemplateWizardPage.this); getContainer().showPage(nextPage); diff -r 12372c19f1b0 -r fb430f25c33d org.symbian.tools.wrttools/src/org/symbian/tools/wrttools/wizards/WgzImportWizard.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/org.symbian.tools.wrttools/src/org/symbian/tools/wrttools/wizards/WgzImportWizard.java Mon Feb 01 13:26:14 2010 -0800 @@ -0,0 +1,113 @@ +package org.symbian.tools.wrttools.wizards; + +import java.io.IOException; +import java.lang.reflect.InvocationTargetException; +import java.net.URI; + +import org.eclipse.core.resources.IFile; +import org.eclipse.core.resources.IProject; +import org.eclipse.core.resources.IResource; +import org.eclipse.core.resources.IWorkspaceRunnable; +import org.eclipse.core.resources.ResourcesPlugin; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IAdaptable; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.Status; +import org.eclipse.core.runtime.SubProgressMonitor; +import org.eclipse.jface.operation.IRunnableWithProgress; +import org.eclipse.jface.viewers.IStructuredSelection; +import org.eclipse.jface.wizard.Wizard; +import org.eclipse.ui.IImportWizard; +import org.eclipse.ui.IWorkbench; +import org.eclipse.ui.statushandlers.StatusManager; +import org.symbian.tools.wrttools.Activator; +import org.symbian.tools.wrttools.util.ProjectUtils; + +public class WgzImportWizard extends Wizard implements IImportWizard { + private IFile file; + private WgzImportWizardPage page; + + public WgzImportWizard() { + setWindowTitle("Import WRT Application Archive"); + setNeedsProgressMonitor(true); + } + + @Override + public void addPages() { + page = new WgzImportWizardPage(file); + addPage(page); + } + + private void createProject(String archiveName, String projectName, URI uri, + IProgressMonitor monitor) throws CoreException { + monitor.beginTask("Importing WRT application archive", 50); + // 1. Create project + IProject project = ProjectUtils.createWrtProject(projectName, uri, + new SubProgressMonitor(monitor, 10)); + + // 2. Unpack archive + try { + ProjectUtils.unzip(archiveName, project, 1, new SubProgressMonitor( + monitor, 40)); + } catch (IOException e) { + new CoreException(new Status(IStatus.ERROR, Activator.PLUGIN_ID, + "Archive unpacking failed", e)); + } + monitor.done(); + } + + @Override + public boolean performFinish() { + try { + final String projectName = page.getProjectName(); + final URI uri = page.getLocationURI(); + final String archiveName = page.getArchiveFile(); + getContainer().run(true, true, new IRunnableWithProgress() { + + public void run(IProgressMonitor monitor) + throws InvocationTargetException, InterruptedException { + try { + ResourcesPlugin.getWorkspace().run( + new IWorkspaceRunnable() { + + public void run(IProgressMonitor monitor) + throws CoreException { + createProject(archiveName, projectName, + uri, monitor); + } + + }, monitor); + } catch (CoreException e) { + StatusManager.getManager().handle(e.getStatus(), + StatusManager.SHOW); + } + } + }); + } catch (InvocationTargetException e) { + Activator.log(e); + } catch (InterruptedException e) { + Activator.log(e); + } + return true; + } + + public void init(IWorkbench workbench, IStructuredSelection selection) { + file = null; + if (selection instanceof IStructuredSelection && !selection.isEmpty()) { + Object element = ((IStructuredSelection) selection) + .getFirstElement(); + if (element instanceof IAdaptable) { + IResource resource = (IResource) ((IAdaptable) element) + .getAdapter(IResource.class); + if (resource != null + && resource.getType() == IResource.FILE + && "wgz".equalsIgnoreCase(resource + .getProjectRelativePath().getFileExtension())) { + file = (IFile) resource; + } + } + } + } + +} diff -r 12372c19f1b0 -r fb430f25c33d org.symbian.tools.wrttools/src/org/symbian/tools/wrttools/wizards/WgzImportWizardPage.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/org.symbian.tools.wrttools/src/org/symbian/tools/wrttools/wizards/WgzImportWizardPage.java Mon Feb 01 13:26:14 2010 -0800 @@ -0,0 +1,451 @@ +package org.symbian.tools.wrttools.wizards; + +import java.io.File; +import java.net.URI; +import java.text.MessageFormat; + +import org.eclipse.core.resources.IFile; +import org.eclipse.core.resources.IProject; +import org.eclipse.core.resources.IResource; +import org.eclipse.core.resources.IWorkspace; +import org.eclipse.core.resources.ResourcesPlugin; +import org.eclipse.core.runtime.IPath; +import org.eclipse.core.runtime.IStatus; +import org.eclipse.core.runtime.Path; +import org.eclipse.jface.dialogs.Dialog; +import org.eclipse.jface.layout.GridDataFactory; +import org.eclipse.jface.viewers.IStructuredSelection; +import org.eclipse.jface.wizard.WizardPage; +import org.eclipse.swt.SWT; +import org.eclipse.swt.events.ModifyEvent; +import org.eclipse.swt.events.ModifyListener; +import org.eclipse.swt.events.SelectionAdapter; +import org.eclipse.swt.events.SelectionEvent; +import org.eclipse.swt.layout.GridData; +import org.eclipse.swt.layout.GridLayout; +import org.eclipse.swt.widgets.Button; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.swt.widgets.Event; +import org.eclipse.swt.widgets.FileDialog; +import org.eclipse.swt.widgets.Label; +import org.eclipse.swt.widgets.Listener; +import org.eclipse.swt.widgets.Text; +import org.eclipse.ui.IWorkingSet; +import org.eclipse.ui.PlatformUI; +import org.eclipse.ui.dialogs.WorkingSetGroup; +import org.eclipse.ui.internal.ide.IDEWorkbenchMessages; +import org.eclipse.ui.internal.ide.IDEWorkbenchPlugin; +import org.eclipse.ui.internal.ide.IIDEHelpContextIds; +import org.eclipse.ui.internal.ide.dialogs.ProjectContentsLocationArea; +import org.eclipse.ui.internal.ide.dialogs.ProjectContentsLocationArea.IErrorMessageReporter; + +public class WgzImportWizardPage extends WizardPage { + private final IFile file; + + protected WgzImportWizardPage(IFile file) { + super("ImportWgz"); + this.file = file; + setTitle("Import WGZ Archive"); + setDescription("Import WGZ archive as a new WRT application project"); + setPageComplete(false); + } + + public void createControl(Composite parent) { + Composite composite = new Composite(parent, SWT.NULL); + + initializeDialogUnits(parent); + + PlatformUI.getWorkbench().getHelpSystem().setHelp(composite, + IIDEHelpContextIds.NEW_PROJECT_WIZARD_PAGE); + + composite.setLayout(new GridLayout()); + composite.setLayoutData(new GridData(GridData.FILL_BOTH)); + + createProjectNameGroup(composite); + locationArea = new ProjectContentsLocationArea(getErrorReporter(), + composite); + if (initialProjectFieldValue != null) { + locationArea.updateProjectName(initialProjectFieldValue); + } + + // Scale the button based on the rest of the dialog + setButtonLayoutData(locationArea.getBrowseButton()); + + if (file != null) { + wgzName.setText(file.getLocation().toOSString()); + } + + setPageComplete(validatePage()); + // Show description on opening + setErrorMessage(null); + setMessage(null); + setControl(composite); + Dialog.applyDialogFont(composite); + + setControl(composite); + } + + // initial value stores + private String initialProjectFieldValue; + + // widgets + Text projectNameField; + + private Listener nameModifyListener = new Listener() { + public void handleEvent(Event e) { + setLocationForSelection(); + boolean valid = validatePage(); + setPageComplete(valid); + + } + }; + + private ProjectContentsLocationArea locationArea; + private WorkingSetGroup workingSetGroup; + + // constants + private static final int SIZING_TEXT_FIELD_WIDTH = 250; + + private Text wgzName; + + /** + * Create a working set group for this page. This method can only be called + * once. + * + * @param composite + * the composite in which to create the group + * @param selection + * the current workbench selection + * @param supportedWorkingSetTypes + * an array of working set type IDs that will restrict what types + * of working sets can be chosen in this group + * @return the created group. If this method has been called previously the + * original group will be returned. + * @since 3.4 + */ + public WorkingSetGroup createWorkingSetGroup(Composite composite, + IStructuredSelection selection, String[] supportedWorkingSetTypes) { + if (workingSetGroup != null) + return workingSetGroup; + workingSetGroup = new WorkingSetGroup(composite, selection, + supportedWorkingSetTypes); + return workingSetGroup; + } + + /** + * Get an error reporter for the receiver. + * + * @return IErrorMessageReporter + */ + private IErrorMessageReporter getErrorReporter() { + return new IErrorMessageReporter() { + /* + * (non-Javadoc) + * + * @see + * org.eclipse.ui.internal.ide.dialogs.ProjectContentsLocationArea + * .IErrorMessageReporter#reportError(java.lang.String) + */ + public void reportError(String errorMessage, boolean infoOnly) { + if (infoOnly) { + setMessage(errorMessage, IStatus.INFO); + setErrorMessage(null); + } else + setErrorMessage(errorMessage); + boolean valid = errorMessage == null; + if (valid) { + valid = validatePage(); + } + + setPageComplete(valid); + } + }; + } + + /** + * Creates the project name specification controls. + * + * @param parent + * the parent composite + */ + private final void createProjectNameGroup(Composite parent) { + // project specification group + Composite projectGroup = new Composite(parent, SWT.NONE); + GridLayout layout = new GridLayout(); + layout.numColumns = 2; + projectGroup.setLayout(layout); + projectGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); + + Label label = new Label(projectGroup, SWT.NONE); + label.setText("WGZ archive:"); + + Composite buttonText = new Composite(projectGroup, SWT.NONE); + + buttonText.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); + + GridLayout gridLayout = new GridLayout(2, false); + gridLayout.marginWidth = 0; + gridLayout.marginHeight = 0; + buttonText.setLayout(gridLayout); + + wgzName = new Text(buttonText, SWT.BORDER); + wgzName.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); + wgzName.addModifyListener(new ModifyListener() { + public void modifyText(ModifyEvent e) { + String val = wgzName.getData() != null ? wgzName.getData() + .toString() : ""; + String name = wgzName.getText().trim(); + updateWgzName(val, name); + wgzName.setData(name); + setPageComplete(validatePage()); + } + }); + Button browse = new Button(buttonText, SWT.NONE); + browse.setText("Browse..."); + browse.addSelectionListener(new SelectionAdapter() { + @Override + public void widgetSelected(SelectionEvent e) { + browse(); + } + }); + + Label separator = new Label(projectGroup, SWT.NONE); + GridDataFactory.generate(separator, 2, 2); + + // new project label + Label projectLabel = new Label(projectGroup, SWT.NONE); + projectLabel + .setText(IDEWorkbenchMessages.WizardNewProjectCreationPage_nameLabel); + projectLabel.setFont(parent.getFont()); + + // new project name entry field + projectNameField = new Text(projectGroup, SWT.BORDER); + GridData data = new GridData(GridData.FILL_HORIZONTAL); + data.widthHint = SIZING_TEXT_FIELD_WIDTH; + projectNameField.setLayoutData(data); + projectNameField.setFont(parent.getFont()); + + // Set the initial value first before listener + // to avoid handling an event during the creation. + if (initialProjectFieldValue != null) { + projectNameField.setText(initialProjectFieldValue); + } + projectNameField.addListener(SWT.Modify, nameModifyListener); + } + + protected void browse() { + FileDialog fileDialog = new FileDialog(getShell(), SWT.OPEN); + fileDialog.setFilterPath(wgzName.getText()); + fileDialog.setFilterExtensions(new String[] {"*.wgz", "*.*"} ); + fileDialog.setFilterNames(new String[] {"WRT Archive (wgz)", "All Files"} ); + String res = fileDialog.open(); + if (res != null) { + updateWgzName(wgzName.getText().trim(), res); + wgzName.setText(res); + setPageComplete(validatePage()); + } + } + + private void updateWgzName(String oldValue, String newValue) { + String project = projectNameField.getText().trim(); + if (project.length() == 0 || project.equals(new Path(oldValue).removeFileExtension().lastSegment())) { + String projectName = new Path(newValue).removeFileExtension().lastSegment(); + projectNameField.setText(projectName); + locationArea.updateProjectName(projectName); + } + } + + /** + * Returns the current project location path as entered by the user, or its + * anticipated initial value. Note that if the default has been returned the + * path in a project description used to create a project should not be set. + * + * @return the project location path or its anticipated initial value. + */ + public IPath getLocationPath() { + return new Path(locationArea.getProjectLocation()); + } + + /** + * /** Returns the current project location URI as entered by the user, or + * null if a valid project location has not been entered. + * + * @return the project location URI, or null + * @since 3.2 + */ + public URI getLocationURI() { + return locationArea.getProjectLocationURI(); + } + + /** + * Creates a project resource handle for the current project name field + * value. The project handle is created relative to the workspace root. + *

+ * This method does not create the project resource; this is the + * responsibility of IProject::create invoked by the new + * project resource wizard. + *

+ * + * @return the new project resource handle + */ + public IProject getProjectHandle() { + return ResourcesPlugin.getWorkspace().getRoot().getProject( + getProjectName()); + } + + /** + * Returns the current project name as entered by the user, or its + * anticipated initial value. + * + * @return the project name, its anticipated initial value, or + * null if no project name is known + */ + public String getProjectName() { + if (projectNameField == null) { + return initialProjectFieldValue; + } + + return getProjectNameFieldValue(); + } + + /** + * Returns the value of the project name field with leading and trailing + * spaces removed. + * + * @return the project name in the field + */ + private String getProjectNameFieldValue() { + if (projectNameField == null) { + return ""; //$NON-NLS-1$ + } + + return projectNameField.getText().trim(); + } + + /** + * Sets the initial project name that this page will use when created. The + * name is ignored if the createControl(Composite) method has already been + * called. Leading and trailing spaces in the name are ignored. Providing + * the name of an existing project will not necessarily cause the wizard to + * warn the user. Callers of this method should first check if the project + * name passed already exists in the workspace. + * + * @param name + * initial project name for this page + * + * @see IWorkspace#validateName(String, int) + * + */ + public void setInitialProjectName(String name) { + if (name == null) { + initialProjectFieldValue = null; + } else { + initialProjectFieldValue = name.trim(); + if (locationArea != null) { + locationArea.updateProjectName(name.trim()); + } + } + } + + /** + * Set the location to the default location if we are set to useDefaults. + */ + void setLocationForSelection() { + locationArea.updateProjectName(getProjectNameFieldValue()); + } + + /** + * Returns whether this page's controls currently all contain valid values. + * + * @return true if all controls are valid, and + * false if at least one is invalid + */ + protected boolean validatePage() { + IWorkspace workspace = IDEWorkbenchPlugin.getPluginWorkspace(); + + String archive = wgzName.getText().trim(); + + if (archive.equals("")) { + setErrorMessage(null); + setMessage("Archive name must be specified"); + return false; + } + + File f = new File(archive); + if (!f.isFile()) { + setErrorMessage(MessageFormat.format("{0} is not a valid WRT archive", archive)); + return false; + } + + String projectFieldContents = getProjectNameFieldValue(); + if (projectFieldContents.equals("")) { //$NON-NLS-1$ + setErrorMessage(null); + setMessage(IDEWorkbenchMessages.WizardNewProjectCreationPage_projectNameEmpty); + return false; + } + + IStatus nameStatus = workspace.validateName(projectFieldContents, + IResource.PROJECT); + if (!nameStatus.isOK()) { + setErrorMessage(nameStatus.getMessage()); + return false; + } + + IProject handle = getProjectHandle(); + if (handle.exists()) { + setErrorMessage(IDEWorkbenchMessages.WizardNewProjectCreationPage_projectExistsMessage); + return false; + } + + IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject( + getProjectNameFieldValue()); + locationArea.setExistingProject(project); + + String validLocationMessage = locationArea.checkValidLocation(); + if (validLocationMessage != null) { // there is no destination location + // given + setErrorMessage(validLocationMessage); + return false; + } + + setErrorMessage(null); + setMessage(null); + return true; + } + + /* + * see @DialogPage.setVisible(boolean) + */ + public void setVisible(boolean visible) { + super.setVisible(visible); + if (visible) { + projectNameField.setFocus(); + } + } + + /** + * Returns the useDefaults. + * + * @return boolean + */ + public boolean useDefaults() { + return locationArea.isDefault(); + } + + /** + * Return the selected working sets, if any. If this page is not configured + * to interact with working sets this will be an empty array. + * + * @return the selected working sets + * @since 3.4 + */ + public IWorkingSet[] getSelectedWorkingSets() { + return workingSetGroup == null ? new IWorkingSet[0] : workingSetGroup + .getSelectedWorkingSets(); + } + + public String getArchiveFile() { + return wgzName.getText().trim(); + } + +} diff -r 12372c19f1b0 -r fb430f25c33d org.symbian.tools.wrttools/src/org/symbian/tools/wrttools/wizards/WrtWidgetWizard.java --- a/org.symbian.tools.wrttools/src/org/symbian/tools/wrttools/wizards/WrtWidgetWizard.java Mon Feb 01 13:24:54 2010 -0800 +++ b/org.symbian.tools.wrttools/src/org/symbian/tools/wrttools/wizards/WrtWidgetWizard.java Mon Feb 01 13:26:14 2010 -0800 @@ -43,10 +43,8 @@ import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IConfigurationElement; import org.eclipse.core.runtime.IExecutableExtension; -import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IStatus; -import org.eclipse.core.runtime.Path; import org.eclipse.core.runtime.Status; import org.eclipse.core.runtime.SubProgressMonitor; import org.eclipse.jface.operation.IRunnableWithProgress; @@ -75,11 +73,9 @@ setWindowTitle("New WRT Widget"); } - @Override public boolean performFinish() { try { getContainer().run(true, true, new IRunnableWithProgress() { - @Override public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException { action(monitor); @@ -97,7 +93,6 @@ protected void action(IProgressMonitor monitor) { try { ResourcesPlugin.getWorkspace().run(new IWorkspaceRunnable() { - @Override public void run(IProgressMonitor monitor) throws CoreException { createAndInitProject(monitor); } @@ -192,7 +187,6 @@ f.create(contents, true, new SubProgressMonitor(monitor, 1)); } - @Override public void init(IWorkbench workbench, IStructuredSelection selection) { context = new WizardContext(); bindingContext = new DataBindingContext(); @@ -232,8 +226,7 @@ public IWizardPage getNextPage(IWizardPage page) { if (page == resourcePage) { context.setProjectName(resourcePage.getProjectName()); - context.setProjectUri(isDefaultProjectLocation() ? null - : resourcePage.getLocationURI()); + context.setProjectUri(resourcePage.getLocationURI()); } if (page == templatesPage) { ProjectTemplate template = context.getTemplate(); @@ -254,14 +247,6 @@ return super.getNextPage(page); } - private boolean isDefaultProjectLocation() { - IPath project = resourcePage.getLocationPath(); - IPath workspace = ResourcesPlugin.getWorkspace().getRoot() - .getLocation(); - return workspace.isPrefixOf(project); - } - - @Override public void setInitializationData(IConfigurationElement config, String propertyName, Object data) throws CoreException { this.config = config; diff -r 12372c19f1b0 -r fb430f25c33d scripts/genBuildScripts.xml --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/scripts/genBuildScripts.xml Mon Feb 01 13:26:14 2010 -0800 @@ -0,0 +1,11 @@ + + + + + + + diff -r 12372c19f1b0 -r fb430f25c33d scripts/hg.sh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/scripts/hg.sh Mon Feb 01 13:26:14 2010 -0800 @@ -0,0 +1,9 @@ +#!/bin/sh + +REPO_DIR=/usr/hg/wrttools/ +LOG_DIR=/var/log/mercurial +HG_CMD=/usr/local/bin/hg + +cd $REPO_DIR +${HG_CMD} serve -d -A ${LOG_DIR}/accesslog$$ -E ${LOG_DIR}/errorlog$$ +# ${HG_CMD} serve diff -r 12372c19f1b0 -r fb430f25c33d scripts/hudson.sh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/scripts/hudson.sh Mon Feb 01 13:26:14 2010 -0800 @@ -0,0 +1,5 @@ +#!/bin/sh + +export PATH=.:/usr/java/jdk1.6.0_18/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games + +java -jar ~symbian/java/hudson.war diff -r 12372c19f1b0 -r fb430f25c33d scripts/runAnt.sh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/scripts/runAnt.sh Mon Feb 01 13:26:14 2010 -0800 @@ -0,0 +1,16 @@ +#!/bin/sh + +set -x + +PDE_ECLIPSE_DIR=/usr/eclipse +PDE_VER=3.5.1.R35x_20090820 +EQUINOX_VER=1.0.201.R35x_v20090715 +WS_DIR=$1 +BUILD_CONF_DIR=${WS_DIR}/org.symbian.tools.wrttools.feature +JAVA_CMD=/usr/java/jdk1.6.0_18/bin/java +BUILD_FILE=${PDE_ECLIPSE_DIR}/plugins/org.eclipse.pde.build_${PDE_VER}/scripts/productBuild/productBuild.xml +SOURCE_LEVEL=1.5 + +cd ${BUILD_CONF_DIR} +${JAVA_CMD} -Dsource=${SOURCE_LEVEL} -Dtarget=${SOURCE_LEVEL} -jar ${PDE_ECLIPSE_DIR}/plugins/org.eclipse.equinox.launcher_${EQUINOX_VER}.jar -application org.eclipse.ant.core.antRunner -buildfile build.xml + diff -r 12372c19f1b0 -r fb430f25c33d scripts/runGen.sh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/scripts/runGen.sh Mon Feb 01 13:26:14 2010 -0800 @@ -0,0 +1,14 @@ +#!/bin/sh + +set -x + +ECLIPSE_DIR=/usr/eclipse +PDE_VER=3.5.1.R35x_20090820 +EQUINOX_VER=1.0.201.R35x_v20090715 +JAVA_CMD=/usr/java/jdk1.6.0_18/bin/java +ANT_SCRIPT=${1} + +${JAVA_CMD} -jar ${ECLIPSE_DIR}/plugins/org.eclipse.equinox.launcher_${EQUINOX_VER}.jar -application org.eclipse.ant.core.antRunner -buildfile ${ANT_SCRIPT} + + + diff -r 12372c19f1b0 -r fb430f25c33d scripts/shepard.sh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/scripts/shepard.sh Mon Feb 01 13:26:14 2010 -0800 @@ -0,0 +1,35 @@ +#!/bin/sh + +SCRIPTS_DIR=/home/symbian/wrttools/scripts +BUILD_DIR=/home/symbian/scratch/build_dir +DAY_OF_YEAR=`date +%j` +HG_CMD=/usr/local/bin/hg + +export WS_DIR=${BUILD_DIR}/${DAY_OF_YEAR}/workspace/wrttools + +# display date and time +date + +# create build structure + +mkdir -p ${BUILD_DIR}/${DAY_OF_YEAR}/workspace +mkdir -p ${BUILD_DIR}/${DAY_OF_YEAR}/linux +mkdir -p ${BUILD_DIR}/${DAY_OF_YEAR}/win32 +mkdir -p ${BUILD_DIR}/${DAY_OF_YEAR}/macosx + +# check out the code. +cd ${BUILD_DIR}/${DAY_OF_YEAR}/workspace +${HG_CMD} clone http://sym-mrswitch:8000 wrttools + +# generate scripts +${SCRIPTS_DIR}/runGen.sh ${SCRIPTS_DIR}/genBuildScripts.xml + +# build it. +${SCRIPTS_DIR}/runAnt.sh ${WS_DIR} + +# create product + + +# package it up. + +