-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2e470bf
commit baea859
Showing
11 changed files
with
415 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
_data/webdrivers/* | ||
node/* | ||
node_modules/* | ||
|
||
|
||
|
||
.DS_Store | ||
.classpath | ||
.project | ||
.settings | ||
.idea | ||
*.iml | ||
*/target/ | ||
vaadin-testbench-standalone/dependency-reduced-pom.xml | ||
vaadin-testbench-recorder/selenium-extensions/core/user-extensions.js | ||
vaadin-testbench-recorder/chrome/content/selenium/scripts/selenium-api.js | ||
vaadin-testbench-recorder/chrome/content/selenium/scripts/selenium-browserbot.js | ||
vaadin-testbench-recorder/chrome/testbench-recorder.jar | ||
vaadin-testbench-recorder/extension/ | ||
vaadin-testbench-recorder/install.rdf | ||
vaadin-testbench-playground | ||
vaadin-testbench-integration-tests/error-screenshots/ | ||
vaadin-testbench-integration-tests/config/testbench.properties | ||
chromedriver.log | ||
phantomjsdriver.log | ||
|
||
test/temp/ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<parent> | ||
<artifactId>pdfviewer-for-flow-parent</artifactId> | ||
<groupId>org.rapidpm.vaadin</groupId> | ||
<version>1.0.0-RPM</version> | ||
</parent> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<artifactId>pdfviewer-for-flow</artifactId> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>javax.servlet</groupId> | ||
<artifactId>javax.servlet-api</artifactId> | ||
<scope>provided</scope> | ||
</dependency> | ||
</dependencies> | ||
|
||
</project> |
92 changes: 92 additions & 0 deletions
92
10_component/src/main/java/org/rapidpm/vaadin/component/pdfviewer/PdfViewer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
package org.rapidpm.vaadin.component.pdfviewer; | ||
|
||
|
||
import com.vaadin.flow.component.Component; | ||
import com.vaadin.flow.component.DetachEvent; | ||
import com.vaadin.flow.component.Tag; | ||
import com.vaadin.flow.component.dependency.JsModule; | ||
import com.vaadin.flow.component.dependency.NpmPackage; | ||
import com.vaadin.flow.server.StreamRegistration; | ||
import com.vaadin.flow.server.StreamResource; | ||
import com.vaadin.flow.server.StreamResourceRegistry; | ||
import com.vaadin.flow.server.VaadinSession; | ||
|
||
import java.net.URI; | ||
|
||
@Tag("pdf-browser-viewer") | ||
@JsModule("@lrnwebcomponents/pdf-browser-viewer/pdf-browser-viewer.js") | ||
@NpmPackage(value = "@lrnwebcomponents/pdf-browser-viewer", version = "2.2.0") | ||
public class PdfViewer | ||
extends Component { | ||
|
||
public static final String NOT_SUPPORTED_MESSAGE = "not-supported-message"; | ||
public static final String NOT_SUPPORTED_LINK_MESSAGE = "not-supported-link-message"; | ||
public static final String CARD = "card"; | ||
public static final String DOWNLOAD_LABEL = "downloadLabel"; | ||
public static final String ELEVATION = "elevation"; | ||
public static final String HEIGHT = "height"; | ||
public static final String WIDTH = "width"; | ||
public static final String FILE = "file"; | ||
private StreamRegistration streamRegistration; | ||
|
||
public PdfViewer() { } | ||
|
||
public void setStreamResource(StreamResource streamResource) { | ||
unregister(); | ||
streamRegistration = VaadinSession.getCurrent() | ||
.getResourceRegistry() | ||
.registerResource(streamResource); | ||
URI uri = StreamResourceRegistry.getURI(streamResource); | ||
final String file = uri.toASCIIString(); | ||
setFile(file); | ||
} | ||
|
||
public void setFile(String file) { | ||
getElement().setAttribute(FILE, file); | ||
} | ||
|
||
public void setNotSupportedMessage(String message) { | ||
getElement().setAttribute(NOT_SUPPORTED_MESSAGE, message); | ||
} | ||
|
||
public void setNotSupportedLinkMessage(String message) { | ||
getElement().setAttribute(NOT_SUPPORTED_LINK_MESSAGE, message); | ||
} | ||
|
||
public void setCard(boolean card) { | ||
getElement().setAttribute(CARD, card); | ||
} | ||
|
||
public void setDownloadLabel(String label) { | ||
getElement().setAttribute(DOWNLOAD_LABEL, label); | ||
} | ||
|
||
public void setElevation(String elevation) { | ||
getElement().setAttribute(ELEVATION, elevation); | ||
} | ||
|
||
public void setHeight(String height) { | ||
getElement().setAttribute(HEIGHT, height); | ||
getElement().getStyle() | ||
.set(HEIGHT, height); | ||
} | ||
|
||
public void setWidth(String width) { | ||
getElement().setAttribute(WIDTH, width); | ||
getElement().getStyle() | ||
.set(WIDTH, width); | ||
} | ||
|
||
@Override | ||
protected void onDetach(DetachEvent detachEvent) { | ||
super.onDetach(detachEvent); | ||
unregister(); | ||
} | ||
|
||
private void unregister() { | ||
if (streamRegistration != null) { | ||
streamRegistration.unregister(); | ||
streamRegistration = null; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!-- | ||
Copyright © 2013 Sven Ruppert ([email protected]) | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
--> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<parent> | ||
<artifactId>pdfviewer-for-flow-parent</artifactId> | ||
<groupId>org.rapidpm.vaadin</groupId> | ||
<version>1.0.0-RPM</version> | ||
</parent> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<artifactId>pdfviewer-for-flow-test</artifactId> | ||
|
||
<!-- Just to disable any accidental deployment to maven.central --> | ||
<distributionManagement> | ||
<repository> | ||
<id>localhost</id> | ||
<url>file://${basedir}/target/repo/</url> | ||
</repository> | ||
<snapshotRepository> | ||
<id>localhost</id> | ||
<url>file://${basedir}/target/snapshot-repo/</url> | ||
</snapshotRepository> | ||
</distributionManagement> | ||
|
||
|
||
</project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<parent> | ||
<artifactId>pdfviewer-for-flow-parent</artifactId> | ||
<groupId>org.rapidpm.vaadin</groupId> | ||
<version>1.0.0-RPM</version> | ||
</parent> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<artifactId>pdfviewer-for-flow-demo</artifactId> | ||
|
||
<!-- Just to disable any accidental deployment to maven.central --> | ||
<distributionManagement> | ||
<repository> | ||
<id>localhost</id> | ||
<url>file://${basedir}/target/repo/</url> | ||
</repository> | ||
<snapshotRepository> | ||
<id>localhost</id> | ||
<url>file://${basedir}/target/snapshot-repo/</url> | ||
</snapshotRepository> | ||
</distributionManagement> | ||
|
||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>org.rapidpm.vaadin</groupId> | ||
<artifactId>pdfviewer-for-flow</artifactId> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.rapidpm.vaadin</groupId> | ||
<artifactId>nano-vaadin-undertow</artifactId> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>com.vaadin</groupId> | ||
<artifactId>vaadin-lumo-theme</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.vaadin</groupId> | ||
<artifactId>vaadin-ordered-layout-flow</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.vaadin</groupId> | ||
<artifactId>vaadin-upload-flow</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.vaadin</groupId> | ||
<artifactId>vaadin-button-flow</artifactId> | ||
</dependency> | ||
</dependencies> | ||
|
||
</project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package demo; | ||
|
||
import org.rapidpm.vaadin.nano.CoreUIServiceJava; | ||
|
||
public class WebUIRunner | ||
extends CoreUIServiceJava { | ||
|
||
public static void main(String[] args) { | ||
new WebUIRunner().startup(); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
package org.rapidpm.demo; | ||
|
||
import com.vaadin.flow.component.Composite; | ||
import com.vaadin.flow.component.button.Button; | ||
import com.vaadin.flow.component.orderedlayout.VerticalLayout; | ||
import com.vaadin.flow.component.upload.Upload; | ||
import com.vaadin.flow.component.upload.receivers.MultiFileMemoryBuffer; | ||
import com.vaadin.flow.router.Route; | ||
import com.vaadin.flow.server.PWA; | ||
import com.vaadin.flow.server.StreamResource; | ||
import com.vaadin.flow.theme.Theme; | ||
import com.vaadin.flow.theme.lumo.Lumo; | ||
import org.rapidpm.vaadin.component.pdfviewer.PdfViewer; | ||
|
||
import java.io.InputStream; | ||
|
||
@Route("") | ||
@PWA(name = "PDFViewer for Flow", shortName = "PDFViewer for Flow") | ||
@Theme(value = Lumo.class, variant = Lumo.LIGHT) | ||
public class VaadinApp | ||
extends Composite<VerticalLayout> { | ||
|
||
// private final PdfViewer pdfViewer = new PdfViewer(); | ||
private final VerticalLayout pdfFiles = new VerticalLayout(); | ||
private final MultiFileMemoryBuffer buffer = new MultiFileMemoryBuffer(); | ||
private final Upload upload = new Upload(buffer); | ||
|
||
public VaadinApp() { | ||
getContent().setHeight("100%"); | ||
// pdfViewer.setHeight("100%"); | ||
final Button btnUpload = new Button(); | ||
btnUpload.addClickListener(e -> pdfFiles.removeAll()); | ||
btnUpload.setText("start Uploading"); | ||
upload.setUploadButton(btnUpload); | ||
upload.addSucceededListener(event -> { | ||
final InputStream inputStream = buffer.getInputStream(event.getFileName()); | ||
final StreamResource streamResource = new StreamResource(event.getFileName(), () -> inputStream); | ||
|
||
final PdfViewer pdfViewer = new PdfViewer(); | ||
pdfViewer.setStreamResource(streamResource); | ||
pdfViewer.setCard(false); | ||
pdfFiles.add(pdfViewer); | ||
}); | ||
upload.setAcceptedFileTypes(".pdf"); | ||
getContent().add(upload); | ||
getContent().add(pdfFiles); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#!/usr/bin/env bash | ||
# | ||
# Copyright © 2013 Sven Ruppert ([email protected]) | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
# | ||
|
||
docker rm deploy-pdfviewer-for-flow | ||
docker-compose up |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
# | ||
# Copyright © 2013 Sven Ruppert ([email protected]) | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
# | ||
|
||
version: '3.5' | ||
|
||
services: | ||
deploy: | ||
image: svenruppert/maven-3.6.2-adopt:1.8.212-04 | ||
container_name: deploy-pdfviewer-for-flow | ||
hostname: deploy-pdfviewer-for-flow | ||
volumes: | ||
- /var/run/docker.sock:/tmp/docker.sock:ro | ||
- $PWD/:/usr/src/mymaven | ||
- ~/.m2/settings.xml:/root/.m2/settings.xml | ||
- ~/.gnupg/:/root/.gnupg/ | ||
working_dir: /usr/src/mymaven | ||
# command: 'mvn help:active-profiles | ||
command: 'mvn license:format clean deploy | ||
-P_release_prepare | ||
-P_release_sign-artifacts | ||
-Pvaadin-install-nodejs | ||
-Dmaven.test.skip=true ' |
Oops, something went wrong.