public void plug(Place where, Pluggable what) { if (!has(where)) throw new IllegalStateException("Layout " + id + " has no place " + where); // if it is the same place and the same pluggable there, just refresh it // else, put a new pluggable in corresponding outlet if (plugged.containsKey(where) && plugged.get(where).id().equals(what.id())) { plugged.get(where).refresh(); // just refresh, nothing else } else { final IsOutlet outlet = outlet(where); if (!outlet.isVisible()) Log.warn( "Outlet at place " + where + " is not visible, but you are plugging " + what + " there"); outlet.clear(); outlet.add(what.asWidget()); what.asWidget().addStyleName(generatePlugCSSClassName(what)); plugged.put(where, what); Log.debug("Plugged " + what.id() + " into outlet at place " + where); what.setPlace(where); what.refresh(); } }
protected static String generatePlugCSSClassName(Pluggable plug) { return "plug plug-" + StringUtils.toCSS(plug.id()); }