From cba875dec243ab88b598f8b16a25a77574893399 Mon Sep 17 00:00:00 2001 From: Philippe Charles Date: Wed, 8 Nov 2023 12:23:47 +0100 Subject: [PATCH] Add desktop plugin example --- README.md | 23 +++ .../jdplus-examples-desktop-plugin/pom.xml | 134 ++++++++++++++++++ .../ProcDocumentItemFactoryExample.java | 46 ++++++ .../plugin/TsActionOpenSpiExample.java | 23 +++ .../src/main/javadoc/EmptyJavaDoc.java | 6 + .../src/main/nbm/manifest.mf | 4 + .../examples/desktop/plugin/Bundle.properties | 6 + jdplus-examples-desktop/pom.xml | 68 ++++++++- 8 files changed, 307 insertions(+), 3 deletions(-) create mode 100644 jdplus-examples-desktop/jdplus-examples-desktop-plugin/pom.xml create mode 100644 jdplus-examples-desktop/jdplus-examples-desktop-plugin/src/main/java/jdplus/examples/desktop/plugin/ProcDocumentItemFactoryExample.java create mode 100644 jdplus-examples-desktop/jdplus-examples-desktop-plugin/src/main/java/jdplus/examples/desktop/plugin/TsActionOpenSpiExample.java create mode 100644 jdplus-examples-desktop/jdplus-examples-desktop-plugin/src/main/javadoc/EmptyJavaDoc.java create mode 100644 jdplus-examples-desktop/jdplus-examples-desktop-plugin/src/main/nbm/manifest.mf create mode 100644 jdplus-examples-desktop/jdplus-examples-desktop-plugin/src/main/resources/jdplus/examples/desktop/plugin/Bundle.properties diff --git a/README.md b/README.md index 31dec98..c9eed6b 100644 --- a/README.md +++ b/README.md @@ -1 +1,24 @@ # JDemetra+ v3 - examples extensions + +This repository contains Java examples of how to use the [JDemetra+ v3 libraries](https://github.com/jdemetra/jdplus-main). + +## Developing + +This project is written in Java and uses [Apache Maven](https://maven.apache.org/) as a build tool. +It requires [Java 17 as minimum version](https://whichjdk.com/) and all its dependencies are hosted on [Maven Central](https://search.maven.org/). + +The code can be build using any IDE or by just type-in the following commands in a terminal: +```shell +git clone https://github.com/jdemetra/jdplus-examples.git +cd jdplus-examples +mvn clean install +``` + +## Contributing + +Any contribution is welcome and should be done through pull requests and/or issues. + +## Licensing + +The code of this project is licensed under the [European Union Public Licence (EUPL)](https://joinup.ec.europa.eu/page/eupl-text-11-12). + \ No newline at end of file diff --git a/jdplus-examples-desktop/jdplus-examples-desktop-plugin/pom.xml b/jdplus-examples-desktop/jdplus-examples-desktop-plugin/pom.xml new file mode 100644 index 0000000..19319de --- /dev/null +++ b/jdplus-examples-desktop/jdplus-examples-desktop-plugin/pom.xml @@ -0,0 +1,134 @@ + + + 4.0.0 + + + eu.europa.ec.joinup.sat + jdplus-examples-desktop + 1.0.0-SNAPSHOT + + + jdplus-examples-desktop-plugin + nbm + + ${project.artifactId} + ${project.parent.artifactId} - ${project.artifactId} + ${project.parent.url} + + + + + org.netbeans.api + org-openide-util + ${netbeans.version} + + + org.netbeans.api + org-openide-awt + ${netbeans.version} + + + org.netbeans.api + org-openide-filesystems + ${netbeans.version} + + + org.netbeans.api + org-openide-nodes + ${netbeans.version} + + + org.netbeans.api + org-openide-windows + ${netbeans.version} + + + org.netbeans.api + org-openide-explorer + ${netbeans.version} + + + org.netbeans.api + org-openide-util-lookup + ${netbeans.version} + + + org.netbeans.api + org-openide-dialogs + ${netbeans.version} + + + org.netbeans.api + org-netbeans-api-progress + ${netbeans.version} + + + org.netbeans.api + org-openide-util-ui + ${netbeans.version} + + + org.netbeans.api + org-netbeans-api-progress-nb + ${netbeans.version} + + + org.netbeans.api + org-openide-filesystems-nb + ${netbeans.version} + + + org.netbeans.api + org-netbeans-swing-outline + ${netbeans.version} + + + + + eu.europa.ec.joinup.sat + jdplus-main-desktop-design + ${jdplus-main.version} + provided + + + eu.europa.ec.joinup.sat + jdplus-toolkit-desktop-plugin + ${jdplus-main.version} + + + org.netbeans.api + * + + + com.github.nbbrd.java-io-util + * + + + + + + + + + + + + + + + + + + org.apache.netbeans.utilities + nbm-maven-plugin + true + + + + + + + + \ No newline at end of file diff --git a/jdplus-examples-desktop/jdplus-examples-desktop-plugin/src/main/java/jdplus/examples/desktop/plugin/ProcDocumentItemFactoryExample.java b/jdplus-examples-desktop/jdplus-examples-desktop-plugin/src/main/java/jdplus/examples/desktop/plugin/ProcDocumentItemFactoryExample.java new file mode 100644 index 0000000..01a15f2 --- /dev/null +++ b/jdplus-examples-desktop/jdplus-examples-desktop-plugin/src/main/java/jdplus/examples/desktop/plugin/ProcDocumentItemFactoryExample.java @@ -0,0 +1,46 @@ +package jdplus.examples.desktop.plugin; + + +import jdplus.toolkit.base.api.processing.ProcDocument; +import jdplus.toolkit.base.api.util.Id; +import jdplus.toolkit.base.api.util.LinearId; +import jdplus.toolkit.desktop.plugin.ui.processing.IProcDocumentItemFactory; +import nbbrd.design.DirectImpl; +import nbbrd.service.ServiceProvider; +import org.checkerframework.checker.nullness.qual.NonNull; + +import javax.swing.*; + +@DirectImpl +@ServiceProvider +public final class ProcDocumentItemFactoryExample implements IProcDocumentItemFactory { + + @Override + public int getPosition() { + return 1000; + } + + @Override + public @NonNull Class getDocumentType() { + return ProcDocument.class; + } + + @Override + public @NonNull Id getItemId() { + return new LinearId("_ROOT_", "_CHILD_"); + } + + @Override + public @NonNull JComponent getView(@NonNull ProcDocument procDocument) throws IllegalArgumentException { + JTextArea result = new JTextArea(); + result.setEditable(false); + result.setText(getProcDocumentAsString(procDocument)); + return new JScrollPane(result); + } + + private static String getProcDocumentAsString(ProcDocument procDocument) { + return "KEY = " + procDocument.getKey() + System.lineSeparator() + + "SPEC = " + procDocument.getSpecification() + System.lineSeparator() + + "STATUS = " + procDocument.getStatus(); + } +} diff --git a/jdplus-examples-desktop/jdplus-examples-desktop-plugin/src/main/java/jdplus/examples/desktop/plugin/TsActionOpenSpiExample.java b/jdplus-examples-desktop/jdplus-examples-desktop-plugin/src/main/java/jdplus/examples/desktop/plugin/TsActionOpenSpiExample.java new file mode 100644 index 0000000..2d5b25c --- /dev/null +++ b/jdplus-examples-desktop/jdplus-examples-desktop-plugin/src/main/java/jdplus/examples/desktop/plugin/TsActionOpenSpiExample.java @@ -0,0 +1,23 @@ +package jdplus.examples.desktop.plugin; + +import jdplus.toolkit.base.api.timeseries.Ts; +import jdplus.toolkit.desktop.plugin.TsActionOpenSpi; +import jdplus.toolkit.desktop.plugin.notification.MessageUtil; +import nbbrd.design.DirectImpl; +import nbbrd.service.ServiceProvider; +import org.checkerframework.checker.nullness.qual.NonNull; + +@DirectImpl +@ServiceProvider +public final class TsActionOpenSpiExample implements TsActionOpenSpi { + + @Override + public void open(@NonNull Ts ts) { + MessageUtil.info("You just opened '" + ts.getName() + "'"); + } + + @Override + public @NonNull String getName() { + return "Message box with TS name"; + } +} diff --git a/jdplus-examples-desktop/jdplus-examples-desktop-plugin/src/main/javadoc/EmptyJavaDoc.java b/jdplus-examples-desktop/jdplus-examples-desktop-plugin/src/main/javadoc/EmptyJavaDoc.java new file mode 100644 index 0000000..530579d --- /dev/null +++ b/jdplus-examples-desktop/jdplus-examples-desktop-plugin/src/main/javadoc/EmptyJavaDoc.java @@ -0,0 +1,6 @@ +/** + * Workaround for JavaDoc issues with Lombok. + */ +public class EmptyJavaDoc { + +} \ No newline at end of file diff --git a/jdplus-examples-desktop/jdplus-examples-desktop-plugin/src/main/nbm/manifest.mf b/jdplus-examples-desktop/jdplus-examples-desktop-plugin/src/main/nbm/manifest.mf new file mode 100644 index 0000000..2e6bb21 --- /dev/null +++ b/jdplus-examples-desktop/jdplus-examples-desktop-plugin/src/main/nbm/manifest.mf @@ -0,0 +1,4 @@ +Manifest-Version: 1.0 +OpenIDE-Module-Localizing-Bundle: jdplus/examples/desktop/plugin/Bundle.properties +OpenIDE-Module-Display-Category: JD+ Examples +OpenIDE-Module-Java-Dependencies: Java > 17 diff --git a/jdplus-examples-desktop/jdplus-examples-desktop-plugin/src/main/resources/jdplus/examples/desktop/plugin/Bundle.properties b/jdplus-examples-desktop/jdplus-examples-desktop-plugin/src/main/resources/jdplus/examples/desktop/plugin/Bundle.properties new file mode 100644 index 0000000..64c8fa1 --- /dev/null +++ b/jdplus-examples-desktop/jdplus-examples-desktop-plugin/src/main/resources/jdplus/examples/desktop/plugin/Bundle.properties @@ -0,0 +1,6 @@ +#Localized module labels. Defaults taken from POM (, , ) if unset. +#OpenIDE-Module-Name= +#OpenIDE-Module-Short-Description= +#OpenIDE-Module-Long-Description= +#OpenIDE-Module-Display-Category= +#Wed Mar 09 13:57:24 CET 2022 diff --git a/jdplus-examples-desktop/pom.xml b/jdplus-examples-desktop/pom.xml index ca7b6bd..25c40df 100644 --- a/jdplus-examples-desktop/pom.xml +++ b/jdplus-examples-desktop/pom.xml @@ -12,10 +12,72 @@ jdplus-examples-desktop pom - ${project.artifactId} - ${project.parent.artifactId} - ${project.artifactId} - ${project.parent.url} + jdplus-examples-desktop + + + + RELEASE190 + + jdplus-examples-desktop-plugin + + + + + + + org.apache.netbeans.utilities + nbm-maven-plugin + 4.8 + + + + + + org.apache.maven.plugins + maven-compiler-plugin + + + + + + + org.apache.maven.plugins + maven-jar-plugin + + + + ${project.build.outputDirectory}/META-INF/MANIFEST.MF + + + + + org.apache.netbeans.utilities + nbm-maven-plugin + true + + + false + + + + + + + list-runtime-dependencies + generate-test-resources + + manifest + + + ${project.build.testOutputDirectory}/runtime-dependencies.mf + skip + + + + + + \ No newline at end of file