wt.clients.beans
Class PrincipalSelectionPanel

java.lang.Object
  extended by java.awt.Component
      extended by java.awt.Container
          extended by java.awt.Panel
              extended by wt.clients.beans.PrincipalSelectionPanel
All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, Accessible

public class PrincipalSelectionPanel
extends Panel

The PrincipalSelectionPanel bean (wt.clients.beans.PrincipalSelectionPanel) has a dev time component and a runtime component. At dev time, you can drag this component from the component library in Visual Cafe and drop it onto a container. The properties can also be edited by using Visual Cafe's Property Editor. At runtime, this class allows you to select a WTPrincipal (WTUser or WTGroup) by either entering the name of the WTPrincipal directly or by browsing lists of the available WTGroups or WTUsers. The bean can also simply display a WTPrincipal. This bean contains a label, a text field, and a browse button when used for selecting a principal. When the browse button is clicked a dialog is launched which allows the user to browse a list or lists for a desired principal. The following is a small example of using the PrincipalSelectionPanel bean:

   import java.awt.*;
   import java.beans.PropertyChangeListener;
   import java.beans.PropertyChangeEvent;

   import wt.clients.beans.PrincipalSelectionPanel;
   import wt.help.*;
   import wt.org.WTPrincipal;

   import symantec.itools.awt.StatusBar;

   public class PSPTestFrame extends Frame
   {
        public PSPTestFrame()
        {
                // This code is automatically generated by Visual Cafe when you add
                // components to the visual environment. It instantiates and initializes
                // the components. To modify the code, only use code syntax that matches
                // what Visual Cafe can generate, or Visual Cafe may be unable to back
                // parse your Java file into its visual environment.
                //{{INIT_CONTROLS
                GridBagLayout gridBagLayout;
                gridBagLayout = new GridBagLayout();
                setLayout(gridBagLayout);
                setVisible(false);
                setSize(497,211);
                setBackground(new Color(12632256));
                psp = new wt.clients.beans.PrincipalSelectionPanel();
                psp.setBounds(0,0,495,143);
                psp.setBackground(new Color(12632256));
                GridBagConstraints gbc;
                gbc = new GridBagConstraints();
                gbc.gridx = 0;
                gbc.gridy = 0;
                gbc.weightx = 1.0;
                gbc.weighty = 1.0;
                gbc.fill = GridBagConstraints.BOTH;
                gbc.insets = new Insets(0,0,0,2);
                ((GridBagLayout)getLayout()).setConstraints(psp, gbc);
                add(psp);
                testButton = new java.awt.Button();
                testButton.setLabel("Test Button");
                testButton.setBounds(414,143,76,23);
                testButton.setBackground(new Color(12632256));
                gbc = new GridBagConstraints();
                gbc.gridx = 0;
                gbc.gridy = 1;
                gbc.weightx = 1.0;
                gbc.anchor = GridBagConstraints.EAST;
                gbc.fill = GridBagConstraints.NONE;
                gbc.insets = new Insets(0,0,5,7);
                ((GridBagLayout)getLayout()).setConstraints(testButton, gbc);
                add(testButton);
                statusBar = new symantec.itools.awt.StatusBar();
                try {
                        statusBar.setBevelStyle(symantec.itools.awt.StatusBar.BEVEL_LOWERED);
                }
                catch(java.beans.PropertyVetoException e) { }
                statusBar.setBounds(0,171,147,40);
                gbc = new GridBagConstraints();
                gbc.gridx = 0;
                gbc.gridy = 2;
                gbc.weightx = 1.0;
                gbc.fill = GridBagConstraints.HORIZONTAL;
                gbc.insets = new Insets(0,0,0,0);
                ((GridBagLayout)getLayout()).setConstraints(statusBar, gbc);
                add(statusBar);
                setTitle("PSP Test Frame");
                //}}

                //{{INIT_MENUS
                //}}

                //{{REGISTER_LISTENERS
                SymWindow aSymWindow = new SymWindow();
                this.addWindowListener(aSymWindow);
                SymAction lSymAction = new SymAction();
                testButton.addActionListener(lSymAction);
                //}}

                psp.setPrincipalMode(PrincipalSelectionPanel.PRINCIPAL_MODE);
                psp.setDisplayMode(PrincipalSelectionPanel.DISPLAY_SELECTION_MODE);
                psp.setLabelMode(PrincipalSelectionPanel.LABEL_VISIBLE_MODE);
                psp.setBrowseButtonLabel("Custom Browse...");
           psp.setPrincipalLabel("Custom Principal:");

                HelpListener helpListener = new HelpListener();
                psp.addHelpListener(helpListener);
        }

        public PSPTestFrame(String title)
        {
                this();
                setTitle(title);
        }

        public void setVisible(boolean b)
        {
                if(b)
                {
                        setLocation(50, 50);
                }
                super.setVisible(b);
        }

        static public void main(String args[])
        {
                (new PSPTestFrame()).setVisible(true);
        }

        public void addNotify()
        {
            Dimension d = getSize();

                super.addNotify();

                if (fComponentsAdjusted)
                        return;

                setSize(insets().left + insets().right + d.width, insets().top + insets().bottom + d.height);
                Component components[] = getComponents();
                for (int i = 0; i < components.length; i++)
                {
                        Point p = components[i].getLocation();
                        p.translate(insets().left, insets().top);
                        components[i].setLocation(p);
                }
                fComponentsAdjusted = true;
        }

        boolean fComponentsAdjusted = false;

        //{{DECLARE_CONTROLS
        wt.clients.beans.PrincipalSelectionPanel psp;
        java.awt.Button testButton;
        symantec.itools.awt.StatusBar statusBar;
        //}}

        //{{DECLARE_MENUS
        //}}

        class SymWindow extends java.awt.event.WindowAdapter
        {
                public void windowClosing(java.awt.event.WindowEvent event)
                {
                        Object object = event.getSource();
                        if (object == PSPTestFrame.this)
                                Frame1_WindowClosing(event);
                }
        }

        void Frame1_WindowClosing(java.awt.event.WindowEvent event)
        {
                        dispose();              // free the system resources
                        System.exit(0);     // close the application
        }

        class HelpListener implements PropertyChangeListener
        {
            public void propertyChange(PropertyChangeEvent pce)
            {
                try
                {
                   if (pce.getPropertyName().equals (HelpContext.TOOL_DESCRIPTION))
                   {
                       try
                       {
                           statusBar.setStatusText((String) pce.getNewValue());
                       }

                       catch (Exception e)
                       {
                           e.printStackTrace();
                       }
                   }
               }

               catch (Exception e) {}
            }
        }

        class SymAction implements java.awt.event.ActionListener
        {
                public void actionPerformed(java.awt.event.ActionEvent event)
                {
                        Object object = event.getSource();
                        if (object == testButton)
                                testButton_ActionPerformed(event);
                }
        }

        void testButton_ActionPerformed(java.awt.event.ActionEvent event)
        {
            WTPrincipal test = psp.getSelectedParticipant();
            System.out.println(test);
        }
    }
 


Supported API: true

See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class java.awt.Panel
Panel.AccessibleAWTPanel
 
Nested classes/interfaces inherited from class java.awt.Container
Container.AccessibleAWTContainer
 
Nested classes/interfaces inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BltBufferStrategy, Component.FlipBufferStrategy
 
Field Summary
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
PrincipalSelectionPanel()
          This is the no arg constructor that creates the PrincipalSelectionPanel with a two modes, a selection mode and a view only mode.
 
Method Summary
 void addHelpListener(PropertyChangeListener pcl)
          Method addHelpListener adds the given listener to be notified of PropertyChangeEvents in the help system.
 void addPropertyChangeListener(PropertyChangeListener pcl)
          This method adds a PropertyChangeListener to the component.
 String getBrowseButtonLabel()
          This method returns the current value for the component's browse button label.
 WTContainerRef getContainerRef()
          This method returns the current value for the component's container reference, or null if the component is not currently associated with a container context.
 int getDisplayMode()
          This method returns the currently selected display mode of the component.
 HelpContext getHelpContext()
          This is the public getter for the HelpContext being used for the online help.
 HelpSystem getHelpSystem()
          This is the public getter for the HelpSystem being used for the online help.
 int getLabelMode()
          This method returns the currently selected label mode of the component.
 LayoutManager getLayout()
          This method returns the component's internal LayoutManager.
 String getPrincipalLabel()
          This method returns the current value for the component's principal label.
 int getPrincipalMode()
          This method returns the currently selected principal mode of the component.
 WTPrincipal getSelectedParticipant()
          This method returns the WTPrincipal that was selected.
 void removeHelpListener(PropertyChangeListener pcl)
          Method removeHelpListener removes a listener which was being notified of PropertyChangeEvents in the help system.
 void removePropertyChangeListener(PropertyChangeListener pcl)
          This method removes the desired PropertyChangeListener from the component.
 void setBrowseButtonLabel(String newLabel)
          This method sets the component's browse button label.
 void setContainerRef(WTContainerRef containerRef)
          This method sets a reference to a container that provides context for queries against users, groups, and organizations.
 void setDisplayMode(int mode)
          This method sets the component's display mode.
 void setEnabled(boolean b)
          This method enables both the browse button and the text field if the value of b is true, it disables both the browse button and the text field if the value of b is false.
 void setLabelMode(int mode)
          This method sets the component's label mode.
 void setLayout(LayoutManager lm)
          This method sets the layout for the PrincipalSelectionPanel.
 void setPrincipalLabel(String newLabel)
          This method sets the component's principal label.
 void setPrincipalMode(int mode)
          This method sets the component's principal mode.
 void setSelectedParticipant(WTPrincipal p)
          This method sets the selected WTPrincipal.
 
Methods inherited from class java.awt.Panel
addNotify, getAccessibleContext
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getInsets, getListeners, getMaximumSize, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paint, paintComponents, paramString, preferredSize, print, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, removeNotify, setComponentZOrder, setFocusCycleRoot, setFocusTraversalKeys, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setFont, transferFocusBackward, transferFocusDownCycle, update, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, createVolatileImage, createVolatileImage, disable, disableEvents, dispatchEvent, enable, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphics, getGraphicsConfiguration, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getToolkit, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isOpaque, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, printAll, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, reshape, resize, resize, setBackground, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setMaximumSize, setMinimumSize, setName, setPreferredSize, setSize, setSize, setVisible, show, show, size, toString, transferFocus, transferFocusUpCycle
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

PrincipalSelectionPanel

public PrincipalSelectionPanel()
This is the no arg constructor that creates the PrincipalSelectionPanel with a two modes, a selection mode and a view only mode. In selection mode, the panel consists of a label, a text field, and a browse button. In view only mode, the panel has a label and a string diaplaying the value of the principal.

Supported API: true.

Method Detail

setLayout

public void setLayout(LayoutManager lm)
This method sets the layout for the PrincipalSelectionPanel. Once the layout has been initialized it cannot be changed. It effectively avoids the component's internal layout from being changed.

Supported API: true.

Overrides:
setLayout in class Container
Parameters:
lm - The LayoutManager the component will have set.
See Also:
LayoutManager

getLayout

public LayoutManager getLayout()
This method returns the component's internal LayoutManager.

Supported API: true.

Overrides:
getLayout in class Container
Returns:
The LayoutManager the component is currently utilizing.
See Also:
LayoutManager

setDisplayMode

public void setDisplayMode(int mode)
This method sets the component's display mode. There are two available display modes, DISPLAY_SELECTION_MODE and DISPLAY_VIEW_ONLY_MODE. In selection mode a label, text field, and a browse button are displayed. In view only mode just a label and a string representing the principal are displayed.

Supported API: true.

Parameters:
mode - The int value of the desired new display mode.

getDisplayMode

public int getDisplayMode()
This method returns the currently selected display mode of the component.

Supported API: true.

Returns:
The int value of the currently selected display mode.

setLabelMode

public void setLabelMode(int mode)
This method sets the component's label mode. There are two available labe modes, LABEL_VISIBLE_MODE and LABEL_INVISIBLE_MODE. In label visible mode, the label is displayed, in label invisible mode it is not.

Supported API: true.

Parameters:
mode - The int value of the desired new display mode.

getLabelMode

public int getLabelMode()
This method returns the currently selected label mode of the component.

Supported API: true.

Returns:
The int value of the currently selected label mode.

setPrincipalMode

public void setPrincipalMode(int mode)
This method sets the component's principal mode. There are three available labe modes, PRINCIPAL_MODE, USER_MODE, and GROUP_MODE. In principal mode either a WTUser or WTGroup can be selected. In user mode only a WTUser can be selected, and in group mode only a WTGroup can be selected.

Supported API: true.

Parameters:
mode - The int value of the desired new principal mode.

getPrincipalMode

public int getPrincipalMode()
This method returns the currently selected principal mode of the component.

Supported API: true.

Returns:
The int value of the currently selected principal mode.

setContainerRef

public void setContainerRef(WTContainerRef containerRef)
This method sets a reference to a container that provides context for queries against users, groups, and organizations.

Supported API: true.

Parameters:
containerRef - The container reference
See Also:
WTContainerRef

getContainerRef

public WTContainerRef getContainerRef()
This method returns the current value for the component's container reference, or null if the component is not currently associated with a container context.

Supported API: true.

Returns:
The current container reference
See Also:
WTContainerRef

setBrowseButtonLabel

public void setBrowseButtonLabel(String newLabel)
This method sets the component's browse button label. If this method is called the label taken from the resource bundle will be overridden with the string that you provide.

Supported API: true.

Parameters:
mode - The String value of the desired new label for the browse button.
See Also:
String

getBrowseButtonLabel

public String getBrowseButtonLabel()
This method returns the current value for the component's browse button label.

Supported API: true.

Returns:
The String value of the current browse button label.
See Also:
String

setPrincipalLabel

public void setPrincipalLabel(String newLabel)
This method sets the component's principal label. If this method is called the label taken from the resource bundle will be overridden with the string that you provide.

Supported API: true.

Parameters:
mode - The String value of the desired new label for the principal.
See Also:
String

getPrincipalLabel

public String getPrincipalLabel()
This method returns the current value for the component's principal label.

Supported API: true.

Returns:
The String value of the current principal label.
See Also:
String

getSelectedParticipant

public WTPrincipal getSelectedParticipant()
This method returns the WTPrincipal that was selected. If the name of a WTPrincipal was entered directly into the text field, the system will verify that the entered principal is indeed valid. If the entered principal is invalid, a message dialog is displayed, notifying the user of this.

Supported API: true.

Returns:
The WTPrincipal that was selected.
See Also:
WTPrincipal

setSelectedParticipant

public void setSelectedParticipant(WTPrincipal p)
This method sets the selected WTPrincipal.

Supported API: true.

Parameters:
p - The principal selected.
See Also:
WTPrincipal

addPropertyChangeListener

public void addPropertyChangeListener(PropertyChangeListener pcl)
This method adds a PropertyChangeListener to the component. The added listener will recieve a PropertyChangeEvent when a principal is selected, or when the text entered directly into the text field is changed.

Supported API: true.

Overrides:
addPropertyChangeListener in class Container
Parameters:
pcl - The PropertyChangeListener
See Also:
PropertyChangeListener, PropertyChangeEvent

removePropertyChangeListener

public void removePropertyChangeListener(PropertyChangeListener pcl)
This method removes the desired PropertyChangeListener from the component.

Supported API: true.

Overrides:
removePropertyChangeListener in class Component
Parameters:
pcl - The PropertyChangeListener
See Also:
PropertyChangeListener, PropertyChangeEvent

setEnabled

public void setEnabled(boolean b)
This method enables both the browse button and the text field if the value of b is true, it disables both the browse button and the text field if the value of b is false.

Supported API: true.

Overrides:
setEnabled in class Component
Parameters:
b - The boolean value that enables or disables the components on the panel.

getHelpSystem

public HelpSystem getHelpSystem()
This is the public getter for the HelpSystem being used for the online help.

Supported API: true.

Returns:
The HelpSystem for the bean
See Also:
HelpSystem

getHelpContext

public HelpContext getHelpContext()
This is the public getter for the HelpContext being used for the online help.

Supported API: true.

Returns:
The HelpContext for the bean.
See Also:
HelpContext

addHelpListener

public void addHelpListener(PropertyChangeListener pcl)
Method addHelpListener adds the given listener to be notified of PropertyChangeEvents in the help system. Tool description PropertyChangeEvents are generated when the user mouses over the buttons and list of ContentItems in this panel. The given listener will be notified of those events.

Supported API: true.

Parameters:
pcl - The PropertyChangeListener to be notified of PropertyChangeEvents generated by the help system.
See Also:
removeHelpListener(java.beans.PropertyChangeListener), HelpSystem, HelpContext, PropertyChangeListener

removeHelpListener

public void removeHelpListener(PropertyChangeListener pcl)
Method removeHelpListener removes a listener which was being notified of PropertyChangeEvents in the help system. If the given listener is not currently a listener, no changes are made.

Supported API: true.

Parameters:
pcl - the PropertyChangeListener to be removed as a listener of events generated by the help system of this panel.
See Also:
addHelpListener(java.beans.PropertyChangeListener), PropertyChangeListener