protected Table createList() { groupTable = new Table(); groupTable.setEditable(false); groupTable.setImmediate(true); groupTable.setSelectable(true); groupTable.setNullSelectionAllowed(false); groupTable.setSortDisabled(true); groupTable.setSizeFull(); groupListQuery = new GroupListQuery(); groupListContainer = new LazyLoadingContainer(groupListQuery, 20); groupTable.setContainerDataSource(groupListContainer); // Column headers groupTable.addGeneratedColumn("icon", new ThemeImageColumnGenerator(Images.GROUP_22)); groupTable.setColumnWidth("icon", 22); groupTable.addContainerProperty("name", String.class, null); groupTable.setColumnHeaderMode(Table.COLUMN_HEADER_MODE_HIDDEN); // Listener to change right panel when clicked on a user groupTable.addListener( new Property.ValueChangeListener() { private static final long serialVersionUID = 1L; public void valueChange(ValueChangeEvent event) { Item item = groupTable.getItem( event .getProperty() .getValue()); // the value of the property is the itemId of the table entry if (item != null) { String groupId = (String) item.getItemProperty("id").getValue(); setDetailComponent(new GroupDetailPanel(GroupPage.this, groupId)); // Update URL ExplorerApp.get() .setCurrentUriFragment(new UriFragment(GroupNavigator.GROUP_URI_PART, groupId)); } else { // Nothing is selected setDetailComponent(null); ExplorerApp.get() .setCurrentUriFragment(new UriFragment(GroupNavigator.GROUP_URI_PART, groupId)); } } }); return groupTable; }
protected Table createList() { // customerService = ProcessEngines.getDefaultProcessEngine().getCustomerService(); // customerService.newUser("hebele"); Table table = new Table(); table.addStyleName(ExplorerLayout.STYLE_PROCESS_DEFINITION_LIST); // table.addGeneratedColumn("icon", new ThemeImageColumnGenerator(Images.REPORT_22)); table.setColumnWidth("icon", 18); // table.addContainerProperty("name", String.class, null); table.setColumnHeaderMode(Table.COLUMN_HEADER_MODE_HIDDEN); // Set non-editable, selectable and full-size table.setEditable(false); table.setImmediate(true); table.setSelectable(true); table.setNullSelectionAllowed(false); table.setSortDisabled(true); table.setSizeFull(); return table; }
private void showSpreadsheet(File file) { // ApplicationResource resource = (ApplicationResource) // file.getResource(); String string = new String(file.bas.toByteArray()); String[] rows = string.split("\n"); String[] cols = rows[0].split(","); Table table = new Table(); for (String string2 : cols) { // String col = string2.replaceAll("\"", ""); // remove surrounding "" table.addContainerProperty(string2, String.class, ""); } for (int i = 1; i < rows.length; i++) { String[] split = rows[i].split(","); table.addItem(split, "" + i); } VerticalLayout layout = new VerticalLayout(); layout.setMargin(true); Window w = new Window(file.getName(), layout); layout.setSizeUndefined(); table.setEditable(true); layout.addComponent(table); getMainWindow().addWindow(w); }
private DataBinder<MarathonData> showPhaseData(final FormLayout layout, final Phase phase) { layout.setMargin(true); final BeanFieldGroup<PhaseDataCompetition> binder = new BeanFieldGroup<PhaseDataCompetition>(PhaseDataCompetition.class); final DurationFieldFactory fieldFactory = new DurationFieldFactory(); binder.setFieldFactory(fieldFactory); // layout.addComponent(binder.buildAndBind("geplante Startzeit", "startTime")); // layout.addComponent(binder.buildAndBind("Maximale Zeit", "maxTime")); // layout.addComponent(binder.buildAndBind("Minimale Zeit", "minTime")); layout.addComponent(binder.buildAndBind("Name der Phase", "phaseName")); layout.addComponent(binder.buildAndBind("Länge in m", "length")); // layout.addComponent(binder.buildAndBind("Geschwindigkeit im m/s", "velocity")); // layout.addComponent(binder.buildAndBind("Tabelle", "entries")); final BeanItemContainer<Entry<String, PhaseDataCategory>> categoryTimesItemContainer = new BeanItemContainer<Map.Entry<String, PhaseDataCategory>>(Map.Entry.class); final Table timesTable = new Table("Zeiten"); timesTable.setContainerDataSource(categoryTimesItemContainer); timesTable.setHeight("8em"); timesTable.removeContainerProperty("key"); timesTable.removeContainerProperty("value"); timesTable.addGeneratedColumn( "Kategorie", new ColumnGenerator() { @Override public Object generateCell( final Table source, final Object itemId, final Object columnId) { @SuppressWarnings("unchecked") final Entry<String, PhaseDataCategory> entry = (Entry<String, PhaseDataCategory>) itemId; return new Label(entry.getKey()); } }); timesTable.addGeneratedColumn( "Min. Zeit", new ColumnGenerator() { @Override public Object generateCell( final Table source, final Object itemId, final Object columnId) { @SuppressWarnings("unchecked") final Entry<String, PhaseDataCategory> entry = (Entry<String, PhaseDataCategory>) itemId; final TextField field = fieldFactory.createField(Duration.class, TextField.class); final PhaseDataCategory phaseDataCategory = entry.getValue(); final ObjectProperty<Duration> property = new ObjectProperty<Duration>( defaultIfNull(phaseDataCategory.getMinTime(), new Duration(0))); field.setPropertyDataSource(property); property.addValueChangeListener( new ValueChangeListener() { @Override public void valueChange(final ValueChangeEvent event) { phaseDataCategory.setMinTime(property.getValue()); } }); return field; } }); timesTable.addGeneratedColumn( "Max. Zeit", new ColumnGenerator() { @Override public Object generateCell( final Table source, final Object itemId, final Object columnId) { @SuppressWarnings("unchecked") final Entry<String, PhaseDataCategory> entry = (Entry<String, PhaseDataCategory>) itemId; final TextField field = fieldFactory.createField(Duration.class, TextField.class); final PhaseDataCategory phaseDataCategory = entry.getValue(); final ObjectProperty<Duration> property = new ObjectProperty<Duration>( defaultIfNull(phaseDataCategory.getMaxTime(), new Duration(0))); field.setPropertyDataSource(property); property.addValueChangeListener( new ValueChangeListener() { @Override public void valueChange(final ValueChangeEvent event) { phaseDataCategory.setMaxTime(property.getValue()); } }); return field; } }); timesTable.addGeneratedColumn( "Geschw.", new ColumnGenerator() { @Override public Object generateCell( final Table source, final Object itemId, final Object columnId) { @SuppressWarnings("unchecked") final Entry<String, PhaseDataCategory> entry = (Entry<String, PhaseDataCategory>) itemId; final PhaseDataCategory phaseDataCategory = entry.getValue(); phaseDataCategory.getVelocity(); final TextField field = fieldFactory.createField(Double.class, TextField.class); final ObjectProperty<Double> property = new ObjectProperty<Double>( defaultIfNull(phaseDataCategory.getVelocity(), Double.valueOf(0))); field.setPropertyDataSource(property); property.addValueChangeListener( new ValueChangeListener() { @Override public void valueChange(final ValueChangeEvent event) { phaseDataCategory.setVelocity(property.getValue()); } }); return field; } }); layout.addComponent(timesTable); final BeanItemContainer<TimeEntry> timeEntryItemContainer = new BeanItemContainer<TimeEntry>(TimeEntry.class); final Table table = new Table("Strecke"); table.setContainerDataSource(timeEntryItemContainer); table.setEditable(true); table.setSortEnabled(false); table.setNullSelectionAllowed(true); layout.addComponent(table); table.setDragMode(TableDragMode.ROW); table.setDropHandler( new DropHandler() { @Override public void drop(final DragAndDropEvent dropEvent) { final DataBoundTransferable t = (DataBoundTransferable) dropEvent.getTransferable(); final TimeEntry sourceItemId = (TimeEntry) t.getItemId(); // returns our Bean final AbstractSelectTargetDetails dropData = ((AbstractSelectTargetDetails) dropEvent.getTargetDetails()); final TimeEntry targetItemId = (TimeEntry) dropData.getItemIdOver(); // returns our Bean // No move if source and target are the same, or there is no target if (sourceItemId == targetItemId || targetItemId == null) return; // Let's remove the source of the drag so we can add it back where requested... timeEntryItemContainer.removeItem(sourceItemId); if (dropData.getDropLocation() == VerticalDropLocation.BOTTOM) { timeEntryItemContainer.addItemAfter(targetItemId, sourceItemId); } else { final Object prevItemId = timeEntryItemContainer.prevItemId(targetItemId); timeEntryItemContainer.addItemAfter(prevItemId, sourceItemId); } } @Override public AcceptCriterion getAcceptCriterion() { return new SourceIs(table); } }); table.addGeneratedColumn( "", new ColumnGenerator() { @Override public Object generateCell( final Table source, final Object itemId, final Object columnId) { final Button button = new Button("Löschen"); button.addClickListener( new ClickListener() { @Override public void buttonClick(final ClickEvent event) { source.getContainerDataSource().removeItem(itemId); } }); return button; } }); final TableFieldFactory tableFieldFactory = new TableFieldFactory() { @Override public Field<?> createField( final Container container, final Object itemId, final Object propertyId, final Component uiContext) { final Class<?> type = container.getType(propertyId); final Field field = fieldFactory.createField(type, Field.class); if (field instanceof AbstractTextField) { final AbstractTextField abstractTextField = (AbstractTextField) field; abstractTextField.setNullRepresentation(""); abstractTextField.setValidationVisible(true); } return field; } }; table.setTableFieldFactory(tableFieldFactory); layout.addComponent( new Button( "Neuer Steckenpunkt", new ClickListener() { @Override public void buttonClick(final ClickEvent event) { timeEntryItemContainer.addBean(new TimeEntry()); } })); final DataBinder<MarathonData> phaseDataBinder = new DataBinder<MarathonData>() { private MarathonData data; @Override public void bindData(final MarathonData phaseData) { this.data = phaseData; final PhaseDataCompetition dataCompetition = data.getCompetitionPhases().get(phase); binder.setItemDataSource(dataCompetition); timeEntryItemContainer.removeAllItems(); timeEntryItemContainer.addAll(dataCompetition.getEntries()); categoryTimesItemContainer.removeAllItems(); final Map<String, PhaseDataCategory> categoryTimes = dataCompetition.getCategoryTimes(); for (final String category : data.getCategories()) { if (!categoryTimes.containsKey(category)) { categoryTimes.put(category, new PhaseDataCategory()); } categoryTimesItemContainer.addBean( new Entry<String, PhaseDataCategory>() { @Override public String getKey() { return category; } @Override public PhaseDataCategory getValue() { return categoryTimes.get(category); } @Override public PhaseDataCategory setValue(final PhaseDataCategory value) { return categoryTimes.put(category, value); } }); } } @Override public void commitHandler() { try { binder.commit(); final PhaseDataCompetition dataCompetition = data.getCompetitionPhases().get(phase); container2Model(timeEntryItemContainer, dataCompetition); for (final Entry<String, PhaseDataCategory> entry : categoryTimesItemContainer.getItemIds()) { dataCompetition.getCategoryTimes().put(entry.getKey(), entry.getValue()); } } catch (final CommitException e) { throw new RuntimeException("Cannot commit", e); } } @Override public MarathonData getCurrentData() { return data; } }; layout.addComponent( new Button( "Reset Strecke", new ClickListener() { @Override public void buttonClick(final ClickEvent event) { phaseDataBinder.commitHandler(); final PhaseDataCompetition phaseData = phaseDataBinder.getCurrentData().getCompetitionPhases().get(phase); phaseData.setDefaultPoints(); model2Container(phaseData, timeEntryItemContainer); System.out.println(phaseData); } })); return phaseDataBinder; }
private DataBinder<MarathonData> showOverviewData(final FormLayout layout) { layout.setMargin(true); final BeanFieldGroup<MarathonData> binder = new BeanFieldGroup<MarathonData>(MarathonData.class); layout.addComponent(binder.buildAndBind("Veranstaltung", "marathonName")); final BeanItemContainer<String> categoryListContainer = new BeanItemContainer<String>(String.class); final ListSelect categoryListSelect = new ListSelect("Kategorieen", categoryListContainer); categoryListSelect.setNewItemsAllowed(true); categoryListSelect.setNullSelectionAllowed(false); categoryListSelect.setMultiSelect(false); layout.addComponent(categoryListSelect); final Button removeItemButton = new Button("Kategorie löschen"); layout.addComponent(removeItemButton); removeItemButton.addClickListener( new ClickListener() { @Override public void buttonClick(final ClickEvent event) { categoryListContainer.removeItem(categoryListSelect.getValue()); } }); // final ListSelect categoryList = new ListSelect("Kategorieen"); // layout.addComponent(categoryList); final BeanItemContainer<DriverData> driverContainer = new BeanItemContainer<DriverData>(DriverData.class); final Table table = new Table("Fahrer"); table.setContainerDataSource(driverContainer); table.removeContainerProperty("smallSheets"); table.removeContainerProperty("startTimes"); table.removeContainerProperty("category"); table.addGeneratedColumn( "Kategorie", new ColumnGenerator() { @Override public Object generateCell( final Table source, final Object itemId, final Object columnId) { final ComboBox comboBox = new ComboBox(); comboBox.setContainerDataSource(categoryListContainer); final DriverData driverData = (DriverData) itemId; final String category = driverData.getCategory() == null ? "" : driverData.getCategory(); final ObjectProperty<String> property = new ObjectProperty<String>(category); comboBox.setPropertyDataSource(property); property.addValueChangeListener( new ValueChangeListener() { @Override public void valueChange(final ValueChangeEvent event) { driverData.setCategory(property.getValue()); } }); return comboBox; } }); table.addGeneratedColumn( "Generieren", new ColumnGenerator() { @Override public Object generateCell( final Table source, final Object itemId, final Object columnId) { final DriverData driverData = (DriverData) itemId; final Button button = new Button("PDF"); button.addClickListener( new ClickListener() { @Override public void buttonClick(final ClickEvent event) { // showPdfHandler.showPdf(driverData.getName()); } }); return button; } }); table.addGeneratedColumn("Phase A Zettel", createPhaseCheckbox(Phase.A)); table.addGeneratedColumn("Phase D Zettel", createPhaseCheckbox(Phase.D)); table.addGeneratedColumn("Phase E Zettel", createPhaseCheckbox(Phase.E)); final DurationFieldFactory fieldFactory = new DurationFieldFactory(); table.addGeneratedColumn("Phase A Start", createPhaseStartInput(fieldFactory, Phase.A)); table.addGeneratedColumn("Phase D Start", createPhaseStartInput(fieldFactory, Phase.D)); table.addGeneratedColumn("Phase E Start", createPhaseStartInput(fieldFactory, Phase.E)); table.addGeneratedColumn( "Fahrer Löschen", new ColumnGenerator() { @Override public Object generateCell( final Table source, final Object itemId, final Object columnId) { final Button button = new Button("-"); button.addClickListener( new ClickListener() { @Override public void buttonClick(final ClickEvent event) { driverContainer.removeItem(itemId); } }); return button; } }); table.setEditable(true); table.setSortEnabled(false); // table.setNullSelectionAllowed(true); layout.addComponent(table); final Button addDriverButton = new Button("Neuer Fahrer"); addDriverButton.addClickListener( new ClickListener() { @Override public void buttonClick(final ClickEvent event) { final DriverData driver = new DriverData(); driver.setName("Fahrer - " + driverContainer.size()); driverContainer.addBean(driver); } }); layout.addComponent(addDriverButton); return new DataBinder<MarathonData>() { private MarathonData data; @Override public void bindData(final MarathonData data) { this.data = data; binder.setItemDataSource(data); categoryListContainer.removeAllItems(); for (final String category : data.getCategories()) { categoryListContainer.addBean(category); } driverContainer.removeAllItems(); for (final DriverData driver : data.getDrivers().values()) { driverContainer.addBean(driver); } } @Override public void commitHandler() { try { binder.commit(); final List<String> categories = data.getCategories(); categories.clear(); categories.addAll(categoryListContainer.getItemIds()); final Map<String, DriverData> drivers = data.getDrivers(); drivers.clear(); for (final DriverData driver : driverContainer.getItemIds()) { drivers.put(driver.getName(), driver); } } catch (final CommitException e) { throw new RuntimeException("Cannot commit", e); } } @Override public MarathonData getCurrentData() { return data; } }; }
@Override public void init() { Window mainWindow = new Window("GridDemo"); mainWindow.getContent().setSizeFull(); ((VerticalLayout) mainWindow.getContent()).setSpacing(true); Indexed c = getTestContainer(); final Table table = new Table(); table.setImmediate(true); table.setSizeUndefined(); table.setHeight("100%"); table.setWidth("100%"); table.setContainerDataSource(c); table.setCacheRate(0.5d); table.setNullSelectionAllowed(false); final Grid grid = new Grid(c); grid.setWidth("100%"); grid.setHeight("100%"); mainWindow.addComponent(grid); grid.getBody().setCelEditingEnabled(true); grid.setColumnWidth("p1", 200); grid.setImmediate(true); grid.setColumnAlignment("p1", Align.RIGHT); grid.setColumnAlignment("p2", Align.CENTER); grid.getHeader() .setHeaderFactory( new HeaderComponentFactory() { @Override public Component createComponent(final Grid grid, final Object propertyId) { final TextField l = new TextField("<b>" + propertyId + "<\b>"); l.setImmediate(true); l.setWidth("100%"); l.addListener( new ValueChangeListener() { @Override public void valueChange(ValueChangeEvent event) { ((Filterable) grid.getContainerDataSource()) .addContainerFilter( new Filter() { @Override public boolean passesFilter(Object itemId, Item item) throws UnsupportedOperationException { return item.getItemProperty(propertyId) .getValue() .toString() .contains(l.getValue().toString()); } @Override public boolean appliesToProperty(Object id) { return id.equals(propertyId); } }); } }); return l; } }); table.setEditable(true); // mainWindow.addComponent(table); setMainWindow(mainWindow); setTheme("griddemotheme"); }
private void doLayout(TestExerExerciseData oldData) { this.setMargin(true); this.setSpacing(true); this.setWidth("100%"); String oldQuestion; if (oldData != null) { oldQuestion = oldData.getQuestion(); } else { oldQuestion = ""; } String oldStartYear; if (oldData != null) { oldStartYear = Integer.toString(oldData.getStartYear()); } else { oldStartYear = "1900"; } String oldEndYear; if (oldData != null) { oldEndYear = Integer.toString(oldData.getEndYear()); } else { oldEndYear = "2000"; } String oldResolution; if (oldData != null) { oldResolution = Integer.toString(oldData.getResolution()); } else { oldResolution = "1"; } VerticalLayout controlsLayout = new VerticalLayout(); controlsLayout.setWidth("400px"); controlsLayout.addComponent(editorHelper.getInfoEditorView()); controlsLayout.addComponent( editorHelper.getControlbar( new EditedExerciseGiver<TestExerExerciseData>() { @Override public TestExerExerciseData getCurrExerData(boolean forSaving) { return getCurrentExercise(); } })); this.addComponent(controlsLayout); VerticalLayout editlayout = new VerticalLayout(); Label questionTextCapt = new Label(localizer.getUIText(TestExerUiConstants.QUESTION)); questionTextCapt.addStyleName(TestExerThemeConsts.TITLE_STYLE); editlayout.addComponent(questionTextCapt); questionText = new TextField(null, oldQuestion); editlayout.addComponent(questionText); eventStartYear = new TextField("Tapahtumien alkuvuosi", oldStartYear); editlayout.addComponent(eventStartYear); eventEndYear = new TextField("Tapahtumien loppuvuosi", oldEndYear); editlayout.addComponent(eventEndYear); eventResolution = new TextField("Tapahtumien tarkkuus", oldResolution); editlayout.addComponent(eventResolution); this.addComponent(editlayout); eventTable.setEditable(true); eventTable.addContainerProperty("Tapahtuma", String.class, null); eventTable.addContainerProperty("Vuosi", String.class, null); if (oldData != null) { ArrayList<String> eList = oldData.getEventList(); ArrayList<Integer> aList = oldData.getAnswerList(); for (int i = 0; i < eList.size(); i++) { String eName = eList.get(i); Integer aName = aList.get(i); if (eName == null) eName = ""; if (aName == null) aName = 0; eventTable.addItem(new Object[] {eName, Integer.toString(aName)}, new Integer(i)); } for (int i = eList.size(); i < maxEvents; i++) { eventTable.addItem(new Object[] {"", ""}, new Integer(i)); } } else { for (int i = 0; i < maxEvents; i++) { eventTable.addItem(new Object[] {"", ""}, new Integer(i)); } } this.addComponent(eventTable); }
protected Component createMainArea() { layout = new VerticalLayout(); layout.setSpacing(true); layout.setMargin(true); layout.setSizeFull(); HorizontalLayout filterLine = new HorizontalLayout(); TextField filterBox = new TextField(); filterBox.addStyleName(JabylonStyle.SEARCH_FIELD.getCSSName()); filterBox.addListener( new TextChangeListener() { @Override public void textChange(TextChangeEvent event) { propertyFilter.setFilterText(event.getText()); propertyPairContainer.addContainerFilter(propertyFilter); } }); filterBox.setInputPrompt( Messages.getString("PropertiesEditor_FILTER_INPUT_PROMPT")); // $NON-NLS-1$ filterLine.addComponent(filterBox); final CheckBox untranslatedBox = new CheckBox( Messages.getString( "PropertiesEditor_SHOW_ONLY_UNTRANSLATED_BUTTON_CAPTION")); //$NON-NLS-1$ untranslatedBox.addListener( new ClickListener() { @Override public void buttonClick(ClickEvent event) { propertyPairContainer.removeContainerFilter(untranslatedFilter); if (untranslatedBox.getValue().equals(Boolean.TRUE)) propertyPairContainer.addContainerFilter(untranslatedFilter); } }); untranslatedBox.setImmediate(true); filterLine.addComponent(untranslatedBox); layout.addComponent(filterLine); layout.setExpandRatio(filterLine, 0); table = new Table(); table.addStyleName(JabylonStyle.TABLE_STRIPED.getCSSName()); table.setSizeFull(); target = descriptor.loadProperties(); source = descriptor.getMaster().loadProperties(); propertyPairContainer = new PropertyPairContainer(source, target); table.setContainerDataSource(propertyPairContainer); table.setVisibleColumns( propertyPairContainer.getContainerPropertyIds().subList(0, 2).toArray()); table.setWidth(100, Table.UNITS_PERCENTAGE); table.addGeneratedColumn( Messages.getString("PropertiesEditor_PROBLEMS_COLUMN_HEADER"), new ColumnGenerator() { //$NON-NLS-1$ @Override public Object generateCell(Table source, Object itemId, Object columnId) { if (reviews.containsKey(itemId)) { Embedded embedded = new Embedded("", ImageConstants.IMAGE_ERROR); // $NON-NLS-1$ Review review = reviews.get((String) itemId).iterator().next(); // TODO: this can't be the right way to refresh? if (review.cdoInvalid()) { reviews.remove(itemId, review); // the review is // no // longer valid embedded.setIcon(ImageConstants.IMAGE_OK); embedded.setDescription(""); // $NON-NLS-1$ } else { embedded.setDescription(review.getMessage()); } return embedded; } else return new Embedded("", ImageConstants.IMAGE_OK); // $NON-NLS-1$ } }); table.setColumnHeaderMode(Table.COLUMN_HEADER_MODE_EXPLICIT); table.setColumnHeaders( new String[] { Messages.getString("PropertiesEditor_ORIGINAL_COLUMN_HEADER"), Messages.getString("PropertiesEditor_TRANSLATED_COLUMN_HEADER"), Messages.getString("PropertiesEditor_PROBLEMS_COLUMN_HEADER") }); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ table.setColumnExpandRatio(propertyPairContainer.getContainerPropertyIds().get(0), 1.0f); table.setColumnExpandRatio(propertyPairContainer.getContainerPropertyIds().get(1), 1.0f); table.setColumnExpandRatio( Messages.getString("PropertiesEditor_PROBLEMS_COLUMN_HEADER"), 0.0f); // $NON-NLS-1$ table.setEditable(false); table.setWriteThrough(false); table.setSelectable(true); table.setMultiSelect(false); table.setImmediate(true); // react at once when something is selected table.addListener(this); layout.addComponent(table); layout.setExpandRatio(table, 2); createEditorArea(); return layout; }