Search in sources :

Example 1 with AbstractCheckboxHeader

use of org.ovirt.engine.ui.common.widget.table.header.AbstractCheckboxHeader in project ovirt-engine by oVirt.

the class ColumnResizeCellTable method addColumnImpl.

private void addColumnImpl(Column<T, ?> column, Header<?> header) {
    // build resizable headers, if necessary
    if (columnResizingEnabled && header instanceof AbstractCheckboxHeader) {
        header = createResizableCheckboxHeader(header, column);
    } else if (columnResizingEnabled) {
        header = createResizableHeader(column, header);
    } else if (applyHeaderStyle && header instanceof SafeHtmlHeader) {
        SafeHtmlHeader safeHtmlHeader = (SafeHtmlHeader) header;
        // not using Resizeable header, but still want it to look that way.
        // nonResizeableColumnHeader does that.
        // TODO nonResizeableColumnHeader copy-pastes CSS. fix.
        SafeHtml newValue = templates.nonResizeableColumnHeader(safeHtmlHeader.getValue());
        header = new SafeHtmlHeader(newValue, safeHtmlHeader.getTooltip());
    }
    // actually add the column
    super.addColumn(column, header);
    // Add empty no-width column as the last column
    if (columnResizingEnabled) {
        if (isColumnPresent(emptyNoWidthColumn)) {
            removeColumn(emptyNoWidthColumn);
        }
        super.addColumn(emptyNoWidthColumn, emptyNoWidthColumnHeader);
    }
    // Add column to header context menu
    if (header instanceof AbstractHeader) {
        ((AbstractHeader) header).setContextMenuHandler(ensureContextMenuHandler());
        contextPopup.getContextMenu().addItem(column);
    }
}
Also used : SafeHtmlHeader(org.ovirt.engine.ui.common.widget.table.header.SafeHtmlHeader) AbstractHeader(org.ovirt.engine.ui.common.widget.table.header.AbstractHeader) SafeHtml(com.google.gwt.safehtml.shared.SafeHtml) AbstractCheckboxHeader(org.ovirt.engine.ui.common.widget.table.header.AbstractCheckboxHeader)

Example 2 with AbstractCheckboxHeader

use of org.ovirt.engine.ui.common.widget.table.header.AbstractCheckboxHeader in project ovirt-engine by oVirt.

the class AbstractNetworkPopupView method initEntityModelCellTable.

void initEntityModelCellTable() {
    AbstractCheckboxHeader assignAllHeader = new AbstractCheckboxHeader() {

        @Override
        protected void selectionChanged(Boolean value) {
            for (NetworkClusterModel networkClusterModel : getClustersTableItems()) {
                if (networkClusterModel.getIsChangable()) {
                    networkClusterModel.setAttached(value);
                    networkClusterModel.setRequired(value && networkClusterModel.isRequired());
                }
            }
            refreshClustersTable();
        }

        @Override
        public Boolean getValue() {
            for (NetworkClusterModel networkClusterModel : getClustersTableItems()) {
                if (networkClusterModel.getIsChangable() && !networkClusterModel.isAttached()) {
                    return false;
                }
            }
            return true;
        }

        @Override
        public boolean isEnabled() {
            for (NetworkClusterModel networkClusterModel : getClustersTableItems()) {
                if (networkClusterModel.getIsChangable()) {
                    return true;
                }
            }
            return false;
        }

        @Override
        public String getLabel() {
            return constants.attachAll();
        }
    };
    AbstractCheckboxHeader requiredAllHeader = new AbstractCheckboxHeader() {

        @Override
        protected void selectionChanged(Boolean value) {
            for (NetworkClusterModel networkClusterModel : getClustersTableItems()) {
                networkClusterModel.setRequired(value && networkClusterModel.isAttached());
            }
            refreshClustersTable();
        }

        @Override
        public Boolean getValue() {
            for (NetworkClusterModel networkClusterModel : getClustersTableItems()) {
                if (!networkClusterModel.isRequired()) {
                    return false;
                }
            }
            return true;
        }

        @Override
        public boolean isEnabled() {
            return isRequiredChangeable();
        }

        @Override
        public String getLabel() {
            return constants.requiredAll();
        }
    };
    clustersTable.addColumn(new AbstractTextColumn<NetworkClusterModel>() {

        @Override
        public String getValue(NetworkClusterModel model) {
            return model.getName();
        }
    }, constants.nameClusterHeader());
    clustersTable.addColumn(new AbstractCheckboxColumn<NetworkClusterModel>((index, model, value) -> {
        model.setAttached(value);
        model.setRequired(value && model.isRequired());
        refreshClustersTable();
    }) {

        @Override
        public Boolean getValue(NetworkClusterModel model) {
            return model.isAttached();
        }

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

        @Override
        public void render(Context context, NetworkClusterModel object, SafeHtmlBuilder sb) {
            super.render(context, object, sb);
            sb.append(templates.textForCheckBox(constants.attach()));
        }
    }, assignAllHeader, // $NON-NLS-1$
    "150px");
    clustersTable.addColumn(new AbstractCheckboxColumn<NetworkClusterModel>((index, model, value) -> {
        model.setRequired(value && model.isAttached());
        refreshClustersTable();
    }) {

        @Override
        public Boolean getValue(NetworkClusterModel model) {
            return model.isRequired();
        }

        @Override
        protected boolean canEdit(NetworkClusterModel model) {
            return isRequiredChangeable() && model.isAttached();
        }

        @Override
        public void render(Context context, NetworkClusterModel object, SafeHtmlBuilder sb) {
            super.render(context, object, sb);
            sb.append(templates.textForCheckBox(constants.required()));
        }
    }, requiredAllHeader, // $NON-NLS-1$
    "150px");
}
Also used : NetworkModel(org.ovirt.engine.ui.uicommonweb.models.datacenters.NetworkModel) EntityModelCellTable(org.ovirt.engine.ui.common.widget.editor.EntityModelCellTable) AssetProvider(org.ovirt.engine.ui.webadmin.gin.AssetProvider) VnicProfilesEditor(org.ovirt.engine.ui.webadmin.widget.vnicProfile.VnicProfilesEditor) Inject(com.google.inject.Inject) Container(org.gwtbootstrap3.client.ui.Container) Provider(org.ovirt.engine.core.common.businessentities.Provider) ApplicationMode(org.ovirt.engine.core.common.mode.ApplicationMode) Unit(com.google.gwt.dom.client.Style.Unit) HTML(com.google.gwt.user.client.ui.HTML) UiBinder(com.google.gwt.uibinder.client.UiBinder) Label(com.google.gwt.user.client.ui.Label) AbstractTabbedModelBoundPopupView(org.ovirt.engine.ui.common.view.popup.AbstractTabbedModelBoundPopupView) ListModelRadioGroupEditor(org.ovirt.engine.ui.common.widget.editor.ListModelRadioGroupEditor) Context(com.google.gwt.cell.client.Cell.Context) SafeHtmlBuilder(com.google.gwt.safehtml.shared.SafeHtmlBuilder) IntegerEntityModelTextBoxOnlyEditor(org.ovirt.engine.ui.common.widget.editor.generic.IntegerEntityModelTextBoxOnlyEditor) SelectionMode(org.ovirt.engine.ui.common.widget.editor.EntityModelCellTable.SelectionMode) NetworkClusterModel(org.ovirt.engine.ui.uicommonweb.models.datacenters.NetworkClusterModel) EventBus(com.google.gwt.event.shared.EventBus) DnsServersWidget(org.ovirt.engine.ui.webadmin.widget.provider.DnsServersWidget) ListModel(org.ovirt.engine.ui.uicommonweb.models.ListModel) WithElementId(org.ovirt.engine.ui.common.idhandler.WithElementId) ListModelSuggestBoxEditor(org.ovirt.engine.ui.common.widget.editor.generic.ListModelSuggestBoxEditor) ApplicationModeHelper(org.ovirt.engine.ui.uicommonweb.models.ApplicationModeHelper) FlowPanel(com.google.gwt.user.client.ui.FlowPanel) UiField(com.google.gwt.uibinder.client.UiField) DialogTabPanel(org.ovirt.engine.ui.common.widget.dialog.tab.DialogTabPanel) MtuSelector(org.ovirt.engine.ui.uicommonweb.models.datacenters.NetworkModel.MtuSelector) StoragePool(org.ovirt.engine.core.common.businessentities.StoragePool) AbstractCheckboxColumn(org.ovirt.engine.ui.common.widget.table.column.AbstractCheckboxColumn) StringEntityModelTextBoxEditor(org.ovirt.engine.ui.common.widget.editor.generic.StringEntityModelTextBoxEditor) 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) ListModelListBoxEditor(org.ovirt.engine.ui.common.widget.editor.ListModelListBoxEditor) ArrayList(java.util.ArrayList) ApplicationConstants(org.ovirt.engine.ui.webadmin.ApplicationConstants) UiCommandButton(org.ovirt.engine.ui.common.widget.UiCommandButton) DialogTab(org.ovirt.engine.ui.common.widget.dialog.tab.DialogTab) ListModelListBoxOnlyEditor(org.ovirt.engine.ui.common.widget.editor.ListModelListBoxOnlyEditor) AbstractNetworkPopupPresenterWidget(org.ovirt.engine.ui.webadmin.section.main.presenter.popup.AbstractNetworkPopupPresenterWidget) Network(org.ovirt.engine.core.common.businessentities.network.Network) HostNetworkQos(org.ovirt.engine.core.common.businessentities.network.HostNetworkQos) EntityModelCheckBoxEditor(org.ovirt.engine.ui.common.widget.editor.generic.EntityModelCheckBoxEditor) AbstractCheckboxHeader(org.ovirt.engine.ui.common.widget.table.header.AbstractCheckboxHeader) EntityModelRadioButtonEditor(org.ovirt.engine.ui.common.widget.editor.generic.EntityModelRadioButtonEditor) NameRenderer(org.ovirt.engine.ui.common.widget.renderer.NameRenderer) ApplicationTemplates(org.ovirt.engine.ui.webadmin.ApplicationTemplates) SimpleDialogPanel(org.ovirt.engine.ui.common.widget.dialog.SimpleDialogPanel) TabName(org.ovirt.engine.ui.uicommonweb.models.TabName) ExternalSubnetWidget(org.ovirt.engine.ui.webadmin.widget.provider.ExternalSubnetWidget) AbstractTextColumn(org.ovirt.engine.ui.common.widget.table.column.AbstractTextColumn) Context(com.google.gwt.cell.client.Cell.Context) NetworkClusterModel(org.ovirt.engine.ui.uicommonweb.models.datacenters.NetworkClusterModel) SafeHtmlBuilder(com.google.gwt.safehtml.shared.SafeHtmlBuilder) AbstractCheckboxHeader(org.ovirt.engine.ui.common.widget.table.header.AbstractCheckboxHeader)

Example 3 with AbstractCheckboxHeader

use of org.ovirt.engine.ui.common.widget.table.header.AbstractCheckboxHeader in project ovirt-engine by oVirt.

the class ImportNetworksPopupView method initEntityModelCellTables.

void initEntityModelCellTables() {
    providerNetworks.addColumn(new AbstractTextColumn<ExternalNetwork>() {

        @Override
        public String getValue(ExternalNetwork model) {
            return model.getDisplayName();
        }
    }, constants.nameNetworkHeader());
    importedNetworks.addColumn(new AbstractEditTextColumn<ExternalNetwork>((index, model, value) -> model.setDisplayName(value)) {

        @Override
        public String getValue(ExternalNetwork model) {
            return model.getDisplayName();
        }
    }, constants.nameNetworkHeader());
    Column<ExternalNetwork, String> idColumn = new AbstractTextColumn<ExternalNetwork>() {

        @Override
        public String getValue(ExternalNetwork model) {
            return model.getNetwork().getProvidedBy().getExternalId();
        }
    };
    providerNetworks.addColumn(idColumn, constants.idNetworkHeader());
    importedNetworks.addColumn(idColumn, constants.idNetworkHeader());
    dcColumn = new AbstractListModelListBoxColumn<ExternalNetwork, StoragePool>(new NameRenderer<StoragePool>()) {

        @Override
        public ListModel<StoragePool> getValue(ExternalNetwork network) {
            return network.getDataCenters();
        }
    };
    importedNetworks.addColumn(dcColumn, constants.dcNetworkHeader());
    AbstractCheckboxHeader publicAllHeader = new AbstractCheckboxHeader() {

        @Override
        protected void selectionChanged(Boolean value) {
            for (ExternalNetwork model : getAllImportedNetworks()) {
                model.setPublicUse(value);
            }
            refreshImportedNetworks();
        }

        @Override
        public Boolean getValue() {
            for (ExternalNetwork model : getAllImportedNetworks()) {
                if (!model.isPublicUse()) {
                    return false;
                }
            }
            return true;
        }

        @Override
        public boolean isEnabled() {
            return true;
        }

        @Override
        public void render(Context context, SafeHtmlBuilder sb) {
            super.render(context, sb);
            sb.append(ImportNetworksPopupView.templates.tableHeaderInlineImage(SafeHtmlUtils.fromTrustedString(new InfoIcon(SafeHtmlUtils.EMPTY_SAFE_HTML).toString())));
        }

        @Override
        public SafeHtml getTooltip() {
            return ImportNetworksPopupView.templates.textForCheckBoxHeader(constants.publicNetworkTooltip());
        }

        @Override
        public String getLabel() {
            return constants.publicNetwork();
        }
    };
    importedNetworks.addColumn(new AbstractCheckboxColumn<ExternalNetwork>((index, model, value) -> {
        model.setPublicUse(value);
        refreshImportedNetworks();
    }) {

        @Override
        public Boolean getValue(ExternalNetwork model) {
            return model.isPublicUse();
        }

        @Override
        protected boolean canEdit(ExternalNetwork model) {
            return true;
        }

        @Override
        public void render(Context context, ExternalNetwork object, SafeHtmlBuilder sb) {
            super.render(context, object, sb);
            // $NON-NLS-1$
            sb.append(templates.textForCheckBox(""));
        }
    }, publicAllHeader, // $NON-NLS-1$
    "80px");
}
Also used : StoragePool(org.ovirt.engine.core.common.businessentities.StoragePool) AbstractCheckboxColumn(org.ovirt.engine.ui.common.widget.table.column.AbstractCheckboxColumn) EntityModelCellTable(org.ovirt.engine.ui.common.widget.editor.EntityModelCellTable) AssetProvider(org.ovirt.engine.ui.webadmin.gin.AssetProvider) Inject(com.google.inject.Inject) Provider(org.ovirt.engine.core.common.businessentities.Provider) AbstractModelBoundPopupView(org.ovirt.engine.ui.common.view.popup.AbstractModelBoundPopupView) GWT(com.google.gwt.core.client.GWT) ImportNetworksPopupPresenterWidget(org.ovirt.engine.ui.webadmin.section.main.presenter.popup.provider.ImportNetworksPopupPresenterWidget) ListModelListBoxEditor(org.ovirt.engine.ui.common.widget.editor.ListModelListBoxEditor) ArrayList(java.util.ArrayList) UiBinder(com.google.gwt.uibinder.client.UiBinder) ApplicationConstants(org.ovirt.engine.ui.webadmin.ApplicationConstants) BaseImportNetworksModel(org.ovirt.engine.ui.uicommonweb.models.networks.BaseImportNetworksModel) ExternalNetwork(org.ovirt.engine.ui.uicommonweb.models.providers.ExternalNetwork) Context(com.google.gwt.cell.client.Cell.Context) SafeHtmlBuilder(com.google.gwt.safehtml.shared.SafeHtmlBuilder) HorizontalSplitTable(org.ovirt.engine.ui.common.widget.HorizontalSplitTable) SafeHtmlUtils(com.google.gwt.safehtml.shared.SafeHtmlUtils) InfoIcon(org.ovirt.engine.ui.common.widget.dialog.InfoIcon) ApplicationResources(org.ovirt.engine.ui.webadmin.ApplicationResources) AbstractEditTextColumn(org.ovirt.engine.ui.common.widget.table.column.AbstractEditTextColumn) EventBus(com.google.gwt.event.shared.EventBus) UiCommonEditorDriver(org.ovirt.engine.ui.common.editor.UiCommonEditorDriver) ListModel(org.ovirt.engine.ui.uicommonweb.models.ListModel) AbstractCheckboxHeader(org.ovirt.engine.ui.common.widget.table.header.AbstractCheckboxHeader) NameRenderer(org.ovirt.engine.ui.common.widget.renderer.NameRenderer) AbstractListModelListBoxColumn(org.ovirt.engine.ui.common.widget.table.column.AbstractListModelListBoxColumn) WithElementId(org.ovirt.engine.ui.common.idhandler.WithElementId) ApplicationTemplates(org.ovirt.engine.ui.webadmin.ApplicationTemplates) List(java.util.List) SimpleDialogPanel(org.ovirt.engine.ui.common.widget.dialog.SimpleDialogPanel) Column(com.google.gwt.user.cellview.client.Column) UiField(com.google.gwt.uibinder.client.UiField) AbstractTextColumn(org.ovirt.engine.ui.common.widget.table.column.AbstractTextColumn) SafeHtml(com.google.gwt.safehtml.shared.SafeHtml) Context(com.google.gwt.cell.client.Cell.Context) StoragePool(org.ovirt.engine.core.common.businessentities.StoragePool) NameRenderer(org.ovirt.engine.ui.common.widget.renderer.NameRenderer) SafeHtmlBuilder(com.google.gwt.safehtml.shared.SafeHtmlBuilder) ListModel(org.ovirt.engine.ui.uicommonweb.models.ListModel) InfoIcon(org.ovirt.engine.ui.common.widget.dialog.InfoIcon) AbstractTextColumn(org.ovirt.engine.ui.common.widget.table.column.AbstractTextColumn) ExternalNetwork(org.ovirt.engine.ui.uicommonweb.models.providers.ExternalNetwork) AbstractCheckboxHeader(org.ovirt.engine.ui.common.widget.table.header.AbstractCheckboxHeader)

Aggregations

AbstractCheckboxHeader (org.ovirt.engine.ui.common.widget.table.header.AbstractCheckboxHeader)3 Context (com.google.gwt.cell.client.Cell.Context)2 GWT (com.google.gwt.core.client.GWT)2 EventBus (com.google.gwt.event.shared.EventBus)2 SafeHtml (com.google.gwt.safehtml.shared.SafeHtml)2 SafeHtmlBuilder (com.google.gwt.safehtml.shared.SafeHtmlBuilder)2 UiBinder (com.google.gwt.uibinder.client.UiBinder)2 UiField (com.google.gwt.uibinder.client.UiField)2 Inject (com.google.inject.Inject)2 ArrayList (java.util.ArrayList)2 Provider (org.ovirt.engine.core.common.businessentities.Provider)2 StoragePool (org.ovirt.engine.core.common.businessentities.StoragePool)2 WithElementId (org.ovirt.engine.ui.common.idhandler.WithElementId)2 SimpleDialogPanel (org.ovirt.engine.ui.common.widget.dialog.SimpleDialogPanel)2 EntityModelCellTable (org.ovirt.engine.ui.common.widget.editor.EntityModelCellTable)2 ListModelListBoxEditor (org.ovirt.engine.ui.common.widget.editor.ListModelListBoxEditor)2 NameRenderer (org.ovirt.engine.ui.common.widget.renderer.NameRenderer)2 AbstractCheckboxColumn (org.ovirt.engine.ui.common.widget.table.column.AbstractCheckboxColumn)2 AbstractTextColumn (org.ovirt.engine.ui.common.widget.table.column.AbstractTextColumn)2 ListModel (org.ovirt.engine.ui.uicommonweb.models.ListModel)2