summaryrefslogtreecommitdiffstats
path: root/idrop-lite
diff options
context:
space:
mode:
authorLISA STILLWELL <lisa@simon.local>2012-01-11 14:43:57 (GMT)
committer LISA STILLWELL <lisa@simon.local>2012-01-11 14:43:57 (GMT)
commit45c4207629b8ac904639de4c332f8ec52b02a764 (patch)
treeeddecc25d9e2bee13ad5a7921d299681fba35c5e /idrop-lite
parentadac3d9f203547fb85014e66852bba8f54dde1a9 (diff)
downloadQCG-Data-45c4207629b8ac904639de4c332f8ec52b02a764.zip
QCG-Data-45c4207629b8ac904639de4c332f8ec52b02a764.tar.gz
QCG-Data-45c4207629b8ac904639de4c332f8ec52b02a764.tar.bz2
[#550] add new source to support Upload from URL
Diffstat (limited to 'idrop-lite')
-rw-r--r--idrop-lite/src/main/java/org/irods/jargon/idrop/lite/UploadFromURLDialog.java211
1 files changed, 211 insertions, 0 deletions
diff --git a/idrop-lite/src/main/java/org/irods/jargon/idrop/lite/UploadFromURLDialog.java b/idrop-lite/src/main/java/org/irods/jargon/idrop/lite/UploadFromURLDialog.java
new file mode 100644
index 0000000..65e1565
--- /dev/null
+++ b/idrop-lite/src/main/java/org/irods/jargon/idrop/lite/UploadFromURLDialog.java
@@ -0,0 +1,211 @@
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+
+/*
+ * UploadFromURLDialog.java
+ *
+ * Created on Jan 6, 2012, 5:07:00 PM
+ */
+
+package org.irods.jargon.idrop.lite;
+
+import java.awt.Frame;
+import java.io.File;
+import java.io.IOException;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.net.URLConnection;
+
+import javax.swing.BorderFactory;
+import javax.swing.border.Border;
+import javax.swing.table.DefaultTableModel;
+import javax.swing.tree.TreePath;
+
+/**
+ *
+ * @author lisa
+ */
+public class UploadFromURLDialog extends javax.swing.JDialog {
+
+ iDropLiteApplet idropApplet = null;
+
+ /** Creates new form UploadFromURLDialog */
+ public UploadFromURLDialog(final iDropLiteApplet parent, final boolean modal) {
+ //super(parent, modal);
+ super((Frame)null, modal);
+ initComponents();
+ Border empty_border = BorderFactory.createEmptyBorder (0,10,0,10);
+ jPanel1.setBorder(empty_border);
+ idropApplet = parent;
+ }
+
+ /** This method is called from within the constructor to
+ * initialize the form.
+ * WARNING: Do NOT modify this code. The content of this method is
+ * always regenerated by the Form Editor.
+ */
+ @SuppressWarnings("unchecked")
+ // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
+ private void initComponents() {
+
+ jPanel1 = new javax.swing.JPanel();
+ jPanel2 = new javax.swing.JPanel();
+ jLabel1 = new javax.swing.JLabel();
+ jPanel3 = new javax.swing.JPanel();
+ txtUploadFromURL = new javax.swing.JTextField();
+ jPanel4 = new javax.swing.JPanel();
+ jPanel5 = new javax.swing.JPanel();
+ jPanel6 = new javax.swing.JPanel();
+ btnUploadDFromURL_Add = new javax.swing.JButton();
+ btnUploadFromURL_Cancel = new javax.swing.JButton();
+ jPanel7 = new javax.swing.JPanel();
+
+ setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
+ setTitle(org.openide.util.NbBundle.getMessage(UploadFromURLDialog.class, "UploadFromURLDialog.title")); // NOI18N
+
+ jPanel1.setLayout(new java.awt.BorderLayout());
+
+ jPanel2.setPreferredSize(new java.awt.Dimension(495, 50));
+ jPanel2.setLayout(new java.awt.BorderLayout());
+
+ jLabel1.setText(org.openide.util.NbBundle.getMessage(UploadFromURLDialog.class, "UploadFromURLDialog.jLabel1.text")); // NOI18N
+ jPanel2.add(jLabel1, java.awt.BorderLayout.CENTER);
+
+ jPanel1.add(jPanel2, java.awt.BorderLayout.NORTH);
+
+ jPanel3.setPreferredSize(new java.awt.Dimension(495, 40));
+ jPanel3.setLayout(new java.awt.BorderLayout());
+
+ txtUploadFromURL.setText(org.openide.util.NbBundle.getMessage(UploadFromURLDialog.class, "UploadFromURLDialog.txtUploadFromURL.text")); // NOI18N
+ txtUploadFromURL.addActionListener(new java.awt.event.ActionListener() {
+ public void actionPerformed(java.awt.event.ActionEvent evt) {
+ txtUploadFromURLActionPerformed(evt);
+ }
+ });
+ jPanel3.add(txtUploadFromURL, java.awt.BorderLayout.CENTER);
+
+ jPanel1.add(jPanel3, java.awt.BorderLayout.CENTER);
+
+ jPanel4.setPreferredSize(new java.awt.Dimension(495, 30));
+ jPanel4.setLayout(new java.awt.BorderLayout());
+
+ jPanel5.setPreferredSize(new java.awt.Dimension(200, 30));
+
+ org.jdesktop.layout.GroupLayout jPanel5Layout = new org.jdesktop.layout.GroupLayout(jPanel5);
+ jPanel5.setLayout(jPanel5Layout);
+ jPanel5Layout.setHorizontalGroup(
+ jPanel5Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+ .add(0, 200, Short.MAX_VALUE)
+ );
+ jPanel5Layout.setVerticalGroup(
+ jPanel5Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+ .add(0, 30, Short.MAX_VALUE)
+ );
+
+ jPanel4.add(jPanel5, java.awt.BorderLayout.WEST);
+
+ jPanel6.setPreferredSize(new java.awt.Dimension(155, 100));
+ jPanel6.setLayout(new java.awt.BorderLayout());
+
+ btnUploadDFromURL_Add.setFont(new java.awt.Font("Lucida Grande", 0, 12)); // NOI18N
+ btnUploadDFromURL_Add.setText(org.openide.util.NbBundle.getMessage(UploadFromURLDialog.class, "UploadFromURLDialog.btnUploadDFromURL_Add.text")); // NOI18N
+ btnUploadDFromURL_Add.setSize(new java.awt.Dimension(80, 29));
+ btnUploadDFromURL_Add.addActionListener(new java.awt.event.ActionListener() {
+ public void actionPerformed(java.awt.event.ActionEvent evt) {
+ btnUploadDFromURL_AddActionPerformed(evt);
+ }
+ });
+ jPanel6.add(btnUploadDFromURL_Add, java.awt.BorderLayout.WEST);
+
+ btnUploadFromURL_Cancel.setFont(new java.awt.Font("Lucida Grande", 0, 12)); // NOI18N
+ btnUploadFromURL_Cancel.setText(org.openide.util.NbBundle.getMessage(UploadFromURLDialog.class, "UploadFromURLDialog.btnUploadFromURL_Cancel.text")); // NOI18N
+ btnUploadFromURL_Cancel.addActionListener(new java.awt.event.ActionListener() {
+ public void actionPerformed(java.awt.event.ActionEvent evt) {
+ btnUploadFromURL_CancelActionPerformed(evt);
+ }
+ });
+ jPanel6.add(btnUploadFromURL_Cancel, java.awt.BorderLayout.EAST);
+
+ jPanel4.add(jPanel6, java.awt.BorderLayout.EAST);
+
+ jPanel1.add(jPanel4, java.awt.BorderLayout.PAGE_END);
+
+ getContentPane().add(jPanel1, java.awt.BorderLayout.CENTER);
+
+ jPanel7.setPreferredSize(new java.awt.Dimension(495, 5));
+
+ org.jdesktop.layout.GroupLayout jPanel7Layout = new org.jdesktop.layout.GroupLayout(jPanel7);
+ jPanel7.setLayout(jPanel7Layout);
+ jPanel7Layout.setHorizontalGroup(
+ jPanel7Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+ .add(0, 400, Short.MAX_VALUE)
+ );
+ jPanel7Layout.setVerticalGroup(
+ jPanel7Layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+ .add(0, 5, Short.MAX_VALUE)
+ );
+
+ getContentPane().add(jPanel7, java.awt.BorderLayout.PAGE_END);
+
+ pack();
+ }// </editor-fold>//GEN-END:initComponents
+
+ private void txtUploadFromURLActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_txtUploadFromURLActionPerformed
+ // TODO add your handling code here:
+ }//GEN-LAST:event_txtUploadFromURLActionPerformed
+
+ private void btnUploadFromURL_CancelActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnUploadFromURL_CancelActionPerformed
+ this.dispose();
+ }//GEN-LAST:event_btnUploadFromURL_CancelActionPerformed
+
+ private void btnUploadDFromURL_AddActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnUploadDFromURL_AddActionPerformed
+ URL url = null;
+ String urlName = null;
+ URLConnection connection = null;
+ int fileSize = 0;
+
+ urlName = txtUploadFromURL.getText();
+
+ if(urlName != null) {
+ try {
+ url = new URL(urlName);
+ connection = url.openConnection();
+ fileSize = connection.getContentLength();
+ } catch (MalformedURLException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ } catch (IOException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+
+ DefaultTableModel tm = idropApplet.getiDropCore().getUploadTableModel();
+ Object [] rowData = new Object[5];
+ rowData[0] = urlName;
+ rowData[1] = 0;
+ rowData[2] = new TransferProgressInfo();
+ rowData[3] = Boolean.TRUE;
+ rowData[4] = iDropLiteApplet.uploadURL; // treat this as a file
+ tm.addRow(rowData);
+ }
+ this.dispose();
+ }//GEN-LAST:event_btnUploadDFromURL_AddActionPerformed
+
+
+ // Variables declaration - do not modify//GEN-BEGIN:variables
+ private javax.swing.JButton btnUploadDFromURL_Add;
+ private javax.swing.JButton btnUploadFromURL_Cancel;
+ private javax.swing.JLabel jLabel1;
+ private javax.swing.JPanel jPanel1;
+ private javax.swing.JPanel jPanel2;
+ private javax.swing.JPanel jPanel3;
+ private javax.swing.JPanel jPanel4;
+ private javax.swing.JPanel jPanel5;
+ private javax.swing.JPanel jPanel6;
+ private javax.swing.JPanel jPanel7;
+ private javax.swing.JTextField txtUploadFromURL;
+ // End of variables declaration//GEN-END:variables
+
+}