diff --git a/org.fortiss.af3.platform.raspberry.ui/tags/end-of-first-course/.classpath b/org.fortiss.af3.platform.raspberry.ui/tags/end-of-first-course/.classpath new file mode 100644 index 0000000000000000000000000000000000000000..6046c7a0d1baa6d3897c2eef516aa6ba0e45df00 --- /dev/null +++ b/org.fortiss.af3.platform.raspberry.ui/tags/end-of-first-course/.classpath @@ -0,0 +1,7 @@ +<?xml version="1.0" encoding="UTF-8"?> +<classpath> + <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/> + <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/> + <classpathentry kind="src" path="src"/> + <classpathentry kind="output" path="build"/> +</classpath> diff --git a/org.fortiss.af3.platform.raspberry.ui/tags/end-of-first-course/.project b/org.fortiss.af3.platform.raspberry.ui/tags/end-of-first-course/.project new file mode 100644 index 0000000000000000000000000000000000000000..b36b3e2e7417ec9ac8b2fd38ffd69f69b705b316 --- /dev/null +++ b/org.fortiss.af3.platform.raspberry.ui/tags/end-of-first-course/.project @@ -0,0 +1,28 @@ +<?xml version="1.0" encoding="UTF-8"?> +<projectDescription> + <name>org.fortiss.af3.platform.raspberry.ui</name> + <comment></comment> + <projects> + </projects> + <buildSpec> + <buildCommand> + <name>org.eclipse.jdt.core.javabuilder</name> + <arguments> + </arguments> + </buildCommand> + <buildCommand> + <name>org.eclipse.pde.ManifestBuilder</name> + <arguments> + </arguments> + </buildCommand> + <buildCommand> + <name>org.eclipse.pde.SchemaBuilder</name> + <arguments> + </arguments> + </buildCommand> + </buildSpec> + <natures> + <nature>org.eclipse.pde.PluginNature</nature> + <nature>org.eclipse.jdt.core.javanature</nature> + </natures> +</projectDescription> diff --git a/org.fortiss.af3.platform.raspberry.ui/tags/end-of-first-course/META-INF/MANIFEST.MF b/org.fortiss.af3.platform.raspberry.ui/tags/end-of-first-course/META-INF/MANIFEST.MF new file mode 100644 index 0000000000000000000000000000000000000000..f68305a2aeb4a5efeafbfb0e3b0a87fb57c5ef99 --- /dev/null +++ b/org.fortiss.af3.platform.raspberry.ui/tags/end-of-first-course/META-INF/MANIFEST.MF @@ -0,0 +1,20 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Name: Fortiss AF3 Platform Raspberry UI +Bundle-SymbolicName: org.fortiss.af3.platform.raspberry.ui;singleton:=true +Bundle-Version: 2.9.0.qualifier +Bundle-Activator: org.fortiss.af3.platform.raspberry.ui.AF3PlatformRaspberryUIActivator +Require-Bundle: org.eclipse.ui.ide;bundle-version="3.7.0";visibility:=reexport, + org.fortiss.af3.project.ui;bundle-version="1.0.0";visibility:=reexport, + org.fortiss.tooling.base.ui;bundle-version="1.0.0";visibility:=reexport, + org.fortiss.af3.platform.ui, + org.fortiss.af3.platform.raspberry;bundle-version="2.9.0" +Bundle-ActivationPolicy: lazy +Bundle-RequiredExecutionEnvironment: JavaSE-1.8 +Bundle-Vendor: fortiss GmbH +Export-Package: org.fortiss.af3.platform.raspberry.ui +Import-Package: org.fortiss.af3.platform.compose, + org.fortiss.af3.platform.compose.base.hierarchical, + org.fortiss.af3.platform.compose.base.hierarchical.elements, + org.fortiss.af3.platform.model, + org.fortiss.af3.platform.utils diff --git a/org.fortiss.af3.platform.raspberry.ui/tags/end-of-first-course/build.properties b/org.fortiss.af3.platform.raspberry.ui/tags/end-of-first-course/build.properties new file mode 100644 index 0000000000000000000000000000000000000000..c514c7fdb6b707a3347714699fddcf5ceecb5028 --- /dev/null +++ b/org.fortiss.af3.platform.raspberry.ui/tags/end-of-first-course/build.properties @@ -0,0 +1,10 @@ +# <copyright> +# </copyright> +# +# $Id$ + +bin.includes = .,\ + META-INF/,\ + plugin.xml +source.. = src/ +output.. = build/ \ No newline at end of file diff --git a/org.fortiss.af3.platform.raspberry.ui/tags/end-of-first-course/icons/can-logo.jpeg b/org.fortiss.af3.platform.raspberry.ui/tags/end-of-first-course/icons/can-logo.jpeg new file mode 100644 index 0000000000000000000000000000000000000000..204934bddfafd5893e71673c16251929914a6045 Binary files /dev/null and b/org.fortiss.af3.platform.raspberry.ui/tags/end-of-first-course/icons/can-logo.jpeg differ diff --git a/org.fortiss.af3.platform.raspberry.ui/tags/end-of-first-course/icons/can-logoBIG.jpeg b/org.fortiss.af3.platform.raspberry.ui/tags/end-of-first-course/icons/can-logoBIG.jpeg new file mode 100644 index 0000000000000000000000000000000000000000..c2be90bc4a910a5e6b459905286c5fcbe4edbd4c Binary files /dev/null and b/org.fortiss.af3.platform.raspberry.ui/tags/end-of-first-course/icons/can-logoBIG.jpeg differ diff --git a/org.fortiss.af3.platform.raspberry.ui/tags/end-of-first-course/icons/raspberry-pi-logo.png b/org.fortiss.af3.platform.raspberry.ui/tags/end-of-first-course/icons/raspberry-pi-logo.png new file mode 100644 index 0000000000000000000000000000000000000000..ca054922c08baf0bb3235fb02d1baafcc9722419 Binary files /dev/null and b/org.fortiss.af3.platform.raspberry.ui/tags/end-of-first-course/icons/raspberry-pi-logo.png differ diff --git a/org.fortiss.af3.platform.raspberry.ui/tags/end-of-first-course/icons/raspberry-pi-logoBIG.png b/org.fortiss.af3.platform.raspberry.ui/tags/end-of-first-course/icons/raspberry-pi-logoBIG.png new file mode 100644 index 0000000000000000000000000000000000000000..faa554e617fb40bb60ab411dbcb13a9db8f88d0b Binary files /dev/null and b/org.fortiss.af3.platform.raspberry.ui/tags/end-of-first-course/icons/raspberry-pi-logoBIG.png differ diff --git a/org.fortiss.af3.platform.raspberry.ui/tags/end-of-first-course/plugin.properties b/org.fortiss.af3.platform.raspberry.ui/tags/end-of-first-course/plugin.properties new file mode 100644 index 0000000000000000000000000000000000000000..35dca873d642ed94938bbbf54744d1cbf042ebe5 --- /dev/null +++ b/org.fortiss.af3.platform.raspberry.ui/tags/end-of-first-course/plugin.properties @@ -0,0 +1,7 @@ +# <copyright> +# </copyright> +# +# $Id$ + +pluginName = Fortiss AF3 Base Project UI +providerName = fortiss GmbH diff --git a/org.fortiss.af3.platform.raspberry.ui/tags/end-of-first-course/plugin.xml b/org.fortiss.af3.platform.raspberry.ui/tags/end-of-first-course/plugin.xml new file mode 100644 index 0000000000000000000000000000000000000000..130e9d8e99a9a0ba08bb03f119d0880ea15d7c30 --- /dev/null +++ b/org.fortiss.af3.platform.raspberry.ui/tags/end-of-first-course/plugin.xml @@ -0,0 +1,59 @@ +<?xml version="1.0" encoding="UTF-8"?> +<?eclipse version="3.0"?> + +<!-- + <copyright> + </copyright> + + $Id$ +--> +<plugin> +<extension + point="org.fortiss.tooling.kernel.modelPrototypeProvider"> + <modelPrototypeProvider + provider="org.fortiss.af3.platform.raspberry.ui.prototype.ProtoypeProvider"> + </modelPrototypeProvider> + </extension> +<extension + point="org.fortiss.tooling.kernel.ui.modelElementHandler"> + <modelElementHandler + handler="org.fortiss.af3.platform.raspberry.ui.handler.RaspberryPiHandler"> + <modelElementClass + modelElementClass="org.fortiss.af3.platform.raspberry.model.RaspberryPi"> + </modelElementClass> + </modelElementHandler> + <modelElementHandler + handler="org.fortiss.af3.platform.raspberry.ui.handler.CanBusHandler"> + <modelElementClass + modelElementClass="org.fortiss.af3.platform.raspberry.model.CanBus"> + </modelElementClass> + </modelElementHandler> + <modelElementHandler + handler="org.fortiss.af3.platform.raspberry.ui.handler.CanConnectorHandler"> + <modelElementClass + modelElementClass="org.fortiss.af3.platform.raspberry.model.CanConnector"> + </modelElementClass> + </modelElementHandler> +</extension> +<extension + point="org.fortiss.tooling.kernel.ui.editPartFactory"> + <editPartFactory + factory="org.fortiss.af3.platform.raspberry.ui.editpart.EditPartFactory"> + <modelElementClass + modelElementClass="org.fortiss.af3.platform.raspberry.model.RaspberryPi"> + </modelElementClass> + <modelElementClass + modelElementClass="org.fortiss.af3.platform.raspberry.model.CanBus"> + </modelElementClass> + <modelElementClass + modelElementClass="org.fortiss.af3.platform.raspberry.model.CanConnector"> + </modelElementClass> + <modelElementClass + modelElementClass="org.fortiss.af3.platform.raspberry.model.SensorConnector"> + </modelElementClass> + <modelElementClass + modelElementClass="org.fortiss.af3.platform.raspberry.model.ActuatorConnector"> + </modelElementClass> + </editPartFactory> +</extension> +</plugin> diff --git a/org.fortiss.af3.platform.raspberry.ui/tags/end-of-first-course/pom.xml b/org.fortiss.af3.platform.raspberry.ui/tags/end-of-first-course/pom.xml new file mode 100644 index 0000000000000000000000000000000000000000..924914f316a0b8fc05f6754a843460bb65493a6b --- /dev/null +++ b/org.fortiss.af3.platform.raspberry.ui/tags/end-of-first-course/pom.xml @@ -0,0 +1,21 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + $Id$ + @version $Rev$ + @ConQAT.Rating RED Hash: E1674C4A6DD3CBC4A7B7E85232D9695F +--> +<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> + <groupId>org.fortiss.af3</groupId> + <artifactId>org.fortiss.af3.platform.raspberry.ui</artifactId> + <packaging>eclipse-plugin</packaging> + + <parent> + <groupId>org.fortiss.std.pom</groupId> + <artifactId>std-parent-pom-indigo</artifactId> + <version>1.0</version> + <relativePath>../fortiss-std-env/maven-build/pom.xml</relativePath> + </parent> + + <version>2.9.0-SNAPSHOT</version> +</project> \ No newline at end of file diff --git a/org.fortiss.af3.platform.raspberry.ui/tags/end-of-first-course/src/org/fortiss/af3/platform/raspberry/ui/AF3PlatformRaspberryUIActivator.java b/org.fortiss.af3.platform.raspberry.ui/tags/end-of-first-course/src/org/fortiss/af3/platform/raspberry/ui/AF3PlatformRaspberryUIActivator.java new file mode 100644 index 0000000000000000000000000000000000000000..e65c3d2765864a3756835ff775660cc1bb6d3ab8 --- /dev/null +++ b/org.fortiss.af3.platform.raspberry.ui/tags/end-of-first-course/src/org/fortiss/af3/platform/raspberry/ui/AF3PlatformRaspberryUIActivator.java @@ -0,0 +1,68 @@ +/*--------------------------------------------------------------------------+ +$Id$ +| | +| Copyright 2011 ForTISS GmbH | +| | +| Licensed 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 org.fortiss.af3.platform.raspberry.ui; + +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. + * + * @author hoelzl + * @author $Author$ + * @version $Rev$ + * @ConQAT.Rating RED Hash: 250D9EED7E36588B51D8F1B3F968B2FB + */ +public class AF3PlatformRaspberryUIActivator extends AbstractUIPlugin { + + /** The plug-in ID. */ + public static final String PLUGIN_ID = AF3PlatformRaspberryUIActivator.class.getPackage().getName(); //$NON-NLS-1$ + + /** The shared instance. */ + private static AF3PlatformRaspberryUIActivator plugin; + + /** Constructor. */ + public AF3PlatformRaspberryUIActivator() { + // do nothing + } + + /** {@inheritDoc} */ + @Override + public void start(BundleContext context) throws Exception { + super.start(context); + plugin = this; + } + + /** {@inheritDoc} */ + @Override + public void stop(BundleContext context) throws Exception { + plugin = null; + super.stop(context); + } + + /** Returns the shared instance. */ + public static AF3PlatformRaspberryUIActivator getDefault() { + return plugin; + } + + /** Returns the image descriptor for the given icon file. */ + public static ImageDescriptor getImageDescriptor(String path) { + return imageDescriptorFromPlugin(PLUGIN_ID, path); + } +} diff --git a/org.fortiss.af3.platform.raspberry.ui/tags/end-of-first-course/src/org/fortiss/af3/platform/raspberry/ui/editpart/EditPartFactory.java b/org.fortiss.af3.platform.raspberry.ui/tags/end-of-first-course/src/org/fortiss/af3/platform/raspberry/ui/editpart/EditPartFactory.java new file mode 100644 index 0000000000000000000000000000000000000000..ccfec9d6d2f1aca82d273295fd174259eadb3482 --- /dev/null +++ b/org.fortiss.af3.platform.raspberry.ui/tags/end-of-first-course/src/org/fortiss/af3/platform/raspberry/ui/editpart/EditPartFactory.java @@ -0,0 +1,68 @@ +/*--------------------------------------------------------------------------+ +$Id: codetemplates.xml 1 2011-01-01 00:00:01Z hoelzl $ +| | +| Copyright 2017 fortiss GmbH | +| | +| Licensed 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 org.fortiss.af3.platform.raspberry.ui.editpart; + +import org.eclipse.gef.EditPart; +import org.eclipse.swt.graphics.Color; +import org.fortiss.af3.platform.model.PlatformConnectorUnit; +import org.fortiss.af3.platform.raspberry.model.ActuatorConnector; +import org.fortiss.af3.platform.raspberry.model.CanBus; +import org.fortiss.af3.platform.raspberry.model.CanConnector; +import org.fortiss.af3.platform.raspberry.model.RaspberryPi; +import org.fortiss.af3.platform.raspberry.model.SensorConnector; +import org.fortiss.af3.platform.ui.DefaultStyle; +import org.fortiss.af3.platform.ui.editpart.generic.ExecutionUnitEditPart; +import org.fortiss.af3.platform.ui.editpart.generic.StickyPlatformConnectorUnitEditPart; +import org.fortiss.af3.platform.ui.editpart.generic.TransmissionUnitDefaultEditPart; +import org.fortiss.tooling.kernel.ui.extension.IEditPartFactory; + +/** + * + * @author eder + * @author $Author: hoelzl $ + * @version $Rev: 18709 $ + * @ConQAT.Rating RED Hash: + */ +public class EditPartFactory implements IEditPartFactory { + + /** {@inheritDoc} */ + @Override + public EditPart createEditPart(EditPart context, Object model) { + if(model instanceof RaspberryPi) { + return new ExecutionUnitEditPart((RaspberryPi)model) { + /** {@inheritDoc} */ + @Override + protected Color getBackgroundColor() { + return DefaultStyle.EU_BACKGROUND; + } + + /** {@inheritDoc} */ + @Override + protected Color getForegroundColor() { + return DefaultStyle.EU_FOREGROUND; + } + }; + } else if(model instanceof CanBus) { + return new TransmissionUnitDefaultEditPart((CanBus)model); + } else if(model instanceof CanConnector || model instanceof SensorConnector || + model instanceof ActuatorConnector) { + return new StickyPlatformConnectorUnitEditPart((PlatformConnectorUnit)model); + } + return null; + } +} diff --git a/org.fortiss.af3.platform.raspberry.ui/tags/end-of-first-course/src/org/fortiss/af3/platform/raspberry/ui/handler/CanBusHandler.java b/org.fortiss.af3.platform.raspberry.ui/tags/end-of-first-course/src/org/fortiss/af3/platform/raspberry/ui/handler/CanBusHandler.java new file mode 100644 index 0000000000000000000000000000000000000000..80896163253a640110905b5f14d95a1e0377a4fd --- /dev/null +++ b/org.fortiss.af3.platform.raspberry.ui/tags/end-of-first-course/src/org/fortiss/af3/platform/raspberry/ui/handler/CanBusHandler.java @@ -0,0 +1,57 @@ +/*--------------------------------------------------------------------------+ +$Id: codetemplates.xml 1 2011-01-01 00:00:01Z hoelzl $ +| | +| Copyright 2017 fortiss GmbH | +| | +| Licensed 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 org.fortiss.af3.platform.raspberry.ui.handler; + +import java.util.List; + +import org.eclipse.emf.ecore.EObject; +import org.eclipse.jface.resource.ImageDescriptor; +import org.fortiss.af3.platform.raspberry.model.CanBus; +import org.fortiss.af3.platform.raspberry.ui.AF3PlatformRaspberryUIActivator; +import org.fortiss.tooling.kernel.ui.extension.IModelElementHandler; +import org.fortiss.tooling.kernel.ui.extension.base.ModelElementHandlerBase; + +/** + * {@link IModelElementHandler} for {@link CanBus}. + * + * @author eder + * @author $Author: hoelzl $ + * @version $Rev: 18709 $ + * @ConQAT.Rating RED Hash: + */ +@SuppressWarnings({"unchecked", "rawtypes"}) +public class CanBusHandler extends ModelElementHandlerBase<CanBus> { + /** {@inheritDoc} */ + @Override + public String getName(CanBus element) { + String name = element.getName(); + return name != null ? name : "CanBus"; + } + + /** {@inheritDoc} */ + @Override + public ImageDescriptor getIconImageDescriptor() { + return AF3PlatformRaspberryUIActivator.getImageDescriptor("icons/can-logo.jpeg"); + } + + /** {@inheritDoc} */ + @Override + public List<EObject> getConnectors(CanBus element) { + return (List)element.getConnectors(); + } +} diff --git a/org.fortiss.af3.platform.raspberry.ui/tags/end-of-first-course/src/org/fortiss/af3/platform/raspberry/ui/handler/CanConnectorHandler.java b/org.fortiss.af3.platform.raspberry.ui/tags/end-of-first-course/src/org/fortiss/af3/platform/raspberry/ui/handler/CanConnectorHandler.java new file mode 100644 index 0000000000000000000000000000000000000000..d3a100a40ed6980ee21563323a7dc7383a520c47 --- /dev/null +++ b/org.fortiss.af3.platform.raspberry.ui/tags/end-of-first-course/src/org/fortiss/af3/platform/raspberry/ui/handler/CanConnectorHandler.java @@ -0,0 +1,48 @@ +/*--------------------------------------------------------------------------+ +$Id: codetemplates.xml 1 2011-01-01 00:00:01Z hoelzl $ +| | +| Copyright 2017 fortiss GmbH | +| | +| Licensed 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 org.fortiss.af3.platform.raspberry.ui.handler; + +import static org.fortiss.af3.platform.ui.AF3PlatformUIActivator.getImageDescriptor; + +import org.eclipse.jface.resource.ImageDescriptor; +import org.fortiss.af3.platform.raspberry.model.CanConnector; +import org.fortiss.tooling.kernel.ui.extension.IModelElementHandler; +import org.fortiss.tooling.kernel.ui.extension.base.ModelElementHandlerBase; + +/** + * {@link IModelElementHandler} for {@link CanConnector}. + * + * @author eder + * @author $Author: hoelzl $ + * @version $Rev: 18709 $ + * @ConQAT.Rating RED Hash: + */ +public class CanConnectorHandler extends ModelElementHandlerBase<CanConnector> { + /** {@inheritDoc} */ + @Override + public ImageDescriptor getIconImageDescriptor() { + return getImageDescriptor("icons/unknown.png"); + } + + /** {@inheritDoc} */ + @Override + public String getName(CanConnector element) { + String name = element.getName(); + return name != null ? name : "CanConnector"; + } +} diff --git a/org.fortiss.af3.platform.raspberry.ui/tags/end-of-first-course/src/org/fortiss/af3/platform/raspberry/ui/handler/RaspberryPiHandler.java b/org.fortiss.af3.platform.raspberry.ui/tags/end-of-first-course/src/org/fortiss/af3/platform/raspberry/ui/handler/RaspberryPiHandler.java new file mode 100644 index 0000000000000000000000000000000000000000..b56bcee3cb7fd311b455267551cd06e9eb4c05c5 --- /dev/null +++ b/org.fortiss.af3.platform.raspberry.ui/tags/end-of-first-course/src/org/fortiss/af3/platform/raspberry/ui/handler/RaspberryPiHandler.java @@ -0,0 +1,58 @@ +/*--------------------------------------------------------------------------+ +$Id: codetemplates.xml 1 2011-01-01 00:00:01Z hoelzl $ +| | +| Copyright 2017 fortiss GmbH | +| | +| Licensed 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 org.fortiss.af3.platform.raspberry.ui.handler; + +import java.util.List; + +import org.eclipse.emf.ecore.EObject; +import org.eclipse.jface.resource.ImageDescriptor; +import org.fortiss.af3.platform.raspberry.model.RaspberryPi; +import org.fortiss.af3.platform.raspberry.ui.AF3PlatformRaspberryUIActivator; +import org.fortiss.tooling.kernel.ui.extension.IModelElementHandler; +import org.fortiss.tooling.kernel.ui.extension.base.ModelElementHandlerBase; + +/** + * {@link IModelElementHandler} for {@link RaspberryPi}. + * + * @author eder + * @author $Author: hoelzl $ + * @version $Rev: 18709 $ + * @ConQAT.Rating RED Hash: + */ +@SuppressWarnings({"unchecked", "rawtypes"}) +public class RaspberryPiHandler extends ModelElementHandlerBase<RaspberryPi> { + /** {@inheritDoc} */ + @Override + public String getName(RaspberryPi element) { + final String name = element.getName(); + return name != null ? name : "RaspberryPi"; + } + + /** {@inheritDoc} */ + @Override + public ImageDescriptor getIconImageDescriptor() { + return AF3PlatformRaspberryUIActivator.getImageDescriptor("icons/raspberry-pi-logo.png"); + } + + /** {@inheritDoc} */ + @Override + public List<EObject> getConnectors(RaspberryPi element) { + return (List)element.getConnectors(); + } + +} diff --git a/org.fortiss.af3.platform.raspberry.ui/tags/end-of-first-course/src/org/fortiss/af3/platform/raspberry/ui/prototype/ProtoypeProvider.java b/org.fortiss.af3.platform.raspberry.ui/tags/end-of-first-course/src/org/fortiss/af3/platform/raspberry/ui/prototype/ProtoypeProvider.java new file mode 100644 index 0000000000000000000000000000000000000000..448ebb2f3099aaef5b068e9d9ce91cbe5e03b83d --- /dev/null +++ b/org.fortiss.af3.platform.raspberry.ui/tags/end-of-first-course/src/org/fortiss/af3/platform/raspberry/ui/prototype/ProtoypeProvider.java @@ -0,0 +1,181 @@ +/*--------------------------------------------------------------------------+ +$Id: codetemplates.xml 1 2011-01-01 00:00:01Z hoelzl $ +| | +| Copyright 2017 fortiss GmbH | +| | +| Licensed 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 org.fortiss.af3.platform.raspberry.ui.prototype; + +import static org.fortiss.tooling.base.layout.DefaultLayoutConstants.DEFAULT_SHAPE_MINIMUM_HEIGHT; +import static org.fortiss.tooling.base.layout.DefaultLayoutConstants.DEFAULT_SHAPE_MINIMUM_WIDTH; +import static org.fortiss.tooling.base.ui.utils.LayoutDataUIUtils.setConnectorPosition; +import static org.fortiss.tooling.base.utils.LayoutDataUtils.setNodeBounds; +import static org.fortiss.tooling.base.utils.LayoutDataUtils.setNodePosition; +import static org.fortiss.tooling.base.utils.LayoutModelElementFactory.createRectangle; + +import org.fortiss.af3.platform.raspberry.model.ActuatorPWM; +import org.fortiss.af3.platform.raspberry.model.CanBus; +import org.fortiss.af3.platform.raspberry.model.CanConnector; +import org.fortiss.af3.platform.raspberry.model.GPI; +import org.fortiss.af3.platform.raspberry.model.GPO; +import org.fortiss.af3.platform.raspberry.model.RaspberryPi; +import org.fortiss.af3.platform.raspberry.model.SensorIMU; +import org.fortiss.af3.platform.raspberry.model.SensorLaserRangeFinder; +import org.fortiss.af3.platform.raspberry.model.SensorLaserScanner; +import org.fortiss.af3.platform.raspberry.model.WheelEncoder; +import org.fortiss.af3.platform.raspberry.model.gamepad.Button1; +import org.fortiss.af3.platform.raspberry.model.gamepad.Button2; +import org.fortiss.af3.platform.raspberry.model.gamepad.Button3; +import org.fortiss.af3.platform.raspberry.model.gamepad.Button4; +import org.fortiss.af3.platform.raspberry.model.gamepad.ButtonL1; +import org.fortiss.af3.platform.raspberry.model.gamepad.ButtonL2; +import org.fortiss.af3.platform.raspberry.model.gamepad.ButtonR1; +import org.fortiss.af3.platform.raspberry.model.gamepad.ButtonR2; +import org.fortiss.af3.platform.raspberry.model.gamepad.Left_StickX_Position; +import org.fortiss.af3.platform.raspberry.model.gamepad.Left_StickY_Position; +import org.fortiss.af3.platform.raspberry.model.gamepad.Right_StickX_Position; +import org.fortiss.af3.platform.raspberry.model.gamepad.Right_StickY_Position; +import org.fortiss.af3.platform.raspberry.util.RaspberryModelElementFactory; +import org.fortiss.tooling.kernel.extension.base.PrototypeProviderBase; +import org.fortiss.tooling.kernel.extension.data.PrototypeCategory; + +/** + * + * @author eder + * @author $Author: hoelzl $ + * @version $Rev: 18709 $ + * @ConQAT.Rating RED Hash: + */ +public class ProtoypeProvider extends PrototypeProviderBase { + + /** Stores the category to display for these prototypes. */ + protected final static String CATEGORY_NAME = "RaspberryPI Platform"; + /** Category for gamepad elements. */ + protected final static String GAMEPAD = "Gamepad"; + + /** {@inheritDoc} */ + @Override + protected void registerPrototypes() { + RaspberryPi pi = RaspberryModelElementFactory.createRaspberryPi(); + registerPrimaryPrototype("RaspberryPi", pi, CATEGORY_NAME); + PrototypeCategory prototypeCategory = registerPrototypeCategory(CATEGORY_NAME); + registerPrototypeCategory(prototypeCategory, GAMEPAD); + + CanBus bus = RaspberryModelElementFactory.createCanBus(); + setNodeBounds(bus, + createRectangle(0, 0, DEFAULT_SHAPE_MINIMUM_WIDTH, DEFAULT_SHAPE_MINIMUM_HEIGHT)); + registerPrototype("CanBus", bus, CATEGORY_NAME); + + CanConnector con = RaspberryModelElementFactory.createCanConnector(); + setNodePosition(con, 0, 0); + setConnectorPosition(con, 0, 0); + registerPrototype("CanConnector", con, CATEGORY_NAME); + + SensorIMU imu = RaspberryModelElementFactory.createSensorIMU(); + setNodePosition(imu, 0, 0); + setConnectorPosition(imu, 0, 0); + registerPrototype("IMU_Sensor", imu, CATEGORY_NAME); + + SensorLaserRangeFinder slrf = RaspberryModelElementFactory.createSensorLaserRangeFinder(); + setNodePosition(slrf, 0, 0); + setConnectorPosition(slrf, 0, 0); + registerPrototype("LaserRangeFinder_Sensor", slrf, CATEGORY_NAME); + + SensorLaserScanner sls = RaspberryModelElementFactory.createSensorLaserScanner(); + setNodePosition(sls, 0, 0); + setConnectorPosition(sls, 0, 0); + registerPrototype("LaserScanner_Sensor", sls, CATEGORY_NAME); + + ActuatorPWM pwm = RaspberryModelElementFactory.createActuatorPWM(); + setNodePosition(pwm, 0, 0); + setConnectorPosition(pwm, 0, 0); + registerPrototype("PWM_Actuator", pwm, CATEGORY_NAME); + + GPI gpi = RaspberryModelElementFactory.createGPI(); + setNodePosition(gpi, 0, 0); + setConnectorPosition(gpi, 0, 0); + registerPrototype("GPI", gpi, CATEGORY_NAME); + + GPO gpo = RaspberryModelElementFactory.createGPO(); + setNodePosition(gpo, 0, 0); + setConnectorPosition(gpo, 0, 0); + registerPrototype("GPO", gpo, CATEGORY_NAME); + + WheelEncoder wEncoder = RaspberryModelElementFactory.createWheelEncoder(); + setNodePosition(wEncoder, 0, 0); + setConnectorPosition(wEncoder, 0, 0); + registerPrototype("WheelEncoder", wEncoder, CATEGORY_NAME); + + Button1 button1 = RaspberryModelElementFactory.createButton1(); + setNodePosition(button1, 0, 0); + setConnectorPosition(button1, 0, 0); + registerPrototype(button1.getName(), button1, GAMEPAD); + + Button2 button2 = RaspberryModelElementFactory.createButton2(); + setNodePosition(button2, 0, 0); + setConnectorPosition(button2, 0, 0); + registerPrototype(button2.getName(), button2, GAMEPAD); + + Button3 button3 = RaspberryModelElementFactory.createButton3(); + setNodePosition(button3, 0, 0); + setConnectorPosition(button3, 0, 0); + registerPrototype(button3.getName(), button3, GAMEPAD); + + Button4 button4 = RaspberryModelElementFactory.createButton4(); + setNodePosition(button4, 0, 0); + setConnectorPosition(button4, 0, 0); + registerPrototype(button4.getName(), button4, GAMEPAD); + + ButtonL1 buttonL1 = RaspberryModelElementFactory.createButtonL1(); + setNodePosition(buttonL1, 0, 0); + setConnectorPosition(buttonL1, 0, 0); + registerPrototype(buttonL1.getName(), buttonL1, GAMEPAD); + + ButtonL2 buttonL2 = RaspberryModelElementFactory.createButtonL2(); + setNodePosition(buttonL2, 0, 0); + setConnectorPosition(buttonL2, 0, 0); + registerPrototype(buttonL2.getName(), buttonL2, GAMEPAD); + + ButtonR1 buttonR1 = RaspberryModelElementFactory.createButtonR1(); + setNodePosition(buttonR1, 0, 0); + setConnectorPosition(buttonR1, 0, 0); + registerPrototype(buttonR1.getName(), buttonR1, GAMEPAD); + + ButtonR2 buttonR2 = RaspberryModelElementFactory.createButtonR2(); + setNodePosition(buttonR2, 0, 0); + setConnectorPosition(buttonR2, 0, 0); + registerPrototype(buttonR2.getName(), buttonR2, GAMEPAD); + + Left_StickX_Position Left_StickX = RaspberryModelElementFactory.createLeftStickX(); + setNodePosition(Left_StickX, 0, 0); + setConnectorPosition(Left_StickX, 0, 0); + registerPrototype(Left_StickX.getName(), Left_StickX, GAMEPAD); + + Left_StickY_Position Left_StickY = RaspberryModelElementFactory.createLeftStickY(); + setNodePosition(Left_StickY, 0, 0); + setConnectorPosition(Left_StickY, 0, 0); + registerPrototype(Left_StickY.getName(), Left_StickY, GAMEPAD); + + Right_StickX_Position Right_StickX = RaspberryModelElementFactory.createRightStickX(); + setNodePosition(Right_StickX, 0, 0); + setConnectorPosition(Right_StickX, 0, 0); + registerPrototype(Right_StickX.getName(), Right_StickX, GAMEPAD); + + Right_StickY_Position Right_StickY = RaspberryModelElementFactory.createRightStickY(); + setNodePosition(Right_StickY, 0, 0); + setConnectorPosition(Right_StickY, 0, 0); + registerPrototype(Right_StickY.getName(), Right_StickY, GAMEPAD); + + } +}