List of usage examples for com.google.gwt.user.client.ui Widget getParent
public Widget getParent()
From source file:com.alkacon.acacia.client.AttributeHandler.java
License:Open Source License
/** * Sets the error message for the given value index.<p> * /* ww w.ja v a 2 s . c o m*/ * @param valueIndex the value index * @param message the error message * @param tabbedPanel the forms tabbed panel if available */ public void setErrorMessage(int valueIndex, String message, TabbedPanel<?> tabbedPanel) { if (!m_attributeValueViews.isEmpty()) { FlowPanel parent = (FlowPanel) m_attributeValueViews.get(0).getParent(); AttributeValueView valueView = (AttributeValueView) parent.getWidget(valueIndex); valueView.setErrorMessage(message); if (tabbedPanel != null) { int tabIndex = tabbedPanel.getTabIndex(valueView.getElement()); if (tabIndex > -1) { Widget tab = tabbedPanel.getTabWidget(tabIndex); tab.setTitle("This tab has errors."); tab.getParent().removeStyleName(I_LayoutBundle.INSTANCE.form().hasWarning()); tab.getParent().addStyleName(I_LayoutBundle.INSTANCE.form().hasError()); } } } }
From source file:com.alkacon.acacia.client.AttributeHandler.java
License:Open Source License
/** * Sets the warning message for the given value index.<p> * /*w w w . j a va 2s . co m*/ * @param valueIndex the value index * @param message the warning message * @param tabbedPanel the forms tabbed panel if available */ public void setWarningMessage(int valueIndex, String message, TabbedPanel<?> tabbedPanel) { if (!m_attributeValueViews.isEmpty()) { FlowPanel parent = (FlowPanel) m_attributeValueViews.get(0).getParent(); AttributeValueView valueView = (AttributeValueView) parent.getWidget(valueIndex); valueView.setWarningMessage(message); if (tabbedPanel != null) { int tabIndex = tabbedPanel.getTabIndex(valueView.getElement()); if (tabIndex > -1) { Widget tab = tabbedPanel.getTabWidget(tabIndex); tab.setTitle("This tab has warnings."); tab.getParent().addStyleName(I_LayoutBundle.INSTANCE.form().hasWarning()); } } } }
From source file:com.alkacon.acacia.client.ButtonBarHandler.java
License:Open Source License
/** * Sets the button bar visibility.<p> * //from ww w. j a v a2s. c om * @param buttonBar the button bar * @param visible <code>true</code> to show the button bar */ private void setButtonBarVisibility(Widget buttonBar, boolean visible) { String hoverStyle = I_LayoutBundle.INSTANCE.form().hoverButton(); if (visible) { buttonBar.addStyleName(hoverStyle); } else { buttonBar.removeStyleName(hoverStyle); } if (buttonBar instanceof InlineEntityWidget) { ((InlineEntityWidget) buttonBar).setContentHighlightingVisible(visible); } if (buttonBar.getParent() instanceof InlineEntityWidget) { ((InlineEntityWidget) buttonBar.getParent()).setContentHighlightingVisible(visible); } }
From source file:com.alkacon.acacia.client.ui.AttributeValueView.java
License:Open Source License
/** * Gets the parent attribute value view, or null if none exists.<p> * /*from w w w.j a v a 2 s . c om*/ * @return the parent attribute value view */ public AttributeValueView getParentView() { Widget ancestor = getParent(); while ((ancestor != null) && !(ancestor instanceof AttributeValueView)) { ancestor = ancestor.getParent(); } return (AttributeValueView) ancestor; }
From source file:com.alkacon.acacia.client.ui.AttributeValueView.java
License:Open Source License
/** * Call when content changes.<p>/*w ww . java 2 s .c o m*/ */ protected void onResize() { Widget parent = getParent(); while (parent != null) { if (parent instanceof I_DescendantResizeHandler) { ((I_DescendantResizeHandler) parent).onResizeDescendant(); break; } parent = parent.getParent(); } }
From source file:com.alkacon.acacia.client.ValueFocusHandler.java
License:Open Source License
/** * @see com.google.gwt.event.dom.client.MouseOverHandler#onMouseOver(com.google.gwt.event.dom.client.MouseOverEvent) *//*from w w w .j a v a 2 s . co m*/ public void onMouseOver(MouseOverEvent event) { if (!(event.getSource() instanceof AttributeValueView)) { AttributeValueView parentView = null; Widget source = ((Widget) event.getSource()).getParent(); while (parentView == null) { if (source instanceof AttributeValueView) { parentView = (AttributeValueView) source; } else { source = source.getParent(); } } if (m_currentButtonFocus != null) { if (m_currentButtonFocus.equals(parentView)) { return; } else if (!m_currentButtonFocus.equals(m_currentFocus)) { m_currentButtonFocus.toggleFocus(false); } } m_currentButtonFocus = parentView; m_currentButtonFocus.toggleFocus(true); return; } }
From source file:com.alkacon.geranium.client.ui.Popup.java
License:Open Source License
/** * @see com.google.gwt.user.client.ui.SimplePanel#remove(com.google.gwt.user.client.ui.Widget) *///from ww w.ja v a 2 s .c o m @Override public boolean remove(Widget w) { // Validate. if (w.getParent() != this) { return false; } // Orphan. try { orphan(w); } finally { // Physical detach. Element elem = w.getElement(); DOM.removeChild(DOM.getParent(elem), elem); // Logical detach. getChildren().remove(w); } return true; }
From source file:com.alkacon.geranium.client.ui.Popup.java
License:Open Source License
/** * Adjusts beforeIndex to account for the possibility that the given widget is * already a child of this panel./*from ww w . j av a2 s .c o m*/ * * @param child the widget that might be an existing child * @param beforeIndex the index at which it will be added to this panel * @return the modified index */ protected int adjustIndex(Widget child, int beforeIndex) { checkIndexBoundsForInsertion(beforeIndex); // Check to see if this widget is already a direct child. if (child.getParent() == this) { // If the Widget's previous position was left of the desired new position // shift the desired position left to reflect the removal int idx = getWidgetIndex(child); if (idx < beforeIndex) { beforeIndex--; } } return beforeIndex; }
From source file:com.allen_sauer.gwt.dnd.client.PickupDragController.java
License:Apache License
/** * Save the selected widgets' current location in case they much be restored due to a cancelled * drop./*from w ww .j a v a 2 s . co m*/ * * @see #restoreSelectedWidgetsLocation() */ protected void saveSelectedWidgetsLocationAndStyle() { savedWidgetInfoMap = new HashMap<Widget, SavedWidgetInfo>(); for (Widget widget : context.selectedWidgets) { SavedWidgetInfo info = new SavedWidgetInfo(); info.initialDraggableParent = widget.getParent(); if (info.initialDraggableParent instanceof AbsolutePanel) { info.initialDraggableParentLocation = new WidgetLocation(widget, info.initialDraggableParent); } else if (info.initialDraggableParent instanceof InsertPanel) { info.initialDraggableIndex = ((InsertPanel) info.initialDraggableParent).getWidgetIndex(widget); } else if (info.initialDraggableParent instanceof SimplePanel) { // save nothing } else { throw new RuntimeException("Unable to handle 'initialDraggableParent instanceof " + info.initialDraggableParent.getClass().getName() + "'; Please create your own " + PickupDragController.class.getName() + " and override saveSelectedWidgetsLocationAndStyle(), restoreSelectedWidgetsLocation() and restoreSelectedWidgetsStyle()"); } info.initialDraggableMargin = DOM.getStyleAttribute(widget.getElement(), "margin"); widget.getElement().getStyle().setProperty("margin", "0px"); savedWidgetInfoMap.put(widget, info); } }
From source file:com.allen_sauer.gwt.dnd.demo.client.example.duallist.ListBoxDragController.java
License:Apache License
@Override public void toggleSelection(Widget draggable) { super.toggleSelection(draggable); MouseListBox currentMouseListBox = (MouseListBox) draggable.getParent().getParent(); ArrayList<Widget> otherWidgets = new ArrayList<Widget>(); for (Widget widget : context.selectedWidgets) { if (widget.getParent().getParent() != currentMouseListBox) { otherWidgets.add(widget);//from w w w . j a v a 2 s . co m } } for (Widget widget : otherWidgets) { super.toggleSelection(widget); } }