Skip navigation


Canned Searches

If you find yourself searching queues for the same thing again and again then why not create a button with that search ready to go?

from javax.swing import Action
from javax.swing import AbstractAction
from java.awt.event import ActionEvent
from hermes.browser import IconCache
from hermes import Domain 

# The singleton HermesJMS browser

browser = HermesBrowser.getBrowser()

class SearchMessagesAction (AbstractAction):
	def __init__(self, browser, searchString):
		self.browser = browser
		self.searchString = searchString
		self.putValue(Action.NAME, "SearchFor" + searchString)
		self.putValue(Action.SHORT_DESCRIPTION, "Search for " + searchString)
		self.putValue(Action.SMALL_ICON, IconCache.getIcon("python"))

	def actionPerformed(self, event):
		try:
 			destination = browser.getBrowserTree().getFirstSelectedDestinationNode() 
		
			if destination == None:
				browser.showInformationDialog("No queue selected") 
			else:
				hermes = destination.getParent().getHermes()
				task = HermesBrowser.getBrowser().getActionFactory().createStringSeachQueueBrowseAction(hermes, destination.getConfig().getName(), Domain.getDomain(destination.getConfig().getDomain()), self.searchString, 1) 
		except (Throwable), e:
				browser.showInformationDialog(e.getMessage())
			
# Get HermesJMS to create a command (tool) bar, add the action and add the command bar to the GUI

commandBar = browser.getDockableBarManager().getDockableBar("DTCC")

if commandBar == None:
	commandBar = browser.createDockableBar("DTCC")
	browser.getDockableBarManager().addDockableBar(commandBar)

commandBar.add(SearchMessagesAction(browser, "DealExist"))
commandBar.add(SearchMessagesAction(browser, "ErrorMsgName"))

Adaptavist Theme Builder Powered by Atlassian Confluence