Search in sources :

Example 51 with FlowPanel

use of com.google.gwt.user.client.ui.FlowPanel in project che by eclipse.

the class PreviewViewImpl method checkParentState.

private void checkParentState(TreeItem treeItem, Boolean value) {
    TreeItem parentItem = treeItem.getParentItem();
    if (parentItem == null) {
        return;
    }
    if (!(parentItem.getWidget() instanceof FlowPanel)) {
        return;
    }
    FlowPanel parentChangeContainer = (FlowPanel) parentItem.getWidget();
    if (!(parentChangeContainer.getWidget(0) instanceof CheckBox)) {
        return;
    }
    CheckBox parentCheckBox = (CheckBox) parentChangeContainer.getWidget(0);
    if (value && !parentCheckBox.getValue()) {
        parentCheckBox.setValue(true);
        checkParentState(parentItem, true);
    }
}
Also used : TreeItem(com.google.gwt.user.client.ui.TreeItem) CheckBox(com.google.gwt.user.client.ui.CheckBox) FlowPanel(com.google.gwt.user.client.ui.FlowPanel)

Example 52 with FlowPanel

use of com.google.gwt.user.client.ui.FlowPanel in project che by eclipse.

the class PreviewViewImpl method createTreeElement.

private void createTreeElement(final TreeItem root, String changeName, List<RefactoringPreview> children) {
    FlowPanel element = new FlowPanel();
    element.getElement().getStyle().setFloat(LEFT);
    CheckBox itemCheckBox = new CheckBox();
    itemCheckBox.setValue(true);
    itemCheckBox.getElement().getStyle().setFloat(LEFT);
    itemCheckBox.getElement().getStyle().setMarginTop(3, PX);
    Label name = new Label(changeName);
    name.addClickHandler(new ClickHandler() {

        @Override
        public void onClick(ClickEvent event) {
            delegate.onSelectionChanged(containerChanges.get(root));
            root.setSelected(true);
        }
    });
    name.getElement().getStyle().setFloat(LEFT);
    element.add(itemCheckBox);
    element.add(name);
    root.setWidget(element);
    element.getElement().getParentElement().getStyle().setMargin(1, PX);
    itemCheckBox.addValueChangeHandler(new ValueChangeHandler<Boolean>() {

        @Override
        public void onValueChange(ValueChangeEvent<Boolean> event) {
            checkChildrenState(root, event.getValue());
            checkParentState(root, event.getValue());
            RefactoringPreview change = containerChanges.get(root);
            change.setEnabled(event.getValue());
            delegate.onEnabledStateChanged(change);
        }
    });
    if (children.isEmpty()) {
        return;
    }
    for (RefactoringPreview child : children) {
        TreeItem treeItem = new TreeItem();
        containerChanges.put(treeItem, child);
        createTreeElement(treeItem, child.getText(), child.getChildrens());
        root.addItem(treeItem);
    }
}
Also used : ClickHandler(com.google.gwt.event.dom.client.ClickHandler) TreeItem(com.google.gwt.user.client.ui.TreeItem) CheckBox(com.google.gwt.user.client.ui.CheckBox) ClickEvent(com.google.gwt.event.dom.client.ClickEvent) FlowPanel(com.google.gwt.user.client.ui.FlowPanel) Label(com.google.gwt.user.client.ui.Label) RefactoringPreview(org.eclipse.che.ide.ext.java.shared.dto.refactoring.RefactoringPreview)

Example 53 with FlowPanel

use of com.google.gwt.user.client.ui.FlowPanel in project gwt-test-utils by gwt-test-utils.

the class GwtBootstrapModule method onModuleLoad.

public void onModuleLoad() {
    FlowPanel panel = new FlowPanel();
    RootLayoutPanel.get().add(panel);
    widget = new TestWidget();
    panel.add(widget);
}
Also used : FlowPanel(com.google.gwt.user.client.ui.FlowPanel)

Example 54 with FlowPanel

use of com.google.gwt.user.client.ui.FlowPanel in project rstudio by rstudio.

the class ModifyKeyboardShortcutsWidget method createMainWidget.

@Override
protected Widget createMainWidget() {
    resetState();
    setEscapeDisabled(true);
    setEnterDisabled(true);
    previewHandler_ = Event.addNativePreviewHandler(new NativePreviewHandler() {

        @Override
        public void onPreviewNativeEvent(NativePreviewEvent preview) {
            if (swallowNextKeyUpEvent_ && preview.getTypeInt() == Event.ONKEYUP) {
                swallowNextKeyUpEvent_ = false;
                preview.cancel();
                preview.getNativeEvent().stopPropagation();
                preview.getNativeEvent().preventDefault();
            } else if (preview.getTypeInt() == Event.ONKEYDOWN) {
                int keyCode = preview.getNativeEvent().getKeyCode();
                if (keyCode == KeyCodes.KEY_ESCAPE || keyCode == KeyCodes.KEY_ENTER) {
                    // If the DataGrid (or an underlying element) has focus, let it
                    // handle the escape / enter key.
                    Element target = preview.getNativeEvent().getEventTarget().cast();
                    Element foundTable = DomUtils.findParentElement(target, new ElementPredicate() {

                        @Override
                        public boolean test(Element el) {
                            return el.equals(table_.getElement());
                        }
                    });
                    if (foundTable != null)
                        return;
                    // the widget.
                    if (filterWidget_.isFocused()) {
                        if (keyCode == KeyCodes.KEY_ENTER) {
                            table_.setKeyboardSelectedRow(0);
                            table_.setKeyboardSelectedColumn(0);
                            return;
                        } else if (keyCode == KeyCodes.KEY_ESCAPE) {
                            focusOkButton();
                            return;
                        }
                    }
                    // Otherwise, handle Enter / Escape 'modally' as we might normally do.
                    preview.cancel();
                    preview.getNativeEvent().stopPropagation();
                    preview.getNativeEvent().preventDefault();
                    if (keyCode == KeyCodes.KEY_ENTER) {
                        clickOkButton();
                        return;
                    } else if (keyCode == KeyCodes.KEY_ESCAPE) {
                        closeDialog();
                        return;
                    }
                }
            }
        }
    });
    addAttachHandler(new AttachEvent.Handler() {

        @Override
        public void onAttachOrDetach(AttachEvent event) {
            if (event.isAttached())
                ;
            else
                previewHandler_.removeHandler();
        }
    });
    VerticalPanel container = new VerticalPanel();
    FlowPanel headerPanel = new FlowPanel();
    Label radioLabel = new Label("Show:");
    radioLabel.getElement().getStyle().setFloat(Style.Float.LEFT);
    radioLabel.getElement().getStyle().setMarginRight(8, Unit.PX);
    headerPanel.add(radioLabel);
    headerPanel.add(radioAll_);
    radioAll_.setValue(true);
    headerPanel.add(radioCustomized_);
    filterWidget_.getElement().getStyle().setFloat(Style.Float.LEFT);
    filterWidget_.getElement().getStyle().setMarginLeft(10, Unit.PX);
    filterWidget_.getElement().getStyle().setMarginTop(-1, Unit.PX);
    headerPanel.add(filterWidget_);
    HelpLink link = new HelpLink("Customizing Keyboard Shortcuts", "custom_keyboard_shortcuts");
    link.getElement().getStyle().setFloat(Style.Float.RIGHT);
    headerPanel.add(link);
    container.add(headerPanel);
    FlowPanel spacer = new FlowPanel();
    spacer.setWidth("100%");
    spacer.setHeight("4px");
    container.add(spacer);
    DockPanel dockPanel = new DockPanel();
    dockPanel.add(table_, DockPanel.CENTER);
    container.add(dockPanel);
    return container;
}
Also used : NativePreviewHandler(com.google.gwt.user.client.Event.NativePreviewHandler) NativePreviewEvent(com.google.gwt.user.client.Event.NativePreviewEvent) VerticalPanel(com.google.gwt.user.client.ui.VerticalPanel) AttachEvent(com.google.gwt.event.logical.shared.AttachEvent) DockPanel(com.google.gwt.user.client.ui.DockPanel) Element(com.google.gwt.dom.client.Element) TableRowElement(com.google.gwt.dom.client.TableRowElement) FlowPanel(com.google.gwt.user.client.ui.FlowPanel) Label(com.google.gwt.user.client.ui.Label) HelpLink(org.rstudio.studio.client.common.HelpLink) ElementPredicate(org.rstudio.core.client.dom.DomUtils.ElementPredicate)

Example 55 with FlowPanel

use of com.google.gwt.user.client.ui.FlowPanel in project rstudio by rstudio.

the class MathJax method createMathJaxLineWidget.

private void createMathJaxLineWidget(int row, boolean bare, final CommandWithArg<LineWidget> onAttached) {
    final FlowPanel panel = createMathJaxContainerWidget();
    ChunkOutputHost host = new ChunkOutputHost() {

        private int lastHeight_ = Integer.MAX_VALUE;

        @Override
        public void onOutputRemoved(final ChunkOutputWidget widget) {
            removeChunkOutputWidget(widget);
        }

        @Override
        public void onOutputHeightChanged(ChunkOutputWidget widget, int height, boolean ensureVisible) {
            final PinnedLineWidget plw = cowToPlwMap_.get(widget);
            if (plw == null)
                return;
            // munge the size of the frame, to avoid issues where the
            // frame's size changes following a collapse + expand
            boolean isExpansion = lastHeight_ <= height;
            if (isExpansion)
                widget.getFrame().setHeight((height + 4) + "px");
            lastHeight_ = height;
            // update the height and report to doc display
            LineWidget lineWidget = plw.getLineWidget();
            lineWidget.setPixelHeight(height);
            docDisplay_.onLineWidgetChanged(lineWidget);
        }
    };
    final ChunkOutputWidget outputWidget = new ChunkOutputWidget(StringUtil.makeRandomId(8), StringUtil.makeRandomId(8), RmdChunkOptions.create(), ChunkOutputWidget.EXPANDED, // can close
    false, host, bare ? ChunkOutputSize.Bare : ChunkOutputSize.Default);
    outputWidget.setRootWidget(panel);
    outputWidget.hideSatellitePopup();
    PinnedLineWidget plWidget = new PinnedLineWidget(LINE_WIDGET_TYPE, docDisplay_, outputWidget, row, null, new PinnedLineWidget.Host() {

        @Override
        public void onLineWidgetRemoved(LineWidget widget) {
        // no action necessary here; this is taken care of by the
        // hosting chunk (see onOutputRemoved)
        }

        @Override
        public void onLineWidgetAdded(LineWidget widget) {
            onAttached.execute(widget);
        }
    });
    cowToPlwMap_.put(outputWidget, plWidget);
    lwToPlwMap_.put(plWidget.getLineWidget(), outputWidget);
}
Also used : ChunkOutputHost(org.rstudio.studio.client.workbench.views.source.editors.text.rmd.ChunkOutputHost) ChunkOutputWidget(org.rstudio.studio.client.workbench.views.source.editors.text.ChunkOutputWidget) FlowPanel(com.google.gwt.user.client.ui.FlowPanel) PinnedLineWidget(org.rstudio.studio.client.workbench.views.source.editors.text.PinnedLineWidget) LineWidget(org.rstudio.studio.client.workbench.views.source.editors.text.ace.LineWidget) PinnedLineWidget(org.rstudio.studio.client.workbench.views.source.editors.text.PinnedLineWidget)

Aggregations

FlowPanel (com.google.gwt.user.client.ui.FlowPanel)81 ClickHandler (com.google.gwt.event.dom.client.ClickHandler)18 ClickEvent (com.google.gwt.event.dom.client.ClickEvent)15 Button (com.google.gwt.user.client.ui.Button)14 Label (com.google.gwt.user.client.ui.Label)12 Grid (com.google.gwt.user.client.ui.Grid)10 VerticalPanel (com.google.gwt.user.client.ui.VerticalPanel)8 HorizontalPanel (com.google.gwt.user.client.ui.HorizontalPanel)7 SmallHeading (com.google.gerrit.client.ui.SmallHeading)6 Element (com.google.gwt.dom.client.Element)6 CheckBox (com.google.gwt.user.client.ui.CheckBox)6 CellFormatter (com.google.gwt.user.client.ui.HTMLTable.CellFormatter)6 InlineLabel (com.google.gwt.user.client.ui.InlineLabel)6 Widget (com.google.gwt.user.client.ui.Widget)6 Test (org.junit.Test)6 ComplexPanel (com.google.gwt.user.client.ui.ComplexPanel)5 HTML (com.google.gwt.user.client.ui.HTML)5 Image (com.google.gwt.user.client.ui.Image)5 IsWidget (com.google.gwt.user.client.ui.IsWidget)5 List (java.util.List)4