Skip to content

Commit

Permalink
Merge pull request #54 from charphi/feature-desktop-plugin
Browse files Browse the repository at this point in the history
Add desktop plugin example
  • Loading branch information
charphi authored Nov 8, 2023
2 parents abf3016 + cba875d commit e4ac335
Show file tree
Hide file tree
Showing 8 changed files with 307 additions and 3 deletions.
23 changes: 23 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -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).

134 changes: 134 additions & 0 deletions jdplus-examples-desktop/jdplus-examples-desktop-plugin/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
<?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">
<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>eu.europa.ec.joinup.sat</groupId>
<artifactId>jdplus-examples-desktop</artifactId>
<version>1.0.0-SNAPSHOT</version>
</parent>

<artifactId>jdplus-examples-desktop-plugin</artifactId>
<packaging>nbm</packaging>

<name>${project.artifactId}</name>
<description>${project.parent.artifactId} - ${project.artifactId}</description>
<url>${project.parent.url}</url>

<dependencies>
<!-- 1. NetBeans Platform -->
<dependency>
<groupId>org.netbeans.api</groupId>
<artifactId>org-openide-util</artifactId>
<version>${netbeans.version}</version>
</dependency>
<dependency>
<groupId>org.netbeans.api</groupId>
<artifactId>org-openide-awt</artifactId>
<version>${netbeans.version}</version>
</dependency>
<dependency>
<groupId>org.netbeans.api</groupId>
<artifactId>org-openide-filesystems</artifactId>
<version>${netbeans.version}</version>
</dependency>
<dependency>
<groupId>org.netbeans.api</groupId>
<artifactId>org-openide-nodes</artifactId>
<version>${netbeans.version}</version>
</dependency>
<dependency>
<groupId>org.netbeans.api</groupId>
<artifactId>org-openide-windows</artifactId>
<version>${netbeans.version}</version>
</dependency>
<dependency>
<groupId>org.netbeans.api</groupId>
<artifactId>org-openide-explorer</artifactId>
<version>${netbeans.version}</version>
</dependency>
<dependency>
<groupId>org.netbeans.api</groupId>
<artifactId>org-openide-util-lookup</artifactId>
<version>${netbeans.version}</version>
</dependency>
<dependency>
<groupId>org.netbeans.api</groupId>
<artifactId>org-openide-dialogs</artifactId>
<version>${netbeans.version}</version>
</dependency>
<dependency>
<groupId>org.netbeans.api</groupId>
<artifactId>org-netbeans-api-progress</artifactId>
<version>${netbeans.version}</version>
</dependency>
<dependency>
<groupId>org.netbeans.api</groupId>
<artifactId>org-openide-util-ui</artifactId>
<version>${netbeans.version}</version>
</dependency>
<dependency>
<groupId>org.netbeans.api</groupId>
<artifactId>org-netbeans-api-progress-nb</artifactId>
<version>${netbeans.version}</version>
</dependency>
<dependency>
<groupId>org.netbeans.api</groupId>
<artifactId>org-openide-filesystems-nb</artifactId>
<version>${netbeans.version}</version>
</dependency>
<dependency>
<groupId>org.netbeans.api</groupId>
<artifactId>org-netbeans-swing-outline</artifactId>
<version>${netbeans.version}</version>
</dependency>

<!-- 2. JD3 Desktop -->
<dependency>
<groupId>eu.europa.ec.joinup.sat</groupId>
<artifactId>jdplus-main-desktop-design</artifactId>
<version>${jdplus-main.version}</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>eu.europa.ec.joinup.sat</groupId>
<artifactId>jdplus-toolkit-desktop-plugin</artifactId>
<version>${jdplus-main.version}</version>
<exclusions>
<exclusion>
<groupId>org.netbeans.api</groupId>
<artifactId>*</artifactId>
</exclusion>
<exclusion>
<groupId>com.github.nbbrd.java-io-util</groupId>
<artifactId>*</artifactId>
</exclusion>
</exclusions>
</dependency>

<!-- 3. JD3 Base -->
<!-- <dependency>-->
<!-- <groupId>eu.europa.ec.joinup.sat</groupId>-->
<!-- <artifactId>jdplus-examples-base-core</artifactId>-->
<!-- <version>${project.version}</version>-->
<!-- </dependency>-->

<!-- 4. Other libraries -->
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.apache.netbeans.utilities</groupId>
<artifactId>nbm-maven-plugin</artifactId>
<extensions>true</extensions>
<configuration>
<publicPackages>
</publicPackages>
</configuration>
</plugin>
</plugins>
</build>
</project>
Original file line number Diff line number Diff line change
@@ -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<? extends ProcDocument> 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();
}
}
Original file line number Diff line number Diff line change
@@ -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";
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/**
* Workaround for JavaDoc issues with Lombok.
*/
public class EmptyJavaDoc {

}
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#Localized module labels. Defaults taken from POM (<name>, <description>, <groupId>) 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
68 changes: 65 additions & 3 deletions jdplus-examples-desktop/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,72 @@
<artifactId>jdplus-examples-desktop</artifactId>
<packaging>pom</packaging>

<name>${project.artifactId}</name>
<description>${project.parent.artifactId} - ${project.artifactId}</description>
<url>${project.parent.url}</url>
<name>jdplus-examples-desktop</name>

<properties>
<!-- dependencies -->
<netbeans.version>RELEASE190</netbeans.version>
</properties>

<modules>
<module>jdplus-examples-desktop-plugin</module>
</modules>

<build>
<pluginManagement>
<plugins>
<!-- Other plugins -->
<plugin>
<groupId>org.apache.netbeans.utilities</groupId>
<artifactId>nbm-maven-plugin</artifactId>
<version>4.8</version>
</plugin>
</plugins>
</pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<!-- Force lookup of annotation processors in classpath by resetting paths -->
<annotationProcessorPaths combine.self="override"/>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<!-- Force use of the nbm generated manifest -->
<archive>
<manifestFile>${project.build.outputDirectory}/META-INF/MANIFEST.MF</manifestFile>
</archive>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.netbeans.utilities</groupId>
<artifactId>nbm-maven-plugin</artifactId>
<extensions>true</extensions>
<configuration>
<!-- Set branding for all NBM plugins -->
<useOSGiDependencies>false</useOSGiDependencies>
<!-- <brandingToken>${brandingToken}</brandingToken>-->
<!-- <cluster>${brandingToken}</cluster>-->
</configuration>
<executions>
<execution>
<!-- List runtime dependencies for tests -->
<id>list-runtime-dependencies</id>
<phase>generate-test-resources</phase>
<goals>
<goal>manifest</goal>
</goals>
<configuration>
<targetManifestFile>${project.build.testOutputDirectory}/runtime-dependencies.mf</targetManifestFile>
<verifyRuntime>skip</verifyRuntime>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>

0 comments on commit e4ac335

Please sign in to comment.