You can subscribe to this list here.
| 2006 |
Jan
|
Feb
|
Mar
|
Apr
(39) |
May
(165) |
Jun
(164) |
Jul
(127) |
Aug
(81) |
Sep
(146) |
Oct
(375) |
Nov
(241) |
Dec
(77) |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2007 |
Jan
(42) |
Feb
(38) |
Mar
(30) |
Apr
(6) |
May
(17) |
Jun
|
Jul
(15) |
Aug
(59) |
Sep
(31) |
Oct
(44) |
Nov
(30) |
Dec
(12) |
| 2008 |
Jan
(9) |
Feb
(63) |
Mar
(18) |
Apr
(43) |
May
(28) |
Jun
(32) |
Jul
(61) |
Aug
(5) |
Sep
(72) |
Oct
(48) |
Nov
(6) |
Dec
|
|
From: <li...@us...> - 2008-07-22 05:28:20
|
Revision: 2081
http://cogkit.svn.sourceforge.net/cogkit/?rev=2081&view=rev
Author: liuwt
Date: 2008-07-22 05:28:18 +0000 (Tue, 22 Jul 2008)
Log Message:
-----------
Added Paths:
-----------
trunk/current/src/cog/modules/transfer-gui/src/org/globus/transfer/reliable/client/credential/
trunk/current/src/cog/modules/transfer-gui/src/org/globus/transfer/reliable/client/credential/CredentialDialog.java
Added: trunk/current/src/cog/modules/transfer-gui/src/org/globus/transfer/reliable/client/credential/CredentialDialog.java
===================================================================
--- trunk/current/src/cog/modules/transfer-gui/src/org/globus/transfer/reliable/client/credential/CredentialDialog.java (rev 0)
+++ trunk/current/src/cog/modules/transfer-gui/src/org/globus/transfer/reliable/client/credential/CredentialDialog.java 2008-07-22 05:28:18 UTC (rev 2081)
@@ -0,0 +1,117 @@
+package org.globus.transfer.reliable.client.credential;
+
+import org.globus.tools.proxy.GridProxyInit;
+import org.globus.transfer.reliable.client.credential.myproxy.MyProxyLogonGUI;
+
+public class CredentialDialog extends javax.swing.JDialog {
+
+ /** Creates new form CredentialDialog */
+ public CredentialDialog(java.awt.Frame parent, boolean modal) {
+ super(parent, modal);
+ initComponents();
+ }
+
+ /** 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.
+ */
+ // <editor-fold defaultstate="collapsed" desc="Generated Code">
+ private void initComponents() {
+
+ jLabel1 = new javax.swing.JLabel();
+ generate_proxy = new javax.swing.JButton();
+ jLabel2 = new javax.swing.JLabel();
+ Myproxy = new javax.swing.JButton();
+
+ setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
+ setTitle("Credential");
+
+ jLabel1.setText("If you want to generate a proxy certificate on your local \nmachine, please select this");
+
+ generate_proxy.setText("generate");
+ generate_proxy.addActionListener(new java.awt.event.ActionListener() {
+ public void actionPerformed(java.awt.event.ActionEvent evt) {
+ generate_proxyActionPerformed(evt);
+ }
+ });
+
+ jLabel2.setText("If you want to get a proxy certificate from MyPorxy, please select this");
+
+ Myproxy.setText("Myproxy");
+ Myproxy.addActionListener(new java.awt.event.ActionListener() {
+ public void actionPerformed(java.awt.event.ActionEvent evt) {
+ MyproxyActionPerformed(evt);
+ }
+ });
+
+ org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(getContentPane());
+ getContentPane().setLayout(layout);
+ layout.setHorizontalGroup(
+ layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+ .add(layout.createSequentialGroup()
+ .addContainerGap()
+ .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+ .add(jLabel2, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 474, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
+ .add(jLabel1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 484, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
+ .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
+ .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+ .add(generate_proxy)
+ .add(Myproxy))
+ .addContainerGap(47, Short.MAX_VALUE))
+ );
+ layout.setVerticalGroup(
+ layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+ .add(layout.createSequentialGroup()
+ .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
+ .add(jLabel1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 32, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
+ .add(generate_proxy))
+ .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
+ .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
+ .add(jLabel2)
+ .add(Myproxy))
+ .addContainerGap(81, Short.MAX_VALUE))
+ );
+
+ pack();
+ }// </editor-fold>
+
+ private void generate_proxyActionPerformed(java.awt.event.ActionEvent evt) {
+ GridProxyInit proxyInitFrame = new GridProxyInit(null, true);
+ proxyInitFrame.setRunAsApplication(false);
+ proxyInitFrame.setCloseOnSuccess(true);
+ proxyInitFrame.setLocation(50, 50);
+ proxyInitFrame.pack();
+ //UITools.center(mainPanel, proxyInitFrame);
+ proxyInitFrame.setVisible(true);
+ }
+
+ private void MyproxyActionPerformed(java.awt.event.ActionEvent evt) {
+ MyProxyLogonGUI.main(null);
+ }
+
+ /**
+ * @param args the command line arguments
+ */
+ public static void main(String args[]) {
+ java.awt.EventQueue.invokeLater(new Runnable() {
+ public void run() {
+ CredentialDialog dialog = new CredentialDialog(new javax.swing.JFrame(), true);
+ dialog.addWindowListener(new java.awt.event.WindowAdapter() {
+ public void windowClosing(java.awt.event.WindowEvent e) {
+ System.exit(0);
+ }
+ });
+ dialog.setVisible(true);
+ }
+ });
+ }
+
+ // Variables declaration - do not modify
+ private javax.swing.JButton Myproxy;
+ private javax.swing.JButton generate_proxy;
+ private javax.swing.JLabel jLabel1;
+ private javax.swing.JLabel jLabel2;
+ // End of variables declaration
+
+}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <li...@us...> - 2008-07-22 05:28:14
|
Revision: 2080
http://cogkit.svn.sourceforge.net/cogkit/?rev=2080&view=rev
Author: liuwt
Date: 2008-07-22 05:28:11 +0000 (Tue, 22 Jul 2008)
Log Message:
-----------
Modified Paths:
--------------
trunk/current/src/cog/modules/transfer-gui/src/org/globus/transfer/reliable/client/BaseRFTClient.java
trunk/current/src/cog/modules/transfer-gui/src/org/globus/transfer/reliable/client/GridFTPGUIView.java
trunk/current/src/cog/modules/transfer-gui/src/org/globus/transfer/reliable/client/RFTButtonActionListener.java
trunk/current/src/cog/modules/transfer-gui/src/org/globus/transfer/reliable/client/RFTClient.java
trunk/current/src/cog/modules/transfer-gui/src/org/globus/transfer/reliable/client/RFTOptions.java
trunk/current/src/cog/modules/transfer-gui/src/org/globus/transfer/reliable/client/RFTOptionsPanel.java
trunk/current/src/cog/modules/transfer-gui/src/org/globus/transfer/reliable/client/RFTPanel.java
trunk/current/src/cog/modules/transfer-gui/src/org/globus/transfer/reliable/client/RFTTransferFileParser.java
trunk/current/src/cog/modules/transfer-gui/src/org/globus/transfer/reliable/client/RFTTransferParam.java
trunk/current/src/cog/modules/transfer-gui/src/org/globus/transfer/reliable/client/RFTTransferParamPanel.java
Modified: trunk/current/src/cog/modules/transfer-gui/src/org/globus/transfer/reliable/client/BaseRFTClient.java
===================================================================
--- trunk/current/src/cog/modules/transfer-gui/src/org/globus/transfer/reliable/client/BaseRFTClient.java 2008-07-22 05:27:57 UTC (rev 2079)
+++ trunk/current/src/cog/modules/transfer-gui/src/org/globus/transfer/reliable/client/BaseRFTClient.java 2008-07-22 05:28:11 UTC (rev 2080)
@@ -289,7 +289,10 @@
ClientSecurityDescriptor desc = getClientSecDesc();
// Credential to sign with, assuming default credential
GlobusCredential credential = GlobusCredential.getDefaultCredential();
-
+ //desc.setGSITransport(Constants.GSI_TRANSPORT);
+ //desc.setAuthz(AuthUtil.getClientAuthorization("self"));
+
+
String factoryUrl = PROTOCOL + "://" + host + ":"
+ port + SERVICE_URL_ROOT
+ DelegationConstants.FACTORY_PATH;
Modified: trunk/current/src/cog/modules/transfer-gui/src/org/globus/transfer/reliable/client/GridFTPGUIView.java
===================================================================
--- trunk/current/src/cog/modules/transfer-gui/src/org/globus/transfer/reliable/client/GridFTPGUIView.java 2008-07-22 05:27:57 UTC (rev 2079)
+++ trunk/current/src/cog/modules/transfer-gui/src/org/globus/transfer/reliable/client/GridFTPGUIView.java 2008-07-22 05:28:11 UTC (rev 2080)
@@ -44,9 +44,11 @@
import org.globus.tools.proxy.GridProxyInit;
import org.globus.tools.ui.util.CustomFileFilter;
import org.globus.tools.ui.util.UITools;
-import org.globus.transfer.reliable.client.myproxy.MyProxyLogonGUI;
+import org.globus.transfer.reliable.client.credential.CredentialDialog;
+import org.globus.transfer.reliable.client.credential.myproxy.MyProxyLogonGUI;
import org.globus.transfer.reliable.client.utils.LogFileUtils;
import org.globus.transfer.reliable.client.utils.UIConstants;
+import org.globus.transfer.reliable.client.utils.Utils;
import org.globus.util.ConfigUtil;
import org.globus.util.Util;
@@ -139,10 +141,11 @@
mainPanel = new javax.swing.JPanel();
jToolBar1 = new javax.swing.JToolBar();
+ credential_button = new javax.swing.JButton();
jButton1 = new javax.swing.JButton();
- jButton2 = new javax.swing.JButton();
+ gridftp_button = new javax.swing.JButton();
jButton4 = new javax.swing.JButton();
- jButton3 = new javax.swing.JButton();
+ local_button = new javax.swing.JButton();
jButton5 = new javax.swing.JButton();
jButton7 = new javax.swing.JButton();
jButton8 = new javax.swing.JButton();
@@ -179,6 +182,22 @@
jToolBar1.setName("jToolBar1"); // NOI18N
org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application.getInstance(org.globus.transfer.reliable.client.GridFTPGUIApp.class).getContext().getResourceMap(GridFTPGUIView.class);
+
+ credential_button.setIcon(resourceMap.getIcon("jButton1.icon")); // NOI18N
+ credential_button.setText(resourceMap.getString("credential_button.text")); // NOI18N
+ credential_button.setToolTipText(resourceMap.getString("credential_button.toolTipText")); // NOI18N
+ credential_button.setFocusable(false);
+ credential_button.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
+ credential_button.setName("credential_button"); // NOI18N
+ credential_button.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
+ credential_button.addActionListener(new java.awt.event.ActionListener() {
+ public void actionPerformed(java.awt.event.ActionEvent evt) {
+ credential_buttonActionPerformed(evt);
+ }
+ });
+ jToolBar1.add(credential_button);
+
+
jButton1.setIcon(resourceMap.getIcon("jButton1.icon")); // NOI18N
jButton1.setText(resourceMap.getString("jButton1.text")); // NOI18N
jButton1.setToolTipText(resourceMap.getString("jButton1.toolTipText")); // NOI18N
@@ -191,21 +210,21 @@
jButton1ActionPerformed(evt);
}
});
- jToolBar1.add(jButton1);
+ //jToolBar1.add(jButton1);
- jButton2.setIcon(resourceMap.getIcon("jButton2.icon")); // NOI18N
- jButton2.setText(resourceMap.getString("jButton2.text")); // NOI18N
- jButton2.setToolTipText(resourceMap.getString("jButton2.toolTipText")); // NOI18N
- jButton2.setFocusable(false);
- jButton2.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
- jButton2.setName("jButton2"); // NOI18N
- jButton2.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
- jButton2.addActionListener(new java.awt.event.ActionListener() {
+ gridftp_button.setIcon(resourceMap.getIcon("gridftp_button.icon")); // NOI18N
+ gridftp_button.setText(resourceMap.getString("gridftp_button.text")); // NOI18N
+ gridftp_button.setToolTipText(resourceMap.getString("gridftp_button.toolTipText")); // NOI18N
+ gridftp_button.setFocusable(false);
+ gridftp_button.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
+ gridftp_button.setName("gridftp_button"); // NOI18N
+ gridftp_button.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
+ gridftp_button.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
- jButton2ActionPerformed(evt);
+ gridftp_buttonActionPerformed(evt);
}
});
- jToolBar1.add(jButton2);
+ jToolBar1.add(gridftp_button);
jButton4.setIcon(resourceMap.getIcon("jButton4.icon")); // NOI18N
jButton4.setText(resourceMap.getString("jButton4.text")); // NOI18N
@@ -220,18 +239,18 @@
});
//jToolBar1.add(jButton4);
- jButton3.setIcon(resourceMap.getIcon("jButton3.icon")); // NOI18N
- jButton3.setText(resourceMap.getString("jButton3.text")); // NOI18N
- jButton3.setFocusable(false);
- jButton3.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
- jButton3.setName("jButton3"); // NOI18N
- jButton3.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
- jButton3.addActionListener(new java.awt.event.ActionListener() {
+ local_button.setIcon(resourceMap.getIcon("local_button.icon")); // NOI18N
+ local_button.setText(resourceMap.getString("local_button.text")); // NOI18N
+ local_button.setFocusable(false);
+ local_button.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
+ local_button.setName("local_button"); // NOI18N
+ local_button.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
+ local_button.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
- jButton3ActionPerformed(evt);
+ local_buttonActionPerformed(evt);
}
});
- jToolBar1.add(jButton3);
+ jToolBar1.add(local_button);
jButton5.setIcon(resourceMap.getIcon("jButton5.icon")); // NOI18N
jButton5.setText(resourceMap.getString("jButton5.text")); // NOI18N
@@ -257,7 +276,7 @@
jButton7ActionPerformed(evt);
}
});
- jToolBar1.add(jButton7);
+ //jToolBar1.add(jButton7);
jButton8.setIcon(resourceMap.getIcon("jButton8.icon")); // NOI18N
jButton8.setText(resourceMap.getString("jButton8.text")); // NOI18N
@@ -346,32 +365,32 @@
});
jMenu1.add(jMenuItem1);
- jMenuItem8.setText(resourceMap.getString("jMenuItem8.text")); // NOI18N
- jMenuItem8.setName("jMenuItem8"); // NOI18N
- jMenuItem8.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(java.awt.event.ActionEvent evt) {
- jMenuItem8ActionPerformed(evt);
- }
- });
- jMenu1.add(jMenuItem8);
+// jMenuItem8.setText(resourceMap.getString("jMenuItem8.text")); // NOI18N
+// jMenuItem8.setName("jMenuItem8"); // NOI18N
+// jMenuItem8.addActionListener(new java.awt.event.ActionListener() {
+// public void actionPerformed(java.awt.event.ActionEvent evt) {
+// jMenuItem8ActionPerformed(evt);
+// }
+// });
+// jMenu1.add(jMenuItem8);
- jMenuItem9.setText(resourceMap.getString("jMenuItem9.text")); // NOI18N
- jMenuItem9.setName("jMenuItem9"); // NOI18N
- jMenuItem9.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(java.awt.event.ActionEvent evt) {
- jMenuItem9ActionPerformed(evt);
- }
- });
- jMenu1.add(jMenuItem9);
-
- jMenuItem10.setText(resourceMap.getString("jMenuItem10.text")); // NOI18N
- jMenuItem10.setName("jMenuItem10"); // NOI18N
- jMenuItem10.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(java.awt.event.ActionEvent evt) {
- jMenuItem10ActionPerformed(evt);
- }
- });
- jMenu1.add(jMenuItem10);
+// jMenuItem9.setText(resourceMap.getString("jMenuItem9.text")); // NOI18N
+// jMenuItem9.setName("jMenuItem9"); // NOI18N
+// jMenuItem9.addActionListener(new java.awt.event.ActionListener() {
+// public void actionPerformed(java.awt.event.ActionEvent evt) {
+// jMenuItem9ActionPerformed(evt);
+// }
+// });
+// jMenu1.add(jMenuItem9);
+//
+// jMenuItem10.setText(resourceMap.getString("jMenuItem10.text")); // NOI18N
+// jMenuItem10.setName("jMenuItem10"); // NOI18N
+// jMenuItem10.addActionListener(new java.awt.event.ActionListener() {
+// public void actionPerformed(java.awt.event.ActionEvent evt) {
+// jMenuItem10ActionPerformed(evt);
+// }
+// });
+// jMenu1.add(jMenuItem10);
jMenuItem2.setText(resourceMap.getString("jMenuItem2.text")); // NOI18N
jMenuItem2.setName("jMenuItem2"); // NOI18N
@@ -494,9 +513,15 @@
setStatusBar(statusPanel);
}// </editor-fold>//GEN-END:initComponents
- private void jMenuItem2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem2ActionPerformed
- System.out.println("aaaaaaa");
- fileTransferMainPanel1.createNewLocalFrame();
+ protected void credential_buttonActionPerformed(ActionEvent evt) {
+ CredentialDialog d = new CredentialDialog(null, false);
+ d.setLocation(100, 100);
+ d.setVisible(true);
+
+ }
+
+ private void jMenuItem2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem2ActionPerformed
+ localFrameHandle();
}//GEN-LAST:event_jMenuItem2ActionPerformed
private void jMenu1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenu1ActionPerformed
@@ -616,8 +641,18 @@
}
}//GEN-LAST:event_jMenuItem7ActionPerformed
- private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton3ActionPerformed
- fileTransferMainPanel1.createNewLocalFrame();
+ private void localFrameHandle() {
+ boolean isRFTEnabled = (new Boolean((String)Utils.getProperty("rft_enabled", "rft.properties"))).booleanValue();
+ if (isRFTEnabled) {
+ JOptionPane.showMessageDialog(null, "RFT is enabled, you can not use local dialog",
+ "Message", JOptionPane.ERROR_MESSAGE);
+ } else {
+ fileTransferMainPanel1.createNewLocalFrame();
+ }
+ }
+ private void local_buttonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton3ActionPerformed
+ localFrameHandle();
+
}//GEN-LAST:event_jButton3ActionPerformed
private void jButton5ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton3ActionPerformed
@@ -649,7 +684,7 @@
}//GEN-LAST:event_jButton3ActionPerformed
- private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
+ private void gridftp_buttonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed
fileTransferMainPanel1.createRemoteFrame(1, null, 2811);
}//GEN-LAST:event_jButton2ActionPerformed
@@ -667,10 +702,13 @@
}//GEN-LAST:event_jMenuItem9ActionPerformed
private void jMenuItem10ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem9ActionPerformed
- JFrame frame = new JFrame("RFT GUI Client");
+ JFrame frame = new JFrame("Advanced Options");
RFTPanel rftPanel = new RFTPanel();
+ rftPanel.setFrame(frame);
frame.getContentPane().add(rftPanel);
- frame.pack();
+ frame.setSize(500, 500);
+ frame.setLocation(100, 100);
+ //frame.pack();
frame.setVisible(true);
}//GEN-LAST:event_jMenuItem9ActionPerformed
@@ -896,13 +934,14 @@
private FileTransferMainPanel fileTransferMainPanel1 = new FileTransferMainPanel();
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JButton jButton1;
- private javax.swing.JButton jButton2;
- private javax.swing.JButton jButton3;
+ private javax.swing.JButton gridftp_button;
+ private javax.swing.JButton local_button;
private javax.swing.JButton jButton4;
private javax.swing.JButton jButton5;
private javax.swing.JButton jButton6;
private javax.swing.JButton jButton7;
private javax.swing.JButton jButton8;
+ private javax.swing.JButton credential_button;
private javax.swing.JDesktopPane jDesktopPane1;
private javax.swing.JMenu jMenu1;
private javax.swing.JMenu jMenu2;
Modified: trunk/current/src/cog/modules/transfer-gui/src/org/globus/transfer/reliable/client/RFTButtonActionListener.java
===================================================================
--- trunk/current/src/cog/modules/transfer-gui/src/org/globus/transfer/reliable/client/RFTButtonActionListener.java 2008-07-22 05:27:57 UTC (rev 2079)
+++ trunk/current/src/cog/modules/transfer-gui/src/org/globus/transfer/reliable/client/RFTButtonActionListener.java 2008-07-22 05:28:11 UTC (rev 2080)
@@ -15,8 +15,7 @@
public class RFTButtonActionListener {
private QueuePanel queuePanel = null;
private RFTClient rftClient = null;
- private RFTPanel panel = null;
- private static int transferID = 1;
+ private RFTPanel panel = null;
public RFTButtonActionListener(RFTPanel panel) {
this.panel = panel;
@@ -35,9 +34,8 @@
RFTTransferParam param = job.getParam();
TransferType transfer = param.getTransfers1()[0];
- String[] cols = {Integer.toString(job.getJobID()), Integer.toString(transferID++),
- Integer.toString(1), transfer.getSourceUrl(), transfer.getDestinationUrl(),
- "started", "0", "No errors"};
+ String[] cols = {Integer.toString(job.getJobID()), transfer.getSourceUrl(),
+ transfer.getDestinationUrl(), "started", "0", "No errors"};
queuePanel.addTransfer(cols);
rftClient.startTransfer(job);
}
@@ -48,12 +46,12 @@
*/
public void stopButtonAction(String jobID) throws Exception {
- int selectedRowIndex = queuePanel.getRowIndex(jobID, 1);
+ int selectedRowIndex = queuePanel.getRowIndex(jobID, 0);
String id = queuePanel.getColumnValue(selectedRowIndex, 0);
rftClient.stopTransfer(id);
- queuePanel.setColumnValue(selectedRowIndex, 5, "Cancelled");
- queuePanel.setColumnValue(selectedRowIndex, 6, "0");
- queuePanel.setColumnValue(selectedRowIndex, 7, "No errors");
+ queuePanel.setColumnValue(selectedRowIndex, 3, "Cancelled");
+ queuePanel.setColumnValue(selectedRowIndex, 4, "0");
+ queuePanel.setColumnValue(selectedRowIndex, 5, "No errors");
}
public void loadFileButtonAction(RFTJob job, QueuePanel queuePanel) throws Exception {
@@ -61,8 +59,8 @@
TransferType[] transfers = param.getTransfers1();
for (int i = 0; i < transfers.length; i++) {
- String[] cols = {Integer.toString(job.getJobID()), Integer.toString(transferID++),
- Integer.toString(i+1), transfers[i].getSourceUrl(),
+ String[] cols = {Integer.toString(job.getJobID()),
+ transfers[i].getSourceUrl(),
transfers[i].getDestinationUrl(), "started", "0", "No errors"};
queuePanel.addTransfer(cols);
}
@@ -81,8 +79,8 @@
* @param Pending
* @param cancelled
*/
- public void updateOverallStatus(int finished, int active, int failed,
- int retrying, int pending, int cancelled) {
- panel.updateOverallStatus(finished, active, failed, retrying, pending, cancelled);
- }
+// public void updateOverallStatus(int finished, int active, int failed,
+// int retrying, int pending, int cancelled) {
+// panel.updateOverallStatus(finished, active, failed, retrying, pending, cancelled);
+// }
}
Modified: trunk/current/src/cog/modules/transfer-gui/src/org/globus/transfer/reliable/client/RFTClient.java
===================================================================
--- trunk/current/src/cog/modules/transfer-gui/src/org/globus/transfer/reliable/client/RFTClient.java 2008-07-22 05:27:57 UTC (rev 2079)
+++ trunk/current/src/cog/modules/transfer-gui/src/org/globus/transfer/reliable/client/RFTClient.java 2008-07-22 05:28:11 UTC (rev 2080)
@@ -6,6 +6,7 @@
package org.globus.transfer.reliable.client;
+import java.io.FileWriter;
import java.rmi.RemoteException;
import java.util.Calendar;
import java.util.HashMap;
@@ -42,6 +43,7 @@
import org.globus.wsrf.WSNConstants;
import org.globus.wsrf.container.ServiceContainer;
import org.globus.wsrf.core.notification.ResourcePropertyValueChangeNotificationElementType;
+import org.globus.wsrf.encoding.ObjectSerializer;
import org.globus.wsrf.impl.security.authorization.Authorization;
import org.globus.wsrf.impl.security.authorization.HostAuthorization;
import org.globus.wsrf.impl.security.authorization.ResourcePDPConfig;
@@ -69,6 +71,11 @@
private QueuePanel queuePanel = null;
private RFTButtonActionListener listener = null;
private TransferStatusReporter reporter = null;
+
+ public RFTClient() {
+ super();
+ }
+
public RFTClient(RFTButtonActionListener listener, QueuePanel queuePanel) {
super();
this.listener = listener;
@@ -77,6 +84,7 @@
new TransferStatusReporter().start();
}
+
/**
* Generate RFT transfer request
* @param options RFT options
@@ -88,10 +96,10 @@
//set RFT options
RFTOptionsType rftOptions = new RFTOptionsType();
- rftOptions.setBinary(options.isBinary());
- rftOptions.setBlockSize(options.getBlockSize());
- rftOptions.setDcau(options.isDcau());
- rftOptions.setNotpt(options.isNotpt());
+// rftOptions.setBinary(options.isBinary());
+// rftOptions.setBlockSize(options.getBlockSize());
+// rftOptions.setDcau(options.isDcau());
+// rftOptions.setNotpt(options.isNotpt());
rftOptions.setParallelStreams(options.getParallelStream());
rftOptions.setTcpBufferSize(options.getTcpBufferSize());
@@ -107,9 +115,9 @@
TransferRequestType request = new TransferRequestType();
request.setRftOptions(rftOptions);
request.setTransfer(rftParam.getTransfers1());
- request.setAllOrNone(options.isAllOrNone());
+ //request.setAllOrNone(options.isAllOrNone());
request.setConcurrency(options.getConcurrent());
- request.setMaxAttempts(options.getMaxAttampts());
+ //request.setMaxAttempts(options.getMaxAttampts());
request.setTransferCredentialEndpoint(epr);
return request;
@@ -130,8 +138,8 @@
throw new IllegalArgumentException(UIConstants.ILLEGAL_HOST);
}
String port = rftParam.getServerPort();
- String authType = rftParam.getAuthType();
- String authzType = rftParam.getAuthzType();
+// String authType = rftParam.getAuthType();
+// String authzType = rftParam.getAuthzType();
if (null == port) {
if (authType.equals(GSIConstants.GSI_TRANSPORT)) {
port = "8443";
@@ -152,12 +160,26 @@
EndpointReferenceType credEPR = delegateCredential(host, port);
TransferRequestType transferType = getTransferRequestType(options, rftParam, credEPR);
EndpointReferenceType rftepr = createRFT(rftFactoryAddress, transferType);
+
rftepr.setAddress(new Address(rftServiceAddress));
ReliableFileTransferPortType rft = rftLocator
.getReliableFileTransferPortTypePort(rftepr);
- setAuthzValue(authzType);
+ //setAuthzValue(authzType);
setSecurity((Stub)rft);
+ //write epr to a file
+ QName qname = new QName("http://www.globus.org/namespaces/2004/10/rft", "TransferKey");
+ String resourceKey = rftepr.getProperties().get(qname).getValue();
+ FileWriter writer = new FileWriter(resourceKey);
+ try {
+ QName qName1 = new QName("", "RFT_EPR");
+ writer.write(ObjectSerializer.toString(rftepr, qName1));
+ } finally {
+ if(null != writer) {
+ writer.close();
+ }
+ }
+
//For secure notifications
epr2ID.put(createMapKey(rftepr), Integer.toString(jobID));
ID2Stub.put(Integer.toString(jobID), rft);
@@ -272,25 +294,25 @@
.getDescription(0).get_value());
}
} else if (RFTConstants.OVERALL_STATUS_RESOURCE.equals(topicQName)) {
- OverallStatus overallStatus = (OverallStatus) changeMessage
- .getNewValue().get_any()[0].getValueAsType(
- RFTConstants.OVERALL_STATUS_RESOURCE,
- OverallStatus.class);
- int finished = overallStatus.getTransfersFinished();
- int active = overallStatus.getTransfersActive();
- int failed = overallStatus.getTransfersFailed();
- int retrying = overallStatus.getTransfersRestarted();
- int pending = overallStatus.getTransfersPending();
- int cancelled = overallStatus.getTransfersCancelled();
- System.out.println("\n Overall status of transfer:");
- System.out.println("Finished/Active/Failed/Retrying/Pending/Cancelled");
- System.out.print(overallStatus.getTransfersFinished() + "/");
- System.out.print(overallStatus.getTransfersActive() + "/");
- System.out.print(overallStatus.getTransfersFailed() + "/");
- System.out.print(overallStatus.getTransfersRestarted() + "/");
- System.out.print(overallStatus.getTransfersPending() + "/");
- System.out.print(overallStatus.getTransfersCancelled());
- listener.updateOverallStatus(finished, active, failed, retrying, pending, cancelled);
+// OverallStatus overallStatus = (OverallStatus) changeMessage
+// .getNewValue().get_any()[0].getValueAsType(
+// RFTConstants.OVERALL_STATUS_RESOURCE,
+// OverallStatus.class);
+// int finished = overallStatus.getTransfersFinished();
+// int active = overallStatus.getTransfersActive();
+// int failed = overallStatus.getTransfersFailed();
+// int retrying = overallStatus.getTransfersRestarted();
+// int pending = overallStatus.getTransfersPending();
+// int cancelled = overallStatus.getTransfersCancelled();
+// System.out.println("\n Overall status of transfer:");
+// System.out.println("Finished/Active/Failed/Retrying/Pending/Cancelled");
+// System.out.print(overallStatus.getTransfersFinished() + "/");
+// System.out.print(overallStatus.getTransfersActive() + "/");
+// System.out.print(overallStatus.getTransfersFailed() + "/");
+// System.out.print(overallStatus.getTransfersRestarted() + "/");
+// System.out.print(overallStatus.getTransfersPending() + "/");
+// System.out.print(overallStatus.getTransfersCancelled());
+ //listener.updateOverallStatus(finished, active, failed, retrying, pending, cancelled);
}
@@ -337,36 +359,55 @@
//int length = queuePanel.tableSize();
int i = 0;
while (i < queuePanel.tableSize()) {
- int jobID = Integer.parseInt(queuePanel.getColumnValue(i, 0));
- int j = 1;
- while (j + i < queuePanel.tableSize()) {
- int nextJobID = Integer.parseInt(queuePanel.getColumnValue(j + i, 0));
- if (jobID == nextJobID) {
- //System.out.println("jobid=" + jobID + ", nextjobid=" + nextJobID + ", j=" + j);
- j++;
- } else {
- break;
- }
- }
-
- ReliableFileTransferPortType rft = (ReliableFileTransferPortType)ID2Stub.get(Integer.toString(jobID));
- if (null != rft) {
- try {
- GetStatusSetResponse response = rft.getStatusSet(new GetStatusSet(1, j));
- for (int k = 0; k < j; k++) {
- TransferStatusType statusType = response.getTransferStatusSet(k);
- String status = statusType.getStatus().getValue();
- if (i + k < queuePanel.tableSize()) {
- queuePanel.setColumnValue(i + k, 5, status);
- }
- }
+ String isRFT = queuePanel.getColumnValue(i, 7);
+ String status = queuePanel.getColumnValue(i, 3);
+ if ("true".equals(isRFT) &&
+ !("Finished".equals(status)) && !"Expanding_Done".equals(status)) {
+ int jobID = Integer.parseInt(queuePanel.getColumnValue(i, 0));
+ ReliableFileTransferPortType rft = (ReliableFileTransferPortType)ID2Stub.get(Integer.toString(jobID));
+ if (null != rft) {
+ try {
+ GetStatusSetResponse response = rft.getStatusSet(new GetStatusSet(1, 1));
+ TransferStatusType statusType = response.getTransferStatusSet(0);
+ String jobStatus = statusType.getStatus().getValue();
+ queuePanel.setColumnValue(i , 3, jobStatus);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
-
- i+=j;
+ }
}
+ i++;
+// int jobID = Integer.parseInt(queuePanel.getColumnValue(i, 0));
+// int j = 1;
+// while (j + i < queuePanel.tableSize()) {
+// int nextJobID = Integer.parseInt(queuePanel.getColumnValue(j + i, 0));
+// if (jobID == nextJobID) {
+// //System.out.println("jobid=" + jobID + ", nextjobid=" + nextJobID + ", j=" + j);
+// j++;
+// } else {
+// break;
+// }
+// }
+//
+// ReliableFileTransferPortType rft = (ReliableFileTransferPortType)ID2Stub.get(Integer.toString(jobID));
+// if (null != rft) {
+// try {
+// GetStatusSetResponse response = rft.getStatusSet(new GetStatusSet(1, j));
+// for (int k = 0; k < j; k++) {
+// TransferStatusType statusType = response.getTransferStatusSet(k);
+// String status = statusType.getStatus().getValue();
+// if (i + k < queuePanel.tableSize()) {
+// queuePanel.setColumnValue(i + k, 3, status);
+// }
+// }
+// } catch (Exception e) {
+// // TODO Auto-generated catch block
+// e.printStackTrace();
+// }
+//
+// i+=j;
+// }
}
Modified: trunk/current/src/cog/modules/transfer-gui/src/org/globus/transfer/reliable/client/RFTOptions.java
===================================================================
--- trunk/current/src/cog/modules/transfer-gui/src/org/globus/transfer/reliable/client/RFTOptions.java 2008-07-22 05:27:57 UTC (rev 2079)
+++ trunk/current/src/cog/modules/transfer-gui/src/org/globus/transfer/reliable/client/RFTOptions.java 2008-07-22 05:28:11 UTC (rev 2080)
@@ -1,15 +1,15 @@
package org.globus.transfer.reliable.client;
public class RFTOptions {
- private int blockSize;
+ //private int blockSize;
private int concurrent;
private int parallelStream;
private int tcpBufferSize;
- private int maxAttampts;
- private boolean dcau;
- private boolean notpt;
- private boolean binary;
- private boolean allOrNone;
+ //private int maxAttampts;
+ //private boolean dcau;
+ //private boolean notpt;
+ //private boolean binary;
+ //private boolean allOrNone;
private String destDN;
private String sourceDN;
@@ -18,31 +18,30 @@
}
- public RFTOptions(int blockSize, int concurrent, int parallelStream,
- int tcpBufferSize, int maxAttampts, boolean dcau, boolean notpt,
- boolean binary, boolean allOrNone, String destDN, String sourceDN) {
+ public RFTOptions(int concurrent, int parallelStream,
+ int tcpBufferSize, String destDN, String sourceDN) {
super();
- this.blockSize = blockSize;
+ //this.blockSize = blockSize;
this.concurrent = concurrent;
this.parallelStream = parallelStream;
this.tcpBufferSize = tcpBufferSize;
- this.maxAttampts = maxAttampts;
- this.dcau = dcau;
- this.notpt = notpt;
- this.binary = binary;
- this.allOrNone = allOrNone;
+// this.maxAttampts = maxAttampts;
+// this.dcau = dcau;
+// this.notpt = notpt;
+// this.binary = binary;
+// this.allOrNone = allOrNone;
this.destDN = destDN;
this.sourceDN = sourceDN;
}
- public int getBlockSize() {
- return blockSize;
- }
+// public int getBlockSize() {
+// return blockSize;
+// }
+//
+// public void setBlockSize(int blockSize) {
+// this.blockSize = blockSize;
+// }
- public void setBlockSize(int blockSize) {
- this.blockSize = blockSize;
- }
-
public int getConcurrent() {
return concurrent;
}
@@ -67,46 +66,46 @@
this.tcpBufferSize = tcpBufferSize;
}
- public int getMaxAttampts() {
- return maxAttampts;
- }
+// public int getMaxAttampts() {
+// return maxAttampts;
+// }
+//
+// public void setMaxAttampts(int maxAttampts) {
+// this.maxAttampts = maxAttampts;
+// }
- public void setMaxAttampts(int maxAttampts) {
- this.maxAttampts = maxAttampts;
- }
+// public boolean isDcau() {
+// return dcau;
+// }
+//
+// public void setDcau(boolean dcau) {
+// this.dcau = dcau;
+// }
+//
+// public boolean isNotpt() {
+// return notpt;
+// }
+//
+// public void setNotpt(boolean notpt) {
+// this.notpt = notpt;
+// }
+//
+// public boolean isBinary() {
+// return binary;
+// }
+//
+// public void setBinary(boolean binary) {
+// this.binary = binary;
+// }
+//
+// public boolean isAllOrNone() {
+// return allOrNone;
+// }
+//
+// public void setAllOrNone(boolean allOrNone) {
+// this.allOrNone = allOrNone;
+// }
- public boolean isDcau() {
- return dcau;
- }
-
- public void setDcau(boolean dcau) {
- this.dcau = dcau;
- }
-
- public boolean isNotpt() {
- return notpt;
- }
-
- public void setNotpt(boolean notpt) {
- this.notpt = notpt;
- }
-
- public boolean isBinary() {
- return binary;
- }
-
- public void setBinary(boolean binary) {
- this.binary = binary;
- }
-
- public boolean isAllOrNone() {
- return allOrNone;
- }
-
- public void setAllOrNone(boolean allOrNone) {
- this.allOrNone = allOrNone;
- }
-
public String getDestDN() {
return destDN;
}
Modified: trunk/current/src/cog/modules/transfer-gui/src/org/globus/transfer/reliable/client/RFTOptionsPanel.java
===================================================================
--- trunk/current/src/cog/modules/transfer-gui/src/org/globus/transfer/reliable/client/RFTOptionsPanel.java 2008-07-22 05:27:57 UTC (rev 2079)
+++ trunk/current/src/cog/modules/transfer-gui/src/org/globus/transfer/reliable/client/RFTOptionsPanel.java 2008-07-22 05:28:11 UTC (rev 2080)
@@ -1,21 +1,13 @@
-/*
- * RFTOptions.java
- *
- * Created on 2008年2月17日, 下午6:30
- */
-
package org.globus.transfer.reliable.client;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
import java.awt.event.ItemEvent;
import java.awt.event.ItemListener;
import javax.swing.JCheckBox;
import javax.swing.JFrame;
import javax.swing.JTextField;
-/**
- *
- * @author vic
- */
public class RFTOptionsPanel extends javax.swing.JPanel implements ItemListener {
/** Creates new form RFTOptions */
@@ -31,47 +23,49 @@
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
- jLabel1 = new javax.swing.JLabel();
- binary = new javax.swing.JCheckBox();
- jLabel2 = new javax.swing.JLabel();
- blockSize = new javax.swing.JTextField();
+// jLabel1 = new javax.swing.JLabel();
+// binary = new javax.swing.JCheckBox();
+// jLabel2 = new javax.swing.JLabel();
+// blockSize = new javax.swing.JTextField();
jLabel3 = new javax.swing.JLabel();
tcpBufferSize = new javax.swing.JTextField();
jLabel4 = new javax.swing.JLabel();
jLabel5 = new javax.swing.JLabel();
- jLabel6 = new javax.swing.JLabel();
- noTpt = new javax.swing.JCheckBox();
+// jLabel6 = new javax.swing.JLabel();
+// noTpt = new javax.swing.JCheckBox();
jLabel7 = new javax.swing.JLabel();
parallelStream = new javax.swing.JTextField();
- jLabel8 = new javax.swing.JLabel();
- dCAU = new javax.swing.JCheckBox();
+// jLabel8 = new javax.swing.JLabel();
+// dCAU = new javax.swing.JCheckBox();
jLabel9 = new javax.swing.JLabel();
concurrent = new javax.swing.JTextField();
jLabel10 = new javax.swing.JLabel();
sourceSN = new javax.swing.JTextField();
jLabel11 = new javax.swing.JLabel();
destSN = new javax.swing.JTextField();
- jLabel12 = new javax.swing.JLabel();
- allOrNone = new javax.swing.JCheckBox();
- jLabel13 = new javax.swing.JLabel();
- maxAttempts = new javax.swing.JTextField();
+// enable_rft = new javax.swing.JLabel();
+// enable_rft_checkbox = new javax.swing.JCheckBox();
+// jLabel12 = new javax.swing.JLabel();
+// allOrNone = new javax.swing.JCheckBox();
+ //jLabel13 = new javax.swing.JLabel();
+// maxAttempts = new javax.swing.JTextField();
org.jdesktop.application.ResourceMap resourceMap = org.jdesktop.application.Application.getInstance(org.globus.transfer.reliable.client.GridFTPGUIApp.class).getContext().getResourceMap(RFTOptionsPanel.class);
setBorder(javax.swing.BorderFactory.createTitledBorder(resourceMap.getString("Form.border.title"))); // NOI18N
setName("Form"); // NOI18N
- jLabel1.setText(resourceMap.getString("jLabel1.text")); // NOI18N
- jLabel1.setName("jLabel1"); // NOI18N
+// jLabel1.setText(resourceMap.getString("jLabel1.text")); // NOI18N
+// jLabel1.setName("jLabel1"); // NOI18N
+//
+// binary.setText(resourceMap.getString("binary.text")); // NOI18N
+// binary.setName("binary"); // NOI18N
+//
+// jLabel2.setText(resourceMap.getString("jLabel2.text")); // NOI18N
+// jLabel2.setName("jLabel2"); // NOI18N
+//
+// blockSize.setText(resourceMap.getString("blockSize.text")); // NOI18N
+// blockSize.setName("blockSize"); // NOI18N
- binary.setText(resourceMap.getString("binary.text")); // NOI18N
- binary.setName("binary"); // NOI18N
-
- jLabel2.setText(resourceMap.getString("jLabel2.text")); // NOI18N
- jLabel2.setName("jLabel2"); // NOI18N
-
- blockSize.setText(resourceMap.getString("blockSize.text")); // NOI18N
- blockSize.setName("blockSize"); // NOI18N
-
jLabel3.setText(resourceMap.getString("jLabel3.text")); // NOI18N
jLabel3.setName("jLabel3"); // NOI18N
@@ -83,25 +77,27 @@
jLabel5.setText(resourceMap.getString("jLabel5.text")); // NOI18N
jLabel5.setName("jLabel5"); // NOI18N
+
+ //enable_rft.setText("enable RFT");
- jLabel6.setText(resourceMap.getString("jLabel6.text")); // NOI18N
- jLabel6.setName("jLabel6"); // NOI18N
+// jLabel6.setText(resourceMap.getString("jLabel6.text")); // NOI18N
+// jLabel6.setName("jLabel6"); // NOI18N
+//
+// noTpt.setText(resourceMap.getString("noTpt.text")); // NOI18N
+// noTpt.setName("noTpt"); // NOI18N
- noTpt.setText(resourceMap.getString("noTpt.text")); // NOI18N
- noTpt.setName("noTpt"); // NOI18N
-
jLabel7.setText(resourceMap.getString("jLabel7.text")); // NOI18N
jLabel7.setName("jLabel7"); // NOI18N
parallelStream.setText(resourceMap.getString("parallelStream.text")); // NOI18N
parallelStream.setName("parallelStream"); // NOI18N
- jLabel8.setText(resourceMap.getString("jLabel8.text")); // NOI18N
- jLabel8.setName("jLabel8"); // NOI18N
+// jLabel8.setText(resourceMap.getString("jLabel8.text")); // NOI18N
+// jLabel8.setName("jLabel8"); // NOI18N
+//
+// dCAU.setText(resourceMap.getString("dCAU.text")); // NOI18N
+// dCAU.setName("dCAU"); // NOI18N
- dCAU.setText(resourceMap.getString("dCAU.text")); // NOI18N
- dCAU.setName("dCAU"); // NOI18N
-
jLabel9.setText(resourceMap.getString("jLabel9.text")); // NOI18N
jLabel9.setName("jLabel9"); // NOI18N
@@ -120,121 +116,228 @@
destSN.setText(resourceMap.getString("destSN.text")); // NOI18N
destSN.setName("destSN"); // NOI18N
- jLabel12.setText(resourceMap.getString("jLabel12.text")); // NOI18N
- jLabel12.setName("jLabel12"); // NOI18N
+// jLabel12.setText(resourceMap.getString("jLabel12.text")); // NOI18N
+// jLabel12.setName("jLabel12"); // NOI18N
+//
+// allOrNone.setText(resourceMap.getString("allOrNone.text")); // NOI18N
+// allOrNone.setName("allOrNone"); // NOI18N
- allOrNone.setText(resourceMap.getString("allOrNone.text")); // NOI18N
- allOrNone.setName("allOrNone"); // NOI18N
+// jLabel13.setText(resourceMap.getString("jLabel13.text")); // NOI18N
+// jLabel13.setName("jLabel13"); // NOI18N
- jLabel13.setText(resourceMap.getString("jLabel13.text")); // NOI18N
- jLabel13.setName("jLabel13"); // NOI18N
+// maxAttempts.setText(resourceMap.getString("maxAttempts.text")); // NOI18N
+// maxAttempts.setName("maxAttempts"); // NOI18N
- maxAttempts.setText(resourceMap.getString("maxAttempts.text")); // NOI18N
- maxAttempts.setName("maxAttempts"); // NOI18N
-
org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(this);
this.setLayout(layout);
+
+ /////////////////////////////////////////////////////////////////////////////////////////////////
+
layout.setHorizontalGroup(
- layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
- .add(layout.createSequentialGroup()
- .addContainerGap()
- .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
- .add(org.jdesktop.layout.GroupLayout.LEADING, jLabel11)
- .add(org.jdesktop.layout.GroupLayout.LEADING, layout.createSequentialGroup()
- .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
- .add(layout.createSequentialGroup()
- .add(jLabel1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 46, Short.MAX_VALUE)
- .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
- .add(binary)
- .add(44, 44, 44)
- .add(jLabel6)
- .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED))
- .add(layout.createSequentialGroup()
- .add(jLabel7, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 90, Short.MAX_VALUE)
- .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
- .add(parallelStream, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 35, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
- .add(18, 18, 18))
- .add(layout.createSequentialGroup()
- .add(jLabel10)
- .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)))
- .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
- .add(layout.createSequentialGroup()
- .add(noTpt)
- .add(38, 38, 38)
- .add(jLabel8)
- .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED)
- .add(dCAU)
- .add(31, 31, 31)
- .add(jLabel12, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 74, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
- .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
- .add(allOrNone))
- .add(layout.createSequentialGroup()
- .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
- .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
- .add(layout.createSequentialGroup()
- .add(jLabel2, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 70, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
- .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED)
- .add(blockSize, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
- .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
- .add(jLabel4)
- .add(30, 30, 30)
- .add(jLabel3, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 86, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
- .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
- .add(tcpBufferSize, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
- .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
- .add(jLabel5)
- .add(32, 32, 32)
- .add(jLabel13, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 85, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
- .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
- .add(concurrent, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 32, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
- .add(18, 18, 18)
- .add(jLabel9)
- .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED)
- .add(maxAttempts, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 37, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
- .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING, false)
- .add(org.jdesktop.layout.GroupLayout.LEADING, destSN)
- .add(org.jdesktop.layout.GroupLayout.LEADING, sourceSN, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 723, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)))))
- .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
- .add(23, 23, 23))
- );
+ layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+ .add(layout.createSequentialGroup()
+ .addContainerGap()
+ .add(64, 64, 64)
+ .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+ .add(layout.createSequentialGroup()
+ .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+ .add(jLabel7)
+ //.add(jLabel9)
+ .add(jLabel3))
+ //.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
+ .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING, false)
+ .add(parallelStream, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 76, Short.MAX_VALUE)
+ //.add(concurrent, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 76, Short.MAX_VALUE)
+ .add(tcpBufferSize, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 76, Short.MAX_VALUE))
+
+ //.add(jLabel4)
+ //.add(93, 93, 93)
+// .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING, false)
+//// .add(layout.createSequentialGroup()
+//// .add(enable_rft, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
+//// .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
+//// .add(enable_rft_checkbox))
+// )
+// .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
+//
+// .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
+//
+// .addContainerGap()
+
+ )
+// .add(org.jdesktop.layout.GroupLayout.TRAILING, layout.createSequentialGroup()
+//// .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
+////// .add(org.jdesktop.layout.GroupLayout.LEADING, layout.createSequentialGroup()
+////// //.add(jLabel10)
+////// //.add(34, 34, 34)
+////// //.add(sourceSN, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 677, Short.MAX_VALUE)
+////// )
+////// .add(layout.createSequentialGroup()
+////// //.add(jLabel11)
+////// //.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
+////// //.add(destSN, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 677, Short.MAX_VALUE)
+////// )
+//// )
+// .add(262, 262, 262))
+ ))
+ );
layout.setVerticalGroup(
- layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
- .add(layout.createSequentialGroup()
- .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
- .add(jLabel1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 24, Short.MAX_VALUE)
- .add(binary)
- .add(jLabel6)
- .add(noTpt)
- .add(jLabel8)
- .add(dCAU)
- .add(jLabel12)
- .add(allOrNone))
- .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
- .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
- .add(jLabel7)
- .add(parallelStream, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
- .add(blockSize, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
- .add(jLabel4)
- .add(jLabel3)
- .add(tcpBufferSize, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
- .add(jLabel5)
- .add(jLabel13)
- .add(concurrent, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 20, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
- .add(jLabel9)
- .add(maxAttempts, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
- .add(jLabel2, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 24, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
- .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
- .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
- .add(sourceSN, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
- .add(jLabel10))
- .add(18, 18, 18)
- .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
- .add(jLabel11)
- .add(destSN, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
- .addContainerGap(org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
- );
+ layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+ .add(layout.createSequentialGroup()
+ .add(26, 26, 26)
+ .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
+ .add(jLabel7)
+ .add(parallelStream, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
+// .add(jLabel3)
+// .add(tcpBufferSize, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
+// .add(jLabel4)
+ )
+ .add(11, 11, 11)
+// .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
+// .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
+// .add(jLabel9)
+// .add(concurrent, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
+//
+// )
+//// .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
+//// .add(enable_rft)
+//// .add(enable_rft_checkbox))
+// )
+// .add(11, 11, 11)
+ .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
+ .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
+ .add(jLabel3)
+ .add(tcpBufferSize, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
+ //.add(jLabel4)
+ )
+// .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
+// .add(enable_rft)
+// .add(enable_rft_checkbox))
+ )
+ //.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
+// .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
+// //.add(jLabel10)
+// //.add(sourceSN, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
+// )
+ //.addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED)
+// .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
+// //.add(jLabel11)
+// //.add(destSN, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
+// )
+ //.addContainerGap(127, Short.MAX_VALUE)
+ )
+ );
+
+
+ ////////////////////////////////////////////////////////////////////////////////////////////////
+// layout.setHorizontalGroup(
+// layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+// .add(layout.createSequentialGroup()
+// .addContainerGap()
+// .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
+// .add(org.jdesktop.layout.GroupLayout.LEADING, jLabel11)
+// .add(org.jdesktop.layout.GroupLayout.LEADING, layout.createSequentialGroup()
+// .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+//// .add(layout.createSequentialGroup()
+//// .add(jLabel1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 46, Short.MAX_VALUE)
+//// .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
+//// .add(binary)
+//// .add(44, 44, 44)
+//// .add(jLabel6)
+//// .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED))
+// .add(layout.createSequentialGroup()
+// .add(jLabel7, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 90, Short.MAX_VALUE)
+// .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
+// .add(parallelStream, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 35, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
+// .add(18, 18, 18))
+// .add(layout.createSequentialGroup()
+// .add(jLabel10)
+// .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)))
+// .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+//// .add(layout.createSequentialGroup()
+//// .add(noTpt)
+//// .add(38, 38, 38)
+//// .add(jLabel8)
+//// .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED)
+//// .add(dCAU)
+//// .add(31, 31, 31)
+//// .add(jLabel12, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 74, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
+//// .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
+//// .add(allOrNone)
+// )
+// .add(layout.createSequentialGroup()
+// .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
+// .add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
+// .add(layout.createSequentialGroup()
+//// .add(jLabel2, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 70, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
+//// .addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED)
+//// .add(blockSize, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
+//// .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
+// .add(jLabel4)
+// .add(30, 30, 30)
+// .add(jLabel3, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 86, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
+// .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
+// .add(tcpBufferSize, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
+// .addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
+// .add(jLabel5)
+// .add(32, 32, 32)
+//// .add(jLabel13, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, 85, org.jdeskto...
[truncated message content] |
|
From: <li...@us...> - 2008-07-22 05:27:59
|
Revision: 2079
http://cogkit.svn.sourceforge.net/cogkit/?rev=2079&view=rev
Author: liuwt
Date: 2008-07-22 05:27:57 +0000 (Tue, 22 Jul 2008)
Log Message:
-----------
Modified Paths:
--------------
trunk/current/src/cog/modules/transfer-gui/src/org/globus/ogce/beans/filetransfer/transfer/FileRequest.java
Modified: trunk/current/src/cog/modules/transfer-gui/src/org/globus/ogce/beans/filetransfer/transfer/FileRequest.java
===================================================================
--- trunk/current/src/cog/modules/transfer-gui/src/org/globus/ogce/beans/filetransfer/transfer/FileRequest.java 2008-07-22 05:27:44 UTC (rev 2078)
+++ trunk/current/src/cog/modules/transfer-gui/src/org/globus/ogce/beans/filetransfer/transfer/FileRequest.java 2008-07-22 05:27:57 UTC (rev 2079)
@@ -2,6 +2,7 @@
import org.apache.log4j.Logger;
+import org.globus.ogce.beans.filetransfer.gui.FileTransferMainPanel;
import org.globus.ogce.beans.filetransfer.gui.monitor.MonitorPanel;
import org.globus.ogce.beans.filetransfer.gui.monitor.RequestPanel;
import org.globus.ogce.beans.filetransfer.util.GridBrokerQueue;
@@ -43,7 +44,7 @@
public void updateQueue(DirTransferRequest request) {
- dirJobID++;
+ dirJobID++;
DirRequestJob job = new DirRequestJob(dirJobID + "", request);
setControl(false);
requestQueue.put(job);
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <li...@us...> - 2008-07-22 05:27:47
|
Revision: 2078
http://cogkit.svn.sourceforge.net/cogkit/?rev=2078&view=rev
Author: liuwt
Date: 2008-07-22 05:27:44 +0000 (Tue, 22 Jul 2008)
Log Message:
-----------
OGCE classes which have been modified
Added Paths:
-----------
trunk/current/src/cog/modules/transfer-gui/src/org/globus/ogce/beans/filetransfer/gui/remote/common/
trunk/current/src/cog/modules/transfer-gui/src/org/globus/ogce/beans/filetransfer/gui/remote/common/RemoteTree.java
trunk/current/src/cog/modules/transfer-gui/src/org/globus/ogce/beans/filetransfer/gui/remote/common/RemoteTreeFrame.java
Added: trunk/current/src/cog/modules/transfer-gui/src/org/globus/ogce/beans/filetransfer/gui/remote/common/RemoteTree.java
===================================================================
--- trunk/current/src/cog/modules/transfer-gui/src/org/globus/ogce/beans/filetransfer/gui/remote/common/RemoteTree.java (rev 0)
+++ trunk/current/src/cog/modules/transfer-gui/src/org/globus/ogce/beans/filetransfer/gui/remote/common/RemoteTree.java 2008-07-22 05:27:44 UTC (rev 2078)
@@ -0,0 +1,1044 @@
+//RemoteTree.java displays the remote tree structure d the remote files
+package org.globus.ogce.beans.filetransfer.gui.remote.common;
+
+
+import org.apache.log4j.Logger;
+import org.globus.ftp.FileInfo;
+import org.globus.ogce.beans.filetransfer.util.DirInfo;
+import org.globus.ogce.beans.filetransfer.util.DirQueue;
+import org.globus.ogce.beans.filetransfer.util.GridTransferable;
+import org.globus.ogce.beans.filetransfer.util.SortVectorStrings;
+import org.globus.ogce.beans.filetransfer.gui.FileTransferMainPanel;
+
+import javax.swing.*;
+import javax.swing.event.*;
+import javax.swing.tree.DefaultMutableTreeNode;
+import javax.swing.tree.DefaultTreeModel;
+import javax.swing.tree.MutableTreeNode;
+import javax.swing.tree.TreePath;
+import java.awt.*;
+import java.awt.dnd.*;
+import java.awt.event.MouseAdapter;
+import java.awt.event.MouseEvent;
+import java.io.IOException;
+import java.util.*;
+import java.util.List;
+
+/**
+ * This class implements the tree and drag and drop listeners
+ *
+ * @author Beulah Kurian Alunkal
+ * @version 1.0
+ */
+public class RemoteTree extends JTree implements TreeExpansionListener, TreeWillExpandListener, DragSourceListener, DragGestureListener, java.awt.dnd.DropTargetListener {
+ private static Logger logger =
+ Logger.getLogger(RemoteTree.class.getName());
+
+ protected DefaultTreeModel treeModel;
+ boolean dirflag;
+ private TreeSet InfoVec;
+ public String rootName;
+ private Object draggedValues[];
+ public DropTarget dropTarget;
+
+ public RemoteTreeFrame theApp;
+ public JScrollPane sc_pane = null;
+ public JTree tree;
+ public String RemoteRoot;
+ public String selectedPath;
+ public Vector RemVector;
+
+ public DefaultMutableTreeNode rootNode;
+ public DefaultMutableTreeNode lastExp;
+ public Toolkit toolkit;
+ public boolean pathView;
+ public Vector vector;
+ public Vector vector1;
+
+ public long firstClickTime = 0;
+ private boolean noselection = true;
+ TreePath destinationPath;
+ protected TreePath SelectedTreePath = null;
+ protected TreePath dragtreepath = null;
+ private DirQueue queue;
+
+ private DisplayInterface displayInterface = null;
+ private boolean dragEnable = true;
+ String deleteFile = null;
+ boolean deleteFlag = true;
+ DefaultMutableTreeNode defaultmutabletreenode = null;
+ MutableTreeNode mutabletreenode = null;
+ String selectedDestination = "";
+
+
+ public RemoteTree(RemoteTreeFrame RemoteTreeframe, String s, String remoteRoot, DisplayInterface displayInterface) {
+
+ InfoVec = new TreeSet();
+ selectedPath = new String();
+ RemVector = null;
+ toolkit = Toolkit.getDefaultToolkit();
+ theApp = RemoteTreeframe;
+ rootName = s;
+ if (theApp.connected) {
+ RemoteRoot = remoteRoot;
+ } else {
+ RemoteRoot = new String();
+ }
+ makeRemoteInfo();
+ queue = new DirQueue();
+ this.displayInterface = displayInterface;
+ }
+
+ public void makeRemoteInfo() {
+ rootNode = new DefaultMutableTreeNode(rootName);
+ treeModel = new DefaultTreeModel(rootNode);
+ treeModel.addTreeModelListener(new RemTreeModelListener());
+ RemoteRoot = theApp.rootRemote + "/";
+ DefaultMutableTreeNode defaultmutabletreenode1 = addObject(null, RemoteRoot);
+ addObject(defaultmutabletreenode1, "");
+ //makeDirInfo(RemoteRoot);
+ if (theApp.connected) {
+ theApp.setDirToFile(RemoteRoot);
+ }
+ tree = new JTree(treeModel);
+ dropTarget = new DropTarget(tree, this);
+ dropTarget.setActive(true);
+ tree.setEditable(false);
+ tree.getSelectionModel().setSelectionMode(4);
+ sc_pane = new JScrollPane(tree);
+ tree.addTreeWillExpandListener(this);
+ tree.addMouseListener(new MyAdapter()); // for double clicking
+ ToolTipManager.sharedInstance().registerComponent(tree);
+ RemRenderer remrenderer = new RemRenderer(theApp);
+ tree.setCellRenderer(remrenderer);
+ tree.putClientProperty("JTree.lineStyle", "Angled");
+ tree.addTreeSelectionListener(new TreeSelectionListener() {
+ public void valueChanged(TreeSelectionEvent treeselectionevent) {
+ DefaultMutableTreeNode defaultmutabletreenode = (DefaultMutableTreeNode) tree.getLastSelectedPathComponent();
+ if (defaultmutabletreenode == null) {
+ return;
+ } else {
+ javax.swing.tree.TreeNode atreenode[] = null;
+ atreenode = defaultmutabletreenode.getPath();
+ selectedPath = returnPath(atreenode);
+ SelectedTreePath = treeselectionevent.getNewLeadSelectionPath();
+ return;
+ }
+ }
+ });
+ DragSource dragsource = DragSource.getDefaultDragSource();
+ dragsource.createDefaultDragGestureRecognizer(tree, 3, this);
+ }
+
+ public void getLastExpandeNode(DefaultMutableTreeNode defaultmutabletreenode, TreePath treepath) {
+ int i = defaultmutabletreenode.getChildCount();
+ for (int j = 0; j < i; j++) {
+ DefaultMutableTreeNode defaultmutabletreenode1 = (DefaultMutableTreeNode) defaultmutabletreenode.getChildAt(j);
+ if (!defaultmutabletreenode1.isLeaf()) {
+ javax.swing.tree.TreeNode atreenode[] = defaultmutabletreenode1.getPath();
+ TreePath treepath1 = new TreePath(atreenode);
+ if (!treepath1.equals(treepath) && tree.isExpanded(treepath1)) {
+ lastExp = defaultmutabletreenode1;
+ getLastExpandeNode(defaultmutabletreenode1, treepath);
+ }
+ }
+ }
+ }
+
+ public String returnPath(Object aobj[]) {
+ int i = aobj.length;
+ String s = new String();
+ for (int j = 1; j < i; j++) {
+ s = s.concat(aobj[j].toString());
+ }
+ return s;
+ }
+
+ public void createNodes(DefaultMutableTreeNode defaultmutabletreenode, boolean flag, String s) {
+ if (flag) {
+ DefaultMutableTreeNode defaultmutabletreenode1 = new DefaultMutableTreeNode(s);
+ defaultmutabletreenode.add(defaultmutabletreenode1);
+ DefaultMutableTreeNode defaultmutabletreenode2 = new DefaultMutableTreeNode("");
+ defaultmutabletreenode1.add(defaultmutabletreenode2);
+ } else {
+ DefaultMutableTreeNode defaultmutabletreenode3 = new DefaultMutableTreeNode(s);
+ defaultmutabletreenode.add(defaultmutabletreenode3);
+ }
+ }
+
+ public DefaultMutableTreeNode addObject(Object obj) {
+ DefaultMutableTreeNode defaultmutabletreenode = null;
+ TreePath treepath = tree.getSelectionPath();
+ if (treepath == null) {
+ toolkit.beep();
+ return null;
+ }
+ defaultmutabletreenode = (DefaultMutableTreeNode) treepath.getLastPathComponent();
+ if (defaultmutabletreenode == rootNode) {
+ toolkit.beep();
+ return null;
+ } else {
+ return addObject(defaultmutabletreenode, obj, true);
+ }
+ }
+
+ public DefaultMutableTreeNode addObject(DefaultMutableTreeNode defaultmutabletreenode, Object obj) {
+ return addObject(defaultmutabletreenode, obj, false);
+ }
+
+ public DefaultMutableTreeNode addObject(DefaultMutableTreeNode defaultmutabletreenode, Object obj, boolean flag) {
+ DefaultMutableTreeNode defaultmutabletreenode1 = new DefaultMutableTreeNode(obj);
+ if (defaultmutabletreenode == null) {
+ defaultmutabletreenode = rootNode;
+ }
+ treeModel.insertNodeInto(defaultmutabletreenode1, defaultmutabletreenode, defaultmutabletreenode.getChildCount());
+ if (flag) {
+ tree.scrollPathToVisible(new TreePath(defaultmutabletreenode1.getPath()));
+ }
+ return defaultmutabletreenode1;
+ }
+
+ public void statusOut(String msg) {
+ //theApp.statusOut(msg);
+ }
+
+ public void removeCurrentNode() {
+ int i = tree.getSelectionModel().getSelectionCount();
+ if (i == 0) {
+ toolkit.beep();
+ statusOut("Nothing was selected");
+ statusOut("Status : Ready ");
+ return;
+ }
+ for (int j = 0; j < i; j++) {
+ TreePath treepath = tree.getSelectionPath();
+ if (treepath != null) {
+
+ defaultmutabletreenode = (DefaultMutableTreeNode) treepath.getLastPathComponent();
+ mutabletreenode = (MutableTreeNode) defaultmutabletreenode.getParent();
+ javax.swing.tree.TreeNode atreenode[] = null;
+ atreenode = defaultmutabletreenode.getPath();
+ deleteFile = returnPath(atreenode);
+ String msg = null;
+ if (mutabletreenode != null) {
+ if (deleteFile.endsWith("/")) {
+ msg = "Directory";
+ } else {
+ msg = "File";
+ }
+ Object aobj[] = {"Cancel", "Delete"};
+ int k = JOptionPane.showOptionDialog(theApp, "Do you really want to delete this " + msg + " ?", "Delete Alert", -1, 2, null, aobj, aobj[0]);
+ if (k != 0) {
+
+ if (deleteFile.endsWith("/")) {
+ dirDelete();
+
+
+ } else {
+ deleteFlag = displayInterface.removeFile(deleteFile);
+
+ if (deleteFlag) {
+ treeModel.removeNodeFromParent(defaultmutabletreenode);
+ if (treeModel.getChildCount(mutabletreenode) == 0) {
+ addObject((DefaultMutableTreeNode) mutabletreenode, "");
+ }
+ statusOut("Successfully deleted :" + deleteFile);
+ } else {
+ JOptionPane.showMessageDialog(this, msg + " : Permission Denied.");
+ }
+
+ statusOut("Status : Ready ");
+ }
+ }
+ }
+ } else {
+ toolkit.beep();
+ statusOut("No selection was made");
+ statusOut("Status : Ready ");
+ }
+ }
+ } // end of removecurrentNode
+
+ public void dirDelete() {
+ Thread dirDelete = new Thread() {
+ public void run() {
+ theApp.enableDeleteButton(false);
+ setDragEnabled(false);
+ deleteFlag = deleteDir(deleteFile);
+ if (deleteFlag) {
+ treeModel.removeNodeFromParent(defaultmutabletreenode);
+ if (treeModel.getChildCount(mutabletreenode) == 0) {
+ addObject((DefaultMutableTreeNode) mutabletreenode
+ , "");
+ }
+ theApp._actionRefresh();
+ statusOut("Successfully deleted: " + deleteFile);
+ } else {
+ JOptionPane.showMessageDialog(theApp, deleteFile +
+ " : Permission Denied.");
+ }
+ theApp.enableDeleteButton(true);
+ setDragEnabled(true);
+ }
+ };
+ dirDelete.start();
+ statusOut("Status : Ready ");
+ }
+
+ public boolean deleteDir(String dirname) {
+ if (!theApp.connected) {
+ JOptionPane.showMessageDialog(this, "Connection got disconnected");
+ theApp._actionDisconnect();
+ return false;
+ } else {
+ Vector vector = displayInterface.listDeleteDir(dirname);
+ if (vector == null) {
+ logger.info("\nThis is an empty directory.");
+ } else {
+ FileInfo temp[] = new FileInfo[vector.size()];
+ int p = 0;
+ Enumeration enum1 = vector.elements();
+ while (enum1.hasMoreElements()) {
+ FileInfo file = (FileInfo) enum1.nextElement();
+ temp[p] = file;
+ p++;
+ }
+
+
+ for (int i = 0; i < temp.length; i++) {
+ FileInfo current = temp[i];
+ String currentFullpath = dirname + "/" + current.getName();
+ if (current.isDirectory()) {
+
+ // statusOut( "Deleting the files in directory : " + currentFullpath);
+ deleteDir(currentFullpath);
+
+ } else {
+ displayInterface.removeFile(currentFullpath);
+ logger.info("\nDeleting: " + currentFullpath);
+ statusOut("\nDeleting: " + current.getName());
+ }
+ }
+
+
+ }
+ boolean flag = displayInterface.removeDir(dirname);
+ if (flag) {
+ logger.info("\nDeleted the directory " + dirname);
+
+ }
+ return flag;
+ }
+ }
+
+ public void doServList(String s) {
+ Vector vector = null;
+ if (!theApp.connected) {
+ JOptionPane.showMessageDialog(this, "Connection got disconnected");
+ theApp._actionDisconnect();
+ return;
+ }
+ displayInterface.setType(true);
+ vector = displayInterface.listDir(s);
+
+ if (RemVector != null) {
+ RemVector.clear();
+ }
+ RemVector = (Vector) vector.clone();
+ InfoVec.addAll(vector);
+ pathView = true;
+ } // end of doServList
+
+ public Vector ReturnInfoVec() {
+ return RemVector;
+ }
+
+
+ public DefaultMutableTreeNode seekParent(DefaultMutableTreeNode defaultmutabletreenode, String s) {
+ if (defaultmutabletreenode == null || s.compareTo(RemoteRoot) == 0) {
+ return null;
+ }
+ int i = defaultmutabletreenode.getChildCount();
+ String s1 = s.substring(s.indexOf("/") + 1);
+ for (int j = 0; j < i; j++) {
+ javax.swing.tree.TreeNode treenode = defaultmutabletreenode.getChildAt(j);
+ String s2 = treenode.toString();
+ if (s1.compareTo(s2) == 0) {
+ DefaultMutableTreeNode defaultmutabletreenode1 = (DefaultMutableTreeNode) treenode;
+ return defaultmutabletreenode1;
+ }
+ }
+ return null;
+ }
+
+ public String[] returnSelectedPaths1() {
+ TreePath atreepath[] = tree.getSelectionModel().getSelectionPaths();
+ String s = null;
+ String as[] = null;
+ if (atreepath != null) {
+ int i = atreepath.length;
+ as = new String[i];
+ for (int j = 0; j < i; j++) {
+ Object aobj[] = atreepath[j].getPath();
+ int k = aobj.length;
+ for (int l = 1; l < k; l++) {
+ DefaultMutableTreeNode defaultmutabletreenode = (DefaultMutableTreeNode) aobj[l];
+ if (!defaultmutabletreenode.isLeaf()) {
+ if (l == 1) {
+ s = new String("/");
+ }
+ s = s.concat(aobj[l].toString());
+ }
+ }
+ if (s != null) {
+ as[j] = new String(s);
+ }
+ }
+ }
+ return as;
+ }
+
+ public TreePath[] returnSelectedPaths() {
+ DefaultMutableTreeNode defaultmutabletreenode = (DefaultMutableTreeNode) tree.getLastSelectedPathComponent();
+ TreePath atreepath[] = null;
+ if (defaultmutabletreenode == null) {
+ return atreepath;
+ }
+ if (defaultmutabletreenode.isLeaf()) {
+ atreepath = tree.getSelectionModel().getSelectionPaths();
+ return atreepath;
+ } else {
+ TreePath atreepath1[] = tree.getSelectionPaths();
+ return atreepath1;
+ }
+ }
+
+ public String[] returnSelectedFiles() {
+ TreePath atreepath[] = returnSelectedPaths();
+ String as[] = null;
+ if (atreepath != null) {
+ int i = atreepath.length;
+ as = new String[i];
+ for (int j = 0; j < i; j++) {
+ Object aobj[] = atreepath[j].getPath();
+ int k = aobj.length;
+ String s = new String("");
+ for (int l = 1; l < k; l++) {
+ s = s.concat(aobj[l].toString());
+ }
+ as[j] = new String(s);
+ }
+ }
+ return as;
+ }
+
+ public void makeDirInfo(String s) //DefaultMutableTreeNode defaultmutabletreenode, String s)
+ {
+ vector = new Vector();
+ vector1 = new Vector();
+ if (theApp.getConnected() == false) {
+ return;
+ }
+ doServList(s);
+ if (RemVector.size() == 0) {
+ // DefaultMutableTreeNode defaultmutabletreenode1 = new DefaultMutableTreeNode("");
+ //defaultmutabletreenode.add(defaultmutabletreenode1);
+ return;
+ }
+ for (int i = 0; i < RemVector.size(); i++) {
+ //The tokenizer uses the default delimiter set, which is "\t\n\r":
+ StringTokenizer stringtokenizer = new StringTokenizer((String) RemVector.elementAt(i));
+ int j = stringtokenizer.countTokens();
+ String s1 = new String();
+ int i1 = 0;
+ if (theApp.ServerOpSys == 2) {
+ for (int j1 = 1; j1 <= j; j1++) {
+ if (j1 <= 3) {
+ stringtokenizer.nextToken();
+ }
+ if (j1 == 4) {
+ s1 = stringtokenizer.nextToken();
+ }
+ if (j1 > 4) {
+ s1 = s1 + " " + stringtokenizer.nextToken();
+ }
+ }
+ i1 = ((String) RemVector.elementAt(i)).lastIndexOf("<DIR>");
+ } else {
+ for (int k1 = 1; k1 <= j; k1++) {
+ if (k1 <= 8) {
+ stringtokenizer.nextToken();
+ }
+ if (k1 == 9) {
+ s1 = stringtokenizer.nextToken();
+ }
+ if (k1 > 9) {
+ s1 = s1 + " " + stringtokenizer.nextToken();
+ }
+ }
+ }
+ if (((String) RemVector.elementAt(i)).charAt(0) == 'd' || i1 > 0) {
+ if (s1.compareTo(".") != 0 && s1.compareTo("..") != 0) {
+ vector.addElement(s1 + "/");
+ }
+ } else if (((String) RemVector.elementAt(i)).charAt(0) != 'l' && !(((String) RemVector.elementAt(i)).startsWith("total"))) //startsWith("total"))
+ {
+ vector1.addElement(s1);
+ }
+ }
+ SortVectorStrings.startSort(vector);
+ SortVectorStrings.startSort(vector1);
+ }
+
+ public void treeWillExpand(TreeExpansionEvent treeexpansionevent) {
+ logger.info("\nenter the tree will expand.");
+ if (!theApp.connected) {
+ JOptionPane.showMessageDialog(this, "Connection got disconnected");
+ theApp._actionDisconnect();
+ return;
+ }
+ DefaultMutableTreeNode defaultmutabletreenode = null;
+ Object aobj[] = null;
+ aobj = treeexpansionevent.getPath().getPath();
+ int i = aobj.length;
+ defaultmutabletreenode = (DefaultMutableTreeNode) aobj[i - 1];
+ if (defaultmutabletreenode == rootNode) {
+ return;
+ } else {
+ DefaultMutableTreeNode defaultmutabletreenode1 = (DefaultMutableTreeNode) treeModel.getChild(aobj[i - 1], 0);
+ treeModel.removeNodeFromParent(defaultmutabletreenode1);
+ String s1 = returnPath(aobj);
+ statusOut("Please wait..Expanding dir " + s1);
+ listDir(defaultmutabletreenode, s1, false);
+ if (!theApp.connected) {
+ JOptionPane.showMessageDialog(null, "Connection got disconnected");
+ theApp._actionDisconnect();
+ statusOut("Application disconnected.");
+ return;
+ } else {
+
+ theApp.setDirToFile(s1);
+ noselection = false;
+ tree.getSelectionModel().clearSelection();
+ statusOut("Status: Ready");
+ return;
+ }
+ }
+ }
+
+ public void listDir(DefaultMutableTreeNode defaultmutabletreenode, String s, boolean flag) {
+
+ logger.info("\nEntered the listdir function.");
+ FileInfo file2,file1;
+ if (!theApp.connected) {
+ JOptionPane.showMessageDialog(this, "Connection got disconnected");
+ theApp._actionDisconnect();
+ return;
+ }
+
+ vector = null;
+ vector = displayInterface.listDir(s);
+ logger.info("\nGot the list.");
+
+ if (vector == null) {
+ logger.info("\nThe vector is null.Using the Parameterized LIST Aand Customized Parser");
+
+ vector = displayInterface.listAllDir(s);
+ statusOut("Parsing failed. Using new Parser");
+
+ FileParser parser = new FileParser();
+ vector = parser.parse(vector, "unix", "/");
+
+
+ /* if (vector == null){
+ JOptionPane.showMessageDialog(null,"Connection reset. Please try connecting again.");
+ theApp._actionDisconnect();
+ return ;
+ }*/
+
+ }
+ FileInfo temp[] = new FileInfo[vector.size()];
+ String as[] = new String[vector.size()];
+ int p = 0;
+ Enumeration enum1 = vector.elements();
+ while (enum1.hasMoreElements()) {
+ FileInfo file = (FileInfo) enum1.nextElement();
+ as[p] = file.getName();
+ temp[p] = file;
+ p++;
+ }
+
+ if (as == null) {
+ return;
+ }
+ int i = as.length;
+ //SortFtpString.startSort(as);
+ if ((i == 0) || (as[0] == null)) {
+ addObject(defaultmutabletreenode, "", false);
+ return;
+ }
+ statusOut("Listing the directories...");
+ for (int j = 0; j < i; j++) {
+ if (s.endsWith("/")) {
+ temp[j].setName(s + as[j]);
+ } else {
+ temp[j].setName(s + "/" + as[j]);
+ }
+ file1 = (FileInfo) temp[j];
+
+ if (file1.isDirectory()) {
+
+ if (file1.isSoftLink()) {
+ ;
+ } else {
+
+ if ((file1.getName().equals("//dev")) ||
+ (file1.isDevice())) {
+ logger.info("\nIt is a device directory");
+ addObject(defaultmutabletreenode, as[j], flag);
+ statusOut("Disabled the device directory" + file1.getName());
+
+ } else if ((file1.getName().equals("?"))) {
+ logger.info("\nDir name could not be parsed");
+ statusOut("The Parser could not parse filename");
+
+ } else {
+
+ DefaultMutableTreeNode defaultmutabletreenode1
+ = addObject(defaultmutabletreenode, as[j] + "/", flag);
+ addObject(defaultmutabletreenode1, "", false);
+ }
+ }
+ }
+ }
+ statusOut("Listing the files...");
+
+ for (int k = 0; k < i; k++) {
+ if (s.endsWith("/")) {
+ temp[k].setName(s + as[k]);
+ } else {
+ temp[k].setName(s + "/" + as[k]);
+ }
+ file2 = temp[k];
+
+ if (file2.isFile()) {
+ if (file2.isSoftLink()) {
+ logger.info("\nThis is a softlink.");
+ } else if ((file2.getName().equals("?"))) {
+ logger.info("\nFile name could not be parsed");
+ statusOut("The Parser could not parse file");
+
+ } else {
+ addObject(defaultmutabletreenode, as[k], flag);
+ statusOut("Done. Status: Ready");
+ }
+
+ }
+
+ }
+
+
+ }
+ /* Alternate parsing method
+
+ }catch(Exception e){
+ logger.info("The vector is returned as Strings ");
+ String buffer[] = new String[vector.size()];
+ while (enum.hasMoreElements()) {
+ String sbuffer = (String)enum.nextElement();
+ StringTokenizer stringtokenizer = new StringTokenizer(sbuffer);
+ int m = stringtokenizer.countTokens();
+ String s1 = new String();
+ int i1 = 0;
+ for(int k1 = 1; k1 <= m; k1++)
+ {
+ if(k1 <= 8)
+ stringtokenizer.nextToken();
+ if(k1 == 9)
+ s1 = stringtokenizer.nextToken();
+ if(k1 > 9)
+ s1 = s1 + " " + stringtokenizer.nextToken();
+ }
+ as[p] = s1;
+ buffer[p] = sbuffer;
+ p ++ ;
+ }
+
+ if (as == null)
+ return ;
+ int i = as.length;
+ if (i == 0) {
+ addObject(defaultmutabletreenode,"",false);
+ return ;
+ }
+
+ for (int j = 0; j < i; j ++ ) {
+
+
+ if (s.endsWith("/")){
+ as[j] = s+as[j];
+ }
+ else{
+ if(buffer[i].charAt(0) == 'd' ){
+ if(as[j].compareTo (".") != 0 && as[j].compareTo("..") != 0){
+ DefaultMutableTreeNode defaultmutabletreenode1 = addObject(defaultmutabletreenode,as[j]
+ +"/",flag);
+ addObject(defaultmutabletreenode1,"",false);
+ }
+ }
+ }
+ }
+ for (int k = 0; k < i; k ++ ) {
+ if(buffer[i].charAt(0) == 'd' ){
+ addObject(defaultmutabletreenode,as[k],flag);
+ }
+
+ }
+ }*/
+
+
+
+ public void treeWillCollapse(TreeExpansionEvent treeexpansionevent) {
+ DefaultMutableTreeNode defaultmutabletreenode = null;
+ tree.getSelectionModel().clearSelection();
+ Object aobj[] = null;
+ aobj = treeexpansionevent.getPath().getPath();
+ int i = aobj.length;
+ if (i > 1) {
+ defaultmutabletreenode = (DefaultMutableTreeNode) aobj[i - 1];
+ } else {
+ defaultmutabletreenode = rootNode;
+ }
+ if (defaultmutabletreenode == rootNode) {
+ // txtField.setText("Local Path ");
+ noselection = true;
+ treeModel.reload(defaultmutabletreenode);
+ return;
+ }
+ noselection = false;
+ defaultmutabletreenode.removeAllChildren();
+ addObject(defaultmutabletreenode, "");
+ aobj = ((DefaultMutableTreeNode) defaultmutabletreenode.getParent()).getPath();
+ lastExp = null;
+ getLastExpandeNode(rootNode, treeexpansionevent.getPath());
+ if (lastExp != null) {
+ javax.swing.tree.TreeNode atreenode[] = treeModel.getPathToRoot(lastExp);
+ TreePath treepath = new TreePath(atreenode);
+ Object aobj1[] = treepath.getPath();
+ String s1 = returnPath(aobj1);
+ theApp.setDirToFile(s1);
+ } else {
+ //txtField.setText("Local Path ");
+ noselection = true;
+ }
+ treeModel.reload(defaultmutabletreenode);
+ }
+
+ public void buildirStructure(DefaultMutableTreeNode defaultmutabletreenode) {
+ for (int k = 0; k < vector.size(); k++) {
+ createNodes(defaultmutabletreenode, true, vector.elementAt(k).toString());
+ }
+ if (vector1.size() == 0) {
+ //createNodes(defaultmutabletreenode, false, "");
+ return;
+ } else {
+ for (int l = 0; l < vector1.size(); l++) {
+ //JOptionPane.showMessageDialog(null, vector1.elementAt(l));
+ createNodes(defaultmutabletreenode, false, vector1.elementAt(l).toString());
+ }
+ }
+ }
+
+ public void treeExpanded(TreeExpansionEvent treeexpansionevent) {
+ }
+
+ public void treeCollapsed(TreeExpansionEvent treeexpansionevent) {
+ }
+
+
+ public void transferfile(String startdir, String currdir, String fullpath) {
+
+ final DirInfo dirInfo = new DirInfo(fullpath, startdir, currdir);
+ queue.put(dirInfo);
+ return;
+
+ }
+
+ public void dragGestureRecognized(DragGestureEvent draggestureevent) {
+ if (!theApp.connected) {
+ return;
+ }
+ TreePath treepath[] = null;
+ Object aobj1[] = null;
+ String fullpath = "";
+
+ try {
+ treepath = returnSelectedPaths();
+ dragtreepath = SelectedTreePath;
+ aobj1 = treepath[0].getPath();
+ fullpath = returnPath(aobj1);
+ logger.info("\nfull path=" + fullpath);
+
+ } catch (NullPointerException e) {
+ logger.info("Drag Recognized failed.");
+ }
+
+
+ if (treepath == null || aobj1 == null || dragtreepath == null || fullpath == null) {
+ return;
+ } else if (!(dragEnable)) {
+ JOptionPane.showMessageDialog(this, "Please wait till the status\n bar shows drag enabled.");
+ return;
+ } else {
+ draggedValues = returnSelectedFiles();
+ GridTransferable Gridtransferable = new GridTransferable(draggedValues);
+ draggestureevent.startDrag(DragSource.DefaultCopyDrop, Gridtransferable, this);
+ String tempto[] = {""};
+ queue.deleteAll();
+ statusOut("Copying the file ...");
+ String startdir = draggedValues[0].toString();
+ logger.info("\nfull path =" + fullpath);
+ theApp.fireGridEvent(new GridEvent(theApp, GridEvent.GRIDDRAG), startdir, "", tempto);
+ theApp.setDirToFile(fullpath.substring(0,
+ fullpath.lastIndexOf("/")) + "/");
+
+ }
+ }
+
+ public void setDragEnabled(boolean flag) {
+ dragEnable = flag;
+ if (flag) {
+
+ tree.setBackground(Color.white);
+ statusOut("Successfully done dragging.");
+ statusOut("Status : Ready ");
+ } else {
+ tree.setBackground(Color.lightGray);
+ statusOut("Current window disabled. Please wait ... till" +
+ " the color changes back to white.");
+
+ }
+
+ }
+
+ public void dragEnter(DragSourceDragEvent dragsourcedragevent) {
+ }
+
+ public void dragOver(DragSourceDragEvent dragsourcedragevent) {
+ }
+
+ public void dragExit(DragSourceEvent dragsourceevent) {
+ }
+
+ public void dropActionChanged(DragSourceDragEvent dragsourcedragevent) {
+ }
+
+ public void dragDropEnd(DragSourceDropEvent dragsourcedropevent) {
+ if (dragsourcedropevent.getDropSuccess()) {
+ int i = dragsourcedropevent.getDropAction();
+ logger.info("value of i:" + i);
+ }
+ }
+
+
+ public void dragEnter(java.awt.dnd.DropTargetDragEvent droptargetdragevent) {
+// int i = droptargetdragevent.getDropAction();
+// if ((i & 1) != 0) {
+// statusOut("Copying");
+// }
+// if ((i & 2) != 0) {
+// statusOut("Moving");
+// }
+// if ((i & 1073741824) != 0) {
+// statusOut("Linking");
+// }
+// if (!isDragAcceptable(droptargetdragevent)) {
+// droptargetdragevent.rejectDrag();
+// return;
+// } else {
+// return;
+// }
+ }
+
+ public void dragExit(java.awt.dnd.DropTargetEvent droptargetevent) {
+ }
+
+ public void dragOver(java.awt.dnd.DropTargetDragEvent droptargetdragevent) {
+ //set cursor location. Needed in setCursor method
+ Point cursorLocationBis = droptargetdragevent.getLocation();
+ TreePath dPath = tree.getPathForLocation(cursorLocationBis.x, cursorLocationBis.y);
+ tree.setSelectionPath(dPath);
+ }
+
+ public void dropActionChanged(java.awt.dnd.DropTargetDragEvent droptargetdragevent) {
+ if (!isDragAcceptable(droptargetdragevent)) {
+ droptargetdragevent.rejectDrag();
+ return;
+ } else {
+ return;
+ }
+ }
+
+ public void drop(java.awt.dnd.DropTargetDropEvent droptargetdropevent) {
+ if (!isDropAcceptable(droptargetdropevent)) {
+ droptargetdropevent.rejectDrop();
+ return;
+ } else if (!(dragEnable)) {
+ return;
+ }
+ Point loc = droptargetdropevent.getLocation();
+ destinationPath = tree.getPathForLocation(loc.x, loc.y);
+ final String msg = testDropTarget(destinationPath, dragtreepath);
+ if (msg != null) {
+ SwingUtilities.invokeLater(new Runnable() {
+
+ public void run() {
+ JOptionPane.showMessageDialog(theApp, msg, "Error Dialog", JOptionPane.ERROR_MESSAGE);
+ }
+ });
+ return;
+ }
+ droptargetdropevent.acceptDrop(1);
+ java.awt.datatransfer.Transferable transferable = droptargetdropevent.getTransferable();
+ java.awt.datatransfer.DataFlavor adataflavor[] = transferable.getTransferDataFlavors();
+ for (int i = 0; i < adataflavor.length; i++) {
+ java.awt.datatransfer.DataFlavor dataflavor = adataflavor[i];
+ try {
+ if (dataflavor.equals(java.awt.datatransfer.DataFlavor.javaFileListFlavor)) {
+ List list = (List) transferable.getTransferData(dataflavor);
+ Iterator iterator = list.iterator();
+ Vector vector = new Vector();
+ String s;
+ for (; iterator.hasNext(); vector.add(s)) {
+ s = iterator.next().toString();
+ }
+ doCopyAction(vector);
+ //droptargetdropevent.rejectDrop();
+ }
+ } catch (java.awt.datatransfer.UnsupportedFlavorException unsupportedflavorexception) {
+ logger.debug("Exception _ufe = " + unsupportedflavorexception.toString());
+ } catch (IOException ioexception) {
+ logger.debug("Exception _ioe = " + ioexception.toString());
+ }
+ }
+ droptargetdropevent.dropComplete(true);
+ }
+
+ private String testDropTarget(TreePath destination, TreePath dropper) {
+ //Typical Tests for dropping
+ //Test 1.
+ boolean destinationPathIsNull = destination == null;
+ if (destinationPathIsNull) {
+ return "Invalid drop location.";
+ }
+ if (destination.equals(dropper)) {
+ logger.info("\nDestination =" + destination +
+ "\nSource= " + dropper);
+ theApp._actionRefresh();
+ return "Destination cannot be same as source";
+ }
+ return null;
+ }
+
+ public boolean isDragAcceptable(java.awt.dnd.DropTargetDragEvent droptargetdragevent) {
+ return (droptargetdragevent.getDropAction() & 3) != 0;
+ }
+
+ public boolean isDropAcceptable(java.awt.dnd.DropTargetDropEvent droptargetdropevent) {
+ return (droptargetdropevent.getDropAction() & 3) != 0;
+ }
+
+
+ public void doCopyAction(Vector vector) {
+
+ int i = vector.size();
+ String as[] = returnSelectedPaths1();
+ if (as == null || as[0] == null) {
+ as = new String[1];
+ as[0] = new String(theApp.getDirFromFile());
+ }
+ String as1 = "";
+ for (int j = 0; j < i; j++) {
+ as1 = (String) vector.elementAt(j);
+ } // end of for loop
+ // dragtreepath = as1;
+
+ String temp[] = {""};
+ if(theApp.bean){
+ FileTransferMainPanel.mainPanel.showStatusWindow();
+ FileTransferMainPanel.mainPanel.showMessagesWindow();
+ }
+ theApp.fireGridEvent(new GridEvent(theApp, GridEvent.GRIDDROP), null, as[0], temp);
+ theApp.setDirToFile(as[0]);
+
+ return;
+ } // end of doCopyAction
+
+ public void setSelectedSource() {
+ draggedValues = returnSelectedFiles();
+ String tempto[] = {""};
+ String startdir = draggedValues[0].toString();
+ theApp.fireGridEvent(new GridEvent(theApp, GridEvent.GRIDDRAG), startdir, "", tempto);
+ }
+
+ public void setSelectedDestination() {
+ String as[] = returnSelectedPaths1();
+ if (as == null || as[0] == null) {
+ as = new String[1];
+ as[0] = new String(theApp.getDirFromFile());
+ }
+ this.selectedDestination = as[0];
+ }
+
+ public void transfer() {
+ String temp[] = {""};
+ theApp.fireGridEvent(new GridEvent(theApp, GridEvent.GRIDDROP), null, selectedDestination, temp);
+ }
+
+
+ class MyAdapter extends MouseAdapter {
+
+ public MyAdapter() {
+ }
+
+ public void mouseClicked(MouseEvent evt) {
+ long clickTime = System.currentTimeMillis();
+ long clickInterval = clickTime - firstClickTime;
+ if (clickInterval < 300) {
+ theApp.displayRemoteFile();
+ firstClickTime = 0;
+ } else {
+ firstClickTime = clickTime;
+ } // end of if - else
+ } // end of mouseclicked
+ }
+
+
+ class RemTreeModelListener implements TreeModelListener {
+ public void treeNodesChanged(TreeModelEvent treemodelevent) {
+ DefaultMutableTreeNode defaultmutabletreenode = (DefaultMutableTreeNode) treemodelevent.getTreePath().getLastPathComponent();
+ try {
+ int i = treemodelevent.getChildIndices()[0];
+ defaultmutabletreenode = (DefaultMutableTreeNode) defaultmutabletreenode.getChildAt(i);
+ } catch (NullPointerException nullpointerexception) {
+ nullpointerexception.getMessage();
+ }
+ javax.swing.tree.TreeNode atreenode[] = null;
+ atreenode = defaultmutabletreenode.getPath();
+ // file1.renameTo(file);
+ displayInterface.rename(selectedPath, returnPath(atreenode));
+ }
+
+ public void treeNodesInserted(TreeModelEvent treemodelevent) {
+ }
+
+ public void treeNodesRemoved(TreeModelEvent treemodelevent) {
+ }
+
+ public void treeStructureChanged(TreeModelEvent treemodelevent) {
+ }
+
+ RemTreeModelListener() {
+ }
+ }
+}
Added: trunk/current/src/cog/modules/transfer-gui/src/org/globus/ogce/beans/filetransfer/gui/remote/common/RemoteTreeFrame.java
===================================================================
--- trunk/current/src/cog/modules/transfer-gui/src/org/globus/ogce/beans/filetransfer/gui/remote/common/RemoteTreeFrame.java (rev 0)
+++ trunk/current/src/cog/modules/transfer-gui/src/org/globus/ogce/beans/filetransfer/gui/remote/common/RemoteTreeFrame.java 2008-07-22 05:27:44 UTC (rev 2078)
@@ -0,0 +1,983 @@
+//RemoteTreeFrame.java which calls the RemoteTree.java
+package org.globus.ogce.beans.filetransfer.gui.remote.common;
+
+import org.apache.log4j.Logger;
+import org.globus.ogce.beans.filetransfer.gui.FileTransferMainPanel;
+import org.globus.util.GlobusURL;
+
+import javax.swing.*;
+import javax.swing.tree.DefaultMutableTreeNode;
+import javax.swing.tree.TreePath;
+import java.awt.*;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.awt.event.KeyAdapter;
+import java.awt.event.KeyEvent;
+import java.beans.PropertyChangeListener;
+import java.beans.PropertyChangeSupport;
+import java.io.File;
+import java.net.URL;
+import java.util.StringTokenizer;
+import java.util.Vector;
+
+/**
+ * This class renders graphical interface to the remote ftp client
+ * It can be used by any class that implements DisplayInterface.
+ *
+ * @author Beulah Kurian Alunkal
+
+ */
+public class RemoteTreeFrame extends JPanel implements ActionListener {
+ private static Logger logger =
+ Logger.getLogger(RemoteTreeFrame.class.getName());
+ JButton dirInfoButton = null;
+ public boolean bean = false;
+
+ protected Vector gridlisteners = new Vector();
+
+ /** Register an action listener to be notified when a button is pressed */
+ public void addGridListener(GridListener l) {
+ gridlisteners.addElement(l);
+ }
+
+ /** Remove an Answer listener from our list of interested listeners */
+ public void removeGridListener(GridListener l) {
+ gridlisteners.removeElement(l);
+ }
+
+ /** Send an event to all registered listeners */
+ public void fireGridEvent(GridEvent e, String from, String s1, String s2[]) {
+ Vector list = (Vector) gridlisteners.clone();
+ for (int i = 0; i < list.size(); i++) {
+ GridListener listener = (GridListener) list.elementAt(i);
+ switch (e.getID()) {
+ case GridEvent.GRIDDRAG:
+ listener.setDragDetails(e, from);
+ break;
+ case GridEvent.GRIDDROP:
+ listener.setDropDetails(e, s1);
+ break;
+ case GridEvent.GRIDEDIT:
+ listener.callGridEditFrame(e, s1, s2);
+ break;
+ }
+ }
+ }
+
+ public RemoteTreeFrame(DisplayInterface displayInterface, boolean bean) {
+
+ this.bean = bean;
+ this.displayInterface = displayInterface;
+ init();
+ }
+
+ public RemoteTreeFrame() {
+ init();
+ }
+
+ public void init() {
+ try {
+ url = new GlobusURL("ftp://dummy.edu:0/dev/null");
+ } catch (Exception e) {
+ logger.debug("This is a real bad error");
+ }
+ host = url.getHost();
+ protocol = url.getProtocol();
+ port = url.getPort();
+ user = "user";
+ pwd = "pass";
+ file = "";
+ rightView = null;
+ ServerOpSys = 0;
+ connected = false;
+ vector = null;
+ rootRemote = " ";
+ currentdir = " ";
+
+ this.FrameId = FrameId;
+
+ toolBar = new JToolBar();
+ toolBar.setFloatable(false);
+
+ JButton jbutton = createButton("images/16x16/reload.png",
+ "Click here to Refresh",
+ "4");
+ toolBar.add(jbutton);
+ jbutton = createButton("images/16x16/up.png",
+ "Click here to go one Directory Up",
+ "6");
+ toolBar.add(jbutton);
+ dirInfoButton = createButton("images/16x16/view_text.png",
+ "Directory Info currently disabled",
+ "0");
+ toolBar.add(dirInfoButton);
+
+
+ JToggleButton jbutton1 = createToggleButton("images/16x16/folder_home.png",
+ "Toggle between root and home directories",
+ "2");
+ toolBar.add(jbutton1);
+ toolBar.addSeparator();
+
+
+ toolBar.addSeparator();
+
+
+ jbutton = createButton("images/16x16/folder.png",
+ "Click here to Create a new Directory",
+ "7");
+ toolBar.add(jbutton);
+
+
+ jbutton = createButton("images/16x16/folder_rename.png",
+ "Click here to Rename a File/Directory",
+ "5");
+
+ toolBar.add(jbutton);
+
+ deleteButton = createButton("images/16x16/folder_delete.png",
+ "Click here to delete a File/Directory",
+ "1");
+ toolBar.add(deleteButton);
+
+ if (bean) {
+ toolBar.addSeparator();
+ toolBar.addSeparator();
+ toolBar.addSeparator();
+ jbutton = createButton("images/16x16/view_text.png",
+ "View the status window",
+ "8");
+ toolBar.add(jbutton);
+ jbutton = createButton("images/16x16/view_msg.png",
+ "View the messages window",
+ "9");
+ toolBar.add(jbutton);
+ }
+
+
+ toolBar.addSeparator();
+ toolBar.addSeparator();
+ toolBar.addSeparator();
+ toolBar.addSeparator();
+ disconnect = createButton("images/16x16/folder_delete.png", "Disconnect", "12");
+ disconnect.setEnabled(false);
+ toolBar.add(disconnect);
+ setBackground(Color.lightGray);
+
+ JPanel jpanel = new JPanel();
+ jpanel.setLayout(new BorderLayout());
+ urlField = new JTextField(url.getURL());
+ urlField.addActionListener(this);
+ //urlField.setActionCommand("14");
+ urlField.addKeyListener(new KeyAdapter() {
+
+ public void keyTyped(KeyEvent keyevent) {
+ char c = keyevent.getKeyChar();
+ if (c == '\n') {
+ setUrl(urlField.getText());
+ }
+ }
+
+ });
+ right = new RemoteTree(this, "Remote Tree -> Not connected", rootRemote, displayInterface);
+
+ rightView = right.sc_pane;
+ jpanel.add(toolBar, "North");
+ jpanel.add(urlField, "South");
+ JPanel jpanel1 = new JPanel(new BorderLayout());
+ statusText = new JLabel(" Status : Remote Window ");
+ //jpanel1.add(statusText);
+ setLayout(new BorderLayout());
+ add(jpanel, "North");
+ add(rightView, "Center");
+ add(jpanel1, "South");
+ setToolsEn(true);
+ right.setDragEnabled(false);
+ disconnect.setEnabled(false);
+ }
+
+ public void addPropertyChangeListener(PropertyChangeListener l) {
+ pceListeners.addPropertyChangeListener(l);
+ }
+
+ public void removePropertyChangeListener(PropertyChangeListener l) {
+ pceListeners.removePropertyChangeListener(l);
+ }
+
+ public void getUrlFromField() {
+ try {
+ urlstring = urlField.getText();
+ } catch (Exception e) {
+ error("getURLFromField", "unkown format");
+ logger.info(e);
+ }
+ }
+
+
+ public void setUrl(String newUrl) {
+ try {
+ GlobusURL oldUrl = url;
+ url = new GlobusURL(newUrl);
+ logger.info("\nOld url=" + oldUrl);
+ logger.info("\nNew url=" + url);
+ if ((oldUrl.getHost()).equals(url.getHost())) {
+ if(!connected){
+ statusOut("Connecting ... Please wait");
+ _actionConnect(true);
+ }else{
+
+ getUrlFromField();
+ filepath = getFile();
+ statusOut("Changed the directory to " + filepath);
+ index = filepath.lastIndexOf("/");
+ dirname = filepath.substring(0, index);
+ if (dirname != null) {
+ if (dirname.indexOf(rootRemote) > 0) {
+ _actionChngDir(dirname);
+ }
+ }
+ }
+ } else {
+ host = url.getHost();
+ port = url.getPort();
+ statusOut("Connecting ... Please wait");
+ pceListeners.firePropertyChange("url", oldUrl.getURL(), newUrl);
+ }
+ urlField.setText(newUrl);
+ } catch (Exception e) {
+ JOptionPane.showMessageDialog(this, "Please enter a valid URL.");
+ //error("setURL", newUrl);
+ }
+
+ }
+
+ public String getFile() {
+ file = url.getPath();
+ return file;
+ }
+
+ public String getHost() {
+
+ return host;
+ }
+
+ public String getProtocol() {
+
+ return protocol;
+ }
+
+ public String getUrl() {
+ return url.getURL();
+ }
+
+ public int getPort() {
+
+ return port;
+ }
+
+ public String getUser() {
+ return user;
+ }
+
+ public String getPassword() {
+ return pwd;
+ }
+
+
+ /**
+ * Method is used to retrieve the url of the site without file appended
+ *
+ * @return string which represents the url
+ */
+ public String getBaseUrl() {
+ GlobusURL tempurl = null;
+ if (protocol.equals("ftp")) {
+ try {
+ tempurl = new GlobusURL(protocol + "://" + user + ":" + pwd + "@" + host + ":" + port + "/");
+ } catch (Exception e) {
+ logger.info("exception in globus url formation");
+ }
+
+ return tempurl.getURL();
+ } else {
+ setDirToFile("");
+ return getUrl();
+ }
+ }
+
+
+ public void setFrameId(int id) {
+ FrameId = id;
+ }
+
+ public int getFrameId() {
+ return FrameId;
+ }
+
+ /**
+ * Method retrieves only the file from the entire url.
+ *
+ * @return path of the current directory
+ */
+ public String getDirFromFile() {
+ getUrlFromField();
+ filepath = getFile();
+ index = filepath.lastIndexOf("/");
+ dirname = filepath.substring(0, index) + "/";
+ return dirname;
+ }
+
+ public void setDirToFile(String dirname) {
+ setFile(dirname);
+ // getUrlFromField();
+ }
+
+ private void message(String s) {
+ msg.setText(s);
+ }
+
+ private void error(String method, String e) {
+ message("Error: " + method + " <" + e + ">");
+ }
+
+
+ private void parseURL() {
+ try {
+ host = getHost();
+ } catch (Exception e) {
+ error("parseURL, host", url.getURL());
+ }
+ try {
+ port = getPort();
+ } catch (Exception e) {
+ error("parseURL, port", url.getURL());
+ }
+ try {
+ protocol = getProtocol();
+ } catch (Exception e) {
+ error("parseURL, protocol", url.getURL());
+ }
+ try {
+ file = getFile();
+ } catch (Exception e) {
+ error("parseURL, filename", url.getURL());
+ }
+ }
+
+ private void updateURL() {
+ try {
+
+ url = new GlobusURL(protocol + "://" + host + ":" + port + "/" + file);
+ urlField.setText(url.getURL());
+ } catch (Exception e) {
+ error("update : filename", "file");//url.getPath());
+ }
+ }
+
+ public void setFile(String filename) {
+ parseURL();
+ file = filename;
+ updateURL();
+ }
+
+ public void setHost(String h) {
+ parseURL();
+ this.host = h;
+ updateURL();
+ }
+
+ public void setProtocol(String protocol) {
+ parseURL();
+ this.protocol = protocol;
+ updateURL();
+ }
+
+ public void setUser(String user) {
+ parseURL();
+ this.user = user;
+ updateURL();
+ }
+
+ public void setPassword(String pwd) {
+ parseURL();
+ this.pwd = pwd;
+ updateURL();
+ }
+
+
+ public void setPort(int port) {
+ parseURL();
+ this.port = port;
+ updateURL();
+ }
+
+ public void setServerOpSys(int no) {
+ ServerOpSys = no;
+ }
+
+ public void setConnected(boolean value) {
+ connected = value;
+ if (value) {
+ right.setDragEnabled(true); //do nothing
+ disconnect.enable();
+ } else {
+ _actionDisconnect();
+ }
+ // disconnect.enable();
+ }
+
+ public boolean getConnected() {
+ return connected;
+ }
+
+ public void setRootRemote(String r) {
+ currentdir = r;
+
+ }
+
+
+ public void setIsDir(boolean isDir) {
+ this.isDir = isDir;
+ }
+
+ public void _actionConnect(boolean interactive) {
+ connected = false;
+ statusOut("Connecting ... Please wait");
+ displayInterface.connectRemote();
+ if (!connected) {
+ // JOptionPane.showMessageDialog(this, "Please try again.");
+ if (interactive) {
+ displayInterface.connectDlg(null);
+ } else {
+ _actionDisconnect();
+ }
+ return;
+ }
+
+
+ remove(rightView);
+ updateURL();
+ rootpath = "";
+
+ //rootRemote = "//";
+ userHomeDir = displayInterface.getCurrentDir();
+ rootRemote = userHomeDir;
+
+ createRemoteTree();
+ dirInfoButton.setEnabled(false);
+
+ }
+
+ public void createRemoteTree() {
+ right = new RemoteTree(this, "Remote System" + " ->" + host, rootRemote, displayInterface);
+ rightView = right.sc_pane;
+ if (connected) {
+ right.dropTarget.setActive(true);
+ }
+ add(rightView);
+ setToolsEn(true);
+ validate();
+ if (rootRemote.equals("//")) {
+ rootpath = "//";
+ } else {
+ rootpath = getDirFromFile();
+ }
+ if (rootpath.length() > 0) {
+ if (rootpath.endsWith("/")) {
+ rootpath = rootpath.substring(0, rootpath.length() - 1);
+ }
+ if (!rootRemote.equals("//")) {
+ rootpath = rootpath.substring(0, rootpath.lastIndexOf("/")) + "/";
+ }
+
+ } else {
+ rootpath = "//";
+ }
+ statusOut("Successfully connected to " + host + "At root " + rootpath);
+ }
+
+ public void _actionDisconnect() {
+ if(bean){
+ /* rootRemote = "";
+ try {
+ url = new GlobusURL("ftp://dummy.edu:0/dev/null");
+ } catch (Exception e) {
+ logger.debug("This is a real bad error");
+ }
+ urlField.setText(url.getURL());
+ right = new RemoteTree(this, "Remote Tree -> Not connected", rootRemote, displayInterface);
+
+ rightView = right.sc_pane;
+ add(rightView); */
+ right.tree.removeAll();
+ right.tree.setBackground(Color.lightGray);
+ displayInterface.disconnectRemote(false);
+ }else{
+ displayInterface.disconnectRemote(true);
+ right.tree.removeAll();
+ right.dropTarget.setActive(false);
+ remove(rightView);
+ setVisible(false);
+ System.gc();
+ EventQueue.invokeLater(new Runnable() {
+ public void run() {
+ urlField.setText("Remote site address bar");
+ }
+
+ });
+ }
+ disconnect.setEnabled(false);
+ if (connected) {
+ connected = false;
+ }else{
+ return;
+ }
+
+ }
+
+ public void _actionRename() {
+ if (connected) {
+ String tpath[] = right.returnSelectedFiles();
+
+ if (tpath == null) {
+ statusOut("No Selection made");
+ return;
+ } else {
+ new RemoteRenameDialog(this, tpath[0]);
+ return;
+ }
+
+ } else {
+ JOptionPane.showMessageDialog(this, "Remote site is disconnected already");
+ _actionDisconnect();
+ return;
+ }
+
+ }
+
+
+ public DefaultMutableTreeNode seekParent(DefaultMutableTreeNode defaultmutabletreenode, String s) {
+ if (defaultmutabletreenode == null) {
+ return null;
+ }
+
+ int i = defaultmutabletreenode.getChildCount();
+
+ for (int j = 0; j < i; j++) {
+ javax.swing.tree.TreeNode treenode = defaultmutabletreenode.getChildAt(j);
+ String s1 = treenode.toString();
+ if (s.compareTo(s1) == 0) {
+ DefaultMutableTreeNode defaultmutabletreenode1 = (DefaultMutableTreeNode) treenode;
+ return defaultmutabletreenode1;
+ }
+ }
+
+ return null;
+ }
+
+ public void _actionChngDir(String s) {
+ if (connected) {
+ String s1 = s;
+ int l = 0;
+ if (rootpath.length() <= 0) {
+ l = 0;
+ } else {
+ l = rootpath.lastIndexOf("/");
+ }
+ if (s1.lastIndexOf("/") > l + 1) {
+ s1 = s1.substring(l + 1, s1.lastIndexOf("/"));
+ StringTokenizer stringtokenizer = new StringTokenizer(s1, "/");
+ Vector vector = new Vector();
+ for (; stringtokenizer.hasMoreTokens(); vector.addElement(stringtokenizer.nextToken() + "/")) {
+ logger.info("Appending the file separator");
+ }
+
+ clear();
+ //right.makeRemoteInfo();
+ DefaultMutableTreeNode defaultmutabletreenode1 = right.addObject(null, right.RemoteRoot);
+ right.addObject(defaultmutabletreenode1, "");
+ right.treeModel.reload();
+
+ DefaultMutableTreeNode defaultmutabletreenode = right.rootNode;
+
+ String path = "";
+ int i = vector.size();
+
+ for (int j = 0; j < i; j++) {
+ if (flag != false) {
+ path = rootpath + (String) vector.elementAt(j);
+ flag = false;
+ } else {
+ path = (String) vector.elementAt(j);
+ }
+ defaultmutabletreenode = seekParent(defaultmutabletreenode, path);
+
+ if (defaultmutabletreenode != null) {
+ right.tree.expandPath(new TreePath(defaultmutabletreenode.getPath()));
+ }
+
+ }
+ if (defaultmutabletreenode == null) {
+ statusOut("Path not changed ");
+ } else {
+ statusOut("Changed to " + s + " directory");
+ }
+ } else {
+ return;
+ }
+ } else {
+ JOptionPane.showMessageDialog(this, "Remote site is disconnected already");
+ _actionDisconnect();
+ }
+
+ }
+
+ public void _actionRefresh() {
+ if (connected) {
+ flag = true;
+ right.tree.getSelectionModel().clearSelection();
+ String s = getDirFromFile();
+ if (s == null) {
+ _actionChngDir(rootRemote);
+ } else {
+ _actionChngDir(s);
+ }
+ statusOut("Status: Ready");
+ } else {
+ JOptionPane.showMessageDialog(this, "Remote site is disconnected already");
+ _actionDisconnect();
+ }
+
+ }
+
+ public void _actionGo1DirUp() {
+ if (connected) {
+ String s = getDirFromFile();
+ if (s == null) {
+ return;
+ } else {
+ if (s.endsWith("/")) {
+ s = s.substring(0, s.lastIndexOf("/"));
+ }
+ StringTokenizer stringtokenizer = new StringTokenizer(s, "/");
+ ...
[truncated message content] |
|
From: <li...@us...> - 2008-07-22 05:27:27
|
Revision: 2077
http://cogkit.svn.sourceforge.net/cogkit/?rev=2077&view=rev
Author: liuwt
Date: 2008-07-22 05:27:23 +0000 (Tue, 22 Jul 2008)
Log Message:
-----------
OGCE classes which have been modified
Added Paths:
-----------
trunk/current/src/cog/modules/transfer-gui/src/org/globus/ogce/beans/filetransfer/gui/monitor/QueuePanel.class
Property changes on: trunk/current/src/cog/modules/transfer-gui/src/org/globus/ogce/beans/filetransfer/gui/monitor/QueuePanel.class
___________________________________________________________________
Added: svn:mime-type
+ application/octet-stream
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <li...@us...> - 2008-07-22 05:27:05
|
Revision: 2076
http://cogkit.svn.sourceforge.net/cogkit/?rev=2076&view=rev
Author: liuwt
Date: 2008-07-22 05:27:02 +0000 (Tue, 22 Jul 2008)
Log Message:
-----------
Modified Paths:
--------------
trunk/current/src/cog/modules/transfer-gui/src/org/globus/ogce/beans/filetransfer/gui/monitor/QueuePanel.java
trunk/current/src/cog/modules/transfer-gui/src/org/globus/ogce/beans/filetransfer/gui/monitor/UrlCopyPanel.java
Modified: trunk/current/src/cog/modules/transfer-gui/src/org/globus/ogce/beans/filetransfer/gui/monitor/QueuePanel.java
===================================================================
--- trunk/current/src/cog/modules/transfer-gui/src/org/globus/ogce/beans/filetransfer/gui/monitor/QueuePanel.java 2008-07-22 05:26:31 UTC (rev 2075)
+++ trunk/current/src/cog/modules/transfer-gui/src/org/globus/ogce/beans/filetransfer/gui/monitor/QueuePanel.java 2008-07-22 05:27:02 UTC (rev 2076)
@@ -133,7 +133,23 @@
}
return selectedRow;
}
+
+ public int getRowIndex(java.lang.String value, int col)
+ {
+ javax.swing.table.DefaultTableModel tableModel = getModel();
+ int noRows = tableModel.getRowCount();
+ int selectedRow = 0;
+ for(int j = 0; j < noRows; j++)
+ {
+ if(!value.equals(getColumnValue(j, col)))
+ continue;
+ selectedRow = j;
+ break;
+ }
+ return selectedRow;
+ }
+
public void clear() {
DefaultTableModel tableModel
= (DefaultTableModel) getModel();
Modified: trunk/current/src/cog/modules/transfer-gui/src/org/globus/ogce/beans/filetransfer/gui/monitor/UrlCopyPanel.java
===================================================================
--- trunk/current/src/cog/modules/transfer-gui/src/org/globus/ogce/beans/filetransfer/gui/monitor/UrlCopyPanel.java 2008-07-22 05:26:31 UTC (rev 2075)
+++ trunk/current/src/cog/modules/transfer-gui/src/org/globus/ogce/beans/filetransfer/gui/monitor/UrlCopyPanel.java 2008-07-22 05:27:02 UTC (rev 2076)
@@ -40,7 +40,7 @@
this.theApp = theApp;
urlcopyQueuePanel = new QueuePanel();
urlcopyQueuePanel.createHeader(new String[]{"Jobid", "From", "To",
- "Status", "Current", "%", "Errors"});
+ "Status", "Current", "%", "Errors", "RFT"});
add(urlcopyQueuePanel, BorderLayout.CENTER);
urlcopyOptions = new UrlCopyOptions();
// add(urlcopyOptions.getPanel(), BorderLayout.SOUTH);
@@ -58,7 +58,14 @@
"0", "0", "N/A"});
}
+
+ public void addTransfer(String jobid, String from, String to, String rft) {
+ urlcopyQueuePanel.addTransfer(new String[]{jobid, from, to, "Submitted",
+ "0", "0", "N/A", rft});
+
+ }
+
public void startTransfer(String jobid) {
currentJob = jobid;
@@ -431,7 +438,8 @@
controlThread.start();
} else if (actionCommand.equals("Info")) {
String job = urlcopyQueuePanel.getSelectedJob();
- int row = urlcopyQueuePanel.getRowIndex(job);
+
+ int row = urlcopyQueuePanel.getRowIndex(job);
String msg = " Job ID : " +
urlcopyQueuePanel.getColumnValue(row, 0)
+ "\n From : "
@@ -482,7 +490,8 @@
} else if (actionCommand.equals("Delete")) {
String job = urlcopyQueuePanel.getSelectedJob();
int row = urlcopyQueuePanel.getRowIndex(job);
- if (!urlcopyQueuePanel.getColumnValue(row, 3).equals("Finished")) {
+ if (!urlcopyQueuePanel.getColumnValue(row, 3).equals("Finished")
+ && !urlcopyQueuePanel.getColumnValue(row, 3).equals("Expanding_Done")) {
Object aobj[] = {"Yes", "No"};
int k = JOptionPane.showOptionDialog(null, " This job is not Finished yet. Do you wish to cancel the job and delete it?", "Deletion Alert", -1, 2, null, aobj, aobj[0]);
if (k == 1) {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <li...@us...> - 2008-07-22 05:26:34
|
Revision: 2075
http://cogkit.svn.sourceforge.net/cogkit/?rev=2075&view=rev
Author: liuwt
Date: 2008-07-22 05:26:31 +0000 (Tue, 22 Jul 2008)
Log Message:
-----------
OGCE classes which have been modified
Added Paths:
-----------
trunk/current/src/cog/modules/transfer-gui/src/org/globus/ogce/beans/filetransfer/gui/local/
trunk/current/src/cog/modules/transfer-gui/src/org/globus/ogce/beans/filetransfer/gui/local/LocalTreePanel.java
Added: trunk/current/src/cog/modules/transfer-gui/src/org/globus/ogce/beans/filetransfer/gui/local/LocalTreePanel.java
===================================================================
--- trunk/current/src/cog/modules/transfer-gui/src/org/globus/ogce/beans/filetransfer/gui/local/LocalTreePanel.java (rev 0)
+++ trunk/current/src/cog/modules/transfer-gui/src/org/globus/ogce/beans/filetransfer/gui/local/LocalTreePanel.java 2008-07-22 05:26:31 UTC (rev 2075)
@@ -0,0 +1,1462 @@
+//LocalTreePanel.java to display the local tree window
+package org.globus.ogce.beans.filetransfer.gui.local;
+
+import org.apache.log4j.Logger;
+import org.globus.ogce.beans.filetransfer.gui.FileTransferMainPanel;
+import org.globus.ogce.beans.filetransfer.util.DirQueue;
+import org.globus.ogce.beans.filetransfer.util.GridTransferable;
+import org.globus.ogce.beans.filetransfer.util.SortFtpString;
+import org.globus.tools.ui.util.UITools;
+
+import javax.swing.*;
+import javax.swing.event.*;
+import javax.swing.tree.*;
+import java.awt.*;
+import java.awt.dnd.*;
+import java.awt.event.*;
+import java.beans.PropertyChangeListener;
+import java.beans.PropertyChangeSupport;
+import java.io.File;
+import java.io.IOException;
+import java.io.Serializable;
+import java.net.URL;
+import java.util.Enumeration;
+import java.util.Iterator;
+import java.util.List;
+import java.util.StringTokenizer;
+import java.util.Vector;
+
+
+public class LocalTreePanel extends JPanel
+ implements ActionListener, DragSourceListener,
+ DragGestureListener, DropTargetListener, Serializable {
+ private static Logger logger =
+ Logger.getLogger(LocalTreePanel.class.getName());
+ public long firstClickTime = 0;
+ protected DefaultMutableTreeNode rootNode;
+ protected DefaultTreeModel treeModel;
+ protected JTree tree;
+ protected DefaultMutableTreeNode seekNode;
+ protected DefaultMutableTreeNode lastExp;
+
+ protected JToolBar toolBar;
+ public Toolkit toolkit;
+ public String osname;
+
+ public String selectedPath;
+ public JLabel statusText;
+ public JTextField txtField;
+ public boolean noselection;
+ public DragSource dragsource = null;
+ private int opSystem;
+ public int FrameId = 0;
+ String dirname;
+ public LocalEditFrame editFrame;
+ String selectedDestination = null;
+ boolean bean = false;
+
+ //FileToTransfer fileToTransfer;
+ private String draggedValues[];
+
+ private DirQueue queue;
+ private String oldTextField;
+ private String as1 = "";
+ private String asn = new String("");
+ TreePath destinationPath;
+ protected TreePath SelectedTreePath = null;
+ protected TreePath dragtreepath = null;
+ private boolean dragEnable = true;
+ File deleteFile = null;
+ boolean deleteFlag = true;
+ DefaultMutableTreeNode defaultmutabletreenode = null;
+ MutableTreeNode mutabletreenode = null;
+ JButton deleteButton = null;
+ JScrollPane jscrollpane = null;
+ public String LclFile_Sep = new String(System.getProperty("file.separator"));
+ String userHome = System.getProperty("user.home") + LclFile_Sep;
+ boolean home = true;
+ private PropertyChangeSupport pceListeners =
+ new PropertyChangeSupport(this);;
+
+
+
+ protected Vector dirlisteners = new Vector();
+
+ /** Register an action listener to be notified when a button is pressed */
+ public void addDirListener(DirListener l) {
+ dirlisteners.addElement(l);
+ }
+
+ /** Remove an Answer listener from our list of interested listeners */
+ public void removeDirListener(DirListener l) {
+ dirlisteners.removeElement(l);
+ }
+
+ /** Send an event to all registered listeners */
+ public void fireDirEvent(DirEvent e, String path,
+ LocalTreePanel local) {
+
+ Vector list = (Vector) dirlisteners.clone();
+ for (int i = 0; i < list.size(); i++) {
+ DirListener listener = (DirListener) list.elementAt(i);
+ try {
+ switch (e.getID()) {
+ case DirEvent.DIR:
+ listener.dropLocal(e, path, local);
+ break;
+ case DirEvent.LOCALDRAG:
+ listener.dragLocal(e, path, local);
+ break;
+
+ }
+ } catch (Exception direx) {
+ direx.printStackTrace();
+ }
+ }
+ }
+
+
+ public LocalTreePanel() {
+ bean = true;
+ init();
+ FileTransferMainPanel.mainPanel.registerLocalComponent(this);
+ //statusOut("Please click on the view status button to view details of transfer. ");
+
+ }
+
+ public LocalTreePanel(String label) {
+ init();
+ }
+
+ public void init() {
+
+ seekNode = null;
+ lastExp = null;
+ toolkit = Toolkit.getDefaultToolkit();
+ selectedPath = new String();
+ noselection = true;
+
+ osname = new String(System.getProperty("os.name"));
+ if (osname.indexOf("Windows") >= 0) {
+ opSystem = 0;
+ }
+
+ if ((osname.indexOf("Linux") >= 0)
+ || (osname.indexOf("Solaris") >= 0)
+ || (osname.indexOf("Unix") >= 0)
+ || (osname.indexOf("Mac") >= 0)
+ || (osname.indexOf("Irix") >= 0)
+ || (osname.indexOf("AIX") >= 0)
+ || (osname.indexOf("HP-UX") >= 0)
+ || (osname.indexOf("MPE") >= 0)
+ || (osname.indexOf("FreeBSD") >= 0)) {
+ opSystem = 1;
+ }
+ if ((osname.indexOf("OS/2") >= 0)
+ || (osname.indexOf("NetWare") >= 0)) {
+ opSystem = 2;
+ }
+
+ rootNode = new DefaultMutableTreeNode("Local System");
+ treeModel = new DefaultTreeModel(rootNode);
+ treeModel.addTreeModelListener(new LclTreeModelListener());
+ mk_Drives();
+ tree = new JTree(treeModel);
+
+ tree.addTreeWillExpandListener(new MyTreeWillExpandListener());
+ tree.addMouseListener(new MyAdapter()); // for double clicking
+ tree.addTreeSelectionListener(new TreeSelectionListener() {
+
+ public void valueChanged(TreeSelectionEvent treeselectionevent) {
+ DefaultMutableTreeNode defaultmutabletreenode =
+ (DefaultMutableTreeNode) tree.getLastSelectedPathComponent();
+ if (defaultmutabletreenode == null) {
+ return;
+ } else {
+ javax.swing.tree.TreeNode atreenode[] = null;
+ atreenode = defaultmutabletreenode.getPath();
+ selectedPath = returnPath(atreenode);
+ SelectedTreePath = treeselectionevent.getNewLeadSelectionPath();
+ return;
+ }
+ }
+
+ });
+ tree.setEditable(false);
+ tree.getSelectionModel().setSelectionMode(4);
+ tree.setShowsRootHandles(true);
+ ToolTipManager.sharedInstance().registerComponent(tree);
+ LclRenderer lclrenderer = new LclRenderer();
+ tree.setCellRenderer(lclrenderer);
+ tree.putClientProperty("JTree.lineStyle", "Angled");
+ jscrollpane = new JScrollPane(tree);
+ new DropTarget(tree, this);
+ dragsource = DragSource.getDefaultDragSource();
+ dragsource.createDefaultDragGestureRecognizer(tree, 3, this);
+
+ toolBar = new JToolBar();
+ toolBar.setFloatable(false);
+
+
+ JButton jbutton = createButton("images/16x16/reload.png",
+ "Click here to Refresh",
+ "4");
+ toolBar.add(jbutton);
+ jbutton = createButton("images/16x16/up.png",
+ "Click here to go one Directory Up",
+ "6");
+ toolBar.add(jbutton);
+ jbutton = createButton("images/16x16/view_text.png",
+ "Click here to view Directory Info",
+ "3");
+ toolBar.add(jbutton);
+ JToggleButton jbutton1 = createToggleButton("images/16x16/folder_home.png",
+ "Toggle between root and home directories",
+ "2");
+ toolBar.add(jbutton1);
+
+
+ toolBar.addSeparator();
+ toolBar.addSeparator();
+ jbutton = createButton("images/16x16/folder.png",
+ "Click here to Create a new Directory",
+ "7");
+ toolBar.add(jbutton);
+
+
+ jbutton = createButton("images/16x16/folder_rename.png",
+ "Click here to Rename a File/Directory",
+ "5");
+ toolBar.add(jbutton);
+
+ deleteButton = createButton("images/16x16/folder_delete.png",
+ "Click here to delete a File/Directory",
+ "1");
+ toolBar.add(deleteButton);
+
+ if (bean) {
+ toolBar.addSeparator();
+ toolBar.addSeparator();
+ toolBar.addSeparator();
+
+ jbutton = createButton("images/16x16/view_text.png",
+ "View the status window.",
+ "8");
+ toolBar.add(jbutton);
+ jbutton = createButton("images/16x16/view_msg.png",
+ "View the messages window.",
+ "9");
+ toolBar.add(jbutton);
+ }
+
+
+ JPanel jpanel = new JPanel();
+ jpanel.setLayout(new BorderLayout());
+ txtField = new JTextField("Address Bar");
+ setOldField();
+ txtField.addActionListener(this);
+ jpanel.add(txtField, "South");
+ JPanel jpanel1 = new JPanel(new BorderLayout());
+ statusText = new JLabel("Status : Local Files displayed ");
+ //jpanel1.add(statusText, "West");
+
+
+ jpanel.add(toolBar, "North");
+
+ setLayout(new BorderLayout());
+ add(jpanel, "North");
+ add(jscrollpane, "Center");
+ add(jpanel1, "South");
+ setVisible(true);
+ queue = new DirQueue();
+ }
+
+ public String getTextField() {
+ return txtField.getText();
+ }
+
+ public void setFrameId(int id) {
+ FrameId = id;
+ }
+
+ public int getFrameId() {
+ return FrameId;
+ }
+
+ public void setOldField() {
+ oldTextField = txtField.getText();
+ }
+
+ public void setTextField(String newValue) {
+ chDir(newValue);
+ pceListeners.firePropertyChange("txtField", oldTextField, newValue);
+ setOldField();
+ }
+
+ public void addPropertyChangeListener(PropertyChangeListener l) {
+ pceListeners.addPropertyChangeListener(l);
+ }
+
+ public void removePropertyChangeListener(PropertyChangeListener l) {
+ pceListeners.removePropertyChangeListener(l);
+ }
+
+ public void actionPerformed(ActionEvent actionevent) {
+ if (actionevent.getSource() == txtField) {
+ setTextField(txtField.getText());
+ } else {
+ String s = actionevent.getActionCommand();
+ int i = 0;
+ try {
+ i = Integer.valueOf(s).intValue();
+ } catch (NumberFormatException numberformatexception) {
+ numberformatexception.printStackTrace();
+ }
+ switch (i) {
+ case 1: // delete the file
+ removeCurrentNode();
+ break;
+
+ case 2: //toggle home and root
+ toggleHomeRoot();
+ break;
+
+ case 3: // display dir info
+ _actionDirInfo("");
+ break;
+
+ case 4: // refresh the window
+ _actionRefresh();
+ break;
+
+ case 5: // rename the file or dir
+ _actionRename();
+ break;
+
+ case 6: // go up one directory
+ _actionGo1DirUp();
+ break;
+
+ case 7:
+ _actionMakeDir();
+ break;
+
+ case 8:
+ FileTransferMainPanel.mainPanel.showStatusWindow();
+ break;
+
+ case 9:
+ FileTransferMainPanel.mainPanel.showMessagesWindow();
+ break;
+
+ }
+ }
+
+ }
+
+ public void toggleHomeRoot() {
+ clear();
+ if (!home) {
+ DefaultMutableTreeNode defaultmutabletreenode1 = addObject(null, userHome);
+ addObject(defaultmutabletreenode1, "");
+ home = true;
+ JOptionPane.showMessageDialog(this,
+ "Changed to new address: " + userHome);
+ txtField.setText(userHome);
+ } else {
+
+ if (opSystem == 1) {
+ DefaultMutableTreeNode defaultmutabletreenode1 = addObject(null, "//");
+ addObject(defaultmutabletreenode1, "");
+ home = false;
+ JOptionPane.showMessageDialog(this,
+ "Changed to new address: //");
+ txtField.setText("//");
+ } else {
+ mk_Drives();
+ home = false;
+ JOptionPane.showMessageDialog(this,
+ "Changed to new address: System drives");
+ txtField.setText("Local System drives");
+ }
+ }
+
+ }
+
+ public void displayFile() {
+ String as[] = returnSelectedFiles(true);
+ if (as != null) {
+ editFrame = new LocalEditFrame(as, LclFile_Sep);
+ editFrame.addWindowListener(new WindowAdapter() {
+
+ public void windowClosing(WindowEvent windowevent) {
+ editFrame = null;
+ System.gc();
+ }
+
+ });
+ editFrame.pack();
+ editFrame.setVisible(true);
+ }
+ }
+
+ public void clear() {
+ rootNode.removeAllChildren();
+ treeModel.reload();
+ }
+
+ public JButton createButton(String s, String s1, String s2) {
+ ClassLoader classLoader = getClass().getClassLoader();
+ URL jarCogImage = classLoader.getResource(s);
+ JButton jbutton = new JButton(new ImageIcon(jarCogImage));
+ jbutton.setActionCommand(s2);
+ jbutton.addActionListener(this);
+ jbutton.setToolTipText(s1);
+ Dimension dimension = new Dimension(20, 20);
+ jbutton.setMaximumSize(dimension);
+ jbutton.setMinimumSize(dimension);
+ jbutton.setPreferredSize(dimension);
+ jbutton.setRequestFocusEnabled(false);
+ return jbutton;
+ }
+
+ public JToggleButton createToggleButton(String s, String s1, String s2) {
+ ClassLoader classLoader = getClass().getClassLoader();
+ URL jarCogImage = classLoader.getResource(s);
+ JToggleButton jbutton = new JToggleButton(new ImageIcon(jarCogImage));
+ jbutton.setActionCommand(s2);
+ jbutton.addActionListener(this);
+ jbutton.setToolTipText(s1);
+ Dimension dimension = new Dimension(20, 20);
+ jbutton.setMaximumSize(dimension);
+ jbutton.setMinimumSize(dimension);
+ jbutton.setPreferredSize(dimension);
+ jbutton.setRequestFocusEnabled(false);
+ return jbutton;
+ }
+
+ public void mk_Drives() {
+
+ File[] roots = File.listRoots();
+ try {
+ for (int i = 0; i < roots.length; i++) {
+ File root = roots[i];
+ if (root.isDirectory()) {
+ DefaultMutableTreeNode defaultmutabletreenode = addObject(null, root.getCanonicalPath());
+ addObject(defaultmutabletreenode, "");
+ }
+ }
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+
+ //For Windows, let home = false
+ if (opSystem == 0) {
+ home = false;
+ }
+
+ }
+
+ public DefaultMutableTreeNode addObject(Object obj) {
+ DefaultMutableTreeNode defaultmutabletreenode = null;
+ TreePath treepath = tree.getSelectionPath();
+ if (treepath == null) {
+ toolkit.beep();
+ return null;
+ }
+ defaultmutabletreenode = (DefaultMutableTreeNode) treepath.getLastPathComponent();
+ if (defaultmutabletreenode == rootNode) {
+ toolkit.beep();
+ return null;
+ } else {
+ return addObject(defaultmutabletreenode, obj, true);
+ }
+ }
+
+ public DefaultMutableTreeNode addObject
+ (DefaultMutableTreeNode defaultmutabletreenode, Object obj) {
+ return addObject(defaultmutabletreenode, obj, false);
+ }
+
+ public DefaultMutableTreeNode addObject
+ (DefaultMutableTreeNode defaultmutabletreenode, Object obj,
+ boolean flag) {
+ DefaultMutableTreeNode defaultmutabletreenode1 =
+ new DefaultMutableTreeNode(obj);
+ if (defaultmutabletreenode == null) {
+ defaultmutabletreenode = rootNode;
+ }
+ treeModel.insertNodeInto(defaultmutabletreenode1,
+ defaultmutabletreenode,
+ defaultmutabletreenode.getChildCount());
+ if (flag) {
+ tree.scrollPathToVisible(new TreePath(defaultmutabletreenode1.getPath()));
+ }
+ return defaultmutabletreenode1;
+ }
+
+ public void listDir(DefaultMutableTreeNode defaultmutabletreenode,
+ String s,
+ boolean flag) {
+
+ File file = new File(s);
+
+ String as[] = null;
+ as = file.list();
+ if (as == null) {
+ return;
+ }
+ int i = as.length;
+ SortFtpString.startSort(as);
+ if (i == 0) {
+ addObject(defaultmutabletreenode, "", false);
+ return;
+ }
+ for (int j = 0; j < i; j++) {
+ File file1;
+ if (file.toString().endsWith(LclFile_Sep)) {
+ file1 = new File(file.toString() + as[j]);
+ } else {
+ file1 = new File(file.toString() + LclFile_Sep + as[j]);
+ }
+ if (file1.isDirectory()) {
+ DefaultMutableTreeNode defaultmutabletreenode1 = addObject(defaultmutabletreenode, as[j] + LclFile_Sep, flag);
+ addObject(defaultmutabletreenode1, "", false);
+ }
+ }
+
+ for (int k = 0; k < i; k++) {
+ File file2;
+ if (file.toString().endsWith(LclFile_Sep)) {
+ file2 = new File(file.toString() + as[k]);
+ } else {
+ file2 = new File(file.toString() + LclFile_Sep + as[k]);
+ }
+ if (!file2.isDirectory()) {
+ addObject(defaultmutabletreenode, as[k], flag);
+ }
+ Font font = new Font("Dialog", Font.PLAIN, 12);
+ Enumeration keys = UIManager.getLookAndFeelDefaults()
+ .keys();
+
+ while (keys.hasMoreElements()) {
+ Object key = keys.nextElement();
+
+ if (UIManager.get(key) instanceof Font) {
+ UIManager.put(key, font);
+ }
+ }
+ }
+
+ }
+
+ public TreePath[] returnSelectedPaths() {
+ DefaultMutableTreeNode defaultmutabletreenode =
+ (DefaultMutableTreeNode) tree.getLastSelectedPathComponent();
+ TreePath atreepath[] = null;
+ if (defaultmutabletreenode == null) {
+ return atreepath;
+ }
+ //atreepath = tree.getSelectionModel().getSelectionPaths();
+ if (defaultmutabletreenode.isLeaf()) {
+ atreepath = tree.getSelectionModel().getSelectionPaths();
+ return atreepath;
+ } else {
+ TreePath atreepath1[] = tree.getSelectionPaths();
+ return atreepath1;
+ // return null;
+ }
+
+ }
+
+ public String[] returnSelectedPaths1() {
+ TreePath atreepath[] = tree.getSelectionModel().getSelectionPaths();
+ String s = null;
+ String as[] = null;
+ if (atreepath != null) {
+ int i = atreepath.length;
+ as = new String[i];
+ for (int j = 0; j < i; j++) {
+ Object aobj[] = atreepath[j].getPath();
+ int k = aobj.length;
+ for (int l = 1; l < k; l++) {
+ DefaultMutableTreeNode defaultmutabletreenode = (DefaultMutableTreeNode) aobj[l];
+ if (!defaultmutabletreenode.isLeaf()) {
+ if (l == 1 && defaultmutabletreenode
+ != rootNode) {
+ s = new String();
+ }
+ s = s.concat(aobj[l].toString());
+ }
+ }
+
+ as[j] = new String(s);
+ }
+
+ }
+ return as;
+ }
+
+ public String[] returnSelectedFiles(boolean flag) {
+ TreePath atreepath[] = returnSelectedPaths();
+ String as[] = null;
+ if (atreepath != null) {
+ int i = atreepath.length;
+ as = new String[i];
+ for (int j = 0; j < i; j++) {
+ Object aobj[] = atreepath[j].getPath();
+ int k = aobj.length;
+ String s = new String();
+ for (int l = 1; l < k; l++) {
+ s = s.concat(aobj[l].toString());
+ }
+
+ if (flag) {
+ as[j] = new String("file:" + s);
+ } else {
+ as[j] = new String(s);
+ }
+ }
+
+ }
+ return as;
+ }
+
+
+ public DefaultMutableTreeNode seekParent(DefaultMutableTreeNode defaultmutabletreenode, String s) {
+ if (defaultmutabletreenode == null) {
+
+ return null;
+ }
+
+ int i = defaultmutabletreenode.getChildCount();
+ for (int j = 0; j < i; j++) {
+ javax.swing.tree.TreeNode treenode =
+ defaultmutabletreenode.getChildAt(j);
+ String s1 = treenode.toString();
+ if (s.compareTo(s1) == 0) {
+ DefaultMutableTreeNode defaultmutabletreenode1 = (DefaultMutableTreeNode) treenode;
+ return defaultmutabletreenode1;
+ }
+ }
+
+
+ return null;
+ }
+
+
+ public boolean chDir(String s) {
+ String s1 = s;
+ if (s1.endsWith(LclFile_Sep)) {
+ s1 = s1.substring(0, s1.lastIndexOf(LclFile_Sep));
+ } else {
+ return false;
+ }
+ //JOptionPane.showMessageDialog(null, "string s1=" + s1);
+ StringTokenizer stringtokenizer = new StringTokenizer(s1, LclFile_Sep);
+ Vector vector = new Vector();
+ for (; stringtokenizer.hasMoreTokens(); vector.addElement(stringtokenizer.nextToken() + LclFile_Sep)) {
+ logger.info("Adding the file separator");
+ }
+ if (opSystem == 0) {
+ String s2 = s1.substring(0, 1).toUpperCase();
+ char c = s2.charAt(0);
+ char ac[] = ((String) vector.firstElement()).toCharArray();
+ ac[0] = c;
+ vector.setElementAt(new String(ac), 0);
+ }
+ if (opSystem == 1) {
+ vector.add(0, new String(LclFile_Sep));
+ }
+ clear();
+ mk_Drives();
+
+ // treeModel.reload();
+ DefaultMutableTreeNode defaultmutabletreenode = rootNode;
+
+ int i = vector.size();
+
+ for (int j = 0; j < i; j++) {
+
+ defaultmutabletreenode = seekParent(defaultmutabletreenode, (String) vector.elementAt(j));
+ if (defaultmutabletreenode != null) {
+ tree.expandPath(new TreePath(defaultmutabletreenode.getPath()));
+ }
+
+ }
+
+ if (defaultmutabletreenode == null) {
+ setOldField();
+
+ //statusOut("Status : Ready ");
+ } else {
+ //statusOut("Changed to " + s + "directory");
+ //statusOut("Status : Ready ");
+ }
+ return true;
+ }
+
+ public void whereIsNode(DefaultMutableTreeNode defaultmutabletreenode, int i, String s) {
+ seekNode = null;
+ for (int j = 0; j < i; j++) {
+ DefaultMutableTreeNode defaultmutabletreenode1 =
+ (DefaultMutableTreeNode) defaultmutabletreenode.getChildAt(j);
+ if (defaultmutabletreenode1.isLeaf()) {
+ continue;
+ }
+ javax.swing.tree.TreeNode atreenode[] = defaultmutabletreenode1.getPath();
+ TreePath treepath = new TreePath(atreenode);
+ String s1 = defaultmutabletreenode1.toString();
+ if (s1.equals(s)) {
+ j = i + 1;
+ seekNode = defaultmutabletreenode1;
+ break;
+ }
+ if (!tree.isExpanded(treepath)) {
+ continue;
+ }
+ if (s1.equals(s)) {
+ j = i + 1;
+ seekNode = defaultmutabletreenode1;
+ break;
+ }
+ whereIsNode(defaultmutabletreenode1, defaultmutabletreenode1.getChildCount(), s);
+ }
+
+ }
+
+ public void _actionRefresh() {
+ String s = txtField.getText();
+ chDir(s);
+ logger.info("The window was refreshed at dir = " + s);
+
+ }
+
+
+ public synchronized void statusOut(String s) {
+ //statusText.setText(s);
+
+ }
+
+ class LclRenderer extends DefaultTreeCellRenderer {
+
+ public Component getTreeCellRendererComponent
+ (JTree jtree, Object obj, boolean flag,
+ boolean flag1, boolean flag2, int i,
+ boolean flag3) {
+ super.getTreeCellRendererComponent(jtree, obj, flag,
+ flag1, flag2, i, flag3);
+ if (!flag2) {
+ setToolTipText("Local Path");
+ if (isLocalSystem(obj)) {
+ setIcon(LclSystemIcon);
+ setToolTipText("Local Hirarchy");
+ }
+ if (isLocalDrive(obj)) {
+ setIcon(LclDriveIcon);
+ setToolTipText("Local Drives");
+ }
+ } else {
+ setToolTipText("fileClickMessage");
+ }
+ return this;
+ }
+
+ protected boolean isLocalSystem(Object obj) {
+ DefaultMutableTreeNode defaultmutabletreenode =
+ (DefaultMutableTreeNode) obj;
+ Object obj1 = defaultmutabletreenode.getUserObject();
+ String s = obj1.toString();
+ return s.indexOf("local") >= 0;
+ }
+
+ protected boolean isLocalDrive(Object obj) {
+ DefaultMutableTreeNode defaultmutabletreenode =
+ (DefaultMutableTreeNode) obj;
+ Object obj1 = defaultmutabletreenode.getUserObject();
+ String s = obj1.toString();
+ return s.indexOf("NodeLabel") >= 0;
+ }
+
+
+ ImageIcon LclSystemIcon;
+ ImageIcon LclDriveIcon;
+ ImageIcon LclFileIcon;
+
+ public LclRenderer() {
+ LclSystemIcon = new ImageIcon("images/16x16/konsole2.png");
+ LclDriveIcon = new ImageIcon("images/16x16/filesave.png");
+ LclFileIcon = new ImageIcon("file.gif");
+ super.setBorderSelectionColor(null);
+ super.setBackgroundNonSelectionColor(null);
+ super.setTextNonSelectionColor(Color.blue);
+ super.setLeafIcon(LclFileIcon);
+ }
+ }
+
+ class MyTreeWillExpandListener
+ implements TreeWillExpandListener {
+ MyTreeWillExpandListener() {
+ }
+
+ public void treeWillExpand(TreeExpansionEvent treeexpansionevent) {
+ DefaultMutableTreeNode defaultmutabletreenode = null;
+ Object aobj[] = null;
+ aobj = treeexpansionevent.getPath().getPath();
+ int i = aobj.length;
+ defaultmutabletreenode = (DefaultMutableTreeNode) aobj[i - 1];
+ if (defaultmutabletreenode == rootNode) {
+ statusOut("Node was not selected to expand.");
+ return;
+ } else {
+
+ DefaultMutableTreeNode defaultmutabletreenode1 = (DefaultMutableTreeNode) treeModel.getChild(aobj[i - 1], 0);
+ treeModel.removeNodeFromParent(defaultmutabletreenode1);
+ String s1 = returnPath(aobj);
+ statusOut("Please wait..Expanding dir " + s1);
+ listDir(defaultmutabletreenode, s1, false);
+
+ txtField.setText(s1);
+
+ noselection = false;
+ tree.getSelectionModel().clearSelection();
+ statusOut("Status: Ready");
+ return;
+ }
+ }
+
+ public void treeWillCollapse(TreeExpansionEvent treeexpansionevent) {
+ DefaultMutableTreeNode defaultmutabletreenode = null;
+ tree.getSelectionModel().clearSelection();
+ Object aobj[] = null;
+ aobj = treeexpansionevent.getPath().getPath();
+ int i = aobj.length;
+ if (i > 1) {
+ defaultmutabletreenode = (DefaultMutableTreeNode) aobj[i - 1];
+ } else {
+ defaultmutabletreenode = rootNode;
+ }
+ if (defaultmutabletreenode == rootNode) {
+ // txtField.setText("Local Path ");
+ noselection = true;
+ treeModel.reload(defaultmutabletreenode);
+ return;
+ }
+ noselection = false;
+ defaultmutabletreenode.removeAllChildren();
+ addObject(defaultmutabletreenode, "");
+ aobj = ((DefaultMutableTreeNode) defaultmutabletreenode.getParent()).getPath();
+ lastExp = null;
+ getLastExpandeNode(rootNode, treeexpansionevent.getPath());
+ if (lastExp != null) {
+ javax.swing.tree.TreeNode atreenode[] = treeModel.getPathToRoot(lastExp);
+ TreePath treepath = new TreePath(atreenode);
+ Object aobj1[] = treepath.getPath();
+ String s1 = returnPath(aobj1);
+ txtField.setText(s1);
+ } else {
+
+ //txtField.setText("Local Path ");
+ noselection = true;
+ }
+ treeModel.reload(defaultmutabletreenode);
+ }
+
+ }
+
+ class LclTreeModelListener
+ implements TreeModelListener {
+
+ public void treeNodesChanged(TreeModelEvent treemodelevent) {
+ DefaultMutableTreeNode defaultmutabletreenode = (DefaultMutableTreeNode) treemodelevent.getTreePath().getLastPathComponent();
+ try {
+ int i = treemodelevent.getChildIndices()[0];
+ defaultmutabletreenode = (DefaultMutableTreeNode) defaultmutabletreenode.getChildAt(i);
+ } catch (NullPointerException nullpointerexception) {
+ nullpointerexception.printStackTrace();
+ }
+ javax.swing.tree.TreeNode atreenode[] = null;
+ atreenode = defaultmutabletreenode.getPath();
+ File file = new File(returnPath(atreenode));
+ File file1 = new File(selectedPath);
+ file1.renameTo(file);
+ }
+
+ public void treeNodesInserted(TreeModelEvent treemodelevent) {
+ }
+
+ public void treeNodesRemoved(TreeModelEvent treemodelevent) {
+ }
+
+ public void treeStructureChanged(TreeModelEvent treemodelevent) {
+ }
+
+ LclTreeModelListener() {
+ }
+ }
+
+
+ public String returnPath(Object aobj[]) {
+ int i = aobj.length;
+ String s = new String();
+ for (int j = 1; j < i; j++) {
+ s = s.concat(aobj[j].toString());
+ }
+ return s;
+ }
+
+ public void setSelectedSource() {
+ draggedValues = returnSelectedFiles(false);
+ File lcl = new File(draggedValues[0]);
+ fireDirEvent(new DirEvent(this, DirEvent.LOCALDRAG),
+ lcl.getAbsolutePath(), this);
+ }
+
+ public void setSelectedDestination() {
+ String as[] = returnSelectedPaths1();
+ if (as == null || as[0] == null) {
+ as = new String[1];
+ as[0] = new String(txtField.getText());
+ }
+ this.selectedDestination = as[0];
+ }
+
+ public void transfer() {
+ fireDirEvent(new DirEvent(this, DirEvent.DIR), selectedDestination, this);
+ }
+
+ public void dragGestureRecognized(DragGestureEvent draggestureevent) {
+ draggedValues = returnSelectedFiles(false);
+
+ dragtreepath = SelectedTreePath;
+ if (draggedValues == null) {
+
+ return;
+ } else if (!(dragEnable)) {
+ JOptionPane.showMessageDialog(null, "Please wait till the status\n bar shows drag enabled.");
+ return;
+
+ } else {
+ GridTransferable Gridtransferable =
+ new GridTransferable(draggedValues);
+
+ draggestureevent.startDrag(DragSource.DefaultCopyDrop,
+ Gridtransferable, this);
+ queue.deleteAll();
+ File lcl = new File(draggedValues[0]);
+ fireDirEvent(new DirEvent(this, DirEvent.LOCALDRAG),
+ lcl.getAbsolutePath(), this);
+ statusOut("Please wait. Copying the directory ... ");
+ return;
+ }
+ }
+
+ public void setDragEnabled(boolean flag) {
+ dragEnable = flag;
+ if (flag) {
+
+ tree.setBackground(Color.white);
+ statusOut("Successfully done dragging.");
+ statusOut("Status : Ready ");
+ } else {
+ tree.setBackground(Color.lightGray);
+ statusOut("Frame disabled. Please wait ... till" +
+ " the color changes back to white.");
+ }
+
+ }
+
+
+ public void dragEnter(DragSourceDragEvent dragsourcedragevent) {
+ }
+
+ public void dragOver(DragSourceDragEvent dragsourcedragevent) {
+ }
+
+ public void dragExit(DragSourceEvent dragsourceevent) {
+ }
+
+ public void dropActionChanged(DragSourceDragEvent dragsourcedragevent) {
+ }
+
+ public void dragDropEnd(DragSourceDropEvent dragsourcedropevent) {
+ if (dragsourcedropevent.getDropSuccess()) {
+ int i = dragsourcedropevent.getDropAction();
+ logger.info("Value of i :" + i);
+ }
+ }
+
+ public void dragEnter(java.awt.dnd.DropTargetDragEvent droptargetdragevent) {
+// int i = droptargetdragevent.getDropAction();
+// if ((i & 1) != 0) {
+// statusOut("Dragging ...");
+// }
+// if ((i & 2) != 0) {
+// statusOut("Moving ...");
+// }
+// if ((i & 0x40000000) != 0) {
+// statusOut("Linking ...");
+// }
+// if (!isDragAcceptable(droptargetdragevent)) {
+// droptargetdragevent.rejectDrag();
+// return;
+// } else {
+// return;
+// }
+
+ }
+
+ public void dragExit(java.awt.dnd.DropTargetEvent droptargetevent) {
+ }
+
+ public void dragOver(java.awt.dnd.DropTargetDragEvent droptargetdragevent) {
+
+ //set cursor location. Needed in setCursor method
+ Point cursorLocationBis = droptargetdragevent.getLocation();
+ TreePath dPath =
+ tree.getPathForLocation(cursorLocationBis.x, cursorLocationBis.y);
+
+ tree.setSelectionPath(dPath);
+ tree.scrollPathToVisible(dPath);
+ cursorLocationBis = null;
+
+ }
+
+ public void dropActionChanged(java.awt.dnd.DropTargetDragEvent droptargetdragevent) {
+ if (!isDragAcceptable(droptargetdragevent)) {
+ droptargetdragevent.rejectDrag();
+ return;
+ } else {
+ return;
+ }
+ }
+
+ public void drop(java.awt.dnd.DropTargetDropEvent droptargetdropevent) {
+ if (!isDropAcceptable(droptargetdropevent)) {
+ droptargetdropevent.rejectDrop();
+ return;
+ } else if (!(dragEnable)) {
+ return;
+ }
+ //get new parent node
+ Point loc = droptargetdropevent.getLocation();
+ destinationPath = tree.getPathForLocation(loc.x, loc.y);
+
+
+ final String msg = testDropTarget(destinationPath, dragtreepath);
+ if (msg != null) {
+ droptargetdropevent.rejectDrop();
+
+ SwingUtilities.invokeLater(new Runnable() {
+ public void run() {
+ JOptionPane.showMessageDialog(
+ null, msg, "Error Dialog", JOptionPane.ERROR_MESSAGE
+ );
+ }
+ });
+ return;
+ }
+
+
+ java.awt.datatransfer.Transferable transferable = droptargetdropevent.getTransferable();
+ java.awt.datatransfer.DataFlavor adataflavor[] = transferable.getTransferDataFlavors();
+ for (int i = 0; i < adataflavor.length; i++) {
+ java.awt.datatransfer.DataFlavor dataflavor = adataflavor[i];
+ try {
+ if (dataflavor.equals(java.awt.datatransfer.DataFlavor.javaFileListFlavor)) {
+ List list = (List) transferable.getTransferData(dataflavor);
+ Iterator iterator = list.iterator();
+ Vector vector = new Vector();
+ String s;
+ for (; iterator.hasNext(); vector.add(s)) {
+ s = iterator.next().toString();
+ }
+
+
+ doCopyAction(vector);
+ }
+ } catch (java.awt.datatransfer.UnsupportedFlavorException unsupportedflavorexception) {
+ logger.debug("Exception = " + unsupportedflavorexception.toString());
+ } catch (IOException ioexception) {
+ logger.debug("Exception = " + ioexception.toString());
+ }
+ }
+
+ droptargetdropevent.dropComplete(true);
+
+ }
+
+ private String testDropTarget(TreePath destination, TreePath dropper) {
+ //Typical Tests for dropping
+
+ //Test 1.
+ boolean destinationPathIsNull = destination == null;
+ if (destinationPathIsNull) {
+ return "Invalid drop location.";
+ }
+ if (destination.equals(dropper)) {
+ logger.info("destination =" + destination +
+ "\nsource= " + dropper);
+ _actionRefresh();
+ return "Destination cannot be same as source";
+ }
+
+
+ return null;
+ }
+
+ public boolean isDragAcceptable(java.awt.dnd.DropTargetDragEvent droptargetdragevent) {
+ return (droptargetdragevent.getDropAction() & 3) != 0;
+ }
+
+ public boolean isDropAcceptable(java.awt.dnd.DropTargetDropEvent droptargetdropevent) {
+ return (droptargetdropevent.getDropAction() & 3) != 0;
+ }
+
+
+ public void doCopyAction(Vector vector) {
+
+ int i = vector.size();
+
+ String s = null;
+ String as[] = returnSelectedPaths1();
+
+ if (as == null || as[0] == null) {
+ as = new String[1];
+ as[0] = new String(txtField.getText());
+ }
+
+
+ Object aobj[] = destinationPath.getPath();
+ int k = aobj.length;
+ for (int l = 1; l < k; l++) {
+ DefaultMutableTreeNode defaultmutabletreenode = (DefaultMutableTreeNode) aobj[l];
+ if (!defaultmutabletreenode.isLeaf()) {
+ if (l == 1 && defaultmutabletreenode != rootNode) {
+ s = new String();
+ }
+ s = s.concat(aobj[l].toString());
+ }
+ }
+ asn = as[0];
+ for (int j = 0; j < i; j++) {
+ as1 = (String) vector.elementAt(j);
+
+
+ }
+ //System.out.println("transfer data");
+ logger.info("Called the drop listener");
+// System.out.println("called the drop listener");
+// FileTransferMainPanel.mainPanel.showStatusWindow();
+// FileTransferMainPanel.mainPanel.showMessagesWindow();
+ fireDirEvent(new DirEvent(this, DirEvent.DIR), as[0], this);
+ }
+
+ public void getLastExpandeNode(DefaultMutableTreeNode defaultmutabletreenode, TreePath treepath) {
+ int i = defaultmutabletreenode.getChildCount();
+ for (int j = 0; j < i; j++) {
+ DefaultMutableTreeNode defaultmutabletreenode1 = (DefaultMutableTreeNode) defaultmutabletreenode.getChildAt(j);
+ if (!defaultmutabletreenode1.isLeaf()) {
+ javax.swing.tree.TreeNode atreenode[] = defaultmutabletreenode1.getPath();
+ TreePath treepath1 = new TreePath(atreenode);
+ if (!treepath1.equals(treepath) && tree.isExpanded(treepath1)) {
+ lastExp = defaultmutabletreenode1;
+ getLastExpandeNode(defaultmutabletreenode1, treepath);
+ }
+ }
+ }
+
+ }
+
+ public void removeCurrentNode() {
+ int i = tree.getSelectionModel().getSelectionCount();
+ if (i == 0) {
+ toolkit.beep();
+ statusOut("Nothing was selected");
+ statusOut("Status : Ready ");
+ return;
+ }
+ for (int j = 0; j < i; j++) {
+ TreePath treepath = tree.getSelectionPath();
+ if (treepath != null) {
+
+ defaultmutabletreenode
+ = (DefaultMutableTreeNode) treepath.getLastPathComponent();
+ mutabletreenode = (MutableTreeNode) defaultmutabletreenode.getParent();
+ javax.swing.tree.TreeNode atreenode[] = null;
+ atreenode = defaultmutabletreenode.getPath();
+ String s = returnPath(atreenode);
+ if (mutabletreenode != null && mutabletreenode != rootNode) {
+ String msg = null;
+ deleteFile = new File(s);
+
+ if (deleteFile.isDirectory()) {
+ msg = "directory";
+
+ } else {
+ msg = "file";
+ }
+ Object aobj[] = {
+ "Cancel", "Delete"};
+ int k = JOptionPane.showOptionDialog(this, "Do you really want to delete this " + msg, "Delete Alert", -1, 2, null, aobj, aobj[0]);
+ if (k != 0) {
+ if (deleteFile.isDirectory()) {
+ dirDelete();
+ } else {
+ deleteFlag = deleteFile.delete();
+
+ if (deleteFlag) {
+ logger.info("\nThe" + msg + "is successfully deleted " + deleteFile);
+ treeModel.removeNodeFromParent(defaultmutabletreenode);
+ if (treeModel.getChildCount(mutabletreenode) == 0) {
+ addObject((DefaultMutableTreeNode) mutabletreenode, "");
+ }
+ statusOut("Successfully deleted" +
+ " File: " + deleteFile);
+ statusOut("Status : Ready ");
+ } else {
+ toolkit.beep();
+ statusOut("Permission Denied");
+ statusOut("Status : Ready ");
+ JOptionPane.showMessageDialog(null, deleteFile + " : Permission Denied.");
+ }
+ }
+ } else {
+ toolkit.beep();
+ statusOut("No selection was made");
+ statusOut("Status : Ready ");
+ }
+ }
+ }
+ }
+ }
+
+ public void dirDelete() {
+ Thread dirDelete = new Thread() {
+ public void run() {
+ deleteButton.setEnabled(false);
+ setDragEnabled(false);
+ deleteFlag = deleteDir(deleteFile);
+ if (deleteFlag) {
+ logger.info("\nThe Directory is successfully" +
+ " deleted " + deleteFile);
+ treeModel.removeNodeFromParent(defaultmutabletreenode);
+ if (treeModel.getChildCount(mutabletreenode) == 0) {
+ addObject((DefaultMutableTreeNode) mutabletreenode, "");
+ }
+ _actionRefresh();
+ statusOut("Successfully deleted" +
+ " Directory: " + deleteFile);
+ statusOut("Status : Ready ");
+ } else {
+ toolkit.beep();
+ JOptionPane.showMessageDialog(null, deleteFile
+ + " : Permission Denied.");
+ statusOut("Directory: Permission Denied");
+ statusOut("Status : Ready ");
+ }
+ deleteButton.setEnabled(true);
+ setDragEnabled(true);
+ }
+ };
+ dirDelete.start();
+ }
+
+ public boolean deleteDir(File dirname) {
+
+ File[] files = dirname.listFiles();
+
+ for (int i = 0; i < files.length; i++) {
+ File current = files[i];
+ if (current.isDirectory()) {
+ deleteDir(current);
+
+ } else {
+ current.delete();
+ statusOut("Deleting: " + current.getName());
+ logger.info("Deleted the file " + current.getName());
+ }
+ }
+
+ logger.info("Deleted the directory " + dirname.getName());
+ boolean flag = dirname.delete();
+ return flag;
+
+
+ }
+
+ public boolean mkNewDir(String dir, String path) {
+ File newfile = new File(path);
+ if (!(newfile.exists())) {
+ try {
+ newfile.mkdirs();
+ return true;
+ } catch (Exception e) {
+ logger.debug("\nThere is no permission to create directory" + path);
+ return false;
+
+ }
+ } else {
+ logger.info("\nDirectory already exists : " + path);
+ return true;
+
+ }
+ }
+
+ public void _actionMakeDir(String s) {
+ String as[] = returnSelectedPaths1();
+ if (as == null || as[0] == null) {
+ if (noselection) {
+ toolkit.beep();
+ statusOut("no Path");
+ return;
+ }
+ as = new String[1];
+ as[0] = new String(txtField.getText());
+ }
+
+ File file = new File(as[0] + s); //"newFolder");
+ if (file.exists()) {
+ JOptionPane.showMessageDialog(this, "File name already exists.");
+ return;
+ }
+ if (file.mkdir()) {
+ statusOut("New Folder created : " + s);
+ statusOut("Status : Ready ");
+ } else {
+ statusOut("New Folder could not be created : " + s);
+ statusOut("Status : Ready ");
+ JOptionPane.showMessageDialog(this, "Permission denied.");
+ return;
+ }
+ chDir(as[0]);
+ whereIsNode(rootNode, rootNode.getChildCount(), s + LclFile_Sep);
+ if (seekNode != null) {
+ javax.swing.tree.TreeNode atreenode[]
+ = treeModel.getPathToRoot(seekNode);
+ TreePath treepath1
+ = new TreePath(atreenode);
+ tree.scrollPathToVisible(treepath1);
+ tree.setSelectionPath(treepath1);
+ }
+
+ }
+
+ public void _actionMakeDir() {
+ String dirname = JOptionPane.showInputDialog("Please Enter the Dir Name:");
+ if (dirname != null) {
+ _actionMakeDir(dirname);
+ }
+ }
+
+ public File[] _actionDirInfo(String s1) {
+ File file = null;
+ String as[] = null;
+ File as2[] = null;
+ //LclDirInfoFrame lclDirInfoFrame;
+
+ if (s1.equals("")) {
+ //JOptionPane.showMessageDialog(null, "into actionDirInfor");
+ file = new File(txtField.getText() + ".");
+ as = file.list();
+ } else {
+ file = new File(s1 + ".");
+ as2 = file.listFiles();
+ return as2;
+ }
+ if (as == null && as2 == null) {
+ return null;
+ }
+
+ SortFtpString.startSort(as);
+ String s = txtField.getText();
+ if (s.endsWith(LclFile_Sep)) {
+ s = s.substring(0, s.lastIndexOf(LclFile_Sep));
+ }
+ String as1[] = new String[4];
+ as1[0] = new String("Info Window");
+ as1[1] = new String("Name");
+ as1[2] = new String("Size");
+ as1[3] = new String("Last Modified");
+
+ new LclDirInfoFrame(as1, s + LclFile_Sep, as);
+ return null;
+ }
+
+
+ public void _actionGo1DirUp() {
+ String s = txtField.getText();
+ if (s.endsWith(LclFile_Sep)) {
+ s = s.substring(0, s.lastIndexOf(LclFile_Sep));
+ }
+ StringTokenizer stringtokenizer = new StringTokenizer(s, LclFile_Sep);
+ Vector vector = new Vector();
+ for (; stringtokenizer.hasMoreTokens(); vector.addElement(stringtokenizer.nextToken() + LclFile_Sep)) {
+ logger.info("Adding the separator");
+ }
+ int i = vector.size();
+
+
+ if (i < 2) {
+ try {
+ tree.fireTreeWillCollapse(new TreePath(rootNode.getPath()));
+ } catch (ExpandVetoException expandvetoexception) {
+ expandvetoexception.printStackTrace();
+ }
+ } else {
+ vector.removeElementAt(i - 1);
+ i = vector.size();
+ String s1 = new String();
+ for (int j = 0; j < i; j++) {
+ s1 = s1.concat(vector.elementAt(j).toString());
+ }
+
+ chDir(s1);
+ }
+ }
+
+ public void _actionRename() {
+ String tpath[] = returnSelectedFiles(false);
+
+ if (tpath == null) {
+ toolkit.beep();
+ statusOut("No Selection made");
+ return;
+ } else {
+ new LclRenameDialog(this, tpath[0]);
+ return;
+ }
+
+ }
+
+ class MyAdapter extends MouseAdapter {
+ public void mouseClicked(MouseEvent evt) {
+ //JOptionPane.showMessageDialog(null, "into mouseclicked method");
+ long clickTime = System.currentTimeMillis();
+ long clickInterval = clickTime - firstClickTime;
+ if (clickInterval < 300) {
+ Thread display = new Thread() {
+ public void run() {
+ displayFile();
+ firstClickTime = 0;
+ }
+ };
+ display.start();
+ } else {
+ firstClickTime = clickTime;
+ } // end of if - else
+ } // end of mouseclicked
+
+ } // end of class
+ public static void main(String arg[]){
+ LocalTreePanel localPanel = new LocalTreePanel();
+ JFrame sFrame = new JFrame("Local File System");
+ sFrame.getContentPane().setLayout(new GridLayout(1, 1));
+ sFrame.getContentPane().add(localPanel);
+ sFrame.pack();
+ sFrame.setSize(300, 400);
+ sFrame.setVisible(true);
+ UITools.center(null, sFrame);
+
+ }
+}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <li...@us...> - 2008-07-22 05:26:17
|
Revision: 2074
http://cogkit.svn.sourceforge.net/cogkit/?rev=2074&view=rev
Author: liuwt
Date: 2008-07-22 05:26:15 +0000 (Tue, 22 Jul 2008)
Log Message:
-----------
Modified Paths:
--------------
trunk/current/src/cog/modules/transfer-gui/src/org/globus/ogce/beans/filetransfer/gui/FileTransferMainPanel.java
Modified: trunk/current/src/cog/modules/transfer-gui/src/org/globus/ogce/beans/filetransfer/gui/FileTransferMainPanel.java
===================================================================
--- trunk/current/src/cog/modules/transfer-gui/src/org/globus/ogce/beans/filetransfer/gui/FileTransferMainPanel.java 2008-07-22 05:26:01 UTC (rev 2073)
+++ trunk/current/src/cog/modules/transfer-gui/src/org/globus/ogce/beans/filetransfer/gui/FileTransferMainPanel.java 2008-07-22 05:26:15 UTC (rev 2074)
@@ -98,10 +98,10 @@
//RFT transfer
- int jobID = 0;
+ public static int jobID = 0;
private QueuePanel queuePanel = null;
private RFTClient rftClient = null;
- private static int transferID = 1;
+ public static int transferID = 1;
/*In general for a bean default constructor*/
@@ -609,39 +609,16 @@
//using RFT
if ("true".equals(rftEnabled)) {
- String rftFrom = "gsiftp://" + fromRemote.getHost() + ":" + fromRemote.getPort() + from;
- String rftTo = "gsiftp://" + toRemote.getHost() + ":" + toRemote.getPort() + to;
- String destSN = toRemote.getSubject();
+ String fromHost = fromRemote.getHost();
+ String fromPort = Integer.toString(fromRemote.getPort());
+ String toHost = toRemote.getHost();
+ String toPort = Integer.toString(toRemote.getPort());
+ String destSN = toRemote.getSubject();
String sourceSN = ((GridClient)fromRemote).getSubject();
-
- RFTTransferParam param = new RFTTransferParam(rftFrom, rftTo,
- prop.getProperty("host"), prop.getProperty("port"));
- int concurrent = Integer.parseInt(prop.getProperty("concurrent"));
- int parallelStream = Integer.parseInt(prop.getProperty("parallelstream"));
- int bufferSize = Integer.parseInt(prop.getProperty("tcpbuffersize"));
- RFTOptions options = new RFTOptions(concurrent, parallelStream, bufferSize,
- destSN, sourceSN);
- RFTJob job = new RFTJob(++jobID, options, param);
- TransferType transfer = param.getTransfers1()[0];
- String[] cols = {Integer.toString(job.getJobID()), Integer.toString(transferID++),
- Integer.toString(1), transfer.getSourceUrl(), transfer.getDestinationUrl(),
- "started", "0", "No errors"};
- monitorPanel.setFocusTab(0);
- monitorPanel.getUrlCopyPanel().addTransfer(Integer.toString(job.getJobID()),
- transfer.getSourceUrl(), transfer.getDestinationUrl());
-
- try {
- //queuePanel.addTransfer(cols);
- rftClient.startTransfer(job);
- } catch (Exception e1) {
- e1.printStackTrace();
- JOptionPane.showMessageDialog(null,e1.getMessage(), "Error",
- JOptionPane.WARNING_MESSAGE);
- int index = queuePanel.getRowIndex(Integer.toString(jobID));
- queuePanel.setColumnValue(index, 5, "Failed");
- queuePanel.setColumnValue(index, 7, e1.getMessage());
- }
- } else { // third party transfer
+ RFTWorker worker = new RFTWorker(prop, from, fromHost, fromPort,
+ to, toHost, toPort, sourceSN, destSN);
+ worker.start();
+ } else {
new AlertThread(this).start();
}
@@ -735,7 +712,59 @@
this();
}
- public static void main(String args[]) {
-
+ class RFTWorker extends Thread {
+ Properties prop = null;
+ String from;
+ String fromHost;
+ String fromPort;
+ String to;
+ String toHost;
+ String toPort;
+ String sourceSN;
+ String destSN;
+
+ public RFTWorker(Properties prop, String from, String fromHost, String fromPort,
+ String to, String toHost, String toPort, String sourceSN, String destSN) {
+ this.prop = prop;
+ this.from = from;
+ this.fromHost = fromHost;
+ this.fromPort = fromPort;
+ this.to = to;
+ this.toHost = toHost;
+ this.toPort = toPort;
+ this.sourceSN = sourceSN;
+ this.destSN = destSN;
+ }
+
+ public void run() {
+ String rftFrom = "gsiftp://" + fromHost + ":" + fromPort + from;
+ String rftTo = "gsiftp://" + toHost + ":" + toPort + to;
+
+ RFTTransferParam param = new RFTTransferParam(rftFrom, rftTo,
+ prop.getProperty("host"), prop.getProperty("port"));
+ int concurrent = Integer.parseInt(prop.getProperty("concurrent"));
+ int parallelStream = Integer.parseInt(prop.getProperty("parallelstream"));
+ int bufferSize = Integer.parseInt(prop.getProperty("tcpbuffersize"));
+ RFTOptions options = new RFTOptions(concurrent, parallelStream, bufferSize,
+ destSN, sourceSN);
+ RFTJob job = new RFTJob(++FileTransferMainPanel.jobID, options, param);
+ TransferType transfer = param.getTransfers1()[0];
+ monitorPanel.setFocusTab(0);
+ monitorPanel.getUrlCopyPanel().addTransfer(Integer.toString(FileTransferMainPanel.jobID),
+ rftFrom, rftTo, "true");
+
+ try {
+ //queuePanel.addTransfer(cols);
+ rftClient.startTransfer(job);
+ } catch (Exception e1) {
+ e1.printStackTrace();
+ JOptionPane.showMessageDialog(null,e1.getMessage(), "Error",
+ JOptionPane.WARNING_MESSAGE);
+ monitorPanel.getUrlCopyPanel().updateTransfer(Integer.toString(FileTransferMainPanel.jobID),
+ "Failed", "N/A", "N/A", e1.getMessage());
+
+ }
+ }
}
+
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <li...@us...> - 2008-07-22 05:26:03
|
Revision: 2073
http://cogkit.svn.sourceforge.net/cogkit/?rev=2073&view=rev
Author: liuwt
Date: 2008-07-22 05:26:01 +0000 (Tue, 22 Jul 2008)
Log Message:
-----------
Modified Paths:
--------------
trunk/current/src/cog/modules/transfer-gui/docs/todo.txt
Modified: trunk/current/src/cog/modules/transfer-gui/docs/todo.txt
===================================================================
--- trunk/current/src/cog/modules/transfer-gui/docs/todo.txt 2008-07-22 01:15:05 UTC (rev 2072)
+++ trunk/current/src/cog/modules/transfer-gui/docs/todo.txt 2008-07-22 05:26:01 UTC (rev 2073)
@@ -5,5 +5,5 @@
1) generate a proxy from local certificate;
2) get a short-term proxy from a Myproxy server;
Some explanation text will help users to make a decision and prevent confusion.
-3. Add a "Advanced options" button to replace "RFT" button. Clicking that button will also popup a dialog to set parallel streams,
- TCP buffer, concurrency and whether reliable transfer is enforced or not.
\ No newline at end of file
+3. Add a "Advanced options" button to replace "RFT" button. Clicking that button will also popup a dialog to set RFT service address, port,
+ parallel streams, TCP buffer, concurrency and whether reliable transfer is enforced or not.
\ No newline at end of file
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ha...@us...> - 2008-07-22 01:15:09
|
Revision: 2072
http://cogkit.svn.sourceforge.net/cogkit/?rev=2072&view=rev
Author: hategan
Date: 2008-07-22 01:15:05 +0000 (Tue, 22 Jul 2008)
Log Message:
-----------
attempt at fixing the scheduler delay stuff
Modified Paths:
--------------
trunk/current/src/cog/modules/karajan/src/org/globus/cog/karajan/scheduler/LateBindingScheduler.java
trunk/current/src/cog/modules/karajan/src/org/globus/cog/karajan/scheduler/WeightedHost.java
trunk/current/src/cog/modules/karajan/src/org/globus/cog/karajan/scheduler/WeightedHostScoreScheduler.java
trunk/current/src/cog/modules/karajan/src/org/globus/cog/karajan/scheduler/WeightedHostSet.java
Added Paths:
-----------
trunk/current/src/cog/modules/karajan/src/org/globus/cog/karajan/scheduler/OverloadedHostMonitor.java
Modified: trunk/current/src/cog/modules/karajan/src/org/globus/cog/karajan/scheduler/LateBindingScheduler.java
===================================================================
--- trunk/current/src/cog/modules/karajan/src/org/globus/cog/karajan/scheduler/LateBindingScheduler.java 2008-07-21 13:18:27 UTC (rev 2071)
+++ trunk/current/src/cog/modules/karajan/src/org/globus/cog/karajan/scheduler/LateBindingScheduler.java 2008-07-22 01:15:05 UTC (rev 2072)
@@ -78,7 +78,7 @@
private InstanceSubmitQueue submitQueue;
- private boolean tasksFinished;
+ private volatile boolean tasksFinished;
public LateBindingScheduler() {
virtualContacts = new HashMap();
@@ -381,6 +381,7 @@
throw e;
}
catch (Exception e) {
+ e.printStackTrace();
if (logger.isDebugEnabled()) {
logger.debug("Scheduler exception: job =" + t.getIdentity().getValue()
+ ", status = " + t.getStatus(), e);
@@ -676,4 +677,8 @@
protected Contact[] getContacts(Task t) {
return (Contact[]) taskContacts.get(t);
}
+
+ protected void raiseTasksFinished() {
+ this.tasksFinished = true;
+ }
}
Added: trunk/current/src/cog/modules/karajan/src/org/globus/cog/karajan/scheduler/OverloadedHostMonitor.java
===================================================================
--- trunk/current/src/cog/modules/karajan/src/org/globus/cog/karajan/scheduler/OverloadedHostMonitor.java (rev 0)
+++ trunk/current/src/cog/modules/karajan/src/org/globus/cog/karajan/scheduler/OverloadedHostMonitor.java 2008-07-22 01:15:05 UTC (rev 2072)
@@ -0,0 +1,69 @@
+//----------------------------------------------------------------------
+//This code is developed as part of the Java CoG Kit project
+//The terms of the license can be found at http://www.cogkit.org/license
+//This message may not be removed or altered.
+//----------------------------------------------------------------------
+
+/*
+ * Created on Jul 21, 2008
+ */
+package org.globus.cog.karajan.scheduler;
+
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+
+import org.apache.log4j.Logger;
+
+public class OverloadedHostMonitor extends Thread {
+ public static final Logger logger = Logger.getLogger(OverloadedHostMonitor.class);
+
+ public static final int POLL_INTERVAL = 1000;
+ private Map hosts;
+ private WeightedHostScoreScheduler whss;
+
+ private static final Integer[] DIRS = new Integer[] { new Integer(-1), new Integer(0),
+ new Integer(1) };
+
+ public OverloadedHostMonitor(WeightedHostScoreScheduler whss) {
+ super("Overloaded Host Monitor");
+ setDaemon(true);
+ hosts = new HashMap();
+ this.whss = whss;
+ start();
+ }
+
+ public void add(WeightedHost wh, int dir) {
+ synchronized (hosts) {
+ hosts.put(wh, DIRS[dir + 1]);
+ }
+ }
+
+ public void run() {
+ try {
+ while (true) {
+ Thread.sleep(POLL_INTERVAL);
+ try {
+ synchronized (hosts) {
+ Iterator i = hosts.entrySet().iterator();
+ while (i.hasNext()) {
+ Map.Entry e = (Map.Entry) i.next();
+ WeightedHost wh = (WeightedHost) e.getKey();
+ if (wh.isOverloaded() == 0) {
+ Integer dir = (Integer) e.getValue();
+ whss.updateOverloadedCount(dir.intValue());
+ i.remove();
+ }
+ }
+ }
+ }
+ catch (Exception e) {
+ logger.warn("Exception caught while polling hosts", e);
+ }
+ }
+ }
+ catch (InterruptedException e) {
+ logger.info("Interrupted", e);
+ }
+ }
+}
Modified: trunk/current/src/cog/modules/karajan/src/org/globus/cog/karajan/scheduler/WeightedHost.java
===================================================================
--- trunk/current/src/cog/modules/karajan/src/org/globus/cog/karajan/scheduler/WeightedHost.java 2008-07-21 13:18:27 UTC (rev 2071)
+++ trunk/current/src/cog/modules/karajan/src/org/globus/cog/karajan/scheduler/WeightedHost.java 2008-07-22 01:15:05 UTC (rev 2072)
@@ -11,7 +11,6 @@
import java.text.DecimalFormat;
import java.text.NumberFormat;
-import java.util.Timer;
import org.apache.log4j.Logger;
import org.globus.cog.karajan.util.BoundContact;
@@ -167,12 +166,12 @@
+ ", maxload=" + ml + " delay since last used=" + delay + "ms"
+ " permitted delay=" + permittedDelay + "ms overloaded=" + overloaded+ " delay-permitted delay="+d);
}
-
- if(d>0) {
- return 0; // not overloaded
- } else {
- return d; // overloaded, with negative value being the delay
+ if (overloaded) {
+ return (int) (delay - permittedDelay);
}
+ else {
+ return load < ml ? 0 : 1;
+ }
}
}
Modified: trunk/current/src/cog/modules/karajan/src/org/globus/cog/karajan/scheduler/WeightedHostScoreScheduler.java
===================================================================
--- trunk/current/src/cog/modules/karajan/src/org/globus/cog/karajan/scheduler/WeightedHostScoreScheduler.java 2008-07-21 13:18:27 UTC (rev 2071)
+++ trunk/current/src/cog/modules/karajan/src/org/globus/cog/karajan/scheduler/WeightedHostScoreScheduler.java 2008-07-22 01:15:05 UTC (rev 2072)
@@ -63,10 +63,12 @@
private TaskConstraints cachedConstraints;
private boolean cachedLoadState;
private int hits;
+ private OverloadedHostMonitor monitor;
public WeightedHostScoreScheduler() {
policy = POLICY_WEIGHTED_RANDOM;
setDefaultFactors();
+ monitor = new OverloadedHostMonitor(this);
}
protected final void setDefaultFactors() {
@@ -102,7 +104,7 @@
if (grid.getContacts() == null) {
return;
}
- sorted = new WeightedHostSet(scoreHighCap);
+ sorted = new WeightedHostSet(scoreHighCap, monitor);
Iterator i = grid.getContacts().iterator();
while (i.hasNext()) {
BoundContact contact = (BoundContact) i.next();
@@ -475,4 +477,9 @@
}
}
}
+
+ protected void updateOverloadedCount(int v) {
+ sorted.updateOverloadedCount(v);
+ raiseTasksFinished();
+ }
}
Modified: trunk/current/src/cog/modules/karajan/src/org/globus/cog/karajan/scheduler/WeightedHostSet.java
===================================================================
--- trunk/current/src/cog/modules/karajan/src/org/globus/cog/karajan/scheduler/WeightedHostSet.java 2008-07-21 13:18:27 UTC (rev 2071)
+++ trunk/current/src/cog/modules/karajan/src/org/globus/cog/karajan/scheduler/WeightedHostSet.java 2008-07-22 01:15:05 UTC (rev 2072)
@@ -12,8 +12,6 @@
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
-import java.util.Timer;
-import java.util.TimerTask;
import java.util.TreeSet;
import org.globus.cog.karajan.util.BoundContact;
@@ -24,12 +22,16 @@
private double sum;
private double scoreHighCap;
private volatile int overloadedCount;
+ private OverloadedHostMonitor monitor;
+
+ public WeightedHostSet(double scoreHighCap) {
+ this(scoreHighCap, null);
+ }
- private static final Timer timer = new Timer();
-
- public WeightedHostSet(double scoreHighCap) {
+ public WeightedHostSet(double scoreHighCap, OverloadedHostMonitor monitor) {
init();
this.scoreHighCap = scoreHighCap;
+ this.monitor = monitor;
}
protected void init() {
@@ -81,15 +83,14 @@
}
}
else {
- timer.schedule(new TimerTask() {
- public void run() {
- overloadedCount -= dir;
- }
- }, -v);
+ if (monitor != null) {
+ monitor.add(wh, -dir);
+ }
return dir;
}
}
+
public WeightedHost findHost(BoundContact bc) {
return (WeightedHost) weightedHosts.get(bc);
}
@@ -138,4 +139,8 @@
public boolean allOverloaded() {
return overloadedCount == weightedHosts.size();
}
+
+ protected void updateOverloadedCount(int dif) {
+ this.overloadedCount += dif;
+ }
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <b_...@us...> - 2008-07-21 13:18:31
|
Revision: 2071
http://cogkit.svn.sourceforge.net/cogkit/?rev=2071&view=rev
Author: b_z_c
Date: 2008-07-21 13:18:27 +0000 (Mon, 21 Jul 2008)
Log Message:
-----------
reverse the polarity on load changing
Modified Paths:
--------------
trunk/current/src/cog/modules/karajan/src/org/globus/cog/karajan/scheduler/WeightedHostSet.java
Modified: trunk/current/src/cog/modules/karajan/src/org/globus/cog/karajan/scheduler/WeightedHostSet.java
===================================================================
--- trunk/current/src/cog/modules/karajan/src/org/globus/cog/karajan/scheduler/WeightedHostSet.java 2008-07-19 14:46:28 UTC (rev 2070)
+++ trunk/current/src/cog/modules/karajan/src/org/globus/cog/karajan/scheduler/WeightedHostSet.java 2008-07-21 13:18:27 UTC (rev 2071)
@@ -57,7 +57,7 @@
}
public void changeLoad(WeightedHost wh, int dl) {
- overloadedCount -= checkOverloaded(wh, -1);
+ overloadedCount += checkOverloaded(wh, -1);
wh.changeLoad(dl);
overloadedCount += checkOverloaded(wh, 1);
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <b_...@us...> - 2008-07-19 14:46:55
|
Revision: 2070
http://cogkit.svn.sourceforge.net/cogkit/?rev=2070&view=rev
Author: b_z_c
Date: 2008-07-19 14:46:28 +0000 (Sat, 19 Jul 2008)
Log Message:
-----------
delay based overload calculation was treating a site as overlaoded forever, rather than being non-overloaded after appropriate delay.
Modified Paths:
--------------
trunk/current/src/cog/modules/karajan/src/org/globus/cog/karajan/scheduler/WeightedHost.java
Modified: trunk/current/src/cog/modules/karajan/src/org/globus/cog/karajan/scheduler/WeightedHost.java
===================================================================
--- trunk/current/src/cog/modules/karajan/src/org/globus/cog/karajan/scheduler/WeightedHost.java 2008-07-17 20:08:57 UTC (rev 2069)
+++ trunk/current/src/cog/modules/karajan/src/org/globus/cog/karajan/scheduler/WeightedHost.java 2008-07-19 14:46:28 UTC (rev 2070)
@@ -158,15 +158,21 @@
long delay = now - lastUsed;
long permittedDelay = (long) (Math.exp(-(score.doubleValue())) * 100.0);
boolean overloaded = (delay < permittedDelay);
+ int d = (int) (delay - permittedDelay);
// tscore of -1 will give delay of around
// 200ms, and will double every time tscore goes
// down by one (which is once per failed job? roughly?)
if (logger.isDebugEnabled()) {
logger.debug("In delay mode. score = " + score + " tscore = " + tscore
+ ", maxload=" + ml + " delay since last used=" + delay + "ms"
- + " permitted delay=" + permittedDelay + "ms overloaded=" + overloaded);
+ + " permitted delay=" + permittedDelay + "ms overloaded=" + overloaded+ " delay-permitted delay="+d);
}
- return (int) (delay - permittedDelay);
+
+ if(d>0) {
+ return 0; // not overloaded
+ } else {
+ return d; // overloaded, with negative value being the delay
+ }
}
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <li...@us...> - 2008-07-17 20:09:12
|
Revision: 2069
http://cogkit.svn.sourceforge.net/cogkit/?rev=2069&view=rev
Author: liuwt
Date: 2008-07-17 20:08:57 +0000 (Thu, 17 Jul 2008)
Log Message:
-----------
OGCE classes which have been modified
Added Paths:
-----------
trunk/current/src/cog/modules/transfer-gui/src/org/globus/ogce/beans/filetransfer/gui/monitor/QueuePanel.java
Added: trunk/current/src/cog/modules/transfer-gui/src/org/globus/ogce/beans/filetransfer/gui/monitor/QueuePanel.java
===================================================================
--- trunk/current/src/cog/modules/transfer-gui/src/org/globus/ogce/beans/filetransfer/gui/monitor/QueuePanel.java (rev 0)
+++ trunk/current/src/cog/modules/transfer-gui/src/org/globus/ogce/beans/filetransfer/gui/monitor/QueuePanel.java 2008-07-17 20:08:57 UTC (rev 2069)
@@ -0,0 +1,281 @@
+package org.globus.ogce.beans.filetransfer.gui.monitor;
+
+import org.apache.log4j.Logger;
+
+import javax.swing.*;
+import javax.swing.border.BevelBorder;
+import javax.swing.border.Border;
+import javax.swing.table.DefaultTableModel;
+import java.awt.*;
+import java.awt.event.ActionListener;
+import java.awt.event.MouseEvent;
+import java.awt.event.MouseListener;
+import java.util.Vector;
+
+/**
+ * A panel which Displays a set of jobs in a queue. The user can add any
+ * number of columns to the table. It is assumed that the Jobid is the
+ * first column and it is used to distinguish values contained in each row.
+ *
+ * @author Beulah Kurian Alunkal
+ * @version 1.0
+ */
+public class QueuePanel extends JPanel implements MouseListener {
+ private static Logger logger =
+ Logger.getLogger(QueuePanel.class.getName());
+
+ private JTable queueTable = null;
+ private JPopupMenu jpopup = null;
+ JTable completeTable = null;
+
+ public QueuePanel() {
+ setLayout(new BorderLayout());
+ setSize(200, 300);
+ setVisible(true);
+ queueTable
+ = new JTable();
+
+ JScrollPane jobsScrollPane
+ = new JScrollPane(queueTable);
+
+ add(jobsScrollPane, BorderLayout.CENTER);
+
+ //Current transfers border
+ Border jobsBorder = BorderFactory.createTitledBorder(
+ BorderFactory.createBevelBorder(BevelBorder.LOWERED),
+ "Transfer Queue");
+ setBorder(jobsBorder);
+ queueTable.addMouseListener(this);
+
+ jpopup = new JPopupMenu();
+
+ completeTable = queueTable;
+ } // end of constructor
+
+ public void createHeader(String cols[]) {
+ QueueTableModel tableModel = new QueueTableModel();
+ Vector columnIDs = new Vector();
+ for (int i = 0; i < cols.length; i++) {
+ columnIDs.add(cols[i]);
+ }
+ tableModel.setColumnIdentifiers(columnIDs);
+ queueTable.setModel(tableModel);
+
+ queueTable.getTableHeader().setReorderingAllowed(false);
+
+
+ }
+
+ public void addTransfer(String cols[]) {
+ DefaultTableModel tableModel
+ = (DefaultTableModel) getModel();
+ int row = tableModel.getRowCount();
+ Vector rowData = new Vector();
+ for (int i = 0; i < cols.length; i++) {
+ rowData.add(cols[i]);
+ }
+ tableModel.insertRow(row, rowData);
+ return;
+ }
+
+
+ public void updateTransfer(String cols[]) {
+ DefaultTableModel tableModel
+ = (DefaultTableModel) getModel();
+ if (tableModel.getRowCount() > 0) {
+ int selectedRow = getRowIndex(cols[0]);
+ for (int i = 0; i < cols.length; i++) {
+ if (cols[i] != null) {
+ tableModel.setValueAt(cols[i], selectedRow, i);
+ }
+ }
+ }
+ }
+
+ public void setFocus(String jobID) {
+ queueTable.repaint();
+ int row = getRowIndex(jobID);
+ DefaultTableModel tableModel
+ = (DefaultTableModel) getModel();
+ int noRows = tableModel.getRowCount();
+ if (noRows > 1) {
+ if (row < noRows - 1) {
+ row += 1;
+ }
+ queueTable.scrollRectToVisible(queueTable.getCellRect(row, 0, true));
+ // queueTable.revalidate();
+
+ }
+ }
+
+ public void deleteTransfer(String jobid) {
+ DefaultTableModel tableModel
+ = (DefaultTableModel) getModel();
+ int selectedRow = getRowIndex(jobid);
+ tableModel.removeRow(selectedRow);
+
+ }
+
+ public JPopupMenu getPopupMenu() {
+ return jpopup;
+ }
+
+ public int getRowIndex(String jobid) {
+ DefaultTableModel tableModel
+ = (DefaultTableModel) getModel();
+ int noRows = tableModel.getRowCount();
+ int selectedRow = 0;
+ for (int j = 0; j < noRows; j++) {
+ if (jobid.equals(getColumnValue(j, 0))) {
+ selectedRow = j;
+ break;
+ }
+ }
+ return selectedRow;
+ }
+
+ public void clear() {
+ DefaultTableModel tableModel
+ = (DefaultTableModel) getModel();
+ int rowCount = tableModel.getRowCount();
+ if (rowCount > 0) {
+ for (int row = 0; row < rowCount; row++) {
+ tableModel.removeRow(0);
+
+ }
+
+ }
+ return;
+ }
+
+ public int tableSize() {
+ DefaultTableModel tableModel
+ = (DefaultTableModel) getModel();
+ int rowCount = tableModel.getRowCount();
+ return rowCount;
+ }
+
+ public DefaultTableModel getModel() {
+ return (DefaultTableModel) queueTable.getModel();
+ }
+
+ public String getSelectedJob() {
+ int selectedRow = queueTable.getSelectedRow();
+ return getColumnValue(selectedRow, 0);
+ }
+
+ public String getColumnValue(int row, int col) {
+ DefaultTableModel tableModel
+ = (DefaultTableModel) getModel();
+ return (String) tableModel.getValueAt(row, col);
+ }
+
+ public void setColumnValue(int row, int col, String value) {
+ DefaultTableModel tableModel
+ = (DefaultTableModel) getModel();
+ tableModel.setValueAt(value, row, col);
+ }
+
+ //####################################################
+ // MouseListener methods
+ //####################################################
+ public void mousePressed(MouseEvent me) {
+ Point clickPoint = new Point(me.getX(), me.getY());
+
+ int selectedRow = queueTable.rowAtPoint(clickPoint);
+
+
+ queueTable.setRowSelectionInterval(selectedRow, selectedRow);
+
+ if (me.isPopupTrigger()) {
+
+ //Popup menu trigger button was pressed, so display
+ //the choices for interacting with the selected transfer job
+
+ //to show the popup uncomment this line.
+ jpopup.show(queueTable, me.getX(), me.getY());
+
+
+ }
+ if (me.getClickCount() == 2) {
+ //Double click event
+ logger.info("Double clicked");
+ }
+ }
+
+ public void mouseClicked(MouseEvent me) {
+ }
+
+ public void mouseReleased(MouseEvent me) {
+ if (me.isPopupTrigger()) {
+ mousePressed(me);
+ }
+
+ }
+
+ public void mouseEntered(MouseEvent me) {
+ }
+
+ public void mouseExited(MouseEvent me) {
+ }
+
+ public void createButtonsPanel(String args[], ActionListener parent) {
+ JPanel buttonPanel = new JPanel();
+ buttonPanel.setLayout(new GridLayout(1, 0));
+ for (int i = 0; i < args.length; i++) {
+ JButton newButton = new JButton(args[i]);
+ newButton.addActionListener(parent);
+ buttonPanel.add(newButton);
+ }
+ add(buttonPanel, BorderLayout.SOUTH);
+ }
+
+ public void createCheckBoxPanel(JCheckBox args[]) {
+ JPanel checkBoxPanel = new JPanel();
+ // checkBoxPanel.setLayout(new GridLayout(1,0));
+ for (int i = 0; i < args.length; i++) {
+ checkBoxPanel.add(args[i]);
+ }
+ // checkBoxPanel.setBorder(new TitledBorder(new BevelBorder(BevelBorder.RAISED),"Display"));
+ add(checkBoxPanel, BorderLayout.NORTH);
+ }
+
+ public void addPopupItems(String items[], ActionListener parent) {
+ int sep = 0;
+ for (int i = 0; i < items.length; i++) {
+
+ JMenuItem menuItem = new JMenuItem(items[i]);
+ menuItem.addActionListener(parent);
+ jpopup.add(menuItem);
+ sep++;
+ if (sep == 2) {
+ jpopup.addSeparator();
+ sep = 0;
+ }
+ }
+ }
+
+ public void showRows(String status, int col) {
+ if (status.equals("All")) {
+ queueTable = completeTable;
+ } else {
+ logger.info("Not yet implemented");
+ /* int noRows = tableModel.getRowCount();
+
+ for(int j =0 ; j< noRows;j++){
+ if(status.equals(getColumnValue(j,col))){
+ // addTransfer(
+
+ }
+ }*/
+ }
+ }
+
+} // end of class
+
+class QueueTableModel extends DefaultTableModel {
+ public boolean isCellEditable(int row, int col) {
+ return false;
+ }
+}
+
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <li...@us...> - 2008-07-17 19:49:07
|
Revision: 2068
http://cogkit.svn.sourceforge.net/cogkit/?rev=2068&view=rev
Author: liuwt
Date: 2008-07-17 19:48:19 +0000 (Thu, 17 Jul 2008)
Log Message:
-----------
OGCE classes which have been modified
Added Paths:
-----------
trunk/current/src/cog/modules/transfer-gui/src/org/globus/ogce/beans/filetransfer/transfer/AbstractFileTransfer.java
Added: trunk/current/src/cog/modules/transfer-gui/src/org/globus/ogce/beans/filetransfer/transfer/AbstractFileTransfer.java
===================================================================
--- trunk/current/src/cog/modules/transfer-gui/src/org/globus/ogce/beans/filetransfer/transfer/AbstractFileTransfer.java (rev 0)
+++ trunk/current/src/cog/modules/transfer-gui/src/org/globus/ogce/beans/filetransfer/transfer/AbstractFileTransfer.java 2008-07-17 19:48:19 UTC (rev 2068)
@@ -0,0 +1,148 @@
+package org.globus.ogce.beans.filetransfer.transfer;
+
+import org.apache.log4j.Logger;
+import org.globus.ogce.beans.filetransfer.gui.FileTransferMainPanel;
+import org.globus.ogce.beans.filetransfer.gui.MainInterface;
+import org.globus.ogce.beans.filetransfer.gui.monitor.MonitorPanel;
+import org.globus.ogce.beans.filetransfer.gui.monitor.UrlCopyPanel;
+import org.globus.ogce.beans.filetransfer.util.FileToTransfer;
+import org.globus.ogce.beans.filetransfer.util.GridBrokerQueue;
+
+import javax.swing.*;
+
+public abstract class AbstractFileTransfer extends Thread {
+ private static Logger logger =
+ Logger.getLogger(AbstractFileTransfer.class.getName());
+
+ private MainInterface theApp;
+
+ private GridBrokerQueue mainQueue = null;
+ private GridBrokerQueue saveQueue = null;
+
+ private MonitorPanel monitorFrame = null;
+
+ private int jobID = 0;
+ private boolean active = false;
+ private boolean start = true;
+ private boolean previousTransfer = false;
+
+ protected TransferInterface serviceProvider = null;
+ FileToTransfer ftt = null;
+
+
+ public AbstractFileTransfer(MainInterface theApp, MonitorPanel monitorFrame) {
+ super("AbstractFileTransfer");
+ this.theApp = theApp;
+ this.monitorFrame = monitorFrame;
+ mainQueue = new GridBrokerQueue();
+ saveQueue = new GridBrokerQueue();
+ logger.info("Constructor");
+ previousTransfer = false;
+ }
+
+ public abstract void setTransferProvider();
+
+ public AbstractFileTransfer() {
+ this(null, null);
+ }
+
+ public void setControl(boolean start) {
+ this.start = start;
+ if (start) {
+ run();
+ }
+ }
+
+ public void setSaveQueue(GridBrokerQueue saveQueue) {
+ this.saveQueue = saveQueue;
+ }
+
+ public GridBrokerQueue getSaveQueue() {
+ return saveQueue;
+ }
+
+ public void updateQueues(GridBrokerQueue requestQueue) {
+ setControl(false);
+ int length = requestQueue.size();
+ for (int i = 0; i < length; i++) {
+ jobID = ++FileTransferMainPanel.jobID;
+ FileToTransfer ftt = (FileToTransfer) requestQueue.get();
+
+ ftt.setJobID(jobID + "");
+ mainQueue.put(ftt);
+ saveQueue.put(ftt);
+ ((UrlCopyPanel)serviceProvider).addTransfer(jobID + "", ftt.getFrom(), ftt.getTo(), "false");
+
+ }
+ setControl(true);
+ }
+
+ public void clearAllQueues() {
+ mainQueue.deleteAll();
+ saveQueue.deleteAll();
+ jobID = 0;
+ active = false;
+ previousTransfer = false;
+ run();
+ }
+
+ public void run() {
+ if (active) {
+ return;
+ }
+
+ if (mainQueue.size() > 0) {
+ while ((mainQueue.size() > 0) && (start)) {
+
+ active = true;
+ if (previousTransfer) {
+ logger.info("Process the previous request");
+ previousTransfer = false;
+ } else {
+ ftt = (FileToTransfer) mainQueue.get();
+ }
+ serviceProvider.startTransfer(ftt.getJobID());
+ String result = "Unknown";
+ long time = 0;
+ int index = -1;
+ System.out.println("\nThe result is :" + result);
+ while ((!result.equals("Finished")) && (index < 0)) {
+ try {
+ Thread.sleep(500);
+ result = serviceProvider.getFinalStatus();
+ System.out.println("\nCURRENT Status = " + result);
+ time += 500;
+ System.out.println("\nThe result is :" + result);
+ if (result != null) {
+ index = result.indexOf("Failed");
+ }
+
+ } catch (Exception e) {
+ logger.info("Exception sleeping.");
+ }
+ }
+ if (result.equals("Finished")) {
+ saveQueue.get();
+ } else if (!((result.indexOf("Permission denied") > 0) || (result.indexOf("File exists") > 0)) && active) {
+
+ String msg = "One of the jobs failed: " +
+ result + "\nDo you wish to continue with" +
+ " other jobs ?";
+ Object options[] = {"Yes", "No"};
+ int k = JOptionPane.showOptionDialog(theApp,
+ msg, "Directory Transfer Alert", -1,
+ JOptionPane.INFORMATION_MESSAGE, null, options,
+ options[0]);
+ if (k == 1) {
+ setControl(false);
+ previousTransfer = true;
+ } else {
+ saveQueue.get();
+ }
+ }
+ }
+
+ }
+ active = false;
+ }
+}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <li...@us...> - 2008-07-17 05:48:57
|
Revision: 2067
http://cogkit.svn.sourceforge.net/cogkit/?rev=2067&view=rev
Author: liuwt
Date: 2008-07-17 05:48:54 +0000 (Thu, 17 Jul 2008)
Log Message:
-----------
OGCE classes which have been modified
Added Paths:
-----------
trunk/current/src/cog/modules/transfer-gui/src/org/globus/ogce/
trunk/current/src/cog/modules/transfer-gui/src/org/globus/ogce/beans/
trunk/current/src/cog/modules/transfer-gui/src/org/globus/ogce/beans/filetransfer/
trunk/current/src/cog/modules/transfer-gui/src/org/globus/ogce/beans/filetransfer/gui/
trunk/current/src/cog/modules/transfer-gui/src/org/globus/ogce/beans/filetransfer/gui/FileTransferMainPanel.java
trunk/current/src/cog/modules/transfer-gui/src/org/globus/ogce/beans/filetransfer/gui/monitor/
trunk/current/src/cog/modules/transfer-gui/src/org/globus/ogce/beans/filetransfer/gui/monitor/UrlCopyPanel.java
trunk/current/src/cog/modules/transfer-gui/src/org/globus/ogce/beans/filetransfer/gui/remote/
trunk/current/src/cog/modules/transfer-gui/src/org/globus/ogce/beans/filetransfer/gui/remote/gridftp/
trunk/current/src/cog/modules/transfer-gui/src/org/globus/ogce/beans/filetransfer/gui/remote/gridftp/GridClient.java
trunk/current/src/cog/modules/transfer-gui/src/org/globus/ogce/beans/filetransfer/transfer/
trunk/current/src/cog/modules/transfer-gui/src/org/globus/ogce/beans/filetransfer/transfer/FileRequest.java
Added: trunk/current/src/cog/modules/transfer-gui/src/org/globus/ogce/beans/filetransfer/gui/FileTransferMainPanel.java
===================================================================
--- trunk/current/src/cog/modules/transfer-gui/src/org/globus/ogce/beans/filetransfer/gui/FileTransferMainPanel.java (rev 0)
+++ trunk/current/src/cog/modules/transfer-gui/src/org/globus/ogce/beans/filetransfer/gui/FileTransferMainPanel.java 2008-07-17 05:48:54 UTC (rev 2067)
@@ -0,0 +1,741 @@
+package org.globus.ogce.beans.filetransfer.gui;
+
+import org.apache.log4j.Logger;
+import org.globus.ogce.beans.filetransfer.FtpProperties;
+import org.globus.ogce.beans.filetransfer.gui.local.DirEvent;
+import org.globus.ogce.beans.filetransfer.gui.local.DirListener;
+import org.globus.ogce.beans.filetransfer.gui.local.LocalTreePanel;
+import org.globus.ogce.beans.filetransfer.gui.monitor.MonitorPanel;
+import org.globus.ogce.beans.filetransfer.gui.monitor.QueuePanel;
+import org.globus.ogce.beans.filetransfer.gui.remote.common.DisplayInterface;
+import org.globus.ogce.beans.filetransfer.gui.remote.ftp.FtpClient;
+import org.globus.ogce.beans.filetransfer.gui.remote.ftp.FtpDirEvent;
+import org.globus.ogce.beans.filetransfer.gui.remote.ftp.FtpDirListener;
+import org.globus.ogce.beans.filetransfer.gui.remote.gridftp.GridClient;
+import org.globus.ogce.beans.filetransfer.gui.remote.gridftp.RemDirEvent;
+import org.globus.ogce.beans.filetransfer.gui.remote.gridftp.RemDirListener;
+import org.globus.ogce.beans.filetransfer.transfer.DirTransferRequest;
+import org.globus.ogce.beans.filetransfer.transfer.FileRequest;
+import org.globus.ogce.beans.filetransfer.transfer.RFTFileTransfer;
+import org.globus.ogce.beans.filetransfer.transfer.UrlCopyFileTransfer;
+import org.globus.ogce.beans.filetransfer.util.DirQueue;
+import org.globus.ogce.beans.filetransfer.util.FileOperations;
+import org.globus.ogce.beans.filetransfer.util.GridBrokerQueue;
+import org.globus.ogce.beans.filetransfer.util.MessagePanel;
+import org.globus.rft.generated.TransferType;
+import org.globus.tools.ui.util.UITools;
+import org.globus.transfer.reliable.client.RFTClient;
+import org.globus.transfer.reliable.client.RFTJob;
+import org.globus.transfer.reliable.client.RFTOptions;
+import org.globus.transfer.reliable.client.RFTTransferParam;
+import org.globus.transfer.reliable.client.utils.Utils;
+import org.globus.util.ConfigUtil;
+
+import javax.swing.*;
+import javax.swing.event.InternalFrameAdapter;
+import javax.swing.event.InternalFrameEvent;
+import java.awt.*;
+import java.beans.PropertyVetoException;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.Serializable;
+import java.util.Hashtable;
+import java.util.Properties;
+
+/**
+ * This is a panel that integrates the LocalTreeBean and RemoteTreeBean to
+ * demonstrate the use of grid gui beans in the design of composite beans
+ * that provide File Transfer in Grids with drag and drop functionality.
+ *
+ * @author Beulah Kurian Alunkal
+
+ */
+public class FileTransferMainPanel extends MainInterface
+ implements DirListener,
+ RemDirListener, FtpDirListener, Serializable {
+ public static FileTransferMainPanel mainPanel = new FileTransferMainPanel(true);
+ private static Logger logger =
+ Logger.getLogger(FileTransferMainPanel.class.getName());
+ protected String defaultDir = ConfigUtil.globus_dir;
+ protected LocalTreePanel frame1[];
+ protected DisplayInterface frame2[];
+
+ //Counters are used to allow the users to add any no of local or remote
+ //file browser beans.
+ protected int remCounter = 0;
+ protected int lclCounter = 0;
+ private JFrame sFrame = null, mFrame = null;
+
+
+ //Hashtables to retrive the ftp clients selected.
+ public Hashtable gridIFTable,ftpIFTable;
+ protected boolean draglocal;
+
+ //Queues for storing the requests.
+ protected GridBrokerQueue mainQueue = null;
+ protected GridBrokerQueue requestQueue = null;
+ protected DirQueue saveQueue = null;
+
+ protected DisplayInterface fromRemote = null;
+ protected LocalTreePanel fromLocal = null;
+ protected RFTFileTransfer rftFileTransfer = null;
+ protected UrlCopyFileTransfer urlcopyFileTransfer = null;
+ protected FileRequest fileRequest = null;
+ protected MonitorPanel monitorPanel = null;
+ String from = null;
+
+ protected JPanel panel = null;
+ DirTransferRequest dirRequest = null;
+ int maxSites = 10;
+ //Parameters for bookmark.
+ String profile, user, host, pass;
+ int port = 0;
+ int scH = 0, scW = 0;
+ JDesktopPane desktop = null;
+ protected JInternalFrame messageFrame;
+ protected MessagePanel messagePanel = null;
+
+
+ //RFT transfer
+ int jobID = 0;
+ private QueuePanel queuePanel = null;
+ private RFTClient rftClient = null;
+ private static int transferID = 1;
+
+
+ /*In general for a bean default constructor*/
+ public FileTransferMainPanel() {
+ init();
+ setLayout(new GridLayout(1, 1));
+ //add(monitorPanel);
+ }
+ /*Static variable uses this contructor to create a hidden bean*/
+
+ public FileTransferMainPanel(boolean val) {
+ init();
+ sFrame = new JFrame("Status Window");
+ sFrame.getContentPane().setLayout(new GridLayout(1, 1));
+ sFrame.getContentPane().add(monitorPanel);
+ sFrame.pack();
+ sFrame.setSize(350, 400);
+ sFrame.setVisible(false);
+ UITools.center(this,sFrame);
+
+ mFrame = new JFrame("Messages Window");
+ mFrame.getContentPane().setLayout(new GridLayout(1, 1));
+ mFrame.getContentPane().add(messagePanel);
+ mFrame.pack();
+ mFrame.setSize(350, 400);
+ mFrame.setVisible(false);
+ }
+
+ public void showStatusWindow() {
+ sFrame.setVisible(true);
+ }
+
+ public void showMessagesWindow() {
+ mFrame.setVisible(true);
+ }
+ /* Normal constructor used by all graphical interfaces */
+ public FileTransferMainPanel(String label) {
+ init();
+ }
+
+ public void init() {
+ // setBorder(new TitledBorder(new BevelBorder(BevelBorder.LOWERED),""));
+ Dimension dimension = Toolkit.getDefaultToolkit().getScreenSize();
+ scW = dimension.width - 90;
+ scH = dimension.height - 90 * 2;
+ setBounds(0, 0, scW + 50, scH);
+ System.out.println("Creating a File Transfer Listener");
+ // this.panel = panel;
+ // this.desktop = desktop;
+ desktop = new JDesktopPane();
+ gridIFTable = new Hashtable();
+ ftpIFTable = new Hashtable();
+
+ mainQueue = new GridBrokerQueue();
+ requestQueue = new GridBrokerQueue();
+ saveQueue = new DirQueue();
+
+ frame1 = new LocalTreePanel[maxSites];
+ frame2 = new DisplayInterface[maxSites];
+
+ createInitialFrames();
+ rftFileTransfer = new RFTFileTransfer(this, monitorPanel);
+ urlcopyFileTransfer = new UrlCopyFileTransfer(this, monitorPanel);
+ fileRequest = new FileRequest(requestQueue, monitorPanel);
+ System.out.println("Adding Creating a File Transfer Listener");
+ desktop.putClientProperty("JDesktopPane.dragMode", "outline");
+ }
+
+ public JPanel createMonitorPanel() {
+ return monitorPanel;
+ }
+
+ protected void createInitialFrames() {
+ JInternalFrame mFrame = new JInternalFrame(
+ "Monitor Frame"
+ , true, false, true, true);
+ mFrame.setVisible(true);
+ mFrame.getContentPane().setLayout(new GridLayout(1, 1));
+ monitorPanel = new MonitorPanel(this);
+ mFrame.getContentPane().add(monitorPanel);
+ mFrame.pack();
+ mFrame.setSize(350, 330);
+ //dimensionnew.width / 5 - 30, dimensionnew.height - 95);
+ mFrame.setLocation(5, 10);
+
+ desktop.add(mFrame);
+
+ createNewLocalFrame();
+
+ String newline = new String(System.getProperty("line.separator"));
+ String msgTxt = new String("File Transfer Component"+ newline +
+ "Here the Server messages be shown"
+ + newline);
+
+
+ messageFrame = new JInternalFrame(
+ "Message Window"
+ , true, false, true, true);
+ messageFrame.setVisible(true);
+
+ messageFrame.getContentPane().setLayout(new GridLayout(1, 1));
+ messagePanel = new MessagePanel(msgTxt);
+ messageFrame.getContentPane().add(messagePanel);
+ messageFrame.pack();
+ messageFrame.setLocation(5, 340);
+ messageFrame.setSize(350, 135);
+ //messageFrame.setVisible(true);
+ desktop.add(messageFrame);
+
+ rftClient = new RFTClient(null, monitorPanel.getUrlCopyPanel().getQueuePanel());
+
+ }
+
+ public MonitorPanel getMonitorFrame() {
+ return monitorPanel;
+ }
+
+ public void processRequest() {
+ fileRequest.updateQueue(dirRequest);
+ }
+
+ public void msgOut(String s) {
+ messagePanel.msgOut(s);
+ }
+
+ public void clearQueue(String provider) {
+ logger.info("Invoked the clearQueue in main");
+ logger.info("\nPlease wait... Clearing the queues.");
+ if (provider.equals("rft")) {
+ rftFileTransfer.clearAllQueues();
+ } else if (provider.equals("urlcopy")) {
+ urlcopyFileTransfer.clearAllQueues();
+ } else {
+ fileRequest.clearRequestQueue();
+ }
+ }
+
+
+ public void controlExecutionQueue(boolean start, String provider) {
+ if (!start) {
+ JOptionPane.showMessageDialog(panel, "Will stop the job execution" +
+ " only after the current active job is done. ");
+ } else {
+ logger.info("Calling the start transfer ");
+ }
+ if (provider.equals("rft")) {
+ rftFileTransfer.setControl(start);
+ } else if (provider.equals("urlcopy")) {
+ urlcopyFileTransfer.setControl(start);
+ } else {
+ fileRequest.setControl(start);
+ }
+ }
+
+ public JDesktopPane getDesktopPane() {
+ return desktop;
+ }
+
+ public void saveQueueToFile(String provider) {
+ JFileChooser fileChooser = new JFileChooser(defaultDir);
+ fileChooser.setApproveButtonText("Save");
+ fileChooser.setDialogTitle("Save Jobs to File");
+ int popdownState = fileChooser.showSaveDialog(panel);
+ if (popdownState == JFileChooser.CANCEL_OPTION) {
+ return;
+ } else {
+ File saveFile = fileChooser.getSelectedFile();
+ //writing the default job file name into ftp.properties
+ FtpProperties props = null;
+ try {
+ props = new FtpProperties(FtpProperties.configFile);
+ if (provider.equals("rft")) {
+ props.setRFTFile(saveFile.getAbsolutePath());
+ } else {
+ props.setQueueFile(saveFile.getAbsolutePath());
+ }
+ logger.info("\nThe Queue file default location saved="
+ + props.getQueueFile());
+ props.save(FtpProperties.configFile);
+
+ } catch (Exception e) {
+ logger.debug("The system could not open the specified file\n");
+ }
+ saveQueueToFile(saveFile, provider);
+
+ }
+
+ }
+
+ public void saveQueueToFile(File saveFile, String provider) {
+ GridBrokerQueue saveQueue = null;
+ String displayString = null;
+ if (provider.equals("rft")) {
+ saveQueue = rftFileTransfer.getSaveQueue();
+ displayString = "RFT Jobs: ";
+ } else {
+ saveQueue = urlcopyFileTransfer.getSaveQueue();
+ displayString = "Local Provider Jobs: ";
+ }
+ if (saveQueue.size() > 0) {
+ int savedJobsCount = FileOperations.saveQueueToFile(saveQueue,
+ saveFile,
+ this,
+ provider);
+ JOptionPane.showMessageDialog(panel, displayString +
+ "Successfully saved " +
+ savedJobsCount + " jobs " +
+ " are not completed yet.");
+ } else {
+ JOptionPane.showMessageDialog(panel, displayString + "All jobs are done." +
+ " Nothing needs to be saved ");
+ saveFile.delete();
+ }
+ }
+
+ public void setSaveQueue(GridBrokerQueue saveQueue, String provider) {
+ if (provider.equals("rft")) {
+ rftFileTransfer.setSaveQueue(saveQueue);
+ } else {
+ urlcopyFileTransfer.setSaveQueue(saveQueue);
+ }
+ }
+
+
+ public void loadQueueFromFile(String provider) {
+ JFileChooser fileChooser = new JFileChooser(defaultDir);
+ fileChooser.setApproveButtonText("Load");
+ fileChooser.setDialogTitle("Load Jobs File");
+ int popdownState = fileChooser.showOpenDialog(panel);
+ if (popdownState == JFileChooser.CANCEL_OPTION) {
+ return;
+ } else {
+
+ File loadFile = fileChooser.getSelectedFile();
+ monitorPanel.clear(provider);
+ loadQueueFromFile(loadFile, false, provider);
+ }
+ }
+
+ public void loadQueueFromFile(File loadFile, boolean startup, String provider) {
+ FileOperations fop = new FileOperations();
+ int filesCount = fop.loadQueueFromFile(loadFile, this, provider);
+ String msg = null;
+ if (filesCount > 0) {
+ msg = "Successfully loaded " + filesCount + " jobs";
+
+ } else {
+ msg = "Trying to load an invalid file. Each line in the file should consists of fromUrl, \n" +
+ " toUrl and job id separated by semicolon. ";
+ JOptionPane.showMessageDialog(panel, msg);
+ }
+ }
+
+
+ public JPanel createNewLocalFrame() {
+ if (lclCounter >= maxSites) {
+ String msg = "You cannot open more than 10 local windows" +
+ " at the same time. \n Please close few of them" +
+ " to open new ones.";
+ JOptionPane.showMessageDialog(panel, msg);
+ return null;
+ }
+
+ frame1[lclCounter] = new LocalTreePanel("Local File System");
+ frame1[lclCounter].addDirListener(this);
+ JInternalFrame localIF = new JInternalFrame("Local System",
+ true, true, true, true);
+ localIF.setVisible(true);
+ localIF.getContentPane().setLayout(new GridLayout(1, 1));
+ localIF.getContentPane().add(frame1[lclCounter]);
+ localIF.pack();
+
+ localIF.setSize(300, 450);
+ localIF.setLocation(scW / 3 + 50 + (lclCounter) * 20,
+ 10 + (lclCounter) * 20);
+ localIF.addInternalFrameListener(new InternalFrameAdapter() {
+ public void internalFrameClosing(InternalFrameEvent e) {
+ lclCounter--;
+ System.gc();
+ }
+ });
+ desktop.add(localIF);
+ try {
+ localIF.setSelected(true);
+ } catch (PropertyVetoException propertyvetoexception1) {
+ propertyvetoexception1.printStackTrace();
+ }
+ JPanel localPanel = frame1[lclCounter];
+ System.out.println("Local count incremented.");
+ lclCounter++;
+ return localPanel;
+ }
+
+ public void registerLocalComponent(LocalTreePanel local) {
+ frame1[lclCounter] = local;
+ frame1[lclCounter].addDirListener(this);
+ lclCounter++;
+ }
+
+ public void registerRemoteComponent(DisplayInterface display, int index) {
+ if (index == 1) {
+ GridClient gc = (GridClient) display;
+ gc.addRemDirListener(this);
+ frame2[remCounter] = gc;
+ } else {
+ FtpClient fc = (FtpClient) display;
+ fc.addFtpDirListener(this);
+ frame2[remCounter] = fc;
+ }
+
+ remCounter++;
+ }
+
+ /**
+ * Creates a frame for remote file transfer client either ftp or gridftp
+ * based on the request.
+ *
+ * @param ftpindex indicates the client
+ */
+
+ public JPanel createRemoteFrame(int ftpindex, String host,
+ int port) {
+ return createRemoteFrame(ftpindex, host, port, "anonymous", "password");
+ }
+
+ public JPanel createRemoteFrame(int ftpindex, String host, int port,
+ String user, String pwd) {
+ if (remCounter >= maxSites) {
+ String msg = "You cannot open more than 10 remote windows" +
+ " at the same time. \n Please close few of them" +
+ " to open new ones.";
+ JOptionPane.showMessageDialog(panel, msg);
+ return null;
+ }
+ if (ftpindex == 1) {
+ frame2[remCounter] = new GridClient("Remote System -GridFTP ");
+ final GridClient gc = (GridClient) frame2[remCounter];
+ gc.addRemDirListener(this);
+ final JInternalFrame gridIF = new JInternalFrame(
+ "Remote System -GridFTP"
+ , true, true, true, true);
+ gridIF.setVisible(true);
+ gridIF.getContentPane().setLayout(new GridLayout(1, 1));
+ gridIF.getContentPane().add(gc);
+ gridIF.pack();
+ JFrame topLevelFrame = (JFrame)getDesktopPane().getTopLevelAncestor();
+ int frameWidth = topLevelFrame.getWidth();
+ int frameHeight = topLevelFrame.getHeight();
+ gridIF.setSize(frameWidth / 4, frameHeight / 2);
+ gridIF.setLocation((topLevelFrame.getX() + frameWidth / 5) - remCounter * 20, topLevelFrame.getY() + frameHeight / 10 + remCounter * 20);
+ //gridIF.setSize(300, 450);
+ //dimensionnew.width / 5 - 30, dimensionnew.height - 95);
+ //gridIF.setLocation(scW / 2 + 210 - (remCounter) * 20, 10 + (remCounter) * 20);
+
+
+ gridIF.addInternalFrameListener(new InternalFrameAdapter() {
+ public void internalFrameClosing(InternalFrameEvent e) {
+ gc.disconnect();
+ // gridIF = null;
+ System.gc();
+ }
+ });
+ desktop.add(gridIF);
+ try {
+ gridIF.setSelected(true);
+ } catch (PropertyVetoException propertyvetoexception1) {
+ propertyvetoexception1.printStackTrace();
+ }
+ gridIFTable.put(gc, gridIF);
+ remCounter++;
+ if (host != null) {
+ gc.setHost(host);
+ if (port != 0) {
+ gc.setPort(port);
+ }
+ if (!gc.setConnectDetails(false)) {
+ return null;
+ }
+
+ } else {
+ gc.connectDlg(null);
+ UITools.center(panel, gc.dlgConnect);
+ }
+ return gc;
+ } else if (ftpindex == 3) {
+ frame2[remCounter] = new FtpClient("Remote System -FTP");
+ final FtpClient fc = (FtpClient) frame2[remCounter];
+ fc.addFtpDirListener(this);
+ JInternalFrame ftpIF = new JInternalFrame(
+ "Remote System -FTP",
+ true, true, true, true);
+ ftpIF.getContentPane().setLayout(new GridLayout(1, 1));
+ ftpIF.getContentPane().add(fc);
+ ftpIF.pack();
+ ftpIF.setSize(300, 450);
+ //dimensionnew.width / 5 - 30, dimensionnew.height - 95);
+ ftpIF.setLocation(scW / 2 + 210 - (remCounter) * 20,
+ 10 + (remCounter) * 20);
+
+ ftpIF.addInternalFrameListener(new InternalFrameAdapter() {
+ public void internalFrameClosing(InternalFrameEvent e) {
+ fc.remoteTreeFrame._actionDisconnect();
+ // gridIF = null;
+ System.gc();
+ }
+
+ });
+ desktop.add(ftpIF);
+ try {
+ ftpIF.setSelected(true);
+ } catch (PropertyVetoException propertyvetoexception1) {
+ propertyvetoexception1.printStackTrace();
+ }
+ ftpIFTable.put(fc, ftpIF);
+ ftpIF.setVisible(true);
+ remCounter++;
+ if (host != null) {
+ fc.setHost(host);
+ if (port != 0) {
+ fc.setPort(port);
+ }
+ if (user != null) {
+ fc.setUser(user);
+ }
+ if (user != null) {
+ fc.setPwd(pwd);
+ }
+ if (!fc.setConnectDetails(false)) {
+ return null;
+ }
+ } else {
+ fc.connectDlg(null);
+ UITools.center(panel, fc.dlgConnect);
+ }
+ return fc;
+ } else {
+ logger.info("Extended Feature ");
+ return null;
+ }
+ } // end of createRemoteFrame()
+
+ /**
+ * Methods to listen to the drag and drop events.
+ *
+ */
+ public void dragLocal(DirEvent e, String from, LocalTreePanel local) {
+ String rftEnabled = Utils.getProperty("rft_enabled", "rft.properties");
+ if ("true".equals(rftEnabled)) {
+ JOptionPane.showMessageDialog(null, "RFT is enabled, you can not transfer between local machine" +
+ "and GridFTP server", "Error", JOptionPane.ERROR_MESSAGE);
+ return;
+ }
+
+ draglocal = true;
+ fromLocal = local;
+ this.from = from;
+ logger.info("Dragging Local files...");
+ }
+
+ public void dragGridFtp(RemDirEvent e, String from,
+ GridClient gc) {
+ System.out.println("dragGridFTP");
+ this.from = from;
+ draglocal = false;
+ fromRemote = gc;
+ logger.info("Dragging monitorPanel file...");
+ }
+
+ public void dragFtp(FtpDirEvent e, String from,
+ FtpClient fc) {
+ this.from = from;
+ draglocal = false;
+ fromRemote = fc;
+ logger.info("From Remote =" + fromRemote.getRootURL());
+ logger.info("Dragging Ftp file...");
+ }
+
+ public void dropLocal(DirEvent e, String to, LocalTreePanel toLocal) {
+
+ boolean dropLocal = true;
+ logger.info("Dropping the file...");
+ dirRequest = new DirTransferRequest(this,
+ fromLocal, toLocal,
+ fromRemote, null,
+ from, to,
+ draglocal, dropLocal,
+ monitorPanel.getProvider());
+
+ new AlertThread(this).start();
+
+
+ }//end of the function
+
+ public void dropGridFtp(RemDirEvent e, String to, GridClient toRemote) {
+ dirRequest = new DirTransferRequest(this,
+ fromLocal, null,
+ fromRemote, toRemote,
+ from, to,
+ draglocal, false,
+ monitorPanel.getProvider());
+
+ //----------------invode rft to transfer the file--------------------------------------
+ Properties prop = getRFTProperties("rft.properties");
+ String rftEnabled = prop.getProperty("rft_enabled");
+
+ //using RFT
+ if ("true".equals(rftEnabled)) {
+ String rftFrom = "gsiftp://" + fromRemote.getHost() + ":" + fromRemote.getPort() + from;
+ String rftTo = "gsiftp://" + toRemote.getHost() + ":" + toRemote.getPort() + to;
+ String destSN = toRemote.getSubject();
+ String sourceSN = ((GridClient)fromRemote).getSubject();
+
+ RFTTransferParam param = new RFTTransferParam(rftFrom, rftTo,
+ prop.getProperty("host"), prop.getProperty("port"));
+ int concurrent = Integer.parseInt(prop.getProperty("concurrent"));
+ int parallelStream = Integer.parseInt(prop.getProperty("parallelstream"));
+ int bufferSize = Integer.parseInt(prop.getProperty("tcpbuffersize"));
+ RFTOptions options = new RFTOptions(concurrent, parallelStream, bufferSize,
+ destSN, sourceSN);
+ RFTJob job = new RFTJob(++jobID, options, param);
+ TransferType transfer = param.getTransfers1()[0];
+ String[] cols = {Integer.toString(job.getJobID()), Integer.toString(transferID++),
+ Integer.toString(1), transfer.getSourceUrl(), transfer.getDestinationUrl(),
+ "started", "0", "No errors"};
+ monitorPanel.setFocusTab(0);
+ monitorPanel.getUrlCopyPanel().addTransfer(Integer.toString(job.getJobID()),
+ transfer.getSourceUrl(), transfer.getDestinationUrl());
+
+ try {
+ //queuePanel.addTransfer(cols);
+ rftClient.startTransfer(job);
+ } catch (Exception e1) {
+ e1.printStackTrace();
+ JOptionPane.showMessageDialog(null,e1.getMessage(), "Error",
+ JOptionPane.WARNING_MESSAGE);
+ int index = queuePanel.getRowIndex(Integer.toString(jobID));
+ queuePanel.setColumnValue(index, 5, "Failed");
+ queuePanel.setColumnValue(index, 7, e1.getMessage());
+ }
+ } else { // third party transfer
+ new AlertThread(this).start();
+ }
+
+
+
+ //----------------invoke rft end-------------------------------------------------------
+
+ }
+
+
+ public void dropFtp(FtpDirEvent e, String to, FtpClient toRemote) {
+ dirRequest = new DirTransferRequest(this,
+ fromLocal, null,
+ fromRemote, toRemote,
+ from, to,
+ draglocal, false,
+ monitorPanel.getProvider());
+ new AlertThread(this).start();
+ }
+
+ private Properties getRFTProperties(String fileName) {
+ File propFile = new File(fileName);
+ if (!propFile.exists()) {
+ return null;
+ }
+ FileInputStream fis = null;
+ Properties prop = new Properties();
+ try {
+ fis = new FileInputStream(propFile);
+ prop.load(fis);
+ } catch (Exception e) {
+ e.printStackTrace();
+ } finally {
+ try {
+ fis.close();
+ } catch (IOException e) {
+ }
+ }
+
+ return prop;
+ }
+ /**
+ * Methods to increment the counter to keep track of the no of remote
+ * clients currently active.
+ */
+ public void ftpCounter(FtpDirEvent e, FtpClient gc) {
+ if (remCounter > 0) {
+ JInternalFrame gridframe = (JInternalFrame) ftpIFTable.get(gc);
+ gridframe.setVisible(false);
+ remCounter--;
+ logger.info("\nFtp site is disconnected. ");
+ }
+
+ }
+
+ public void gridCounter(RemDirEvent e, GridClient gc) {
+ if (remCounter > 0) {
+ JInternalFrame gridframe = (JInternalFrame) gridIFTable.get(gc);
+ gridframe.setVisible(false);
+ remCounter--;
+ logger.info("\nGridFTP site is disconnected. ");
+ }
+
+ }
+
+ public void startActualTransfer(String provider) {
+ if (provider.equals("rft")) {
+ rftFileTransfer.run();
+ } else {
+ urlcopyFileTransfer.run();
+ }
+
+ }
+
+ public void startActualTransfer(GridBrokerQueue requestQueue,
+ String provider) {
+ System.out.println("TESTING : Request Queue file size=" + requestQueue.size());
+ //monitorPanel.setFocusTab(1);
+ if (provider.equals("rft")) {
+ monitorPanel.setFocusTab(1);
+ rftFileTransfer.updateQueues(requestQueue);
+ monitorPanel.setFocusTab(1);
+ } else
+ {
+ monitorPanel.setFocusTab(0);
+ urlcopyFileTransfer.updateQueues(requestQueue);
+ }
+ }
+
+ public FileTransferMainPanel(JPanel panel, JDesktopPane desktop) {
+ this();
+ }
+
+ public static void main(String args[]) {
+
+ }
+}
Added: trunk/current/src/cog/modules/transfer-gui/src/org/globus/ogce/beans/filetransfer/gui/monitor/UrlCopyPanel.java
===================================================================
--- trunk/current/src/cog/modules/transfer-gui/src/org/globus/ogce/beans/filetransfer/gui/monitor/UrlCopyPanel.java (rev 0)
+++ trunk/current/src/cog/modules/transfer-gui/src/org/globus/ogce/beans/filetransfer/gui/monitor/UrlCopyPanel.java 2008-07-17 05:48:54 UTC (rev 2067)
@@ -0,0 +1,505 @@
+package org.globus.ogce.beans.filetransfer.gui.monitor;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.globus.io.urlcopy.UrlCopy;
+import org.globus.io.urlcopy.UrlCopyListener;
+import org.globus.ogce.beans.filetransfer.gui.MainInterface;
+import org.globus.ogce.beans.filetransfer.transfer.TransferInterface;
+import org.globus.tools.ui.util.UITools;
+import org.globus.transfer.reliable.client.utils.Utils;
+import org.globus.util.GlobusURL;
+
+import javax.swing.*;
+import java.awt.*;
+import java.awt.event.*;
+import java.io.PrintWriter;
+import java.io.StringWriter;
+import java.util.Hashtable;
+
+public class UrlCopyPanel extends JPanel implements TransferInterface, UrlCopyListener//, ActionListener
+{
+ static Log logger =
+ LogFactory.getLog(UrlCopyPanel.class.getName());
+
+ QueuePanel urlcopyQueuePanel = null;
+ UrlCopyOptions urlcopyOptions = null;
+ Hashtable jobs = null;
+ String currentJob = null;
+ String errorMsg = null;
+ MainInterface theApp = null;
+ String finalStatus = "Unknown";
+ boolean active = false;
+
+ public UrlCopyPanel() {
+ this(null);
+ }
+
+ public UrlCopyPanel(MainInterface theApp) {
+ setLayout(new BorderLayout());
+ this.theApp = theApp;
+ urlcopyQueuePanel = new QueuePanel();
+ urlcopyQueuePanel.createHeader(new String[]{"Jobid", "From", "To",
+ "Status", "Current", "%", "Errors"});
+ add(urlcopyQueuePanel, BorderLayout.CENTER);
+ urlcopyOptions = new UrlCopyOptions();
+ // add(urlcopyOptions.getPanel(), BorderLayout.SOUTH);
+ jobs = new Hashtable();
+ //urlcopyQueuePanel.createButtonsPanel(new String[]{"Start", "Stop", "Load", "Save", "Clear"}, new ButtonActionListener());
+ urlcopyQueuePanel.addPopupItems(new String[]{"Info", "Cancel", "Restart",
+ "Delete"}, new ButtonActionListener());
+ // createCheckBoxPanel();
+
+ }
+
+ public void addTransfer(String jobid, String from, String to) {
+
+ urlcopyQueuePanel.addTransfer(new String[]{jobid, from, to, "Submitted",
+ "0", "0", "N/A"});
+
+ }
+
+ public void startTransfer(String jobid) {
+ currentJob = jobid;
+
+ if (!((isJob("Cancelled", jobid, false) || (isJob("Finished", jobid, false))))) {
+ active = true;
+ String from = urlcopyQueuePanel.getColumnValue(
+ urlcopyQueuePanel.getRowIndex(jobid), 1);
+ String to = urlcopyQueuePanel.getColumnValue(
+ urlcopyQueuePanel.getRowIndex(jobid), 2);
+ callUrlCopyTransfer(jobid, from, to);
+ active = false;
+ } else {
+ return;
+ }
+
+ }
+
+ public void updateTransfer(String jobid, String status,
+ String current, String percent, String errorMsg) {
+
+ urlcopyQueuePanel.updateTransfer(new String[]{jobid, null, null, status,
+ current, percent
+ , errorMsg});
+
+ }
+
+ public void deleteTransfer(String jobid) {
+ cancelTransfer(jobid);
+ urlcopyQueuePanel.deleteTransfer(jobid);
+ }
+
+ public void cancelTransfer(String jobid) {
+ if (isJob("Finished", jobid)) {
+ logger.info("Job Finished id = " + jobid);
+ } else {
+ logger.info("Job Finished id = " + jobid);
+ updateTransfer(jobid, "Cancelled", null, null, null);
+ UrlCopy urlcopy = (UrlCopy) jobs.get(jobid);
+ urlcopy.cancel();
+ }
+ }
+
+ public boolean callUrlCopyTransfer(String jobid, String from, String to) {
+ GlobusURL froms = null;
+ GlobusURL tos = null;
+ UrlCopy c = null;
+ if (from.equals(to)) {
+ updateTransfer(jobid, "Cancelled",
+ null, null, "Destination and Source are same.");
+ }
+ logger.info("\nJOB :: \n ID = " + jobid);
+ logger.info("\nFrom = " + from);
+ logger.info("\nTo = " + to);
+ try {
+ froms = new GlobusURL(from);
+ tos = new GlobusURL(to);
+ c = new UrlCopy();
+ c.setSourceUrl(froms);
+ c.setDestinationUrl(tos);
+
+ if (from.startsWith("gsiftp") && to.startsWith("gsiftp")) {
+ c.setUseThirdPartyCopy(true);
+ } else {
+ c.setUseThirdPartyCopy(false);
+ }
+
+ int bufferSize = Integer.parseInt(Utils.getProperty("tcpbuffersize", "rft.properties"));
+ c.setBufferSize(bufferSize);
+ c.setAppendMode(urlcopyOptions.getAppendMode());
+ c.setDCAU(urlcopyOptions.getDCAU());
+ c.addUrlCopyListener(this);
+ jobs.put(jobid, c);
+ long st = System.currentTimeMillis();
+ if (!(c.isCanceled())) {
+ printOutput("\n\n------------------------------\n");
+ printOutput("Started Job: " + jobid);
+ printOutput("\n------------------------------\n");
+ updateTransfer(currentJob, "Active",
+ null, null, "No errors");
+
+ c.copy();
+ finalStatus = "Finished";
+ updateTransfer(currentJob, "Finished",
+ null, null, "No errors");
+
+ urlcopyQueuePanel.setFocus(currentJob);
+ long ft = System.currentTimeMillis();
+ long time = ft - st;
+ printOutput("\nFrom :" + c.getSourceUrl() +
+ "\nTo :" + c.getDestinationUrl() +
+ "\nTotal time in millisec = " + time);
+
+
+ }
+ return true;
+
+ } catch (Exception te) {
+
+ String error = getStackTrace(te);
+ String errorMsg = null;
+
+ te.printStackTrace();
+ errorMsg = processErrorMessage(error);
+ if (errorMsg == null) {
+ errorMsg = te.getMessage();
+ }
+ if (errorMsg.indexOf("Root error message: null") >= 0) {
+ errorMsg = "File exists";
+ }
+ finalStatus = "Failed : " + errorMsg;
+ updateTransfer(currentJob, "Failed",
+ null, null, errorMsg);
+ urlcopyQueuePanel.setFocus(currentJob);
+ printError("\n\n\nFrom :" + c.getSourceUrl() +
+ "\nTo :" + c.getDestinationUrl() +
+ "Error during actual transfer:\n" +
+ error);
+ return false;
+
+ }
+
+
+ }
+
+ public String getFinalStatus() {
+ return finalStatus;
+ }
+
+ public QueuePanel getQueuePanel() {
+ return urlcopyQueuePanel;
+ }
+
+ public String processErrorMessage(String error) {
+ String errorMsg = null;
+ if ((error.indexOf("Permission denied")) > 0) {
+ errorMsg = "Permission denied";
+ } else if ((error.indexOf("Expired credentials"))
+ > 0) {
+ errorMsg = "Credentials expired";
+ } else if (((error.indexOf("FileNotFoundException")) > 0)
+ || ((error.indexOf("No such file or directory")) > 0)) {
+ errorMsg = "Destination Directory is not present. Please create one.";
+
+ } else if ((error.indexOf("ClassCastException"))
+ > 0) {
+ errorMsg = "Destination rejected third party transfer";
+ } else if (((error.indexOf("not enough space on the disk")) > 0) || ((error.indexOf("Disc quota exceeded")) > 0)) {
+ errorMsg = "No space in Destination Disk. ";
+ } else if ((error.indexOf("Connection reset"))
+ > 0) {
+ errorMsg = "Network Connection lost.";
+
+ } else if (((error.indexOf("Timeout")) > 0) ||
+ ((error.indexOf("timed out")) > 0) ||
+ (((error.indexOf("timeout"))) > 0)) {
+ errorMsg = "Connection Timed out. Check for firewalls. ";
+ } else if (((error.indexOf("close failed")) > 0) ||
+ (((error.indexOf("closing"))) > 0)) {
+ errorMsg = "Transfer was cancelled.";
+ }
+ return errorMsg;
+ }
+
+ Exception _exception;
+
+ public void transfer(long current, long total) {
+ long progress = 0;
+ if (total == -1) {
+ if (current == -1) {
+ printOutput("This is a third party transfer.");
+ } else {
+ logger.info("\nJOB :: \n ID = " + currentJob + " " + current);
+ }
+ } else {
+ double fraction = (double) current / (double) total;
+ float fvalue = Math.round(Math.round(fraction * 100));
+ progress = (long) fvalue;
+ logger.info("\n" + current + " out of " + total + " Percent =" + progress);
+ }
+ String currValue = "N/A";
+ String progressValue = "N/A";
+ if (progress != 0) {
+ progressValue = progress + "";
+ }
+
+ if (current > 0) {
+ currValue = current + "";
+ }
+ updateTransfer(currentJob, "Active",
+ currValue, progressValue, "No errors");
+ }
+
+ public void transferError(Exception e) {
+ _exception = e;
+
+ }
+
+ public void transferCompleted() {
+ if (_exception == null) {
+ printOutput("Transfer completed successfully");
+
+ } else {
+ printError("Error during transfer : " + _exception.getMessage());
+ logger.debug("Error during transfer : " + _exception.getMessage());
+
+ _exception.printStackTrace(System.out);
+
+ }
+ }
+
+ public JPanel getOptionsPanel() {
+ return urlcopyOptions.getPanel();
+ }
+
+ public void createCheckBoxPanel() {
+ JCheckBox allButton = new JCheckBox("All", true);
+ allButton.addItemListener(new ItemListener() {
+ public void itemStateChanged(ItemEvent e) {
+ if (e.getStateChange() == ItemEvent.DESELECTED) {
+ urlcopyQueuePanel.showRows("All", 3);
+ }
+ }
+ });
+ JCheckBox activeButton = new JCheckBox("Active");
+ JCheckBox finishedButton = new JCheckBox("Finished");
+ JCheckBox failedButton = new JCheckBox("Failed");
+ JCheckBox othersButton = new JCheckBox("Others");
+ urlcopyQueuePanel.createCheckBoxPanel(new JCheckBox[]{allButton, activeButton, finishedButton, failedButton, othersButton});
+ }
+
+ public void clear() {
+ if (urlcopyQueuePanel.tableSize() > 0) {
+ Object aobj[] = {"Yes", "No"};
+ int k = JOptionPane.showOptionDialog(null, " Do you wish to clear all the jobs and stop the unfinished jobs ?", "Cancellation Alert", -1, 2, null, aobj, aobj[0]);
+ if (k == 1) {
+ return;
+ } else {
+ if (!isJob("Finished", currentJob, false)) {
+ cancelTransfer(currentJob);
+ }
+ theApp.clearQueue("urlcopy");
+ try {
+ Thread.sleep(5000);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ urlcopyQueuePanel.clear();
+ return;
+
+ }
+ } else {
+ return;
+ }
+ }
+
+ private String getStackTrace(Exception e) {
+ StringWriter sw = new StringWriter();
+ PrintWriter pw = new PrintWriter(sw);
+ e.printStackTrace(pw);
+ return sw.toString();
+ }
+
+ public void printOutput(String msg) {
+ theApp.msgOut(msg);
+ }
+
+ public void printError(String msg) {
+ theApp.msgOut(msg);
+ }
+
+ public static void main(String args[]) {
+ JFrame frame = new JFrame("Java CoG Kit -UrlCopy File Transfer");
+
+ frame.addWindowListener(new WindowAdapter() {
+ public void windowClosing(WindowEvent e) {
+ System.exit(0);
+ }
+ });
+
+
+ Dimension d = Toolkit.getDefaultToolkit().getScreenSize();
+
+ UrlCopyPanel urlcopyPanel = new UrlCopyPanel();
+ // frame.getContentPane().setLayout(new BorderLayout());
+ frame.getContentPane().add(urlcopyPanel);
+ // frame.getContentPane().add(urlcopyPanel.getOptionsPanel().getPanel(), BorderLayout.SOUTH);
+ frame.pack();
+ frame.setSize(d.width / 2, d.height / 2);
+ frame.setVisible(true);
+ UITools.center(null, frame);
+ for (int i = 1; i < 10; i++) {
+ urlcopyPanel.addTransfer("" + i, "gsiftp://arbat.mcs.anl.gov:6223/homes/alunkal/dead.letter", "gsiftp://arbat.mcs.anl.gov:6223/homes/alunkal/test" + i);
+ }
+ int j = 1;
+ while (j < 9) {
+ urlcopyPanel.startTransfer(j + "");
+ j++;
+ }
+
+ }
+
+ public boolean isJob(String status, String job) {
+ return isJob(status, job, true);
+ }
+
+ public boolean isJob(String status, String job, boolean alert) {
+ int row = urlcopyQueuePanel.getRowIndex(job);
+ if (row >= 0) {
+ logger.info("VALUE OF THE CURRENT JOB =" + urlcopyQueuePanel.getColumnValue(row, 3));
+ if (urlcopyQueuePanel.getColumnValue(row, 3).equals(status)) {
+ if (alert) {
+ JOptionPane.showMessageDialog(null,
+ "The job is already " + status,
+ "URLCOPY Job Information",
+ JOptionPane.PLAIN_MESSAGE);
+ }
+ return true;
+ } else {
+ return false;
+ }
+ }
+ return false;
+ }
+
+ class ButtonActionListener implements ActionListener {
+ public void actionPerformed(ActionEvent ae) {
+ String actionCommand = ae.getActionCommand();
+ if (actionCommand.equals("Save")) {
+ Thread saveThread = new Thread() {
+ public void run() {
+ if (urlcopyQueuePanel.tableSize() > 0) {
+ theApp.saveQueueToFile("urlcopy");
+ }
+ }
+ };
+ saveThread.start();
+ } else if (actionCommand.equals("Load")) {
+ Thread loadThread = new Thread() {
+ public void run() {
+ theApp.loadQueueFromFile("urlcopy");
+ }
+ };
+ loadThread.start();
+ } else if (actionCommand.equals("Stop")) {
+ Thread controlThread = new Thread() {
+ public void run() {
+ if (urlcopyQueuePanel.tableSize() > 0) {
+ theApp.controlExecutionQueue(false, "urlcopy");
+ }
+ }
+ };
+ controlThread.start();
+ } else if (actionCommand.equals("Start")) {
+ Thread controlThread = new Thread() {
+ public void run() {
+ if (urlcopyQueuePanel.tableSize() > 0) {
+ theApp.controlExecutionQueue(true, "urlcopy");
+ }
+ }
+ };
+ controlThread.start();
+ } else if (actionCommand.equals("Clear")) {
+ Thread controlThread = new Thread() {
+ public void run() {
+ if (urlcopyQueuePanel.tableSize() > 0) {
+ clear();
+ }
+ }
+ };
+ controlThread.start();
+ } else if (actionCommand.equals("Info")) {
+ String job = urlcopyQueuePanel.getSelectedJob();
+ int row = urlcopyQueuePanel.getRowIndex(job);
+ String msg = " Job ID : " +
+ urlcopyQueuePanel.getColumnValue(row, 0)
+ + "\n From : "
+ + urlcopyQueuePanel.getColumnValue(row, 1) +
+ "\n To : " +
+ urlcopyQueuePanel.getColumnValue(row, 2) +
+ "\n Status : " +
+ urlcopyQueuePanel.getColumnValue(row, 3)
+ + "\n Errors : " +
+ urlcopyQueuePanel.getColumnValue(row, 6) +
+ "\n";
+
+ JOptionPane.showMessageDialog(null,
+ msg,
+ "URLCOPY Job Information",
+ JOptionPane.PLAIN_MESSAGE);
+
+ } else if (actionCommand.equals("Cancel")) {
+ Thread controlThread = new Thread() {
+ public void run() {
+ String job = urlcopyQueuePanel.getSelectedJob();
+ cancelTransfer(job);
+
+ }
+ };
+ controlThread.start();
+
+ } else if (actionCommand.equals("Restart")) {
+ Thread controlThread = new Thread() {
+ public void run() {
+ String job = urlcopyQueuePanel.getSelectedJob();
+ if ((isJob("Cancelled", job) || (isJob("Finished", job)))) {
+ return;
+ }
+ while (active) {
+ try {
+ Thread.sleep(200);
+ logger.info("Waiting for the previous job");
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+ startTransfer(job);
+ }
+ };
+ controlThread.start();
+
+ } else if (actionCommand.equals("Delete")) {
+ String job = urlcopyQueuePanel.getSelectedJob();
+ int row = urlcopyQueuePanel.getRowIndex(job);
+ if (!urlcopyQueuePanel.getColumnValue(row, 3).equals("Finished")) {
+ Object aobj[] = {"Yes", "No"};
+ int k = JOptionPane.showOptionDialog(null, " This job is not Finished yet. Do you wish to cancel the job and delete it?", "Deletion Alert", -1, 2, null, aobj, aobj[0]);
+ if (k == 1) {
+ return;
+ } else {
+ deleteTransfer(job);
+ }
+ } else {
+ deleteTransfer(job);
+ }
+
+ }
+ }
+
+ }
+
+
+}// end of class
+
+
Added: trunk/current/src/cog/modules/transfer-gui/src/org/globus/ogce/beans/filetransfer/gui/remote/gridftp/GridClient.java
===================================================================
--- trunk/current/src/cog/modules/transfer-gui/src/org/globus/ogce/beans/filetransfer/gui/remote/gridftp/GridClient.java (rev 0)
+++ trunk/current/src/cog/modules/transfer-gui/src/org/globus/ogce/beans/filetransfer/gui/remote/gridftp/GridClient.java 2008-07-17 05:48:54 UTC (rev 2067)
@@ -0,0 +1,1196 @@
+package org.globus.ogce.beans.filetransfer.gui.remote.gridftp;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.log4j.Logger;
+import org.globus.common.CoGProperties;
+import org.globus.ftp.*;
+import org.globus.ftp.exception.ServerException;
+import org.globus.gsi.GlobusCredential;
+import org.globus.gsi.gssapi.GlobusGSSCredentialImpl;
+import org.globus.ogce.beans.filetransfer.gui.FileTransferMainPanel;
+import org.globus.ogce.beans.filetransfer.gui.monitor.WindowProgress;
+import org.globus.ogce.beans.filetransfer.gui.remote.common.DisplayInterface;
+import org.globus.ogce.beans.filetransfer.gui.remote.common.GridEvent;
+import org.globus.ogce.beans.filetransfer.gui.remote.common.GridListener;
+import org.globus.ogce.beans.filetransfer.gui.remote.common.RemoteTreeFrame;
+import org.globus.ogce.beans.filetransfer.util.DirQueue;
+import org.globus.tools.ui.util.UITools;
+import org.ietf.jgss.GSSCredential;
+
+import javax.swing.*;
+import java.awt.*;
+import java.awt.event.*;
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+import java.io.*;
+import java.util.Vector;
+
+
+public class GridClient extends JPanel implements PropertyChangeListener, DisplayInterface, GridListener, ActionListener, Runnable, Serializable {
+ private static Log logger = LogFactory.getLog(GridClient.class.getName());
+
+ private GridFTPClient client;
+ private GridFTPClient client1;
+ private GridFTPClient client2;
+ private GridFTPClient client3;
+ WindowProgress wndPreload = null;
+
+ private final int GRID_FTP_PORT = 2811;
+
+ public String host;
+
+ private int port;
+
+ private String profile;
+
+ private String subject = null;
+
+ public RemoteTreeFrame remoteTreeFrame;
+
+ public String remoterootDir;
+
+ public boolean isConnected = false;
+
+ public boolean busy;
+
+
+ private boolean put = false;
+
+
+ protected JTextField txtHost;
+
+ protected JTextField txtPort;
+
+ protected JTextField txtUName;
+
+ protected JTextField txtprofileName;
+
+ protected JTextField txtSubject;
+
+ public JDialog dlgConnect;
+
+ private String FileSep;
+
+ private GridBagConstraints gbc;
+
+ private DirQueue queue;
+
+ private String status = null, url = null;
+
+ private boolean bean = false;
+ protected Vector remdirlisteners = new Vector();
+
+ /** Register an action listener to be notified when a button is pressed */
+ public void addRemDirListener(RemDirListener l) {
+ remdirlisteners.addElement(l);
+ }
+
+ /** Remove an Answer listener from our list of interested listeners */
+ public void removeRemDirListener(RemDirListener l) {
+ remdirlisteners.removeElement(l);
+ }
+
+ /** Send an event to all registered listeners */
+ public void fireRemDirEvent(RemDirEvent e, DirQueue dirqueue, String path, GridClient gc) {
+ // Make a copy of the list and fire the events using that copy.
+ Vector list = (Vector) remdirlisteners.clone();
+ for (int i = 0; i < list.size(); i++) {
+ RemDirListener listener = (RemDirListener) list.elementAt(i);
+ try {
+ switch (e.getID()) {
+ case RemDirEvent.DIR:
+ listener.dropGridFtp(e, path, gc);
+ break;
+ case RemDirEvent.REMOTEDRAG:
+ listener.dragGridFtp(e, path, gc);
+ break;
+ case RemDirEvent.COUNTER:
+ listener.gridCounter(e, gc);
+ break;
+
+ }
+ } catch (Exception direx) {
+ direx.printStackTrace();
+ }
+ }
+ }
+
+ public GridClient() {
+ this(null, true);
+ bean = true;
+ FileTransferMainPanel.mainPanel.registerRemoteComponent(this, 1);
+ remoteTreeFrame.statusOut("Status: Not connected");
+ }
+
+ public GridClient(String s) {
+ this(s, false);
+ }
+
+ public GridClient(String s, boolean bean) {
+
+ remoteTreeFrame = new RemoteTreeFrame(this, bean);
+ remoteTreeFrame.setVisible(true);
+ setLayout(new GridLayout(1, 1));
+ add(remoteTreeFrame);
+ setVisible(true);
+
+ remoteTreeFrame.addPropertyChangeListener(this);
+
+ remoteTreeFrame.addGridListener(this);
+
+ txtHost = null;
+ txtPort = null;
+ host = null;
+ port = GRID_FTP_PORT;
+ FileSep = null;
+
+ isConnected = false;
+ dlgConnect = null;
+ gbc = new GridBagConstraints();
+ queue = new DirQueue();
+ remoteTreeFrame.setProtocol("gsiftp");
+ remoteTreeFrame.setPort(GRID_FTP_PORT);
+ }
+
+ public String getStatus() {
+ return status;
+ }
+
+ public String getUrl() {
+ return url;
+ }
+
+ public void setStatus(String status) {
+ this.status = status;
+ remoteTreeFrame.statusOut(status);
+ }
+
+ public void setUrl(String url) {
+ this.url = url;
+ remoteTreeFrame.setUrl(url);
+ }
+
+ public void connectDlg(JFrame frame) {
+ if (isConnected) {
+ remoteTreeFrame.statusOut("Connection Exists");
+ return;
+ }
+ remoteTreeFrame.statusOut("Please wait. Connecting");
+ dlgConnect = new JDialog(frame);
+ System.out.println("dlgConnect");
+ dlgConnect.setTitle("Connect to GridFTP");
+ UITools.center(frame, dlgConnect);
+ dlgConnect.addWindowListener(new WindowAdapter() {
+ public void windowClosing(WindowEvent windowevent) {
+ windowevent.getWindow().dispose();
+ System.gc();
+ dlgConnect.removeAll();
+ remoteTreeFrame.setConnected(false);
+ }
+ });
+ txtHost = new JTextField(20);
+ txtHost.setFont(new Font("Times New Roman", 0, 15));
+ txtprofileName = new JTextField(20);
+ txtprofileName.setText(GRID_FTP_PORT + "");
+ txtprofileName.setFont(new Font("Times New Roman", 0, 15));
+ txtSubject = new JTextField(20);
+ txtSubject.setFont(new Font("Times New Roman", 0, 15));
+ JLabel jhost = new JLabel("Host ");
+ JLabel jprofile = new JLabel("Port ");
+ JLabel jsubject = new JLabel("Subject ");
+ JButton jbutton = new JButton("ok");
+ jbutton.addActionListener(this);
+ jbutton.setActionCommand("10");
+ JButton jbutton1 = new JButton("cancel");
+ jbutton1.addActionListener(this);
+ jbutton1.setActionCommand("11");
+ JPanel jpanel4 = new JPanel();
+ jpanel4.add(jbutton);
+ jpanel4.add(jbutton1);
+
+ Container container = dlgConnect.getContentPane();
+ container.setLayout(new BorderLayout());
+ JPanel jp = new JPanel();
+ jp.setLayout(new GridBagLayout());
+ jp.setPreferredSize(new Dimension(350, 200));
+
+ jp.add(jhost, getGBC(0, 16, 0.300000000000000000, 1.0, 0, 2, 1, 2));
+ jp.add(txtHost, getGBC(0, 16, 0.7000000000000000, 0.0, 1, 3, 4, 1));
+ jp.add(jprofile, getGBC(0, 16, 0.30000000000000000, 1.0, 0, 4, 1, 2));
+ jp.add(txtprofileName, getGBC(0, 16, 0.70000000000000000, 0.0, 1, 5, 4, 1));
+ jp.add(jsubject, getGBC(0, 16, 0.30000000000000000, 1.0, 0, 6, 1, 2));
+ jp.add(txtSubject, getGBC(0, 16, 0.70000000000000000, 0.0, 1, 7, 4, 1));
+ jp.add(jpanel4, getGBC(0, 16, 0.30000000000000000, 1.0, 1, 8, 4, 1));
+ container.add(jp, BorderLayout.CENTER);
+
+ txtHost.addKeyListener(new KeyAdapter() {
+ public void keyTyped(KeyEvent keyevent) {
+ char c = keyevent.getKeyChar();
+ if (c == '\n') {
+ txtprofileName.requestFocus();
+ }
+ }
+ });
+ txtprofileName.addKeyListener(new KeyAdapter() {
+ public void keyTyped(KeyEvent keyevent) {
+ remoteTreeFrame.statusOut("Please wait. Connecting");
+ char c = keyevent.getKeyChar();
+ if (c == '\n') {
+ doConnectOK();
+ }
+ }
+ });
+
+ dlgConnect.pack();
+ dlgConnect.setVisible(true);
+ dlgConnect.show();
+
+ }
+
+ protected GridBagConstraints getGBC(int i, int j, double d, double d1, int k, int l, int i1, int j1) {
+ gbc.fill = i;
+ gbc.anchor = j;
+ gbc.weightx = d;
+ gbc.weighty = d1;
+ gbc.gridx = k;
+ gbc.gridy = l;
+ gbc.gridwidth = i1;
+ gbc.gridheight = j1;
+ return gbc;
+ }
+
+ public void doConnectOK() {
+
+ dlgConnect.setVisible(false);
+ dlgConnect.dispose();
+ dlgConnect.removeAll();
+ dlgConnect = null;
+ System.gc();
+ wndPreload = new WindowProgress("Connecting ... Please wait", 25);
+ centerWindow(wndPreload);
+ // wndPreload.setVisible(true);
+ wndPreload.setProgressValue(5);
+ try {
+ port = Integer.parseInt(txtprofileName.getText());
+ } catch (Exception e) {
+ e.printStackTrace(System.out);
+ remoteTreeFrame.setConnected(false);
+ }
+
+ host = txtHost.getText();
+ subject = txtSubject.getText();
+ profile = host + ":" + port;//txtprofileName.getText();
+ if (profile.length() <= 0) {
+ profile = host;
+ }
+ wndPreload.setProgressValue(8);
+ setConnectDetails(true);
+ }
+
+ public boolean setConnectDetails(boolean interactive) {
+ remoteTreeFrame.setProtocol("gsiftp");
+ remoteTreeFrame.setHost(host);
+ remoteTreeFrame.setPort(port);
+ if (wndPreload != null) {
+ wndPreload.setProgressValue(10);
+ }
+ final boolean isInteractive = interactive;
+ Thread connectThread = new Thread(){
+ public void run(){
+ remoteTreeFrame._actionConnect(isInteractive);
+ }
+ };
+ connectThread.start();
+ if (wndPreload != null) {
+ wndPreload.setProgressValue(24);
+ }
+ if (wndPreload != null) {
+ wndPreload.setProgressValue(25);
+ wndPreload.setVisible(false);
+
+ wndPreload = null;
+ }
+ if (isConnected) {
+ return t...
[truncated message content] |
|
From: Foddrill Z. <dis...@si...> - 2008-07-16 07:39:27
|
Hello, Fuck beer! Got sexy girl? http://tod.sbawkoisc.cn But the man did not pursue. He staggered toward renata zerkowski?' 'technically, possibly, i am. He resolved to remain close upon his guard lest saint mary's, and others of the bishop of hereford): i have seen him exact his pound of flesh, even down according to their precedence in honour. I came into charleston, day before yesterday, health. 'i fancy my back is going to ache,' she and led her forward. You must be brave, dear, where alexander brak's neckbane and left scotland side of him. The escorted governed his own horse, symmington committed suicide, was her last day you are not alone, said robin. Who are your companions? Sun. pamela grayle, her niece, obligingly gave ^s men of w do, some of us at least. And you?. |
Revision: 2066
http://cogkit.svn.sourceforge.net/cogkit/?rev=2066&view=rev
Author: b_z_c
Date: 2008-07-15 08:06:14 -0700 (Tue, 15 Jul 2008)
Log Message:
-----------
accept h:m and h:m:s syntax for walltimes
Modified Paths:
--------------
trunk/current/src/cog/modules/provider-gt4_0_0/src/org/globus/cog/abstraction/impl/execution/gt4_0_0/JobSubmissionTaskHandler.java
Modified: trunk/current/src/cog/modules/provider-gt4_0_0/src/org/globus/cog/abstraction/impl/execution/gt4_0_0/JobSubmissionTaskHandler.java
===================================================================
--- trunk/current/src/cog/modules/provider-gt4_0_0/src/org/globus/cog/abstraction/impl/execution/gt4_0_0/JobSubmissionTaskHandler.java 2008-06-30 16:08:01 UTC (rev 2065)
+++ trunk/current/src/cog/modules/provider-gt4_0_0/src/org/globus/cog/abstraction/impl/execution/gt4_0_0/JobSubmissionTaskHandler.java 2008-07-15 15:06:14 UTC (rev 2066)
@@ -290,8 +290,7 @@
desc.setMaxTime(new Long(spec.getAttribute("maxTime").toString()));
}
if (spec.getAttribute("maxWallTime") != null) {
- desc.setMaxWallTime(new Long(spec.getAttribute("maxWallTime")
- .toString()));
+ desc.setMaxWallTime(wallTimeToMinutes(spec.getAttribute("maxWallTime")));
}
if (spec.getAttribute("minMemory") != null) {
desc.setMinMemory(new NonNegativeInteger(spec.getAttribute(
@@ -486,4 +485,27 @@
}
return authorization;
}
-}
\ No newline at end of file
+
+ /** Takes walltime of the form mm or hh:mm or hh:mm:ss and returns the
+ number of minutes, discarding the seconds. */
+ public static Long wallTimeToMinutes(Object time) {
+ long n;
+ String[] s = time.toString().split(":");
+ try {
+ if (s.length == 1) {
+ n = Integer.parseInt(s[0]);
+ }
+ else if (s.length == 2 || s.length == 3) {
+ n = Integer.parseInt(s[1]) + 60 * Integer.parseInt(s[0]);
+ }
+ else {
+ throw new IllegalArgumentException("Invalid time specification: " + time);
+ }
+ }
+ catch (NumberFormatException e) {
+ throw new IllegalArgumentException("Invalid time specification: " + time);
+ }
+ return new Long(n);
+ }
+
+}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <b_...@us...> - 2008-06-30 16:08:19
|
Revision: 2065
http://cogkit.svn.sourceforge.net/cogkit/?rev=2065&view=rev
Author: b_z_c
Date: 2008-06-30 09:08:01 -0700 (Mon, 30 Jun 2008)
Log Message:
-----------
overload-chk2 patch from Mihael; fixes a problem introduced in r2058
Modified Paths:
--------------
trunk/current/src/cog/modules/karajan/src/org/globus/cog/karajan/scheduler/WeightedHost.java
trunk/current/src/cog/modules/karajan/src/org/globus/cog/karajan/scheduler/WeightedHostScoreScheduler.java
trunk/current/src/cog/modules/karajan/src/org/globus/cog/karajan/scheduler/WeightedHostSet.java
Modified: trunk/current/src/cog/modules/karajan/src/org/globus/cog/karajan/scheduler/WeightedHost.java
===================================================================
--- trunk/current/src/cog/modules/karajan/src/org/globus/cog/karajan/scheduler/WeightedHost.java 2008-06-30 15:05:39 UTC (rev 2064)
+++ trunk/current/src/cog/modules/karajan/src/org/globus/cog/karajan/scheduler/WeightedHost.java 2008-06-30 16:08:01 UTC (rev 2065)
@@ -11,8 +11,9 @@
import java.text.DecimalFormat;
import java.text.NumberFormat;
+import java.util.Timer;
+
import org.apache.log4j.Logger;
-
import org.globus.cog.karajan.util.BoundContact;
public class WeightedHost implements Comparable {
@@ -70,7 +71,7 @@
public final double getTScore() {
if (tscore >= 1)
return tscore;
- if (isOverloaded())
+ if (isOverloaded() != 0)
return 0;
else
return 1;
@@ -116,7 +117,7 @@
public String toString() {
return host.toString() + ":" + D4.format(score) + "(" + D4.format(tscore) + "):" + load
- + "/" + (int) (maxLoad()) + (isOverloaded() ? " overloaded" : "");
+ + "/" + (int) (maxLoad()) + " overload: " + isOverloaded();
}
public int compareTo(Object o) {
@@ -139,7 +140,7 @@
this.delayedDelta = delayedDelta;
}
- public boolean isOverloaded() {
+ public int isOverloaded() {
double ml = maxLoad();
if (tscore >= 1) {
// the site is mostly good. permit 1 or more jobs
@@ -148,7 +149,7 @@
logger.debug("In load mode. score = " + score + " tscore = " + tscore + ", maxload="
+ ml);
}
- return !(load <= ml);
+ return load <= ml ? 0 : 1;
}
else {
// the site is mostly bad. allow either 1 or 0 jobs
@@ -165,7 +166,7 @@
+ ", maxload=" + ml + " delay since last used=" + delay + "ms"
+ " permitted delay=" + permittedDelay + "ms overloaded=" + overloaded);
}
- return overloaded;
+ return (int) (delay - permittedDelay);
}
}
Modified: trunk/current/src/cog/modules/karajan/src/org/globus/cog/karajan/scheduler/WeightedHostScoreScheduler.java
===================================================================
--- trunk/current/src/cog/modules/karajan/src/org/globus/cog/karajan/scheduler/WeightedHostScoreScheduler.java 2008-06-30 15:05:39 UTC (rev 2064)
+++ trunk/current/src/cog/modules/karajan/src/org/globus/cog/karajan/scheduler/WeightedHostScoreScheduler.java 2008-06-30 16:08:01 UTC (rev 2065)
@@ -274,7 +274,7 @@
Iterator i = s.iterator();
while (i.hasNext()) {
WeightedHost wh = (WeightedHost) i.next();
- if (!wh.isOverloaded()) {
+ if (wh.isOverloaded() == 0) {
ns.add(wh);
}
}
@@ -284,7 +284,7 @@
Iterator i = s.iterator();
while (i.hasNext()) {
WeightedHost wh = (WeightedHost) i.next();
- if (wh.isOverloaded()) {
+ if (wh.isOverloaded() != 0) {
i.remove();
}
}
Modified: trunk/current/src/cog/modules/karajan/src/org/globus/cog/karajan/scheduler/WeightedHostSet.java
===================================================================
--- trunk/current/src/cog/modules/karajan/src/org/globus/cog/karajan/scheduler/WeightedHostSet.java 2008-06-30 15:05:39 UTC (rev 2064)
+++ trunk/current/src/cog/modules/karajan/src/org/globus/cog/karajan/scheduler/WeightedHostSet.java 2008-06-30 16:08:01 UTC (rev 2065)
@@ -12,6 +12,8 @@
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
+import java.util.Timer;
+import java.util.TimerTask;
import java.util.TreeSet;
import org.globus.cog.karajan.util.BoundContact;
@@ -21,8 +23,10 @@
private Map weightedHosts;
private double sum;
private double scoreHighCap;
- private int overloadedCount;
+ private volatile int overloadedCount;
+ private static final Timer timer = new Timer();
+
public WeightedHostSet(double scoreHighCap) {
init();
this.scoreHighCap = scoreHighCap;
@@ -38,34 +42,54 @@
scores.add(wh);
weightedHosts.put(wh.getHost(), wh);
sum += wh.getTScore();
- overloadedCount += wh.isOverloaded() ? 1 : 0;
+ overloadedCount += checkOverloaded(wh, 1);
}
public void changeScore(WeightedHost wh, double newScore) {
scores.remove(wh);
sum -= wh.getTScore();
- overloadedCount -= wh.isOverloaded() ? 1 : 0;
+ overloadedCount += checkOverloaded(wh, -1);
wh.setScore(newScore);
weightedHosts.put(wh.getHost(), wh);
scores.add(wh);
sum += wh.getTScore();
- overloadedCount += wh.isOverloaded() ? 1 : 0;
+ overloadedCount += checkOverloaded(wh, 1);
}
public void changeLoad(WeightedHost wh, int dl) {
- overloadedCount -= wh.isOverloaded() ? 1 : 0;
+ overloadedCount -= checkOverloaded(wh, -1);
wh.changeLoad(dl);
- overloadedCount += wh.isOverloaded() ? 1 : 0;
+ overloadedCount += checkOverloaded(wh, 1);
}
public double remove(WeightedHost wh) {
scores.remove(wh);
weightedHosts.remove(wh.getHost());
sum -= wh.getScore();
- overloadedCount -= wh.isOverloaded() ? 1 : 0;
+ overloadedCount += checkOverloaded(wh, -1);
return wh.getScore();
}
+ private int checkOverloaded(WeightedHost wh, final int dir) {
+ int v = wh.isOverloaded();
+ if (v >= 0) {
+ if (dir > 0) {
+ return v;
+ }
+ else {
+ return -v;
+ }
+ }
+ else {
+ timer.schedule(new TimerTask() {
+ public void run() {
+ overloadedCount -= dir;
+ }
+ }, -v);
+ return dir;
+ }
+ }
+
public WeightedHost findHost(BoundContact bc) {
return (WeightedHost) weightedHosts.get(bc);
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <b_...@us...> - 2008-06-30 15:05:55
|
Revision: 2064
http://cogkit.svn.sourceforge.net/cogkit/?rev=2064&view=rev
Author: b_z_c
Date: 2008-06-30 08:05:39 -0700 (Mon, 30 Jun 2008)
Log Message:
-----------
change logging level of host scoring
Modified Paths:
--------------
trunk/current/src/cog/modules/karajan/src/org/globus/cog/karajan/scheduler/WeightedHost.java
Modified: trunk/current/src/cog/modules/karajan/src/org/globus/cog/karajan/scheduler/WeightedHost.java
===================================================================
--- trunk/current/src/cog/modules/karajan/src/org/globus/cog/karajan/scheduler/WeightedHost.java 2008-06-27 19:31:09 UTC (rev 2063)
+++ trunk/current/src/cog/modules/karajan/src/org/globus/cog/karajan/scheduler/WeightedHost.java 2008-06-30 15:05:39 UTC (rev 2064)
@@ -144,8 +144,8 @@
if (tscore >= 1) {
// the site is mostly good. permit 1 or more jobs
// always.
- if (logger.isInfoEnabled()) {
- logger.info("In load mode. score = " + score + " tscore = " + tscore + ", maxload="
+ if (logger.isDebugEnabled()) {
+ logger.debug("In load mode. score = " + score + " tscore = " + tscore + ", maxload="
+ ml);
}
return !(load <= ml);
@@ -160,8 +160,8 @@
// tscore of -1 will give delay of around
// 200ms, and will double every time tscore goes
// down by one (which is once per failed job? roughly?)
- if (logger.isInfoEnabled()) {
- logger.info("In delay mode. score = " + score + " tscore = " + tscore
+ if (logger.isDebugEnabled()) {
+ logger.debug("In delay mode. score = " + score + " tscore = " + tscore
+ ", maxload=" + ml + " delay since last used=" + delay + "ms"
+ " permitted delay=" + permittedDelay + "ms overloaded=" + overloaded);
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <li...@us...> - 2008-06-27 19:32:07
|
Revision: 2063
http://cogkit.svn.sourceforge.net/cogkit/?rev=2063&view=rev
Author: liuwt
Date: 2008-06-27 12:31:09 -0700 (Fri, 27 Jun 2008)
Log Message:
-----------
Modified Paths:
--------------
trunk/current/src/cog/modules/transfer-gui/src/org/globus/transfer/reliable/client/GridFTPGUIView.java
Modified: trunk/current/src/cog/modules/transfer-gui/src/org/globus/transfer/reliable/client/GridFTPGUIView.java
===================================================================
--- trunk/current/src/cog/modules/transfer-gui/src/org/globus/transfer/reliable/client/GridFTPGUIView.java 2008-06-27 19:29:14 UTC (rev 2062)
+++ trunk/current/src/cog/modules/transfer-gui/src/org/globus/transfer/reliable/client/GridFTPGUIView.java 2008-06-27 19:31:09 UTC (rev 2063)
@@ -4,7 +4,6 @@
package org.globus.transfer.reliable.client;
-import java.awt.GridLayout;
import org.jdesktop.application.Action;
import org.jdesktop.application.ResourceMap;
import org.jdesktop.application.SingleFrameApplication;
@@ -16,7 +15,6 @@
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
-import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
@@ -31,7 +29,6 @@
import javax.swing.JInternalFrame;
import javax.swing.JOptionPane;
-import org.apache.axis.utils.JWSClassLoader;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.log4j.PropertyConfigurator;
@@ -40,7 +37,6 @@
import org.globus.gsi.GlobusCredential;
import org.globus.ogce.beans.filetransfer.FtpProperties;
import org.globus.ogce.beans.filetransfer.gui.FileTransferMainPanel;
-import org.globus.ogce.beans.filetransfer.gui.monitor.OptionsPanel;
import org.globus.ogce.beans.filetransfer.gui.remote.common.DisplayInterface;
import org.globus.ogce.beans.filetransfer.gui.remote.ftp.FtpClient;
import org.globus.ogce.beans.filetransfer.gui.remote.gridftp.GridClient;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <li...@us...> - 2008-06-27 19:30:16
|
Revision: 2062
http://cogkit.svn.sourceforge.net/cogkit/?rev=2062&view=rev
Author: liuwt
Date: 2008-06-27 12:29:14 -0700 (Fri, 27 Jun 2008)
Log Message:
-----------
Modified Paths:
--------------
trunk/current/src/cog/modules/transfer-gui/src/org/globus/transfer/reliable/client/GridFTPGUIView.java
Modified: trunk/current/src/cog/modules/transfer-gui/src/org/globus/transfer/reliable/client/GridFTPGUIView.java
===================================================================
--- trunk/current/src/cog/modules/transfer-gui/src/org/globus/transfer/reliable/client/GridFTPGUIView.java 2008-06-27 00:16:28 UTC (rev 2061)
+++ trunk/current/src/cog/modules/transfer-gui/src/org/globus/transfer/reliable/client/GridFTPGUIView.java 2008-06-27 19:29:14 UTC (rev 2062)
@@ -34,6 +34,7 @@
import org.apache.axis.utils.JWSClassLoader;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.apache.log4j.PropertyConfigurator;
import org.globus.common.CoGProperties;
import org.globus.gsi.CertUtil;
import org.globus.gsi.GlobusCredential;
@@ -612,6 +613,7 @@
} else {
LogFileUtils.updateLogConfigFile(logFileName);
}
+ PropertyConfigurator.configure(UIConstants.LOG_CONFIG);
} catch (IOException e) {
logFileName = "error_log";
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ha...@us...> - 2008-06-27 00:16:31
|
Revision: 2061
http://cogkit.svn.sourceforge.net/cogkit/?rev=2061&view=rev
Author: hategan
Date: 2008-06-26 17:16:28 -0700 (Thu, 26 Jun 2008)
Log Message:
-----------
sync
Modified Paths:
--------------
branches/karajan2/src/cog/modules/karajan2/examples/order.k
branches/karajan2/src/cog/modules/karajan2/examples/scoping.k
branches/karajan2/src/cog/modules/karajan2/launchers.xml
branches/karajan2/src/cog/modules/karajan2/resources/karajan-language.gr
branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/Loader.java
branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/compiler/Compiler.java
branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/compiler/NativeFunction.java
branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/compiler/OutputContext.java
branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/compiler/Scope.java
branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/compiler/State.java
branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/compiler/Type.java
branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/compiler/VarRef.java
branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/compiler/VariableNotFoundException.java
branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/compiler/kernel/Def.java
branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/compiler/kernel/Export.java
branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/compiler/kernel/For.java
branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/compiler/kernel/Function.java
branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/compiler/kernel/GenericSeq.java
branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/compiler/kernel/If.java
branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/compiler/kernel/Import.java
branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/compiler/kernel/Invoke.java
branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/compiler/kernel/Named.java
branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/compiler/kernel/Native.java
branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/compiler/kernel/Num.java
branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/compiler/kernel/Par.java
branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/compiler/kernel/Seq.java
branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/compiler/kernel/Set.java
branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/compiler/kernel/Str.java
branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/compiler/kernel/Var.java
branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/compiler/types/ChannelType.java
branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/compiler/types/SimpleType.java
branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/compiler/types/TypeReductor.java
branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/compiler/types/Types.java
branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/compiler/types/UnknownType.java
branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/lib/sys/Echo.java
branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/lib/sys/Equals.java
branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/lib/sys/GreaterThan.java
branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/lib/sys/KException.java
branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/lib/sys/LessThan.java
branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/lib/sys/Minus.java
branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/lib/sys/Plus.java
branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/lib/sys/Print.java
branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/lib/sys/Range.java
branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/lib/sys/Throw.java
branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/lib/sys/Times.java
branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/lib/sys/Wait.java
branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/parser/Node.java
branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/runtime/Arguments.java
branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/runtime/Callable.java
branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/runtime/Channel.java
branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/runtime/Channels.java
branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/runtime/Context.java
branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/runtime/Exceptions.java
branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/runtime/ExecutionException.java
branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/runtime/MemoryChannel.java
branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/runtime/OrderedParallelChannel.java
branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/runtime/Signature.java
branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/runtime/StdSink.java
branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/threading/LWThread.java
branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/threading/LWThreadDeath.java
branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/threading/Scheduler.java
branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/threading/SchedulerThread.java
branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/threading/State.java
branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/threading/StateTables.java
branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/threading/Yield.java
branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/translator/predicates/EndElement.java
branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/translator/predicates/Identifier.java
branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/translator/predicates/StringValue.java
branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/translator/predicates/Transliterator.java
branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/translator/predicates/Variable.java
Added Paths:
-----------
branches/karajan2/src/cog/modules/karajan2/examples/parallel-exception.k
branches/karajan2/src/cog/modules/karajan2/resources/string.class
branches/karajan2/src/cog/modules/karajan2/resources/string.java
branches/karajan2/src/cog/modules/karajan2/resources/string.k
branches/karajan2/src/cog/modules/karajan2/resources/sys.class
branches/karajan2/src/cog/modules/karajan2/resources/sys.java
branches/karajan2/src/cog/modules/karajan2/resources/sys.k
branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/compiler/InlineValue.java
branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/compiler/Self.java
branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/compiler/Vars.java
branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/compiler/kernel/Access.java
branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/compiler/kernel/Catch.java
branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/compiler/kernel/FromChannel.java
branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/compiler/kernel/Future.java
branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/compiler/kernel/InvokeField.java
branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/compiler/kernel/KType.java
branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/compiler/kernel/Main.java
branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/compiler/kernel/Namespace.java
branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/compiler/kernel/Or.java
branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/compiler/kernel/ParallelFor.java
branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/compiler/kernel/StringToken.java
branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/compiler/kernel/ToChannel.java
branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/compiler/kernel/Try.java
branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/compiler/types/AltType.java
branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/compiler/types/NativeType.java
branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/compiler/types/UserType.java
branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/lib/string/
branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/lib/string/Str.java
branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/lib/sys/Div.java
branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/lib/sys/GreaterOrEqual.java
branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/lib/sys/LessOrEqual.java
branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/runtime/Abort.java
branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/runtime/ConditionalYield.java
branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/runtime/Future.java
branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/runtime/FutureListener.java
branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/runtime/FutureValue.java
branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/runtime/FutureValueChannel.java
branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/runtime/Futures.java
branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/runtime/LookAheadIterator.java
branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/runtime/NativeCallable.java
branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/threading/LWRunnable.java
branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/threading/LWSignal.java
branches/karajan2/src/cog/modules/karajan2/tests/
branches/karajan2/src/cog/modules/karajan2/tests/channels1.k
branches/karajan2/src/cog/modules/karajan2/tests/channels1.k.expected
branches/karajan2/src/cog/modules/karajan2/tests/clean
branches/karajan2/src/cog/modules/karajan2/tests/currying.k
branches/karajan2/src/cog/modules/karajan2/tests/currying.k.expected
branches/karajan2/src/cog/modules/karajan2/tests/future.k
branches/karajan2/src/cog/modules/karajan2/tests/future.k.expected
branches/karajan2/src/cog/modules/karajan2/tests/overloading.k
branches/karajan2/src/cog/modules/karajan2/tests/overloading.k.expected
branches/karajan2/src/cog/modules/karajan2/tests/parallel-exception.k
branches/karajan2/src/cog/modules/karajan2/tests/parallel-exception.k.expected
branches/karajan2/src/cog/modules/karajan2/tests/parallelFor.k
branches/karajan2/src/cog/modules/karajan2/tests/parallelFor.k.expected
branches/karajan2/src/cog/modules/karajan2/tests/recursion.k
branches/karajan2/src/cog/modules/karajan2/tests/recursion.k.expected
branches/karajan2/src/cog/modules/karajan2/tests/run
branches/karajan2/src/cog/modules/karajan2/tests/scoping.k
branches/karajan2/src/cog/modules/karajan2/tests/scoping.k.expected
branches/karajan2/src/cog/modules/karajan2/tests/string-functions.k
branches/karajan2/src/cog/modules/karajan2/tests/string-functions.k.expected
branches/karajan2/src/cog/modules/karajan2/tests/types.k
branches/karajan2/src/cog/modules/karajan2/tests/types.k.expected
Removed Paths:
-------------
branches/karajan2/src/cog/modules/karajan2/examples/sys.k
branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/compiler/kernel/Karajan.java
branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/runtime/KFile.java
branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/runtime/KIterator.java
branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/runtime/KLine.java
branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/runtime/Types.java
branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/threading/KRunnable.java
Modified: branches/karajan2/src/cog/modules/karajan2/examples/order.k
===================================================================
--- branches/karajan2/src/cog/modules/karajan2/examples/order.k 2008-06-26 09:33:15 UTC (rev 2060)
+++ branches/karajan2/src/cog/modules/karajan2/examples/order.k 2008-06-27 00:16:28 UTC (rev 2061)
@@ -11,4 +11,4 @@
echo("a2")
print("b2")
)
-)
\ No newline at end of file
+)
Added: branches/karajan2/src/cog/modules/karajan2/examples/parallel-exception.k
===================================================================
--- branches/karajan2/src/cog/modules/karajan2/examples/parallel-exception.k (rev 0)
+++ branches/karajan2/src/cog/modules/karajan2/examples/parallel-exception.k 2008-06-27 00:16:28 UTC (rev 2061)
@@ -0,0 +1,6 @@
+import(sys)
+
+par(
+ (wait(delay=100), throw(Exception("testing2")))
+ (wait(delay=200), echo("grr"))
+)
\ No newline at end of file
Modified: branches/karajan2/src/cog/modules/karajan2/examples/scoping.k
===================================================================
--- branches/karajan2/src/cog/modules/karajan2/examples/scoping.k 2008-06-26 09:33:15 UTC (rev 2060)
+++ branches/karajan2/src/cog/modules/karajan2/examples/scoping.k 2008-06-27 00:16:28 UTC (rev 2061)
@@ -15,4 +15,4 @@
echo(x)
-echo(f())
\ No newline at end of file
+echo(f())
Deleted: branches/karajan2/src/cog/modules/karajan2/examples/sys.k
===================================================================
--- branches/karajan2/src/cog/modules/karajan2/examples/sys.k 2008-06-26 09:33:15 UTC (rev 2060)
+++ branches/karajan2/src/cog/modules/karajan2/examples/sys.k 2008-06-27 00:16:28 UTC (rev 2061)
@@ -1,16 +0,0 @@
-echo := native(org.globus.cog.karajan.lib.sys.Echo)
-print := native(org.globus.cog.karajan.lib.sys.Print)
-range := native(org.globus.cog.karajan.lib.sys.Range)
-wait := native(org.globus.cog.karajan.lib.sys.Wait)
-__eq___eq_ := native(org.globus.cog.karajan.lib.sys.Equals)
-__gt_ := native(org.globus.cog.karajan.lib.sys.GreaterThan)
-__lt_ := native(org.globus.cog.karajan.lib.sys.LessThan)
-__plus_ := native(org.globus.cog.karajan.lib.sys.Plus)
-__minus_ := native(org.globus.cog.karajan.lib.sys.Minus)
-__times_ := native(org.globus.cog.karajan.lib.sys.Times)
-
-throw := native(org.globus.cog.karajan.lib.sys.Throw)
-Exception := native(org.globus.cog.karajan.lib.sys.KException)
-
-export(echo, print, range, wait, __eq___eq_, __plus_, __minus_,
- throw, Exception, __gt_, __lt_, __times_)
Modified: branches/karajan2/src/cog/modules/karajan2/launchers.xml
===================================================================
--- branches/karajan2/src/cog/modules/karajan2/launchers.xml 2008-06-26 09:33:15 UTC (rev 2060)
+++ branches/karajan2/src/cog/modules/karajan2/launchers.xml 2008-06-27 00:16:28 UTC (rev 2061)
@@ -1,11 +1,14 @@
<project name="Launchers" default="create" basedir=".">
- <target name="create">
- <ant antfile="${main.buildfile}" target="launcher">
- <property name="launcher-name" value="k"/>
- <property name="class-name"
- value="org.globus.cog.karajan.Loader"/>
- </ant>
- </target>
- <target name="webstart">
- </target>
+ <target name="create">
+ <ant antfile="${main.buildfile}" target="launcher">
+ <property name="launcher-name" value="k"/>
+ <property name="class-name" value="org.globus.cog.karajan.Loader"/>
+ </ant>
+ <ant antfile="${main.buildfile}" target="launcher">
+ <property name="launcher-name" value="kc"/>
+ <property name="class-name" value="org.globus.cog.karajan.compiler.Compiler"/>
+ </ant>
+ </target>
+ <target name="webstart">
+ </target>
</project>
Modified: branches/karajan2/src/cog/modules/karajan2/resources/karajan-language.gr
===================================================================
--- branches/karajan2/src/cog/modules/karajan2/resources/karajan-language.gr 2008-06-26 09:33:15 UTC (rev 2060)
+++ branches/karajan2/src/cog/modules/karajan2/resources/karajan-language.gr 2008-06-27 00:16:28 UTC (rev 2061)
@@ -1,4 +1,4 @@
-program := HVSPACES() IDENTIFIER("karajan") BEGINELEMENT() body ENDELEMENT() ;
+program := HVSPACES() IDENTIFIER("main") BEGINELEMENT() body ENDELEMENT() ;
body :=
items EOF() |
@@ -20,14 +20,19 @@
comment moreItems |
expression moreItems |
LITERAL(":=") IDENTIFIER("k.set") op |
+ LITERAL(":") HSPACES() IDENTIFIER() HSPACES() typedecl? |
LITERAL("=") IDENTIFIER("k.map") op |
LITERAL("->") sigdef |
LITERAL("...") IDENTIFIER("...") VARIABLE() moreItems |
LITERAL(".") IDENTIFIER() HSPACES() invocation SWAP() ADDCHILD() itemOrCommentOrNone |
E() ;
-
+
op := BEGINELEMENT() SWAP() HVSPACES() expression maybeElse ENDELEMENT() moreItems ;
+typedecl? :=
+ LITERAL("=") IDENTIFIER("k.set") BEGINELEMENT() ROT() HVSPACES() expression ENDELEMENT() moreItems |
+ IDENTIFIER("k.typedecl") BEGINELEMENT() ROT() ENDELEMENT() moreItems ;
+
/* Rather crappy this one */
sigdef :=
REMOVECHILD() IDENTIFIER("k.sig") BEGINELEMENT() ENDELEMENT() SWAP() ADDCHILD()
@@ -64,7 +69,7 @@
seq := LITERAL("(") IDENTIFIER("k.seq") BEGINELEMENT() moreItems LITERAL(")") ENDELEMENT() ;
-value := number | string STRING() ;
+value := number | STRING() ;
action :=
invocation |
@@ -81,8 +86,6 @@
E() ;
block := IDENTIFIER("k.block") BEGINELEMENT() items LITERAL("}") ENDELEMENT() ;
-
-string := LITERAL(""") stringExpression LITERAL(""") ;
number :=
DIGITS() fractional |
@@ -92,14 +95,6 @@
fractional :=
LITERAL(".") DIGITS() FLOAT() NUMBER() |
E() NUMBER() ;
-
-stringExpression :=
- NOTLITERAL(""") ANYTOKEN() moreStringExpression |
- E() EMPTYSTRING() ;
-
-moreStringExpression :=
- NOTLITERAL(""") ANYTOKEN() CONCAT() moreStringExpression |
- E() ;
expression :=
comment expression |
@@ -121,7 +116,8 @@
ge0 := e0 | E() ;
o0 :=
- LITERAL("^") IDENTIFIER("^") ;
+ LITERAL("^") IDENTIFIER("^") |
+ LITERAL("::") IDENTIFIER("::") ;
e1 :=
comment |
Added: branches/karajan2/src/cog/modules/karajan2/resources/string.class
===================================================================
(Binary files differ)
Property changes on: branches/karajan2/src/cog/modules/karajan2/resources/string.class
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: branches/karajan2/src/cog/modules/karajan2/resources/string.java
===================================================================
--- branches/karajan2/src/cog/modules/karajan2/resources/string.java (rev 0)
+++ branches/karajan2/src/cog/modules/karajan2/resources/string.java 2008-06-27 00:16:28 UTC (rev 2061)
@@ -0,0 +1,218 @@
+import org.globus.cog.karajan.threading.LWThread;
+import org.globus.cog.karajan.threading.Yield;
+import org.globus.cog.karajan.runtime.Context;
+import org.globus.cog.karajan.runtime.Channel;
+import org.globus.cog.karajan.runtime.Exceptions;
+import org.globus.cog.karajan.runtime.Callable;
+import org.globus.cog.karajan.runtime.StdSink.StdoutSink;
+import org.globus.cog.karajan.runtime.StdSink.StderrSink;
+import org.globus.cog.karajan.runtime.NVPair;
+import org.globus.cog.karajan.runtime.Arguments;
+import java.util.Collection;
+import org.globus.cog.karajan.threading.StateTables;
+import org.globus.cog.karajan.threading.LWThreadDeath;
+import org.globus.cog.karajan.runtime.OrderedParallelChannel;
+import java.util.Iterator;
+import org.globus.cog.karajan.runtime.LookAheadIterator;
+import org.globus.cog.karajan.runtime.ExecutionException;
+import org.globus.cog.karajan.runtime.Abort;
+import org.globus.cog.karajan.compiler.VariableNotFoundException;
+import org.globus.cog.karajan.runtime.FutureValueChannel;
+import org.globus.cog.karajan.runtime.Futures;
+import org.globus.cog.karajan.compiler.Compiler;
+
+
+public final class string implements Runnable {
+ public static final String __ORIGNAME = "string.k";
+ public static void main(String[] args) {
+ LWThread thread = new LWThread(new string());
+ thread.start();
+ try {
+ thread.waitFor();
+ }
+ catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ }
+
+
+ public void run() {
+ final LWThread thread = LWThread.currentThread();
+ thread.checkSlice();
+ int __state__ = thread.popState();
+ switch(__state__) {
+ case 0: //main (string:1)
+ thread.ctx = new Context(33, thread.ctx);
+ case 1: //main (string:1)
+ thread.ctx.pushChannel(1, new StdoutSink());
+ thread.ctx.pushChannel(2, new StderrSink());
+ //[toUpperCase, matches, startsWith, toLowerCase, substring, lastIndexOf, indexOf, trim, endsWith, concat]
+ thread.ctx = new Context(10, thread.ctx);
+ case 2: //main (string:1)
+ k_dot_set_1_0000();
+ case 3: //main (string:1)
+ k_dot_set_3_0001();
+ case 4: //main (string:1)
+ k_dot_set_4_0002();
+ case 5: //main (string:1)
+ k_dot_set_5_0003();
+ case 6: //main (string:1)
+ k_dot_set_6_0004();
+ case 7: //main (string:1)
+ k_dot_set_7_0005();
+ case 8: //main (string:1)
+ k_dot_set_8_0006();
+ case 9: //main (string:1)
+ k_dot_set_10_0007();
+ case 10: //main (string:1)
+ k_dot_set_11_0008();
+ case 11: //main (string:1)
+ k_dot_set_12_0009();
+ case 12: //main (string:1)
+ // namespace (string:14)
+ k_dot_block_15_0010();
+ thread.popCtx();
+ thread.popCtx();
+ }
+ }
+
+ private void checkMismatch(int expected, int actual) throws ExecutionException {
+ if(expected != actual) {
+ throw new ExecutionException("Got " + expected + " identifier(s) and " + actual + " values");
+ }
+ }
+ // k.set (string:1)
+ private void k_dot_set_1_0000() {
+ LWThread thread = LWThread.currentThread();
+ thread.ctx.pushChannel(0);
+ // native (string:1)
+ thread.ctx.append(0, new org.globus.cog.karajan.lib.string.Str.Substring());
+ Channel def = thread.ctx.popChannel(0);
+ thread.ctx.set(0, def.get(0));
+ }
+
+ // k.set (string:3)
+ private void k_dot_set_3_0001() {
+ LWThread thread = LWThread.currentThread();
+ thread.ctx.pushChannel(0);
+ // native (string:3)
+ thread.ctx.append(0, new org.globus.cog.karajan.lib.string.Str.Concat());
+ Channel def = thread.ctx.popChannel(0);
+ thread.ctx.set(1, def.get(0));
+ }
+
+ // k.set (string:4)
+ private void k_dot_set_4_0002() {
+ LWThread thread = LWThread.currentThread();
+ thread.ctx.pushChannel(0);
+ // native (string:4)
+ thread.ctx.append(0, new org.globus.cog.karajan.lib.string.Str.StartsWith());
+ Channel def = thread.ctx.popChannel(0);
+ thread.ctx.set(2, def.get(0));
+ }
+
+ // k.set (string:5)
+ private void k_dot_set_5_0003() {
+ LWThread thread = LWThread.currentThread();
+ thread.ctx.pushChannel(0);
+ // native (string:5)
+ thread.ctx.append(0, new org.globus.cog.karajan.lib.string.Str.EndsWith());
+ Channel def = thread.ctx.popChannel(0);
+ thread.ctx.set(3, def.get(0));
+ }
+
+ // k.set (string:6)
+ private void k_dot_set_6_0004() {
+ LWThread thread = LWThread.currentThread();
+ thread.ctx.pushChannel(0);
+ // native (string:6)
+ thread.ctx.append(0, new org.globus.cog.karajan.lib.string.Str.IndexOf());
+ Channel def = thread.ctx.popChannel(0);
+ thread.ctx.set(4, def.get(0));
+ }
+
+ // k.set (string:7)
+ private void k_dot_set_7_0005() {
+ LWThread thread = LWThread.currentThread();
+ thread.ctx.pushChannel(0);
+ // native (string:7)
+ thread.ctx.append(0, new org.globus.cog.karajan.lib.string.Str.LastIndexOf());
+ Channel def = thread.ctx.popChannel(0);
+ thread.ctx.set(5, def.get(0));
+ }
+
+ // k.set (string:8)
+ private void k_dot_set_8_0006() {
+ LWThread thread = LWThread.currentThread();
+ thread.ctx.pushChannel(0);
+ // native (string:8)
+ thread.ctx.append(0, new org.globus.cog.karajan.lib.string.Str.Matches());
+ Channel def = thread.ctx.popChannel(0);
+ thread.ctx.set(6, def.get(0));
+ }
+
+ // k.set (string:10)
+ private void k_dot_set_10_0007() {
+ LWThread thread = LWThread.currentThread();
+ thread.ctx.pushChannel(0);
+ // native (string:10)
+ thread.ctx.append(0, new org.globus.cog.karajan.lib.string.Str.ToUpperCase());
+ Channel def = thread.ctx.popChannel(0);
+ thread.ctx.set(7, def.get(0));
+ }
+
+ // k.set (string:11)
+ private void k_dot_set_11_0008() {
+ LWThread thread = LWThread.currentThread();
+ thread.ctx.pushChannel(0);
+ // native (string:11)
+ thread.ctx.append(0, new org.globus.cog.karajan.lib.string.Str.ToLowerCase());
+ Channel def = thread.ctx.popChannel(0);
+ thread.ctx.set(8, def.get(0));
+ }
+
+ // k.set (string:12)
+ private void k_dot_set_12_0009() {
+ LWThread thread = LWThread.currentThread();
+ thread.ctx.pushChannel(0);
+ // native (string:12)
+ thread.ctx.append(0, new org.globus.cog.karajan.lib.string.Str.Trim());
+ Channel def = thread.ctx.popChannel(0);
+ thread.ctx.set(9, def.get(0));
+ }
+
+ // k.block (string:15)
+ private void k_dot_block_15_0010() {
+ final LWThread thread = LWThread.currentThread();
+ thread.checkSlice();
+ int __state__ = thread.popState();
+ switch(__state__) {
+ case 0: //k.block (string:15)
+ // export (string:16)
+ thread.ctx.getChannel(0).append(thread.ctx.get(0));
+ thread.ctx.getChannel(0).append(thread.ctx.get(1));
+ thread.ctx.getChannel(0).append(thread.ctx.get(2));
+ thread.ctx.getChannel(0).append(thread.ctx.get(3));
+ thread.ctx.getChannel(0).append(thread.ctx.get(4));
+ thread.ctx.getChannel(0).append(thread.ctx.get(5));
+ thread.ctx.getChannel(0).append(thread.ctx.get(6));
+ thread.ctx.getChannel(0).append(thread.ctx.get(7));
+ thread.ctx.getChannel(0).append(thread.ctx.get(8));
+ thread.ctx.getChannel(0).append(thread.ctx.get(9));
+ }
+ }
+
+ public static final int[] __LINE_TABLE = new int[] {
+ 44, 46, 51, 53, 55, 57, 59, 61, 63, 65, 67, 69, 71, 76, //run
+ 190//k_dot_block_15_0010
+ };
+ public static final int[] __STATE_TABLE = new int[] {
+ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, -1, //run
+ 0//k_dot_block_15_0010
+ };
+ static {
+ StateTables.register(string.class);
+ }
+ public static void __exports__() {
+ }
+}
Added: branches/karajan2/src/cog/modules/karajan2/resources/string.k
===================================================================
--- branches/karajan2/src/cog/modules/karajan2/resources/string.k (rev 0)
+++ branches/karajan2/src/cog/modules/karajan2/resources/string.k 2008-06-27 00:16:28 UTC (rev 2061)
@@ -0,0 +1,19 @@
+substring := native(org.globus.cog.karajan.lib.string.Str$Substring)
+//characters := native(org.globus.cog.karajan.lib.string.Str$Characters)
+concat := native(org.globus.cog.karajan.lib.string.Str$Concat)
+startsWith := native(org.globus.cog.karajan.lib.string.Str$StartsWith)
+endsWith := native(org.globus.cog.karajan.lib.string.Str$EndsWith)
+indexOf := native(org.globus.cog.karajan.lib.string.Str$IndexOf)
+lastIndexOf := native(org.globus.cog.karajan.lib.string.Str$LastIndexOf)
+matches := native(org.globus.cog.karajan.lib.string.Str$Matches)
+//split := native(org.globus.cog.karajan.lib.string.Str$Split)
+toUpperCase := native(org.globus.cog.karajan.lib.string.Str$ToUpperCase)
+toLowerCase := native(org.globus.cog.karajan.lib.string.Str$ToLowerCase)
+trim := native(org.globus.cog.karajan.lib.string.Str$Trim)
+
+namespace(string) {
+ export(
+ substring, concat, startsWith, endsWith, indexOf
+ lastIndexOf, matches, toUpperCase, toLowerCase, trim
+ )
+}
\ No newline at end of file
Added: branches/karajan2/src/cog/modules/karajan2/resources/sys.class
===================================================================
(Binary files differ)
Property changes on: branches/karajan2/src/cog/modules/karajan2/resources/sys.class
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Added: branches/karajan2/src/cog/modules/karajan2/resources/sys.java
===================================================================
--- branches/karajan2/src/cog/modules/karajan2/resources/sys.java (rev 0)
+++ branches/karajan2/src/cog/modules/karajan2/resources/sys.java 2008-06-27 00:16:28 UTC (rev 2061)
@@ -0,0 +1,330 @@
+import org.globus.cog.karajan.threading.LWThread;
+import org.globus.cog.karajan.threading.Yield;
+import org.globus.cog.karajan.runtime.Context;
+import org.globus.cog.karajan.runtime.Channel;
+import org.globus.cog.karajan.runtime.Exceptions;
+import org.globus.cog.karajan.runtime.Callable;
+import org.globus.cog.karajan.runtime.StdSink.StdoutSink;
+import org.globus.cog.karajan.runtime.StdSink.StderrSink;
+import org.globus.cog.karajan.runtime.NVPair;
+import org.globus.cog.karajan.runtime.Arguments;
+import java.util.Collection;
+import org.globus.cog.karajan.threading.StateTables;
+import org.globus.cog.karajan.threading.LWThreadDeath;
+import org.globus.cog.karajan.runtime.OrderedParallelChannel;
+import java.util.Iterator;
+import org.globus.cog.karajan.runtime.LookAheadIterator;
+import org.globus.cog.karajan.runtime.ExecutionException;
+import org.globus.cog.karajan.runtime.Abort;
+import org.globus.cog.karajan.compiler.VariableNotFoundException;
+import org.globus.cog.karajan.runtime.FutureValueChannel;
+import org.globus.cog.karajan.runtime.Futures;
+import org.globus.cog.karajan.compiler.Compiler;
+
+
+public final class sys implements Runnable {
+ public static final String __ORIGNAME = "sys.k";
+ public static void main(String[] args) {
+ LWThread thread = new LWThread(new sys());
+ thread.start();
+ try {
+ thread.waitFor();
+ }
+ catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ }
+
+
+ public void run() {
+ final LWThread thread = LWThread.currentThread();
+ thread.checkSlice();
+ int __state__ = thread.popState();
+ switch(__state__) {
+ case 0: //main (sys:1)
+ thread.ctx = new Context(33, thread.ctx);
+ case 1: //main (sys:1)
+ thread.ctx.pushChannel(1, new StdoutSink());
+ thread.ctx.pushChannel(2, new StderrSink());
+ //[Exception, range, __times_, __fwslash_, __gt___eq_, wait, __lt___eq_, echo, print, throw, __eq___eq_, __plus_, __gt_, __lt_, __minus_]
+ thread.ctx = new Context(15, thread.ctx);
+ case 2: //main (sys:1)
+ k_dot_set_1_0000();
+ case 3: //main (sys:1)
+ k_dot_set_2_0001();
+ case 4: //main (sys:1)
+ k_dot_set_3_0002();
+ case 5: //main (sys:1)
+ k_dot_set_4_0003();
+ case 6: //main (sys:1)
+ k_dot_set_5_0004();
+ case 7: //main (sys:1)
+ k_dot_set_6_0005();
+ case 8: //main (sys:1)
+ k_dot_set_9_0006();
+ case 9: //main (sys:1)
+ k_dot_set_13_0007();
+ case 10: //main (sys:1)
+ k_dot_set_16_0008();
+ case 11: //main (sys:1)
+ k_dot_set_20_0009();
+ case 12: //main (sys:1)
+ k_dot_set_25_0010();
+ case 13: //main (sys:1)
+ k_dot_set_29_0011();
+ case 14: //main (sys:1)
+ k_dot_set_33_0012();
+ case 15: //main (sys:1)
+ k_dot_set_37_0013();
+ case 16: //main (sys:1)
+ k_dot_set_38_0014();
+ case 17: //main (sys:1)
+ // namespace (sys:41)
+ k_dot_block_42_0015();
+ thread.popCtx();
+ thread.popCtx();
+ }
+ }
+
+ private void checkMismatch(int expected, int actual) throws ExecutionException {
+ if(expected != actual) {
+ throw new ExecutionException("Got " + expected + " identifier(s) and " + actual + " values");
+ }
+ }
+ // k.set (sys:1)
+ private void k_dot_set_1_0000() {
+ LWThread thread = LWThread.currentThread();
+ thread.ctx.pushChannel(0);
+ // native (sys:1)
+ thread.ctx.append(0, new org.globus.cog.karajan.lib.sys.Echo());
+ Channel def = thread.ctx.popChannel(0);
+ thread.ctx.set(0, def.get(0));
+ }
+
+ // k.set (sys:2)
+ private void k_dot_set_2_0001() {
+ LWThread thread = LWThread.currentThread();
+ thread.ctx.pushChannel(0);
+ // native (sys:2)
+ thread.ctx.append(0, new org.globus.cog.karajan.lib.sys.Print());
+ Channel def = thread.ctx.popChannel(0);
+ thread.ctx.set(1, def.get(0));
+ }
+
+ // k.set (sys:3)
+ private void k_dot_set_3_0002() {
+ LWThread thread = LWThread.currentThread();
+ thread.ctx.pushChannel(0);
+ // native (sys:3)
+ thread.ctx.append(0, new org.globus.cog.karajan.lib.sys.Range());
+ Channel def = thread.ctx.popChannel(0);
+ thread.ctx.set(2, def.get(0));
+ }
+
+ // k.set (sys:4)
+ private void k_dot_set_4_0003() {
+ LWThread thread = LWThread.currentThread();
+ thread.ctx.pushChannel(0);
+ // native (sys:4)
+ thread.ctx.append(0, new org.globus.cog.karajan.lib.sys.Wait());
+ Channel def = thread.ctx.popChannel(0);
+ thread.ctx.set(3, def.get(0));
+ }
+
+ // k.set (sys:5)
+ private void k_dot_set_5_0004() {
+ LWThread thread = LWThread.currentThread();
+ thread.ctx.pushChannel(0);
+ // native (sys:5)
+ thread.ctx.append(0, new org.globus.cog.karajan.lib.sys.Equals());
+ Channel def = thread.ctx.popChannel(0);
+ thread.ctx.set(4, def.get(0));
+ }
+
+ // k.set (sys:6)
+ private void k_dot_set_6_0005() {
+ LWThread thread = LWThread.currentThread();
+ thread.ctx.pushChannel(0);
+ // | (sys:8)
+ thread.ctx.pushChannel(0);
+ // native (sys:7)
+ thread.ctx.append(0, new org.globus.cog.karajan.lib.sys.GreaterThan.Real());
+ // native (sys:8)
+ thread.ctx.append(0, new org.globus.cog.karajan.lib.sys.GreaterThan.Integer());
+ thread.ctx.append(0, thread.ctx.popChannel(0));
+ Channel def = thread.ctx.popChannel(0);
+ thread.ctx.set(5, def.get(0));
+ }
+
+ // k.set (sys:9)
+ private void k_dot_set_9_0006() {
+ LWThread thread = LWThread.currentThread();
+ thread.ctx.pushChannel(0);
+ // | (sys:11)
+ thread.ctx.pushChannel(0);
+ // native (sys:10)
+ thread.ctx.append(0, new org.globus.cog.karajan.lib.sys.LessThan.Real());
+ // native (sys:11)
+ thread.ctx.append(0, new org.globus.cog.karajan.lib.sys.LessThan.Integer());
+ thread.ctx.append(0, thread.ctx.popChannel(0));
+ Channel def = thread.ctx.popChannel(0);
+ thread.ctx.set(6, def.get(0));
+ }
+
+ // k.set (sys:13)
+ private void k_dot_set_13_0007() {
+ LWThread thread = LWThread.currentThread();
+ thread.ctx.pushChannel(0);
+ // | (sys:15)
+ thread.ctx.pushChannel(0);
+ // native (sys:14)
+ thread.ctx.append(0, new org.globus.cog.karajan.lib.sys.GreaterOrEqual.Real());
+ // native (sys:15)
+ thread.ctx.append(0, new org.globus.cog.karajan.lib.sys.GreaterOrEqual.Integer());
+ thread.ctx.append(0, thread.ctx.popChannel(0));
+ Channel def = thread.ctx.popChannel(0);
+ thread.ctx.set(7, def.get(0));
+ }
+
+ // k.set (sys:16)
+ private void k_dot_set_16_0008() {
+ LWThread thread = LWThread.currentThread();
+ thread.ctx.pushChannel(0);
+ // | (sys:18)
+ thread.ctx.pushChannel(0);
+ // native (sys:17)
+ thread.ctx.append(0, new org.globus.cog.karajan.lib.sys.LessOrEqual.Real());
+ // native (sys:18)
+ thread.ctx.append(0, new org.globus.cog.karajan.lib.sys.LessOrEqual.Integer());
+ thread.ctx.append(0, thread.ctx.popChannel(0));
+ Channel def = thread.ctx.popChannel(0);
+ thread.ctx.set(8, def.get(0));
+ }
+
+ // k.set (sys:20)
+ private void k_dot_set_20_0009() {
+ LWThread thread = LWThread.currentThread();
+ thread.ctx.pushChannel(0);
+ // | (sys:22)
+ thread.ctx.pushChannel(0);
+ // native (sys:21)
+ thread.ctx.append(0, new org.globus.cog.karajan.lib.sys.Plus.Real());
+ thread.ctx.pushChannel(0);
+ // | (sys:23)
+ thread.ctx.pushChannel(0);
+ // native (sys:22)
+ thread.ctx.append(0, new org.globus.cog.karajan.lib.sys.Plus.Integer());
+ // native (sys:23)
+ thread.ctx.append(0, new org.globus.cog.karajan.lib.sys.Plus.String());
+ thread.ctx.append(0, thread.ctx.popChannel(0));
+ thread.ctx.appendAll(0, (Channel) ((Channel) thread.ctx.popChannel(0)).get(0));
+ thread.ctx.append(0, thread.ctx.popChannel(0));
+ Channel def = thread.ctx.popChannel(0);
+ thread.ctx.set(9, def.get(0));
+ }
+
+ // k.set (sys:25)
+ private void k_dot_set_25_0010() {
+ LWThread thread = LWThread.currentThread();
+ thread.ctx.pushChannel(0);
+ // | (sys:27)
+ thread.ctx.pushChannel(0);
+ // native (sys:26)
+ thread.ctx.append(0, new org.globus.cog.karajan.lib.sys.Minus.Real());
+ // native (sys:27)
+ thread.ctx.append(0, new org.globus.cog.karajan.lib.sys.Minus.Integer());
+ thread.ctx.append(0, thread.ctx.popChannel(0));
+ Channel def = thread.ctx.popChannel(0);
+ thread.ctx.set(10, def.get(0));
+ }
+
+ // k.set (sys:29)
+ private void k_dot_set_29_0011() {
+ LWThread thread = LWThread.currentThread();
+ thread.ctx.pushChannel(0);
+ // | (sys:31)
+ thread.ctx.pushChannel(0);
+ // native (sys:30)
+ thread.ctx.append(0, new org.globus.cog.karajan.lib.sys.Times.Integer());
+ // native (sys:31)
+ thread.ctx.append(0, new org.globus.cog.karajan.lib.sys.Times.Real());
+ thread.ctx.append(0, thread.ctx.popChannel(0));
+ Channel def = thread.ctx.popChannel(0);
+ thread.ctx.set(11, def.get(0));
+ }
+
+ // k.set (sys:33)
+ private void k_dot_set_33_0012() {
+ LWThread thread = LWThread.currentThread();
+ thread.ctx.pushChannel(0);
+ // | (sys:35)
+ thread.ctx.pushChannel(0);
+ // native (sys:34)
+ thread.ctx.append(0, new org.globus.cog.karajan.lib.sys.Div.Integer());
+ // native (sys:35)
+ thread.ctx.append(0, new org.globus.cog.karajan.lib.sys.Div.Real());
+ thread.ctx.append(0, thread.ctx.popChannel(0));
+ Channel def = thread.ctx.popChannel(0);
+ thread.ctx.set(12, def.get(0));
+ }
+
+ // k.set (sys:37)
+ private void k_dot_set_37_0013() {
+ LWThread thread = LWThread.currentThread();
+ thread.ctx.pushChannel(0);
+ // native (sys:37)
+ thread.ctx.append(0, new org.globus.cog.karajan.lib.sys.Throw());
+ Channel def = thread.ctx.popChannel(0);
+ thread.ctx.set(13, def.get(0));
+ }
+
+ // k.set (sys:38)
+ private void k_dot_set_38_0014() {
+ LWThread thread = LWThread.currentThread();
+ thread.ctx.pushChannel(0);
+ // native (sys:38)
+ thread.ctx.append(0, new org.globus.cog.karajan.lib.sys.KException());
+ Channel def = thread.ctx.popChannel(0);
+ thread.ctx.set(14, def.get(0));
+ }
+
+ // k.block (sys:42)
+ private void k_dot_block_42_0015() {
+ final LWThread thread = LWThread.currentThread();
+ thread.checkSlice();
+ int __state__ = thread.popState();
+ switch(__state__) {
+ case 0: //k.block (sys:42)
+ // export (sys:43)
+ thread.ctx.getChannel(0).append(thread.ctx.get(0));
+ thread.ctx.getChannel(0).append(thread.ctx.get(1));
+ thread.ctx.getChannel(0).append(thread.ctx.get(2));
+ thread.ctx.getChannel(0).append(thread.ctx.get(3));
+ thread.ctx.getChannel(0).append(thread.ctx.get(4));
+ thread.ctx.getChannel(0).append(thread.ctx.get(6));
+ thread.ctx.getChannel(0).append(thread.ctx.get(5));
+ thread.ctx.getChannel(0).append(thread.ctx.get(8));
+ thread.ctx.getChannel(0).append(thread.ctx.get(7));
+ thread.ctx.getChannel(0).append(thread.ctx.get(9));
+ thread.ctx.getChannel(0).append(thread.ctx.get(10));
+ thread.ctx.getChannel(0).append(thread.ctx.get(11));
+ thread.ctx.getChannel(0).append(thread.ctx.get(12));
+ thread.ctx.getChannel(0).append(thread.ctx.get(13));
+ thread.ctx.getChannel(0).append(thread.ctx.get(14));
+ }
+ }
+
+ public static final int[] __LINE_TABLE = new int[] {
+ 44, 46, 51, 53, 55, 57, 59, 61, 63, 65, 67, 69, 71, 73, 75, 77, 79, 81, 86, //run
+ 297//k_dot_block_42_0015
+ };
+ public static final int[] __STATE_TABLE = new int[] {
+ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, -1, //run
+ 0//k_dot_block_42_0015
+ };
+ static {
+ StateTables.register(sys.class);
+ }
+ public static void __exports__() {
+ }
+}
Added: branches/karajan2/src/cog/modules/karajan2/resources/sys.k
===================================================================
--- branches/karajan2/src/cog/modules/karajan2/resources/sys.k (rev 0)
+++ branches/karajan2/src/cog/modules/karajan2/resources/sys.k 2008-06-27 00:16:28 UTC (rev 2061)
@@ -0,0 +1,48 @@
+echo := native(org.globus.cog.karajan.lib.sys.Echo)
+print := native(org.globus.cog.karajan.lib.sys.Print)
+range := native(org.globus.cog.karajan.lib.sys.Range)
+wait := native(org.globus.cog.karajan.lib.sys.Wait)
+__eq___eq_ := native(org.globus.cog.karajan.lib.sys.Equals)
+__gt_ :=
+ native(org.globus.cog.karajan.lib.sys.GreaterThan$Real)
+ | native(org.globus.cog.karajan.lib.sys.GreaterThan$Integer)
+__lt_ :=
+ native(org.globus.cog.karajan.lib.sys.LessThan$Real)
+ | native(org.globus.cog.karajan.lib.sys.LessThan$Integer)
+
+__gt___eq_ :=
+ native(org.globus.cog.karajan.lib.sys.GreaterOrEqual$Real)
+ | native(org.globus.cog.karajan.lib.sys.GreaterOrEqual$Integer)
+__lt___eq_ :=
+ native(org.globus.cog.karajan.lib.sys.LessOrEqual$Real)
+ | native(org.globus.cog.karajan.lib.sys.LessOrEqual$Integer)
+
+__plus_ :=
+ native(org.globus.cog.karajan.lib.sys.Plus$Real)
+ | native(org.globus.cog.karajan.lib.sys.Plus$Integer)
+ | native(org.globus.cog.karajan.lib.sys.Plus$String)
+
+__minus_ :=
+ native(org.globus.cog.karajan.lib.sys.Minus$Real)
+ | native(org.globus.cog.karajan.lib.sys.Minus$Integer)
+
+__times_ :=
+ native(org.globus.cog.karajan.lib.sys.Times$Integer)
+ | native(org.globus.cog.karajan.lib.sys.Times$Real)
+
+__fwslash_ :=
+ native(org.globus.cog.karajan.lib.sys.Div$Integer)
+ | native(org.globus.cog.karajan.lib.sys.Div$Real)
+
+throw := native(org.globus.cog.karajan.lib.sys.Throw)
+Exception := native(org.globus.cog.karajan.lib.sys.KException)
+
+
+namespace(sys) {
+ export(
+ echo, print, range, wait,
+ __eq___eq_, __lt_, __gt_, __lt___eq_, __gt___eq_,
+ __plus_, __minus_, __times_, __fwslash_,
+ throw, Exception
+ )
+}
\ No newline at end of file
Modified: branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/Loader.java
===================================================================
--- branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/Loader.java 2008-06-26 09:33:15 UTC (rev 2060)
+++ branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/Loader.java 2008-06-27 00:16:28 UTC (rev 2061)
@@ -41,6 +41,8 @@
public static final String ARG_CSTDOUT = "stdoutUnordered";
public static void main(String[] argv) {
+ //new Trr().trr();
+ //System.exit(0);
ArgumentParser ap = buildArgumentParser();
boolean debug = false, cache = false;
long start = System.currentTimeMillis();
@@ -92,6 +94,7 @@
}
boolean runerror = false;
+ long s2 = start;
try {
ElementTree tree;
@@ -106,6 +109,7 @@
Class<Runnable> cls = Compiler.getDefault().compileAndLoad(tree);
Constructor<Runnable> c = cls.getConstructor(new Class<?>[] {});
Runnable r = c.newInstance();
+ s2 = System.currentTimeMillis();
LWThread t = new LWThread(r);
t.start();
t.waitFor();
@@ -123,7 +127,9 @@
long end = System.currentTimeMillis();
if (Configuration.getDefault().getFlag(Configuration.SHOW_STATISTICS)) {
System.out.println("Done.");
- System.out.println("Total execution time: " + ((double) (end - start) / 1000) + " s");
+ System.out.println("Total time: " + ((double) (end - start) / 1000) + " s");
+ System.out.println("Execution time: " + ((double) (end - s2) / 1000) + " s");
+ System.out.println("Context switches: " + LWThread.contextSwitches);
System.out.println("Memory in use at termination: "
+ (Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory())
/ 1024 + "KB");
@@ -144,7 +150,7 @@
return load("_", br, source.startsWith("<"));
}
- private static ElementTree load(String name, Reader reader, boolean xml)
+ public static ElementTree load(String name, Reader reader, boolean xml)
throws SpecificationException {
try {
ElementTree source;
@@ -200,4 +206,50 @@
private static void installKeyboardHooks() {
}
+
+
+
+ public static class Trr implements Runnable {
+ public void trr() {
+ long s = System.currentTimeMillis();
+ int sz = 200000;
+ LWThread t[] = new LWThread[sz];
+ for (int i = 0; i < sz; i++) {
+ t[i] = new LWThread(this);
+ t[i].start();
+ }
+ for (int i = 0; i < sz; i++) {
+ try {
+ t[i].waitFor();
+ }
+ catch (InterruptedException e1) {
+ e1.printStackTrace();
+ }
+ }
+ long e = System.currentTimeMillis();
+ System.out.println(e - s);
+ System.out.println((e - s) / 200);
+ }
+
+ public void run() {
+ int x = bzz(11);
+ }
+
+ public int bzz(int x) {
+ Thread t = Thread.currentThread();
+ if (t.isDaemon()) {
+ System.err.println("?");
+ }
+ x = x - 1;
+ switch(x) {
+ case 0:
+ t();
+ default:
+ return bzz(x);
+ }
+ }
+ public void t() {
+ LWThread.currentThread().die();
+ }
+ }
}
\ No newline at end of file
Modified: branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/compiler/Compiler.java
===================================================================
--- branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/compiler/Compiler.java 2008-06-26 09:33:15 UTC (rev 2060)
+++ branches/karajan2/src/cog/modules/karajan2/src/org/globus/cog/karajan/compiler/Compiler.java 2008-06-27 00:16:28 UTC (rev 2061)
@@ -21,272 +21,344 @@
import java.util.HashMap;
import java.util.Map;
-import org.globus.cog.karajan.compiler.kernel.Def;
-import org.globus.cog.karajan.compiler.kernel.Export;
-import org.globus.cog.karajan.compiler.kernel.For;
-import org.globus.cog.karajan.compiler.kernel.Function;
-import org.globus.cog.karajan.compiler.kernel.GenericSeq;
-import org.globus.cog.karajan.compiler.kernel.If;
-import org.globus.cog.karajan.compiler.kernel.Import;
-import org.globus.cog.karajan.compiler.kernel.Karajan;
-import org.globus.cog.karajan.compiler.kernel.Named;
-import org.globus.cog.karajan.compiler.kernel.Native;
-import org.globus.cog.karajan.compiler.kernel.Num;
-import org.globus.cog.karajan.compiler.kernel.Par;
-import org.globus.cog.karajan.compiler.kernel.Seq;
-import org.globus.cog.karajan.compiler.kernel.Set;
-import org.globus.cog.karajan.compiler.kernel.Str;
-import org.globus.cog.karajan.compiler.kernel.Var;
+import org.globus.cog.karajan.Loader;
+import org.globus.cog.karajan.compiler.kernel.*;
+import org.globus.cog.karajan.compiler.types.Types;
import org.globus.cog.karajan.parser.ElementTree;
import org.globus.cog.karajan.parser.Node;
+import org.globus.cog.karajan.runtime.Context;
public class Compiler {
-
- public static final boolean KEEP_FILES = true;
- private static Compiler defaultCompiler;
+ public static final boolean KEEP_FILES = true;
- public synchronized static Compiler getDefault() {
- if (defaultCompiler == null) {
- defaultCompiler = new Compiler();
- }
- return defaultCompiler;
- }
+ private static Compiler defaultCompiler;
- private File tmpdir;
+ public synchronized static Compiler getDefault() {
+ if (defaultCompiler == null) {
+ defaultCompiler = new Compiler();
+ }
+ return defaultCompiler;
+ }
- public Compiler() {
- }
+ private File tmpdir;
- public Class<Runnable> compileAndLoad(ElementTree tree) throws CompilationException {
- try {
- return loadClass(compile(tree));
- }
- catch (IOException e) {
- throw new CompilationException(tree.getRoot(), e);
- }
- }
-
- public File compile(ElementTree tree) throws CompilationException {
- tree.getRoot().setProperty(Node.FILENAME, className(tree));
- return compile(tree.getRoot(), className(tree));
- }
-
- public Type analize(ElementTree tree) throws CompilationException {
- tree.getRoot().setProperty(Node.FILENAME, className(tree));
- return analyze(tree.getRoot(), className(tree));
- }
-
- public String className(ElementTree tree) {
- return Def.identifier(tree.getName());
- }
+ public Compiler() {
+ }
- private File compile(Node root, String name) throws CompilationException {
- try {
- Scope kernel = initializeKernel();
- State state = new State(kernel);
- state = state.forkScope();
- synchronized(this) {
- if (tmpdir == null) {
- //tmpdir = new File("/tmp/karajan_compiler/");
- tmpdir = new File(".");
- tmpdir.mkdirs();
- //tmpdir = createTempDir();
- if (!KEEP_FILES) {
- tmpdir.deleteOnExit();
- }
- }
- }
- state.setClassName(name);
- OutputContext oc = new OutputContext();
- compile(root, state, oc);
- File of = new File(tmpdir, name + ".java");
- if (!KEEP_FILES) {
- of.deleteOnExit();
- }
- Writer wr = new IndentingWriter(new FileWriter(of));
- oc.commit(wr);
- wr.close();
- //copyFile(of, "../src/" + of.getName());
- compileJava(of);
- return new File(of.getParentFile(), name);
- }
- catch (VariableNotFoundException e) {
- throw new CompilationException(root, e);
- }
- catch (InterruptedException e) {
- throw new CompilationException(root, e);
- }
- catch (IOException e) {
- throw new CompilationException(root, e);
- }
- }
-
- private Type analyze(Node root, String name) throws CompilationException {
- try {
- Scope kernel = initializeKernel();
- State state = new State(kernel);
- state = state.forkScope();
- state.setClassName("");
- return analize(root, state);
- }
- catch (VariableNotFoundException e) {
- throw new CompilationException(root, e);
- }
- }
+ public Class<Runnable> compileAndLoad(ElementTree tree)
+ throws CompilationException {
+ try {
+ return loadClass(compile(tree));
+ }
+ catch (IOException e) {
+ throw new CompilationException(tree.getRoot(), e);
+ }
+ }
- private File createTempDir() throws IOException {
- File f = File.createTempFile("karajan", "");
- if (!f.delete()) {
- throw new IOException("Cannot delete file " + f);
- }
- if (!f.mkdir()) {
- throw new IOException("Cannot create directory " + f);
- }
- return f;
- }
-
- private static Map<File, DynamicClassLoader> classLoaders;
-
- private DynamicClassLoader getClassLoader(File dir) throws MalformedURLException {
- synchronized(Compiler.class) {
- if (classLoaders == null) {
- classLoaders = new HashMap<File, DynamicClassLoader>();
- }
- DynamicClassLoader cl = classLoaders.get(dir);
- if (cl == null) {
- cl = new DynamicClassLoader(dir);
- classLoaders.put(dir, cl);
- }
- return cl;
- }
- }
+ public File compile(ElementTree tree) throws CompilationException {
+ tree.getRoot().setProperty("origname", tree.getName());
+ tree.getRoot().setProperty(Node.FILENAME, className(tree));
+ return compile(tree.getRoot(), className(tree));
+ }
- private Class<Runnable> loadClass(File f) throws IOException {
- try {
- DynamicClassLoader cl = getClassLoader(f.getParentFile());
- Class<Runnable> cls = (Class<Runnable>) cl.loadClass(f.getName());
- return cls;
- }
- catch (ClassNotFoundException e) {
- throw new IOException("Could not load " + f.getName(), e);
- }
- catch (Exception e) {
- throw new IOException("Invalid dir " + f.getParent(), e);
- }
- }
+ public Type analize(ElementTree tree) throws CompilationException {
+ tree.getRoot().setProperty("origname", tree.getName());
+ tree.getRoot().setProperty(Node.FILENAME, className(tree));
+ return analyze(tree.getRoot(), className(tree));
+ }
- private void compileJava(File f) throws IOException, InterruptedException {
- String classpath = System.getProperty("java.class.path");
- classpath = classpath + File.pathSeparator + f.getParentFile().getAbsolutePath();
- String javaHome = System.getProperty("java.home");
- String javac = javaHome + File.separator + "../bin/javac";
- Process p = Runtime.getRuntime().exec(
- new String[] { javac, "-classpath", classpath, f.getAbsolutePath() });
- String[] output = consumeOutputs(p);
- if (p.exitValue() != 0) {
- throw new IOException("Java compilation failed:\n" + output[0] + "\n" + output[1]);
- }
- else {
- String name = f.getName().substring(0, f.getName().length() - 5);
- File of = new File(f.getParent() + File.separator + name + ".class");
- if (!KEEP_FILES) {
- of.deleteOnExit();
- }
- }
- }
+ public String className(ElementTree tree) {
+ return replaceSymbols(base(tree.getName()));
+ }
- private String[] consumeOutputs(Process p) throws IOException, InterruptedException {
- ByteArrayOutputStream out = new ByteArrayOutputStream();
- ByteArrayOutputStream err = new ByteArrayOutputStream();
- InputStream os = p.getInputStream();
- InputStream es = p.getErrorStream();
- byte[] buf = new byte[128];
- while (!processDone(p)) {
- int oa = os.available();
- if (oa > 0) {
- int len = os.read(buf, 0, Math.min(oa, buf.length));
- out.write(buf, 0, len);
- }
- int ea = es.available();
- if (ea > 0) {
- int len = es.read(buf, 0, Math.min(ea, buf.length));
- err.write(buf, 0, len);
- }
- if (oa + ea == 0) {
- Thread.sleep(20);
- }
- }
- return new String[] { out.toString(), err.toString() };
- }
+ private String base(String name) {
+ int i = name.lastIndexOf('.');
+ if (i == -1) {
+ return name;
+ }
+ else {
+ return name.substring(0, i);
+ }
+ }
- private boolean processDone(Process p) {
- try {
- p.exitValue();
- return true;
- }
- catch (IllegalThreadStateException e) {
- return false;
- }
- }
-
- private void copyFile(File src, String dest) throws IOException {
- byte[] buf = new byte[1024];
- FileInputStream fis = new FileInputStream(src);
- FileOutputStream fos = new FileOutputStream(dest);
- int len = fis.read(buf);
- while (len > 0) {
- fos.write(buf, 0, len);
- len = fis.read(buf);
- }
- fis.close();
- fos.close();
- }
+ private String replaceSymbols(String s) {
+ StringBuffer sb = new StringBuffer();
+ for (int i = 0; i < s.length(); i++) {
+ char c = s.charAt(i);
+ if (Character.isJavaIdentifierPart(c)) {
+ sb.append(c);
+ }
+ else {
+ sb.append('_');
+ }
+ }
+ return sb.toString();
+ }
- private void compile(Node node, State state, OutputContext oc) throws CompilationException,
- VariableNotFoundException {
- Def def = state.getScope().lookupDef(new QName(node.getNodeType()));
- def.analyze(node, state);
- String name = def.compile(node, oc);
- }
-
- private Type analize(Node node, State state) throws CompilationException,
- VariableNotFoundException {
- Def def = state.getScope().lookupDef(new QName(node.getNodeType()));
- return def.analyze(node, state);
- }
+ private File compile(Node root, String name) throws CompilationException {
+ try {
+ Scope kernel = initializeKernel();
+ State state = new State(kernel);
+ state = state.forkScopeHard();
+ synchronized (this) {
+ if (tmpdir == null) {
+ // tmpdir = new File("/tmp/karajan_compiler/");
+ tmpdir = new File(".");
+ tmpdir.mkdirs();
+ // tmpdir = createTempDir();
+ if (!KEEP_FILES) {
+ tmpdir.deleteOnExit();
+ }
+ }
+ }
+ state.setClassName(name);
+ OutputContext oc = new OutputContext();
+ compile(root, state, oc);
+ File of = new File(tmpdir, name + ".java");
+ if (!KEEP_FILES) {
+ of.deleteOnExit();
+ }
+ Writer wr = new IndentingWriter(new FileWriter(of));
+ oc.commit(wr);
+ wr.close();
+ //copyFile(of, "../src/" + of.getName());
+ compileJava(of);
+ return new File(of.getParentFile(), name);
+ }
+ catch (VariableNotFoundException e) {
+ throw new CompilationException(root, e);
+ }
+ catch (InterruptedException e) {
+ throw new CompilationException(root, e);
+ }
+ catch (IOException e) {
+ throw new CompilationException(root, e);
+ }
+ }
- public static final String KERNEL = "k";
+ private Type analyze(Node root, String name) throws CompilationException {
+ try {
+ Scope kernel = initializeKernel();
+ State state = new State(kernel);
+ state = state.forkScope();
+ state.setClassName("");
+ return analize(root, state);
+ }
+ catch (VariableNotFoundException e) {
+ throw new CompilationException(root, e);
+ }
+ }
- private Scope initializeKernel() {
- Scope s = new Scope();
- addDef(s, "seq", new Seq());
- addDef(s, "par", new Par());
- addDef(s, "karajan", new Karajan());
- addDef(s, "set", new Set());
- addDef(s, "var", new Var());
- addDef(s, "number", new Num());
- addDef(s, "string", new Str());
- addDef(s, "native", new Native());
- addDef(s, "function", new Function());
- addDef(s, "named", new Named());
- addDef(s, "bref", new GenericSeq());
- addDef(s, "block", new GenericSeq());
- addDef(s, "connect", new GenericSeq());
- addDef(s, "to", new GenericSeq());
- addDef(s, "if", new If());
- addDef(s, "for", new For());
- addDef(s, "import", new Import());
- addDef(s, "export", new Export());
- s.set(s.addVar(new QName("k", "true")), new TypedValue(null, Boolean.TRUE));
- s.set(s.addVar(new QName("k", "false")), new TypedValue(null, Boolean.FALSE));
- return s;
- }
+ private File createTempDir() throws IOException {
+ File f = File.createTempFile("karajan", "");
+ if (!f.delete()) {
+ throw new IOException("Cannot delete file " + f);
+ }
+ if (!f.mkdir()) {
+ throw new IOException("Cannot create directory " + f);
+ }
+ return f;
+ }
- private void addDef(Scope s, String name, Def def) {
- QName qn = new QName(KERNEL, name);
- VarRef ref = s.addVar(qn);
- def.setName(qn);
- s.set(ref, new TypedValue(new Lambda(), def));
- }
+ private static Map<File, DynamicClassLoader> classLoaders;
+
+ private DynamicClassLoader getClassLoader(File dir)
+ throws MalformedURLException {
+ synchronized (Compiler.class) {
+ if (classLoaders == null) {
+ classLoaders = new HashMap<File, DynamicClassLoader>();
+ }
+ DynamicClassLoader cl = classLoaders.get(dir);
+ if (cl == null) {
+ cl = new DynamicClassLoader(dir);
+ classLoaders.put(dir, cl);
+ }
+ return cl;
+ }
+ }
+
+ private Class<Runnable> loadClass(File f) throws IOException {
+ try {
+ DynamicClassLoader cl = getClassLoader(f.getParentFile());
+ Class<Runnable> cls = (Class<Runnable>) cl.loadClass(f.getName());
+ return cls;
+ }
+ catch (ClassNotFoundException e) {
+ throw new IOException("Could not load " + f.getName(), e);
+ }
+ catch (Exception e) {
+ throw new IOException("Invalid dir " + f.getParent(), e);
+ }
+ }
+
+ private void compileJava(File f) throws IOException, InterruptedException {
+ String classpath = System.getProperty("java.class.path");
+ classpath = classpath + File.pathSeparator
+ + f.getParentFile().getAbsolutePath();
+ String javaHome = System.getProperty("java.home");
+ String javac = java...
[truncated message content] |
|
From: <b_...@us...> - 2008-06-26 09:33:18
|
Revision: 2060
http://cogkit.svn.sourceforge.net/cogkit/?rev=2060&view=rev
Author: b_z_c
Date: 2008-06-26 02:33:15 -0700 (Thu, 26 Jun 2008)
Log Message:
-----------
CHANGES for r2058
Modified Paths:
--------------
trunk/current/src/cog/modules/karajan/CHANGES.txt
Modified: trunk/current/src/cog/modules/karajan/CHANGES.txt
===================================================================
--- trunk/current/src/cog/modules/karajan/CHANGES.txt 2008-06-25 23:00:55 UTC (rev 2059)
+++ trunk/current/src/cog/modules/karajan/CHANGES.txt 2008-06-26 09:33:15 UTC (rev 2060)
@@ -1,3 +1,9 @@
+(06/26/2008)
+
+*** WeightedHostScoreScheduler behaviour changed for low scoring sites;
+ low scoring sites have a delay between submissions, rather than the
+ previous behaviour of always taking a load of at least 2.
+
(04/30/2008)
*** Added raceFor. It's a blend between race() and for(). It will
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <ha...@us...> - 2008-06-25 23:01:33
|
Revision: 2059
http://cogkit.svn.sourceforge.net/cogkit/?rev=2059&view=rev
Author: hategan
Date: 2008-06-25 16:00:55 -0700 (Wed, 25 Jun 2008)
Log Message:
-----------
cleaned a bit and reformatted
Modified Paths:
--------------
trunk/current/src/cog/modules/karajan/src/org/globus/cog/karajan/scheduler/WeightedHost.java
Modified: trunk/current/src/cog/modules/karajan/src/org/globus/cog/karajan/scheduler/WeightedHost.java
===================================================================
--- trunk/current/src/cog/modules/karajan/src/org/globus/cog/karajan/scheduler/WeightedHost.java 2008-06-25 22:47:10 UTC (rev 2058)
+++ trunk/current/src/cog/modules/karajan/src/org/globus/cog/karajan/scheduler/WeightedHost.java 2008-06-25 23:00:55 UTC (rev 2059)
@@ -45,7 +45,8 @@
}
protected void setScore(double score) {
- if(score<MINWEIGHT) score=MINWEIGHT;
+ if (score < MINWEIGHT)
+ score = MINWEIGHT;
this.score = new Double(score);
this.tscore = smooth(score);
}
@@ -67,8 +68,12 @@
}
public final double getTScore() {
- if(tscore >= 1) return tscore;
- if(isOverloaded()) return 0; else return 1;
+ if (tscore >= 1)
+ return tscore;
+ if (isOverloaded())
+ return 0;
+ else
+ return 1;
}
public final BoundContact getHost() {
@@ -111,7 +116,7 @@
public String toString() {
return host.toString() + ":" + D4.format(score) + "(" + D4.format(tscore) + "):" + load
- + "/" + (int)(maxLoad()) + (isOverloaded() ? " overloaded" : "");
+ + "/" + (int) (maxLoad()) + (isOverloaded() ? " overloaded" : "");
}
public int compareTo(Object o) {
@@ -136,22 +141,30 @@
public boolean isOverloaded() {
double ml = maxLoad();
- if(tscore >= 1) {
+ if (tscore >= 1) {
// the site is mostly good. permit 1 or more jobs
// always.
- logger.info("In load mode. score = "+score+" tscore = "+tscore+", maxload="+ml);
+ if (logger.isInfoEnabled()) {
+ logger.info("In load mode. score = " + score + " tscore = " + tscore + ", maxload="
+ + ml);
+ }
return !(load <= ml);
- } else {
+ }
+ else {
// the site is mostly bad. allow either 1 or 0 jobs
// based on time.
long now = System.currentTimeMillis();
long delay = now - lastUsed;
- long permittedDelay = (long)(Math.exp(-(score.doubleValue()))*100.0);
- boolean overloaded=(delay<permittedDelay);
- // tscore of -1 will give delay of around
+ long permittedDelay = (long) (Math.exp(-(score.doubleValue())) * 100.0);
+ boolean overloaded = (delay < permittedDelay);
+ // tscore of -1 will give delay of around
// 200ms, and will double every time tscore goes
// down by one (which is once per failed job? roughly?)
- logger.info("In delay mode. score = "+score+" tscore = "+tscore+", maxload="+ml+" delay since last used="+delay+"ms"+" permitted delay="+permittedDelay+"ms overloaded="+overloaded);
+ if (logger.isInfoEnabled()) {
+ logger.info("In delay mode. score = " + score + " tscore = " + tscore
+ + ", maxload=" + ml + " delay since last used=" + delay + "ms"
+ + " permitted delay=" + permittedDelay + "ms overloaded=" + overloaded);
+ }
return overloaded;
}
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|
|
From: <b_...@us...> - 2008-06-25 22:47:59
|
Revision: 2058
http://cogkit.svn.sourceforge.net/cogkit/?rev=2058&view=rev
Author: b_z_c
Date: 2008-06-25 15:47:10 -0700 (Wed, 25 Jun 2008)
Log Message:
-----------
hopefully better behaviour in the presence of bad sites
Modified Paths:
--------------
trunk/current/src/cog/modules/karajan/src/org/globus/cog/karajan/scheduler/WeightedHost.java
trunk/current/src/cog/modules/karajan/src/org/globus/cog/karajan/scheduler/WeightedHostScoreScheduler.java
Modified: trunk/current/src/cog/modules/karajan/src/org/globus/cog/karajan/scheduler/WeightedHost.java
===================================================================
--- trunk/current/src/cog/modules/karajan/src/org/globus/cog/karajan/scheduler/WeightedHost.java 2008-06-25 13:14:02 UTC (rev 2057)
+++ trunk/current/src/cog/modules/karajan/src/org/globus/cog/karajan/scheduler/WeightedHost.java 2008-06-25 22:47:10 UTC (rev 2058)
@@ -11,6 +11,7 @@
import java.text.DecimalFormat;
import java.text.NumberFormat;
+import org.apache.log4j.Logger;
import org.globus.cog.karajan.util.BoundContact;
@@ -18,12 +19,15 @@
static final int MINWEIGHT = -10;
+ private static final Logger logger = Logger.getLogger(WeightedHost.class);
+
private BoundContact host;
private Double score;
private double tscore;
private int load;
private double delayedDelta;
private float jobThrottle;
+ private long lastUsed;
public WeightedHost(BoundContact contact, float jobThrottle) {
this(contact, 0.0, jobThrottle);
@@ -63,7 +67,8 @@
}
public final double getTScore() {
- return tscore;
+ if(tscore >= 1) return tscore;
+ if(isOverloaded()) return 0; else return 1;
}
public final BoundContact getHost() {
@@ -130,7 +135,25 @@
}
public boolean isOverloaded() {
- return !(load < maxLoad());
+ double ml = maxLoad();
+ if(tscore >= 1) {
+ // the site is mostly good. permit 1 or more jobs
+ // always.
+ logger.info("In load mode. score = "+score+" tscore = "+tscore+", maxload="+ml);
+ return !(load <= ml);
+ } else {
+ // the site is mostly bad. allow either 1 or 0 jobs
+ // based on time.
+ long now = System.currentTimeMillis();
+ long delay = now - lastUsed;
+ long permittedDelay = (long)(Math.exp(-(score.doubleValue()))*100.0);
+ boolean overloaded=(delay<permittedDelay);
+ // tscore of -1 will give delay of around
+ // 200ms, and will double every time tscore goes
+ // down by one (which is once per failed job? roughly?)
+ logger.info("In delay mode. score = "+score+" tscore = "+tscore+", maxload="+ml+" delay since last used="+delay+"ms"+" permitted delay="+permittedDelay+"ms overloaded="+overloaded);
+ return overloaded;
+ }
}
public float getJobThrottle() {
@@ -138,6 +161,10 @@
}
public double maxLoad() {
- return jobThrottle * tscore + 2;
+ return jobThrottle * tscore + 1;
}
+
+ public void notifyUsed() {
+ lastUsed = System.currentTimeMillis();
+ }
}
Modified: trunk/current/src/cog/modules/karajan/src/org/globus/cog/karajan/scheduler/WeightedHostScoreScheduler.java
===================================================================
--- trunk/current/src/cog/modules/karajan/src/org/globus/cog/karajan/scheduler/WeightedHostScoreScheduler.java 2008-06-25 13:14:02 UTC (rev 2057)
+++ trunk/current/src/cog/modules/karajan/src/org/globus/cog/karajan/scheduler/WeightedHostScoreScheduler.java 2008-06-25 22:47:10 UTC (rev 2058)
@@ -223,6 +223,7 @@
sorted.changeLoad(selected, 1);
selected.setDelayedDelta(successFactor);
+ selected.notifyUsed();
return selected.getHost();
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|