diff options
15 files changed, 611 insertions, 115 deletions
diff --git a/WebContent/VAADIN/themes/base/colorpicker/colorpicker.scss b/WebContent/VAADIN/themes/base/colorpicker/colorpicker.scss index bd4420b55b..b2558d8df3 100644 --- a/WebContent/VAADIN/themes/base/colorpicker/colorpicker.scss +++ b/WebContent/VAADIN/themes/base/colorpicker/colorpicker.scss @@ -86,13 +86,13 @@ opacity: 0; } -.#{$name}-popup #rgb-gradient .#{$name}-gradient-background { +.#{$name}-popup .rgb-gradient .#{$name}-gradient-background { width: 220px; height: 220px; background: url(images/gradient2.png); } -.#{$name}-popup #hsv-gradient .#{$name}-gradient-foreground { +.#{$name}-popup .hsv-gradient .#{$name}-gradient-foreground { background: url(images/gradient.png); } diff --git a/WebContent/license.html b/WebContent/license.html index 10d760a782..272d153f89 100644 --- a/WebContent/license.html +++ b/WebContent/license.html @@ -18,31 +18,231 @@ <div id="content"> - <h1>Licensing</h1> - - <p> - <strong><i>Vaadin Framework</i> is intended to be freely - used and extended by anyone without any fees</strong>. In order to guarantee - these freedoms, <i>Vaadin Framework</i> is licensed under the Apache - License, Version 2.0. - </p> - <p>Vaadin Framework is built using Google Web Toolkit, which is - also licensed under the Apache License, v 2.0. Development using - Vaadin Framework or use of applications created with Vaadin Framework - do not require Google Web Toolkit. Vaadin Framework includes a - precompiled "widget set", which uses only Apache 2 licensed code from - Google Web Toolkit.</p> - - <p> - Extending Vaadin Framework requires use of Google Web Toolkit. For - details on Google Web Toolkit licensing, see <a - href="http://code.google.com/webtoolkit/terms.html">http://code.google.com/webtoolkit/terms.html</a>. - </p> - <p> - If you have any questions on licensing terms, please contact us - through <a href="http://vaadin.com/contact">the vaadin.com - web-site</a>. - </p> + <h1>Licensing</h1> + + <p> + <strong><i>Vaadin Framework</i> is intended to be freely used and extended by + anyone without any fees</strong>. In order to guarantee these freedoms, <i>Vaadin + Framework</i> is licensed under the Apache License, Version 2.0, as given below. + </p> + + <p> + Third-party software included in this distribution is provided under the same + license or compatible licenses, as listed in the section below. + </p> + + <p> + The license of the Vaadin Framework is for this product only and may not apply to + all Vaadin add-ons, such as those available from Vaadin Directory, or other Vaadin + products, which may have different licenses. + </p> + + <p> + If you have any questions on licensing terms, please contact us through <a + href="http://vaadin.com/contact">the vaadin.com web-site</a>. + </p> + + <h3>Included Third-Party Software and Licenses</h3> + + <table border="1" cellspacing="1"> + <thead style="background: #ccc;"> + <tr><th>Package</th><th>License</th></tr> + </thead> + <tbody> + <tr> + <td>Apache Ant<br/> + Ant Launcher</td> + <td><a href="http://www.apache.org/licenses/">Apache License, Version 2.0</a></td> + </tr> + + <tr> + <td>Apache Commons<br/> + BCEL<br/> + Beanutils<br/> + CLI<br/> + Codec<br/> + Collections<br/> + Digester 3<br/> + Discovery<br/> + EL<br/> + IO<br/> + Jexl<br/> + Lang<br/> + Logging<br/> + Math<br/> + Modeler</td> + <td><a href="http://www.apache.org/licenses/">Apache License, Version 2.0</a></td> + </tr> + + <tr> + <td>Apache HttpComponents Core</td> + <td><a href="http://www.apache.org/licenses/">Apache License, Version 2.0</a></td> + </tr> + + <tr> + <td>Apache Jakarta Regexp</td> + <td><a href="http://www.apache.org/licenses/">Apache License, Version 2.0</a></td> + </tr> + + <tr> + <td>Apache James Server<br/> + Apache James Mime4j</td> + <td><a href="http://www.apache.org/licenses/">Apache License, Version 2.0</a></td> + </tr> + + <tr> + <td>Apache Tapestry</td> + <td><a href="http://www.apache.org/licenses/">Apache License, Version 2.0</a></td> + </tr> + + <tr> + <td>Apache Tomcat<br/>Catalina<br/>Coyote<br/>Jasper<br/>JK<br/>Naming</td> + <td><a href="http://www.apache.org/licenses/">Apache License, Version 2.0</a></td> + </tr> + + <tr> + <td>Apache Xalan</td> + <td><a href="http://www.apache.org/licenses/">Apache License, Version 2.0</a></td> + </tr> + + <tr> + <td>Apache Xerces</td> + <td><a href="http://www.apache.org/licenses/">Apache License, Version 2.0</a></td> + </tr> + + <tr> + <td>Args4j</td> + <td><a href="https://github.com/kohsuke/args4j/blob/master/args4j/LICENSE.txt">The MIT License (MIT)</a></td> + </tr> + + <tr> + <td>Bean Validation (JSR-303) API</td> + <td><a href="http://www.apache.org/licenses/">Apache License, Version 2.0</a></td> + </tr> + + <tr> + <td>CSS Parser</td> + <td><a href="http://www.gnu.org/licenses/old-licenses/lgpl-2.0.html">GNU Lesser General Public License, version 2.0</a></td> + </tr> + + <tr> + <td>CUP</td> + <td><a href="http://www.cs.princeton.edu/~appel/modern/java/CUP/#LICENSE">CUP Open Source License</a></td> + </tr> + + <tr> + <td>CyberNeko HTML Parser</td> + <td><a href="http://www.apache.org/licenses/">Apache License, Version 2.0</a></td> + </tr> + + <tr> + <td>Eclipse + JDT</td> + <td><a href="http://eclipse.org/org/documents/epl-v10.php">Eclipse Public License - v 1.0</a></td> + </tr> + + <tr> + <td>Flute</td> + <td><a href="http://www.w3.org/Consortium/Legal/copyright-software-19980720">W3C Software Copyright Notice and License</a></td> + </tr> + + <tr> + <td>Google AppEngine API</td> + <td><a href="https://developers.google.com/appengine/terms">Google App Engine Terms of Service</a></td> + </tr> + + <tr> + <td>Google Closure Compiler</td> + <td><a href="http://www.apache.org/licenses/">Apache License, Version 2.0</a></td> + </tr> + + <tr> + <td>Google Collections</td> + <td><a href="http://www.apache.org/licenses/">Apache License, Version 2.0</a></td> + </tr> + + <tr> + <td>Google Protocol Buffers</td> + <td><a href="http://protobuf.googlecode.com/svn/trunk/COPYING.txt">BSD License</a></td> + </tr> + + <tr> + <td>Google GWT</td> + <td><a href="http://www.apache.org/licenses/">Apache License, Version 2.0</a></td> + </tr> + + <tr> + <td>Guava</td> + <td><a href="http://www.apache.org/licenses/">Apache License, Version 2.0</a></td> + </tr> + + <tr> + <td>HtmlUnit</td> + <td><a href="http://www.apache.org/licenses/">Apache License, Version 2.0</a></td> + </tr> + + <tr> + <td>ICU</td> + <td><a href="http://source.icu-project.org/repos/icu/icu/trunk/license.html">ICU License</a></td> + </tr> + + <tr> + <td>Jetty</td> + <td><a href="http://www.google.com/url?q=http%3A%2F%2Fwww.eclipse.org%2Fjetty%2Flicenses.php&sa=D&sntz=1&usg=AFQjCNEwpnb4RRBBG6c4gF-zsuA9eaNJuA">Apache License, Version 2.0 OR Eclipse 1.0 (see exceptions)</a></td> + </tr> + + <tr> + <td>Jsilver</td> + <td><a href="http://www.apache.org/licenses/">Apache License, Version 2.0</a></td> + </tr> + + <tr> + <td>JSON</td> + <td><a href="http://www.json.org/license.html">The JSON License</a></td> + </tr> + + <tr> + <td>JSoup</td> + <td><a href="http://jsoup.org/license">The MIT License</a></td> + </tr> + + <tr> + <td>JUnit</td> + <td><a href="http://www.junit.org/license">Common Public License (CPL) - v 1.0</a></td> + </tr> + + <!-- Includes portal-service --> + <tr> + <td>Liferay Service Interfaces</td> + <td><a href="http://www.gnu.org/licenses/lgpl.html">GNU Lesser General Public License 2.1 or newer</a></td> + </tr> + + <tr> + <td>Mozilla Rhino</td> + <td><a href="http://www.mozilla.org/MPL/1.1/">Mozilla Public License v. 1.1</a></td> + </tr> + + <tr> + <td>MX4J</td> + <td><a href="http://mx4j.sourceforge.net/docs/ch01s06.html">The MX4J License</a></td> + </tr> + + <tr> + <td>SAC: The Simple API for CSS</td> + <td><a href="http://www.w3.org/Consortium/Legal/copyright-software-19980720">W3C Software Copyright Notice and License</a></td> + </tr> + + <tr> + <td>SmartSprites</td> + <td><a href="https://github.com/carrotsearch/smartsprites/blob/master/smartsprites.LICENSE">BSD License</a></td> + </tr> + + <tr> + <td>Swingworker</td> + <td><a href="http://www.gnu.org/licenses/lgpl-2.1.html">GNU Lesser General Public License 2.1</a></td> + </tr> + </tbody> + </table> <h1>Copyright and trademarks</h1> <p> diff --git a/WebContent/release-notes.html b/WebContent/release-notes.html index 313ed85a9e..b0522b3727 100644 --- a/WebContent/release-notes.html +++ b/WebContent/release-notes.html @@ -51,8 +51,9 @@ <p> <b>Vaadin</b> is a Java framework for building modern web applications that look - great, perform well and make you and your users happy. <b>Vaadin</b> and is - available under the Apache 2 license (see <tt>license.html</tt>). + great, perform well and make you and your users happy. <b>Vaadin</b> is + available under the Apache License, Version 2.0 (see the <tt>license.html</tt> in + the Vaadin ZIP or JAR package). </p> <p> @@ -69,8 +70,7 @@ </ul> <p> - It is also available as a ZIP package downloadable from <a - href="http://vaadin.com/download">Vaadin Download page</a>. + It is also available as a ZIP package downloadable from <a href="http://vaadin.com/download">Vaadin Download page</a>. </p> <h3 id="package">Package Contents</h3> @@ -81,7 +81,7 @@ <li>Separate server-side (<tt>vaadin-server</tt>) and client-side (<tt>vaadin-client</tt>, <tt>vaadin-client-compiler</tt>) development libraries</li> <li>Precompiled widget set (<tt>vaadin-client-compiled</tt>) for server-side development</li> <li>Shared library (<tt>vaadin-shared</tt>) for both server- and client-side libraries</li> - <li>Built-in themes (<tt>vaadin-themes</tt>) and the theme compiler (<tt>vaadin-theme-compiler</tt>) + <li>Built-in themes (<tt>vaadin-themes</tt>) and the theme compiler (<tt>vaadin-theme-compiler</tt>)</li> <li>Dependency libraries provided under the <tt>lib/</tt> folder</li> </ul> @@ -159,7 +159,7 @@ </li> <li><b>Form</b> is deprecated and form hand is replaced with the <b>FieldGroup</b></li> <li>Get computed style of a component from the browser</li> - <li>Support for border, padding, and margin in core layout components</li> + <li>Support for border, padding, and margin in core layout components</li></ul> <ul> <li>Applications are now written by extending the <b>UI</b> class <ul> @@ -192,22 +192,17 @@ </p> <p> - Please see the release notes for <a - href="http://vaadin.com/download/prerelease/7.0/7.0.0/7.0.0.alpha1/release-notes.html">alpha1</a>, - <a - href="http://vaadin.com/download/prerelease/7.0/7.0.0/7.0.0.alpha2/release-notes.html">alpha2</a>, - <a - href="http://vaadin.com/download/prerelease/7.0/7.0.0/7.0.0.alpha3/release-notes.html">alpha3</a>, - and <a - href="http://vaadin.com/download/prerelease/7.0/7.0.0/7.0.0.beta1/release-notes.html">beta1</a> + Please see the release notes for <a href="http://vaadin.com/download/prerelease/7.0/7.0.0/7.0.0.alpha1/release-notes.html">alpha1</a>, + <a href="http://vaadin.com/download/prerelease/7.0/7.0.0/7.0.0.alpha2/release-notes.html">alpha2</a>, + <a href="http://vaadin.com/download/prerelease/7.0/7.0.0/7.0.0.alpha3/release-notes.html">alpha3</a>, + and <a href="http://vaadin.com/download/prerelease/7.0/7.0.0/7.0.0.beta1/release-notes.html">beta1</a> for the lists of where the major enhancements were introduced. </p> <h3 id="changelog">ChangeLog</h3> <p> - For a complete list of changes in this release, please see the <a - href="http://dev.vaadin.com/query?status=closed&group=resolution&milestone=Vaadin+@version@">list + For a complete list of changes in this release, please see the <a href="http://dev.vaadin.com/query?status=closed&group=resolution&milestone=Vaadin+@version@">list of closed tickets</a>. </p> @@ -217,8 +212,7 @@ All Vaadin 6 applications need some changes when migrating to Vaadin 7. The most obvious changes are in the application/window API and require extending either <b>UI</b> or <b>UI.LegacyApplication</b> instead of <b>Application</b>. A detailed - list of migration changes are given in the <a - href="http://dev.vaadin.com/wiki/Vaadin7/MigrationGuide">Vaadin 7 Migration + list of migration changes are given in the <a href="http://dev.vaadin.com/wiki/Vaadin7/MigrationGuide">Vaadin 7 Migration Guide</a>. </p> @@ -235,35 +229,30 @@ <h2 id="dependencies">Vaadin @version@ Dependencies</h2> - <h3>Dependencies Included in Installation package</h3> - <p> - The Vaadin ZIP installation package includes the following dependencies in the - <tt>lib</tt> subfolder: + When using Maven, Ivy, Gradle, or other dependency management system, all Vaadin + dependencies are downloaded automatically. This is also the case when using the + Vaadin Plugin for Eclipse. </p> - <ul> - <li>Apache Ant (<tt>ant-*.jar</tt>)</li> - <li>Args4j (<tt>args4j-*.jar</tt>)</li> - <li>Apache Commons CLI, Collections, Discovery, IO, Lang, Logging, and Math (<tt>commons-*.jar</tt>)</li> - <li>CSS Parser (<tt>cssparser-*.jar</tt>)</li> - <li>Flute (<tt>flute-*.jar</tt>)</li> - <li>Google Collections Library (<tt>google-collections-*.jar</tt>)</li> - <li>JSON (<tt>json-*.jar</tt>)</li> - <li>jsoup (<tt>jsoup-*.jar</tt>)</li> - <li>JUnit (<tt>junit-*.jar</tt>)</li> - <li><tt>portal-service-*.jar</tt></li> - <li>SAC (<tt>sac-*.jar</tt>)</li> - <li>SmartSprites (<tt>smartsprites-*.jar</tt>)</li> - <li>Validation API (<tt>validation-*.jar</tt>)</li> - </ul> + <p> + The Vaadin ZIP installation package includes the dependencies in the <tt>lib</tt> + subfolder. These need to be copied to the <tt>WEB-INF/lib</tt> folder of the web + application that uses Vaadin. + </p> + + <p> + The dependencies are listed in the <a href="#terms">Vaadin Framework Terms and + Conditions</a>. Some are explicit dependencies packaged and distributed as + separate JARs, while some are included inside other libraries. + </p> <h3>Bean Validation</h3> <p> - If you want to use the bean validation feature in Vaadin 7, you need a Bean - Validation API implementation. You need to install the JAR in the - <tt>WEB-INF/lib</tt> directory. + If you use the bean validation feature in Vaadin 7, you need a Bean Validation API + implementation. You need to install the implementation JAR in the + <tt>WEB-INF/lib</tt> directory of the web application that uses validation. </p> <h2 id="upgrading">Upgrading to Vaadin @version-minor@</h2> @@ -273,8 +262,7 @@ <p> This release requires that you use the <i>experimental</i> Vaadin Plugin for Eclipse. Its update site is - <tt>http://vaadin.com/eclipse/experimental</tt>. Please see the <a - href="http://vaadin.com/eclipse">installation instructions</a> for more details. + <tt>http://vaadin.com/eclipse/experimental</tt>. Please see the <a href="http://vaadin.com/eclipse">installation instructions</a> for more details. </p> <h3>General Upgrading Instructions</h3> @@ -324,14 +312,13 @@ <tt>vaadin.jar</tt>). Additionally, the contents of the <tt>vaadin-client-compiled</tt> and <tt>vaadin-themes</tt> must be extracted to the <tt>ROOT/html/VAADIN</tt> directory in the Liferay - installation. If your portal uses custom widgets, install the latest version of <a - href="http://vaadin.com/directory#addon/vaadin-control-panel-for-liferay">Vaadin + installation. If your portal uses custom widgets, install the latest version of <a href="http://vaadin.com/directory#addon/vaadin-control-panel-for-liferay">Vaadin Control Panel for Liferay</a> for easy widget set compilation - when it is available - the add-on is not compatible with Vaadin @version@ at the time of this - Vaadin release. <!-- TODO: Remove note when done --> + Vaadin release. <!-- TODO: Remove note when done --></t> </p> - <h2 id="gae">Notes and Limitations for Google App Engine</h4> + <h2 id="gae">Notes and Limitations for Google App Engine</h4></h2> <p>The following instructions and limitations apply when you run a Vaadin application under the Google App Engine.</p> @@ -392,8 +379,7 @@ </ul> <p> - For other known problems, see open tickets at developer site <a - href="http://dev.vaadin.com/">dev.vaadin.com</a>. + For other known problems, see open tickets at developer site <a href="http://dev.vaadin.com/">dev.vaadin.com</a>. </p> <h2 id="supportedversions">Supported Technologies</h2> @@ -498,12 +484,12 @@ <li><a href="http://dev.vaadin.com">dev.vaadin.com - Bug tracker</a></li> - <li><a - href="http://dev.vaadin.com/wiki/Vaadin/Development/StartingVaadin7Development">How + <li><a href="http://dev.vaadin.com/wiki/Vaadin/Development/StartingVaadin7Development">How to get the source code of Vaadin</a> </li> </ul> - </div> <!-- /content--> + + </div> <!-- /content--> <div id="footer"> <span class="slogan"><strong>vaadin <em>}></em> </strong> diff --git a/client-compiler/ivy.xml b/client-compiler/ivy.xml index 1340ab2c5b..ee36e4e261 100644 --- a/client-compiler/ivy.xml +++ b/client-compiler/ivy.xml @@ -25,6 +25,8 @@ rev="${vaadin.version}" conf="build" /> <dependency org="com.vaadin" name="vaadin-client" rev="${vaadin.version}" conf="build" /> + <dependency org="com.vaadin" name="vaadin-theme-compiler" + rev="${vaadin.version}" conf="build" /> <dependency org="commons-collections" name="commons-collections" rev="3.1" conf="build,ide -> default" /> diff --git a/client-compiler/src/com/vaadin/sass/linker/SassLinker.java b/client-compiler/src/com/vaadin/sass/linker/SassLinker.java new file mode 100644 index 0000000000..82a228a166 --- /dev/null +++ b/client-compiler/src/com/vaadin/sass/linker/SassLinker.java @@ -0,0 +1,195 @@ +package com.vaadin.sass.linker; + +import java.io.ByteArrayInputStream; +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.util.ArrayList; +import java.util.Date; +import java.util.List; + +import org.w3c.css.sac.CSSException; + +import com.google.gwt.core.ext.LinkerContext; +import com.google.gwt.core.ext.TreeLogger; +import com.google.gwt.core.ext.UnableToCompleteException; +import com.google.gwt.core.ext.linker.AbstractLinker; +import com.google.gwt.core.ext.linker.ArtifactSet; +import com.google.gwt.core.ext.linker.EmittedArtifact; +import com.google.gwt.core.ext.linker.LinkerOrder; +import com.google.gwt.core.ext.linker.LinkerOrder.Order; +import com.google.gwt.core.ext.linker.Shardable; +import com.vaadin.sass.internal.ScssStylesheet; + +/** + * Pre-linker that checks for the existence of SASS files in public folders, + * compiles them to CSS files with the SassCompiler from Vaadin and adds the CSS + * back into the artifact. + * + */ +@LinkerOrder(Order.PRE) +@Shardable +public class SassLinker extends AbstractLinker { + + @Override + public String getDescription() { + return "Compiling SASS files in public folders to standard CSS"; + } + + @Override + public ArtifactSet link(TreeLogger logger, LinkerContext context, + ArtifactSet artifacts, boolean onePermutation) + throws UnableToCompleteException { + + if (!onePermutation) { + // The artifact to return + ArtifactSet toReturn = new ArtifactSet(artifacts); + + // The temporary sass files provided from the artefacts + List<FileInfo> sassFiles = new ArrayList<FileInfo>(); + + // The public files are provided as inputstream, but the compiler + // needs real files, as they can contain references to other + // files. They will be stored here, with their relative paths intact + String tempFolderName = new Date().getTime() + File.separator; + File tempFolder = createTempDir(tempFolderName); + + // Create the temporary files + for (EmittedArtifact resource : artifacts + .find(EmittedArtifact.class)) { + + String partialPath = resource.getPartialPath(); + if (partialPath.endsWith(".scss")) { + + String fileName = partialPath; + File path = tempFolder; + + int separatorIndex = fileName.lastIndexOf(File.separator); + if (-1 != separatorIndex) { + fileName = fileName.substring(separatorIndex + 1); + + String filePath = partialPath.substring(0, + separatorIndex); + path = createTempDir(tempFolderName + filePath); + } + + File tempfile = new File(path, fileName); + try { + boolean fileCreated = tempfile.createNewFile(); + if (fileCreated) { + + // write the received inputstream to the temp file + writeFromInputStream(resource.getContents(logger), + tempfile); + + // Store the file info for the compilation + sassFiles.add(new FileInfo(tempfile, partialPath)); + + // In my oppinion, the SASS file does not need to be + // output to the web content, as they can't be used + // there + toReturn.remove(resource); + } + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + } + + // Compile the files and store them in the artifact + logger.log(TreeLogger.INFO, "Processing " + sassFiles.size() + + " Sass file(s)"); + for (FileInfo fileInfo : sassFiles) { + logger.log(TreeLogger.INFO, " " + fileInfo.originalScssPath + + " -> " + fileInfo.getOriginalCssPath()); + + ScssStylesheet scss; + + try { + scss = ScssStylesheet.get(fileInfo.getAbsolutePath()); + scss.compile(); + InputStream is = new ByteArrayInputStream(scss.toString() + .getBytes()); + + toReturn.add(this.emitInputStream(logger, is, + fileInfo.getOriginalCssPath())); + } catch (CSSException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (IOException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } catch (Exception e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + + return toReturn; + } + + return artifacts; + } + + private void writeFromInputStream(InputStream contents, File tempfile) + throws IOException { + // write the inputStream to a FileOutputStream + OutputStream out = new FileOutputStream(tempfile); + + int read = 0; + byte[] bytes = new byte[1024]; + + while ((read = contents.read(bytes)) != -1) { + out.write(bytes, 0, read); + } + + contents.close(); + out.flush(); + out.close(); + } + + /** + * Create folder in temporary space on disk. + * + * @param partialPath + * @return + */ + private File createTempDir(String partialPath) { + String baseTempPath = System.getProperty("java.io.tmpdir"); + + File tempDir = new File(baseTempPath + File.separator + partialPath); + if (!tempDir.exists()) { + tempDir.mkdir(); + } + + tempDir.deleteOnExit(); + return tempDir; + } + + /** + * Temporal storage for file info from Artifact + * + */ + private class FileInfo { + private String originalScssPath; + private File file; + + public FileInfo(File file, String originalScssPath) { + this.file = file; + this.originalScssPath = originalScssPath; + } + + public String getAbsolutePath() { + return file.getAbsolutePath(); + } + + public String getOriginalCssPath() { + return originalScssPath.substring(0, originalScssPath.length() - 5) + + ".css"; + } + } + +} diff --git a/client/src/com/vaadin/client/ui/colorpicker/VColorPickerGradient.java b/client/src/com/vaadin/client/ui/colorpicker/VColorPickerGradient.java index 6defc57996..6a3f50cecc 100644 --- a/client/src/com/vaadin/client/ui/colorpicker/VColorPickerGradient.java +++ b/client/src/com/vaadin/client/ui/colorpicker/VColorPickerGradient.java @@ -1,15 +1,17 @@ package com.vaadin.client.ui.colorpicker; +import com.google.gwt.dom.client.Style.Unit; import com.google.gwt.event.dom.client.MouseDownEvent; import com.google.gwt.event.dom.client.MouseDownHandler; import com.google.gwt.event.dom.client.MouseMoveEvent; import com.google.gwt.event.dom.client.MouseMoveHandler; import com.google.gwt.event.dom.client.MouseUpEvent; import com.google.gwt.event.dom.client.MouseUpHandler; -import com.google.gwt.user.client.DOM; +import com.google.gwt.user.client.Element; import com.google.gwt.user.client.ui.AbsolutePanel; import com.google.gwt.user.client.ui.FocusPanel; import com.google.gwt.user.client.ui.HTML; +import com.vaadin.client.ui.SubPartAware; /** * Client side implementation for ColorPickerGradient. @@ -18,7 +20,7 @@ import com.google.gwt.user.client.ui.HTML; * */ public class VColorPickerGradient extends FocusPanel implements - MouseDownHandler, MouseUpHandler, MouseMoveHandler { + MouseDownHandler, MouseUpHandler, MouseMoveHandler, SubPartAware { /** Set the CSS class name to allow styling. */ public static final String CLASSNAME = "v-colorpicker-gradient"; @@ -28,6 +30,7 @@ public class VColorPickerGradient extends FocusPanel implements public static final String CLASSNAME_HIGHERBOX = CLASSNAME + "-higherbox"; public static final String CLASSNAME_CONTAINER = CLASSNAME + "-container"; public static final String CLASSNAME_CLICKLAYER = CLASSNAME + "-clicklayer"; + private static final String CLICKLAYER_ID = "clicklayer"; private final HTML background; private final HTML foreground; @@ -41,6 +44,9 @@ public class VColorPickerGradient extends FocusPanel implements private int cursorX; private int cursorY; + private int width = 220; + private int height = 220; + /** * Instantiates the client side component for a color picker gradient. */ @@ -49,9 +55,6 @@ public class VColorPickerGradient extends FocusPanel implements setStyleName(CLASSNAME); - int width = 220; - int height = 220; - background = new HTML(); background.setStyleName(CLASSNAME_BACKGROUND); background.setPixelSize(width, height); @@ -107,7 +110,11 @@ public class VColorPickerGradient extends FocusPanel implements * @param bgColor */ protected void setBGColor(String bgColor) { - background.getElement().getStyle().setProperty("background", bgColor); + if (bgColor == null) { + background.getElement().getStyle().clearBackgroundColor(); + } else { + background.getElement().getStyle().setBackgroundColor(bgColor); + } } @Override @@ -148,29 +155,41 @@ public class VColorPickerGradient extends FocusPanel implements cursorX = x; cursorY = y; if (x >= 0) { - DOM.setStyleAttribute(lowercross.getElement(), "width", - String.valueOf(x) + "px"); + lowercross.getElement().getStyle().setWidth(x, Unit.PX); } if (y >= 0) { - DOM.setStyleAttribute(lowercross.getElement(), "top", - String.valueOf(y) + "px"); + lowercross.getElement().getStyle().setTop(y, Unit.PX); } if (y >= 0) { - DOM.setStyleAttribute(lowercross.getElement(), "height", - String.valueOf((background.getOffsetHeight() - y)) + "px"); + lowercross.getElement().getStyle().setHeight(height - y, Unit.PX); } if (x >= 0) { - DOM.setStyleAttribute(highercross.getElement(), "width", - String.valueOf((background.getOffsetWidth() - x)) + "px"); + highercross.getElement().getStyle().setWidth(width - x, Unit.PX); } if (x >= 0) { - DOM.setStyleAttribute(highercross.getElement(), "left", - String.valueOf(x) + "px"); + highercross.getElement().getStyle().setLeft(x, Unit.PX); } if (y >= 0) { - DOM.setStyleAttribute(highercross.getElement(), "height", - String.valueOf((y)) + "px"); + highercross.getElement().getStyle().setHeight(y, Unit.PX); + } + } + + @Override + public Element getSubPartElement(String subPart) { + if (subPart.equals(CLICKLAYER_ID)) { + return clicklayer.getElement(); } + + return null; + } + + @Override + public String getSubPartName(Element subElement) { + if (clicklayer.getElement().isOrHasChild(subElement)) { + return CLICKLAYER_ID; + } + + return null; } } diff --git a/client/src/com/vaadin/client/ui/dd/VDragAndDropManager.java b/client/src/com/vaadin/client/ui/dd/VDragAndDropManager.java index ae14218fff..ac1ae72877 100644 --- a/client/src/com/vaadin/client/ui/dd/VDragAndDropManager.java +++ b/client/src/com/vaadin/client/ui/dd/VDragAndDropManager.java @@ -84,7 +84,14 @@ public class VDragAndDropManager { currentDrag.setCurrentGwtEvent(nativeEvent); updateDragImagePosition(); - Element targetElement = Element.as(nativeEvent.getEventTarget()); + Node targetNode = Node.as(nativeEvent.getEventTarget()); + Element targetElement; + if (Element.is(targetNode)) { + targetElement = Element.as(targetNode); + } else { + targetElement = targetNode.getParentElement(); + } + if (Util.isTouchEvent(nativeEvent) || (dragElement != null && dragElement .isOrHasChild(targetElement))) { diff --git a/server/src/com/vaadin/ui/components/colorpicker/ColorPickerGradient.java b/server/src/com/vaadin/ui/components/colorpicker/ColorPickerGradient.java index ddd61f37b2..1bff71f0f7 100644 --- a/server/src/com/vaadin/ui/components/colorpicker/ColorPickerGradient.java +++ b/server/src/com/vaadin/ui/components/colorpicker/ColorPickerGradient.java @@ -52,9 +52,6 @@ public class ColorPickerGradient extends AbstractComponent implements /** The y-coordinate. */ private int y = 0; - /** The background color. */ - private Color backgroundColor; - /** * Instantiates a new color picker gradient. * @@ -65,7 +62,7 @@ public class ColorPickerGradient extends AbstractComponent implements */ public ColorPickerGradient(String id, Coordinates2Color converter) { registerRpc(rpc); - getState().id = id; + addStyleName(id); // width and height must be set here instead of in theme, otherwise // coordinate calculations fail getState().width = "220px"; @@ -103,7 +100,6 @@ public class ColorPickerGradient extends AbstractComponent implements * the new background color */ public void setBackgroundColor(Color color) { - backgroundColor = color; getState().bgColor = color.getCSS(); } diff --git a/theme-compiler/src/com/vaadin/sass/internal/ScssStylesheet.java b/theme-compiler/src/com/vaadin/sass/internal/ScssStylesheet.java index 2a5d617a6b..6c759167c7 100644 --- a/theme-compiler/src/com/vaadin/sass/internal/ScssStylesheet.java +++ b/theme-compiler/src/com/vaadin/sass/internal/ScssStylesheet.java @@ -20,6 +20,7 @@ import java.io.File; import java.io.IOException; import java.util.ArrayList; import java.util.Arrays; +import java.util.Collections; import java.util.HashMap; import java.util.HashSet; import java.util.Map; @@ -217,9 +218,7 @@ public class ScssStylesheet extends Node { node.traverse(); - @SuppressWarnings("unchecked") - HashMap<String, VariableNode> variableScope = (HashMap<String, VariableNode>) variables - .clone(); + Map<String, VariableNode> variableScope = openVariableScope(); // the size of the child list may change on each iteration: current node // may get deleted and possibly other nodes have been inserted where it @@ -232,8 +231,7 @@ public class ScssStylesheet extends Node { } } - variables.clear(); - variables.putAll(variableScope); + closeVariableScope(variableScope); // clean up insert point so that processing of the next block will // insert after that block @@ -248,6 +246,34 @@ public class ScssStylesheet extends Node { } } + /** + * Start a new scope for variables. Any variables set or modified after + * opening a new scope are only valid until the scope is closed, at which + * time they are replaced with their old values. + * + * @return old scope to give to a paired {@link #closeVariableScope(Map)} + * call at the end of the scope (unmodifiable map). + */ + public static Map<String, VariableNode> openVariableScope() { + @SuppressWarnings("unchecked") + HashMap<String, VariableNode> variableScope = (HashMap<String, VariableNode>) variables + .clone(); + return Collections.unmodifiableMap(variableScope); + } + + /** + * End a scope for variables, replacing all active variables with those from + * the original scope (obtained from {@link #openVariableScope()}). + * + * @param originalScope + * original scope + */ + public static void closeVariableScope( + Map<String, VariableNode> originalScope) { + variables.clear(); + variables.putAll(originalScope); + } + public void removeEmptyBlocks(Node node) { // depth first for avoiding re-checking parents of removed nodes for (Node child : new ArrayList<Node>(node.getChildren())) { diff --git a/theme-compiler/src/com/vaadin/sass/internal/tree/MixinNode.java b/theme-compiler/src/com/vaadin/sass/internal/tree/MixinNode.java index d92e3ebe9d..9fa7e369c0 100644 --- a/theme-compiler/src/com/vaadin/sass/internal/tree/MixinNode.java +++ b/theme-compiler/src/com/vaadin/sass/internal/tree/MixinNode.java @@ -18,6 +18,7 @@ package com.vaadin.sass.internal.tree; import java.util.ArrayList; import java.util.Collection; +import java.util.Map; import com.vaadin.sass.internal.ScssStylesheet; import com.vaadin.sass.internal.parser.LexicalUnitImpl; @@ -59,14 +60,23 @@ public class MixinNode extends Node implements IVariableNode { this.arglist = arglist; } + /** + * Replace variable references with their values in the mixin argument list. + */ @Override public void replaceVariables(ArrayList<VariableNode> variables) { for (final VariableNode var : variables) { for (final LexicalUnitImpl arg : new ArrayList<LexicalUnitImpl>( arglist)) { - if (arg.getLexicalUnitType() == LexicalUnitImpl.SCSS_VARIABLE - && arg.getStringValue().equals(var.getName())) { - arg.replaceValue(var.getExpr()); + LexicalUnitImpl unit = arg; + // only perform replace in the value if separate argument name + // and value + if (unit.getNextLexicalUnit() != null) { + unit = unit.getNextLexicalUnit(); + } + if (unit.getLexicalUnitType() == LexicalUnitImpl.SCSS_VARIABLE + && unit.getStringValue().equals(var.getName())) { + unit.replaceValue(var.getExpr()); } } @@ -86,8 +96,15 @@ public class MixinNode extends Node implements IVariableNode { @Override public void traverse() { try { + // limit variable scope to the mixin + Map<String, VariableNode> variableScope = ScssStylesheet + .openVariableScope(); + replaceVariables(ScssStylesheet.getVariables()); MixinNodeHandler.traverse(this); + + ScssStylesheet.closeVariableScope(variableScope); + } catch (Exception e) { e.printStackTrace(); } diff --git a/theme-compiler/tests/resources/automatic/css/chained_mixins.css b/theme-compiler/tests/resources/automatic/css/chained_mixins.css new file mode 100644 index 0000000000..73a270a1ab --- /dev/null +++ b/theme-compiler/tests/resources/automatic/css/chained_mixins.css @@ -0,0 +1,3 @@ +.bar-link { + a: b; +} diff --git a/theme-compiler/tests/resources/automatic/css/mixin_variables.css b/theme-compiler/tests/resources/automatic/css/mixin_variables.css new file mode 100644 index 0000000000..d879a080b7 --- /dev/null +++ b/theme-compiler/tests/resources/automatic/css/mixin_variables.css @@ -0,0 +1,15 @@ +.foo { + color: purple; +} + +.baz { + color: red; +} + +.foobar { + color: green; +} + +.foobaz { + color: red; +} diff --git a/theme-compiler/tests/resources/automatic/scss/chained_mixins.scss b/theme-compiler/tests/resources/automatic/scss/chained_mixins.scss new file mode 100644 index 0000000000..007d611149 --- /dev/null +++ b/theme-compiler/tests/resources/automatic/scss/chained_mixins.scss @@ -0,0 +1,15 @@ +/* based on reindeer nativebutton */ + +@mixin foo-link($styleName : bar) { + +.#{$styleName}-link { + a: b; + } + +} + +@mixin foo($styleName : bar) { + @include foo-link($styleName); +} + +@include foo; diff --git a/theme-compiler/tests/resources/automatic/scss/mixin_variables.scss b/theme-compiler/tests/resources/automatic/scss/mixin_variables.scss new file mode 100644 index 0000000000..28cde661dd --- /dev/null +++ b/theme-compiler/tests/resources/automatic/scss/mixin_variables.scss @@ -0,0 +1,10 @@ +@mixin color($color : red, $tag : bar) { + .#{$tag} { + color: $color; + } +} +$color : green; +@include color($color: purple, $tag : foo); +@include color($tag : baz); +@include color($color: $color, $tag : foobar); +@include color($tag : foobaz); diff --git a/uitest/src/com/vaadin/tests/components/colorpicker/ColorPickerTest.html b/uitest/src/com/vaadin/tests/components/colorpicker/ColorPickerTest.html index fb8669b9f0..23c44d3cc0 100644 --- a/uitest/src/com/vaadin/tests/components/colorpicker/ColorPickerTest.html +++ b/uitest/src/com/vaadin/tests/components/colorpicker/ColorPickerTest.html @@ -3,7 +3,7 @@ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head profile="http://selenium-ide.openqa.org/profiles/test-case"> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> -<link rel="selenium.base" href="http://localhost:8888/run/com.vaadin.tests.components.colorpicker.ColorPickerTest?restartApplication" /> +<link rel="selenium.base" href="" /> <title>ColorPickerTest</title> </head> <body> @@ -24,8 +24,13 @@ <td></td> </tr> <tr> + <td>waitForElementPresent</td> + <td>vaadin=runcomvaadintestscomponentscolorpickerColorPickerTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VTabsheet[0]/VTabsheetPanel[0]/VVerticalLayout[0]/Slot[1]/VColorPickerGradient[0]#clicklayer</td> + <td></td> +</tr> +<tr> <td>mouseClick</td> - <td>vaadin=runcomvaadintestscomponentscolorpickerColorPickerTest::PID_Srgb-gradient/domChild[1]/domChild[4]</td> + <td>vaadin=runcomvaadintestscomponentscolorpickerColorPickerTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VTabsheet[0]/VTabsheetPanel[0]/VVerticalLayout[0]/Slot[1]/VColorPickerGradient[0]#clicklayer</td> <td>190,87</td> </tr> <tr> @@ -42,7 +47,7 @@ </tr> <tr> <td>mouseClick</td> - <td>vaadin=runcomvaadintestscomponentscolorpickerColorPickerTest::PID_Srgb-gradient/domChild[1]/domChild[4]</td> + <td>vaadin=runcomvaadintestscomponentscolorpickerColorPickerTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VTabsheet[0]/VTabsheetPanel[0]/VVerticalLayout[0]/Slot[1]/VColorPickerGradient[0]#clicklayer</td> <td>51,33</td> </tr> <tr> @@ -260,7 +265,7 @@ </tr> <tr> <td>mouseClick</td> - <td>vaadin=runcomvaadintestscomponentscolorpickerColorPickerTest::PID_Srgb-gradient/domChild[1]/domChild[4]</td> + <td>vaadin=runcomvaadintestscomponentscolorpickerColorPickerTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VTabsheet[0]/VTabsheetPanel[0]/VVerticalLayout[0]/Slot[1]/VColorPickerGradient[0]#clicklayer</td> <td>148,127</td> </tr> <tr> @@ -299,7 +304,7 @@ </tr> <tr> <td>mouseClick</td> - <td>vaadin=runcomvaadintestscomponentscolorpickerColorPickerTest::PID_Srgb-gradient/domChild[1]/domChild[4]</td> + <td>vaadin=runcomvaadintestscomponentscolorpickerColorPickerTest::/VWindow[0]/FocusableScrollPanel[0]/VVerticalLayout[0]/Slot[0]/VTabsheet[0]/VTabsheetPanel[0]/VVerticalLayout[0]/Slot[1]/VColorPickerGradient[0]#clicklayer</td> <td>36,93</td> </tr> <tr> |