use of org.ovirt.engine.ui.uicommonweb.models.storage.LunModel in project ovirt-engine by oVirt.
the class SanStorageLunToTargetList method initRootNodeTable.
private void initRootNodeTable(EntityModelCellTable<ListModel<LunModel>> table) {
table.addColumn(new AbstractLunTextColumn() {
@Override
public String getRawValue(LunModel model) {
return model.getLunId();
}
}, templates.textWithToolTip(constants.lunIdSanStorage()), // $NON-NLS-1$
"250px");
table.addColumn(new AbstractLunTextColumn() {
@Override
public String getRawValue(LunModel model) {
return messages.gibibytes(String.valueOf(model.getSize()));
}
}, templates.textWithToolTip(constants.devSizeSanStorage()), // $NON-NLS-1$
"60px");
table.addColumn(new AbstractLunTextColumn() {
@Override
public String getRawValue(LunModel model) {
return String.valueOf(model.getMultipathing());
}
}, templates.textWithToolTip(constants.pathSanStorage()), // $NON-NLS-1$
"45px");
table.addColumn(new AbstractLunTextColumn() {
@Override
public String getRawValue(LunModel model) {
return model.getVendorId();
}
}, templates.textWithToolTip(constants.vendorIdSanStorage()), // $NON-NLS-1$
"70px");
table.addColumn(new AbstractLunTextColumn() {
@Override
public String getRawValue(LunModel model) {
return model.getProductId();
}
}, templates.textWithToolTip(constants.productIdSanStorage()), // $NON-NLS-1$
"70px");
table.addColumn(new AbstractLunTextColumn() {
@Override
public String getRawValue(LunModel model) {
return model.getSerial();
}
}, constants.serialSanStorage(), // $NON-NLS-1$
"210px");
if (model.getContainer().isNewStorage() || model.getContainer().getStorage().getStatus() != StorageDomainStatus.Maintenance) {
if (multiSelection) {
addAbstractLunActionsColumn(table, model.getContainer().isNewStorage() ? constants.addSanStorage() : constants.actionsSanStorage());
}
} else if (model.isReduceDeviceSupported()) {
AbstractLunRemoveColumn removeColumn = new AbstractLunRemoveColumn(model) {
@Override
public LunModel getValue(LunModel object) {
return object;
}
};
// $NON-NLS-1$
table.addColumn(removeColumn, templates.textWithToolTip(constants.removeSanStorage()), "95px");
model.getRequireTableRefresh().getEntityChangedEvent().addListener((ev, sender, args) -> {
table.redraw();
});
}
}
use of org.ovirt.engine.ui.uicommonweb.models.storage.LunModel in project ovirt-engine by oVirt.
the class SanStorageTargetToLunList method createLeafNode.
@SuppressWarnings("unchecked")
@Override
protected TreeItem createLeafNode(ListModel leafModel) {
final TreeItem item = new TreeItem();
List<LunModel> items = (List<LunModel>) leafModel.getItems();
if (hideLeaf || items.isEmpty()) {
item.setUserObject(Boolean.TRUE);
return item;
}
final SortedListModel sortedLeafModel = new SortedListModel();
sortedLeafModel.setItems(items);
final EntityModelCellTable<ListModel<LunModel>> table = new EntityModelCellTable<>(multiSelection, (Resources) GWT.create(SanStorageListLunTableResources.class));
table.enableColumnResizing();
table.initModelSortHandler(sortedLeafModel);
AbstractLunSelectionColumn lunSelectionColumn = new AbstractLunSelectionColumn(multiSelection) {
@Override
public LunModel getValue(LunModel object) {
return object;
}
};
// $NON-NLS-1$
table.setCustomSelectionColumn(lunSelectionColumn, "25px");
AbstractLunTextColumn lunIdColumn = new AbstractLunTextColumn() {
@Override
public String getRawValue(LunModel model) {
return model.getLunId();
}
};
lunIdColumn.makeSortable();
// $NON-NLS-1$
table.addColumn(lunIdColumn, constants.lunIdSanStorage(), "250px");
AbstractLunTextColumn devSizeColumn = new AbstractLunTextColumn() {
@Override
public String getRawValue(LunModel model) {
return messages.gibibytes(String.valueOf(model.getSize()));
}
};
devSizeColumn.makeSortable();
// $NON-NLS-1$
table.addColumn(devSizeColumn, constants.devSizeSanStorage(), "60px");
AbstractLunTextColumn path = new AbstractLunTextColumn() {
@Override
public String getRawValue(LunModel model) {
return String.valueOf(model.getMultipathing());
}
};
path.makeSortable();
// $NON-NLS-1$
table.addColumn(path, constants.pathSanStorage(), "45px");
AbstractLunTextColumn vendorIdColumn = new AbstractLunTextColumn() {
@Override
public String getRawValue(LunModel model) {
return model.getVendorId();
}
};
vendorIdColumn.makeSortable();
// $NON-NLS-1$
table.addColumn(vendorIdColumn, constants.vendorIdSanStorage(), "70px");
AbstractLunTextColumn productIdColumn = new AbstractLunTextColumn() {
@Override
public String getRawValue(LunModel model) {
return model.getProductId();
}
};
productIdColumn.makeSortable();
// $NON-NLS-1$
table.addColumn(productIdColumn, constants.productIdSanStorage(), "70px");
AbstractLunTextColumn serialNumColumn = new AbstractLunTextColumn() {
@Override
public String getRawValue(LunModel model) {
return model.getSerial();
}
};
serialNumColumn.makeSortable();
// $NON-NLS-1$
table.addColumn(serialNumColumn, constants.serialSanStorage(), "210px");
if (model.getContainer().isNewStorage() || model.getContainer().getStorage().getStatus() != StorageDomainStatus.Maintenance) {
if (multiSelection) {
addAbstractLunActionsColumn(table, model.getContainer().isNewStorage() ? constants.addSanStorage() : constants.actionsSanStorage());
}
} else if (model.isReduceDeviceSupported()) {
AbstractLunRemoveColumn removeColumn = new AbstractLunRemoveColumn(model) {
@Override
public LunModel getValue(LunModel object) {
return object;
}
};
// $NON-NLS-1$
table.addColumn(removeColumn, constants.removeSanStorage(), "95px");
}
model.getRequireTableRefresh().getEntityChangedEvent().addListener((ev, sender, args) -> {
if (Boolean.TRUE.equals(model.getRequireTableRefresh().getEntity())) {
if (!multiSelection) {
updateLunSelectionModel(table, items);
}
}
table.redraw();
});
table.setRowData(items);
final Object selectedItem = sortedLeafModel.getSelectedItem();
sortedLeafModel.setSelectedItem(null);
table.asEditor().edit(sortedLeafModel);
sortedLeafModel.setSelectedItem(selectedItem);
// $NON-NLS-1$
table.setWidth("100%");
if (!multiSelection) {
table.getSelectionModel().addSelectionChangeHandler(event -> {
SingleSelectionModel SingleSelectionModel = (SingleSelectionModel) event.getSource();
selectedLunModel = SingleSelectionModel.getSelectedObject() == null ? selectedLunModel : (LunModel) SingleSelectionModel.getSelectedObject();
if (selectedLunModel != null && !selectedLunModel.getIsGrayedOut()) {
updateSelectedLunWarning(selectedLunModel);
sortedLeafModel.setSelectedItem(selectedLunModel);
}
});
} else {
for (LunModel lunModel : items) {
table.getSelectionModel().setSelected(lunModel, lunModel.getIsSelected());
}
table.getSelectionModel().addSelectionChangeHandler(event -> model.updateLunWarningForDiscardAfterDelete());
}
item.setWidget(table);
// Display LUNs as grayed-out if needed
for (LunModel lunModel : items) {
if (lunModel.getIsGrayedOut()) {
grayOutItem(lunModel.getGrayedOutReasons(), lunModel, table);
}
}
addOpenHandlerToTree(tree, item, table);
return item;
}
use of org.ovirt.engine.ui.uicommonweb.models.storage.LunModel in project ovirt-engine by oVirt.
the class DataCenterGuideModel method onSaveSanStorage.
private void onSaveSanStorage() {
ConfirmationModel confirmationModel = (ConfirmationModel) getConfirmWindow();
if (confirmationModel != null && !confirmationModel.validate()) {
return;
}
cancelConfirm();
getWindow().startProgress();
StorageModel model = (StorageModel) getWindow();
SanStorageModelBase sanModel = (SanStorageModelBase) model.getCurrentStorageItem();
VDS host = model.getHost().getSelectedItem();
boolean force = sanModel.isForce();
HashSet<String> lunIds = new HashSet<>();
for (LunModel lun : sanModel.getAddedLuns()) {
lunIds.add(lun.getLunId());
}
AddSANStorageDomainParameters params = new AddSANStorageDomainParameters(storageDomain);
params.setVdsId(host.getId());
params.setLunIds(new HashSet<>(lunIds));
params.setForce(force);
Frontend.getInstance().runAction(ActionType.AddSANStorageDomain, params, result -> {
DataCenterGuideModel dataCenterGuideModel = (DataCenterGuideModel) result.getState();
StorageModel storageModel = (StorageModel) dataCenterGuideModel.getWindow();
StoragePool dataCenter = storageModel.getDataCenter().getSelectedItem();
if (!dataCenter.getId().equals(StorageModel.UnassignedDataCenterId)) {
ActionReturnValue returnValue = result.getReturnValue();
Guid storageId = returnValue.getActionReturnValue();
dataCenterGuideModel.attachStorageToDataCenter(storageId, dataCenter.getId());
}
dataCenterGuideModel.onFinish(dataCenterGuideModel.context, true, dataCenterGuideModel.storageModel);
}, this);
}
use of org.ovirt.engine.ui.uicommonweb.models.storage.LunModel in project ovirt-engine by oVirt.
the class DataCenterGuideModel method saveNewSanStorage.
public void saveNewSanStorage() {
StorageModel storageModel = (StorageModel) getWindow();
final SanStorageModelBase sanStorageModelBase = (SanStorageModelBase) storageModel.getCurrentStorageItem();
Guid hostId = sanStorageModelBase.getContainer().getHost().getSelectedItem().getId();
Set<String> unkownStatusLuns = new HashSet<>();
for (LunModel lunModel : sanStorageModelBase.getAddedLuns()) {
unkownStatusLuns.add(lunModel.getLunId());
}
Frontend.getInstance().runQuery(QueryType.GetDeviceList, new GetDeviceListQueryParameters(hostId, sanStorageModelBase.getType(), true, unkownStatusLuns, false), new AsyncQuery<QueryReturnValue>(response -> {
if (response.getSucceeded()) {
List<LUNs> checkedLuns = (ArrayList<LUNs>) response.getReturnValue();
postGetLunsMessages(sanStorageModelBase.getUsedLunsMessages(checkedLuns));
} else {
sanStorageModelBase.setGetLUNsFailure(ConstantsManager.getInstance().getConstants().couldNotRetrieveLUNsLunsFailure());
}
}, true));
}
use of org.ovirt.engine.ui.uicommonweb.models.storage.LunModel in project ovirt-engine by oVirt.
the class SanStorageLunToTargetList method createRootNode.
@Override
protected TreeItem createRootNode(LunModel rootModel) {
final EntityModelCellTable<ListModel<LunModel>> table = new EntityModelCellTable<>(multiSelection, (Resources) GWT.create(SanStorageListLunRootResources.class));
// Create table
initRootNodeTable(table);
// Set custom selection column
AbstractLunSelectionColumn lunSelectionColumn = new AbstractLunSelectionColumn(multiSelection) {
@Override
public LunModel getValue(LunModel object) {
return object;
}
};
// $NON-NLS-1$
table.setCustomSelectionColumn(lunSelectionColumn, "20px");
// Add items
List<LunModel> items = new ArrayList<>();
items.add(rootModel);
ListModel<LunModel> listModel = new ListModel<>();
listModel.setItems(items);
// Update table
table.setRowData(items);
table.asEditor().edit(listModel);
// $NON-NLS-1$
table.setWidth("100%");
// This was the height of the header
// $NON-NLS-1$
table.setHeight("26px");
rootModel.getPropertyChangedEvent().removeListener(lunModelSelectedItemListener);
rootModel.getPropertyChangedEvent().addListener(lunModelSelectedItemListener, table);
if (!multiSelection) {
table.getSelectionModel().addSelectionChangeHandler(event -> {
SingleSelectionModel SingleSelectionModel = (SingleSelectionModel) event.getSource();
LunModel selectedLunModel = (LunModel) SingleSelectionModel.getSelectedObject();
if (selectedLunModel != null) {
updateSelectedLunWarning(selectedLunModel);
}
});
} else {
table.getSelectionModel().setSelected(rootModel, rootModel.getIsSelected());
table.getSelectionModel().addSelectionChangeHandler(event -> model.updateLunWarningForDiscardAfterDelete());
}
// Create tree item
HorizontalPanel panel = new HorizontalPanel();
panel.add(table);
// $NON-NLS-1$
panel.setWidth("100%");
panel.getElement().getStyle().setTableLayout(TableLayout.FIXED);
TreeItem item = new TreeItem(table);
// Display LUNs as grayed-out if needed
if (rootModel.getIsGrayedOut()) {
grayOutItem(rootModel.getGrayedOutReasons(), rootModel, table);
}
return item;
}
Aggregations