fixing the global macro panel

The RPTools applications are written in Java. If you're interested in contributing to any project here by submitting patches to the source code, this is the forum to ask questions about how to do so. Please put the two-letter tool name abbreviation in your thread Title. To enter this group, go to the Usergroups page of your User Control Panel and join the Java Developer group.

Moderators: dorpond, trevor, Azhrei

Post Reply
User avatar
aku
Dragon
Posts: 856
Joined: Wed Nov 15, 2006 9:03 am
Contact:

fixing the global macro panel

Post by aku »

reference This discussion for the start of these thoughts.

So, with az's comments that the global macros are saved in the registry, which i "knew", but again, being the newb i am at coding i didnt really "know" (as in, how that was done), so m current thought is that, perhaps, the java or the registry doesnt allow a "batch" clearing of the values, to maintain data intergrity.

Right now, i've got 2 ideas, to solve this. First, again, being the newb i am, i tried adding the same line the same line that is in the campaign code of (or atleast, modifiying it a little to what seemed to fit)

Code: Select all

 		List<MacroButtonProperties> globalProps = MapTool.getCampaign().getMacroButtonPropertiesArray();
The second, and what seems to be the most sure fire way, is to construct a for loop to go through int index and calling the delete function. The second one seems like it would definately work, but probably be considered more amaturish in the long term.

User avatar
jay
RPTools Team
Posts: 1767
Joined: Tue Feb 07, 2006 1:07 am
Location: Austin, Tx

Re: fixing the global macro panel

Post by jay »

The preferences API is here. The method you would be interested in is removeNode(). All you need to do is get the proper preference node and execute that method. Not sure how MT exposes its preferences.

User avatar
aku
Dragon
Posts: 856
Joined: Wed Nov 15, 2006 9:03 am
Contact:

Re: fixing the global macro panel

Post by aku »

ok, here's what i've come up with.

it looks like

Code: Select all

Preferences prefsRoot = Preferences.userRoot().node(AppConstants.APP_NAME + "/macros");
is what names the keys with in the registry/whatever else.

doing some more fiddling. i found a website that is really giving me ahand, exampledepot.com

EDIT: Well, i managed to get the clear panel function to work... but now it won't recreate the node when you go to recreate a new global macro... oh well, one step closer, i suppose, and technically, no steps back...

EDIT2: Sucess! the last thing i need to know, is, is it possible to make global macro groups? i'm looking, but i'm not really seeing any reference to them... will continue fiddling with them to see if i can experiment the answer out of the interface but if not i'd love an absolute answer :D


if its not, than i just need to call the same function for both clicks, hopefully it doesnt break anything else :D
I think i can officially say i've put more time into developing and doing a couple of bug fixes for maptools than i have in actually using it hehe (which is really sad, since i havent done much digging with it either, but i'm happy to be able to contribute what little i can as i l can while i try to learn even a little bit from doing it :D

EDIT 3: Yes, i found out through simple trial and error you can group global macros, however, it is a property of the macro itself, and not part of the global functionality. This now has me puzzled. I'm not certain, given that, if it will actually be possible to clear a group of global macros only. One seemingly sure fire way to do this would be to change

Code: Select all

Preferences prefs = Preferences.userRoot().node(AppConstants.APP_NAME + "/macros");
to something like

Code: Select all

Preferences prefs = Preferences.userRoot().node(AppConstants.APP_NAME + "/macros" + .PREF_GROUP_KEY);
But i already for see that being a problem, because you dont get the group name until AFTER the macro is created, and thus named, and the registry key created, so, probably a bad idea. I'm thinking running the single macro delete function through a loop while the group exists might be the better way to do it. More experimentation to come.

User avatar
aku
Dragon
Posts: 856
Joined: Wed Nov 15, 2006 9:03 am
Contact:

Re: fixing the global macro panel

Post by aku »

ok, so i've been poking at this for a few days, and i finally actually have a question, i think.


if i import net.rptools.maptool.client.ui.macrobuttons.buttongroup.ButtonGroup.java into the GlobalPanel.java, i would then be able to use the MacroGroup being set (i think) by the mouseListener.this in the Public ButtonGroup(ags), correct?

User avatar
trevor
Codeum Arcanum (RPTools Founder)
Posts: 11311
Joined: Mon Jan 09, 2006 4:16 pm
Location: Austin, Tx
Contact:

Re: fixing the global macro panel

Post by trevor »

I'm not quite following the question ...
Dreaming of a 1.3 release

User avatar
aku
Dragon
Posts: 856
Joined: Wed Nov 15, 2006 9:03 am
Contact:

Re: fixing the global macro panel

Post by aku »

i guess, the base question is, can i use a mouse listener from another class, to identify focus while in another class?

User avatar
trevor
Codeum Arcanum (RPTools Founder)
Posts: 11311
Joined: Mon Jan 09, 2006 4:16 pm
Location: Austin, Tx
Contact:

Re: fixing the global macro panel

Post by trevor »

Hmm, it's still kinda fuzzy, but the sound of it feels wrong.

You are trying to know when something has focus ? What is the subject (target component that gets the focus) and the observer (the one that wants to listen) ?

Is it just the focus that matters, or other details ?
Dreaming of a 1.3 release

User avatar
aku
Dragon
Posts: 856
Joined: Wed Nov 15, 2006 9:03 am
Contact:

Re: fixing the global macro panel

Post by aku »

oi, sorry trevor, the problem with being a newb sometimes, is not knowing WHAt i'm trying to ask, but HOW to ask it :D. ok.. try it this way.

in ButtonGroup.java, there SEEMS to already be an mouseListener() that determines what group you have clicked on. What i dont know, is if i need to write a class within ButtonGroup.java to store the current selected group, so that i can then use that variable in a class in GlobalPanel.java.

or, if i can import ButtonGroup.java into GlobalPanel.java, and then just do something like

Code: Select all


String currentGroup = ButtonGroup.ButtonGroup.group();
if(currentGroup = MacroButtonPrefs.getButtonProperties.group();
Do my Junk
or something.......
Thats about as clear as i can make the question at this point, if i'm still rambling to you, i'll just have to try to hammer it out and see if the idea works...

User avatar
aku
Dragon
Posts: 856
Joined: Wed Nov 15, 2006 9:03 am
Contact:

Re: fixing the global macro panel

Post by aku »

stumped? still not making sense? rtfm aku?

User avatar
Azhrei
Site Admin
Posts: 12086
Joined: Mon Jun 12, 2006 1:20 pm
Location: Tampa, FL

Re: fixing the global macro panel

Post by Azhrei »

Is that even Trevor's code? In fact, I don't remember who was responsible for adding the macro panels back in the day. Perhaps someone who's not hanging around here any more?

Sorry, not very helpful. :( I've got a bunch on my plate this coming week, but I'll try taking a look at it on Wednesday to see if I have any ideas.

User avatar
aku
Dragon
Posts: 856
Joined: Wed Nov 15, 2006 9:03 am
Contact:

Re: fixing the global macro panel

Post by aku »

Thanks az at this point, i dont think its a problem with the panels itself i'm struggling with, but some syntax issues on how to cycle through a particular property of all the buttons in a panel, and running another function if they belong to the group in question. I'm pretty certain i understand all of the compartive statements i need, i just cant figure out how to determine WHAT group it is thats been selected to be deleted.

User avatar
aku
Dragon
Posts: 856
Joined: Wed Nov 15, 2006 9:03 am
Contact:

Re: fixing the global macro panel

Post by aku »

ok try my question this way:

Should i add a new mouse event to be able to get the group when the global panel is clicked on, or is there one somewhere else that is already getting the info?

Post Reply

Return to “Java Programming Info”