Commit 0acd3e31 authored by Johannes Eder's avatar Johannes Eder
Browse files

Merge branch '4053' into 'master'

4053

See merge request af3/af3!358
parents 44949afd 85862384
......@@ -25,19 +25,22 @@
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.modelEditorBinding">
<modelEditorBinding
binding="org.fortiss.af3.platform.raspberry.ui.editor.PlatformRaspberryPiArchitectureFXEditorBinding">
<modelElementClass
modelElementClass="org.fortiss.af3.platform.model.PlatformArchitecture"></modelElementClass>
</modelEditorBinding>
<modelEditorBinding binding="org.fortiss.af3.platform.raspberry.ui.editor.PlatformRaspberryPiArchitectureFXEditorBinding">
<modelElementClass modelElementClass="org.fortiss.af3.platform.raspberry.model.RaspberryPi"/>
</modelEditorBinding>
<modelEditorBinding binding="org.fortiss.af3.platform.raspberry.ui.editor.PlatformRaspberryPiArchitectureFXEditorBinding">
<modelElementClass modelElementClass="org.fortiss.af3.platform.raspberry.model.CanBus"/>
</modelEditorBinding>
</extension>
<extension
point="org.fortiss.tooling.kernel.ui.editPartFactory">
<editPartFactory
......@@ -413,6 +416,18 @@
<modelElementClass
modelElementClass="org.fortiss.af3.platform.raspberry.model.lightrunner.Poti"/>
</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.eclipse.ui.views.properties.tabbed.propertySections">
......
PlatformRaspberryPiArchitectureFXEditorBinding.java 9be142805db274439b6c5e05470d822272f03539 GREEN
PlatformRaspberryPiControllerFactory.java afdb681a5a039ac0512b7f8897815ca358bdc8e7 GREEN
PlatformRaspberryPiModelFactory.java a2550b7cd0b6d31767db7fc316ecca687f0039bf GREEN
PlatformRaspberryPiVisualFactory.java c3e24dee4a2557dd88d9d8b3a899330d068bef6d GREEN
/*-------------------------------------------------------------------------+
| Copyright 2019 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.editor;
import org.eclipse.ui.IEditorPart;
import org.fortiss.af3.platform.model.PlatformArchitecture;
import org.fortiss.tooling.common.ui.javafx.lwfxef.controller.IControllerFactory;
import org.fortiss.tooling.common.ui.javafx.lwfxef.model.IModelFactory;
import org.fortiss.tooling.common.ui.javafx.lwfxef.visual.IVisualFactory;
import org.fortiss.tooling.kernel.ui.extension.base.ModelEditorBindingBase;
/**
* Editor binding for the JavaFX-based platform architecture editor.
*
* @author eisenmann
*/
public class PlatformRaspberryPiArchitectureFXEditorBinding
extends ModelEditorBindingBase<PlatformArchitecture> {
/** {@inheritDoc} */
@Override
public Class<? extends IEditorPart> getEditorClass() {
// has to be null otherwise editor is instantiated twice
return null;
}
/** {@inheritDoc} */
@Override
public Class<? extends IModelFactory> getModelFactory() {
return PlatformRaspberryPiModelFactory.class;
}
/** {@inheritDoc} */
@Override
public Class<? extends IVisualFactory> getVisualFactory() {
return PlatformRaspberryPiVisualFactory.class;
}
/** {@inheritDoc} */
@Override
public Class<? extends IControllerFactory> getControllerFactory() {
return PlatformRaspberryPiControllerFactory.class;
}
/** {@inheritDoc} */
@Override
public int getPriority() {
return 0;
}
}
/*-------------------------------------------------------------------------+
| Copyright 2019 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.editor;
import org.fortiss.af3.platform.model.PlatformArchitecture;
import org.fortiss.af3.platform.model.TransmissionConnection;
import org.fortiss.af3.platform.raspberry.model.CanBus;
import org.fortiss.af3.platform.raspberry.model.RaspberryPi;
import org.fortiss.af3.platform.raspberry.model.RaspberryPiReceiverBase;
import org.fortiss.af3.platform.raspberry.model.RaspberryPiTransmitterBase;
import org.fortiss.tooling.base.ui.editor.fx.controller.EObjectDiagramController;
import org.fortiss.tooling.base.ui.editor.fx.controller.LayoutedContentAnchorageController;
import org.fortiss.tooling.base.ui.editor.fx.controller.LayoutedLineLinkBendPointController;
import org.fortiss.tooling.base.ui.editor.fx.controller.LayoutedRectangularResizableContentController;
import org.fortiss.tooling.common.ui.javafx.lwfxef.controller.IController;
import org.fortiss.tooling.common.ui.javafx.lwfxef.controller.IControllerFactory;
import org.fortiss.tooling.common.ui.javafx.lwfxef.mvc.IContentAnchorageMVCBundle;
import org.fortiss.tooling.common.ui.javafx.lwfxef.mvc.IContentMVCBundle;
import org.fortiss.tooling.common.ui.javafx.lwfxef.mvc.IDiagramAnchorageMVCBundle;
import org.fortiss.tooling.common.ui.javafx.lwfxef.mvc.IDiagramMVCBundle;
import org.fortiss.tooling.common.ui.javafx.lwfxef.mvc.ILinkMVCBundle;
/**
* The implementation of the {@link IControllerFactory} for the platform architecture editor.
*
* @author eisenmann
*/
public class PlatformRaspberryPiControllerFactory implements IControllerFactory {
/** {@inheritDoc} */
@Override
public IController createContentController(IContentMVCBundle modelBundle) {
Object model = modelBundle.getModel();
if(model instanceof RaspberryPi) {
return new LayoutedRectangularResizableContentController<>(modelBundle,
RaspberryPi.class);
} else if(model instanceof CanBus) {
return new LayoutedRectangularResizableContentController<>(modelBundle, CanBus.class);
}
return null;
}
/** {@inheritDoc} */
@Override
public IController createDiagramAnchorageController(IDiagramAnchorageMVCBundle modelBundle) {
return null;
}
/** {@inheritDoc} */
@Override
public IController createContentAnchorageController(IContentAnchorageMVCBundle modelBundle) {
Object model = modelBundle.getModel();
if(model instanceof RaspberryPiReceiverBase) {
return new LayoutedContentAnchorageController<>(modelBundle,
RaspberryPiReceiverBase.class);
} else if(model instanceof RaspberryPiTransmitterBase) {
return new LayoutedContentAnchorageController<>(modelBundle,
RaspberryPiTransmitterBase.class);
}
return null;
}
/** {@inheritDoc} */
@Override
public IController createLinkController(ILinkMVCBundle modelBundle) {
return new LayoutedLineLinkBendPointController<>(modelBundle, TransmissionConnection.class);
}
/** {@inheritDoc} */
@Override
public IController createDiagramController(IDiagramMVCBundle diagramBundle) {
return new EObjectDiagramController<>(diagramBundle, PlatformArchitecture.class);
}
}
/*-------------------------------------------------------------------------+
| Copyright 2019 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.editor;
import static java.util.Collections.emptyList;
import java.util.List;
import org.fortiss.af3.platform.model.PlatformArchitecture;
import org.fortiss.af3.platform.raspberry.model.CanBus;
import org.fortiss.af3.platform.raspberry.model.RaspberryPi;
import org.fortiss.af3.platform.ui.editor.fx.PlatformModelFactory;
import org.fortiss.tooling.common.ui.javafx.lwfxef.model.IModelFactory;
/**
* The implementation of the {@link IModelFactory} for the RaspberryPi platform architecture editor.
*
* @author eisenmann
*/
public class PlatformRaspberryPiModelFactory extends PlatformModelFactory {
/** Constructor. */
public PlatformRaspberryPiModelFactory(PlatformArchitecture root) {
super(root);
}
/** {@inheritDoc} */
@Override
public List<?> getContentAnchorageModels(Object parent) {
if(parent instanceof RaspberryPi) {
return ((RaspberryPi)parent).getConnectors();
}
if(parent instanceof CanBus) {
return ((CanBus)parent).getConnectors();
}
return emptyList();
}
}
/*-------------------------------------------------------------------------+
| Copyright 2019 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.editor;
import org.fortiss.af3.platform.model.TransmissionConnection;
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.RaspberryPiReceiverBase;
import org.fortiss.af3.platform.raspberry.model.RaspberryPiTransmitterBase;
import org.fortiss.af3.platform.raspberry.model.brick.UIDReceiver;
import org.fortiss.af3.platform.raspberry.model.brick.UIDTtransmitter;
import org.fortiss.af3.platform.raspberry.model.gamepad.GamepadReceiverBase;
import org.fortiss.af3.platform.raspberry.model.rumblepad.RumbleMagnitudeStrong;
import org.fortiss.af3.platform.raspberry.model.rumblepad.RumbleMagnitudeWeak;
import org.fortiss.af3.platform.raspberry.model.rumblepad.RumblepadReceiverBase;
import org.fortiss.af3.platform.raspberry.ui.editor.visual.CanBusTransmissionUnitVisual;
import org.fortiss.af3.platform.raspberry.ui.editor.visual.RaspberryPiExecutionUnitVisual;
import org.fortiss.af3.platform.raspberry.ui.editor.visual.RaspberryPiReceiverVisual;
import org.fortiss.af3.platform.raspberry.ui.editor.visual.RaspberryPiTransceiverVisual;
import org.fortiss.af3.platform.raspberry.ui.editor.visual.RaspberryPiTransmitterVisual;
import org.fortiss.af3.platform.ui.editor.fx.visual.TransmissionConnectionVisual;
import org.fortiss.tooling.common.ui.javafx.lwfxef.mvc.IContentAnchorageMVCBundle;
import org.fortiss.tooling.common.ui.javafx.lwfxef.mvc.IContentMVCBundle;
import org.fortiss.tooling.common.ui.javafx.lwfxef.mvc.IDiagramAnchorageMVCBundle;
import org.fortiss.tooling.common.ui.javafx.lwfxef.mvc.ILinkMVCBundle;
import org.fortiss.tooling.common.ui.javafx.lwfxef.visual.IContentAnchorageVisual;
import org.fortiss.tooling.common.ui.javafx.lwfxef.visual.IContentVisual;
import org.fortiss.tooling.common.ui.javafx.lwfxef.visual.IDiagramAnchorageVisual;
import org.fortiss.tooling.common.ui.javafx.lwfxef.visual.ILinkVisual;
import org.fortiss.tooling.common.ui.javafx.lwfxef.visual.IVisualFactory;
/**
* The implementation of the {@link IVisualFactory} for the platform architecture editor.
*
* @author eisenmann
*/
public class PlatformRaspberryPiVisualFactory implements IVisualFactory {
/** {@inheritDoc} */
@Override
public IContentVisual createContentVisual(IContentMVCBundle modelBundle) {
Object modelObj = modelBundle.getModel();
if(modelObj instanceof RaspberryPi) {
return new RaspberryPiExecutionUnitVisual(modelBundle);
}
if(modelObj instanceof CanBus) {
return new CanBusTransmissionUnitVisual(modelBundle);
}
return null;
}
/** {@inheritDoc} */
@Override
public IDiagramAnchorageVisual
createDiagramAnchorageVisual(IDiagramAnchorageMVCBundle modelBundle) {
return null;
}
/** {@inheritDoc} */
@Override
public IContentAnchorageVisual
createContentAnchorageVisual(IContentAnchorageMVCBundle modelBundle) {
Object modelObj = modelBundle.getModel();
if(modelObj instanceof RaspberryPiTransmitterBase ||
modelObj instanceof RumbleMagnitudeStrong ||
modelObj instanceof RumbleMagnitudeWeak || modelObj instanceof UIDTtransmitter) {
return new RaspberryPiTransmitterVisual(modelBundle);
}
if(modelObj instanceof RaspberryPiReceiverBase || modelObj instanceof GamepadReceiverBase ||
modelObj instanceof RumblepadReceiverBase || modelObj instanceof UIDReceiver) {
return new RaspberryPiReceiverVisual(modelBundle);
}
if(modelObj instanceof CanConnector) {
return new RaspberryPiTransceiverVisual(modelBundle);
}
return null;
}
/** {@inheritDoc} */
@Override
public ILinkVisual createLinkVisual(ILinkMVCBundle modelBundle) {
Object modelObj = modelBundle.getModel();
if(modelObj instanceof TransmissionConnection) {
return new TransmissionConnectionVisual(modelBundle);
}
return null;
}
}
CanBusTransmissionUnitVisual.java e5b63b66db715016a836643fc3e0411ff88c029f GREEN
RaspberryPiExecutionUnitVisual.java 157aa23b9ba18e591b434c59576df5c2e43b49de GREEN
RaspberryPiReceiverVisual.java 474b6e6057a3330f84bc9f7eb953ebc6cd9e3d30 GREEN
RaspberryPiTransceiverVisual.java 60c020813f9b213f341fd0a7f14b07bfddd92870 GREEN
RaspberryPiTransmitterVisual.java 2adead2607212ce25501619e1498b6a2066e3561 GREEN
/*-------------------------------------------------------------------------+
| Copyright 2019 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.editor.visual;
import static javafx.scene.paint.Color.BLACK;
import static javafx.scene.text.TextAlignment.CENTER;
import static org.eclipse.wb.swt.SWTResourceManager.getColor;
import static org.fortiss.af3.platform.ui.AF3PlatformUIActivator.PLUGIN_ID;
import static org.fortiss.af3.platform.ui.DefaultStyle.EU_FOREGROUND;
import static org.fortiss.tooling.common.ui.javafx.util.GraphicUtils.convertColor;
import static org.fortiss.tooling.common.ui.javafx.util.GraphicUtils.getFXImage;
import org.fortiss.af3.platform.raspberry.model.CanBus;
import org.fortiss.tooling.base.ui.editor.fx.visual.NamedLayoutedRectangularContentVisual;
import org.fortiss.tooling.common.ui.javafx.lwfxef.mvc.IContentMVCBundle;
import org.fortiss.tooling.common.ui.javafx.lwfxef.visual.IContentVisual;
import javafx.scene.image.Image;
import javafx.scene.paint.Color;
import javafx.scene.paint.Paint;
import javafx.scene.text.TextAlignment;
/**
* {@link IContentVisual} for {@link CanBus}s displayed in the diagram.
*
* @author eisenmann
*/
public final class CanBusTransmissionUnitVisual
extends NamedLayoutedRectangularContentVisual<CanBus> {
/** The icon image. */
private static final Image ICON = getFXImage(PLUGIN_ID, "/icons/unknown.png");
/** The fill color used by CanBusTransmissionUnitVisual. */
private static final Color FILL_COLOR = convertColor(getColor(47, 86, 233));
/** The foreground color used by CanBusTransmissionUnitVisual. */
private static final Color BORDER_COLOR = convertColor(EU_FOREGROUND);
/** Constructor. */
public CanBusTransmissionUnitVisual(IContentMVCBundle mvcb) {
super(mvcb, CanBus.class);
}
/** {@inheritDoc} */
@Override
protected TextAlignment getHorizontalTextAlignment() {
return CENTER;
}
/** {@inheritDoc} */
@Override
protected Color getSelectedFocusedColor() {
return BLACK;
}
/** {@inheritDoc} */
@Override
protected Paint getFillColor() {
return FILL_COLOR;
}
/** {@inheritDoc} */
@Override
protected Paint getBorderColor() {
return BORDER_COLOR;
}
/** {@inheritDoc} */
@Override
protected Image getIcon() {
return ICON;
}
}
/*-------------------------------------------------------------------------+
| Copyright 2019 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.editor.visual;
import static javafx.scene.paint.Color.BLACK;
import static javafx.scene.text.TextAlignment.CENTER;
import static org.fortiss.af3.platform.ui.AF3PlatformUIActivator.PLUGIN_ID;
import static org.fortiss.af3.platform.ui.DefaultStyle.EU_BACKGROUND;
import static org.fortiss.af3.platform.ui.DefaultStyle.EU_FOREGROUND;
import static org.fortiss.tooling.common.ui.javafx.util.GraphicUtils.convertColor;
import static org.fortiss.tooling.common.ui.javafx.util.GraphicUtils.getFXImage;
import org.fortiss.af3.platform.raspberry.model.RaspberryPi;
import org.fortiss.tooling.base.ui.editor.fx.visual.NamedLayoutedRectangularContentVisual;
import org.fortiss.tooling.common.ui.javafx.lwfxef.mvc.IContentMVCBundle;
import org.fortiss.tooling.common.ui.javafx.lwfxef.visual.IContentVisual;
import javafx.scene.image.Image;
import javafx.scene.paint.Color;
import javafx.scene.paint.Paint;
import javafx.scene.text.TextAlignment;
/**
* {@link IContentVisual} for {@link RaspberryPi}s displayed in the diagram.
*
* @author eisenmann
*/
public final class RaspberryPiExecutionUnitVisual
extends NamedLayoutedRectangularContentVisual<RaspberryPi> {
/** The icon image. */
private static final Image ICON = getFXImage(PLUGIN_ID, "/icons/unknown.png");
/** The fill color used by RaspberryPis. */
private static final Color FILL_COLOR = convertColor(EU_BACKGROUND);
/** The foreground color used by RaspberryPis. */
private static final Color BORDER_COLOR = convertColor(EU_FOREGROUND);
/** Constructor. */
public RaspberryPiExecutionUnitVisual(IContentMVCBundle mvcb) {
super(mvcb, RaspberryPi.class);
}
/** {@inheritDoc} */
@Override
protected TextAlignment getHorizontalTextAlignment() {
return CENTER;
}
/** {@inheritDoc} */
@Override
protected Color getSelectedFocusedColor() {
return BLACK;
}
/** {@inheritDoc} */
@Override
protected Paint getFillColor() {
return FILL_COLOR;
}
/** {@inheritDoc} */
@Override
protected Paint getBorderColor() {
return BORDER_COLOR;
}
/** {@inheritDoc} */
@Override
protected Image getIcon() {
return ICON;
}
}
/*-------------------------------------------------------------------------+
| Copyright 2019 fortiss GmbH |
| |
| Licensed under the Apache License, Version 2.0 (the "License"); |
| you may not use this file except in compliance with the License. |