Skip to content

Commit

Permalink
- first version of plugin adapted
Browse files Browse the repository at this point in the history
  • Loading branch information
fbergmann committed Jul 9, 2021
0 parents commit 697579a
Show file tree
Hide file tree
Showing 17 changed files with 488 additions and 0 deletions.
27 changes: 27 additions & 0 deletions .classpath
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="src" output="target/classes" path="src/main/java">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" output="target/test-classes" path="src/test/java">
<attributes>
<attribute name="test" value="true"/>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="output" path="target/classes"/>
</classpath>
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
.settings
.vscode
/target

.class
34 changes: 34 additions & 0 deletions .project
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>MyApp</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.m2e.core.maven2Builder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.eclipse.m2e.core.maven2Nature</nature>
</natures>
<filteredResources>
<filter>
<id>1625820775768</id>
<name></name>
<type>30</type>
<matcher>
<id>org.eclipse.core.resources.regexFilterMatcher</id>
<arguments>node_modules|.git|__CREATED_BY_JAVA_LANGUAGE_SERVER__</arguments>
</matcher>
</filter>
</filteredResources>
</projectDescription>
Empty file added README.md
Empty file.
Binary file added lib/CopasiJava.dll
Binary file not shown.
Binary file added lib/copasi-gui.jar
Binary file not shown.
Binary file added lib/copasi.jar
Binary file not shown.
Binary file added lib/org.COPASI/copasi/1/CopasiJava.dll
Binary file not shown.
Binary file added lib/org.COPASI/copasi/1/copasi-gui.jar
Binary file not shown.
Binary file added lib/org.COPASI/copasi/1/copasi.jar
Binary file not shown.
8 changes: 8 additions & 0 deletions lib/org.COPASI/copasi/1/copasi.pom
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<modelVersion>4.0.0</modelVersion>
<groupId>org.COPASI</groupId>
<artifactId>copasi</artifactId>
<version>1</version>
</project>
1 change: 1 addition & 0 deletions package_jar.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
mvn org.apache.maven.plugins:maven-install-plugin:2.5.2:install-file -Dfile=lib\copasi.jar -DgroupId=org.COPASI -DartifactId=copasi -Dversion=1 -Dpackaging=jar
173 changes: 173 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,173 @@
<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">
<!-- The version of the pom.xml format that this is written in -->
<modelVersion>4.0.0</modelVersion>

<!--
Properties are variables that can be referenced throughout the pom.xml file.
When the pom.xml file has repeated elements, it's best to use them as properties.
-->
<properties>
<cytoscape.api.version>3.2.0</cytoscape.api.version>
<maven-compiler-plugin.version>2.0.2</maven-compiler-plugin.version>
<maven-bundle-plugin.version>2.3.4</maven-bundle-plugin.version>
<osgi.api.version>4.2.0</osgi.api.version>
</properties>

<!--
These are the key elements of a pom.xml file. All
pom.xml files must have a "groupId", "artifactId", and "version".
These three things uniquely identify a project in Maven.
A "groupId" is the hierarchical name of the organization
that is making this project.
An "artifactId" is the name of the project.
-->
<groupId>org.copasi</groupId>
<artifactId>CopasiPlugin</artifactId>
<version>1.0</version>

<!--
"packaging" tells Maven what sort of thing you want to build.
If we were building a plain, old JAR, we'd put in "jar" here.
However, we're building an OSGi bundle JAR, so we've put
"bundle" here.
-->
<packaging>bundle</packaging>

<!--
This section tells Maven how the build is configured. Maven
has numerous plugins that control very specific phases of the
build.
-->
<build>
<plugins>
<!--
The maven-compiler-plugin configures the Java
compiler Maven uses to build the project.
-->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>${maven-compiler-plugin.version}</version>
<configuration>
<!--
These options indicate the source code is Java
1.7-compliant and the resulting class files
should be Java 1.7-compatible.
-->
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>

<!--
The maven-bundle-plugin creates the metadata
that's necessary for an OSGi bundle. You can
customize the OSGi options in the "instructions"
section below.
-->
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<version>${maven-bundle-plugin.version}</version>
<extensions>true</extensions>
<configuration>
<instructions>
<Bundle-SymbolicName>org.copasi.CopasiPlugin</Bundle-SymbolicName>
<Bundle-Version>${project.version}</Bundle-Version>

<!--
This tells the bundle plugin which packages should not
be exported.
-->
<Private-Package>org.copasi.cytoscape.internal.*</Private-Package>

<Bundle-Activator>org.copasi.cytoscape.internal.CyActivator</Bundle-Activator>
<Embed-Dependency>*;scope=!provided|test;groupId=!org.cytoscape</Embed-Dependency>
<Embed-Transitive>true</Embed-Transitive>
</instructions>
</configuration>
</plugin>
</plugins>
</build>

<!--
These are repositories Maven uses to download Cytoscape API JARs we
use in our app.
-->
<repositories>
<repository>
<id>in-project</id>
<name>In project repository</name>
<url>file://${project.basedir}/lib</url>
</repository>
<repository>
<id>cytoscape_snapshots</id>
<snapshots>
<enabled>true</enabled>
</snapshots>
<releases>
<enabled>false</enabled>
</releases>
<name>Cytoscape Snapshots</name>
<url>http://code.cytoscape.org/nexus/content/repositories/snapshots/</url>
</repository>
<repository>
<id>cytoscape_releases</id>
<snapshots>
<enabled>false</enabled>
</snapshots>
<releases>
<enabled>true</enabled>
</releases>
<name>Cytoscape Releases</name>
<url>http://code.cytoscape.org/nexus/content/repositories/releases/</url>
</repository>
</repositories>

<!--
Our app depends on other OSGi bundle JARs. We list all the JARs
we depend on here. Just like our own Maven project, these
dependencies are uniquely identified by groupId, artifactId,
and version. Dependencies do not necessarily have to be
OSGi bundles. They can be regular JAR files, in which case they must
be inlined or embedded into this bundle.
-->
<dependencies>
<dependency>
<groupId>org.cytoscape</groupId>
<artifactId>application-api</artifactId>
<version>${cytoscape.api.version}</version>
</dependency>
<dependency>
<groupId>org.cytoscape</groupId>
<artifactId>model-api</artifactId>
<version>${cytoscape.api.version}</version>
</dependency>
<dependency>
<groupId>org.cytoscape</groupId>
<artifactId>service-api</artifactId>
<version>${cytoscape.api.version}</version>
</dependency>
<dependency>
<groupId>org.cytoscape</groupId>
<artifactId>work-api</artifactId>
<version>${cytoscape.api.version}</version>
</dependency>

<!-- OSGi core API -->
<dependency>
<groupId>org.osgi</groupId>
<artifactId>org.osgi.core</artifactId>
<version>${osgi.api.version}</version>
</dependency>

<dependency>
<groupId>org.COPASI</groupId>
<artifactId>copasi</artifactId>
<version>1</version>
</dependency>

</dependencies>
</project>
71 changes: 71 additions & 0 deletions src/main/java/org/copasi/cytoscape/internal/CyActivator.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
package org.copasi.cytoscape.internal;

import java.util.Properties;

import org.cytoscape.application.CyApplicationManager;
import org.cytoscape.model.CyNetworkFactory;
import org.cytoscape.model.CyNetworkManager;
import org.cytoscape.service.util.AbstractCyActivator;
import org.cytoscape.work.ServiceProperties;
import org.cytoscape.work.TaskFactory;
import org.osgi.framework.BundleContext;

import org.copasi.cytoscape.internal.tasks.MyAppTaskFactory;
import org.copasi.cytoscape.internal.tasks.MySelectionListener;

/**
* {@code CyActivator} is a class that is a starting point for OSGi bundles.
*
* A quick overview of OSGi: The common currency of OSGi is the <i>service</i>.
* A service is merely a Java interface, along with objects that implement the
* interface. OSGi establishes a system of <i>bundles</i>. Most bundles import
* services. Some bundles export services. Some do both. When a bundle exports a
* service, it provides an implementation to the service's interface. Bundles
* import a service by asking OSGi for an implementation. The implementation is
* provided by some other bundle.
*
* When OSGi starts your bundle, it will invoke {@CyActivator}'s
* {@code start} method. So, the {@code start} method is where
* you put in all your code that sets up your app. This is where you import and
* export services.
*
* Your bundle's {@code Bundle-Activator} manifest entry has a fully-qualified
* path to this class. It's not necessary to inherit from
* {@code AbstractCyActivator}. However, we provide this class as a convenience
* to make it easier to work with OSGi.
*
* Note: AbstractCyActivator already provides its own {@code stop} method, which
* {@code unget}s any services we fetch using getService().
*/
public class CyActivator extends AbstractCyActivator {
/**
* This is the {@code start} method, which sets up your app. The
* {@code BundleContext} object allows you to communicate with the OSGi
* environment. You use {@code BundleContext} to import services or ask OSGi
* about the status of some service.
*/
@Override
public void start(BundleContext context) throws Exception {
// Get the services we're going to want to use
CyNetworkFactory networkFactory = getService(context, CyNetworkFactory.class);
CyNetworkManager networkManager = getService(context, CyNetworkManager.class);

// Configure the service properties first.
Properties properties = new Properties();

// Our task should be exposed in the "Apps" menu...
properties.put(ServiceProperties.PREFERRED_MENU,
"Apps.COPASI");

// ... as a sub menu item called "Import".
properties.put(ServiceProperties.TITLE, "Import COPASI file");


TaskFactory myFactory = new MyAppTaskFactory(networkManager, networkFactory);

registerService(context,
myFactory,
TaskFactory.class, // Interface
properties); // Service properties
}
}
Loading

0 comments on commit 697579a

Please sign in to comment.