public Section setSelected(String name) { eventHandler.fireChanged(new Event(this,EVENTS.SECTION_CHANGEING,getSection(name))); Section sel = null; synchronized (sections) { for (Section section : sections) { if (section.getName().equals(name)) { section.setSelected(true); sel = section; } else { section.setSelected(false); } } } eventHandler.fireChanged(new Event(this,EVENTS.SECTION_CHANGED,getSection(name))); return sel; }
public Section setSelected(String name) { eventHandler.fireChanged(new Event(this,EVENTS.SECTION_CHANGEING,getSection(name))); Section sel = null; synchronized (sections) { for (Section section : sections) { if (section.getName().equals(name)) { section.setSelected(true); sel = section; } else { section.setSelected(false); } } } eventHandler.fireChanged(new Event(this,EVENTS.SECTION_CHANGED,getSection(name))); return sel; }
public Section addSection(String name, String title, Object userData) { Section section = getSection(name); if (section != null) { section.setTitle(title); if (userData != null) section.setUserData(userData); eventHandler.fireChanged(new Event(this,EVENTS.UPDATED,section)); } else { section = new Section(name,title); section.setUserData(userData); eventHandler.fireChanged(new Event(this,EVENTS.ADDED,section)); if (autoSelect) { if (sections.size() == 1) { // first one setSelected(name); } } } return section; }
public Section addSection(String name, String title, Object userData) { Section section = getSection(name); if (section != null) { section.setTitle(title); if (userData != null) section.setUserData(userData); eventHandler.fireChanged(new Event(this,EVENTS.UPDATED,section)); } else { section = new Section(name,title); section.setUserData(userData); eventHandler.fireChanged(new Event(this,EVENTS.ADDED,section)); if (autoSelect) { if (sections.size() == 1) { // first one setSelected(name); } } } return section; }
public Section removeSection(String name) { Section sec = getSection(name); if (autoSelect && sec.isSelected()) { synchronized (sections) { for (Section section : sections) { if (section.isEnabled()) { setSelected(section.getName()); break; } } } } synchronized (sections) { if (sec == null) return null; sections.remove(sec); } eventHandler.fireChanged(new Event(this,EVENTS.REMOVED,sec)); return sec; }
public Section removeSection(String name) { Section sec = getSection(name); if (autoSelect && sec.isSelected()) { synchronized (sections) { for (Section section : sections) { if (section.isEnabled()) { setSelected(section.getName()); break; } } } } synchronized (sections) { if (sec == null) return null; sections.remove(sec); } eventHandler.fireChanged(new Event(this,EVENTS.REMOVED,sec)); return sec; }