Is there a way how to search a file or class (I mean by Ctrl + Shift + T or R) only in some particular project and not in all workspace?I have Eclipse Indigo.
On Menu of Ctrl + Shift + T or R dialogue Small down arrow on extreme right use option Select Working Set then set the working set and you are done now you can only search files from selected working set.
Ctrl + Shift + T Or R
>Menu
>Select Working Set
>New
>Java
>Add Or Add All
>Click on Selected Working set in Select Working set Dialog
>Select Working set and you are done.
Select the project in project explorer -> Ctrl + H -> File Search Tab -> enter file name in containing text -> Check Selected Resources under Scope.
One more trick -> if you want to search only from *.java files then in File name patterns text box in the same File Search Tab enter *.java or *.props. This will filter out for you
Click on file search
select enclosing projects under the subcategory 'scope'.
this will enable you to search inside a specific project
For that you have the Search menu. You could use Search > File or Search > Java for that. In the search dialog, you can restrict the search scope as only the selected project, or as a predefined working set, as long as some additional options.
Related
I clone the java code from gitlab firstly.
Then I open one of the java classes with a editor without modifying any code.
I find the relative indent of every method body disappear in any java class.
I tried to open the class with more than one editor, including intellij idea, sts, notpad++.
But When I use notpad which is installed in win10 natively. It goes as expected.
This is the result opened by intellij idea, sts, notpad++:
enter image description here
public ElasticSearchRepository(Class<E> entityClass) {
this.entityClass = entityClass;
}
This is the result opened by notpad in win10:
public ElasticSearchRepository(Class<E> entityClass) {
this.entityClass = entityClass;
}
This is a difference in the indent settings of the default number of spaces in a TAB character.
A. Intellij
In IntelliJ you can do this
File > Settings > Editor > Code Style > Java > Tabs and Indents > Use tab character
B. VSCode
Go to Code > Preferences > Settings if you’re using macOS (shortcut: Command + ,).
Go to File > Preferences > Settings if you’re using Windows (hotkey: Ctrl + ,).
Type Indentation into the search field then head to the Editor: Tab Size section. Replace the default space number with your preferred one:
C. Atom
In Atom, open preferences or CMD + ,
Click on Editor on the left pane.
Scroll down to Tab Length and input what you prefer.
D. Notepad++
To change the default action of the tab key:
Click on the Settings menu
Select Preferences
Go to the Language Menu/Tab on the left Settings pane.
Make sure [Default] is selected in the rightmost list.
At The bottom right, there's a checkbox labelled Replace by space. You can check this to use spaces or set the nomber of spaces for your tab character above this option.
E. Komodo Edit
Open up Preferences. On mac it's simply Command + , and on PC, hopefully control + p.
Click on the arrow beside Editor to bring down the further categories for it.
Select Indentation.
Simply enter the desired number of spaces for indents in the appropriate window and hit OK at the bottom.
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.
I want to add a quick shortcut like (sout + Tab = System.out.println() ) in eclipse how I can do this?
There is already a shortcut for System.out.println().
just type sysout then press ctrl + space.
If you want to make a template for other code, for example System.out.print(), Go to Preferences > Java > Editor > Templates and create a new template. To use the newly created template, type the name of the template + ctrl + space.
Window>Preferences>Java>Editor>Templates>New
edit name and pattern
try it
I am trying to send "String" as argument in sendKeys method [type WebElement] but system is using it as char sequence, so I am not getting proper output.
public static void setGridDropDownValue(Selenium selenium, WebDriver webDriver, String strGridId, int nRowIndex, int nCellIndex, String strValue)
{
String strXPath = "//div[#id='"+strGridId+"']//table/tbody/tr[2]/td/div/div/table/tbody/tr["+(nRowIndex+2)+"]/td["+(nCellIndex+1)+"]/";
selenium.click(strXPath);
selenium.doubleClick(strXPath);
strXPath = "//select";
Select selStatus = new Select(webDriver.findElement(By.xpath(strXPath)));
List<WebElement> we = selStatus.getOptions();
for(int i = 0; i< we.size();i++)
{
WebElement wei = we.get(i);
System.out.println("Options : "+wei.getText().toString());
if(wei.getText().toString().equals(strValue))
{
wei.sendKeys(strValue);
break;
}
}
}
For example : My dropdown have 4 options(Partial,Done,Verified,Delete). If selected value is "Partial" and I am sending key "Done" then it is working fine, but if selected value is "Verified" and I am sending "Done" then system is selecting "Delete". I am not getting its working procedure but I think system is comparing characters. If selected value is "Verified" and I am sending "Partial" then system is selecting "Partial"(working proper).
F.Y.I. : My dropdown is invisible until user double click on that element.
Please let me know if there is any way to send "String" with sendKeys method. TIA
Follow the steps below if you are using eclipse:
Right click on your java project and select Build Path -> Click on Configure Build Path...
In project properties window: Click/select Java Compiler at the left panel
At the right panel: change the Compiler compliance level from 1.4 to 1.7 or higher
Lastly Click on Apply and OK
Set the JRE System Library again. If you use eclipse follow the steps below:
Go to project properties
Select Java Build Path at the left panel -> Select Libraries tab at the right
Click/select JRE System Library[] -> Click Edit button at the right side
Set your preferred JRE and click Finish button
Lastly click OK button from the project properties pop up window
Instead of editing you can also do by deleting and adding. The steps are:
Right-click on project » Properties » Java Build Path
Select Libraries tab
Find the JRE System Library and remove it
Click Add Library... button at right side » Add the JRE System Library
(Workspace default JRE)
You can use Select class
Select select = (Select) driver.findElement(By.xpath(strXPath));
select.selectByVisibleText(strValue);
If you are using eclipse, follow below steps:-
1.Right click your project-> Build Path->Configure Build Path
2.Select Java Compiler-> Change level to 1.7
3.Click Apply-> OK`
I think this should work. No compilation error.
The console window in eclipse disappeared.
How can I open it? Its not possible to print System.out.println().
Check in this menu
Windows > Show View > Console (Alt + Shift + Q, C)
Use shortcut:
Alt + Shift + Q, C
The Console is one of many views you can configure in Eclipse. To add a new view go to Window > Show View.