Java Code Examples for ghidra.framework.plugintool.PluginTool#getToolEventNames()

The following examples show how to use ghidra.framework.plugintool.PluginTool#getToolEventNames() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ToolManagerImpl.java    From ghidra with Apache License 2.0 5 votes vote down vote up
@Override
public PluginTool[] getProducerTools() {
	ArrayList<PluginTool> producers = new ArrayList<>(TYPICAL_NUM_TOOLS);
	PluginTool[] runningTools = getRunningTools();
	for (PluginTool tool : runningTools) {
		if (tool.getToolEventNames().length > 0) {
			producers.add(tool);
		}
	}
	PluginTool[] tools = new PluginTool[producers.size()];
	return producers.toArray(tools);
}
 
Example 2
Source File: ToolConnectionPanel.java    From ghidra with Apache License 2.0 5 votes vote down vote up
/**
 * Tool was added to the workspace; update the display.
 * @param tool tool added
 */
void toolAdded(PluginTool tool) {
	String[] consumedEvents = tool.getConsumedToolEventNames();
	String[] producedEvents = tool.getToolEventNames();
	if (consumedEvents.length > 0) {
		consumerModel.addElement(tool);
	}
	if (producedEvents.length > 0) {
		producerModel.addElement(tool);
	}
	validate();
}
 
Example 3
Source File: ConnectToolsTest.java    From ghidra with Apache License 2.0 4 votes vote down vote up
@Test
public void testConnectTools() throws Exception {

	PluginTool producer = new DummyTool("ProducerTool");
	PluginTool consumer = new DummyTool("ConsumerTool");

	ToolConnection tc;
	String eventName = null;
	//
	// TEST 1: connect the tools for both events specified
	//

	ToolManager tm = project.getToolManager();
	//
	// setup the tools to connect
	//
	String[] eventNames = producer.getToolEventNames();
	String[] consumedNames = consumer.getConsumedToolEventNames();
	if (eventNames.length == 0 || consumedNames.length == 0 ||
		(eventName = canConnectTools(eventNames, consumedNames)) == null) {
		Assert.fail("Connect Tools Failed: no event names for connection");
	}

	//
	// connect the tools with good event name
	//
	tc = tm.getConnection(producer, consumer);
	tc.connect(eventName);
	if (!tc.isConnected(eventName)) {
		Assert.fail("Connect Tools Failed: " + producer.getName() + " and " +
			consumer.getName() + " failed to CONNECT for event: " + eventName);
	}

	//
	// connect the tools with a bad event name to make sure they don't connect
	//
	try {
		tc.connect(BAD_EVENT_NAME);
	}
	catch (IllegalArgumentException e) {
		// don't do anything since we expect to get an exception here
	}
	if (tc.isConnected(BAD_EVENT_NAME)) {
		Assert.fail("Connect Tools Failed: " + producer.getName() + " and " +
			consumer.getName() + " conncted for BAD EVENT");
	}

	//
	// TEST 2: now disconnect the tools for a goodEventName, since the framework doesn't
	// do anything for disconnecting tools for events they are not connected by
	//
	tc.disconnect(eventName);
	// verify the tools are now disconnected
	if (tc.isConnected(eventName)) {
		Assert.fail("Connect Tools Failed: " + producer.getName() + " and " +
			consumer.getName() + " failed to DISCONNECT for event: " + eventName);
	}
}