Assigning a perspective for each project on Eclipse - eclipse

I'm using SVN (Subversive) for some projects and git (EGit) for others, so I've configured two different perspectives for each type of project. I'd like to know if there's a way to associate a perspective for each project, so that when I open them the perspective is changed automatically.
Is there a way, native or via a plugin, to accomplish this?

I believe, it is very hard, if not impossible to do this. At project creation sometimes a perspective change is triggered (e.g. the creation of a plug-in project opens the PDE view). Otherwise, no general perspective opening method is used.
If you write your own plug-in, it could provide the required switch: either by listening to the opening of the project, or by adding a different Open project command, it is possible to write code that changes the current perspective. On the other hand, I don't know any of those plug-ins available.

Related

Sharing an Eclipse Perspective

I have created an Eclipse Python perspective to suit what I need, and have deleted most of the menus and toolbar icons. I want to keep it this way. However, the goal of this perspective is to be used by others, so I want to share it as it is exactly.
I've tried multiple methods, File>Export>General>Preferences, using the Yatta Profiles tool, and others, none of it worked (Yatta Profiles works fine, using in my own computer, but on another computer, all the default menus are back).
Does anyone have a solution for this, where one can share an Eclipse perspective EXACTLY as it is?
The solution to this is to create an Eclipse plug-in providing that Perspective (via https://help.eclipse.org/2020-12/topic/org.eclipse.platform.doc.isv/reference/extension-points/org_eclipse_ui_perspectives.html?cp=2_1_1_196), or convince the developers of the Python plug-in you're using to provide it for you.

Eclipse Workspaces: What for and why?

I have seen, read and thought of different ways of using Workspaces (per project, per application (multi-asseted or not), per program language, per target (web-development, plugins,..), and so on) and I am still doubting what the best approach is.
Can anyone give a detailed, but not a page long insight into this?
This involves a lot of sub-questions, so to speak, and I don't know all the specific sub-questions I should ask, as I am sure I don't know all aspects of Eclipse (and Workspaces), but I'll try to give an example of what I am looking for:
What for?
What did the Eclipse development team expect it to be used for?
What do other/most people think?
What do you think?
... ?
Why?
Are there configuration conflicts vs. sharing merits?
Any filespace reasons?
Performance?
... ?
I am speaking of the minimum use-case for a developer that uses different languages and protocols, not necessarily all of them in one project (E.g. Php, Javascript and XML for some projects, C# for others, Java and SQL for still others, etc..)
Edit 2012-11-27: Don't get me wrong. I don't doubt the use of
Workspaces, I just want to use it as it is meant to be or otherwise if
anyone would think it better. So "what for?" means: What's the best use? And
"why?" actually targets on the "what for?", in other words: tell me the reasons
for your answer.
I'll provide you with my vision of somebody who feels very uncomfortable in the Java world, which I assume is also your case.
What it is
A workspace is a concept of grouping together:
a set of (somehow) related projects
some configuration pertaining to all these projects
some settings for Eclipse itself
This happens by creating a directory and putting inside it (you don't have to do it, it's done for you) files that manage to tell Eclipse these information. All you have to do explicitly is to select the folder where these files will be placed. And this folder doesn't need to be the same where you put your source code - preferentially it won't be.
Exploring each item above:
a set of (somehow) related projects
Eclipse seems to always be opened in association with a particular workspace, i.e., if you are in a workspace A and decide to switch to workspace B (File > Switch Workspaces), Eclipse will close itself and reopen. All projects that were associated with workspace A (and were appearing in the Project Explorer) won't appear anymore and projects associated with workspace B will now appear. So it seems that a project, to be open in Eclipse, MUST be associated to a workspace.
Notice that this doesn't mean that the project source code must be inside the workspace. The workspace will, somehow, have a relation to the physical path of your projects in your disk (anybody knows how? I've looked inside the workspace searching for some file pointing to the projects paths, without success).
This way, a project can be inside more than 1 workspace at a time. So it seems good to keep your workspace and your source code separated.
some configuration pertaining to all these projects
I heard that something, like the Java compiler version (like 1.7, e.g - I don't know if 'version' is the word here), is a workspace-level configuration. If you have several projects inside your workspace, and compile them inside of Eclipse, all of them will be compiled with the same Java compiler.
some settings for Eclipse itself
Some things like your key bindings are stored at a workspace-level, also. So, if you define that ctrl+tab will switch tabs in a smart way (not stacking them), this will only be bound to your current workspace. If you want to use the same key binding in another workspace (and I think you want!), it seems that you have to export/import them between workspaces (if that's true, this IDE was built over some really strange premises). Here is a link on this.
It also seems that workspaces are not necessarily compatible between different Eclipse versions. This article suggests that you name your workspaces containing the name of the Eclipse version.
And, more important, once you pick a folder to be your workspace, don't touch any file inside there or you are in for some trouble.
How I think is a good way to use it
(actually, as I'm writing this, I don't know how to use this in a good way, that's why I was looking for an answer – that I'm trying to assemble here)
Create a folder for your projects:
/projects
Create a folder for each project and group the projects' sub-projects inside of it:
/projects/proj1/subproj1_1
/projects/proj1/subproj1_2
/projects/proj2/subproj2_1
Create a separate folder for your workspaces:
/eclipse-workspaces
Create workspaces for your projects:
/eclipse-workspaces/proj1
/eclipse-workspaces/proj2
The whole point of a workspace is to group a set of related projects together that usually make up an application. The workspace framework comes down to the eclipse.core.resources plugin and it naturally by design makes sense.
Projects have natures, builders are attached to specific projects and as you change resources in one project you can see in real time compile or other issues in projects that are in the same workspace. So the strategy I suggest is have different workspaces for different projects you work on but without a workspace in eclipse there would be no concept of a collection of projects and configurations and after all it's an IDE tool.
If that does not make sense ask how Net Beans or Visual Studio addresses this? It's the same theme. Maven is a good example, checking out a group of related maven projects into a workspace lets you develop and see errors in real time. If not a workspace what else would you suggest? An RCP application can be a different beast depending on what its used for but in the true IDE sense I don't know what would be a better solution than a workspace or context of projects. Just my thoughts. - Duncan
Basically the scope of workspace(s) is divided in two points.
First point (and primary) is the eclipse it self and is related with the settings and metadata configurations (plugin ctr). Each time you create a project, eclipse collects all the configurations and stores them on that workspace and if somehow in the same workspace a conflicting project is present you might loose some functionality or even stability of eclipse it self.
And second (secondary) the point of development strategy one can adopt.
Once the primary scope is met (and mastered) and there's need for further adjustments regarding project relations (as libraries, perspectives ctr) then initiate separate workspace(s) could be appropriate based on development habits or possible language/frameworks "behaviors".
DLTK for examples is a beast that should be contained in a separate cage.
Lots of complains at forums for it stopped working (properly or not at all) and suggested solution was to clean the settings of the equivalent plugin from the current workspace.
Personally, I found myself lean more to language distinction when it comes to separate workspaces which is relevant to known issues that comes with the current state of the plugins are used. Preferably I keep them in the minimum numbers as this is leads to less frustration when the projects are become... plenty and version control is not the only version you keep your projects.
Finally, loading speed and performance is an issue that might come up if lots of (unnecessary) plugins are loaded due to presents of irrelevant projects.
Bottom line; there is no one solution to every one, no master blue print that solves the issue. It's something that grows with experience,
Less is more though!
Although I've used Eclipse for years, this "answer" is only conjecture (which I'm going to try tonight). If it gets down-voted out of existence, then obviously I'm wrong.
Oracle relies on CMake to generate a Visual Studio "Solution" for their MySQL Connector C source code. Within the Solution are "Projects" that can be compiled individually or collectively (by the Solution). Each Project has its own makefile, compiling its portion of the Solution with settings that are different than the other Projects.
Similarly, I'm hoping an Eclipse Workspace can hold my related makefile Projects (Eclipse), with a master Project whose dependencies compile the various unique-makefile Projects as pre-requesites to building its "Solution". (My folder structure would be as #Rafael describes).
So I'm hoping a good way to use Workspaces is to emulate Visual Studio's ability to combine dissimilar Projects into a Solution.
It's just a feature for structuring projects.
Obviously Eclipse designers tried to avoid having global settings for Eclipse and decided to put them into workspace.
Each Eclipse app depends on each workspace settings.
Is it a good decision? I think it's not so.
It lacks flexibility. It was naive to expect that global settings can be avoided.
It doesn't allow you to have single projects (it can be a surprise for Eclipse designers but it happens quite often).
But it still works.
Many people use it. Sometimes they suffer but more frequently everything is ok.

Associate a particular type of projects with a specific perspective

I want to associate all Java projects with only the Java perspective. However, at this time, the java projects also show up in the Ruby perspective under the Ruby explorer. I want only ruby projects to show up in the ruby perspective. How do I do that?
You don't, there's zero relationship between the two apart from anything the new project wizard might do for you. Check the Ruby Explorer's local menu for a way to filter the projects you don't want to see in there.

Easy way to add a context action to Eclipse

I'm trying to add a very simple action to the context menu of Eclipse: clicking with right button over a folder object, this action should call an external tool (configured in the "External Tools") using the path of the folder as the only parameter.
I've found a tutorial on how to add a context menu, but it's more complex than what I need -- I don't really want to create a plugin, I don't even want to create classes to do what I want. My only purpose is to call an external tool.
How can I do it?
If you want to extend Eclipse with functionality such as editing context menu's, the only way to go is by writing a plug-in. However, this can be very light-weight and targeted to your needs, so the tutorial you found might be a good way to do it.
Check out StartExplorer. It's very handy. It's the equivalent of the IntelliJ "Neighborhood" plugin.
It comes with the basics of explore, command shell, open, and copy path for Windows, Mac and Linux. It also supports custom commands. And can be installed through a normal Eclipse repository.

Eclipse alternative to VS .sln files

I've recently had to switch from Visual Studio to Eclipse CDT.
It would seem that Eclipse "workspaces" are not quite like VS solution files.
Eclipse workspaces use the .metadata folder for managing multiple projects, but there doesn't seem to be a simple distinction between user settings or IDE preferences and project/solution settings.
What I want is a way to group a collection of related (and dependent) projects together and have that data live in source control without all the other user specific stuff that developers don't need to share.
You know, like a .sln file in Visual Studio.
Does Eclipse just not work this way? (And if not, then why not?)
Yes you are right eclipse does not manage projects in the same way VS does with solution files. However for putting a group of related projects into a VCS eclipse has the concept of a Team Project Set available in File->Export then under the Team folder there is Team Project Set.
Like JProgrammer said there is Team Project Set. You can send your colleagues a bunch of .psf files, works similar to VS.NET. I can only say we have good expierience with this feature.
I often find IDE's have a preferred way to work. Sure, you might be able to get the IDE to do it your way, but you'll probably end up fighting it all the way.
Try to use your IDE like their makers intended you to. They have made presumptions on how you are supposed to do your work. They have optimized the user experience according to those presumptions.
Go with the flow. Anything else will make you gnarly, bitter, wrinkly and give you gastly breath!
Corollary: If you can, choose the IDE that makes the same presumptions about workflow as you do!