Hiding dialogs behind an abstraction. Does this pattern have a name?

Here's the deal. I've got user input coming from a bunch of different sources, a dozen dialogs, console etc. The standard way to get something from a dialog is buy reading it's attribute after it's closed.
e.g.
dialogInstance.setModal(true);
dialogInstance.setVisible(true);
String s = dialogInstance.getUserInput();Now, I find this very ugly as it ties you tightly to the implementation of the class that accepts the input (a dialog in this case). In order to loosen the coupling, I came up with the following pattern. Components that are used to accept input (dialogs) are required to bind that input to a previously specified variable in the "global context" that is also available to the main program (that instantiated the dialog in the first place). So, it looks like this:
initInputGatheringComponent(); //this is also abstracted but details are not relevant at the moment, see below if you care for more info
UserInput input = Context.get("variableName")
...And the dialog does this:
//OK button is pressed
Context.set("variableName", UserInput) //UserInput comes from reading a text field value or something like that. This way, the main program has no idea how the variable got it's value, be it from a dialog, console or whatever. And if I change the way I get data, I don't have to change the main program, as long as the same variable is populated.
Now, what I want to know is if this pattern has a name and what it might be? I'm sure I haven't invented anything new, but I want to know what have I reinvented...
Also, I'm interested in the opinions on my approach... Hopefully, the topic is at least a bit interesting to discuss.

Implementation details, for those who care
Every class that is used for accepting input is associated with a name (through an XML config file, I'll see if I know how to change this to annotations), and the method that starts it is annotated with @Run. When requested by the main program, using the name of the component, like this:
Context.start("componentName")the class associated with this name is instantiated by reflection, and it's @Run method is executed. So, for the dialog example, it looks like this:
XML:
<component name="loginDialog" class="javax.swing.JDialog">Code:
@Run
public void display() {
    init();
    setModal(true);
    setVisible(true);
public void btnOKMouseClick(...) {
    Context.set("userName", txtUserName.getText()); //reads the value of the text field and binds it to a context variable named "userName"
    Context.set("password", txtPassword.getPassword()); //same with password field
}and the main program would look something like this:
//the user needs to login
Context.start("loginDialog"); //finds out the class of the component named "loginDialog" (JDialog in this case) from the XML config, instantiates it through reflection,
//and runs it's annotated method (display() in this case)
String userName = Context.get("userName"); //gets the value of "userName" from the context, without being aware how it got there
String pass = Context.get("password"); //same here with "password"

Similar Messages

  • I have a MacBook Pro , Model Identifier MacBook Pro8,2 , MAC OX S 10.7.4.  Question 1: Does this model have a PCI Express slot?  Question 2: Can I upgrade my USB2 port in this laptop to a USB3 port? Appreciate your help & advice..

    I have a MacBook Pro , Model Identifier MacBook Pro8,2 , MAC OX S 10.7.4.
    Question 1: Does this model have a PCI Express slot?
    Question 2: Can I upgrade my USB2 port in this laptop to a USB3 port?
    Appreciate your help & advice..

    No & no.

  • I bought a Power Mac in March, 2008.  Does this machine have WiFi capability?  If it does how can I initiate WiFi?

    I bought a Power Mac (Mac Pro?) in March, 2008.  Does this machine have Wi Fi capability?  If it does how can I initiate Wi Fi?

    Look on the MenuBar. A Mac with no Wi-FI will shows a distinctive completely grayed-out Wi-Fi Icon (not just a black outline.)
    Or look in About this Mac > ( More Info ) > Report >  system report > Network > Wi-Fi
    Installed Hardware always shows the many channels available. If none are listed, you likely do not have the correct adapter installed.
    These adapters are available on the Used market and Amazon. Installation is fussy because everything is so small, and there are several antenna wires to attach correctly.
    There are two models, and most sellers know which Macs they apply to. Installing the wrong one sometimes means you cannot do a software Upgrade.

  • Why does this logo have jagged edges?

    I'm working on a new logo and before I get too far along I need to resolve this issue;  why does this shape have jagged edges when posted on the web?
      you can see it on-line auctionontario.ca
    Thx

    auctioneer,
    Obviously, you are using the transparency available for the GIF format.
    In addition, you should tick the Anti-Aliasing which is, unfortunately, hidden away like a hidden feature in the Image Size window within Save for Web.

  • ABOUT ADOBE MUSE Does this software have responsive design? Do I pay...

    Does this software have responsive design? Do I pay a fee to use the software and another fee to host the web site? How much does it cost to have ONE website edited in Muse and published by Adobe server?

    Hi Leonardo,
    Muse does not offer responsive design at this stage.
    You need to pay the subscription fees to be able to use the software. As far as the hosting fees in concerned, if you opt for subscription to creative cloud that you get 5 free sites hosted on business catalyst for free on the webBasics/webHostings plan. If you choose to opt for single app subscription for Muse then you get one free site.
    This free site offer is not available for the students and the teachers edition.
    You can check different site plans that are available with business catalyst here, US Monthly Pricing | Adobe Business Catalyst
    - Abhishek Maurya

  • Does this computer have gps (my daughter's was just stolen), is there a way to remotely disable it?

    does this computer have gps (my daughter's was just stolen), is there a way to remotely disable it?

    First off, I'm sorry to hear about the theft of your daughter's computer.  The good news is that all Apple computers have their serial number in multiple places (depending on the model) and Apple maintains a list of every one of them.  Do you have the serial number?  If not, you can get it from the retailer you purchased it from.
    As far as GPS and disabling it, it is going to depend on several factors but the short answer is probably not.  I mean, Yes, there is a a way to detect location in most modern Mac's through a web browser using Geolocation (W3C API) but there is no onboard GPS; disabling the machine remotely would require you to have 'Back to my Mac' already set up on it from iCloud.  There might also be some third party tools available that I'm not aware of.
    Again, I'm really sorry to hear about the stolen computer.  I'll keep an eye on this thread to see if you have any other questions.
    BTW, what model and year is the computer that was stolen?

  • Why does this site have online chat when you can never actually chat - always "not available"?  I was trying to get a simple question answered without calling and being on hold for 10 minutes?

    Why does this site have online chat when you can never actually chat - always "not available"?  I was trying to get a simple question answered without calling and being on hold for 10 minutes?

        Hello flabucki,
    Help is just a post away for you my friend! I can help with your questions right here. May I ask what question do you have? Both myself and the community would love to assist in any way that we can.
    Thank you…
    ArnettH_VZW
    Follow us on Twitter @VZWSupport

  • Does this cite have pre-designed forms

    Does this cite have predesigned forms?

    We provide 50 templates to start from and an easy to use authroing tool to modify them to your liking. You can see all of the templates here:
    https://www.acrobat.com/formscentral/en/templates/web-forms-builder.html
    Randy

  • HT4623 does this phone have a flash bulb for picturesin dark settings

    does this iphone have a flash bulb for taking pictures in dark settings

    u303827 wrote:
    does this iphone have a flash bulb for taking pictures in dark settings
    It has an LED light that will work for short distances (1 to 2 meters).

  • Verizon iPhone 4: does this phone have an INTERNAL GPS unit?

    I thought it would but when I drove into an area with no cell coverage my pre-installed MAPS did not work?! If the iPhone has an internal GPS should I not have map coverage anyway? My wife's Droid switches to internal gps.... Can anyone educate me on this?
    For good turn by turn is the Tom Tom ap for iPhone a good one?
    If the iPhone 4 verizon has an internal gps why does tom tom have a car kit for iPhone??????
    thank you!

    As a test I put my iPhone in Airplane mode and when I opened Maps I was instructed to turn off Airplane mode or use WiFi to show my location on the map. I pressed OK and got another message that my location is unable to be displayed on the map. I know data is used to download the map to show your current location and I guess without some type of data connection the Map app will not function.

  • Does this computer have built-in camera?

    Hi there,
    I have brought home my son's lovely laptop computer. He is developmentally disabled and needs some upgrading and file organizing done to the machine. I didn't think too much of it but a question came up when I started running Software Update. Two software items -- Airport and iSight -- are listed for updating.
    But I don't know this computer's capabilities or lack of them for Airport and iSight.
    This is a G4 iBook with a 14 inch screen he purchased in March of 2005. I checked "About this Mac," and it does have an Airport Extreme card installed. I did click on the Airport update.
    I know some newer laptops have a built-in camera, but I don't know if this model in new enough to have that. I do not see anything in "About this Mac" to indicate that it does My guess is that it does not, but I don't know how to tell!
    Does anyone know if it has a built-in camera? If not, then I don't need to bother with the iSight upgrade, right?
    Thanks,
    Linda

    Hi Linda,
    No, the iBook G4 does NOT have a built-in iSight camera.
    You might be able to find an external iSight camera on eBay or other Internet source. Then you might need the iSight update software.

  • I have a macbook air 13inch late 2010.  Does this model have an illuminated keyboard

    I would like to know if my keybord is suposed to light up

    your model does not have this feature.

  • TS1424 What does this page have to do with error code 8003 and not being able to empty trash?

    I did a search for help and this is where I keep landing. But I can open the iTunes Store site just fine, even though I never do.

    Lastly while at the AT&T Store and
    with this guy, I explained that I am in need of a
    cellular telephone for work and he said that "I can
    take my iPhone SIM card out and put it into my old
    telephone (which is a Treo 650) if I need service
    back or to use a cell phone in the meantime". Won't
    this delay the activation of the iPhone though and
    how would an iPhone SIM work in a treo 650 anyways?
    AFAIK the SIM that comes with the iPhone is nothing out of the ordinary...just a new SIM card with AT&T livery. I am in the same boat as you and your wife, but I removed the SIM from the iPhone and am using it in my Treo650 until they can sort this out because I need a phone...period. So it does in fact work if you wish to do it.
    I have no idea about the rumor that the iPhone must remain docked/online during this process nor do I know if using the new SIM in an old phone is elongating things. My guess is that neither is true and the delay is being caused by a MASSIVE onslaught of activity upon AT&T's mainframe.
    Craig
    Powerbook G4 Aluminum 1.25 Superdrive   Mac OS X (10.3.9)   Mac Mini 1.5 running OSX 10.4.8

  • Does this com have a expresscard slot?

    I have a Pavilion dv7 [Product  number: QA668UA#ABA], and I am unsure if it has a Expresscard slot of some sort. I can see a slot labled SD&MMC, but I don't know if that would work. I have also been led to believe there is such a slot inside some laptops. As for why I need to ask, I am going to hook up an external video card, if I can (probably using ViDock).

    Hi,
    No, this model does not have Express card slot (it isn't small, easy to find out). You can check using the first document of the following link:
         http://h10025.www1.hp.com/ewfrf/wc/manualCategory?cc=us&lc=en&dlc=en&document=&product=5141405
    Regards.
    BH
    **Click the KUDOS thumb up on the left to say 'Thanks'**
    Make it easier for other people to find solutions by marking a Reply 'Accept as Solution' if it solves your problem.

  • How many usb ports does this notebook have

    I wanna buy hp pavilion g6 2305tx.but the problem is that it has only 2 usb ports.But i contacted a dealer and he told me that there are 3 ports.is it true ?please give me hands on review.and is it safe to use usb hub in the laptop ?Please inform me.Thanks
    This question was solved.
    View Solution.

    Hi:
    According to the user guide at the link below, chapter 2, pp 3 - 5, there is one USB 2.0 port on one side of the notebook and 2 USB 3.0 ports on the other side of the notebook.
    http://h10032.www1.hp.com/ctg/Manual/c03529460.pdf
    I do not own a g6 model notebook so I cannot provide any further information regarding it.

Maybe you are looking for

  • Systemcopy problem by installing the central instance

    Hello, i am trying to make a Systemcopy from the PRD System to QAS System (Release R/3 4.7 X200) , and got a error message duringsapinst.exe at Input section: Error by Dbo objects check Database QAS contains user objects belonging to system user dbo;

  • Save error when exporting to Png i Illustrator

    Anybody experience the issue of png being saved with "/" in the beginning of the file name when exporting to png in Illustrator. This only happens when I use my mac not my PC. Due to the save error my PC cannot identify the files and when the files a

  • How do I change the color of Icons in the Tool bar of FF4?

    In the FF4, I want to change the color of the X mark of the Stop button and Back and Forward buttons. Is it possible through about:config commands?

  • Headphones don't fit as snug in jack as they used to

    I have a 2 year old 160gb classic. When I use my headphones, they seem to just slide in, and don't stay in very well. My iPhone 4S snaps the headphones in snug. Is this just an issue of age, or an issue ? Is there anything I can do, besides change th

  • Change default mvt 311 for stock transfer reservation generated by system

    Dear SAPper, I used storage location '0003' planned seperately in material master MRP4 and set reorder point 100 and replenishment 100 too. After the stock fall below 100 the system will create stock trasnfer to '0003' the 'from storage location' is