View Javadoc

1   package org.lsst.ccs.plugin.jas3.elog;
2   
3   /**
4    *
5    * @author turri
6    */
7   public class LsstElogAttachment extends javax.swing.JPanel {
8   
9       private boolean isImage;
10      private String name;
11      private LsstElogSubmissionDialog dialog;
12      
13      /**
14       * Creates new form LsstElogAttachment
15       */
16      public LsstElogAttachment() {
17          initComponents();        
18      }
19  
20      public LsstElogAttachment(String name, boolean isImage, LsstElogSubmissionDialog dialog) {
21          this();
22          this.isImage = isImage;
23          String type = isImage ? "image" : "file";
24          attachmentName.setText(name);
25          attachmentType.setText(type);
26          this.name = name;
27          this.dialog = dialog;
28      }
29  
30      public boolean isImage() {
31          return isImage;
32      }
33      
34      public String getFileName() {
35          return name;
36      }
37      
38      
39      
40      /**
41       * This method is called from within the constructor to initialize the form.
42       * WARNING: Do NOT modify this code. The content of this method is always
43       * regenerated by the Form Editor.
44       */
45      @SuppressWarnings("unchecked")
46      // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
47      private void initComponents() {
48  
49          attachmentName = new javax.swing.JLabel();
50          attachmentType = new javax.swing.JLabel();
51          removeButton = new javax.swing.JButton();
52  
53          attachmentName.setText("jLabel1");
54  
55          attachmentType.setText("jLabel1");
56  
57          removeButton.setText("Remove");
58          removeButton.addActionListener(new java.awt.event.ActionListener() {
59              public void actionPerformed(java.awt.event.ActionEvent evt) {
60                  removeButtonActionPerformed(evt);
61              }
62          });
63  
64          javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
65          this.setLayout(layout);
66          layout.setHorizontalGroup(
67              layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
68              .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
69                  .addContainerGap()
70                  .addComponent(attachmentName)
71                  .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 213, Short.MAX_VALUE)
72                  .addComponent(attachmentType)
73                  .addGap(10, 10, 10)
74                  .addComponent(removeButton))
75          );
76          layout.setVerticalGroup(
77              layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
78              .addGroup(layout.createSequentialGroup()
79                  .addGap(0, 0, Short.MAX_VALUE)
80                  .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
81                      .addComponent(attachmentName)
82                      .addComponent(attachmentType)
83                      .addComponent(removeButton))
84                  .addGap(0, 0, Short.MAX_VALUE))
85          );
86      }// </editor-fold>//GEN-END:initComponents
87  
88      private void removeButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_removeButtonActionPerformed
89          dialog.removeAttachment(this);
90      }//GEN-LAST:event_removeButtonActionPerformed
91  
92      // Variables declaration - do not modify//GEN-BEGIN:variables
93      private javax.swing.JLabel attachmentName;
94      private javax.swing.JLabel attachmentType;
95      private javax.swing.JButton removeButton;
96      // End of variables declaration//GEN-END:variables
97  }