public static GraphicsType fromVmDeviceType(VmDeviceType type) { for (GraphicsType graphicsType : GraphicsType.values()) { if (graphicsType.getCorrespondingDeviceType() == type) { return graphicsType; } } return null; } }
/** * Set data about graphics from (REST) Template to parameters. * * @param display - display that contains graphics data * @param params - parameters to be updated with graphics data */ public static void setGraphicsToParams(Display display, HasGraphicsDevices params) { if (display != null && display.isSetType()) { DisplayType newDisplayType = display.getType(); if (newDisplayType != null) { for (GraphicsType graphicsType : GraphicsType.values()) { params.getGraphicsDevices().put(graphicsType, null); // reset graphics devices } GraphicsType newGraphicsType = DisplayMapper.map(newDisplayType, null); params.getGraphicsDevices().put(newGraphicsType, new GraphicsDevice(newGraphicsType.getCorrespondingDeviceType())); } } }
public GraphicsDevice(VmDevice vmDev) { this(GraphicsType.fromString(vmDev.getDevice()).getCorrespondingDeviceType()); setId(vmDev.getId()); setSpecParams(vmDev.getSpecParams()); }
@Override protected void build(UnitVmModel source, HasGraphicsDevices destination) { if (source.getDisplayType().getSelectedItem() == null || source.getGraphicsType().getSelectedItem() == null) { return; } for (GraphicsType graphicsType : GraphicsType.values()) { destination.getGraphicsDevices().put(graphicsType, null); // reset // if not headless VM then set the selected graphic devices if (!source.getIsHeadlessModeEnabled().getEntity() && source.getGraphicsType().getSelectedItem().getBackingGraphicsTypes().contains(graphicsType)) { GraphicsDevice d = new GraphicsDevice(graphicsType.getCorrespondingDeviceType()); destination.getGraphicsDevices().put(d.getGraphicsType(), d); } } }
private void postDoUpdateManagedFieldsFrom(VmBase vmBase) { if (isNextRunConfigurationExists()) { deactivate(); getModel().getIsSoundcardEnabled().setEntity( VmDeviceCommonUtils.isVmDeviceExists(vmBase.getManagedDeviceMap(), VmDeviceGeneralType.SOUND)); getModel().getIsConsoleDeviceEnabled().setEntity( VmDeviceCommonUtils.isVmDeviceExists(vmBase.getManagedDeviceMap(), VmDeviceType.CONSOLE)); Set<GraphicsType> graphicsTypeSet = new HashSet<>(); for (GraphicsType graphicsType : GraphicsType.values()) { if (VmDeviceCommonUtils.isVmDeviceExists(vmBase.getManagedDeviceMap(), graphicsType.getCorrespondingDeviceType())) { graphicsTypeSet.add(graphicsType); } } getModel().getGraphicsType().setSelectedItem(UnitVmModel.GraphicsTypes.fromGraphicsTypes(graphicsTypeSet)); activate(); } updateWatchdog(vmBase, true); }
device = new GraphicsDevice(supportedGraphicsType.getCorrespondingDeviceType()); device.setId(new VmDeviceId(Guid.newGuid(), vmBase.getId())); addManagedVmDevice(device);