rana_b 2003/01/20 07:17:06
Modified: ftpserver/src/java/org/apache/avalon/ftpserver/gui
FtpSpyContainerPanel.java
Log:
buttons enabled/disabled depending one the tab
Revision Changes Path
1.4 +29 -15
jakarta-avalon-apps/ftpserver/src/java/org/apache/avalon/ftpserver/gui/FtpSpyContainerPanel.java
Index: FtpSpyContainerPanel.java
===================================================================
RCS file:
/home/cvs/jakarta-avalon-apps/ftpserver/src/java/org/apache/avalon/ftpserver/gui/FtpSpyContainerPanel.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- FtpSpyContainerPanel.java 20 May 2002 10:20:17 -0000 1.3
+++ FtpSpyContainerPanel.java 20 Jan 2003 15:17:06 -0000 1.4
@@ -13,6 +13,7 @@
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
+import javax.swing.event.*;
import org.apache.avalon.ftpserver.FtpUser;
import org.apache.avalon.ftpserver.util.IoUtils;
@@ -23,7 +24,7 @@
* @author <a href="mailto:[EMAIL PROTECTED]">Rana Bhattacharyya</a>
*/
public
-class FtpSpyContainerPanel extends PluginPanel {
+class FtpSpyContainerPanel extends PluginPanel implements ChangeListener {
public static final String SPY_PAGE =
"org/apache/avalon/ftpserver/gui/spy.html";
@@ -50,6 +51,7 @@
setLayout(new BorderLayout());
mjTabbedPane = new JTabbedPane();
mjTabbedPane.setPreferredSize(new Dimension(470, 340));
+ mjTabbedPane.addChangeListener(this);
add(mjTabbedPane, BorderLayout.CENTER);
JPanel bottomPane = new JPanel();
@@ -63,14 +65,6 @@
}
});
- mjCloseButton = new JButton("Close");
- bottomPane.add(mjCloseButton);
- mjCloseButton.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent evt) {
- closePane();
- }
- });
-
mjDisconnectButton = new JButton("Disconnect");
bottomPane.add(mjDisconnectButton);
mjDisconnectButton.addActionListener(new ActionListener() {
@@ -78,6 +72,14 @@
disconnectUser();
}
});
+
+ mjCloseButton = new JButton("Close");
+ bottomPane.add(mjCloseButton);
+ mjCloseButton.addActionListener(new ActionListener() {
+ public void actionPerformed(ActionEvent evt) {
+ closePane();
+ }
+ });
add(bottomPane, BorderLayout.SOUTH);
// initialize component to be displayed if
@@ -97,11 +99,11 @@
finally {
IoUtils.close(is);
}
+
mjAboutPane = new JScrollPane(editorPane,
JScrollPane.VERTICAL_SCROLLBAR_AS_NEEDED,
JScrollPane.HORIZONTAL_SCROLLBAR_AS_NEEDED);
mjTabbedPane.addTab("Spy", mjAboutPane);
-
}
@@ -135,7 +137,7 @@
private void disconnectUser() {
Component selComp = mjTabbedPane.getSelectedComponent();
if ( (selComp != null) && (selComp != mjAboutPane) ) {
- boolean bConf =
GuiUtils.getConfirmation(getCommonHandler().getTopComponent(), "Do you want to close
the connection?");
+ boolean bConf =
GuiUtils.getConfirmation(getCommonHandler().getTopFrame(), "Do you want to close the
connection?");
if(bConf) {
((SpyPanel)selComp).disconnect();
}
@@ -146,12 +148,12 @@
* Monitor connection
*/
public void monitorConnection(FtpUser user) {
- String userName = getName(user);
+ String userName = getCaption(user);
String userSession = user.getSessionId();
// don't add another tab if already being monitored
int tabCount = mjTabbedPane.getTabCount();
- for(int i=tabCount; --i>=0; ) {
+ for(int i=0; i<tabCount; i++) {
Component selComp = mjTabbedPane.getComponentAt(i);
if ( (selComp != null) && (selComp != mjAboutPane) ) {
String tabUserSessionId = ((SpyPanel)selComp).getSessionId();
@@ -176,9 +178,9 @@
}
/**
- * Get name
+ * Get tab caption.
*/
- private String getName(FtpUser user) {
+ private String getCaption(FtpUser user) {
String name = "";
if (user != null) {
name = user.getName();
@@ -187,6 +189,18 @@
}
}
return name;
+ }
+
+
+ /**
+ * Tab change notification
+ */
+ public void stateChanged(ChangeEvent e) {
+ Component selComp = mjTabbedPane.getSelectedComponent();
+ boolean isUserPane = selComp != mjAboutPane;
+ mjClearButton.setEnabled(isUserPane);
+ mjCloseButton.setEnabled(isUserPane);
+ mjDisconnectButton.setEnabled(isUserPane);
}
/**
--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>