Search in sources :

Example 31 with Cursor

use of org.eclipse.swt.graphics.Cursor in project eclipse.platform.swt by eclipse.

the class AddressBook method findEntry.

private boolean findEntry() {
    Cursor waitCursor = shell.getDisplay().getSystemCursor(SWT.CURSOR_WAIT);
    shell.setCursor(waitCursor);
    boolean matchCase = searchDialog.getMatchCase();
    boolean matchWord = searchDialog.getMatchWord();
    String searchString = searchDialog.getSearchString();
    int column = searchDialog.getSelectedSearchArea();
    searchString = matchCase ? searchString : searchString.toLowerCase();
    boolean found = false;
    if (searchDialog.getSearchDown()) {
        for (int i = table.getSelectionIndex() + 1; i < table.getItemCount(); i++) {
            if (found = findMatch(searchString, table.getItem(i), column, matchWord, matchCase)) {
                table.setSelection(i);
                break;
            }
        }
    } else {
        for (int i = table.getSelectionIndex() - 1; i > -1; i--) {
            if (found = findMatch(searchString, table.getItem(i), column, matchWord, matchCase)) {
                table.setSelection(i);
                break;
            }
        }
    }
    shell.setCursor(null);
    return found;
}
Also used : Cursor(org.eclipse.swt.graphics.Cursor)

Example 32 with Cursor

use of org.eclipse.swt.graphics.Cursor in project eclipse.platform.swt by eclipse.

the class Test_org_eclipse_swt_widgets_Control method test_setCursorLorg_eclipse_swt_graphics_Cursor.

@Test
public void test_setCursorLorg_eclipse_swt_graphics_Cursor() {
    control.setCursor(null);
    Cursor c = new Cursor(control.getDisplay(), 0);
    control.setCursor(c);
    c.dispose();
}
Also used : Cursor(org.eclipse.swt.graphics.Cursor) Test(org.junit.Test)

Example 33 with Cursor

use of org.eclipse.swt.graphics.Cursor in project yamcs-studio by yamcs.

the class SWTResourceManager method getCursor.

/**
 * Returns the system cursor matching the specific ID.
 *
 * @param id
 *            int The ID value for the cursor
 * @return Cursor The system cursor matching the specific ID
 */
public static Cursor getCursor(int id) {
    Integer key = Integer.valueOf(id);
    Cursor cursor = m_idToCursorMap.get(key);
    if (cursor == null) {
        cursor = new Cursor(Display.getDefault(), id);
        m_idToCursorMap.put(key, cursor);
    }
    return cursor;
}
Also used : Cursor(org.eclipse.swt.graphics.Cursor)

Example 34 with Cursor

use of org.eclipse.swt.graphics.Cursor in project cubrid-manager by CUBRID.

the class AboutDialog method createDialogArea.

/**
	 * Creates the page content
	 *
	 * @param parent the parent composite to contain the dialog area
	 * @return the dialog area control
	 */
protected Control createDialogArea(Composite parent) {
    final Cursor hand = new Cursor(parent.getDisplay(), SWT.CURSOR_HAND);
    final Cursor busy = new Cursor(parent.getDisplay(), SWT.CURSOR_WAIT);
    setHandCursor(hand);
    setBusyCursor(busy);
    getShell().addDisposeListener(new DisposeListener() {

        public void widgetDisposed(DisposeEvent event) {
            setHandCursor(null);
            hand.dispose();
            setBusyCursor(null);
            busy.dispose();
        }
    });
    // brand the about box if there is product info
    Image aboutImage = null;
    if (product != null && aboutImageDescriptor != null) {
        aboutImage = aboutImageDescriptor.createImage();
    }
    Composite workArea = new Composite(parent, SWT.NONE);
    GridLayout workLayout = new GridLayout();
    workLayout.marginHeight = 0;
    workLayout.marginWidth = 0;
    workLayout.verticalSpacing = 0;
    workLayout.horizontalSpacing = 0;
    workArea.setLayout(workLayout);
    workArea.setLayoutData(new GridData(GridData.FILL_BOTH));
    // page group
    Color background = JFaceColors.getBannerBackground(parent.getDisplay());
    Color foreground = JFaceColors.getBannerForeground(parent.getDisplay());
    Composite top = (Composite) super.createDialogArea(workArea);
    // override any layout inherited from createDialogArea
    GridLayout layout = new GridLayout();
    layout.marginHeight = 0;
    layout.marginWidth = 0;
    layout.verticalSpacing = 0;
    layout.horizontalSpacing = 0;
    top.setLayout(layout);
    top.setLayoutData(new GridData(GridData.FILL_BOTH));
    top.setBackground(background);
    top.setForeground(foreground);
    // the image & text
    Composite topContainer = new Composite(top, SWT.NONE);
    topContainer.setBackground(background);
    topContainer.setForeground(foreground);
    layout = new GridLayout();
    layout.numColumns = (aboutImage == null || getItem() == null ? 1 : 2);
    layout.marginWidth = 0;
    layout.marginHeight = 0;
    layout.verticalSpacing = 0;
    layout.horizontalSpacing = 0;
    topContainer.setLayout(layout);
    GridData data = new GridData();
    data.horizontalAlignment = GridData.FILL;
    data.grabExcessHorizontalSpace = true;
    topContainer.setLayoutData(data);
    // image on left side of dialog
    if (aboutImage != null) {
        Label imageLabel = new Label(topContainer, SWT.NONE);
        imageLabel.setBackground(background);
        imageLabel.setForeground(foreground);
        data = new GridData();
        data.horizontalAlignment = GridData.FILL;
        data.verticalAlignment = GridData.BEGINNING;
        data.grabExcessHorizontalSpace = false;
        imageLabel.setLayoutData(data);
        imageLabel.setImage(aboutImage);
    }
    if (getItem() != null) {
        Composite textContainer = new Composite(topContainer, SWT.NONE);
        textContainer.setBackground(background);
        textContainer.setForeground(foreground);
        layout = new GridLayout();
        layout.numColumns = 1;
        textContainer.setLayout(layout);
        data = new GridData();
        data.horizontalAlignment = GridData.FILL;
        data.verticalAlignment = GridData.BEGINNING;
        data.grabExcessHorizontalSpace = true;
        textContainer.setLayoutData(data);
        // text on the right
        text = new StyledText(textContainer, SWT.MULTI | SWT.READ_ONLY);
        text.setCaret(null);
        text.setFont(parent.getFont());
        data = new GridData();
        data.horizontalAlignment = GridData.FILL;
        data.verticalAlignment = GridData.BEGINNING;
        data.grabExcessHorizontalSpace = true;
        text.setText(getItem().getText());
        text.setLayoutData(data);
        text.setCursor(null);
        text.setBackground(background);
        text.setForeground(foreground);
        setLinkRanges(text, getItem().getLinkRanges());
        addListeners(text);
    }
    // horizontal bar
    Label bar = new Label(workArea, SWT.HORIZONTAL | SWT.SEPARATOR);
    data = new GridData();
    data.horizontalAlignment = GridData.FILL;
    bar.setLayoutData(data);
    // add image buttons for bundle groups that have them
    Composite bottom = (Composite) super.createDialogArea(workArea);
    // override any layout inherited from createDialogArea
    layout = new GridLayout();
    bottom.setLayout(layout);
    bottom.setLayoutData(new GridData(GridData.FILL_BOTH));
    // spacer
    bar = new Label(bottom, SWT.NONE);
    data = new GridData();
    data.horizontalAlignment = GridData.FILL;
    bar.setLayoutData(data);
    return workArea;
}
Also used : DisposeListener(org.eclipse.swt.events.DisposeListener) GridLayout(org.eclipse.swt.layout.GridLayout) StyledText(org.eclipse.swt.custom.StyledText) Composite(org.eclipse.swt.widgets.Composite) Color(org.eclipse.swt.graphics.Color) GridData(org.eclipse.swt.layout.GridData) Label(org.eclipse.swt.widgets.Label) Cursor(org.eclipse.swt.graphics.Cursor) DisposeEvent(org.eclipse.swt.events.DisposeEvent) Image(org.eclipse.swt.graphics.Image)

Example 35 with Cursor

use of org.eclipse.swt.graphics.Cursor in project cogtool by cogtool.

the class WindowUtil method getClosedHandCursor.

public static Cursor getClosedHandCursor() {
    if (CLOSED_HAND_CURSOR == null) {
        ImageData curData = GraphicsUtil.getImageDataFromResource("edu/cmu/cs/hcii/cogtool/resources/closed_hand.gif");
        if (curData == null) {
            return null;
        }
        CLOSED_HAND_CURSOR = new Cursor(GLOBAL_DISPLAY, curData, 8, 8);
    }
    return CLOSED_HAND_CURSOR;
}
Also used : ImageData(org.eclipse.swt.graphics.ImageData) Cursor(org.eclipse.swt.graphics.Cursor)

Aggregations

Cursor (org.eclipse.swt.graphics.Cursor)64 DisposeEvent (org.eclipse.swt.events.DisposeEvent)26 DisposeListener (org.eclipse.swt.events.DisposeListener)26 Image (org.eclipse.swt.graphics.Image)24 GridData (org.eclipse.swt.layout.GridData)23 SelectionEvent (org.eclipse.swt.events.SelectionEvent)22 ToolBar (org.eclipse.swt.widgets.ToolBar)22 SelectionAdapter (org.eclipse.swt.events.SelectionAdapter)21 ToolItem (org.eclipse.swt.widgets.ToolItem)20 ImageData (org.eclipse.swt.graphics.ImageData)8 Composite (org.eclipse.swt.widgets.Composite)8 SWTException (org.eclipse.swt.SWTException)7 Point (org.eclipse.swt.graphics.Point)7 Test (org.junit.Test)6 InputStream (java.io.InputStream)5 SWTError (org.eclipse.swt.SWTError)5 ImageLoader (org.eclipse.swt.graphics.ImageLoader)5 FileDialog (org.eclipse.swt.widgets.FileDialog)5 IOException (java.io.IOException)4 URL (java.net.URL)4