List of usage examples for com.vaadin.ui Component getParent
@Override
public HasComponents getParent();
From source file:com.foc.vaadin.gui.layouts.FVVertical_WYSIWYG_DropHandler.java
License:Apache License
public void drop(DragAndDropEvent event) { VerticalLayoutTargetDetails details = (VerticalLayoutTargetDetails) event.getTargetDetails(); DropTarget layout = details.getTarget(); Component source = event.getTransferable().getSourceComponent(); if (layout == source) { handleComponentReordering(event); } else if (event.getTransferable() instanceof LayoutBoundTransferable) { LayoutBoundTransferable transferable = (LayoutBoundTransferable) event.getTransferable(); Component comp = transferable.getComponent(); if (comp == layout) { if (comp.getParent() instanceof DDAbsoluteLayout) { handleDropFromAbsoluteParentLayout(event); }/* w w w . ja v a2 s .c o m*/ } else { handleDropFromLayout(event); } } else if (event.getTransferable() instanceof DataBoundTransferable) { DataBoundTransferable t = (DataBoundTransferable) event.getTransferable(); String name = t.getItemId() + ""; Globals.logString("Item ID = " + t.getItemId()); Globals.logString("Here in DataBoundTrans"); FVLayout targetLayout = (FVLayout) details.getTarget(); FocXMLAttributes attributes = new FocXMLAttributes(); attributes.addAttribute("", FXML.ATT_IDX, FXML.ATT_IDX, "CDATA", details.getOverIndex() + ""); handleSourceContainer(t, targetLayout, name, attributes); Globals.logString(targetLayout.toString()); } }
From source file:com.foc.vaadin.gui.windows.EditFieldsLayoutInTab.java
License:Apache License
public ICentralPanel getCentralPanel() { ICentralPanel centralPanel = null;/* w ww . j a v a 2 s. c o m*/ Component comp = (Component) componentEdited; while (comp != null && comp.getParent() != null) { if (comp instanceof ICentralPanel) { centralPanel = (ICentralPanel) comp; } comp = comp.getParent(); } return centralPanel; }
From source file:com.foc.vaadin.gui.XMLBuilder.java
License:Apache License
private void buildXMLRecursive(FVLayout layout) { if (layout != null) { Attributes attributes = layout != null ? layout.getAttributes() : null; appendLine("<" + layout.getXMLType() + " " + constructAttributes(attributes) + " >"); incrementSpaces();/*from www . j a v a2 s . c om*/ layout.fillXMLNodeContent(this); Component layoutComponent = (Component) layout; if (layoutComponent.getParent() != null && layoutComponent.getParent() instanceof ICentralPanel) { FValidationSettings validationSettings = ((ICentralPanel) layoutComponent.getParent()) .getValidationSettings(true); if (validationSettings != null) { validationSettings.fillXML(this); } } if (!layout.isXMLLeaf()) { Iterator<Component> itr = ((FVLayout) layout).getComponentIterator(); while (itr.hasNext()) { Component temp = itr.next(); if (temp instanceof FVLayout) { FVLayout childLayout = (FVLayout) temp; buildXMLRecursive(childLayout); } else if (temp instanceof FocXMLGuiComponent) { attributes = ((FocXMLGuiComponent) temp).getAttributes(); appendLine("<" + ((FocXMLGuiComponent) temp).getXMLType() + " " + constructAttributes(attributes) + " />"); } } } decrementSpaces(); appendLine("</" + ((FVLayout) layout).getXMLType() + ">"); } }
From source file:com.foc.web.unitTesting.FocUnitTestingCommand.java
License:Apache License
public void component_AssertVisible(String componentName, boolean visible) throws Exception { FocXMLLayout navigationLayout = getCurrentCentralPanel(); FocXMLGuiComponent component = findComponent(navigationLayout, componentName); if (component == null) { getLogger().addFailure("Component " + componentName + " not found"); } else {//from ww w . ja v a2 s. co m if (component instanceof Component) { Component comp = (Component) component; boolean compVisible = comp.isVisible(); while (compVisible && comp != null) { comp = comp.getParent(); if (comp != null) compVisible = comp.isVisible(); } if (compVisible == visible) { getLogger() .addInfo("Component " + componentName + (visible ? " is Visible " : " is not Visible")); } else { getLogger().addFailure("Component " + componentName + (visible ? " should be Visible " : " should not be Visible")); } } } }
From source file:com.github.peholmst.i18n4vaadin.support.I18NComponentSupport.java
License:Apache License
/** * Gets the <code>I18N</code>-instance to use. If an instance has been set * using {@link #setI18N(I18N)}, it will be returned. Otherwise, this method * will traverse the owning component's parent chain looking for a component * that implements {@link I18NComponent}. If one is found, that component's * <code>I18N</code>-instance will be returned. * //www . j a va2 s . co m * @return the <code>I18N</code> instance, or <code>null</code> if none * could be found. */ public I18N getI18N() { if (i18n != null) { return i18n; } else { Component c = owner.getParent(); while (c != null) { if (c instanceof I18NComponent) { return ((I18NComponent) c).getI18N(); } c = c.getParent(); } } return null; }
From source file:com.haulmont.cuba.web.gui.components.WebTabSheet.java
License:Apache License
@Override public TabSheet.Tab addTab(String name, Component childComponent) { if (childComponent.getParent() != null && childComponent.getParent() != this) { throw new IllegalStateException("Component already has parent"); }//from w w w . j a v a 2s . co m final Tab tab = new Tab(name, childComponent); this.tabs.put(name, tab); final com.vaadin.ui.Component tabComponent = WebComponentsHelper.getComposition(childComponent); tabComponent.setSizeFull(); tabMapping.put(tabComponent, new ComponentDescriptor(name, childComponent)); com.vaadin.ui.TabSheet.Tab tabControl = this.component.addTab(tabComponent); if (getDebugId() != null) { this.component.setTestId(tabControl, AppUI.getCurrent().getTestIdManager().getTestId(getDebugId() + "." + name)); } if (AppUI.getCurrent().isTestMode()) { this.component.setCubaId(tabControl, name); } if (frame != null) { if (childComponent instanceof BelongToFrame && ((BelongToFrame) childComponent).getFrame() == null) { ((BelongToFrame) childComponent).setFrame(frame); } else { frame.registerComponent(childComponent); } } childComponent.setParent(this); return tab; }
From source file:com.haulmont.cuba.web.toolkit.ui.CubaGrid.java
License:Apache License
protected boolean allAttached(Collection<? extends Component> components) { for (Component component : components) { if (component.getParent() != this) { return false; }/*from w w w . j av a2s .c om*/ } return true; }
From source file:com.haulmont.cuba.web.widgets.addons.dragdroplayouts.drophandlers.AbstractDefaultLayoutDropHandler.java
License:Apache License
/** * Handles a drop by a component which has an absolute layout as parent. In * this case the component is moved.//w ww .j a va2s . co m * * @param event * The drag and drop event */ protected void handleDropFromAbsoluteParentLayout(DragAndDropEvent event) { LayoutBoundTransferable transferable = (LayoutBoundTransferable) event.getTransferable(); TargetDetails details = event.getTargetDetails(); MouseEventDetails mouseDown = transferable.getMouseDownEvent(); MouseEventDetails mouseUp = MouseEventDetails .deSerialize((String) details.getData(Constants.DROP_DETAIL_MOUSE_EVENT)); int movex = mouseUp.getClientX() - mouseDown.getClientX(); int movey = mouseUp.getClientY() - mouseDown.getClientY(); Component comp = transferable.getComponent(); DDAbsoluteLayout parent = (DDAbsoluteLayout) comp.getParent(); ComponentPosition position = parent.getPosition(comp); if (position.getLeftValue() != null) { float x = position.getLeftValue() + movex; position.setLeft(x, Sizeable.UNITS_PIXELS); } if (position.getRightValue() != null) { float x = position.getRightValue() - movex; position.setRight(x, Sizeable.UNITS_PIXELS); } if (position.getTopValue() != null) { float y = position.getTopValue() + movey; position.setTop(y, Sizeable.UNITS_PIXELS); } if (position.getBottomValue() != null) { float y = position.getBottomValue() - movey; position.setBottom(y, Sizeable.UNITS_PIXELS); } }
From source file:com.haulmont.cuba.web.widgets.addons.dragdroplayouts.drophandlers.AbstractDefaultLayoutDropHandler.java
License:Apache License
public void drop(DragAndDropEvent event) { // Get information about the drop TargetDetails details = event.getTargetDetails(); DropTarget layout = details.getTarget(); Component source = event.getTransferable().getSourceComponent(); if (event.getTransferable().getData("html5Data") != null) { handleHTML5Drop(event);/*w ww .j a v a 2 s.c om*/ } else if (layout == source) { handleComponentReordering(event); } else if (event.getTransferable() instanceof LayoutBoundTransferable) { LayoutBoundTransferable transferable = (LayoutBoundTransferable) event.getTransferable(); Component comp = transferable.getComponent(); if (comp == layout) { if (comp.getParent() instanceof DDAbsoluteLayout) { handleDropFromAbsoluteParentLayout(event); } } else { handleDropFromLayout(event); } } }
From source file:com.haulmont.cuba.web.widgets.addons.dragdroplayouts.drophandlers.DefaultAbsoluteLayoutDropHandler.java
License:Apache License
/** * Handle a drop from another layout/*from w w w .jav a 2s . co m*/ * * @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 if (source instanceof ComponentContainer) { ((ComponentContainer) source).removeComponent(component); } else if (source instanceof SingleComponentContainer) { ((SingleComponentContainer) source).setContent(null); } // Add component to absolute layout layout.addComponent(component, "left:" + leftPixelPosition + "px;top:" + topPixelPosition + "px"); }