Search in sources :

Example 26 with EntityModel

use of org.ovirt.engine.ui.uicommonweb.models.EntityModel in project ovirt-engine by oVirt.

the class DiskModel method diskToModel.

public static DiskModel diskToModel(Disk disk) {
    DiskModel diskModel = new DiskModel();
    diskModel.getAlias().setEntity(disk.getDiskAlias());
    if (disk.getDiskStorageType() == DiskStorageType.IMAGE) {
        DiskImage diskImage = (DiskImage) disk;
        EntityModel<Integer> sizeEntity = new EntityModel<>();
        sizeEntity.setEntity((int) diskImage.getSizeInGigabytes());
        diskModel.setSize(sizeEntity);
        ListModel<VolumeType> volumeList = new ListModel<>();
        volumeList.setItems(diskImage.getVolumeType() == VolumeType.Preallocated ? new ArrayList<>(Arrays.asList(new VolumeType[] { VolumeType.Preallocated })) : AsyncDataProvider.getInstance().getVolumeTypeList());
        volumeList.setSelectedItem(diskImage.getVolumeType());
        diskModel.setVolumeType(volumeList);
    }
    diskModel.setDisk(disk);
    return diskModel;
}
Also used : VolumeType(org.ovirt.engine.core.common.businessentities.storage.VolumeType) ListModel(org.ovirt.engine.ui.uicommonweb.models.ListModel) EntityModel(org.ovirt.engine.ui.uicommonweb.models.EntityModel) ArrayList(java.util.ArrayList) DiskImage(org.ovirt.engine.core.common.businessentities.storage.DiskImage)

Example 27 with EntityModel

use of org.ovirt.engine.ui.uicommonweb.models.EntityModel in project ovirt-engine by oVirt.

the class HostPopupView method edit.

@Override
public void edit(final HostModel object) {
    driver.edit(object);
    setTabIndexes(0);
    object.getFetchResult().getEntityChangedEvent().addListener((ev, sender, args) -> {
        String fetchResultText = object.getFetchResult().getEntity();
        if (ConstantsManager.getInstance().getConstants().errorLoadingFingerprint().equals(fetchResultText)) {
            fetchResult.addStyleName(style.fetchResultErrorLabel());
        } else {
            fetchResult.removeStyleName(style.fetchResultErrorLabel());
        }
        fetchResult.setText(fetchResultText);
    });
    object.getPkSection().getPropertyChangedEvent().addListener((ev, sender, args) -> {
        if ("IsAvailable".equals(args.propertyName)) {
            // $NON-NLS-1$
            setPkPasswordSectionVisiblity(false);
        }
    });
    object.getProviders().getSelectedItemChangedEvent().addListener((ev, sender, args) -> object.updateHosts());
    object.getExternalHostProviderEnabled().getEntityChangedEvent().addListener((ev, sender, args) -> {
        boolean showForemanProviders = object.getExternalHostProviderEnabled().getEntity();
        boolean doProvisioning = object.externalProvisionEnabled();
        boolean isProvisioned = showForemanProviders && doProvisioning;
        providersEditor.setVisible(showForemanProviders);
        // showing or hiding radio buttons
        provisionedHostSection.setVisible(isProvisioned);
        discoveredHostSection.setVisible(isProvisioned);
        // disabling ip and name textbox when using provisioned hosts
        hostAddressEditor.setEnabled(!isProvisioned);
        hostAddressLabel.setStyleName(OvirtCss.LABEL_DISABLED, isProvisioned);
        if (isProvisioned) {
            object.updateHosts();
            object.getIsDiscoveredHosts().setEntity(true);
        } else {
            if (doProvisioning) {
                object.cleanHostParametersFields();
            }
            hideProviderWidgets(object);
            object.getIsDiscoveredHosts().setEntity(null);
        }
    });
    object.getIsDiscoveredHosts().getEntityChangedEvent().addListener((ev, sender, args) -> {
        if (object.getIsDiscoveredHosts().getEntity() != null) {
            if (object.getIsDiscoveredHosts().getEntity()) {
                rbDiscoveredHost.asRadioButton().setValue(true);
                showDiscoveredHostsWidgets(true);
            } else if (!object.getIsDiscoveredHosts().getEntity()) {
                rbProvisionedHost.asRadioButton().setValue(true);
                showProvisionedHostsWidgets(true);
            }
        }
    });
    nameEditor.asValueBox().addKeyDownHandler(event -> Scheduler.get().scheduleDeferred(() -> {
        if (object.getExternalHostProviderEnabled().getEntity() && Boolean.TRUE.equals(object.getIsDiscoveredHosts().getEntity())) {
            ExternalHostGroup dhg = (ExternalHostGroup) object.getExternalHostGroups().getSelectedItem();
            if (dhg != null) {
                String base = nameEditor.asEditor().getSubEditor().getValue();
                if (base == null) {
                    base = constants.empty();
                }
                String generatedHostName = // $NON-NLS-1$
                base + "." + (dhg.getDomainName() != null ? dhg.getDomainName() : constants.empty());
                object.getHost().setEntity(generatedHostName);
            }
        }
    }));
    if (object.isPasswordSectionViewable()) {
        rbPassword.setValue(true);
        rbPassword.setFocus(true);
        fetchSshFingerprint.hideLabel();
        object.setAuthenticationMethod(AuthenticationMethod.Password);
        displayPassPkWindow(true);
        rbPassword.addClickHandler(event -> {
            object.setAuthenticationMethod(AuthenticationMethod.Password);
            displayPassPkWindow(true);
        });
        rbPublicKey.addClickHandler(event -> {
            object.setAuthenticationMethod(AuthenticationMethod.PublicKey);
            displayPassPkWindow(false);
        });
    } else {
        passwordSection.getElement().getStyle().setDisplay(Display.NONE);
        rbPublicKey.getElement().getStyle().setDisplay(Display.NONE);
        rbPublicKeyLabel.setStyleName(OvirtCss.LABEL_DISABLED);
        object.setAuthenticationMethod(AuthenticationMethod.PublicKey);
    }
    updateHostsButton.setResource(resources.searchButtonImage());
    // Create SPM related controls.
    IEventListener<EventArgs> spmListener = (ev, sender, args) -> createSpmControls(object);
    object.getSpmPriority().getItemsChangedEvent().addListener(spmListener);
    object.getSpmPriority().getSelectedItemChangedEvent().addListener(spmListener);
    createSpmControls(object);
    initExternalHostProviderWidgets(object.showExternalProviderPanel());
    // TODO: remove setIsChangeable when configured ssh username is enabled
    userNameEditor.setEnabled(false);
    networkProviderTab.setVisible(object.showNetworkProviderTab());
    networkProviderWidget.edit(object.getNetworkProviderModel());
    this.fenceAgentsEditor.edit(object.getFenceAgentListModel());
    this.proxySourceEditor.edit(object.getPmProxyPreferencesList());
    addTextAndLinkAlert(fetchPanel, constants.fetchingHostFingerprint(), object.getSSHFingerPrint());
    providerSearchFilterLabel.setText(constants.hostPopupProviderSearchFilter());
    nameEditor.setFocus(true);
    hostedEngineTab.setVisible(object.getIsHeSystem() && object.getIsNew());
    object.getHostedEngineWarning().getPropertyChangedEvent().addListener((ev, sender, args) -> {
        EntityModel entity = (EntityModel) sender;
        if ("IsAvailable".equals(args.propertyName)) {
            // $NON-NLS-1$
            hostedEngineWarningLabel.setVisible(entity.getIsAvailable());
        }
    });
    affinityLabelSelectionWidget.init(object.getLabelList());
}
Also used : Anchor(com.google.gwt.user.client.ui.Anchor) AssetProvider(org.ovirt.engine.ui.webadmin.gin.AssetProvider) Image(com.google.gwt.user.client.ui.Image) OvirtCss(org.ovirt.engine.ui.common.css.OvirtCss) Inject(com.google.inject.Inject) Container(org.gwtbootstrap3.client.ui.Container) Provider(org.ovirt.engine.core.common.businessentities.Provider) CommonApplicationMessages(org.ovirt.engine.ui.common.CommonApplicationMessages) ApplicationMode(org.ovirt.engine.core.common.mode.ApplicationMode) Column(org.gwtbootstrap3.client.ui.Column) EntityModel(org.ovirt.engine.ui.uicommonweb.models.EntityModel) StringEntityModelPasswordBoxEditor(org.ovirt.engine.ui.common.widget.editor.generic.StringEntityModelPasswordBoxEditor) UiBinder(com.google.gwt.uibinder.client.UiBinder) AuthenticationMethod(org.ovirt.engine.core.common.action.VdsOperationActionParameters.AuthenticationMethod) ExternalEntityBase(org.ovirt.engine.core.common.businessentities.ExternalEntityBase) StringEntityModelTextAreaLabelEditor(org.ovirt.engine.ui.common.widget.editor.generic.StringEntityModelTextAreaLabelEditor) HostNetworkProviderWidget(org.ovirt.engine.ui.webadmin.widget.provider.HostNetworkProviderWidget) FenceAgentsEditor(org.ovirt.engine.ui.webadmin.widget.host.FenceAgentsEditor) Label(com.google.gwt.user.client.ui.Label) RadioButton(com.google.gwt.user.client.ui.RadioButton) AbstractTabbedModelBoundPopupView(org.ovirt.engine.ui.common.view.popup.AbstractTabbedModelBoundPopupView) ConstantsManager(org.ovirt.engine.ui.uicompat.ConstantsManager) HostPopupPresenterWidget(org.ovirt.engine.ui.webadmin.section.main.presenter.popup.host.HostPopupPresenterWidget) EventArgs(org.ovirt.engine.ui.uicompat.EventArgs) InfoIcon(org.ovirt.engine.ui.common.widget.dialog.InfoIcon) OpenstackNetworkProviderProperties(org.ovirt.engine.core.common.businessentities.OpenstackNetworkProviderProperties) Display(com.google.gwt.dom.client.Style.Display) SimplePanel(com.google.gwt.user.client.ui.SimplePanel) EventBus(com.google.gwt.event.shared.EventBus) UICommand(org.ovirt.engine.ui.uicommonweb.UICommand) UiCommonEditorDriver(org.ovirt.engine.ui.common.editor.UiCommonEditorDriver) GroupedListModelListBox(org.ovirt.engine.ui.common.widget.editor.GroupedListModelListBox) WithElementId(org.ovirt.engine.ui.common.idhandler.WithElementId) ApplicationModeHelper(org.ovirt.engine.ui.uicommonweb.models.ApplicationModeHelper) HasClickHandlers(com.google.gwt.event.dom.client.HasClickHandlers) FlowPanel(com.google.gwt.user.client.ui.FlowPanel) Cluster(org.ovirt.engine.core.common.businessentities.Cluster) GroupedListModelListBoxEditor(org.ovirt.engine.ui.common.widget.editor.GroupedListModelListBoxEditor) CssResource(com.google.gwt.resources.client.CssResource) UiField(com.google.gwt.uibinder.client.UiField) Element(com.google.gwt.dom.client.Element) HostedEngineDeployConfiguration(org.ovirt.engine.core.common.businessentities.HostedEngineDeployConfiguration) AffinityLabelSelectionWithListWidget(org.ovirt.engine.ui.common.widget.AffinityLabelSelectionWithListWidget) DialogTabPanel(org.ovirt.engine.ui.common.widget.dialog.tab.DialogTabPanel) EnumRenderer(org.ovirt.engine.ui.common.widget.renderer.EnumRenderer) HostModel(org.ovirt.engine.ui.uicommonweb.models.hosts.HostModel) ExternalHostGroup(org.ovirt.engine.core.common.businessentities.ExternalHostGroup) StringEntityModelTextBoxEditor(org.ovirt.engine.ui.common.widget.editor.generic.StringEntityModelTextBoxEditor) IEventListener(org.ovirt.engine.ui.uicompat.IEventListener) StringEntityModelTextBoxOnlyEditor(org.ovirt.engine.ui.common.widget.editor.generic.StringEntityModelTextBoxOnlyEditor) Align(org.ovirt.engine.ui.common.widget.Align) GWT(com.google.gwt.core.client.GWT) TextDecoration(com.google.gwt.dom.client.Style.TextDecoration) Button(org.gwtbootstrap3.client.ui.Button) AdvancedParametersExpander(org.ovirt.engine.ui.common.widget.dialog.AdvancedParametersExpander) ListModelListBoxEditor(org.ovirt.engine.ui.common.widget.editor.ListModelListBoxEditor) EnableableFormLabel(org.ovirt.engine.ui.common.widget.label.EnableableFormLabel) ApplicationConstants(org.ovirt.engine.ui.webadmin.ApplicationConstants) ListModelTypeAheadListBoxEditor(org.ovirt.engine.ui.common.widget.editor.ListModelTypeAheadListBoxEditor) DialogTab(org.ovirt.engine.ui.common.widget.dialog.tab.DialogTab) ColumnSize(org.gwtbootstrap3.client.ui.constants.ColumnSize) EntityModelCheckBoxEditor(org.ovirt.engine.ui.common.widget.editor.generic.EntityModelCheckBoxEditor) SafeHtmlUtils(com.google.gwt.safehtml.shared.SafeHtmlUtils) ApplicationResources(org.ovirt.engine.ui.webadmin.ApplicationResources) ElementIdHandler(org.ovirt.engine.ui.common.idhandler.ElementIdHandler) EntityModelRadioButtonEditor(org.ovirt.engine.ui.common.widget.editor.generic.EntityModelRadioButtonEditor) NameRenderer(org.ovirt.engine.ui.common.widget.renderer.NameRenderer) IntegerEntityModelTextBoxEditor(org.ovirt.engine.ui.common.widget.editor.generic.IntegerEntityModelTextBoxEditor) ApplicationTemplates(org.ovirt.engine.ui.webadmin.ApplicationTemplates) Scheduler(com.google.gwt.core.client.Scheduler) SimpleDialogPanel(org.ovirt.engine.ui.common.widget.dialog.SimpleDialogPanel) Row(org.gwtbootstrap3.client.ui.Row) TabName(org.ovirt.engine.ui.uicommonweb.models.TabName) HostProxySourceEditor(org.ovirt.engine.ui.webadmin.widget.host.HostProxySourceEditor) Comparator(java.util.Comparator) VDS(org.ovirt.engine.core.common.businessentities.VDS) EntityModel(org.ovirt.engine.ui.uicommonweb.models.EntityModel) ExternalHostGroup(org.ovirt.engine.core.common.businessentities.ExternalHostGroup) EventArgs(org.ovirt.engine.ui.uicompat.EventArgs)

Example 28 with EntityModel

use of org.ovirt.engine.ui.uicommonweb.models.EntityModel in project ovirt-engine by oVirt.

the class MultipleHostsPopupView method initTableColumns.

private void initTableColumns() {
    Column<EntityModel, String> nameColumn = new Column<EntityModel, String>(new TextInputCell()) {

        @Override
        public String getValue(EntityModel object) {
            return ((HostDetailModel) object.getEntity()).getName();
        }
    };
    // $NON-NLS-1$
    hostsTable.addColumn(nameColumn, constants.nameHost(), "50px");
    nameColumn.setFieldUpdater((index, object, value) -> ((HostDetailModel) object.getEntity()).setName(value));
    hostsTable.addColumn(new AbstractEntityModelTextColumn<HostDetailModel>() {

        @Override
        public String getText(HostDetailModel hostModel) {
            return hostModel.getAddress();
        }
    }, constants.ipHost(), // $NON-NLS-1$
    "100px");
    Column<EntityModel, String> passwordColumn = new Column<EntityModel, String>(new PasswordTextInputCell()) {

        @Override
        public String getValue(EntityModel object) {
            return ((HostDetailModel) object.getEntity()).getPassword();
        }
    };
    // $NON-NLS-1$
    hostsTable.addColumn(passwordColumn, constants.hostPopupPasswordLabel(), "100px");
    passwordColumn.setFieldUpdater((index, object, value) -> ((HostDetailModel) object.getEntity()).setPassword(value));
    hostsTable.addColumn(new AbstractEntityModelTextColumn<HostDetailModel>() {

        @Override
        public String getText(HostDetailModel hostModel) {
            return hostModel.getFingerprint();
        }
    }, constants.hostsPopupFingerprint(), // $NON-NLS-1$
    "300px");
}
Also used : PasswordTextInputCell(org.ovirt.engine.ui.common.widget.table.cell.PasswordTextInputCell) HostDetailModel(org.ovirt.engine.ui.uicommonweb.models.hosts.HostDetailModel) AbstractEntityModelTextColumn(org.ovirt.engine.ui.common.widget.table.column.AbstractEntityModelTextColumn) Column(com.google.gwt.user.cellview.client.Column) EntityModel(org.ovirt.engine.ui.uicommonweb.models.EntityModel) TextInputCell(com.google.gwt.cell.client.TextInputCell) PasswordTextInputCell(org.ovirt.engine.ui.common.widget.table.cell.PasswordTextInputCell)

Example 29 with EntityModel

use of org.ovirt.engine.ui.uicommonweb.models.EntityModel in project ovirt-engine by oVirt.

the class DisksAllocationPopupView method edit.

@Override
public void edit(DisksAllocationModel object) {
    driver.edit(object);
    disksAllocationView.edit(object);
    disksAllocationModel = object;
    object.getDynamicWarning().getPropertyChangedEvent().addListener((ev, sender, args) -> {
        EntityModel ownerModel = (EntityModel) sender;
        String propName = ((PropertyChangedEventArgs) args).propertyName;
        if ("IsAvailable".equals(propName)) {
            // $NON-NLS-1$
            warningMessage.setVisible(ownerModel.getIsAvailable());
        }
    });
}
Also used : PropertyChangedEventArgs(org.ovirt.engine.ui.uicompat.PropertyChangedEventArgs) EntityModel(org.ovirt.engine.ui.uicommonweb.models.EntityModel)

Example 30 with EntityModel

use of org.ovirt.engine.ui.uicommonweb.models.EntityModel in project ovirt-engine by oVirt.

the class HostPopupView method createSpmControls.

private void createSpmControls(final HostModel object) {
    Row labelRow = (Row) spmContainer.getWidget(0);
    spmContainer.clear();
    spmContainer.add(labelRow);
    Iterable<?> items = object.getSpmPriority().getItems();
    if (items == null) {
        return;
    }
    // Recreate SPM related controls.
    for (Object item : items) {
        @SuppressWarnings("unchecked") final EntityModel<Integer> model = (EntityModel<Integer>) item;
        // $//$NON-NLS-1$
        RadioButton rb = new RadioButton("spm");
        rb.setText(model.getTitle());
        Element labelElement = (Element) rb.getElement().getChild(1);
        labelElement.addClassName(style.patternFlyRadio());
        rb.setValue(object.getSpmPriority().getSelectedItem() == model);
        rb.addValueChangeHandler(e -> object.getSpmPriority().setSelectedItem(model));
        Row row = new Row();
        Column column = new Column(ColumnSize.SM_12, rb);
        row.add(column);
        spmContainer.add(row);
    }
}
Also used : Column(org.gwtbootstrap3.client.ui.Column) Element(com.google.gwt.dom.client.Element) EntityModel(org.ovirt.engine.ui.uicommonweb.models.EntityModel) Row(org.gwtbootstrap3.client.ui.Row) RadioButton(com.google.gwt.user.client.ui.RadioButton)

Aggregations

EntityModel (org.ovirt.engine.ui.uicommonweb.models.EntityModel)105 ArrayList (java.util.ArrayList)56 UICommand (org.ovirt.engine.ui.uicommonweb.UICommand)27 List (java.util.List)26 ActionParametersBase (org.ovirt.engine.core.common.action.ActionParametersBase)23 AsyncDataProvider (org.ovirt.engine.ui.uicommonweb.dataprovider.AsyncDataProvider)22 ListModel (org.ovirt.engine.ui.uicommonweb.models.ListModel)22 ConstantsManager (org.ovirt.engine.ui.uicompat.ConstantsManager)22 ConfirmationModel (org.ovirt.engine.ui.uicommonweb.models.ConfirmationModel)20 HelpTag (org.ovirt.engine.ui.uicommonweb.help.HelpTag)19 ActionType (org.ovirt.engine.core.common.action.ActionType)18 Frontend (org.ovirt.engine.ui.frontend.Frontend)18 QueryReturnValue (org.ovirt.engine.core.common.queries.QueryReturnValue)17 Guid (org.ovirt.engine.core.compat.Guid)17 PropertyChangedEventArgs (org.ovirt.engine.ui.uicompat.PropertyChangedEventArgs)17 VDS (org.ovirt.engine.core.common.businessentities.VDS)16 QueryType (org.ovirt.engine.core.common.queries.QueryType)16 NoSelectionModel (com.google.gwt.view.client.NoSelectionModel)13 Cluster (org.ovirt.engine.core.common.businessentities.Cluster)13 StoragePool (org.ovirt.engine.core.common.businessentities.StoragePool)13