List of usage examples for com.vaadin.ui DateField DateField
public DateField()
DateField
with no caption. From source file:annis.gui.admin.OptionalDateTimeField.java
License:Apache License
public OptionalDateTimeField(String checkboxCaption) { dateField = new DateField(); dateField.setConverter(new DateTimeConverter()); dateField.setDateFormat("yyyy-MM-dd"); dateField.setImmediate(true);//w w w.j ava2 s . c o m dateField.setPropertyDataSource(OptionalDateTimeField.this); checkBox = new CheckBox(checkboxCaption); checkBox.addValueChangeListener(new ValueChangeListener() { @Override public void valueChange(Property.ValueChangeEvent event) { if (Objects.equals(event.getProperty().getValue(), Boolean.TRUE)) { if (getValue() == null) { // only set something if changed setValue(DateTime.now()); } } else { if (getValue() != null) { // only set something if changed setValue(null); } } } }); layout = new HorizontalLayout(dateField, checkBox); }
From source file:ch.bfh.ti.soed.hs16.srs.red.ui.helper.SubWindowReservation.java
License:Open Source License
public SubWindowReservation() { this.layout = new VerticalLayout(); this.id = new Label("id"); this.name = new Label("name"); this.roomTitle = new Label("select room"); this.startTime = new Label("start time"); this.endTime = new Label("end time"); this.textFieldId = new TextField(); this.textFieldName = new TextField(); this.rooms = new ComboBox(); this.dateFieldStart = new DateField(); this.dateFieldEnd = new DateField(); this.buttonSave = new Button("save"); this.buttonDelete = new Button("delete"); dateFieldStart.setResolution(Resolution.MINUTE); dateFieldEnd.setResolution(Resolution.MINUTE); /*--------------------------------- add objects to horizontal container//from w w w. ja v a2 s .co m ---------------------------------*/ HorizontalLayout idContainer = new HorizontalLayout(id, textFieldId); HorizontalLayout nameContainer = new HorizontalLayout(name, textFieldName); HorizontalLayout roomContainer = new HorizontalLayout(roomTitle, rooms); HorizontalLayout startContainer = new HorizontalLayout(startTime, dateFieldStart); HorizontalLayout endContainer = new HorizontalLayout(endTime, dateFieldEnd); HorizontalLayout buttons = new HorizontalLayout(buttonSave, buttonDelete); /*--------------------------------- add style names ---------------------------------*/ layout.setPrimaryStyleName(CSS_NAME); idContainer.setPrimaryStyleName(CSS_NAME + "-horizontalContainer"); nameContainer.setPrimaryStyleName(CSS_NAME + "-horizontalContainer"); roomContainer.setPrimaryStyleName(CSS_NAME + "-horizontalContainer"); startContainer.setPrimaryStyleName(CSS_NAME + "-horizontalContainer"); endContainer.setPrimaryStyleName(CSS_NAME + "-horizontalContainer"); buttons.setPrimaryStyleName(CSS_NAME + "-horizontalContainer"); /*--------------------------------- add to root layout ---------------------------------*/ this.layout.addComponents(idContainer, nameContainer, roomContainer, startContainer, endContainer, buttons); }
From source file:com.anphat.list.ui.PopupAddCategoryList.java
public PopupAddCategoryList() { mainLayout.setImmediate(true);/* www . java 2 s .c om*/ mainLayout.setWidth("100%"); mainLayout.setHeight("-1px"); mainLayout.setMargin(true); mainLayout.setSpacing(true); mainLayout.setStyleName("main-popup"); addCategoryListLayout = new GridLayout(); addCategoryListLayout.setImmediate(true); addCategoryListLayout.setWidth("100.0%"); addCategoryListLayout.setHeight("-1px"); addCategoryListLayout.setMargin(true); addCategoryListLayout.setSpacing(true); addCategoryListLayout.setColumns(4); addCategoryListLayout.setRows(4); setWidth("70.0%"); setHeight("-1px"); setModal(true); lblCode = new Label(); lblCode.setImmediate(true); lblCode.setWidth("100.0%"); lblCode.setHeight("-1px"); lblCode.setValue(BundleUtils.getString("label.CategoryList.code")); addCategoryListLayout.addComponent(lblCode, 0, 0); txtCode = new TextField(); txtCode.setRequired(true); txtCode.setImmediate(true); txtCode.setWidth("100.0%"); txtCode.setHeight("-1px"); addCategoryListLayout.addComponent(txtCode, 1, 0); lblName = new Label(); lblName.setImmediate(true); lblName.setWidth("100.0%"); lblName.setHeight("-1px"); lblName.setValue(BundleUtils.getString("label.CategoryList.name")); addCategoryListLayout.addComponent(lblName, 2, 0); txtName = new TextField(); txtName.setRequired(true); txtName.setImmediate(true); txtName.setWidth("100.0%"); txtName.setHeight("-1px"); addCategoryListLayout.addComponent(txtName, 3, 0); lblReceivedDate = new Label(); lblReceivedDate.setImmediate(true); lblReceivedDate.setWidth("100.0%"); lblReceivedDate.setHeight("-1px"); lblReceivedDate.setValue(BundleUtils.getString("label.CategoryList.receivedDate")); addCategoryListLayout.addComponent(lblReceivedDate, 0, 1); txtReceivedDate = new DateField(); txtReceivedDate.setRequired(true); txtReceivedDate.setImmediate(true); txtReceivedDate.setWidth("100.0%"); txtReceivedDate.setHeight("-1px"); addCategoryListLayout.addComponent(txtReceivedDate, 1, 1); lblEndDate = new Label(); lblEndDate.setImmediate(true); lblEndDate.setWidth("100.0%"); lblEndDate.setHeight("-1px"); lblEndDate.setValue(BundleUtils.getString("label.CategoryList.endDate")); addCategoryListLayout.addComponent(lblEndDate, 2, 1); txtEndDate = new DateField(); txtEndDate.setRequired(true); txtEndDate.setImmediate(true); txtEndDate.setWidth("100.0%"); txtEndDate.setHeight("-1px"); addCategoryListLayout.addComponent(txtEndDate, 3, 1); lblDescription = new Label(); lblDescription.setImmediate(true); lblDescription.setWidth("100.0%"); lblDescription.setHeight("-1px"); lblDescription.setValue(BundleUtils.getString("label.CategoryList.description")); addCategoryListLayout.addComponent(lblDescription, 0, 2); txtDescription = new TextField(); txtDescription.setImmediate(true); txtDescription.setWidth("100.0%"); txtDescription.setHeight("-1px"); addCategoryListLayout.addComponent(txtDescription, 1, 2); lblCreator = new Label(); lblCreator.setImmediate(true); lblCreator.setWidth("100.0%"); lblCreator.setHeight("-1px"); lblCreator.setValue(BundleUtils.getString("label.CategoryList.creator")); addCategoryListLayout.addComponent(lblCreator, 2, 2); txtCreator = new TextField(); txtCreator.setRequired(true); txtCreator.setImmediate(true); txtCreator.setWidth("100.0%"); txtCreator.setHeight("-1px"); addCategoryListLayout.addComponent(txtCreator, 3, 2); lblService = new Label(); lblService.setImmediate(true); lblService.setWidth("100.0%"); lblService.setHeight("-1px"); lblService.setValue(BundleUtils.getString("customerStatusForm.service")); addCategoryListLayout.addComponent(lblService, 0, 3); cboService = CommonUtils.buildComboBox(); cboService.setRequired(true); cboService.setImmediate(true); cboService.setWidth("100.0%"); cboService.setHeight("-1px"); AppParamsDTO appParams = new AppParamsDTO(); appParams.setStatus(Constants.ACTIVE); appParams.setParType(Constants.APP_PARAMS.SERVICE_TYPE); List<AppParamsDTO> lstServices = WSAppParams.getListAppParamsDTO(appParams, 0, 1000, Constants.ASC, Constants.APP_PARAMS.PAR_ORDER); ComboComponent comboUtils = new ComboComponent(); String serviceDefault = Constants.NULL; if (!DataUtil.isListNullOrEmpty(lstServices)) { serviceDefault = lstServices.get(0).getParCode(); } comboUtils.fillDataCombo(cboService, Constants.NULL, serviceDefault, lstServices, Constants.APP_PARAMS.SERVICE_TYPE); addCategoryListLayout.addComponent(cboService, 1, 3); mainLayout.addComponent(addCategoryListLayout); GridManyButton gridBtnPrint = new GridManyButton( new String[] { Constants.BUTTON_SAVE, Constants.BUTTON_CLOSE }); mainLayout.addComponent(gridBtnPrint); btnSave = gridBtnPrint.getBtnCommon().get(0); btnClose = gridBtnPrint.getBtnCommon().get(1); setContent(mainLayout); // setCaption(CAPTION); }
From source file:com.cavisson.gui.dashboard.components.controls.Tables.java
License:Apache License
static void configure(Table table, boolean footer, boolean sized, boolean expandRatios, boolean stripes, boolean verticalLines, boolean horizontalLines, boolean borderless, boolean headers, boolean compact, boolean small, boolean rowIndex, boolean rowCaption, boolean rowIcon, boolean componentsInRows) { table.setSelectable(true);/*from w w w . j a v a 2 s . c o m*/ table.setMultiSelect(true); table.setSortEnabled(true); table.setColumnCollapsingAllowed(true); table.setColumnReorderingAllowed(true); table.setPageLength(6); table.addActionHandler(ValoThemeUI.getActionHandler()); table.setDragMode(TableDragMode.MULTIROW); table.setDropHandler(new DropHandler() { @Override public AcceptCriterion getAcceptCriterion() { return AcceptAll.get(); } @Override public void drop(DragAndDropEvent event) { Notification.show(event.getTransferable().toString()); } }); table.setColumnAlignment(ValoThemeUI.DESCRIPTION_PROPERTY, Align.RIGHT); table.setColumnAlignment(ValoThemeUI.INDEX_PROPERTY, Align.CENTER); table.removeContainerProperty("textfield"); table.removeGeneratedColumn("textfield"); table.removeContainerProperty("button"); table.removeGeneratedColumn("button"); table.removeContainerProperty("label"); table.removeGeneratedColumn("label"); table.removeContainerProperty("checkbox"); table.removeGeneratedColumn("checkbox"); table.removeContainerProperty("datefield"); table.removeGeneratedColumn("datefield"); table.removeContainerProperty("combobox"); table.removeGeneratedColumn("combobox"); table.removeContainerProperty("optiongroup"); table.removeGeneratedColumn("optiongroup"); table.removeContainerProperty("slider"); table.removeGeneratedColumn("slider"); table.removeContainerProperty("progress"); table.removeGeneratedColumn("progress"); if (componentsInRows) { table.addContainerProperty("textfield", TextField.class, null); table.addGeneratedColumn("textfield", new ColumnGenerator() { @Override public Object generateCell(Table source, Object itemId, Object columnId) { TextField tf = new TextField(); tf.setInputPrompt("Type here"); // tf.addStyleName("compact"); if ((Integer) itemId % 2 == 0) { tf.addStyleName("borderless"); } return tf; } }); table.addContainerProperty("datefield", TextField.class, null); table.addGeneratedColumn("datefield", new ColumnGenerator() { @Override public Object generateCell(Table source, Object itemId, Object columnId) { DateField tf = new DateField(); tf.addStyleName("compact"); if ((Integer) itemId % 2 == 0) { tf.addStyleName("borderless"); } return tf; } }); table.addContainerProperty("combobox", TextField.class, null); table.addGeneratedColumn("combobox", new ColumnGenerator() { @Override public Object generateCell(Table source, Object itemId, Object columnId) { ComboBox tf = new ComboBox(); tf.setInputPrompt("Select"); tf.addStyleName("compact"); if ((Integer) itemId % 2 == 0) { tf.addStyleName("borderless"); } return tf; } }); table.addContainerProperty("button", Button.class, null); table.addGeneratedColumn("button", new ColumnGenerator() { @Override public Object generateCell(Table source, Object itemId, Object columnId) { Button b = new Button("Button"); b.addStyleName("small"); return b; } }); table.addContainerProperty("label", TextField.class, null); table.addGeneratedColumn("label", new ColumnGenerator() { @Override public Object generateCell(Table source, Object itemId, Object columnId) { Label label = new Label("Label component"); label.setSizeUndefined(); label.addStyleName("bold"); return label; } }); table.addContainerProperty("checkbox", TextField.class, null); table.addGeneratedColumn("checkbox", new ColumnGenerator() { @Override public Object generateCell(Table source, Object itemId, Object columnId) { CheckBox cb = new CheckBox(null, true); return cb; } }); table.addContainerProperty("optiongroup", TextField.class, null); table.addGeneratedColumn("optiongroup", new ColumnGenerator() { @Override public Object generateCell(Table source, Object itemId, Object columnId) { OptionGroup op = new OptionGroup(); op.addItem("Male"); op.addItem("Female"); op.addStyleName("horizontal"); return op; } }); table.addContainerProperty("slider", TextField.class, null); table.addGeneratedColumn("slider", new ColumnGenerator() { @Override public Object generateCell(Table source, Object itemId, Object columnId) { Slider s = new Slider(); s.setValue(30.0); return s; } }); table.addContainerProperty("progress", TextField.class, null); table.addGeneratedColumn("progress", new ColumnGenerator() { @Override public Object generateCell(Table source, Object itemId, Object columnId) { ProgressBar bar = new ProgressBar(); bar.setValue(0.7f); return bar; } }); } table.setFooterVisible(footer); if (footer) { table.setColumnFooter(ValoThemeUI.CAPTION_PROPERTY, "caption"); table.setColumnFooter(ValoThemeUI.DESCRIPTION_PROPERTY, "description"); table.setColumnFooter(ValoThemeUI.ICON_PROPERTY, "icon"); table.setColumnFooter(ValoThemeUI.INDEX_PROPERTY, "index"); } if (sized) { table.setWidth("400px"); table.setHeight("300px"); } else { table.setSizeUndefined(); } if (expandRatios) { if (!sized) { table.setWidth("100%"); } } table.setColumnExpandRatio(ValoThemeUI.CAPTION_PROPERTY, expandRatios ? 1.0f : 0); table.setColumnExpandRatio(ValoThemeUI.DESCRIPTION_PROPERTY, expandRatios ? 1.0f : 0); if (!stripes) { table.addStyleName("no-stripes"); } else { table.removeStyleName("no-stripes"); } if (!verticalLines) { table.addStyleName("no-vertical-lines"); } else { table.removeStyleName("no-vertical-lines"); } if (!horizontalLines) { table.addStyleName("no-horizontal-lines"); } else { table.removeStyleName("no-horizontal-lines"); } if (borderless) { table.addStyleName("borderless"); } else { table.removeStyleName("borderless"); } if (!headers) { table.addStyleName("no-header"); } else { table.removeStyleName("no-header"); } if (compact) { table.addStyleName("compact"); } else { table.removeStyleName("compact"); } if (small) { table.addStyleName("small"); } else { table.removeStyleName("small"); } if (!rowIndex && !rowCaption && rowIcon) { table.setRowHeaderMode(RowHeaderMode.HIDDEN); } if (rowIndex) { table.setRowHeaderMode(RowHeaderMode.INDEX); } if (rowCaption) { table.setRowHeaderMode(RowHeaderMode.PROPERTY); table.setItemCaptionPropertyId(ValoThemeUI.CAPTION_PROPERTY); } else { table.setItemCaptionPropertyId(null); } if (rowIcon) { table.setRowHeaderMode(RowHeaderMode.ICON_ONLY); table.setItemIconPropertyId(ValoThemeUI.ICON_PROPERTY); } else { table.setItemIconPropertyId(null); } }
From source file:com.cms.utils.CommonUtils.java
public static DateField buildDateField(String caption) { DateField returnTextField = new DateField(); if (!DataUtil.isStringNullOrEmpty(caption)) { returnTextField.setCaption(BundleUtils.getString(caption)); }/*w w w.j a v a 2s . c om*/ returnTextField.setWidth("100%"); returnTextField.setHeight("-1px"); returnTextField.setImmediate(true); return returnTextField; }
From source file:com.cms.view.CategoryListView.java
public void buildSearchLayout() { searchLayout = new GridLayout(); searchLayout.setCaption(MakeURL.makeURLForGrid(BundleUtils.getString("caption.search.info"))); searchLayout.setCaptionAsHtml(true); searchLayout.setImmediate(true);/* www . jav a 2 s . co m*/ searchLayout.setWidth("100.0%"); searchLayout.setHeight("-1px"); searchLayout.setMargin(true); searchLayout.setSpacing(true); searchLayout.setColumns(4); searchLayout.setRows(4); searchLayout.setStyleName("custom-feildset"); lblCode = new Label(); lblCode.setImmediate(true); lblCode.setWidth("100.0%"); lblCode.setHeight("-1px"); lblCode.setValue(BundleUtils.getString("label.CategoryList.code")); searchLayout.addComponent(lblCode, 0, 0); txtCode = new TextField(); // txtCode.setRequired(true); txtCode.setImmediate(true); txtCode.setWidth("100.0%"); txtCode.setHeight("-1px"); searchLayout.addComponent(txtCode, 1, 0); lblName = new Label(); lblName.setImmediate(true); lblName.setWidth("100.0%"); lblName.setHeight("-1px"); lblName.setValue(BundleUtils.getString("label.CategoryList.name")); searchLayout.addComponent(lblName, 2, 0); txtName = new TextField(); txtName.setImmediate(true); txtName.setWidth("100.0%"); txtName.setHeight("-1px"); searchLayout.addComponent(txtName, 3, 0); lblReceivedDate = new Label(); lblReceivedDate.setImmediate(true); lblReceivedDate.setWidth("100.0%"); lblReceivedDate.setHeight("-1px"); lblReceivedDate.setValue(BundleUtils.getString("label.CategoryList.receivedDate")); searchLayout.addComponent(lblReceivedDate, 0, 1); dfReceivedDate = new DateField(); // dfReceivedDate.setRequired(true); dfReceivedDate.setImmediate(true); dfReceivedDate.setWidth("100.0%"); dfReceivedDate.setHeight("-1px"); searchLayout.addComponent(dfReceivedDate, 1, 1); lblEndDate = new Label(); lblEndDate.setImmediate(true); lblEndDate.setWidth("100.0%"); lblEndDate.setHeight("-1px"); lblEndDate.setValue(BundleUtils.getString("label.CategoryList.endDate")); searchLayout.addComponent(lblEndDate, 2, 1); dfEndDate = new DateField(); // dfEndDate.setRequired(true); dfEndDate.setImmediate(true); dfEndDate.setWidth("100.0%"); dfEndDate.setHeight("-1px"); searchLayout.addComponent(dfEndDate, 3, 1); lblDescription = new Label(); lblDescription.setImmediate(true); lblDescription.setWidth("100.0%"); lblDescription.setHeight("-1px"); lblDescription.setValue(BundleUtils.getString("label.CategoryList.description")); searchLayout.addComponent(lblDescription, 0, 2); txtDescription = new TextField(); txtDescription.setImmediate(true); txtDescription.setWidth("100.0%"); txtDescription.setHeight("-1px"); searchLayout.addComponent(txtDescription, 1, 2); lblCreator = new Label(); lblCreator.setImmediate(true); lblCreator.setWidth("100.0%"); lblCreator.setHeight("-1px"); lblCreator.setValue(BundleUtils.getString("label.CategoryList.creator")); searchLayout.addComponent(lblCreator, 2, 2); txtCreator = new TextField(); txtCreator.setImmediate(true); txtCreator.setWidth("100.0%"); txtCreator.setHeight("-1px"); searchLayout.addComponent(txtCreator, 3, 2); lblService = new Label(); lblService.setImmediate(true); lblService.setWidth("100.0%"); lblService.setHeight("-1px"); lblService.setValue(BundleUtils.getString("customerStatusForm.service")); searchLayout.addComponent(lblService, 0, 3); cboService = CommonUtils.buildComboBox(); cboService.setImmediate(true); cboService.setWidth("100.0%"); cboService.setHeight("-1px"); searchLayout.addComponent(cboService, 1, 3); }
From source file:com.esofthead.mycollab.module.project.view.assignments.gantt.GanttTreeTable.java
License:Open Source License
public GanttTreeTable(final GanttExt gantt) { super();//from w w w . jav a 2 s . co m this.gantt = gantt; this.setWidth("800px"); this.setBuffered(true); beanContainer = gantt.getBeanContainer(); this.setContainerDataSource(beanContainer); this.setVisibleColumns("ganttIndex", "name", "startDate", "endDate", "duration", "percentageComplete", "predecessors", "assignUser"); this.setColumnHeader("ganttIndex", ""); this.setColumnWidth("ganttIndex", 25); this.setColumnHeader("name", "Task"); this.setColumnExpandRatio("name", 1.0f); this.setHierarchyColumn("name"); this.setColumnHeader("startDate", "Start"); this.setColumnWidth("startDate", 90); this.setColumnHeader("endDate", "End"); this.setColumnWidth("endDate", 90); this.setColumnHeader("duration", "Duration"); this.setColumnWidth("duration", 65); this.setColumnHeader("predecessors", "Predecessors"); this.setColumnWidth("predecessors", 100); this.setColumnHeader("percentageComplete", "% Complete"); this.setColumnWidth("percentageComplete", 75); this.setColumnHeader("assignUser", "Assignee"); this.setColumnWidth("assignUser", 80); this.setColumnCollapsingAllowed(true); this.setColumnCollapsed("assignUser", true); this.setEditable(true); this.setNullSelectionAllowed(false); this.addGeneratedColumn("ganttIndex", new ColumnGenerator() { @Override public Object generateCell(Table table, Object itemId, Object columnId) { GanttItemWrapper item = (GanttItemWrapper) itemId; return new ELabel("" + item.getGanttIndex()).withStyleName(ValoTheme.LABEL_SMALL); } }); this.setTableFieldFactory(new TableFieldFactory() { @Override public Field<?> createField(Container container, Object itemId, final Object propertyId, Component uiContext) { Field field = null; final GanttItemWrapper ganttItem = (GanttItemWrapper) itemId; if ("name".equals(propertyId)) { field = new AssignmentNameCellField(ganttItem.getType()); } else if ("percentageComplete".equals(propertyId)) { field = new TextField(); ((TextField) field).setNullRepresentation("0"); ((TextField) field).setImmediate(true); field.addStyleName(ValoTheme.TEXTFIELD_SMALL); if (ganttItem.hasSubTasks() || ganttItem.isMilestone()) { field.setEnabled(false); ((TextField) field).setDescription("Because this row has sub-tasks, this cell " + "is a summary value and can not be edited directly. You can edit cells " + "beneath this row to change its value"); } } else if ("startDate".equals(propertyId) || "endDate".equals(propertyId)) { field = new DateField(); field.addStyleName(ValoTheme.DATEFIELD_SMALL); ((DateField) field).setConverter(new LocalDateConverter()); ((DateField) field).setImmediate(true); if (ganttItem.hasSubTasks()) { field.setEnabled(false); ((DateField) field).setDescription("Because this row has sub-tasks, this cell " + "is a summary value and can not be edited directly. You can edit cells " + "beneath this row to change its value"); } } else if ("assignUser".equals(propertyId)) { field = new ProjectMemberSelectionField(); } else if ("predecessors".equals(propertyId)) { field = new DefaultViewField(""); ((DefaultViewField) field).setConverter(new PredecessorConverter()); return field; } else if ("duration".equals(propertyId)) { field = new TextField(); ((TextField) field).setConverter(new HumanTimeConverter()); field.addStyleName(ValoTheme.TEXTFIELD_SMALL); if (ganttItem.hasSubTasks()) { field.setEnabled(false); ((TextField) field).setDescription("Because this row has sub-tasks, this cell " + "is a summary value and can not be edited directly. You can edit cells " + "beneath this row to change its value"); } } if (field != null) { field.setBuffered(true); field.setWidth("100%"); if (ganttItem.isMilestone()) { if (!CurrentProjectVariables.canWrite(ProjectRolePermissionCollections.MILESTONES)) { field.setEnabled(false); ((AbstractComponent) field).setDescription( AppContext.getMessage(GenericI18Enum.NOTIFICATION_NO_PERMISSION_DO_TASK)); } } else if (ganttItem.isTask()) { if (!CurrentProjectVariables.canWrite(ProjectRolePermissionCollections.TASKS)) { field.setEnabled(false); ((AbstractComponent) field).setDescription( AppContext.getMessage(GenericI18Enum.NOTIFICATION_NO_PERMISSION_DO_TASK)); } } else if (ganttItem.isBug()) { if (!CurrentProjectVariables.canWrite(ProjectRolePermissionCollections.BUGS)) { field.setEnabled(false); ((AbstractComponent) field).setDescription( AppContext.getMessage(GenericI18Enum.NOTIFICATION_NO_PERMISSION_DO_TASK)); } } else { throw new MyCollabException( "Do not support gantt item type " + ganttItem.getTask().getType()); } if (field instanceof FieldEvents.BlurNotifier) { ((FieldEvents.BlurNotifier) field).addBlurListener(new FieldEvents.BlurListener() { @Override public void blur(FieldEvents.BlurEvent event) { Object o = event.getSource(); if (o instanceof Field) { Field f = (Field) o; if (f.isModified()) { f.commit(); EventBusFactory.getInstance().post(new GanttEvent.AddGanttItemUpdateToQueue( GanttTreeTable.this, ganttItem)); GanttTreeTable.this.refreshRowCache(); } } } }); } } return field; } }); this.addExpandListener(new Tree.ExpandListener() { @Override public void nodeExpand(Tree.ExpandEvent expandEvent) { GanttItemWrapper item = (GanttItemWrapper) expandEvent.getItemId(); List<GanttItemWrapper> subTasks = item.subTasks(); insertSubSteps(item, subTasks); } }); this.addCollapseListener(new Tree.CollapseListener() { @Override public void nodeCollapse(Tree.CollapseEvent collapseEvent) { GanttItemWrapper item = (GanttItemWrapper) collapseEvent.getItemId(); List<GanttItemWrapper> subTasks = item.subTasks(); removeSubSteps(item, subTasks); } }); this.setCellStyleGenerator(new CellStyleGenerator() { @Override public String getStyle(Table source, Object itemId, Object propertyId) { GanttItemWrapper item = (GanttItemWrapper) itemId; if (item.isMilestone()) { return "root"; } else if (item.isTask()) { return ""; } return ""; } }); final GanttContextMenu contextMenu = new GanttContextMenu(); contextMenu.setAsContextMenuOf(this); contextMenu.setOpenAutomatically(false); ContextMenu.ContextMenuOpenedListener.TableListener tableListener = new ContextMenu.ContextMenuOpenedListener.TableListener() { public void onContextMenuOpenFromRow(ContextMenu.ContextMenuOpenedOnTableRowEvent event) { GanttItemWrapper item = (GanttItemWrapper) event.getItemId(); contextMenu.displayContextMenu(item); contextMenu.open(GanttTreeTable.this); } public void onContextMenuOpenFromHeader(ContextMenu.ContextMenuOpenedOnTableHeaderEvent event) { } public void onContextMenuOpenFromFooter(ContextMenu.ContextMenuOpenedOnTableFooterEvent event) { } }; contextMenu.addContextMenuTableListener(tableListener); gantt.setVerticalScrollDelegateTarget(this); this.setPageLength(currentPageLength); }
From source file:com.etest.valo.Tables.java
License:Apache License
static void configure(Table table, boolean footer, boolean sized, boolean expandRatios, boolean stripes, boolean verticalLines, boolean horizontalLines, boolean borderless, boolean headers, boolean compact, boolean small, boolean rowIndex, boolean rowCaption, boolean rowIcon, boolean componentsInRows) { table.setSelectable(true);/* w w w . jav a2 s .c o m*/ table.setMultiSelect(true); table.setSortEnabled(true); table.setColumnCollapsingAllowed(true); table.setColumnReorderingAllowed(true); table.setPageLength(6); table.addActionHandler(MainUI.getActionHandler()); table.setDragMode(TableDragMode.MULTIROW); table.setDropHandler(new DropHandler() { @Override public AcceptCriterion getAcceptCriterion() { return AcceptAll.get(); } @Override public void drop(DragAndDropEvent event) { Notification.show(event.getTransferable().toString()); } }); table.setColumnAlignment(MainUI.DESCRIPTION_PROPERTY, Align.RIGHT); table.setColumnAlignment(MainUI.INDEX_PROPERTY, Align.CENTER); table.removeContainerProperty("textfield"); table.removeGeneratedColumn("textfield"); table.removeContainerProperty("button"); table.removeGeneratedColumn("button"); table.removeContainerProperty("label"); table.removeGeneratedColumn("label"); table.removeContainerProperty("checkbox"); table.removeGeneratedColumn("checkbox"); table.removeContainerProperty("datefield"); table.removeGeneratedColumn("datefield"); table.removeContainerProperty("combobox"); table.removeGeneratedColumn("combobox"); table.removeContainerProperty("optiongroup"); table.removeGeneratedColumn("optiongroup"); table.removeContainerProperty("slider"); table.removeGeneratedColumn("slider"); table.removeContainerProperty("progress"); table.removeGeneratedColumn("progress"); if (componentsInRows) { table.addContainerProperty("textfield", TextField.class, null); table.addGeneratedColumn("textfield", new ColumnGenerator() { @Override public Object generateCell(Table source, Object itemId, Object columnId) { TextField tf = new TextField(); tf.setInputPrompt("Type here"); // tf.addStyleName("compact"); if ((Integer) itemId % 2 == 0) { tf.addStyleName("borderless"); } return tf; } }); table.addContainerProperty("datefield", TextField.class, null); table.addGeneratedColumn("datefield", new ColumnGenerator() { @Override public Object generateCell(Table source, Object itemId, Object columnId) { DateField tf = new DateField(); tf.addStyleName("compact"); if ((Integer) itemId % 2 == 0) { tf.addStyleName("borderless"); } return tf; } }); table.addContainerProperty("combobox", TextField.class, null); table.addGeneratedColumn("combobox", new ColumnGenerator() { @Override public Object generateCell(Table source, Object itemId, Object columnId) { ComboBox tf = new ComboBox(); tf.setInputPrompt("Select"); tf.addStyleName("compact"); if ((Integer) itemId % 2 == 0) { tf.addStyleName("borderless"); } return tf; } }); table.addContainerProperty("button", Button.class, null); table.addGeneratedColumn("button", new ColumnGenerator() { @Override public Object generateCell(Table source, Object itemId, Object columnId) { Button b = new Button("Button"); b.addStyleName("small"); return b; } }); table.addContainerProperty("label", TextField.class, null); table.addGeneratedColumn("label", new ColumnGenerator() { @Override public Object generateCell(Table source, Object itemId, Object columnId) { Label label = new Label("Label component"); label.setSizeUndefined(); label.addStyleName("bold"); return label; } }); table.addContainerProperty("checkbox", TextField.class, null); table.addGeneratedColumn("checkbox", new ColumnGenerator() { @Override public Object generateCell(Table source, Object itemId, Object columnId) { CheckBox cb = new CheckBox(null, true); return cb; } }); table.addContainerProperty("optiongroup", TextField.class, null); table.addGeneratedColumn("optiongroup", new ColumnGenerator() { @Override public Object generateCell(Table source, Object itemId, Object columnId) { OptionGroup op = new OptionGroup(); op.addItem("Male"); op.addItem("Female"); op.addStyleName("horizontal"); return op; } }); table.addContainerProperty("slider", TextField.class, null); table.addGeneratedColumn("slider", new ColumnGenerator() { @Override public Object generateCell(Table source, Object itemId, Object columnId) { Slider s = new Slider(); s.setValue(30.0); return s; } }); table.addContainerProperty("progress", TextField.class, null); table.addGeneratedColumn("progress", new ColumnGenerator() { @Override public Object generateCell(Table source, Object itemId, Object columnId) { ProgressBar bar = new ProgressBar(); bar.setValue(0.7f); return bar; } }); } table.setFooterVisible(footer); if (footer) { table.setColumnFooter(MainUI.CAPTION_PROPERTY, "caption"); table.setColumnFooter(MainUI.DESCRIPTION_PROPERTY, "description"); table.setColumnFooter(MainUI.ICON_PROPERTY, "icon"); table.setColumnFooter(MainUI.INDEX_PROPERTY, "index"); } if (sized) { table.setWidth("400px"); table.setHeight("300px"); } else { table.setSizeUndefined(); } if (expandRatios) { if (!sized) { table.setWidth("100%"); } } table.setColumnExpandRatio(MainUI.CAPTION_PROPERTY, expandRatios ? 1.0f : 0); table.setColumnExpandRatio(MainUI.DESCRIPTION_PROPERTY, expandRatios ? 1.0f : 0); if (!stripes) { table.addStyleName("no-stripes"); } else { table.removeStyleName("no-stripes"); } if (!verticalLines) { table.addStyleName("no-vertical-lines"); } else { table.removeStyleName("no-vertical-lines"); } if (!horizontalLines) { table.addStyleName("no-horizontal-lines"); } else { table.removeStyleName("no-horizontal-lines"); } if (borderless) { table.addStyleName("borderless"); } else { table.removeStyleName("borderless"); } if (!headers) { table.addStyleName("no-header"); } else { table.removeStyleName("no-header"); } if (compact) { table.addStyleName("compact"); } else { table.removeStyleName("compact"); } if (small) { table.addStyleName("small"); } else { table.removeStyleName("small"); } if (!rowIndex && !rowCaption && rowIcon) { table.setRowHeaderMode(RowHeaderMode.HIDDEN); } if (rowIndex) { table.setRowHeaderMode(RowHeaderMode.INDEX); } if (rowCaption) { table.setRowHeaderMode(RowHeaderMode.PROPERTY); table.setItemCaptionPropertyId(MainUI.CAPTION_PROPERTY); } else { table.setItemCaptionPropertyId(null); } if (rowIcon) { table.setRowHeaderMode(RowHeaderMode.ICON_ONLY); table.setItemIconPropertyId(MainUI.ICON_PROPERTY); } else { table.setItemIconPropertyId(null); } }
From source file:com.expressui.core.view.field.FormField.java
License:Open Source License
private Field generateField() { Class propertyType = getPropertyType(); if (propertyType == null) { return null; }/*from w w w . j a v a2 s . co m*/ if (Date.class.isAssignableFrom(propertyType)) { return new DateField(); } if (boolean.class.isAssignableFrom(propertyType) || Boolean.class.isAssignableFrom(propertyType)) { return new CheckBox(); } if (ReferenceEntity.class.isAssignableFrom(propertyType)) { return new Select(); } if (Currency.class.isAssignableFrom(propertyType)) { return new Select(); } if (propertyType.isEnum()) { return new Select(); } if (Collection.class.isAssignableFrom(propertyType)) { return new ListSelect(); } if (getBeanPropertyType().hasAnnotation(Lob.class)) { return new RichTextArea(); } return new TextField(); }
From source file:com.github.mjvesa.herd.wordset.VaadinWordSet.java
License:Apache License
@Override public Word[] getWords() { return new Word[] { new BaseWord("new-button", "", Word.POSTPONED) { private static final long serialVersionUID = -2492817908731559368L; @Override/*from w ww .j a v a 2 s .co m*/ public void execute(final Interpreter interpreter) { Button b = new Button("", new Button.ClickListener() { private static final long serialVersionUID = -4622489800920283752L; @Override public void buttonClick(ClickEvent event) { Button b = event.getButton(); Word command = (Word) b.getData(); if (command != null) { interpreter.execute(command); } } }); interpreter.pushData(b); } }, new BaseWord("set-click-listener", "", Word.POSTPONED) { private static final long serialVersionUID = 5749856686458297558L; @Override public void execute(Interpreter interpreter) { Object o = interpreter.popData(); Button b = (Button) interpreter.popData(); b.setData(o); interpreter.pushData(b); } }, new BaseWord("new-hl", "", Word.POSTPONED) { private static final long serialVersionUID = 8813556668649386248L; @Override public void execute(Interpreter interpreter) { HorizontalLayout hl = new HorizontalLayout(); hl.setSpacing(true); interpreter.pushData(hl); } }, new BaseWord("new-vl", "", Word.POSTPONED) { private static final long serialVersionUID = -1848213448504804229L; @Override public void execute(Interpreter interpreter) { VerticalLayout vl = new VerticalLayout(); vl.setSpacing(true); interpreter.pushData(vl); } }, new BaseWord("new-gl", "( x y - gl )", Word.POSTPONED) { private static final long serialVersionUID = 4079634885691605257L; @Override public void execute(Interpreter interpreter) { Integer height = (Integer) interpreter.popData(); Integer width = (Integer) interpreter.popData(); interpreter.pushData(new GridLayout(width, height)); } }, new BaseWord("gl-new-line", "", Word.POSTPONED) { private static final long serialVersionUID = 975877390052961807L; @Override public void execute(Interpreter interpreter) { ((GridLayout) interpreter.peekData()).newLine(); } }, new BaseWord("new-window", "", Word.POSTPONED) { private static final long serialVersionUID = -6887364362728545090L; @Override public void execute(Interpreter interpreter) { Window w = new Window(); VerticalLayout vl = new VerticalLayout(); vl.setSpacing(true); w.setContent(vl); interpreter.pushData(w); interpreter.pushData(vl); } }, new BaseWord("main-panel", "", Word.POSTPONED) { private static final long serialVersionUID = -8622281600566696475L; @Override public void execute(Interpreter interpreter) { interpreter.pushData(interpreter.getMainPanel()); } }, new BaseWord("add-window", "", Word.POSTPONED) { private static final long serialVersionUID = 7106029415576813922L; @Override public void execute(Interpreter interpreter) { Window w = (Window) interpreter.popData(); interpreter.getView().getUI().addWindow(w); } }, new BaseWord("add-component", "", Word.POSTPONED) { private static final long serialVersionUID = 5640824046985354091L; @Override public void execute(Interpreter interpreter) { Component comp = (Component) interpreter.popData(); ComponentContainer cc = (ComponentContainer) interpreter.popData(); cc.addComponent(comp); interpreter.pushData(cc); } }, new BaseWord("set-caption", "", Word.POSTPONED) { private static final long serialVersionUID = 5497598050469462487L; @Override public void execute(Interpreter interpreter) { String s = (String) interpreter.popData(); Component c = (Component) interpreter.popData(); c.setCaption(s); interpreter.pushData(c); } }, new BaseWord("set-value", "", Word.POSTPONED) { private static final long serialVersionUID = -1769743552659215058L; @Override public void execute(Interpreter interpreter) { Object o = interpreter.popData(); Property p = (Property) interpreter.popData(); p.setValue(o); interpreter.pushData(p); } }, new BaseWord("get-value", "", Word.POSTPONED) { private static final long serialVersionUID = 8445550546521886374L; @Override public void execute(Interpreter interpreter) { Field f = (Field) interpreter.popData(); interpreter.pushData(f); interpreter.pushData(f.getValue()); } }, new BaseWord("set-size-full", "", Word.POSTPONED) { private static final long serialVersionUID = -1206491811133054467L; @Override public void execute(Interpreter interpreter) { Component comp = (Component) interpreter.popData(); comp.setSizeFull(); interpreter.pushData(comp); } }, new BaseWord("set-size-undefined", "", Word.POSTPONED) { private static final long serialVersionUID = -3450618729379622987L; @Override public void execute(Interpreter interpreter) { Component comp = (Component) interpreter.popData(); comp.setSizeUndefined(); interpreter.pushData(comp); } }, new BaseWord("set-height", "", Word.POSTPONED) { private static final long serialVersionUID = -8426734568403715950L; @Override public void execute(Interpreter interpreter) { String str = (String) interpreter.popData(); Component comp = (Component) interpreter.popData(); comp.setHeight(str); interpreter.pushData(comp); } }, new BaseWord("set-width", "", Word.POSTPONED) { private static final long serialVersionUID = -4558264143049463814L; @Override public void execute(Interpreter interpreter) { String str = (String) interpreter.popData(); Component comp = (Component) interpreter.popData(); comp.setWidth(str); interpreter.pushData(comp); } }, new BaseWord("clear-container", "", Word.POSTPONED) { private static final long serialVersionUID = 1070175466682034329L; @Override public void execute(Interpreter interpreter) { ComponentContainer cc = (ComponentContainer) interpreter.popData(); cc.removeAllComponents(); } }, new BaseWord("new-check-box", "", Word.POSTPONED) { private static final long serialVersionUID = 4018632924389912599L; @Override public void execute(Interpreter interpreter) { interpreter.pushData(new CheckBox()); } }, new BaseWord("new-date-field", "", Word.POSTPONED) { private static final long serialVersionUID = 6313296566085274642L; @Override public void execute(final Interpreter interpreter) { interpreter.pushData(new DateField()); final String dfCommand = (String) interpreter.popData(); DateField df = new DateField(); df.setImmediate(true); df.addValueChangeListener(new ValueChangeListener() { /** * */ private static final long serialVersionUID = 1472139878970514093L; public void valueChange(ValueChangeEvent event) { interpreter.pushData(event.getProperty().getValue()); interpreter.interpret(dfCommand); } }); interpreter.pushData(df); } }, new BaseWord("new-label", "", Word.POSTPONED) { private static final long serialVersionUID = -2825285195439247251L; @Override public void execute(Interpreter interpreter) { interpreter.pushData(new Label()); } }, new BaseWord("new-text-field", "", Word.POSTPONED) { private static final long serialVersionUID = -1064489458253275380L; @Override public void execute(final Interpreter interpreter) { final String tfCommand = interpreter.getNextNonNopWord(); TextField tf = new TextField(); tf.setCaption((String) interpreter.popData()); tf.setValue(""); tf.setImmediate(true); tf.addValueChangeListener(new ValueChangeListener() { private static final long serialVersionUID = 4325104922208051065L; public void valueChange(ValueChangeEvent event) { interpreter.pushData(event.getProperty().getValue()); interpreter.interpret(tfCommand); } }); interpreter.pushData(tf); } }, new BaseWord("new-table", "", Word.POSTPONED) { private static final long serialVersionUID = -5052653341575232035L; @Override public void execute(final Interpreter interpreter) { final String tableCommand = interpreter.getParser().getNextWord(); Table table = new Table(); table.setCaption((String) interpreter.popData()); table.setImmediate(true); table.setSelectable(true); table.addItemClickListener(new ItemClickListener() { /** * */ private static final long serialVersionUID = 3585546076571010729L; public void itemClick(ItemClickEvent event) { interpreter.pushData(event.getItem()); interpreter.execute(interpreter.getDictionary().get(tableCommand)); } }); interpreter.pushData(table); } }, new BaseWord("new-combo-box", "", Word.POSTPONED) { private static final long serialVersionUID = 3881577354424928897L; @Override public void execute(final Interpreter interpreter) { final String newItemCommand = interpreter.getParser().getNextWord(); final String itemSelectedCommand = interpreter.getParser().getNextWord(); final ComboBox cb = new ComboBox(); String str = (String) interpreter.popData(); cb.setNullSelectionAllowed(false); cb.setCaption(str); cb.setItemCaptionMode(AbstractSelect.ItemCaptionMode.ITEM); cb.setNewItemsAllowed(true); cb.setNewItemHandler(new NewItemHandler() { /** * */ private static final long serialVersionUID = 3340658590351611289L; public void addNewItem(String newItemCaption) { cb.setImmediate(false); interpreter.pushData(newItemCaption); interpreter.interpret(newItemCommand); cb.setImmediate(true); } }); cb.addValueChangeListener(new ValueChangeListener() { /** * */ private static final long serialVersionUID = 2706579869793251379L; public void valueChange(ValueChangeEvent event) { interpreter.pushData( cb.getContainerDataSource().getItem(event.getProperty().getValue())); interpreter.interpret(itemSelectedCommand); } }); cb.setImmediate(true); interpreter.pushData(cb); } }, new BaseWord("new-select", "", Word.POSTPONED) { private static final long serialVersionUID = -6142351970812196488L; @Override public void execute(final Interpreter interpreter) { final String selCommand = interpreter.getParser().getNextWord(); final ComboBox sel = new ComboBox(); sel.setCaption((String) interpreter.popData()); sel.setItemCaptionMode(AbstractSelect.ItemCaptionMode.ITEM); sel.setNullSelectionAllowed(false); sel.setImmediate(true); sel.addValueChangeListener(new ValueChangeListener() { /** * */ private static final long serialVersionUID = -7705548618092166199L; public void valueChange(ValueChangeEvent event) { Item item = sel.getContainerDataSource().getItem(event.getProperty().getValue()); interpreter.pushData(item); interpreter.interpret(selCommand); } }); interpreter.pushData(sel); } }, new BaseWord("new-list-select", "", Word.POSTPONED) { private static final long serialVersionUID = 8686093227035249035L; @Override public void execute(final Interpreter interpreter) { final String lselCommand = interpreter.getParser().getNextWord(); final ListSelect lsel = new ListSelect(); lsel.setCaption((String) interpreter.popData()); lsel.setItemCaptionMode(AbstractSelect.ItemCaptionMode.ITEM); lsel.setNullSelectionAllowed(false); lsel.setImmediate(true); lsel.addValueChangeListener(new ValueChangeListener() { private static final long serialVersionUID = -5523488417834167806L; public void valueChange(ValueChangeEvent event) { Item item = lsel.getContainerDataSource().getItem(event.getProperty().getValue()); interpreter.pushData(item); interpreter.interpret(lselCommand); } }); interpreter.pushData(lsel); } }, new BaseWord("set-container-data-source", "", Word.POSTPONED) { private static final long serialVersionUID = 8644721936358613031L; @Override public void execute(Interpreter interpreter) { Container cont = (Container) interpreter.popData(); AbstractSelect as = (AbstractSelect) interpreter.popData(); as.setContainerDataSource(cont); interpreter.pushData(as); } }, new BaseWord("set-column-headers", "", Word.POSTPONED) { private static final long serialVersionUID = -7296881714369214846L; @Override public void execute(Interpreter interpreter) { Table table = (Table) interpreter.popData(); table.setColumnHeaders((String[]) getArrayFromList(interpreter, new String[0])); } }, new BaseWord("set-visible-columns", "", Word.POSTPONED) { private static final long serialVersionUID = 5674765074478598320L; @Override public void execute(Interpreter interpreter) { Table table = (Table) interpreter.popData(); table.setVisibleColumns((String[]) getArrayFromList(interpreter, new String[0])); } } }; }