Before further settings can be made in the Command editor, command class should be created. For this a new Java class has to be created, which implements the interface Command. The interface Command prescribes the method
public Object action(Object[] args, Macro macro)
The method represents the entry point of the command class. The parameter arg0 contains the parameters established in the command editor as Object-Array that conatins the parameter values as String.
The method
public Parameter[] getParameters()
returns a Parameter array, that can be taken in the the list of parameters that of the command editor . For this, the command has to be right clicked in the Navigator view and the menu entry has to be selected.
In addition the method
public String getComment()
should be implemented, wich returns a String to describe the
command.
Example:
package com.odc.eva3.wiz.utils; // Import Section ... public class OpenReportAndCloseCurrentWindow implements SystemCommand { // Gets the Comment String public String getComment() { return null; } // Gets the names for the Parameters public Parameter[] getParameters() { return new Parameter[] { new Parameter("Report frame", String.class, "Report frame to open"), new Parameter("show print menu", Boolean.TYPE, "show print menu")}; } // Executes the Command public Object action(Object[] args, Macro macro) { String reportFrame = (String) args[0]; boolean showPrintMenu = new Boolean((String) args[1]).booleanValue(); try { ReportManager.previewReport(reportFrame, showPrintMenu); EvaUtils.getActiveSWindow().dispose(); Frame frames = Frame.getFrames()[Frame.getFrames().length-1]; frames.toFront(); } catch (Exception ex) { ex.printStackTrace(); } return null; } }
Common used classes and methods, used by a command can be found in the section Examples for Tasks of an Command.
Note: The Java classes of the commands should be stored in a separate folder with the name src. The .command files should be stored outside of this folder.
Note:The Command class must not be in the Default package. It must be in a "named" package:
Example:
package com.odc.eva3.customerservices.actions;