Implement Serializable in BaseLanguage Class - mps

How can I implement Serializable in a class in BaseLanguage?
What I did so far:
Using MPS 3.3.4
Create new solution Project
Add new Model
Add module.JDK#project_stub as Dependency
Add jetbrains.mps.baseLanguage as Used Language
Add new Class
Trigger implements in editor.
Trigger AutoComplete
The editor now shows a list of available interfaces from java.lang namespace, like Clonable, Comparable and so on. However, there is no Serializable. The same behavior emerges when I try to implement Serializable in a Generator.
Is this a bug or am I missing something?

You perhaps did not import the java.io#java_stub model to your dependencies. Control + M while in the editor will do the job.
Vaclav

Related

Creating Xamarin ios storyboard interfaces using classes that are not directly or do not inheret directly from InterfaceController

When creating a WatchKit (WatchOS) Interface controller in the storyboard designer/editor, I cannot set it's class to something that is not itself type WKInterfaceController nor an immediate derived child of WKInterfaceController.
Basically in the hope of abstraction and better code reuse, better design overall, I would like to be able to use classes that are how to say, a more distant relative of their base WKInterfaceController
Basically right now it seems that your stuck using the storyboard designer to make a new WatchOS project. And using the storyboard designer you only have the option to select the WKInterfaceController class:
public partial class WKInterfaceController
or one that directly inherits from it:
public partial class ChildInterfaceController : WKInterfaceController
but nothing else such as:
public partial class GrandChildInterfaceController: ChildInterfaceController
So is there any way to do this that doesn't risk the chance of getting corrupted when you reenter the storyboard designer at some point?
Note: I've already asked if it is possible to avoid using a storyboard all together, but that has gone unanswered so I'm assuming no.
For clarity I'm talking about this dialog for "class":

Menus in Unity3D, using UnityScript and subclasses

I am trying to set up a generic class that deals with menus within Unity3D.
The following code I intend to attach to an empty game object
import System.Collections.Generic;
#pragma strict
public enum MenuType { loadSceneOnMouseDown, enableGameObject, changeValue };
public class MenuClass extends System.Object
{
public var menuObject : GameObject;
public var menuType : MenuType;
}
public var menuItems = List.<MenuClass>();
This results in the following within the editor:
I want each menu type to have its own parameter, so in this example I want the "loadSceneOnMouseDown" to have another public variable as a string defining the name of the scene to be loaded, once loadSceneOnMouseDown is selected from the enum. Whereas I want the "enableGameObject" Type to have a gameobject as a public var. However I dont want both to appear in both fields. For example I could make it like this:
public class MenuClass extends System.Object
{
public var menuObject : GameObject;
public var menuType : MenuType;
public var sceneName : String
public var targetObject : GameObject
}
But that would make it come under each element of the list. I considered doing a further subclass to resolve this, but then with the line "public var menuItems = List.();" that wouldnt work. (or would it? :D)
Apologies if I have been unclear, trying my best here but Im finding it difficult. Theres probably a very simple solution, or im going about thins entirely the wrong way. Any help with this problem would be very much appreciated!
Thanks!
Unity's serialization doesn't really support polymorphism. A list of type MenuClass can technically contain subclassed objects at runtime, but as far as serializing the list Unity is going to assume they are all objects of the base type.
It's a bit inconvenient, sometimes.
There are a few popular workarounds:
Leave all of the possible fields serialized MenuClass, then write a custom inspector which exposes only the relevant fields while you're working. In simple cases like yours, this is often the quickest solution.
Serialize some basic data fields, then use that data to reconstruct your more elaborate objects at runtime. For example, Unity can't serialize a Dictionary, but it can serialize two lists which you stitch back together. Handy, still simple, has some limits.
Build in some custom serialization library, and go nuts with it. Popular choices include JsonFx, MiniJson, Protobufs, and C#'s built-in XML serialization. Lots of work, but very powerful.
Like I said, in your case I'd recommend starting with the custom inspector, if you think that'll cover your needs.
Aside from code that's in most common tutorials, you could switch based on that control value, then call functions like EditorGUILayout.FloatField(), EditorGUILayout.ObjectField() and their cousins to get data.
Custom editor scripting is often overlooked, but it's one of the most powerful features available to Unity developers.

Loading Data-Backed ComboBox with Simple Types

I have a RPC method that returns a List of Strings. I want to create a ComboBox with a store that will load the values through a RpcProxy, but I can't find an example that doesn't use some sort of ModelData class.
I would prefer not to have to create a simple Bean with only one property (the string) and then have to convert the List one item at a time.
My ideal would be to create something like this:
RpcProxy<List<String>> proxy = new RpcProxy<List<String>>()...
Any suggestions?
Unfortunately, with GXT 2.2.5, you can't get around not using ModelData.
The class definition for ComboBox says it all:
public class ComboBox<D extends ModelData> extends TriggerField<D> implements SelectionProvider<D> {
...
protected ListStore<D> store;
...
So, at this point your biggest concern is keeping your code clean. If you have to make a specialized ModelData derived class, you could subclass ComboBox and keep a nested class definition for your wrapper object.
If you're not tied to using GXT 2.2.5, I would update to GXT 3.0.x and GWT 2.5.0. GXT 3 moved away from using ModelData. Now, everything accepts bean-like objects.

inheriting a GUI class in LWUIT 1.5

I'm trying to inherit a class that I made in the GUI Resource Editor of Lwuit to extend some functionality. I want to do something like:
public class MyCustomGUIForm extend CustomGUIForm{...}
Where CustomGUIForm its a Form that I create in the Resource Editor. Any idea??
I am going to explain you what I do for extend some functionallity in the Formsthat I create with the Resource Editor.
When you build a NetBeansProject with the Resource Editor, you get a StateMachine class wich allows you to modify/add some aspects of your apps navigation.
In the StateMachine class you can find a lot of methods related to the elements that you create in the Resource Editor.
For example:
You create a Form in the Resource Editor, called CustomGUIForm. After you save the .res, you should find some methods in the StateMachine class called beforeCustomGUIForm postCustomGUIForm and exitGUIForm, with this methods you can use the Form and add some functionality. You can observe that in StateMachine there are other methods for Commands that you build in the Resource Editor, ActionListeners, etc etc. Take a look to the overriden methods for the StateMachine, they could be usefull for you.
Let me know if you have more questions
While jmunoz gave the better answer for this just for completeness you can indeed inherit and override any component created by the resource editor.
In your Statemachine override:
protected Component createComponentInstance(String componentType, Class cls) {
if(cls == Form.class) {
return new MyFormInstance();
}
return null;
}
There is one drawback in this approach, all forms will now be MyFormInstance. This is or usable for some use cases and not so much for others.

Monotouch: Library with a Foundation.Register class

I have an additional Libary project which has a custom button classs:
[MonoTouch.Foundation.Register("ItunesIphoneOpen")]
public class ItunesIphoneOpen: UIButton
When I set the class of a button in UIBuilder to ItunesIphoneOpen the partial code that is generated does not know about this class as it is in another namespace (and project)
Howe can I get the generated code to include a namespace reference to the namespace of ItunesIphoneOpen?
You're going to have to go into the *.designer.cs file and specify the namespace yourself. The standard MonoTouch.UIKit classes get handled automatically but I don't think the tool that generates the designer file will generate the namespace for custom UI classes.

Resources