List of usage examples for com.google.gwt.user.client.ui Widget getParent
public Widget getParent()
From source file:org.kuali.student.common.ui.client.util.ExportUtils.java
License:Educational Community License
/** * /*from ww w .ja v a 2 s.c o m*/ * Inspect the given widget for the value and add it to the export element object. * * @param exportItem * @param fieldWidget * @param setFirstFieldValue * @param viewName * @param sectionName * @return */ public static ExportElement getExportItemDetails(ExportElement exportItem, Widget fieldWidget, boolean setFirstFieldValue, String viewName, String sectionName) { // Do not display the widget data if it is not visible on the screen. if (!fieldWidget.getParent().getElement().getStyle().getDisplay().equals("none")) { if (fieldWidget instanceof HasHTML) { // HasHTML... HasHTML itemHasHTML = (HasHTML) fieldWidget; setFieldValue(exportItem, setFirstFieldValue, itemHasHTML.getHTML()); } else if (fieldWidget instanceof HasText) { // Hastext... HasText itemHasTextValue = (HasText) fieldWidget; setFieldValue(exportItem, setFirstFieldValue, itemHasTextValue.getText()); } else if (fieldWidget instanceof KSSelectedList) { KSSelectedList selectedList = (KSSelectedList) fieldWidget; List<KSItemLabel> selectedItems = selectedList.getSelectedItems(); String values = new String(); for (int j = 0; j < selectedItems.size(); j++) { values = selectedItems.get(j).getDisplayText(); } setFieldValue(exportItem, setFirstFieldValue, values); } else if (fieldWidget instanceof KSPicker) { KSPicker picker = (KSPicker) fieldWidget; if (picker.getInputWidget() instanceof HasText) { HasText item = (HasText) picker.getInputWidget(); setFieldValue(exportItem, setFirstFieldValue, item.getText()); } else if (picker.getInputWidget() instanceof KSLabelList) { String fieldValue = null; KSLabelList widget = (KSLabelList) picker.getInputWidget(); List<String> selected = widget.getSelectedItemsForExport(); for (int j = 0; j < selected.size(); j++) { if (fieldValue == null) { fieldValue = new String(selected.get(j)); } else { fieldValue = fieldValue + ", " + selected.get(j); } } setFieldValue(exportItem, setFirstFieldValue, fieldValue); } } else if (fieldWidget instanceof ListBox) { // Get the selected element from a list box. ListBox listBox = (ListBox) fieldWidget; setFieldValue(exportItem, setFirstFieldValue, listBox.getItemText(listBox.getSelectedIndex())); } else if (fieldWidget instanceof SectionTitle) { try { // Retrieve the title from sections. SectionTitle sectionTitle = (SectionTitle) fieldWidget; setFieldValue(exportItem, setFirstFieldValue, sectionTitle.getExportFieldValue()); // If the value does not already contain the bold html tags, set the print type to bold. if (!exportItem.getValue().contains("<b>")) { exportItem.setPrintType(ExportElement.BOLD); } } catch (Exception e) { // ignore, section tile interface problem - only in debugging."); } } else if (fieldWidget instanceof SummaryTable) { // Call custom details for widget method for summary tables. if (fieldWidget.isVisible()) { exportItem.setSubset(ExportUtils.getDetailsForWidget((SummaryTable) fieldWidget)); } } else if (fieldWidget instanceof ReportExportWidget) { // Retrieve custom implementation data of report export widget. if (fieldWidget.isVisible()) { ReportExportWidget widget = (ReportExportWidget) fieldWidget; if (widget.isExportElement()) { exportItem.setSubset(widget.getExportElementSubset(exportItem)); setFieldValue(exportItem, setFirstFieldValue, widget.getExportFieldValue()); } } } else if (fieldWidget instanceof ComplexPanel) { // Retrieve child elements from complex panel. if (fieldWidget.isVisible()) { exportItem.setSubset(ExportUtils.getDetailsForWidget(fieldWidget, viewName, sectionName)); } } else if (fieldWidget instanceof FieldElement) { // Retrieve subset from the widget on the field element. if (fieldWidget.isVisible()) { Widget widget = ((FieldElement) fieldWidget).getFieldWidget(); exportItem = getExportItemDetails(exportItem, widget, true, viewName, sectionName); exportItem.setPrintType(ExportElement.PARAGRAPH); } } } return exportItem; }
From source file:org.kuali.student.common.ui.client.util.ExportUtils.java
License:Educational Community License
/** * This method gets the current controller based on the widget that was passed to it. * /* w w w . jav a 2s . com*/ * @param theWidget * @return currentController */ public static Controller getController(Widget theWidget) { // TODO Nina - This can't be the correct way of getting handle to // Controller, isn't there a better way?? if (theWidget != null) { if (theWidget instanceof Controller) { Controller controller = (Controller) theWidget; return controller; } else { return getController(theWidget.getParent()); } } else { return null; } }
From source file:org.kuali.student.common.ui.client.util.ExportUtils.java
License:Educational Community License
/** * // ww w . j av a2 s . co m * Retrieves the sub elements from a container widget. * * @param currentViewWidget * @param viewName * @param sectionName * @return */ public static List<ExportElement> getDetailsForWidget(Widget currentViewWidget, String viewName, String sectionName) { List<ExportElement> childElements = new ArrayList<ExportElement>(); if (!currentViewWidget.getParent().getElement().getStyle().getDisplay().equals("none")) { if (currentViewWidget instanceof Section) { Section widgetHasFields = (Section) currentViewWidget; List<FieldDescriptor> widgetFields = widgetHasFields.getFields(); for (FieldDescriptor field : widgetFields) { ExportElement exportItem = createExportElement(viewName, sectionName, childElements, field.getFieldElement().getFieldWidget()); exportItem.setFieldLabel(field.getFieldLabel()); } } else if (currentViewWidget instanceof KSListPanel) { KSListPanel ksListPanelWidget = (KSListPanel) currentViewWidget; WidgetCollection children = ksListPanelWidget.getChildren(); for (int i = 0; i < children.size(); i++) { createExportElement(viewName, sectionName, childElements, children.get(i)); } } else if (currentViewWidget instanceof ULPanel) { ComplexPanel complexPanel = (ComplexPanel) currentViewWidget; if (complexPanel.isVisible()) { for (int i = 0; i < complexPanel.getWidgetCount(); i++) { Widget child = complexPanel.getWidget(i); if (child instanceof FlowPanel) { List<ExportElement> subset = ExportUtils.getDetailsForWidget(child, viewName, sectionName); if (subset != null && subset.size() > 0) { //Code Changed for JIRA-9075 - SONAR Critical issues - Use get(0) with caution - 5 int firstExportElement = 0; subset.get(firstExportElement).setPrintType(ExportElement.LIST); childElements.addAll(subset); } } else if (!(child instanceof KSButton) && !(child instanceof WarnContainer)) { ExportElement exportItem = createExportElement(viewName, sectionName, childElements, child); exportItem.setPrintType(ExportElement.LIST); } } } } else if (currentViewWidget instanceof ComplexPanel) { ComplexPanel complexPanel = (ComplexPanel) currentViewWidget; if (complexPanel.isVisible()) { for (int i = 0; i < complexPanel.getWidgetCount(); i++) { Widget child = complexPanel.getWidget(i); if (child instanceof FlowPanel) { List<ExportElement> subset = ExportUtils.getDetailsForWidget(child, viewName, sectionName); if (subset != null && subset.size() > 0) { childElements.addAll(subset); } } else if (!(child instanceof KSButton) && !(child instanceof WarnContainer)) { createExportElement(viewName, sectionName, childElements, child); } } } } else { System.out.println( "ExportUtils does not cater for this type..." + currentViewWidget.getClass().getName()); } } return childElements; }
From source file:org.kuali.student.common.ui.client.util.ExportUtils.java
License:Educational Community License
public static List<ExportElement> getDetailsForWidget(ExportElement element, Widget currentViewWidget, boolean setFirstFieldValue, String viewName, String sectionName) { List<ExportElement> childElements = new ArrayList<ExportElement>(); if (!currentViewWidget.getParent().getElement().getStyle().getDisplay().equals("none")) { if (currentViewWidget instanceof Section) { Section widgetHasFields = (Section) currentViewWidget; List<FieldDescriptor> widgetFields = widgetHasFields.getFields(); for (FieldDescriptor field : widgetFields) { ExportElement exportItem = createExportElement(viewName, sectionName, childElements, field.getFieldElement().getFieldWidget()); exportItem.setFieldLabel(field.getFieldLabel()); }// www . j a v a 2 s. co m } else if (currentViewWidget instanceof KSListPanel) { KSListPanel ksListPanelWidget = (KSListPanel) currentViewWidget; WidgetCollection children = ksListPanelWidget.getChildren(); for (int i = 0; i < children.size(); i++) { if (!element.getSubset().isEmpty() && i < element.getSubset().size()) createExportElementOld(element.getSubset().get(i), viewName, sectionName, childElements, children.get(i)); else createExportElement2(viewName, sectionName, childElements, children.get(i)); } } else if (currentViewWidget instanceof ULPanel) { ComplexPanel complexPanel = (ComplexPanel) currentViewWidget; if (complexPanel.isVisible()) { for (int i = 0; i < complexPanel.getWidgetCount(); i++) { Widget child = complexPanel.getWidget(i); if (child instanceof FlowPanel) { List<ExportElement> subset = ExportUtils.getDetailsForWidget(child, viewName, sectionName); if (subset != null && subset.size() > 0) { //Code Changed for JIRA-9075 - SONAR Critical issues - Use get(0) with caution - 5 int firstExportElement = 0; subset.get(firstExportElement).setPrintType(ExportElement.LIST); childElements.addAll(subset); } } else if (!(child instanceof KSButton) && !(child instanceof WarnContainer)) { ExportElement exportItem = createExportElement(viewName, sectionName, childElements, child); exportItem.setPrintType(ExportElement.LIST); } } } } else if (currentViewWidget instanceof ComplexPanel) { ComplexPanel complexPanel = (ComplexPanel) currentViewWidget; if (complexPanel.isVisible()) { for (int i = 0; i < complexPanel.getWidgetCount(); i++) { Widget child = complexPanel.getWidget(i); if (child instanceof FlowPanel) { List<ExportElement> subset = ExportUtils.getDetailsForWidget(child, viewName, sectionName); if (subset != null && subset.size() > 0) { childElements.addAll(subset); } } else if (!(child instanceof KSButton) && !(child instanceof WarnContainer)) { createExportElement(viewName, sectionName, childElements, child); } } } } else { System.out.println( "ExportUtils does not cater for this type..." + currentViewWidget.getClass().getName()); } } return childElements; }
From source file:org.kuali.student.common.ui.client.util.ExportUtils.java
License:Educational Community License
public static ArrayList<ExportElement> getExportElementsFromView(Widget currentViewWidget, ArrayList<ExportElement> exportElements, String viewName, String sectionName) { if (exportElements == null) { exportElements = new ArrayList<ExportElement>(); }// w w w . j a v a 2 s . co m if (currentViewWidget.getParent() == null || !currentViewWidget.getParent().getElement().getStyle().getDisplay().equals("none")) { if (currentViewWidget instanceof VerticalSectionView) { Section widgetHasFields = (Section) currentViewWidget; List<FieldDescriptor> widgetFields = widgetHasFields.getFields(); for (FieldDescriptor field : widgetFields) { Widget child = field.getFieldElement().getFieldWidget(); ExportElement exportItem = createExportElement(viewName, sectionName, exportElements, child); exportItem.setFieldLabel(field.getFieldLabel()); } if ((currentViewWidget instanceof BaseSection) && (widgetHasFields.getFields().size() == 0)) { BaseSection bSection = (BaseSection) currentViewWidget; createExportElement(viewName, sectionName, exportElements, bSection.getLayout()); } } } return exportElements; }
From source file:org.metawidget.gwt.client.ui.layout.FlexTableLayout.java
License:LGPL
/** * Get the number of columns to use in the layout. * <p>/*from ww w .ja v a 2s .com*/ * Nested Metawidgets are always just single column. */ private int getEffectiveNumberOfColumns(Widget container) { if (container.getParent() instanceof FlexTable && container.getParent().getParent() instanceof GwtMetawidget) { return 1; } return mNumberOfColumns; }
From source file:org.mobicents.servlet.management.client.dnd.PickupDragController.java
License:Open Source License
/** * Save the selected widgets' current location in case they much * be restored due to a cancelled drop.//from www . j a v a 2 s . c o m * @see #restoreSelectedWidgetsLocation() */ protected void saveSelectedWidgetsLocationAndStyle() { savedWidgetInfoMap = new HashMap(); for (int q = 0; q < context.selectedWidgets.size(); q++) { Widget widget = (Widget) context.selectedWidgets.get(q); SavedWidgetInfo info = new SavedWidgetInfo(); info.initialDraggableParent = widget.getParent(); // TODO simplify after enhancement for issue 1112 provides InsertPanel interface // http://code.google.com/p/google-web-toolkit/issues/detail?id=1112 if (info.initialDraggableParent instanceof AbsolutePanel) { info.initialDraggableParentLocation = new WidgetLocation(widget, info.initialDraggableParent); } else if (info.initialDraggableParent instanceof HorizontalPanel) { info.initialDraggableIndex = ((HorizontalPanel) info.initialDraggableParent).getWidgetIndex(widget); } else if (info.initialDraggableParent instanceof VerticalPanel) { info.initialDraggableIndex = ((VerticalPanel) info.initialDraggableParent).getWidgetIndex(widget); } else if (info.initialDraggableParent instanceof FlowPanel) { info.initialDraggableIndex = ((FlowPanel) info.initialDraggableParent).getWidgetIndex(widget); } else if (info.initialDraggableParent instanceof SimplePanel) { // save nothing } else { throw new RuntimeException("Unable to handle 'initialDraggableParent instanceof " + info.initialDraggableParent.toString() + "'; Please create your own DragController and override saveDraggableLocationAndStyle() and restoreDraggableLocation()"); } info.initialDraggableMargin = DOM.getStyleAttribute(widget.getElement(), "margin"); DOM.setStyleAttribute(widget.getElement(), "margin", "0px"); savedWidgetInfoMap.put(widget, info); } }
From source file:org.onecmdb.ui.gwt.desktop.client.action.CloseTextToolItem.java
License:Open Source License
private void closeParentWindow(Widget w) { if (w == null) { return;/*from w w w .j a v a 2 s.c o m*/ } if (w instanceof Window) { ((Window) w).close(); } closeParentWindow(w.getParent()); }
From source file:org.onecmdb.ui.gwt.desktop.client.widget.grid.CIPropertyPanel.java
License:Open Source License
protected void setHeader(Widget parent, String header) { if (parent == null) { return;/*from ww w. jav a2 s . c o m*/ } if (parent instanceof Window) { ((Window) parent).setHeading(header); return; } setHeader(parent.getParent(), header); }
From source file:org.onecmdb.ui.gwt.toolkit.client.view.dnd.DragControl.java
License:Open Source License
private AbsolutePanel getAbsoluteWidgetPanel(Widget widget) { if (widget == null) { return (null); }//ww w .j a v a 2 s .co m Widget parent = widget.getParent(); if (parent == null) { return (null); } if (parent instanceof AbsolutePanel) { return ((AbsolutePanel) parent); } return (getAbsoluteWidgetPanel(parent)); }