Skip to content

Commit

Permalink
Fixed eclipse launch configuration
Browse files Browse the repository at this point in the history
Added support for text file thumbnails to demonstrate the use of
Blob.slice()
  • Loading branch information
Lukas Laag committed Mar 29, 2012
1 parent 29da181 commit 0588f39
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 16 deletions.
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -2,3 +2,4 @@
/target
/gwt-unitCache
/war/WEB-INF/deploy
/war/org.vectomatic.file.TestApp
21 changes: 10 additions & 11 deletions lib-gwt-file-test.launch
Expand Up @@ -6,17 +6,17 @@
<listAttribute key="org.eclipse.debug.core.MAPPED_RESOURCE_TYPES">
<listEntry value="4"/>
</listAttribute>
<booleanAttribute key="org.eclipse.debug.core.appendEnvironmentVariables" value="true"/>
<stringAttribute key="org.eclipse.debug.core.source_locator_id" value="org.eclipse.jdt.launching.sourceLocator.JavaSourceLookupDirector"/>
<stringAttribute key="org.eclipse.debug.core.source_locator_memento" value="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#10;&lt;sourceLookupDirector&gt;&#10;&lt;sourceContainers duplicates=&quot;false&quot;&gt;&#10;&lt;container memento=&quot;&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;UTF-8&amp;quot; standalone=&amp;quot;no&amp;quot;?&amp;gt;&amp;#10;&amp;lt;directory nest=&amp;quot;false&amp;quot; path=&amp;quot;/home/laaglu/workspaces/lab/lib-gwt-file-test/target/gen&amp;quot;/&amp;gt;&amp;#10;&quot; typeId=&quot;org.eclipse.debug.core.containerType.directory&quot;/&gt;&#10;&lt;container memento=&quot;&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;UTF-8&amp;quot; standalone=&amp;quot;no&amp;quot;?&amp;gt;&amp;#10;&amp;lt;folder nest=&amp;quot;false&amp;quot; path=&amp;quot;/lib-gwt-file-test/target/.generated&amp;quot;/&amp;gt;&amp;#10;&quot; typeId=&quot;org.eclipse.debug.core.containerType.folder&quot;/&gt;&#10;&lt;container memento=&quot;&amp;lt;?xml version=&amp;quot;1.0&amp;quot; encoding=&amp;quot;UTF-8&amp;quot; standalone=&amp;quot;no&amp;quot;?&amp;gt;&amp;#10;&amp;lt;default/&amp;gt;&amp;#10;&quot; typeId=&quot;org.eclipse.debug.core.containerType.default&quot;/&gt;&#10;&lt;/sourceContainers&gt;&#10;&lt;/sourceLookupDirector&gt;&#10;"/>
<listAttribute key="org.eclipse.jdt.launching.CLASSPATH">
<listEntry value="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#10;&lt;runtimeClasspathEntry containerPath=&quot;org.eclipse.jdt.launching.JRE_CONTAINER&quot; javaProject=&quot;testoophm3&quot; path=&quot;1&quot; type=&quot;4&quot;/&gt;&#10;"/>
<listEntry value="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#10;&lt;runtimeClasspathEntry internalArchive=&quot;/lib-gwt-file-test/src/main/java&quot; path=&quot;3&quot; type=&quot;2&quot;/&gt;&#10;"/>
<listEntry value="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#10;&lt;runtimeClasspathEntry internalArchive=&quot;/lib-gwt-file-test/src/main/resources&quot; path=&quot;3&quot; type=&quot;2&quot;/&gt;&#10;"/>
<listEntry value="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#10;&lt;runtimeClasspathEntry internalArchive=&quot;/lib-gwt-file-test/war/WEB-INF/classes&quot; path=&quot;3&quot; type=&quot;2&quot;/&gt;&#10;"/>
<listEntry value="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#10;&lt;runtimeClasspathEntry containerPath=&quot;org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6&quot; path=&quot;1&quot; type=&quot;4&quot;/&gt;&#10;"/>
<listEntry value="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#10;&lt;runtimeClasspathEntry path=&quot;3&quot; projectName=&quot;lib-gwt-file-test&quot; type=&quot;1&quot;/&gt;&#10;"/>
<listEntry value="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#10;&lt;runtimeClasspathEntry containerPath=&quot;org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER&quot; path=&quot;3&quot; type=&quot;4&quot;/&gt;&#10;"/>
<listEntry value="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#10;&lt;runtimeClasspathEntry internalArchive=&quot;/lib-gwt-file/src&quot; path=&quot;3&quot; type=&quot;2&quot;/&gt;&#10;"/>
<listEntry value="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#10;&lt;runtimeClasspathEntry internalArchive=&quot;/lib-gwt-file/src/main/java&quot; path=&quot;3&quot; type=&quot;2&quot;/&gt;&#10;"/>
<listEntry value="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#10;&lt;runtimeClasspathEntry internalArchive=&quot;/lib-gwt-file/src/main/resources&quot; path=&quot;3&quot; type=&quot;2&quot;/&gt;&#10;"/>
<listEntry value="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#10;&lt;runtimeClasspathEntry internalArchive=&quot;/lib-gwt-file/target/classes&quot; path=&quot;3&quot; type=&quot;2&quot;/&gt;&#10;"/>
<listEntry value="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#10;&lt;runtimeClasspathEntry internalArchive=&quot;/lib-gwt-file-test/src/main/java&quot; path=&quot;3&quot; type=&quot;2&quot;/&gt;&#10;"/>
<listEntry value="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#10;&lt;runtimeClasspathEntry internalArchive=&quot;/lib-gwt-file-test/src/main/resources&quot; path=&quot;3&quot; type=&quot;2&quot;/&gt;&#10;"/>
<listEntry value="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#10;&lt;runtimeClasspathEntry internalArchive=&quot;/lib-gwt-file-test/target/classes&quot; path=&quot;3&quot; type=&quot;2&quot;/&gt;&#10;"/>
<listEntry value="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#10;&lt;runtimeClasspathEntry internalArchive=&quot;/lib-gwt-svg/src/main/java&quot; path=&quot;3&quot; type=&quot;2&quot;/&gt;&#10;"/>
<listEntry value="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#10;&lt;runtimeClasspathEntry internalArchive=&quot;/lib-gwt-svg/src/main/resources&quot; path=&quot;3&quot; type=&quot;2&quot;/&gt;&#10;"/>
<listEntry value="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#10;&lt;runtimeClasspathEntry internalArchive=&quot;/lib-gwt-svg/target/classes&quot; path=&quot;3&quot; type=&quot;2&quot;/&gt;&#10;"/>
Expand All @@ -25,11 +25,10 @@
<listEntry value="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#10;&lt;runtimeClasspathEntry externalArchive=&quot;/home/laaglu/.m2/repository/com/google/gwt/gwt-dev/2.4.0/gwt-dev-2.4.0.jar&quot; path=&quot;3&quot; type=&quot;2&quot;/&gt;&#10;"/>
<listEntry value="&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot; standalone=&quot;no&quot;?&gt;&#10;&lt;runtimeClasspathEntry externalArchive=&quot;/home/laaglu/.m2/repository/com/google/gwt/gwt-user/2.4.0/gwt-user-2.4.0.jar&quot; path=&quot;3&quot; type=&quot;2&quot;/&gt;&#10;"/>
</listAttribute>
<stringAttribute key="org.eclipse.jdt.launching.CLASSPATH_PROVIDER" value="org.maven.ide.eclipse.launchconfig.classpathProvider"/>
<stringAttribute key="org.eclipse.jdt.launching.CLASSPATH_PROVIDER" value="org.eclipse.m2e.launchconfig.classpathProvider"/>
<booleanAttribute key="org.eclipse.jdt.launching.DEFAULT_CLASSPATH" value="false"/>
<stringAttribute key="org.eclipse.jdt.launching.MAIN_TYPE" value="com.google.gwt.dev.DevMode"/>
<stringAttribute key="org.eclipse.jdt.launching.PROGRAM_ARGUMENTS" value="-bindAddress 0.0.0.0 -startupUrl lib-gwt-file-test.html&#10;org.vectomatic.file.TestApp"/>
<stringAttribute key="org.eclipse.jdt.launching.PROGRAM_ARGUMENTS" value="-bindAddress 0.0.0.0 -startupUrl lib-gwt-file-test.html org.vectomatic.file.TestApp"/>
<stringAttribute key="org.eclipse.jdt.launching.PROJECT_ATTR" value="lib-gwt-file-test"/>
<stringAttribute key="org.eclipse.jdt.launching.SOURCE_PATH_PROVIDER" value="org.maven.ide.eclipse.launchconfig.sourcepathProvider"/>
<stringAttribute key="org.eclipse.jdt.launching.VM_ARGUMENTS" value="-Xmx512M"/>
<stringAttribute key="org.eclipse.jdt.launching.SOURCE_PATH_PROVIDER" value="org.eclipse.m2e.launchconfig.sourcepathProvider"/>
</launchConfiguration>
2 changes: 1 addition & 1 deletion pom.xml
Expand Up @@ -7,7 +7,7 @@
</parent>
<artifactId>lib-gwt-file-test</artifactId>
<packaging>war</packaging>
<version>0.5-SNAPSHOT</version>
<version>0.4.1-SNAPSHOT</version>
<name>lib-gwt-file-test</name>
<description>A demo program for lib-gwt-file</description>
<url>http://www.vectomatic.org/lib-gwt-file</url>
Expand Down
20 changes: 20 additions & 0 deletions src/main/java/org/vectomatic/file/client/TestAppMain.java
Expand Up @@ -27,6 +27,7 @@
import org.vectomatic.dom.svg.ui.SVGImage;
import org.vectomatic.dom.svg.utils.OMSVGParser;
import org.vectomatic.dom.svg.utils.SVGConstants;
import org.vectomatic.file.Blob;
import org.vectomatic.file.ErrorCode;
import org.vectomatic.file.File;
import org.vectomatic.file.FileError;
Expand Down Expand Up @@ -96,6 +97,8 @@ interface TestAppMainCss extends CssResource {
public String thumbnailImage();
@ClassName("thumbnail-text")
public String thumbnailText();
@ClassName("txt")
public String text();
}
interface TestAppMainBundle extends ClientBundle {
@Source("TestAppMainCss.css")
Expand Down Expand Up @@ -175,6 +178,13 @@ private void readNext() {
reader.readAsText(file);
} else if (type.startsWith("image/")) {
reader.readAsBinaryString(file);
} else if (type.startsWith("text/")) {
// If the file is larger than 1kb, read only the first 1000 characters
Blob blob = file;
if (file.getSize() > 0) {
blob = file.slice(0, 1000, "text/plain; charset=utf-8");
}
reader.readAsText(blob);
}
} catch(Throwable t) {
// Necessary for FF (see bug https://bugzilla.mozilla.org/show_bug.cgi?id=701154)
Expand Down Expand Up @@ -202,6 +212,8 @@ private FlowPanel createThumbnail(File file) {
image = createSvgImage();
} else if (type.startsWith("image/")) {
image = createBitmapImage(file);
} else if (type.startsWith("text/")) {
image = createText(file);
}
SimplePanel thumbnailImage = new SimplePanel(image);
thumbnailImage.setStyleName(bundle.css().thumbnailImage());
Expand Down Expand Up @@ -256,6 +268,14 @@ public void onLoad(LoadEvent event) {
return image;
}

private FlowPanel createText(final File file) {
String result = reader.getStringResult();
FlowPanel panel = new FlowPanel();
panel.getElement().appendChild(Document.get().createTextNode(result));
panel.addStyleName(bundle.css().text());
return panel;
}

@UiHandler("browseBtn")
public void browse(ClickEvent event) {
customUpload.click();
Expand Down
Expand Up @@ -29,14 +29,14 @@
and displayed in your browser.</i>
</p>
</g:HTML>
<g:Label>Click the browse button to select local SVG or PNG files to load</g:Label>
<g:Label>Click the browse button to select local SVG, PNG or text files to load</g:Label>
<f:FileUploadExt ui:field="fileUpload" />
<g:Label>Same thing as above, but with a custom browse button</g:Label>
<f:FileUploadExt ui:field="customUpload" styleName="{bundle.css.customUpload}" />
<g:Button text="Load SVG files" ui:field="browseBtn" />
<g:Label>Alternatively, drag and drop your SVG or PNG files in this drop zone</g:Label>
<g:Button text="Load files" ui:field="browseBtn" />
<g:Label>Alternatively, drag and drop your SVG, PNG or text files in this drop zone</g:Label>
<v:DropPanel ui:field="dropPanel" styleName="{bundle.css.dropPanel}"/>
<g:Label>Click this button to remove previously loaded SVG or PNG files</g:Label>
<g:Label>Click this button to remove previously loaded files</g:Label>
<g:Button ui:field="resetBtn" text="Reset" />
<g:FlowPanel ui:field="imagePanel" styleName="{bundle.css.imagePanel}" />
</g:FlowPanel>
Expand Down
Expand Up @@ -49,3 +49,12 @@
text-align: center;
word-wrap:break-word;
}
.txt {
margin-left:2px;
width:144px;
height:144px;
border:1px solid black;
padding: 3px 3px;
font: 6px arial,helvetica,sans-serif;
overflow:hidden;
}

0 comments on commit 0588f39

Please sign in to comment.