Commit 5cfb6b6d authored by Alexander Diewald's avatar Alexander Diewald
Browse files

Merge branch '3885' into 'master'

[UI] Introduce JavaFX-based editor for OperatorPanel

See merge request af3/af3!265
parents 4e8d62ff 1c89e260
AF3ComponentUIActivator.java 64ae4377ecc4975ff42fc3dbe70754dd1775dc07 YELLOW
AF3ComponentUIActivator.java 64ae4377ecc4975ff42fc3dbe70754dd1775dc07 GREEN
DefaultStyle.java c3b60c89b4917e9d8514812ee1884010d142b616 GREEN
......@@ -138,6 +138,12 @@
modelElementClass="org.fortiss.af3.operatorpanel.viewpanel.model.OP3DDisplay">
</modelElementClass>
</modelEditorBinding>
<modelEditorBinding
binding="org.fortiss.af3.operatorpanel.ui.editor.fx.OperatorPanelFXEditorBinding">
<modelElementClass
modelElementClass="org.fortiss.af3.operatorpanel.model.OperatorPanelSpecification">
</modelElementClass>
</modelEditorBinding>
</extension>
<extension
point="org.fortiss.tooling.kernel.ui.editPartFactory">
......
OperatorPanelControllerFactory.java af4f811952dad2cc5dae53c0fef2c4952db253eb GREEN
OperatorPanelFXEditor.java f3f4a848984763fafdc57e4499f0318829d27e47 GREEN
OperatorPanelFXEditorBinding.java 269d7b5340ced0a5f61e792c8b5d768fe04c9922 GREEN
OperatorPanelItemController.java 346a2902a74ee5e185ae2099ca9374eee501f843 GREEN
OperatorPanelModelFactory.java 0ef189c6e589351c59a2186d4fa9570367ad7397 GREEN
OperatorPanelVisualFactory.java 85d35ae542e2f3492c3f23aacf33dfb31fd0cd37 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.operatorpanel.ui.editor.fx;
import org.eclipse.systemfocus.kernel.common.ui.javafx.lwfxef.controller.IController;
import org.eclipse.systemfocus.kernel.common.ui.javafx.lwfxef.controller.IControllerFactory;
import org.eclipse.systemfocus.kernel.common.ui.javafx.lwfxef.mvc.IContentAnchorageMVCBundle;
import org.eclipse.systemfocus.kernel.common.ui.javafx.lwfxef.mvc.IContentMVCBundle;
import org.eclipse.systemfocus.kernel.common.ui.javafx.lwfxef.mvc.IDiagramAnchorageMVCBundle;
import org.eclipse.systemfocus.kernel.common.ui.javafx.lwfxef.mvc.IDiagramMVCBundle;
import org.eclipse.systemfocus.kernel.common.ui.javafx.lwfxef.mvc.ILinkMVCBundle;
import org.fortiss.af3.operatorpanel.model.OperatorPanelSpecification;
import org.fortiss.tooling.base.ui.editor.fx.controller.EObjectDiagramController;
/**
* The implementation of the {@link IControllerFactory} for the operator panel.
*
* @author munaro
*/
public class OperatorPanelControllerFactory implements IControllerFactory {
/** {@inheritDoc} */
@Override
public IController createContentController(IContentMVCBundle model) {
return new OperatorPanelItemController(model);
}
/** {@inheritDoc} */
@Override
public IController createDiagramAnchorageController(IDiagramAnchorageMVCBundle modelBundle) {
return null;
}
/** {@inheritDoc} */
@Override
public IController createContentAnchorageController(IContentAnchorageMVCBundle modelBundle) {
return null;
}
/** {@inheritDoc} */
@Override
public IController createLinkController(ILinkMVCBundle modelBundle) {
return null;
}
/** {@inheritDoc} */
@Override
public IController createDiagramController(IDiagramMVCBundle diagramBundle) {
return new EObjectDiagramController<>(diagramBundle, OperatorPanelSpecification.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.operatorpanel.ui.editor.fx;
import org.fortiss.af3.operatorpanel.model.OperatorPanelSpecification;
import org.fortiss.tooling.kernel.ui.extension.base.LWFXEFEditorBase;
/**
* Graphical editor for operator panels based on JavaFX.
*
* @author munaro
*/
public class OperatorPanelFXEditor extends LWFXEFEditorBase<OperatorPanelSpecification> {
// Concrete class for reference from the plugin.xml file.
}
/*-------------------------------------------------------------------------+
| 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.operatorpanel.ui.editor.fx;
import org.eclipse.systemfocus.kernel.common.ui.javafx.lwfxef.controller.IControllerFactory;
import org.eclipse.systemfocus.kernel.common.ui.javafx.lwfxef.model.IModelFactory;
import org.eclipse.systemfocus.kernel.common.ui.javafx.lwfxef.visual.IVisualFactory;
import org.eclipse.ui.IEditorPart;
import org.fortiss.af3.operatorpanel.model.OperatorPanelSpecification;
import org.fortiss.tooling.kernel.ui.extension.base.ModelEditorBindingBase;
/**
* Editor binding for the JavaFX-based operator panel editor.
*
* @author munaro
*/
public class OperatorPanelFXEditorBinding
extends ModelEditorBindingBase<OperatorPanelSpecification> {
/** {@inheritDoc} */
@Override
public Class<? extends IEditorPart> getEditorClass() {
return OperatorPanelFXEditor.class;
}
/** {@inheritDoc} */
@Override
public Class<? extends IModelFactory> getModelFactory() {
return OperatorPanelModelFactory.class;
}
/** {@inheritDoc} */
@Override
public Class<? extends IVisualFactory> getVisualFactory() {
return OperatorPanelVisualFactory.class;
}
/** {@inheritDoc} */
@Override
public Class<? extends IControllerFactory> getControllerFactory() {
return OperatorPanelControllerFactory.class;
}
/** {@inheritDoc} */
@Override
public String getLabel() {
return "Operator Panel (FX)";
}
/** {@inheritDoc} */
@Override
public int getPriority() {
return -100;
}
}
/*-------------------------------------------------------------------------+
| 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.operatorpanel.ui.editor.fx;
import org.eclipse.systemfocus.kernel.common.ui.javafx.lwfxef.controller.IController;
import org.eclipse.systemfocus.kernel.common.ui.javafx.lwfxef.controller.IDragController;
import org.eclipse.systemfocus.kernel.common.ui.javafx.lwfxef.mvc.IContentAnchorageMVCBundle;
import org.eclipse.systemfocus.kernel.common.ui.javafx.lwfxef.mvc.IContentMVCBundle;
import org.fortiss.af3.operatorpanel.model.OperatorPanelItem;
import org.fortiss.tooling.base.ui.editor.fx.controller.LayoutedRectangularResizableContentController;
import javafx.geometry.Side;
/**
* {@link IController} for {@link OperatorPanelItem}s displayed in the diagram.
*
*
* @author munaro
*/
public class OperatorPanelItemController
extends LayoutedRectangularResizableContentController<OperatorPanelItem> {
/** Constructor. */
public OperatorPanelItemController(IContentMVCBundle mvcb) {
super(mvcb, OperatorPanelItem.class);
}
/** {@inheritDoc} */
@Override
protected boolean allowLink() {
return false;
}
/** {@inheritDoc} */
@Override
protected IDragController createAnchorageMoveController(IContentAnchorageMVCBundle anchorage) {
return null;
}
/** {@inheritDoc} */
@Override
protected void moveAnchorageToSideOffset(IContentAnchorageMVCBundle anchorage, Side side,
double offset) {
// Nothing to do
}
}
/*-------------------------------------------------------------------------+
| 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.operatorpanel.ui.editor.fx;
import static java.util.Collections.emptyList;
import static java.util.Objects.requireNonNull;
import java.util.List;
import org.eclipse.systemfocus.kernel.common.ui.javafx.lwfxef.model.IModelFactory;
import org.fortiss.af3.operatorpanel.model.OperatorPanelSpecification;
/**
* The implementation of the {@link IModelFactory} for the operator panel.
*
* @author munaro
*/
public class OperatorPanelModelFactory implements IModelFactory {
/** The currently edited operator panel. */
private final OperatorPanelSpecification rootElement;
/** Constructor. */
public OperatorPanelModelFactory(OperatorPanelSpecification root) {
this.rootElement = requireNonNull(root);
}
/** {@inheritDoc} */
@Override
public Object getRootModel() {
return rootElement;
}
/** {@inheritDoc} */
@Override
public List<?> getContentModels() {
return rootElement.getItems();
}
/** {@inheritDoc} */
@Override
public List<?> getDiagramAnchorageModels() {
return emptyList();
}
/** {@inheritDoc} */
@Override
public List<?> getContentAnchorageModels(Object parent) {
return emptyList();
}
/** {@inheritDoc} */
@Override
public List<?> getLinkModels() {
return emptyList();
}
/** {@inheritDoc} */
@Override
public Object getLinkStart(Object link) {
return null;
}
/** {@inheritDoc} */
@Override
public Object getLinkEnd(Object link) {
return null;
}
/** {@inheritDoc} */
@Override
public Object getParent(Object element) {
return null;
}
/** {@inheritDoc} */
@Override
public void update() {
// Nothing to do
}
}
/*-------------------------------------------------------------------------+
| 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.operatorpanel.ui.editor.fx;
import org.eclipse.systemfocus.kernel.common.ui.javafx.lwfxef.mvc.IContentAnchorageMVCBundle;
import org.eclipse.systemfocus.kernel.common.ui.javafx.lwfxef.mvc.IContentMVCBundle;
import org.eclipse.systemfocus.kernel.common.ui.javafx.lwfxef.mvc.IDiagramAnchorageMVCBundle;
import org.eclipse.systemfocus.kernel.common.ui.javafx.lwfxef.mvc.ILinkMVCBundle;
import org.eclipse.systemfocus.kernel.common.ui.javafx.lwfxef.visual.IContentAnchorageVisual;
import org.eclipse.systemfocus.kernel.common.ui.javafx.lwfxef.visual.IContentVisual;
import org.eclipse.systemfocus.kernel.common.ui.javafx.lwfxef.visual.IDiagramAnchorageVisual;
import org.eclipse.systemfocus.kernel.common.ui.javafx.lwfxef.visual.ILinkVisual;
import org.eclipse.systemfocus.kernel.common.ui.javafx.lwfxef.visual.IVisualFactory;
import org.fortiss.af3.operatorpanel.model.OPAreaInput;
import org.fortiss.af3.operatorpanel.model.OPButton;
import org.fortiss.af3.operatorpanel.model.OPColorDisplay;
import org.fortiss.af3.operatorpanel.model.OPITermInput;
import org.fortiss.af3.operatorpanel.model.OPLabel;
import org.fortiss.af3.operatorpanel.model.OPTextDisplay;
import org.fortiss.af3.operatorpanel.ui.editor.fx.visual.AreaInputVisual;
import org.fortiss.af3.operatorpanel.ui.editor.fx.visual.ButtonVisual;
import org.fortiss.af3.operatorpanel.ui.editor.fx.visual.ColorDisplayVisual;
import org.fortiss.af3.operatorpanel.ui.editor.fx.visual.Display3DVisual;
import org.fortiss.af3.operatorpanel.ui.editor.fx.visual.Graph2DVisual;
import org.fortiss.af3.operatorpanel.ui.editor.fx.visual.ITermInputVisual;
import org.fortiss.af3.operatorpanel.ui.editor.fx.visual.LabelVisual;
import org.fortiss.af3.operatorpanel.ui.editor.fx.visual.TextDisplayVisual;
import org.fortiss.af3.operatorpanel.viewpanel.model.OP2DGraphDisplay;
import org.fortiss.af3.operatorpanel.viewpanel.model.OP3DDisplay;
/**
* The implementation of the {@link IVisualFactory} for the operator panel.
*
* @author munaro
*/
public class OperatorPanelVisualFactory implements IVisualFactory {
/** {@inheritDoc} */
@Override
public IContentVisual createContentVisual(IContentMVCBundle modelBundle) {
Object modelObj = modelBundle.getModel();
if(modelObj instanceof OPLabel) {
return new LabelVisual(modelBundle);
}
if(modelObj instanceof OPAreaInput) {
return new AreaInputVisual(modelBundle);
}
if(modelObj instanceof OPTextDisplay) {
return new TextDisplayVisual(modelBundle);
}
if(modelObj instanceof OPColorDisplay) {
return new ColorDisplayVisual(modelBundle);
}
if(modelObj instanceof OPButton) {
return new ButtonVisual(modelBundle);
}
if(modelObj instanceof OPITermInput) {
return new ITermInputVisual(modelBundle);
}
if(modelObj instanceof OP3DDisplay) {
return new Display3DVisual(modelBundle);
}
if(modelObj instanceof OP2DGraphDisplay) {
return new Graph2DVisual(modelBundle);
}
return null;
}
/** {@inheritDoc} */
@Override
public IDiagramAnchorageVisual
createDiagramAnchorageVisual(IDiagramAnchorageMVCBundle modelBundle) {
return null;
}
/** {@inheritDoc} */
@Override
public IContentAnchorageVisual
createContentAnchorageVisual(IContentAnchorageMVCBundle modelBundle) {
return null;
}
/** {@inheritDoc} */
@Override
public ILinkVisual createLinkVisual(ILinkMVCBundle modelBundle) {
return null;
}
}
AreaInputVisual.java 11d5d5d21b6ec985acf2b3d8acdb9ee103c14c81 GREEN
ButtonVisual.java 7eaada73ef762d173031aea0871af2da48ea850d GREEN
ColorDisplayVisual.java 3fe3cd82f2445e1b39023d5058756a078d7a9882 GREEN
Display3DVisual.java a06d53435e7314cd3fbd9b68b23349a3ffcff37a GREEN
Graph2DVisual.java eb023548dd8c88ec563af1db9f831e50e1145a50 GREEN
ITermInputVisual.java ba3903609be0ccfde15ad1d0277414c90f2835b7 GREEN
LabelVisual.java 8327be0cb6cbd0a7a136211fa87ad9f4ef676616 GREEN
OperatorPanelItemVisualBase.java bff495b7515b96a5d61369d099e67d25cbf36398 GREEN
TextDisplayVisual.java e16d46489d952e58d19c06867cf74bb124f579a5 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.operatorpanel.ui.editor.fx.visual;
import static org.fortiss.af3.operatorpanel.ui.AF3OperatorpanelUIActivator.PLUGIN_ID;
import static org.fortiss.tooling.common.ui.javafx.util.GraphicUtils.getFXImage;
import org.eclipse.systemfocus.kernel.common.ui.javafx.lwfxef.mvc.IContentMVCBundle;
import org.eclipse.systemfocus.kernel.common.ui.javafx.lwfxef.visual.IContentVisual;
import org.fortiss.af3.operatorpanel.model.OPAreaInput;
import javafx.scene.image.Image;
/**
* {@link IContentVisual} for {@link OPAreaInput}s displayed in the diagram.
*
* @author munaro
*/
public class AreaInputVisual extends OperatorPanelItemVisualBase<OPAreaInput> {
/** Constructor. */
public AreaInputVisual(IContentMVCBundle mvcb) {
super(mvcb, OPAreaInput.class);
}
/** {@inheritDoc} */
@Override
protected Image getIcon() {
return getFXImage(PLUGIN_ID, "/icons/area_input.png");
}
}
/*-------------------------------------------------------------------------+
| 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.operatorpanel.ui.editor.fx.visual;
import static org.fortiss.af3.operatorpanel.ui.AF3OperatorpanelUIActivator.PLUGIN_ID;
import static org.fortiss.tooling.common.ui.javafx.util.GraphicUtils.getFXImage;
import org.eclipse.systemfocus.kernel.common.ui.javafx.lwfxef.mvc.IContentMVCBundle;
import org.eclipse.systemfocus.kernel.common.ui.javafx.lwfxef.visual.IContentVisual;
import org.fortiss.af3.operatorpanel.model.OPButton;
import javafx.scene.image.Image;
import javafx.scene.paint.Color;
import javafx.scene.paint.Paint;
/**
* {@link IContentVisual} for {@link OPButton}s displayed in the diagram.
*
* @author munaro
*/
public class ButtonVisual extends OperatorPanelItemVisualBase<OPButton> {
/** Constructor. */
public ButtonVisual(IContentMVCBundle mvcb) {
super(mvcb, OPButton.class);
}
/** {@inheritDoc} */
@Override
protected Paint getFillColor() {
return Color.DARKGRAY;
}
/** {@inheritDoc} */
@Override
protected Image getIcon() {
return getFXImage(PLUGIN_ID, "/icons/button.png");
}
}
/*-------------------------------------------------------------------------+
| Copyright 2019 fortiss GmbH |
| |