Example usage for com.google.gwt.dom.client SpanElement setClassName

List of usage examples for com.google.gwt.dom.client SpanElement setClassName

Introduction

In this page you can find the example usage for com.google.gwt.dom.client SpanElement setClassName.

Prototype

@Override
    public void setClassName(String className) 

Source Link

Usage

From source file:com.smartgwt.mobile.client.widgets.tableview.TableView.java

License:Open Source License

private LIElement showGroup(List<Record> recordsToShow, UListElement ul) {
    final Document document = Document.get();
    final String primaryKeyField = getPrimaryKeyFieldName(), iconField = getIconField(),
            titleField = getTitleField(), infoField = getInfoField(), descriptionField = getDescriptionField();
    LIElement lastLI = null;/*from  w  w  w. j  a  v  a 2  s  . co  m*/
    for (final Record record : recordsToShow) {
        final Canvas recordComponent;
        if (getShowRecordComponents()) {
            recordComponent = createRecordComponent(record);
            if (recordComponent == null) {
                continue;
            } else
                recordComponents.add(recordComponent);
        } else
            recordComponent = null;

        final LIElement li = document.createLIElement();
        li.addClassName(ROW_CLASS_NAME);
        com.google.gwt.user.client.Element element = li.cast();
        final Object recordID = record.getAttributeAsObject(primaryKeyField);
        elementMap.put(recordID, element);
        final Integer recordIndex = record.getAttributeAsInt(recordIndexProperty);
        li.setAttribute(RECORD_INDEX_ATTRIBUTE_NAME, recordIndex.toString());

        if (lastLI == null) {
            li.addClassName(_CSS.firstTableViewRowClass());
        }

        if (showSelectedIcon && selectedIcon == null && getSelectionType() == SelectionStyle.MULTIPLE) {
            DivElement selectionDisclosure = document.createDivElement();
            selectionDisclosure.setClassName(_CSS.recordSelectionDisclosureClass());
            if (!_canSelectRecord(record)) {
                selectionDisclosure.addClassName(_CSS.nonselectableSelectionDisclosureClass());
            }
            SpanElement span = document.createSpanElement();
            selectionDisclosure.appendChild(span);
            li.appendChild(selectionDisclosure);
        }

        if (canRemoveRecords) {
            Boolean deletable = record.getAttributeAsBoolean(canRemoveProperty);
            if (deletable == null || (deletable != null && deletable.booleanValue())) {
                DivElement div = document.createDivElement();
                div.addClassName(_CSS.recordDeleteDisclosureClass());
                SpanElement span = document.createSpanElement();
                div.appendChild(span);
                li.appendChild(div);

                if (markedForRemoval != null && markedForRemoval.contains(record)) {
                    _markRecordRemoved(record, div, true);
                }
            }
        }

        if (canReorderRecords) {
            MoveIndicator draggableRow = new MoveIndicator(element);
            add(draggableRow, element);
        }

        if (!getShowRecordComponents()) {
            if (recordFormatter != null) {
                DivElement div = document.createDivElement();
                div.setClassName("content");
                div.setInnerHTML(recordFormatter.format(record));
                li.appendChild(div);
            } else {
                if (getShowNavigation(record)) {
                    final ImageResource navIcon = getNavigationIcon(record);
                    if (navigationMode == NavigationMode.NAVICON_ONLY) {
                        Boolean navigate = record.getAttributeAsBoolean(getRecordNavigationProperty());
                        if (navigate == null || (navigate != null && navigate.booleanValue())) {
                            final DetailsRow detailsRow = new DetailsRow(navIcon);
                            add(detailsRow, element);
                        }
                    } else if (navIcon != null) {
                        final Image image = new Image(navIcon);
                        image.getElement().addClassName(TableView._CSS.recordDetailDisclosureNavIconClass());
                        add(image, element);
                    } else {
                        li.addClassName(_CSS.tableViewRowHasNavigationDisclosureClass());
                    }
                }
                if (showIcons) {
                    Object icon = record.get(iconField);
                    if (!(icon instanceof ImageResource) && !(icon instanceof Image)) {
                        icon = formatCellValue(record, recordIndex.intValue(), iconField);
                    }
                    if (icon != null) {
                        SpanElement span = document.createSpanElement();
                        span.addClassName(RECORD_ICON_CLASS_NAME);
                        li.appendChild(span);
                        li.addClassName(_CSS.tableViewRowHasIconClass());
                        ImageElement img = document.createImageElement();
                        if (icon instanceof ImageResource) {
                            img.setSrc(((ImageResource) icon).getSafeUri().asString());
                        } else if (icon instanceof Image) {
                            img.setSrc(((Image) icon).getUrl());
                        } else {
                            img.setSrc(icon.toString());
                        }
                        span.appendChild(img);
                    }
                }
                if (showDetailCount) {
                    String count = formatCellValue(record, recordIndex.intValue(), detailCountProperty);
                    if (count != null) {
                        SpanElement span = document.createSpanElement();
                        span.addClassName(RECORD_COUNTER_CLASS_NAME);
                        span.setInnerHTML(count);
                        li.appendChild(span);
                    }
                }
                String title = formatCellValue(record, recordIndex.intValue(), titleField);
                if (title != null) {
                    SpanElement span = document.createSpanElement();
                    final String baseStyle = getBaseStyle(record, recordIndex.intValue(),
                            getFieldNum(titleField));
                    if (baseStyle != null)
                        span.setClassName(baseStyle);
                    span.addClassName(RECORD_TITLE_CLASS_NAME);
                    span.setInnerHTML(title);
                    li.appendChild(span);
                }
                if (recordLayout == RecordLayout.AUTOMATIC || recordLayout == RecordLayout.SUMMARY_FULL
                        || recordLayout == RecordLayout.SUMMARY_INFO) {
                    String info = formatCellValue(record, recordIndex.intValue(), infoField);
                    if (info != null) {
                        ul.addClassName(_CSS.stackedTableViewClass());
                        li.addClassName(_CSS.tableViewRowHasRecordInfoClass());
                        SpanElement span = document.createSpanElement();
                        final String baseStyle = getBaseStyle(record, recordIndex.intValue(),
                                getFieldNum(infoField));
                        if (baseStyle != null)
                            span.setClassName(baseStyle);
                        span.addClassName(RECORD_INFO_CLASS_NAME);
                        span.appendChild(document.createTextNode(info));
                        li.appendChild(span);
                    }
                }
                if (recordLayout == RecordLayout.AUTOMATIC || recordLayout == RecordLayout.TITLE_DESCRIPTION
                        || recordLayout == RecordLayout.SUMMARY_DATA
                        || recordLayout == RecordLayout.SUMMARY_FULL
                        || recordLayout == RecordLayout.SUMMARY_INFO) {
                    String description = formatCellValue(record, recordIndex.intValue(), descriptionField);
                    if (description != null) {
                        SpanElement span = document.createSpanElement();
                        final String baseStyle = getBaseStyle(record, recordIndex.intValue(),
                                getFieldNum(descriptionField));
                        if (baseStyle != null)
                            span.setClassName(baseStyle);
                        span.addClassName(RECORD_DESCRIPTION_CLASS_NAME);
                        span.appendChild(document.createTextNode(description));
                        li.appendChild(span);
                    }
                }
            }
        } else {
            assert recordComponent != null;
            recordComponent.getElement().addClassName(RECORD_COMPONENT_CLASS_NAME);
            add(recordComponent, element);
        }

        ul.appendChild(li);
        lastLI = li;
    }
    return lastLI;
}

From source file:org.dashbuilder.client.cms.widget.PerspectivesExplorerView.java

License:Apache License

@Override
public void addPerspective(String name, Command onClicked) {
    AnchorElement anchor = Document.get().createAnchorElement();
    anchor.getStyle().setCursor(Style.Cursor.POINTER);
    anchor.getStyle().setColor("black");
    anchor.getStyle().setProperty("fontSize", "larger");
    anchor.setInnerText(name);/*from   w w  w  . ja va  2 s . co  m*/

    Event.sinkEvents(anchor, Event.ONCLICK);
    Event.setEventListener(anchor, event -> {
        if (Event.ONCLICK == event.getTypeInt()) {
            onClicked.execute();
        }
    });

    SpanElement icon = Document.get().createSpanElement();
    icon.getStyle().setMarginRight(10, Style.Unit.PX);
    icon.setClassName("fa fa-file-text-o");
    icon.getStyle().setProperty("fontSize", "larger");

    DivElement gi = createItemDiv(new Element[] { icon, anchor });
    perspectivesDiv.appendChild((Node) gi);
}

From source file:org.dashbuilder.client.navigation.widget.NavTreeWidgetView.java

License:Apache License

protected void addItem(String iconClass, String id, String name, String description, Command onClicked) {
    Element nameEl = onClicked != null ? Document.get().createAnchorElement()
            : Document.get().createSpanElement();
    nameEl.setInnerText(name);//from   w w  w .ja v  a2 s  . c  o m
    nameEl.setClassName(
            onClicked != null ? "uf-navtree-widget-non-clicked" : "uf-navtree-widget-non-clickable");
    if (description != null && !description.equals(name)) {
        nameEl.setTitle(description);
    }

    SpanElement iconSpan = Document.get().createSpanElement();
    iconSpan.setClassName("uf-navtree-widget-icon " + iconClass);

    DivElement div = Document.get().createDivElement();
    div.appendChild(iconSpan);
    div.appendChild(nameEl);

    navWidget.appendChild((Node) div);
    itemMap.put(id, nameEl);

    if (onClicked != null) {
        Event.sinkEvents(nameEl, Event.ONCLICK);
        Event.setEventListener(nameEl, event -> {
            if (Event.ONCLICK == event.getTypeInt()) {
                onClicked.execute();
            }
        });
    }
}

From source file:org.eclipse.che.ide.ext.debugger.client.configuration.EditDebugConfigurationsViewImpl.java

License:Open Source License

private SpanElement renderSubElementButtons() {
    final SpanElement categorySubElement = Document.get().createSpanElement();
    categorySubElement.setClassName(editConfigurationsResources.getCss().buttonArea());

    final SpanElement removeConfigurationButtonElement = Document.get().createSpanElement();
    categorySubElement.appendChild(removeConfigurationButtonElement);
    removeConfigurationButtonElement//from  ww w.  j  ava2 s.  c o  m
            .appendChild(this.editConfigurationsResources.removeConfigurationButton().getSvg().getElement());
    Event.sinkEvents(removeConfigurationButtonElement, Event.ONCLICK);
    Event.setEventListener(removeConfigurationButtonElement, new EventListener() {
        @Override
        public void onBrowserEvent(Event event) {
            if (Event.ONCLICK == event.getTypeInt()) {
                event.stopPropagation();
                setSelectedConfiguration(selectedConfiguration);
                delegate.onRemoveClicked(selectedConfiguration);
            }
        }
    });

    final SpanElement duplicateConfigurationButton = Document.get().createSpanElement();
    categorySubElement.appendChild(duplicateConfigurationButton);
    duplicateConfigurationButton
            .appendChild(this.editConfigurationsResources.duplicateConfigurationButton().getSvg().getElement());
    Event.sinkEvents(duplicateConfigurationButton, Event.ONCLICK);
    Event.setEventListener(duplicateConfigurationButton, new EventListener() {
        @Override
        public void onBrowserEvent(Event event) {
            if (Event.ONCLICK == event.getTypeInt()) {
                event.stopPropagation();
                delegate.onDuplicateClicked();
            }
        }
    });

    return categorySubElement;
}

From source file:org.eclipse.che.ide.ext.debugger.client.configuration.EditDebugConfigurationsViewImpl.java

License:Open Source License

private SpanElement renderCategoryHeader(final String categoryTitle) {
    SpanElement categoryHeaderElement = Document.get().createSpanElement();
    categoryHeaderElement.setClassName(editConfigurationsResources.getCss().categoryHeader());

    SpanElement iconElement = Document.get().createSpanElement();
    categoryHeaderElement.appendChild(iconElement);

    SpanElement textElement = Document.get().createSpanElement();
    categoryHeaderElement.appendChild(textElement);
    DebugConfigurationType currentDebugConfigurationType = getTypeById(categoryTitle);
    textElement//from  www.ja  v a 2 s. co  m
            .setInnerText(currentDebugConfigurationType != null ? currentDebugConfigurationType.getDisplayName()
                    : categoryTitle);

    SpanElement buttonElement = Document.get().createSpanElement();
    buttonElement.appendChild(editConfigurationsResources.addConfigurationButton().getSvg().getElement());
    categoryHeaderElement.appendChild(buttonElement);

    Event.sinkEvents(buttonElement, Event.ONCLICK);
    Event.setEventListener(buttonElement, new EventListener() {
        @Override
        public void onBrowserEvent(Event event) {
            if (Event.ONCLICK == event.getTypeInt()) {
                event.stopPropagation();
                namePanel.setVisible(true);
                selectedType = getTypeById(categoryTitle);
                delegate.onAddClicked();
                resetFilter();
            }
        }
    });

    Icon icon = iconRegistry.getIconIfExist(categoryTitle + ".debug.configuration.type.icon");
    if (icon != null) {
        final SVGImage iconSVG = icon.getSVGImage();
        if (iconSVG != null) {
            iconElement.appendChild(iconSVG.getElement());
            return categoryHeaderElement;
        }
    }

    return categoryHeaderElement;
}

From source file:org.eclipse.che.ide.extension.machine.client.command.edit.EditCommandsViewImpl.java

License:Open Source License

private SpanElement renderSubElementButtons(CommandConfiguration commandConfiguration) {
    SpanElement categorySubElement = Document.get().createSpanElement();
    categorySubElement.setClassName(commandResources.getCss().buttonArea());

    SpanElement removeCommandButtonElement = Document.get().createSpanElement();
    categorySubElement.appendChild(removeCommandButtonElement);
    removeCommandButtonElement.appendChild(this.commandResources.removeCommandButton().getSvg().getElement());
    Event.sinkEvents(removeCommandButtonElement, Event.ONCLICK);
    Event.setEventListener(removeCommandButtonElement, new EventListener() {
        @Override/*from   w ww  .ja v  a  2 s.c  om*/
        public void onBrowserEvent(Event event) {
            if (Event.ONCLICK == event.getTypeInt()) {
                event.stopPropagation();
                setSelectedConfiguration(selectConfiguration);
                delegate.onRemoveClicked(selectConfiguration);
            }
        }
    });

    SpanElement duplicateCommandButton = Document.get().createSpanElement();
    categorySubElement.appendChild(duplicateCommandButton);
    duplicateCommandButton.appendChild(this.commandResources.duplicateCommandButton().getSvg().getElement());
    Event.sinkEvents(duplicateCommandButton, Event.ONCLICK);
    Event.setEventListener(duplicateCommandButton, new EventListener() {
        @Override
        public void onBrowserEvent(Event event) {
            if (Event.ONCLICK == event.getTypeInt()) {
                event.stopPropagation();
                delegate.onDuplicateClicked();
            }
        }
    });

    return categorySubElement;
}

From source file:org.eclipse.che.ide.extension.machine.client.command.edit.EditCommandsViewImpl.java

License:Open Source License

private SpanElement renderCategoryHeader(final String commandId) {
    SpanElement categoryHeaderElement = Document.get().createSpanElement();
    categoryHeaderElement.setClassName(commandResources.getCss().categoryHeader());

    SpanElement iconElement = Document.get().createSpanElement();
    categoryHeaderElement.appendChild(iconElement);

    SpanElement textElement = Document.get().createSpanElement();
    categoryHeaderElement.appendChild(textElement);
    CommandType currentCommandType = getTypeById(commandId);
    textElement.setInnerText(currentCommandType != null ? currentCommandType.getDisplayName() : commandId);

    SpanElement buttonElement = Document.get().createSpanElement();
    buttonElement.appendChild(commandResources.addCommandButton().getSvg().getElement());
    categoryHeaderElement.appendChild(buttonElement);

    Event.sinkEvents(buttonElement, Event.ONCLICK);
    Event.setEventListener(buttonElement, new EventListener() {
        @Override//from w  w  w  . jav a  2 s  .  c  o m
        public void onBrowserEvent(Event event) {
            if (Event.ONCLICK == event.getTypeInt()) {
                event.stopPropagation();
                savePanel.setVisible(true);
                previewUrlPanel.setVisible(true);
                selectType = getTypeById(commandId);
                delegate.onAddClicked();
                resetFilter();
            }
        }
    });

    Icon icon = iconRegistry.getIconIfExist(commandId + ".commands.category.icon");
    if (icon != null) {
        final SVGImage iconSVG = icon.getSVGImage();
        if (iconSVG != null) {
            iconElement.appendChild(iconSVG.getElement());
            return categoryHeaderElement;
        }
    }

    return categoryHeaderElement;
}

From source file:org.eclipse.che.ide.extension.machine.client.targets.TargetsViewImpl.java

License:Open Source License

private SpanElement createMachineLabel(String machineCategory) {
    final SpanElement machineLabel = Document.get().createSpanElement();

    Icon icon = iconRegistry.getIconIfExist(machineCategory + ".machine.icon");
    if (icon != null) {
        machineLabel.appendChild(icon.getSVGImage().getElement());
        return machineLabel;
    }/*from  w w w.  j av  a  2 s  .  com*/

    if (MACHINE_LABELS_BY_CATEGORY_MAP.containsKey(machineCategory)) {
        machineLabel.setInnerText(MACHINE_LABELS_BY_CATEGORY_MAP.get(machineCategory));
        machineLabel.setClassName(this.machineResources.getCss().dockerMachineLabel());
        return machineLabel;
    }

    machineLabel.setInnerText(machineCategory.substring(0, 3));
    machineLabel.setClassName(this.machineResources.getCss().differentMachineLabel());
    return machineLabel;

}

From source file:org.eclipse.che.ide.extension.machine.client.targets.TargetsViewImpl.java

License:Open Source License

private SpanElement renderCategoryHeader(final Category<Target> category) {
    SpanElement categoryHeaderElement = Document.get().createSpanElement();
    categoryHeaderElement.setClassName(commandResources.getCss().categoryHeader());
    categoryHeaderElement.appendChild(createMachineLabel(category.getTitle()));

    SpanElement textElement = Document.get().createSpanElement();
    categoryHeaderElement.appendChild(textElement);
    textElement.setInnerText(category.getTitle());

    if (machineLocale.targetsViewCategorySsh().equalsIgnoreCase(category.getTitle())) {
        // Add button to create a target
        SpanElement buttonElement = Document.get().createSpanElement();
        buttonElement.appendChild(commandResources.addCommandButton().getSvg().getElement());
        categoryHeaderElement.appendChild(buttonElement);

        Event.sinkEvents(buttonElement, Event.ONCLICK);
        Event.setEventListener(buttonElement, new EventListener() {
            @Override//  w  w  w  . j  a  va  2s  . com
            public void onBrowserEvent(Event event) {
                event.stopPropagation();
                event.preventDefault();
                delegate.onAddTarget(category.getTitle());
            }
        });
    } else {
        // Add empty span for properly aligning items
        categoryHeaderElement.appendChild(Document.get().createSpanElement());
    }

    return categoryHeaderElement;
}

From source file:org.eclipse.che.ide.projecttype.wizard.categoriespage.CategoriesPageViewImpl.java

License:Open Source License

private Element renderCategoryHeader(String category) {
    SpanElement categoryElement = Document.get().createSpanElement();
    categoryElement.setClassName(resources.defaultCategoriesListCss().headerText());

    SpanElement iconElement = Document.get().createSpanElement();
    categoryElement.appendChild(iconElement);

    SpanElement textElement = Document.get().createSpanElement();
    categoryElement.appendChild(textElement);
    textElement.setInnerText(category);/*w  w  w  .ja v  a  2 s .c om*/

    Icon icon = iconRegistry.getIconIfExist(category + ".samples.category.icon");
    if (icon != null) {
        final SVGImage iconSVG = icon.getSVGImage();
        if (iconSVG != null) {
            iconElement.appendChild(iconSVG.getElement());
            return categoryElement;
        }
    }

    return categoryElement;
}