Exemplo n.º 1
0
  @Action
  public Task remove() {
    ConfirmationDialog dialog = module.objectBuilderFactory().newObject(ConfirmationDialog.class);
    dialog.setRemovalMessage(
        i18n.text(
            attachments.getSelectedRows().length > 1
                ? WorkspaceResources.attachments
                : WorkspaceResources.attachment));
    dialogs.showOkCancelHelpDialog(this, dialog, i18n.text(StreamflowResources.confirmation));

    if (dialog.isConfirmed()) {
      final List<AttachmentDTO> removedAttachments = new ArrayList<AttachmentDTO>();
      for (int i : attachments.getSelectedRows()) {
        removedAttachments.add(
            attachmentsModel.getEventList().get(attachments.convertRowIndexToModel(i)));
      }

      return new CommandTask() {
        @Override
        public void command() throws Exception {

          for (AttachmentDTO removedAttachment : removedAttachments) {
            attachmentsModel.removeAttachment(removedAttachment);
          }
        }
      };
    } else return null;
  }
Exemplo n.º 2
0
 @org.jdesktop.application.Action(block = COMPONENT)
 public Task remove() throws IOException, ResourceException {
   ConfirmationDialog dialog = module.objectBuilderFactory().newObject(ConfirmationDialog.class);
   dialog.setRemovalMessage(((ContactDTO) contacts.getSelectedValue()).name().get());
   dialogs.showOkCancelHelpDialog(this, dialog, i18n.text(StreamflowResources.confirmation));
   if (dialog.isConfirmed()) {
     return new CommandTask() {
       @Override
       public void command() throws Exception {
         model.removeElement(getContactsList().getSelectedIndex());
       }
     };
   } else return null;
 }