| /******************************************************************************* |
| * Copyright (c) 2011-2014 EclipseSource Muenchen GmbH and others. |
| * |
| * All rights reserved. This program and the accompanying materials |
| * are made available under the terms of the Eclipse Public License 2.0 |
| * which accompanies this distribution, and is available at |
| * https://www.eclipse.org/legal/epl-2.0/ |
| * |
| * SPDX-License-Identifier: EPL-2.0 |
| * |
| * Contributors: |
| * Edgar Mueller - initial API and implementation |
| ******************************************************************************/ |
| package org.eclipse.emf.ecp.view.internal.swt; |
| |
| import java.util.ArrayList; |
| import java.util.List; |
| |
| import org.eclipse.emf.ecp.view.spi.context.ViewModelContext; |
| import org.eclipse.emf.ecp.view.spi.model.VElement; |
| import org.eclipse.emf.ecp.view.spi.renderer.NoPropertyDescriptorFoundExeption; |
| import org.eclipse.emf.ecp.view.spi.renderer.NoRendererFoundException; |
| import org.eclipse.emfforms.spi.common.report.ReportService; |
| import org.eclipse.emfforms.spi.swt.core.AbstractSWTRenderer; |
| import org.eclipse.emfforms.spi.swt.core.layout.GridDescriptionFactory; |
| import org.eclipse.emfforms.spi.swt.core.layout.SWTGridCell; |
| import org.eclipse.emfforms.spi.swt.core.layout.SWTGridDescription; |
| import org.eclipse.swt.widgets.Composite; |
| import org.eclipse.swt.widgets.Control; |
| |
| /** |
| * An no-op renderer. |
| * |
| * @author emueller |
| * @since 1.3 |
| * |
| */ |
| public final class EmptyVElementSWTRenderer extends AbstractSWTRenderer<VElement> { |
| |
| private final SWTGridDescription gridDescription; |
| |
| /** |
| * @param vElement the view model element to be rendered |
| * @param viewContext the view context |
| * @param reportService teh {@link ReportService} |
| */ |
| public EmptyVElementSWTRenderer(VElement vElement, ViewModelContext viewContext, ReportService reportService) { |
| super(vElement, viewContext, reportService); |
| gridDescription = GridDescriptionFactory.INSTANCE.createEmptyGridDescription(); |
| final SWTGridCell gc = new SWTGridCell(0, 0, this); |
| gc.setHorizontalFill(true); |
| gc.setHorizontalGrab(true); |
| gc.setVerticalFill(false); |
| gc.setVerticalGrab(false); |
| final List<SWTGridCell> grid = new ArrayList<SWTGridCell>(); |
| grid.add(gc); |
| gridDescription.setGrid(grid); |
| } |
| |
| /** |
| * {@inheritDoc} |
| * |
| * @see org.eclipse.emfforms.spi.swt.core.AbstractSWTRenderer#getGridDescription(org.eclipse.emfforms.spi.swt.core.layout.SWTGridDescription) |
| */ |
| @Override |
| public SWTGridDescription getGridDescription(SWTGridDescription gridDescription) { |
| return this.gridDescription; |
| } |
| |
| /** |
| * {@inheritDoc} |
| * |
| * @see org.eclipse.emfforms.spi.swt.core.AbstractSWTRenderer#renderControl(org.eclipse.emfforms.spi.swt.core.layout.SWTGridCell, |
| * org.eclipse.swt.widgets.Composite) |
| */ |
| @Override |
| protected Control renderControl(SWTGridCell cell, Composite parent) throws NoRendererFoundException, |
| NoPropertyDescriptorFoundExeption { |
| // do not render anything |
| return parent; |
| } |
| |
| /** |
| * {@inheritDoc} |
| * |
| * @see org.eclipse.emfforms.spi.swt.core.AbstractSWTRenderer#applyEnable() |
| */ |
| @Override |
| protected void applyEnable() { |
| // do nothing |
| } |
| |
| /** |
| * {@inheritDoc} |
| * |
| * @see org.eclipse.emfforms.spi.swt.core.AbstractSWTRenderer#applyValidation() |
| */ |
| @Override |
| protected void applyValidation() { |
| // do nothing |
| } |
| |
| /** |
| * {@inheritDoc} |
| * |
| * @see org.eclipse.emfforms.spi.swt.core.AbstractSWTRenderer#applyVisible() |
| */ |
| @Override |
| protected void applyVisible() { |
| // do nothing |
| } |
| |
| } |