Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Eclipse: Show different Files in each Perspective?

Tags:

eclipse

I'm using Eclipse to work with several types of files such as Python, Javascript and PHP. When working on Python files I use the PyDev perspective and likewise for PHP I switch to the PHP perspective etc.

I find it uncomfortable that when switching from one perspective to another I still see all types of files open in the main work area.

I would prefer that when I switch to Python all non-Python files will be hidden away and only .py files will be shown. When switching to Javascript, I'd like to have any hidden (open) .js files visible and my open .py files hidden. Is this an existing feature in Eclipse or is this just something I'm expecting to see? :) How might one go about implementing this functionality?

like image 388
urig Avatar asked May 12 '11 07:05

urig


People also ask

How do I change project perspective in Eclipse?

You may switch perspectives by choosing Window, Open Perspective from the main menu, as shown below. Close the Welcome window and you will see the Eclipse user interface. The current perspective is displayed on the title bar.

How do I open two tabs in Eclipse?

To open multiple Eclipse windows using the same workspace, select Window→ New Window.


2 Answers

If you are interested in implementing the feature yourself, you can use the new API we introduced in 3.5. https://bugs.eclipse.org/bugs/show_bug.cgi?id=11001

Edit:

For example, here's a handler that hides the active editor, storing the reference in the plugin activator until it can be shown:

public class HideEditorHandler extends AbstractHandler {

    @Override
    public Object execute(ExecutionEvent event) throws ExecutionException {
        IEditorPart activeEditor = HandlerUtil.getActiveEditorChecked(event);
        IWorkbenchPage page = activeEditor.getSite().getPage();
        IEditorReference reference = (IEditorReference) page
                .getReference(activeEditor);
        Activator.getDefault().getEditorManager().add(reference);
        page.hideEditor(reference);
        return null;
    }

}
like image 153
rcjsuen Avatar answered Nov 16 '22 07:11

rcjsuen


The only way you might combine different perspective with different set of file is by taking advantage of mylyn contexts.

A context can show you only the resources (and the editors) associated to a current task.
If, when you are switching of perspective, you also indicate a mylyn task, then you would restore your environment to what that task was referring to.

like image 35
VonC Avatar answered Nov 16 '22 06:11

VonC