ContainerSelectionDialog in Java - 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.

Related

How to use the atom text editor with git -java-

I am trying to use atom with git to work on a coding project with some class mates, for this particular project we are supposed to practice making different classes. I just pulled the most recent version of the project from git and I now see that they were successfully able to create new classes/tab-things but have it still within the main file. How do I do something like this in atom? I can't ask them because they use a different ide.
In the picture you can see different classes in drop-downs but its still within "project2" - how do I do this for another class and have it in a new drop down and upload it to git?
image of what i'm looking at
From the screen shot, those dropdowns appear to simply be diffs from the git log. So if you want your changes to appear in a similar fashion, you'll need to create the classes (or additional files) and commit/push them.

How to generate and integrate own constructor in netbeans IDE for java

Most of the IDE gives some templates or insert code options. In netbeans IDE option like "right click in any java source page" then "insert code or (alt+insert)" then we can choose like "constructor","getter setter method" or "tostring method"...etc and if
a user does not fulfill it's requirement. For example my requirement is like generated constructor, it's data member must be final or if i want to add some extra code at the generation time. i was going through following steps below
File -> New Project -> NetBeans Modules -> Module
New -> Other -> Module Development -> Code Generator.
it is available in this link.
Then run the project. It will open a new netbeans window -->new project-->java application --> create a classfile--> right click on page --> it will show new option like sample generator. Then will generate a method.
So my requirement is when i click sample generator, it will generate a constructor according to my specification and requirement.
let me show you what i am getting. some screen shoot.
First:
Second:
A little difficult to follow what you are asking but if I understand you correctly you are asking how to create a custom template file for Netbeans?
There is a tutorial here that describes how to do that. It may be a little out of date though but hopefully close enough to the version of Netbeans you are using.

Same workspace with eclipse

I'm using Eclipse in server and I have two users who can connect on this server. I want to find a solution which allows me to use the same workspace by they two users. I tried it and I got an error message which tells me that you can't use this workspace because it is used by another user and it makes sense. But I want to know if they have a solution which allows me to open the same workspace in the same time by the differents users who use the different authority.
Thank you
you cannot do that as it locks the workspace for one user. others cant edit the same. Try using Version Control like Git or SVN.
You can make developers use the same Eclipse by starting it's launcher with the "-data" argument set to a unique folder. (Let's say the user's name)
You can write a startup-script that copies the contents of a reference workspace, each time a user starts using this shared Eclipse.
But that's the most you can achieve; two instances of Eclipse can not use the same workspace. In server terms: think of it as a Session rather than a Workspace.

Force Eclipse to ignore tests classes for Java search

I've got following structure in Eclipse project
- /src/main/java
- /src/test/java
When I open call hierarchy or using java search, search result contains classes from /src/test/java classes. The same true for type hierarchy and others searches.
There are numbers of unit tests and I don't want to see classes from /src/test/java packages in search result.
The most straightforward way - simply exclude it from build path. Also there are filters for call hierarchy, however I was not able to find them for simple java search. Also filters relies on name pattern, which is not very good though.
I am looking for more convenient way
Right click on your test folder, go to properties and check the "Derived" checkbox. Then click ok.
Or you can create 2 working sets. 1 set for your code and a second one for your tests. Then when you search, you can search only the working set that holds the code.
Open Search dialog (ctrl+h)
Change search scope to Working Set
Click Choose ...
Click New to create a new Working Set with the what you want searched (or Add All and then remove the ones you want filtered

Difference between Java working set and Resource working set in Eclipse

What is the difference between Java working set and Resource working set in Eclipse?
The Resource working set is more general and it can include not only the Java applications / projects, but let me put it this way:
Let's assume a daily life of a Java developer. Do you suggest him/her to use Resource working set over Java working set? Is there any specific situation in which you prefer one over the other?
It sounds like this should have answered the question:
http://www.avajava.com/tutorials/lessons/what-is-a-working-set-and-how-do-i-use-it.html
A Working Set is a subset of your Eclipse projects. You can create
different Working Sets and then select which Working Set to display in
the Navigator view.
Specifically:
"Working set" (in this particular context), is an "Eclipse thing"
The purpose of Eclipse working sets is to help organize your projects
A project consists of "stuff": source code, bitmap graphics files, WSDL's, CSS style sheets - just about anything imagineable.
Consequently, Eclipse projects are organized (glancing at my J2EE perspective, for example) into subsections like "src", "WebContent", "Services" and so on. A project itself can be one of many different types: a "Java project", a "Java Swing Design project", and "Dynamic Web Project" and so on.
Similarly, an Eclipse Working set can be one of several different types: a "Java working set", a "Breakpoint working set ... and a "Resource working set".
As with Eclipse "Views" and Perspectives", you can usually access any project resource you need any time you need it. Selecting one or another perspective simply makes the object (e.g. "Problems pane" or "Build list") easier to get to.
Which kind of "Working Set" you choose - or whether or not you use working sets at all - is largely just a matter of personal preference and convenience.
Please let us know if you still have any further questions.
PS:
Additional links:
https://www.ibm.com/developerworks/library/os-eclipse-visualstudio/
As mentioned, many developers load all their projects into a single
Eclipse workspace. It's convenient, but it can sometimes create too
much clutter. In addition to closing unnecessary projects, you can
define working sets: groups of elements (projects, folders, classes,
etc.). Eclipse can use working sets in different views (such as
Package Explorer) and operations (like searching).
...and:
help.eclipse.org: Working Sets
A working set in the context of eclipse is a logical grouping of related projects to ease search and organize views within the IDE.
A resource working set can capture all types of resources - maybe java source, html, xml, javascript, images - anything that exists within the scope of the projects included into the working set.
The Java working set is a different working set (it is NOT a subset of a resource working set!) which captures only those java files which belong to a source folder and are being compiled into the classpath, or those java files which belong to a module (library) in the build path. Hence, it lets you lookup java "classes" which are in the classpath. Note that all java file in your project may not necessarily be built into the classpath (for example when you exclude a java source file, it does not get built any more). But a java source file which is not included in your classpath can still be detected by a resource working set (you will notice that the icon for an included java source file is a solid J, while for an excluded java source, it is a hollow J).
Example:
Say you have two projects p1 and p2 of which p1 belongs to the working set but p2 does not. So:
MyClass.java (belongs to p1 and included in build path) - Shows up in java type search (Ctrl + T) and also in resource search (Ctrl + R).
MyOtherClass.java (belongs to p2 and included in build path) - Does not show up in java type search nor in resource search.
MyExcludedClass.java (belongs to p1 and excluded from build path) - Does not show up in java type search but shows up in resource search.
MyExcludedClass.class (belongs to a dependency jar in the build path of p1) - Shows up in java type search but does not show up in resource search.
MyWebPage.html (belongs to p1) - Does not show up in java working set but in resource working set.
MyOtherWebPage.html (belongs to p2) - Does not show up in java type search nor in resource search.
MyConfig.xml (belongs to p1) - Does not show up in java type search but shows up in resource search.
So, in the context of a Java developer's use: I use Java working sets to look up types / classes defined in Java, whereas the resources working set to lookup all different types.
One difference between the working sets is that they provide different editing wizards (as stated here: http://help.eclipse.org/helios/index.jsp?topic=%2Forg.eclipse.platform.doc.user%2Fconcepts%2Fcworkset.htm). If you edit a resource working set and a java working set respectively you will see they use different screens for selecting which resources/projects are included.
Apart from this I haven't found any other difference. It also does not seem to differ which resources you can choose in any way. So to answer your question which one would be recommended I would answer "it doesn't matter" since they behave the same way.
A working set is a subset of your workspace and is a way to organise all your projects. With the different types of working sets you have also different types of editing wizards as described here.
Editing wizards
For java projects the Java working set is a more comfortable way to work. Let's assume you have a bunch of java projects in a java working set and you have just opend the editing wizard of the Java Working set:
First of all you can see everything what is in the working set at the moment in the right table. If you now want to include another project you can simply select the project(s) and press CTRL+a. To remove a project you can press CTRL+r
In the Properties of a Resources Working set you don't know what is in the working set until you have scrolled to the bottom of the tree view. This is impossible for people who have 300+ projects in their workspace.
Structure
A benefit from having two types of working sets is structure. There are situations in a daily workflow where it is useful to have different types of working sets, because they have different icons. If you have resources like config files you can create a Resource working set namend 'config files' and put all the files in there.
Afterwards you can open your File Search and search in your config files. This is possible because you can define a working set as a scope for a search.
There are several parts in Eclipse where you can select your working set with the Select working set dialog.
I'll try answering from the perspective as a plugin developer. From the API:
A working set is intended to group elements for presentation to the user or for operations on a set of elements.
This can be any kind of element and does not have to be a project. Working sets are provided by plugins, which can decide what kind of elements can be added and which provide wizards for adding elements as well as operations that can be performed.
It doesn't really matter for a project in which working set(s) it is in. A Java project is still a Java project if it in a resource working set. It only affects some views, dialogs and operations that filter for certain types of working sets.
Besides Java and Resource working sets, there are also Breakpoint, Task, Plugin and C/C++ working sets (depending on your Eclipse setup of course). Some views only show certain types of working sets while other views don't seem to filter them. For example the "Open Type" and "Open Resource" dialogs seem to display all types of working sets. The "Open task" dialog only shows task working sets.
So what is the actual difference between Java and Resource working sets? I haven't seen any functional differences yet. All standard views and dialogs either seem to handle both or none of these two working set types. Most plugins don't seem to care about the distinction at all - but that doesn't mean some plugin could handle both types differently.
On the other hand resource working sets seem to be a catch-all for any type of project, so it makes sense that most plugins don't make a distinction here.
For example if I were to create a plugin that provides an option to analyze Java projects, I would add that operation to the context menu of Java working sets but certainly not to C/C++ working sets. But some people might use resource working sets because they have both Java and C projects in the same working set. So I have to add the Java-specific operation to the context menu of resource working sets too.

Categories

Resources