I am writing this application in Java, where I have a JTree on the left of the JFrame, and the item selected in the JTree determines what appears on the right. This is similar to Edit --> Preferences in Thunderbird, and several other applications' preferences.
Anyhow the main difference is that in my app the stuff on the right is dynamic, and needs to be generated at run time using input from a file.
What I am after is various ways in which this can be accomplished, code snippets or existing frameworks / libraries if they exist.
The input file needs to be something higher level than the sort of XML generated during Serialization. No output capability is required.
Thanks
The JEasy Framework looks to do exactly what you're asking for.
But here's a whole list of similar projects: http://java-source.net/open-source/xml-user-interface-toolkits
There's a short description for each one and a link to their project page. You'll want to look at a handful of the ones that sound good to you, and then try one or two for yourself.
As of now i think one of the most actively used is Swixml. better support compared to JEasy.
have been using it for some while now, and is very easy to learn too
Perhaps it - http://www.soyatec.com/eface/ - XAML/WPF for Java.
Related
I have a problem with translating default context menu items on TextField. There's no documentation about this menu in JavaFX javadocs (at least I couldn't find the one).
I can manually create new context menu on each TextField, rewrite the exising code and just change displayed text, but is there a sense in that? I can't believe that no one thought about this when designing JavaFX components.
So, my question is - is there a way to overwrite these values?
The text displayed in the context menu is stored in properties files that are read into a resource bundle. There is a collection of properties files with somewhat limited support for different languages. You can see these files in the source code repository.
It seems to be quite hard to add support for unsupported languages on the fly: there is a related question here - though I am still hoping someone who understands better than I how to do this may add a better answer to that.
In the meantime you might want to file a request at JIRA for support for additional languages - better still provide a properties file for your language of interest by translating the values in those linked above and submit it.
I will develop a game in java which is about chemistry experiments that include quizzes and lessons . I need to store only two things in my game which is
Score of the quiz
the experiments that the user finished in order to put some sign or change color or whatever to indicate that this one you have already finished it in the experiments menu
Do I need a database ? I read about XML and it used to store simple things . But as I far as I know that XML work with web and my game is offline, how am I going to use it in my case ?
Also , someone told that I can use simple text-based format . But how ?
If you're not planning on making the game online, then you don't 'need' to use a database. You can use an XML (which can be used offline as well as online), or you can use SQLite.
On the text based format thing, it might seem easier to use, but it will cause you trouble on the long run. My suggestion would be to go with XML.
You can learn about XML here as well as how to parse them.
XML should work fine and would probably be my approach to this problem. It's not tied specifically to the web. It's an extensible format for data that has many existing libraries in many different languages including java.
You also have other options like CSV files.
You can use a file-based local database like SQLite but it sounds like overkill for what you've described.
I am trying to build a search engine using java and the lucene API as part of a project. For the last step, we plan to build a web UI (a local host would do) for the same. Are there UI softwares/plugins for eclipse which will allow me to call the functions present in the java classes?
Essentially I would want to have a search box and a search key, pressing which will throw up the search results(which is computed from the java program). javascript cannot call java code I understand. So using that is eliminated?
Any suggestions on what to use will be greatly appreciated. I have pretty poor knowledge in front end design!
Cheers!
AB
If all you have is a simple screen with a entry field and a button and you simply want to return an html table. I would go with a servlet and two jsps. Your servlet can call your search engine and then have the jsp format the data into the table. If you do not know web apis this is probably the easiest entry.
I think, If your using JAVA, that you should look into JSF.
It's a rather easy to maintain and work with library for just the uses you describe.
I recommend these tutorials to get you started: http://www.coreservlets.com/JSF-Tutorial/jsf2/#Tutorial-Intro
There are lots of options to achieve this.
you can create web-ui using jsp.
I have also created same type of project using Lucene, here i have used spring mvc.i have provided all the back-end process as REST api which any web-ui can use.
Please do not look into JSF; it is an overengineered pile for your task.
Sure you can call your java code from javascript, you can make it really simple with something like DWR.
However, for your project I would suggest GWT as then you only deal with Java and it will generate javascript, html and css for you.
For your project you dont really need an "enterprise" level framework like spring or a fullstack JavaEE, you could keep it real oldschool with only JSPs and html/javascript. However thats a bit too flaky for my taste, so go with GWT.
With GWT you basically set it up, define your module, entrance point (look at the hello world), and then you add a layout to your page like something to place the searchbox into and the resultbox to. Then you call your other Java code and classes from there like you normally would.
I would suggest you to use GWT in your application because GWT enables you to call java methods and it will also convert Javascript and css for your Java modules after GWT compile.
GWT reference :- http://code.google.com/webtoolkit/gettingstarted.html
If you're going to use GWT, you could aslo check Vaadin.
Creating a search UI is really simple, and the tutorial show a criteria /result table application taht could be adapted.
Hope somebody could help me, giving a hint and way out.
Right now I'm involved in a ambitious project trying to create mixed math and programming IDE.
After a huge prestudy we decided to use eclipse as a base, and somehow add Mathematica,maple functionality.
Generally speaking we want to make entering math expressions (a = sin(Pi)+10^2) into java code possible. Also those expressions should be showed in LaTex view, right in the code to make it more readable for engineers, to illustrate the code we want to implement insertion images in comments.
As we need all th java editor functionality, in my opinion it's correct to use standart eclipse java editor, and learn it to behave with other objects, e. g. images.
So my questions are:
- Could somebody share experience developing similar products?
- May be there are something like we are going to develop?
Probably I'll write more questions, especially tighter ones.
That is certainly an interesting sounding project. As Gilbert Le Blanc mentions, the Java Editor is highly optimized to edit Java code and is not meant to be extensible.
That being said, I can recommend two options (one that plays by the rules, and one that goes against them).
Instead of embedding your images directly in the Java editor, you could implement your own hover, through the org.eclipse.jdt.ui.JavaEditorTextHovers extension point (so it would work like JavaDoc hovers), or in a separate view that sits beside the editor (so it would work like the JavaDoc view). (This is playing by the rules.)
A while ago, I implemented a prototype editor that allows you to edit Java code with snippets of CAL (a functional JVM language) embedded inside of it. The snippets were stored in there own little window inside the editor. This was a prototype and not everything worked smoothly and it was also using Eclipse 3.2, but this is exactly the kind of thing that you want to do. It won't be easy to compile and run the code, but you can have a look at it....well, maybe. I have to find an EPL variant of the source code. Until then, just realize that hacking the Java Editor like this requires some specialized knowledge about the JDT and you need to be careful about how you do it so that you do inadvertently break other things.
Edit
Here is a zip of the project I described. It will not compile as it is, but you can look at the source code:
Try this link. It should be viewable by the world.
The essential thing to realize is that swt StyledText widgets can themselves contain other widgets. This project leverages that in Java editors.
In particular, look at the class org.openquark.cal.eclipse.embedded.containing.ContainingEditor, which is a sub-class of CompilaitonUnitEditor. This particular class embeds a second text editor (the contained editor) inside of another editor (the containing editor).
Also, take a look at org.openquark.cal.eclipse.embedded.containing.ControlManager. This class manages the different controls inside of a styled text of the containing CompilationUnitEditor.
What this project does is creates a Java-like editor, and allows users to embed editors for another language inside of the Java editor. These editors are actually backed by text in the containing Java editor, but the text is covered by the contained editor.
The contained editors move up and down as text is entered into containing editor. Also, you can use the keyboard to gain/lose focus in a contained editor.
It's been several years since I looked at this code, but if you have any questions, drop me a line or add to this question.
The Eclipse Java Editor is made up of hundreds of Java classes. There's an implicit assumption in those hundreds of Java classes that the editor view is just for code.
In my opinion, you'll find it much easier to develop a Mathematica-type editor for your math images, and leave the Java editor alone. Your engineers can open two editors in Eclipse.
If my comments haven't dissuaded you, here's the Eclipse documentation for Eclipse Helios, otherwise known as Eclipse 3.6
The section you'd start with is called the JDT Plug-in Developer Guide.
The Eclipse web site is responding slowly as I'm typing this. You can also access the Help from inside of Eclipse Helios.
Help -> Help Contents
I know exactly what you can do. First, you can turn-on the unicode character set. This will allow you to have variables such as greeks, which makes the code much more readable. [General->WorkSpace->Text Encoding = UTF-8].
// Apply spring soft constraint using Erin Catto's method with Semi-Implicit Euler :
// Figure out (ω,ζ) from node sizes, then k=mEff.ω², c=2.mEff.ω.ζ
double ω = 2.0*π*f; // ω (angular frequency)
double k = meff * ω*ω; // spring stiffness
double ζ = (b1.ζ + b2.ζ)/2; // Average out the damping coefficients
double d = 2.0 * meff * ω * ζ; // damping coefficient
double γ=h*(d+h*k); // CFM (Constraint Force Mixing)
Second, your suggestion to have a LaTeX formula visible within the code is also the next best thing. I know it's possible because I wrote one 3 years ago, but I can't find the code anywhere. I had posted it on a forum for eclipse plug-ins but it's gone now.
The good news is that I'm writing it again, because I need it - that's how I found your post . This time I'm using jlatexmath which is better than what I used last time.
The idea was/is that you can embed a formula in a comment as LaTeX, and the plug-in renders the LaTeX in a tooltip when you hover on it.
I'll post a link or code here when I'm done. Most of the work is figuring out how to make eclipse accept the new hover control.
J.D.
Ok, as a follow-up to my post above, here is the Eclipse Plug-In Development Environment (PDE) project I developed for this. The Plug-in is named LaTeXHover and will pop-up a tooltip whenever you hover on top of a comment line that contains LaTeX such as:
// $latex i\hbar\frac{\partial}{\partial t}\left|\Psi(t)\right>=H\left|\Psi(t)\right>$
// $latex x=\frac{-b \pm \sqrt{b^2-4ac}}{2a}$
The LaTeX must be delimited using $latex and $ with no extra spaces.
It uses jlatexmath for rendering.
I'll try to package the plug-in better and add that to the Git repo, and maybe contribute it to one of the Eclipse Plug-In projects. As last time, I don't have time now to do this, but at least it's out there now. Anyone wishing to continue the project from here is welcome to do so.
J.D.
git://github.com/jdbertron/latexhover.git
I've recently been charged with creating a Android & iphone app for work. That being said, I'm a css/php designer-developer with a bit of javascript in the mix.
I need to write a bit of Java (not javascript) that will convert a table based layout into a div based layout so that I can then have control over positioning, padding, and what not.
I see many similar post, but these post involve more "designer" oriented goals rather than functional control over positioning, layout and so on.
A good resource would be greatly appreciated as I can't seem to google an appropriate search string. My searches tend to yield more "free javascript code", "Java tutorials about making flashing banners", "How to make fading menus" and countless other rabbit holes that lead to wonderland.
Oh, Currently using eclipse with Android SDK & ADT plugins installed.
It would be much more easier if you have predefinied a set of rules how the conversion should actually be taken place. There is namely fairly a lot which needs to be taken into account. This is really not going to be a bit of Java.
If you're looking for an existing tool, in Adobe Dreamweaver you can do that by Modify > Convert > Tables to AP divs. But still, I question if those kind of tools provides exactly that what you need. As said, there's fairly a lot which needs to be taken into account and it's shooting in the dark without a clear set of rules/requirements.
you may have to write more than a bit of java. you will need parse the html (http://www.benmccann.com/dev-blog/java-html-parsing-library-comparison/) and walk the dom (How to search in a HTML file for some tags?). that's fairly straightforward (assuming that your html is well formed), but i suspect that turning each table element into a div will require a moderate amount of code.
as BalusC pointed out, there may be tools that can get you part of the way, so you might try to do it in two passes.