Example usage for com.google.gwt.user.client.ui Widget getParent

List of usage examples for com.google.gwt.user.client.ui Widget getParent

Introduction

In this page you can find the example usage for com.google.gwt.user.client.ui Widget getParent.

Prototype

public Widget getParent() 

Source Link

Document

Gets this widget's parent panel.

Usage

From source file:org.drools.brms.client.ruleeditor.MetaDataWidget.java

License:Apache License

private void showRenameAsset(Widget source) {
    final FormStylePopup pop = new FormStylePopup("images/package_large.png", "Rename this item");
    final TextBox box = new TextBox();
    pop.addAttribute("New name", box);
    Button ok = new Button("Rename item");
    pop.addAttribute("", ok);
    ok.addClickListener(new ClickListener() {
        public void onClick(Widget w) {
            RepositoryServiceFactory.getService().renameAsset(uuid, box.getText(), new GenericCallback() {
                public void onSuccess(Object data) {
                    refreshView.execute();
                    Window.alert("Item has been renamed");
                    pop.hide();/*  w w w.jav  a 2  s .  co m*/
                }
            });
        }
    });

    pop.setPopupPosition(source.getParent().getParent().getAbsoluteLeft() - 18,
            source.getParent().getParent().getAbsoluteTop());
    pop.show();
}

From source file:org.drools.brms.client.ruleeditor.MetaDataWidget.java

License:Apache License

private void showEditPackage(final String pkg, Widget source) {
    final FormStylePopup pop = new FormStylePopup("images/package_large.png",
            "Move this item to another package");
    pop.addAttribute("Current package:", new Label(pkg));
    final RulePackageSelector sel = new RulePackageSelector();
    pop.addAttribute("New package:", sel);
    Button ok = new Button("Change package");
    pop.addAttribute("", ok);
    ok.addClickListener(new ClickListener() {

        public void onClick(Widget w) {
            if (sel.getSelectedPackage().equals(pkg)) {
                Window.alert("You need to pick a different package to move this to.");
                return;
            }/*from   w w w  . j  a  v a  2s.  c om*/
            RepositoryServiceFactory.getService().changeAssetPackage(uuid, sel.getSelectedPackage(),
                    "Moved from : " + pkg, new GenericCallback() {
                        public void onSuccess(Object data) {
                            makeDirty();
                            refreshView.execute();
                            pop.hide();
                        }

                    });

        }

    });
    pop.setPopupPosition(source.getParent().getParent().getAbsoluteLeft(),
            source.getParent().getParent().getAbsoluteTop());
    pop.show();
}

From source file:org.eclipse.draw2d.FigureCanvas.java

License:Open Source License

private boolean isInPalette(Widget widget) {
    Widget parent = widget.getParent();
    if (parent == null) {
        return false;
    } else {//  ww  w.  ja  v a  2  s .  com
        if (parent.getElement().getId().equals("PALETTE_PANEL")) {
            return true;
        } else {
            return isInPalette(parent);
        }
    }
}

From source file:org.eclipse.swt.widgets.Control.java

License:Open Source License

/**
 * Returns a rectangle describing the receiver's size and location relative
 * to its parent (or its display if its parent is null), unless the receiver
 * is a shell. In this case, the location is relative to the display.
 * /* w w  w .  j  a v a 2 s. c  o  m*/
 * @return the receiver's bounding rectangle
 * 
 * @exception SWTException
 *                <ul>
 *                <li>ERROR_WIDGET_DISPOSED - if the receiver has been
 *                disposed</li>
 *                <li>ERROR_THREAD_INVALID_ACCESS - if not called from the
 *                thread that created the receiver</li>
 *                </ul>
 */
public Rectangle getBounds() {
    com.google.gwt.user.client.ui.Widget gwtWidget = getGwtWidget();
    int offsetWidth;
    int offsetHeight;
    if (gwtWidget != null) {
        com.google.gwt.user.client.ui.Widget parentWidget = gwtWidget.getParent();
        Element element = parentWidget.getElement();
        offsetWidth = element.getOffsetWidth();
        offsetHeight = element.getOffsetHeight();
    } else {
        System.err.println("Control.getBounds() error: gwtWidget is null");
        offsetWidth = 30;
        offsetHeight = 15;
    }

    return new Rectangle(0, 0, offsetWidth, offsetHeight);
}

From source file:org.eclipse.swt.widgets.Control.java

License:Open Source License

protected void closeMenu(MenuBar gwtMenuBar) {
    com.google.gwt.user.client.ui.Widget widget = gwtMenuBar.getParent();
    if (widget instanceof PopupPanel) {
        ((PopupPanel) widget).hide();//w ww . ja v a 2 s . c o  m
    } else if (widget instanceof DecoratorPanel) {
        ((PopupPanel) widget.getParent()).hide();
    } else {
        closeMenu((MenuBar) widget);
    }
}

From source file:org.ednovo.gooru.client.mvp.shelf.collection.tab.resource.CollectionResourceTabView.java

License:Open Source License

@Override
public void setEditMode(boolean editMode, Widget resourceWidget) {
    Widget sequenceWidget = sequenceVerPanel
            .getWidget(collectionResourcePanelVc.getWidgetIndex(resourceWidget.getParent()));
    collectionResourcePanelVc.makeChildrenDraggable(!editMode);
    sequenceWidget.setHeight((resourceWidget.getOffsetHeight() - 7) + "px");
}

From source file:org.freemedsoftware.gwt.client.widget.AccordionPanel.java

License:Open Source License

protected void selectPanel(Widget widget, Label label) {
    widget.addStyleDependentName("selected");
    currentlyExpanded = widget.getParent();
    currentlyExpandedLabel = label;//from w  ww  .j a  va 2 s.c  o  m
    currentlyExpandedLabel.addStyleDependentName("selected");
    Element elem = widget.getParent().getElement();
    DOM.setStyleAttribute(elem, "overflow", "auto");
    DOM.setStyleAttribute(elem, animField, "auto");
    elem.getStyle().setDisplay(Display.BLOCK);
}

From source file:org.freemedsoftware.gwt.client.widget.PatientTagsWidget.java

License:Open Source License

/**
 * Actual addition of tag to display.//www  .j a v a 2s.c o  m
 * 
 * @param tag
 */
protected void addTagToDisplay(String tag) {
    JsonUtil.debug("addTagToDisplay(" + tag + ")");
    HorizontalPanel p = new HorizontalPanel();
    p.setTitle(tag);
    final String oldTagName = tag.trim();
    final HTML r = new HTML("<sup>X</sup>");
    final Anchor tagLabel = new Anchor(tag);
    tagLabel.setStylePrimaryName("freemed-PatientTag");
    JsonUtil.debug("addclicklistener");
    tagLabel.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent evt) {
            final Widget w = (Widget) evt.getSource();
            final PopupPanel p = new PopupPanel(true);
            final FlexTable fT = new FlexTable();
            fT.setWidget(0, 0, new HTML("<b>" + oldTagName + "</b>"));
            fT.setWidget(1, 0, new Label(_("Rename Tag")));
            final TextBox newTagName = new TextBox();
            fT.setWidget(2, 0, newTagName);
            final CustomButton changeTagButton = new CustomButton(_("Change"), AppConstants.ICON_MODIFY);
            fT.setWidget(2, 1, changeTagButton);
            changeTagButton.addClickHandler(new ClickHandler() {
                @Override
                public void onClick(ClickEvent bEvt) {
                    if (newTagName.getText().trim().length() > 0) {
                        if (Util.getProgramMode() == ProgramMode.STUBBED) {
                            // Stubbed mode
                            p.hide();
                            p.removeFromParent();
                            ((HorizontalPanel) w.getParent()).removeFromParent();
                            addTagToDisplay(newTagName.getText().trim());
                        } else if (Util.getProgramMode() == ProgramMode.JSONRPC) {
                            String[] params = { oldTagName, newTagName.getText().trim() };
                            RequestBuilder builder = new RequestBuilder(RequestBuilder.POST,
                                    URL.encode(Util.getJsonRequest(
                                            "org.freemedsoftware.module.PatientTag.ChangeTag", params)));
                            try {
                                builder.sendRequest(null, new RequestCallback() {
                                    public void onError(Request request, Throwable ex) {
                                    }

                                    public void onResponseReceived(Request request, Response response) {
                                        if (200 == response.getStatusCode()) {
                                            Boolean r = (Boolean) JsonUtil.shoehornJson(
                                                    JSONParser.parseStrict(response.getText()), "Boolean");
                                            if (r != null) {
                                                p.hide();
                                                p.removeFromParent();
                                                ((HorizontalPanel) w.getParent()).removeFromParent();
                                                addTagToDisplay(newTagName.getText().trim());
                                            }
                                        } else {
                                        }
                                    }
                                });
                            } catch (RequestException e) {
                            }
                        } else {
                            getProxy().ChangeTag(oldTagName, newTagName.getText().trim(),
                                    new AsyncCallback<Boolean>() {
                                        public void onSuccess(Boolean o) {
                                            p.hide();
                                            p.removeFromParent();
                                            ((HorizontalPanel) w.getParent()).removeFromParent();
                                            addTagToDisplay(newTagName.getText().trim());
                                        }

                                        public void onFailure(Throwable t) {
                                            GWT.log("Exception", t);
                                        }
                                    });
                        }
                    }
                }
            });
            final CustomButton searchButton = new CustomButton(_("Search"), AppConstants.ICON_SEARCH);
            fT.setWidget(2, 2, searchButton);
            searchButton.addClickHandler(new ClickHandler() {
                @Override
                public void onClick(ClickEvent evt) {
                    PatientTagSearchScreen searchScreen = new PatientTagSearchScreen();
                    searchScreen.setTagValue(oldTagName);
                    Util.spawnTab(_("Tag Search"), searchScreen);
                    p.hide();
                }
            });
            p.add(fT);
            p.setPopupPosition(tagLabel.getAbsoluteLeft() + 5, tagLabel.getAbsoluteTop() - 10);
            p.setStyleName("freemed-PatientTagPopup");
            p.show();
        }
    });
    p.add(tagLabel);
    p.add(r);
    p.setStyleName("freemed-PatientTag");
    r.addStyleName("freemed-PatientTagRemove");
    r.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent evt) {
            if (Window.confirm("Are you sure you want to remove this tag?")) {
                HorizontalPanel container = (HorizontalPanel) ((Widget) evt.getSource()).getParent();
                removeTag(container.getTitle(), container);
            }
        }
    });
    flowPanel.add(p);
}

From source file:org.freemedsoftware.gwt.client.widget.UserMultipleChoiceWidget.java

License:Open Source License

protected void addValue(String text, final Integer value) {
    // Push into internal store of values
    pushWidgetValue(value);//  ww  w.ja va 2 s  .co  m

    // Create new container, push in
    final HorizontalPanel hp = new HorizontalPanel();
    hp.add(new Label(text));
    Button removeButton = new Button("<sup>X</sup>");
    removeButton.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent evt) {
            Widget w = (Widget) evt.getSource();
            // Remove the HorizontalPanel object from its parent container,
            // "container"
            w.getParent().removeFromParent();

            // Remove from data store
            removeValueFromStore(value);
        }
    });
    hp.add(removeButton);

    container.add(hp);
}

From source file:org.gems.ajax.client.connection.RectilinearConnection.java

License:Open Source License

public void updateDecorations() {
    if (segments_ != null) {
        for (ConnectionDecoration d : getConnectionDecorations()) {
            if (d.getLocation() instanceof BasicConnectionLocation) {
                BasicConnectionLocation bcl = (BasicConnectionLocation) d.getLocation();

                int direction = LEFT;
                Segment s = null;
                Segment s2 = null;

                if (bcl.getLocation() == START) {
                    s = segments_.get(0);
                    s2 = segments_.get(segments_.size() - 1);
                } else if (bcl.getLocation() == END) {
                    s = segments_.get(segments_.size() - 1);
                    s2 = segments_.get(0);
                } else if (bcl.getLocation() == MIDDLE) {
                    s = segments_.get(2);
                    s2 = segments_.get(0);
                }/*from   w w w  .  j a v  a2s  .com*/

                if (s.isHorizontal()) {
                    direction = (s.getAbsoluteLeft() - s2.getAbsoluteLeft() < 0) ? LEFT : RIGHT;
                } else {
                    direction = (s.getAbsoluteTop() - s2.getAbsoluteTop() < 0) ? UP : DOWN;
                }

                d.setDirection(direction);

                Widget w = d.getWidget();

                int x = 0;
                int y = 0;
                Point p = Util.getDiagramLocation(s);
                if (direction == UP) {
                    x = Util.half(Util.getOffsetWidth(s)) + p.x - Util.half(w.getOffsetWidth());
                    y = p.y - 3;
                } else if (direction == DOWN) {
                    x = Util.half(Util.getOffsetWidth(s)) + p.x - Util.half(w.getOffsetWidth());
                    y = 3 + p.y + s.getLength() - w.getOffsetHeight();
                } else if (direction == LEFT) {
                    y = Util.half(Util.getOffsetHeight(s)) + p.y - Util.half(w.getOffsetHeight());
                    x = p.x - 3;
                } else if (direction == RIGHT) {
                    y = Util.half(Util.getOffsetHeight(s)) + p.y - Util.half(w.getOffsetHeight());
                    x = 3 + p.x + s.getLength() - w.getOffsetWidth();
                }

                x = adjustXOffset(bcl, s, w, x, direction);
                y = adjustYOffset(bcl, s, w, y, direction);

                AbsolutePanel cp = getConnectionLayer().getConnectionPanel();
                if (w.getParent() != cp) {
                    w.removeFromParent();
                    cp.add(w, x, y);
                } else {
                    cp.setWidgetPosition(w, x, y);
                }

                d.update();
            }
        }
    }
}