# HG changeset patch # User Eugene Ostroukhov # Date 1263001207 28800 # Node ID e3d48d24826c18a037eeca0d0ebbc37b0e4912db # Parent cba53a9bb2242b3326c961a9416c517839f609a5# Parent 683bdcbc3ebde8bc4b271332efc1b06e78917093 UI refresh diff -r cba53a9bb224 -r e3d48d24826c org.symbian.tools.wrttools.jseditors/bin/org/symbian/tools/wrttools/jseditors/wizards/NewHTMLWizard$1.class Binary file org.symbian.tools.wrttools.jseditors/bin/org/symbian/tools/wrttools/jseditors/wizards/NewHTMLWizard$1.class has changed diff -r cba53a9bb224 -r e3d48d24826c org.symbian.tools.wrttools.jseditors/bin/org/symbian/tools/wrttools/jseditors/wizards/NewHTMLWizard$2.class Binary file org.symbian.tools.wrttools.jseditors/bin/org/symbian/tools/wrttools/jseditors/wizards/NewHTMLWizard$2.class has changed diff -r cba53a9bb224 -r e3d48d24826c org.symbian.tools.wrttools.jseditors/bin/org/symbian/tools/wrttools/jseditors/wizards/NewHTMLWizard.class Binary file org.symbian.tools.wrttools.jseditors/bin/org/symbian/tools/wrttools/jseditors/wizards/NewHTMLWizard.class has changed diff -r cba53a9bb224 -r e3d48d24826c org.symbian.tools.wrttools.jseditors/bin/org/symbian/tools/wrttools/jseditors/wizards/NewHTMLWizardPage$1.class Binary file org.symbian.tools.wrttools.jseditors/bin/org/symbian/tools/wrttools/jseditors/wizards/NewHTMLWizardPage$1.class has changed diff -r cba53a9bb224 -r e3d48d24826c org.symbian.tools.wrttools.jseditors/bin/org/symbian/tools/wrttools/jseditors/wizards/NewHTMLWizardPage$2.class Binary file org.symbian.tools.wrttools.jseditors/bin/org/symbian/tools/wrttools/jseditors/wizards/NewHTMLWizardPage$2.class has changed diff -r cba53a9bb224 -r e3d48d24826c org.symbian.tools.wrttools.jseditors/bin/org/symbian/tools/wrttools/jseditors/wizards/NewHTMLWizardPage$3.class Binary file org.symbian.tools.wrttools.jseditors/bin/org/symbian/tools/wrttools/jseditors/wizards/NewHTMLWizardPage$3.class has changed diff -r cba53a9bb224 -r e3d48d24826c org.symbian.tools.wrttools.jseditors/bin/org/symbian/tools/wrttools/jseditors/wizards/NewHTMLWizardPage.class Binary file org.symbian.tools.wrttools.jseditors/bin/org/symbian/tools/wrttools/jseditors/wizards/NewHTMLWizardPage.class has changed diff -r cba53a9bb224 -r e3d48d24826c org.symbian.tools.wrttools.jseditors/icons/Thumbs.db Binary file org.symbian.tools.wrttools.jseditors/icons/Thumbs.db has changed diff -r cba53a9bb224 -r e3d48d24826c org.symbian.tools.wrttools.jseditors/icons/new_xml.gif Binary file org.symbian.tools.wrttools.jseditors/icons/new_xml.gif has changed diff -r cba53a9bb224 -r e3d48d24826c org.symbian.tools.wrttools.jseditors/icons/newjscript_wiz.gif Binary file org.symbian.tools.wrttools.jseditors/icons/newjscript_wiz.gif has changed diff -r cba53a9bb224 -r e3d48d24826c org.symbian.tools.wrttools.jseditors/plugin.xml --- a/org.symbian.tools.wrttools.jseditors/plugin.xml Fri Jan 08 14:40:12 2010 -0800 +++ b/org.symbian.tools.wrttools.jseditors/plugin.xml Fri Jan 08 17:40:07 2010 -0800 @@ -3,31 +3,6 @@ - - - - - - - - - - + id="org.symbian.tools.wrttools.jseditors.category" + name="WRT Files"> + + diff -r cba53a9bb224 -r e3d48d24826c org.symbian.tools.wrttools.jseditors/src/org/symbian/tools/wrttools/jseditors/wizards/NewHTMLWizard.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/org.symbian.tools.wrttools.jseditors/src/org/symbian/tools/wrttools/jseditors/wizards/NewHTMLWizard.java Fri Jan 08 17:40:07 2010 -0800 @@ -0,0 +1,181 @@ +/** + * Copyright (c) 2009 Symbian Foundation and/or its subsidiary(-ies). + * All rights reserved. + * This component and the accompanying materials are made available + * under the terms of + * the License "Eclipse Public License v1.0" + * which accompanies this distribution, and is available + * at the URL "http://www.eclipse.org/legal/epl-v10.html". + * + * Initial Contributors: + * Symbian Foundation - initial contribution. + * Contributors: + * Description: + * Overview: + * Details: + * Platforms/Drives/Compatibility: + * Assumptions/Requirement/Pre-requisites: + * Failures and causes: + */ +package org.symbian.tools.wrttools.jseditors.wizards; + +import org.eclipse.jface.viewers.IStructuredSelection; +import org.eclipse.jface.wizard.Wizard; +import org.eclipse.ui.INewWizard; +import org.eclipse.ui.IWorkbench; +import org.eclipse.core.runtime.*; +import org.eclipse.jface.operation.*; +import java.lang.reflect.InvocationTargetException; +import org.eclipse.jface.dialogs.MessageDialog; +import org.eclipse.jface.viewers.ISelection; +import org.eclipse.core.resources.*; +import org.eclipse.core.runtime.CoreException; +import java.io.*; +import org.eclipse.ui.*; +import org.eclipse.ui.ide.IDE; + +/** + * This is a sample new HTML wizard. Its role is to create a new file + * resource in the provided container. If the container resource + * (a folder or a project) is selected in the workspace + * when the wizard is opened, it will accept it as the target + * container. The wizard creates one file with the extension + * "html". If a sample html editor (also available + * as a template) is registered for the same extension, it will + * be able to open it. + */ + +public class NewHTMLWizard extends Wizard implements INewWizard { + private NewHTMLWizardPage page; + private ISelection selection; + + /** + * Constructor for SampleNewWizard. + */ + public NewHTMLWizard() { + super(); + setNeedsProgressMonitor(true); + } + + /** + * Adding the page to the wizard. + */ + + public void addPages() { + page = new NewHTMLWizardPage(selection); + addPage(page); + } + + /** + * This method is called when 'Finish' button is pressed in + * the wizard. We will create an operation and run it + * using wizard as execution context. + */ + public boolean performFinish() { + final String containerName = page.getContainerName(); + final String fileName = page.getFileName(); + IRunnableWithProgress op = new IRunnableWithProgress() { + public void run(IProgressMonitor monitor) throws InvocationTargetException { + try { + doFinish(containerName, fileName, monitor); + } catch (CoreException e) { + throw new InvocationTargetException(e); + } finally { + monitor.done(); + } + } + }; + try { + getContainer().run(true, false, op); + } catch (InterruptedException e) { + return false; + } catch (InvocationTargetException e) { + Throwable realException = e.getTargetException(); + MessageDialog.openError(getShell(), "Error", realException.getMessage()); + return false; + } + return true; + } + + /** + * The worker method. It will find the container, create the + * file if missing or just replace its contents, and open + * the editor on the newly created file. + */ + + private void doFinish( + String containerName, + String fileName, + IProgressMonitor monitor) + throws CoreException { + // create a sample file + monitor.beginTask("Creating " + fileName, 2); + IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot(); + IResource resource = root.findMember(new Path(containerName)); + if (!resource.exists() || !(resource instanceof IContainer)) { + throwCoreException("Container \"" + containerName + "\" does not exist."); + } + IContainer container = (IContainer) resource; + final IFile file = container.getFile(new Path(fileName)); + try { + InputStream stream = openContentStream(); + if (file.exists()) { + file.setContents(stream, true, true, monitor); + } else { + file.create(stream, true, monitor); + } + stream.close(); + } catch (IOException e) { + } + monitor.worked(1); + monitor.setTaskName("Opening file for editing..."); + getShell().getDisplay().asyncExec(new Runnable() { + public void run() { + IWorkbenchPage page = + PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(); + try { + IDE.openEditor(page, file, true); + } catch (PartInitException e) { + } + } + }); + monitor.worked(1); + } + + /** + * We will initialize file contents with a sample text. + */ + + private InputStream openContentStream() { + String contents = + "\n" + + "\n" + + "\n" + + "Sample Widget\n" + + "\n" + + "\n" + + "\n" + + "\n" + + "\n" + + "\n" + + "\n"; + + return new ByteArrayInputStream(contents.getBytes()); + } + + private void throwCoreException(String message) throws CoreException { + IStatus status = + new Status(IStatus.ERROR, "org.symbian.tools.wrttools.jseditors", IStatus.OK, message, null); + throw new CoreException(status); + } + + /** + * We will accept the selection in the workbench to see if + * we can initialize from it. + * @see IWorkbenchWizard#init(IWorkbench, IStructuredSelection) + */ + public void init(IWorkbench workbench, IStructuredSelection selection) { + this.selection = selection; + } +} diff -r cba53a9bb224 -r e3d48d24826c org.symbian.tools.wrttools.jseditors/src/org/symbian/tools/wrttools/jseditors/wizards/NewHTMLWizardPage.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/org.symbian.tools.wrttools.jseditors/src/org/symbian/tools/wrttools/jseditors/wizards/NewHTMLWizardPage.java Fri Jan 08 17:40:07 2010 -0800 @@ -0,0 +1,204 @@ +/** + * Copyright (c) 2009 Symbian Foundation and/or its subsidiary(-ies). + * All rights reserved. + * This component and the accompanying materials are made available + * under the terms of the License "Eclipse Public License v1.0" + * which accompanies this distribution, and is available + * at the URL "http://www.eclipse.org/legal/epl-v10.html". + * + * Initial Contributors: + * Symbian Foundation - initial contribution. + * Contributors: + * Description: + * Overview: + * Details: + * Platforms/Drives/Compatibility: + * Assumptions/Requirement/Pre-requisites: + * Failures and causes: + */ +package org.symbian.tools.wrttools.jseditors.wizards; + + +import org.eclipse.core.resources.IContainer; +import org.eclipse.core.resources.IResource; +import org.eclipse.core.resources.ResourcesPlugin; +import org.eclipse.core.runtime.Path; +import org.eclipse.jface.viewers.ISelection; +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.Label; +import org.eclipse.swt.widgets.Text; +import org.eclipse.ui.dialogs.ContainerSelectionDialog; + +/** + * The "New" wizard page allows setting the container for the new file as well + * as the file name. The page will only accept file name without the extension + * OR with the extension that matches the expected one (html). + */ + +public class NewHTMLWizardPage extends WizardPage { + private Text containerText; + + private Text fileText; + + private ISelection selection; + + /** + * Constructor for SampleNewWizardPage. + * + * @param pageName + */ + public NewHTMLWizardPage(ISelection selection) { + super("wizardPage"); + setTitle("HTML File"); + setDescription("This wizard creates a new HTML file with *.html extension that can be opened by an HTML editor."); + this.selection = selection; + } + + /** + * @see IDialogPage#createControl(Composite) + */ + public void createControl(Composite parent) { + Composite container = new Composite(parent, SWT.NULL); + GridLayout layout = new GridLayout(); + container.setLayout(layout); + layout.numColumns = 3; + layout.verticalSpacing = 9; + Label label = new Label(container, SWT.NULL); + label.setText("&Container:"); + + containerText = new Text(container, SWT.BORDER | SWT.SINGLE); + GridData gd = new GridData(GridData.FILL_HORIZONTAL); + containerText.setLayoutData(gd); + containerText.addModifyListener(new ModifyListener() { + public void modifyText(ModifyEvent e) { + dialogChanged(); + } + }); + + Button button = new Button(container, SWT.PUSH); + button.setText("Browse..."); + button.addSelectionListener(new SelectionAdapter() { + public void widgetSelected(SelectionEvent e) { + handleBrowse(); + } + }); + label = new Label(container, SWT.NULL); + label.setText("&File name:"); + + fileText = new Text(container, SWT.BORDER | SWT.SINGLE); + gd = new GridData(GridData.FILL_HORIZONTAL); + fileText.setLayoutData(gd); + fileText.addModifyListener(new ModifyListener() { + public void modifyText(ModifyEvent e) { + dialogChanged(); + } + }); + initialize(); + dialogChanged(); + setControl(container); + } + + /** + * Tests if the current workbench selection is a suitable container to use. + */ + + private void initialize() { + if (selection != null && selection.isEmpty() == false + && selection instanceof IStructuredSelection) { + IStructuredSelection ssel = (IStructuredSelection) selection; + if (ssel.size() > 1) + return; + Object obj = ssel.getFirstElement(); + if (obj instanceof IResource) { + IContainer container; + if (obj instanceof IContainer) + container = (IContainer) obj; + else + container = ((IResource) obj).getParent(); + containerText.setText(container.getFullPath().toString()); + } + } + fileText.setText("index.html"); + } + + /** + * Uses the standard container selection dialog to choose the new value for + * the container field. + */ + + private void handleBrowse() { + ContainerSelectionDialog dialog = new ContainerSelectionDialog( + getShell(), ResourcesPlugin.getWorkspace().getRoot(), false, + "Select new file container"); + if (dialog.open() == ContainerSelectionDialog.OK) { + Object[] result = dialog.getResult(); + if (result.length == 1) { + containerText.setText(((Path) result[0]).toString()); + } + } + } + + /** + * Ensures that both text fields are set. + */ + + private void dialogChanged() { + IResource container = ResourcesPlugin.getWorkspace().getRoot() + .findMember(new Path(getContainerName())); + String fileName = getFileName(); + + if (getContainerName().length() == 0) { + updateStatus("File container must be specified"); + return; + } + if (container == null + || (container.getType() & (IResource.PROJECT | IResource.FOLDER)) == 0) { + updateStatus("File container must exist"); + return; + } + if (!container.isAccessible()) { + updateStatus("Project must be writable"); + return; + } + if (fileName.length() == 0) { + updateStatus("File name must be specified"); + return; + } + if (fileName.replace('\\', '/').indexOf('/', 1) > 0) { + updateStatus("File name must be valid"); + return; + } + int dotLoc = fileName.lastIndexOf('.'); + if (dotLoc != -1) { + String ext = fileName.substring(dotLoc + 1); + if (ext.equalsIgnoreCase("html") == false) { + updateStatus("File extension must be \"html\""); + return; + } + } + updateStatus(null); + } + + private void updateStatus(String message) { + setErrorMessage(message); + setPageComplete(message == null); + } + + public String getContainerName() { + return containerText.getText(); + } + + public String getFileName() { + return fileText.getText(); + } +} diff -r cba53a9bb224 -r e3d48d24826c org.symbian.tools.wrttools/bin/org/symbian/tools/wrttools/util/ProjectUtils$1.class Binary file org.symbian.tools.wrttools/bin/org/symbian/tools/wrttools/util/ProjectUtils$1.class has changed diff -r cba53a9bb224 -r e3d48d24826c org.symbian.tools.wrttools/bin/org/symbian/tools/wrttools/util/ProjectUtils.class Binary file org.symbian.tools.wrttools/bin/org/symbian/tools/wrttools/util/ProjectUtils.class has changed diff -r cba53a9bb224 -r e3d48d24826c org.symbian.tools.wrttools/bin/org/symbian/tools/wrttools/wizards/AptanaProjectLocationWizardPage$1.class Binary file org.symbian.tools.wrttools/bin/org/symbian/tools/wrttools/wizards/AptanaProjectLocationWizardPage$1.class has changed diff -r cba53a9bb224 -r e3d48d24826c org.symbian.tools.wrttools/bin/org/symbian/tools/wrttools/wizards/AptanaProjectLocationWizardPage$10.class Binary file org.symbian.tools.wrttools/bin/org/symbian/tools/wrttools/wizards/AptanaProjectLocationWizardPage$10.class has changed diff -r cba53a9bb224 -r e3d48d24826c org.symbian.tools.wrttools/bin/org/symbian/tools/wrttools/wizards/AptanaProjectLocationWizardPage$11.class Binary file org.symbian.tools.wrttools/bin/org/symbian/tools/wrttools/wizards/AptanaProjectLocationWizardPage$11.class has changed diff -r cba53a9bb224 -r e3d48d24826c org.symbian.tools.wrttools/bin/org/symbian/tools/wrttools/wizards/AptanaProjectLocationWizardPage$12.class Binary file org.symbian.tools.wrttools/bin/org/symbian/tools/wrttools/wizards/AptanaProjectLocationWizardPage$12.class has changed diff -r cba53a9bb224 -r e3d48d24826c org.symbian.tools.wrttools/bin/org/symbian/tools/wrttools/wizards/AptanaProjectLocationWizardPage$13.class Binary file org.symbian.tools.wrttools/bin/org/symbian/tools/wrttools/wizards/AptanaProjectLocationWizardPage$13.class has changed diff -r cba53a9bb224 -r e3d48d24826c org.symbian.tools.wrttools/bin/org/symbian/tools/wrttools/wizards/AptanaProjectLocationWizardPage$14.class Binary file org.symbian.tools.wrttools/bin/org/symbian/tools/wrttools/wizards/AptanaProjectLocationWizardPage$14.class has changed diff -r cba53a9bb224 -r e3d48d24826c org.symbian.tools.wrttools/bin/org/symbian/tools/wrttools/wizards/AptanaProjectLocationWizardPage$15.class Binary file org.symbian.tools.wrttools/bin/org/symbian/tools/wrttools/wizards/AptanaProjectLocationWizardPage$15.class has changed diff -r cba53a9bb224 -r e3d48d24826c org.symbian.tools.wrttools/bin/org/symbian/tools/wrttools/wizards/AptanaProjectLocationWizardPage$16.class Binary file org.symbian.tools.wrttools/bin/org/symbian/tools/wrttools/wizards/AptanaProjectLocationWizardPage$16.class has changed diff -r cba53a9bb224 -r e3d48d24826c org.symbian.tools.wrttools/bin/org/symbian/tools/wrttools/wizards/AptanaProjectLocationWizardPage$17.class Binary file org.symbian.tools.wrttools/bin/org/symbian/tools/wrttools/wizards/AptanaProjectLocationWizardPage$17.class has changed diff -r cba53a9bb224 -r e3d48d24826c org.symbian.tools.wrttools/bin/org/symbian/tools/wrttools/wizards/AptanaProjectLocationWizardPage$2.class Binary file org.symbian.tools.wrttools/bin/org/symbian/tools/wrttools/wizards/AptanaProjectLocationWizardPage$2.class has changed diff -r cba53a9bb224 -r e3d48d24826c org.symbian.tools.wrttools/bin/org/symbian/tools/wrttools/wizards/AptanaProjectLocationWizardPage$3.class Binary file org.symbian.tools.wrttools/bin/org/symbian/tools/wrttools/wizards/AptanaProjectLocationWizardPage$3.class has changed diff -r cba53a9bb224 -r e3d48d24826c org.symbian.tools.wrttools/bin/org/symbian/tools/wrttools/wizards/AptanaProjectLocationWizardPage$4.class Binary file org.symbian.tools.wrttools/bin/org/symbian/tools/wrttools/wizards/AptanaProjectLocationWizardPage$4.class has changed diff -r cba53a9bb224 -r e3d48d24826c org.symbian.tools.wrttools/bin/org/symbian/tools/wrttools/wizards/AptanaProjectLocationWizardPage$5.class Binary file org.symbian.tools.wrttools/bin/org/symbian/tools/wrttools/wizards/AptanaProjectLocationWizardPage$5.class has changed diff -r cba53a9bb224 -r e3d48d24826c org.symbian.tools.wrttools/bin/org/symbian/tools/wrttools/wizards/AptanaProjectLocationWizardPage$6.class Binary file org.symbian.tools.wrttools/bin/org/symbian/tools/wrttools/wizards/AptanaProjectLocationWizardPage$6.class has changed diff -r cba53a9bb224 -r e3d48d24826c org.symbian.tools.wrttools/bin/org/symbian/tools/wrttools/wizards/AptanaProjectLocationWizardPage$7.class Binary file org.symbian.tools.wrttools/bin/org/symbian/tools/wrttools/wizards/AptanaProjectLocationWizardPage$7.class has changed diff -r cba53a9bb224 -r e3d48d24826c org.symbian.tools.wrttools/bin/org/symbian/tools/wrttools/wizards/AptanaProjectLocationWizardPage$8.class Binary file org.symbian.tools.wrttools/bin/org/symbian/tools/wrttools/wizards/AptanaProjectLocationWizardPage$8.class has changed diff -r cba53a9bb224 -r e3d48d24826c org.symbian.tools.wrttools/bin/org/symbian/tools/wrttools/wizards/AptanaProjectLocationWizardPage$9.class Binary file org.symbian.tools.wrttools/bin/org/symbian/tools/wrttools/wizards/AptanaProjectLocationWizardPage$9.class has changed diff -r cba53a9bb224 -r e3d48d24826c org.symbian.tools.wrttools/bin/org/symbian/tools/wrttools/wizards/AptanaProjectLocationWizardPage.class Binary file org.symbian.tools.wrttools/bin/org/symbian/tools/wrttools/wizards/AptanaProjectLocationWizardPage.class has changed diff -r cba53a9bb224 -r e3d48d24826c org.symbian.tools.wrttools/bin/org/symbian/tools/wrttools/wizards/AptanaProjectsImportWizard.class Binary file org.symbian.tools.wrttools/bin/org/symbian/tools/wrttools/wizards/AptanaProjectsImportWizard.class has changed diff -r cba53a9bb224 -r e3d48d24826c org.symbian.tools.wrttools/bin/org/symbian/tools/wrttools/wizards/WRTProjectTemplateWizardPage$1.class Binary file org.symbian.tools.wrttools/bin/org/symbian/tools/wrttools/wizards/WRTProjectTemplateWizardPage$1.class has changed diff -r cba53a9bb224 -r e3d48d24826c org.symbian.tools.wrttools/bin/org/symbian/tools/wrttools/wizards/WRTProjectTemplateWizardPage$2.class Binary file org.symbian.tools.wrttools/bin/org/symbian/tools/wrttools/wizards/WRTProjectTemplateWizardPage$2.class has changed diff -r cba53a9bb224 -r e3d48d24826c org.symbian.tools.wrttools/bin/org/symbian/tools/wrttools/wizards/WRTProjectTemplateWizardPage$3.class Binary file org.symbian.tools.wrttools/bin/org/symbian/tools/wrttools/wizards/WRTProjectTemplateWizardPage$3.class has changed diff -r cba53a9bb224 -r e3d48d24826c org.symbian.tools.wrttools/bin/org/symbian/tools/wrttools/wizards/WRTProjectTemplateWizardPage.class Binary file org.symbian.tools.wrttools/bin/org/symbian/tools/wrttools/wizards/WRTProjectTemplateWizardPage.class has changed diff -r cba53a9bb224 -r e3d48d24826c org.symbian.tools.wrttools/plugin.xml --- a/org.symbian.tools.wrttools/plugin.xml Fri Jan 08 14:40:12 2010 -0800 +++ b/org.symbian.tools.wrttools/plugin.xml Fri Jan 08 17:40:07 2010 -0800 @@ -55,7 +55,7 @@ point="org.eclipse.ui.newWizards"> + name="Web Runtime(WRT)"> Creates a new Symbian WRT widget project using one of the provided templates @@ -90,7 +90,7 @@ point="org.eclipse.ui.importWizards"> + name="Web Runtime(WRT)"> - - - - - - - - - - @@ -151,13 +129,6 @@ - - - - diff -r cba53a9bb224 -r e3d48d24826c 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 Fri Jan 08 14:40:12 2010 -0800 +++ b/org.symbian.tools.wrttools/src/org/symbian/tools/wrttools/util/ProjectUtils.java Fri Jan 08 17:40:07 2010 -0800 @@ -43,7 +43,6 @@ import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.NullProgressMonitor; -import org.eclipse.core.runtime.Path; import org.eclipse.core.runtime.Status; import org.eclipse.core.runtime.SubProgressMonitor; import org.eclipse.jface.window.Window; @@ -56,6 +55,9 @@ import org.symbian.tools.wrttools.dialogs.AptanaProjectSelectionDialog; public class ProjectUtils { + public static final String PREVIEW_FOLDER = "preview"; + public static final String PREVIEW_FRAME_FILE = "wrt_preview_frame.html"; + public static IProject createWrtProject(String name, URI uri, IProgressMonitor monitor) throws CoreException { monitor.beginTask("Create project resources", 20); @@ -130,7 +132,7 @@ .append("previewer.zip").toFile(); } - protected static void importPreviewer() { + private static void importPreviewer() { AptanaProjectSelectionDialog dialog = new AptanaProjectSelectionDialog( PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell()); int open = dialog.open(); @@ -155,9 +157,9 @@ ZipOutputStream stream = new ZipOutputStream(new FileOutputStream( getPreviewerZip())); try { - zip(new File(project, "preview"), stream, "preview/"); - zipFile(new File(project, "wrt_preview_frame.html"), - "wrt_preview_frame.html", stream); + zip(new File(project, PREVIEW_FOLDER), stream, PREVIEW_FOLDER + "/"); + zipFile(new File(project, PREVIEW_FRAME_FILE), + PREVIEW_FRAME_FILE, stream); } finally { stream.close(); } @@ -210,8 +212,8 @@ } public static boolean isAptanaProject(File f) { - return new File(f, "preview").isDirectory() - && new File(f, "wrt_preview_frame.html").isFile(); + return new File(f, PREVIEW_FOLDER).isDirectory() + && new File(f, PREVIEW_FRAME_FILE).isFile(); } public static void copyFile(IProject project, String name, ZipInputStream stream, @@ -221,4 +223,19 @@ file.create(new NonClosingStream(stream), true, 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 cba53a9bb224 -r e3d48d24826c 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 Fri Jan 08 14:40:12 2010 -0800 +++ b/org.symbian.tools.wrttools/src/org/symbian/tools/wrttools/wizards/AptanaProjectLocationWizardPage.java Fri Jan 08 17:40:07 2010 -0800 @@ -414,14 +414,28 @@ // first look for project description files final String dotProject = IProjectDescription.DESCRIPTION_FILE_NAME; + + 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(dotProject)) { - files.add(file); - // don't search sub-directories since we can't have nested - // projects - return true; + dotProjectFile = file; + } + if (file.isFile() && ProjectUtils.PREVIEW_FRAME_FILE.equalsIgnoreCase(file.getName())) { + hasFrame = true; } + if (file.isDirectory() && ProjectUtils.PREVIEW_FOLDER.equalsIgnoreCase(file.getName())) { + hasPreviewer = true; + } + } + if (dotProjectFile != null && hasFrame && hasPreviewer) { + files.add(dotProjectFile); + // don't search sub-directories since we can't have nested + // projects + return true; } // no project description found, so recurse into sub-directories for (int i = 0; i < contents.length; i++) { @@ -469,16 +483,28 @@ children = new ArrayList(1); } Iterator childrenEnum = children.iterator(); + boolean hasPreviewFolder = false; + boolean hasFrameHtml = false; + ProjectRecord projectRecord = null; while (childrenEnum.hasNext()) { Object child = childrenEnum.next(); + String elementLabel = structureProvider.getLabel(child); if (structureProvider.isFolder(child)) { + if (ProjectUtils.PREVIEW_FOLDER.equalsIgnoreCase(elementLabel)) { + hasPreviewFolder = true; + } collectProjectFilesFromProvider(files, child, level + 1, monitor); } - String elementLabel = structureProvider.getLabel(child); if (elementLabel.equals(IProjectDescription.DESCRIPTION_FILE_NAME)) { - files.add(new ProjectRecord(child, entry, level)); + projectRecord = new ProjectRecord(child, entry, level); } + if (ProjectUtils.PREVIEW_FRAME_FILE.equalsIgnoreCase(elementLabel)) { + hasFrameHtml = true; + } + } + if (projectRecord != null && hasPreviewFolder && hasFrameHtml) { + files.add(projectRecord); } return true; } @@ -506,7 +532,8 @@ createWorkingSetGroup(workArea); restoreWidgetValues(); Dialog.applyDialogFont(workArea); - + + updateProjectsList(directoryPathField.getText().trim()); } /** @@ -555,7 +582,7 @@ operation.setCreateContainerStructure(false); operation.run(monitor); } - + ProjectUtils.importPreviewer(record.description.getLocationURI()); } catch (CoreException e) { Activator.log(e); return false; @@ -1084,7 +1111,7 @@ public ProjectRecord[] getProjectRecords() { List projectRecords = new ArrayList(); for (int i = 0; i < selectedProjects.length; i++) { - if (isProjectInWorkspace(selectedProjects[i].getProjectName())) { + if (!ProjectUtils.isAptanaProject(selectedProjects[i].description.getLocationURI()) || isProjectInWorkspace(selectedProjects[i].getProjectName())) { selectedProjects[i].hasConflicts = true; } projectRecords.add(selectedProjects[i]); diff -r cba53a9bb224 -r e3d48d24826c 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 Fri Jan 08 14:40:12 2010 -0800 +++ b/org.symbian.tools.wrttools/src/org/symbian/tools/wrttools/wizards/AptanaProjectsImportWizard.java Fri Jan 08 17:40:07 2010 -0800 @@ -29,6 +29,7 @@ public AptanaProjectsImportWizard() { setWindowTitle("Import Aptana Project"); + setNeedsProgressMonitor(true); } @Override diff -r cba53a9bb224 -r e3d48d24826c 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 Fri Jan 08 14:40:12 2010 -0800 +++ b/org.symbian.tools.wrttools/src/org/symbian/tools/wrttools/wizards/WRTProjectTemplateWizardPage.java Fri Jan 08 17:40:07 2010 -0800 @@ -73,6 +73,12 @@ @Override public void createControl(Composite parent) { + ProjectTemplate[] allTemplates = ProjectTemplate.getAllTemplates(); + + if (allTemplates.length == 1) { + context.setTemplate(allTemplates[0]); + } + Composite composite = new Composite(parent, SWT.NONE); FormLayout layout = new FormLayout(); layout.marginWidth = 5; @@ -119,7 +125,7 @@ templates.setContentProvider(new ArrayContentProvider()); templates.setLabelProvider(new ProjectTemplateLabelProvider()); - templates.setInput(ProjectTemplate.getAllTemplates()); + templates.setInput(allTemplates); setControl(composite); setPageComplete(false); @@ -128,6 +134,10 @@ IObservableValue property = BeansObservables.observeValue(context, WizardContext.TEMPLATE); bindingContext.bindValue(selection, property); + if (context.getTemplate() != null) { + refreshSelection(context.getTemplate()); + } + setErrorMessage(null); } protected void switchWizardPage() {