コード例 #1
0
ファイル: UIUtils.java プロジェクト: ralic/dbeaver
 public static void dispose(Widget widget) {
   if (widget != null && !widget.isDisposed()) {
     try {
       widget.dispose();
     } catch (Exception e) {
       log.debug("widget dispose error", e);
     }
   }
 }
コード例 #2
0
  /*
   * (non-Javadoc)
   *
   * @see
   * org.eclipse.e4.ui.internal.workbench.swt.AbstractPartRenderer#hideChild
   * (org.eclipse.e4.ui.model.application.MElementContainer,
   * org.eclipse.e4.ui.model.application.MUIElement)
   */
  @Override
  public void hideChild(MElementContainer<MUIElement> parentElement, MUIElement child) {
    super.hideChild(parentElement, child);

    // Since there's no place to 'store' a child that's not in a menu
    // we'll blow it away and re-create on an add
    Widget widget = (Widget) child.getWidget();
    if (widget != null && !widget.isDisposed()) widget.dispose();
  }
コード例 #3
0
  @Test
  public void testMarkDisposed() {
    Fixture.fakeNewRequest();
    Fixture.fakeResponseWriter();

    // dispose un-initialized widget: must not occur in list of disposed widgets
    Widget widget = new Shell(display);
    widget.dispose();
    assertTrue(widget.isDisposed());
    assertEquals(0, DisposedWidgets.getAll().length);

    // dispose initialized widget: must be present in list of disposed widgets
    widget = new Shell(display);
    WidgetAdapterImpl adapter = (WidgetAdapterImpl) WidgetUtil.getAdapter(widget);
    adapter.setInitialized(true);
    widget.dispose();

    assertTrue(widget.isDisposed());
    assertEquals(1, DisposedWidgets.getAll().length);
  }
コード例 #4
0
  private void doRemoveGroup(String group) {
    try {
      policy.setRedraw(false);

      for (Widget col : policy.getColumns()) {
        Column column = (Column) col.getData(Column.class.getName());
        if (group.equals(column.getGroupLabel())) col.dispose();
      }
    } finally {
      policy.getViewer().refresh();
      policy.setRedraw(true);
    }
  }
コード例 #5
0
 public void destroyColumnWithOption(Column column, Object option) {
   for (Widget widget : policy.getColumns()) {
     if (column.equals(widget.getData(Column.class.getName())) //
         && (option == null || option.equals(widget.getData(OPTIONS_KEY)))) {
       try {
         policy.setRedraw(false);
         widget.dispose();
       } finally {
         policy.getViewer().refresh();
         policy.setRedraw(true);
       }
       break;
     }
   }
 }
コード例 #6
0
  @Override
  public void hideChild(MElementContainer<MUIElement> parentElement, MUIElement child) {
    super.hideChild(parentElement, child);

    // Since there's no place to 'store' a child that's not in a menu
    // we'll blow it away and re-create on an add
    Widget widget = (Widget) child.getWidget();
    if (widget != null && !widget.isDisposed()) {
      widget.dispose();
    }
    ToolBar toolbar = (ToolBar) getUIContainer(child);
    if (toolbar != null && !toolbar.isDisposed()) {
      toolbar.getShell().layout(new Control[] {toolbar}, SWT.DEFER);
    }
    disposeToolbarIfNecessary(parentElement);
  }
コード例 #7
0
  @Override
  public void disposeWidget(MUIElement element) {
    if (element instanceof MPart) {
      MPart part = (MPart) element;
      MToolBar toolBar = part.getToolbar();
      if (toolBar != null) {
        Widget widget = (Widget) toolBar.getWidget();
        if (widget != null) {
          unbindWidget(toolBar);
          widget.dispose();
        }
      }

      for (MMenu menu : part.getMenus()) {
        engine.removeGui(menu);
      }
    }
    super.disposeWidget(element);
  }
コード例 #8
0
 @Override
 public void hideChild(MElementContainer<MUIElement> parentElement, MUIElement child) {
   super.hideChild(parentElement, child);
   // only handle the disposal of this element if it was actually rendered
   // by the engine
   if (child.getRenderer() != null) {
     // Since there's no place to 'store' a child that's not in a menu
     // we'll blow it away and re-create on an add
     Widget widget = (Widget) child.getWidget();
     if (widget != null && !widget.isDisposed()) {
       widget.dispose();
     }
     ToolBar toolbar = (ToolBar) getUIContainer(child);
     if (toolbar != null && !toolbar.isDisposed()) {
       toolbar.pack(true);
       toolbar.getShell().layout(new Control[] {toolbar}, SWT.DEFER);
     }
     // disposeToolbarIfNecessary(parentElement);
   }
 }