My first plugin development: CollectionInterface [was: Need help with getting started using C++ Plugin Template]
-
@PeterJones ,
It worked beautifully. I was able to download my dBASE UDL files, and install them in the right directories. The only problem, is that the Autocomplete and Functionlist aren’t functional because of the lack of linkage via the overrideMap.xml file, that didn’t include the association. That’s the only remaining issue, of automating it completely. :-) -
@PeterJones ,
One other thing, is that the names have to be consistent, and mine were all over the place. The file internal names (for the UDL definition) and the names in the autoCompletion and functionList and the overrideMap.xml file. That’s the weak spot at this point, is being able to keep the names consistent between the internal file name and the rest. I only did the Light version and had to modify all of them, because the long names in the repository, don’t match the names needed in the rest of the linkages needed for the files. At least, mine. :-)Other than that…where was this thing when I needed it. I could have focused more on the things I’m trying to do now with the UDL, but had to write the darn installer because of the namings required. :-)
I’m going to have to look at your code and stuff now, so maybe I can learn from it as it’s apparently something I’m interested in. -
might confuse users. The rightmost button is usually Cancel or Close
I knew that, but since RESTART N++ is “even more close than CLOSE” – it’s a more drastic “exit this dialog”, since it also exits and restarts the application, so I thought that it might be more logical to be further right than the DONE. I’ll probably reorder and rename to DOWNLOAD, RESTART N++, and CLOSE (instead of DONE)
if it means “Download what I have selected and then restart” or “Restart without downloading anything (more).”
Odd, I wasn’t expecting any confusion, especially since the instructions in the dialog explain why you would need to RESTART. I’ll definitely have the README explain things in more detail, but maybe I’ll add a HELP interface of some sort.
If it means just Restart, I would put it to the far left and disable it
I like the idea of disabling it… But putting it on the far left doesn’t make sense to me, because the primary action of the dialog is to DOWNLOAD, and I tend to think of the buttons as being layed out left-to-right in the order they would be used: since you would DOWNLOAD first, it would be leftmost, and then you would either RESTART or CLOSE, depending on your preferences, so those would go to the right. What’s your reasoning for putting the RESTART on the left?
really consider the multiple selection option
We’ll see. Doing the automatic or at least optional “also download AC and/or FL when you download the UDL” makes sense to me… but I’m not as certain about downloading multiple UDLs at the same time.
since you’re using an asynchronous interface (wininet) you should be able to put a cancel button on the downloading dialog. (Progress would be more work; I’d guess these files are small enough that it wouldn’t be necessary?)
With the downloading happening self-contained in a method on the object, rather than being inside the dialog-handler, I’m not sure of an easy way to signal the class/method to stop the download. Progress, in my mind, would be easier, because if I just passed the control for the progress bar as an argument to the download method, it could send the right signals at appropriate times. But we’ll see what I can figure out.
-
@Lycan-Thrope said in Need help with getting started using C++ Plugin Template:
@PeterJones ,
One other thing, is that the names have to be consistent, and mine were all over the place.yes, that does get confusing. And I’ve just realized that I might have to work on the autoCompletion naming, because I think I’m basing it off the JSON’s “id-name” field (ie, the UDL’s filename) rather than basing it off the JSON’s “display-name” field (which is what Notepad++ calls the UDL, and what I understand the autoCompletion feature needs for file naming on UDLs; I’ll have to double-check.[*]
The file internal names (for the UDL definition) and the names in the autoCompletion and functionList and the overrideMap.xml file.
The functionList requires the overrideMap update. If named correctly, autoCompletion should “just work” (though “if named correctly” is a big caveat; see my previous paragraph in this reply ;-))
Other than that…where was this thing when I needed it.
Just an idea at the back of my mind, at that point. Sorry I’m not a time traveler. ;-)
[*] update: yes, AC files must match the “display-name” (ie, the
<UserLang name="XYZPDQ" ...
name); I need to update the CONTRIBUTING.md to make that clear, and eventually update the automatic checks run on the repo so that any AC filename must match its associated UDL actual-name. Yay, another thing for my growing TODO list on this project. ;-) -
@PeterJones said in Need help with getting started using C++ Plugin Template:
What’s your reasoning for putting the RESTART on the left?
(All these things are just thoughts from someone who is merely looking at your writing and images and hasn’t used the program or tried to implement any part of its function. If my tone sounds a little know-it-all, please accept my apology in advance; it gets unreadable to qualify everything with “I think maybe, if you like the idea”; but I’m really not trying to say everything should be the way I say, even if succinctness sometimes makes it sound that way.)
Usually dialogs which you call up via a command either show requested information, let you specify changes and then either OK or Cancel them, or let you make changes “live” and then Close them.
In all those cases, when the dialog closes, you are (in some sense) back where you started when you opened it. The buttons at the bottom in the center or at the right of a dialog usually represent actions within that flow.
Closing and restarting the host program is a more drastic action than one normally associates with a dialog. Buttons don’t usually go on the left; when you see one there, you know (maybe subconsciously) that something is different about that button.
However, the more I think about it, the more I would recommend just the two buttons — Download and Close — and then raise an message box after the user closes your dialog if anything was downloaded. (Users are more used to a message box — if it appears when the action they took didn’t represent the intent to raise a dialog — indicating something unusual happened, will happen or might happen depending on their choice.) In that separate step, tell the user the changes won’t take effect until Notepad++ is restarted and ask whether to do that now. (Yes or No, No should be the default.)
(This isn’t something people are going to do often, so clarity is more important than keystroke efficiency.)
I will keep the Category as a dropdown (since there are only 4), but yeah, it makes sense to make the file list a List Box.
If there are only four categories, and they are always the same, and the names are short, consider radio buttons. (Or tabs: not a true tabbed dialog, since the content would be always the same single list box populated with different data; just the visual appearance. I haven’t used one in a while, but if memory serves the Tab Control itself is really just like a group box with a selector on top; what you put in the box is your business. If I did that, I would also put the Download button in the tab box, under the list box, with the close button below and outside the tab box.)
Edit to add: Roughly, like this:
-
@PeterJones said in Need help with getting started using C++ Plugin Template:
[*] update: yes, AC files must match the “display-name” (ie, the <UserLang name=“XYZPDQ” … name); I need to update the CONTRIBUTING.md to make that clear, and eventually update the automatic checks run on the repo so that any AC filename must match its associated UDL actual-name. Yay, another thing for my growing TODO list on this project. ;-)
Now you know how I felt making the UDL. I had to figure out how to implement the features everyone wanted, via the Notepad++ features and learn how to do it, then learn the hard way that the naming matters, and then write the installer because people had problems figuring out which
dbaseplus.xml
(UDL, functionList & autoCompletion) file went into which directory, then try and explain how to modify theoverrideMap.xml
file, and then depending on if they had a standard, portable and/or cloud install, and then write the installer to handle it all. I know your angst, believe me. :-)And your herculean efforts are appreciated for sure by me for my future works, considering you can’t time travel. :-) So Thanks!
-
@Coises ,
I can understand your point about upon having a popup appear when the user tries closing the dialog box, alerting them that their changes won’t take effect until NPP is rebooted, so you’re putting the responsibility on to the user…which by the way, is counter to the way the Plugin Admin itself does things.It does the reboot, the same as @PeterJones plugin does, which is what I would expect when I’m required to reboot after completion, also just like Windows own update process requires. This might be the only change needed for the reboot procedure, but other than that, for a rough first version, it’s fine for me…I read directions. Sometimes not as well as I should, but I do read them. :-)
-
@PeterJones said in Need help with getting started using C++ Plugin Template:
since you’re using an asynchronous interface (wininet) you should be able to put a cancel button on the downloading dialog. (Progress would be more work; I’d guess these files are small enough that it wouldn’t be necessary?)
With the downloading happening self-contained in a method on the object, rather than being inside the dialog-handler, I’m not sure of an easy way to signal the class/method to stop the download. Progress, in my mind, would be easier, because if I just passed the control for the progress bar as an argument to the download method, it could send the right signals at appropriate times. But we’ll see what I can figure out.
My apologies. I also used wininet, but forgot that asynchronous operation is an option, not the only way it works. I see from your code that you are operating synchronously. I think passing a progress bar control couldn’t work, because if you’re operating synchronously, the message loop doesn’t run until you return. You can update the control, but the change won’t be displayed because the message loop never gets control to update the display.
-
Next GUI opinion: if I’m going to make the “download AutoCompletion/FunctionList at same time as UDL” optional, I’ll want checkboxes.
Should they go on the left or right?
My plan is to disable the checkbox for a given UDL if the UDL doesn’t have the corresponding AC or FL. And on the AC, FL, and Theme tabs, the checkboxes will be hidden completely (but the Download button will still be in the same place).
-
@PeterJones said in Need help with getting started using C++ Plugin Template:
Should they go on the left or right?
I think left is better.
-
@Coises ,
Thanks, I was thinking that, too.
The copy currently in GitHub now allows the additional download of the associated AC or FL for a given UDL. (But it still only allows selecting one UDL at a time.)
Whether in the AlsoXX mode or the normal XX category, it also now warns you if it’s going to be asking for elevated UAC permissions (usually when downloading AutoCompletion, since those go in Program Files), and if you CANCEL, it will not bother with the UAC prompt and thus won’t download the file. I thought that people might be confused why Windows was giving the UAC elevation prompt, so decided that a MessageBox in between would be helpful.
-
@PeterJones ,
Left for me too, although, when I first looked at it, I thought you were doing a selection on the left and the right would expand showing the files that the UDL could download…and then those would have checkboxes…but then I saw the red line and realized while reading it was an either or choice. :-)As for the UAC mention a little further down, are you able to do that via NPP and the installation? I know NPP does it, so that’s why I ask…in my installer, I had to let people know they might have to install the package while in Admin mode, for the autoCompletion file for a standard install.
-
@Lycan-Thrope said in Need help with getting started using C++ Plugin Template:
and realized while reading it was an either or choice
Sorry, at one point, I thought I put in a “VS” next to the red line, but I did an UNDO on that at some point while manipulating the image. I probably should have just pasted two separate images, rather than joining them to one.
As for the UAC mention a little further down, are you able to do that via NPP and the installation? I know NPP does it, so that’s why I ask…in my installer, I had to let people know they might have to install the package while in Admin mode, for the autoCompletion file for a standard install.
Since neither Notepad++ nor my plugin have Elevated permission yet, and I didn’t want to tell the user that they had to restart Notepad++, I cheat: instead of downloading the file directly to the protected directory, I download it to a temporary directory (and hence the GetTempPath2W-vs-GetTempPathW from earlier), then I run a ShellExecute
runas
to copy from the temp-dir – and therunas
prompts for the UAC for just the process that’s copying the file. -
@PeterJones ,
Clever. :-)Now, you might be interested to know, that your package download works just fine, as far as getting the files in the right directories. However, this brings up the file naming (internally and externally) problems that I was mentioning earlier.
Since the dBASEPlus UDL is currently the only UDL package with all 3 files, (sans additional separate themes other than Dark and Light variants), I had to rename things, and I think I got it sorted out and wasn’t sure if this is something you are going to work on, or was going to leave for later. I know the filenames in the JSON in the repository are probably what will need to be changed, but have some info about what the final product for all 3 packages needs to look like.
1.) The UDL userDefineLangs name needs to be the same internally and externally and in the same case for the functionList definition to work properly and that name needs to be in the overrideMap.xml in the same case. (any change in case in any of the 3 places, makes the functionList not function)
2.) The name of the autoCompletion files can be any case, as long as the name is the same as the actual UDL’s file name. (which should have internal/external the same, and case wise)
eg. dbaseplus_light.xml to be used for autocompletion of the dBASEPlus_Light.xml UDL.3.) The actual functionList file can be the same file for both Dark and Light versions, just the overrideMap.xml file has to point the association to each like so:
<association id= "dbaseplus.xml" userDefinedLangName="dBASEPlus_Light"/> <association id= "dbaseplus.xml" userDefinedLangName="dBASEPlus_Dark"/>
Any future dBASE variants would be named differently to accomodate that version’s functionList needs, for both Light and Dark. Such as dbaseIIIPlus.xml, dbase4,xml, etc.)
My original naming was helped by your putting the name first and the color type after, but the extremely long name, or only changing the internal name differently than the external name, causes linkage problems between the 3 different aspects. I think you already know that, but thought it was probably something that I should bring up that is the only hiccup right now.
I hope this helps rather than complicates your current development focus. :-)
-
have some info about what the final product for all 3 packages needs to look like.
I don’t quite agree with your interpretation:
-
UDL Naming Mismatch OK: I created a UDL file called
GeoRge.xml
with<UserLang name="Gracie"
It is recognized as a UDL, and the mismatch between the filename and the internal name doesn’t interfere with UDL or FunctionList or AutoCompletion, as long as FunctionList and AutoCompletion reference the internal
Gracie
, not theGeoRge.xml
filename. -
FunctionList Filename/displayName mismatch OK:
Example: With FunctionList filename
GracieFL.xml
and the setting inside GracieFL.xml being<parser displayName="ThisIsIgnored"
, and the overrideMap.xml having the line:<association id= "graciefl.xml" userDefinedLangName="Gracie"/>
it all maps correctly.
- The association ID name must match the FL filename, but case is not important, because the Windows filesystem is not case sensitive.
- The association
userDefinedLangName
must match the<UserLang name="..."
, but doesn’t care about the UDL definition’s filename- I can, however, confirm that if
userDefinedLangName="gracie"
case does not match<UserLang name="Gracie"
case, it will not map properly, because XML attribute values are case-sensitive, and Notepad++ does the internal searching based on case.
- I can, however, confirm that if
- Notepad++ ignores the FL parser’s
displayName
andid
values for any of these mappings.
In my example, the regex is
<function mainExpr="(?x-is)^\d+\..*(?=:)"/>
so that the dummy text as I am writing up this post will have functions, so I can share screenshot showing that with these settings, it does correctly show FunctionList- AutoCompletion needs to match UDL name, not filename:
If I name the AutoCompletion file
gracie.xml
– so it matches the<UserLang name="Gracie"
(case insensitive), but does not matchGeoRge.xml
, the autoCompletions work properly.
However, other than the fact that I can enforce AutoCompletion filename name must match the UDL’s internal name (with the
.xml
extension added), none of this has to do with my plugin. -
-
@Lycan-Thrope said in Need help with getting started using C++ Plugin Template:
Since the dBASEPlus UDL is currently the only UDL package with all 3 files
LSL_byKimpaTammas
(“LSL”) has UDL and FunctionList and AutoCompletionBut they have the same problem, where the autoCompletion filename matches the UDL filename
LSL_byKimpaTammas.xml
instead of the UDL’s internal name, which is justLSL
.I have not yet had an opportunity to improve the consistency-checks (validators) in the UDL repo yet, though the issue #303 exists.
-
@PeterJones ,
I stand corrected. I didn’t scroll the longer list, so missed it. Doh! -
@PeterJones ,
This is wierd, because I spent the earlier part of the day, testing just for these different scenarios, changing something, saving, closing NPP, and then reopening. I would open a recent file and if the FL didn’t populate I worked the different aspects and that’s what made me document the changes of names and how they needed to be.Hmm…can’t explain that…and this is the repaired NPP exe that changes to the correct UDL/FL combination that was fixed from my bug report.
Hmm…I think I need to go retest this and find out what went changed, because I thought I was being pretty meticulous with these checks. Remember, I have Dark and Light versions, and that’s how I was knowing when one was working and the other wasn’t.
-
@PeterJones ,
Well, I don’t know how it happened, but either through a fluke or what not, all that testing I did was just undone.It took a while to get it right with your naming the file one thing and the internal name another, but I ended up getting it to work like you show. I just can’t explain how it didn’t work that way the first time I went through it…but oh well. :-(
-
I have a version good enough that I’m going to call it “beta”:
https://github.com/pryrt/NppPlugin-CollectionInterface/releases/tag/v1.0.0betaIt doesn’t have multiple-UDL-download feature (that can wait until a future version), but it’s got the download one file, or download UDL+FL/AC. It should properly ask for UAC permission on AutoCompletion. It will ask if you want to restart Notepad++ through a new MessageBox after the Done button is pressed on the main dialog. There is a ? button on the dialog, and that help is also available through the plugin’s menu.
Mostly what I’m looking for at this point is feedback on whether it does what I claim it does, and whether it works as expected for other people, not just for me. For now, ignore any problems with the metadata mismatch that @Lycan-Thrope has been focused on; I will eventually improve the UDL Collection checkers to flag those, and work on fixes. Other than that, let me know if you think there are any show-stoppers that would prevent it from being released.
(I’m calling this beta, not RC, because I know there are at least one-or-two behind-the-scenes things that I want to improve, though hopefully the end user wouldn’t be able to guess what those might be, because it shouldn’t affect the user.)