public GraphicsType getGraphicsType() { return GraphicsType.fromString(getDevice()); }
private List<Pair<GraphicsType, DisplayType>> parseDisplayProtocols(int osId, Version version) { List<Pair<GraphicsType, DisplayType>> graphicsAndDisplays = new ArrayList<>(); String displayAndGraphicsLine = getValueByVersion(idToUnameLookup.get(osId), "devices.display.protocols", version); // todo - use different key? for (String displayAndGraphics : displayAndGraphicsLine.split(",")) { Pair<String, String> pair = parseSlashSeparatedPair(displayAndGraphics); if (pair != null) { GraphicsType graphics = GraphicsType.fromString(pair.getFirst()); DisplayType display = DisplayType.valueOf(pair.getSecond()); graphicsAndDisplays.add(new Pair<>(graphics, display)); } } return graphicsAndDisplays; }
protected void updateGraphics(Guid id) { Frontend.getInstance().runQuery(QueryType.GetGraphicsDevices, new IdQueryParameters(id), new AsyncQuery<QueryReturnValue>(returnValue -> { List<VmDevice> graphicsVmDevs = returnValue.getReturnValue(); List<GraphicsType> graphicsTypes = new ArrayList<>(); for (VmDevice graphicsVmDev : graphicsVmDevs) { graphicsTypes.add(GraphicsType.fromString(graphicsVmDev.getDevice())); } boolean hasSpiceAndVnc = graphicsTypes.size() == 2 && graphicsTypes.containsAll(Arrays.asList(GraphicsType.SPICE, GraphicsType.VNC)); boolean canBeSelected = getModel().getGraphicsType().getItems().contains(UnitVmModel.GraphicsTypes.SPICE_AND_VNC); if (hasSpiceAndVnc && canBeSelected) { getModel().getGraphicsType().setSelectedItem(UnitVmModel.GraphicsTypes.SPICE_AND_VNC); } else if (graphicsVmDevs.size() == 1) { GraphicsType type = GraphicsType.fromString(graphicsVmDevs.get(0).getDevice()); getModel().getGraphicsType().setSelectedItem(UnitVmModel.GraphicsTypes.fromGraphicsType(type)); } })); }
public GraphicsDevice(VmDevice vmDev) { this(GraphicsType.fromString(vmDev.getDevice()).getCorrespondingDeviceType()); setId(vmDev.getId()); setSpecParams(vmDev.getSpecParams()); }