Example usage for com.google.gwt.user.client.ui VerticalPanel getWidgetIndex

List of usage examples for com.google.gwt.user.client.ui VerticalPanel getWidgetIndex

Introduction

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

Prototype

int getWidgetIndex(Widget child);

Source Link

Document

Gets the index of the specified child widget.

Usage

From source file:de.catma.ui.client.ui.tagger.menu.TagMenuPopup.java

License:Open Source License

public TagMenuPopup(TaggerEditor vTagger, String lastSelectedColor) {
    super(true);/* w  w  w  .jav a  2  s . c o m*/
    getElement().addClassName("tagmenu-popup");
    this.setText("Annotations");
    this.vTagger = vTagger;
    this.lastSelectedColor = lastSelectedColor;
    root = new TreeItem("Available annotations");
    final Tree tree = new Tree();
    tree.addItem(root);
    root.setState(true);
    root.setStyleName("tagger_menu_root");

    final VerticalPanel vPanel = new VerticalPanel();

    if (vTagger.hasSelection()) {

        final VerticalPanel annotationCreationPanel = new VerticalPanel();
        annotationCreationPanel.setSpacing(5);
        annotationCreationPanel.setWidth("100%");
        final TextArea annotationBodyInput = new TextArea();
        annotationBodyInput.setWidth("90%");
        annotationCreationPanel.add(annotationBodyInput);
        final HorizontalPanel annotationCreationButtonPanel = new HorizontalPanel();
        annotationCreationButtonPanel.setSpacing(5);
        final Label colorLabel = new HTML("     ");
        final ColorPicker colorPicker = new ColorPicker() {
            @Override
            public void onChange(Widget sender) {
                super.onChange(sender);
                colorLabel.getElement().setAttribute("style", "background:#" + this.getHexColor() + ";");
            }
        };
        try {
            if (lastSelectedColor != null) {
                colorPicker.setHex(lastSelectedColor);
            } else {
                int[] randomColor = getRandomColor();
                colorPicker.setRGB(randomColor[0], randomColor[1], randomColor[2]);
            }
        } catch (Exception e) {
            // well...
        }
        colorLabel.getElement().setAttribute("style", "background:#" + colorPicker.getHexColor() + ";");

        HorizontalPanel colorPanel = new HorizontalPanel();
        colorPanel.setSpacing(5);
        PushButton colorButton = new PushButton("Change color...");
        colorPanel.add(colorButton);

        colorPanel.add(colorLabel);

        HandlerRegistration colorButtonReg = colorButton.addClickHandler(new ClickHandler() {

            public void onClick(ClickEvent event) {

                annotationCreationPanel.insert(colorPicker,
                        annotationCreationPanel.getWidgetIndex(annotationCreationButtonPanel));
                TagMenuPopup.this.center();
            }
        });
        handlerRegistrations.add(colorButtonReg);
        annotationCreationPanel.add(colorPanel);

        PushButton saveButton = new PushButton("Save");
        //saveButton.setStylePrimaryName("tagger-pushButton");
        HandlerRegistration saveButtonReg = saveButton.addClickHandler(new ClickHandler() {

            public void onClick(ClickEvent event) {
                //   TagMenuPopup.this.vTagger.createAndAddTagIntance(colorPicker.getHexColor());
                TagMenuPopup.this.lastSelectedColor = colorPicker.getHexColor();
                hide();
            }
        });
        handlerRegistrations.add(saveButtonReg);

        PushButton cancelButton = new PushButton("Cancel");
        //cancelButton.setStylePrimaryName("tagger-pushButton");

        annotationCreationButtonPanel.add(saveButton);
        annotationCreationButtonPanel.add(cancelButton);
        annotationCreationPanel.add(annotationCreationButtonPanel);

        PushButton addAnnotationButton = new PushButton("Add annotation...");
        //addAnnotationButton.setStylePrimaryName("tagger-pushButton");

        HandlerRegistration addAnnotationBtReg = addAnnotationButton.addClickHandler(new ClickHandler() {

            public void onClick(ClickEvent event) {
                vPanel.insert(annotationCreationPanel, vPanel.getWidgetIndex(tree));
            }
        });
        handlerRegistrations.add(addAnnotationBtReg);
        vPanel.add(addAnnotationButton);

        HandlerRegistration cancelButtonReg = cancelButton.addClickHandler(new ClickHandler() {
            public void onClick(ClickEvent event) {
                annotationBodyInput.setText("");
                vPanel.remove(annotationCreationPanel);
            }
        });

        handlerRegistrations.add(cancelButtonReg);
    }

    vPanel.add(tree);
    vPanel.setStylePrimaryName("tagger_menu");
    setWidget(vPanel);
}

From source file:org.eurekastreams.web.client.ui.common.stream.filters.FilterDragHandler.java

License:Apache License

/**
 * Gets fired when the drag is finished.
 *
 * @param event//from w  ww .ja v a  2s  .  c  o m
 *            the event.
 */
public void onDragEnd(final DragEndEvent event) {
    listPanel.fixHiddenLine();
    FilterPanel listItem = (FilterPanel) event.getContext().draggable;
    VerticalPanel dropPanel = (VerticalPanel) event.getContext().finalDropController.getDropTarget();

    Integer hiddenLineIndex = listPanel.getHiddenLineIndex();
    Integer itemIndex = new Integer(dropPanel.getWidgetIndex((Widget) listItem));

    if (itemIndex > hiddenLineIndex) {
        itemIndex--;
        ((Widget) listItem).addStyleName(StaticResourceBundle.INSTANCE.coreCss().hide());
        listPanel.showTextOnHiddenLine();
    } else {
        ((Widget) listItem).removeStyleName(StaticResourceBundle.INSTANCE.coreCss().hide());
        listPanel.hideTextOnHiddenLine(hiddenLineIndex);
    }

    SetStreamOrderRequest request = new SetStreamOrderRequest(listItem.getItemId(), itemIndex,
            hiddenLineIndex - 1);
    reorderable.reorder(request);

}

From source file:org.openxdata.querybuilder.client.view.DisplayFieldsView.java

private void moveItemUp(VerticalPanel vertialPanel, Widget widget) {
    int index = vertialPanel.getWidgetIndex(widget);
    if (index == 1)
        return;//  ww  w . j a va 2s  .com
    vertialPanel.remove(widget);
    vertialPanel.insert(widget, index - 1);
}

From source file:org.openxdata.querybuilder.client.view.DisplayFieldsView.java

private void moveItemDown(VerticalPanel vertialPanel, Widget widget) {
    int index = vertialPanel.getWidgetIndex(widget);

    if (widget instanceof SortColumnWidget && index == vertialPanel.getWidgetCount() - 1)
        return;/*from  ww w. ja va2 s  . c o  m*/
    else if (widget instanceof DisplayColumnWidget && index == vertialPanel.getWidgetCount() - 2)
        return;

    vertialPanel.remove(widget);
    vertialPanel.insert(widget, index + 1);
}

From source file:org.pentaho.platform.dataaccess.datasource.ui.importing.MetadataImportDialogController.java

License:Open Source License

private void reset() {
    metaFileLocation//  w w w.ja v  a  2  s.c o  m
            .setValue(resBundle.getString("importDialog.SELECT_METAFILE_LABEL", "Browse for metadata file"));
    importDialogModel.removeAllLocalizedBundles();
    VerticalPanel gwtHiddenArea = (VerticalPanel) hiddenArea.getManagedObject();
    if (formPanel != null && gwtHiddenArea.getWidgetIndex(formPanel) != -1) {
        gwtHiddenArea.remove(formPanel);
    }
    acceptButton.setDisabled(true);
    domainIdText.setValue("");
    overwrite = false;
}