Commits

Anonymous committed c02caa0 Draft

Added missing files.

Comments (0)

Files changed (9)

 include
 bin
 working
-java
 .cache

editor/java/EntityModel/Activator.java

+package EntityModel;
+
+import org.eclipse.imp.preferences.PreferencesService;
+import org.eclipse.imp.runtime.PluginBase;
+import org.osgi.framework.BundleContext;
+
+public class Activator extends PluginBase 
+{ 
+  public static final String kPluginID = "EntityModel";
+
+  public static final String kLanguageName = "EntityModel";
+
+  protected static Activator sPlugin;
+
+  public static Activator getInstance()
+  { 
+    if(sPlugin == null)
+      return new Activator();
+    return sPlugin;
+  }
+
+  public Activator () 
+  { 
+    super();
+    sPlugin = this;
+  }
+
+  @Override public void start(BundleContext context) throws Exception
+  { 
+    super.start(context);
+  }
+
+  @Override public String getID()
+  { 
+    return kPluginID;
+  }
+
+  @Override public String getLanguageID()
+  { 
+    return kLanguageName;
+  }
+
+  protected static PreferencesService preferencesService = null;
+}

editor/java/EntityModel/EntityModelParseController.java

+package EntityModel;
+
+public class EntityModelParseController extends EntityModelParseControllerGenerated 
+{ }

editor/java/EntityModel/EntityModelParseControllerGenerated.java

+package EntityModel;
+
+import java.io.InputStream;
+import java.io.IOException;
+import java.io.File;
+import java.io.FileInputStream;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.imp.parser.IParseController;
+import org.strategoxt.imp.runtime.Environment;
+import org.strategoxt.imp.runtime.dynamicloading.BadDescriptorException;
+import org.strategoxt.imp.runtime.dynamicloading.Descriptor;
+import org.strategoxt.imp.runtime.dynamicloading.DescriptorFactory;
+import org.strategoxt.imp.runtime.dynamicloading.DynamicParseController;
+
+public class EntityModelParseControllerGenerated extends DynamicParseController 
+{ 
+  public static final String LANGUAGE = new String("EntityModel");
+
+  private static final String TABLE = "/include/" + LANGUAGE + ".tbl";
+
+  private static final String DESCRIPTOR = "/include/" + LANGUAGE + ".packed.esv";
+
+  private static volatile Descriptor descriptor;
+
+  private static Throwable notLoadingCause;
+
+  public static synchronized Descriptor getDescriptor()
+  { 
+    if(notLoadingCause != null)
+      throw new RuntimeException(notLoadingCause);
+    if(descriptor == null)
+      createDescriptor();
+    return descriptor;
+  }
+
+  protected static synchronized void setDescriptor(Descriptor descriptor)
+  { 
+    EntityModelParseControllerGenerated.descriptor = descriptor;
+  }
+
+  protected static void createDescriptor()
+  { 
+    try
+    { 
+      InputStream descriptorStream = EntityModelParseControllerGenerated.class.getResourceAsStream(DESCRIPTOR);
+      InputStream table = EntityModelParseControllerGenerated.class.getResourceAsStream(TABLE);
+      boolean filesystem = false;
+      if(descriptorStream == null && new File("./" + DESCRIPTOR).exists())
+      { 
+        descriptorStream = new FileInputStream("./" + DESCRIPTOR);
+        filesystem = true;
+      }
+      if(table == null && new File("./" + TABLE).exists())
+      { 
+        table = new FileInputStream("./" + TABLE);
+        filesystem = true;
+      }
+      if(descriptorStream == null)
+        throw new BadDescriptorException("Could not load descriptor file from " + DESCRIPTOR + " (not found in plugin: " + getPluginLocation() + ")");
+      if(table == null)
+        throw new BadDescriptorException("Could not load parse table from " + TABLE + " (not found in plugin: " + getPluginLocation() + ")");
+      descriptor = DescriptorFactory.load(descriptorStream, table, filesystem ? Path.fromPortableString("./") : null);
+      descriptor.setAttachmentProvider(EntityModelParseControllerGenerated.class);
+    }
+    catch(BadDescriptorException exc)
+    { 
+      notLoadingCause = exc;
+      Environment.logException("Bad descriptor for " + LANGUAGE + " plugin", exc);
+      throw new RuntimeException("Bad descriptor for " + LANGUAGE + " plugin", exc);
+    }
+    catch(IOException exc)
+    { 
+      notLoadingCause = exc;
+      Environment.logException("I/O problem loading descriptor for " + LANGUAGE + " plugin", exc);
+      throw new RuntimeException("I/O problem loading descriptor for " + LANGUAGE + " plugin", exc);
+    }
+  }
+
+  private static String getPluginLocation()
+  { 
+    return EntityModelParseController.class.getProtectionDomain().getCodeSource().getLocation().getFile();
+  }
+
+  @Override public IParseController getWrapped()
+  { 
+    if(!isInitialized())
+    { 
+      if(notLoadingCause != null)
+        throw new RuntimeException(notLoadingCause);
+      try
+      { 
+        initialize(this, getDescriptor().getLanguage());
+      }
+      catch(BadDescriptorException exc)
+      { 
+        notLoadingCause = exc;
+        throw new RuntimeException(exc);
+      }
+    }
+    return super.getWrapped();
+  }
+
+  @Override protected void setNotLoadingCause(Throwable value)
+  { 
+    notLoadingCause = value;
+    super.setNotLoadingCause(value);
+  }
+}

editor/java/EntityModel/EntityModelValidator.java

+package EntityModel;
+
+import org.strategoxt.imp.runtime.dynamicloading.Descriptor;
+import org.strategoxt.imp.runtime.services.MetaFileLanguageValidator;
+
+public class EntityModelValidator extends MetaFileLanguageValidator 
+{ 
+  @Override public Descriptor getDescriptor()
+  { 
+    return EntityModelParseController.getDescriptor();
+  }
+}

editor/java/EntityModel/strategies/InteropRegisterer.java

+package EntityModel.strategies;
+
+import org.strategoxt.lang.JavaInteropRegisterer;
+import org.strategoxt.lang.Strategy;
+
+/**
+ * Helper class for {@link java_strategy_0_0}.
+ */
+public class InteropRegisterer extends JavaInteropRegisterer {
+
+  public InteropRegisterer() {
+    super(new Strategy[] { java_strategy_0_0.instance });
+  }
+}

editor/java/EntityModel/strategies/Main.java

+package EntityModel.strategies;
+
+import org.strategoxt.lang.Context;
+
+public class Main {
+  
+  public static void init(Context context) {
+    // Called when the editor is being initialized
+  }
+
+}

editor/java/EntityModel/strategies/java_strategy_0_0.java

+package EntityModel.strategies;
+
+import org.spoofax.interpreter.terms.IStrategoTerm;
+import org.spoofax.interpreter.terms.ITermFactory;
+import org.strategoxt.lang.Context;
+import org.strategoxt.lang.Strategy;
+
+/**
+ * Example Java strategy implementation.
+ *
+ * This strategy can be used by editor services and can be called
+ * in Stratego modules by declaring it as an external strategy
+ * as follows:
+ *
+ * <code>
+ *  external java-strategy(|)
+ * </code>
+ *
+ * @see InteropRegisterer  This class registers java_strategy_0_0 for use.
+ */
+public class java_strategy_0_0 extends Strategy {
+  
+  public static java_strategy_0_0 instance = new java_strategy_0_0();
+
+  @Override
+  public IStrategoTerm invoke(Context context, IStrategoTerm current) {
+    context.getIOAgent().printError("Input for java-strategy: " + current);
+    ITermFactory factory = context.getFactory();
+    return factory.makeString("Regards from java-strategy");
+  }
+
+}
 from sample.crm import models
 
 class CustomerAdmin(admin.ModelAdmin):
-    pass
+    list_display = ('name', 'description',)
 
 
 class ContactAdmin(admin.ModelAdmin):
-    pass
+    list_display = ('customer', 'name', 'phone', 'email',)