예제 #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);
     }
   }
 }
  /*
   * (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();
  }
  @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;
     }
   }
 }
  @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);
  }
  @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);
  }
 @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);
   }
 }