Java Code Examples for org.eclipse.swt.custom.CLabel#setToolTipText()

The following examples show how to use org.eclipse.swt.custom.CLabel#setToolTipText() . 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: TmfEventsTableHeader.java    From tracecompass with Eclipse Public License 2.0 6 votes vote down vote up
private void toggle() {
    fCollapsed = !fCollapsed;
    for (Control child : getChildren()) {
        if (child instanceof CLabel) {
            CLabel label = (CLabel) child;
            if (fCollapsed) {
                label.setImage(null);
                label.setToolTipText(label.getText());
                label.setText(null);
                label.setMargins(DEFAULT_MARGIN, 0, COLLAPSED_RIGHT_MARGIN, 0);
            } else {
                label.setImage(DELETE);
                label.setText(label.getToolTipText());
                label.setToolTipText((String) label.getData(TOOLTIP_KEY));
                label.setMargins(DEFAULT_MARGIN, DEFAULT_MARGIN, DEFAULT_MARGIN, DEFAULT_MARGIN);
            }
        }
    }
    getParent().layout();
}
 
Example 2
Source File: ComponentRiskThresholds.java    From arx with Apache License 2.0 6 votes vote down vote up
/**
 * Creates a label for a knob
 * @param root
 * @param knob
 */
private CLabel createLabel(final Composite root, 
                           final Knob<Double> knob) {

    // Label
    String text = "100%"; //$NON-NLS-1$
    final CLabel label = new CLabel(root, SWT.NONE);
    label.setText(text);
    label.setAlignment(SWT.LEFT);
    label.setLayoutData(SWTUtil.createFillGridData());
    label.setToolTipText(text);
    
    // Listen
    knob.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(SelectionEvent arg0) {
            updateLabel(knob, label);
        }
    });
    
    // Return
    return label;
}
 
Example 3
Source File: XYGraphConfigDialog.java    From nebula with Eclipse Public License 2.0 5 votes vote down vote up
private void addMaxWarningMessage(Composite composite, String type) {
	final CLabel warning = new CLabel(composite, SWT.NONE);
	warning.setText("There are too many " + type + " to edit");
	warning.setToolTipText("Currently only the first " + MAX_CONFIG_PAGE_COUNT + " " + type
			+ " can have their properties manually edited.\n"
			+ "This is due to a limitation with the current widget design on the configure form.\n"
			+ "Please see Bug 514179 for more details.");
	warning.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false));
	warning.setImage(XYGraphMediaFactory.getInstance().getImage("images/warning.png"));
}
 
Example 4
Source File: ComponentRiskThresholds.java    From arx with Apache License 2.0 5 votes vote down vote up
/**
 * Creates a label
 * @param root
 * @param text
 */
private void createLabel(Composite root, String text) {

    // Label
    CLabel label = new CLabel(root, SWT.CENTER);
    label.setText(text);
    label.setLayoutData(SWTUtil.createFillHorizontallyGridData(true, 2));
    label.setToolTipText(text);
}
 
Example 5
Source File: ComponentRiskMonitor.java    From arx with Apache License 2.0 4 votes vote down vote up
/**
 * Creates a new instance
 * @param parent
 * @param controller
 * @param text
 * @param shortText
 */
public ComponentRiskMonitor(final Composite parent, 
                            final Controller controller,
                            final String text, 
                            final String shortText) {
    
    // Images
    imageLow = controller.getResources().getManagedImage("bullet_green.png"); //$NON-NLS-1$
    imageHigh = controller.getResources().getManagedImage("bullet_red.png"); //$NON-NLS-1$
    
    // Layout
    GridLayout layout = SWTUtil.createGridLayout(1);
    layout.marginHeight = 0;
    layout.marginTop = 0;
    layout.marginBottom = 0;
    layout.verticalSpacing = 0;
    
    // Root
    this.root = new Composite(parent, SWT.NONE);
    this.root.setLayout(layout);
    this.root.setToolTipText(text);
    
    // Caption
    this.caption = new CLabel(root, SWT.CENTER);
    this.caption.setText(shortText);
    this.caption.setLayoutData(SWTUtil.createFillHorizontallyGridData());
    this.caption.setToolTipText(text);
    this.caption.setImage(imageHigh);
    SWTUtil.changeFont(caption, SWT.BOLD);
    
    // Content
    Composite content = new Composite(root, SWT.NONE);
    content.setLayoutData(SWTUtil.createFillGridData());
    content.setToolTipText(text);

    // Create meter
    Canvas canvas = new Canvas(content, SWT.DOUBLE_BUFFERED);
    canvas.setToolTipText(text);
    this.meter = new ComponentMeterFigure();
    this.meter.setNeedleColor(XYGraphMediaFactory.getInstance().getColor(0, 0, 0));
    this.meter.setValueLabelVisibility(true);
    this.meter.setRange(new Range(0, 100));
    this.meter.setLoLevel(0);
    this.meter.setLoColor(XYGraphMediaFactory.getInstance().getColor(0, 150, 0));
    this.meter.setLoloLevel(25);
    this.meter.setLoloColor(XYGraphMediaFactory.getInstance().getColor(255, 255, 0));
    this.meter.setHiLevel(50);
    this.meter.setHiColor(XYGraphMediaFactory.getInstance().getColor(255, 200, 25));
    this.meter.setHihiLevel(100);
    this.meter.setHihiColor(XYGraphMediaFactory.getInstance().getColor(255, 0, 0));
    this.meter.setMajorTickMarkStepHint(50);
    LightweightSystem lws = new LightweightSystem(canvas);
    lws.setContents(this.meter);
    
    // Create label
    label = new CLabel(content, SWT.CENTER);
    label.setLayoutData(SWTUtil.createFillHorizontallyGridData());
    label.setToolTipText(text);
    
    // Create responsive layout
    new ComponentResponsiveLayout(content, 100, 50, canvas, label);
}
 
Example 6
Source File: ComponentRiskThresholds.java    From arx with Apache License 2.0 4 votes vote down vote up
/**
 * Updates the value on the label
 * @param knob
 * @param label
 */
private void updateLabel(Knob<Double> knob, CLabel label) {
    String text = SWTUtil.getPrettyString(knob.getValue())+"%"; //$NON-NLS-1$
    label.setText(text);
    label.setToolTipText(text);
}