# HG changeset patch # User Eugene Ostroukhov # Date 1264539312 28800 # Node ID aa2fb3fcc303fa16285fb6054161578afdfaad47 # Parent 2527ecaf66ff493baa592c70946961cdb6ea5ca1 Aptana requirement was removed diff -r 2527ecaf66ff -r aa2fb3fcc303 org.symbian.tools.wrttools.debug.core/src/org/symbian/tools/wrttools/debug/internal/IConstants.java --- a/org.symbian.tools.wrttools.debug.core/src/org/symbian/tools/wrttools/debug/internal/IConstants.java Mon Jan 25 16:59:39 2010 -0800 +++ b/org.symbian.tools.wrttools.debug.core/src/org/symbian/tools/wrttools/debug/internal/IConstants.java Tue Jan 26 12:55:12 2010 -0800 @@ -20,7 +20,7 @@ public interface IConstants { String PREF_NAME_CHROME_LOCATION="chrome.location"; + String PROP_PROJECT_NAME = "projectName"; - String PROP_PROJECT_NAME = "projectName"; - public static final String WRT_PREVIEW_HTML = "wrt_preview_main.html"; + public static final String WRT_PREVIEW_HTML = "wrt_preview_frame.html"; } diff -r 2527ecaf66ff -r aa2fb3fcc303 org.symbian.tools.wrttools.previewer/META-INF/MANIFEST.MF --- a/org.symbian.tools.wrttools.previewer/META-INF/MANIFEST.MF Mon Jan 25 16:59:39 2010 -0800 +++ b/org.symbian.tools.wrttools.previewer/META-INF/MANIFEST.MF Tue Jan 26 12:55:12 2010 -0800 @@ -9,7 +9,9 @@ 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.eclipse.equinox.http.jetty;bundle-version="2.0.0" + org.eclipse.equinox.http.jetty;bundle-version="2.0.0", + org.eclipse.wst.jsdt.core;bundle-version="1.0.201", + org.eclipse.wst.jsdt.ui;bundle-version="1.0.200" Bundle-ActivationPolicy: lazy Bundle-RequiredExecutionEnvironment: JavaSE-1.6 Export-Package: org.symbian.tools.wrttools.previewer, diff -r 2527ecaf66ff -r aa2fb3fcc303 org.symbian.tools.wrttools.previewer/build.properties --- a/org.symbian.tools.wrttools.previewer/build.properties Mon Jan 25 16:59:39 2010 -0800 +++ b/org.symbian.tools.wrttools.previewer/build.properties Tue Jan 26 12:55:12 2010 -0800 @@ -6,4 +6,5 @@ preview/,\ preferences.ini,\ icons/,\ - wrt.xml + wrt.xml,\ + http-content/ diff -r 2527ecaf66ff -r aa2fb3fcc303 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 Jan 25 16:59:39 2010 -0800 +++ b/org.symbian.tools.wrttools.previewer/src/org/symbian/tools/wrttools/previewer/preview/PreviewView.java Tue Jan 26 12:55:12 2010 -0800 @@ -183,7 +183,7 @@ } private boolean isWrtProject(IProject project) { - return project.getFile("wrt_preview_main.html").exists(); + return project.getFile("wrt_preview_frame.html").exists(); } private void loadPreferences() { diff -r 2527ecaf66ff -r aa2fb3fcc303 org.symbian.tools.wrttools.product/launch/WRT IDE (Product).launch --- a/org.symbian.tools.wrttools.product/launch/WRT IDE (Product).launch Mon Jan 25 16:59:39 2010 -0800 +++ b/org.symbian.tools.wrttools.product/launch/WRT IDE (Product).launch Tue Jan 26 12:55:12 2010 -0800 @@ -1,32 +1,32 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff -r 2527ecaf66ff -r aa2fb3fcc303 org.symbian.tools.wrttools/src/org/symbian/tools/wrttools/dialogs/AptanaProjectSelectionDialog.java --- a/org.symbian.tools.wrttools/src/org/symbian/tools/wrttools/dialogs/AptanaProjectSelectionDialog.java Mon Jan 25 16:59:39 2010 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,131 +0,0 @@ -package org.symbian.tools.wrttools.dialogs; - -import java.io.File; -import java.text.MessageFormat; - -import org.eclipse.jface.dialogs.IDialogConstants; -import org.eclipse.jface.dialogs.TitleAreaDialog; -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.Control; -import org.eclipse.swt.widgets.DirectoryDialog; -import org.eclipse.swt.widgets.Label; -import org.eclipse.swt.widgets.Shell; -import org.eclipse.swt.widgets.Text; -import org.symbian.tools.wrttools.util.ProjectUtils; - -public class AptanaProjectSelectionDialog extends TitleAreaDialog { - private File project; - private Text location; - - public AptanaProjectSelectionDialog(Shell parentShell) { - super(parentShell); - } - - @Override - protected void configureShell(Shell newShell) { - super.configureShell(newShell); - newShell.setText("WebRuntime Tools"); - } - - @Override - protected Control createDialogArea(Composite parent) { - setTitle("Select Aptana WRT Project"); - setMessage("Select an Aptana WRT project or Aptana workspace containing one"); - Composite root = (Composite) super.createDialogArea(parent); - - Composite workingArea = new Composite(root, SWT.NONE); - workingArea.setLayoutData(new GridData(GridData.FILL_BOTH)); - - workingArea.setLayout(new GridLayout(2, false)); - Label label = new Label(workingArea, SWT.NONE); - label.setLayoutData(new GridData(GridData.BEGINNING, - GridData.BEGINNING, false, false, 2, 1)); - label.setText("Specify Aptana project or Aptana workspace location:"); - location = new Text(workingArea, SWT.BORDER); - location.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); - location.addModifyListener(new ModifyListener() { - @Override - public void modifyText(ModifyEvent e) { - validate(); - } - }); - - Button browse = new Button(workingArea, SWT.NONE); - browse.setText("Browse..."); - browse.addSelectionListener(new SelectionAdapter() { - @Override - public void widgetSelected(SelectionEvent e) { - browse(); - } - }); - - location.setText(ProjectUtils.getDefaultAptanaLocation()); - - return root; - } - - @Override - protected void createButtonsForButtonBar(Composite parent) { - super.createButtonsForButtonBar(parent); - validate(); - setErrorMessage(null); - } - - protected void browse() { - DirectoryDialog dialog = new DirectoryDialog(getShell()); - dialog.setFilterPath(location.getText()); - dialog.setMessage("Select Aptana WRT project or workspace"); - dialog.setText("Web Runtime Tools"); - - String string = dialog.open(); - if (string != null) { - location.setText(string); - } - } - - protected void validate() { - String error = null; - File f = new File(location.getText()); - if (f.isDirectory()) { - if (!ProjectUtils.isAptanaProject(f)) { - File[] files = f.listFiles(); - f = null; - for (File file : files) { - if (ProjectUtils.isAptanaProject(file)) { - f = file; - break; - } - } - if (f == null) { - error = MessageFormat.format("{0} is not a WRT project or an Aptana workspace containing WRT projects", location.getText()); - } - } - } else { - error = "Specified folder does not exist"; - } - project = f; - setErrorMessage(error); - Button button = getButton(IDialogConstants.OK_ID); - if (button != null) { - button.setEnabled(error == null); - } - } - - @Override - protected void cancelPressed() { - project = null; - super.cancelPressed(); - } - - public File getProject() { - return project; - } -} diff -r 2527ecaf66ff -r aa2fb3fcc303 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 Jan 25 16:59:39 2010 -0800 +++ b/org.symbian.tools.wrttools/src/org/symbian/tools/wrttools/util/ProjectUtils.java Tue Jan 26 12:55:12 2010 -0800 @@ -18,23 +18,15 @@ */ package org.symbian.tools.wrttools.util; -import java.io.BufferedInputStream; +import java.io.ByteArrayInputStream; import java.io.File; -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.io.FileOutputStream; import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; import java.net.URI; -import java.util.zip.ZipEntry; import java.util.zip.ZipInputStream; -import java.util.zip.ZipOutputStream; import javax.swing.filechooser.FileSystemView; import org.eclipse.core.resources.IFile; -import org.eclipse.core.resources.IFolder; import org.eclipse.core.resources.IProject; import org.eclipse.core.resources.IWorkspace; import org.eclipse.core.resources.ResourcesPlugin; @@ -45,24 +37,14 @@ import org.eclipse.core.runtime.NullProgressMonitor; import org.eclipse.core.runtime.Status; import org.eclipse.core.runtime.SubProgressMonitor; -import org.eclipse.jface.window.Window; -import org.eclipse.swt.widgets.Display; -import org.eclipse.ui.PlatformUI; import org.eclipse.ui.statushandlers.StatusManager; import org.eclipse.wst.jsdt.internal.ui.wizards.buildpaths.BuildPathsBlock; -import org.eclipse.wst.sse.core.StructuredModelManager; -import org.eclipse.wst.sse.core.internal.provisional.IModelManager; import org.eclipse.wst.validation.ValidationFramework; -import org.eclipse.wst.xml.core.internal.provisional.document.IDOMDocument; -import org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel; import org.symbian.tools.wrttools.Activator; -import org.symbian.tools.wrttools.dialogs.AptanaProjectSelectionDialog; -import org.w3c.dom.Element; -import org.w3c.dom.NodeList; public class ProjectUtils { private static final String DEFAULT_APTANA_WORKSPACE = "Aptana Studio Workspace"; - private static final String WRT_PREVIEW_MAIN_HTML = "wrt_preview_main.html"; + private static final String WRT_PREVIEW_MAIN_HTML = "wrt_preview_frame.html"; public static final String PREVIEW_FOLDER = "preview"; public static final String PREVIEW_FRAME_FILE = "wrt_preview_frame.html"; @@ -89,23 +71,7 @@ } public static void addPreviewer(IProject project, IPath mainHtml) { - URI archive = getPreviewerArchive(); try { - if (archive != null) { - ZipInputStream stream = new ZipInputStream(archive.toURL().openStream()); - ZipEntry entry; - while ((entry = stream.getNextEntry()) != null) { - if (!entry.isDirectory()) { - copyFile(project, entry.getName(), stream, entry.getSize(), new NullProgressMonitor()); - } else { - IFolder folder = project.getFolder(entry.getName()); - if (!folder.exists()) { - folder.create(false, true, new NullProgressMonitor()); - } - } - stream.closeEntry(); - } - } createPreviewerHomePage(project, mainHtml); } catch (IOException e) { StatusManager.getManager().handle(new Status(IStatus.ERROR, Activator.PLUGIN_ID, "Unable to add previewer to project")); @@ -114,138 +80,11 @@ } } - @SuppressWarnings("restriction") private static void createPreviewerHomePage(IProject project, IPath mainHtml) throws CoreException, IOException { - IFile file = project.getFile(mainHtml + ".html"); - if (file.exists()) { - IFile newFile = project.getFile(WRT_PREVIEW_MAIN_HTML); - file.copy(newFile.getFullPath(), false, new NullProgressMonitor()); - IModelManager modelManager = StructuredModelManager - .getModelManager(); - IDOMModel model = (IDOMModel) modelManager - .getModelForEdit(newFile); - if (model != null) { - try { - addJS(model); - } finally { - model.releaseFromEdit(); - } - } - } - } - - @SuppressWarnings("restriction") - private static void addJS(IDOMModel model) throws IOException, CoreException { - IDOMDocument document = model.getDocument(); - Element documentElement = document.getDocumentElement(); - if (documentElement != null) { - NodeList elementsByTagName = documentElement.getElementsByTagName("head"); - if (elementsByTagName.getLength() == 1) { // We do not want to handle malformed HTMLs - Element head = (Element) elementsByTagName.item(0); - Element script = document.createElement("script"); - script.setAttribute("language", "JavaScript"); - script.setAttribute("type", "text/javascript"); - script.setAttribute("src", "preview/script/lib/loader.js"); - head.insertBefore(script, head.getFirstChild()); - model.save(); - } - } - } - - private static URI getPreviewerArchive() { - File file = getPreviewerZip(); - if (file.isFile()) { - return file.toURI(); - } - Display display = Display.getDefault(); - display.syncExec(new Runnable() { - @Override - public void run() { - importPreviewer(); - } - }); - if (file.isFile()) { - return file.toURI(); - } - return null; - } - - private static File getPreviewerZip() { - return Activator.getDefault().getStateLocation() - .append("previewer.zip").toFile(); - } - - private static void importPreviewer() { - AptanaProjectSelectionDialog dialog = new AptanaProjectSelectionDialog( - PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell()); - int open = dialog.open(); - if (open == Window.OK) { - File project = dialog.getProject(); - try { - zipPreviewer(project); - } catch (IOException e) { - StatusManager - .getManager() - .handle( - new Status( - IStatus.ERROR, - Activator.PLUGIN_ID, - "Failed to create Web Runtime previewer archive.", - e), StatusManager.SHOW); - } - } - } - - private static void zipPreviewer(File project) throws IOException { - ZipOutputStream stream = new ZipOutputStream(new FileOutputStream( - getPreviewerZip())); - try { - zip(new File(project, PREVIEW_FOLDER), stream, PREVIEW_FOLDER + "/"); - zipFile(new File(project, PREVIEW_FRAME_FILE), - PREVIEW_FRAME_FILE, stream); - } finally { - stream.close(); - } - } - - private static void zip(File folder, ZipOutputStream stream, String path) - throws IOException { - ZipEntry entry = new ZipEntry(path); - stream.putNextEntry(entry); - stream.closeEntry(); - File[] files = folder.listFiles(); - for (File file : files) { - if (file.isFile()) { - zipFile(file, path + file.getName(), stream); - } else { - zip(file, stream, path + file.getName() + "/"); - } - } - } - - private static void zipFile(File file, String zipEntry, - ZipOutputStream stream) throws IOException, FileNotFoundException { - ZipEntry entry = new ZipEntry(zipEntry); - stream.putNextEntry(entry); - BufferedInputStream inputStream = new BufferedInputStream( - new FileInputStream(file)); - try { - copy(inputStream, stream); - } finally { - inputStream.close(); - } - stream.closeEntry(); - } - - private static void copy(InputStream in, OutputStream out) - throws IOException { - byte[] buffer = new byte[131072]; // 128k - should be enough for most - // JS/CSS files - int count; - while ((count = in.read(buffer)) > 0) { - out.write(buffer, 0, count); - } + IFile newFile = project.getFile(WRT_PREVIEW_MAIN_HTML); + newFile.create(new ByteArrayInputStream("Should not be in release!" + .getBytes()), false, new NullProgressMonitor()); } public static String getDefaultAptanaLocation() { @@ -275,17 +114,6 @@ new SubProgressMonitor(monitor, 1)); } - public static void importPreviewer(URI locationURI) { - if (!getPreviewerZip().exists()) { - File file = new File(locationURI); - try { - zipPreviewer(file); - } catch (IOException e) { - Activator.log(e); - } - } - } - public static boolean isAptanaProject(URI locationURI) { return isAptanaProject(new File(locationURI)); } diff -r 2527ecaf66ff -r aa2fb3fcc303 org.symbian.tools.wrttools/src/org/symbian/tools/wrttools/wizards/AptanaProjectLocationWizardPage.java --- a/org.symbian.tools.wrttools/src/org/symbian/tools/wrttools/wizards/AptanaProjectLocationWizardPage.java Mon Jan 25 16:59:39 2010 -0800 +++ b/org.symbian.tools.wrttools/src/org/symbian/tools/wrttools/wizards/AptanaProjectLocationWizardPage.java Tue Jan 26 12:55:12 2010 -0800 @@ -343,7 +343,7 @@ private static final Collection EXCLUDED; static { - EXCLUDED = new TreeSet(Arrays.asList(".project")); + EXCLUDED = new TreeSet(Arrays.asList(".project", "preview", "wrt_preview_main.html")); } public AptanaProjectLocationWizardPage() { @@ -582,7 +582,6 @@ operation.setCreateContainerStructure(false); operation.run(monitor); } - ProjectUtils.importPreviewer(record.description.getLocationURI()); } catch (CoreException e) { Activator.log(e); return false;