List of usage examples for com.vaadin.ui Embedded setDescription
public void setDescription(String description)
From source file:com.lizardtech.expresszip.vaadin.SetupMapViewComponent.java
License:Apache License
@Override public void updateTree(List<ExpressZipLayer> chosenLayers, Set<String> supportedProjections) { treeHier.removeAllItems();//from w w w. j a v a 2 s .co m for (ExpressZipLayer layer : chosenLayers) { Item item = treeHier.addItem(layer); item.getItemProperty(ExpressZipTreeTable.LAYER).setValue(layer); Embedded dragImg = new Embedded("", new ThemeResource("img/MoveUpDown23px.png")); dragImg.setDescription("Drag to change layer order"); item.getItemProperty(DRAG_PROPERTY).setValue(dragImg); // using treetable just for drag-drop, no children treeTable.setChildrenAllowed(layer, false); } // update the EPSG combo box with the union of supported projections from the enabled layers cmbProjection.removeAllItems(); for (String epsg : supportedProjections) { String displayName = epsg; final String EPSG = "EPSG:"; try { CoordinateReferenceSystem sourceCRS = CRS.decode(epsg); displayName = sourceCRS.getName().toString(); if (displayName.startsWith(EPSG)) displayName = displayName.substring(EPSG.length()); ReferenceIdentifier id = (ReferenceIdentifier) sourceCRS.getIdentifiers().iterator().next(); displayName = String.format("%s (%s)", displayName, id.getCode()); } catch (NoSuchAuthorityCodeException e) { } catch (FactoryException e) { } cmbProjection.addItem(epsg); cmbProjection.setItemCaption(epsg, displayName); } if (supportedProjections.size() > 0) { if (selectedEpsg == null || !cmbProjection.containsId(selectedEpsg)) { selectedEpsg = supportedProjections.iterator().next(); } cmbProjection.select(selectedEpsg); } }
From source file:com.lst.deploymentautomation.vaadin.page.TodoListView.java
License:Open Source License
@SuppressWarnings("serial") private void createView() { final LspsUI ui = (LspsUI) getUI(); setTitle(ui.getMessage(TITLE));/* w w w .j a v a 2s. com*/ VerticalLayout layout = new VerticalLayout(); setContent(layout); table = new Table(); table.setSizeFull(); table.setSelectable(true); table.setMultiSelectMode(MultiSelectMode.SIMPLE); table.setSortEnabled(false); table.setColumnReorderingAllowed(true); table.setColumnCollapsingAllowed(true); table.addValueChangeListener(new Property.ValueChangeListener() { @Override public void valueChange(ValueChangeEvent event) { final Object sel = event.getProperty().getValue(); if (sel instanceof Set) { selection = (Set<Long>) sel; } else if (sel instanceof Long) { selection = Collections.singleton((Long) sel); } else { selection = Collections.emptySet(); } //enable todo actions only if the sel is non-empty actionBtn.setEnabled(selection.size() > 0); } }); table.addItemClickListener(new ItemClickListener() { @Override public void itemClick(ItemClickEvent event) { if (table.isMultiSelect()) { return; //don't do anything if in selection mode } if (event.getButton() != MouseButton.LEFT || event.isDoubleClick()) { return; //ignore right-clicks } final Item item = event.getItem(); final Long todoId = (Long) item.getItemProperty("id").getValue(); try { ((LspsUI) getUI()).openTodo(todoId); } catch (Exception e) { Utils.log(e, "could not open to-do " + todoId, log); final LspsUI ui = (LspsUI) getUI(); ui.showErrorMessage("app.unknownErrorOccurred", e); //todo.openFailed? } } }); table.setContainerDataSource(container); Object[] defaultColumns = new Object[] { "title", "notes", "priority", "authorization", "modelInstanceId", "issuedDate" }; //load table settings String settings = ui.getUser().getSettingString(SETTINGS_KEY, null); if (settings == null) { table.setVisibleColumns(defaultColumns); originalSettings = getColumnSettings(); } else { originalSettings = settings; try { applyTableSettings(settings); } catch (Exception e) { table.setVisibleColumns(defaultColumns); Utils.log(e, "could not load todo list settings", log); } } table.setColumnHeader("title", ui.getMessage("todo.title")); table.setColumnHeader("notes", ui.getMessage("todo.notes")); table.setColumnHeader("priority", ui.getMessage("todo.priority")); table.setColumnHeader("authorization", ui.getMessage("todo.authorizationShort")); table.setColumnHeader("modelInstanceId", ui.getMessage("todo.process")); table.setColumnHeader("issuedDate", ui.getMessage("todo.issued")); table.setColumnAlignment("modelInstanceId", Table.Align.CENTER); table.setColumnExpandRatio("title", 2); table.setColumnExpandRatio("notes", 1); //localize todo titles table.addGeneratedColumn("title", new ColumnGenerator() { @Override public Object generateCell(Table source, Object itemId, Object columnId) { @SuppressWarnings("unchecked") BeanItem<Todo> item = (BeanItem<Todo>) source.getItem(itemId); return ui.localizeEngineText(item.getBean().getTitle()); } }); //show icons for authorization table.addGeneratedColumn("authorization", new ColumnGenerator() { @Override public Object generateCell(Table source, Object itemId, Object columnId) { @SuppressWarnings("unchecked") BeanItem<Todo> item = (BeanItem<Todo>) source.getItem(itemId); String icon; String text; switch (item.getBean().getAuthorization()) { case INITIAL_PERFORMER: icon = "auth_performer.gif"; text = ui.getMessage("todo.authorizationPerformer"); break; case DELEGATE: icon = "auth_delegate.gif"; text = ui.getMessage("todo.authorizationDelegate"); break; case SUBSTITUTE: icon = "auth_substitute.gif"; text = ui.getMessage("todo.authorizationSubstitute"); break; case NOT_PERMITTED: default: icon = "auth_unknown.gif"; text = ui.getMessage("todo.authorizationUnknown"); break; } Embedded authIcon = new Embedded(null, new ThemeResource("../icons/" + icon)); authIcon.setDescription(text); if (item.getBean().getAllocatedTo() != null) { HorizontalLayout layout = new HorizontalLayout(); layout.setSpacing(true); layout.addComponent(authIcon); Embedded lockedIcon = new Embedded(null, new ThemeResource("../icons/lock.gif")); lockedIcon.setDescription( ui.getMessage("todo.lockedBy", item.getBean().getAllocatedToFullName())); layout.addComponent(lockedIcon); return layout; } else { return authIcon; } } }); //format date final SimpleDateFormat df = new SimpleDateFormat(ui.getMessage("app.dateTimeFormat")); table.addGeneratedColumn("issuedDate", new ColumnGenerator() { @Override public Object generateCell(Table source, Object itemId, Object columnId) { @SuppressWarnings("unchecked") BeanItem<Todo> item = (BeanItem<Todo>) source.getItem(itemId); return df.format(item.getBean().getIssuedDate()); } }); layout.addComponent(table); layout.setExpandRatio(table, 1); }
From source file:com.rdonasco.common.vaadin.view.utils.EmbeddedResourceBuilder.java
License:Apache License
public Embedded createEmbedded() throws InvalidBuilderParameter { if (null == application) { throw new InvalidBuilderParameter("application not set"); }//from w w w . j a v a 2s. com if (null == name) { throw new InvalidBuilderParameter("name not set"); } Embedded embedded = null; if (null != bytes) { embedded = createUsingStreamSource(); } else if (null != resourceId) { embedded = createUsingResourceId(); } else { throw new InvalidBuilderParameter("bytes or resource ID is not set"); } embedded.setDescription(description); embedded.setAlternateText(alternateText); if (null != height) { embedded.setHeight(height, units); } if (null != width) { embedded.setWidth(width, units); } return embedded; }
From source file:com.rdonasco.datamanager.listeditor.controller.ListEditorViewPanelController.java
License:Apache License
public void configureDataContainerDefaultStrategies() { if (null == dataContainer) { throw new NullPointerException("dataContainer cannot be null"); }//from ww w.j a v a2 s .c o m if (dataContainer.getDataManager() == null) { LOG.log(Level.WARNING, "dataContainer.dataManager is null, defaultStrategies may fail if it is not set properly. An alternative is to use custom strategies"); } dataContainer.setDataRetrieveListStrategy(new DataRetrieveListStrategy<VO>() { @Override public List<VO> retrieve() throws DataAccessException { List<VO> listItems; listItems = dataContainer.getDataManager().retrieveAllData(); Embedded icon; for (VO listItem : listItems) { icon = createDeleteIcon(); icon.setDescription(I18NResource.localize("Delete Item")); listItem.setIcon(icon); setupDeleteIconClickListener(icon, listItem); } return listItems; } }); dataContainer.setDataSaveStrategy(new DataSaveStrategy<VO>() { @Override public VO save(VO dataToSaveAndReturn) throws DataAccessException { return dataContainer.getDataManager().saveData(dataToSaveAndReturn); } }); dataContainer.setDataUpdateStrategy(new DataUpdateStrategy<VO>() { @Override public void update(VO dataToUpdate) throws DataAccessException { dataContainer.getDataManager().updateData(dataToUpdate); } }); dataContainer.setDataDeleteStrategy(new DataDeleteStrategy<VO>() { @Override public void delete(VO dataToDelete) throws DataAccessException { dataContainer.getDataManager().deleteData(dataToDelete); } }); }
From source file:com.selzlein.lojavirtual.vaadin.page.TodoListView.java
License:Open Source License
@SuppressWarnings("serial") private void createView() { final LspsUI ui = (LspsUI) getUI(); setTitle(ui.getMessage(TITLE));/*from w w w . java2s . c o m*/ VerticalLayout layout = new VerticalLayout(); setContent(layout); table = new Table(); table.setSizeFull(); table.setSelectable(true); table.setMultiSelectMode(MultiSelectMode.SIMPLE); table.setSortEnabled(false); table.setColumnReorderingAllowed(true); table.setColumnCollapsingAllowed(true); table.addValueChangeListener(new Property.ValueChangeListener() { @Override public void valueChange(ValueChangeEvent event) { final Object sel = event.getProperty().getValue(); if (sel instanceof Set) { selection = (Set<Long>) sel; } else if (sel instanceof Long) { selection = Collections.singleton((Long) sel); } else { selection = Collections.emptySet(); } //enable todo actions only if the sel is non-empty actionBtn.setEnabled(selection.size() > 0); } }); table.addItemClickListener(new ItemClickListener() { @Override public void itemClick(ItemClickEvent event) { if (table.isMultiSelect()) { return; //don't do anything if in selection mode } if (event.getButton() != MouseButton.LEFT || event.isDoubleClick()) { return; //ignore right-clicks } final Item item = event.getItem(); final Long todoId = (Long) item.getItemProperty("id").getValue(); try { ((LspsUI) getUI()).openTodo(todoId); } catch (Exception e) { Utils.log(e, "could not open to-do " + todoId, log); final LspsUI ui = (LspsUI) getUI(); ui.showErrorMessage("app.unknownErrorOccurred", e); //todo.openFailed? } } }); table.setContainerDataSource(container); Object[] defaultColumns = new Object[] { "title", "notes", "priority", "authorization", "modelInstanceId", "issuedDate" }; //load table settings String settings = ui.getUser().getSettingString(SETTINGS_KEY, null); if (settings == null) { table.setVisibleColumns(defaultColumns); originalSettings = getColumnSettings(); } else { originalSettings = settings; try { applyTableSettings(settings); } catch (Exception e) { table.setVisibleColumns(defaultColumns); Utils.log(e, "could not load todo list settings", log); } } table.setColumnHeader("title", ui.getMessage("todo.title")); table.setColumnHeader("notes", ui.getMessage("todo.notes")); table.setColumnHeader("priority", ui.getMessage("todo.priority")); table.setColumnHeader("authorization", ui.getMessage("todo.authorizationShort")); table.setColumnHeader("modelInstanceId", ui.getMessage("todo.process")); table.setColumnHeader("issuedDate", ui.getMessage("todo.issued")); table.setColumnAlignment("modelInstanceId", Table.Align.CENTER); if (table.getItemIds().size() > 0) { table.setColumnExpandRatio("title", 2); table.setColumnExpandRatio("notes", 1); } //localize todo titles table.addGeneratedColumn("title", new ColumnGenerator() { @Override public Object generateCell(Table source, Object itemId, Object columnId) { @SuppressWarnings("unchecked") BeanItem<Todo> item = (BeanItem<Todo>) source.getItem(itemId); return ui.localizeEngineText(item.getBean().getTitle()); } }); //show icons for authorization table.addGeneratedColumn("authorization", new ColumnGenerator() { @Override public Object generateCell(Table source, Object itemId, Object columnId) { @SuppressWarnings("unchecked") BeanItem<Todo> item = (BeanItem<Todo>) source.getItem(itemId); String icon; String text; switch (item.getBean().getAuthorization()) { case INITIAL_PERFORMER: icon = "auth_performer.gif"; text = ui.getMessage("todo.authorizationPerformer"); break; case DELEGATE: icon = "auth_delegate.gif"; text = ui.getMessage("todo.authorizationDelegate"); break; case SUBSTITUTE: icon = "auth_substitute.gif"; text = ui.getMessage("todo.authorizationSubstitute"); break; case NOT_PERMITTED: default: icon = "auth_unknown.gif"; text = ui.getMessage("todo.authorizationUnknown"); break; } Embedded authIcon = new Embedded(null, new ThemeResource("../icons/" + icon)); authIcon.setDescription(text); if (item.getBean().getAllocatedTo() != null) { HorizontalLayout layout = new HorizontalLayout(); layout.setSpacing(true); layout.addComponent(authIcon); Embedded lockedIcon = new Embedded(null, new ThemeResource("../icons/lock.gif")); lockedIcon.setDescription( ui.getMessage("todo.lockedBy", item.getBean().getAllocatedToFullName())); layout.addComponent(lockedIcon); return layout; } else { return authIcon; } } }); //format date final SimpleDateFormat df = new SimpleDateFormat(ui.getMessage("app.dateTimeFormat")); table.addGeneratedColumn("issuedDate", new ColumnGenerator() { @Override public Object generateCell(Table source, Object itemId, Object columnId) { @SuppressWarnings("unchecked") BeanItem<Todo> item = (BeanItem<Todo>) source.getItem(itemId); return df.format(item.getBean().getIssuedDate()); } }); layout.addComponent(table); layout.setExpandRatio(table, 1); }
From source file:com.skysql.manager.ui.ChartPreviewLayout.java
License:Open Source License
/** * Instantiates a new chart preview layout. * * @param userChart the user chart//from w w w . ja v a 2 s. c o m * @param time the time * @param interval the interval */ public ChartPreviewLayout(final UserChart userChart, String time, String interval) { this.userChart = userChart; this.time = time; this.interval = interval; addStyleName("ChartPreviewLayout"); setSpacing(true); setMargin(true); HorizontalLayout formDescription = new HorizontalLayout(); formDescription.setSpacing(true); Embedded info = new Embedded(null, new ThemeResource("img/info.png")); info.addStyleName("infoButton"); String infoText = "<table border=0 cellspacing=3 cellpadding=0 summary=\"\">\n" + " <tr bgcolor=\"#ccccff\">" + " <th align=left>Field" + " <th align=left>Description" + " <tr>" + " <td><code>Title</code>" + " <td>Name of the Chart" + " <tr bgcolor=\"#eeeeff\">" + " <td><code>Description</code>" + " <td>Description of the Chart " + " <tr>" + " <td nowrap><code>Measurement Unit</code>" + " <td>Unit of measurement for the data returned by the monitor, used as caption for the vertical axis of the chart" + " <tr bgcolor=\"#eeeeff\">" + " <td><code>Type</code>" + " <td>Chart type (LineChart, AreaChart)" + " <tr>" + " <td><code>Points</code>" + " <td>Number of data points displayed"; infoText += " </table>" + " </blockquote>"; info.setDescription(infoText); formDescription.addComponent(info); final Label monitorsLabel = new Label("Display as Chart"); monitorsLabel.setStyleName("dialogLabel"); formDescription.addComponent(monitorsLabel); formDescription.setComponentAlignment(monitorsLabel, Alignment.MIDDLE_LEFT); addComponent(formDescription); setComponentAlignment(formDescription, Alignment.TOP_CENTER); HorizontalLayout chartInfo = new HorizontalLayout(); chartInfo.setSpacing(true); addComponent(chartInfo); setComponentAlignment(chartInfo, Alignment.MIDDLE_CENTER); FormLayout formLayout = new FormLayout(); chartInfo.addComponent(formLayout); chartName = new TextField("Title"); chartName.setImmediate(true); formLayout.addComponent(chartName); chartDescription = new TextField("Description"); chartDescription.setWidth("25em"); chartDescription.setImmediate(true); formLayout.addComponent(chartDescription); chartUnit = new TextField("Measurement Unit"); chartUnit.setImmediate(true); formLayout.addComponent(chartUnit); chartSelectType = new NativeSelect("Type"); chartSelectType.setImmediate(true); for (UserChart.ChartType type : UserChart.ChartType.values()) { chartSelectType.addItem(type.name()); } chartSelectType.setNullSelectionAllowed(false); formLayout.addComponent(chartSelectType); selectCount = new NativeSelect("Points"); selectCount.setImmediate(true); for (int points : UserChart.chartPoints()) { selectCount.addItem(points); selectCount.setItemCaption(points, String.valueOf(points)); } selectCount.setNullSelectionAllowed(false); formLayout.addComponent(selectCount); updateChartInfo(userChart.getName(), userChart.getDescription(), userChart.getUnit(), userChart.getType(), userChart.getPoints()); chartName.addValueChangeListener(new ValueChangeListener() { private static final long serialVersionUID = 0x4C656F6E6172646FL; public void valueChange(ValueChangeEvent event) { String chartName = (String) (event.getProperty()).getValue(); userChart.setName(chartName); refreshChart(); } }); chartDescription.addValueChangeListener(new ValueChangeListener() { private static final long serialVersionUID = 0x4C656F6E6172646FL; public void valueChange(ValueChangeEvent event) { String value = (String) (event.getProperty()).getValue(); userChart.setDescription(value); refreshChart(); } }); chartUnit.addValueChangeListener(new ValueChangeListener() { private static final long serialVersionUID = 0x4C656F6E6172646FL; public void valueChange(ValueChangeEvent event) { String value = (String) (event.getProperty()).getValue(); userChart.setUnit(value); refreshChart(); } }); chartSelectType.addValueChangeListener(new ValueChangeListener() { private static final long serialVersionUID = 0x4C656F6E6172646FL; public void valueChange(ValueChangeEvent event) { String value = (String) (event.getProperty()).getValue(); userChart.setType(value); refreshChart(); } }); selectCount.addValueChangeListener(new ValueChangeListener() { private static final long serialVersionUID = 0x4C656F6E6172646FL; public void valueChange(ValueChangeEvent event) { int points = (Integer) (event.getProperty()).getValue(); userChart.setPoints(points); refreshChart(); } }); chartLayout = drawChart(); addComponent(chartLayout); }
From source file:com.skysql.manager.ui.components.ScriptingProgressLayout.java
License:Open Source License
/** * Sets the error info.//ww w.j av a2 s. c o m * * @param msg the new error info */ public void setErrorInfo(String msg) { Embedded info = new Embedded(null, new ThemeResource("img/alert.png")); info.addStyleName("infoButton"); info.setDescription(msg); resultLayout.addComponent(info); resultLayout.setComponentAlignment(info, Alignment.MIDDLE_CENTER); }
From source file:com.skysql.manager.ui.components.ScriptingProgressLayout.java
License:Open Source License
/** * Builds the progress./*from w w w .j a v a 2s .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.// w w w .j av a 2 s.com * * @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.NodeForm.java
License:Open Source License
/** * Instantiates a new node form.//from www.jav a 2 s .co m * * @param node the node * @param description the description */ NodeForm(final NodeInfo node, String description) { this.node = node; setMargin(new MarginInfo(true, true, false, true)); setSpacing(false); isGalera = node.getSystemType().equals(SystemTypes.Type.galera.name()); HorizontalLayout formDescription = new HorizontalLayout(); formDescription.setSpacing(true); Embedded info = new Embedded(null, new ThemeResource("img/info.png")); info.addStyleName("infoButton"); String infoText = "<table border=0 cellspacing=3 cellpadding=0 summary=\"\">\n" + " <tr bgcolor=\"#ccccff\">" + " <th align=left>Field" + " <th align=left>Description" + " <tr>" + " <td><code>Name</code>" + " <td>Name of the Node" + " <tr bgcolor=\"#eeeeff\">" + " <td><code>Hostname</code>" + " <td>In some systems, a hostname that identifies the node" + " <tr>" + " <td><code>Instance ID</code>" + " <td>The instance ID field is for information only and is not used within the Manager" + " <tr bgcolor=\"#eeeeff\">" + " <td><code>Public IP</code>" + " <td>In some systems, the public IP address of the node" + " <tr>" + " <td><code>Private IP</code>" + " <td>The IP address that accesses the node internally to the manager"; if (!isGalera) { infoText += " <tr bgcolor=\"#eeeeff\">" + " <td><code>Database Username</code>" + " <td>Node system override for database user name" + " <tr>" + " <td><code>Database Password</code>" + " <td>Node system override for database password" + " <tr bgcolor=\"#eeeeff\">" + " <td><code>Replication Username</code>" + " <td>Node system override for replication user name" + " <tr>" + " <td><code>Replication Password</code>" + " <td>Node system override for replication password"; } infoText += " </table>" + " </blockquote>"; info.setDescription(infoText); formDescription.addComponent(info); Label labelDescription = new Label(description); formDescription.addComponent(labelDescription); formDescription.setComponentAlignment(labelDescription, Alignment.MIDDLE_LEFT); addComponent(formDescription); addComponent(form); form.setImmediate(false); form.setFooter(null); form.setDescription(null); String value; if ((value = node.getName()) != null) { name.setValue(value); } form.addField("name", name); name.focus(); name.setImmediate(true); name.addValidator(new NodeNameValidator(node.getName())); if ((value = node.getHostname()) != null) { hostname.setValue(value); } form.addField("hostname", hostname); if ((value = node.getInstanceID()) != null) { instanceID.setValue(value); } form.addField("instanceID", instanceID); if ((value = node.getPublicIP()) != null) { publicIP.setValue(value); } form.addField("publicIP", publicIP); if ((value = node.getPrivateIP()) != null) { privateIP.setValue(value); } form.addField("privateIP", privateIP); privateIP.setRequired(true); privateIP.setRequiredError("Private IP is a required field"); if (!isGalera) { if ((value = node.getDBUsername()) != null) { dbUsername.setValue(value); } form.addField("dbusername", dbUsername); dbUsername.setRequired(true); dbUsername.setImmediate(false); dbUsername.setRequiredError("Database Username is a required field"); dbUsername.addValidator(new UserNotRootValidator(dbUsername.getCaption())); if ((value = node.getDBPassword()) != null) { dbPassword.setValue(value); } form.addField("dbpassword", dbPassword); dbPassword.setRequired(true); dbPassword.setImmediate(false); dbPassword.setRequiredError("Database Password is a required field"); if ((value = node.getDBPassword()) != null) { dbPassword2.setValue(value); } form.addField("dbpassword2", dbPassword2); dbPassword2.setRequired(true); dbPassword2.setImmediate(true); dbPassword2.setRequiredError("Confirm Password is a required field"); dbPassword2.addValidator(new Password2Validator(dbPassword)); if ((value = node.getRepUsername()) != null) { repUsername.setValue(value); } form.addField("repusername", repUsername); repUsername.setRequired(true); repUsername.setImmediate(false); repUsername.setRequiredError("Replication Username is a required field"); repUsername.addValidator(new UserNotRootValidator(repUsername.getCaption())); if ((value = node.getRepPassword()) != null) { repPassword.setValue(value); } form.addField("reppassword", repPassword); repPassword.setRequired(true); repPassword.setImmediate(false); repPassword.setRequiredError("Replication Password is a required field"); if ((value = node.getRepPassword()) != null) { repPassword2.setValue(value); } form.addField("reppassword2", repPassword2); repPassword2.setRequired(true); repPassword2.setImmediate(true); repPassword2.setRequiredError("Confirm Password is a required field"); repPassword2.addValidator(new Password2Validator(repPassword)); } if (node.getID() == null) { Layout layout = form.getLayout(); { Label spacer = new Label(); spacer.setWidth("40px"); layout.addComponent(spacer); } HorizontalLayout optionLayout = new HorizontalLayout(); optionLayout.addStyleName("formInfoLayout"); optionLayout.setSpacing(true); optionLayout.setSizeUndefined(); layout.addComponent(optionLayout); Label padding = new Label("\u00A0\u00A0\u00A0\u00A0\u00A0\u00A0"); optionLayout.addComponent(padding); Embedded info2 = new Embedded(null, new ThemeResource("img/info.png")); info2.addStyleName("infoButton"); info2.setDescription(connectionInfo); optionLayout.addComponent(info2); final Validator validator = new Password2Validator(connectPassword); final OptionGroup connectOption = new OptionGroup("Connection options"); connectOption.setSizeUndefined(); connectOption.addItem(false); connectOption.setItemCaption(false, "Node is not available, user will run connect later"); connectOption.addItem(true); connectOption.setItemCaption(true, "Node is available now, connect automatically"); connectOption.setImmediate(true); connectOption.addValueChangeListener(new Property.ValueChangeListener() { private static final long serialVersionUID = 0x4C656F6E6172646FL; @Override public void valueChange(ValueChangeEvent event) { runConnect = (Boolean) event.getProperty().getValue(); passwordOption.setVisible(runConnect); connectPassword.setRequired(runConnect && usePassword); connectPassword2.setRequired(runConnect && usePassword); connectKey.setRequired(runConnect && !usePassword); if (!runConnect) { connectPassword.setVisible(false); connectPassword2.setVisible(false); connectPassword2.removeValidator(validator); connectKey.setVisible(false); } else { if (usePassword) { connectPassword.setVisible(true); connectPassword2.setVisible(true); connectPassword2.addValidator(validator); } else { connectKey.setVisible(true); } } form.setComponentError(null); form.setValidationVisible(false); } }); optionLayout.addComponent(connectOption); optionLayout.setComponentAlignment(connectOption, Alignment.MIDDLE_LEFT); connectOption.select(true); passwordOption.addItem(true); passwordOption.setItemCaption(true, "Authenticate with root user"); passwordOption.addItem(false); passwordOption.setItemCaption(false, "Authenticate with SSH Key"); passwordOption.setImmediate(true); passwordOption.addValueChangeListener(new Property.ValueChangeListener() { private static final long serialVersionUID = 0x4C656F6E6172646FL; @Override public void valueChange(ValueChangeEvent event) { usePassword = (Boolean) event.getProperty().getValue(); if (usePassword) { connectPassword2.addValidator(validator); } else { connectPassword2.removeValidator(validator); } connectPassword.setVisible(usePassword); connectPassword.setRequired(usePassword); connectPassword2.setVisible(usePassword); connectPassword2.setRequired(usePassword); connectKey.setVisible(!usePassword); connectKey.setRequired(!usePassword); form.setComponentError(null); form.setValidationVisible(false); } }); layout.addComponent(passwordOption); passwordOption.select(false); form.addField("connectPassword", connectPassword); connectPassword.setImmediate(false); connectPassword.setRequiredError("Root Password is a required field"); form.addField("connectPassword2", connectPassword2); connectPassword2.setImmediate(true); connectPassword2.setRequiredError("Confirm Password is a required field"); form.addField("connectKey", connectKey); connectKey.setStyleName("sshkey"); connectKey.setColumns(41); connectKey.setRequiredError("SSH Key is a required field"); } }