Skip to content

Instantly share code, notes, and snippets.

@adietish
Forked from fbricon/gist:7674232
Last active December 29, 2015 12:59
Show Gist options
  • Select an option

  • Save adietish/7674337 to your computer and use it in GitHub Desktop.

Select an option

Save adietish/7674337 to your computer and use it in GitHub Desktop.
private void createLink(Composite composite) {
warningArea = new Composite(composite, SWT.NONE);
warningArea.setLayoutData(new GridData(SWT.LEFT, SWT.CENTER, true, false, 2, 1));
RowLayout layout = new RowLayout();
layout.justify = false;
warningArea.setLayout(layout)
Label warningImg = new Label(warningArea, SWT.NONE);
warningImg.setImage(JFaceResources.getImage(Dialog.DLG_IMG_MESSAGE_WARNING));
link = new Link(composite, SWT.NONE);
link.addSelectionListener(new SelectionListener() {
@Override
public void widgetSelected(SelectionEvent e) {
addOutOfDateProjects();
}
@Override
public void widgetDefaultSelected(SelectionEvent e) {
addOutOfDateProjects();
}
});
}
private void updateLink(int outOfDateProjectCount) {
boolean visibility = true;
if(outOfDateProjectCount == 0) {
visibility = false;
} else if(outOfDateProjectCount > 1) {
link.setText(outOfDateProjectCount
+ " unselected projects are out of date and should be updated. <A>Click here</A> to include them."); //$NON-NLS-1$//$NON-NLS-2$
} else {
link.setText("One unselected project is out of date and should be updated. <A>Click here</A> to include it."); //$NON-NLS-1$//$NON-NLS-2$
}
warningArea.setVisible(visibility);
warningArea.getParent().layout(new Control[] {warningArea});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment