-
Notifications
You must be signed in to change notification settings - Fork 874
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
NETBEANS-59 - Document split actions #3
NETBEANS-59 - Document split actions #3
Conversation
Did this need a second PR? Could it not have been done in the first one? |
Maybe not, but I reverted everything, cloned the repo new, pulled from the original master, created a new branch, copied over the files manually and change the line endings. |
Of course, it's much easier to read since there are no more newline changes. What this patch seems to do is add an @ActionReference so we can have shortcuts for those 3 actions. So, as a fix I would have preferred 2 commits:
I seems the existing static inner classes might have been sufficient: you could have just made them public. You could have introduced SplitDocumentHorizontallyAction which just extends SplitDocumentAction and calls super(tc, JSplitPane.HORIZONTAL_SPLIT). Same for SplitDocumentVerticallyAction. I believe initTopComponent only exists so you can have a no-arg constructor which is odd because you are instantiating the actions manually (so it must have to do with the registrations). Also, you know that So, what I am curious to learn is how does the shortcut work for your manually created instance? |
Can one of the admins verify this patch? |
Smth missing here for the merge? |
@Chris2011 I don't see any new commits based on my comment from Sep 23rd. |
Most of the code, was only moved out to separated the code and created actions, I only created one base class by my self. You only mean that I should split it up to 2 commits? The last sentence I don't understand in your comment:
|
I wrote a rather long message in September. Does nothing I said there make sense? It hard to review a patch that has +320 line and −101 lines in a single commit. From what I remember and what I deduced while trying to figure it out, you just added an Reviewing would be much simpler if refactoring would be a separate commit.
I was just curious how the solution even works considering the action is created manually and not by the Platform. How does the shortcut plumbing work? Because, maybe you don't even need an |
This is what I didn't get yet, I didn't get your point of this. Thx it is clearer. Yes, I added 3 ActionReferences for 3 new actions "Split Action Horizontally", "Split Action Vertically" and "Clear Split" because those actions didn't exist. Now you can change the hotkeys for each of them, which was not possible before. I only set such ActionReferences to have Actions, where I can add shortcuts to it. It is from the official Documentation I think, how we can create actions. I don't know an other way. Only the layer.xml but this is obsoleted I think(?) |
But if you instantiate the action manually with |
The shortcut is set here: 67bdd60#r150193869 The functionality is still there, if you right click on an editor tab -> Split -> Vertically. So I decoupled the functionality from 5dc272e#diff-c2b5538f4bdcf56983c605aebf73887a and created new classes for each action to set the ActionReference. Now you can use the functionality like before via Right click on editor tab -> Split -> Vertically OR you can use the shortcut, which I set to Ctrl + Alt + Shift + V or you can set your own. |
c18f031
to
efd6864
Compare
Please see my latest commits, I splitted my one commit into two as requested. Thx. |
Can someone have a look now, please? :) |
Hello @Chris2011, I believe what @emilianbold meant by having two commits is that the first commit would implement the requested feature while keeping the One subtle issue is that moving message strings LBL_ClearSplitAction, LBL_ValueClearSplit, LBL_SplitDocumentActionHorizontal, LBL_ValueSplitHorizontal, LBL_SplitDocumentActionVertical, LBL_ValueSplitVertical to a different package (from |
public void actionPerformed(ActionEvent evt) { | ||
final TopComponent tc = WindowManager.getDefault().getRegistry().getActivated(); | ||
|
||
if (tc != null && ((Splitable) tc).getSplitOrientation() != -1) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe better check not for tc != null
but tc instanceof Splitable
, which covers bot non-null AND the required interface presence. Maybe even the check for getSplitOrientation
could move into clearSplit
* @author Christian Lenz (Chrizzly) | ||
*/ | ||
@ActionID( | ||
category = "Tools", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider category "Windows" or "Windows / Layout" rather than Tools.
|
||
if (tc != null) { | ||
super.setTopComponent(tc); | ||
super.setOrientation(JSplitPane.HORIZONTAL_SPLIT); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could be the orientation set from the constructor (it is constant).
@ActionRegistration( | ||
displayName = "#LBL_ValueSplitHorizontal" | ||
) | ||
@ActionReference(path = "Shortcuts", name = "DOS-H") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also consider creating @ActionReference
for placement in Menu/Windows
. Note that the registered singletons (unlike instance created in window popup menus) do not update their enable flag according to the current TC.
@dtrebbien thx for the explanation, the refactoring was needed to added the ActionIds, I tried it before I refactored the code, because that wasn't my intention. So I changed the code a bit and got it working, while I created new actions in external classes. Maybe I made a mistake and it would work right inside as nested classes but now I think it is a bit cleaner. |
@sdedic thx for reviewing, I will have a look later. |
BTW, regarding my remark:
I believe there may be 2 instances of the same action. One added manually with I would appreciate somebody confirming this or not, etc. because it was not obvious to me. |
efd6864
to
2c82540
Compare
@sdedic markiewb and me had a coding session yesterday. Big thx to him. He helped me a lot with other stuff and with this PR. So in general we fixed everything what was requested (Refactoring, simplifications, etc.). Hope this is now enough to merge the request. We tested all actions. View -> Split; Window -> Configure Window -> Split Document; Right Click on an editor tab -> Split; And my shortcuts. @emilianbold Yes those are 2 instances. One for the menu actions and one for my shortcuts via the ActionReference. But both of us, don't see any problem with this. We added some comments too to describe the constructors a bit better. Cheers Chris |
Great. So @Chris2011, from your and markiewb point of view, everything is now done and there's nothing at all that should block this one from being accepted? |
@geertjanw right. We don't see any other problems with that stuff. Maybe an other can test it before, if someone wants it. But from our pov, everything should be fine. |
@matthiasblaesing Thanks a lot for your help!
👍 BTW, diff of this PR is here: https://github.com/apache/incubator-netbeans/pull/3.diff
|
Chris is a committer, so he can commit himself. @Chris2011 if you need help, feel free to contact me. |
Sure. Anyway, I wanted to avoid merging it as it is :) |
Will try that. Thx. |
7ea6b9a
to
68f02a5
Compare
So now, everyhing should be fine now. I renamed the old branch, made a clean one, updated all branches that is needed, applied the patch, changed the line endings from CRLF to Unix LF. 3 files are new, which are the 3 actions (ClearSplit, SplitDocumentVerticallyAction and SplitDocumentHorizontallyAction). The SplitAction.java file only removes some Bundle messages. Atm, I don't know why is the SplitAction completely red and green again but finally, it shouldn't matter now. Everything was discussed earlier. Please merge now. |
Please recheck SplitAction - it now has windows line endings (\r\n), which is also the reason, that it looks so red. |
Hm, I closed the file and reopened it, now it is CRLF, will fix it. |
It doesn't make sense to change it now to LF and amend the commit, right? Do I have to do it again? I mean applying the patch and fix the line endings? |
If you change line endings, do an amend commit and then force push that should do it. |
68f02a5
to
cb388db
Compare
Got it. |
You now lost the commit message :-) - When you amend you need to keep in mind, that you replace the previous commit. |
Hm, ok. I thoght they will merged together. The Message too. But this should Not be a Problem now. Now I know it and will make it better next time :). |
Why wait? An amend commit is possible without any file changes, so you can still fix the commit message. Same procedure s before: Start the amend commit, check/update the message, finish the commit, force push.
Am 15. September 2018 23:26:34 MESZ schrieb Chrizzly <notifications@github.com>:
…Hm, ok. I thoght they will merged together. The Message too. But this
should Not be a Problem now. Now I know it and will make it better next
time :).
|
…ts. And Changed line endings.
cb388db
to
5f9dff2
Compare
Done. |
Looks better, though I would not choose this message. I would have worded it:
It is a summary what was the desired outcome of this commit, which helps to understand the code changes. If an explanation is required why it was implemented the way it was or context should be provided, the further lines of the message can be used. The context is not always required, but helps to put the understand changes years later. You can change the message or merge to master as is. |
I can understand your point but first, my commit message is exact that, what the commit means. Maybe it is only a wording for sure and I know that, because I do it every day as all of you, But to be clear, the commit message should be as short as possible to explain what the commit makes. Here we only have one commit, but often we have more. Second, everything else, what is not kind of related to the commit, is written in this ticket: https://issues.apache.org/jira/browse/NETBEANS-59. There is the exact explanation why it was implemented or why I want it or what I want. So If you need further information, look into the ticket. Thx to all of us with my first apache netbeans PR for the info, help, hints and everything. Next time, I will be more careful. But please don't be that strict to everyone. I think a lot of people can lose motivation. IMHO. Will merge it now. |
I often use the "Show annotations" functions when working with code bases. Often the commit message holds the information that is necessary to understand why something was done the way it was. I see good commit messages in the same league as good comments: I'm not interested in comments, that just repeat what is obvious, but that give the code some meaning/context (explain the why). In the same sense good commit message give context (summary of the change) and explain why the change was done. I have yet to see an instance where I took the time to wander through several issue reports, even if they are referenced. Switching to the issue tracker takes time and often issue texts don't help or the real explanation is buried in one of the uncounted number of comments. Consider the current situation: Oracle could shutdown the bugzilla instance of netbeans right now. If the commit messages are meaningfull and explain the main reasoning, history could be reconstructed from my mercurial clone (or the git conversion of that). The commit history in a DVCS is by definition a good place to give context information. Don't take this wrong: I appreciate your work and also the stamina to see this through. I will keep being strict about these things. I have seen code bases, where commits looked like shit and the earlier a contributer learns about good commits, the better for him/her and the project and the commiter. |
apidoc error/warning fix (#3)
Cleaned up code as discussed here: #1
Everything fine now?