/** * callback for action events Such events occur, if someone clicked the JCheckBox control, on * which we are registered. Such events do not occur, if we set it programmatically (e.g. if we * get status events to -> see class StatusListener too) * * @param aEvent describes the check box and its state we can use to toogle the requested office * resource. */ public void actionPerformed(ActionEvent aEvent) { synchronized (this) { if (m_xFrame == null) return; } // define parameters for following dispatch boolean bState = ((JCheckBox) aEvent.getSource()).isSelected(); // prepare the dispatch com.sun.star.util.URL aURL = FunctionHelper.parseURL(m_sURL); if (aURL == null) return; com.sun.star.beans.PropertyValue[] lProperties = new com.sun.star.beans.PropertyValue[1]; lProperties[0] = new com.sun.star.beans.PropertyValue(); lProperties[0].Name = m_sProp; lProperties[0].Value = new Boolean(bState); // execute (dispatch) it into the frame if (m_xFrame == null) return; FunctionHelper.execute(m_xFrame, aURL, lProperties, null); }
public static JDefinedClass createFunctionCallbackInterface( Option option, String packageName, String rootDirectoryPathName) { JCodeModel model = new JCodeModel(); JDefinedClass jClass = null; try { String fqn = FunctionHelper.getFunctionCallbackFqn(option, packageName); JClass contextObject = FunctionHelper.getContextObject(option, OutputType.Interface); jClass = model._class(fqn, ClassType.INTERFACE); JMethod method = jClass.method(JMod.NONE, Object.class, EventHelper.ON_PREFIX + "Callback"); if (contextObject != null) method.param( contextObject, option.getContext().substring(0, 1).toLowerCase() + option.getContext().substring(1)); ClassRegistry.INSTANCE .getRegistry() .put(new ClassRegistry.RegistryKey(option, OutputType.Interface), jClass); logger.info("Function callback created;" + option.getTitle()); } catch (JClassAlreadyExistsException e) { throw new RuntimeException(e); } try { model.build(new File(rootDirectoryPathName)); } catch (IOException e) { throw new RuntimeException(e); } return jClass; }
/** * 在参数列表中获取最大值 2014年10月26日 下午11:40:22 ShuiQing PM 添加此方法 * * @param evaluator 表达式执行器 * @param arguments 参数列表 * @return 函数执行结果 * @throws FunctionException */ @SuppressWarnings("unchecked") public FunctionResult execute(Evaluator evaluator, String arguments) throws FunctionException { Double result = 0d; ArrayList<Double> numbers = FunctionHelper.getDoubles(arguments, EvaluationConstants.FUNCTION_ARGUMENT_SEPARATOR); try { for (double num : numbers) { result += num; } } catch (Exception e) { throw new FunctionException("参数列表格式或数量出错!", e); } return new FunctionResult(result.toString(), FunctionConstants.FUNCTION_RESULT_TYPE_NUMERIC); }