/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at
* trunk/opends/resource/legal-notices/OpenDS.LICENSE. If applicable,
* add the following below this CDDL HEADER, with the fields enclosed
* by brackets "[]" replaced with your own identifying information:
* Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*
*
* Copyright 2008 Sun Microsystems, Inc.
*/
/**
* A simple panel used in the LDAP entry viewers to display a binary value.
* It does not allow to edit the binary value. It is used for instance in the
* tables.
*
*/
{
private boolean displayDelete;
/**
* Default constructor.
*
*/
public BinaryCellPanel()
{
super(new GridBagLayout());
setOpaque(false);
iconButton.setVisible(false);
editButton.setOpaque(false);
deleteButton.setOpaque(false);
lockLabel.setVisible(false);
}
/**
* Returns the message describing the provided array of bytes.
* @param value the array of bytes.
* @param isImage whether the array of bytes represents an image or not.
* @return the message describing the provided array of bytes.
*/
{
{
return INFO_CTRL_PANEL_NO_VALUE_SPECIFIED.get();
}
else if (isImage)
{
}
else
{
return INFO_CTRL_PANEL_BINARY_VALUE.get();
}
}
/**
* Updates the visibility of the lock icon.
* @param visible whether the lock icon is visible or not.
*/
{
if (visible)
{
lockLabel.setVisible(true);
}
else
{
lockLabel.setVisible(false);
}
}
/**
* Sets the text of the edit button (for instance if this panel is displaying
* a read-only value, the user might set a value of 'View...' that launches
* a viewer).
* @param text the text of the button.
*/
{
}
/**
* Returns the message describing the provided binary value.
* @param value the binary value.
* @param isImage whether the binary value represents an image or not.
* @return the message describing the provided binary value.
*/
{
{
}
else if (isImage)
{
}
{
}
else
{
}
return returnValue;
}
/**
* Sets the value to be displayed by this panel.
* @param value the binary value as an array of bytes.
* @param isImage whether the binary value represents an image or not.
*/
{
if (!isImage)
{
label.setVisible(true);
iconButton.setVisible(false);
}
else
{
}
}
/**
* Sets the value to be displayed by this panel.
* @param value the binary value as a BinaryValue object.
* @param isImage whether the binary value represents an image or not.
*/
{
if (!isImage)
{
label.setVisible(true);
iconButton.setVisible(false);
}
else
{
try
{
}
catch (ParseException pe)
{
}
}
}
{
{
label.setVisible(true);
iconButton.setVisible(false);
}
else
{
{
label.setVisible(true);
iconButton.setVisible(false);
}
else
{
iconButton.setVisible(true);
label.setVisible(false);
}
}
}
/**
* Returns the object represented by this panel.
* @return the object represented by this panel.
*/
{
return value;
}
/**
* Explicitly request the focus for the edit button of this panel.
*
*/
public void requestFocusForButton()
{
}
/**
* Adds an action listener to this panel. The action listener will be
* invoked when the user clicks on the 'Edit' button or the icon.
* @param listener the action listener.
*/
{
}
/**
* Removes an action listener previously added with the method
* addEditActionListener.
* @param listener the action listener.
*/
{
}
/**
* Adds an action listener to this panel. The action listener will be
* invoked when the user clicks on the 'Delete'.
* @param listener the action listener.
*/
{
}
/**
* Removes an action listener previously added with the method
* addDeleteActionListener.
* @param listener the action listener.
*/
{
}
/**
* {@inheritDoc}
*/
{
// This method is used to transfer the key events to the button.
}
/**
* Tells whether the 'Delete' button is displayed or not.
* @return <CODE>true</CODE> if the 'Delete' button is visible and
* <CODE>false</CODE> otherwise.
*/
public boolean isDisplayDelete()
{
return displayDelete;
}
/**
* Sets whether the 'Delete' button must be displayed or not.
* @param displayDelete whether the 'Delete' button must be displayed or not.
*/
{
this.displayDelete = displayDelete;
}
{
true);
}
}