Implementing a Defined Function Package Tool

After the definition of this extension a Java class implementing the IToolExecutor interface is created in the plug-in project. Edit this Java class to implement the functionality of your tool.

Find below a sample implementation of the Simple Tool which determines the value of the sole tool attribute and lists the values of all modeled tool parameters:

public class SimpleToolExecutor implements IToolExecutor {

	public SimpleToolExecutor() {
			}

	@Override
	public ToolExecutionStatus execTool(IExecutionContext pContext,
			ToolDescriptor pToolDescriptor, String pAffectedResName,
			IProgressMonitor pMon) throws TaurusToolException {
		// Get a modeled attribute value
		Object attributeValue = pToolDescriptor
				.getDynamicValue("update-allowed.attr");
		if (attributeValue instanceof Boolean) {
			Boolean updateAllowed = (Boolean) attributeValue;
			if (updateAllowed)
				System.out.println("Update is allowed.");
			else
				System.out.println("Update is not allowed.");

		}
		// Print every parameter value into console
		for (RToolInParameter inputParameter : pToolDescriptor.getInputParm()) {
			String parameterValue = ActionExecutor.getParameterValue(
					inputParameter, pContext);
			int sequenceNumber = inputParameter.getSeqNo();
			System.out.println("Input parameter #" + sequenceNumber + ": "
					+ parameterValue);
		}
		// Return OK execution status
		int returnCode = 0;
		return new ToolExecutionStatus(pToolDescriptor.getID(), returnCode);

	}

	@Override
	public IToolOutputReader getOutputReader() {
		// Do nothing
		return null;
	}

	@Override
	public List<String> readParmFile(ISystemImage pImg, String pParmFilePath,
			IProgressMonitor pMon) throws IOException {
		// Do nothing
		return null;
	}

}

The implementation of the new Simple Function Package tool is now complete and will be tested later on.