void updateCursor(Control c, int dir) {
   if (!(c instanceof Sash)) {
     Cursor cursor = null;
     switch (dir) {
       case VERTICAL:
         if (fAncestorVisible) {
           if (fVSashCursor == null) fVSashCursor = new Cursor(c.getDisplay(), SWT.CURSOR_SIZENS);
           cursor = fVSashCursor;
         } else {
           if (fNormalCursor == null) fNormalCursor = new Cursor(c.getDisplay(), SWT.CURSOR_ARROW);
           cursor = fNormalCursor;
         }
         break;
       case HORIZONTAL:
         if (fHSashCursor == null) fHSashCursor = new Cursor(c.getDisplay(), SWT.CURSOR_SIZEWE);
         cursor = fHSashCursor;
         break;
       case VERTICAL + HORIZONTAL:
         if (fAncestorVisible) {
           if (fHVSashCursor == null)
             fHVSashCursor = new Cursor(c.getDisplay(), SWT.CURSOR_SIZEALL);
           cursor = fHVSashCursor;
         } else {
           if (fHSashCursor == null) fHSashCursor = new Cursor(c.getDisplay(), SWT.CURSOR_SIZEWE);
           cursor = fHSashCursor;
         }
         break;
     }
     if (cursor != null) c.setCursor(cursor);
   }
 }
Example #2
0
 public MoveTracker(Control control) {
   this.control = control;
   cursor = new Cursor(control.getDisplay(), SWT.CURSOR_SIZEALL);
   control.setCursor(cursor);
   control.addListener(SWT.MouseDown, this);
   control.addListener(SWT.Dispose, this);
 }
  private void restoreCursor() {

    if (m_pushedCursor != null) {
      Control ctrl = getCurrentViewer().getControl();
      ctrl.setCursor(m_pushedCursor);
      m_pushedCursor = null;
    }
  }
 private void updateCursor(final String selection) {
   Cursor cursor = null;
   Class swtClass = SWT.class;
   if (selection != null) {
     try {
       Field field = swtClass.getField(selection);
       int cursorStyle = field.getInt(swtClass);
       cursor = Display.getCurrent().getSystemCursor(cursorStyle);
     } catch (Exception e) {
       e.printStackTrace();
     }
   }
   Iterator iter = controls.iterator();
   while (iter.hasNext()) {
     Control control = (Control) iter.next();
     control.setCursor(cursor);
   }
 }
  private void setCursor(int i_cursorId) {

    // save current cursor
    Control ctrl = getCurrentViewer().getControl();
    while (ctrl != null) {
      if (ctrl.getCursor() != null) {
        m_pushedCursor = ctrl.getCursor();
        break;
      }

      ctrl = ctrl.getParent();
    }

    m_pushedCursor = getCurrentViewer().getControl().getDisplay().getSystemCursor(SWT.CURSOR_ARROW);

    // hide cursor and save position
    ctrl = getCurrentViewer().getControl();
    Display display = ctrl.getDisplay();

    Cursor cursor = display.getSystemCursor(i_cursorId);
    ctrl.setCursor(cursor);
  }
Example #6
0
  /**
   * Applies a cursor to the specified SWT control. If no cursor is found for the specified id, no
   * cursor is applied.
   *
   * @param control the SWT control
   * @param cursorId the cursor id
   */
  public static void applyCursor(Control control, String cursorId) {
    Cursor cursor = getCursor(cursorId);

    // a null value sets the cursor back to the system default
    control.setCursor(cursor);
  }