You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@isis.apache.org by da...@apache.org on 2022/08/29 19:17:00 UTC

[isis] 01/05: ISIS-3194: provides default impl of PdfJsViewerAdvisor SPI.

This is an automated email from the ASF dual-hosted git repository.

danhaywood pushed a commit to branch ISIS-3195
in repository https://gitbox.apache.org/repos/asf/isis.git

commit 34652577d4765440e7f470653fd58e8fccdbb85a
Author: Dan Haywood <da...@haywood-associates.co.uk>
AuthorDate: Mon Aug 29 19:56:24 2022 +0100

    ISIS-3194: provides default impl of PdfJsViewerAdvisor SPI.
---
 .../applib/IsisModuleExtPdfjsApplibModel.java      | 31 +++++++++++++++++++
 .../pdfjs/applib/spi/PdfJsViewerAdvisor.java       | 35 ++++++++++++++++++++--
 2 files changed, 64 insertions(+), 2 deletions(-)

diff --git a/extensions/vw/pdfjs/applib/src/main/java/org/apache/isis/extensions/pdfjs/applib/IsisModuleExtPdfjsApplibModel.java b/extensions/vw/pdfjs/applib/src/main/java/org/apache/isis/extensions/pdfjs/applib/IsisModuleExtPdfjsApplibModel.java
new file mode 100644
index 0000000000..481fd73156
--- /dev/null
+++ b/extensions/vw/pdfjs/applib/src/main/java/org/apache/isis/extensions/pdfjs/applib/IsisModuleExtPdfjsApplibModel.java
@@ -0,0 +1,31 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you 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.
+ */
+package org.apache.isis.extensions.pdfjs.applib;
+
+import org.springframework.context.annotation.Configuration;
+import org.springframework.context.annotation.Import;
+
+import org.apache.isis.extensions.pdfjs.applib.spi.PdfJsViewerAdvisor;
+
+@Configuration
+@Import({
+        PdfJsViewerAdvisor.Default.class
+})
+public class IsisModuleExtPdfjsApplibModel {
+}
diff --git a/extensions/vw/pdfjs/applib/src/main/java/org/apache/isis/extensions/pdfjs/applib/spi/PdfJsViewerAdvisor.java b/extensions/vw/pdfjs/applib/src/main/java/org/apache/isis/extensions/pdfjs/applib/spi/PdfJsViewerAdvisor.java
index ed519ac828..8f9b2b8376 100644
--- a/extensions/vw/pdfjs/applib/src/main/java/org/apache/isis/extensions/pdfjs/applib/spi/PdfJsViewerAdvisor.java
+++ b/extensions/vw/pdfjs/applib/src/main/java/org/apache/isis/extensions/pdfjs/applib/spi/PdfJsViewerAdvisor.java
@@ -20,6 +20,11 @@ package org.apache.isis.extensions.pdfjs.applib.spi;
 
 import java.io.Serializable;
 
+import javax.annotation.Priority;
+
+import org.springframework.stereotype.Service;
+
+import org.apache.isis.applib.annotation.PriorityPrecedence;
 import org.apache.isis.applib.annotation.Programmatic;
 import org.apache.isis.applib.services.bookmark.Bookmark;
 import org.apache.isis.applib.value.Blob;
@@ -69,8 +74,8 @@ public interface PdfJsViewerAdvisor {
         /**
          * The identifier of the object being rendered.
          * <p>
-         * The {@link TypeKey#getType()} and {@link #getIdentifier()} together constitute the object's
-         * identity (in effect, its {@link Bookmark}).
+         * The {@link TypeKey#getLogicalTypeName() TypeKey#logicalTypeName}  and {@link #getIdentifier() identifier}
+         * together constitute the object's identity (in effect, its {@link Bookmark}).
          */
         private final String identifier;
 
@@ -133,4 +138,30 @@ public interface PdfJsViewerAdvisor {
         private final Integer height;
     }
 
+
+    /**
+     * Default implementation.
+     */
+    @Service
+    @Priority(PriorityPrecedence.LATE)
+    public static class Default implements PdfJsViewerAdvisor {
+
+        @Override
+        public Advice advise(InstanceKey instanceKey) {
+            return new Advice(1, Scale._0_75, 800);
+        }
+
+        @Override
+        public void pageNumChangedTo(InstanceKey instanceKey, int pageNum) {
+        }
+
+        @Override
+        public void scaleChangedTo(InstanceKey instanceKey, Scale scale) {
+        }
+
+        @Override
+        public void heightChangedTo(InstanceKey instanceKey, int height) {
+        }
+    }
+
 }