1 24 package org.riotfamily.riot.list.command.core; 25 26 import org.riotfamily.riot.list.command.CommandContext; 27 import org.riotfamily.riot.list.command.CommandResult; 28 import org.riotfamily.riot.list.command.result.PopupResult; 29 30 34 public abstract class PopupCommand extends AbstractCommand { 35 36 private String windowName; 37 38 public PopupCommand() { 39 setShowOnForm(true); 40 } 41 42 public void setWindowName(String windowName) { 43 this.windowName = windowName; 44 } 45 46 protected boolean isEnabled(CommandContext context, String action) { 47 return context.getObjectId() != null; 48 } 49 50 public CommandResult execute(CommandContext context) { 51 String url = getUrl(context); 52 return new PopupResult(url, windowName, 53 getPopupBlockerMessage(context, url)); 54 } 55 56 protected String getPopupBlockerMessage(CommandContext context, String url) { 57 return context.getMessageResolver().getMessage("error.popupBlocked", 58 new Object [] { url }, 59 "A popup-blocker prevented the window from opening. " + 60 "Please allow popups for this domain."); 61 } 62 63 protected abstract String getUrl(CommandContext context); 64 65 } 66 | Popular Tags |