/** * Removes the corresponding table item from the table and records a command for detaching the * corresponding argument from the model. * * @param itemIndex index of the row which is to be removed. */ private void unbindArgument(int itemIndex) { TableItem item = tblArguments.getItem(itemIndex); ArgumentWrapper wrapper = (ArgumentWrapper) item.getData(); PayloadFactoryArgument argument = wrapper.getArgument(); if (null != argument.eContainer()) { RemoveCommand removeCmd = new RemoveCommand( editingDomain, mediator, EsbPackage.Literals.PAYLOAD_FACTORY_MEDIATOR__ARGS, argument); getResultCommand().append(removeCmd); } tblArguments.remove(tblArguments.indexOf(item)); }
@Override protected void okPressed() { for (TableItem item : tblArguments.getItems()) { ArgumentWrapper wrapper = (ArgumentWrapper) item.getData(); PayloadFactoryArgument argument = wrapper.getArgument(); // If the argument is a new one, add it to the model. if (null == argument.eContainer()) { AddCommand addCmd = new AddCommand( editingDomain, mediator, EsbPackage.Literals.PAYLOAD_FACTORY_MEDIATOR__ARGS, argument); getResultCommand().append(addCmd); } SetCommand setCmd = null; // set argument type if it has been changed i.e expression or value if ((argument.getArgumentType() == PayloadFactoryArgumentType.EXPRESSION) != wrapper.isExpression()) { setCmd = new SetCommand( editingDomain, argument, EsbPackage.Literals.PAYLOAD_FACTORY_ARGUMENT__ARGUMENT_TYPE, wrapper.isExpression() ? PayloadFactoryArgumentType.EXPRESSION : PayloadFactoryArgumentType.VALUE); getResultCommand().append(setCmd); } if (wrapper.isExpression()) { wrapper.setArgumentValue("default"); } else { wrapper.getArgumentExpression().setPropertyValue("/default/expression"); } if (wrapper.isExpression()) { setCmd = new SetCommand( editingDomain, argument, EsbPackage.Literals.PAYLOAD_FACTORY_ARGUMENT__EVALUATOR, wrapper.getEvaluator()); getResultCommand().append(setCmd); } if (!argument.getArgumentExpression().equals(wrapper.getArgumentExpression())) { setCmd = new SetCommand( editingDomain, argument, EsbPackage.Literals.PAYLOAD_FACTORY_ARGUMENT__ARGUMENT_EXPRESSION, wrapper.getArgumentExpression()); getResultCommand().append(setCmd); } if (!argument.getArgumentValue().equals(wrapper.getArgumentValue())) { setCmd = new SetCommand( editingDomain, argument, EsbPackage.Literals.PAYLOAD_FACTORY_ARGUMENT__ARGUMENT_VALUE, wrapper.getArgumentValue()); getResultCommand().append(setCmd); } } // Apply changes. if (getResultCommand().canExecute()) { editingDomain.getCommandStack().execute(getResultCommand()); } super.okPressed(); }