Java Swing front-end to Etherpad - java

I am looking to implement Etherpad's functionality into a Java Swing application. There is a Java library for accessing Etherpad's HTTP API, but it only seems to support getting/setting the entire pad text. I want to have live multi-user editing of plain text in Java, where all users see each other's changes realtime while editing. Can anybody point me in the right direction?

Just use: http://docs.oracle.com/javafx/2/swing/SimpleSwingBrowser.java.htm and point it at the Etherpad Pad URL you want to edit...
If I'm honest though, your question is not very clear in what you want to accomplish.

I found a Java library for easily accessing Etherpad's API. I combined this with the JavaFX web browser component and a custom Swing UI.
For anyone finding this on Google or something, you can see my code on GitHub as a standalone app here: https://github.com/Netsyms/SyMATPadViewer
Feel free to use it (BSD license), just change the PADS_URL in the PadUtils class and put your Etherpad API key in the file padkey at the root of the src directory.

Related

making a browser without using JTextPane or any other class that reads HTML

Good evening, I'm working on a project with a team, we have to make a browser without using JEditorPane or any other class that reads HTML.
How can we do that? Do we need to make a new class that does what JEditorPane does? Can I find somewhere JEditorPane's code? Thanks!
Well, this is an answer:
If you need to display web content without using any pre-existing engine (such JEditorPanel or a ChromeBind), you need to read the HTML as a XML file and construct your native View based on it (without CSS and JS this is a fairly easy task) by constructing the screen based on a one-to-one equivalent of a HTML tag to a Java JComponent.
Modern Web Browsers are pretty complicated, so there are a lot of different pieces that come together to display a web page. In order to build a browser, you need to first understand what a browser is. For that, I recommend reading this tutorial.
Once you have an understanding of how a browser actually works you need to determine which pieces you can reuse and which pieces you have to write from scratch. Do you have to write the entire rendering engine? Good luck! Can you use an existing engine like Gecko or Webkit? Or maybe you can get a little closer to done and use the java port of Webkit?
Once you have a better understanding of the question come back and ask more direct questions when you get stuck at a specific piece. As it is, your first step is to gain an understanding of the problem you are trying to solve.

Accessing HTML elements from java

I need to access HTML elements from my Java program based on the id or className of the element (like getElementByID or getElementsByClassName). I also need to be able to click a few buttons on the page.
Main Points:
I am creating a desktop application. It is not a web app.
I need a browserless solution
My code needs to auto fill a form and submit it without opening a page.
Are there any libraries out there that could suit my needs, or could I achieve this in plain Java code? If my question isn't clear please let me know and I will try to explain it in a better way. Thank you.
Selenium is a library used for scraping html elements using java. It is often used for testing. There is another library called Vaadin. It is used for doing front-end work on the back-end using java. It is similar to Java Swing but used on the web. Hope this helps!

How to open and edit a file(doc,pdf,excel etc) in browser window using zk?

I have a application which is created on ZK Framework , i want to give user a functionality where user can open a saved file in edit mode and then again saved the changed in database can any one know which API can help me to do this?
You could use Google Apps to do so and set Google Docs to edit your DOC, PDF or even XLS extension files. For more help on setting it up, feel free to ask again. :)
The problem you're posing doesn't have a simple answer, unfortunately.
There are two general approaches you could take..
The low hanging fruit is to provide an interface for the user to download a file and upload it after they make edits using whichever editing software they choose / is appropriate.
The other approach would be to provide a GUI to edit files. Regardless of the web framework you are using, this is a daunting task to say the least. As #userRandom mentioned, this is a large part of what Google Drive (formerly Google Docs) is attempting to solve.. but even Google's solution is not perfect and very much a work in progress.
I would strongly suggest evaluating the scope of your project before proceeding.
If you choose to move forward, consider a simple solution that works for .txt files. Then, consider how you might handle .doc files. Then, PDF files, XLS files, etc.
Folks here will be able to answer specific questions.

Web UI for existing Java application

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.

When JEditorPane will not do. JRex, JRex wherefore are thou JRex?

IDEA: Implement a recent web browser into a java application (for saved offline, non server content).
The question is this: can I have a java application implement a webbrowser with jquery / html / css support within a java program?
So I am asking anyone who has played with JRex for advice: I want to know how complicated will it be to integrate an open source webbrowser into java. I am not all that keen on the idea of compiling Mozilla from source build. Is there a ready made compiled version?
Is there a simplified method to have latest compiled version (most current in terms of support for HTML css & javascript), and integrate that into an application?
Also: I appreciate the amount of work required to support for HTML4 nevermind 5, and CSS2 compliance. How close is JRex to that?
Application: My intention with the webbrowser is to render a webpage from offline content. It will not need to be online content, and will simply be for file based displays = e.g. file:///C:...
Does the webbrowser have to be wrapped into a server to function, e.g. to pass files to the browser to render is how complicated? I am not keen to have to implement Jetty or another server type application just for this.
If JRex is not the solution... what then? Is it possible to start a browser implementation within Java and can Java interact with the information and traverse the Dom?
Or alternatively is there .hta equivalent in recent browsers like firefox?
If you need to have the embedded browser interact with your application code, you could try the SWT Browser control, it's actually maintained as opposed to JRex. Browser uses either WebKit or Gecko or embedded IE as appropriate, or lets you choose which one you want, so it should run jQuery and familiar Javascript. And since SWT is a JNI library to begin with they probably already have guidance on how to deploy an app that uses JNI.
You can feed HTML into the control from a string (example) or a java Url - which can point to local files or resource files in your JAR, which I assume will let you split your app into different files.
To call Java code, you need to expose it as Javascript functions. example
To manipulate the HTML from Java code, you need to call Javascript functions from Java. example
To make the previous two tasks easier, you might want to look into a JSON library to simplify passing around complex data.
Does it have to be implemented within a Java program? Could you let the user use the default browser on their machine (ie does it matter what browser)?
If not would use the Java Desktop API.
if (desktop.isSupported(Desktop.Action.BROWSE)) {
txtBrowserURI.setEnabled(true);
btnLaunchBrowser.setEnabled(true);
}
If you are using Java 1.5 try http://javadesktop.org/articles/jdic/

Categories

Resources