/* Apply Gridlayout */
setLayout(LayoutUtils.createGridLayout(4, 0, 0));
/* State: New */
fNewState = new Button(this, SWT.CHECK);
fNewState.setText(Messages.StateConditionControl_NEW);
fNewState.setToolTipText(Messages.StateConditionControl_NEW_INFO);
fNewState.setLayoutData(new GridData(SWT.BEGINNING, SWT.CENTER, false, true));
/* State: Unread */
fUnreadState = new Button(this, SWT.CHECK);
fUnreadState.setText(Messages.StateConditionControl_UNREAD);
fUnreadState.setToolTipText(Messages.StateConditionControl_UNREAD_INFO);
fUnreadState.setLayoutData(new GridData(SWT.BEGINNING, SWT.CENTER, false, true));
/* Use Control Decoration on Mac */
if (Application.IS_MAC) {
/* Use a decoration to help the user understand the State Semantic */
final ControlDecoration newControlDeco = new ControlDecoration(fNewState, SWT.LEFT | SWT.TOP);
newControlDeco.setImage(OwlUI.getImage(fNewState, "icons/obj16/dotempty.gif")); //$NON-NLS-1$
newControlDeco.hide();
final ControlDecoration unreadControlDeco = new ControlDecoration(fUnreadState, SWT.LEFT | SWT.TOP);
unreadControlDeco.setImage(OwlUI.getImage(fUnreadState, "icons/obj16/dotempty.gif")); //$NON-NLS-1$
unreadControlDeco.hide();
fNewState.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
if (fNewState.getSelection() && !fUnreadState.getSelection()) {
unreadControlDeco.show();
unreadControlDeco.showHoverText(Messages.StateConditionControl_UNREAD_HINT);
} else {
unreadControlDeco.hide();
unreadControlDeco.hideHover();
}
}
});
fUnreadState.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
if (fUnreadState.getSelection() && !fNewState.getSelection()) {
newControlDeco.show();
newControlDeco.showHoverText(Messages.StateConditionControl_NEW_HINT);
} else {
newControlDeco.hide();
newControlDeco.hideHover();
}
}
});
fNewState.addFocusListener(new FocusAdapter() {
@Override
public void focusLost(FocusEvent e) {
newControlDeco.hide();
newControlDeco.hideHover();
}
});
fUnreadState.addFocusListener(new FocusAdapter() {
@Override
public void focusLost(FocusEvent e) {
unreadControlDeco.hide();
unreadControlDeco.hideHover();
}
});
}
/* Use Balloon Tooltip on Windows and Linux */
else {
/* Use a Tooltip to help the user understand the State Semantic */
final ToolTip newStateToolTip = new ToolTip(getShell(), SWT.BALLOON);
newStateToolTip.setMessage(Messages.StateConditionControl_NEW_HINT);
newStateToolTip.setAutoHide(false);
final ToolTip unreadStateToolTip = new ToolTip(getShell(), SWT.BALLOON);
unreadStateToolTip.setMessage(Messages.StateConditionControl_UNREAD_HINT);
unreadStateToolTip.setAutoHide(false);
fNewState.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
if (fNewState.getSelection() && !fUnreadState.getSelection()) {
Point toolTipLocation = toDisplay(fUnreadState.getLocation());
toolTipLocation.y += fUnreadState.getSize().y;
if (Application.IS_WINDOWS)
toolTipLocation.x += 5;
else if (Application.IS_LINUX)
toolTipLocation.x += 12;
unreadStateToolTip.setLocation(toolTipLocation);
unreadStateToolTip.setVisible(true);
} else {
unreadStateToolTip.setVisible(false);
}
}
});
fUnreadState.addSelectionListener(new SelectionAdapter() {
@Override
public void widgetSelected(SelectionEvent e) {
if (fUnreadState.getSelection() && !fNewState.getSelection()) {
Point toolTipLocation = toDisplay(fNewState.getLocation());
toolTipLocation.y += fNewState.getSize().y;
if (Application.IS_WINDOWS)
toolTipLocation.x += 5;
else if (Application.IS_LINUX)
toolTipLocation.x += 12;
newStateToolTip.setLocation(toolTipLocation);
newStateToolTip.setVisible(true);
} else {
newStateToolTip.setVisible(false);
}
}
});
fNewState.addFocusListener(new FocusAdapter() {
@Override
public void focusGained(FocusEvent e) {
newStateToolTip.setVisible(false);
}
@Override
public void focusLost(FocusEvent e) {
unreadStateToolTip.setVisible(false);
}
});
fUnreadState.addFocusListener(new FocusAdapter() {
@Override
public void focusGained(FocusEvent e) {
unreadStateToolTip.setVisible(false);
}
@Override
public void focusLost(FocusEvent e) {
newStateToolTip.setVisible(false);
}
});
addDisposeListener(new DisposeListener() {
public void widgetDisposed(DisposeEvent e) {
unreadStateToolTip.dispose();
newStateToolTip.dispose();
}
});
}
/* State: Updated */
fUpdatedState = new Button(this, SWT.CHECK);
fUpdatedState.setText(Messages.StateConditionControl_UPDATED);
fUpdatedState.setToolTipText(Messages.StateConditionControl_UPDATED_INFO);
fUpdatedState.setLayoutData(new GridData(SWT.BEGINNING, SWT.CENTER, false, true));
/* State: Read */
fReadState = new Button(this, SWT.CHECK);
fReadState.setText(Messages.StateConditionControl_READ);
fReadState.setToolTipText(Messages.StateConditionControl_READ_INFO);
fReadState.setLayoutData(new GridData(SWT.BEGINNING, SWT.CENTER, false, true));
/* Selection Listener to issue modify events */