/**
   * Handle a drop from another layout
   *
   * @param event The drag and drop event
   */
  @Override
  protected void handleDropFromLayout(DragAndDropEvent event) {
    AbsoluteLayoutTargetDetails details = (AbsoluteLayoutTargetDetails) event.getTargetDetails();
    LayoutBoundTransferable transferable = (LayoutBoundTransferable) event.getTransferable();
    Component component = transferable.getComponent();
    Component source = event.getTransferable().getSourceComponent();
    DDAbsoluteLayout layout = (DDAbsoluteLayout) details.getTarget();
    int leftPixelPosition = details.getRelativeLeft();
    int topPixelPosition = details.getRelativeTop();

    // Check that we are not dragging an outer layout into an
    // inner
    // layout
    Component parent = source.getParent();
    while (parent != null) {
      parent = parent.getParent();
    }

    // remove component from source using filter
    if (source instanceof ComponentContainer) {
      ComponentContainer sourceLayout = (ComponentContainer) source;
      sourceLayout.removeComponent(component);
    }

    // Add component to absolute layout
    layout.addComponent(
        component, "left:" + leftPixelPosition + "px;top:" + topPixelPosition + "px");
  }
  @Inject
  public EditStatusToolItem(ComponentContainer parent, IEclipseContext context) {
    // the parent - is toolcontrol widget, we must add style for layouting in trimbar to parent
    // widget, not to user control
    parent.addStyleName("editstatus");

    final Label label = new Label("Smart Insert");
    parent.addComponent(label);
  }
예제 #3
0
 public void replaceContainer(ComponentContainer newContainer, ComponentContainer newPosition) {
   ComponentContainer containerParent = (ComponentContainer) tabContainer.getParent();
   if (containerParent != null) {
     containerParent.removeComponent(tabContainer);
   }
   if (newPosition == null) newPosition = newContainer;
   newPosition.addComponent(tabContainer);
   contentWrapper.addComponent(newContainer);
 }
예제 #4
0
 protected void activateLoadedView(Component lazyLoad) {
   if (getParent() instanceof ComponentContainer) {
     final ComponentContainer parent = (ComponentContainer) getParent();
     parent.replaceComponent(this, lazyLoad);
   } else {
     removeAllComponents();
     addComponent(lazyLoad);
   }
 }
예제 #5
0
 private void disconnectReferencedElementsFromPerspectiveWidgets(
     MElementContainer<? extends MUIElement> container) {
   for (MUIElement e : container.getChildren()) {
     if (e instanceof MPlaceholder) {
       MPlaceholder ph = (MPlaceholder) e;
       if (ph.isToBeRendered()) {
         ComponentContainer phComponent = (ComponentContainer) ph.getWidget();
         Component refComponent = (Component) ph.getRef().getWidget();
         phComponent.removeComponent(refComponent);
       }
     }
   }
 }
  /** {@inheritDoc} */
  @Override
  public void doUnrender() {
    if (textArea != null) {

      // unbind all active bindings
      unbind();

      ComponentContainer parent = ((ComponentContainer) textArea.getParent());
      if (parent != null) {
        parent.removeComponent(textArea);
      }

      // remove assocations
      unassociateWidget(textArea);

      textArea = null;
    }
  }
  /** {@inheritDoc} */
  @Override
  public void doUnrender() {
    if (checkBox != null) {

      // unbind all active bindings
      unbind();

      ComponentContainer parent = ((ComponentContainer) checkBox.getParent());
      if (parent != null) {
        parent.removeComponent(checkBox);
      }

      // remove assocations
      unassociateWidget(checkBox);

      checkBox = null;
    }
  }
  @Override
  protected ComponentContainer createSectionWidget(
      ComponentContainer previousSectionWidget,
      String section,
      Map<String, String> attributes,
      ComponentContainer container,
      VaadinMetawidget metawidget) {

    TabSheet tabSheet;

    // Whole new tabbed pane?

    if (previousSectionWidget == null) {

      tabSheet = new TabSheet();
      tabSheet.setWidth("100%");

      // Add to parent container

      Map<String, String> tabbedPaneAttributes = CollectionUtils.newHashMap();
      tabbedPaneAttributes.put(LABEL, "");
      tabbedPaneAttributes.put(LARGE, TRUE);
      getDelegate().layoutWidget(tabSheet, PROPERTY, tabbedPaneAttributes, container, metawidget);
    } else {
      tabSheet = (TabSheet) previousSectionWidget.getParent();
    }

    // New tab

    Panel tabPanel = new Panel();

    // Tab name (possibly localized)

    String localizedSection = metawidget.getLocalizedKey(StringUtils.camelCase(section));

    if (localizedSection == null) {
      localizedSection = section;
    }

    tabSheet.addTab(tabPanel, localizedSection, null);

    return tabPanel;
  }
  @Override
  protected void handleDropFromLayout(DragAndDropEvent event) {
    LayoutBoundTransferable transferable = (LayoutBoundTransferable) event.getTransferable();
    TabSheetTargetDetails details = (TabSheetTargetDetails) event.getTargetDetails();
    DDTabSheet tabSheet = (DDTabSheet) details.getTarget();
    Component c = transferable.getComponent();
    HorizontalDropLocation location = details.getDropLocation();
    int idx = details.getOverIndex();
    ComponentContainer source = (ComponentContainer) transferable.getSourceComponent();

    // Detach from old source
    if (source instanceof ComponentContainer) {
      ((ComponentContainer) source).removeComponent(c);
    } else if (source instanceof SingleComponentContainer) {
      ((SingleComponentContainer) source).setContent(null);
    }

    if (location == HorizontalDropLocation.LEFT) {
      tabSheet.addTab(c, idx);
    } else if (location == HorizontalDropLocation.RIGHT) {
      tabSheet.addTab(c, idx + 1);
    }
  }
예제 #10
0
  private void showElementRecursive(MUIElement element) {
    if (!element.isToBeRendered()) return;

    if (element instanceof MPlaceholder && element.getWidget() != null) {
      MPlaceholder ph = (MPlaceholder) element;
      MUIElement ref = ph.getRef();
      ref.setCurSharedRef(ph);

      ComponentContainer phComponent = (ComponentContainer) ph.getWidget();
      Component refComponent = (Component) ph.getRef().getWidget();
      phComponent.addComponent(refComponent);

      element = ref;

      // top right folder
      MPartStack topLeftStack = HierarchyUtils.findTopLeftFolder(ph.getRef());
      if (topLeftStack != null) {
        if (ph.getTags().contains(IPresentationEngine.MAXIMIZED))
          ((StackWidget) topLeftStack.getWidget()).setState(1);
        else if (ph.getTags().contains(IPresentationEngine.MINIMIZED))
          ((StackWidget) topLeftStack.getWidget()).setState(-1);
        else ((StackWidget) topLeftStack.getWidget()).setState(0);
      }
    }

    if (element instanceof MContext) {
      IEclipseContext context = ((MContext) element).getContext();
      if (context != null) {
        IEclipseContext newParentContext = modelService.getContainingContext(element);
        if (context.getParent() != newParentContext) {
          context.setParent(newParentContext);
        }
      }
    }

    // Show any floating windows
    if (element instanceof MWindow && element.getWidget() != null) {
      int visCount = 0;
      for (MUIElement kid : ((MWindow) element).getChildren()) {
        if (kid.isToBeRendered() && kid.isVisible()) visCount++;
      }
      if (visCount > 0) element.setVisible(true);
    }

    if (element instanceof MElementContainer<?>) {
      MElementContainer<?> container = (MElementContainer<?>) element;
      List<MUIElement> kids = new ArrayList<MUIElement>(container.getChildren());
      for (MUIElement childElement : kids) {
        showElementRecursive(childElement);
      }

      // OK, now process detached windows
      if (element instanceof MWindow) {
        for (MWindow w : ((MWindow) element).getWindows()) {
          showElementRecursive(w);
        }
      } else if (element instanceof MPerspective) {
        for (MWindow w : ((MPerspective) element).getWindows()) {
          showElementRecursive(w);
        }
      }
    }
  }