Java Code Examples for org.eclipse.swt.widgets.Label#addDisposeListener()

The following examples show how to use org.eclipse.swt.widgets.Label#addDisposeListener() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: LabelImageLoader.java    From google-cloud-eclipse with Apache License 2.0 5 votes vote down vote up
/**
 * Loads an image to a {@link Label}. The image will be fetched from {@code imageUrl}
 * asynchronously if not previously cached.
 *
 * Must be called in the UI context.
 */
@VisibleForTesting
public void loadImage(String imageUrl, Label label) throws MalformedURLException {
  Preconditions.checkNotNull(imageUrl);

  ImageData imageData = cache.get(imageUrl);
  if (imageData != null) {
    Image image = new Image(label.getDisplay(), imageData);
    label.addDisposeListener(new ImageDisposer(image));
    label.setImage(image);
  } else {
    loadJob = new LabelImageLoadJob(new URL(imageUrl), label);
    loadJob.schedule();
  }
}
 
Example 2
Source File: AddAnalysisDialog.java    From tracecompass with Eclipse Public License 2.0 5 votes vote down vote up
private static void createSubtitleLabel(Composite parent, String text) {
    final Label label = new Label(parent, SWT.WRAP);
    label.setText(text + ':');
    final FontDescriptor boldDescriptor = FontDescriptor.createFrom(parent.getFont()).setStyle(SWT.BOLD);
    final Font boldFont = boldDescriptor.createFont(parent.getDisplay());
    label.setFont(boldFont);
    label.addDisposeListener(event -> boldDescriptor.destroyFont(boldFont));
}
 
Example 3
Source File: AddAnalysisDialog.java    From tracecompass with Eclipse Public License 2.0 5 votes vote down vote up
private static Label createErrorLabel(Composite parent) {
    final Label label = new Label(parent, SWT.WRAP);
    Color color = new Color(parent.getDisplay(), 0xe7, 0x4c, 0x3c);
    label.setForeground(color);
    final FontDescriptor fd = FontDescriptor.createFrom(parent.getFont());
    Font font = fd.createFont(parent.getDisplay());
    label.setFont(font);

    label.addDisposeListener(e -> {
        color.dispose();
        fd.destroyFont(font);
    });

    return label;
}
 
Example 4
Source File: AttributesEditorsView.java    From gama with GNU General Public License v3.0 5 votes vote down vote up
public void addEditor(final AbstractEditor<?> editor) {
	editor.createComposite(this);
	final Label label = editor.getLabel();
	if (label != null) {
		// ((GridData) label.getLayoutData()).heightHint = 36;
		labels.add(label);
		label.addDisposeListener(e -> labels.remove(label));
	}
}
 
Example 5
Source File: ImageSection.java    From olca-app with Mozilla Public License 2.0 5 votes vote down vote up
private void createControls(File f) {
	Label header = tk.createLabel(comp, Strings.cut(f.getName(), 40));
	header.setToolTipText(f.getName());
	UI.gridData(header, false, false).verticalAlignment = SWT.BEGINNING;
	controls.add(header);
	Image img = new Image(comp.getDisplay(), f.getAbsolutePath());
	Label lab = tk.createLabel(comp, "");
	lab.setImage(img);
	lab.addDisposeListener(e -> {
		if (!img.isDisposed()) {
			img.dispose();
		}
	});
	controls.add(lab);
}