1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/samples/extensionpoint/build.xml Sat Jun 14 09:53:48 2008 +0200
1.3 @@ -0,0 +1,70 @@
1.4 +<?xml version="1.0" encoding="UTF-8"?>
1.5 +<project name="extensionpoint" default="run" basedir=".">
1.6 + <target name="clean">
1.7 + <delete dir="build"/>
1.8 + </target>
1.9 +
1.10 + <target name="build">
1.11 + <antcall target="-build-one">
1.12 + <param name="version" value="api"/>
1.13 + </antcall>
1.14 + <antcall target="-build-one">
1.15 + <param name="version" value="helloworld"/>
1.16 + <param name="cp" location="build/api/classes"/>
1.17 + </antcall>
1.18 + <antcall target="-build-one">
1.19 + <param name="version" value="hellodesign"/>
1.20 + <param name="cp" location="build/api/classes"/>
1.21 + </antcall>
1.22 + </target>
1.23 +
1.24 + <target name="run" depends="build">
1.25 + <echo level="info" message="Running without any extension points."/>
1.26 + <antcall target="-run-one">
1.27 + </antcall>
1.28 + <echo level="info" message="Running with 'Hello World!' extension."/>
1.29 + <antcall target="-run-one">
1.30 + <param name="version1" value="helloworld"/>
1.31 + </antcall>
1.32 + <echo level="info" message="Running with 'Hello Design!' extension."/>
1.33 + <antcall target="-run-one">
1.34 + <param name="version1" value="hellodesign"/>
1.35 + </antcall>
1.36 + <echo level="info" message="Running with both extension."/>
1.37 + <antcall target="-run-one">
1.38 + <param name="version1" value="helloworld"/>
1.39 + <param name="version2" value="hellodesign"/>
1.40 + </antcall>
1.41 + </target>
1.42 +
1.43 +
1.44 + <!-- support methods -->
1.45 +
1.46 + <target name="-run-one">
1.47 + <java
1.48 + classpath="build/${version1}/classes:build/${version2}/classes:build/api/classes:../libs/dist/org-openide-util.jar"
1.49 + classname="org.apidesign.extensionpoint.Main"
1.50 + failonerror="true"
1.51 + >
1.52 + <jvmarg value="-ea"/>
1.53 + </java>
1.54 + </target>
1.55 +
1.56 + <target name="-build-one">
1.57 + <fail message="You need to specify version number" unless="version"/>
1.58 +
1.59 + <mkdir dir="build/${version}/classes"/>
1.60 + <property name="cp" value=""/>
1.61 + <javac
1.62 + srcdir="src-${version}"
1.63 + destdir="build/${version}/classes"
1.64 + source="1.5" target="1.5"
1.65 + classpath="${cp}"
1.66 + />
1.67 + <copy todir="build/${version}/classes">
1.68 + <fileset dir="src-${version}">
1.69 + <exclude name="**/*.java"/>
1.70 + </fileset>
1.71 + </copy>
1.72 + </target>
1.73 +</project>
2.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
2.2 +++ b/samples/extensionpoint/nbproject/project.xml Sat Jun 14 09:53:48 2008 +0200
2.3 @@ -0,0 +1,105 @@
2.4 +<?xml version="1.0" encoding="UTF-8"?>
2.5 +<project xmlns="http://www.netbeans.org/ns/project/1" xmlns:ns4="null">
2.6 + <type>org.netbeans.modules.ant.freeform</type>
2.7 + <configuration>
2.8 + <general-data xmlns="http://www.netbeans.org/ns/freeform-project/1">
2.9 + <name>extensionpoint</name>
2.10 + </general-data>
2.11 + <general-data xmlns="http://www.netbeans.org/ns/freeform-project/2">
2.12 + <!-- Do not use Project Properties customizer when editing this file manually. -->
2.13 + <name>extensionpoint</name>
2.14 + <properties/>
2.15 + <folders>
2.16 + <source-folder>
2.17 + <label>extensionpoint</label>
2.18 + <location>.</location>
2.19 + <encoding>UTF-8</encoding>
2.20 + </source-folder>
2.21 + <source-folder>
2.22 + <label>src-hellodesign</label>
2.23 + <type>java</type>
2.24 + <location>src-hellodesign</location>
2.25 + <encoding>UTF-8</encoding>
2.26 + </source-folder>
2.27 + <source-folder>
2.28 + <label>src-helloworld</label>
2.29 + <type>java</type>
2.30 + <location>src-helloworld</location>
2.31 + <encoding>UTF-8</encoding>
2.32 + </source-folder>
2.33 + </folders>
2.34 + <ide-actions>
2.35 + <action name="build">
2.36 + <target>build</target>
2.37 + </action>
2.38 + <action name="clean">
2.39 + <target>clean</target>
2.40 + </action>
2.41 + <action name="run">
2.42 + <target>run</target>
2.43 + </action>
2.44 + <action name="rebuild">
2.45 + <target>clean</target>
2.46 + <target>build</target>
2.47 + </action>
2.48 + </ide-actions>
2.49 + <export>
2.50 + <type>folder</type>
2.51 + <location>build/api/classes</location>
2.52 + <build-target>build</build-target>
2.53 + </export>
2.54 + <export>
2.55 + <type>folder</type>
2.56 + <location>build/api2.0/classes</location>
2.57 + <build-target>build</build-target>
2.58 + </export>
2.59 + <view>
2.60 + <items>
2.61 + <source-folder style="packages">
2.62 + <label>src-api</label>
2.63 + <location>src-api</location>
2.64 + </source-folder>
2.65 + <source-folder style="packages">
2.66 + <label>src-helloworld</label>
2.67 + <location>src-helloworld</location>
2.68 + </source-folder>
2.69 + <source-folder style="packages">
2.70 + <label>src-hellodesign</label>
2.71 + <location>src-hellodesign</location>
2.72 + </source-folder>
2.73 + <source-file>
2.74 + <location>build.xml</location>
2.75 + </source-file>
2.76 + </items>
2.77 + <context-menu>
2.78 + <ide-action name="build"/>
2.79 + <ide-action name="rebuild"/>
2.80 + <ide-action name="clean"/>
2.81 + <ide-action name="run"/>
2.82 + <ide-action name="debug"/>
2.83 + </context-menu>
2.84 + </view>
2.85 + <subprojects/>
2.86 + </general-data>
2.87 + <java-data xmlns="http://www.netbeans.org/ns/freeform-project-java/1">
2.88 + <compilation-unit>
2.89 + <package-root>src-api</package-root>
2.90 + <classpath mode="compile">../libs/dist/org-openide-util.jar</classpath>
2.91 + <built-to>build/api/classes</built-to>
2.92 + <source-level>1.5</source-level>
2.93 + </compilation-unit>
2.94 + <compilation-unit>
2.95 + <package-root>src-helloworld</package-root>
2.96 + <classpath mode="compile">src-api</classpath>
2.97 + <built-to>build/helloworld/classes</built-to>
2.98 + <source-level>1.5</source-level>
2.99 + </compilation-unit>
2.100 + <compilation-unit>
2.101 + <package-root>src-hellodesign</package-root>
2.102 + <classpath mode="compile">src-api</classpath>
2.103 + <built-to>build/hellodesign/classes</built-to>
2.104 + <source-level>1.5</source-level>
2.105 + </compilation-unit>
2.106 + </java-data>
2.107 + </configuration>
2.108 +</project>
3.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
3.2 +++ b/samples/extensionpoint/src-api/org/apidesign/extensionpoint/Main.java Sat Jun 14 09:53:48 2008 +0200
3.3 @@ -0,0 +1,44 @@
3.4 +package org.apidesign.extensionpoint;
3.5 +
3.6 +import java.util.ArrayList;
3.7 +import java.util.Collection;
3.8 +import java.util.Collections;
3.9 +import java.util.List;
3.10 +import javax.swing.JOptionPane;
3.11 +import org.apidesign.extensionpoint.api.TipOfTheDay;
3.12 +import org.openide.util.Lookup;
3.13 +
3.14 +public class Main {
3.15 + public static void main(String[] args) {
3.16 + for (;;) {
3.17 + // BEGIN: extension.point.Query
3.18 + Collection<? extends TipOfTheDay> all = Lookup.getDefault().lookupAll(TipOfTheDay.class);
3.19 + List<TipOfTheDay> arr = new ArrayList<TipOfTheDay>(all);
3.20 + Collections.shuffle(arr);
3.21 +
3.22 + String msg;
3.23 + String title;
3.24 + int type;
3.25 + if (arr.isEmpty()) {
3.26 + msg = "I do not know what to say!";
3.27 + title = "No provider registered";
3.28 + type = JOptionPane.WARNING_MESSAGE;
3.29 + } else {
3.30 + msg = arr.get(0).sayHello();
3.31 + title = "Selected from " + arr.size() + " providers";
3.32 + type = JOptionPane.INFORMATION_MESSAGE;
3.33 + }
3.34 + // END: extension.point.Query
3.35 +
3.36 + String again = "Once Again";
3.37 + String exit = "Exit";
3.38 + String[] options = new String[] { again, exit };
3.39 + int ret = JOptionPane.showOptionDialog(null, msg, title, 0, type, null, options, exit);
3.40 +
3.41 + if (ret != 0) {
3.42 + break;
3.43 + }
3.44 + }
3.45 + System.exit(0);
3.46 + }
3.47 +}
4.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
4.2 +++ b/samples/extensionpoint/src-api/org/apidesign/extensionpoint/api/TipOfTheDay.java Sat Jun 14 09:53:48 2008 +0200
4.3 @@ -0,0 +1,8 @@
4.4 +// BEGIN: extension.point.Tip
4.5 +package org.apidesign.extensionpoint.api;
4.6 +
4.7 +public interface TipOfTheDay {
4.8 + public String sayHello();
4.9 +}
4.10 +// END: extension.point.Tip
4.11 +
5.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
5.2 +++ b/samples/extensionpoint/src-hellodesign/META-INF/services/org.apidesign.extensionpoint.api.TipOfTheDay Sat Jun 14 09:53:48 2008 +0200
5.3 @@ -0,0 +1,1 @@
5.4 +org.apidesign.extensionpoint.impl1.HelloDesign
6.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
6.2 +++ b/samples/extensionpoint/src-hellodesign/org/apidesign/extensionpoint/impl1/HelloDesign.java Sat Jun 14 09:53:48 2008 +0200
6.3 @@ -0,0 +1,9 @@
6.4 +package org.apidesign.extensionpoint.impl1;
6.5 +
6.6 +import org.apidesign.extensionpoint.api.TipOfTheDay;
6.7 +
6.8 +public class HelloDesign implements TipOfTheDay{
6.9 + public String sayHello() {
6.10 + return "Hello API Design!";
6.11 + }
6.12 +}
7.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
7.2 +++ b/samples/extensionpoint/src-helloworld/META-INF/services/org.apidesign.extensionpoint.api.TipOfTheDay Sat Jun 14 09:53:48 2008 +0200
7.3 @@ -0,0 +1,3 @@
7.4 +# BEGIN: extension.point.Reg2
7.5 +org.apidesign.extensionpoint.impl2.HelloWorld
7.6 +# END: extension.point.Reg2
8.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
8.2 +++ b/samples/extensionpoint/src-helloworld/org/apidesign/extensionpoint/impl2/HelloWorld.java Sat Jun 14 09:53:48 2008 +0200
8.3 @@ -0,0 +1,12 @@
8.4 +// BEGIN: extension.point.Impl2
8.5 +package org.apidesign.extensionpoint.impl2;
8.6 +
8.7 +import org.apidesign.extensionpoint.api.TipOfTheDay;
8.8 +
8.9 +
8.10 +public class HelloWorld implements TipOfTheDay {
8.11 + public String sayHello() {
8.12 + return "Hello World!";
8.13 + }
8.14 +}
8.15 +// END: extension.point.Impl2