// Sample code file: UAMMenuHandler.java
// Warning: This code has been marked up for HTML
/***************************************************************************
$name: UAMMenuHandler.java
$version: 1.0
$date_modified: 210104
$description:
$owner: Beans for Novell Services Team
Copyright (c) 1998 Novell, Inc. All Rights Reserved.
THIS WORK IS SUBJECT TO U.S. AND INTERNATIONAL COPYRIGHT LAWS AND TREATIES.
USE AND REDISTRIBUTION OF THIS WORK IS SUBJECT TO THE LICENSE AGREEMENT
ACCOMPANYING THE SOFTWARE DEVELOPMENT KIT (SDK) THAT CONTAINS THIS WORK.
PURSUANT TO THE SDK LICENSE AGREEMENT, NOVELL HEREBY GRANTS TO DEVELOPER A
ROYALTY-FREE, NON-EXCLUSIVE LICENSE TO INCLUDE NOVELL'S SAMPLE CODE IN ITS
PRODUCT. NOVELL GRANTS DEVELOPER WORLDWIDE DISTRIBUTION RIGHTS TO MARKET,
DISTRIBUTE, OR SELL NOVELL'S SAMPLE CODE AS A COMPONENT OF DEVELOPER'S
PRODUCTS. NOVELL SHALL HAVE NO OBLIGATIONS TO DEVELOPER OR DEVELOPER'S
CUSTOMERS WITH RESPECT TO THIS CODE.
****************************************************************************/
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.tree.*;
import java.util.Vector;
//This class implements methods for handling events generated in UAMConsole
class UAMMenuHandler implements ActionListener, ItemListener
{
UAMConsole m_uamConsole;
//JDialog msgbox;
public UAMMenuHandler(UAMConsole uam)
{
m_uamConsole = uam;
}
//Handle action events
public void actionPerformed(ActionEvent e)
{
String arg = (String) e.getActionCommand();
if (arg.equals("User"))
{
NewUser nwusr = new NewUser(m_uamConsole);
ObjectEntry oe = m_uamConsole.selectedObject;
if ((oe !=null) &&((oe.getClassName().equalsIgnoreCase("Organization")) || (oe.getClassName().equalsIgnoreCase("Organizational Unit"))))
nwusr.setFullName(oe.getFullName());
nwusr.setUI();
Utilities.centerWindow(nwusr);
nwusr.show();
}
else if (arg.equals("Group"))
{
NewGroup nwgrp = new NewGroup(m_uamConsole);
ObjectEntry oe = m_uamConsole.selectedObject;
if ((oe !=null) &&((oe.getClassName().equalsIgnoreCase("Organization")) || (oe.getClassName().equalsIgnoreCase("Organizational Unit"))))
nwgrp.setFullName(oe.getFullName());
nwgrp.setUI();
Utilities.centerWindow(nwgrp);
nwgrp.show();
}
else if (arg.equals("Organizational Unit"))
{
NewOU nwou = new NewOU(m_uamConsole);
ObjectEntry oe = m_uamConsole.selectedObject;
if ((oe !=null) &&((oe.getClassName().equalsIgnoreCase("Organization")) || (oe.getClassName().equalsIgnoreCase("Organizational Unit"))))
nwou.setFullName(oe.getFullName());
nwou.setUI();
Utilities.centerWindow(nwou);
nwou.show();
}
else if (arg.equals("Exit"))
{
m_uamConsole.exitFromSystem();
}
else if (arg.equals("Properties"))
{
ObjectEntry oe = m_uamConsole.selectedObject;
if (oe != null)
{
m_uamConsole.rPaneDoubleClick(oe);
}
}
else if (arg.equals("Refresh"))
{
DefaultMutableTreeNode node = (DefaultMutableTreeNode) m_uamConsole.topTree.getLastSelectedPathComponent();
if ((node!=null)&&(node!=m_uamConsole.root))
{
Vector elem = m_uamConsole.getChildren(node);
m_uamConsole.makeRightPane(elem);
}
}
else if (arg.equals("Login"))
{
m_uamConsole.login.setVisible(true);
}
else if (arg.equals("Logout"))
{
m_uamConsole.unauthenticate();
}
else if (arg.equalsIgnoreCase("Delete"))
{
JFrame mainFrame = m_uamConsole.getFrame();
ObjectEntry oe = (ObjectEntry) m_uamConsole.objectList.getSelectedValue();
String thisFullName = m_uamConsole.m_populator.getFullName();
try
{
int confirmInt = JOptionPane.showConfirmDialog(m_uamConsole.getFrame(), "Are you sure that you want to delete? ", "Delete Confirm Dialog" , JOptionPane.YES_NO_OPTION);
if (confirmInt == JOptionPane.NO_OPTION)
{
m_uamConsole.getFrame().setCursor(new Cursor(Cursor.DEFAULT_CURSOR));
return;
}
m_uamConsole.m_populator.delObject(oe.getFullName());
DefaultMutableTreeNode node = (DefaultMutableTreeNode) m_uamConsole.topTree.getLastSelectedPathComponent();
if ((node!=null)&&(node!=m_uamConsole.root))
{
Vector elem = m_uamConsole.getChildren(node);
m_uamConsole.makeRightPane(elem);
}
}
catch(Exception ex)
{
JOptionPane.showMessageDialog(mainFrame, ex.getMessage(), "Error", JOptionPane.ERROR_MESSAGE);
}
finally
{
try
{
m_uamConsole.m_populator.refresh(thisFullName);
}
catch(Exception thisex)
{
//do nothing.. Should not get caught
}
}
}
}
//Handle Item events
public void itemStateChanged(ItemEvent ie)
{
m_uamConsole.repaint();
}
}