private ArchivePanel getArchivePanel(Device device) { ArchivePanel panel = archivePanels.get(device.getId()); if (panel == null) { panel = new ArchivePanel(archiveHandler); archivePanels.put(device.getId(), panel); devicesTabs.add(panel.getContentPanel(), new TabItemConfig(device.getName(), true)); } return panel; }
@UiHandler("clearButton") public void onClearClicked(SelectEvent event) { for (Map.Entry<Long, ArchivePanel> entry : archivePanels.entrySet()) { Device device = deviceStore.findModelWithKey(entry.getKey().toString()); archiveHandler.onClear(device); devicesTabs.remove(entry.getValue().getContentPanel()); } archivePanels.clear(); }
@UiHandler("devicesTabs") public void onDeviceTabClosed(CloseEvent<Widget> event) { for (Map.Entry<Long, ArchivePanel> entry : archivePanels.entrySet()) { if (entry.getValue().getContentPanel().equals(event.getItem())) { Device device = deviceStore.findModelWithKey(entry.getKey().toString()); archiveHandler.onClear(device); archivePanels.remove(entry.getKey()); break; } } }
@Override public void onUpdate(StoreUpdateEvent<Device> event) { super.onUpdate(event); if (event.getItems() != null) { for (Device device : event.getItems()) { ArchivePanel panel = archivePanels.get(device.getId()); if (panel != null) { TabItemConfig config = devicesTabs.getConfig(panel.getContentPanel()); config.setText(device.getName()); devicesTabs.update(panel.getContentPanel(), config); } } } }