예제 #1
0
파일: SWTEvents.java 프로젝트: xored/rcptt
  public synchronized void sendUnfocus(Widget widget) {
    if (widget.isDisposed()) {
      return;
    }
    if (!(widget instanceof Control)) {
      return;
    }
    Control ctrl = (Control) widget;
    boolean sendUnfocus = TeslaCellEditorManager.getInstance().getEditors().length > 0;

    if (!sendUnfocus) {
      if (ctrl.isFocusControl() || widget == lastFocusControl) {
        if (!ctrl.isDisposed()) {
          sendEvent(ctrl, SWT.FocusOut);
        }
        if (!ctrl.isDisposed()) {
          sendEvent(ctrl, SWT.Deactivate);
        }
        if (!ctrl.isDisposed()) {
          sendEvent(ctrl, SWT.MouseMove);
        }
        if (!ctrl.isDisposed()) {
          sendEvent(ctrl, SWT.MouseExit);
        }
      }
      lastFocusControl = null;
      TeslaEventManager.getManager().setForceFocusControl(null);
    }
  }
예제 #2
0
파일: SWTEvents.java 프로젝트: xored/rcptt
  public synchronized void sendFocus(Widget widget) {
    if (widget.isDisposed()) {
      return;
    }
    if (!(widget instanceof Control)) {
      return;
    }
    Control ctrl = (Control) widget;

    boolean sendUnfocus = TeslaCellEditorManager.getInstance().getEditors().length > 0;

    if (sendUnfocus) {
      if (ctrl != lastFocusControl) {
        // new focus control
        // send focusOut for real last focused control
        if (ctrl == lastFocusControl) {
          return;
        }
        if (lastFocusControl != null && !lastFocusControl.isDisposed()) {
          if (lastFocusControl.isFocusControl()) {
            sendEvent(lastFocusControl, SWT.FocusOut);
            if (!lastFocusControl.isDisposed()) {
              sendEvent(lastFocusControl, SWT.Deactivate);
            }
            if (!lastFocusControl.isDisposed()) {
              sendEvent(lastFocusControl, SWT.MouseExit);
            }
          }
        }
        lastFocusControl = ctrl;
        if (!ctrl.isFocusControl()) {
          ctrl.setFocus();
          sendEvent(lastFocusControl, SWT.MouseEnter);
          sendEvent(lastFocusControl, SWT.MouseMove);
          sendEvent(lastFocusControl, SWT.Activate);
          sendEvent(lastFocusControl, SWT.FocusIn);
        }
      }
    } else {
      // ctrl.getShell().forceActive();
      if (!ctrl.isFocusControl()) {
        try {
          ShellUtilsProvider.getShellUtils().forceActive(ctrl.getShell());
        } catch (CoreException e) {
          throw new RuntimeException(e);
        }
        ctrl.setFocus();
        ctrl.forceFocus();
        sendEvent(ctrl, SWT.MouseEnter);
        sendEvent(ctrl, SWT.MouseMove);
        sendEvent(ctrl, SWT.Activate);
        sendEvent(ctrl, SWT.FocusIn);
      }
      lastFocusControl = ctrl;
    }
  }