001package jmri.jmrit.operations.automation.actions; 002 003public class MessageYesNoAction extends Action { 004 005 private static final int _code = ActionCodes.MESSAGE_YES_NO; 006 007 @Override 008 public int getCode() { 009 return _code; 010 } 011 012 @Override 013 public String getName() { 014 return Bundle.getMessage("MessageYesNo"); 015 } 016 017 @Override 018 public String getActionSuccessfulString() { 019 return Bundle.getMessage("ButtonYes"); 020 } 021 022 @Override 023 public String getActionFailedString() { 024 return Bundle.getMessage("ButtonNo"); 025 } 026 027 @Override 028 public void doAction() { 029 if (getAutomationItem() != null) { 030 setRunning(true); 031 int response = sendMessage(getAutomationItem().getMessage(), 032 new Object[]{Bundle.getMessage("ButtonYes"), Bundle.getMessage("ButtonNo")}, true); 033 getAutomationItem().setActionSuccessful(response != 1); 034 setRunning(false); 035 firePropertyChange(ACTION_COMPLETE_CHANGED_PROPERTY, false, true); 036 } 037 } 038 039 @Override 040 public void cancelAction() { 041 // no cancel for this action 042 } 043 044}