/** * Check if a specific attribute is set. * * @param name the name of the attribute * @return {@code true} in case a attribute with the supplied name exists */ public boolean isSet(@Nonnull final String name) { return get(name) != null; }
@Nullable private String getExtendsAttribute(@Nonnull final Attributes attributes) { return attributes.get("extends"); } }
@Nullable public String get(@Nonnull final String key) { return attributes.get(key); }
@Nonnull private String getNameAttribute(@Nonnull final Attributes attributes) throws Exception { String name = attributes.get("name"); if (name == null) { throw new Exception("[name] attribute is a required attribute"); } return name; }
@Nonnull public String getWithDefault(@Nonnull final String name, @Nonnull final String defaultValue) { String value = get(name); if (value == null) { value = defaultValue; } return value; }
/** * popup. * * @param popup popup */ public void registerPopup(@Nonnull final PopupType popup) { popupTypes.put(popup.getAttributes().get("id"), popup); }
@Nullable private String getFilename() { return getAttributes().get("filename"); } }
@Nullable private String getFilename() { return getAttributes().get("filename"); } }
@Nullable private String getFilename() { return getAttributes().get("filename"); } }
@Nullable private String getClassName() { return getAttributes().get("class"); } }
@Nullable private String getFilename() { return getAttributes().get("filename"); } }
@Nullable public Color getAsColor(@Nonnull final String name) { String value = get(name); if (value == null) { return null; } return new Color(value); }
public void loadStyle( @Nonnull final NiftyLoader niftyLoader, @Nonnull final NiftyType niftyType, @Nonnull final Nifty nifty) throws Exception { final String filename = getAttributes().get("filename"); if (filename == null) { log.log(Level.SEVERE, "Missing filename attribute for style!"); } else { niftyLoader.loadStyleFile("nifty-styles.nxs", filename, niftyType, nifty); } } }
public void loadControl(@Nonnull final NiftyLoader niftyLoader, @Nonnull final NiftyType niftyType) throws Exception { final String filename = getAttributes().get("filename"); if (filename == null) { log.severe("Missing filename attribute for control"); } else { niftyLoader.loadControlFile("nifty-controls.nxs", filename, niftyType); } } }
@Nullable private OnClickType getOnClickType(@Nonnull final String key) { String onClick = getAttributes().get(key); if (onClick == null) { return null; } return new OnClickType(onClick); }
@Override void makeFlatControlsInternal() { if (!elements.isEmpty()) { mergeFromElementType(elements.get(0)); } String id = getAttributes().get("id"); resolveIds(this, id, id); }
void resolveControllers(@Nonnull final Nifty nifty, @Nonnull final Collection<Object> controllerParam) { controllers = new LinkedList<Object>(controllerParam); if(controller == null) { controller = nifty.getControllerFactory().create(getAttributes().get("controller")); } if (controller != null) { controllers.addFirst(controller); } for (ElementType elementType : elements) { elementType.resolveControllers(nifty, controllers); } }
private void applyIdPrefixToElementType(@Nonnull final String prefix, @Nonnull final ElementType type) { type.getAttributes().set("id", prefix + type.getAttributes().get("id")); for (final ElementType child : type.getElements()) { applyIdPrefixToElementType(prefix, child); } }
private void applyIdPrefixToElementType(@Nonnull final String prefix, @Nonnull final ElementType type) { type.getAttributes().set("id", prefix + type.getAttributes().get("id")); for (final ElementType child : type.getElements()) { applyIdPrefixToElementType(prefix, child); } }