Swing and Android Apps with shared code base and resources - java

In my company we would like to develop a swing and a android application. Both should basically have the same functions. So we thought to create a normal java project with the core code, a java project for XML communication with the endpoint (both apps use the same endpoint) and a java project for shared resources like bundles, images and so on.
Now the drawback: After having a first look at android we noticed that android handles resources very much different from any other system. Everything has to be in XML files and logos/images have to be in different folders with different resolutions. From my understanding this would mean to discard the idea of a shared resource project and to maintain the resources two times: one time for swing in the form of bundles and the like and another time for android.
Our architecture is layer based: the business logic layer defines functions that are the core functionalities of the app. The presentation layer should grab the functions and build the layout dynamically based on the role of the logged in user. Here too, I'm not sure how to archive this with android.
Questions:
Is it possible to have the applications use the same resources?
Do someone know another way how to handle this? (I'm a noob with android)
All comments, ideas and alternatives are welcome!

You can have string resources in xml for android, so it will parse them by itself, so all you need in your desktop app is to write parser to grab this resources and use them. I believe it's better then duplicating. In case if you have too much resources you can put them in few xml files, that will be the same: android will grab them automatically but you will just change file name.

Related

Addapt bootstrap theme for web application

So I was trying to make web app. And because I'm not very good with frontend I decided to buy bootstrap theme. When I inspected it, I realised it's just static theme. I can't use it for my web app with Java backend and REST end points. It's like I just bought good wireframes. I need REST functions implemented. Now first thing that came to my mind is to learn Angular and create those pages by myself, but that is time consuming. What is the fastest way to make those pages usable.
I will try to be the clearest I can be.
The theme you purchaised is just plain html with css (Bootstrap)
What you have to do now is:
define a new frontend project with AngularJS, maybe using some Yeoman generator
add Bootstrap as Bower dependency
define all your AngularJS views (or templates, or partials)
copy the theme html fragments into your views
customized it using an additional css file (i.e. custom.css) that overrides the theme original ones
use all the theme components to design your specific UI.
Also keep in mind that purchaising an html/css theme does not mean to buy a frontend skeleton application. It's just a way to accelerate the UX/UI design and development of a complete new frontend application from scratch and you must have some kind of web design/web development basic skills in order to use it properly.
Hope this could help you

Store Data to file in CodeNameOne AND a Swing GUI java application

I've started using CodeNeme One to develop an app that displays a curriculum of data made up of modules, categories and topics in a hierarchical data structure (Modules contain categories which contain Topics). My goal is to make this a general purpose framework within which the Data determines the app behaviour and content so organizations can customize the app by using a desktop GUI to edit data.
So I took a break from my mobile App Development to add a Swing GUI to generate the data model instead of hard-coded test data.
I used Java.io.ObjectInputStream/OutputStream to write my data structure conveniently to file and read it. Then tried to use the file input and output code in my codenameOne project and got errors like in this StackOverflow question: In Codename One, why can I not get FileInputStream to import or compile? .
So, CodenameOne recommends use of their own APIs to read and write to storage. Is there a way I read and write the data files that my compiled CodenameOne App will be able to read, but in the Swing GUI Desktop application? How should I implement file (or hopefully object I/O) in the desktop GUI Swing app and then be able to package that data file with the app to compile it?
We usually use a common format when interacting between JavaSE/EE and Codename One. So we use XML or JSON parsers/generators for which are available on both platforms and they allow us to be "future proof" for any type of technology.
We also have the ability to work with objects with our own custom externalization code, the webservice wizard generates Java SE/EE compatible versions of these classes and you can use those within your Swing project.
FYI Codename One also supports desktop and JavaScript builds. We also have quite a lot of Swing applications and we are slowly migrating them to Codename One since Swing doesn't get updated anymore.

MessageResouce files in JSF

My application suppose to work with different languages. In order to provide this feature, I have created different messageResource files for each language.
Each resource files contain the same keys but values are different according to which language application is running. I load the specific language resource file on application load up.
This is working very fine.
However, as we are adding more features, the resource files for each language becoming very long, which makes it difficult to manage (edit) for non-techy person like Content editor guy.
Therefore, I would like to know, how can I redesign or remodularise in such a way that it will be easy to manage for Content Writers?
I hope I clear the scenario but please shout, if any thing needs?
I do not know a i18n standard mechanism in the Java world to split message properties in chunks. However, I have made good experiences with a standalone properties-edit-tool like jLokalize. It's pretty user-friendly even for non-programmers: hand over the properties files to the content writer and let him/her load the files in the editor.

Command line utility to run code in a web app

I just got a requirement to create a small (I assume standalone) utility to hit some code in our web application to do some custom processing of files from the app and then dump the files into a shared drive. My question is what is the best way for doing this? Do I just create a small app and then jar it up and run it off a command line or is there a better way?
Sorry, I didn't give enough detail. It's an old application, like over 10 years, so while it's been upgraded to jdk 1.6, most of the code uses the old collections, old loops, etc... There aren't any interfaces, very tightly coupled code that uses inheritance with lots of nested objects. The web app will do the processing. I think what they want is create some code outside of the application code that will login and then fire off the file processing code. Prior to this I had upgraded their version of Windward Reports in a separate branch and they want to make sure that the processed files: contracts, forms, etc.. don't get altered greatly as there are legal requirements on fonts and layouts. So this utility will go in, fire off the list of reports (a few thousand) dump it to a share drive so they can view them with another tool for comparision based on rules you can automate with that commercial tool, en masse. I was thinking create a small class with a main method, then jar it up and while the web server is running with my upgraded branch code, run the utility off the command line to fire it off.
There's not enough to go on here. How is the web app's functions exposed? If it's a REST interface then wget/curl/spring-rest-template are the way to go. If it's something like a JFS app then you're going to need something like Selenium to imitate a browser. If the functionality is in a shared library (JAR) then there web never even comes into play.
Well, I was originally looking at creating a standalone utility jar that I would run off the command line to connect with URLConnection to the app, but I found there is already testing code built into the application that I can run from a command line as long as I deploy the new code with the existing code. The utility will dump out the files to a shared drive and then XTest can be run to compare files. After reviewing the capabilities of XTest, it appears that it can handle the comparison of files well.

Dynamic GUI Framework Designing

There is a Scenario to be developed for a 3-tier Application .We need to design a Framework or a utility sort of thing .
In tradional aspect of GUI Designing , either we tend to create a static gui page and code the elements on it along with other properties of the elements such as (disabled/enabled,image source,name ,id ,which function to be called under onclick event.) or we tend to drag and drop the elements from the control pallete provided by variety of gui frameworks.
Certain things i need to design a POC so that we can develop this concept.
There must a utility ,such that during creation of screen layout , that screen should be saved in the database(RDBMS) with a screen number.
All the Events related to that control should be saved in some other table which will be dynamically mapped during the calling of screen number by the user.
When the user call that screen ,a generic function should be invoked which'll call the screen file from the database and apply all the properties ,events,etc at runtime and the final output will be displayed to the user.
This POC will help the us to customised the screens according to our usage.also all the code will seperated which can easily be used for some other development process.
Thanks
Amit Kalra
-- Migrated from Answer --
Iam not getting it with GUI framework supporting serialization .
The Concept should be like this .
The Developer has a utility like a Screen Painter in which developer can drag drop controls ,now this file will get saved in 2 formats ,first one is a source file and another on is the compiled one (say compiled in a .cpp format or any other format).
now on a client side ,when the user enters any transaction number ,there should be a utility which can load the file from the database ,also apply all the functions applicable to each event .
This Concept is similar to wat is there in SAP R/3.
please help me in undergoing this POC.
Thanks
If I understand your question, you are asking for a GUI framework supporting serialization. There are several ones supporting this. Two I have been using are the FOX Toolkit (C++, cross-platform) and the Windows Presentation Foundation (.NET), which is using the XAML format for serialization.
You can achieve the purpose by using the Serialization support of many popular languages. Even if there is no support for that it shouldn't not be very difficult, storing essential data in some configuration files (or as such in your case storing in a DB) will do the expected like controls details, their position etc. But standard frameworks will make your life easy in long running.

Categories