blob: 3b05da8e55993fedd115fedca796bde05442cf76 [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 v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Christophe Loetz (Loetz GmbH&Co.KG) - initial implementation
*
*
* This copyright notice shows up in the generated Java code
*
*/
package org.eclipse.osbp.xtext.entitymock.ui.labeling
import com.google.inject.Inject
import org.eclipse.osbp.xtext.basic.ui.labeling.BasicDSLLabelProvider
import org.eclipse.osbp.xtext.entitymock.EntityMockAttributeByObject
import org.eclipse.osbp.xtext.entitymock.EntityMockAttributeFiller
import org.eclipse.osbp.xtext.entitymock.EntityMockEntities
import org.eclipse.osbp.xtext.entitymock.EntityMockEntity
import org.eclipse.osbp.xtext.entitymock.EntityMockModel
import org.eclipse.osbp.xtext.entitymock.EntityMockObjectArrayValue
import org.eclipse.osbp.xtext.entitymock.EntityMockObjectEmbed
import org.eclipse.osbp.xtext.entitymock.EntityMockObjectEnum
import org.eclipse.osbp.xtext.entitymock.EntityMockObjectFill
import org.eclipse.osbp.xtext.entitymock.EntityMockObject
import org.eclipse.osbp.xtext.entitymock.EntityMockObjectPlainValue
import org.eclipse.osbp.xtext.entitymock.EntityMockObjects
import org.eclipse.osbp.xtext.entitymock.EntityMockPackage
import org.eclipse.osbp.dsl.semantic.common.types.LImport
import org.eclipse.xtext.Keyword
import org.eclipse.osbp.xtext.entitymock.EntityMockAttributeByReference
import org.eclipse.osbp.xtext.entitymock.EntityMockReferencedObjectAttribute
import org.eclipse.osbp.xtext.entitymock.PropertyFillerTextSentences
import org.eclipse.osbp.xtext.entitymock.PropertyFillerUnsignedDoubleRange
import org.eclipse.osbp.xtext.entitymock.EntityMockObjectItemValue
import org.eclipse.osbp.xtext.entitymock.PropertyFillerDateFuture
import org.eclipse.osbp.xtext.entitymock.PropertyFillerDatePast
import org.eclipse.osbp.xtext.entitymock.PropertyFillerDateRange
import org.eclipse.osbp.xtext.entitymock.PropertyFillerSignedDoubleRandom
import org.eclipse.osbp.xtext.entitymock.PropertyFillerSignedDoubleRange
import org.eclipse.osbp.xtext.entitymock.PropertyFillerSignedIntegerRandom
import org.eclipse.osbp.xtext.entitymock.PropertyFillerSignedIntegerRange
import org.eclipse.osbp.xtext.entitymock.PropertyFillerTextParagraphs
import org.eclipse.osbp.xtext.entitymock.PropertyFillerTextRandom
import org.eclipse.osbp.xtext.entitymock.PropertyFillerTextWords
import org.eclipse.osbp.xtext.entitymock.PropertyFillerUnsignedDoubleRandom
import org.eclipse.osbp.xtext.entitymock.PropertyFillerUnsignedIntegerRandom
import org.eclipse.osbp.xtext.entitymock.PropertyFillerUnsignedIntegerRange
import org.eclipse.osbp.xtext.entitymock.EntityMockResourceDataRow
import org.eclipse.osbp.xtext.entitymock.EntityMockResources
import org.eclipse.osbp.xtext.entitymock.EntityMockResource
import org.eclipse.osbp.xtext.entitymock.RunningDataInterchanges
import org.eclipse.osbp.xtext.entitymock.RunningDataInterchange
import org.eclipse.osbp.xtext.entitymock.DateIterate
import org.eclipse.osbp.xtext.entitymock.EntityMockEntityFunction
import org.eclipse.osbp.xtext.datainterchange.DataInterchangeFileCSV
import org.eclipse.osbp.xtext.datainterchange.DataInterchangeFileEDI
import org.eclipse.osbp.xtext.datainterchange.DataInterchangeFileXML
import org.eclipse.osbp.xtext.entitymock.EntityMockTemplate
/**
* Provides labels for a EObjects.
*
* see http://www.eclipse.org/Xtext/documentation.html#labelProvider
*/
class EntityMockDSLLabelProvider extends BasicDSLLabelProvider {
@Inject
new(org.eclipse.emf.edit.ui.provider.AdapterFactoryLabelProvider delegate) {
super(delegate);
}
override text (Object o) {
switch o {
EntityMockAttributeByObject : generateText( o, 'attribute by object' , o.attributeRef.name )
EntityMockAttributeByReference : generateText( o, 'attribute by reference', o.attributeRef.name )
EntityMockAttributeFiller : generateText( o, 'attribute filler' , o.attributeRef.name )
EntityMockEntities : 'mocked entity model'
EntityMockEntity : generateText( o, 'entity' , o.entityRef.name )
EntityMockEntityFunction : generateText( o, 'entity function' , o.attributeRef?.name )
EntityMockObject : generateText( o, 'object' , o.name )
EntityMockObjectArrayValue : generateText( o, 'array value' , o.name )
EntityMockObjectEmbed : generateText( o, 'object embed' , o.name )
EntityMockObjectEnum : generateText( o, 'object enum' , o.name )
EntityMockObjectFill : generateText( o, 'object fill' , o.name )
EntityMockObjectItemValue : generateText( o, 'item value' , o.datarow.name )
EntityMockObjectPlainValue : generateText( o, 'plain value' , o.name )
EntityMockObjects : 'mock objects'
EntityMockPackage : 'mocked entity model'
EntityMockReferencedObjectAttribute : {
var r = o.template.name
for (e : o.embedded) {
r = '''«r».«e.name»'''
}
'''«r».«getText(o.attribute)»'''.toString
}
EntityMockResource : generateText( o, 'resource' , o.name )
EntityMockResources : 'mock resources'
EntityMockResourceDataRow : generateText( o, 'data row' , o.name )
EntityMockTemplate : generateText( o, 'template' , o.name )
DateIterate : generateText( o, 'date iterate' , (o.eContainer as EntityMockEntity)?.iterator?.name )
LImport : generateText( o, 'import' , o.importedNamespace )
PropertyFillerDateFuture : '''between now and «o.dateFutureYears» years into the future'''
PropertyFillerDatePast : '''between «o.datePastYears» years in the past and now'''
PropertyFillerDateRange : '''between «o.dateBeginYears» and «o.dateEndYears» from now'''
PropertyFillerSignedDoubleRandom : '''random signed double'''
PropertyFillerSignedDoubleRange : '''singned double between «o.beginRange» and «o.endRange» with «o.decimals» decimals'''
PropertyFillerSignedIntegerRandom : '''random signed integer'''
PropertyFillerSignedIntegerRange : '''singned integer between «o.beginRange» and «o.endRange»'''
PropertyFillerTextParagraphs : '''«o.count» paragraph(s)'''
PropertyFillerTextRandom : 'random filler text'
PropertyFillerTextSentences : '''«o.count» sentence(s)'''
PropertyFillerTextWords : '''«o.count» word(s)'''
PropertyFillerUnsignedDoubleRandom : '''random unsigned double'''
PropertyFillerUnsignedDoubleRange : '''unsingned double between «o.beginRange» and «o.endRange» with «o.decimals» decimals'''
PropertyFillerUnsignedIntegerRandom : '''random unsigned integer'''
PropertyFillerUnsignedIntegerRange : '''unsingned integer between «o.beginRange» and «o.endRange»'''
RunningDataInterchange : generateText( o, 'data interchange', o.datainterchangeRef.name )
RunningDataInterchanges : 'data interchanges'
default : {
var r = super.text(o)
if (r == null) {
System.err.println('''text for «o.class.canonicalName»''')
}
r
}
}
}
override image (Object o) {
switch o {
EntityMockAttributeByObject : getInternalImage( 'private_field.png' , class )
EntityMockAttributeByReference : getInternalImage( 'class.gif' , class )
EntityMockAttributeFiller : getImage ( o.fillerType ) //getInternalImage('function.gif')
EntityMockEntities : getInternalImage( 'dice-16.gif' , class )
EntityMockEntity : getInternalImage( 'dice-16.gif' , class )
EntityMockEntityFunction : getInternalImage( 'function.gif' , class )
EntityMockModel : getInternalImage( 'dice-16.gif' , class )
EntityMockObject : getInternalImage( 'private_method.png', class )
EntityMockObjectArrayValue : getInternalImage( 'enum.gif' , class )
EntityMockObjectEmbed : getInternalImage( 'private_field.png' , class )
EntityMockObjectEnum : getInternalImage( 'enum_obj.gif' , class )
EntityMockObjectFill : getImage ( o.fillerType ) //getInternalImage('function.gif')
EntityMockObjectItemValue : getInternalImage( 'array.png' , class )
EntityMockObjectPlainValue : getInternalImage( 'array.png' , class )
EntityMockObjects : getInternalImage( 'private_method.png', class )
EntityMockPackage : getInternalImage( 'package.gif' , class )
EntityMockReferencedObjectAttribute : getInternalImage( 'private_field.png' , class )
EntityMockResourceDataRow : getInternalImage( 'enum_alt_obj.gif' , class )
EntityMockResources : getInternalImage( 'enum_alt_obj.gif' , class )
EntityMockTemplate : getInternalImage( 'private_method.png', class )
DateIterate : getInternalImage( 'date-iterate.png' , class )
Keyword : null
LImport : getInternalImage( 'class.gif' , class )
PropertyFillerDateFuture : getInternalImage( 'calendar-small.gif', class )
PropertyFillerDatePast : getInternalImage( 'calendar-small.gif', class )
PropertyFillerDateRange : getInternalImage( 'calendar-small.gif', class )
PropertyFillerSignedDoubleRandom : getInternalImage( 'double.gif' , class )
PropertyFillerSignedDoubleRange : getInternalImage( 'double.gif' , class )
PropertyFillerSignedIntegerRandom : getInternalImage( 'int.gif' , class )
PropertyFillerSignedIntegerRange : getInternalImage( 'int.gif' , class )
PropertyFillerTextParagraphs : getInternalImage( 'var_string.gif' , class )
PropertyFillerTextRandom : getInternalImage( 'var_string.gif' , class )
PropertyFillerTextSentences : getInternalImage( 'var_string.gif' , class )
PropertyFillerTextWords : getInternalImage( 'var_string.gif' , class )
PropertyFillerUnsignedDoubleRandom : getInternalImage( 'double.gif' , class )
PropertyFillerUnsignedDoubleRange : getInternalImage( 'double.gif' , class )
PropertyFillerUnsignedIntegerRandom : getInternalImage( 'int.gif' , class )
PropertyFillerUnsignedIntegerRange : getInternalImage( 'int.gif' , class )
RunningDataInterchange: {
if (o.datainterchangeRef?.fileEndpoint instanceof DataInterchangeFileCSV) {
getInternalImage('csv.png', class)
}
else if (o.datainterchangeRef?.fileEndpoint instanceof DataInterchangeFileEDI) {
getInternalImage('edi.png', class)
}
else if (o.datainterchangeRef?.fileEndpoint instanceof DataInterchangeFileXML) {
getInternalImage('xml.png', class)
}
else {
getInternalImage('data_interchange.png', class)
}
}
RunningDataInterchanges : getInternalImage( 'dsl_datainterchange.png', class )
default: {
System.err.println('''image for «o.class.canonicalName»''')
null
}
}
}
}