Package org.trzcinka.intellitrac.dto

Examples of org.trzcinka.intellitrac.dto.Attachment


    List<Attachment> result = new ArrayList<Attachment>();
    try {
      Object response = retrieveClient().execute("ticket.listAttachments", new Object[]{ticketId});
      Object[] array = (Object[]) response;
      for (Object o : array) {
        Attachment attachment = new AttachmentAdapter(o);
        result.add(attachment);
      }
    } catch (XmlRpcException e) {
      handleException(e);
    }
View Full Code Here


        dialog.dispose();
      }
    });
    downloadButton.addActionListener(new ActionListener() {
      public void actionPerformed(ActionEvent e) {
        Attachment attachment = (Attachment) attachmentsList.getSelectedValue();
        OutputStream stream = null;
        if (attachment != null) {
          try {
            byte[] body = gateway.retrieveAttachment(ticketsModel.getCurrentTicketModel().getCurrentTicket().getId(), attachment.getFileName());
            JFileChooser fc = new JFileChooser();
            File dir = fc.getCurrentDirectory();
            fc.setSelectedFile(new File(dir, attachment.getFileName()));
            int save = fc.showSaveDialog(rootComponent);

            if (save == JFileChooser.APPROVE_OPTION) {
              File file = fc.getSelectedFile();
              stream = new FileOutputStream(file);
              IOUtils.write(body, stream);
            }
          } catch (ConnectionFailedException e1) {
            TracGatewayLocator.handleConnectionProblem();
          } catch (IOException e1) {
            logger.error("Could not save file", e1);
          } finally {
            IOUtils.closeQuietly(stream);
          }
        }
      }
    });
    showDescriptionButton.addActionListener(new ActionListener() {
      public void actionPerformed(ActionEvent e) {
        Attachment attachment = (Attachment) attachmentsList.getSelectedValue();
        if (attachment != null) {
          JOptionPane popup = new AttachmentDescriptionPopup(attachment.getDescription());
          JDialog dialog = popup.createDialog(null, MessageFormat.format(bundle.getString("tool_window.tickets.ticket_editor.attachments.popup_title"), attachment.getFileName()));
          dialog.setVisible(true);
          dialog.dispose();
        }
      }
    });
    attachmentsList.addListSelectionListener(new ListSelectionListener() {
      public void valueChanged(ListSelectionEvent e) {
        Attachment selected = (Attachment) attachmentsList.getSelectedValue();
        if (selected == null) {
          downloadButton.setEnabled(false);
          showDescriptionButton.setEnabled(false);
        } else {
          downloadButton.setEnabled(true);
          if (!(StringUtils.isEmpty(selected.getDescription()))) {
            showDescriptionButton.setEnabled(true);
          }
        }
      }
    });
View Full Code Here

  public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {

    if (!(value instanceof Attachment)) {
      throw new IllegalArgumentException("AttachmentsListCellRenderer may render only Attachments, not " + value.getClass().getName());
    }
    Attachment attachment = (Attachment) value;

    final JPanel panel = new JPanel(new FlowLayout(FlowLayout.LEFT));
    ListCellRendererUtils.applyDefaultDisplaySettings(list, index, isSelected, cellHasFocus, panel);

    JLabel fileName = new JLabel(attachment.getFileName());
    fileName.setForeground(panel.getForeground());
    panel.add(fileName);

    String additionalTextString = MessageFormat.format(BundleLocator.getBundle().getString("tool_window.tickets.ticket_editor.attachments.attachment_info"), FileUtils.byteCountToDisplaySize(attachment.getSize()), attachment.getAuthor());
    JLabel additionalText = new JLabel(additionalTextString);
    additionalText.setForeground(panel.getForeground());
    panel.add(additionalText);

    return panel;
View Full Code Here

TOP

Related Classes of org.trzcinka.intellitrac.dto.Attachment

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.