package org.ovirt.engine.ui.webadmin.section.main.view.popup.vm;
import org.ovirt.engine.core.compat.Event;
import org.ovirt.engine.core.compat.EventArgs;
import org.ovirt.engine.core.compat.IEventListener;
import org.ovirt.engine.core.compat.PropertyChangedEventArgs;
import org.ovirt.engine.ui.uicommonweb.models.vms.UnitVmModel;
import org.ovirt.engine.ui.webadmin.ApplicationConstants;
import org.ovirt.engine.ui.webadmin.ApplicationResources;
import org.ovirt.engine.ui.webadmin.section.main.presenter.popup.vm.VmDesktopNewPopupPresenterWidget;
import org.ovirt.engine.ui.webadmin.section.main.view.popup.AbstractVmPopupView;
import com.google.gwt.event.shared.EventBus;
import com.google.inject.Inject;
public class VmDesktopNewPopupView extends AbstractVmPopupView implements VmDesktopNewPopupPresenterWidget.ViewDef {
@Inject
public VmDesktopNewPopupView(EventBus eventBus, ApplicationResources resources, ApplicationConstants constants) {
super(eventBus, resources, constants);
}
@Override
public void edit(UnitVmModel object) {
super.edit(object);
initTabAvailabilityListeners(object);
}
private void initTabAvailabilityListeners(final UnitVmModel vm) {
// TODO should be handled by the core framework
vm.getPropertyChangedEvent().addListener(new IEventListener() {
@Override
public void eventRaised(Event ev, Object sender, EventArgs args) {
String propName = ((PropertyChangedEventArgs) args).PropertyName;
if ("IsHostAvailable".equals(propName)) {
hostTab.setVisible(vm.getIsHostAvailable());
} else if ("IsHostTabValid".equals(propName)) {
if (vm.getIsHostTabValid()) {
hostTab.markAsValid();
} else {
hostTab.markAsInvalid(null);
}
}
}
});
// High Availability only avail in server mode
highAvailabilityTab.setVisible(false);
// only avail for desktop mode
isStatelessEditor.setVisible(true);
numOfMonitorsEditor.setVisible(true);
}
}