use of org.cytoscape.view.vizmap.gui.internal.view.VisualPropertySheetItem.MessageType in project cytoscape-impl by cytoscape.
the class VizMapperMediator method updateItemsStatus.
private void updateItemsStatus() {
// Children of enabled dependencies must be disabled
final Set<VisualProperty<?>> disabled = new HashSet<>();
final Map<VisualProperty<?>, String> messages = new HashMap<>();
final VisualStyle style = vmProxy.getCurrentVisualStyle();
final String infoMsgTemplate = "<html>To enable this visual property,<br><b>%s</b> the dependency <i><b>%s</b></i></html>";
for (final VisualPropertyDependency<?> dep : style.getAllVisualPropertyDependencies()) {
final VisualProperty<?> parent = dep.getParentVisualProperty();
final Set<VisualProperty<?>> properties = dep.getVisualProperties();
if (dep.isDependencyEnabled()) {
disabled.addAll(properties);
for (final VisualProperty<?> vp : properties) messages.put(vp, String.format(infoMsgTemplate, "uncheck", dep.getDisplayName()));
} else {
disabled.add(parent);
messages.put(parent, String.format(infoMsgTemplate, "check", dep.getDisplayName()));
}
}
for (final VisualPropertySheet vpSheet : vizMapperMainPanel.getVisualPropertySheets()) {
final Set<VisualPropertySheetItem<?>> vpSheetItems = vpSheet.getItems();
for (final VisualPropertySheetItem<?> item : vpSheetItems) {
// First check if this property item must be disabled and show an INFO message
String msg = null;
MessageType msgType = null;
if (msgType == null && item.getModel().getVisualPropertyDependency() == null) {
item.setEnabled(!disabled.contains(item.getModel().getVisualProperty()));
msg = messages.get(item.getModel().getVisualProperty());
msgType = item.isEnabled() ? null : MessageType.INFO;
}
item.setMessage(msg, msgType);
// If item is enabled, check whether or not the mapping is valid for the current network
updateMappingStatus(item);
}
}
}
use of org.cytoscape.view.vizmap.gui.internal.view.VisualPropertySheetItem.MessageType in project cytoscape-impl by cytoscape.
the class VizMapperMediator method updateMappingStatus.
private void updateMappingStatus(final VisualPropertySheetItem<?> item) {
if (!item.isEnabled())
return;
final CyNetwork net = vmProxy.getCurrentNetwork();
final Class<? extends CyIdentifiable> targetDataType = item.getModel().getTargetDataType();
if (net != null && targetDataType != CyNetwork.class) {
final CyTable netTable = targetDataType == CyNode.class ? net.getDefaultNodeTable() : net.getDefaultEdgeTable();
String msg = null;
MessageType msgType = null;
if (netTable != null) {
final VizMapperProperty<VisualProperty<?>, String, VisualMappingFunctionFactory> columnProp = vizMapPropertyBuilder.getColumnProperty(item.getPropSheetPnl());
final String colName = (columnProp != null && columnProp.getValue() != null) ? columnProp.getValue().toString() : null;
if (colName != null) {
final VisualMappingFunction<?, ?> mapping = item.getModel().getVisualMappingFunction();
Class<?> mapColType = mapping != null ? mapping.getMappingColumnType() : null;
final CyColumn column = netTable.getColumn(colName);
Class<?> colType = column != null ? column.getType() : null;
// Ignore "List" type
if (mapColType == List.class)
mapColType = String.class;
if (colType == List.class)
colType = String.class;
if (column == null || (mapColType != null && !mapColType.isAssignableFrom(colType))) {
String tableName = netTable != null ? targetDataType.getSimpleName().replace("Cy", "") : null;
msg = "<html>Visual Mapping cannot be applied to current network:<br>" + tableName + " table does not have column <b>\"" + colName + "\"</b>" + (mapColType != null ? " (" + mapColType.getSimpleName() + ")" : "") + "</html>";
msgType = MessageType.WARNING;
}
}
}
final String finalMsg = msg;
final MessageType finalMsgType = msgType;
invokeOnEDT(() -> item.setMessage(finalMsg, finalMsgType));
}
}
Aggregations