Search in sources :

Example 31 with SafeHtmlBuilder

use of com.google.gwt.safehtml.shared.SafeHtmlBuilder in project ovirt-engine by oVirt.

the class ClusterWarningsPopupView method buildWarnings.

private SafeHtml buildWarnings(List<ClusterEditWarnings.Warning> warnings) {
    SafeHtmlBuilder builder = new SafeHtmlBuilder();
    for (ClusterEditWarnings.Warning warning : warnings) {
        builder.append(warningTemplates.warningTitle(localize(warning.getMainMessage())));
        builder.append(warningTemplates.warningList(buildWarningDetails(warning.getDetailsByName())));
    }
    return builder.toSafeHtml();
}
Also used : SafeHtmlBuilder(com.google.gwt.safehtml.shared.SafeHtmlBuilder) ClusterEditWarnings(org.ovirt.engine.core.common.businessentities.ClusterEditWarnings)

Example 32 with SafeHtmlBuilder

use of com.google.gwt.safehtml.shared.SafeHtmlBuilder in project ovirt-engine by oVirt.

the class ManageGlusterSwiftPopupView method initEditors.

private void initEditors() {
    swiftStatusEditor = new EntityModelLabelEditor<>(new EnumRenderer<GlusterServiceStatus>());
    // $NON-NLS-1$
    startSwift = new EntityModelRadioButtonEditor("swift_action", Align.RIGHT);
    // $NON-NLS-1$
    stopSwift = new EntityModelRadioButtonEditor("swift_action", Align.RIGHT);
    // $NON-NLS-1$
    restartSwift = new EntityModelRadioButtonEditor("swift_action", Align.RIGHT);
    manageSwiftServerLevel = new EntityModelCheckBoxEditor(Align.RIGHT);
    hostServicesTable = new EntityModelCellTable<>(false, true);
    hostServicesTable.addColumn(new AbstractEntityModelTextColumn<GlusterServerService>() {

        @Override
        public String getText(GlusterServerService entity) {
            return entity.getHostName();
        }
    }, constants.hostGlusterSwift());
    hostServicesTable.addColumn(new AbstractEnumColumn<EntityModel, ServiceType>() {

        @Override
        protected ServiceType getRawValue(EntityModel object) {
            return ((GlusterSwiftServiceModel) object).getEntity().getServiceType();
        }
    }, constants.serviceNameGlusterSwift());
    hostServicesTable.addColumn(new AbstractEnumColumn<EntityModel, GlusterServiceStatus>() {

        @Override
        protected GlusterServiceStatus getRawValue(EntityModel object) {
            return ((GlusterSwiftServiceModel) object).getEntity().getStatus();
        }
    }, constants.serviceStatusGlusterSwift());
    Column<EntityModel, Boolean> startSwiftColumn = new Column<EntityModel, Boolean>(new RadioboxCell(false, true)) {

        @Override
        public Boolean getValue(EntityModel object) {
            GlusterSwiftServiceModel swiftServiceModel = (GlusterSwiftServiceModel) object;
            return swiftServiceModel.getStartSwift().getEntity();
        }

        @Override
        public void render(Context context, EntityModel object, SafeHtmlBuilder sb) {
            GlusterSwiftServiceModel swiftServiceModel = (GlusterSwiftServiceModel) object;
            if (swiftServiceModel.getStartSwift().getIsChangable()) {
                super.render(context, object, sb);
            }
        }
    };
    startSwiftColumn.setFieldUpdater((index, object, value) -> {
        GlusterSwiftServiceModel swiftModel = (GlusterSwiftServiceModel) object;
        swiftModel.getStartSwift().setEntity(value);
        if (value) {
            swiftModel.getStopSwift().setEntity(false);
            swiftModel.getRestartSwift().setEntity(false);
            hostServicesTable.redraw();
        }
    });
    hostServicesTable.addColumn(startSwiftColumn, constants.startGlusterSwift());
    Column<EntityModel, Boolean> stopSwiftColumn = new Column<EntityModel, Boolean>(new RadioboxCell(false, true)) {

        @Override
        public Boolean getValue(EntityModel object) {
            GlusterSwiftServiceModel swiftServiceModel = (GlusterSwiftServiceModel) object;
            return swiftServiceModel.getStopSwift().getEntity();
        }

        @Override
        public void render(Context context, EntityModel object, SafeHtmlBuilder sb) {
            GlusterSwiftServiceModel swiftServiceModel = (GlusterSwiftServiceModel) object;
            if (swiftServiceModel.getStopSwift().getIsChangable()) {
                super.render(context, object, sb);
            }
        }
    };
    stopSwiftColumn.setFieldUpdater((index, object, value) -> {
        GlusterSwiftServiceModel swiftModel = (GlusterSwiftServiceModel) object;
        if (swiftModel.getStopSwift().getIsChangable()) {
            swiftModel.getStopSwift().setEntity(value);
            if (value) {
                swiftModel.getStartSwift().setEntity(false);
                swiftModel.getRestartSwift().setEntity(false);
                hostServicesTable.redraw();
            }
        }
    });
    hostServicesTable.addColumn(stopSwiftColumn, constants.stopGlusterSwift());
    Column<EntityModel, Boolean> restartSwiftColumn = new Column<EntityModel, Boolean>(new RadioboxCell(false, true)) {

        @Override
        public Boolean getValue(EntityModel object) {
            GlusterSwiftServiceModel swiftServiceModel = (GlusterSwiftServiceModel) object;
            return swiftServiceModel.getRestartSwift().getEntity();
        }

        @Override
        public void render(Context context, EntityModel object, SafeHtmlBuilder sb) {
            GlusterSwiftServiceModel swiftServiceModel = (GlusterSwiftServiceModel) object;
            if (swiftServiceModel.getRestartSwift().getIsChangable()) {
                super.render(context, object, sb);
            }
        }
    };
    restartSwiftColumn.setFieldUpdater((index, object, value) -> {
        GlusterSwiftServiceModel swiftModel = (GlusterSwiftServiceModel) object;
        swiftModel.getRestartSwift().setEntity(value);
        if (value) {
            swiftModel.getStartSwift().setEntity(false);
            swiftModel.getStopSwift().setEntity(false);
            hostServicesTable.redraw();
        }
    });
    hostServicesTable.addColumn(restartSwiftColumn, constants.restartGlusterSwift());
}
Also used : Context(com.google.gwt.cell.client.Cell.Context) GlusterServerService(org.ovirt.engine.core.common.businessentities.gluster.GlusterServerService) EntityModel(org.ovirt.engine.ui.uicommonweb.models.EntityModel) RadioboxCell(org.ovirt.engine.ui.common.widget.table.cell.RadioboxCell) SafeHtmlBuilder(com.google.gwt.safehtml.shared.SafeHtmlBuilder) EnumRenderer(org.ovirt.engine.ui.common.widget.renderer.EnumRenderer) GlusterServiceStatus(org.ovirt.engine.core.common.businessentities.gluster.GlusterServiceStatus) AbstractEntityModelTextColumn(org.ovirt.engine.ui.common.widget.table.column.AbstractEntityModelTextColumn) AbstractEnumColumn(org.ovirt.engine.ui.common.widget.table.column.AbstractEnumColumn) Column(com.google.gwt.user.cellview.client.Column) ServiceType(org.ovirt.engine.core.common.businessentities.gluster.ServiceType) EntityModelCheckBoxEditor(org.ovirt.engine.ui.common.widget.editor.generic.EntityModelCheckBoxEditor) GlusterSwiftServiceModel(org.ovirt.engine.ui.uicommonweb.models.clusters.GlusterSwiftServiceModel) EntityModelRadioButtonEditor(org.ovirt.engine.ui.common.widget.editor.generic.EntityModelRadioButtonEditor)

Example 33 with SafeHtmlBuilder

use of com.google.gwt.safehtml.shared.SafeHtmlBuilder in project ovirt-engine by oVirt.

the class AlertPanel method updateBadge.

private void updateBadge() {
    badge.setVisible(count != 1);
    badgeText.setText(String.valueOf(count));
    if (badge.isVisible()) {
        SafeHtmlBuilder builder = new SafeHtmlBuilder();
        for (SafeHtml message : messagesList) {
            builder.append(message);
        }
        alertTooltip.setHtml(builder.toSafeHtml());
    }
}
Also used : SafeHtml(com.google.gwt.safehtml.shared.SafeHtml) SafeHtmlBuilder(com.google.gwt.safehtml.shared.SafeHtmlBuilder)

Example 34 with SafeHtmlBuilder

use of com.google.gwt.safehtml.shared.SafeHtmlBuilder in project ovirt-engine by oVirt.

the class RegisterVmPopupView method createEntityTable.

@Override
protected void createEntityTable(RegisterVmModel model) {
    entityTable.addColumn(new AbstractImageResourceColumn<RegisterVmData>() {

        @Override
        public ImageResource getValue(RegisterVmData registerVmData) {
            if (registerVmData.getError() != null) {
                return resources.errorImage();
            }
            if (registerVmData.getWarning() != null) {
                return resources.alertImage();
            }
            return null;
        }

        @Override
        public SafeHtml getTooltip(RegisterVmData registerVmData) {
            String problem;
            if (registerVmData.getError() != null) {
                problem = registerVmData.getError();
            } else {
                problem = registerVmData.getWarning();
            }
            return problem == null ? null : new SafeHtmlBuilder().appendEscapedLines(problem).toSafeHtml();
        }
    }, constants.empty(), // $NON-NLS-1$
    "20px");
    AbstractTextColumn<RegisterVmData> nameColumn = new AbstractTextColumn<RegisterVmData>() {

        @Override
        public String getValue(RegisterVmData registerVmData) {
            return registerVmData.getVm().getName();
        }
    };
    // $NON-NLS-1$
    entityTable.addColumn(nameColumn, constants.nameVm(), "150px");
    AbstractTextColumn<RegisterVmData> originColumn = new AbstractEnumColumn<RegisterVmData, OriginType>() {

        @Override
        protected OriginType getRawValue(RegisterVmData registerVmData) {
            return registerVmData.getVm().getOrigin();
        }
    };
    // $NON-NLS-1$
    entityTable.addColumn(originColumn, constants.originVm(), "100px");
    AbstractTextColumn<RegisterVmData> memoryColumn = new AbstractTextColumn<RegisterVmData>() {

        @Override
        public String getValue(RegisterVmData registerVmData) {
            int size = registerVmData.getVm().getVmMemSizeMb();
            return messages.megabytes(String.valueOf(size));
        }
    };
    // $NON-NLS-1$
    entityTable.addColumn(memoryColumn, constants.memoryVm(), "100px");
    AbstractTextColumn<RegisterVmData> cpuColumn = new AbstractTextColumn<RegisterVmData>() {

        @Override
        public String getValue(RegisterVmData registerVmData) {
            int numOfCpus = registerVmData.getVm().getNumOfCpus();
            return String.valueOf(numOfCpus);
        }
    };
    // $NON-NLS-1$
    entityTable.addColumn(cpuColumn, constants.cpusVm(), "50px");
    AbstractTextColumn<RegisterVmData> archColumn = new AbstractTextColumn<RegisterVmData>() {

        @Override
        public String getValue(RegisterVmData registerVmData) {
            ArchitectureType clusterArch = registerVmData.getVm().getClusterArch();
            return String.valueOf(clusterArch);
        }
    };
    // $NON-NLS-1$
    entityTable.addColumn(archColumn, constants.architectureVm(), "100px");
    AbstractTextColumn<RegisterVmData> diskColumn = new AbstractTextColumn<RegisterVmData>() {

        @Override
        public String getValue(RegisterVmData registerVmData) {
            int numOfDisks = registerVmData.getVm().getDiskMap().size();
            return String.valueOf(numOfDisks);
        }
    };
    // $NON-NLS-1$
    entityTable.addColumn(diskColumn, constants.disksVm(), "50px");
    // $NON-NLS-1$
    entityTable.addColumn(creatReassignMacsColumn(), new ReassignBadMacsHeader(), "150px");
    // $NON-NLS-1$
    entityTable.addColumn(createAllowPartialColumn(), constants.allowPartial(), "95px");
    // $NON-NLS-1$
    entityTable.addColumn(getClusterColumn(), constants.clusterVm(), "150px");
    if (model.isQuotaEnabled()) {
        // $NON-NLS-1$
        entityTable.addColumn(getClusterQuotaColumn(), constants.quotaVm(), "150px");
    }
}
Also used : ArchitectureType(org.ovirt.engine.core.common.businessentities.ArchitectureType) RegisterVmData(org.ovirt.engine.ui.uicommonweb.models.vms.register.RegisterVmData) SafeHtml(com.google.gwt.safehtml.shared.SafeHtml) SafeHtmlBuilder(com.google.gwt.safehtml.shared.SafeHtmlBuilder) AbstractEnumColumn(org.ovirt.engine.ui.common.widget.table.column.AbstractEnumColumn) ImageResource(com.google.gwt.resources.client.ImageResource) AbstractTextColumn(org.ovirt.engine.ui.common.widget.table.column.AbstractTextColumn)

Example 35 with SafeHtmlBuilder

use of com.google.gwt.safehtml.shared.SafeHtmlBuilder in project ovirt-engine by oVirt.

the class DisksBreadCrumbsView method getName.

@Override
public SafeHtml getName(Disk item) {
    SafeHtmlBuilder builder = new SafeHtmlBuilder();
    builder.append(super.getName(item));
    // $NON-NLS-1$
    builder.appendEscaped(" (");
    builder.appendEscaped(item.getId().toString());
    // $NON-NLS-1$
    builder.appendEscaped(")");
    return builder.toSafeHtml();
}
Also used : SafeHtmlBuilder(com.google.gwt.safehtml.shared.SafeHtmlBuilder)

Aggregations

SafeHtmlBuilder (com.google.gwt.safehtml.shared.SafeHtmlBuilder)142 SafeHtml (com.google.gwt.safehtml.shared.SafeHtml)26 Test (org.junit.Test)18 Column (com.google.gwt.user.cellview.client.Column)17 Cell (com.google.gwt.cell.client.Cell)14 BaseColumnFieldDiff (org.drools.workbench.models.guided.dtable.shared.model.BaseColumnFieldDiff)12 Context (com.google.gwt.cell.client.Cell.Context)7 MenuItem (com.google.gwt.user.client.ui.MenuItem)7 NativeEvent (com.google.gwt.dom.client.NativeEvent)6 Command (com.google.gwt.user.client.Command)6 ArrayList (java.util.ArrayList)6 ValueUpdater (com.google.gwt.cell.client.ValueUpdater)5 GWT (com.google.gwt.core.client.GWT)5 Element (com.google.gwt.dom.client.Element)5 AbstractCell (com.google.gwt.cell.client.AbstractCell)4 ClickableTextCell (com.google.gwt.cell.client.ClickableTextCell)4 TextCell (com.google.gwt.cell.client.TextCell)4 ScheduledCommand (com.google.gwt.core.client.Scheduler.ScheduledCommand)4 ImageResource (com.google.gwt.resources.client.ImageResource)4 Map (java.util.Map)4