Outsource the generated Swing code - eclipse

Is there any way to outsource the generated Java source code from the actual class (the frame or panel class) into an XML file (for example)?
I do not like this messy Swing code in my GUI objects; it makes my class huge and unreadable.
I know that the GUI Builder which is implemented into the IntelliJ IDEA can do that (see http://www.jetbrains.com/idea/features/gui_builder.html).

GUI Builder (from Google, formerly Instantiations) always generate Java code. That is actually the primary idea of the designer :-)
There are many things you can do using Java as the implementation language that cannot be done with XML or other static specification languages.
EDIT: You can also look at XWT - XML Windowing Toolkit - though I don't whether it works under Eclipse 3 or "just" Eclipse 4...

Related

Include AspectJ support to VS Code

In my current project I'm working with Java, Spring Boot and .aj files. However, the main problem about work with AspectJ is that there are not a lot of IDEs that supports this feature.
Eclipse (and i think that netbeans too) supports the AspectJ language because I've used it in the past. However, I've worked with IntelliJ and Visual Studio Code IDEs during the last years and I don't really want to come back to Eclipse (or Netbeans). :)
Also, I know that the Ultimate Version of IntelliJ has support to AspectJ. The problem is that you must have an IntelliJ license to use it.
https://www.jetbrains.com/help/idea/enabling-aspectj-support-plugins.html
I started to create a new language server for the Visual Studio Code to manage the .aj files. I'm following this guide.
https://code.visualstudio.com/docs/extensions/example-language-server
The .aj files are now correct colored and shows a valid syntax!
However, I'm getting errors in the Java code. Check this schema about the AspectJ description:
As you could see, I have a .java file called Point and I want to have some methods divided in some .aj files. When the project is compiled, I'll have just one Point.class that includes the methods clone(), compareTo(), etc.
Also, another possible use is that if my .java class implements some interface, I'm able to implements the methods in a .aj file.
Problem: I'm not able to see my Java project without errors because the .java files and the .aj files are not "synchronized", so the .java class says that needs to implements some methods although they're defined in the .aj file.
Someone could help me with tips about language server development?
Regards,
I can't help you with VS Code <> AspectJ integration, but I could recommend a work-around with your issue. If my understanding is correct, you get errors because the methods declared through inter-type declarations by your aspects are not visible to your java code.
In that case you might try to create Java 8 interfaces with default methods that declare and implement those methods. I would try to get rid of the aspects altogether and work with just interfaces with default methods, but if - for some reason unknown to me - you really need to use aspects to implement those methods, you can still leave your default methods empty and move the implementation into the aspects. This way you don't need to use inter-type declarations anymore, so VS Code integration might work better.

Call a Scala Embeded Method in External Java Action

I'm developing a program mixed with java and scala.
Eclipse : Eclipse Modeling Tool 2.4
Sirius : for model representation
Scala IDE
My situation is that I use External Java Action Interface in Sirius to extend modeling representation. Let say the class is A_Extend which is implement External Java Action Interface. A_Extend calls a JFace Class, B_GUI. The B_GUI calls Scala Function, C_Scala.
By the way, in the development mode ( it includes automatically generated model source code and A_Extend, and B_GUI and C_Scala codes), When I executed B_GUI as Java Application, it can call C_Scala (I set Scala nature). However, when I execute B_GUI using A_Extend in instance of Workbench (I clicked "run as Eclipse Application"), C_Scala is not called.
I thought it is because there is no Scala compiler in runtime Workbench, so I tried to include the Scala nature both on an instance model and odesign file. However, it does not work.
Are there any one who can help me?
Thank you so much in advance and have a wonderful day.
Best Regards,
Grace

Need brief understanding on how eclipse autocomplete works

Hi I am interested in understanding how eclipse autocomplete works. I want to understand how eclipse distinguishes between local and global variables in a piece of Java code. I would also like to understand how eclipse stores method signatures for an infinite number of classes and how it associates a method to a given class. And is it possible for one person to develop an autocomplete feature for a language like JavaScript.
There is already an AutoComplete feature for Javascript. You just need to let Eclipse install the appropriate extensions.
Eclipse maintains a model of your program, including the project and all the dependencies. It's big, but it's not infinite. When you hit the dot, it figures out based on the variable type what the target type can be, and then displays the relevant methods based on its internal model.
This is easy for Java because you can usually know the static type. Much harder in other languages.
The Eclipse plug-in developer's guide discusses how different things, including the internal model and auto completion works. There are extension points to implement yiur own.

GWT Designer produced code

I'm trying to understand GWT and its associated Designer plugin better. Using one of the more recent versions of GWT Designer and GWT 2.* in your application, can you give me a sense for
1) how much additional (UI) code you needed to develop by hand (outside GWT Designer), perhaps as a rough percentage? Was this code generally doing the model interface and controller part of MVC?
2) how well were you able to go between "design and code view" -- i.e. keep using GWT Designer for your GUI layout after you supplemented with hand-written code?
1) It does a lot like it generates html code, and ui:fields and binds the ui:field with a variable in java class. You have to write to your handlers. It does the model interface and controller done by hands.
2) To me it took a lot of time to switch views, to me the designer's performance was poor and I try to finish nt work inside the designer before switching to code view.

Editor library used in Eclipse source

I am looking to create an editor and I was wondering if there was a Swing library which Eclipse uses for its main editor. It may be something quite basic, but I am looking for the drop down menus which come when you press full stop. Strings become symbols rather than just text.
Eclipse is rather SWT-based than Swing-based.
As for a custom editor, you could look into an eclipse-GMF-EMF-based editor with XText
Xtext is a framework for development of textual domain specific languages (DSLs).
Just describe your very own DSL using Xtext's simple EBNF grammar language and the generator will create a parser, an AST-meta model (implemented in EMF) as well as a full-featured Eclipse text editor from that.
alt text http://www.eclipse.org/Xtext/images/screenshot-title.png
The Framework integrates with technology from Eclipse Modeling such as EMF, GMF, M2T and parts of EMFT.
Development with Xtext is optimized for short turn-arounds, so that adding new features to an existing DSL is a matter of minutes. Still sophisticated programming languages can be implemented.
Actually I think you want to consider developing an Eclipse RCP application which involves using SWT, JFace and other parts of the Eclipse platform. There are many layers of editor support which are in the Platform Text component, this is what the Eclipse JDT editors are based on. The modelling stuff (GMF, EMF, etc) is probably much more than what you want. The AbstractTextEditor class in org.eclipse.ui.texteditor is a good place to start. RCP gets you a lot of other stuff as far as helping you to manage the objects you are editing, but you don't necessarily need to use this.
There are likely Eclipse corner (on eclipse.org) articles on how to do this, but the specific one escapes me now. I always just look at the code.