Example usage for com.google.gwt.user.cellview.client CellWidget addStyleName

List of usage examples for com.google.gwt.user.cellview.client CellWidget addStyleName

Introduction

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

Prototype

public void addStyleName(String style) 

Source Link

Document

Adds a secondary or dependent style name to this object.

Usage

From source file:n3phele.client.widgets.FileNodeBrowserCore.java

License:Open Source License

public FileNodeBrowserCore(BrowserPresenter presenter, boolean isInput, int rowLength, int width,
        MenuItem heading) {// w  ww  .j  a v a 2 s  .com
    this.setWidth(width + "px");
    this.ROWLENGTH = rowLength;
    this.isInput = isInput;
    this.isOptional = !isInput;
    this.presenter = presenter;
    header = new HorizontalPanel();
    header.setWidth("100%");
    if (heading != null) {
        Cell<MenuItem> cell = new IconTextCell<MenuItem>(32, 32);
        CellWidget<MenuItem> headerIcon = new CellWidget<MenuItem>(cell, heading);
        headerIcon.addStyleName(N3phele.n3pheleResource.css().workspacePanelHeader());
        header.add(headerIcon);
    }

    if (!isInput) {
        newFolderPanel = new DisclosurePanel("New Folder");
        newFolderView = NewFolderView.newInstance();
        newFolderPanel.add(newFolderView);
        newFolderPanel.addOpenHandler(new OpenHandler<DisclosurePanel>() {

            @Override
            public void onOpen(OpenEvent<DisclosurePanel> event) {
                FileNodeBrowserCore.this.newFolderView.clearName();

            }
        });
        newFolderPanel.addCloseHandler(new CloseHandler<DisclosurePanel>() {

            @Override
            public void onClose(CloseEvent<DisclosurePanel> event) {
                String name = FileNodeBrowserCore.this.newFolderView.getFolderName();
                if (name != null) {
                    FileNodeBrowserCore.this.newFolder(name);
                }

            }

        });
        newFolderView.setDisclosurePanel(newFolderPanel);
        header.add(newFolderPanel);
    }
    this.add(header);
    actions = new FlexTable();
    this.add(actions);
    actions.setWidth("100%");

    crumbs = new FlowPanel();
    crumbs.setWidth("100%");
    actions.setWidget(0, 0, crumbs);

    ScrollPanel gridPanel = new ScrollPanel();
    gridPanel.setHeight("200px");
    grid = new CellTable<List<FileNode>>();
    grid.setWidth("100%");
    grid.setTableLayoutFixed(true);
    for (int i = 0; i < ROWLENGTH; i++) {
        Column<List<FileNode>, FileNode> c = new Column<List<FileNode>, FileNode>(
                new FileNodeIconTextCell(N3phele.n3pheleResource.folderIcon(), new FileNodeTextCell(), i)) {

            @Override
            public FileNode getValue(List<FileNode> object) {
                int index = ((FileNodeIconTextCell) this.getCell()).getIndex();
                if (index < object.size()) {
                    return object.get(index);
                } else {
                    return null;
                }
            }
        };
        c.setFieldUpdater(new FieldUpdater<List<FileNode>, FileNode>() {

            @Override
            public void update(int index, List<FileNode> object, FileNode value) {
                if (value != null) {
                    if (!value.getMime().endsWith("Folder") && !value.getMime().endsWith("Placeholder")) {
                        FileNodeBrowserCore.this.filename.setText(value.getName());
                        FileNodeBrowserCore.this.openButtonValidate(!isZip);
                    } else {
                        FileNodeBrowserCore.this.filename.setText(null);
                        if (FileNodeBrowserCore.this.presenter != null) {
                            FileNodeBrowserCore.this.openButtonValidate(isZip);
                            FileNodeBrowserCore.this.presenter.selectFolder(value);
                        }
                    }
                }
                GWT.log("got " + index + " " + value.toFormattedString());

            }
        });
        grid.addColumn(c);
        grid.setColumnWidth(c, 100.0 / ROWLENGTH, Unit.PCT);
    }
    grid.setKeyboardSelectionPolicy(KeyboardSelectionPolicy.DISABLED);
    gridPanel.add(grid);
    actions.setWidget(1, 0, gridPanel);

    repoList = new ListBox(false);
    repoList.addChangeHandler(new ChangeHandler() {

        @Override
        public void onChange(ChangeEvent event) {
            FileNodeBrowserCore.this.filename.setText(null);
            FileNodeBrowserCore.this.openButtonValidate(false);
            if (FileNodeBrowserCore.this.presenter != null) {
                int selected = FileNodeBrowserCore.this.repoList.getSelectedIndex()
                        + (FileNodeBrowserCore.this.isOptional ? -1 : 0);
                if (selected >= 0 && selected < FileNodeBrowserCore.this.repos.size()) {
                    FileNodeBrowserCore.this.presenter
                            .selectFolder(FileNodeBrowserCore.this.repos.get(selected));
                } else {
                    FileNodeBrowserCore.this.presenter.selectFolder((Repository) null);
                }
            }

        }
    });
    actions.setWidget(2, 0, repoList);

    filename = new TextBox();
    filename.addKeyUpHandler(new KeyUpHandler() {

        @Override
        public void onKeyUp(KeyUpEvent event) {
            FileNodeBrowserCore.this.enableOpenButton(false);
            String filename = FileNodeBrowserCore.this.filename.getText();
            String repoURI = FileNodeBrowserCore.this.repoList
                    .getValue(FileNodeBrowserCore.this.repoList.getSelectedIndex());
            GWT.log("save " + filename + " on " + repoURI);
            if (repoURI.length() == 0)
                repoURI = null;
            if (FileNodeBrowserCore.this.presenter != null) {
                validateAndEnableOpenButton(filename, repoURI);
            }
        }
    });
    actions.setWidget(2, 1, filename);
    filename.setWidth((width - 50) + "px");

    this.openButton = getOpenButton(this.isInput);
    if (this.openButton != null)
        actions.setWidget(3, 2, this.openButton);

    this.cancelButton = getCancelButton();
    if (this.cancelButton != null)
        actions.setWidget(3, 3, cancelButton);
    errorIndicator = new Image(N3phele.n3pheleResource.inputErrorIcon());
    setErrorText();

    actions.setWidget(3, 1, errorIndicator);
    actions.getCellFormatter().setHorizontalAlignment(3, 1, HasHorizontalAlignment.ALIGN_RIGHT);
    actions.getFlexCellFormatter().setWidth(3, 3, "80px");
    actions.getFlexCellFormatter().setWidth(3, 2, "80px");
    actions.getFlexCellFormatter().setWidth(3, 1, (width - 100) + "px");

    actions.getFlexCellFormatter().setColSpan(0, 0, 4);
    actions.getFlexCellFormatter().setColSpan(1, 0, 4);
    actions.getFlexCellFormatter().setColSpan(2, 1, 3);
}

From source file:org.datacleaner.monitor.dashboard.widgets.CustomizeChartOptionsPanel.java

License:Open Source License

private CellWidget<Date> createDatePickerWidget(Date date) {
    CellWidget<Date> cellWidget = new CellWidget<Date>(createDatePickerCell(), date);
    cellWidget.addStyleName("DateSelectionWidget");
    return cellWidget;
}