コード例 #1
0
 private Point computeMenuLocation(Control focus, Menu menu) {
   Point cursorLocation = focus.getDisplay().getCursorLocation();
   Rectangle clientArea = null;
   Point result = null;
   if (focus instanceof StyledText) {
     StyledText styledText = (StyledText) focus;
     clientArea = styledText.getClientArea();
     result = computeMenuLocation(styledText);
   } else if (focus instanceof Tree) {
     Tree tree = (Tree) focus;
     clientArea = tree.getClientArea();
     result = computeMenuLocation(tree);
   } else if (focus instanceof Table) {
     Table table = (Table) focus;
     clientArea = table.getClientArea();
     result = computeMenuLocation(table);
   }
   if (result == null) {
     result = focus.toControl(cursorLocation);
   }
   if (clientArea != null && !clientArea.contains(result)) {
     result = new Point(clientArea.x + clientArea.width / 2, clientArea.y + clientArea.height / 2);
   }
   Rectangle shellArea = focus.getShell().getClientArea();
   if (!shellArea.contains(focus.getShell().toControl(focus.toDisplay(result)))) {
     result = new Point(shellArea.x + shellArea.width / 2, shellArea.y + shellArea.height / 2);
   }
   return focus.toDisplay(result);
 }
コード例 #2
0
  private void addOwnerShellListener() {

    final Shell ownerShell = _ownerControl.getShell();

    ownerShell.addListener(SWT.Deactivate, _ownerShellListener);
    ownerShell.addListener(SWT.Move, _ownerShellListener);
  }
コード例 #3
0
  private Object aboutToStart(boolean cancelable) {
    Map savedState = null;
    Shell shell = getShell();
    if (shell != null) {
      // Save focus control
      Control focusControl = getShell().getDisplay().getFocusControl();
      if (focusControl != null && focusControl.getShell() != getShell()) focusControl = null;

      Button cancelButton = getButton(IDialogConstants.CANCEL_ID);
      // Set the busy cursor to all shells.
      Display d = getShell().getDisplay();
      setDisplayCursor(d, d.getSystemCursor(SWT.CURSOR_WAIT));

      // Set the arrow cursor to the cancel component.
      cancelButton.setCursor(d.getSystemCursor(SWT.CURSOR_ARROW));

      boolean hasProgressMonitor = fProgressMonitorPart != null;

      // Deactivate shell
      savedState = saveUIState(false);
      if (focusControl != null) savedState.put("focus", focusControl); // $NON-NLS-1$

      if (hasProgressMonitor) {
        if (cancelable) fProgressMonitorPart.attachToCancelComponent(cancelButton);
        fStatusContainer.showPage(fProgressMonitorPart);
      }
      // Update the status container since we are blocking the event loop right now.
      fStatusContainer.update();
    }
    return savedState;
  }
コード例 #4
0
  public void update() {

    tick++;
    if (tick == 2) {
      internal =
          new LinkedHashSet<Class>(
              ((MyClassLoader) Trampoline2.trampoline.getClassLoader()).getAllLoadedClasses());
      ; // ;//System.out.println(" ----------- reload plugin ----------");
      populateTree();
    } else if (tick > 2) {

      Control c = Launcher.display.getFocusControl();
      if (c == null) return;
      Shell s = c.getShell();
      if (s.getText().trim().length() == 0) return;

      Set<Class> allClass =
          ((MyClassLoader) Trampoline2.trampoline.getClassLoader()).getAllLoadedClasses();
      int hashNow = allClass.hashCode();
      if (hashNow != hashWas && willRep < 0) {
        willRep = 5;
      }
    }

    willRep--;
    if (willRep == 0) {
      populateTree();
    }
  }
    protected Object openDialogBox(Control cellEditorWindow) {
      ValueDialog vd = new ValueDialog(cellEditorWindow.getShell());
      vd.setValue((DatabaseQuerySettingsStructure.DataMapping) this.getValue());
      vd.open();

      return this.getValue();
    }
コード例 #6
0
  @Override
  public Shell getShell() {
    if (targetControl instanceof Shell) {
      return (Shell) targetControl;
    }

    return targetControl == null ? null : targetControl.getShell();
  }
コード例 #7
0
ファイル: TaskTableView.java プロジェクト: merks/cdo
 public Font getBoldFont() {
   Control control = viewer.getControl();
   FontData[] datas = control.getFont().getFontData().clone();
   datas[0].setStyle(SWT.BOLD);
   Display display = control.getShell().getDisplay();
   Font font = new Font(display, datas);
   return font;
 }
  @Override
  protected Object openDialogBox(Control cellEditorWindow) {
    if (mUiFlagAttribute != null) {
      String currentValue = (String) getValue();
      return mUiFlagAttribute.showDialog(cellEditorWindow.getShell(), currentValue);
    }

    return null;
  }
コード例 #9
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;
    }
  }
コード例 #10
0
  @Override
  protected Object openDialogBox(Control cellEditorWindow) {
    HTMLEditor dialog = new HTMLEditor(cellEditorWindow.getShell(), richText);
    int x = dialog.open();
    if (x == Window.OK) {
      return dialog.getValue();
    }

    return getValue();
  }
コード例 #11
0
 /* (non-Javadoc)
  * @see org.eclipse.jface.viewers.DialogCellEditor#openDialogBox(org.eclipse.swt.widgets.Control)
  */
 protected Object openDialogBox(Control cellEditorWindow) {
   FontDialog dialog = new FontDialog(cellEditorWindow.getShell());
   dialog.setText(MessageUtil.getString("FontDialogTitle"));
   if (getValue() != null) {
     FontData[] oldFont = new FontData[] {new FontData(getValue().toString(), 12, SWT.NORMAL)};
     dialog.setFontList(oldFont);
   }
   FontData fontData = dialog.open();
   if (fontData != null) return fontData.getName();
   return "";
 }
コード例 #12
0
ファイル: NotesPopup.java プロジェクト: Bluelich/xmind
 public void hook(Control control) {
   control.getDisplay().addFilter(SWT.KeyDown, this);
   control
       .getShell()
       .addDisposeListener(
           new DisposeListener() {
             public void widgetDisposed(DisposeEvent e) {
               if (!e.display.isDisposed()) {
                 e.display.removeFilter(SWT.KeyDown, PopupKeyboardListener.this);
               }
             }
           });
 }
コード例 #13
0
 private boolean acceptEvent(final Event event) {
   // check that this is the latest event
   final boolean isCurrent = event.time > lastEventTime;
   // 282089: check this window is has the focus, to avoid scrolling when
   // the mouse pointer happens to be over another overlapping window
   final Control control = (Control) event.widget;
   final boolean isActive = control.getShell() == getActiveShell();
   // 282091: check that this navigation component is visible. Since
   // we are using a display filter the navigation componentes of _each_
   // subapplicatio are notified when scrolling!
   final boolean isVisible = getNavigationComponent().isVisible();
   return isCurrent && isActive && isVisible;
 }
コード例 #14
0
ファイル: FXFillCellEditor.java プロジェクト: psuzzi/gef4
 @Override
 protected Object openDialogBox(Control cellEditorWindow) {
   FXFillSelectionDialog dialog =
       new FXFillSelectionDialog(cellEditorWindow.getShell(), "Select Fill");
   Object value = getValue();
   if (value != null) {
     dialog.setPaint((Paint) value);
   }
   int result = dialog.open();
   if (result == Dialog.CANCEL) {
     return value;
   } else {
     return dialog.getPaint();
   }
 }
コード例 #15
0
        public void handleEvent(Event event) {
          MUIElement changedElement = (MUIElement) event.getProperty(UIEvents.EventTags.ELEMENT);
          MUIElement parent = changedElement.getParent();
          if (parent == null) {
            parent = (MUIElement) ((EObject) changedElement).eContainer();
            if (parent == null) {
              return;
            }
          }

          AbstractPartRenderer renderer = (AbstractPartRenderer) parent.getRenderer();
          if (renderer == null || parent instanceof MToolBar) return;

          // Re-parent the control based on the visible state
          if (changedElement.isVisible()) {
            if (changedElement.isToBeRendered()) {
              if (changedElement.getWidget() instanceof Control) {
                // Ensure that the control is under its 'real' parent if
                // it's visible
                Composite realComp = (Composite) renderer.getUIContainer(changedElement);
                Control ctrl = (Control) changedElement.getWidget();
                ctrl.setParent(realComp);
                fixZOrder(changedElement);
              }

              if (parent instanceof MElementContainer<?>) {
                renderer.childRendered((MElementContainer<MUIElement>) parent, changedElement);
              }
            }
          } else {
            // Put the control under the 'limbo' shell
            if (changedElement.getWidget() instanceof Control) {
              Control ctrl = (Control) changedElement.getWidget();

              if (!(ctrl instanceof Shell)) {
                ctrl.getShell().layout(new Control[] {ctrl}, SWT.DEFER);
              }

              ctrl.setParent(getLimboShell());
            }

            if (parent instanceof MElementContainer<?>) {
              renderer.hideChild((MElementContainer<MUIElement>) parent, changedElement);
            }
          }
        }
コード例 #16
0
  /** {@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();
    }
  }
コード例 #17
0
  protected void fixZOrder(MUIElement element) {
    MElementContainer<MUIElement> parent = element.getParent();
    if (parent == null) {
      Object container = ((EObject) element).eContainer();
      if (container instanceof MElementContainer<?>) {
        parent = (MElementContainer<MUIElement>) container;
      }
    }
    if (parent == null || !(element.getWidget() instanceof Control)) return;

    Control elementCtrl = (Control) element.getWidget();
    Control prevCtrl = null;
    for (MUIElement kid : parent.getChildren()) {
      if (kid == element) {
        if (prevCtrl != null) elementCtrl.moveBelow(prevCtrl);
        else elementCtrl.moveAbove(null);
        break;
      } else if (kid.getWidget() instanceof Control) {
        prevCtrl = (Control) kid.getWidget();
      }
    }

    Object widget = parent.getWidget();
    if (widget instanceof Composite) {
      Composite composite = (Composite) widget;
      if (composite.getShell() == elementCtrl.getShell()) {
        Composite temp = elementCtrl.getParent();
        while (temp != composite) {
          if (temp == null) {
            return;
          }
          temp = temp.getParent();
        }

        composite.layout(true, true);
      }
    }
  }
コード例 #18
0
ファイル: PopupMenu.java プロジェクト: daicaheb/nutch-bbcore
 public Shell getShell() {
   if (control.isDisposed()) return null;
   if (control instanceof Shell) return (Shell) control;
   return control.getShell();
 }
コード例 #19
0
ファイル: PopupMenu.java プロジェクト: daicaheb/nutch-bbcore
  public void open() {
    if (screenPos == null) screenPos = Display.getDefault().getCursorLocation();
    leftScreenPos = screenPos;
    popupRight = true;
    if (control == null || control.isDisposed()) return;
    control.addDisposeListener(
        new DisposeListener() {

          public void widgetDisposed(DisposeEvent e) {
            dispose();
          }
        });
    final ShellListener shellListener =
        new ShellAdapter() {

          public void shellClosed(ShellEvent e) {
            hideMenu();
          }

          public void shellDeactivated(ShellEvent e) {
            hideMenu();
          }

          public void shellIconified(ShellEvent e) {
            hideMenu();
          }
        };
    control.getShell().addShellListener(shellListener);
    ignoreTaskbar = true;

    Event event = new Event();
    event.data = this;
    event.type = SWT.OPEN;
    menu.fireMenuEvent(event);

    createAndShowWindow();
    installMouseHook();
    shell.addDisposeListener(
        new DisposeListener() {

          public void widgetDisposed(DisposeEvent e) {
            if (!control.isDisposed()) control.getShell().removeShellListener(shellListener);
          }
        });

    final Listener mouseDownListener =
        new Listener() {

          public void handleEvent(Event e) {
            if (shell == null || shell.isDisposed()) {
              Display.getDefault().removeFilter(SWT.MouseDown, this);
              return;
            }
            if (e.widget == null
                || e.widget.isDisposed()
                || checkMouseDownEvent(((Control) e.widget).toDisplay(e.x, e.y))) {
              hideMenu();
            }
          }
        };

    Display.getDefault().addFilter(SWT.MouseDown, mouseDownListener);

    final Listener keyDownListener =
        new Listener() {

          public void handleEvent(Event e) {
            if (shell == null || shell.isDisposed()) {
              Display.getDefault().removeFilter(SWT.KeyDown, this);
              e.doit = false;
              return;
            }
            KeyEvent ke = new KeyEvent(e);
            if ((ke.keyCode == SWT.ALT) || ke.keyCode == SWT.F10) {
              hideMenu();
              return;
            }
            getCurrentMenu().dealAltKeyEvent(ke);

            if (ke.keyCode == KEY_RIGHT && trackItemIndex > -1) {
              getCurrentMenu().subMenuSelected();
            }
            if (ke.keyCode == KEY_LEFT && trackItemIndex > -1) {
              getCurrentMenu().parentMenuSelected();
            }
            if (ke.keyCode == KEY_DOWN || ke.keyCode == KEY_UP) {
              if (ke.keyCode == KEY_DOWN) getCurrentMenu().downSelected();
              else getCurrentMenu().upSelected();
            }
            if (ke.keyCode == SWT.ESC) {
              if (getCurrentMenu().parentMenu == null) getCurrentMenu().hideMenu();
              else getCurrentMenu().parentMenuSelected();
            }
            if (ke.keyCode == SWT.CR) {
              getCurrentMenu().handleSelectedEvent();
            }
          }
        };
    Display.getDefault().addFilter(SWT.KeyDown, keyDownListener);

    shell.addDisposeListener(
        new DisposeListener() {

          public void widgetDisposed(DisposeEvent e) {
            Display.getDefault().removeFilter(SWT.MouseDown, mouseDownListener);
            Display.getDefault().removeFilter(SWT.KeyDown, keyDownListener);
            getShell().removeShellListener(shellListener);
          }
        });
  }
コード例 #20
0
 /**
  * Opens GradientSelectionDialog without transparency setting available, receives the return
  * values and uses them to create the resulting GradientData object.
  *
  * @see org.eclipse.jface.viewers.DialogCellEditor#openDialogBox(org.eclipse.swt.widgets.Control)
  */
 protected Object openDialogBox(Control cellEditorWindow) {
   String value = (String) getValue();
   RGB color1 = null, color2 = null;
   int gradientStyle = -1;
   // value is in format: RGB {x, x, x},RGB {x, x, x},style
   // parse it
   if (value != null) {
     StringTokenizer st = new StringTokenizer(value, ",{}"); // $NON-NLS-1$
     try {
       int red, green, blue;
       st.nextToken().trim(); // RGB string			
       // color1
       red = Integer.parseInt(st.nextToken().trim());
       green = Integer.parseInt(st.nextToken().trim());
       blue = Integer.parseInt(st.nextToken().trim());
       if (red > -1 && green > -1 && blue > -1) {
         color1 = new RGB(red, green, blue);
       }
       st.nextToken().trim(); // RGB string			
       // color2
       red = Integer.parseInt(st.nextToken().trim());
       green = Integer.parseInt(st.nextToken().trim());
       blue = Integer.parseInt(st.nextToken().trim());
       if (red > -1 && green > -1 && blue > -1) {
         color2 = new RGB(red, green, blue);
       }
       // style
       GradientStyle gradientStyleObj =
           GradientStyle.get(value.substring(value.lastIndexOf(',') + 1).trim());
       if (gradientStyleObj != null) {
         gradientStyle = gradientStyleObj.getValue();
       }
     } finally {
       if (color1 == null || color2 == null || gradientStyle == -1) {
         value = null;
       }
     }
   }
   if (value == null) {
     // use default
     GradientData def = GradientData.getDefaultGradientData();
     color1 = FigureUtilities.integerToRGB(def.getGradientColor1());
     color2 = FigureUtilities.integerToRGB(def.getGradientColor2());
     gradientStyle = def.getGradientStyle();
   }
   GradientSelectionDialog dialog =
       new GradientSelectionDialog(
           cellEditorWindow.getShell(), SWT.APPLICATION_MODAL, color1, color2, gradientStyle, 0);
   int result = dialog.open();
   if (result == SWT.OK) {
     return new GradientData(
         FigureUtilities.RGBToInteger(dialog.getGradientColor1()),
         FigureUtilities.RGBToInteger(dialog.getGradientColor2()),
         dialog.getGradientStyle());
   } else if (result == -1) { // user selected Clear button
     // make the calls here, since parent ignores null, and we need to clear gradient
     markDirty();
     doSetValue(null);
     fireApplyEditorValue();
   }
   return null;
 }
コード例 #21
0
 @Override
 protected Object openDialogBox(Control cellEditorWindow) {
   IType type = DataUtils.chooseClass(cellEditorWindow.getShell(), null, null);
   return type.getFullyQualifiedName();
 }
コード例 #22
0
  private void drag(Event dragEvent) {
    DNDEvent event = new DNDEvent();
    event.widget = this;
    event.x = dragEvent.x;
    event.y = dragEvent.y;
    event.time = OS.GetMessageTime();
    event.doit = true;
    notifyListeners(DND.DragStart, event);
    if (!event.doit || transferAgents == null || transferAgents.length == 0) return;

    int[] pdwEffect = new int[1];
    int operations = opToOs(getStyle());
    Display display = control.getDisplay();
    String key = "org.eclipse.swt.internal.win32.runMessagesInIdle"; // $NON-NLS-1$
    Object oldValue = display.getData(key);
    display.setData(key, Boolean.TRUE);
    ImageList imagelist = null;
    Image image = event.image;
    hwndDrag = 0;
    topControl = null;
    if (image != null) {
      imagelist = new ImageList(SWT.NONE);
      imagelist.add(image);
      topControl = control.getShell();
      /*
       * Bug in Windows. The image is inverted if the shell is RIGHT_TO_LEFT.
       * The fix is to create a transparent window that covers the shell client
       * area and use it during the drag to prevent the image from being inverted.
       * On XP if the shell is RTL, the image is not displayed.
       */
      int offsetX = event.offsetX;
      hwndDrag = topControl.handle;
      if ((topControl.getStyle() & SWT.RIGHT_TO_LEFT) != 0) {
        offsetX = image.getBounds().width - offsetX;
        RECT rect = new RECT();
        OS.GetClientRect(topControl.handle, rect);
        hwndDrag =
            OS.CreateWindowEx(
                OS.WS_EX_TRANSPARENT | OS.WS_EX_NOINHERITLAYOUT,
                WindowClass,
                null,
                OS.WS_CHILD | OS.WS_CLIPSIBLINGS,
                0,
                0,
                rect.right - rect.left,
                rect.bottom - rect.top,
                topControl.handle,
                0,
                OS.GetModuleHandle(null),
                null);
        OS.ShowWindow(hwndDrag, OS.SW_SHOW);
      }
      OS.ImageList_BeginDrag(imagelist.getHandle(), 0, offsetX, event.offsetY);
      /*
       * Feature in Windows. When ImageList_DragEnter() is called,
       * it takes a snapshot of the screen  If a drag is started
       * when another window is in front, then the snapshot will
       * contain part of the other window, causing pixel corruption.
       * The fix is to force all paints to be delivered before
       * calling ImageList_DragEnter().
       */
      if (OS.IsWinCE) {
        OS.UpdateWindow(topControl.handle);
      } else {
        int flags = OS.RDW_UPDATENOW | OS.RDW_ALLCHILDREN;
        OS.RedrawWindow(topControl.handle, null, 0, flags);
      }
      POINT pt = new POINT();
      pt.x = dragEvent.x;
      pt.y = dragEvent.y;
      OS.MapWindowPoints(control.handle, 0, pt, 1);
      RECT rect = new RECT();
      OS.GetWindowRect(hwndDrag, rect);
      OS.ImageList_DragEnter(hwndDrag, pt.x - rect.left, pt.y - rect.top);
    }
    int result = COM.DRAGDROP_S_CANCEL;
    try {
      result =
          COM.DoDragDrop(iDataObject.getAddress(), iDropSource.getAddress(), operations, pdwEffect);
    } finally {
      // ensure that we don't leave transparent window around
      if (hwndDrag != 0) {
        OS.ImageList_DragLeave(hwndDrag);
        OS.ImageList_EndDrag();
        imagelist.dispose();
        if (hwndDrag != topControl.handle) OS.DestroyWindow(hwndDrag);
        hwndDrag = 0;
        topControl = null;
      }
      display.setData(key, oldValue);
    }
    int operation = osToOp(pdwEffect[0]);
    if (dataEffect == DND.DROP_MOVE) {
      operation =
          (operation == DND.DROP_NONE || operation == DND.DROP_COPY)
              ? DND.DROP_TARGET_MOVE
              : DND.DROP_MOVE;
    } else {
      if (dataEffect != DND.DROP_NONE) {
        operation = dataEffect;
      }
    }
    event = new DNDEvent();
    event.widget = this;
    event.time = OS.GetMessageTime();
    event.doit = (result == COM.DRAGDROP_S_DROP);
    event.detail = operation;
    notifyListeners(DND.DragEnd, event);
    dataEffect = DND.DROP_NONE;
  }
コード例 #23
0
  /**
   * Create a shell but do not display it
   *
   * @return Returns <code>true</code> when shell is created.
   */
  private void createUI() {

    final boolean isRecreateContent = _toolTipStyle == TOOLTIP_STYLE_RECREATE_CONTENT;
    boolean isShellCreated = false;
    boolean isCreateContent = false;

    if (_shell == null || _shell.isDisposed()) {

      /*
       * create shell
       */
      _shell =
          new Shell(
              _ownerControl.getShell(), //
              SWT.ON_TOP //
                  /*
                   * SWT.TOOL must be disabled that NO_FOCUS is working !!!
                   */
                  //							| SWT.TOOL
                  | SWT.NO_FOCUS);

      _shell.setLayout(new FillLayout());

      addTTShellListener(_shell);

      isShellCreated = true;

    } else {

      if (isRecreateContent) {

        // hide previous tooltip content

        _shell.setRedraw(false);

        final Control[] shellChildren = _shell.getChildren();
        for (final Control control : shellChildren) {
          control.dispose();
        }

        isCreateContent = true;
      }
    }

    final boolean isNewContent = isShellCreated || isCreateContent;

    if (isNewContent) {

      // create content
      createToolTipContentArea(_shell);
    }

    if (isShellCreated) {
      _shell.pack(true);
    } else {
      _shell.layout();
      _shell.pack(true);
    }

    _shell.setRedraw(true);

    if (isNewContent) {
      addTTAllControlsListener(_shell);
    }
  }
コード例 #24
0
ファイル: UIUtils.java プロジェクト: ralic/dbeaver
 public static boolean isInDialog(Control control) {
   return control.getShell().getData() instanceof org.eclipse.jface.dialogs.Dialog;
 }
コード例 #25
0
 private Shell getShell() {
   if (fSWTControl != null) {
     return fSWTControl.getShell();
   }
   return JavaScriptPlugin.getActiveWorkbenchShell();
 }
コード例 #26
0
        public void handleEvent(Event event) {

          Object changedObj = event.getProperty(UIEvents.EventTags.ELEMENT);
          if (!(changedObj instanceof MElementContainer<?>)) return;

          MElementContainer<MUIElement> changedElement = (MElementContainer<MUIElement>) changedObj;
          boolean isApplication = changedObj instanceof MApplication;

          boolean menuChild = changedObj instanceof MMenu;
          // If the parent isn't in the UI then who cares?
          AbstractPartRenderer renderer = getRendererFor(changedElement);
          if ((!isApplication && renderer == null) || menuChild) return;

          String eventType = (String) event.getProperty(UIEvents.EventTags.TYPE);
          if (UIEvents.EventTypes.ADD.equals(eventType)) {
            Activator.trace(Policy.DEBUG_RENDERER, "Child Added", null); // $NON-NLS-1$
            MUIElement added = (MUIElement) event.getProperty(UIEvents.EventTags.NEW_VALUE);

            // OK, we have a new -visible- part we either have to create
            // it or host it under the correct parent. Note that we
            // explicitly do *not* render non-selected elements in
            // stacks (to support lazy loading).
            boolean isStack = changedObj instanceof MGenericStack<?>;
            boolean hasWidget = added.getWidget() != null;
            boolean isSelected = added == changedElement.getSelectedElement();
            boolean renderIt = !isStack || hasWidget || isSelected;
            if (renderIt) {
              // NOTE: createGui will call 'childAdded' if successful
              Object w = createGui(added);
              if (w instanceof Control && !(w instanceof Shell)) {
                final Control ctrl = (Control) w;
                fixZOrder(added);
                if (!ctrl.isDisposed()) {
                  ctrl.getShell().layout(new Control[] {ctrl}, SWT.DEFER);
                }
              }
            } else {
              if (renderer != null && added.isToBeRendered())
                renderer.childRendered(changedElement, added);
            }

            // If the element being added is a placeholder, check to see if
            // it's 'globally visible' and, if so, remove all other
            // 'local' placeholders referencing the same element.
            int newLocation = modelService.getElementLocation(added);
            if (newLocation == EModelService.IN_SHARED_AREA
                || newLocation == EModelService.OUTSIDE_PERSPECTIVE) {
              MWindow topWin = modelService.getTopLevelWindowFor(added);
              modelService.hideLocalPlaceholders(topWin, null);
            }
          } else if (UIEvents.EventTypes.REMOVE.equals(eventType)) {
            Activator.trace(Policy.DEBUG_RENDERER, "Child Removed", null); // $NON-NLS-1$
            MUIElement removed = (MUIElement) event.getProperty(UIEvents.EventTags.OLD_VALUE);
            // Removing invisible elements is a NO-OP as far as the
            // renderer is concerned
            if (!removed.isToBeRendered()) return;

            if (removed.getWidget() instanceof Control) {
              Control ctrl = (Control) removed.getWidget();
              ctrl.setLayoutData(null);
              ctrl.getParent().layout(new Control[] {ctrl}, SWT.CHANGED | SWT.DEFER);
            }

            // Ensure that the element about to be removed is not the
            // selected element
            if (changedElement.getSelectedElement() == removed)
              changedElement.setSelectedElement(null);

            if (renderer != null) renderer.hideChild(changedElement, removed);
          }
        }