blob: 7928bdb413fc924b4423e6c7f48a4673713059d6 [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:
* Christophe Loetz (Loetz GmbH&Co.KG) - initial implementation
*/
package org.eclipse.osbp.infogrid.ecview;
import org.eclipse.osbp.infogrid.api.DefaultECViewGridFactory;
import org.eclipse.osbp.infogrid.api.IECViewGridFactory;
import org.eclipse.osbp.infogrid.api.IGridSourceDescriptor;
import org.eclipse.osbp.infogrid.api.IGridSourceDescriptor.ConfigCallback;
import org.eclipse.osbp.infogrid.api.IGridSourceDescriptorProvider;
import org.eclipse.osbp.infogrid.api.SingleECViewGridFactory;
import org.eclipse.osbp.infogrid.model.gridsource.CxGridSource;
import org.osgi.service.component.annotations.Component;
/**
* Creates an ECViewGridSourceDescriptor which is based on ECView.
*/
@Component(property = { IGridSourceDescriptorProvider.PROP_KIND + "="
+ IGridSourceDescriptorProvider.KIND_ECVIEW })
public class GridSourceDescriptorProvider implements
IGridSourceDescriptorProvider {
@Override
public IGridSourceDescriptor createDescriptor(Class<?> inputType,
CxGridSource source, ConfigCallback callback) {
ECViewGridSourceDescriptor descriptor = new ECViewGridSourceDescriptor(
inputType, source, createFactory(source));
if (callback != null) {
descriptor.setProperties(callback.getProperties(descriptor));
}
return descriptor;
}
/**
* Creates a proper grid factory for different use cases.
*
* @param source
* @return
*/
private IECViewGridFactory createFactory(CxGridSource source) {
if (source.getTags().contains(IGridSourceDescriptor.TAG__SINGLE_GRID)) {
return new SingleECViewGridFactory();
}
return new DefaultECViewGridFactory();
}
}