Skip to content
Snippets Groups Projects
Commit 2cd8f1a5 authored by Florian Hölzl's avatar Florian Hölzl
Browse files

Kernel: JavaFX editor. Added base classes for extendable LWFXEF editor.

parent 54ab765a
No related branches found
No related tags found
2 merge requests!81JFX: Base classes,!75Kernel: JavaFX editor. Added base classes for extendable LWFXEF editor.
DelegatingControllerFactoryBase.java dea6b5dc56a157f0125bfe5c176e993d376b66b2 YELLOW
DelegatingFactoryBase.java 37955dec868a0cb0e12986997c0078e0348e9e16 YELLOW
DelegatingModelFactoryBase.java 413dcfad6542ffbc9a9504d08c17f6741ec3b01c YELLOW
DelegatingVisualFactoryBase.java 4ec6971399df993b4cbd6d6ced6e801d914e1ae4 YELLOW
/*-------------------------------------------------------------------------+
| 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.tooling.base.ui.editor.fx.delegating;
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.eclipse.systemfocus.kernel.common.ui.javafx.lwfxef.mvc.IMVCBundle;
import org.fortiss.tooling.kernel.service.ITransformationService;
/**
* Base class for {@link IControllerFactory controller factories} of extendable graphical LWFXEF
* editors.
* <P>
* This class uses the {@link ITransformationService} to find a delegate controller factory for the
* model elements in question.
*
* @author hoelzl
*/
public abstract class DelegatingControllerFactoryBase extends DelegatingFactoryBase
implements IControllerFactory {
/** Uses the {@link ITransformationService} to find a delegate {@link IControllerFactory}. */
private IControllerFactory getDelegateControllerFactory(IMVCBundle modelBundle) {
return getDelegationResult(modelBundle.getModel(), IControllerFactory.class);
}
/** {@inheritDoc} */
@Override
public IController createContentController(IContentMVCBundle modelBundle) {
return getDelegateControllerFactory(modelBundle).createContentController(modelBundle);
}
/** {@inheritDoc} */
@Override
public IController createDiagramAnchorageController(IDiagramAnchorageMVCBundle modelBundle) {
return getDelegateControllerFactory(modelBundle)
.createDiagramAnchorageController(modelBundle);
}
/** {@inheritDoc} */
@Override
public IController createContentAnchorageController(IContentAnchorageMVCBundle modelBundle) {
return getDelegateControllerFactory(modelBundle)
.createContentAnchorageController(modelBundle);
}
/** {@inheritDoc} */
@Override
public IController createLinkController(ILinkMVCBundle modelBundle) {
return getDelegateControllerFactory(modelBundle).createLinkController(modelBundle);
}
/** {@inheritDoc} */
@Override
public IController createDiagramController(IDiagramMVCBundle diagramBundle) {
return getDelegateControllerFactory(diagramBundle).createDiagramController(diagramBundle);
}
}
/*-------------------------------------------------------------------------+
| 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.tooling.base.ui.editor.fx.delegating;
import org.fortiss.tooling.kernel.extension.exception.TransformationFailedException;
import org.fortiss.tooling.kernel.service.ITransformationService;
/**
* Base class for delegating request to the transformation service.
*
* @author hoelzl
*/
abstract class DelegatingFactoryBase {
/** The transformation service. */
protected final static ITransformationService SERVICE = ITransformationService.getInstance();
/** Tries to transform the given object into the given target class. */
@SuppressWarnings("unchecked")
protected <T> T getDelegationResult(Object model, Class<T> targetType) {
Exception ex = null;
try {
if(SERVICE.canTransform(model, targetType, null)) {
return (T)SERVICE.transform(model, targetType, null);
}
} catch(TransformationFailedException tfex) {
ex = tfex;
}
throw new IllegalArgumentException("Missing transformation from '" +
model.getClass().getName() + "' to '" + targetType.getName(), ex);
}
}
/*-------------------------------------------------------------------------+
| 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.tooling.base.ui.editor.fx.delegating;
import java.util.List;
import org.eclipse.systemfocus.kernel.common.ui.javafx.lwfxef.model.IModelFactory;
import org.fortiss.tooling.kernel.service.ITransformationService;
/**
* Base class for {@link IModelFactory model factories} of extendable graphical LWFXEF
* editors.
* <P>
* This class uses the {@link ITransformationService} to find a delegate model factory for the
* model elements in question.
*
* @author hoelzl
*/
public abstract class DelegatingModelFactoryBase extends DelegatingFactoryBase
implements IModelFactory {
/** Uses the {@link ITransformationService} to find a delegate {@link IModelFactory}. */
private IModelFactory getDelegateModelFactory(Object model) {
return getDelegationResult(model, IModelFactory.class);
}
/** {@inheritDoc} */
@Override
public List<?> getContentAnchorageModels(Object parent) {
return getDelegateModelFactory(parent).getContentAnchorageModels(parent);
}
/** {@inheritDoc} */
@Override
public Object getLinkStart(Object link) {
return getDelegateModelFactory(link).getLinkStart(link);
}
/** {@inheritDoc} */
@Override
public Object getLinkEnd(Object link) {
return getDelegateModelFactory(link).getLinkEnd(link);
}
/** {@inheritDoc} */
@Override
public Object getParent(Object element) {
return getDelegateModelFactory(element).getParent(element);
}
}
/*-------------------------------------------------------------------------+
| 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.tooling.base.ui.editor.fx.delegating;
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.mvc.IMVCBundle;
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.tooling.kernel.service.ITransformationService;
/**
* Base class for {@link IVisualFactory visual factories} of extendable graphical LWFXEF editors.
* <P>
* This class uses the {@link ITransformationService} to find a delegate visual factory for the
* model elements in question.
*
* @author hoelzl
*/
public abstract class DelegatingVisualFactoryBase extends DelegatingFactoryBase
implements IVisualFactory {
/** Uses the {@link ITransformationService} to find a delegate {@link IVisualFactory}. */
private IVisualFactory getDelegateVisualFactory(IMVCBundle modelBundle) {
return getDelegationResult(modelBundle.getModel(), IVisualFactory.class);
}
/** {@inheritDoc} */
@Override
public IContentVisual createContentVisual(IContentMVCBundle modelBundle) {
return getDelegateVisualFactory(modelBundle).createContentVisual(modelBundle);
}
/** {@inheritDoc} */
@Override
public IDiagramAnchorageVisual
createDiagramAnchorageVisual(IDiagramAnchorageMVCBundle modelBundle) {
return getDelegateVisualFactory(modelBundle).createDiagramAnchorageVisual(modelBundle);
}
/** {@inheritDoc} */
@Override
public IContentAnchorageVisual
createContentAnchorageVisual(IContentAnchorageMVCBundle modelBundle) {
return getDelegateVisualFactory(modelBundle).createContentAnchorageVisual(modelBundle);
}
/** {@inheritDoc} */
@Override
public ILinkVisual createLinkVisual(ILinkMVCBundle modelBundle) {
return getDelegateVisualFactory(modelBundle).createLinkVisual(modelBundle);
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment