Example usage for org.eclipse.swt.widgets Display getData

List of usage examples for org.eclipse.swt.widgets Display getData

Introduction

In this page you can find the example usage for org.eclipse.swt.widgets Display getData.

Prototype


public Object getData(String key) 

Source Link

Document

Returns the application defined property of the receiver with the specified name, or null if it has not been set.

Usage

From source file:org.eclipse.swt.examples.accessibility.CTable.java

static void initImages(final Display display) {
    PaletteData arrowPalette = new PaletteData(new RGB(0, 0, 0), new RGB(255, 255, 255));
    if (display.getData(ID_ARROWDOWN) == null) {
        ImageData arrowDown = new ImageData(7, 4, 1, arrowPalette, 1,
                new byte[] { 0x00, (byte) 0x83, (byte) 0xC7, (byte) 0xEF });
        arrowDown.transparentPixel = 0x1; /* use white for transparency */
        display.setData(ID_ARROWDOWN, new Image(display, arrowDown));
    }//from w  ww . j  ava  2  s .  com
    if (display.getData(ID_ARROWUP) == null) {
        ImageData arrowUp = new ImageData(7, 4, 1, arrowPalette, 1,
                new byte[] { (byte) 0xEF, (byte) 0xC7, (byte) 0x83, 0x00 });
        arrowUp.transparentPixel = 0x1; /* use white for transparency */
        display.setData(ID_ARROWUP, new Image(display, arrowUp));
    }

    PaletteData checkMarkPalette = new PaletteData(new RGB(0, 0, 0), new RGB(252, 3, 251));
    byte[] checkbox = new byte[] { 0, 0, 127, -64, 127, -64, 127, -64, 127, -64, 127, -64, 127, -64, 127, -64,
            127, -64, 127, -64, 0, 0 };
    ImageData checkmark = new ImageData(7, 7, 1, checkMarkPalette, 1,
            new byte[] { -4, -8, 112, 34, 6, -114, -34 });
    checkmark.transparentPixel = 1;
    if (display.getData(ID_CHECKMARK) == null) {
        display.setData(ID_CHECKMARK, new Image(display, checkmark));
    }

    if (display.getData(ID_UNCHECKED) == null) {
        PaletteData uncheckedPalette = new PaletteData(new RGB(128, 128, 128), new RGB(255, 255, 255));
        ImageData unchecked = new ImageData(11, 11, 1, uncheckedPalette, 2, checkbox);
        display.setData(ID_UNCHECKED, new Image(display, unchecked));
    }

    if (display.getData(ID_GRAYUNCHECKED) == null) {
        PaletteData grayUncheckedPalette = new PaletteData(new RGB(128, 128, 128), new RGB(192, 192, 192));
        ImageData grayUnchecked = new ImageData(11, 11, 1, grayUncheckedPalette, 2, checkbox);
        display.setData(ID_GRAYUNCHECKED, new Image(display, grayUnchecked));
    }

    display.disposeExec(() -> {
        Image unchecked = (Image) display.getData(ID_UNCHECKED);
        if (unchecked != null)
            unchecked.dispose();
        Image grayUnchecked = (Image) display.getData(ID_GRAYUNCHECKED);
        if (grayUnchecked != null)
            grayUnchecked.dispose();
        Image checkmark1 = (Image) display.getData(ID_CHECKMARK);
        if (checkmark1 != null)
            checkmark1.dispose();
        Image arrowDown = (Image) display.getData(ID_ARROWDOWN);
        if (arrowDown != null)
            arrowDown.dispose();
        Image arrowUp = (Image) display.getData(ID_ARROWUP);
        if (arrowUp != null)
            arrowUp.dispose();

        display.setData(ID_UNCHECKED, null);
        display.setData(ID_GRAYUNCHECKED, null);
        display.setData(ID_CHECKMARK, null);
        display.setData(ID_ARROWDOWN, null);
        display.setData(ID_ARROWUP, null);
    });
}