Example usage for com.google.gwt.user.client.ui Grid getRowCount

List of usage examples for com.google.gwt.user.client.ui Grid getRowCount

Introduction

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

Prototype

@Override
public int getRowCount() 

Source Link

Document

Return number of rows.

Usage

From source file:asquare.gwt.tests.memoryleak.client.Demo.java

License:Apache License

public void onModuleLoad() {
    m_button.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent event) {
            if (m_popupPanel == null) {
                m_popupPanel = new NonModalPopup();
                Grid grid = new Grid(10, 10);
                for (int row = 0; row < grid.getRowCount(); row++) {
                    for (int col = 0; col < grid.getColumnCount(); col++) {
                        grid.setHTML(row, col, "<img height='20' width='20' src='JohannesElison.jpg'/>");
                    }/*from  ww  w  .j a  va  2s  . c o m*/
                }
                m_popupPanel.add(grid);
                m_popupPanel.show();
                m_button.setText("Remove Popup");
            } else {
                m_popupPanel.hide();
                m_popupPanel = null;
                m_button.setText("Add Popup");
            }
        }
    });
    RootPanel.get().add(m_button);
}

From source file:co.fxl.gui.gwt.GWTGridPanel.java

License:Open Source License

private void resize() {
    Grid grid = (Grid) container.widget;
    if (gridCell.column >= grid.getColumnCount()) {
        grid.resizeColumns(gridCell.column + 1);
    }/*  ww  w.  ja v  a  2  s.  c  o  m*/
    if (gridCell.row >= grid.getRowCount()) {
        grid.resizeRows(gridCell.row + 1);
    }
}

From source file:co.fxl.gui.gwt.GWTGridPanel.java

License:Open Source License

@Override
public int rows() {
    Grid grid = (Grid) container.widget;
    return grid.getRowCount();
}

From source file:com.example.texture_mapping.client.Texture_mapping.java

License:Apache License

public void onModuleLoad() {
    // HTML ben/*  w ww  . j a  v a2s .c o  m*/
    Grid grid = new Grid(3, 3);
    grid.setBorderWidth(1);

    int numRows = grid.getRowCount();
    int numColumns = grid.getColumnCount();
    for (int row = 0; row < numRows; row++) {
        for (int col = 0; col < numColumns; col++) {
            grid.setWidget(row, col, new Image(PlaceholderImages.INSTANCE.myImage()));
        }
    }

    RootPanel.get().add(grid);

    // WebGL
    final Canvas webGLCanvas = Canvas.createIfSupported();
    webGLCanvas.setCoordinateSpaceHeight(500); // ToDo: AutoSize
    webGLCanvas.setCoordinateSpaceWidth(500);
    glContext = (WebGLRenderingContext) webGLCanvas.getContext("experimental-webgl");
    if (glContext == null) {
        glContext = (WebGLRenderingContext) webGLCanvas.getContext("experimental-webgl");
    }

    if (glContext == null) {
        Window.alert("Sorry, Your Browser doesn't support WebGL!");
    }

    glContext.viewport(0, 0, 500, 500);

    RootPanel.get("gwtGL").add(webGLCanvas);
    start();
}

From source file:com.google.gerrit.client.account.ContactPanelShort.java

License:Apache License

protected void onInitUI() {
    if (LocaleInfo.getCurrentLocale().isRTL()) {
        labelIdx = 1;// w w  w .  j  a  v  a2s .c o m
        fieldIdx = 0;
    } else {
        labelIdx = 0;
        fieldIdx = 1;
    }

    nameTxt = new NpTextBox();
    nameTxt.setVisibleLength(60);
    nameTxt.setReadOnly(!canEditFullName());

    emailPick = new ListBox();

    final Grid infoPlainText = new Grid(2, 2);
    infoPlainText.setStyleName(Gerrit.RESOURCES.css().infoBlock());
    infoPlainText.addStyleName(Gerrit.RESOURCES.css().accountInfoBlock());

    body.add(infoPlainText);

    registerNewEmail = new Button(Util.C.buttonOpenRegisterNewEmail());
    registerNewEmail.setEnabled(false);
    registerNewEmail.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(final ClickEvent event) {
            doRegisterNewEmail();
        }
    });
    final FlowPanel emailLine = new FlowPanel();
    emailLine.add(emailPick);
    if (canRegisterNewEmail()) {
        emailLine.add(registerNewEmail);
    }

    int row = 0;
    if (!Gerrit.getConfig().canEdit(FieldName.USER_NAME) && Gerrit.getConfig().siteHasUsernames()) {
        infoPlainText.resizeRows(infoPlainText.getRowCount() + 1);
        row(infoPlainText, row++, Util.C.userName(), new UsernameField());
    }

    if (!canEditFullName()) {
        FlowPanel nameLine = new FlowPanel();
        nameLine.add(nameTxt);
        if (Gerrit.getConfig().getEditFullNameUrl() != null) {
            Button edit = new Button(Util.C.linkEditFullName());
            edit.addClickHandler(new ClickHandler() {
                @Override
                public void onClick(ClickEvent event) {
                    Window.open(Gerrit.getConfig().getEditFullNameUrl(), "_blank", null);
                }
            });
            nameLine.add(edit);
        }
        Button reload = new Button(Util.C.linkReloadContact());
        reload.addClickHandler(new ClickHandler() {
            @Override
            public void onClick(ClickEvent event) {
                Window.Location.replace(Gerrit.loginRedirect(PageLinks.SETTINGS_CONTACT));
            }
        });
        nameLine.add(reload);
        row(infoPlainText, row++, Util.C.contactFieldFullName(), nameLine);
    } else {
        row(infoPlainText, row++, Util.C.contactFieldFullName(), nameTxt);
    }
    row(infoPlainText, row++, Util.C.contactFieldEmail(), emailLine);

    infoPlainText.getCellFormatter().addStyleName(0, 0, Gerrit.RESOURCES.css().topmost());
    infoPlainText.getCellFormatter().addStyleName(0, 1, Gerrit.RESOURCES.css().topmost());
    infoPlainText.getCellFormatter().addStyleName(row - 1, 0, Gerrit.RESOURCES.css().bottomheader());

    save = new Button(Util.C.buttonSaveChanges());
    save.setEnabled(false);
    save.addClickHandler(new ClickHandler() {
        @Override
        public void onClick(final ClickEvent event) {
            doSave(null);
        }
    });
    new OnEditEnabler(save, nameTxt);

    emailPick.addChangeHandler(new ChangeHandler() {
        @Override
        public void onChange(final ChangeEvent event) {
            final int idx = emailPick.getSelectedIndex();
            final String v = 0 <= idx ? emailPick.getValue(idx) : null;
            if (Util.C.buttonOpenRegisterNewEmail().equals(v)) {
                for (int i = 0; i < emailPick.getItemCount(); i++) {
                    if (currentEmail.equals(emailPick.getValue(i))) {
                        emailPick.setSelectedIndex(i);
                        break;
                    }
                }
                doRegisterNewEmail();
            } else {
                save.setEnabled(true);
            }
        }
    });
}

From source file:com.google.gwt.sample.showcase.client.content.tables.CwGrid.java

License:Apache License

/**
 * Initialize this example.//from  w  w  w.ja v  a 2  s.  c  o m
 */
@ShowcaseSource
@Override
public Widget onInitialize() {
    // Create a grid
    Grid grid = new Grid(4, 4);

    // Add images to the grid
    int numRows = grid.getRowCount();
    int numColumns = grid.getColumnCount();
    for (int row = 0; row < numRows; row++) {
        for (int col = 0; col < numColumns; col++) {
            grid.setWidget(row, col, new Image(Showcase.images.gwtLogo()));
        }
    }

    // Return the panel
    grid.ensureDebugId("cwGrid");
    return grid;
}

From source file:com.gs.fw.common.mithra.ui.gwt.client.ControllerPanel.java

License:Apache License

private void updateData(CachedClassData cachedClassData) {
    Grid g = this.grid;
    if (g != null && (filter == null
            || MithraCacheUi.contains(cachedClassData.getClassName().toLowerCase(), filter))) {
        for (int i = 0; i < g.getRowCount(); i++) {
            if (g.getText(i, 0).equals(cachedClassData.getClassName())) {
                populateRow(g, i, cachedClassData);
            }/*w  ww  . j  a v a 2  s  . c o m*/
        }
    }
}

From source file:com.nanosim.client.content.tables.CwGrid.java

License:Apache License

/**
 * Initialize this example./*www . j  av a2 s. c  o  m*/
 */
@NanosimSource
@Override
public Widget onInitialize() {
    // Create a grid
    Grid grid = new Grid(4, 4);

    // Add images to the grid
    int numRows = grid.getRowCount();
    int numColumns = grid.getColumnCount();
    for (int row = 0; row < numRows; row++) {
        for (int col = 0; col < numColumns; col++) {
            grid.setWidget(row, col, Nanosim.images.logo().createImage());
        }
    }

    // Return the panel
    grid.ensureDebugId("cwGrid");
    return grid;
}

From source file:com.novartis.pcs.ontology.webapp.client.view.AddRelationshipPopup.java

License:Apache License

private void addDialogWidgets() {
    VerticalPanel vertPanel = new VerticalPanel();
    Grid grid = new Grid(4, 2);
    HorizontalPanel buttonsHPanel = new HorizontalPanel();
    DisclosurePanel recentlyViewedPanel = new DisclosurePanel("Recently Viewed Terms");
    DisclosurePanel recentlyCreatedPanel = new DisclosurePanel("Recently Created Terms");
    Button cancelButton = new Button("Cancel");

    recentlyViewedPanel.getHeader().addStyleName("dialog-label");
    recentlyViewedPanel.add(recentlyViewTable);

    recentlyCreatedPanel.getHeader().addStyleName("dialog-label");
    recentlyCreatedPanel.add(recentlyCreatedTable);

    cancelButton.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent event) {
            dialogBox.hide();//w  w w.j  av a  2s.c  o  m
            if (currentTerm != null) {
                eventBus.fireEvent(new ViewTermEvent(currentTerm));
            }
        }
    });

    grid.addStyleName("gwt-Grid");
    errorLabel.addStyleName("dialog-error");
    buttonsHPanel.addStyleName("dialog-buttons");
    buttonsHPanel.addStyleName("centered-hortz");
    vertPanel.addStyleName("dialog-vpanel");
    //vertPanel.setHorizontalAlignment(VerticalPanel.ALIGN_CENTER);

    int row = 0, col = 0;
    grid.setWidget(row, col, new Label("Ontology:"));
    grid.setWidget(++row, col, new Label("Term:"));
    grid.setWidget(++row, col, new Label("Relationship:"));
    grid.setWidget(++row, col, new Label("Related Term:"));
    row = 0;
    col = 1;
    grid.setWidget(row, col, ontologyLabel);
    grid.setWidget(++row, col, termLabel);
    grid.setWidget(++row, col, typeDropBox);
    grid.setWidget(++row, col, relatedTermLabel);

    for (row = col = 0; row < grid.getRowCount(); row++) {
        Label label = (Label) grid.getWidget(row, col);
        label.addStyleName("dialog-label");
    }

    buttonsHPanel.add(addButton);
    buttonsHPanel.add(cancelButton);

    vertPanel.add(grid);
    vertPanel.add(recentlyViewedPanel);
    vertPanel.add(recentlyCreatedPanel);
    vertPanel.add(errorLabel);
    vertPanel.add(buttonsHPanel);
    dialogBox.setWidget(vertPanel);
}

From source file:com.novartis.pcs.ontology.webapp.client.view.CrossRefPopup.java

License:Apache License

private void addDialogWidgets() {
    VerticalPanel vertPanel = new VerticalPanel();
    Grid grid = new Grid(4, 2); //new Grid(6,2);
    SimplePager.Resources pagerResources = GWT.create(SimplePager.Resources.class);
    SimplePager pager = new SimplePager(TextLocation.CENTER, pagerResources, false, 0, true) {
        @Override//from  w w  w  .j  a va 2  s. c o  m
        public void setPageStart(int index) {
            HasRows display = getDisplay();
            if (display != null) {
                Range range = display.getVisibleRange();
                int pageSize = range.getLength();
                if (isRangeLimited() && display.isRowCountExact()) {
                    index = Math.min(index, display.getRowCount() - 1);
                }
                index = Math.max(0, index);
                if (index != range.getStart()) {
                    display.setVisibleRange(index, pageSize);
                }
            }
        }
    };

    Button closeButton = new Button("Close");
    closeButton.addClickHandler(new ClickHandler() {
        public void onClick(ClickEvent event) {
            if (errorLabel.isVisible()) {
                errorLabel.setVisible(false);
            }

            dialogBox.hide();
        }
    });

    vertPanel.addStyleName("dialog-vpanel");
    vertPanel.add(errorLabel);
    //vertPanel.setHorizontalAlignment(VerticalPanel.ALIGN_CENTER);

    grid.addStyleName("gwt-Grid");
    int row = 0, col = 0;
    //grid.setWidget(row, col, new Label("Ontology:"));
    //grid.setWidget(++row, col, new Label("Ontology Term:"));
    grid.setWidget(row, col, new Label("Vocabulary Domain:"));
    grid.setWidget(++row, col, new Label("Vocabulary Context:"));
    grid.setWidget(++row, col, new Label("Vocabulary Source:"));
    grid.setWidget(++row, col, new Label("Keyword Filter:"));
    row = 0;
    col = 1;
    //grid.setWidget(row, col, ontologyLabel);
    //grid.setWidget(++row, col, termLabel);
    grid.setWidget(row, col, domainDropBox);
    grid.setWidget(++row, col, contextDropBox);
    grid.setWidget(++row, col, sourceDropBox);
    grid.setWidget(++row, col, filterTextBox);

    for (row = col = 0; row < grid.getRowCount(); row++) {
        Label label = (Label) grid.getWidget(row, col);
        label.addStyleName("dialog-label");
    }

    FlowPanel flowPanel = new FlowPanel();
    flowPanel.addStyleName("decorator-panel");
    flowPanel.add(grid);
    flowPanel.add(table);
    flowPanel.add(pager);

    pager.setDisplay(table);
    pager.addStyleName("centered-hortz");

    vertPanel.add(flowPanel);
    //vertPanel.setCellHorizontalAlignment(flowPanel, HasHorizontalAlignment.ALIGN_LEFT);
    /*
    Label tip = new Label("Click icon next to unmapped term to perform auto search in main window");
     tip.addStyleName("dialog-message");
    tip.addStyleName("info-icon-left");
    vertPanel.add(tip);
    vertPanel.setCellHorizontalAlignment(tip, HasHorizontalAlignment.ALIGN_LEFT);
    */

    if (curator != null) {

        Label tip = new Label("Select ontology/codelist term in main window");
        tip.addStyleName("dialog-message");
        tip.addStyleName("info-icon-left");
        vertPanel.add(tip);
        //vertPanel.setCellHorizontalAlignment(tip, HasHorizontalAlignment.ALIGN_LEFT);

        SimplePanel decPanel = new SimplePanel();
        decPanel.addStyleName("decorator-panel");
        vertPanel.add(decPanel);
        //vertPanel.setCellHorizontalAlignment(decPanel, HasHorizontalAlignment.ALIGN_LEFT);

        grid = new Grid(3, 2);
        grid.addStyleName("gwt-Grid");

        row = 0;
        col = 0;

        grid.setWidget(row, col, ontologyHeadingLabel);
        grid.setWidget(++row, col, new Label("Term:"));
        grid.setWidget(++row, col, new Label("Synonym Type:"));

        row = 0;
        col = 1;
        grid.setWidget(row, col, ontologyLabel);
        grid.setWidget(++row, col, termLabel);
        grid.setWidget(++row, col, typeDropBox);

        for (row = col = 0; row < grid.getRowCount(); row++) {
            Label label = (Label) grid.getWidget(row, col);
            label.addStyleName("dialog-label");
        }

        decPanel.setWidget(grid);

        HorizontalPanel buttonsHPanel = new HorizontalPanel();
        Button excludeButton = new Button("Exclude");

        excludeButton.addClickHandler(new ClickHandler() {
            public void onClick(ClickEvent event) {
                final Set<ControlledVocabularyTerm> selected = selection.getSelectedSet();
                selected.removeAll(processing);
                if (!selected.isEmpty()) {
                    processing.addAll(selected);
                    busyIndicator.busy();

                    if (errorLabel.isVisible()) {
                        errorLabel.setVisible(false);
                    }

                    service.excludeControlledVocabularyTerms(selected, new AsyncCallback<Void>() {
                        public void onFailure(Throwable caught) {
                            GWT.log("Failed to exclude vocab terms", caught);
                            processing.removeAll(selected);
                            busyIndicator.idle();
                            ErrorView.instance().onUncaughtException(caught);
                        }

                        public void onSuccess(Void v) {
                            processing.removeAll(selected);
                            for (ControlledVocabularyTerm t : selected) {
                                selection.setSelected(t, false);
                            }
                            dataProvider.getList().removeAll(selected);
                            busyIndicator.idle();
                        }
                    });
                }
            }
        });

        buttonsHPanel.add(addButton);
        if (createChildTermButton != null) {
            buttonsHPanel.add(createChildTermButton);
        }
        buttonsHPanel.add(excludeButton);
        buttonsHPanel.add(closeButton);
        buttonsHPanel.addStyleName("dialog-buttons");
        buttonsHPanel.addStyleName("centered-hortz");
        vertPanel.add(buttonsHPanel);
        /*
        Label label = new Label("*Use Shift key to select/unselect consecutive rows");
        label.addStyleName("dialog-message");
        vertPanel.add(label);
        */
    } else {
        vertPanel.add(closeButton);
        vertPanel.setCellHorizontalAlignment(closeButton, HasHorizontalAlignment.ALIGN_CENTER);
    }

    dialogBox.setWidget(vertPanel);
}