Search in sources :

Example 1 with AbstractRenderer

use of com.google.gwt.text.shared.AbstractRenderer in project openremote by openremote.

the class DatapointBrowser method createChart.

protected void createChart() {
    addLabel(environment.getMessages().historicalData());
    Canvas canvas = Canvas.createIfSupported();
    if (canvas == null) {
        add(new Label(environment.getMessages().canvasNotSupported()));
        return;
    }
    canvas.getCanvasElement().setWidth(width);
    canvas.getCanvasElement().setHeight(height);
    FlowPanel canvasContainer = new FlowPanel();
    canvasContainer.setWidth(width + "px");
    canvasContainer.setHeight(height + "px");
    canvasContainer.getElement().getStyle().setProperty("margin", "0 auto");
    canvasContainer.add(canvas);
    add(canvasContainer);
    Form controlForm = new Form();
    controlForm.getElement().getStyle().setWidth(width, PX);
    controlForm.getElement().getStyle().setMarginTop(0.4, EM);
    controlForm.getElement().getStyle().setProperty("margin", "0 auto");
    add(controlForm);
    FormGroup controlFormGroup = new FormGroup();
    controlForm.add(controlFormGroup);
    FormLabel controlFormLabel = new FormLabel(environment.getMessages().showChartAggregatedFor());
    controlFormLabel.addStyleName("end-justified");
    controlFormGroup.setFormLabel(controlFormLabel);
    FormField controlFormField = new FormField();
    controlFormGroup.setFormField(controlFormField);
    intervalListBox = new FormValueListBox<>(new AbstractRenderer<DatapointInterval>() {

        @Override
        public String render(DatapointInterval interval) {
            return environment.getMessages().datapointInterval(interval.name());
        }
    });
    intervalListBox.addValueChangeHandler(event -> refresh(timestamp));
    intervalListBox.setValue(interval);
    intervalListBox.setAcceptableValues(Arrays.asList(DatapointInterval.values()));
    intervalListBox.setEnabled(true);
    controlFormField.add(intervalListBox);
    timeOutput = new FormOutputText();
    timeOutput.addStyleName("flex");
    timeOutput.getElement().getStyle().setFontSize(0.8, EM);
    controlFormField.add(timeOutput);
    FormGroupActions controlFormActions = new FormGroupActions();
    controlFormGroup.setFormGroupActions(controlFormActions);
    FormButton previousButton = new FormButton();
    previousButton.setIcon("arrow-circle-left");
    previousButton.setText(environment.getMessages().previous());
    previousButton.addClickHandler(event -> refresh(calculateTimestamp(true)));
    controlFormActions.add(previousButton);
    nextButton = new FormButton();
    nextButton.setIcon("arrow-circle-right");
    nextButton.setText(environment.getMessages().next());
    nextButton.addClickHandler(event -> refresh(calculateTimestamp(false)));
    controlFormActions.add(nextButton);
    chart = ChartUtil.createLineChart(canvas.getContext2d());
    // TODO: Ugly, sometimes the chart is not ready (chart == undefined but !null in Java...) so we wait a bit
    Browser.getWindow().setTimeout(() -> refresh(timestamp), 50);
}
Also used : DatapointInterval(org.openremote.model.datapoint.DatapointInterval) Canvas(com.google.gwt.canvas.client.Canvas) Label(com.google.gwt.user.client.ui.Label) AbstractRenderer(com.google.gwt.text.shared.AbstractRenderer) FlowPanel(com.google.gwt.user.client.ui.FlowPanel)

Example 2 with AbstractRenderer

use of com.google.gwt.text.shared.AbstractRenderer in project ovirt-engine by oVirt.

the class VolumeGeoRepSessionDetailsPopUpView method intiEditors.

private void intiEditors(final ApplicationConstants constants) {
    checkPointStatus = new EntityModelLabelEditor<>(new AbstractRenderer<GlusterGeoRepSessionDetails>() {

        @Override
        public String render(GlusterGeoRepSessionDetails object) {
            String checkPointStatusValue = object.getCheckPointStatus();
            return checkPointStatusValue == null || checkPointStatusValue.isEmpty() ? constants.notAvailableLabel() : checkPointStatusValue;
        }
    });
    crawlStatus = new EntityModelLabelEditor<>(new AbstractRenderer<GlusterGeoRepSessionDetails>() {

        @Override
        public String render(GlusterGeoRepSessionDetails object) {
            return object.getCrawlStatus().toString();
        }
    });
    dataOpsPending = new EntityModelLabelEditor<>(new AbstractRenderer<GlusterGeoRepSessionDetails>() {

        @Override
        public String render(GlusterGeoRepSessionDetails object) {
            return object.getDataOpsPending().toString();
        }
    });
    metaOpsPending = new EntityModelLabelEditor<>(new AbstractRenderer<GlusterGeoRepSessionDetails>() {

        @Override
        public String render(GlusterGeoRepSessionDetails object) {
            return object.getMetaOpsPending().toString();
        }
    });
    entryOpsPending = new EntityModelLabelEditor<>(new AbstractRenderer<GlusterGeoRepSessionDetails>() {

        @Override
        public String render(GlusterGeoRepSessionDetails object) {
            return object.getEntryOpsPending().toString();
        }
    });
    failures = new EntityModelLabelEditor<>(new AbstractRenderer<GlusterGeoRepSessionDetails>() {

        @Override
        public String render(GlusterGeoRepSessionDetails object) {
            return object.getFailures().toString();
        }
    });
    checkPointTime = new EntityModelLabelEditor<>(new AbstractRenderer<GlusterGeoRepSessionDetails>() {

        @Override
        public String render(GlusterGeoRepSessionDetails object) {
            return new FullDateTimeRenderer().render(object.getCheckPointTime());
        }
    });
    checkPointCompletedAt = new EntityModelLabelEditor<>(new AbstractRenderer<GlusterGeoRepSessionDetails>() {

        @Override
        public String render(GlusterGeoRepSessionDetails object) {
            return new FullDateTimeRenderer().render(object.getCheckPointCompletedAt());
        }
    });
    geoRepSessionSummaryTable = new EntityModelCellTable<>(false, true);
    geoRepSessionSummaryTable.addColumn(new AbstractEntityModelTextColumn<GlusterGeoRepSessionDetails>() {

        @Override
        public String getText(GlusterGeoRepSessionDetails object) {
            return object.getMasterBrickHostName() == null ? constants.notAvailableLabel() : object.getMasterBrickHostName();
        }
    }, constants.geoRepSessionHostName());
    geoRepSessionSummaryTable.addColumn(new AbstractEntityModelTextColumn<GlusterGeoRepSessionDetails>() {

        @Override
        protected String getText(GlusterGeoRepSessionDetails entity) {
            return (entity == null || entity.getStatus() == null) ? constants.notAvailableLabel() : entity.getStatus().toString();
        }
    }, constants.geoRepSessionStatus());
    geoRepSessionSummaryTable.addColumn(new AbstractFullDateTimeColumn<EntityModel<GlusterGeoRepSessionDetails>>() {

        @Override
        protected Date getRawValue(EntityModel<GlusterGeoRepSessionDetails> object) {
            GlusterGeoRepSessionDetails sessionDetail = object.getEntity();
            return (sessionDetail == null || sessionDetail.getLastSyncedAt() == null) ? new Date() : sessionDetail.getLastSyncedAt();
        }
    }, constants.geoRepLastSyncedAt());
}
Also used : FullDateTimeRenderer(org.ovirt.engine.ui.common.widget.renderer.FullDateTimeRenderer) AbstractRenderer(com.google.gwt.text.shared.AbstractRenderer) EntityModel(org.ovirt.engine.ui.uicommonweb.models.EntityModel) GlusterGeoRepSessionDetails(org.ovirt.engine.core.common.businessentities.gluster.GlusterGeoRepSessionDetails) Date(java.util.Date)

Example 3 with AbstractRenderer

use of com.google.gwt.text.shared.AbstractRenderer in project ovirt-engine by oVirt.

the class StoragePopupView method initListBoxEditors.

@SuppressWarnings({ "unchecked", "rawtypes" })
void initListBoxEditors() {
    datacenterListEditor = new ListModelListBoxEditor<>(new AbstractRenderer<StoragePool>() {

        @Override
        public String render(StoragePool storage) {
            // $NON-NLS-1$
            String formattedString = "";
            if (storage != null) {
                // Get formatted storage type and format using Enum renders
                // $NON-NLS-1$
                String storageType = storage.isLocal() ? constants.storageTypeLocal() : "";
                String storageFormatType = // $NON-NLS-1$
                storage.getStoragePoolFormatType() == null ? // $NON-NLS-1$
                "" : new EnumRenderer<StorageFormatType>().render(storage.getStoragePoolFormatType());
                // Add storage type and format if available
                if (!storageType.isEmpty() || !storageFormatType.isEmpty()) {
                    // $NON-NLS-1$
                    formattedString = " (";
                    if (storage.isLocal()) {
                        formattedString += storageType;
                    } else {
                        formattedString += storageFormatType;
                    }
                    // $NON-NLS-1$
                    formattedString += ")";
                }
                formattedString = storage.getName() + formattedString;
            }
            return formattedString;
        }
    });
    formatListEditor = new ListModelListBoxEditor<>(new EnumRenderer());
    hostListEditor = new ListModelListBoxEditor<>(new NameRenderer<VDS>());
    domainFunctionListEditor = new ListModelListBoxEditor<>(new EnumRenderer<StorageDomainType>());
    storageTypeListEditor = new ListModelListBoxEditor<>(new EnumRenderer<StorageType>());
    activateDomainEditor = new EntityModelCheckBoxEditor(Align.RIGHT);
    wipeAfterDeleteEditor = new EntityModelCheckBoxEditor(Align.RIGHT);
    backup = new EntityModelCheckBoxEditor(Align.RIGHT);
    discardAfterDeleteEditor = new EntityModelCheckBoxEditor(Align.RIGHT);
}
Also used : EnumRenderer(org.ovirt.engine.ui.common.widget.renderer.EnumRenderer) StoragePool(org.ovirt.engine.core.common.businessentities.StoragePool) AbstractRenderer(com.google.gwt.text.shared.AbstractRenderer) NameRenderer(org.ovirt.engine.ui.common.widget.renderer.NameRenderer) EntityModelCheckBoxEditor(org.ovirt.engine.ui.common.widget.editor.generic.EntityModelCheckBoxEditor)

Example 4 with AbstractRenderer

use of com.google.gwt.text.shared.AbstractRenderer in project ovirt-engine by oVirt.

the class GlusterVolumeSnapshotCreatePopupView method initEditors.

private void initEditors() {
    snapshotNameEditor = new StringEntityModelTextBoxEditor();
    snapshotNameEditor.hideLabel();
    EnableableFormLabel label = new EnableableFormLabel();
    label.setText(constants.volumeSnapshotNamePrefixLabel());
    snapshotNameEditorWithInfo = new EntityModelWidgetWithInfo(label, snapshotNameEditor);
    snapshotNameEditorWithInfo.setExplanation(templates.italicText(constants.snapshotNameInfo()));
    startAtEditor = new EntityModelDateTimeBoxEditor();
    startAtEditor.getContentWidget().setDateTimeFormat(GwtBootstrapDateTimePicker.DEFAULT_DATE_TIME_FORMAT);
    startAtEditor.getContentWidget().showDateAndTime();
    daysOfWeekEditor = new ListModelCheckBoxGroupEditor<>(new AbstractRenderer<DayOfWeek>() {

        @Override
        public String render(DayOfWeek object) {
            return object.toString().substring(0, 3);
        }
    });
    endDate = new EntityModelDateTimeBoxEditor();
    endDate.getContentWidget().setDateTimeFormat(GwtBootstrapDateTimePicker.DEFAULT_DATE_TIME_FORMAT);
    endDate.getContentWidget().showDateAndTime();
    executionTimeEditor = new EntityModelDateTimeBoxEditor();
    // $NON-NLS-1$
    executionTimeEditor.getContentWidget().setDateTimeFormat("hh:ii");
    executionTimeEditor.getContentWidget().showTimeOnly();
    recurrenceEditor = new ListModelListBoxEditor<>(new AbstractRenderer<GlusterVolumeSnapshotScheduleRecurrence>() {

        @Override
        public String render(GlusterVolumeSnapshotScheduleRecurrence object) {
            return EnumTranslator.getInstance().translate(object);
        }
    });
}
Also used : DayOfWeek(org.ovirt.engine.core.compat.DayOfWeek) EntityModelWidgetWithInfo(org.ovirt.engine.ui.common.widget.EntityModelWidgetWithInfo) GlusterVolumeSnapshotScheduleRecurrence(org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeSnapshotScheduleRecurrence) AbstractRenderer(com.google.gwt.text.shared.AbstractRenderer) EnableableFormLabel(org.ovirt.engine.ui.common.widget.label.EnableableFormLabel) EntityModelDateTimeBoxEditor(org.ovirt.engine.ui.common.widget.editor.EntityModelDateTimeBoxEditor) StringEntityModelTextBoxEditor(org.ovirt.engine.ui.common.widget.editor.generic.StringEntityModelTextBoxEditor)

Example 5 with AbstractRenderer

use of com.google.gwt.text.shared.AbstractRenderer in project ovirt-engine by oVirt.

the class ClusterPopupView method initCheckBoxEditors.

private void initCheckBoxEditors() {
    enableOvirtServiceEditor = new EntityModelCheckBoxEditor(Align.RIGHT);
    enableGlusterServiceEditor = new EntityModelCheckBoxEditor(Align.RIGHT);
    importGlusterConfigurationEditor = new EntityModelCheckBoxEditor(Align.RIGHT);
    countThreadsAsCoresEditor = new EntityModelCheckBoxEditor(Align.RIGHT);
    enableTrustedServiceEditor = new EntityModelCheckBoxEditor(Align.RIGHT);
    enableHaReservationEditor = new EntityModelCheckBoxEditor(Align.RIGHT);
    enableOptionalReasonEditor = new EntityModelCheckBoxEditor(Align.RIGHT);
    enableHostMaintenanceReasonEditor = new EntityModelCheckBoxEditor(Align.RIGHT);
    enableKsm = new EntityModelCheckBoxEditor(Align.RIGHT);
    // $NON-NLS-1$
    enableKsm.getContentWidgetContainer().setWidth("350px");
    enableBallooning = new EntityModelCheckBoxEditor(Align.RIGHT);
    // $NON-NLS-1$
    enableBallooning.getContentWidgetContainer().setWidth("350px");
    rngHwrngSourceRequired = new EntityModelCheckBoxEditor(Align.RIGHT);
    fencingEnabledCheckBox = new EntityModelCheckBoxEditor(Align.RIGHT);
    skipFencingIfSDActiveCheckBox = new EntityModelCheckBoxEditor(Align.RIGHT);
    skipFencingIfConnectivityBrokenCheckBox = new EntityModelCheckBoxEditor(Align.RIGHT);
    skipFencingIfGlusterBricksUpCheckBox = new EntityModelCheckBoxEditor(Align.RIGHT);
    skipFencingIfGlusterQuorumNotMetCheckBox = new EntityModelCheckBoxEditor(Align.RIGHT);
    spiceProxyOverrideEnabled = new EntityModelCheckBoxEditor(Align.RIGHT);
    additionalFeaturesEditor = new ListModelCheckBoxGroup<>(new AbstractRenderer<AdditionalFeature>() {

        @Override
        public String render(AdditionalFeature feature) {
            return feature.getDescription();
        }
    });
}
Also used : AbstractRenderer(com.google.gwt.text.shared.AbstractRenderer) AdditionalFeature(org.ovirt.engine.core.common.businessentities.AdditionalFeature) EntityModelCheckBoxEditor(org.ovirt.engine.ui.common.widget.editor.generic.EntityModelCheckBoxEditor)

Aggregations

AbstractRenderer (com.google.gwt.text.shared.AbstractRenderer)7 EntityModelCheckBoxEditor (org.ovirt.engine.ui.common.widget.editor.generic.EntityModelCheckBoxEditor)3 EnumRenderer (org.ovirt.engine.ui.common.widget.renderer.EnumRenderer)3 NameRenderer (org.ovirt.engine.ui.common.widget.renderer.NameRenderer)3 EntityModelWidgetWithInfo (org.ovirt.engine.ui.common.widget.EntityModelWidgetWithInfo)2 EnableableFormLabel (org.ovirt.engine.ui.common.widget.label.EnableableFormLabel)2 BooleanRendererWithNullText (org.ovirt.engine.ui.common.widget.renderer.BooleanRendererWithNullText)2 NullSafeRenderer (org.ovirt.engine.ui.common.widget.renderer.NullSafeRenderer)2 EntityModel (org.ovirt.engine.ui.uicommonweb.models.EntityModel)2 Canvas (com.google.gwt.canvas.client.Canvas)1 NumberFormatRenderer (com.google.gwt.text.client.NumberFormatRenderer)1 FlowPanel (com.google.gwt.user.client.ui.FlowPanel)1 Label (com.google.gwt.user.client.ui.Label)1 Date (java.util.Date)1 DatapointInterval (org.openremote.model.datapoint.DatapointInterval)1 AdditionalFeature (org.ovirt.engine.core.common.businessentities.AdditionalFeature)1 ArchitectureType (org.ovirt.engine.core.common.businessentities.ArchitectureType)1 BootSequence (org.ovirt.engine.core.common.businessentities.BootSequence)1 InstanceType (org.ovirt.engine.core.common.businessentities.InstanceType)1 OpenstackNetworkProviderProperties (org.ovirt.engine.core.common.businessentities.OpenstackNetworkProviderProperties)1