Fixes some possible NullPointerExceptions.

cusax-fix
Damian Minkov 15 years ago
parent 7c33e76456
commit 096047bbbe

@ -742,12 +742,12 @@ private void initButtonsPanel(UIContact uiContact)
// check for phone stored in contact info only
// if telephony contact is missing
if(uiContact.getContactNode().getContactDescriptor().getDescriptor()
instanceof MetaContact && telephonyContact == null)
if(uiContact.getDescriptor() != null
&& uiContact.getDescriptor() instanceof MetaContact
&& telephonyContact == null)
{
MetaContact metaContact =
(MetaContact)uiContact.getContactNode().getContactDescriptor().
getDescriptor();
(MetaContact)uiContact.getDescriptor();
Iterator<Contact> contacts = metaContact.getContacts();
while(contacts.hasNext() && !hasPhone)

@ -1181,7 +1181,7 @@ private void dispatchEventToButtons(MouseEvent event)
Component mouseComponent
= renderer.findComponentAt(translatedX, translatedY);
if (logger.isDebugEnabled())
if (logger.isDebugEnabled() && mouseComponent != null)
logger.debug("DISPATCH MOUSE EVENT TO COMPONENT: "
+ mouseComponent.getClass().getName()
+ " with bounds: " + mouseComponent.getBounds()

@ -179,19 +179,24 @@ protected void customPaintBackground(Graphics g)
Rectangle deleteButtonRect = getDeleteButtonRect();
int dx = deleteButtonRect.x;
int dy = deleteButtonRect.y;
if (c.getText() != null
&& c.getText().length() > 0
&& isDeleteButtonEnabled)
if(deleteButtonRect != null)
{
if (isDeleteMouseOver)
g2.drawImage(deleteButtonRolloverImg, dx, dy, null);
int dx = deleteButtonRect.x;
int dy = deleteButtonRect.y;
if (c.getText() != null
&& c.getText().length() > 0
&& isDeleteButtonEnabled)
{
if (isDeleteMouseOver)
g2.drawImage(deleteButtonRolloverImg, dx, dy, null);
else
g2.drawImage(deleteButtonImg, dx, dy, null);
isDeleteIconVisible = true;
}
else
g2.drawImage(deleteButtonImg, dx, dy, null);
isDeleteIconVisible = true;
isDeleteIconVisible = false;
}
else
isDeleteIconVisible = false;
@ -267,6 +272,9 @@ protected Rectangle getDeleteButtonRect()
{
JTextComponent c = getComponent();
if(c == null)
return null;
Rectangle rect = c.getBounds();
int dx = rect.width - deleteButton.getWidth() - BUTTON_GAP - 5;
@ -292,6 +300,9 @@ protected Rectangle getVisibleEditorRect()
}
JTextComponent c = getComponent();
if(c == null)
return null;
Rectangle alloc = c.getBounds();
@ -439,7 +450,8 @@ public void mouseMoved(MouseEvent e)
private void updateCursor(MouseEvent mouseEvent)
{
if (getVisibleEditorRect().contains(mouseEvent.getPoint()))
Rectangle rect = getVisibleEditorRect();
if (rect != null && rect.contains(mouseEvent.getPoint()))
{
getComponent().setCursor(
Cursor.getPredefinedCursor(Cursor.TEXT_CURSOR));

Loading…
Cancel
Save