# HG changeset patch # User Eugene Ostroukhov # Date 1265390360 28800 # Node ID 2196d1511a176a32bb6858e6dccda692d8ab81c5 # Parent b6d252d808df4abaf83c9f59ec0c62ea4a53c79b# Parent 024f49774fbbbe7d4d98a80d5f2ee35bd99e9797 Heads were merged diff -r 024f49774fbb -r 2196d1511a17 org.symbian.tools.wrttools.debug.core/.classpath --- a/org.symbian.tools.wrttools.debug.core/.classpath Fri Feb 05 08:19:36 2010 -0800 +++ b/org.symbian.tools.wrttools.debug.core/.classpath Fri Feb 05 09:19:20 2010 -0800 @@ -1,6 +1,6 @@ - + diff -r 024f49774fbb -r 2196d1511a17 org.symbian.tools.wrttools.jseditors/.classpath --- a/org.symbian.tools.wrttools.jseditors/.classpath Fri Feb 05 08:19:36 2010 -0800 +++ b/org.symbian.tools.wrttools.jseditors/.classpath Fri Feb 05 09:19:20 2010 -0800 @@ -1,6 +1,6 @@ - + diff -r 024f49774fbb -r 2196d1511a17 org.symbian.tools.wrttools.previewer/.classpath --- a/org.symbian.tools.wrttools.previewer/.classpath Fri Feb 05 08:19:36 2010 -0800 +++ b/org.symbian.tools.wrttools.previewer/.classpath Fri Feb 05 09:19:20 2010 -0800 @@ -1,6 +1,6 @@ - + diff -r 024f49774fbb -r 2196d1511a17 org.symbian.tools.wrttools.previewer/src/org/symbian/tools/wrttools/previewer/http/WorkspaceResourcesServlet.java --- a/org.symbian.tools.wrttools.previewer/src/org/symbian/tools/wrttools/previewer/http/WorkspaceResourcesServlet.java Fri Feb 05 08:19:36 2010 -0800 +++ b/org.symbian.tools.wrttools.previewer/src/org/symbian/tools/wrttools/previewer/http/WorkspaceResourcesServlet.java Fri Feb 05 09:19:20 2010 -0800 @@ -47,14 +47,13 @@ import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.Path; import org.symbian.tools.wrttools.previewer.PreviewerPlugin; +import org.symbian.tools.wrttools.util.CoreUtil; public class WorkspaceResourcesServlet extends HttpServlet { private static final String STARTING_PAGE = "preview-frame.html"; private static final String INDEX_PAGE = "wrt_preview_main.html"; private static final long serialVersionUID = -3217197074249607950L; - private static final Pattern HTML_FILE_NAME_PROPERTY = Pattern - .compile("\\s*MainHTML\\s*\\s*\\s*(.*)\\s*", Pattern.CASE_INSENSITIVE); private static final Pattern HEAD_TAG_PATTERN = Pattern.compile("", Pattern.CASE_INSENSITIVE); private static final String SCRIPT = ""; @@ -103,7 +102,7 @@ IProject project = ResourcesPlugin.getWorkspace().getRoot().getProject( projectName); if (project.isAccessible()) { - String indexFileName = getIndexFileName(project); + String indexFileName = CoreUtil.getIndexFileName(readFile(project, "Info.plist")); if (indexFileName != null) { String string = readFile(project, indexFileName); if (string != null) { @@ -118,18 +117,6 @@ return null; } - private String getIndexFileName(IProject project) throws CoreException, - UnsupportedEncodingException, IOException { - String buffer = readFile(project, "Info.plist"); - if (buffer != null) { - Matcher matcher = HTML_FILE_NAME_PROPERTY.matcher(buffer); - if (matcher.find()) { - return matcher.group(1); - } - } - return null; - } - private String readFile(IProject project, String fileName) throws CoreException, UnsupportedEncodingException, IOException { IFile file = getFile(project, fileName); diff -r 024f49774fbb -r 2196d1511a17 org.symbian.tools.wrttools.product/.classpath --- a/org.symbian.tools.wrttools.product/.classpath Fri Feb 05 08:19:36 2010 -0800 +++ b/org.symbian.tools.wrttools.product/.classpath Fri Feb 05 09:19:20 2010 -0800 @@ -1,6 +1,6 @@ - + diff -r 024f49774fbb -r 2196d1511a17 org.symbian.tools.wrttools/.classpath --- a/org.symbian.tools.wrttools/.classpath Fri Feb 05 08:19:36 2010 -0800 +++ b/org.symbian.tools.wrttools/.classpath Fri Feb 05 09:19:20 2010 -0800 @@ -1,11 +1,11 @@ - - - - - - - - - - - + + + + + + + + + + + diff -r 024f49774fbb -r 2196d1511a17 org.symbian.tools.wrttools/plugin.xml --- a/org.symbian.tools.wrttools/plugin.xml Fri Feb 05 08:19:36 2010 -0800 +++ b/org.symbian.tools.wrttools/plugin.xml Fri Feb 05 09:19:20 2010 -0800 @@ -42,22 +42,18 @@ - - - - - - + --> @@ -614,4 +610,23 @@ id="org.symbian.wrtkit"> + + + + + + + + + + diff -r 024f49774fbb -r 2196d1511a17 org.symbian.tools.wrttools/src/org/symbian/tools/wrttools/core/internal/validation/WrtApplicationValidator.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/org.symbian.tools.wrttools/src/org/symbian/tools/wrttools/core/internal/validation/WrtApplicationValidator.java Fri Feb 05 09:19:20 2010 -0800 @@ -0,0 +1,322 @@ +package org.symbian.tools.wrttools.core.internal.validation; + +import java.io.IOException; +import java.text.MessageFormat; +import java.util.Set; +import java.util.TreeSet; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +import org.eclipse.core.resources.IContainer; +import org.eclipse.core.resources.IFile; +import org.eclipse.core.resources.IMarker; +import org.eclipse.core.resources.IProject; +import org.eclipse.core.resources.IResource; +import org.eclipse.core.runtime.CoreException; +import org.eclipse.core.runtime.IPath; +import org.eclipse.core.runtime.IProgressMonitor; +import org.eclipse.core.runtime.Path; +import org.eclipse.jface.text.IRegion; +import org.eclipse.wst.sse.core.StructuredModelManager; +import org.eclipse.wst.sse.core.internal.provisional.IStructuredModel; +import org.eclipse.wst.validation.AbstractValidator; +import org.eclipse.wst.validation.ValidationResult; +import org.eclipse.wst.validation.ValidationState; +import org.eclipse.wst.validation.ValidatorMessage; +import org.eclipse.wst.xml.core.internal.provisional.document.IDOMElement; +import org.eclipse.wst.xml.core.internal.provisional.document.IDOMModel; +import org.eclipse.wst.xml.core.internal.provisional.document.IDOMNode; +import org.symbian.tools.wrttools.Activator; +import org.symbian.tools.wrttools.core.validator.ValidatorPropMessages; +import org.symbian.tools.wrttools.core.validator.PlistValidator.plistElements; +import org.symbian.tools.wrttools.util.CoreUtil; +import org.symbian.tools.wrttools.util.ProjectUtils; +import org.symbian.tools.wrttools.util.Util; +import org.w3c.dom.Element; +import org.w3c.dom.Node; +import org.w3c.dom.NodeList; + +@SuppressWarnings("restriction") +public class WrtApplicationValidator extends AbstractValidator { + @Override + public ValidationResult validate(IResource resource, int kind, + ValidationState state, IProgressMonitor monitor) { + if (ProjectUtils.isPlist(resource)) { + return validatePlist((IFile) resource); + } else if (isProject(resource)) { + return validateProject((IProject) resource); + } else { + return null; + } + } + + private ValidationResult validateProject(IProject resource) { + ValidationResult result = new ValidationResult(); + try { + isPlistPresent(resource, result); + } catch (CoreException e) { + Activator.log(e); + } + return result; + } + + private boolean isProject(IResource resource) { + return resource.getType() == IResource.PROJECT + && ProjectUtils.hasWrtNature(resource.getProject()); + } + + private ValidationResult validatePlist(IFile resource) { + ValidationResult result = new ValidationResult(); + IStructuredModel structuredModel; + try { + structuredModel = StructuredModelManager.getModelManager() + .getModelForRead(resource); + try { + if (structuredModel instanceof IDOMModel) { + IDOMModel model = (IDOMModel) structuredModel; + validateElement((IDOMElement) model.getDocument() + .getDocumentElement(), result, resource); + checkHtml(model, resource, result); + checkPlistValues(model, resource, result); + } + } finally { + if (structuredModel != null) { + structuredModel.releaseFromRead(); + } + } + } catch (IOException e) { + Activator.log(e); + } catch (CoreException e) { + Activator.log(e); + } + return result; + } + + private void validateElement(IDOMElement element, ValidationResult result, + IResource resource) { + // showData(""); + plistElements[] values = plistElements.values(); + boolean isValidElement = false; + for (plistElements validElement : values) { + if (validElement.toString().equalsIgnoreCase( + element.getNodeName().trim())) { + isValidElement = true; + break; + + } + continue; + } + if (!isValidElement) { + Object[] arguments = { " ", element.getNodeName().trim() }; + String message = MessageFormat.format(ValidatorPropMessages + .getString("plist.element.not.supported") + + "{0}" + "{1}", arguments); + result.add(createMessage(resource, message, element + .getStartOffset(), element.getEndOffset())); + } + + NodeList childNodes = element.getChildNodes(); + for (int i = 0; i < childNodes.getLength(); i++) { + Node item = childNodes.item(i); + if (item.getNodeType() == Node.ELEMENT_NODE) { + validateElement((IDOMElement) item, result, resource); + } + } + } + + private ValidatorMessage createMessage(IResource resource, String message, + int startOffset, int endOffset) { + ValidatorMessage msg = ValidatorMessage.create(message, resource); + msg.setAttribute(IMarker.SEVERITY, IMarker.SEVERITY_ERROR); + msg.setAttribute(IMarker.CHAR_START, startOffset); + msg.setAttribute(IMarker.CHAR_END, endOffset); + return msg; + } + + private boolean checkHtml(IDOMModel model, IFile plist, + ValidationResult result) { + String text = model.getStructuredDocument().get(); + IRegion region = CoreUtil.getIndexFileNameRegion(text); + boolean checkHtml = false; + if (region != null) { + String htmlName = text.substring(region.getOffset(), region + .getOffset() + + region.getLength()); + IFile htmlFile = null; + try { + htmlFile = getFile(plist.getProject(), new Path(htmlName), 0, + "html", "htm"); + } catch (CoreException e) { + Activator.log(e); + } + if (htmlFile == null) { + Object[] arguments = { htmlName, "<>", htmlName }; + String message = MessageFormat.format(ValidatorPropMessages + .getString("plist.html.element.mismatch") + + "{0}" + "{1}" + "{2}", arguments); + result.add(createMessage(plist, message, region.getOffset(), + region.getOffset() + region.getLength())); + } + } else { + String message = ValidatorPropMessages + .getString("plist.html.element.mailHtml.missing"); + ValidatorMessage msg = createMessage(plist, message, 0, 0); + setMessageOnRootElement(msg, model); + result.add(msg); + } + + return checkHtml; + } + + private void setMessageOnRootElement(ValidatorMessage msg, IDOMModel model) { + Element element = model.getDocument().getDocumentElement(); + int begin = 0, end = 0; + if (element instanceof IDOMNode) { + IDOMNode node = (IDOMNode) element; + begin = node.getStartOffset(); + end = node.getFirstStructuredDocumentRegion().getEnd(); + } + msg.setAttribute(IMarker.CHAR_START, begin); + msg.setAttribute(IMarker.CHAR_END, end); + } + + private IFile getFile(IContainer container, IPath path, int segment, + String... extensions) throws CoreException { + if (segment + 1 == path.segmentCount()) { + return getFile(container, path.lastSegment(), extensions); + } else { + String name = path.segment(segment).toLowerCase(); + IResource[] members = container.members(); + for (IResource resource : members) { + if (resource.getName().toLowerCase().equals(name)) { + if (resource.getType() == IResource.FOLDER) { + return getFile((IContainer) resource, path, + segment + 1, extensions); + } + } + } + } + return null; + } + + private IFile getFile(IContainer container, String lastSegment, + String[] extensions) throws CoreException { + final Set names = new TreeSet(); + names.add(lastSegment.toLowerCase()); + for (String extension : extensions) { + names.add(lastSegment.concat(".").concat(extension).toLowerCase()); + } + IResource[] members = container.members(); + for (IResource resource : members) { + if (resource.getType() == IResource.FILE + && names.contains(resource.getName().toLowerCase()) + && resource.isAccessible()) { + return (IFile) resource; + } + } + return null; + } + + private void checkPlistValues(IDOMModel model, IResource plist, + ValidationResult result) { + String source = model.getStructuredDocument().get(); + if (!hasAttributeValue(source, "DisplayName")) { + Object[] arguments = { " 'Display Name' ", + ValidatorPropMessages.getString("not.in.plist.file") }; + String message = MessageFormat.format(ValidatorPropMessages + .getString("plist.mankey.mising") + + "{0}" + "{1}", arguments); + ValidatorMessage msg = createMessage(plist, message, 0, 0); + setMessageOnRootElement(msg, model); + result.add(msg); + } else /* validating Widget name (Display name) */ + { + Matcher matcher = CoreUtil.getPropertyLookupPattern("DisplayName") + .matcher(source); + if (matcher.find()) { + String strError = Util.validateWidgetName(matcher.group(1)); + if (strError != null) { + Object[] arguments = { + " 'Display Name' ", + ValidatorPropMessages + .getString("contains.invalid.character") }; + String message = MessageFormat.format(ValidatorPropMessages + .getString("plist.mankey.mising") + + "{0}" + "{1}", arguments); + + ValidatorMessage msg = createMessage(plist, message, + matcher.start(), matcher.end()); + result.add(msg); + } + } + } + + if (!hasAttributeValue(source, "MainHTML")) { + Object[] arguments = { " 'MainHTML ' ", + ValidatorPropMessages.getString("not.in.plist.file") }; + String message = MessageFormat.format(ValidatorPropMessages + .getString("plist.mankey.mising") + + "{0}" + "{1}", arguments); + ValidatorMessage msg = createMessage(plist, message, 0, 0); + setMessageOnRootElement(msg, model); + result.add(msg); + } + if (!hasAttributeValue(source, "Identifier")) { + Object[] arguments = { " 'Identifier ' ", + ValidatorPropMessages.getString("not.in.plist.file") }; + String message = MessageFormat.format(ValidatorPropMessages + .getString("plist.mankey.mising") + + "{0}" + "{1}", arguments); + ValidatorMessage msg = createMessage(plist, message, 0, 0); + setMessageOnRootElement(msg, model); + result.add(msg); + } else /* validating Widget Idenfier (UID) */ + { + Matcher matcher = CoreUtil.getPropertyLookupPattern("Identifier") + .matcher(source); + if (matcher.find()) { + String strError = Util.validateWidgetID(matcher.group(1)); + if (strError != null) { + Object[] arguments = { + " 'Identifier' ", + ValidatorPropMessages + .getString("contains.invalid.character") }; + String message = MessageFormat.format(ValidatorPropMessages + .getString("plist.mankey.mising") + + "{0}" + "{1}", arguments); + + ValidatorMessage msg = createMessage(plist, message, + matcher.start(1), matcher.end(1)); + result.add(msg); + } + } + } + } + + private boolean hasAttributeValue(String source, String propertyName) { + Pattern pattern = CoreUtil.getPropertyLookupPattern(propertyName); + boolean hasAttr = true; + Matcher matcher = pattern.matcher(source); + if (!matcher.find()) { + hasAttr = false; + } else { + hasAttr = matcher.group(1).trim().length() > 0; + } + return hasAttr; + } + + private void isPlistPresent(IProject project, ValidationResult result) + throws CoreException { + IResource[] members = project.members(); + for (IResource resource : members) { + if (ProjectUtils.isPlist(resource)) { + return; + } + } + ValidatorMessage msg = ValidatorMessage.create(ValidatorPropMessages + .getString("plist.File.Not.Present"), project); + msg.setAttribute(IMarker.SEVERITY, IMarker.SEVERITY_ERROR); + + result.add(msg); + } +} diff -r 024f49774fbb -r 2196d1511a17 org.symbian.tools.wrttools/src/org/symbian/tools/wrttools/core/validator/HtmlValidator.java --- a/org.symbian.tools.wrttools/src/org/symbian/tools/wrttools/core/validator/HtmlValidator.java Fri Feb 05 08:19:36 2010 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,259 +0,0 @@ -/** - * 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.core.validator; - -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.text.MessageFormat; -import java.util.List; -import java.util.Stack; -import java.util.logging.Level; -import java.util.logging.Logger; - -import org.w3c.tidy.Node; -import org.w3c.tidy.Tidy; -import org.w3c.tidy.TidyMessage; -import org.w3c.tidy.TidyMessageListener; - -import org.symbian.tools.wrttools.core.report.Message; -import org.symbian.tools.wrttools.core.report.MessageHandler; -import org.symbian.tools.wrttools.core.status.IWRTConstants; -import org.symbian.tools.wrttools.core.widgetmodel.WidgetModel; -import org.symbian.tools.wrttools.util.FileUtil; -import org.symbian.tools.wrttools.util.Util; - -/** -* Html Validator -* Accepts the MessageManager . -* Accept File projDir. -* Use xmlParser to get all elements in a stack. -* Call rule methods() passing the MessageManager and the stack of elements. -* -* @author Sailaja duvvuri -*/ -public class HtmlValidator implements IValidator { - boolean htmlValidationStaus; - private String htmlFileName=null; - private String htmlPlistFileName=null; - private File htmlFile=null; - private Logger log = Logger.getLogger(getClass().getName()); - private MessageHandler messageHandler; - private WidgetModel widgetModel; - private boolean allRulesPassed; - - - - public WidgetModel getWidgetModel() { - return widgetModel; - } - - public void setWidgetModel(WidgetModel widgetModel) { - this.widgetModel = widgetModel; - } - - - public MessageHandler getMessageHandler() { - return messageHandler; - } - - - public void setMessageHandler(MessageHandler messageHandler) { - this.messageHandler = messageHandler; - } - - public boolean validate( File projDir) { - - Stack htmlElements = null; - FileUtil fileUtil = new FileUtil(); - List dirList = fileUtil.getCurrDirFiles(projDir); - htmlFileName=widgetModel.getMainHtml(); - - try { - - htmlFile = fileUtil.getFile(dirList, htmlFileName); - - if (htmlFile != null){ - htmlFileName = htmlFile.getName(); - if (widgetModel.getHtmlXmlFile()!=null) { - checkWellformed(htmlFile,true); - for(int i=0;i> - private boolean checkWellformed(File htmlfile, boolean isParsingNeeded) { - String userDir = System.getProperty("user.dir"); - String outputFile = userDir+ "/tidy.html"; - //htmlfile will behave as directory when src field in html is blank (src =""), so skipping that. - if(htmlfile.isDirectory()){ - return true; - } - InputStream inStream; - try { - inStream = new FileInputStream(htmlfile); - OutputStream outStream = new FileOutputStream(outputFile); - //Parsing here is required only for html, coz js, css files cannot have reference files. - //fixing bug 742 - if(isParsingNeeded){ - Tidy jtidy = new Tidy(); - TMessageListener msglis= new TMessageListener(); - jtidy.setMessageListener(msglis); - Node xmlDocument = jtidy.parse(inStream, outStream); - } - inStream.close(); - } catch (FileNotFoundException e) { - Message msg = new Message(); - msg.setMessageSource(IWRTConstants.VALIDATOR); - msg.setMessageKey("no.element"); - msg.setMessage(htmlfile.getName()+ " referred in main html" + " could not be found"); - msg.setFileTypeZip(messageHandler.isFileTypeZip()); - msg.setTargetObject(htmlfile.toString()); - msg.setFullPath(htmlfile.getAbsolutePath()); - msg.setSeverity(IWRTConstants.WARN); - msg.setRecommendAction(ValidatorPropMessages.getString("todo.no.html.element")); - messageHandler.publishMessage(msg); - Util.logEvent(log, Level.SEVERE, e); - log.severe(e.getMessage()); - } catch (IOException e) { - Util.logEvent(log, Level.SEVERE, e); - log.severe(e.getMessage()); - } - return false; -} - - public class TMessageListener implements TidyMessageListener { - - public void messageReceived(TidyMessage tdyMsg) { - - if (tdyMsg.getLevel().equals(TidyMessage.Level.ERROR)) { - log.info("line :" + tdyMsg.getLine()); - log.info("message :" + tdyMsg.getMessage()); - Message msg = new Message(); - msg.setMessageSource(IWRTConstants.VALIDATOR); - msg.setMessageKey("html.wellform.error"); - msg.setMessage(tdyMsg.getMessage()); - msg.setFileTypeZip(messageHandler.isFileTypeZip()); - msg.setTargetObject(htmlFileName); - msg.setFullPath(htmlFile.getAbsolutePath()); - msg.setSeverity(IWRTConstants.WARN); - msg.setLineNumber(tdyMsg.getLine()); - // msg.setRecommendAction(ValidatorPropMessages.getString("todo.correct.html.tag")+ - // tdyMsg.getLine()+" of "+htmlFileName); - Object[] arguments = { tdyMsg.getLine(), " of , ", htmlFileName }; - String message = MessageFormat.format(ValidatorPropMessages - .getString("todo.correct.html.tag") - + "{0}" + "{1}" + "{2}", arguments); - msg.setRecommendAction(message); - - // set all msg fields - // For generating TO DO list - messageHandler.publishMessage(msg); - allRulesPassed = false; - - } - - } - } -//////<<<-----------------------------------code for Jtidy---------------------------------------// - - -} \ No newline at end of file diff -r 024f49774fbb -r 2196d1511a17 org.symbian.tools.wrttools/src/org/symbian/tools/wrttools/core/validator/WidgetValidator.java --- a/org.symbian.tools.wrttools/src/org/symbian/tools/wrttools/core/validator/WidgetValidator.java Fri Feb 05 08:19:36 2010 -0800 +++ b/org.symbian.tools.wrttools/src/org/symbian/tools/wrttools/core/validator/WidgetValidator.java Fri Feb 05 09:19:20 2010 -0800 @@ -68,7 +68,6 @@ private boolean htmlVal; private MandatoryFilesValidator manFilevalidator; private PlistValidator plistValidator; - private HtmlValidator htmlValidator; private MessageHandler messageHandler; private IMessageListener msgListener; @@ -160,7 +159,6 @@ log.info("ValidateMandatoryFiles is done"); validatePlist( widgetProjFile); log.info("Validate plist is done"); - validateHtml( widgetProjFile); } catch (ReportException e) { Util.logEvent(log, Level.INFO, e); @@ -199,7 +197,6 @@ ValidateMandatoryFiles(widgetProjFile); validatePlist( widgetProjFile); log.info("Validate plist is done"); - validateHtml( widgetProjFile); } catch (ReportException e) { Util.logEvent(log, Level.INFO, e); @@ -276,32 +273,6 @@ return plistVal; } - - private boolean validateHtml(File fileName) throws ReportException { - log.info("validateHtml-->>-->>"); - try{ - emitStatus(ValidatorPropMessages.getString("validate.html.started")); -// statusHandler.emitStatus(status); - htmlValidator=new HtmlValidator(); - htmlValidator.setWidgetModel(widgetModel); - htmlValidator.setMessageHandler(getMessageHandler()); - - if (widgetModel.isHtmlPresent()) { - htmlValidator.setHtmlPlistFileName(widgetModel.getMainHtml()); - htmlVal = htmlValidator.validate( fileName); - } - log.info("validateHtml--<<--<<"); - emitStatus(ValidatorPropMessages.getString("validate.html.finished")); -// statusHandler.emitStatus(status); - } catch (Exception e) { - Util.logEvent(log, Level.INFO, e); - status.setStatusDescription("Exception "+e.getMessage()); - - } - return htmlVal; - - } - protected void emitStatus(String statusDescription) { WRTStatus status = new WRTStatus(); status.setStatusSource(IWRTConstants.StatusSourceType.VALIDATOR.name()); diff -r 024f49774fbb -r 2196d1511a17 org.symbian.tools.wrttools/src/org/symbian/tools/wrttools/util/CoreUtil.java --- a/org.symbian.tools.wrttools/src/org/symbian/tools/wrttools/util/CoreUtil.java Fri Feb 05 08:19:36 2010 -0800 +++ b/org.symbian.tools.wrttools/src/org/symbian/tools/wrttools/util/CoreUtil.java Fri Feb 05 09:19:20 2010 -0800 @@ -1,8 +1,15 @@ package org.symbian.tools.wrttools.util; +import java.text.MessageFormat; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + import org.eclipse.core.runtime.Platform; +import org.eclipse.jface.text.IRegion; +import org.eclipse.jface.text.Region; public class CoreUtil { + public static final String PROPERTY_PATTERN = "\\s*{0}\\s*\\s*\\s*(.*)\\s*"; public static boolean isWindows() { return "windows".equals(Platform.getOS()); @@ -15,4 +22,27 @@ public static boolean isLinux() { return "linux".equals(Platform.getOS()); } + + public static String getIndexFileName(String buffer) { + if (buffer != null) { + Matcher matcher = getPropertyLookupPattern("MainHTML").matcher(buffer); + if (matcher.find()) { + return matcher.group(1); + } + } + return null; + } + + public static Pattern getPropertyLookupPattern(String propertyName) { + return Pattern.compile(MessageFormat.format(PROPERTY_PATTERN, propertyName), Pattern.CASE_INSENSITIVE); + } + + public static IRegion getIndexFileNameRegion(String string) { + Matcher matcher = getPropertyLookupPattern("MainHTML").matcher(string); + if (matcher.find()) { + int start = matcher.start(1); + return new Region(start, matcher.end(1) - start); + } + return null; + } } diff -r 024f49774fbb -r 2196d1511a17 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 Feb 05 08:19:36 2010 -0800 +++ b/org.symbian.tools.wrttools/src/org/symbian/tools/wrttools/util/ProjectUtils.java Fri Feb 05 09:19:20 2010 -0800 @@ -217,4 +217,9 @@ ((IFolder) parent).create(false, true, new NullProgressMonitor()); } } + + public static boolean isPlist(IResource resource) { + return resource.getType() == IResource.FILE + && resource.getName().equalsIgnoreCase("info.plist"); + } } diff -r 024f49774fbb -r 2196d1511a17 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 Fri Feb 05 08:19:36 2010 -0800 +++ b/org.symbian.tools.wrttools/src/org/symbian/tools/wrttools/wizards/WrtWidgetWizard.java Fri Feb 05 09:19:20 2010 -0800 @@ -59,7 +59,6 @@ import org.eclipse.wst.jsdt.core.IIncludePathEntry; import org.eclipse.wst.jsdt.core.IJavaScriptProject; import org.eclipse.wst.jsdt.core.JavaScriptCore; -import org.eclipse.wst.jsdt.core.JavaScriptModelException; import org.eclipse.wst.jsdt.core.JsGlobalScopeContainerInitializer; import org.symbian.tools.wrttools.Activator; import org.symbian.tools.wrttools.core.ProjectTemplate; @@ -78,6 +77,7 @@ public WrtWidgetWizard() { setWindowTitle("New WRT Widget"); + setNeedsProgressMonitor(true); } public boolean performFinish() { @@ -135,17 +135,17 @@ ((IWrtIdeContainer) containerInitializer).populateProject(project, new SubProgressMonitor(progressMonitor, perContainer)); } } - IJavaScriptProject js = JavaScriptCore.create(project); - IIncludePathEntry[] rawIncludepath = js.getRawIncludepath(); - int preconfigured = rawIncludepath.length; - IIncludePathEntry[] newIncludepath = new IIncludePathEntry[preconfigured + libraryIds.length]; - System.arraycopy(rawIncludepath, 0, newIncludepath, 0, preconfigured); - for (int i = 0; i < libraryIds.length; i++) { - String string = libraryIds[i]; - IIncludePathEntry entry = JavaScriptCore.newContainerEntry(new Path(string)); - newIncludepath[preconfigured + i] = entry; - } - js.setRawIncludepath(newIncludepath, new SubProgressMonitor(progressMonitor, 10)); +// IJavaScriptProject js = JavaScriptCore.create(project); +// IIncludePathEntry[] rawIncludepath = js.getRawIncludepath(); +// int preconfigured = rawIncludepath.length; +// IIncludePathEntry[] newIncludepath = new IIncludePathEntry[preconfigured + libraryIds.length]; +// System.arraycopy(rawIncludepath, 0, newIncludepath, 0, preconfigured); +// for (int i = 0; i < libraryIds.length; i++) { +// String string = libraryIds[i]; +// IIncludePathEntry entry = JavaScriptCore.newContainerEntry(new Path(string)); +// newIncludepath[preconfigured + i] = entry; +// } +// js.setRawIncludepath(newIncludepath, new SubProgressMonitor(progressMonitor, 10)); progressMonitor.done(); }