Skip to content

Instantly share code, notes, and snippets.

View kthoms's full-sized avatar
👨‍💻
Working in spare time on Eclipse IDE & Xtext

Karsten Thoms kthoms

👨‍💻
Working in spare time on Eclipse IDE & Xtext
View GitHub Profile
@kthoms
kthoms / gist:1771043
Created February 8, 2012 16:57
Spray_Listing_Styles_BlackAndWhiteStyle_DSL
style BlackAndWhiteStyle {
description = "A style with white background and black foreground."
transparency = 0.95
background-color = black
line-color = black
line-style = solid
line-width = 1
font-color = black
font-name = "Tahoma"
font-size = 10
@kthoms
kthoms / gist:1771065
Created February 8, 2012 17:02
Spray_Listing_Styles_BlackAndWhiteStyle_Java
IGaService gaService = Graphiti.getGaService();
// Creating Style with given id and description
Style style = super.getStyle(diagram);
style.setId("BlackAndWhiteStyle");
style.setDescription("A style with white background and black foreground.");
// transparency value
style.setTransparency(0.95);
public class DmodelCustomOpenModelElementFeature extends DmodelCustomOpenModelElementFeatureBase {
@Inject IURIEditorOpener opener;
public DmodelCustomOpenModelElementFeature(IFeatureProvider fp) {
super(fp);
opener = Activator.get(IURIEditorOpener.class);
}
@Override
public boolean canExecute(ICustomContext context) {
@kthoms
kthoms / gist:1820444
Created February 13, 2012 21:02
Eclipse Magazin Spray
class Relation icon "uml/Extension.gif" :
connection ( ) {
from fromEntity;
to toEntity;
fromText text ( ) {
fromCardinality
};
toText text ( ) {
toCardinality
};
@kthoms
kthoms / GC291W9.java
Created May 21, 2012 06:44
Solution for Geocache GC291W9
package main;
import ch.aplu.turtle.Turtle;
import ch.aplu.turtle.TurtleFrame;
/**
* see http://www.aplu.ch/home/apluhomex.jsp?site=65
* download Jar from http://www.aplu.ch/home/download/aplujar5.zip
* see http://www.geocaching.com/seek/cache_details.aspx?guid=fb9e65c2-aa9e-4848-9786-899d6eed9ca9
*/
@kthoms
kthoms / QlDsl.xtext
Last active December 12, 2015 10:19
LWC13: QlDsl.xtext, Step 1
grammar org.eclipse.xtext.example.ql.QlDsl with org.eclipse.xtext.xbase.Xbase
generate qlDsl "http://www.eclipse.org/xtext/example/ql/QlDsl"
/* The top-most container of QL files is a Questionnaire */
Questionnare:
imports+=Import*
forms+=Form*;
/* Allows importing of qualified names of types */
@kthoms
kthoms / houseowning.ql
Created February 26, 2013 06:15
LWC13: Initial QL model
import types.Money
form Box1HouseOwning {
hasSoldHouse: "Did you sell a house in 2010?" boolean
hasBoughtHouse: "Did you by a house in 2010?" boolean
hasMaintLoan: "Did you enter a loan for maintenance/reconstruction?" boolean
sellingPrice: "Price the house was sold for :" Money
privateDebt: "Private debts for the sold house: " Money
valueResidue: "Value residue: " Money
@kthoms
kthoms / Ql.xtext
Created March 8, 2013 05:39
LWC13: QlDsl.xtext, Step2
grammar org.eclipse.xtext.example.ql.QlDsl with org.eclipse.xtext.xbase.Xbase
generate qlDsl "http://www.eclipse.org/xtext/example/ql/QlDsl"
/* The top-most container of QL files is a Questionnaire */
Questionnaire:
imports+=Import*
forms+=Form*;
/* Allows importing of qualified names of types */
@kthoms
kthoms / QlDslJvmModelInferrer.xtend
Created March 11, 2013 06:03
LWC13: QlDslJvmModelInferrer.xtend
package org.eclipse.xtext.example.ql.jvmmodel
import com.google.inject.Inject
import java.io.Serializable
import org.eclipse.xtext.common.types.JvmOperation
import org.eclipse.xtext.common.types.util.TypeReferences
import org.eclipse.xtext.example.ql.qlDsl.ConditionalQuestionGroup
import org.eclipse.xtext.example.ql.qlDsl.Question
import org.eclipse.xtext.example.ql.qlDsl.Questionnaire
import org.eclipse.xtext.xbase.XExpression
@kthoms
kthoms / QlDslXtendValidator.xtend
Created March 25, 2013 20:33
LWC13: QlDslXtendValidator.xtend check_featureDeclaredBeforeCall
@Check
def void check_featureDeclaredBeforeCall (XFeatureCall featureCall) {
val featureSource = featureCall.feature.sourceElements.head
val nodeFeature = if (featureSource != null) featureSource.node else featureCall.feature.node
val nodeCall = featureCall.node
if (nodeFeature != null) {
if (nodeFeature.offset > nodeCall.offset) {
error(featureCall.feature.simpleName+" must be declared before.",featureCall,
XbasePackage::eINSTANCE.XAbstractFeatureCall_Feature, IssueCodes::FEATURE_CALL_BEFORE_DECLARATION, null
)