Example usage for com.google.gwt.user.client.ui HasVerticalAlignment ALIGN_MIDDLE

List of usage examples for com.google.gwt.user.client.ui HasVerticalAlignment ALIGN_MIDDLE

Introduction

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

Prototype

VerticalAlignmentConstant ALIGN_MIDDLE

To view the source code for com.google.gwt.user.client.ui HasVerticalAlignment ALIGN_MIDDLE.

Click Source Link

Document

Specifies that the widget's contents should be aligned in the middle.

Usage

From source file:com.google.testing.testify.risk.frontend.client.view.widgets.LabelWidget.java

License:Apache License

/**
 * Constructs a label for a given object, allowing customized styling.  The constructed
 * label will use styles:/*  w  w w.java  2s. c om*/
 *   tty-GenericLabel
 *   tty-GenericLabelRemoveLabelImage
 * @param text the textual representation for this label.
 * @param isAddWidget true if this is a "new label..." widget, false if not.
 */
public LabelWidget(String text, final boolean isAddWidget) {
    DefaultSuggestionDisplay suggestionDisplay = (DefaultSuggestionDisplay) inputBox.getSuggestionDisplay();
    suggestionDisplay.setPopupStyleName("tty-SuggestBoxPopup");
    contentPanel.addStyleName("tty-RemovableLabel");

    if (isAddWidget) {
        // Craft a little plus image.
        image.setStyleName("tty-RemovableLabelAddImage");
        image.setUrl("images/collapsed_12.png");
        image.addClickHandler(new ClickHandler() {
            @Override
            public void onClick(ClickEvent event) {
                switchMode(EDIT_MODE);
            }
        });
        contentPanel.add(image);
    }

    // Craft the view mode.
    label.setText(text);
    label.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent arg0) {
            switchMode(EDIT_MODE);
        }
    });
    deckPanel.add(label);

    // Craft the edit mode.
    if (!isAddWidget) {
        inputBox.setText(text);
    }
    inputBox.getTextBox().addBlurHandler(new BlurHandler() {
        @Override
        public void onBlur(BlurEvent arg0) {
            switchMode(VIEW_MODE);
        }
    });
    inputBox.getTextBox().addKeyDownHandler(new KeyDownHandler() {
        @Override
        public void onKeyDown(KeyDownEvent event) {
            if (event.getNativeKeyCode() == KeyCodes.KEY_ENTER) {
                switchMode(VIEW_MODE);
            } else if (event.getNativeKeyCode() == KeyCodes.KEY_ESCAPE) {
                if (isAddWidget) {
                    inputBox.setText("");
                } else {
                    inputBox.setText(label.getText());
                }
                switchMode(VIEW_MODE);
            }
        }
    });
    // Explicitly does not call switchMode to avoid logic inside that function that would think
    // we have switched from edit mode to view mode.
    deckPanel.showWidget(VIEW_MODE);
    deckPanel.add(inputBox);

    contentPanel.add(deckPanel);

    if (!isAddWidget) {
        // Craft the delete button.
        image.setStyleName("tty-RemovableLabelDeleteImage");
        image.setUrl("images/x.png");
        image.addClickHandler(new ClickHandler() {
            @Override
            public void onClick(ClickEvent event) {
                setValue(null, true);
            }
        });
        contentPanel.add(image);
    }

    // Set some alignments to make the widget pretty.
    contentPanel.setCellVerticalAlignment(label, HasVerticalAlignment.ALIGN_MIDDLE);
    contentPanel.setCellVerticalAlignment(image, HasVerticalAlignment.ALIGN_MIDDLE);
    initWidget(contentPanel);
}

From source file:com.google.testing.testify.risk.frontend.client.view.widgets.RiskCapabilityWidget.java

License:Apache License

@UiFactory
@Override//from   w w w. j  a  v  a 2  s . c o m
public EasyDisclosurePanel createDisclosurePanel() {
    HorizontalPanel header = new HorizontalPanel();
    header.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE);
    header.setStyleName("tty-CapabilityRiskHeader");
    header.add(capabilityLabel);
    riskLabel = new Label();
    riskLabel.setStyleName("tty-CapabilityRiskValueHeader");
    updateRiskLabel();
    header.add(riskLabel);

    EasyDisclosurePanel panel = new EasyDisclosurePanel(header);
    panel.setOpen(false);
    return panel;
}

From source file:com.googlecode.gchart.client.GChart.java

License:Apache License

private Grid createLegend(PlotPanel pp) {
    Grid result = new Grid(getNVisibleCurvesOnLegend(), 2);
    int iVisible = 0;
    /*/*from ww  w  .  ja v  a  2s.  com*/
     * Simply eliminating the border entirely is a valid transparency emulation
     * for the legend (no positional shifting is needed as is needed for the
     * images used to draw the main chart's curves) because the legend is always
     * positioned by its center point, and the border extends around the entire
     * legend key, so removing it does not result in any change to the legend
     * key's center position. <p>
     * 
     * If multiple legend locations (beyond the current "always centered in a
     * band along the right edge" option) were ever supported, appropriate
     * positional shifts would then have to be introduced to emulate transparent
     * borders.
     */
    GChart.setBorderWidth(result,
            TRANSPARENT_BORDER_COLOR == getLegendBorderColor() ? 0 : Math.abs(getLegendBorderWidth()));
    GChart.setBorderColor(result,
            TRANSPARENT_BORDER_COLOR == getLegendBorderColor() ? "transparent" : getLegendBorderColor());
    GChart.setBorderStyle(result, getLegendBorderStyle());
    GChart.setBackgroundColor(result, getLegendBackgroundColor());
    int nCurves = getNCurves();
    for (int i = 0; i < nCurves; i++) {
        Curve c = getSystemCurve(i);
        if (c.isVisible() && c.getLegendLabel() != null) {
            double symBorderFraction = c.getSymbol().getBorderWidth()
                    / Math.max(Math.max(1.0, c.getSymbol().getFillThickness()),
                            Math.max(c.getSymbol().getWidth(pp), c.getSymbol().getHeight(pp, c.onY2())));
            Image icon = c.getSymbol().getSymbolType().createIconImage(c.getSymbol(), getLegendFontSize(),
                    symBorderFraction);

            result.setWidget(iVisible, 0, icon);
            result.getCellFormatter().setAlignment(iVisible, 0, HasHorizontalAlignment.ALIGN_CENTER,
                    HasVerticalAlignment.ALIGN_MIDDLE);

            HTML label = new HTML(c.getLegendLabel());
            GChart.setFontWeight(label, getLegendFontWeight());
            GChart.setFontFamily(label,
                    (null == getLegendFontFamily()) ? getFontFamily() : getLegendFontFamily());
            GChart.setFontStyle(label, getLegendFontStyle());
            GChart.setColor(label, getLegendFontColor());
            GChart.setFontSize(label, getLegendFontSize());

            result.setWidget(iVisible, 1, label);
            result.getCellFormatter().setAlignment(iVisible, 1, HasHorizontalAlignment.ALIGN_LEFT,
                    HasVerticalAlignment.ALIGN_MIDDLE);

            iVisible++;
        }
    }
    return result;
}

From source file:com.ikon.frontend.client.widget.foldertree.FolderSelectPopup.java

License:Open Source License

public FolderSelectPopup() {
    // Establishes auto-close when click outside
    super(false, true);

    vPanel = new VerticalPanel();
    vPanel.setWidth("450");
    vPanel.setHeight("400");
    hPanel = new HorizontalPanel();
    hListPanel = new HorizontalPanel();
    hContextPanel = new HorizontalPanel();

    contextTxt = new HTML(Main.i18n("search.context"));
    contextListBox = new ListBox();
    contextListBox.setStyleName("okm-Select");

    contextListBox.addChangeHandler(new ChangeHandler() {
        @Override//from w  ww . j a va2s  .c  om
        public void onChange(ChangeEvent event) {
            folderSelectTree
                    .changeView(Integer.parseInt(contextListBox.getValue(contextListBox.getSelectedIndex())));
        }
    });
    hContextPanel.add(contextTxt);
    hContextPanel.add(new HTML("&nbsp;&nbsp;"));
    hContextPanel.add(contextListBox);
    hContextPanel.setCellVerticalAlignment(contextTxt, HasVerticalAlignment.ALIGN_MIDDLE);

    hListPanel.add(hContextPanel);
    hListPanel.setWidth("440");

    scrollDirectoryPanel = new ScrollPanel();
    scrollDirectoryPanel.setSize("440", "350");
    scrollDirectoryPanel.setStyleName("okm-Popup-text");
    verticalDirectoryPanel = new VerticalPanel();
    verticalDirectoryPanel.setSize("100%", "100%");
    folderSelectTree = new FolderSelectTree();
    folderSelectTree.setSize("100%", "100%");

    verticalDirectoryPanel.add(folderSelectTree);
    scrollDirectoryPanel.add(verticalDirectoryPanel);

    cancelButton = new Button(Main.i18n("button.cancel"), new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            action = ACTION_NONE;
            hide();
        }
    });

    actionButton = new Button(Main.i18n("button.move"), new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            executeAction(folderSelectTree.getActualPath(), false);
        }
    });

    status.setWidth("430");
    status.setWordWrap(true);
    status.setStyleName("fancyfileupload-pending");
    status.setVisible(false);

    vPanel.add(new HTML("<br>"));
    vPanel.add(hListPanel);
    vPanel.add(new HTML("<br>"));
    vPanel.add(scrollDirectoryPanel);
    vPanel.add(status);
    vPanel.add(new HTML("<br>"));
    hPanel.add(cancelButton);
    HTML space = new HTML();
    space.setWidth("50");
    hPanel.add(space);
    hPanel.add(actionButton);
    vPanel.add(hPanel);
    vPanel.add(new HTML("<br>"));

    vPanel.setCellHorizontalAlignment(hListPanel, HasAlignment.ALIGN_CENTER);
    vPanel.setCellHorizontalAlignment(scrollDirectoryPanel, HasAlignment.ALIGN_CENTER);
    vPanel.setCellHorizontalAlignment(status, HasAlignment.ALIGN_CENTER);
    vPanel.setCellHorizontalAlignment(hPanel, HasAlignment.ALIGN_CENTER);
    vPanel.setCellHeight(scrollDirectoryPanel, "350");

    cancelButton.setStyleName("okm-NoButton");
    actionButton.setStyleName("okm-YesButton");

    massiveStatus = new com.ikon.frontend.client.widget.popup.Status(this);
    massiveStatus.setStyleName("okm-StatusPopup");

    super.hide();
    setWidget(vPanel);
}

From source file:com.ikon.frontend.client.widget.foldertree.FolderSelectPopup.java

License:Open Source License

public FolderSelectPopup(boolean isRestore) {
    super(false, true);

    if (isRestore) {
        vPanel = new VerticalPanel();
        vPanel.setWidth("450");
        vPanel.setHeight("50");
        hPanel = new HorizontalPanel();
        hPanel.setWidth("115%");
        hPanel.setSpacing(10);//from  w w w.j ava 2 s.c o m
        hListPanel = new HorizontalPanel();
        hContextPanel = new HorizontalPanel();

        contextTxt = new HTML(Main.i18n("search.context"));
        contextListBox = new ListBox();
        contextListBox.setStyleName("okm-Select");

        contextListBox.addChangeHandler(new ChangeHandler() {
            @Override
            public void onChange(ChangeEvent event) {
                folderSelectTree.changeView(
                        Integer.parseInt(contextListBox.getValue(contextListBox.getSelectedIndex())));
            }
        });
        hContextPanel.add(contextTxt);
        hContextPanel.add(new HTML("&nbsp;&nbsp;"));
        hContextPanel.add(contextListBox);
        hContextPanel.setCellVerticalAlignment(contextTxt, HasVerticalAlignment.ALIGN_MIDDLE);

        hListPanel.add(hContextPanel);
        hListPanel.setWidth("440");

        scrollDirectoryPanel = new ScrollPanel();
        scrollDirectoryPanel.setSize("440", "350");
        scrollDirectoryPanel.setStyleName("okm-Popup-text");
        verticalDirectoryPanel = new VerticalPanel();
        verticalDirectoryPanel.setSize("100%", "100%");
        folderSelectTree = new FolderSelectTree();
        folderSelectTree.setSize("100%", "100%");

        verticalDirectoryPanel.add(folderSelectTree);
        scrollDirectoryPanel.add(verticalDirectoryPanel);

        cancelButton = new Button(Main.i18n("button.cancel"), new ClickHandler() {
            @Override
            public void onClick(ClickEvent event) {
                action = ACTION_NONE;
                hide();
            }
        });

        actionButton = new Button(Main.i18n("button.move"), new ClickHandler() {
            @Override
            public void onClick(ClickEvent event) {
                executeAction(folderSelectTree.getActualPath(), false);
            }
        });

        defaultRestoreButton = new Button("Default", new ClickHandler() {
            @Override
            public void onClick(ClickEvent event) {
                restoreDefaultExecuteAction(pathRestore, true);
            }
        });

        status.setWidth("430");
        status.setWordWrap(true);
        status.setStyleName("fancyfileupload-pending");
        status.setVisible(false);

        vPanel.add(new HTML("<br>"));
        vPanel.add(hListPanel);
        vPanel.add(new HTML("<br>"));
        vPanel.add(scrollDirectoryPanel);
        vPanel.add(status);
        vPanel.add(new HTML("<br>"));
        hPanel.add(cancelButton);
        hPanel.add(actionButton);
        hPanel.add(defaultRestoreButton);
        vPanel.add(hPanel);
        vPanel.add(new HTML("<br>"));

        vPanel.setCellHorizontalAlignment(hListPanel, HasAlignment.ALIGN_CENTER);
        vPanel.setCellHorizontalAlignment(scrollDirectoryPanel, HasAlignment.ALIGN_CENTER);
        vPanel.setCellHorizontalAlignment(status, HasAlignment.ALIGN_CENTER);
        vPanel.setCellHorizontalAlignment(hPanel, HasAlignment.ALIGN_CENTER);
        vPanel.setCellHeight(scrollDirectoryPanel, "350");

        cancelButton.setStyleName("okm-NoButton");
        actionButton.setStyleName("okm-YesButton");
        defaultRestoreButton.setStyleName("okm-YesButton");

        massiveStatus = new com.ikon.frontend.client.widget.popup.Status(this);
        massiveStatus.setStyleName("okm-StatusPopup");

        super.hide();
        setWidget(vPanel);
    }
}

From source file:com.ikon.frontend.client.widget.form.FolderSelectPopup.java

License:Open Source License

/**
 * FolderSelectPopup// w ww .  j  ava 2  s  . com
 */
public FolderSelectPopup() {
    // Establishes auto-close when click outside
    super(false, true);

    vPanel = new VerticalPanel();
    vPanel.setWidth("300");
    vPanel.setHeight("200");
    hPanel = new HorizontalPanel();
    hListPanel = new HorizontalPanel();
    hContextPanel = new HorizontalPanel();

    contextTxt = new HTML(Main.i18n("search.context"));
    contextListBox = new ListBox();
    contextListBox.setStyleName("okm-Select");

    contextListBox.addChangeHandler(new ChangeHandler() {
        @Override
        public void onChange(ChangeEvent event) {
            folderSelectTree
                    .changeView(Integer.parseInt(contextListBox.getValue(contextListBox.getSelectedIndex())));
        }
    });
    hContextPanel.add(contextTxt);
    hContextPanel.add(new HTML("&nbsp;&nbsp;"));
    hContextPanel.add(contextListBox);
    hContextPanel.setCellVerticalAlignment(contextTxt, HasVerticalAlignment.ALIGN_MIDDLE);

    hListPanel.add(hContextPanel);
    hListPanel.setWidth("290");

    setText(Main.i18n("search.folder.filter"));

    scrollDirectoryPanel = new ScrollPanel();
    scrollDirectoryPanel.setSize("290", "150");
    scrollDirectoryPanel.setStyleName("okm-Popup-text");
    verticalDirectoryPanel = new VerticalPanel();
    verticalDirectoryPanel.setSize("100%", "100%");
    folderSelectTree = new FolderSelectTree();
    folderSelectTree.setSize("100%", "100%");

    verticalDirectoryPanel.add(folderSelectTree);
    scrollDirectoryPanel.add(verticalDirectoryPanel);

    cancelButton = new Button(Main.i18n("button.cancel"), new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            hide();
        }
    });

    actionButton = new Button(Main.i18n("button.select"), new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            textBox.setValue(folderSelectTree.getActualPath());
            if (search != null) {
                search.metadataValueChanged();
            }
            hide();
        }
    });

    vPanel.add(new HTML("<br>"));
    vPanel.add(hListPanel);
    vPanel.add(new HTML("<br>"));
    vPanel.add(scrollDirectoryPanel);
    vPanel.add(new HTML("<br>"));
    hPanel.add(cancelButton);
    HTML space = new HTML();
    space.setWidth("50");
    hPanel.add(space);
    hPanel.add(actionButton);
    vPanel.add(hPanel);
    vPanel.add(new HTML("<br>"));

    vPanel.setCellHorizontalAlignment(hListPanel, HasAlignment.ALIGN_CENTER);
    vPanel.setCellHorizontalAlignment(scrollDirectoryPanel, HasAlignment.ALIGN_CENTER);
    vPanel.setCellHorizontalAlignment(hPanel, HasAlignment.ALIGN_CENTER);
    vPanel.setCellHeight(scrollDirectoryPanel, "150");

    cancelButton.setStyleName("okm-Input");
    actionButton.setStyleName("okm-Input");

    super.hide();
    setWidget(vPanel);
}

From source file:com.itgp.gwtviz.client.ui.config.ItemGrid.java

License:Open Source License

@Override
public Widget asWidget() {
    if (panel == null) {

        IdentityValueProvider<Item> identity = new IdentityValueProvider<Item>();
        final IgnoreRowClickCheckBoxSelectionModel<Item> selectionModel = new IgnoreRowClickCheckBoxSelectionModel<Item>(
                identity) {//from w ww  .j  a v a2s  .  c o  m
            @Override
            protected void onRefresh(RefreshEvent event) {
                // this code selects all rows when paging if the header checkbox is selected
                if (isSelectAllChecked()) {
                    selectAll();
                }
                super.onRefresh(event);
            }

            @Override
            public void deselect(Item item) {
                item.setSelected(false);
                super.deselect(item);
            }

            @Override
            public void select(Item item, boolean keepExisting) {
                item.setSelected(true);
                super.select(item, keepExisting);
            }

        };
        selectionModel.setSelectionMode(selectionMode);

        String columnName = "Column";
        if (GridType.XAXIS_LABEL.equals(gridType)) {
            columnName = "X Axis Column";
        }

        ColumnConfig<Item, String> valueCol = new ColumnConfig<Item, String>(props.value(), 245, columnName);
        ColumnConfig<Item, String> labelCol = new ColumnConfig<Item, String>(props.valueLabel(), 195,
                "X Axis Label");
        ColumnConfig<Item, Integer> dataCol = new ColumnConfig<Item, Integer>(props.datacount(), 130,
                "Data Elements Selected");
        ColumnConfig<Item, String> sortOrderCol = new ColumnConfig<Item, String>(props.sortOrder(), 60,
                "Sort Order");
        ColumnConfig<Item, String> sortDirCol = new ColumnConfig<Item, String>(props.sortDirection(), 125,
                "Sort Direction");

        valueCol.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE);
        labelCol.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE);
        dataCol.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE);
        sortOrderCol.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE);
        selectionModel.getColumn().setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE);

        sortOrderCol.setHidden(true);

        sortOrderCol.setFixed(true);
        sortDirCol.setFixed(true);

        sortOrderCol.setResizable(false);
        sortDirCol.setResizable(false);

        ListStore<String> direction = new ListStore<String>(new ModelKeyProvider<String>() {
            @Override
            public String getKey(String item) {
                return item;
            }
        });
        direction.add(SortDirection.Ascending.name());
        direction.add(SortDirection.Descending.name());

        ComboBoxCell<String> sortCombo = new ComboBoxCell<String>(direction, new LabelProvider<String>() {
            @Override
            public String getLabel(String item) {
                return item;
            }
        });

        JSNIsetEditable(sortCombo, false);
        sortCombo.setTriggerAction(TriggerAction.ALL);
        sortCombo.setForceSelection(true);
        sortCombo.setWidth(110);
        sortCombo.setHeight(10);
        sortCombo.addSelectionHandler(new SelectionHandler<String>() {

            @Override
            public void onSelection(SelectionEvent<String> event) {
                String data = event.getSelectedItem();
                data = data + "";
                grid.getStore().commitChanges();

            }
        });

        sortDirCol.setCell(sortCombo);

        List<ColumnConfig<Item, ?>> columns = new ArrayList<ColumnConfig<Item, ?>>();

        if (GridType.REGULAR.equals(gridType)) {
            columns.add(selectionModel.getColumn());
            columns.add(valueCol);
            columns.add(dataCol);

        } else if (GridType.HIDE_CHECKBOX.equals(gridType)) {
            columns.add(selectionModel.getColumn());
            selectionModel.getColumn().setHidden(true); // DO NOT REMOVE THE selectionModel FROM COLUMNS. You'll GET NULL Pointer on refresh of GRID   
            columns.add(valueCol);
            columns.add(dataCol);

        } else if (GridType.XAXIS_LABEL.equals(gridType)) {
            columns.add(selectionModel.getColumn());
            columns.add(valueCol);
            columns.add(labelCol);
            columns.add(sortOrderCol);
            columns.add(sortDirCol);
        } else {
            columns.add(selectionModel.getColumn());
            columns.add(valueCol);
            columns.add(dataCol);
        }

        ColumnModel<Item> cm = new ColumnModel<Item>(columns);

        store = new ListStore<Item>(props.key());
        store.setAutoCommit(true);
        store.addAll(itemList);

        // ToolTipConfig config = new ToolTipConfig("Example Info",
        // "This examples includes resizable panel, reorderable columns and grid state. Text selection is allowed.");
        // config.setMaxWidth(225);
        // ToolButton info = new ToolButton(ToolButton.QUESTION);
        // info.setToolTipConfig(config);

        grid = new Grid<Item>(store, cm);
        grid.getElement().setMargins(1);
        grid.setSelectionModel(selectionModel);
        // grid.setAllowTextSelection(true);
        // grid.getView().setAutoExpandColumn(valueCol);
        if (GridType.XAXIS_LABEL.equals(gridType)) {
            grid.getView().setAutoExpandColumn(labelCol);

            final GridEditing<Item> editing = new GridInlineEditing<Item>(grid);
            editing.addEditor(labelCol, (new TextField()));
            editing.addEditor(sortOrderCol, new TextField());
            // editing.addCompleteEditHandler(getCompleteEditHandler(labelCol));
            // editing.addCompleteEditHandler(getCompleteEditHandler(sortDirCol));
            // editing.addCompleteEditHandler(getCompleteEditHandler(sortOrderCol));

        }
        grid.getView().setStripeRows(true);
        grid.getView().setColumnLines(true);
        grid.setBorders(false);
        grid.setColumnReordering(true);

        grid.addRowClickHandler(new RowClickHandler() {

            @Override
            public void onRowClick(RowClickEvent event) {
                if (dataSelector != null) {
                    Item clickedItem = ((Item) event.getSource().getSelectionModel().getSelectedItem());
                    if (clickedItem != null) {
                        // List<Item> uniqueDataList = selecteItem.getData();// ItemUtil.getDataFromColumn(MRoute.jsonData, selecteItem.getId(), true);
                        if (clickedItem.isSelected()) {
                            // clickedItem.setSelected(true);
                            Item originalItem = ItemUtil.findItem(MainDesktop.getCurrentDataModel(),
                                    clickedItem.getValue());
                            Item uniqueDataItem = ItemUtil.elimateDuplicateDataForItem(originalItem);
                            currentlySelectedItem = clickedItem;
                            dataSelector.setData(uniqueDataItem.getData(), clickedItem.getData());
                            grid.getStore().commitChanges();
                        }
                    }
                } else {
                    // Item clickedItem = ((Item) event.getSource().getSelectionModel().getSelectedItem());
                    // if(clickedItem!=null){
                    // if(grid.getSelectionModel().getSelectedItems().contains(clickedItem)){
                    // clickedItem.setSelected(true);
                    // }else{
                    // clickedItem.setSelected(false);
                    // }
                    //
                    // }
                }
            }
        });

        if (enableDnD) {
            GridDragSource source = new GridDragSource<Item>(grid);

            GridDropTarget<Item> target = new GridDropTarget<Item>(grid);
            target.setAllowSelfAsSource(true);
            target.setFeedback(Feedback.BOTH);

            target.addDropHandler(new DndDropHandler() {

                @Override
                public void onDrop(DndDropEvent event) {
                    // TODO Auto-generated method stub
                    // grid.getSelectionModel().setSelection(selectedItemsForDrag);
                }
            });

            source.addDragStartHandler(new DndDragStartHandler() {
                @Override
                public void onDragStart(DndDragStartEvent event) {
                    // selectedItemsForDrag = getSelectedItems();
                }
            });
        }

        panel = new ContentPanel();
        panel.setHeadingText("Columns");
        panel.getHeader().hide();
        panel.setWidget(grid);
        // panel.setBodyBorder(true);
        panel.getElement().getStyle().setBorderWidth(1, Style.Unit.PX);
        // panel.addStyleName("margin-10");
    }

    return panel;
}

From source file:com.konakart.client.KKBaseWin.java

License:Open Source License

/**
 * Utility method to format a cell/*from w w w .  j a  v  a 2 s .  c  o m*/
 * 
 * @param ft
 * @param r
 * @param c
 * @param style
 * @param hAlign
 * @param vAlign
 * @param width
 */
protected void formatCell(FlexTable ft, int r, int c, String style, String hAlign, String vAlign,
        String width) {

    if (style != null) {
        ft.getFlexCellFormatter().setStyleName(r, c, style);
    }

    if (hAlign != null) {
        if (hAlign.equalsIgnoreCase("right")) {
            ft.getFlexCellFormatter().setHorizontalAlignment(r, c, HasHorizontalAlignment.ALIGN_RIGHT);

        } else if (hAlign.equalsIgnoreCase("left")) {
            ft.getFlexCellFormatter().setHorizontalAlignment(r, c, HasHorizontalAlignment.ALIGN_LEFT);

        } else if (hAlign.equalsIgnoreCase("center")) {
            ft.getFlexCellFormatter().setHorizontalAlignment(r, c, HasHorizontalAlignment.ALIGN_CENTER);
        }
    }
    if (vAlign != null) {
        if (vAlign.equalsIgnoreCase("top")) {
            ft.getFlexCellFormatter().setVerticalAlignment(r, c, HasVerticalAlignment.ALIGN_TOP);

        } else if (vAlign.equalsIgnoreCase("bottom")) {
            ft.getFlexCellFormatter().setVerticalAlignment(r, c, HasVerticalAlignment.ALIGN_BOTTOM);

        } else if (vAlign.equalsIgnoreCase("middle")) {
            ft.getFlexCellFormatter().setVerticalAlignment(r, c, HasVerticalAlignment.ALIGN_MIDDLE);
        }
    }

    if (width != null) {
        ft.getFlexCellFormatter().setWidth(r, c, width);
    }
}

From source file:com.mallentechinc.smartwire.client.SmartWireWeb.java

License:Open Source License

public void onModuleLoad() {

    RootPanel rootPanel = RootPanel.get();

    dockLayoutPanel = new DockLayoutPanel(Unit.EM);
    rootPanel.add(dockLayoutPanel, 10, 10);
    dockLayoutPanel.setSize("1100px", "900px");

    HorizontalPanel headerPanel = new HorizontalPanel();
    dockLayoutPanel.addNorth(headerPanel, 6);

    headerPanel.setWidth("1200px");
    headerPanel.setBorderWidth(0);//from w w w .j a  v a2s.c o m

    Image logo = new Image("images/smartwire_logo.jpg");
    headerPanel.setCellWidth(logo, "400px");
    headerPanel.add(logo);

    headerPanel.add(new HTML("jxu"));

    Image logoff = new Image("images/doorlogoff.jpg");
    logoff.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent event) {
            boolean confirm = Window.confirm("You are about to logoff");
            if (confirm) {
                //redirect("j_spring_security_logout");
                logoff();
            }

        }
    });
    headerPanel.add(logoff);

    HTML htmlCopyRight = new HTML("Copy Right 2012 mallentechinc.com", true);
    dockLayoutPanel.addSouth(htmlCopyRight, 7.7);

    tabPanel = new TabLayoutPanel(2.5, Unit.EM);
    tabPanel.setAnimationDuration(1000);
    tabPanel.getElement().getStyle().setMarginBottom(10.0, Unit.PX);
    dockLayoutPanel.add(tabPanel);

    tabPanel.addSelectionHandler(new SelectionHandler() {
        public void onSelection(SelectionEvent event) {
            // Let the user know what they just did.
            // Window.alert("You clicked tab " + event.getSelectedItem().toString());
            if (event.getSelectedItem().toString().equals("0")) {
                getAllUsers();
                deckPanel.showWidget(1);
            } else if (event.getSelectedItem().toString().equals("3")) {
                getAllCircuitsByUser("jxu");
                subsysContentDeckPanel.showWidget(1);
            }

        }
    });

    //user admin
    DockLayoutPanel userdockLayoutPanel = new DockLayoutPanel(Unit.EM);

    VerticalPanel userAdminMenuPanel = new VerticalPanel();
    userAdminMenuPanel.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE);

    userdockLayoutPanel.addWest(userAdminMenuPanel, 11);

    Button getAllUsersButton = new Button("Get All Users");
    getAllUsersButton.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent event) {
            getAllUsers();
            deckPanel.showWidget(1);
        }
    });
    userAdminMenuPanel.setSpacing(2);
    userAdminMenuPanel.add(getAllUsersButton);

    Button addNewUserButton = new Button("Add New User");
    addNewUserButton.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent event) {
            deckPanel.showWidget(2);

        }
    });
    userAdminMenuPanel.setSpacing(2);
    userAdminMenuPanel.add(addNewUserButton);
    userAdminMenuPanel.setSize("130px", "150px");

    //search user
    Button searchUserButton = new Button("Search User");
    searchUserButton.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent event) {
            Window.alert("Working on it, stay tune...");

        }
    });
    userAdminMenuPanel.setSpacing(2);
    userAdminMenuPanel.add(searchUserButton);

    //user content area
    deckPanel = new DeckPanel();
    deckPanel.setAnimationEnabled(true);
    userdockLayoutPanel.add(deckPanel);

    //add default page for this
    HTML htmlNewHtml = new HTML("This is admin page", true);
    deckPanel.add(htmlNewHtml);

    //add flex table
    flexTable = new FlexTable();
    flexTable.setCellSpacing(2);
    flexTable.setCellPadding(2);
    deckPanel.add(flexTable);
    flexTable.setSize("700px", "");

    //add user input page
    userformPanel = new FormPanel();
    deckPanel.add(userformPanel);

    final VerticalPanel addUserFormContentPanel = new VerticalPanel();
    addUserFormContentPanel.setSpacing(3);

    addUserFormContentPanel.add(new Label("User Name"));
    userName = new TextBox();
    userName.setName("userName");
    addUserFormContentPanel.add(userName);

    addUserFormContentPanel.add(new Label("Password"));
    passWord = new PasswordTextBox();
    userName.setName("password");
    addUserFormContentPanel.add(passWord);

    addUserFormContentPanel.add(new Label("First Name"));
    firstName = new TextBox();
    firstName.setName("firstName");
    addUserFormContentPanel.add(firstName);

    addUserFormContentPanel.add(new Label("Last Name"));
    lastName = new TextBox();
    lastName.setName("lastName");
    addUserFormContentPanel.add(lastName);

    addUserFormContentPanel.add(new Label("Email"));
    email = new TextBox();
    email.setName("email");
    addUserFormContentPanel.add(email);

    addUserFormContentPanel.add(new Label("User Role"));

    userRole = new ListBox();
    userRole.addStyleName("demo-ListBox");
    userRole.addItem("ADMIN");
    userRole.addItem("USER");
    userRole.setName("userRole");
    addUserFormContentPanel.add(userRole);

    addUserFormContentPanel.add(new Label("Position"));

    position = new ListBox();
    position.addStyleName("demo-ListBox");
    position.addItem("EMPLOYEE");
    position.addItem("MANAGER");
    position.setName("position");
    addUserFormContentPanel.add(position);

    Button insertUserButton = new Button("Add New User");
    insertUserButton.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent event) {

            //get user input
            String requestData = getAddUserInput();
            //add user
            saveUpdateUser(requestData);

        }
    });
    addUserFormContentPanel.add(insertUserButton);

    userformPanel.add(addUserFormContentPanel);

    tabPanel.add(userdockLayoutPanel, "User Admin");

    //end of user admin

    //arch
    DockLayoutPanel archdockLayoutPanel = new DockLayoutPanel(Unit.EM);
    tabPanel.add(archdockLayoutPanel, "Planning & Architecture");

    VerticalPanel archMenuPanel = new VerticalPanel();
    archMenuPanel.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE);
    archMenuPanel.setSize("160px", "140px");

    Button getAllOption = new Button("All Option Code");
    getAllOption.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent event) {
            Window.alert("Working on it, stay tune...");
        }
    });
    archMenuPanel.setSpacing(2);
    archMenuPanel.add(getAllOption);

    Button addNewOptionButton = new Button("New Option Code");
    addNewOptionButton.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent event) {
            Window.alert("Working on it, stay tune...");

        }
    });
    archMenuPanel.setSpacing(2);
    archMenuPanel.add(addNewOptionButton);

    //search user
    Button searchOptionCodeButton = new Button("Search Option Code");
    searchOptionCodeButton.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent event) {
            Window.alert("Working on it, stay tune...");

        }
    });
    archMenuPanel.setSpacing(2);
    archMenuPanel.add(searchOptionCodeButton);

    //search user
    Button functionCodeButton = new Button("Fuction Code");
    functionCodeButton.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent event) {
            Window.alert("Working on it, stay tune...");

        }
    });
    archMenuPanel.setSpacing(2);
    archMenuPanel.add(functionCodeButton);

    archdockLayoutPanel.addWest(archMenuPanel, 11);

    //end of arch

    //ee components

    DockLayoutPanel eeCompdockLayoutPanel = new DockLayoutPanel(Unit.EM);

    VerticalPanel eeCompMenuPanel = new VerticalPanel();
    eeCompMenuPanel.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE);
    eeCompMenuPanel.setSize("160px", "120px");

    Button device = new Button("Device");
    device.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent event) {
            Window.alert("Working on it, stay tune...");
        }
    });
    eeCompMenuPanel.setSpacing(2);
    eeCompMenuPanel.add(device);

    eeCompdockLayoutPanel.addWest(eeCompMenuPanel, 11);
    tabPanel.add(eeCompdockLayoutPanel, "EE Components");

    //end of ee components      

    //sub system
    DockLayoutPanel subSystemdockLayoutPanel = new DockLayoutPanel(Unit.EM);

    VerticalPanel subsysMenuPanel = new VerticalPanel();
    subsysMenuPanel.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE);
    subsysMenuPanel.setSize("160px", "120px");

    Button myCircuits = new Button("My Sub Systems");
    myCircuits.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent event) {
            getAllCircuitsByUser("jxu");
            subsysContentDeckPanel.showWidget(1);
        }
    });
    subsysMenuPanel.setSpacing(2);
    subsysMenuPanel.add(myCircuits);

    //all sub system
    Button allSubSystems = new Button("Sub Systems");
    allSubSystems.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent event) {
            Window.alert("Working on it, stay tune...");
        }
    });
    subsysMenuPanel.setSpacing(2);
    subsysMenuPanel.add(allSubSystems);

    //sub system family
    Button allSubSystemFamily = new Button("Sub System Family");
    allSubSystemFamily.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent event) {
            Window.alert("Working on it, stay tune...");
        }
    });
    subsysMenuPanel.setSpacing(2);
    subsysMenuPanel.add(allSubSystemFamily);

    subSystemdockLayoutPanel.addWest(subsysMenuPanel, 11);

    //sub system content
    subsysContentDeckPanel = new DeckPanel();
    subsysContentDeckPanel.setAnimationEnabled(true);

    //html
    HTML subsystemHtml = new HTML("This is place you can manager your Sub System", true);
    subsysContentDeckPanel.add(subsystemHtml);

    //add circuit page
    circuitsFlexTable = new FlexTable();
    circuitsFlexTable.setSize("500px", "100px");
    circuitsFlexTable.setCellPadding(2);
    circuitsFlexTable.setCellSpacing(2);
    subsysContentDeckPanel.add(this.circuitsFlexTable);

    subSystemdockLayoutPanel.add(subsysContentDeckPanel);

    //end of sub system content

    tabPanel.add(subSystemdockLayoutPanel, "Sub System Design");
    //end of system       

    //config vechile
    DockLayoutPanel vehicledockLayoutPanel = new DockLayoutPanel(Unit.EM);

    VerticalPanel vehicleMenuPanel = new VerticalPanel();
    vehicleMenuPanel.setVerticalAlignment(HasVerticalAlignment.ALIGN_MIDDLE);
    vehicleMenuPanel.setSize("160px", "120px");

    Button addVehcile = new Button("Add Vehicle");
    addVehcile.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent event) {
            Window.alert("Working on it, stay tune...");
        }
    });
    vehicleMenuPanel.setSpacing(2);
    vehicleMenuPanel.add(addVehcile);

    //all sub system
    Button addTrim = new Button("Add Trim");
    addTrim.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent event) {
            Window.alert("Working on it, stay tune...");
        }
    });
    vehicleMenuPanel.setSpacing(2);
    vehicleMenuPanel.add(addTrim);

    vehicledockLayoutPanel.addWest(vehicleMenuPanel, 11);

    tabPanel.add(vehicledockLayoutPanel, "Vehicle Configurations");
    //end of //config vechile

    DockLayoutPanel qadockLayoutPanel = new DockLayoutPanel(Unit.EM);

    tabPanel.add(qadockLayoutPanel, "Quality Assurance");

    DockLayoutPanel midockLayoutPanel = new DockLayoutPanel(Unit.EM);

    tabPanel.add(midockLayoutPanel, "Manufacture Interface");

    tabPanel.selectTab(0);
    getAllUsers();
    deckPanel.showWidget(1);

}

From source file:com.mashery.examples.api.client.PagedTable.java

License:Open Source License

public PagedTable(int pageSize) {
    assert pageSize > 0;
    this.pageSize = pageSize;

    Grid rootPanel = new Grid(2, 1);

    table = new FlexTable();
    rootPanel.setWidget(0, 0, table);/*from   ww w  . j ava 2 s.c  om*/
    table.addStyleName("gwt-PagedTable");
    table.setWidth("100%");
    //      table.setBorderWidth(1);
    table.getRowFormatter().addStyleName(0, "gwt-PagedTableHeader");

    Grid controlPanel = new Grid(1, 5);
    rootPanel.setWidget(1, 0, controlPanel);
    controlPanel.setSize("100%", "2em");

    firstButton = new PushButton("|<", new ControlButtonHandler() {
        @Override
        protected void setPageIndex() {
            pageIndex = 0;
        }
    });

    firstButton.setWidth("4em");
    firstButton.getElement().getStyle().setProperty("textAlign", "center");

    prevButton = new PushButton("<<", new ControlButtonHandler() {
        @Override
        protected void setPageIndex() {
            --pageIndex;
        }
    });

    prevButton.setWidth("4em");
    prevButton.getElement().getStyle().setProperty("textAlign", "center");

    nextButton = new PushButton(">>", new ControlButtonHandler() {
        @Override
        protected void setPageIndex() {
            ++pageIndex;
        }
    });

    nextButton.setWidth("4em");
    nextButton.getElement().getStyle().setProperty("textAlign", "center");

    lastButton = new PushButton(">|", new ControlButtonHandler() {
        @Override
        protected void setPageIndex() {
            pageIndex = pageCount - 1;
        }
    });

    lastButton.setWidth("4em");
    lastButton.getElement().getStyle().setProperty("textAlign", "center");

    Grid centerPanel = new Grid(1, 2);

    pageLabel = new InlineLabel();
    centerPanel.setWidget(0, 0, pageLabel);

    Anchor refreshLink = new Anchor("Refresh", "#");
    refreshLink.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(ClickEvent event) {
            event.preventDefault();
            showLoading(true);
            reloadData(args);
        }
    });

    refreshPanel = new FlowPanel();
    centerPanel.setWidget(0, 1, refreshPanel);

    refreshPanel.add(new InlineHTML("&nbsp;|&nbsp;"));
    refreshPanel.add(refreshLink);

    controlPanel.setWidget(0, 0, firstButton);
    controlPanel.setWidget(0, 1, prevButton);
    controlPanel.setWidget(0, 2, centerPanel);
    controlPanel.setWidget(0, 3, nextButton);
    controlPanel.setWidget(0, 4, lastButton);

    controlPanel.getRowFormatter().setVerticalAlign(0, HasVerticalAlignment.ALIGN_MIDDLE);
    controlPanel.getCellFormatter().setHorizontalAlignment(0, 2, HasHorizontalAlignment.ALIGN_CENTER);
    controlPanel.getCellFormatter().setWidth(0, 2, "100%");

    updateNavigationControls();

    loadingPopup = new PopupPanel();
    loadingPopup.getElement().getStyle().setBorderStyle(BorderStyle.NONE);
    loadingPopup.getElement().getStyle().setBorderWidth(0d, Unit.PX);
    loadingPopup.getElement().getStyle().setOpacity(0.75d);
    Grid loadingLabel = new Grid(1, 1);
    loadingPopup.setWidget(loadingLabel);
    loadingLabel.setWidget(0, 0, new Image("resources/img/ajax-loader.gif"));
    loadingLabel.getCellFormatter().setAlignment(0, 0, HasHorizontalAlignment.ALIGN_CENTER,
            HasVerticalAlignment.ALIGN_MIDDLE);

    initWidget(rootPanel);
}