Bug 219848 - Copy file path-action should be able to copy the project path too
Copy file path-action should be able to copy the project path too
Status: RESOLVED FIXED
Product: utilities
Classification: Unclassified
Component: Code
7.3
PC Windows 7
: P3 (vote)
: 7.3
Assigned To: Jaroslav Havlin
issues@utilities
: NETFIX
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2012-10-10 16:20 UTC by markiewb
Modified: 2012-10-13 02:10 UTC (History)
0 users

See Also:
Issue Type: ENHANCEMENT
:


Attachments
Patch for supporting project paths too (9.78 KB, patch)
2012-10-10 16:20 UTC, markiewb
Details | Diff
Patch for supporting project paths too (9.19 KB, patch)
2012-10-11 14:02 UTC, Jaroslav Havlin
Details | Diff
Screenshot (48.77 KB, image/png)
2012-10-12 12:13 UTC, Jaroslav Havlin
Details

Note You need to log in before you can comment on or make changes to this bug.
Description markiewb 2012-10-10 16:20:40 UTC
Created attachment 125712 [details]
Patch for supporting project paths too

The newly introduced "Copy file path"-action (http://netbeans.org/bugzilla/show_bug.cgi?id=153728) should be able to copy the project path too.

Usecase: select a project node, copy its path then paste it for use in command line
Comment 1 markiewb 2012-10-10 16:24:16 UTC
I want to contribute a patch which implements the requested feature. It works for me and it is meant as a drop-in-replacement (the previous functionality still works).

See attachment http://netbeans.org/bugzilla/attachment.cgi?id=125712

Changes:
* add dependency to Project API
* converted action to an AlwaysEnabledAction (so it can be used for Project and DataObject)
* the currently selected dataobjects/projects were identified by asking the lookup of the current topcomponent
* updated the test and added test for project


@NetBeans-Dev: Please review, test and commit.
Comment 2 Jaroslav Havlin 2012-10-11 14:02:08 UTC
Created attachment 125780 [details]
Patch for supporting project paths too

Thank you very much for the patch!

I've noticed a small bug. If I wanted to copy path of a file in a tab that was not focused, path of file in focused tab was copied instead.

I've modified the patch slightly. Constructor now accepts all Lookup.Provider objects (both DataObject and Project classes implements this interface) and type of passed objects is checked when the action is performed (not very nice, but I haven't found any better solution so far).

Please, check the updated patch and let me know whether you find it OK.
Thanks again.
Comment 3 markiewb 2012-10-11 14:25:49 UTC
(In reply to comment #2)
> Created attachment 125780 [details]
> Patch for supporting project paths too
> 
> Thank you very much for the patch!
> 
> I've noticed a small bug. If I wanted to copy path of a file in a tab that was
> not focused, path of file in focused tab was copied instead.
> 
> I've modified the patch slightly. Constructor now accepts all Lookup.Provider
> objects (both DataObject and Project classes implements this interface) and
> type of passed objects is checked when the action is performed (not very nice,
> but I haven't found any better solution so far).
> 
> Please, check the updated patch and let me know whether you find it OK.
> Thanks again.

Patch looks good at the first glance, but i haven't tried it yet.

> I've noticed a small bug. If I wanted to copy path of a file in a tab that was
> not focused, path of file in focused tab was copied instead.
IMHO it is not a bug. The action only accepts DataNodes/Projects which are in the current lookup. When the tab is not focused, then its DataNode is not in the lookup and its path cannot be copied. Working as expected, isn't it?
Comment 4 Jaroslav Havlin 2012-10-11 14:35:18 UTC
(In reply to comment #3)
> IMHO it is not a bug. The action only accepts DataNodes/Projects which are in
> the current lookup. When the tab is not focused, then its DataNode is not in
> the lookup and its path cannot be copied. Working as expected, isn't it?
I mean copying file path using context menu of an editor tab.
If you have two or more tabs, and you right-click a tab that is not active (selected), a pop-up menu is shown, but the tab is not activated. Then, if you select "Copy File Path" from the menu, incorrect path is copied to clipboard.
Comment 5 markiewb 2012-10-12 11:42:23 UTC
(In reply to comment #4)
> I mean copying file path using context menu of an editor tab.
> If you have two or more tabs, and you right-click a tab that is not active
> (selected), a pop-up menu is shown, but the tab is not activated. Then, if you
> select "Copy File Path" from the menu, incorrect path is copied to clipboard.

Curious i cannot reproduce this faulty behaviour in my dev build.

Product Version: NetBeans IDE Dev (Build 201210070002)
Java: 1.6.0_30; Java HotSpot(TM) 64-Bit Server VM 20.5-b03
System: Windows 7 version 6.1 running on amd64; Cp1252; de_DE (nb)
Comment 6 Jaroslav Havlin 2012-10-12 12:13:53 UTC
Created attachment 125857 [details]
Screenshot

> > I mean copying file path using context menu of an editor tab.
> > If you have two or more tabs, and you right-click a tab that is not active
> > (selected), a pop-up menu is shown, but the tab is not activated. Then, if you
> > select "Copy File Path" from the menu, incorrect path is copied to clipboard.
> 
> Curious i cannot reproduce this faulty behaviour in my dev build.
I can reproduce it with very similar PC configuration.
See attached screenshot. After right-clicking on inactive tab for DbMain.java and invoking "Copy File Path" from the context menu, path of the file in active tab (MercurialTest.java) is copied to clipboard.

This was the only reason for modifying the patch, otherwise it works perfectly. Can you please try to reproduce it with the original path again.
Maybe the problem is somewhere else and your original patch can be used.
Thank you very much.
Comment 7 markiewb 2012-10-12 12:43:35 UTC
(In reply to comment #6)
> Created attachment 125857 [details]
> Screenshot
> 
> > > I mean copying file path using context menu of an editor tab.
> > > If you have two or more tabs, and you right-click a tab that is not active
> > > (selected), a pop-up menu is shown, but the tab is not activated. Then, if you
> > > select "Copy File Path" from the menu, incorrect path is copied to clipboard.
> > 
> > Curious i cannot reproduce this faulty behaviour in my dev build.
> I can reproduce it with very similar PC configuration.
> See attached screenshot. After right-clicking on inactive tab for DbMain.java
> and invoking "Copy File Path" from the context menu, path of the file in active
> tab (MercurialTest.java) is copied to clipboard.
> 
> This was the only reason for modifying the patch, otherwise it works perfectly.
> Can you please try to reproduce it with the original path again.
> Maybe the problem is somewhere else and your original patch can be used.
> Thank you very much.

Trying your scenario:
Your patch works. It cannot be reproduced. Build 20121010-cb1493056264
My original patch does not work. The error can be reproduced. Build 20121010-cb1493056264
Comment 8 Jaroslav Havlin 2012-10-12 13:11:39 UTC
Integrated as http://hg.netbeans.org/core-main/rev/eaac8d40a713

Thanks a lot for providing the patch and for your help!
Comment 9 Quality Engineering 2012-10-13 02:10:39 UTC
Integrated into 'main-golden', will be available in build *201210130002* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main-golden/rev/eaac8d40a713
User: Jaroslav Havlin <jhavlin@netbeans.org>
Log: #219848: Copy file path-action should be able to copy the project path too


By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2012, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo