use of org.ovirt.engine.ui.uicommonweb.models.Model in project ovirt-engine by oVirt.
the class AbstractSubTabPanelPresenter method onBind.
@Override
protected void onBind() {
super.onBind();
// initialize detail tab to model mappings
initDetailTabToModelMapping(detailTabToModelMapping);
// add IsAvailable property change listener for each detail model
for (Map.Entry<TabData, Model> entry : detailTabToModelMapping.entrySet()) {
TabData tabData = entry.getKey();
Model detailModel = entry.getValue();
detailModel.getPropertyChangedEvent().addListener((ev, sender, args) -> {
if ("IsAvailable".equals(args.propertyName)) {
// $NON-NLS-1$
updateTabVisibility(tabData, detailModel);
}
});
}
}
use of org.ovirt.engine.ui.uicommonweb.models.Model in project ovirt-engine by oVirt.
the class VmSnapshotListModel method preview.
private void preview() {
VM vm = getEntity();
if (vm == null) {
return;
}
final Snapshot snapshot = getSelectedItem();
AsyncDataProvider.getInstance().getVmConfigurationBySnapshot(new AsyncQuery<>(v -> {
ArrayList<DiskImage> snapshotDisks = v.getDiskList();
List<DiskImage> disksExcludedFromSnapshot = imagesSubtract(getVmDisks(), snapshotDisks);
boolean showMemorySnapshotWarning = isMemorySnapshotSupported() && snapshot.containsMemory();
boolean showPartialSnapshotWarning = !disksExcludedFromSnapshot.isEmpty();
if (showMemorySnapshotWarning || showPartialSnapshotWarning) {
SnapshotModel model = new SnapshotModel();
model.setVmDisks(getVmDisks());
model.setDisks(snapshotDisks);
model.setShowMemorySnapshotWarning(showMemorySnapshotWarning);
model.setShowPartialSnapshotWarning(showPartialSnapshotWarning);
if (showMemorySnapshotWarning) {
model.setOldClusterVersionOfSnapshotWithMemory(v);
}
setWindow(model);
model.setTitle(showPartialSnapshotWarning ? ConstantsManager.getInstance().getConstants().previewPartialSnapshotTitle() : ConstantsManager.getInstance().getConstants().previewSnapshotTitle());
model.setHelpTag(showPartialSnapshotWarning ? HelpTag.preview_partial_snapshot : HelpTag.preview_snapshot);
// $NON-NLS-1$ //$NON-NLS-2$
model.setHashName(showPartialSnapshotWarning ? "preview_partial_snapshot" : "preview_snapshot");
// $NON-NLS-1$
addCommands(model, "OnPreview");
} else {
runTryBackToAllSnapshotsOfVm(null, v, snapshot, false, null, true, null);
}
}), snapshot.getId());
}
use of org.ovirt.engine.ui.uicommonweb.models.Model in project ovirt-engine by oVirt.
the class UiCommonEditorVisitor method visit.
@SuppressWarnings("unchecked")
@Override
public <T> boolean visit(final EditorContext<T> ctx) {
final String absolutePath = ctx.getAbsolutePath();
LeafValueEditor<T> currentLeafEditor = ctx.asLeafValueEditor();
if (currentLeafEditor == null) {
// Ignore non-leaf Editors
return super.visit(ctx);
}
final LeafValueEditor<T> editor = getActualEditor(currentLeafEditor);
// If this Editor implements HasValueChangeHandlers, register a value change listener
if (editor instanceof HasValueChangeHandlers) {
((HasValueChangeHandlers<T>) editor).addValueChangeHandler(event -> setInModel(ctx, event.getSource(), event.getValue()));
}
final UiCommonEditor<T> functionalEditor = getFunctionalEditor(currentLeafEditor);
if (functionalEditor != null) {
// Pass in the EditorDelegate
if (editor instanceof HasEditorDelegate) {
((HasEditorDelegate<T>) editor).setDelegate(ctx.getEditorDelegate());
}
// Set tab index, unless it's being set manually (i.e. already been set)
if (functionalEditor.getTabIndex() <= 0) {
functionalEditor.setTabIndex(++tabIndexCounter);
}
// Add key press handler
functionalEditor.addKeyPressHandler(event -> {
if (KeyCodes.KEY_ENTER == event.getNativeEvent().getKeyCode()) {
setInModel(ctx, editor, editor.getValue());
}
});
}
// Handle owner entity models
if (ownerModels.containsKey(absolutePath)) {
Model ownerModel = ownerModels.get(absolutePath);
// If this editor edits a ListModel, initialize it
if (editor instanceof TakesConstrainedValueListEditor && ownerModel instanceof ListModel) {
updateListEditor((TakesConstrainedValueListEditor<T>) editor, (ListModel) ownerModel);
} else if (editor instanceof TakesConstrainedValueEditor && ownerModel instanceof ListModel) {
updateListEditor((TakesConstrainedValueEditor<T>) editor, (ListModel) ownerModel);
}
if (functionalEditor != null) {
// Register a property change listener on the owner entity model
ownerModel.getPropertyChangedEvent().addListener((ev, sender, args) -> {
Model owner = (Model) sender;
String propName = args.propertyName;
// IsValid
if ("IsValid".equals(propName)) {
// $NON-NLS-1$
onIsValidPropertyChange(functionalEditor, owner);
} else // IsChangable
if ("IsChangable".equals(propName)) {
// $NON-NLS-1$
onIsChangablePropertyChange(functionalEditor, owner);
} else // ChangeProhibitionReason
if ("ChangeProhibitionReason".equals(propName)) {
// $NON-NLS-1$
onChangeProhibitionReasonChange(functionalEditor, owner);
} else // IsAvailable
if ("IsAvailable".equals(propName)) {
// $NON-NLS-1$
onIsAvailablePropertyChange(functionalEditor, owner);
}
});
// Update editor since we might have missed property change
// events fired as part of the entity model constructor
onIsValidPropertyChange(functionalEditor, ownerModel);
onIsChangablePropertyChange(functionalEditor, ownerModel);
onChangeProhibitionReasonChange(functionalEditor, ownerModel);
onIsAvailablePropertyChange(functionalEditor, ownerModel);
}
}
// Register listeners
// $NON-NLS-1$
eventMap.registerListener(// $NON-NLS-1$
absolutePath, // $NON-NLS-1$
"EntityChanged", (ev, sender, args) -> editor.setValue((T) ((EntityModel) sender).getEntity()));
// $NON-NLS-1$
eventMap.registerListener(// $NON-NLS-1$
absolutePath, // $NON-NLS-1$
"ItemsChanged", (ev, sender, args) -> updateListEditor((TakesConstrainedValueEditor<T>) editor, (ListModel) sender));
eventMap.registerListener(absolutePath, "SelectedItemChanged", (ev, sender, args) -> {
// $NON-NLS-1$
T selectedItem = (T) ((ListModel) sender).getSelectedItem();
if (editor instanceof TakesConstrainedValueListEditor && ownerModels.get(absolutePath) instanceof ListModel) {
editor.setValue((T) Arrays.asList(selectedItem));
} else {
editor.setValue(selectedItem);
}
});
eventMap.registerListener(absolutePath, "SelectedItemsChanged", (ev, sender, args) -> {
// $NON-NLS-1$
if (editor instanceof TakesConstrainedValueListEditor && ownerModels.get(absolutePath) instanceof ListModel) {
((TakesConstrainedValueListEditor) editor).setListValue((List<T>) ((ListModel) sender).getSelectedItems());
}
});
return super.visit(ctx);
}
use of org.ovirt.engine.ui.uicommonweb.models.Model in project ovirt-engine by oVirt.
the class SanStorageModelBase method connectTargets.
private void connectTargets() {
VDS host = getContainer().getHost().getSelectedItem();
if (host == null) {
return;
}
ArrayList<ActionType> actionTypes = new ArrayList<>();
ArrayList<ActionParametersBase> parameters = new ArrayList<>();
ArrayList<IFrontendActionAsyncCallback> callbacks = new ArrayList<>();
final SanStorageModelBase sanStorageModel = this;
IFrontendActionAsyncCallback loginCallback = result -> sanStorageModel.postLogin(result.getReturnValue(), sanStorageModel);
for (int i = 0; i < targetsToConnect.size(); i++) {
SanTargetModel model = targetsToConnect.get(i);
StorageServerConnections connection = new StorageServerConnections();
connection.setStorageType(StorageType.ISCSI);
// $NON-NLS-1$
connection.setUserName(getUseUserAuth().getEntity() ? getUserName().getEntity() : "");
// $NON-NLS-1$
connection.setPassword(getUseUserAuth().getEntity() ? getPassword().getEntity() : "");
connection.setIqn(model.getName());
connection.setConnection(model.getAddress());
connection.setPort(String.valueOf(model.getPort()));
connection.setPortal(model.getPortal());
actionTypes.add(ActionType.ConnectStorageToVds);
parameters.add(new StorageServerConnectionParametersBase(connection, host.getId(), false));
callbacks.add(loginCallback);
}
Object target = getWidgetModel() != null ? getWidgetModel() : getContainer();
Frontend.getInstance().runMultipleActions(actionTypes, parameters, callbacks, null, target);
}
use of org.ovirt.engine.ui.uicommonweb.models.Model in project ovirt-engine by oVirt.
the class SanStorageModelBase method postPrepareSanStorageForEdit.
private void postPrepareSanStorageForEdit(final SanStorageModelBase model, boolean isStorageActive, StorageDomain storage) {
model.setStorageDomain(storage);
VDS host = getContainer().getHost().getSelectedItem();
if (Objects.equals(previousGetLunsByVGIdHost, host) && isStorageActive) {
return;
}
previousGetLunsByVGIdHost = host;
Guid hostId = host != null && isStorageActive ? host.getId() : null;
setValuesForMaintenance(model);
getContainer().startProgress();
AsyncDataProvider.getInstance().getLunsByVgId(new AsyncQuery<>(lunList -> model.applyData(lunList, true, Linq.findSelectedItems((Collection<EntityModel<?>>) getSelectedItem()), isInMaintenance, metadata)), storage.getStorage(), hostId);
}
Aggregations