use of org.gephi.ui.tools.plugin.edit.EditWindowUtils.AttributeValueWrapper in project gephi by gephi.
the class EditEdges method prepareEdgesAttributes.
/**
* Prepare set of attributes of the edges.
*
* @return Set of these attributes
*/
private Sheet.Set prepareEdgesAttributes() {
try {
// DynamicModel dm=Lookup.getDefault().lookup(DynamicController.class).getModel();
// if(dm!=null){
// currentTimeFormat=dm.getTimeFormat();
// }
AttributeColumnsController ac = Lookup.getDefault().lookup(AttributeColumnsController.class);
Sheet.Set set = new Sheet.Set();
set.setName("attributes");
if (edges.length > 1) {
set.setDisplayName(NbBundle.getMessage(EditEdges.class, "EditEdges.attributes.text.multiple"));
} else {
set.setDisplayName(NbBundle.getMessage(EditEdges.class, "EditEdges.attributes.text", edges[0].getLabel()));
}
Edge row = edges[0];
AttributeValueWrapper wrap;
for (Column column : row.getAttributeColumns()) {
if (multipleEdges) {
wrap = new MultipleRowsAttributeValueWrapper(edges, column, currentTimeFormat, dateTimeZone);
} else {
wrap = new SingleRowAttributeValueWrapper(edges[0], column, currentTimeFormat, dateTimeZone);
}
Class<?> type = column.getTypeClass();
Property p;
PropertyEditor propEditor = PropertyEditorManager.findEditor(type);
if (ac.canChangeColumnData(column)) {
// Editable column, provide "set" method:
if (propEditor != null && !type.isArray()) {
// The type can be edited by default:
p = new PropertySupport.Reflection(wrap, type, "getValue" + type.getSimpleName(), "setValue" + type.getSimpleName());
} else {
// Use the AttributeType as String:
p = new PropertySupport.Reflection(wrap, String.class, "getValueAsString", "setValueAsString");
}
} else // Not editable column, do not provide "set" method:
{
if (propEditor != null) {
// The type can be edited by default:
p = new PropertySupport.Reflection(wrap, type, "getValue" + type.getSimpleName(), null);
} else {
// Use the AttributeType as String:
p = new PropertySupport.Reflection(wrap, String.class, "getValueAsString", null);
}
}
p.setDisplayName(column.getTitle());
p.setName(column.getId());
set.put(p);
}
return set;
} catch (Exception ex) {
Exceptions.printStackTrace(ex);
return null;
}
}
use of org.gephi.ui.tools.plugin.edit.EditWindowUtils.AttributeValueWrapper in project gephi by gephi.
the class EditNodes method prepareNodesAttributes.
/**
* Prepare set of attributes of the node(s).
*
* @return Set of these attributes
*/
private Sheet.Set prepareNodesAttributes() {
try {
// DynamicModel dm=Lookup.getDefault().lookup(DynamicController.class).getModel();
// if(dm!=null){
// currentTimeFormat=dm.getTimeFormat();
// }
AttributeColumnsController ac = Lookup.getDefault().lookup(AttributeColumnsController.class);
Sheet.Set set = new Sheet.Set();
set.setName("attributes");
if (nodes.length > 1) {
set.setDisplayName(NbBundle.getMessage(EditNodes.class, "EditNodes.attributes.text.multiple"));
} else {
set.setDisplayName(NbBundle.getMessage(EditNodes.class, "EditNodes.attributes.text", nodes[0].getLabel()));
}
Node row = nodes[0];
AttributeValueWrapper wrap;
for (Column column : row.getAttributeColumns()) {
if (multipleNodes) {
wrap = new MultipleRowsAttributeValueWrapper(nodes, column, currentTimeFormat, dateTimeZone);
} else {
wrap = new SingleRowAttributeValueWrapper(nodes[0], column, currentTimeFormat, dateTimeZone);
}
Property p;
Class<?> type = column.getTypeClass();
PropertyEditor propEditor = PropertyEditorManager.findEditor(type);
if (ac.canChangeColumnData(column)) {
// Editable column, provide "set" method:
if (propEditor != null && !type.isArray()) {
// The type can be edited by default:
p = new PropertySupport.Reflection(wrap, type, "getValue" + type.getSimpleName(), "setValue" + type.getSimpleName());
} else {
// Use the AttributeType as String:
p = new PropertySupport.Reflection(wrap, String.class, "getValueAsString", "setValueAsString");
}
} else // Not editable column, do not provide "set" method:
if (propEditor != null) {
// The type can be edited by default:
p = new PropertySupport.Reflection(wrap, type, "getValue" + type.getSimpleName(), null);
} else {
// Use the AttributeType as String:
p = new PropertySupport.Reflection(wrap, String.class, "getValueAsString", null);
}
p.setDisplayName(column.getTitle());
p.setName(column.getId());
set.put(p);
}
return set;
} catch (Exception ex) {
Exceptions.printStackTrace(ex);
return null;
}
}
Aggregations