I want to change the automatic author that appears when I create a file in AndroidStudio.
/**
* Created by a556520 on 16/01/14.
*/
public class POI {
The author takes 'a556520' but I want that appears my name, and not the number of employee. Is that possible?
I didn't find in the settings.
You can overwrite the ${USER} variable in the template file with the
#set( $VARIABLE = "value")
function. Go to Settings -> Editor -> File and Code Templates -> Includes -> File Header prepend the #set() function call, for example:
#set( $USER = "Your name" )
/**
* Created by ${USER} on ${DATE}.
*/
The above answers are correct. But you can go even further and define your own variables - such as User, Company, Email etc.:
#set ($USER = "Name name")
#set ($COMPANY = "company Ltd")
#set ($EMAIL = "example#gmail.com")
/**
* Created by ${USER} on ${DATE}.
* ${COMPANY}
* ${EMAIL}
*/
To edit your File Header template, do the following:
1)Open Android Studio Preferences dialog.
2)In the search box, write "File and Code Templates".
3)Select the left menu item "File and Code Templates".
4)From the middle tabular navigation section, select Includes.
5)Select File Header item that applies to the Java files.
6)You will find an editor section that allow you to edit it for the required pattern. Use the description section below to understand the different parameters that can be used.
/**
* Created by ${USER} on ${DAY},${MONTH_NAME_FULL},${YEAR}
*/
Note: For the name attribute, you can simply write it directly without using attributes. Also you can add your company name or project name in the same way also such as:
/**
* Created by Sami on ${DAY},${MONTH_NAME_FULL},${YEAR}
* ABCDFG company,
* Dubai, UAE.
*/
Press Ctrl+Alt+S then go to File and Code Templates. Here you can set up what you want. E.g. replace ${USER} to your name.
Actually the correct way to change the username is to change the name
of the current user logged in into Windows. (if you're using windows)
Android Studio uses the name saved in %USERNAME% variable.
This is the name you get if you type whoami into a command console
or batch file. And it is the name that is stored under C(orWhatEver):\User.
To change the name you can not just change the name of the profile
you are logged in.
You need to create a new user and give it the correct name.
This way, even if you reinstall AndroidStudio some day, you will end with
the correct ${USER} again.
The easier way surely is to just hard code your name into the template.
But that is just treating the symptoms and you should use the way to fix the root cause.
You can change template for file header by going to Preferences -> Editor -> File and Code Templates. Then change ${USER} in File Header under Includes tab. However this is hardcoding solution it would be better to change actual value of ${USER} variable.
Settings -> Editor -> File and Code Templates -> Includes -> File Header
/**
* #Author: yourname
* #Date: ${DATE}
*/
Open Android Studio Preferences dialog.
In the search box, write "File and Code Templates".
Select the left menu item "File and Code Templates".
From the middle tabular navigation section, select Includes.
Select File Header item that applies to the Java files.
You will find an editor section that allow you to edit it for the required pattern. Use the description section below to understand the different parameters that can be used.
Set the properties first.
#set ($USER = "Your name")
#set ($COMPANY = "Your company")
#set ($EMAIL = "Your email")
/**Created by ${USER} on ${DAY},${MONTH_NAME_FULL},${YEAR} ${COMPANY} ${EMAIL} **/
Related
I am trying to automate text field using selenium, when I try to inspect the object its not showing in dev tools
-text fields-
Industry : CGS-AGRIBUSINESS,
Client NAME : AB VOLVO
text name(Industry) I can see in dev tools but the text value not visible(CGS-AGRIBUSINESS), I want to verify the text ex : AB VOLVO, whether it is present or not
enter image description here
Open your Chrome devtools, and navigate to a tab called Properties. See the screenshot below.
In that tab, see if there is a property called value. I think you will be able to see the text that you want to verify CGS-AGRIBUSINESS in that value.
Now to retrieve the text from the value attribute, just use the getAttribute method to get the attribute value.
Here is a rough syntax
driver.findElement(your_xpath_or_any_locator_here).getAttribute('value')
This has already been explained in this SO question.
In my current project, there is a situation where we have one file let's say "File1.cfg" in project explorer. There is a default editor "Editor 1" registered using "*.editors" extension.
Requirement Function:
When a user double click on the File1.cfg, it should be opened with an "Editor 1" by default and all the time.
There is one more option provided in Toolbar which will be used to open "Editor 2". And this editor should use the resource "File1.cfg" and display the contents as per the UI.
How can this be achieved in the Eclipse?
A plug-in can specify the editor id to be used when opening an editor. See IWorkbenchPage.openEditor and IDE.openEditor.
Normally these APIs check for an editor (of any id) already being open on the file. If you want to force the editor with the given id to open regardless you need to use the IWorkbenchPage method:
IEditorPart openEditor(IEditorInput input, String editorId, boolean activate,
int matchFlags)
with the matchFlags value set to:
IWorkbenchPage.MATCH_ID | IWorkbenchPage.MATCH_INPUT
to only match an existing editor with the same id and input.
Ok, I'm working in android studio, hopefully works the same in java.
Ideally I would love something like this:
//parent addapter is here
friendlyRobotAdapter.setListener(new FriendlyRobotAdapter.DoubleListener() {...}
And if I could press ctr+b on the "here" and then opens the parent file when the listener is set(at another comment created by me).
There is no such feature in Android Studio out of the box, but it's possible to build a plugin to support this kind of navigation. The main difficulty would be keeping track of where exactly to navigate to, given that line numbers in source code change all the time.
Ok, not quite what op(me) wanted, but its the fastest so far.Rather than my old method (adding a comment with the file name and a unique word, then using ctr+f in the target file searching for the 2nd comment with the unique word). We also have Bookmarks:
Navigate/Bookmarks/Show Bookmarks(shift+F11)
Add Bookmark(F11)
Add Bookmark with mnemonic(ctr+f11)
Numeric mnemonics can be opened by ctr+number (ie ctr+3)
Edit Bookmark name (right click on bookmark, edit description)
At least for 10 numeric mnemonics we can do this:
//press ctr+3 for parent addapter
friendlyRobotAdapter.setListener(new FriendlyRobotAdapter.DoubleListener() {...}
Try adding a javadoc description inside your code and with the #see tag or {#link } tag add your class, then you can ctr+b on the name to get to the class. This works in android studio, you can either try to copy everything manually, or right click method or class and "copy reference" (but this method looks a bit shabby because although sometimes it just pastes the method without the file, ie #getLayout() or ViewHolder, even in other files)
int getItemViewTypeSwitch(int position) {
if (isActive()){
/**
* works on classes
* #see android.support.v7.widget.CardView
* {#link android.support.v7.widget.CardView}
*
* on methods
* {#link me2.iwanttoeat.FR_RecycleViewSettings#getLayout()}
* #see me2.iwanttoeat.FR_RecycleViewSettings#getLayout()
*
* on subclasses
* #see FR_Adapter.ViewHolder
* {#link FR_Adapter.ViewHolder}
*/
return position;
}
return -1;
}
How to add "create on" comment in eclipse every time in create a new class file? I know the alt+shift+j option creates comments for adding name to the eclipse class file.
Window -> Preferences -> Java -> Code Style -> Code Templates
Expand Comments -> Types
Edit the template for comments created for new types. Use the ${date} token.
I have a invoice for which I want to show in preview mode with a watermark. I have integrated the report with my web application (Spring MVC).
Any solution?
EDIT: I want to pick a value from a dataset (Table: invoiceheader), and use that value to decide whether to show /not show the watermark. I am unable to pick that value from Birt script. Can you please please guide..
Sorry .. the customer asked for a different way of identifying the fact rather that from passing the parameter.
Thanks
You need to declare a report parameter in the .rptdesign of the invoice. For example we name it "useWatermark", and we set the datatype to boolean and a default value to true.
Select the report root in the outline view of the designer -> script tab -> beforeFactory
if (!params["useWatermark"].value){
reportContext.getDesignHandle().findMasterPage("Simple MasterPage").setProperty("backgroundImage", "");
}
This script removes the watermark if the parameter is set to false. By default, the master page is named "Simple Masterpage" but if you have renamed it or if there are multiple masterPages defined in the report you should adjust the script consequently.
EDIT: if we need to extract the information from a dataset, then we can't make use of the masterPage, we have to use a grid instead.
Create a grid with one cell, and drop all the content of your page into it
Set your watermark as background-image of the grid
Create a report variable "useWatermark" in the "Outline/variables" branch (see picture below), set default value to true/false as you like
Select dataset invoiceHeader -> script tab -> onFetch, and affect the variable from a boolean dataset column, or from any expression returning true/false:
vars["useWatermark"]=row["myBooleanDatasetColumn"];
This dataset must be used somewhere in the report body, otherwise it won't be triggered and the variable won't be initialized
Select the grid -> script tab -> onRender
if (!vars["useWatermark"]){
this.getStyle().backgroundImage="";
}