Search in sources :

Example 11 with SimplePanel

use of com.google.gwt.user.client.ui.SimplePanel in project cuba by cuba-platform.

the class EscKeyDownHandler method onKeyDown.

@Override
public void onKeyDown(KeyDownEvent keyDownEvent) {
    if (keyDownEvent.getNativeKeyCode() == KeyCodes.KEY_ESCAPE) {
        SimplePanel panel = WidgetUtil.findWidget(WidgetUtil.getFocusedElement(), SimplePanel.class);
        if (panel != null) {
            WidgetUtil.focus(panel.getParent().getElement());
            // prevent further bubbling of the event as it has only
            // navigational purpose if thrown at this depth. A subsequent
            // press of ESC is not stopped, so ESC abort actions of the
            // application should work as soon as the focus is in
            // "navigational mode" on a grid-cell
            keyDownEvent.preventDefault();
            keyDownEvent.stopPropagation();
        }
    }
}
Also used : SimplePanel(com.google.gwt.user.client.ui.SimplePanel)

Example 12 with SimplePanel

use of com.google.gwt.user.client.ui.SimplePanel in project ovirt-engine by oVirt.

the class Slider method setSlidersWidth.

private void setSlidersWidth() {
    slider.clear();
    westPanel = new SimplePanel();
    int width = getPivot() - getMin();
    // $NON-NLS-1$
    westPanel.setWidth((width < 0 ? 0 : width) + "px");
    // $NON-NLS-1$
    percentLabel.setText(getPercent() + "%");
    centerPanel = new SimplePanel();
    width = getMax() - getMin();
    // $NON-NLS-1$
    centerPanel.setWidth((width < 0 ? 0 : width) + "px");
    slider.addWest(westPanel, getPivot() - getMin());
    slider.add(centerPanel);
}
Also used : SimplePanel(com.google.gwt.user.client.ui.SimplePanel)

Example 13 with SimplePanel

use of com.google.gwt.user.client.ui.SimplePanel in project ovirt-engine by oVirt.

the class InternalNetworksPanel method initTitlePanel.

private SimplePanel initTitlePanel(String title) {
    Label label = new Label(title);
    SimplePanel titlePanel = new SimplePanel(label);
    titlePanel.setStyleName(style.requiredTitlePanel());
    label.getElement().addClassName(style.requiredLabel());
    return titlePanel;
}
Also used : Label(com.google.gwt.user.client.ui.Label) SimplePanel(com.google.gwt.user.client.ui.SimplePanel)

Example 14 with SimplePanel

use of com.google.gwt.user.client.ui.SimplePanel in project ovirt-engine by oVirt.

the class EntityModelDetachableWidgetWithLabel method setUsePatternFly.

@Override
public void setUsePatternFly(boolean use) {
    usePatternFly = use;
    decorated.setUsePatternFly(use);
    if (use) {
        wrapperPanel.remove(contentWidgetContainer);
        sizeContainer = new SimplePanel();
        sizeContainer.setWidget(contentWidgetContainer);
        // The label and the chain icon come first
        wrapperPanel.insert(sizeContainer, 2);
        wrapperPanel.removeStyleName(style.wrapper());
        wrapperPanel.addStyleName(Styles.FORM_GROUP);
        contentWrapper.removeStyleName(style.contentWrapper());
        contentWidgetContainer.removeStyleName(style.contentWidgetContainer());
        contentWidgetContainer.removeStyleName(style.contentWidgetWithDetachable());
        contentWidgetContainer.removeStyleName(style.contentWidgetWithoutDetachable());
        label.getElement().replaceClassName(style.labelDisabled(), style.labelEnabled());
        imageContainer.addStyleName(ColumnSize.SM_1.getCssName());
    }
}
Also used : SimplePanel(com.google.gwt.user.client.ui.SimplePanel)

Example 15 with SimplePanel

use of com.google.gwt.user.client.ui.SimplePanel in project perun by CESNET.

the class FindSimilarPublications method getEmptyTable.

/**
 * Returns table of users publications
 * @return table
 */
public CellTable<Publication> getEmptyTable() {
    // Table data provider.
    dataProvider = new ListDataProvider<Publication>(list);
    // Cell table
    table = new PerunTable<Publication>(list);
    // display row-count for perun admin only
    if (!session.isPerunAdmin()) {
        table.removeRowCountChangeHandler();
    }
    // Connect the table to the data provider.
    dataProvider.addDataDisplay(table);
    // Sorting
    ListHandler<Publication> columnSortHandler = new ListHandler<Publication>(dataProvider.getList());
    table.addColumnSortHandler(columnSortHandler);
    // table selection
    table.setSelectionModel(selectionModel, DefaultSelectionEventManager.<Publication>createCheckboxManager());
    // set empty content & loader
    table.setEmptyTableWidget(loaderImage);
    loaderImage.setEmptyResultMessage("No similar publications found.");
    // show checkbox column
    if (this.checkable) {
        // checkbox column column
        table.addCheckBoxColumn();
    }
    // ID COLUMN
    table.addIdColumn("Publication ID", tableFieldUpdater, 60);
    Column<Publication, ImageResource> lockedColumn = new Column<Publication, ImageResource>(new CustomImageResourceCell("click")) {

        public ImageResource getValue(Publication object) {
            if (object.isLocked()) {
                return SmallIcons.INSTANCE.lockIcon();
            } else {
                return SmallIcons.INSTANCE.lockOpenIcon();
            }
        }

        public void onBrowserEvent(final Context context, final Element elem, final Publication object, NativeEvent event) {
            // on click and for perun admin
            if ("click".equals(event.getType()) && session.isPerunAdmin()) {
                final ImageResource value;
                if (object.isLocked()) {
                    value = SmallIcons.INSTANCE.lockOpenIcon();
                    object.setLocked(false);
                } else {
                    value = SmallIcons.INSTANCE.lockIcon();
                    object.setLocked(true);
                }
                LockUnlockPublications request = new LockUnlockPublications(new JsonCallbackEvents() {

                    @Override
                    public void onLoadingStart() {
                        getCell().setValue(context, elem, SmallIcons.INSTANCE.updateIcon());
                    }

                    @Override
                    public void onFinished(JavaScriptObject jso) {
                        // change picture (object already changed)
                        getCell().setValue(context, elem, value);
                    }

                    @Override
                    public void onError(PerunError error) {
                        // on error switch object back
                        if (object.isLocked()) {
                            object.setLocked(false);
                            getCell().setValue(context, elem, SmallIcons.INSTANCE.lockOpenIcon());
                        } else {
                            object.setLocked(true);
                            getCell().setValue(context, elem, SmallIcons.INSTANCE.lockIcon());
                        }
                    }
                });
                // send request
                ArrayList<Publication> list = new ArrayList<Publication>();
                list.add(object);
                request.lockUnlockPublications(object.isLocked(), list);
            }
        }
    };
    table.addColumn(lockedColumn, "Lock");
    // TITLE COLUMN
    Column<Publication, String> titleColumn = JsonUtils.addColumn(new JsonUtils.GetValue<Publication, String>() {

        public String getValue(Publication object) {
            return object.getTitle();
        }
    }, this.tableFieldUpdater);
    titleColumn.setSortable(true);
    columnSortHandler.setComparator(titleColumn, new PublicationComparator(PublicationComparator.Column.TITLE));
    table.addColumn(titleColumn, "Title");
    // if display authors
    if (ids.containsKey("authors")) {
        if ((Integer) ids.get("authors") == 1) {
            // AUTHORS COLUMN
            Column<Publication, String> authorColumn = JsonUtils.addColumn(new JsonUtils.GetValue<Publication, String>() {

                public String getValue(Publication object) {
                    return object.getAuthorsFormatted();
                }
            }, this.tableFieldUpdater);
            authorColumn.setSortable(true);
            columnSortHandler.setComparator(authorColumn, new PublicationComparator(PublicationComparator.Column.AUTHORS));
            table.addColumn(authorColumn, "Reported by");
        }
    }
    // YEAR COLUMN
    Column<Publication, String> yearColumn = JsonUtils.addColumn(new JsonUtils.GetValue<Publication, String>() {

        public String getValue(Publication object) {
            return String.valueOf(object.getYear());
        }
    }, this.tableFieldUpdater);
    yearColumn.setSortable(true);
    columnSortHandler.setComparator(yearColumn, new PublicationComparator(PublicationComparator.Column.YEAR));
    table.addColumn(yearColumn, "Year");
    // CATEGORY COLUMN
    Column<Publication, String> categoryColumn = JsonUtils.addColumn(new JsonUtils.GetValue<Publication, String>() {

        public String getValue(Publication object) {
            return object.getCategoryName();
        }
    }, this.tableFieldUpdater);
    categoryColumn.setSortable(true);
    columnSortHandler.setComparator(categoryColumn, new PublicationComparator(PublicationComparator.Column.CATEGORY));
    table.addColumn(categoryColumn, "Category");
    // THANKS COLUMN
    Column<Publication, String> thanksColumn = JsonUtils.addColumn(new JsonUtils.GetValue<Publication, String>() {

        public String getValue(Publication object) {
            String result = "";
            JsArray<Thanks> thks = object.getThanks();
            for (int i = 0; i < thks.length(); i++) {
                result += thks.get(i).getOwnerName() + ", ";
            }
            if (result.length() >= 2) {
                result = result.substring(0, result.length() - 2);
            }
            return result;
        }
    }, this.tableFieldUpdater);
    thanksColumn.setSortable(true);
    columnSortHandler.setComparator(thanksColumn, new PublicationComparator(PublicationComparator.Column.THANKS));
    table.addColumn(thanksColumn, "Thanked to");
    // CITE COLUMN
    Column<Publication, String> citaceColumn = JsonUtils.addColumn(new JsonUtils.GetValue<Publication, String>() {

        public String getValue(Publication object) {
            return "Cite";
        }
    }, new FieldUpdater<Publication, String>() {

        public void update(int index, Publication object, String value) {
            SimplePanel sp = new SimplePanel();
            sp.add(new HTML(object.getMain()));
            Confirm cf = new Confirm("Cite publication", sp, true);
            cf.show();
        }
    });
    table.addColumn(citaceColumn, "Cite");
    return table;
}
Also used : PublicationComparator(cz.metacentrum.perun.webgui.json.comparators.PublicationComparator) Element(com.google.gwt.dom.client.Element) ArrayList(java.util.ArrayList) Confirm(cz.metacentrum.perun.webgui.widgets.Confirm) HTML(com.google.gwt.user.client.ui.HTML) ImageResource(com.google.gwt.resources.client.ImageResource) Column(com.google.gwt.user.cellview.client.Column) Context(com.google.gwt.cell.client.Cell.Context) ListHandler(com.google.gwt.user.cellview.client.ColumnSortEvent.ListHandler) CustomImageResourceCell(cz.metacentrum.perun.webgui.widgets.cells.CustomImageResourceCell) JsArray(com.google.gwt.core.client.JsArray) Publication(cz.metacentrum.perun.webgui.model.Publication) SimplePanel(com.google.gwt.user.client.ui.SimplePanel) JavaScriptObject(com.google.gwt.core.client.JavaScriptObject) PerunError(cz.metacentrum.perun.webgui.model.PerunError) NativeEvent(com.google.gwt.dom.client.NativeEvent)

Aggregations

SimplePanel (com.google.gwt.user.client.ui.SimplePanel)60 Label (com.google.gwt.user.client.ui.Label)19 VerticalPanel (com.google.gwt.user.client.ui.VerticalPanel)14 HorizontalPanel (com.google.gwt.user.client.ui.HorizontalPanel)9 ClickEvent (com.google.gwt.event.dom.client.ClickEvent)7 ClickHandler (com.google.gwt.event.dom.client.ClickHandler)7 HTML (com.google.gwt.user.client.ui.HTML)7 Test (org.junit.Test)5 Element (com.google.gwt.dom.client.Element)4 Style (com.google.gwt.dom.client.Style)4 ChangeEvent (com.google.gwt.event.dom.client.ChangeEvent)4 ChangeHandler (com.google.gwt.event.dom.client.ChangeHandler)4 Button (com.google.gwt.user.client.ui.Button)4 FlowPanel (com.google.gwt.user.client.ui.FlowPanel)4 ListHandler (com.google.gwt.user.cellview.client.ColumnSortEvent.ListHandler)3 Image (com.google.gwt.user.client.ui.Image)3 Widget (com.google.gwt.user.client.ui.Widget)3 HorizontalScrollWrapper (org.pentaho.mantle.client.ui.custom.HorizontalScrollWrapper)3 ListBoxTitle (org.pentaho.mantle.client.ui.custom.ListBoxTitle)3 Context (com.google.gwt.cell.client.Cell.Context)2