Example usage for com.google.gwt.user.cellview.client Column setHorizontalAlignment

List of usage examples for com.google.gwt.user.cellview.client Column setHorizontalAlignment

Introduction

In this page you can find the example usage for com.google.gwt.user.cellview.client Column setHorizontalAlignment.

Prototype

@Override
public void setHorizontalAlignment(HorizontalAlignmentConstant align) 

Source Link

Document

The new horizontal alignment will apply the next time the table is rendered.

Usage

From source file:com.gsr.myschool.back.client.web.application.settings.widget.MatiereExamenView.java

License:Apache License

private void initDataGrid() {
    TextColumn<MatiereExamenProxy> nomPrenomColumn = new TextColumn<MatiereExamenProxy>() {
        @Override// w  w  w  .  j  a v a  2  s .  co  m
        public String getValue(MatiereExamenProxy object) {
            return object.getNom();
        }
    };
    nomPrenomColumn.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_LEFT);
    matiereExamenTable.addColumn(nomPrenomColumn, "Nom");
    matiereExamenTable.setColumnWidth(nomPrenomColumn, 70, Style.Unit.PCT);

    ActionCell<MatiereExamenProxy> actionCell = new ActionCell<MatiereExamenProxy>("Supprimer",
            new ActionCell.Delegate<MatiereExamenProxy>() {
                @Override
                public void execute(MatiereExamenProxy object) {
                    getUiHandlers().deleteMatiereExamen(object);
                }
            });
    Column<MatiereExamenProxy, MatiereExamenProxy> actionColumn = new Column<MatiereExamenProxy, MatiereExamenProxy>(
            actionCell) {
        @Override
        public MatiereExamenProxy getValue(MatiereExamenProxy object) {
            return object;
        }
    };
    actionColumn.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);
    matiereExamenTable.addColumn(actionColumn, "Action");
    matiereExamenTable.setColumnWidth(actionColumn, 30, Style.Unit.PCT);
}

From source file:com.gsr.myschool.back.client.web.application.settings.widget.PiecesJustifView.java

License:Apache License

private void initDataGrid() {
    TextColumn<PieceJustifProxy> nomPrenomColumn = new TextColumn<PieceJustifProxy>() {
        @Override/*from  w  w  w. ja v  a  2 s.c o m*/
        public String getValue(PieceJustifProxy object) {
            return object.getNom();
        }
    };
    nomPrenomColumn.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_LEFT);
    piecesJustifTable.addColumn(nomPrenomColumn, "Nom");
    piecesJustifTable.setColumnWidth(nomPrenomColumn, 70, Style.Unit.PCT);

    ActionCell<PieceJustifProxy> actionCell = new ActionCell<PieceJustifProxy>("Supprimer",
            new ActionCell.Delegate<PieceJustifProxy>() {
                @Override
                public void execute(PieceJustifProxy object) {
                    getUiHandlers().deletePieceJustif(object);
                }
            });
    Column<PieceJustifProxy, PieceJustifProxy> actionColumn = new Column<PieceJustifProxy, PieceJustifProxy>(
            actionCell) {
        @Override
        public PieceJustifProxy getValue(PieceJustifProxy object) {
            return object;
        }
    };
    actionColumn.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);
    piecesJustifTable.addColumn(actionColumn, "Action");
    piecesJustifTable.setColumnWidth(actionColumn, 30, Style.Unit.PCT);
}

From source file:com.gsr.myschool.back.client.web.application.user.UserAccountView.java

License:Apache License

private void initDataGrid() {
    TextColumn<UserProxy> refColumn = new TextColumn<UserProxy>() {
        @Override//from ww w  . j a  v a  2 s.  c o  m
        public String getValue(UserProxy object) {
            return object.getFirstName() + " " + object.getLastName();
        }
    };
    refColumn.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);
    userPortalTable.addColumn(refColumn, "Nom");
    userPortalTable.setColumnWidth(refColumn, 20, Style.Unit.PCT);

    TextColumn<UserProxy> emailColumn = new TextColumn<UserProxy>() {
        @Override
        public String getValue(UserProxy object) {
            return object.getEmail();
        }
    };
    emailColumn.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_LEFT);
    userPortalTable.addColumn(emailColumn, "Email");
    userPortalTable.setColumnWidth(emailColumn, 30, Style.Unit.PCT);

    TextColumn<UserProxy> submittedColumn = new TextColumn<UserProxy>() {
        @Override
        public String getValue(UserProxy object) {
            if (object.getCreated() == null)
                return "";
            return dateFormat.format(object.getCreated());
        }
    };
    submittedColumn.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_LEFT);
    userPortalTable.addColumn(submittedColumn, "Date de cration");
    userPortalTable.setColumnWidth(submittedColumn, 20, Style.Unit.PCT);

    TextColumn<UserProxy> statusColumn = new TextColumn<UserProxy>() {
        @Override
        public String getValue(UserProxy object) {
            if (object.getStatus() == null)
                return "";
            return object.getStatus().toString();
        }
    };
    statusColumn.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);
    userPortalTable.addColumn(statusColumn, "Statut");
    userPortalTable.setColumnWidth(statusColumn, 15, Style.Unit.PCT);

    TextColumn<UserProxy> roleColumn = new TextColumn<UserProxy>() {
        @Override
        public String getValue(UserProxy object) {
            if (object.getAuthority() == null)
                return "";
            return object.getAuthority().toString();
        }
    };
    roleColumn.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);
    userPortalTable.addColumn(roleColumn, "Type");
    userPortalTable.setColumnWidth(roleColumn, 15, Style.Unit.PCT);

    UserAccountActionCell actionsCell = actionCellFactory.create(editAccount, logingAccount);
    Column<UserProxy, UserProxy> actionsColumn = new Column<UserProxy, UserProxy>(actionsCell) {
        @Override
        public UserProxy getValue(UserProxy object) {
            return object;
        }
    };
    actionsColumn.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);
    userPortalTable.addColumn(actionsColumn, "Actions");
    userPortalTable.setColumnWidth(actionsColumn, 10, Style.Unit.PCT);
}

From source file:com.gsr.myschool.back.client.web.application.usergsr.AdminUserAccountView.java

License:Apache License

private void initDataGrid() {
    TextColumn<AdminUserProxy> loginColumn = new TextColumn<AdminUserProxy>() {
        @Override/* ww w .jav  a2  s  .  c  o  m*/
        public String getValue(AdminUserProxy object) {
            return object.getEmail();
        }
    };
    loginColumn.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);
    userGsrTable.addColumn(loginColumn, "Email");
    userGsrTable.setColumnWidth(loginColumn, 20, Style.Unit.PCT);

    TextColumn<AdminUserProxy> fNameColumn = new TextColumn<AdminUserProxy>() {
        @Override
        public String getValue(AdminUserProxy object) {
            return object.getFirstName();
        }
    };
    fNameColumn.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);
    userGsrTable.addColumn(fNameColumn, "Prnom");
    userGsrTable.setColumnWidth(fNameColumn, 20, Style.Unit.PCT);

    TextColumn<AdminUserProxy> lNameColumn = new TextColumn<AdminUserProxy>() {
        @Override
        public String getValue(AdminUserProxy object) {
            return object.getLastName();
        }
    };
    lNameColumn.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);
    userGsrTable.addColumn(lNameColumn, "Nom");
    userGsrTable.setColumnWidth(lNameColumn, 20, Style.Unit.PCT);

    TextColumn<AdminUserProxy> roleColumn = new TextColumn<AdminUserProxy>() {
        @Override
        public String getValue(AdminUserProxy object) {
            if (object.getAuthority() == null)
                return "";
            return object.getAuthority().toString();
        }
    };
    roleColumn.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_LEFT);
    userGsrTable.addColumn(roleColumn, "Rle");
    userGsrTable.setColumnWidth(roleColumn, 20, Style.Unit.PCT);

    TextColumn<AdminUserProxy> statusColumn = new TextColumn<AdminUserProxy>() {
        @Override
        public String getValue(AdminUserProxy object) {
            if (object.getStatus() == null)
                return "";
            return object.getStatus().toString();
        }
    };
    statusColumn.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_LEFT);
    userGsrTable.addColumn(statusColumn, "Statut");
    userGsrTable.setColumnWidth(statusColumn, 20, Style.Unit.PCT);

    TextColumn<AdminUserProxy> submittedColumn = new TextColumn<AdminUserProxy>() {
        @Override
        public String getValue(AdminUserProxy object) {
            if (object.getCreated() == null)
                return "";
            return dateFormat.format(object.getCreated());
        }
    };
    submittedColumn.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_LEFT);
    userGsrTable.addColumn(submittedColumn, "Date de Cration");
    userGsrTable.setColumnWidth(submittedColumn, 30, Style.Unit.PCT);

    AdminUserActionCell actionsCellAdmin = actionCellFactoryAdmin.create(editAccount, delete);
    Column<AdminUserProxy, AdminUserProxy> actionsColumn = new Column<AdminUserProxy, AdminUserProxy>(
            actionsCellAdmin) {
        @Override
        public AdminUserProxy getValue(AdminUserProxy object) {
            return object;
        }
    };
    actionsColumn.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);
    userGsrTable.addColumn(actionsColumn, "Actions");
    userGsrTable.setColumnWidth(actionsColumn, 10, Style.Unit.PCT);
}

From source file:com.gsr.myschool.back.client.web.application.validation.ValidationView.java

License:Apache License

private void initDataGrid() {
    TextColumn<DossierProxy> refColumn = new TextColumn<DossierProxy>() {
        @Override/*from   ww  w  . j  a v  a2 s  . co  m*/
        public String getValue(DossierProxy object) {
            return object.getGeneratedNumDossier();
        }
    };
    refColumn.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);
    inscriptionsTable.addColumn(refColumn, "N Dossier");
    inscriptionsTable.setColumnWidth(refColumn, 10, Style.Unit.PCT);

    TextColumn<DossierProxy> cNameColumn = new TextColumn<DossierProxy>() {
        @Override
        public String getValue(DossierProxy object) {
            return object.getCandidat().getFirstname() + " " + object.getCandidat().getLastname();
        }
    };
    refColumn.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);
    inscriptionsTable.addColumn(cNameColumn, "Nom Candidat");
    inscriptionsTable.setColumnWidth(cNameColumn, 15, Style.Unit.PCT);

    TextColumn<DossierProxy> cFiliereColumn = new TextColumn<DossierProxy>() {
        @Override
        public String getValue(DossierProxy object) {
            if (object.getFiliere() == null) {
                return "";
            } else {
                return object.getFiliere().getNom();
            }
        }
    };
    cFiliereColumn.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_LEFT);
    inscriptionsTable.addColumn(cFiliereColumn, "Formation");
    inscriptionsTable.setColumnWidth(cFiliereColumn, 15, Style.Unit.PCT);

    TextColumn<DossierProxy> cLevelColumn = new TextColumn<DossierProxy>() {
        @Override
        public String getValue(DossierProxy object) {
            if (object.getNiveauEtude() == null) {
                return "";
            } else {
                return object.getNiveauEtude().getNom();
            }
        }
    };
    cLevelColumn.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_LEFT);
    inscriptionsTable.addColumn(cLevelColumn, "Niveau demand");
    inscriptionsTable.setColumnWidth(cLevelColumn, 15, Style.Unit.PCT);

    TextColumn<DossierProxy> createdColumn = new TextColumn<DossierProxy>() {
        @Override
        public String getValue(DossierProxy object) {
            if (object.getCreateDate() == null)
                return "";
            return dateFormat.format(object.getCreateDate());
        }
    };
    createdColumn.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_LEFT);
    inscriptionsTable.addColumn(createdColumn, "Date du dossier");
    inscriptionsTable.setColumnWidth(createdColumn, 20, Style.Unit.PCT);

    TextColumn<DossierProxy> statusColumn = new TextColumn<DossierProxy>() {
        @Override
        public String getValue(DossierProxy object) {
            if (object.getStatus() == null)
                return "";
            return object.getStatus().toString();
        }
    };
    statusColumn.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_LEFT);
    inscriptionsTable.addColumn(statusColumn, "Statut");
    inscriptionsTable.setColumnWidth(statusColumn, 10, Style.Unit.PCT);

    ActionCell.Delegate<DossierProxy> verifyAction = new ActionCell.Delegate<DossierProxy>() {
        @Override
        public void execute(DossierProxy dossier) {
            getUiHandlers().verify(dossier);
        }
    };
    ActionCell.Delegate<DossierProxy> previewAction = new ActionCell.Delegate<DossierProxy>() {
        @Override
        public void execute(DossierProxy dossier) {
            getUiHandlers().viewDetails(dossier);
        }
    };

    ValidationActionCell actionsCell = actionCellFactory.create(verifyAction, previewAction);
    Column<DossierProxy, DossierProxy> actionsColumn = new Column<DossierProxy, DossierProxy>(actionsCell) {
        @Override
        public DossierProxy getValue(DossierProxy object) {
            return object;
        }
    };
    actionsColumn.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);
    inscriptionsTable.addColumn(actionsColumn, "Action");
    inscriptionsTable.setColumnWidth(actionsColumn, 10, Style.Unit.PCT);
}

From source file:com.gsr.myschool.back.client.web.application.valueList.ValueListView.java

License:Apache License

private void initDataGrid() {
    TextColumn<ValueListProxy> labelColumn = new TextColumn<ValueListProxy>() {
        @Override//from   ww  w  .  ja va 2 s . c  o  m
        public String getValue(ValueListProxy valueList) {
            return valueList.getLabel();
        }
    };
    labelColumn.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_LEFT);
    valueListTable.addColumn(labelColumn, "Label");
    valueListTable.setColumnWidth(labelColumn, 35, Style.Unit.PCT);

    TextColumn<ValueListProxy> valueColumn = new TextColumn<ValueListProxy>() {
        @Override
        public String getValue(ValueListProxy valueList) {
            return valueList.getValue();
        }
    };
    valueColumn.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_LEFT);
    valueListTable.addColumn(valueColumn, "Valeur");
    valueListTable.setColumnWidth(valueColumn, 35, Style.Unit.PCT);

    ValueListActionCell actionsCell = actionCellFactory.create(deleteAction, modifyAction);
    Column<ValueListProxy, ValueListProxy> actionsColumn = new Column<ValueListProxy, ValueListProxy>(
            actionsCell) {
        @Override
        public ValueListProxy getValue(ValueListProxy object) {
            return object;
        }
    };
    actionsColumn.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_RIGHT);
    valueListTable.addColumn(actionsColumn, "Actions");
    valueListTable.setColumnWidth(actionsColumn, 35, Style.Unit.PCT);
}

From source file:com.gsr.myschool.front.client.web.application.inscription.InscriptionView.java

License:Apache License

private void initDataGrid() {
    TextColumn<DossierProxy> idColumn = new TextColumn<DossierProxy>() {
        @Override/* w w  w  .  j  ava  2s . c  o m*/
        public String getValue(DossierProxy object) {
            return object.getGeneratedNumDossier();
        }
    };
    idColumn.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);
    inscriptionsTable.addColumn(idColumn, "N Dossier");
    inscriptionsTable.setColumnWidth(idColumn, 15, Style.Unit.PCT);

    TextColumn<DossierProxy> statusColumn = new TextColumn<DossierProxy>() {
        @Override
        public String getValue(DossierProxy object) {
            return object.getStatus().toString();
        }
    };
    statusColumn.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_LEFT);
    inscriptionsTable.addColumn(statusColumn, "Statut");
    inscriptionsTable.setColumnWidth(statusColumn, 20, Style.Unit.PCT);

    TextColumn<DossierProxy> anneeScolaireColumn = new TextColumn<DossierProxy>() {
        @Override
        public String getValue(DossierProxy object) {
            if (object.getAnneeScolaire() == null)
                return "";
            return object.getAnneeScolaire().getLabel();
        }
    };
    statusColumn.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_LEFT);
    inscriptionsTable.addColumn(anneeScolaireColumn, "Anne scolaire");
    inscriptionsTable.setColumnWidth(anneeScolaireColumn, 20, Style.Unit.PCT);

    TextColumn<DossierProxy> candidatColumn = new TextColumn<DossierProxy>() {
        @Override
        public String getValue(DossierProxy dossierProxy) {
            String firstName = dossierProxy.getCandidat().getFirstname();
            String lastName = dossierProxy.getCandidat().getLastname();

            if (Strings.isNullOrEmpty(firstName) && Strings.isNullOrEmpty(lastName)) {
                return "";
            } else {
                return firstName + " " + lastName;
            }
        }
    };
    candidatColumn.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_LEFT);
    inscriptionsTable.addColumn(candidatColumn, "Candidat");
    inscriptionsTable.setColumnWidth(candidatColumn, 30, Style.Unit.PCT);

    TextColumn<DossierProxy> createdColumn = new TextColumn<DossierProxy>() {
        @Override
        public String getValue(DossierProxy object) {
            if (object.getCreateDate() == null) {
                return "";
            } else {
                return dateFormat.format(object.getCreateDate());
            }
        }
    };
    createdColumn.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_LEFT);
    inscriptionsTable.addColumn(createdColumn, "Date de pr-inscription");
    inscriptionsTable.setColumnWidth(createdColumn, 20, Style.Unit.PCT);

    actionsCell = actionCellFactory.create(previewAction, editAction, deleteAction, submitAction, printAction);
    Column<DossierProxy, DossierProxy> actionsColumn = new Column<DossierProxy, DossierProxy>(actionsCell) {
        @Override
        public DossierProxy getValue(DossierProxy object) {
            return object;
        }
    };
    actionsColumn.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);
    inscriptionsTable.addColumn(actionsColumn, "Actions");
    inscriptionsTable.setColumnWidth(actionsColumn, 15, Style.Unit.PCT);
}

From source file:com.gwtmodel.table.view.table.PresentationTable.java

License:Apache License

@SuppressWarnings("unchecked")
private void createHeader() {
    if (model == null) {
        return;/*from  w ww.java  2 s .co m*/
    }
    if (columnC) {
        return;
    }
    // 2015/05/01
    while (table.getColumnCount() > 0)
        table.removeColumn(0);
    VListHeaderContainer vo = model.getHeaderList();
    if (!CUtil.EmptyS(vo.getWidthDef())) {
        table.setWidth(vo.getWidthDef(), true);
    }
    List<VListHeaderDesc> li = vo.getVisHeList();
    int colNo = 0;
    for (VListHeaderDesc he : li) {
        boolean editable = he.isEditable();
        @SuppressWarnings("rawtypes")
        Header header = null;
        @SuppressWarnings("rawtypes")
        Column co = null;
        if (he.getgHeader() != null) {
            header = he.getgHeader().getHeader();
            co = he.getgHeader().getColumn();
            if (co == null) {
                co = new RawColumn(he.getFie());
            }
            // table.addColumn(co, header);
            // continue;
        }
        if (co == null) {
            FieldDataType fType = he.getFie().getType();
            if (he.getButtonAction() != null) {
                co = fa.constructActionButtonCell(he.getButtonAction(), he.getFie(), fType,
                        new AttachClass(he.getFie()));
            } else if (fType.isConvertableToString()) {
                if (editable) {
                    co = faEdit.constructEditTextCol(he);
                } else {
                    co = new TColumnString(he.getFie(), fType);
                }
            } else {
                switch (fType.getType()) {
                case LONG:
                case BIGDECIMAL:
                case INT:
                    if (editable) {
                        co = faEdit.constructNumberCol(he);
                    } else {
                        co = fa.constructNumberCol(he.getFie());
                    }
                    break;
                case DATE:
                    if (editable) {
                        co = faEdit.constructDateEditCol(he);
                    } else {
                        co = fa.constructDateEditCol(he.getFie());
                    }
                    break;
                case BOOLEAN:
                    if (editable) {
                        co = faEdit.contructBooleanCol(he.getFie(), !selectEnabled());
                    } else {
                        co = fa.contructBooleanCol(he.getFie());
                    }
                    break;
                default:
                    if (editable || he.isImageCol()) {
                        co = faEdit.constructEditTextCol(he);
                    } else {
                        co = fa.constructTextCol(he.getFie(), he);
                    }
                    break;
                }
            }
            co.setSortable(true);
            // align
            switch (AlignCol.getCo(he.getAlign(), he.getFie().getType())) {
            case LEFT:
                co.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_LEFT);
                break;
            case RIGHT:
                co.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_RIGHT);
                break;
            case CENTER:
                co.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_CENTER);
                break;
            }
        }
        // col width
        String width = he.getColWidth();
        if (!CUtil.EmptyS(width)) {
            String[] pa = width.split(";");
            if (pa.length == 1) {
                table.setColumnWidth(co, pa[0]);
            } else {
                double wi;
                try {
                    wi = DecimalUtils.toDouble(pa[0]);
                } catch (NumberFormatException e) {
                    String info = LogT.getT().InproperWidthInColumn(he.getHeaderString(), pa[0]);
                    LogT.errorLogE(info, e);
                    return;
                }
                Style.Unit u;
                try {
                    u = Style.Unit.valueOf(pa[1]);
                } catch (IllegalArgumentException e) {
                    String info = LogT.getT().InproperColumnUnit(he.getHeaderString(), pa[1]);
                    LogT.errorLogE(info, e);
                    return;
                }
                table.setColumnWidth(co, wi, u);
            }
        }
        //
        if (header == null && (he.isHidden() || he.getHeaderString() == null)) {
            // Important: for some reason the assert violation cause
            // breaking without Exception throwing
            // So additional error alert is displayed to avoid confusion
            Utils.errAlert(he.getFie().getId(), LogT.getT().HeaderNull());
            assert !he.isHidden() && he.getHeaderString() != null : LogT.getT().cannotBeNull();
        }

        VFooterDesc footer = null;
        if (vo.getFoList() != null) {
            for (VFooterDesc fo : vo.getFoList()) {
                if (fo.getFie().eq(he.getFie())) {
                    footer = fo;
                    break;
                }
            }
        }

        if (header == null) {
            header = footFactory.constructHeader(he, editable);
        }
        if (he.getHeaderClass() != null)
            header.setHeaderStyleNames(he.getHeaderClass());
        if (footer != null) {
            table.addColumn(co, header, footFactory.constructFooter(footer));
        } else {
            // table.addColumn(co, he.getHeaderString());
            table.addColumn(co, header);
        }

        if (!async) {
            ListHandler<MutableInteger> columnSortHandler = new ListHandler<MutableInteger>(
                    dProvider.getList());
            columnSortHandler.setComparator(co, new CoComparator(he));
            table.addColumnSortHandler(columnSortHandler);
        } else {
            ColumnSortEvent.AsyncHandler sortHandler = new ColumnSortEvent.AsyncHandler(table);
            table.addColumnSortHandler(sortHandler);
        }
        // ColumnSortEvent.fire(myTable, myTable.getColumnSortList());
        // iMap.put(colNo, he);
        coV.addColDesc(colNo, he);
        colNo++;
    } // for
    columnC = true;
    setWrapCol();
    setSortCol();
}

From source file:com.jitlogic.zico.client.views.traces.TraceCallTreePanel.java

License:Open Source License

private void createCallTreeGrid() {
    grid = new DataGrid<TraceRecordInfo>(1024 * 1024, ZicoDataGridResources.INSTANCE, KEY_PROVIDER);
    selection = new SingleSelectionModel<TraceRecordInfo>(KEY_PROVIDER);
    grid.setSelectionModel(selection);/*w  w w .j a va  2  s. c  o  m*/

    Column<TraceRecordInfo, TraceRecordInfo> colExpander = new IdentityColumn<TraceRecordInfo>(
            DETAIL_EXPANDER_CELL);
    grid.addColumn(colExpander, "#");
    grid.setColumnWidth(colExpander, 32, Style.Unit.PX);

    Column<TraceRecordInfo, TraceRecordInfo> colMethodName = new IdentityColumn<TraceRecordInfo>(
            METHOD_TREE_CELL);
    grid.addColumn(colMethodName, new ResizableHeader<TraceRecordInfo>("Method", grid, colMethodName));
    grid.setColumnWidth(colMethodName, 100, Style.Unit.PCT);

    Column<TraceRecordInfo, TraceRecordInfo> colTime = new IdentityColumn<TraceRecordInfo>(METHOD_TIME_CELL);
    grid.addColumn(colTime, new ResizableHeader<TraceRecordInfo>("Time", grid, colTime));
    grid.setColumnWidth(colTime, 60, Style.Unit.PX);
    colTime.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_RIGHT);

    Column<TraceRecordInfo, TraceRecordInfo> colCTime = new IdentityColumn<TraceRecordInfo>(METHOD_CTIME_CELL);
    grid.addColumn(colCTime, new ResizableHeader<TraceRecordInfo>("CTime", grid, colTime));
    grid.setColumnWidth(colCTime, 60, Style.Unit.PX);
    colCTime.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_RIGHT);

    Column<TraceRecordInfo, TraceRecordInfo> colCalls = new IdentityColumn<TraceRecordInfo>(METHOD_CALLS_CELL);
    grid.addColumn(colCalls, new ResizableHeader<TraceRecordInfo>("Calls", grid, colCalls));
    grid.setColumnWidth(colCalls, 60, Style.Unit.PX);

    Column<TraceRecordInfo, TraceRecordInfo> colErrors = new IdentityColumn<TraceRecordInfo>(
            METHOD_ERRORS_CELL);
    grid.addColumn(colErrors, new ResizableHeader<TraceRecordInfo>("Errors", grid, colErrors));
    grid.setColumnWidth(colErrors, 60, Style.Unit.PX);

    Column<TraceRecordInfo, TraceRecordInfo> colPct = new IdentityColumn<TraceRecordInfo>(METHOD_PCT_CELL);
    grid.addColumn(colPct, new ResizableHeader<TraceRecordInfo>("Pct", grid, colPct));
    grid.setColumnWidth(colPct, 60, Style.Unit.PX);

    rowBuilder = new TraceCallTableBuilder(grid, expandedDetails);
    grid.setTableBuilder(rowBuilder);

    // Disable hovering "features" overall to improve performance on big trees.
    grid.setSkipRowHoverStyleUpdate(true);
    grid.setSkipRowHoverFloatElementCheck(true);
    grid.setSkipRowHoverCheck(true);
    grid.setKeyboardSelectionPolicy(HasKeyboardSelectionPolicy.KeyboardSelectionPolicy.DISABLED);

    grid.addCellPreviewHandler(new CellPreviewEvent.Handler<TraceRecordInfo>() {
        @Override
        public void onCellPreview(CellPreviewEvent<TraceRecordInfo> event) {
            NativeEvent nev = event.getNativeEvent();
            String eventType = nev.getType();
            if ((BrowserEvents.KEYDOWN.equals(eventType) && nev.getKeyCode() == KeyCodes.KEY_ENTER)
                    || BrowserEvents.DBLCLICK.equals(nev.getType())) {
                TraceRecordInfo tr = event.getValue();
                panelFactory.methodAttrsDialog(trace.getHostName(), trace.getDataOffs(), tr.getPath(), 0L)
                        .asPopupWindow().show();
            }
            if (BrowserEvents.CONTEXTMENU.equals(eventType)) {
                selection.setSelected(event.getValue(), true);
                contextMenu.setPopupPosition(event.getNativeEvent().getClientX(),
                        event.getNativeEvent().getClientY());
                contextMenu.show();
            }
        }
    });

    grid.addDomHandler(new DoubleClickHandler() {
        @Override
        public void onDoubleClick(DoubleClickEvent event) {
            event.preventDefault();
        }
    }, DoubleClickEvent.getType());

    grid.addDomHandler(new ContextMenuHandler() {
        @Override
        public void onContextMenu(ContextMenuEvent event) {
            event.preventDefault();
        }
    }, ContextMenuEvent.getType());

    data = new ListDataProvider<TraceRecordInfo>();
    data.addDataDisplay(grid);
}

From source file:com.jitlogic.zico.client.views.traces.TraceSearchPanel.java

License:Open Source License

private void createTraceGrid() {
    grid = new DataGrid<TraceInfo>(1024 * 1024, ZicoDataGridResources.INSTANCE, KEY_PROVIDER);
    selection = new SingleSelectionModel<TraceInfo>(KEY_PROVIDER);
    grid.setSelectionModel(selection);//  ww  w  .j  ava2  s.c  o m

    data = new ListDataProvider<TraceInfo>();
    data.addDataDisplay(grid);

    sortHandler = new ColumnSortEvent.ListHandler<TraceInfo>(data.getList());
    grid.addColumnSortHandler(sortHandler);

    Column<TraceInfo, TraceInfo> colExpander = new IdentityColumn<TraceInfo>(DETAIL_EXPANDER_CELL);
    grid.addColumn(colExpander, "#");
    grid.setColumnWidth(colExpander, 32, Style.Unit.PX);

    Column<TraceInfo, TraceInfo> colTraceClock = new IdentityColumn<TraceInfo>(TRACE_CLOCK_CELL);
    grid.addColumn(colTraceClock, new ResizableHeader<TraceInfo>("Clock", grid, colTraceClock));
    grid.setColumnWidth(colTraceClock, 140, Style.Unit.PX);

    colTraceClock.setSortable(true);
    sortHandler.setComparator(colTraceClock, new Comparator<TraceInfo>() {
        @Override
        public int compare(TraceInfo o1, TraceInfo o2) {
            return (int) (o1.getClock() - o2.getClock());
        }
    });

    Column<TraceInfo, TraceInfo> colTraceType = new IdentityColumn<TraceInfo>(TRACE_TYPE_CELL);
    grid.addColumn(colTraceType, new ResizableHeader<TraceInfo>("Type", grid, colTraceType));
    grid.setColumnWidth(colTraceType, 60, Style.Unit.PX);

    Column<TraceInfo, TraceInfo> colTraceDuration = new IdentityColumn<TraceInfo>(TRACE_DURATION_CELL);
    grid.addColumn(colTraceDuration, new ResizableHeader<TraceInfo>("Time", grid, colTraceDuration));
    grid.setColumnWidth(colTraceDuration, 64, Style.Unit.PX);
    colTraceDuration.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_RIGHT);

    colTraceDuration.setSortable(true);
    sortHandler.setComparator(colTraceDuration, new Comparator<TraceInfo>() {
        @Override
        public int compare(TraceInfo o1, TraceInfo o2) {
            return (int) ((o1.getExecutionTime() - o2.getExecutionTime()) / 1000000L);
        }
    });

    Column<TraceInfo, TraceInfo> colTraceCalls = new IdentityColumn<TraceInfo>(TRACE_CALLS_CELL);
    grid.addColumn(colTraceCalls, new ResizableHeader<TraceInfo>("Calls", grid, colTraceCalls));
    grid.setColumnWidth(colTraceCalls, 50, Style.Unit.PX);

    colTraceCalls.setSortable(true);
    sortHandler.setComparator(colTraceCalls, new Comparator<TraceInfo>() {
        @Override
        public int compare(TraceInfo o1, TraceInfo o2) {
            return (int) (o1.getCalls() - o2.getCalls());
        }
    });

    Column<TraceInfo, TraceInfo> colTraceErrors = new IdentityColumn<TraceInfo>(TRACE_ERRORS_CELL);
    grid.addColumn(colTraceErrors, new ResizableHeader<TraceInfo>("Errs", grid, colTraceErrors));
    grid.setColumnWidth(colTraceErrors, 50, Style.Unit.PX);

    colTraceErrors.setSortable(true);
    sortHandler.setComparator(colTraceErrors, new Comparator<TraceInfo>() {
        @Override
        public int compare(TraceInfo o1, TraceInfo o2) {
            return (int) (o1.getErrors() - o2.getErrors());
        }
    });

    Column<TraceInfo, TraceInfo> colTraceRecords = new IdentityColumn<TraceInfo>(TRACE_RECORDS_CELL);
    grid.addColumn(colTraceRecords, new ResizableHeader<TraceInfo>("Recs", grid, colTraceRecords));
    grid.setColumnWidth(colTraceRecords, 50, Style.Unit.PX);

    colTraceRecords.setSortable(true);
    sortHandler.setComparator(colTraceRecords, new Comparator<TraceInfo>() {
        @Override
        public int compare(TraceInfo o1, TraceInfo o2) {
            return (int) (o1.getRecords() - o2.getRecords());
        }
    });

    Column<TraceInfo, TraceInfo> colTraceDesc = new IdentityColumn<TraceInfo>(TRACE_NAME_CELL);
    grid.addColumn(colTraceDesc, "Description");
    grid.setColumnWidth(colTraceDesc, 100, Style.Unit.PCT);

    rowBuilder = new TraceSearchTableBuilder(grid, expandedDetails);
    grid.setTableBuilder(rowBuilder);

    grid.setSkipRowHoverStyleUpdate(true);
    grid.setSkipRowHoverFloatElementCheck(true);
    grid.setSkipRowHoverCheck(true);
    grid.setKeyboardSelectionPolicy(HasKeyboardSelectionPolicy.KeyboardSelectionPolicy.DISABLED);

    grid.addCellPreviewHandler(new CellPreviewEvent.Handler<TraceInfo>() {
        @Override
        public void onCellPreview(CellPreviewEvent<TraceInfo> event) {
            NativeEvent nev = event.getNativeEvent();
            String eventType = nev.getType();
            if ((BrowserEvents.KEYDOWN.equals(eventType) && nev.getKeyCode() == KeyCodes.KEY_ENTER)
                    || BrowserEvents.DBLCLICK.equals(nev.getType())) {
                selection.setSelected(event.getValue(), true);
                openDetailView();
            }
            if (BrowserEvents.CONTEXTMENU.equals(eventType)) {
                selection.setSelected(event.getValue(), true);
                if (selection.getSelectedObject() != null) {
                    contextMenu.setPopupPosition(event.getNativeEvent().getClientX(),
                            event.getNativeEvent().getClientY());
                    contextMenu.show();
                }
            }
        }
    });

    grid.addDomHandler(new DoubleClickHandler() {
        @Override
        public void onDoubleClick(DoubleClickEvent event) {
            event.preventDefault();
        }
    }, DoubleClickEvent.getType());
    grid.addDomHandler(new ContextMenuHandler() {
        @Override
        public void onContextMenu(ContextMenuEvent event) {
            event.preventDefault();
        }
    }, ContextMenuEvent.getType());
}