List of usage examples for com.vaadin.ui Alignment MIDDLE_CENTER
Alignment MIDDLE_CENTER
To view the source code for com.vaadin.ui Alignment MIDDLE_CENTER.
Click Source Link
From source file:com.skysql.manager.ui.components.ScriptingProgressLayout.java
License:Open Source License
/** * Builds the progress./*from ww w. j a v a 2 s .c om*/ * * @param taskRecord the task record * @param command the command * @param steps the steps */ public void buildProgress(TaskRecord taskRecord, String command, String steps) { VaadinSession session = getSession(); if (session == null) { session = VaadinSession.getCurrent(); } if (observerMode) { // String userName = Users.getUserNames().get(taskRecord.getUser()); String userID = taskRecord.getUserID(); UserInfo userInfo = (UserInfo) session.getAttribute(UserInfo.class); DateConversion dateConversion = session.getAttribute(DateConversion.class); setTitle(command + " was started on " + dateConversion.adjust(taskRecord.getStart()) + " by " + userID); } else { setTitle(command); } String[] stepIDs; try { stepIDs = steps.split(","); } catch (NullPointerException npe) { stepIDs = new String[] {}; } totalSteps = stepIDs.length; primitives = new String[totalSteps]; taskImages = new Embedded[totalSteps]; // add steps icons progressIconsLayout.removeAllComponents(); for (int index = 0; index < totalSteps; index++) { String stepID = stepIDs[index].trim(); String description = Steps.getDescription(stepID); VerticalLayout stepLayout = new VerticalLayout(); progressIconsLayout.addComponent(stepLayout); stepLayout.addStyleName("stepIcons"); Label name = new Label(stepID); stepLayout.addComponent(name); stepLayout.setComponentAlignment(name, Alignment.MIDDLE_CENTER); Embedded image = new Embedded(null, new ThemeResource("img/scripting/pending.png")); image.setImmediate(true); image.setDescription(description); stepLayout.addComponent(image); primitives[index] = stepID; taskImages[index] = image; } setProgress(""); }
From source file:com.skysql.manager.ui.GeneralSettings.java
License:Open Source License
/** * Time layout.//from w w w . ja v a2 s . co m * * @return the vertical layout */ private VerticalLayout timeLayout() { VerticalLayout layout = new VerticalLayout(); layout.setWidth("100%"); layout.setSpacing(true); layout.setMargin(new MarginInfo(false, true, false, true)); HorizontalLayout titleLayout = new HorizontalLayout(); titleLayout.setSpacing(true); layout.addComponent(titleLayout); final Label title = new Label("<h3>Date & Time Presentation</h3>", ContentMode.HTML); title.setSizeUndefined(); titleLayout.addComponent(title); Embedded info = new Embedded(null, new ThemeResource("img/info.png")); info.addStyleName("infoButton"); info.setDescription( "Determines if date & time stamps are displayed in the originally recorded format or adjusted to the local timezone.<br/>The format can be customized by using the following Java 6 SimpleDateFormat patterns:" + "</blockquote>" + " <table border=0 cellspacing=3 cellpadding=0 summary=\"Chart shows pattern letters, date/time component, presentation, and examples.\">\n" + " <tr bgcolor=\"#ccccff\">\n" + " <th align=left>Letter\n" + " <th align=left>Date or Time Component\n" + " <th align=left>Presentation\n" + " <th align=left>Examples\n" + " <tr>\n" + " <td><code>G</code>\n" + " <td>Era designator\n" + " <td><a href=\"#text\">Text</a>\n" + " <td><code>AD</code>\n" + " <tr bgcolor=\"#eeeeff\">\n" + " <td><code>y</code>\n" + " <td>Year\n" + " <td><a href=\"#year\">Year</a>\n" + " <td><code>1996</code>; <code>96</code>\n" + " <tr>\n" + " <td><code>M</code>\n" + " <td>Month in year\n" + " <td><a href=\"#month\">Month</a>\n" + " <td><code>July</code>; <code>Jul</code>; <code>07</code>\n" + " <tr bgcolor=\"#eeeeff\">\n" + " <td><code>w</code>\n" + " <td>Week in year\n" + " <td><a href=\"#number\">Number</a>\n" + " <td><code>27</code>\n" + " <tr>\n" + " <td><code>W</code>\n" + " <td>Week in month\n" + " <td><a href=\"#number\">Number</a>\n" + " <td><code>2</code>\n" + " <tr bgcolor=\"#eeeeff\">\n" + " <td><code>D</code>\n" + " <td>Day in year\n" + " <td><a href=\"#number\">Number</a>\n" + " <td><code>189</code>\n" + " <tr>\n" + " <td><code>d</code>\n" + " <td>Day in month\n" + " <td><a href=\"#number\">Number</a>\n" + " <td><code>10</code>\n" + " <tr bgcolor=\"#eeeeff\">\n" + " <td><code>F</code>\n" + " <td>Day of week in month\n" + " <td><a href=\"#number\">Number</a>\n" + " <td><code>2</code>\n" + " <tr>\n" + " <td><code>E</code>\n" + " <td>Day in week\n" + " <td><a href=\"#text\">Text</a>\n" + " <td><code>Tuesday</code>; <code>Tue</code>\n" + " <tr bgcolor=\"#eeeeff\">\n" + " <td><code>a</code>\n" + " <td>Am/pm marker\n" + " <td><a href=\"#text\">Text</a>\n" + " <td><code>PM</code>\n" + " <tr>\n" + " <td><code>H</code>\n" + " <td>Hour in day (0-23)\n" + " <td><a href=\"#number\">Number</a>\n" + " <td><code>0</code>\n" + " <tr bgcolor=\"#eeeeff\">\n" + " <td><code>k</code>\n" + " <td>Hour in day (1-24)\n" + " <td><a href=\"#number\">Number</a>\n" + " <td><code>24</code>\n" + " <tr>\n" + " <td><code>K</code>\n" + " <td>Hour in am/pm (0-11)\n" + " <td><a href=\"#number\">Number</a>\n" + " <td><code>0</code>\n" + " <tr bgcolor=\"#eeeeff\">\n" + " <td><code>h</code>\n" + " <td>Hour in am/pm (1-12)\n" + " <td><a href=\"#number\">Number</a>\n" + " <td><code>12</code>\n" + " <tr>\n" + " <td><code>m</code>\n" + " <td>Minute in hour\n" + " <td><a href=\"#number\">Number</a>\n" + " <td><code>30</code>\n" + " <tr bgcolor=\"#eeeeff\">\n" + " <td><code>s</code>\n" + " <td>Second in minute\n" + " <td><a href=\"#number\">Number</a>\n" + " <td><code>55</code>\n" + " <tr>\n" + " <td><code>S</code>\n" + " <td>Millisecond\n" + " <td><a href=\"#number\">Number</a>\n" + " <td><code>978</code>\n" + " <tr bgcolor=\"#eeeeff\">\n" + " <td><code>z</code>\n" + " <td>Time zone\n" + " <td><a href=\"#timezone\">General time zone</a>\n" + " <td><code>Pacific Standard Time</code>; <code>PST</code>; <code>GMT-08:00</code>\n" + " <tr>\n" + " <td><code>Z</code>\n" + " <td>Time zone\n" + " <td><a href=\"#rfc822timezone\">RFC 822 time zone</a>\n" + " <td><code>-0800</code>\n" + " </table>\n" + " </blockquote>\n" + ""); titleLayout.addComponent(info); titleLayout.setComponentAlignment(info, Alignment.MIDDLE_CENTER); final DateConversion dateConversion = VaadinSession.getCurrent().getAttribute(DateConversion.class); OptionGroup option = new OptionGroup("Display options"); option.addItem(false); option.setItemCaption(false, "Show time in UTC/GMT"); option.addItem(true); option.setItemCaption(true, "Adjust to local timezone (" + dateConversion.getClientTZname() + ")"); String propertyTimeAdjust = userObject.getProperty(UserObject.PROPERTY_TIME_ADJUST); option.select(propertyTimeAdjust == null ? DEFAULT_TIME_ADJUST : Boolean.valueOf(propertyTimeAdjust)); option.setNullSelectionAllowed(false); option.setHtmlContentAllowed(true); option.setImmediate(true); layout.addComponent(option); final HorizontalLayout defaultLayout = new HorizontalLayout(); defaultLayout.setSpacing(true); layout.addComponent(defaultLayout); final Form form = new Form(); form.setFooter(null); final TextField timeFormat = new TextField("Format"); form.addField("timeFormat", timeFormat); defaultLayout.addComponent(form); option.addValueChangeListener(new ValueChangeListener() { @Override public void valueChange(final ValueChangeEvent event) { boolean value = (Boolean) event.getProperty().getValue(); dateConversion.setAdjustedToLocal(value); userObject.setProperty(UserObject.PROPERTY_TIME_ADJUST, String.valueOf(value)); settingsDialog.setRefresh(true); if (value == false) { timeFormat.removeAllValidators(); timeFormat.setComponentError(null); form.setComponentError(null); form.setValidationVisible(false); settingsDialog.setClose(true); } else { timeFormat.addValidator(new TimeFormatValidator()); timeFormat.setInputPrompt(DateConversion.DEFAULT_TIME_FORMAT); //timeFormat.setClickShortcut(KeyCode.ENTER); } } }); String propertyTimeFormat = userObject.getProperty(UserObject.PROPERTY_TIME_FORMAT); propertyTimeFormat = (propertyTimeFormat == null ? DateConversion.DEFAULT_TIME_FORMAT : String.valueOf(propertyTimeFormat)); timeFormat.setColumns(16); timeFormat.setValue(propertyTimeFormat); timeFormat.setImmediate(true); timeFormat.setRequired(true); timeFormat.setRequiredError("Format cannot be empty."); timeFormat.addValidator(new TimeFormatValidator()); timeFormat.addValueChangeListener(new ValueChangeListener() { @Override public void valueChange(final ValueChangeEvent event) { String value = (String) event.getProperty().getValue(); try { form.setComponentError(null); form.commit(); timeFormat.setComponentError(null); form.setValidationVisible(false); dateConversion.setFormat(value); userObject.setProperty(UserObject.PROPERTY_TIME_FORMAT, value); settingsDialog.setClose(true); settingsDialog.setRefresh(true); } catch (InvalidValueException e) { settingsDialog.setClose(false); timeFormat.setComponentError(new UserError("Invalid Format (Java SimpleDateFormat).")); timeFormat.focus(); } } }); Button defaultButton = new Button("Restore Default"); defaultLayout.addComponent(defaultButton); defaultLayout.setComponentAlignment(defaultButton, Alignment.MIDDLE_LEFT); defaultButton.addClickListener(new Button.ClickListener() { private static final long serialVersionUID = 0x4C656F6E6172646FL; public void buttonClick(Button.ClickEvent event) { timeFormat.setValue(DateConversion.DEFAULT_TIME_FORMAT); } }); return layout; }
From source file:com.skysql.manager.ui.LoginView.java
License:Open Source License
/** * Instantiates a new login view./* www . j a v a 2 s .c om*/ * * @param aboutRecord the about record */ public LoginView() { setSizeFull(); setMargin(true); setSpacing(true); addStyleName("loginView"); VerticalLayout logoLayout = new VerticalLayout(); addComponent(logoLayout); setComponentAlignment(logoLayout, Alignment.BOTTOM_CENTER); setExpandRatio(logoLayout, 1.0f); Embedded logo = new Embedded(null, new ThemeResource("img/loginlogo.png")); logoLayout.addComponent(logo); logoLayout.setComponentAlignment(logo, Alignment.BOTTOM_CENTER); Label releaseInfo = new Label("Version " + ManagerUI.GUI_RELEASE); releaseInfo.setSizeUndefined(); releaseInfo.addStyleName("releaseInfo"); logoLayout.addComponent(releaseInfo); logoLayout.setComponentAlignment(releaseInfo, Alignment.TOP_CENTER); VerticalLayout spacer = new VerticalLayout(); spacer.setHeight("20px"); logoLayout.addComponent(spacer); VerticalLayout loginBox = new VerticalLayout(); loginBox.addStyleName("loginBox"); loginBox.setSizeUndefined(); loginBox.setMargin(true); loginBox.setSpacing(true); addComponent(loginBox); setComponentAlignment(loginBox, Alignment.MIDDLE_CENTER); VerticalLayout loginFormLayout = new VerticalLayout(); loginFormLayout.addStyleName("loginForm"); loginFormLayout.setMargin(true); loginFormLayout.setSpacing(true); loginBox.addComponent(loginFormLayout); // userName.focus(); userName.setStyleName("loginControl"); userName.setInputPrompt("Username"); userName.setImmediate(true); userName.addValueChangeListener(new ValueChangeListener() { private static final long serialVersionUID = 0x4C656F6E6172646FL; public void valueChange(ValueChangeEvent event) { password.focus(); login.setClickShortcut(KeyCode.ENTER); } }); loginFormLayout.addComponent(userName); loginFormLayout.setComponentAlignment(userName, Alignment.MIDDLE_CENTER); // spacer loginFormLayout.addComponent(new Label("")); password.setStyleName("loginControl"); password.setInputPrompt("Password"); password.setImmediate(true); password.addValueChangeListener(new ValueChangeListener() { private static final long serialVersionUID = 0x4C656F6E6172646FL; public void valueChange(ValueChangeEvent event) { login.focus(); } }); loginFormLayout.addComponent(password); loginFormLayout.setComponentAlignment(password, Alignment.MIDDLE_CENTER); // spacer loginFormLayout.addComponent(new Label(" ")); login.setStyleName("loginControl"); login.setEnabled(false); loginFormLayout.addComponent(login); loginFormLayout.setComponentAlignment(login, Alignment.BOTTOM_CENTER); VerticalLayout filler = new VerticalLayout(); addComponent(filler); setExpandRatio(filler, 1.0f); preload(); }
From source file:com.skysql.manager.ui.MonitorsSettings.java
License:Open Source License
/** * Instantiates a new monitors settings. * * @param settingsDialog the settings dialog * @param systemID the system id/*from w ww . j ava 2s.c o m*/ * @param systemType the system type */ MonitorsSettings(SettingsDialog settingsDialog, String systemID, String systemType) { this.settingsDialog = settingsDialog; this.systemID = systemID; this.systemType = systemType; addStyleName("monitorsTab"); setSizeFull(); setSpacing(true); setMargin(true); HorizontalLayout selectLayout = new HorizontalLayout(); addComponent(selectLayout); selectLayout.setSizeFull(); selectLayout.setSpacing(true); Monitors.reloadMonitors(); monitorsAll = Monitors.getMonitorsList(systemType); select = new ListSelect("Monitors"); select.setImmediate(true); for (MonitorRecord monitor : monitorsAll.values()) { String id = monitor.getID(); select.addItem(id); select.setItemCaption(id, monitor.getName()); } select.setNullSelectionAllowed(false); selectLayout.addComponent(select); select.addValueChangeListener(new ValueChangeListener() { private static final long serialVersionUID = 0x4C656F6E6172646FL; public void valueChange(ValueChangeEvent event) { String monitorID = (String) event.getProperty().getValue(); displayMonitorRecord(monitorID); MonitorRecord monitor = monitorsAll.get(monitorID); if (monitor != null) { String monitorType = monitor.getType(); for (Monitors.EditableMonitorType editable : EditableMonitorType.values()) { if (editable.name().equals(monitorType)) { editMonitor.setEnabled(true); break; } } } } }); selectLayout.addLayoutClickListener(new LayoutClickListener() { private static final long serialVersionUID = 0x4C656F6E6172646FL; public void layoutClick(LayoutClickEvent event) { Component child; if (event.isDoubleClick() && (child = event.getChildComponent()) != null && (child instanceof ListSelect)) { // Get the child component which was double-clicked ListSelect select = (ListSelect) child; String monitorID = (String) select.getValue(); MonitorRecord monitor = monitorsAll.get(monitorID); String monitorType = monitor.getType(); for (Monitors.EditableMonitorType editable : EditableMonitorType.values()) { if (editable.name().equals(monitorType)) { editMonitor(monitor); break; } } } } }); monitorLayout = new FormLayout(); selectLayout.addComponent(monitorLayout); selectLayout.setExpandRatio(monitorLayout, 1.0f); monitorLayout.setSpacing(false); id.setCaption("ID:"); monitorLayout.addComponent(id); name.setCaption("Name:"); monitorLayout.addComponent(name); description.setCaption("Description:"); monitorLayout.addComponent(description); unit.setCaption("Unit:"); monitorLayout.addComponent(unit); // type.setCaption("Type:"); // monitorLayout.addComponent(type); delta.setCaption("Is Delta:"); monitorLayout.addComponent(delta); average.setCaption("Is Average:"); monitorLayout.addComponent(average); chartType.setCaption("Chart Type:"); monitorLayout.addComponent(chartType); interval.setCaption("Interval:"); monitorLayout.addComponent(interval); sql.setCaption("Statement:"); monitorLayout.addComponent(sql); HorizontalLayout selectButtons = new HorizontalLayout(); selectButtons.setSizeFull(); addComponent(selectButtons); selectButtons.setSpacing(true); Button addMonitor = new Button("Add..."); selectButtons.addComponent(addMonitor); selectButtons.setComponentAlignment(addMonitor, Alignment.MIDDLE_LEFT); addMonitor.addClickListener(new Button.ClickListener() { private static final long serialVersionUID = 0x4C656F6E6172646FL; public void buttonClick(ClickEvent event) { addMonitor(); } }); deleteMonitor = new Button("Delete"); deleteMonitor.setEnabled(false); selectButtons.addComponent(deleteMonitor); selectButtons.setComponentAlignment(deleteMonitor, Alignment.MIDDLE_LEFT); deleteMonitor.addClickListener(new Button.ClickListener() { private static final long serialVersionUID = 0x4C656F6E6172646FL; public void buttonClick(ClickEvent event) { String monitorID = (String) select.getValue(); if (monitorID != null) { deleteMonitor(monitorsAll.get(monitorID)); } } }); editMonitor = new Button("Edit..."); editMonitor.setEnabled(false); selectButtons.addComponent(editMonitor); selectButtons.setComponentAlignment(editMonitor, Alignment.MIDDLE_CENTER); selectButtons.setExpandRatio(editMonitor, 1.0f); editMonitor.addClickListener(new Button.ClickListener() { private static final long serialVersionUID = 0x4C656F6E6172646FL; public void buttonClick(ClickEvent event) { String monitorID = (String) select.getValue(); if (monitorID != null) { editMonitor(monitorsAll.get(monitorID)); } } }); }
From source file:com.skysql.manager.ui.OverviewPanel.java
License:Open Source License
/** * Instantiates a new overview panel.//from w w w. j a va2 s . c om */ public OverviewPanel() { HorizontalLayout overviewContainer = new HorizontalLayout(); overviewContainer.addStyleName("overviewPanel"); overviewContainer.setWidth("100%"); setContent(overviewContainer); systemInfo = VaadinSession.getCurrent().getAttribute(SystemInfo.class); systemRecord = systemInfo.getCurrentSystem(); systemLayout = new SystemLayout(systemRecord); overviewContainer.addComponent(systemLayout); VerticalLayout nodesSlot = new VerticalLayout(); nodesSlot.addStyleName("nodesSlot"); nodesSlot.setMargin(new MarginInfo(false, false, false, false)); overviewContainer.addComponent(nodesSlot); overviewContainer.setExpandRatio(nodesSlot, 1.0f); final HorizontalLayout nodesHeader = new HorizontalLayout(); nodesHeader.setStyleName("panelHeaderLayout"); nodesHeader.setWidth("100%"); nodesSlot.addComponent(nodesHeader); nodesLabel = new Label(" "); nodesLabel.setSizeUndefined(); nodesHeader.addComponent(nodesLabel); nodesHeader.setComponentAlignment(nodesLabel, Alignment.MIDDLE_CENTER); nodesHeader.setExpandRatio(nodesLabel, 1.0f); final HorizontalLayout buttonsLayout = new HorizontalLayout(); buttonsLayout.setSpacing(true); buttonsLayout.setMargin(new MarginInfo(false, true, false, false)); nodesHeader.addComponent(buttonsLayout); nodesHeader.setComponentAlignment(buttonsLayout, Alignment.MIDDLE_RIGHT); addSystemButton = new Button("Add System..."); addSystemButton.setDescription("Add System"); addSystemButton.setVisible(false); buttonsLayout.addComponent(addSystemButton); addSystemButton.addClickListener(new Button.ClickListener() { public void buttonClick(ClickEvent event) { new SystemDialog(null, null); } }); addNodeButton = new Button("Add Node..."); addNodeButton.setDescription("Add Node to the current System"); addNodeButton.setVisible(false); buttonsLayout.addComponent(addNodeButton); addNodeButton.addClickListener(new Button.ClickListener() { public void buttonClick(ClickEvent event) { new NodeDialog(null, null); } }); final Button editButton = new Button("Edit"); editButton.setDescription("Enter Editing mode"); final Button saveButton = new Button("Done"); saveButton.setDescription("Exit Editing mode"); buttonsLayout.addComponent(editButton); editButton.addClickListener(new Button.ClickListener() { public void buttonClick(ClickEvent event) { buttonsLayout.replaceComponent(editButton, saveButton); isEditable = true; systemLayout.setEditable(true); nodesLayout.setEditable(true); nodesHeader.setStyleName("panelHeaderLayout-editable"); if (systemRecord != null && !SystemInfo.SYSTEM_ROOT.equals(systemRecord.getID())) { addNodeButton.setVisible(true); } else { addSystemButton.setVisible(true); } if (systemRecord == null || (systemRecord != null && systemRecord.getNodes().length == 0)) { nodesLayout.placeholderLayout(null); } } }); saveButton.addClickListener(new Button.ClickListener() { public void buttonClick(ClickEvent event) { buttonsLayout.replaceComponent(saveButton, editButton); isEditable = false; systemLayout.setEditable(false); nodesLayout.setEditable(false); nodesHeader.setStyleName("panelHeaderLayout"); if (systemRecord != null && systemRecord.getNodes().length == 0) { nodesLayout.placeholderLayout(null); } addNodeButton.setVisible(false); addSystemButton.setVisible(false); } }); Panel panel = new Panel(); panel.setHeight(PANEL_HEIGHT, Unit.PIXELS); panel.addStyleName(Runo.PANEL_LIGHT); nodesSlot.addComponent(panel); nodesLayout = new NodesLayout(systemRecord); nodesLayout.addStyleName("nodesLayout"); nodesLayout.setWidth("100%"); panel.setContent(nodesLayout); }
From source file:com.skysql.manager.ui.PanelControl.java
License:Open Source License
/** * Creates the new layout.//from w ww . ja v a 2s . c om */ private void createNewLayout() { newLayout = new HorizontalLayout(); newLayout.addStyleName("newLayout"); newLayout.setMargin(true); newLayout.setSpacing(true); addComponent(newLayout); // COMMANDS commandsLayout = new VerticalLayout(); commandsLayout.addStyleName("instructions"); commandsLayout.setSizeUndefined(); newLayout.addComponent(commandsLayout); commandSelect = new ListSelect("Commands"); commandSelect.setImmediate(true); commandSelect.setRows(10); commandSelect.setNullSelectionAllowed(false); commandSelect.setWidth("12em"); commandSelect.addValueChangeListener(commandListener); commandsLayout.addComponent(commandSelect); commandsLayout.setComponentAlignment(commandSelect, Alignment.MIDDLE_CENTER); // Scripting layout placeholder placeholderLayout = new VerticalLayout(); placeholderLayout.addStyleName("placeholderLayout"); placeholderLabel = new Label("No Command is currently running on this node"); placeholderLabel.addStyleName("instructions"); placeholderLabel.setSizeUndefined(); placeholderLayout.addComponent(placeholderLabel); placeholderLayout.setComponentAlignment(placeholderLabel, Alignment.MIDDLE_CENTER); newLayout.addComponent(placeholderLayout); newLayout.setComponentAlignment(placeholderLayout, Alignment.MIDDLE_CENTER); runningContainerLayout = placeholderLayout; }
From source file:com.skysql.manager.ui.PanelControl.java
License:Open Source License
/** * Creates the logs layout./*from ww w . jav a 2 s . co m*/ */ private void createLogsLayout() { Label separator = new Label(); separator.addStyleName("separator"); //separator.setHeight(Sizeable.SIZE_UNDEFINED, Unit.PIXELS); addComponent(separator); logsLayout = new HorizontalLayout(); logsLayout.addStyleName("logsLayout"); logsLayout.setSpacing(true); logsLayout.setMargin(true); addComponent(logsLayout); setExpandRatio(logsLayout, 1.0f); logsTable = new Table("Previously run Commands"); logsTable.setPageLength(10); logsTable.addContainerProperty("Command", String.class, null); logsTable.addContainerProperty("State", String.class, null); logsTable.addContainerProperty("Info", Embedded.class, null); logsTable.addContainerProperty("Started", String.class, null); logsTable.addContainerProperty("Completed", String.class, null); logsTable.addContainerProperty("Steps", String.class, null); logsTable.addContainerProperty("Parameters", String.class, null); logsTable.addContainerProperty("User", String.class, null); logsLayout.addComponent(logsTable); logsLayout.setComponentAlignment(logsTable, Alignment.MIDDLE_CENTER); }
From source file:com.skysql.manager.ui.PanelControl.java
License:Open Source License
/** * Asynch refresh.//from w w w . j a va 2 s . c o m * * @param updaterThread the updater thread */ private void asynchRefresh(final UpdaterThread updaterThread) { ManagerUI managerUI = getSession().getAttribute(ManagerUI.class); nodeInfo = (NodeInfo) getSession().getAttribute(ClusterComponent.class); final String newNodeID = nodeInfo.getID(); final UserInfo userInfo = (UserInfo) getSession().getAttribute(UserInfo.class); TaskRecord taskRecord = nodeInfo.getTask(); final String taskID = (taskRecord != null && taskRecord.getState().equals("running")) ? taskRecord.getID() : null; // update command history section TaskInfo taskInfo = new TaskInfo(null, nodeInfo.getParentID(), nodeInfo.getID()); final ArrayList<TaskRecord> tasksList = taskInfo.getTasksList(); managerUI.access(new Runnable() { @Override public void run() { // Here the UI is locked and can be updated ManagerUI.log("PanelControl access run() - taskID: " + taskID); RunningTask runningTask = nodeInfo.getCommandTask(); DateConversion dateConversion = getSession().getAttribute(DateConversion.class); boolean adjust = dateConversion.isAdjustedToLocal(); String format = dateConversion.getFormat(); if (!newNodeID.equals(lastNodeID) || (tasksList != null && tasksList.size() != oldTasksCount) || adjust != updaterThread.adjust || !format.equals(updaterThread.format)) { updaterThread.adjust = adjust; updaterThread.format = format; logsTable.removeAllItems(); if (tasksList != null) { oldTasksCount = tasksList.size(); firstObject = null; for (TaskRecord taskRecord : tasksList) { Embedded info = null; if (taskRecord.getState().equals(CommandStates.States.error.name())) { info = new Embedded(null, new ThemeResource("img/alert.png")); info.addStyleName("infoButton"); info.setDescription(taskRecord.getError()); } Object itemID = logsTable.addItem(new Object[] { taskRecord.getCommand(), CommandStates.getDescriptions().get(taskRecord.getState()), info, dateConversion.adjust(taskRecord.getStart()), dateConversion.adjust(taskRecord.getEnd()), taskRecord.getSteps(), taskRecord.getParams(), taskRecord.getUserID() }, taskRecord.getID()); if (firstObject == null) { firstObject = itemID; } } } } else if (tasksList.size() > 0 && firstObject != null) { // update top of the list with last task info TaskRecord taskRecord = tasksList.get(0); Embedded info = null; if (taskRecord.getState().equals(CommandStates.States.error.name())) { info = new Embedded(null, new ThemeResource("img/alert.png")); info.addStyleName("infoButton"); info.setDescription(taskRecord.getError()); } Item tableRow = logsTable.getItem(firstObject); tableRow.getItemProperty("State") .setValue(CommandStates.getDescriptions().get(taskRecord.getState())); tableRow.getItemProperty("Info").setValue(info); tableRow.getItemProperty("Completed").setValue(dateConversion.adjust(taskRecord.getEnd())); } // task is running although it was not started by us if (taskID != null && runningTask == null) { runningTask = new RunningTask(null, nodeInfo, commandSelect); runningTask.addRefreshListener(refreshListener); } if (!newNodeID.equals(lastNodeID)) { commandSelect.removeAllItems(); nodeInfo.updateCommands(); } if (nodeInfo.getCommands() == null || nodeInfo.getCommands().getNames().isEmpty()) { commandSelect.removeAllItems(); oldcommands = null; placeholderLabel.setValue("No Command is currently available on this node"); } else { placeholderLabel.setValue("No Command is currently running on this node"); String commands[] = new String[nodeInfo.getCommands().getNames().keySet().size()]; nodeInfo.getCommands().getNames().keySet().toArray(commands); if (!newNodeID.equals(lastNodeID) || !Arrays.equals(commands, oldcommands)) { oldcommands = commands; commandSelect.removeValueChangeListener(commandListener); // rebuild list of commands with what node is accepting commandSelect.removeAllItems(); if ((commands != null) && (commands.length != 0)) { for (String command : commands) { commandSelect.addItem(command); } } commandSelect.addValueChangeListener(commandListener); } commandSelect.removeValueChangeListener(commandListener); String selected = (runningTask != null) ? runningTask.getCommand() : null; commandSelect.select(selected); commandSelect.addValueChangeListener(commandListener); } commandSelect.setEnabled(taskID != null ? false : true); if (runningTask != null) { VerticalLayout newScriptingLayout = runningTask.getLayout(); newLayout.replaceComponent(runningContainerLayout, newScriptingLayout); runningContainerLayout = newScriptingLayout; } else if (runningContainerLayout != placeholderLayout) { newLayout.replaceComponent(runningContainerLayout, placeholderLayout); newLayout.setComponentAlignment(placeholderLayout, Alignment.MIDDLE_CENTER); runningContainerLayout = placeholderLayout; } lastNodeID = newNodeID; } }); }
From source file:com.skysql.manager.ui.PanelInfo.java
License:Open Source License
/** * Creates the charts layout.//from www . java 2 s.c o m */ private void createChartsLayout() { chartsLayout = new VerticalLayout(); chartsLayout.addStyleName("chartsLayout"); chartsLayout.setHeight("100%"); chartsLayout.setSpacing(true); addComponent(chartsLayout); final HorizontalLayout chartsHeaderLayout = new HorizontalLayout(); chartsHeaderLayout.setStyleName("panelHeaderLayout"); chartsHeaderLayout.setWidth("100%"); chartsHeaderLayout.setSpacing(true); chartsHeaderLayout.setMargin(new MarginInfo(false, true, false, true)); chartsLayout.addComponent(chartsHeaderLayout); chartControls = new ChartControls(); chartControls.addIntervalSelectionListener(chartIntervalListener); chartControls.addThemeSelectionListener(chartThemeListener); chartsHeaderLayout.addComponent(chartControls); chartsHeaderLayout.setComponentAlignment(chartControls, Alignment.MIDDLE_LEFT); final HorizontalLayout buttonsLayout = new HorizontalLayout(); buttonsLayout.setSpacing(true); chartsHeaderLayout.addComponent(buttonsLayout); chartsHeaderLayout.setComponentAlignment(buttonsLayout, Alignment.MIDDLE_RIGHT); SettingsDialog settingsDialog = new SettingsDialog("Edit Monitors...", "Monitors"); final Button editMonitorsButton = settingsDialog.getButton(); editMonitorsButton.setVisible(false); buttonsLayout.addComponent(editMonitorsButton); final Button addChartButton = new Button("Add Chart..."); addChartButton.setVisible(false); buttonsLayout.addComponent(addChartButton); addChartButton.addClickListener(new Button.ClickListener() { public void buttonClick(ClickEvent event) { new ChartsDialog(chartsArrayLayout, null); } }); final Button editButton = new Button("Edit"); editButton.setDescription("Enter Editing mode"); final Button saveButton = new Button("Done"); saveButton.setDescription("Exit Editing mode"); buttonsLayout.addComponent(editButton); editButton.addClickListener(new Button.ClickListener() { public void buttonClick(ClickEvent event) { buttonsLayout.replaceComponent(editButton, saveButton); chartsArrayLayout.setDragMode(LayoutDragMode.CLONE); chartsArrayLayout.setEditable(true); chartsHeaderLayout.setStyleName("panelHeaderLayout-editable"); editMonitorsButton.setVisible(true); addChartButton.setVisible(true); OverviewPanel overviewPanel = getSession().getAttribute(OverviewPanel.class); overviewPanel.setEnabled(false); } }); saveButton.addClickListener(new Button.ClickListener() { public void buttonClick(ClickEvent event) { buttonsLayout.replaceComponent(saveButton, editButton); chartsArrayLayout.setDragMode(LayoutDragMode.NONE); chartsArrayLayout.setEditable(false); chartsHeaderLayout.setStyleName("panelHeaderLayout"); editMonitorsButton.setVisible(false); addChartButton.setVisible(false); OverviewPanel overviewPanel = getSession().getAttribute(OverviewPanel.class); overviewPanel.setEnabled(true); refresh(); } }); final Button expandButton = new NativeButton(); expandButton.setStyleName("expandButton"); expandButton.setDescription("Expand/Reduce viewing area"); buttonsLayout.addComponent(expandButton); buttonsLayout.setComponentAlignment(expandButton, Alignment.MIDDLE_CENTER); expandButton.addClickListener(new Button.ClickListener() { public void buttonClick(ClickEvent event) { isExpanded = !isExpanded; AnimatorProxy proxy = getSession().getAttribute(AnimatorProxy.class); proxy.addListener(new AnimationListener() { public void onAnimation(AnimationEvent event) { Component component = event.getComponent(); component.setVisible(isExpanded ? false : true); } }); // OverviewPanel overviewPanel = getSession().getAttribute(OverviewPanel.class); // if (!isExpanded) { // overviewPanel.setVisible(isExpanded ? false : true); // } // proxy.animate(overviewPanel, isExpanded ? AnimType.ROLL_UP_CLOSE : AnimType.ROLL_DOWN_OPEN).setDuration(500).setDelay(100); // // TopPanel topPanel = getSession().getAttribute(TopPanel.class); // if (!isExpanded) { // topPanel.setVisible(isExpanded ? false : true); // } // proxy.animate(topPanel, isExpanded ? AnimType.ROLL_UP_CLOSE : AnimType.ROLL_DOWN_OPEN).setDuration(500).setDelay(100); VerticalLayout topMid = getSession().getAttribute(VerticalLayout.class); if (!isExpanded) { topMid.setVisible(isExpanded ? false : true); } proxy.animate(topMid, isExpanded ? AnimType.ROLL_UP_CLOSE : AnimType.ROLL_DOWN_OPEN) .setDuration(500).setDelay(100); expandButton.setStyleName(isExpanded ? "contractButton" : "expandButton"); } }); chartsPanel = new Panel(); chartsPanel.setSizeFull(); chartsPanel.addStyleName(Runo.PANEL_LIGHT); chartsLayout.addComponent(chartsPanel); chartsLayout.setExpandRatio(chartsPanel, 1.0f); }
From source file:com.skysql.manager.ui.PanelTools.java
License:Open Source License
/** * Instantiates a new panel tools.// w w w . j a va 2s. co m */ PanelTools() { // thisTab.setSizeFull(); // thisTab.setWidth(Sizeable.SIZE_UNDEFINED, 0); // Default setHeight("200px"); setSpacing(true); // External Tools Vertical Module SystemInfo systemInfo = getSession().getAttribute(SystemInfo.class); LinkedHashMap<String, String> properties = systemInfo.getCurrentSystem().getProperties(); if (properties != null) { VerticalLayout externalsLayout = new VerticalLayout(); externalsLayout.setWidth("150px"); externalsLayout.addStyleName("externalsLayout"); externalsLayout.setSpacing(true); String EIP = properties.get(SystemInfo.PROPERTY_EIP); String MONyog = properties.get(SystemInfo.PROPERTY_MONYOG); if (EIP != null && MONyog != null) { String url = "http://" + EIP + MONyog; monyogLink = new Link("MONyog", new ExternalResource(url)); monyogLink.setTargetName("_blank"); monyogLink.setDescription("Open MONyog for the whole system"); monyogLink.setIcon(new ThemeResource("img/externalLink.png")); monyogLink.addStyleName("icon-after-caption"); externalsLayout.addComponent(monyogLink); externalsLayout.setComponentAlignment(monyogLink, Alignment.BOTTOM_CENTER); } phpUrl = properties.get(SystemInfo.PROPERTY_PHPMYADMIN); if (phpUrl != null) { phpLink = new Link("phpMyAdmin", null); phpLink.setTargetName("_blank"); phpLink.setDescription("Open phpMyAdmin for the selected node"); phpLink.setIcon(new ThemeResource("img/externalLink.png")); phpLink.addStyleName("icon-after-caption"); externalsLayout.addComponent(phpLink); externalsLayout.setComponentAlignment(phpLink, Alignment.BOTTOM_CENTER); } addComponent(externalsLayout); setComponentAlignment(externalsLayout, Alignment.MIDDLE_CENTER); } { Label spacer = new Label(); spacer.setWidth("40px"); addComponent(spacer); } // Scripting layout placeholder VerticalLayout placeholderLayout = new VerticalLayout(); placeholderLayout.addStyleName("placeholderLayout"); placeholderLayout.setSizeUndefined(); Label placeholderLabel = new Label("Links to external tools"); placeholderLabel.addStyleName("instructions"); placeholderLayout.addComponent(placeholderLabel); addComponent(placeholderLayout); setComponentAlignment(placeholderLayout, Alignment.MIDDLE_CENTER); }