Bug 15510 - Enable Print in project explorer if an active editor can print and is selected
Summary: Enable Print in project explorer if an active editor can print and is selected
Status: CLOSED DUPLICATE of bug 6134
Alias: None
Product: Platform
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 2.0   Edit
Hardware: PC Windows NT
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Platform-UI-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2002-05-08 06:57 EDT by Dani Megert CLA
Modified: 2010-03-15 05:33 EDT (History)
3 users (show)

See Also:


Attachments
Preliminary work on a patch (4.41 KB, patch)
2010-03-08 18:25 EST, Francis Upton IV CLA
no flags Details | Diff
The ProjectExplorer portion (6.51 KB, patch)
2010-03-11 13:35 EST, Francis Upton IV CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Dani Megert CLA 2002-05-08 06:57:38 EDT
Build 20020502

I would expect Print to work on the selection of the Navigator or Packages view
since Print is in the File menu. However the menu is only available if an editor
is active.
Comment 1 Nick Edgar CLA 2002-05-08 11:43:15 EDT
Print is a global retargetable action which the views would have to handle.
Defer to v3.
Comment 2 Randy Giffen CLA 2002-08-12 09:39:43 EDT
Reopen for investigation
Comment 3 Tod Creasey CLA 2006-06-22 08:30:40 EDT
Is this still an issue in 3.2?
Comment 4 Dani Megert CLA 2006-06-22 08:46:24 EDT
Is there someting in comment 0 that you do not understand and that doesn't let you reproduce the problem?
Comment 5 Tod Creasey CLA 2006-06-22 10:23:34 EDT
reopening
Comment 6 Tod Creasey CLA 2006-06-22 10:24:13 EDT
Actually I was going through a lot of bug quickly - moving to Paul to investigate
Comment 7 Paul Webster CLA 2006-09-29 15:14:36 EDT
Print is a retargetable action, and is only enabled if the part provides a print action.

ex, AbstractTextEditor provides a print action.

This doesn't look like a problem to me.

PW
Comment 8 Dani Megert CLA 2006-10-09 05:27:28 EDT
>This doesn't look like a problem to me.
The point is that the Navigator (and also the Package Explorer) should retarget the command in order to make print work off a structured selection.
Comment 9 Paul Webster CLA 2007-06-20 11:38:06 EDT
In our case the Project explorer should be providing the action handler if possible.

PW
Comment 10 Dani Megert CLA 2009-01-30 01:32:57 EST
This is not an enhancement.
Comment 11 Francis Upton IV CLA 2010-03-08 18:25:26 EST
Created attachment 161383 [details]
Preliminary work on a patch

Paul,

I can see that the selection changed listener is getting invoked, and telling the handler service to activate the handler, but the File -> Print menu item (in the main menu bar) does not enable.  Can you help me with this?

I know this bug is probably not that important, but I mainly want to learn about the actions/commands and have the experience, one time in my life, of fixing a 5 digit bug number.
Comment 12 Paul Webster CLA 2010-03-09 08:46:45 EST
(In reply to comment #11)
> Created an attachment (id=161383) [details]
> Preliminary work on a patch
> 
> Paul,
> 
> I can see that the selection changed listener is getting invoked, and telling
> the handler service to activate the handler, but the File -> Print menu item
> (in the main menu bar) does not enable.  Can you help me with this?


Sure, comments:

1) you have to entries in your plugin.xml that don't do anything

2) ActionFactory.PRINT is a retarget action.  It was used in the WorkbenchActionBuilder to add Print to the main menu/toolbar, but it doesn't do anything by itself.  You can't use it as your print handler.

3) For example, text does it with the code in org.eclipse.ui.texteditor.AbstractDecoratedTextEditor.createPrintAction()

PW
Comment 13 Francis Upton IV CLA 2010-03-11 13:35:39 EST
Created attachment 161790 [details]
The ProjectExplorer portion

This gets the action enabled properly depending on the selection. It has been tested to enable and run the action.

However it needs to be finished correctly to identify which editor can print and have the editor print, which is something beyond the scope of the ProjectExplorer.

Feel free to change the contents of PrintAction.updateSelection() and .run to hook up to the appropriate mechanisms.
Comment 14 Francis Upton IV CLA 2010-03-11 13:37:20 EST
Not sure if this is Platform Text or editor management, trying text first.
Comment 15 Markus Keller CLA 2010-03-12 06:27:16 EST
I find this confusing. Why should the enablement of the print action depend on whether the selected file is opened in an editor anywhere?

I see 4 possible implementations for a Print action in Navigator-like views:
1) Print the view (similar to request in bug 108320)
2) Print the selected files (bug 6134)
3) Print the frontmost editor, i.e. Print action targets the same editor as the Save action. Not that this should work from all views that don't define their own print action.
4) Do not enable print for now

I would prefer (4).

Dani, please have a look (and note that the original summary has been changed).
Comment 16 Dani Megert CLA 2010-03-15 05:33:14 EDT

*** This bug has been marked as a duplicate of bug 6134 ***