Extracting all string literals from a java project - java

There is a big Java project that contains lots of Java and JavaScript classes. We need to translate the app into a foreign language.
What we need to do is:
Right click on a class
Click on Extract Strings button
Display all strings in the file with a check-list structure in a pop-up window
Select the strings we want to save
The unselected ones will be assigned as not-string-literal in order to prevent it from appearing in the list when I try next time.
Click on Ok and the strings are stored in a messages.properties file
We are using Netbeans IDE and a plugin would be wonderful if there is any. Can you advise me on how to do this?

Related

get two input files from CompareEditorInput

My requirement is to use a new external compare tool for certain type of file extensions in eclipse RCP product.
For other files eclipse default compare editor should be used.
In order to achieve this , I am using ASPECTJ to hook to eclipse default compare editor method . In my aspect method I am validating the file which is selected, If the file is a particular type I am trying to call my external compare tool or else continue with using eclipse default editor.
I am not able to get two files( that is left and right input file) from the compareEditorInput Object which is a parameter.
Is there any way to get two input files so that i can pass to my external compare tool??
The compare editor itself does not require that the input comes from files, nor does the base CompareEditorInput class.
Subclasses of CompareEditorInput such as ResourceCompareInput do work from files so you may be able to get the input from them. But these are internal classes and not part of the API.

How to focus on a folder from java program

I am trying to open a folder from java program by using the following java code
Desktop.getDesktop().open(new File("d:\\abc"));
I can successfully opened d:\\abc, now this abc folder is having two sub folders images, and songs now my reuirement is to focus this folder then open it by depending on user given input at run time.
May be tomorrow these sub file names will be changed, but depending on user input i want to focus on corresponding sub folders and open them.
I tried lot of ways in google and stackoverflow also. But I didn't get proper way.
Use a JFileChooser to display the local file system and get the user's selection. Alternatively, add a suitable list or tree selection listener to one of the display components cited here.
You can use Robot class, by using this Robot class you can press key on keyboard programatically.
If user input is
images
then user Robot class to press corresponding key programatically.
Here you can get tutorial on Robot class
http://docs.oracle.com/javase/7/docs/api/java/awt/Robot.html

can we create izpack input panels at runtime, depending on an input file specified by the user?

this is a standalone utility. on launching the utility, it asks the user to input the location of an input.xml file. what i am trying to figure out is if there is a way to - read the input.xml file during runtime and using the data specified within that xml file, build the next user input panel.
the data specified within input.xml will include number and type of input fields, radio buttons with options' values, password field or text field etc.
in case it's possible the actual solution would include multiple such input.xml files to generate corresponding input panels at runtime.
any suggestions on its feasibility?? (the constraint is using izpack as the base/utility)
EDIT: nope, doesnt seem possible. in order to build the dynamic UserInputPanel at runtime, a fresh compile required at runtime which would be like another installer running in parallel. havent been able to find any easier option.

ContainerSelectionDialog in Java

I develop my first plugin - 2 questions:
I'm using ContainerSelectionDialog dialog in my eclipse plugin to give my user the option to choose project.
but it show me the project and the folder in them, I want to show the user only the project with out option to expend the project and choose folder,
how can I do it?
when user select my wizard (new->other->myWizard) i want to know which project in the packageexplorer it select ( like you have in new class that it know which project is selectd)
Thanks!!
You can use a org.eclipse.ui.dialogs.ElementListSelectionDialog and call setElements() on it. The data you pass to setElements() should be an array of IProject instances; one way to obtain that is via org.eclipse.core.resources.ResourcesPlugin.getWorkspace().getRoot().getProjects()
Note A: IWorkspaceRoot.getProjects() will return all projects, including closed ones, so depending on your needs you may want to filter that list before passing it to the dialog (look at IProject.isAccessible())
Note B: You can use org.eclipse.ui.model.WorkbenchLabelProvider.getDecoratingWorkbenchLabelProvider() for the dialog's labelProvider.

remove component from initComponent()

i am using netBeans editor to create desktop application , i did something wrong that generate
three line of code in the initComponent() method related to connection with database. Then i removed the lines by opening the .java file in txt editor , but one of them keep coming back when i do anything with netBeans editor , So i want to delete this line from the netbeans itself . this is the line
historyList = java.beans.Beans.isDesignTime() ? java.util.Collections.emptyList() : ((javax.persistence.Query)null).getResultList();
and this is its declaration
private java.util.List<idetect.History> historyList;
Use the Inspector to find the query component and delete it
Window->Navigating->Inspector menu in Netbeans IDE 7.0.1
I think the simplest way to edit the automatically generated code is to do the following;
If you go to the Design panel of your class in Netbeans (where you can see the constructed GUI) then all of the elements you have added will be in the Navigator Pane, which is usually located in the bottom left.
If you can't see the Navigator pane then ctrl+7 brings it up.
Find the element you wish to remove in the list, right click and click Refactor > Safely Delete.
Personally if I need to write a GUI in Netbeans I use it to generate the boring stuff, and then paste the generated code into a different editor to write my actions.
The java source is regenerated automatically from the matching .form file. You need to delete the component either from the GUI editor itself or from the form file(which is not visible in NetBeans).
When you've opened a GUI form in NetBeans its components are visible in a tree in the Inspector tab in the lower left part of your screen. You can select the component you want to delete there, right click and select "Delete".
Easiest Solution: Open the .java-file in your project-directory containing your "initComponent"-Method with another text-editing Program (e.g. notepad++) and delete the lines you want to remove. It worked out for me.

Categories

Resources