/** Returns an internally generated id associated with this object, that is unique among all network elements of * all types in this network * @return see above */ public long getId () { return e.getId(); }
public static NetworkElementType getType(List<? extends NetworkElement> networkElements) { NetworkElementType res = null, aux = null; for (NetworkElement networkElement : networkElements) { aux = networkElement.getNeType(); if (res == null) res = aux; if (res != aux) return null; } return res; }
/** Returns the underlying net2plan object that is giving support for this network. * Regular users should NOT access the underlying NetPlan objtec in any form. This method is just provided for debugging * for those users who really know what they are doing * @return see above */ public NetPlan getNetPlan () { return e.getNetPlan(); }
if (!this.isForwardingRulesTable()) completeListIncludingCommonColumns.add(new AjtColumnInfo<T>(this, Long.class, null, "Id", "Unique identifier (never repeated in any other network element)", null , e->((NetworkElement)e).getId() , AGTYPE.NOAGGREGATION , null)); completeListIncludingCommonColumns.add(new AjtColumnInfo<T>(this, Integer.class, null , "Index", "Index (consecutive integer starting in zero)", null , e->((NetworkElement)e).getIndex () , AGTYPE.NOAGGREGATION , null)); completeListIncludingCommonColumns.add(new AjtColumnInfo<T>(this, String.class, null , "Tags", "User-defined tags associated to this element", null , e->((NetworkElement)e).getTags() , AGTYPE.NOAGGREGATION , null)); completeListIncludingCommonColumns.add(new AjtColumnInfo<T>(this, String.class, null , "Attributes", "User-defined attributes associated to this element", null , e->((NetworkElement)e).getAttributes() , AGTYPE.NOAGGREGATION , null)); else this.getAllAbstractElementsInTable().forEach(e->allAttributeKeys.addAll(((NetworkElement)e).getAttributes().keySet())); for (String attributeKey : allAttributeKeys) if (!value.isEmpty()) ((NetworkElement)e).setAttribute(attributeKey, value); }, e->((NetworkElement)e).getAttribute(attributeKey, "") , AGTYPE.NOAGGREGATION , null));
/** * Constructor that allows to show a selection of items. * * @param callback Reference to the handler of the network design * @param selection List of the selected elements. */ public AttributeEditor(final GUINetworkDesign callback, ElementSelection selection) { this(callback, selection.getElementType()); final List<? extends NetworkElement> networkElements = selection.getNetworkElements(); final TableColumnHider hider = new TableColumnHider(table); final List<String> shownColumns = new ArrayList<>(); shownColumns.add("Attribute"); for (NetworkElement networkElement : networkElements) { final NetworkElementType type = networkElement.getNeType(); if (type != null) shownColumns.add(generateColumnName(type, networkElement.getId())); } final List<String> toHideColumns = new ArrayList<>(); for (int i = 0; i < table.getColumnCount(); i++) { String columnName = table.getColumnName(i); if (!shownColumns.contains(columnName)) toHideColumns.add(columnName); } for (String toRemoveColumn : toHideColumns) hider.hide(toRemoveColumn); }
if (netPlan.getNetworkElement(networkElement.getId()) == null) np = networkElement.getNetPlan(); } else if (o instanceof Pair)
public NetworkLayer getOrEstimateLayer () { if (ne == null && fr == null) return null; if (isFr()) return fr.getFirst().getLayer(); switch (ne.getNeType()) { case DEMAND: return ((Demand) ne).getLayer(); case LAYER: return (NetworkLayer) ne; case LINK: return ((Link) ne).getLayer(); case MULTICAST_DEMAND: return ((MulticastDemand) ne).getLayer(); case MULTICAST_TREE: return ((MulticastTree) ne).getLayer(); case NETWORK: return ((NetPlan) ne).getNetworkLayerDefault(); case NODE: return ne.getNetPlan().getNetworkLayerDefault(); case RESOURCE: return ne.getNetPlan().getNetworkLayerDefault(); case ROUTE: return ((Route) ne).getLayer(); case SRG: return ne.getNetPlan().getNetworkLayerDefault(); default: throw new Net2PlanException (); } } }
if (e.wasRemoved()) continue; switch (e.getNeType())
updateElement.addTag(xmlStreamReader.getAttributeValue(xmlStreamReader.getAttributeIndex(null, "value"))); break; String key = xmlStreamReader.getAttributeValue(xmlStreamReader.getAttributeIndex(null, "key")); String name = xmlStreamReader.getAttributeValue(xmlStreamReader.getAttributeIndex(null, "value")); if (updateElement != null) updateElement.setAttribute(key, name); break;
private AjtRcMenu getMenuTags () getSelectedNetworkElementsNorFr().forEach(e->allTags.addAll(e.getTags())); final List<String> allTagsList = allTags.stream().collect(Collectors.toList()); return new AjtRcMenu("Tags...", null , (a,b)->true, Arrays.asList( if(tag.isEmpty()) return; for (NetworkElement ne : getSelectedNetworkElementsNorFr()) ne.addTag(tag); }); }, (a,b)->b>0, null), ne.removeTag((String) list.get(0).get()); }); }, (a,b)->b>0 && getSelectedNetworkElementsNorFr().stream().anyMatch(e->e.getTags().size()>0), null) , ne.getTags().forEach(t->ne.removeTag(t)); }, (a,b)->b>0 && getSelectedNetworkElementsNorFr().stream().anyMatch(e->e.getTags().size()>0), null) ));
private AjtRcMenu getMenuAttributes () getSelectedNetworkElementsNorFr().forEach(e->allAttributes.addAll(e.getAttributes().keySet())); final List<String> allAttributesList = allAttributes.stream().collect(Collectors.toList()); if(key.isEmpty() || value.isEmpty()) return; for (NetworkElement ne : getSelectedNetworkElementsNorFr()) ne.setAttribute(key, value); }); }, (a,b)->b>0, null) , InputForDialog.inputTfCombo("Attribute name to edit", "The attribute to be edited from selected element", 10, getSelectedNetworkElementsNorFr().iterator().next().getAttributes().keySet().stream().collect(Collectors.toList()).get(0), getSelectedNetworkElementsNorFr().iterator().next().getAttributes().keySet().stream().collect(Collectors.toList()) , getSelectedNetworkElementsNorFr().iterator().next().getAttributes().keySet().stream().collect(Collectors.toList()) , null), InputForDialog.inputTfString("New attribute value", "The attribute value to be changed in selected element", 10, "")), (list)-> if(key.isEmpty() || value.isEmpty()) return; for (NetworkElement ne : getSelectedNetworkElementsNorFr()) ne.setAttribute(key, value); }); }, (a,b)->b==1 && !getSelectedNetworkElementsNorFr().first().getAttributes().isEmpty(), null) , ne.removeAttribute((String) list.get(0).get()); }); }, (a,b)->b>0 && getSelectedNetworkElementsNorFr().stream().anyMatch(e->e.getAttributes().size()>0), null) , ne.getAttributes().keySet().forEach(a->ne.removeAttribute(a)); }, (a,b)->b>0 && getSelectedNetworkElementsNorFr().stream().anyMatch(e->e.getAttributes().size()>0), null) , expandCollapseAttributesOption));
/** Returns the value of a user-defined attributes * @param name the name of the attribute * @param defaultValue if no attribute with this name exists, returns this default value * @return see above */ protected String getAttributeOrDefault (String name , String defaultValue) { return e.getAttribute(name, defaultValue); }
/** * Returns the value of a given attribute for this network element, or null if not found. * @param key Attribute name * @return Attribute value (or {@code null}, if not defined) */ public String getAttribute(String key) { checkAttachedToNetPlanObject(); return attributes.get(key); }
/** Returns true if this element was removed from the network * @return see above */ public boolean wasRemoved () { return e.wasRemoved(); }
protected void setAttributeAsBoolean (String name , Boolean value) { e.setAttribute(name, value.toString()); }
updateElement.addTag(xmlStreamReader.getAttributeValue(xmlStreamReader.getAttributeIndex(null, "value"))); break; String key = xmlStreamReader.getAttributeValue(xmlStreamReader.getAttributeIndex(null, "key")); String name = xmlStreamReader.getAttributeValue(xmlStreamReader.getAttributeIndex(null, "value")); if (updateElement != null) updateElement.setAttribute(key, name); break;
private static int [] getIndexes (Collection<? extends NetworkElement> col) { final int [] res = new int [col.size ()]; int cont = 0; for (NetworkElement el : col) res [cont++] = el.getIndex (); return res; }
/** Returns the value associated to a user-defined attribute, as a boolean, or a default is the attribute does not exist, * or cannot be parsed to a boolen * @param name the name of the attribute * @param defaultValue see above * @return see above */ protected boolean getAttributeAsBooleanOrDefault (String name , Boolean defaultValue) { final String s = e.getAttribute(name); if (s == null) return defaultValue; try { return Boolean.parseBoolean (s); } catch (Exception ee) { return defaultValue; } }