Exemple #1
0
 private static void renderFocus(Display display) {
   if (!display.isDisposed()) {
     IDisplayAdapter displayAdapter = getDisplayAdapter(display);
     RemoteAdapter widgetAdapter = getAdapter(display);
     Object oldValue = widgetAdapter.getPreserved(PROP_FOCUS_CONTROL);
     if (!widgetAdapter.isInitialized()
         || oldValue != display.getFocusControl()
         || displayAdapter.isFocusInvalidated()) {
       // TODO [rst] Added null check as a NPE occurred in some rare cases
       Control focusControl = display.getFocusControl();
       if (focusControl != null) {
         getRemoteObject(display).set(PROP_FOCUS_CONTROL, getId(display.getFocusControl()));
       }
     }
   }
 }
 @Override
 public boolean canPaste(Clipboard clipboard) {
   Display d = getSection().getDisplay();
   Control c = d.getFocusControl();
   if (c instanceof Text) return true;
   return false;
 }
  /** {@inheritDoc} */
  public void run() {
    Display display = Display.getCurrent();
    if (display == null) return;
    Control focus = display.getFocusControl();
    if (focus == null || focus.isDisposed()) return;

    MenuManager menu = new MenuManager();
    fillMenu(menu);
    final Menu widget = menu.createContextMenu(focus.getShell());
    Point location = computeMenuLocation(focus, widget);
    if (location == null) return;
    widget.setLocation(location);
    widget.setVisible(true);
    while (!widget.isDisposed() && widget.isVisible()) {
      if (!display.readAndDispatch()) display.sleep();
    }
    if (!widget.isDisposed()) {
      widget.dispose();
    }
  }
Exemple #4
0
 @Override
 public void preserveValues(Display display) {
   RemoteAdapter adapter = getAdapter(display);
   adapter.preserve(PROP_FOCUS_CONTROL, display.getFocusControl());
   adapter.preserve(PROP_EXIT_CONFIRMATION, getExitConfirmation());
   adapter.preserve(PROP_RESIZE_LISTENER, Boolean.valueOf(hasResizeListener(display)));
   ActiveKeysUtil.preserveActiveKeys(display);
   ActiveKeysUtil.preserveCancelKeys(display);
   ActiveKeysUtil.preserveMnemonicActivator(display);
   if (adapter.isInitialized()) {
     for (Shell shell : getShells(display)) {
       WidgetTreeVisitor.accept(
           shell,
           new AllWidgetTreeVisitor() {
             @Override
             public boolean doVisit(Widget widget) {
               getLCA(widget).preserveValues(widget);
               return true;
             }
           });
     }
   }
 }
 @Override
 public boolean canPaste(Clipboard clipboard) {
   Display d = getSection().getDisplay();
   return d.getFocusControl() instanceof Text;
 }