From d64d4281ec5636ffc7511cc94fcc3171f34bb805 Mon Sep 17 00:00:00 2001 From: antelder Date: Thu, 10 Feb 2011 08:38:40 +0000 Subject: Rename these old samples in contrib git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@1069273 13f79535-47bb-0310-9956-ffa450edef68 --- .../calculator-rcp/build.properties | 5 + .../calculator-rcp/icons/alt_window_16.gif | Bin 0 -> 637 bytes .../calculator-rcp/icons/alt_window_32.gif | Bin 0 -> 1192 bytes .../very-old-samples/calculator-rcp/plugin.xml | 31 +++++ .../very-old-samples/calculator-rcp/pom.xml | 126 +++++++++++++++++++++ .../src/main/java/Calculator.composite | 54 +++++++++ .../src/main/java/calculator/AddService.java | 28 +++++ .../src/main/java/calculator/AddServiceImpl.java | 35 ++++++ .../src/main/java/calculator/CalculatorClient.java | 52 +++++++++ .../main/java/calculator/CalculatorService.java | 34 ++++++ .../java/calculator/CalculatorServiceImpl.java | 69 +++++++++++ .../src/main/java/calculator/DivideService.java | 28 +++++ .../main/java/calculator/DivideServiceImpl.java | 35 ++++++ .../src/main/java/calculator/MultiplyService.java | 28 +++++ .../main/java/calculator/MultiplyServiceImpl.java | 35 ++++++ .../src/main/java/calculator/SubtractService.java | 28 +++++ .../main/java/calculator/SubtractServiceImpl.java | 35 ++++++ .../src/main/java/calculator/rcp/Activator.java | 94 +++++++++++++++ .../src/main/java/calculator/rcp/Application.java | 63 +++++++++++ .../rcp/ApplicationActionBarAdvisor.java | 65 +++++++++++ .../rcp/ApplicationWorkbenchAdvisor.java | 37 ++++++ .../rcp/ApplicationWorkbenchWindowAdvisor.java | 44 +++++++ .../src/main/java/calculator/rcp/Perspective.java | 34 ++++++ .../src/main/java/calculator/rcp/View.java | 88 ++++++++++++++ 24 files changed, 1048 insertions(+) create mode 100644 sca-java-2.x/contrib/very-old-samples/calculator-rcp/build.properties create mode 100644 sca-java-2.x/contrib/very-old-samples/calculator-rcp/icons/alt_window_16.gif create mode 100644 sca-java-2.x/contrib/very-old-samples/calculator-rcp/icons/alt_window_32.gif create mode 100644 sca-java-2.x/contrib/very-old-samples/calculator-rcp/plugin.xml create mode 100644 sca-java-2.x/contrib/very-old-samples/calculator-rcp/pom.xml create mode 100644 sca-java-2.x/contrib/very-old-samples/calculator-rcp/src/main/java/Calculator.composite create mode 100644 sca-java-2.x/contrib/very-old-samples/calculator-rcp/src/main/java/calculator/AddService.java create mode 100644 sca-java-2.x/contrib/very-old-samples/calculator-rcp/src/main/java/calculator/AddServiceImpl.java create mode 100644 sca-java-2.x/contrib/very-old-samples/calculator-rcp/src/main/java/calculator/CalculatorClient.java create mode 100644 sca-java-2.x/contrib/very-old-samples/calculator-rcp/src/main/java/calculator/CalculatorService.java create mode 100644 sca-java-2.x/contrib/very-old-samples/calculator-rcp/src/main/java/calculator/CalculatorServiceImpl.java create mode 100644 sca-java-2.x/contrib/very-old-samples/calculator-rcp/src/main/java/calculator/DivideService.java create mode 100644 sca-java-2.x/contrib/very-old-samples/calculator-rcp/src/main/java/calculator/DivideServiceImpl.java create mode 100644 sca-java-2.x/contrib/very-old-samples/calculator-rcp/src/main/java/calculator/MultiplyService.java create mode 100644 sca-java-2.x/contrib/very-old-samples/calculator-rcp/src/main/java/calculator/MultiplyServiceImpl.java create mode 100644 sca-java-2.x/contrib/very-old-samples/calculator-rcp/src/main/java/calculator/SubtractService.java create mode 100644 sca-java-2.x/contrib/very-old-samples/calculator-rcp/src/main/java/calculator/SubtractServiceImpl.java create mode 100644 sca-java-2.x/contrib/very-old-samples/calculator-rcp/src/main/java/calculator/rcp/Activator.java create mode 100644 sca-java-2.x/contrib/very-old-samples/calculator-rcp/src/main/java/calculator/rcp/Application.java create mode 100644 sca-java-2.x/contrib/very-old-samples/calculator-rcp/src/main/java/calculator/rcp/ApplicationActionBarAdvisor.java create mode 100644 sca-java-2.x/contrib/very-old-samples/calculator-rcp/src/main/java/calculator/rcp/ApplicationWorkbenchAdvisor.java create mode 100644 sca-java-2.x/contrib/very-old-samples/calculator-rcp/src/main/java/calculator/rcp/ApplicationWorkbenchWindowAdvisor.java create mode 100644 sca-java-2.x/contrib/very-old-samples/calculator-rcp/src/main/java/calculator/rcp/Perspective.java create mode 100644 sca-java-2.x/contrib/very-old-samples/calculator-rcp/src/main/java/calculator/rcp/View.java (limited to 'sca-java-2.x/contrib/very-old-samples/calculator-rcp') diff --git a/sca-java-2.x/contrib/very-old-samples/calculator-rcp/build.properties b/sca-java-2.x/contrib/very-old-samples/calculator-rcp/build.properties new file mode 100644 index 0000000000..0530eb648b --- /dev/null +++ b/sca-java-2.x/contrib/very-old-samples/calculator-rcp/build.properties @@ -0,0 +1,5 @@ +source.. = src/main/java/ +output.. = target/classes/ +bin.includes = plugin.xml,\ + META-INF/,\ + . diff --git a/sca-java-2.x/contrib/very-old-samples/calculator-rcp/icons/alt_window_16.gif b/sca-java-2.x/contrib/very-old-samples/calculator-rcp/icons/alt_window_16.gif new file mode 100644 index 0000000000..05626b17d8 Binary files /dev/null and b/sca-java-2.x/contrib/very-old-samples/calculator-rcp/icons/alt_window_16.gif differ diff --git a/sca-java-2.x/contrib/very-old-samples/calculator-rcp/icons/alt_window_32.gif b/sca-java-2.x/contrib/very-old-samples/calculator-rcp/icons/alt_window_32.gif new file mode 100644 index 0000000000..b432f88339 Binary files /dev/null and b/sca-java-2.x/contrib/very-old-samples/calculator-rcp/icons/alt_window_32.gif differ diff --git a/sca-java-2.x/contrib/very-old-samples/calculator-rcp/plugin.xml b/sca-java-2.x/contrib/very-old-samples/calculator-rcp/plugin.xml new file mode 100644 index 0000000000..1fb5acd9b5 --- /dev/null +++ b/sca-java-2.x/contrib/very-old-samples/calculator-rcp/plugin.xml @@ -0,0 +1,31 @@ + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-2.x/contrib/very-old-samples/calculator-rcp/pom.xml b/sca-java-2.x/contrib/very-old-samples/calculator-rcp/pom.xml new file mode 100644 index 0000000000..0e5214cdd0 --- /dev/null +++ b/sca-java-2.x/contrib/very-old-samples/calculator-rcp/pom.xml @@ -0,0 +1,126 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-sca + 2.0-SNAPSHOT + ../../pom.xml + + sample.calculator.rcp + Apache Tuscany SCA Calculator RCP Sample + + + apache.incubator + http://people.apache.org/repo/m2-incubating-repository + + + + + + org.apache.tuscany.sca + tuscany-node-api + 2.0-SNAPSHOT + + + org.apache.tuscany.sca + tuscany-node-impl + 2.0-SNAPSHOT + runtime + + + org.apache.tuscany.sca + tuscany-implementation-java-runtime + 2.0-SNAPSHOT + runtime + + + org.apache.tuscany.sca + tuscany-implementation-node-runtime + 2.0-SNAPSHOT + runtime + + + org.apache.tuscany.sca + tuscany-extensibility-equinox + 2.0-SNAPSHOT + runtime + + + org.apache.tuscany.sca + tuscany-node-launcher-equinox + 2.0-SNAPSHOT + compile + + + + javax.servlet + servlet-api + 2.5 + provided + + + junit + junit + 4.5 + test + + + + ${artifactId} + + + maven-eclipse-plugin + 2.5.1 + + + org.eclipse.pde.ManifestBuilder + org.eclipse.jdt.core.javabuilder + + + org.eclipse.jdt.core.javanature + org.eclipse.pde.PluginNature + + + org.eclipse.jdt.launching.JRE_CONTAINER + + org.eclipse.pde.core.requiredPlugins + + + + + + maven-jar-plugin + + + ${basedir}/META-INF/MANIFEST.MF + + + + + + diff --git a/sca-java-2.x/contrib/very-old-samples/calculator-rcp/src/main/java/Calculator.composite b/sca-java-2.x/contrib/very-old-samples/calculator-rcp/src/main/java/Calculator.composite new file mode 100644 index 0000000000..913081b9be --- /dev/null +++ b/sca-java-2.x/contrib/very-old-samples/calculator-rcp/src/main/java/Calculator.composite @@ -0,0 +1,54 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-java-2.x/contrib/very-old-samples/calculator-rcp/src/main/java/calculator/AddService.java b/sca-java-2.x/contrib/very-old-samples/calculator-rcp/src/main/java/calculator/AddService.java new file mode 100644 index 0000000000..188451ebac --- /dev/null +++ b/sca-java-2.x/contrib/very-old-samples/calculator-rcp/src/main/java/calculator/AddService.java @@ -0,0 +1,28 @@ +/* + * 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 calculator; + +/** + * The Add service interface + */ +public interface AddService { + + double add(double n1, double n2); + +} diff --git a/sca-java-2.x/contrib/very-old-samples/calculator-rcp/src/main/java/calculator/AddServiceImpl.java b/sca-java-2.x/contrib/very-old-samples/calculator-rcp/src/main/java/calculator/AddServiceImpl.java new file mode 100644 index 0000000000..7ca8fb04b5 --- /dev/null +++ b/sca-java-2.x/contrib/very-old-samples/calculator-rcp/src/main/java/calculator/AddServiceImpl.java @@ -0,0 +1,35 @@ +/* + * 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 calculator; + +import java.util.logging.Level; +import java.util.logging.Logger; + +/** + * An implementation of the Add service + */ +public class AddServiceImpl implements AddService { + + public double add(double n1, double n2) { + Logger logger = Logger.getLogger("calculator"); + logger.log(Level.FINEST, "Adding " + n1 + " and " + n2); + return n1 + n2; + } + +} diff --git a/sca-java-2.x/contrib/very-old-samples/calculator-rcp/src/main/java/calculator/CalculatorClient.java b/sca-java-2.x/contrib/very-old-samples/calculator-rcp/src/main/java/calculator/CalculatorClient.java new file mode 100644 index 0000000000..afd5ea48fc --- /dev/null +++ b/sca-java-2.x/contrib/very-old-samples/calculator-rcp/src/main/java/calculator/CalculatorClient.java @@ -0,0 +1,52 @@ +/* + * 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 calculator; + +import org.oasisopen.sca.annotation.EagerInit; +import org.oasisopen.sca.annotation.Init; +import org.oasisopen.sca.annotation.Reference; +import org.oasisopen.sca.annotation.Scope; + +/** + * This client program shows how to create an SCA runtime, start it, + * and locate and invoke a SCA component + */ +@Scope("COMPOSITE") +@EagerInit +public class CalculatorClient { + + private CalculatorService calculatorService; + + @Reference + public void setCalculatorService(CalculatorService calculatorService) { + this.calculatorService = calculatorService; + } + + @Init + public void calculate() { + // Calculate + System.out.println("SCA API ClassLoader: " + Reference.class.getClassLoader()); + System.out.println("3 + 2=" + calculatorService.add(3, 2)); + System.out.println("3 - 2=" + calculatorService.subtract(3, 2)); + System.out.println("3 * 2=" + calculatorService.multiply(3, 2)); + System.out.println("3 / 2=" + calculatorService.divide(3, 2)); + } + +} diff --git a/sca-java-2.x/contrib/very-old-samples/calculator-rcp/src/main/java/calculator/CalculatorService.java b/sca-java-2.x/contrib/very-old-samples/calculator-rcp/src/main/java/calculator/CalculatorService.java new file mode 100644 index 0000000000..c89043276e --- /dev/null +++ b/sca-java-2.x/contrib/very-old-samples/calculator-rcp/src/main/java/calculator/CalculatorService.java @@ -0,0 +1,34 @@ +/* + * 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 calculator; + +/** + * The Calculator service interface. + */ +public interface CalculatorService { + + double add(double n1, double n2); + + double subtract(double n1, double n2); + + double multiply(double n1, double n2); + + double divide(double n1, double n2); + +} diff --git a/sca-java-2.x/contrib/very-old-samples/calculator-rcp/src/main/java/calculator/CalculatorServiceImpl.java b/sca-java-2.x/contrib/very-old-samples/calculator-rcp/src/main/java/calculator/CalculatorServiceImpl.java new file mode 100644 index 0000000000..39f55ca31f --- /dev/null +++ b/sca-java-2.x/contrib/very-old-samples/calculator-rcp/src/main/java/calculator/CalculatorServiceImpl.java @@ -0,0 +1,69 @@ +/* + * 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 calculator; + +import org.oasisopen.sca.annotation.Reference; + +/** + * An implementation of the Calculator service. + */ +public class CalculatorServiceImpl implements CalculatorService { + + private AddService addService; + private SubtractService subtractService; + private MultiplyService multiplyService; + private DivideService divideService; + + @Reference + public void setAddService(AddService addService) { + this.addService = addService; + } + + @Reference + public void setSubtractService(SubtractService subtractService) { + this.subtractService = subtractService; + } + + @Reference + public void setDivideService(DivideService divideService) { + this.divideService = divideService; + } + + @Reference + public void setMultiplyService(MultiplyService multiplyService) { + this.multiplyService = multiplyService; + } + + public double add(double n1, double n2) { + return addService.add(n1, n2); + } + + public double subtract(double n1, double n2) { + return subtractService.subtract(n1, n2); + } + + public double multiply(double n1, double n2) { + return multiplyService.multiply(n1, n2); + } + + public double divide(double n1, double n2) { + return divideService.divide(n1, n2); + } + +} diff --git a/sca-java-2.x/contrib/very-old-samples/calculator-rcp/src/main/java/calculator/DivideService.java b/sca-java-2.x/contrib/very-old-samples/calculator-rcp/src/main/java/calculator/DivideService.java new file mode 100644 index 0000000000..30d248208b --- /dev/null +++ b/sca-java-2.x/contrib/very-old-samples/calculator-rcp/src/main/java/calculator/DivideService.java @@ -0,0 +1,28 @@ +/* + * 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 calculator; + +/** + * The divide service interface + */ +public interface DivideService { + + double divide(double n1, double n2); + +} diff --git a/sca-java-2.x/contrib/very-old-samples/calculator-rcp/src/main/java/calculator/DivideServiceImpl.java b/sca-java-2.x/contrib/very-old-samples/calculator-rcp/src/main/java/calculator/DivideServiceImpl.java new file mode 100644 index 0000000000..1323edf55a --- /dev/null +++ b/sca-java-2.x/contrib/very-old-samples/calculator-rcp/src/main/java/calculator/DivideServiceImpl.java @@ -0,0 +1,35 @@ +/* + * 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 calculator; + +import java.util.logging.Level; +import java.util.logging.Logger; + +/** + * An implementation of the Divide service. + */ +public class DivideServiceImpl implements DivideService { + + public double divide(double n1, double n2) { + Logger logger = Logger.getLogger("calculator"); + logger.log(Level.FINEST, "Dividing " + n1 + " with " + n2); + return n1 / n2; + } + +} diff --git a/sca-java-2.x/contrib/very-old-samples/calculator-rcp/src/main/java/calculator/MultiplyService.java b/sca-java-2.x/contrib/very-old-samples/calculator-rcp/src/main/java/calculator/MultiplyService.java new file mode 100644 index 0000000000..5290605938 --- /dev/null +++ b/sca-java-2.x/contrib/very-old-samples/calculator-rcp/src/main/java/calculator/MultiplyService.java @@ -0,0 +1,28 @@ +/* + * 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 calculator; + +/** + * The interface for the multiply service + */ +public interface MultiplyService { + + double multiply(double n1, double n2); + +} diff --git a/sca-java-2.x/contrib/very-old-samples/calculator-rcp/src/main/java/calculator/MultiplyServiceImpl.java b/sca-java-2.x/contrib/very-old-samples/calculator-rcp/src/main/java/calculator/MultiplyServiceImpl.java new file mode 100644 index 0000000000..91b803bc9e --- /dev/null +++ b/sca-java-2.x/contrib/very-old-samples/calculator-rcp/src/main/java/calculator/MultiplyServiceImpl.java @@ -0,0 +1,35 @@ +/* + * 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 calculator; + +import java.util.logging.Level; +import java.util.logging.Logger; + +/** + * An implementation of the Multiply service. + */ +public class MultiplyServiceImpl implements MultiplyService { + + public double multiply(double n1, double n2) { + Logger logger = Logger.getLogger("calculator"); + logger.log(Level.FINEST, "Multiplying " + n1 + " with " + n2); + return n1 * n2; + } + +} diff --git a/sca-java-2.x/contrib/very-old-samples/calculator-rcp/src/main/java/calculator/SubtractService.java b/sca-java-2.x/contrib/very-old-samples/calculator-rcp/src/main/java/calculator/SubtractService.java new file mode 100644 index 0000000000..bf0d1882b6 --- /dev/null +++ b/sca-java-2.x/contrib/very-old-samples/calculator-rcp/src/main/java/calculator/SubtractService.java @@ -0,0 +1,28 @@ +/* + * 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 calculator; + +/** + * The interface for the multiply service + */ +public interface SubtractService { + + double subtract(double n1, double n2); + +} diff --git a/sca-java-2.x/contrib/very-old-samples/calculator-rcp/src/main/java/calculator/SubtractServiceImpl.java b/sca-java-2.x/contrib/very-old-samples/calculator-rcp/src/main/java/calculator/SubtractServiceImpl.java new file mode 100644 index 0000000000..58cc4a3547 --- /dev/null +++ b/sca-java-2.x/contrib/very-old-samples/calculator-rcp/src/main/java/calculator/SubtractServiceImpl.java @@ -0,0 +1,35 @@ +/* + * 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 calculator; + +import java.util.logging.Level; +import java.util.logging.Logger; + +/** + * An implementation of the subtract service. + */ +public class SubtractServiceImpl implements SubtractService { + + public double subtract(double n1, double n2) { + Logger logger = Logger.getLogger("calculator"); + logger.log(Level.FINEST, "Subtracting " + n1 + " from " + n2); + return n1 - n2; + } + +} diff --git a/sca-java-2.x/contrib/very-old-samples/calculator-rcp/src/main/java/calculator/rcp/Activator.java b/sca-java-2.x/contrib/very-old-samples/calculator-rcp/src/main/java/calculator/rcp/Activator.java new file mode 100644 index 0000000000..50f68dcb01 --- /dev/null +++ b/sca-java-2.x/contrib/very-old-samples/calculator-rcp/src/main/java/calculator/rcp/Activator.java @@ -0,0 +1,94 @@ +/* + * 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 calculator.rcp; + +import java.io.File; + +import org.apache.tuscany.sca.extensibility.equinox.EquinoxServiceDiscoverer; +import org.apache.tuscany.sca.node.SCAContribution; +import org.apache.tuscany.sca.node.SCANode; +import org.apache.tuscany.sca.node.SCANodeFactory; +import org.eclipse.jface.resource.ImageDescriptor; +import org.eclipse.ui.plugin.AbstractUIPlugin; +import org.osgi.framework.BundleContext; + +/** + * The activator class controls the plug-in life cycle + */ +public class Activator extends AbstractUIPlugin { + + // The plug-in ID + public static final String PLUGIN_ID = "org.apache.tuscany.sca.sample.calculator.rcp"; + + // The shared instance + private static Activator plugin; + + private SCANode node; + + /** + * The constructor + */ + public Activator() { + } + + /* + * (non-Javadoc) + * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext) + */ + public void start(BundleContext context) throws Exception { + super.start(context); + plugin = this; + Class cls = EquinoxServiceDiscoverer.class; + SCANodeFactory factory = SCANodeFactory.newInstance(); + node = factory.createSCANode("Calculator.composite", new SCAContribution("c1", new File("target/classes").toURI().toString())); + node.start(); + } + + /* + * (non-Javadoc) + * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext) + */ + public void stop(BundleContext context) throws Exception { + plugin = null; + super.stop(context); + if (node != null) { + node.stop(); + } + } + + /** + * Returns the shared instance + * + * @return the shared instance + */ + public static Activator getDefault() { + return plugin; + } + + /** + * Returns an image descriptor for the image file at the given + * plug-in relative path + * + * @param path the path + * @return the image descriptor + */ + public static ImageDescriptor getImageDescriptor(String path) { + return imageDescriptorFromPlugin(PLUGIN_ID, path); + } +} diff --git a/sca-java-2.x/contrib/very-old-samples/calculator-rcp/src/main/java/calculator/rcp/Application.java b/sca-java-2.x/contrib/very-old-samples/calculator-rcp/src/main/java/calculator/rcp/Application.java new file mode 100644 index 0000000000..5ce6522fed --- /dev/null +++ b/sca-java-2.x/contrib/very-old-samples/calculator-rcp/src/main/java/calculator/rcp/Application.java @@ -0,0 +1,63 @@ +/* + * 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 calculator.rcp; + +import org.eclipse.equinox.app.IApplication; +import org.eclipse.equinox.app.IApplicationContext; +import org.eclipse.swt.widgets.Display; +import org.eclipse.ui.IWorkbench; +import org.eclipse.ui.PlatformUI; + +/** + * This class controls all aspects of the application's execution + */ +public class Application implements IApplication { + + /* (non-Javadoc) + * @see org.eclipse.equinox.app.IApplication#start(org.eclipse.equinox.app.IApplicationContext) + */ + public Object start(IApplicationContext context) { + Display display = PlatformUI.createDisplay(); + try { + int returnCode = PlatformUI.createAndRunWorkbench(display, new ApplicationWorkbenchAdvisor()); + if (returnCode == PlatformUI.RETURN_RESTART) { + return IApplication.EXIT_RESTART; + } + return IApplication.EXIT_OK; + } finally { + display.dispose(); + } + } + + /* (non-Javadoc) + * @see org.eclipse.equinox.app.IApplication#stop() + */ + public void stop() { + final IWorkbench workbench = PlatformUI.getWorkbench(); + if (workbench == null) + return; + final Display display = workbench.getDisplay(); + display.syncExec(new Runnable() { + public void run() { + if (!display.isDisposed()) + workbench.close(); + } + }); + } +} diff --git a/sca-java-2.x/contrib/very-old-samples/calculator-rcp/src/main/java/calculator/rcp/ApplicationActionBarAdvisor.java b/sca-java-2.x/contrib/very-old-samples/calculator-rcp/src/main/java/calculator/rcp/ApplicationActionBarAdvisor.java new file mode 100644 index 0000000000..2fccfb2d77 --- /dev/null +++ b/sca-java-2.x/contrib/very-old-samples/calculator-rcp/src/main/java/calculator/rcp/ApplicationActionBarAdvisor.java @@ -0,0 +1,65 @@ +/* + * 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 calculator.rcp; + +import org.eclipse.jface.action.IMenuManager; +import org.eclipse.jface.action.MenuManager; +import org.eclipse.ui.IWorkbenchActionConstants; +import org.eclipse.ui.IWorkbenchWindow; +import org.eclipse.ui.actions.ActionFactory; +import org.eclipse.ui.actions.ActionFactory.IWorkbenchAction; +import org.eclipse.ui.application.ActionBarAdvisor; +import org.eclipse.ui.application.IActionBarConfigurer; + +/** + * An action bar advisor is responsible for creating, adding, and disposing of + * the actions added to a workbench window. Each window will be populated with + * new actions. + */ +public class ApplicationActionBarAdvisor extends ActionBarAdvisor { + + // Actions - important to allocate these only in makeActions, and then use + // them + // in the fill methods. This ensures that the actions aren't recreated + // when fillActionBars is called with FILL_PROXY. + private IWorkbenchAction exitAction; + + public ApplicationActionBarAdvisor(IActionBarConfigurer configurer) { + super(configurer); + } + + protected void makeActions(final IWorkbenchWindow window) { + // Creates the actions and registers them. + // Registering is needed to ensure that key bindings work. + // The corresponding commands keybindings are defined in the plugin.xml + // file. + // Registering also provides automatic disposal of the actions when + // the window is closed. + + exitAction = ActionFactory.QUIT.create(window); + register(exitAction); + } + + protected void fillMenuBar(IMenuManager menuBar) { + MenuManager fileMenu = new MenuManager("&File", IWorkbenchActionConstants.M_FILE); + menuBar.add(fileMenu); + fileMenu.add(exitAction); + } + +} diff --git a/sca-java-2.x/contrib/very-old-samples/calculator-rcp/src/main/java/calculator/rcp/ApplicationWorkbenchAdvisor.java b/sca-java-2.x/contrib/very-old-samples/calculator-rcp/src/main/java/calculator/rcp/ApplicationWorkbenchAdvisor.java new file mode 100644 index 0000000000..ac1893509c --- /dev/null +++ b/sca-java-2.x/contrib/very-old-samples/calculator-rcp/src/main/java/calculator/rcp/ApplicationWorkbenchAdvisor.java @@ -0,0 +1,37 @@ +/* + * 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 calculator.rcp; + +import org.eclipse.ui.application.IWorkbenchWindowConfigurer; +import org.eclipse.ui.application.WorkbenchAdvisor; +import org.eclipse.ui.application.WorkbenchWindowAdvisor; + +public class ApplicationWorkbenchAdvisor extends WorkbenchAdvisor { + + private static final String PERSPECTIVE_ID = "org.apache.tuscany.sca.sample.calculator.rcp.perspective"; + + public WorkbenchWindowAdvisor createWorkbenchWindowAdvisor(IWorkbenchWindowConfigurer configurer) { + return new ApplicationWorkbenchWindowAdvisor(configurer); + } + + public String getInitialWindowPerspectiveId() { + return PERSPECTIVE_ID; + } + +} diff --git a/sca-java-2.x/contrib/very-old-samples/calculator-rcp/src/main/java/calculator/rcp/ApplicationWorkbenchWindowAdvisor.java b/sca-java-2.x/contrib/very-old-samples/calculator-rcp/src/main/java/calculator/rcp/ApplicationWorkbenchWindowAdvisor.java new file mode 100644 index 0000000000..6378decf20 --- /dev/null +++ b/sca-java-2.x/contrib/very-old-samples/calculator-rcp/src/main/java/calculator/rcp/ApplicationWorkbenchWindowAdvisor.java @@ -0,0 +1,44 @@ +/* + * 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 calculator.rcp; + +import org.eclipse.swt.graphics.Point; +import org.eclipse.ui.application.ActionBarAdvisor; +import org.eclipse.ui.application.IActionBarConfigurer; +import org.eclipse.ui.application.IWorkbenchWindowConfigurer; +import org.eclipse.ui.application.WorkbenchWindowAdvisor; + +public class ApplicationWorkbenchWindowAdvisor extends WorkbenchWindowAdvisor { + + public ApplicationWorkbenchWindowAdvisor(IWorkbenchWindowConfigurer configurer) { + super(configurer); + } + + public ActionBarAdvisor createActionBarAdvisor(IActionBarConfigurer configurer) { + return new ApplicationActionBarAdvisor(configurer); + } + + public void preWindowOpen() { + IWorkbenchWindowConfigurer configurer = getWindowConfigurer(); + configurer.setInitialSize(new Point(400, 300)); + configurer.setShowCoolBar(false); + configurer.setShowStatusLine(false); + configurer.setTitle("Tuscany SCA Calculator RCP Application"); + } +} diff --git a/sca-java-2.x/contrib/very-old-samples/calculator-rcp/src/main/java/calculator/rcp/Perspective.java b/sca-java-2.x/contrib/very-old-samples/calculator-rcp/src/main/java/calculator/rcp/Perspective.java new file mode 100644 index 0000000000..445b4b65b2 --- /dev/null +++ b/sca-java-2.x/contrib/very-old-samples/calculator-rcp/src/main/java/calculator/rcp/Perspective.java @@ -0,0 +1,34 @@ +/* + * 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 calculator.rcp; + +import org.eclipse.ui.IPageLayout; +import org.eclipse.ui.IPerspectiveFactory; + +public class Perspective implements IPerspectiveFactory { + + public void createInitialLayout(IPageLayout layout) { + String editorArea = layout.getEditorArea(); + layout.setEditorAreaVisible(false); + layout.setFixed(true); + + layout.addStandaloneView(View.ID, false, IPageLayout.LEFT, 1.0f, editorArea); + } + +} diff --git a/sca-java-2.x/contrib/very-old-samples/calculator-rcp/src/main/java/calculator/rcp/View.java b/sca-java-2.x/contrib/very-old-samples/calculator-rcp/src/main/java/calculator/rcp/View.java new file mode 100644 index 0000000000..f95c1e029c --- /dev/null +++ b/sca-java-2.x/contrib/very-old-samples/calculator-rcp/src/main/java/calculator/rcp/View.java @@ -0,0 +1,88 @@ +/* + * 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 calculator.rcp; + +import org.eclipse.jface.viewers.IStructuredContentProvider; +import org.eclipse.jface.viewers.ITableLabelProvider; +import org.eclipse.jface.viewers.LabelProvider; +import org.eclipse.jface.viewers.TableViewer; +import org.eclipse.jface.viewers.Viewer; +import org.eclipse.swt.SWT; +import org.eclipse.swt.graphics.Image; +import org.eclipse.swt.widgets.Composite; +import org.eclipse.ui.ISharedImages; +import org.eclipse.ui.PlatformUI; +import org.eclipse.ui.part.ViewPart; + +public class View extends ViewPart { + public static final String ID = "org.apache.tuscany.sca.sample.calculator.rcp.view"; + + private TableViewer viewer; + + /** + * The content provider class is responsible for providing objects to the + * view. It can wrap existing objects in adapters or simply return objects + * as-is. These objects may be sensitive to the current input of the view, + * or ignore it and always show the same content (like Task List, for + * example). + */ + class ViewContentProvider implements IStructuredContentProvider { + public void inputChanged(Viewer v, Object oldInput, Object newInput) { + } + + public void dispose() { + } + + public Object[] getElements(Object parent) { + return new String[] {"One", "Two", "Three"}; + } + } + + class ViewLabelProvider extends LabelProvider implements ITableLabelProvider { + public String getColumnText(Object obj, int index) { + return getText(obj); + } + + public Image getColumnImage(Object obj, int index) { + return getImage(obj); + } + + public Image getImage(Object obj) { + return PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_OBJ_ELEMENT); + } + } + + /** + * This is a callback that will allow us to create the viewer and initialize + * it. + */ + public void createPartControl(Composite parent) { + viewer = new TableViewer(parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL); + viewer.setContentProvider(new ViewContentProvider()); + viewer.setLabelProvider(new ViewLabelProvider()); + viewer.setInput(getViewSite()); + } + + /** + * Passing the focus request to the viewer's control. + */ + public void setFocus() { + viewer.getControl().setFocus(); + } +} -- cgit v1.2.3