Search in sources :

Example 1 with AbstractCheckboxColumn

use of org.ovirt.engine.ui.common.widget.table.column.AbstractCheckboxColumn in project ovirt-engine by oVirt.

the class ImportTemplatePopupView method initMainTable.

@Override
protected void initMainTable() {
    this.table = new ListModelObjectCellTable<>();
    AbstractCheckboxColumn<Object> cloneTemplateColumn = new AbstractCheckboxColumn<Object>((index, model, value) -> {
        ((ImportTemplateData) model).getClone().setEntity(value);
        table.asEditor().edit(importModel);
    }) {

        @Override
        public Boolean getValue(Object model) {
            return ((ImportTemplateData) model).getClone().getEntity();
        }

        @Override
        protected boolean canEdit(Object model) {
            return ((ImportTemplateData) model).getClone().getIsChangable();
        }
    };
    // $NON-NLS-1$
    table.addColumn(cloneTemplateColumn, constants.cloneVM(), "50px");
    AbstractTextColumn<Object> nameColumn = new AbstractTextColumn<Object>() {

        @Override
        public String getValue(Object object) {
            return ((ImportTemplateData) object).getTemplate().getName();
        }
    };
    // $NON-NLS-1$
    table.addColumn(nameColumn, constants.nameTemplate(), "150px");
    AbstractTextColumn<Object> versionNameColumn = new AbstractTextColumn<Object>() {

        @Override
        public String getValue(Object object) {
            VmTemplate template = ((ImportTemplateData) object).getTemplate();
            if (template.isBaseTemplate()) {
                // $NON-NLS-1$
                return "";
            }
            return // $NON-NLS-1$
            StringFormat.format(// $NON-NLS-1$
            "%s (%s)", // $NON-NLS-1$
            template.getTemplateVersionName() != null ? template.getTemplateVersionName() : "", template.getTemplateVersionNumber());
        }
    };
    // $NON-NLS-1$
    table.addColumn(versionNameColumn, constants.versionTemplate(), "150px");
    AbstractTextColumn<Object> originColumn = new AbstractEnumColumn<Object, OriginType>() {

        @Override
        protected OriginType getRawValue(Object object) {
            return ((ImportTemplateData) object).getTemplate().getOrigin();
        }
    };
    // $NON-NLS-1$
    table.addColumn(originColumn, constants.originTemplate(), "100px");
    AbstractTextColumn<Object> memoryColumn = new AbstractTextColumn<Object>() {

        @Override
        public String getValue(Object object) {
            return messages.megabytes(String.valueOf(((ImportTemplateData) object).getTemplate().getMemSizeMb()));
        }
    };
    // $NON-NLS-1$
    table.addColumn(memoryColumn, constants.memoryTemplate(), "100px");
    AbstractTextColumn<Object> cpuColumn = new AbstractTextColumn<Object>() {

        @Override
        public String getValue(Object object) {
            return String.valueOf(((ImportTemplateData) object).getTemplate().getNumOfCpus());
        }
    };
    // $NON-NLS-1$
    table.addColumn(cpuColumn, constants.cpusTemplate(), "50px");
    AbstractTextColumn<Object> archColumn = new AbstractTextColumn<Object>() {

        @Override
        public String getValue(Object object) {
            return String.valueOf(((ImportTemplateData) object).getTemplate().getClusterArch());
        }
    };
    // $NON-NLS-1$
    table.addColumn(archColumn, constants.architectureTemplate(), "50px");
    AbstractTextColumn<Object> diskColumn = new AbstractTextColumn<Object>() {

        @Override
        public String getValue(Object object) {
            return String.valueOf(((ImportTemplateData) object).getTemplate().getDiskList().size());
        }
    };
    // $NON-NLS-1$
    table.addColumn(diskColumn, constants.disksTemplate(), "50px");
    isObjectInSystemColumn = new AbstractImageResourceColumn<Object>() {

        @Override
        public ImageResource getValue(Object object) {
            return ((ImportTemplateData) object).isExistsInSystem() ? resources.logNormalImage() : null;
        }
    };
    // $NON-NLS-1$
    table.addColumn(isObjectInSystemColumn, constants.templateInSetup(), "60px");
    ScrollPanel sp = new ScrollPanel();
    sp.add(table);
    splitLayoutPanel.add(sp);
    table.getElement().getStyle().setPosition(Position.RELATIVE);
}
Also used : AbstractCheckboxColumn(org.ovirt.engine.ui.common.widget.table.column.AbstractCheckboxColumn) AbstractEnumColumn(org.ovirt.engine.ui.common.widget.table.column.AbstractEnumColumn) ImportTemplateData(org.ovirt.engine.ui.uicommonweb.models.vms.ImportTemplateData) ImageResource(com.google.gwt.resources.client.ImageResource) VmTemplate(org.ovirt.engine.core.common.businessentities.VmTemplate) AbstractTextColumn(org.ovirt.engine.ui.common.widget.table.column.AbstractTextColumn) ScrollPanel(com.google.gwt.user.client.ui.ScrollPanel)

Example 2 with AbstractCheckboxColumn

use of org.ovirt.engine.ui.common.widget.table.column.AbstractCheckboxColumn in project ovirt-engine by oVirt.

the class VmDiskAttachPopupWidget method getReadOnlyCheckBoxColumn.

private AbstractCheckboxColumn<EntityModel> getReadOnlyCheckBoxColumn() {
    AbstractCheckboxColumn<EntityModel> readOnlyCheckboxColumn = new AbstractCheckboxColumn<EntityModel>((idx, object, value) -> {
        DiskModel diskModel = (DiskModel) object.getEntity();
        diskModel.setReadOnly(value);
    }) {

        @Override
        protected boolean canEdit(EntityModel object) {
            DiskModel diskModel = (DiskModel) object.getEntity();
            Disk disk = diskModel.getDisk();
            boolean isScsiPassthrough = disk.isScsiPassthrough();
            boolean ideLimitation = diskModel.getDiskInterface().getSelectedItem() == DiskInterface.IDE;
            return !isScsiPassthrough && !ideLimitation;
        }

        @Override
        public Boolean getValue(EntityModel object) {
            DiskModel diskModel = (DiskModel) object.getEntity();
            return diskModel.isReadOnly();
        }
    };
    return readOnlyCheckboxColumn;
}
Also used : AttachDiskModel(org.ovirt.engine.ui.uicommonweb.models.vms.AttachDiskModel) DiskModel(org.ovirt.engine.ui.uicommonweb.models.vms.DiskModel) EntityModel(org.ovirt.engine.ui.uicommonweb.models.EntityModel) AbstractCheckboxColumn(org.ovirt.engine.ui.common.widget.table.column.AbstractCheckboxColumn) CinderDisk(org.ovirt.engine.core.common.businessentities.storage.CinderDisk) LunDisk(org.ovirt.engine.core.common.businessentities.storage.LunDisk) Disk(org.ovirt.engine.core.common.businessentities.storage.Disk)

Example 3 with AbstractCheckboxColumn

use of org.ovirt.engine.ui.common.widget.table.column.AbstractCheckboxColumn in project ovirt-engine by oVirt.

the class VmDiskAttachPopupWidget method getBootCheckBoxColumn.

private AbstractCheckboxColumn<EntityModel> getBootCheckBoxColumn() {
    AbstractCheckboxColumn<EntityModel> bootCheckboxColumn = new AbstractCheckboxColumn<EntityModel>((idx, object, value) -> {
        DiskModel diskModel = (DiskModel) object.getEntity();
        diskModel.getIsBootable().setEntity(value);
    }) {

        @Override
        public SafeHtml getTooltip(EntityModel object) {
            EntityModel<Boolean> bootModel = ((DiskModel) object.getEntity()).getIsBootable();
            return bootModel.getChangeProhibitionReason() == null ? null : SafeHtmlUtils.fromString(bootModel.getChangeProhibitionReason());
        }

        @Override
        protected boolean canEdit(EntityModel object) {
            EntityModel<Boolean> bootModel = ((DiskModel) object.getEntity()).getIsBootable();
            return bootModel.getIsChangable() || bootModel.getEntity();
        }

        @Override
        public Boolean getValue(EntityModel object) {
            DiskModel diskModel = (DiskModel) object.getEntity();
            return diskModel.getIsBootable().getEntity();
        }
    };
    return bootCheckboxColumn;
}
Also used : AttachDiskModel(org.ovirt.engine.ui.uicommonweb.models.vms.AttachDiskModel) DiskModel(org.ovirt.engine.ui.uicommonweb.models.vms.DiskModel) EntityModel(org.ovirt.engine.ui.uicommonweb.models.EntityModel) AbstractCheckboxColumn(org.ovirt.engine.ui.common.widget.table.column.AbstractCheckboxColumn)

Example 4 with AbstractCheckboxColumn

use of org.ovirt.engine.ui.common.widget.table.column.AbstractCheckboxColumn in project ovirt-engine by oVirt.

the class ImportVmFromExternalProviderPopupView method initMainTable.

protected void initMainTable() {
    this.table = new ListModelObjectCellTable<>();
    AbstractCheckboxColumn<ImportVmData> cloneVMColumn = new AbstractCheckboxColumn<ImportVmData>((index, model, value) -> {
        model.getClone().setEntity(value);
        table.asEditor().edit(importModel);
    }) {

        @Override
        public Boolean getValue(ImportVmData model) {
            return model.getClone().getEntity();
        }

        @Override
        protected boolean canEdit(ImportVmData model) {
            return model.getClone().getIsChangable();
        }

        @Override
        protected String getDisabledMessage(ImportVmData model) {
            return model.getClone().getChangeProhibitionReason();
        }
    };
    // $NON-NLS-1$
    table.addColumn(cloneVMColumn, constants.cloneVM(), "50px");
    AbstractTextColumn<ImportVmData> nameColumn = new AbstractTextColumn<ImportVmData>() {

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

        @Override
        protected OriginType getRawValue(ImportVmData object) {
            return object.getVm().getOrigin();
        }
    };
    // $NON-NLS-1$
    table.addColumn(originColumn, constants.originVm(), "100px");
    table.addColumn(new AbstractSafeHtmlColumn<ImportVmData>() {

        @Override
        public SafeHtml getValue(ImportVmData object) {
            return VmTypeColumn.getRenderedValue(object.getVm());
        }
    }, constants.empty(), // $NON-NLS-1$
    "30px");
    AbstractTextColumn<ImportVmData> memoryColumn = new AbstractTextColumn<ImportVmData>() {

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

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

        @Override
        public String getValue(ImportVmData object) {
            return String.valueOf(object.getVm().getClusterArch());
        }
    };
    // $NON-NLS-1$
    table.addColumn(archColumn, constants.architectureVm(), "50px");
    AbstractTextColumn<ImportVmData> diskColumn = new AbstractTextColumn<ImportVmData>() {

        @Override
        public String getValue(ImportVmData object) {
            return String.valueOf(object.getVm().getDiskMap().size());
        }
    };
    // $NON-NLS-1$
    table.addColumn(diskColumn, constants.disksVm(), "50px");
    ScrollPanel sp = new ScrollPanel();
    sp.add(table);
    splitLayoutPanel.add(sp);
    table.getElement().getStyle().setPosition(Position.RELATIVE);
}
Also used : AbstractEnumColumn(org.ovirt.engine.ui.common.widget.table.column.AbstractEnumColumn) SafeHtml(com.google.gwt.safehtml.shared.SafeHtml) AbstractTextColumn(org.ovirt.engine.ui.common.widget.table.column.AbstractTextColumn) ImportVmData(org.ovirt.engine.ui.uicommonweb.models.vms.ImportVmData) AbstractCheckboxColumn(org.ovirt.engine.ui.common.widget.table.column.AbstractCheckboxColumn) ScrollPanel(com.google.gwt.user.client.ui.ScrollPanel)

Example 5 with AbstractCheckboxColumn

use of org.ovirt.engine.ui.common.widget.table.column.AbstractCheckboxColumn in project ovirt-engine by oVirt.

the class SubTabNetworkClusterView method initTable.

private void initTable() {
    getTable().enableColumnResizing();
    AbstractTextColumn<PairQueryable<Cluster, NetworkCluster>> nameColumn = new AbstractLinkColumn<PairQueryable<Cluster, NetworkCluster>>(new FieldUpdater<PairQueryable<Cluster, NetworkCluster>, String>() {

        @Override
        public void update(int index, PairQueryable<Cluster, NetworkCluster> cluster, String value) {
            Map<String, String> parameters = new HashMap<>();
            parameters.put(FragmentParams.NAME.getName(), cluster.getFirst().getName());
            getPlaceTransitionHandler().handlePlaceTransition(WebAdminApplicationPlaces.clusterGeneralSubTabPlace, parameters);
        }
    }) {

        @Override
        public String getValue(PairQueryable<Cluster, NetworkCluster> object) {
            return object.getFirst().getName();
        }
    };
    nameColumn.makeSortable();
    // $NON-NLS-1$
    getTable().addColumn(nameColumn, constants.nameCluster(), "400px");
    AbstractTextColumn<PairQueryable<Cluster, NetworkCluster>> versionColumn = new AbstractTextColumn<PairQueryable<Cluster, NetworkCluster>>() {

        @Override
        public String getValue(PairQueryable<Cluster, NetworkCluster> object) {
            return object.getFirst().getCompatibilityVersion().getValue();
        }
    };
    versionColumn.makeSortable();
    // $NON-NLS-1$
    getTable().addColumn(versionColumn, constants.comptVersCluster(), "130px");
    AbstractCheckboxColumn<PairQueryable<Cluster, NetworkCluster>> attachedColumn = new AbstractCheckboxColumn<PairQueryable<Cluster, NetworkCluster>>(true) {

        @Override
        public Boolean getValue(PairQueryable<Cluster, NetworkCluster> object) {
            return object.getSecond() != null;
        }

        @Override
        protected boolean canEdit(PairQueryable<Cluster, NetworkCluster> object) {
            return false;
        }
    };
    attachedColumn.makeSortable();
    // $NON-NLS-1$
    getTable().addColumn(attachedColumn, constants.attachedNetworkCluster(), "120px");
    NetworkClusterStatusColumn statusColumn = new NetworkClusterStatusColumn();
    statusColumn.makeSortable(new SimpleStatusColumnComparator<>(statusColumn));
    // $NON-NLS-1$
    getTable().addColumn(statusColumn, constants.networkStatus(), "120px");
    AbstractCheckboxColumn<PairQueryable<Cluster, NetworkCluster>> netRequiredColumn = new AbstractCheckboxColumn<PairQueryable<Cluster, NetworkCluster>>(true) {

        @Override
        public Boolean getValue(PairQueryable<Cluster, NetworkCluster> object) {
            if (object.getSecond() != null) {
                return object.getSecond().isRequired();
            }
            return false;
        }

        @Override
        protected boolean canEdit(PairQueryable<Cluster, NetworkCluster> object) {
            return false;
        }
    };
    netRequiredColumn.makeSortable();
    // $NON-NLS-1$
    getTable().addColumn(netRequiredColumn, constants.requiredNetCluster(), "120px");
    AbstractSafeHtmlColumn<PairQueryable<Cluster, NetworkCluster>> netRoleColumn = createNetRoleColumn();
    netRoleColumn.makeSortable(new NetRoleColumnComparator());
    // $NON-NLS-1$
    getTable().addColumn(netRoleColumn, constants.roleNetCluster(), "120px");
    AbstractTextColumn<PairQueryable<Cluster, NetworkCluster>> descriptionColumn = new AbstractTextColumn<PairQueryable<Cluster, NetworkCluster>>() {

        @Override
        public String getValue(PairQueryable<Cluster, NetworkCluster> object) {
            return object.getFirst().getDescription();
        }
    };
    descriptionColumn.makeSortable();
    // $NON-NLS-1$
    getTable().addColumn(descriptionColumn, constants.descriptionCluster(), "400px");
}
Also used : PairQueryable(org.ovirt.engine.core.common.utils.PairQueryable) Cluster(org.ovirt.engine.core.common.businessentities.Cluster) NetworkCluster(org.ovirt.engine.core.common.businessentities.network.NetworkCluster) AbstractCheckboxColumn(org.ovirt.engine.ui.common.widget.table.column.AbstractCheckboxColumn) AbstractLinkColumn(org.ovirt.engine.ui.common.widget.table.column.AbstractLinkColumn) NetworkClusterStatusColumn(org.ovirt.engine.ui.webadmin.widget.table.column.NetworkClusterStatusColumn) AbstractTextColumn(org.ovirt.engine.ui.common.widget.table.column.AbstractTextColumn) NetworkCluster(org.ovirt.engine.core.common.businessentities.network.NetworkCluster) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) Map(java.util.Map)

Aggregations

AbstractCheckboxColumn (org.ovirt.engine.ui.common.widget.table.column.AbstractCheckboxColumn)11 AbstractTextColumn (org.ovirt.engine.ui.common.widget.table.column.AbstractTextColumn)7 ListModel (org.ovirt.engine.ui.uicommonweb.models.ListModel)5 GWT (com.google.gwt.core.client.GWT)4 SafeHtml (com.google.gwt.safehtml.shared.SafeHtml)4 UiBinder (com.google.gwt.uibinder.client.UiBinder)4 UiField (com.google.gwt.uibinder.client.UiField)4 ArrayList (java.util.ArrayList)4 EntityModelCellTable (org.ovirt.engine.ui.common.widget.editor.EntityModelCellTable)4 EntityModel (org.ovirt.engine.ui.uicommonweb.models.EntityModel)4 Context (com.google.gwt.cell.client.Cell.Context)3 EventBus (com.google.gwt.event.shared.EventBus)3 ImageResource (com.google.gwt.resources.client.ImageResource)3 SafeHtmlBuilder (com.google.gwt.safehtml.shared.SafeHtmlBuilder)3 ScrollPanel (com.google.gwt.user.client.ui.ScrollPanel)3 Inject (com.google.inject.Inject)3 UiCommonEditorDriver (org.ovirt.engine.ui.common.editor.UiCommonEditorDriver)3 WithElementId (org.ovirt.engine.ui.common.idhandler.WithElementId)3 SimpleDialogPanel (org.ovirt.engine.ui.common.widget.dialog.SimpleDialogPanel)3 ApplicationConstants (org.ovirt.engine.ui.webadmin.ApplicationConstants)3