List of usage examples for com.vaadin.ui NativeSelect NativeSelect
public NativeSelect(String caption)
From source file:com.pms.component.ganttchart.DemoUI.java
License:Apache License
private Panel createControls() { Panel panel = new Panel(); panel.setWidth(100, Sizeable.Unit.PERCENTAGE); controls = new HorizontalLayout(); controls.setSpacing(true);//from www .j a v a2 s. co m controls.setMargin(true); panel.setContent(controls); start = createStartDateField(); end = createEndDateField(); Button createStep = new Button("Create New Step...", createStepClickListener); HorizontalLayout heightAndUnit = new HorizontalLayout(Util.createHeightEditor(gantt), Util.createHeightUnitEditor(gantt)); HorizontalLayout widthAndUnit = new HorizontalLayout(Util.createWidthEditor(gantt), Util.createWidthUnitEditor(gantt)); reso = new NativeSelect("Resolution"); reso.setNullSelectionAllowed(false); reso.addItem(org.tltv.gantt.client.shared.Resolution.Hour); reso.addItem(org.tltv.gantt.client.shared.Resolution.Day); reso.addItem(org.tltv.gantt.client.shared.Resolution.Week); reso.setValue(gantt.getResolution()); reso.setImmediate(true); reso.addValueChangeListener(resolutionValueChangeListener); localeSelect = new NativeSelect("Locale") { @Override public void attach() { super.attach(); if (getValue() == null) { // use default locale setValue(gantt.getLocale()); addValueChangeListener(localeValueChangeListener); } } }; localeSelect.setNullSelectionAllowed(false); for (Locale l : Locale.getAvailableLocales()) { localeSelect.addItem(l); localeSelect.setItemCaption(l, l.getDisplayName(DashboardUI.getCurrent().getUI().getLocale())); } localeSelect.setImmediate(true); String[] zones = new String[] { "GMT-0", "GMT-1", "GMT-2", "GMT-3", "GMT-4", "GMT-5", "GMT-6", "GMT-7", "GMT-8", "GMT-9", "GMT-10", "GMT-11", "GMT-12", "GMT+1", "GMT+2", "GMT+3", "GMT+4", "GMT+5", "GMT+6", "GMT+7", "GMT+8", "GMT+9", "GMT+10", "GMT+11", "GMT+12", "GMT+13", "GMT+14" }; NativeSelect timezoneSelect = new NativeSelect("Timezone"); timezoneSelect.setNullSelectionAllowed(false); timezoneSelect.addItem("Default"); timezoneSelect.setItemCaption("Default", "Default (" + TimeZone.getDefault().getDisplayName() + ")"); for (String timezoneId : zones) { TimeZone tz = TimeZone.getTimeZone(timezoneId); timezoneSelect.addItem(timezoneId); timezoneSelect.setItemCaption(timezoneId, tz.getDisplayName(DashboardUI.getCurrent().getUI().getLocale())); } timezoneSelect.setValue("Default"); timezoneSelect.setImmediate(true); timezoneSelect.addValueChangeListener(timezoneValueChangeListener); controls.addComponent(start); controls.addComponent(end); controls.addComponent(reso); controls.addComponent(localeSelect); controls.addComponent(timezoneSelect); controls.addComponent(heightAndUnit); controls.addComponent(widthAndUnit); controls.addComponent(createStep); controls.setComponentAlignment(createStep, Alignment.MIDDLE_LEFT); return panel; }
From source file:com.pms.component.ganttchart.DemoUI.java
License:Apache License
private void openStepEditor(AbstractStep step) { final Window win = new Window("Step Editor"); win.setResizable(false);/*from w w w .j av a 2s. c o m*/ win.center(); final Collection<Component> hidden = new ArrayList<Component>(); BeanItem<AbstractStep> item = new BeanItem<AbstractStep>(step); final FieldGroup group = new FieldGroup(item); group.setBuffered(true); TextField captionField = new TextField("Caption"); captionField.setNullRepresentation(""); group.bind(captionField, "caption"); TextField descriptionField = new TextField("Description"); descriptionField.setNullRepresentation(""); group.bind(descriptionField, "description"); descriptionField.setVisible(false); hidden.add(descriptionField); NativeSelect captionMode = new NativeSelect("Caption Mode"); captionMode.addItem(Step.CaptionMode.TEXT); captionMode.addItem(Step.CaptionMode.HTML); group.bind(captionMode, "captionMode"); captionMode.setVisible(false); hidden.add(captionMode); final NativeSelect parentStepSelect = new NativeSelect("Parent Step"); parentStepSelect.setEnabled(false); if (!gantt.getSteps().contains(step)) { // new step parentStepSelect.setEnabled(true); for (Step parentStepCanditate : gantt.getSteps()) { parentStepSelect.addItem(parentStepCanditate); parentStepSelect.setItemCaption(parentStepCanditate, parentStepCanditate.getCaption()); if (step instanceof SubStep) { if (parentStepCanditate.getSubSteps().contains(step)) { parentStepSelect.setValue(parentStepCanditate); parentStepSelect.setEnabled(false); break; } } } } parentStepSelect.setVisible(false); hidden.add(parentStepSelect); TextField bgField = new TextField("Background color"); bgField.setNullRepresentation(""); group.bind(bgField, "backgroundColor"); bgField.setVisible(false); hidden.add(bgField); DateField startDate = new DateField("Start date"); startDate.setLocale(gantt.getLocale()); startDate.setTimeZone(gantt.getTimeZone()); startDate.setResolution(Resolution.SECOND); startDate.setConverter(new DateToLongConverter()); group.bind(startDate, "startDate"); DateField endDate = new DateField("End date"); endDate.setLocale(gantt.getLocale()); endDate.setTimeZone(gantt.getTimeZone()); endDate.setResolution(Resolution.SECOND); endDate.setConverter(new DateToLongConverter()); group.bind(endDate, "endDate"); CheckBox showMore = new CheckBox("Show all settings"); showMore.addValueChangeListener(new ValueChangeListener() { @Override public void valueChange(ValueChangeEvent event) { for (Component c : hidden) { c.setVisible((Boolean) event.getProperty().getValue()); } win.center(); } }); VerticalLayout content = new VerticalLayout(); content.setMargin(true); content.setSpacing(true); win.setContent(content); content.addComponent(captionField); content.addComponent(captionMode); content.addComponent(descriptionField); content.addComponent(parentStepSelect); content.addComponent(bgField); content.addComponent(startDate); content.addComponent(endDate); content.addComponent(showMore); HorizontalLayout buttons = new HorizontalLayout(); content.addComponent(buttons); Button ok = new Button("Ok", new ClickListener() { @Override public void buttonClick(ClickEvent event) { try { group.commit(); AbstractStep step = ((BeanItem<AbstractStep>) group.getItemDataSource()).getBean(); gantt.markStepDirty(step); if (parentStepSelect.isEnabled() && parentStepSelect.getValue() != null) { SubStep subStep = addSubStep(parentStepSelect, step); step = subStep; } if (step instanceof Step && !gantt.getSteps().contains(step)) { gantt.addStep((Step) step); } if (ganttListener != null && step instanceof Step) { ganttListener.stepModified((Step) step); } win.close(); } catch (CommitException e) { Notification.show("Commit failed", e.getMessage(), Type.ERROR_MESSAGE); e.printStackTrace(); } } private SubStep addSubStep(final NativeSelect parentStepSelect, AbstractStep dataSource) { SubStep subStep = new SubStep(); subStep.setCaption(dataSource.getCaption()); subStep.setCaptionMode(dataSource.getCaptionMode()); subStep.setStartDate(dataSource.getStartDate()); subStep.setEndDate(dataSource.getEndDate()); subStep.setBackgroundColor(dataSource.getBackgroundColor()); subStep.setDescription(dataSource.getDescription()); subStep.setStyleName(dataSource.getStyleName()); ((Step) parentStepSelect.getValue()).addSubStep(subStep); return subStep; } }); Button cancel = new Button("Cancel", new ClickListener() { @Override public void buttonClick(ClickEvent event) { group.discard(); win.close(); } }); Button delete = new Button("Delete", new ClickListener() { @Override public void buttonClick(ClickEvent event) { AbstractStep step = ((BeanItem<AbstractStep>) group.getItemDataSource()).getBean(); if (step instanceof SubStep) { SubStep substep = (SubStep) step; substep.getOwner().removeSubStep(substep); } else { gantt.removeStep((Step) step); if (ganttListener != null) { ganttListener.stepDeleted((Step) step); } } win.close(); } }); buttons.addComponent(ok); buttons.addComponent(cancel); buttons.addComponent(delete); win.setClosable(true); DashboardUI.getCurrent().getUI().addWindow(win); }
From source file:com.pms.component.ganttchart.GanttChart.java
License:Apache License
private Panel createControls() { Panel panel = new Panel(); panel.setWidth(100, Sizeable.Unit.PERCENTAGE); controls = new HorizontalLayout(); controls.setSpacing(true);/*from w w w.j a va2 s. c om*/ controls.setMargin(true); panel.setContent(controls); start = createStartDateField(); end = createEndDateField(); Button createStep = new Button("Create New Step...", createStepClickListener); HorizontalLayout heightAndUnit = new HorizontalLayout(Util.createHeightEditor(gantt), Util.createHeightUnitEditor(gantt)); HorizontalLayout widthAndUnit = new HorizontalLayout(Util.createWidthEditor(gantt), Util.createWidthUnitEditor(gantt)); reso = new NativeSelect("Resolution"); reso.setNullSelectionAllowed(false); reso.addItem(org.tltv.gantt.client.shared.Resolution.Hour); reso.addItem(org.tltv.gantt.client.shared.Resolution.Day); reso.addItem(org.tltv.gantt.client.shared.Resolution.Week); reso.setValue(gantt.getResolution()); reso.setImmediate(true); reso.addValueChangeListener(resolutionValueChangeListener); localeSelect = new NativeSelect("Locale") { @Override public void attach() { super.attach(); if (getValue() == null) { // use default locale setValue(gantt.getLocale()); addValueChangeListener(localeValueChangeListener); } } }; localeSelect.setNullSelectionAllowed(false); for (Locale l : Locale.getAvailableLocales()) { localeSelect.addItem(l); localeSelect.setItemCaption(l, l.getDisplayName(DashboardUI.getCurrent().getUI().getLocale())); } localeSelect.setImmediate(true); String[] zones = new String[] { "GMT-0", "GMT-1", "GMT-2", "GMT-3", "GMT-4", "GMT-5", "GMT-6", "GMT-7", "GMT-8", "GMT-9", "GMT-10", "GMT-11", "GMT-12", "GMT+1", "GMT+2", "GMT+3", "GMT+4", "GMT+5", "GMT+6", "GMT+7", "GMT+8", "GMT+9", "GMT+10", "GMT+11", "GMT+12", "GMT+13", "GMT+14" }; NativeSelect timezoneSelect = new NativeSelect("Timezone"); timezoneSelect.setNullSelectionAllowed(false); timezoneSelect.addItem("Default"); timezoneSelect.setItemCaption("Default", "Default (" + TimeZone.getDefault().getDisplayName() + ")"); for (String timezoneId : zones) { TimeZone tz = TimeZone.getTimeZone(timezoneId); timezoneSelect.addItem(timezoneId); timezoneSelect.setItemCaption(timezoneId, tz.getDisplayName(DashboardUI.getCurrent().getUI().getLocale())); } timezoneSelect.setValue("Default"); timezoneSelect.setImmediate(true); timezoneSelect.addValueChangeListener(timezoneValueChangeListener); controls.addComponent(start); controls.addComponent(end); controls.addComponent(reso); //controls.addComponent(localeSelect); //controls.addComponent(timezoneSelect); controls.addComponent(heightAndUnit); controls.addComponent(widthAndUnit); //controls.addComponent(createStep); // controls.setComponentAlignment(createStep, Alignment.MIDDLE_LEFT); //controls.setComponentAlignment(widthAndUnit, Alignment.MIDDLE_LEFT); return panel; }
From source file:com.pms.component.ganttchart.scheduletask.UserStoryGanntChart.java
License:Apache License
private Panel createControls() { Panel panel = new Panel(); panel.setWidth(100, Sizeable.Unit.PERCENTAGE); controls = new HorizontalLayout(); controls.setSpacing(true);// ww w .j a va2s .c o m controls.setMargin(true); panel.setContent(controls); start = createStartDateField(); end = createEndDateField(); Button createStep = new Button("Create New Step...", createStepClickListener); HorizontalLayout heightAndUnit = new HorizontalLayout(Util.createHeightEditor(gantt), Util.createHeightUnitEditor(gantt)); HorizontalLayout widthAndUnit = new HorizontalLayout(Util.createWidthEditor(gantt), Util.createWidthUnitEditor(gantt)); reso = new NativeSelect("Resolution"); reso.setNullSelectionAllowed(false); reso.addItem(org.tltv.gantt.client.shared.Resolution.Hour); reso.addItem(org.tltv.gantt.client.shared.Resolution.Day); reso.addItem(org.tltv.gantt.client.shared.Resolution.Week); reso.setValue(gantt.getResolution()); //reso.setValue(org.tltv.gantt.client.shared.Resolution.Week); reso.setImmediate(true); reso.addValueChangeListener(resolutionValueChangeListener); localeSelect = new NativeSelect("Locale") { @Override public void attach() { super.attach(); if (getValue() == null) { // use default locale setValue(gantt.getLocale()); addValueChangeListener(localeValueChangeListener); } } }; localeSelect.setNullSelectionAllowed(false); for (Locale l : Locale.getAvailableLocales()) { localeSelect.addItem(l); localeSelect.setItemCaption(l, l.getDisplayName(DashboardUI.getCurrent().getUI().getLocale())); } localeSelect.setImmediate(true); String[] zones = new String[] { "GMT-0", "GMT-1", "GMT-2", "GMT-3", "GMT-4", "GMT-5", "GMT-6", "GMT-7", "GMT-8", "GMT-9", "GMT-10", "GMT-11", "GMT-12", "GMT+1", "GMT+2", "GMT+3", "GMT+4", "GMT+5", "GMT+6", "GMT+7", "GMT+8", "GMT+9", "GMT+10", "GMT+11", "GMT+12", "GMT+13", "GMT+14" }; NativeSelect timezoneSelect = new NativeSelect("Timezone"); timezoneSelect.setNullSelectionAllowed(false); timezoneSelect.addItem("Default"); timezoneSelect.setItemCaption("Default", "Default (" + TimeZone.getDefault().getDisplayName() + ")"); for (String timezoneId : zones) { TimeZone tz = TimeZone.getTimeZone(timezoneId); timezoneSelect.addItem(timezoneId); timezoneSelect.setItemCaption(timezoneId, tz.getDisplayName(DashboardUI.getCurrent().getUI().getLocale())); } timezoneSelect.setValue("Default"); timezoneSelect.setImmediate(true); timezoneSelect.addValueChangeListener(timezoneValueChangeListener); controls.addComponent(start); controls.addComponent(end); controls.addComponent(reso); //controls.addComponent(localeSelect); //controls.addComponent(timezoneSelect); controls.addComponent(heightAndUnit); controls.addComponent(widthAndUnit); //controls.addComponent(createStep); // controls.setComponentAlignment(createStep, Alignment.MIDDLE_LEFT); //controls.setComponentAlignment(widthAndUnit, Alignment.MIDDLE_LEFT); return panel; }
From source file:com.pms.component.member.taskganntchart.TaskGanttChart.java
License:Apache License
private Panel createControls() { Panel panel = new Panel(); panel.setWidth(100, Sizeable.Unit.PERCENTAGE); controls = new HorizontalLayout(); controls.setSpacing(true);/*from w w w .ja v a2 s . c o m*/ controls.setMargin(true); panel.setContent(controls); start = createStartDateField(); end = createEndDateField(); Button createStep = new Button("Create New Step...", createStepClickListener); HorizontalLayout heightAndUnit = new HorizontalLayout(Util.createHeightEditor(gantt), Util.createHeightUnitEditor(gantt)); HorizontalLayout widthAndUnit = new HorizontalLayout(Util.createWidthEditor(gantt), Util.createWidthUnitEditor(gantt)); reso = new NativeSelect("Resolution"); reso.setNullSelectionAllowed(false); reso.addItem(org.tltv.gantt.client.shared.Resolution.Hour); reso.addItem(org.tltv.gantt.client.shared.Resolution.Day); reso.addItem(org.tltv.gantt.client.shared.Resolution.Week); reso.setValue(gantt.getResolution()); reso.setImmediate(true); reso.addValueChangeListener(resolutionValueChangeListener); localeSelect = new NativeSelect("Locale") { @Override public void attach() { super.attach(); if (getValue() == null) { // use default locale setValue(gantt.getLocale()); addValueChangeListener(localeValueChangeListener); } } }; localeSelect.setNullSelectionAllowed(false); for (Locale l : Locale.getAvailableLocales()) { localeSelect.addItem(l); localeSelect.setItemCaption(l, l.getDisplayName(DashboardUI.getCurrent().getUI().getLocale())); } localeSelect.setImmediate(true); String[] zones = new String[] { "GMT-0", "GMT-1", "GMT-2", "GMT-3", "GMT-4", "GMT-5", "GMT-6", "GMT-7", "GMT-8", "GMT-9", "GMT-10", "GMT-11", "GMT-12", "GMT+1", "GMT+2", "GMT+3", "GMT+4", "GMT+5", "GMT+6", "GMT+7", "GMT+8", "GMT+9", "GMT+10", "GMT+11", "GMT+12", "GMT+13", "GMT+14" }; NativeSelect timezoneSelect = new NativeSelect("Timezone"); timezoneSelect.setNullSelectionAllowed(false); timezoneSelect.addItem("Default"); timezoneSelect.setItemCaption("Default", "Default (" + TimeZone.getDefault().getDisplayName() + ")"); for (String timezoneId : zones) { TimeZone tz = TimeZone.getTimeZone(timezoneId); timezoneSelect.addItem(timezoneId); timezoneSelect.setItemCaption(timezoneId, tz.getDisplayName(DashboardUI.getCurrent().getUI().getLocale())); } timezoneSelect.setValue("Default"); timezoneSelect.setImmediate(true); timezoneSelect.addValueChangeListener(timezoneValueChangeListener); controls.addComponent(start); controls.addComponent(end); controls.addComponent(reso); //controls.addComponent(localeSelect); //controls.addComponent(timezoneSelect); //controls.addComponent(heightAndUnit); //controls.addComponent(widthAndUnit); //controls.addComponent(createStep); // controls.setComponentAlignment(createStep, Alignment.MIDDLE_LEFT); //controls.setComponentAlignment(widthAndUnit, Alignment.MIDDLE_LEFT); return panel; }
From source file:com.skysql.manager.ui.CalendarDialog.java
License:Open Source License
/** * Update calendar event form./*from ww w. j a v a2 s. c om*/ * * @param event the event */ @SuppressWarnings("deprecation") private void updateCalendarEventForm(CalendarEvent event) { // Lets create a CalendarEvent BeanItem and pass it to the form's data // source. BeanItem<CalendarEvent> item = new BeanItem<CalendarEvent>(event); scheduleEventForm.setBuffered(true); scheduleEventForm.setItemDataSource(item); scheduleEventForm.setFormFieldFactory(new FormFieldFactory() { private static final long serialVersionUID = 1L; public Field createField(Item item, Object propertyId, Component uiContext) { if (propertyId.equals("caption")) { TextField f = createTextField("Caption"); f.focus(); return f; } else if (propertyId.equals("description")) { TextField f = createTextField("Description"); //f.setRows(3); return f; } else if (propertyId.equals("styleName")) { return createStyleNameSelect(); } else if (propertyId.equals("start")) { startDateField = createDateField("Start"); return startDateField; } else if (propertyId.equals("end")) { return createDateField("End"); } else if (propertyId.equals("allDay")) { CheckBox cb = createCheckBox("All-day"); cb.addListener(new Property.ValueChangeListener() { private static final long serialVersionUID = -7104996493482558021L; public void valueChange(ValueChangeEvent event) { Object value = event.getProperty().getValue(); if (value instanceof Boolean && Boolean.TRUE.equals(value)) { setFormDateResolution(Resolution.DAY); } else { setFormDateResolution(Resolution.MINUTE); } } }); return cb; } else if (propertyId.equals("repeat")) { repeatSelectField = createRepeatSelect(); repeatSelectField.addValueChangeListener(new ValueChangeListener() { private static final long serialVersionUID = 1L; public void valueChange(ValueChangeEvent event) { if (untilSelectField != null) { boolean isRepeat = !(event.getProperty().getValue() .equals(CalendarCustomEvent.RECUR_NONE)); untilSelectField.setVisible(isRepeat); untilSelectField.markAsDirty(); } } }); return repeatSelectField; } else if (propertyId.equals("untilSelect")) { untilSelectField = createUntilSelect(); if (repeatSelectField != null && repeatSelectField.getValue().equals(CalendarCustomEvent.RECUR_NONE)) { untilSelectField.setVisible(false); } untilSelectField.addValueChangeListener(new ValueChangeListener() { private static final long serialVersionUID = 1L; public void valueChange(ValueChangeEvent event) { Until until = Until.valueOf((String) event.getProperty().getValue()); boolean untilCount = false; boolean untilDate = false; switch (until) { case never: break; case count: untilCount = true; break; case date: untilDate = true; break; } if (untilCountField != null) { untilCountField.setVisible(untilCount); untilCountField.markAsDirty(); } if (untilDateField != null) { untilDateField.setVisible(untilDate); untilDateField.markAsDirty(); } } }); return untilSelectField; } else if (propertyId.equals("untilCount")) { untilCountField = createTextField("Times"); if (!untilSelectField.getValue().equals(Until.count.name())) { untilCountField.setVisible(false); } return untilCountField; } else if (propertyId.equals("untilDate")) { untilDateField = createDateField("On Date"); if (!untilSelectField.getValue().equals(Until.date.name())) { untilDateField.setVisible(false); } return untilDateField; } else if (propertyId.equals("node")) { NativeSelect ns = createNodeSelect(); ns.addValueChangeListener(new ValueChangeListener() { private static final long serialVersionUID = 1L; public void valueChange(ValueChangeEvent event) { String nodeID = ((String) event.getProperty().getValue()); } }); return ns; } return null; } private CheckBox createCheckBox(String caption) { CheckBox cb = new CheckBox(caption); cb.setImmediate(true); return cb; } private TextField createTextField(String caption) { TextField f = new TextField(caption); f.setNullRepresentation(""); return f; } private DateField createDateField(String caption) { DateField f = new DateField(caption); if (useSecondResolution) { f.setResolution(Resolution.SECOND); } else { f.setResolution(Resolution.MINUTE); } return f; } private NativeSelect createStyleNameSelect() { NativeSelect s = new NativeSelect("Color"); s.addContainerProperty("c", String.class, ""); s.setItemCaptionPropertyId("c"); Item i = s.addItem("color1"); i.getItemProperty("c").setValue("Green"); i = s.addItem("color2"); i.getItemProperty("c").setValue("Blue"); i = s.addItem("color3"); i.getItemProperty("c").setValue("Red"); i = s.addItem("color4"); i.getItemProperty("c").setValue("Orange"); return s; } private NativeSelect createRepeatSelect() { NativeSelect s = new NativeSelect("Repeat"); s.setImmediate(true); s.setNullSelectionAllowed(false); s.addContainerProperty("r", String.class, ""); s.setItemCaptionPropertyId("r"); Item i = s.addItem(CalendarCustomEvent.RECUR_NONE); i.getItemProperty("r").setValue("None"); i = s.addItem(Recur.HOURLY); i.getItemProperty("r").setValue("Every Hour"); i = s.addItem(Recur.DAILY); i.getItemProperty("r").setValue("Every Day"); i = s.addItem(Recur.WEEKLY); i.getItemProperty("r").setValue("Every Week"); i = s.addItem(Recur.MONTHLY); i.getItemProperty("r").setValue("Every Month"); i = s.addItem(Recur.YEARLY); i.getItemProperty("r").setValue("Every Year"); return s; } private NativeSelect createUntilSelect() { NativeSelect s = new NativeSelect("End"); s.setImmediate(true); s.setNullSelectionAllowed(false); s.addContainerProperty("u", String.class, ""); s.setItemCaptionPropertyId("u"); Item i = s.addItem(Until.never.name()); i.getItemProperty("u").setValue("Never"); i = s.addItem(Until.count.name()); i.getItemProperty("u").setValue("After"); i = s.addItem(Until.date.name()); i.getItemProperty("u").setValue("On Date"); return s; } private NativeSelect createNodeSelect() { //Select s = new Select("Node"); final NativeSelect s = new NativeSelect("Node"); s.setImmediate(true); s.setNullSelectionAllowed(false); s.addContainerProperty("n", String.class, ""); s.setItemCaptionPropertyId("n"); for (NodeInfo node : nodes) { Item i = s.addItem(node.getID()); i.getItemProperty("n").setValue(node.getName()); } return s; } }); scheduleEventForm.setVisibleItemProperties(new Object[] { "caption", "description", "node", "start", "repeat", "untilSelect", "untilCount", "untilDate" }); Date occurrence = ((CalendarCustomEvent) event).getOccurrence(); if (occurrence != null) { startDateField.setValue(occurrence); } }
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 www .ja v a2 s .co 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.ChartControls.java
License:Open Source License
/** * Instantiates a new chart controls./*from www . ja v a2 s . c om*/ */ public ChartControls() { setSpacing(true); final FormLayout form1 = new FormLayout(); form1.setSpacing(false); form1.setMargin(false); addComponent(form1); selectInterval = new NativeSelect("Charts Time Span"); selectInterval.setImmediate(true); selectInterval.setNullSelectionAllowed(false); selectInterval.addItem(INTERVAL_5_MIN); selectInterval.addItem(INTERVAL_10_MIN); selectInterval.addItem(INTERVAL_30_MIN); selectInterval.addItem(INTERVAL_1_HOUR); selectInterval.addItem(INTERVAL_6_HOURS); selectInterval.addItem(INTERVAL_12_HOURS); selectInterval.addItem(INTERVAL_1_DAY); selectInterval.addItem(INTERVAL_1_WEEK); selectInterval.addItem(INTERVAL_1_MONTH); selectInterval.setItemCaption(INTERVAL_5_MIN, "5 Minutes"); selectInterval.setItemCaption(INTERVAL_10_MIN, "10 Minutes"); selectInterval.setItemCaption(INTERVAL_30_MIN, "30 Minutes"); selectInterval.setItemCaption(INTERVAL_1_HOUR, "1 Hour"); selectInterval.setItemCaption(INTERVAL_6_HOURS, "6 Hours"); selectInterval.setItemCaption(INTERVAL_12_HOURS, "12 Hours"); selectInterval.setItemCaption(INTERVAL_1_DAY, "1 Day"); selectInterval.setItemCaption(INTERVAL_1_WEEK, "1 Week"); selectInterval.setItemCaption(INTERVAL_1_MONTH, "1 Month"); form1.addComponent(selectInterval); final FormLayout form2 = new FormLayout(); form2.setSpacing(false); form2.setMargin(false); addComponent(form2); selectTheme = new NativeSelect("Theme"); selectTheme.setImmediate(true); selectTheme.setNullSelectionAllowed(false); for (Themes theme : Themes.values()) { selectTheme.addItem(theme.name()); } form2.addComponent(selectTheme); }
From source file:com.skysql.manager.ui.components.ParametersLayout.java
License:Open Source License
/** * Instantiates a new parameters layout. * * @param runningTask the running task/*from w ww . j a v a2 s . c om*/ * @param nodeInfo the node info * @param commandEnum the command enum */ public ParametersLayout(final RunningTask runningTask, final NodeInfo nodeInfo, Commands.Command commandEnum) { this.runningTask = runningTask; addStyleName("parametersLayout"); setSizeFull(); setSpacing(true); setMargin(true); params = new HashMap<String, String>(); runningTask.selectParameter(params); switch (commandEnum) { case backup: backupLevel = new OptionGroup("Backup Level"); backupLevel.setImmediate(true); backupLevel.addItem(BackupRecord.BACKUP_TYPE_FULL); backupLevel.setItemCaption(BackupRecord.BACKUP_TYPE_FULL, "Full"); backupLevel.addItem(BackupRecord.BACKUP_TYPE_INCREMENTAL); backupLevel.setItemCaption(BackupRecord.BACKUP_TYPE_INCREMENTAL, "Incremental"); addComponent(backupLevel); setComponentAlignment(backupLevel, Alignment.MIDDLE_LEFT); backupLevel.addValueChangeListener(new ValueChangeListener() { private static final long serialVersionUID = 0x4C656F6E6172646FL; public void valueChange(ValueChangeEvent event) { String level = (String) event.getProperty().getValue(); params.put(PARAM_BACKUP_TYPE, level); if (level.equals(BackupRecord.BACKUP_TYPE_INCREMENTAL)) { addComponent(prevBackupsLayout); selectPrevBackup.select(firstItem); } else { params.remove(PARAM_BACKUP_PARENT); if (getComponentIndex(prevBackupsLayout) != -1) { removeComponent(prevBackupsLayout); } } } }); backupLevel.setValue(BackupRecord.BACKUP_TYPE_FULL); isParameterReady = true; case restore: VerticalLayout restoreLayout = new VerticalLayout(); restoreLayout.setSpacing(true); if (commandEnum == Command.restore) { addComponent(restoreLayout); FormLayout formLayout = new FormLayout(); //formLayout.setMargin(new MarginInfo(false, false, true, false)); formLayout.setMargin(false); restoreLayout.addComponent(formLayout); final NativeSelect selectSystem; selectSystem = new NativeSelect("Backups from"); selectSystem.setImmediate(true); selectSystem.setNullSelectionAllowed(false); SystemInfo systemInfo = VaadinSession.getCurrent().getAttribute(SystemInfo.class); for (SystemRecord systemRecord : systemInfo.getSystemsMap().values()) { if (!systemRecord.getID().equals(SystemInfo.SYSTEM_ROOT)) { selectSystem.addItem(systemRecord.getID()); selectSystem.setItemCaption(systemRecord.getID(), systemRecord.getName()); } } selectSystem.select(systemInfo.getCurrentID()); formLayout.addComponent(selectSystem); selectSystem.addValueChangeListener(new ValueChangeListener() { private static final long serialVersionUID = 0x4C656F6E6172646FL; public void valueChange(ValueChangeEvent event) { String systemID = (String) event.getProperty().getValue(); Backups backups = new Backups(systemID, null); backupsList = backups.getBackupsList(); selectPrevBackup.removeAllItems(); firstItem = null; if (backupsList != null && backupsList.size() > 0) { Collection<BackupRecord> set = backupsList.values(); Iterator<BackupRecord> iter = set.iterator(); while (iter.hasNext()) { BackupRecord backupRecord = iter.next(); String backupID = backupRecord.getID(); selectPrevBackup.addItem(backupID); selectPrevBackup.setItemCaption(backupID, "ID: " + backupID + ", " + backupRecord.getStarted()); if (firstItem == null) { firstItem = backupID; selectPrevBackup.select(firstItem); } } runningTask.getControlsLayout().enableControls(true, Controls.Run); } else { if (backupInfoLayout != null) { displayBackupInfo(backupInfoLayout, new BackupRecord()); } runningTask.getControlsLayout().enableControls(false, Controls.Run); } } }); } prevBackupsLayout = new HorizontalLayout(); restoreLayout.addComponent(prevBackupsLayout); selectPrevBackup = (commandEnum == Command.backup) ? new ListSelect("Backups") : new ListSelect(); selectPrevBackup.setImmediate(true); selectPrevBackup.setNullSelectionAllowed(false); selectPrevBackup.setRows(8); // Show a few items and a scrollbar if there are more selectPrevBackup.setWidth("20em"); prevBackupsLayout.addComponent(selectPrevBackup); final Backups backups = new Backups(nodeInfo.getParentID(), null); //*** this is for when we only want backups from a specific node // backupsList = backups.getBackupsForNode(nodeInfo.getID()); backupsList = backups.getBackupsList(); if (backupsList != null && backupsList.size() > 0) { Collection<BackupRecord> set = backupsList.values(); Iterator<BackupRecord> iter = set.iterator(); while (iter.hasNext()) { BackupRecord backupRecord = iter.next(); selectPrevBackup.addItem(backupRecord.getID()); selectPrevBackup.setItemCaption(backupRecord.getID(), "ID: " + backupRecord.getID() + ", " + backupRecord.getStarted()); if (firstItem == null) { firstItem = backupRecord.getID(); } } backupInfoLayout = new VerticalLayout(); backupInfoLayout.setSpacing(false); backupInfoLayout.setMargin(new MarginInfo(false, true, false, true)); prevBackupsLayout.addComponent(backupInfoLayout); prevBackupsLayout.setComponentAlignment(backupInfoLayout, Alignment.MIDDLE_CENTER); selectPrevBackup.addValueChangeListener(new ValueChangeListener() { private static final long serialVersionUID = 0x4C656F6E6172646FL; public void valueChange(ValueChangeEvent event) { String backupID = (String) event.getProperty().getValue(); if (backupID == null) { isParameterReady = false; runningTask.getControlsLayout().enableControls(isParameterReady, Controls.Run); return; } BackupRecord backupRecord = backupsList.get(backupID); displayBackupInfo(backupInfoLayout, backupRecord); if (backupLevel != null) { // we're doing a backup params.put(PARAM_BACKUP_PARENT, backupRecord.getID()); } else { // we're doing a restore params.put(PARAM_BACKUP_ID, backupRecord.getID()); } isParameterReady = true; ScriptingControlsLayout controlsLayout = runningTask.getControlsLayout(); if (controlsLayout != null) { controlsLayout.enableControls(isParameterReady, Controls.Run); } } }); // final DisplayBackupRecord displayRecord = new // DisplayBackupRecord(parameterLayout); if (commandEnum == Command.restore) { restoreLayout.addComponent(prevBackupsLayout); selectPrevBackup.select(firstItem); } } else { // no previous backups if (commandEnum == Command.backup) { backupLevel.setEnabled(false); isParameterReady = true; } else if (commandEnum == Command.restore) { //runningTask.getControlsLayout().enableControls(false, Controls.run); } } break; case connect: VerticalLayout connectLayout = new VerticalLayout(); addComponent(connectLayout); final Validator validator = new Password2Validator(connectPassword); 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); boolean isValid; if (runningTask.getControlsLayout() != null) { if (usePassword) { isValid = connectPassword.isValid(); } else { isValid = connectKey.isValid(); } if (isValid) { connectParamsListener.valueChange(null); } else { form.setComponentError(null); form.setValidationVisible(false); runningTask.getControlsLayout().enableControls(false, Controls.Run); } } } }); connectLayout.addComponent(passwordOption); passwordOption.select(false); connectLayout.addComponent(form); form.setImmediate(true); form.setFooter(null); Layout layout = form.getLayout(); form.addField("connectPassword", connectPassword); connectPassword.setImmediate(true); connectPassword.setRequiredError("Root Password is a required field"); connectPassword.addValueChangeListener(connectParamsListener); form.addField("connectPassword2", connectPassword2); connectPassword2.setImmediate(true); connectPassword2.setRequiredError("Confirm Password is a required field"); connectPassword2.addValueChangeListener(connectParamsListener); form.addField("connectKey", connectKey); connectKey.setStyleName("sshkey"); connectKey.setColumns(41); connectKey.setImmediate(true); connectKey.setRequiredError("SSH Key is a required field"); connectKey.addValueChangeListener(connectParamsListener); break; default: isParameterReady = true; break; } }
From source file:com.skysql.manager.ui.GeneralSettings.java
License:Open Source License
/** * Backups layout.//from ww w . jav a2 s . com * * @return the vertical layout */ private VerticalLayout backupsLayout() { VerticalLayout layout = new VerticalLayout(); layout.setSpacing(true); layout.setMargin(true); final Label label = new Label("<h2>Backups</h2>", ContentMode.HTML); layout.addComponent(label); final SystemInfo systemInfo = VaadinSession.getCurrent().getAttribute(SystemInfo.class); LinkedHashMap<String, String> properties = systemInfo.getCurrentSystem().getProperties(); if (properties != null) { maxBackupCount = properties.get(SystemInfo.PROPERTY_DEFAULTMAXBACKUPCOUNT); maxBackupSize = properties.get(SystemInfo.PROPERTY_DEFAULTMAXBACKUPSIZE); } NativeSelect selectCount = new NativeSelect("Max number of backups"); selectCount.setImmediate(true); SettingsValues countValues = new SettingsValues(SettingsValues.SETTINGS_MAX_BACKUP_COUNT); String[] counts = countValues.getValues(); for (String value : counts) { selectCount.addItem(value); } selectCount.select(maxBackupCount); selectCount.setNullSelectionAllowed(false); layout.addComponent(selectCount); selectCount.addValueChangeListener(new ValueChangeListener() { private static final long serialVersionUID = 0x4C656F6E6172646FL; public void valueChange(ValueChangeEvent event) { maxBackupCount = (String) ((NativeSelect) event.getProperty()).getValue(); systemInfo.setProperty(SystemInfo.PROPERTY_DEFAULTMAXBACKUPCOUNT, maxBackupCount); } }); NativeSelect selectSize = new NativeSelect("Max total backup size"); selectSize.setImmediate(true); SettingsValues sizeValues = new SettingsValues(SettingsValues.SETTINGS_MAX_BACKUP_SIZE); String[] sizes = sizeValues.getValues(); for (String value : sizes) { selectSize.addItem(value + " GB"); } selectSize.select(maxBackupSize + " GB"); selectSize.setNullSelectionAllowed(false); layout.addComponent(selectSize); selectSize.addValueChangeListener(new ValueChangeListener() { private static final long serialVersionUID = 0x4C656F6E6172646FL; public void valueChange(ValueChangeEvent event) { maxBackupSize = (String) ((NativeSelect) event.getProperty()).getValue(); String value = maxBackupSize.substring(0, maxBackupSize.indexOf(" GB")); systemInfo.setProperty(SystemInfo.PROPERTY_DEFAULTMAXBACKUPSIZE, value); } }); return layout; }