blob: 25fe8c2fd60175e8958fc75acba2449672c98d6f [file] [log] [blame]
/*
*
* Copyright (c) 2011, 2016 - Loetz GmbH&Co.KG (69115 Heidelberg, Germany)
*
* 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:
* Florian Pirchner - Initial implementation
* Loetz GmbH&Co.KG
*
*/
package org.eclipse.osbp.vaadin.emf.views;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.osbp.runtime.web.vaadin.common.resource.IResourceProvider;
import org.eclipse.osbp.vaadin.emf.api.IModelingContext;
import org.eclipse.osbp.vaadin.emf.data.EmfItemPropertyDescritorValueConverter;
import org.eclipse.osbp.vaadin.emf.data.EmfPropertiesContainer;
import org.eclipse.osbp.vaadin.emf.data.fields.EmfItemPropertyEditorField;
import com.vaadin.ui.CustomComponent;
import com.vaadin.ui.Grid;
import com.vaadin.ui.TextField;
import com.vaadin.ui.VerticalLayout;
// TODO: Auto-generated Javadoc
/**
* Show properties for any given EObject.
*/
@SuppressWarnings("serial")
public class EmfPropertyViewer extends CustomComponent {
/** The grid. */
private Grid grid;
/** The container. */
private EmfPropertiesContainer container;
/**
* Instantiates a new emf property viewer.
*
* @param modelingContext
* the modeling context
* @param resourceProvider
* the resource provider
*/
public EmfPropertyViewer(IModelingContext modelingContext,
IResourceProvider resourceProvider) {
VerticalLayout mainLayout = new VerticalLayout();
mainLayout.setSizeFull();
setCompositionRoot(mainLayout);
grid = new Grid();
grid.setSizeFull();
grid.setEditorEnabled(true);
mainLayout.addComponent(grid);
container = new EmfPropertiesContainer(modelingContext, resourceProvider);
grid.setContainerDataSource(container);
grid.getColumn(EmfPropertiesContainer.KEY)
.setEditorField(new TextField()).setEditable(false);
grid.getColumn(EmfPropertiesContainer.VALUE)
.setConverter(new EmfItemPropertyDescritorValueConverter())
.setEditorField(new EmfItemPropertyEditorField(modelingContext));
}
/**
* Sets the root element.
*
* @param rootElement
* the new root element
*/
public void setRootElement(EObject rootElement) {
container.setRootElement(rootElement);
}
}