private void OnSave() {
    VmInterfaceModel model = (VmInterfaceModel) getWindow();
    VmNetworkInterface nic =
        model.getIsNew()
            ? new VmNetworkInterface()
            : (VmNetworkInterface) Cloner.clone((VmNetworkInterface) getSelectedItem());

    if (!model.Validate()) {
      return;
    }

    // Save changes.
    nic.setName((String) model.getName().getEntity());
    nic.setNetworkName(((network) model.getNetwork().getSelectedItem()).getname());
    if (model.getNicType().getSelectedItem() == null) {
      nic.setType(null);
    } else {
      nic.setType(((VmInterfaceType) model.getNicType().getSelectedItem()).getValue());
    }
    nic.setMacAddress(
        model.getMAC().getIsChangable()
            ? (model.getMAC().getEntity() == null
                ? null
                : ((String) (model.getMAC().getEntity())).toLowerCase())
            : model.getIsNew() ? "" : nic.getMacAddress());

    if (model.getIsNew()) {
      Frontend.RunMultipleAction(
          VdcActionType.AddVmTemplateInterface,
          new java.util.ArrayList<VdcActionParametersBase>(
              java.util.Arrays.asList(
                  new VdcActionParametersBase[] {
                    new AddVmTemplateInterfaceParameters(getEntityStronglyTyped().getId(), nic)
                  })),
          new IFrontendMultipleActionAsyncCallback() {
            @Override
            public void Executed(FrontendMultipleActionAsyncResult result) {

              Cancel();
            }
          },
          null);
    } else {
      Frontend.RunMultipleAction(
          VdcActionType.UpdateVmTemplateInterface,
          new java.util.ArrayList<VdcActionParametersBase>(
              java.util.Arrays.asList(
                  new VdcActionParametersBase[] {
                    new AddVmTemplateInterfaceParameters(getEntityStronglyTyped().getId(), nic)
                  })),
          new IFrontendMultipleActionAsyncCallback() {
            @Override
            public void Executed(FrontendMultipleActionAsyncResult result) {

              Cancel();
            }
          },
          null);
    }
  }
  private void OnRemove() {
    ConfirmationModel model = (ConfirmationModel) getWindow();

    if (model.getProgress() != null) {
      return;
    }

    java.util.ArrayList<VdcActionParametersBase> list =
        new java.util.ArrayList<VdcActionParametersBase>();
    for (Object item : getSelectedItems()) {
      VmNetworkInterface a = (VmNetworkInterface) item;
      list.add(
          new RemoveVmTemplateInterfaceParameters(getEntityStronglyTyped().getId(), a.getId()));
    }

    model.StartProgress(null);

    Frontend.RunMultipleAction(
        VdcActionType.RemoveVmTemplateInterface,
        list,
        new IFrontendMultipleActionAsyncCallback() {
          @Override
          public void Executed(FrontendMultipleActionAsyncResult result) {

            ConfirmationModel localModel = (ConfirmationModel) result.getState();
            localModel.StopProgress();
            Cancel();
          }
        },
        model);
  }
  @Override
  protected void AsyncSearch() {
    super.AsyncSearch();

    setAsyncResult(
        Frontend.RegisterQuery(
            VdcQueryType.GetTemplateInterfacesByTemplateId,
            new GetVmTemplateParameters(getEntityStronglyTyped().getId())));
    setItems(getAsyncResult().getData());
  }