Action question

Hi to all!
I have to write my own Action object that extends AbstractAction. I want to use this Action object to set the checked/unchecked state of a JMenuItem or a JButton of a toolbar.
I want to subclass my object from AbstractAction but I DON'T want to subclass every object using it (JMenuItem or JButton).
So I'm thinking the the best way to solve the problem was manage the selected state from within the Action object.
The action object contains its PropertyChangeListneners. For a JMenuItem or JButton the listeners are ButtonActionPropertyChangeListener objects. Those listeners contain the AbstractButton reference they belong, but ButtonActionPropertyChangeListener are contained in a private way, so i cannot access them.
Any suggestion?
thanks
Jacopo.

It appears that AbstractActionPropertyChangeListener, the superclass to ButtonActionPropertyChangeListener, has a method called getTarget(). You could use this method and cast it to an AbstractButton type and call the setSelected() method on it. As long as you know your AbstractAction is only being used for AbstractButton subclasses, you ought to be OK.
It would probably be wise to put in some type-checking using instanceof -- I think there may be some extra PropertyChangeListener's that Swing puts in there that aren't of type AbstractActionPropertyChangeListener. The other thing you may have to look out for is recursive calls to this. If you have three AbstractButtons w/ this listener, then as you programmatically set each one to be the same as the one that got clicked on, they may fire their own action listeners to do the same thing. Bad loop to be in.
I think the code would look something like this:
setPropertyChangeListenersValue(boolean b)
  PropertyChangeListener[] pcl = this.getPropertyChangeListeners();
  for(int i = 0; i < pcl.length; i++)
    AbstractActionPropertyChangeListener aapcl = (AbstractActionPropertyChangeListener) pcl;
AbstractButton ab = (AbstractButton) aapcl.getTarget();
ab.setSelected(b);

Similar Messages

  • Photoshop Action question

    Is there a way to automate the selection of a certain color or color range?
    For example, I'd like to make an action that selects the foreground color in a series of images and makes a mask based on that selection (then goes on to do other things...)
    Thanks for any and all help.
    Phil

    I can’t test on CS3, but I think the affected features should not have changes since CS3.
    Anyway, I think an Action cannot perform what you want, a Script should be able to, though.
    You could adapt the following code by changing the variable docPath to the correct path of the Folder you want to save the jpgs into.
    If you want to give it a try, paste the following text into a new file in ExtendScript Toolkit (part of Photoshop’s installation, Applications/Utilities/Adobe Utilities/ExtendScript Toolkit CS3, I guess) and save it as a jsx-file into Photoshop’s Presets/Scripts-folder.
    After restarting Photoshop the Script should be available under File > Scripts and can be assigned a Keyboard Shortcut directly, recorded into an Action or started from ExtendScript Toolkit directly.
    // saves jpg into same folder;
    // be advised: this  overwrites existing jpgs of the same name without prompting.
    // 2010, use it at your own risk;
    #target photoshop;
    if (app.documents.length > 0) {
    var thedoc = app.activeDocument;
    // getting the name and location;
    var docName = thedoc.name;
    if (docName.indexOf(".") != -1) {var basename = docName.match(/(.*)\.[^\.]+$/)[1]}
    else {var basename = docName};
    // getting the location, if unsaved save to desktop;
    try {var docPath = thedoc.path}
    catch (e) {var docPath = "~/Desktop"};
    // jpg options;
    var jpegOptions = new JPEGSaveOptions();
    jpegOptions.quality = 9;
    jpegOptions.embedColorProfile = true;
    jpegOptions.matte = MatteType.NONE;
    //save jpg as a copy:
    thedoc.saveAs((new File(docPath+"/"+basename+".jpg")),jpegOptions,true);
    //that’s it; thanks to xbytor;

  • Actions question

    I'm in CS6 and have a few actions I need to do to 300+ files, I'm familiar with the actions process but this has me a bit stumped.
    The actions are as follows
    Open a pdf in Pshop called Main.psd
    select the 300 pages ( doc has multiple pages ) but lets say select only 100 for now.
    make sure bounding box is selected convert dimension heights to 700
    Pshop opens each page individually in open windows
    then
    Open psd template (called) template 560 x 720.psd)
    copy page 1 of the main.pdf on to the template
    select background and align
    name and save doc as (whatever)
    repeat this for all documents
    Now
    when I tried this I got the msg that PShop cannot find a source file, this must be because when I recorded the actions I did not save the open windows PShop created when I extracted each page from main.pdf
    ***this is the part that I get stuck in as if I do it manually the pdf I'm extracting the graphics from has 100 windows open, how do I save all those windows at once, follow?
    when I do this manually I just drag and drop each graphic from the wondows Pshop created from the extraction to the template, then align and save as page 101 102 103 etc.
    I never save the individual pages or open windows.
    I hope I'm clear as automating this would save me hours and hours of manual work.
    anyone?
    R

    You may want to ask for help over at
    http://forums.adobe.com/community/photoshop/photoshop_scripting
    as I think this task is probably beyond Actions alone at current.

  • Smart Object And Action Question

    I have a smart object layer in one document and I want to drag it over to another document and record this in an action. If I just drag it over, the action records it as select previous document. Copy and paste doesn't transfer the layer as a smart object.
    Is there any way to do this in an action?
    Thanks!

    The place suggestion worked. It's too bad that it has to be so wasteful on space though. It looks like placing a file makes it a smart object which then contains the original smart object I wanted to transfer over.
    Thanks!

  • Offset Path in an Action Question

    I have an action that performs several steps on a selected object, namely removing rounded edges, changing the stroke to a specific color, and setting the line width to a specific measurement. What I would like to add to this Action is a final step where the Offset Path is invoked (easily done) and then the original object is deleted (I'm stumped). When using Offset Path, both the original path and the new offset path are selected, so I can't just add a delete step. While this might be better suited for a script, I'd really rather keep it as a function key enabled script. Any guidance will be appreciated.
    Gary

    Thanks for the reply. Yeah I know that, its just a little tedious. It would be nice if they made it a little more accessible like the scripting languages in a lot of 3d packages.

  • Action Questions - Is scripting the answer?

    I'm in CS6 and have a few actions I need to do to 300+ files, I'm familiar with the actions process but this has me a bit stumped.
    The actions are as follows
    Open a pdf in Pshop called Main.psd
    select the 300 pages ( doc has multiple pages ) but lets say select only 100 for now.
    make sure bounding box is selected convert dimension heights to 700
    Pshop opens each page individually in open windows
    then
    Open psd template (called) template 560 x 720.psd)
    copy page 1 of the main.pdf on to the template
    select background and align
    name and save doc as (whatever)
    repeat this for all documents
    Now
    when I tried this I got the msg that PShop cannot find a source file, this must be because when I recorded the actions I did not save the open windows PShop created when I extracted each page from main.pdf
    ***this is the part that I get stuck in as if I do it manually the pdf I'm extracting the graphics from has 100 windows open, how do I save all those windows at once, follow?
    when I do this manually I just drag and drop each graphic from the wondows Pshop created from the extraction to the template, then align and save as page 101 102 103 etc.
    I never save the individual pages or open windows.
    I hope I'm clear as automating this would save me hours and hours of manual work.
    anyone?
    R

    Ok sorry for the confusion let me break it down.
    The original document I need to extract from is an .indd file so I exported the file as a pdf document and opened that in Photoshop. When I open it I get the import .pdf dialogue box , so since the pdf is way too large in dimension I narrow it down to 720 height which is the size I need.
    I select 100 pages ( out of 300) or I can select 5 pages, regardless and hit OK.
    Photoshop opens the selected amount of pages as individual windows.
    Now manually I would seletc each window one at a time, lets say page 1 is the name of the first one, then I  open a second document in Photoshop called template 560 x 720 .psd
    I drag the artwork from the page one doc extracted from the pdf and place i ton a layer in the template 560x720.psd
    then select the new layer and the background so I can align the graphic, then save the original template 560 x 720 .psd with the new graphic as a.jpg In this case image or page1.jpg.
    Then drag a graphic from another open window and repeat, follow?
    hope this is clearer
    R

  • Batch action question

    Hi,
    I am experimenting with batching an action on a folder of .jpg images using PSCS5. These are the steps I am taking:
    1. File>Automate>Batch
    2. Select Action from Play area
    3. Choose folder of images
    4. Choose destination folder
    5. OK
    The process works fine except it requires that I click OK on the JPEG options dialog. I must be missing something simple because I am sure you can batch a folder of images without having to click OK for JPEG options for every file.
    How do I apply the same JPEG options to all images so that I can start a batch process and simply walk away for an hour while the job completes.
    Thanks for your help.
    b

    It can be done, but you have to record the Save As - JPEG step (to set the save quality), then use the Override Action "Save As" Commands option in the Batch dialog to keep that step from prompting.
    -Noel

  • Photoshop Action Question How to Avoid Replace Files Dialogue Box

    I have Photoshop CS3 running on a Macintosh. This Photoshop action on this Mac opens PDFs and saves them as a JPEG to a folder on a server.
    Sometimes the originating file will be modfied, so a new PDF will be created and have to go through the action again. The intent is for the action to overwrite the preexisting JPEG file(s) on the server, because they are out of date and must be replaced.
    The photoshop action on the Mac converts the new PDF to a JPEG, but then stops and shows a "Replace Files" dialgue box, which displays a listing of the name(s) of the JPEG(s) that will be overwritten. The dialogue box reads "Some of the specified files already exist in the target location. The files marked will be replaced." Below that message are two buttons to choose from, "Cancel" and "Replace". I always click "Replace"
    Is there a way to get the the action, (which specifically reads, "With Save Image Files" on the part of the action where it saves the jpg),  to just go ahead and overwrite the existing JPEG file(s) on the server without presenting the dialogue box?

    I can’t test on CS3, but I think the affected features should not have changes since CS3.
    Anyway, I think an Action cannot perform what you want, a Script should be able to, though.
    You could adapt the following code by changing the variable docPath to the correct path of the Folder you want to save the jpgs into.
    If you want to give it a try, paste the following text into a new file in ExtendScript Toolkit (part of Photoshop’s installation, Applications/Utilities/Adobe Utilities/ExtendScript Toolkit CS3, I guess) and save it as a jsx-file into Photoshop’s Presets/Scripts-folder.
    After restarting Photoshop the Script should be available under File > Scripts and can be assigned a Keyboard Shortcut directly, recorded into an Action or started from ExtendScript Toolkit directly.
    // saves jpg into same folder;
    // be advised: this  overwrites existing jpgs of the same name without prompting.
    // 2010, use it at your own risk;
    #target photoshop;
    if (app.documents.length > 0) {
    var thedoc = app.activeDocument;
    // getting the name and location;
    var docName = thedoc.name;
    if (docName.indexOf(".") != -1) {var basename = docName.match(/(.*)\.[^\.]+$/)[1]}
    else {var basename = docName};
    // getting the location, if unsaved save to desktop;
    try {var docPath = thedoc.path}
    catch (e) {var docPath = "~/Desktop"};
    // jpg options;
    var jpegOptions = new JPEGSaveOptions();
    jpegOptions.quality = 9;
    jpegOptions.embedColorProfile = true;
    jpegOptions.matte = MatteType.NONE;
    //save jpg as a copy:
    thedoc.saveAs((new File(docPath+"/"+basename+".jpg")),jpegOptions,true);
    //that’s it; thanks to xbytor;

  • Bulk Account Actions Question

    hi.
    when i have a IT Role, name is it_role_name,
    if i want to assign a role to a lot of account.
    i setup some configure at Launch Bulk Account Actions tab like From Action List, Get action list from      
    Input Area et...
    is it right??
    Input area instruction&#65306;
    command,user,waveset.roles
    Update,user1,it_role_name
    Update,user2,it_role_name
    Update,user3,it_role_name
    Update,user4,it_role_name
    Update,user5,it_role_name
    ........

    Hi,
    What you have should work OK. See [http://docs.sun.com/app/docs/doc/820-5822/byaej?a=view] for more info
    As a guide here is an extract of a upload file that I use
    Where a user does not have a role then use
    command,user,waveset.roles
    update,userID1,|List|role1
    update,userID2,|List|role1
    If you wish to merge with other roles then use
    command,user,waveset.roles
    update,userID1,|Merge|role1
    update,userID2,|Merge|role1

  • Folder actions question

    I would like a folder action that takes a file that I drag and drop to it to be attached to an email and sent to a specific recipient with out any further intervention
    Can that be done ??

    I had a bit of a problem with this but I think I've got it
    Create a new folder to contain your files - this seems to work best from the desktop
    In Automator use the Finder "Choose Folders" command and select the fiolder from the drop down, tick "return references to the folder contents"
    Drag Mail's "New Mail" command below and input the address you want in to the to section. Tick "attach items" , I can't get the "send mail' option to work here it always reports an address error for some reason, I have tried attaching the "Send Outgoing Mail" action to the end too, but this also won't work for me.
    Still it will at least create the message and only require you to press send - will investigate more and see if I can fix it.

  • Specific document using an action question

    Would I be right in assuming that there is NO way that an action can pick a specific open document by name (to then perform an action on). As you can't rely on "previous" or "next" documents - as the number of open documents is unknown. (unlike scripting where you can getByName). I'm pretty sure this is the case, but I just want to double check. Cheers.

    Objects can be selected in an Action if they have a "note" assigned to them, which is done using the Attributes panel. Since you would surely know if your objects had notes already, I doubt you'll be able to do this, unfortunately.
    Mike D.

  • Strange Action results in PSCC

    Last night I was working a lot with actions. Mostly making 1 or 2 step actions with a flatten step and a save step. I'm getting all sorts of strange behavior in my results. In one example, trying to flatten 8 open files with a 1 step action, only six files get flattened. Another example, Using a 1 step save action, only 5 files get saved. Another example, with 8 files open I build a simple Save As action, the end result should give me 8 files in my destination folder. Instead I get 2 files saved. BTW no errors reported in any of these examples. I'm swearing more because of it.
    After experimenting further, I'm finding something truely is broken with the batch processor in CC. I made a 1 step action to flatten file. I had 8 open files on which I ran the action. Only 5 of the files were flattened.

    This is a scripting forum. Action questions should be asked in the Photoshop general forum and bugs should be reported on Adobe Photoshop Family feedback site.

  • Action advice

    Hi everybody,
    I'm refactoring an application to deal with Actions, and I've run into a slightly confusing situation. (I would have put this in the Swing forum, but technically it doesn't involve a Swing problem, just a conceptual Actions question.)
    I need to create menus on a MenuBar, and thus far, I'm doing it with a for loop, like this:
    for( condition ) { create; }The problem with that approach is that it doesn't seem to offer a lot of flexibility. For each menu item, I have a string read in from a file formatted like this:
    Item Text=InfoTip=Action=Keyboard Shortcut (where applicable)OK, so after all this rambling, my question is this:
    It doesn't appear that you can transfer a string (ie. "Action" in the above string) into a direct function call to an action. The only way I can think of to make this happen is to map strings to actions and check with a lot of if statements, like this:
    for( condition )
       // Split string on "="
      // Create menu with array[0]
      // Add infotip from array[1]
    // Add shortcut if applicable from array]3]
      // Check all possibilities for action string
      if string is "blah", add this action to the item
      if string is "zz", add a different action to the item
      etc.
    }It seems to me that there must be an easier way to add the actions, but I can't think of it. Can anyone give me some ideas, please?
    Thanks,
    Jezzica85

    Create a Map<String, Action> and put pairings of your action strings with their respective action classes before they're used to create your menu items. Something like private final Map<String, Action> actions = new HashMap<String, Action>();
      actions.put("fileopen", new FileOpenAction());
      actions.put("filesave", new FileSaveAction());
    } then you can assign action actions.get(array[2]) to the new component in create(), avoiding the if statement.
    HTH

  • Multiple outcomes from action

    Hi,
    I have a scenario where the user enters his id on the start page and on clicking submit he should be forwarded to a verification page. But if the user id doesn't exist or if he is disabled, the start page should be displayed with a message.
    The problem I have is, it is always staying on the start page irrespective of the outcome.
    Here is the task flow definition.
    <control-flow-rule id="__11">
          <from-activity-id id="__12">IVS</from-activity-id>
          <control-flow-case id="__14">
            <from-action id="__44">#{sessionScope.IVSActionBean.startAction}</from-action>
            <from-outcome id="__15">questions</from-outcome>
            <to-activity-id id="__13">IVSQuestions</to-activity-id>
          </control-flow-case>
          <control-flow-case id="__33">
            <from-action id="__45">#{sessionScope.IVSActionBean.resetStartPage}</from-action>
            <from-outcome id="__34">reset</from-outcome>
            <to-activity-id id="__32">IVS</to-activity-id>
          </control-flow-case>
          <control-flow-case id="__40">
            <from-action id="__43">#{sessionScope.IVSActionBean.startAction}</from-action>
            <from-outcome id="__41">resetstart</from-outcome>
            <to-activity-id id="__42">IVS</to-activity-id>
          </control-flow-case>
    </control-flow-rule>Please suggest
    M

    Is this determined by the action specified int he command button.
    <af:commandButton text="#{IVSBundle.NEXT}"
                                      actionListener="#{IVSActionBean.startAction}"
                                      id="dc_cb1" action="questions">
                     </af:commandButton> 

  • 4 month delay in answering questions

    I see that it takes up to 4 months for a reply from Adobe to some of the questions posted here

    For the vast majority of civil, actionable questions, we try to get to them within a couple days.  That falls apart when we're side-tracked with a crisis or a tight schedule, but we try to stay on top of it.  January was especially brutal from an operational perspective, and we are out of the office over the US holiday season, so it's definitely possible that we we didn't have time to get to your question.  You said four months, which is the right window.  I always cringe when I reply to an ancient thread, but I figure I owe you the respect of at least a late answer.
    Like Chris said, the engineering staff working on the actual product is pretty active here as a courtesy to our users, but we're usually doing it on our own time or squeezing it in when we have a few minutes here and there.  If you have an issue that you're still struggling with, we'd be happy to try and help you with it.
    For future reference, if you want an immediate answer, Adobe provides telephone support.  We just charge for the free products.
    What are my contact options?

Maybe you are looking for

  • Jquery slider problems need help with css part

    I am building a website with the jquery slider and for some reason it is entering the amount of pics in the slider below the slider and I can't figure out how to get rid of it. It appears in Live Mode and when you view in in any browser. Here is the

  • Mail stops pushing to the phone

    Anyone have this issue?  My icloud e-mail stops getting pushed to my phone.  If I go into e-mail it downloads messages that were waiting but don't get pushed.  This has happened on my 4s and my wifes 4.  I had to hard restart to get it back to work o

  • Keywords and LR 1.1

    I finally got updated to LR 1.1. Last week I was introduced to a "Missing a required dll file" message; jump on Google and with a couple of minutes found that I wasn't the only. Downloaded "Windows Installer Update" and was good to go. Enough about t

  • Lightroom 1 updates

    I have got Lightroom version one and my PC has crashed. I am having to reinstall everything from scratch and it wants to update to 1.4, which I need to be able to view my Canon RAW images. The link is no longer available. Help!

  • Youtube "an error occurred, please try again later."

    I keep getting the message on youtube "an error occurred, please try again later."  I've tried all of the recommended solutions to no avail.  The funny thing is, the advertisements play just fine, but the actual video won't.  Any ideas?