List of usage examples for com.vaadin.server VaadinSession getCurrent
public static VaadinSession getCurrent()
From source file:com.skysql.manager.ui.CalendarDialog.java
License:Open Source License
/** * Inits the content.//w w w . j a va2s . c om */ public void initContent() { OverviewPanel overviewPanel = VaadinSession.getCurrent().getAttribute(OverviewPanel.class); nodes = overviewPanel.getNodes(); if (nodes == null || nodes.isEmpty()) { SystemInfo systemInfo = VaadinSession.getCurrent().getAttribute(SystemInfo.class); String systemID = systemInfo.getCurrentID(); String systemType = systemInfo.getCurrentSystem().getSystemType(); if (systemID.equals(SystemInfo.SYSTEM_ROOT)) { ClusterComponent clusterComponent = VaadinSession.getCurrent().getAttribute(ClusterComponent.class); systemID = clusterComponent.getID(); systemType = clusterComponent.getSystemType(); } nodes = new ArrayList<NodeInfo>(); for (String nodeID : systemInfo.getSystemRecord(systemID).getNodes()) { NodeInfo nodeInfo = new NodeInfo(systemID, systemType, nodeID); nodes.add(nodeInfo); } } // Set default Locale for this application setLocale(Locale.getDefault()); // Initialize locale, timezone and timeformat selects. //localeSelect = createLocaleSelect(); timeZoneSelect = createTimeZoneSelect(); //formatSelect = createCalendarFormatSelect(); initCalendar(); initLayoutContent(); addInitialEvents(); }
From source file:com.skysql.manager.ui.CalendarDialog.java
License:Open Source License
/** * Adds/updates the event in the data source and fires change event. *///w w w .j a va 2 s .com private void commitCalendarEvent() { scheduleEventForm.commit(); CalendarCustomEvent event = (CalendarCustomEvent) getFormCalendarEvent(); VEvent vEvent = iCalSupport.createVEvent(event); ManagerUI.log("" + vEvent); String scheduleID = (String) event.getData(); ScheduleRecord scheduleRecord; if (scheduleID == null) { ClusterComponent systemRecord = VaadinSession.getCurrent().getAttribute(ClusterComponent.class); UserObject userObject = VaadinSession.getCurrent().getAttribute(UserObject.class); Map<String, String> params = new HashMap<String, String>(); params.put(ParametersLayout.PARAM_BACKUP_TYPE, BackupRecord.BACKUP_TYPE_FULL); Schedule schedule = new Schedule(systemRecord.getID(), event.getNode(), userObject.getUserID(), "backup", params, null, vEvent.toString()); scheduleRecord = schedule.getScheduleList().entrySet().iterator().next().getValue(); scheduleID = scheduleRecord.getID(); event.setData(scheduleID); // Generate a UID for the event.. UidGenerator ug; try { ug = new UidGenerator(scheduleID); Uid uid = ug.generateUid(); // override 'proper' UID with just scheduleID for now uid.setValue(scheduleID); vEvent.getProperties().add(uid); } catch (SocketException e) { ManagerUI.error(e.getMessage()); } } else { scheduleRecord = schedule.getScheduleList().get(scheduleID); scheduleRecord.setICal(vEvent.toString()); Schedule.update(scheduleID, vEvent.toString()); ArrayList<CalendarCustomEvent> eventsList = eventsMap.remove(scheduleID); for (CalendarCustomEvent removeEvent : eventsList) { if (dataSource.containsEvent(removeEvent)) { dataSource.removeEvent(removeEvent); } } } schedule.getScheduleList().put(scheduleID, scheduleRecord); addEventsToMap(scheduleID, vEvent, event.getNode()); ArrayList<CalendarCustomEvent> eventsList = eventsMap.get(scheduleID); for (CalendarCustomEvent addEvent : eventsList) { if (!dataSource.containsEvent(addEvent)) { dataSource.addEvent(addEvent); } } UI.getCurrent().removeWindow(scheduleEventPopup); }
From source file:com.skysql.manager.ui.ChartsDialog.java
License:Open Source License
/** * New user chart.// w w w. j ava2 s. c om * * @return the user chart */ public UserChart newUserChart() { ClusterComponent clusterComponent = VaadinSession.getCurrent().getAttribute(ClusterComponent.class); MonitorRecord monitor = (MonitorRecord) Monitors.getMonitorsList(clusterComponent.getSystemType()).values() .toArray()[0]; ArrayList<String> monitorsForChart = new ArrayList<String>(); monitorsForChart.add(monitor.getID()); String chartType = monitor.getChartType(); if (chartType == null) { chartType = UserChart.DEFAULT_CHARTTYPE.name(); } UserChart userChart = new UserChart(monitor.getName(), monitor.getDescription(), monitor.getUnit(), chartType, UserChart.COUNT_15, monitorsForChart); return (userChart); }
From source file:com.skysql.manager.ui.components.BackupScheduledLayout.java
License:Open Source License
/** * Gets the schedule.//from w w w . j a va2s . com * * @return the schedule */ private Schedule getSchedule() { SystemInfo systemInfo = VaadinSession.getCurrent().getAttribute(SystemInfo.class); String systemID = systemInfo.getCurrentID(); if (SystemInfo.SYSTEM_ROOT.equals(systemID)) { ClusterComponent clusterComponent = VaadinSession.getCurrent().getAttribute(ClusterComponent.class); systemID = clusterComponent.getID(); } return new Schedule(systemID, null); }
From source file:com.skysql.manager.ui.components.BackupScheduledLayout.java
License:Open Source License
/** * Asynch refresh./* w ww. j av a 2 s.co m*/ * * @param updaterThread the updater thread */ private void asynchRefresh(final UpdaterThread updaterThread) { ManagerUI managerUI = getSession().getAttribute(ManagerUI.class); schedule = getSchedule(); final LinkedHashMap<String, ScheduleRecord> scheduleList = schedule.getScheduleList(); managerUI.access(new Runnable() { @Override public void run() { // Here the UI is locked and can be updated ManagerUI.log(this.getClass().getName() + " access run(): "); SystemInfo systemInfo = VaadinSession.getCurrent().getAttribute(SystemInfo.class); String systemID = systemInfo.getCurrentID(); if (systemID.equals(SystemInfo.SYSTEM_ROOT)) { ClusterComponent clusterComponent = VaadinSession.getCurrent() .getAttribute(ClusterComponent.class); systemID = clusterComponent.getID(); } SystemRecord systemRecord = systemInfo.getSystemRecord(systemID); if (systemRecord.getNodes().length == 0) { calendarButton.setEnabled(false); calendarButton.setDescription( "There are no nodes in this system: no backups scheduling is possible."); } else { calendarButton.setEnabled(true); calendarButton.setDescription(null); } scheduledTable.removeAllItems(); if (scheduleList != null) { DateConversion dateConversion = getSession().getAttribute(DateConversion.class); TreeMap<String, String> eventsTree = collectEvents(); int i = 0; for (Map.Entry<String, String> entry : eventsTree.entrySet()) { String key = entry.getKey(); String myDate = null; try { Date start = new DateTime(key); SimpleDateFormat sdfInput = new SimpleDateFormat("E, d MMM y HH:mm:ss Z"); // Mon, 02 Sep 2013 13:08:14 +0000 myDate = sdfInput.format(start); } catch (ParseException e) { ManagerUI.error(e.getMessage()); } ScheduleRecord scheduleRecord = scheduleList.get(entry.getValue()); scheduledTable .addItem(new Object[] { dateConversion.adjust(myDate), scheduleRecord.getNodeID(), scheduleRecord.getParams(), scheduleRecord.getUserID() }, i++); } } } }); }
From source file:com.skysql.manager.ui.components.BackupSetsLayout.java
License:Open Source License
/** * Asynch refresh.//from w w w . j a va 2 s . c om * * @param updaterThread the updater thread */ private void asynchRefresh(final UpdaterThread updaterThread) { ManagerUI managerUI = getSession().getAttribute(ManagerUI.class); SystemInfo systemInfo = VaadinSession.getCurrent().getAttribute(SystemInfo.class); /*** LinkedHashMap<String, String> sysProperties = systemInfo.getCurrentSystem().getProperties(); final String EIP = sysProperties.get(SystemInfo.PROPERTY_EIP); ***/ String systemID = systemInfo.getCurrentID(); if (SystemInfo.SYSTEM_ROOT.equals(systemID)) { ClusterComponent clusterComponent = VaadinSession.getCurrent().getAttribute(ClusterComponent.class); systemID = clusterComponent.getID(); } Backups backups = new Backups(systemID, null); final LinkedHashMap<String, BackupRecord> backupsList = backups.getBackupsList(); managerUI.access(new Runnable() { @Override public void run() { // Here the UI is locked and can be updated ManagerUI.log(this.getClass().getName() + " access run(): "); DateConversion dateConversion = getSession().getAttribute(DateConversion.class); boolean adjust = dateConversion.isAdjustedToLocal(); String format = dateConversion.getFormat(); if (backupsList != null) { int size = backupsList.size(); if (oldBackupsCount != size || adjust != updaterThread.adjust || !format.equals(updaterThread.format)) { oldBackupsCount = size; updaterThread.adjust = adjust; updaterThread.format = format; backupsTable.removeAllItems(); ListIterator<Map.Entry<String, BackupRecord>> iter = new ArrayList<Entry<String, BackupRecord>>( backupsList.entrySet()).listIterator(0); while (iter.hasNext()) { if (updaterThread.flagged) { ManagerUI.log("PanelBackup - flagged is set during table population"); return; } Map.Entry<String, BackupRecord> entry = iter.next(); BackupRecord backupRecord = entry.getValue(); Link backupLogLink = null; /** if (EIP != null) { String url = "http://" + EIP + "/consoleAPI/" + backupRecord.getLog(); backupLogLink = new Link("Backup Log", new ExternalResource(url)); backupLogLink.setTargetName("_blank"); backupLogLink.setDescription("Open backup log in a new window"); backupLogLink.setIcon(new ThemeResource("img/externalLink.png")); backupLogLink.addStyleName("icon-after-caption"); } ***/ backupsTable.addItem(new Object[] { backupRecord.getID(), dateConversion.adjust(backupRecord.getStarted()), dateConversion.adjust(backupRecord.getCompleted()), dateConversion.adjust(backupRecord.getRestored()), backupRecord.getLevelAsString(), backupRecord.getParent(), backupRecord.getNode(), backupRecord.getSize(), backupRecord.getStorage(), BackupStates.getDescriptions().get(backupRecord.getState()), backupLogLink }, backupRecord.getID()); } } } else { backupsTable.removeAllItems(); } } }); }
From source file:com.skysql.manager.ui.components.BackupStrategiesLayout.java
License:Open Source License
/** * Asynch refresh.//w ww . j ava 2 s.co m * * @param updaterThread the updater thread */ private void asynchRefresh(final UpdaterThread updaterThread) { ManagerUI managerUI = getSession().getAttribute(ManagerUI.class); SystemInfo systemInfo = getSession().getAttribute(SystemInfo.class); String systemID = systemInfo.getCurrentID(); if (SystemInfo.SYSTEM_ROOT.equals(systemID)) { ClusterComponent clusterComponent = VaadinSession.getCurrent().getAttribute(ClusterComponent.class); systemID = clusterComponent.getID(); } managerUI.access(new Runnable() { @Override public void run() { // Here the UI is locked and can be updated ManagerUI.log(this.getClass().getName() + " access.run(): "); } }); }
From source file:com.skysql.manager.ui.components.ChartsLayout.java
License:Open Source License
/** * Sets the editable./*from w w w . j a v a 2 s .co m*/ * * @param editable the new editable */ public void setEditable(boolean editable) { isChartsEditing = editable; VaadinSession.getCurrent().setAttribute("isChartsEditing", isChartsEditing); Iterator<Component> iter = iterator(); while (iter.hasNext()) { ChartButton chartButton = (ChartButton) iter.next(); chartButton.setEditable(editable); } // when getting out of editable mode, save mappings if (editable == false) { saveChartsToProperties(); } }
From source file:com.skysql.manager.ui.components.ChartsLayout.java
License:Open Source License
/** * Refresh./*from ww w . j av a 2s . c om*/ * * @param time the time * @param interval the interval */ public void refresh(String time, String interval) { this.time = time; this.interval = interval; // if (isChartsEditing) { // return; // } VaadinSession session = getSession(); if (session == null) { session = VaadinSession.getCurrent(); } boolean isChartsEditing2 = (Boolean) session.getAttribute("isChartsEditing"); if (isChartsEditing2) { return; } ManagerUI.log("ChartsLayout refresh()"); Iterator<Component> iter = iterator(); while (iter.hasNext()) { Component component = iter.next(); if (component instanceof ChartButton) { ChartButton chartButton = (ChartButton) component; UpdaterThread updaterThread = new UpdaterThread(chartButton); updaterThread.start(); } } }
From source file:com.skysql.manager.ui.components.ChartsLayout.java
License:Open Source License
/** * Asynch refresh./* w w w .j a v a 2 s. c o m*/ * * @param updaterThread the updater thread */ private void asynchRefresh(UpdaterThread updaterThread) { VaadinSession.getCurrent().setAttribute("ChartsRefresh", true); refreshCode(updaterThread.chartButton, updaterThread); VaadinSession.getCurrent().setAttribute("ChartsRefresh", false); }