Skip to content

Instantly share code, notes, and snippets.

View louismrose's full-sized avatar

Louis Rose louismrose

View GitHub Profile
// Currently type is checked against the name of each class directly
public Collection<EObject> getAllOfType(String type) throws EolModelElementTypeNotFoundException {
...
if (allOfType == null || !cachingEnabled){
allOfType = new ArrayList<EObject>();
for (EObject eObject : allContents()) {
if (eObject.eClass().getName().equals(type) || getFullyQualifiedName(eObject.eClass()).equals(type)){
allOfType.add(eObject);
import static org.junit.Assert.*;
import java.util.*;
import org.junit.*;
public class SellOneItemTest {
public static class Sale {
private Display display;
/*******************************************************************************
* Copyright (c) 2011 The University of York.
* 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:
* Louis Rose - initial API and implementation
******************************************************************************/
@louismrose
louismrose / HelloServlet.java
Created December 3, 2012 21:00
ENAR - Redis on Heroku
package com.example;
import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
import javax.servlet.ServletException;
import javax.servlet.ServletOutputStream;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
@louismrose
louismrose / HelloServlet.java
Created December 3, 2012 21:11
ENAR - MongoDB on Heroku
package com.example;
import java.io.IOException;
import java.net.URI;
import java.net.UnknownHostException;
import java.util.Set;
import java.util.logging.Logger;
import javax.servlet.ServletConfig;
import javax.servlet.ServletException;
@louismrose
louismrose / PetriNetConvert.java
Created March 2, 2013 11:03
Code for converting an EMF file containing ID-based references to EMF fragment path style references. Models using the latter format appear to be quicker to load than equivalent models using the former.
/**
* <copyright>
* </copyright>
*
* $Id$
*/
package PetriNet.tests;
import PetriNet.Net;
import PetriNet.PetriNetFactory;
// diff --git a/plugins/org.eclipse.epsilon.eol.engine/src/org/eclipse/epsilon/eol/AbstractModule.java b/plugins/org.eclipse.epsilon.eol.engine/src/org/eclipse/epsilon/eol/AbstractModule.java
// index 20c1972..8a98273 100644
//--- a/plugins/org.eclipse.epsilon.eol.engine/src/org/eclipse/epsilon/eol/AbstractModule.java
//+++ b/plugins/org.eclipse.epsilon.eol.engine/src/org/eclipse/epsilon/eol/AbstractModule.java
//@@ -69,7 +69,9 @@ public abstract class AbstractModule extends AbstractModuleElement implements IM
public boolean parse(String code, File file) throws Exception {
this.sourceFile = file;
- this.sourceUri = (file != null) ? file.toURI() : null;
+ if (file != null) {
public void run(IAction action) {
if (getFirstElementInSelection() instanceof IFile) {
final IFile file = (IFile)getFirstElementInSelection();
String projectName = file.getProject().getName();
final EglFileGeneratingTemplateFactory factory = new EglFileGeneratingTemplateFactory();
final EglTemplate template = factory.load(Activator.getDefault().getBundle().getResource("transformations/my.egx").toURI());
// You'll need to loop over the list returned by this method, and
// log any errors somewhere.
<?php
class Widget_Controller extends Dev_Controller {
public function show() {
$params = $this->app->request()->params();
// Here we use a "null object" that initialises all attributes to empty strings or other sensible defaults
$this->render(new Widget());
}
public function create() {
@louismrose
louismrose / state.json
Created July 25, 2013 12:49
First cut of behavioural definition
{
"name": "State",
"properties": [
"name",
"recurrent",
"w",
"h"
],
"behavior": {
"tick" : {