Author: tchemit Date: 2013-03-04 18:05:50 +0100 (Mon, 04 Mar 2013) New Revision: 530 Url: http://forge.codelutin.com/projects/tutti/repository/revisions/530 Log: refs #1861: [CAPTURE] - Fonctionnalit?\195?\169s de pi?\195?\168ces jointes (review Attachmenteditor + add it on SpeciesBatch) Added: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/editor/AttachmentEditor.java Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUI.jaxx trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUIHandler.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUIModel.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/editor/AttachmentCellComponent.java trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/editor/AttachmentEditorUI.jaxx trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/editor/AttachmentEditorUIHandler.java Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUI.jaxx =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUI.jaxx 2013-03-04 16:57:44 UTC (rev 529) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUI.jaxx 2013-03-04 17:05:50 UTC (rev 530) @@ -75,7 +75,7 @@ <LongTextEditorUI id='longTextEditor'/> - <AttachmentEditorUI id='attachmentEditor'/> + <!--<AttachmentEditorUI id='attachmentEditor'/>--> <JPopupMenu id='tablePopup'> <!--onPopupMenuWillBecomeVisible='handler.updateTablePopup()'>--> Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUIHandler.java =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUIHandler.java 2013-03-04 16:57:44 UTC (rev 529) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUIHandler.java 2013-03-04 17:05:50 UTC (rev 530) @@ -30,6 +30,7 @@ import com.google.common.collect.Multimap; import com.google.common.collect.Sets; import fr.ifremer.tutti.persistence.entities.TuttiEntities; +import fr.ifremer.tutti.persistence.entities.data.AttachementObjectTypeEnum; import fr.ifremer.tutti.persistence.entities.data.Attachment; import fr.ifremer.tutti.persistence.entities.data.BatchContainer; import fr.ifremer.tutti.persistence.entities.data.FishingOperation; @@ -622,7 +623,10 @@ { // File column addColumnToModel(columnModel, - AttachmentCellComponent.newEditor(ui), + AttachmentCellComponent.newEditor(ui, + AttachementObjectTypeEnum.SAMPLE, + "id", + _(SpeciesBatchTableModel.ATTACHMENTS.getHeaderI18nKey())), AttachmentCellComponent.newRender( getDecorator(Attachment.class, null), n_("tutti.tooltip.attachment.none")), Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUIModel.java =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUIModel.java 2013-03-04 16:57:44 UTC (rev 529) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUIModel.java 2013-03-04 17:05:50 UTC (rev 530) @@ -140,6 +140,8 @@ private boolean renameSpeciesBatchEnabled; + private String rootBatchId; + public SpeciesBatchUIModel(EditCatchesUIModel catchesUIModel) { super(catchesUIModel, EditCatchesUIModel.PROPERTY_SPECIES_TOTAL_COMPUTED_WEIGHT, @@ -337,4 +339,11 @@ firePropertyChange(PROPERTY_CREATE_MELAG_ENABLED, oldValue, createMelagEnabled); } + public void setRootBatchId(String rootBatchId) { + this.rootBatchId = rootBatchId; + } + + public String getRootBatchId() { + return rootBatchId; + } } Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/editor/AttachmentCellComponent.java =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/editor/AttachmentCellComponent.java 2013-03-04 16:57:44 UTC (rev 529) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/editor/AttachmentCellComponent.java 2013-03-04 17:05:50 UTC (rev 530) @@ -25,23 +25,20 @@ */ import com.google.common.base.Preconditions; +import fr.ifremer.tutti.persistence.entities.data.AttachementObjectTypeEnum; import fr.ifremer.tutti.persistence.entities.data.Attachment; import fr.ifremer.tutti.ui.swing.util.AbstractTuttiBeanUIModel; +import fr.ifremer.tutti.ui.swing.util.TuttiUI; import fr.ifremer.tutti.ui.swing.util.TuttiUIUtil; import fr.ifremer.tutti.ui.swing.util.table.AbstractSelectTableAction; import fr.ifremer.tutti.ui.swing.util.table.AbstractTuttiTableModel; import fr.ifremer.tutti.ui.swing.util.table.ColumnIdentifier; -import jaxx.runtime.JAXXUtil; import jaxx.runtime.SwingUtil; -import jaxx.runtime.swing.ComponentMover; -import jaxx.runtime.swing.ComponentResizer; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.nuiton.util.decorator.Decorator; import javax.swing.AbstractCellEditor; -import javax.swing.BorderFactory; -import javax.swing.JDialog; import javax.swing.JTable; import javax.swing.border.LineBorder; import javax.swing.table.DefaultTableCellRenderer; @@ -50,18 +47,12 @@ import java.awt.Color; import java.awt.Component; import java.awt.Frame; -import java.awt.event.KeyAdapter; -import java.awt.event.KeyEvent; -import java.awt.event.MouseAdapter; -import java.awt.event.MouseEvent; -import java.awt.event.WindowAdapter; -import java.awt.event.WindowEvent; import java.util.Collection; import static org.nuiton.i18n.I18n._; /** - * Component to edit a cell containing attachments + * Component to edit a cell containing attachments. * * @author kmorin * @since 0.2 @@ -87,18 +78,38 @@ return new AttachmentCellRenderer(decorator, noneText); } + //FIXME remove this public static TableCellEditor newEditor(AttachmentEditorUI ui) { - return new AttachmentCellEditor(ui); + return new AttachmentCellEditor(null, null, null, null, null); } + public static TableCellEditor newEditor(TuttiUI ui, + AttachementObjectTypeEnum objectType, + String objectIdProperty, + String title) { + + Frame frame = SwingUtil.getParentContainer(ui, Frame.class); + + AttachmentCellComponent component = new AttachmentCellComponent(); + component.setBorder(new LineBorder(Color.BLACK)); + + return new AttachmentCellEditor(frame, + component, + objectType, + objectIdProperty, + title); + } + public static class AttachmentCellEditor extends AbstractCellEditor implements TableCellEditor { private static final long serialVersionUID = 1L; protected final AttachmentCellComponent component; - protected final AttachmentEditorUI ui; +// protected final AttachmentEditorUI ui; + protected AttachmentEditor attachmentEditor; + protected Frame frame; protected JTable table; @@ -113,103 +124,144 @@ protected Integer columnIndex; - public AttachmentCellEditor(AttachmentEditorUI ui) { - this.ui = ui; + public AttachmentCellEditor(Frame frame, + AttachmentCellComponent component, + AttachementObjectTypeEnum objectTypeProperty, + String objectIdProperty, + String title) { - component = new AttachmentCellComponent(); - component.setBorder(new LineBorder(Color.BLACK)); - component.addKeyListener(new KeyAdapter() { + this.component = component; + this.attachmentEditor = new AttachmentEditor(frame, + component, + objectTypeProperty, + objectIdProperty, + title) { + + private static final long serialVersionUID = 1L; + @Override - public void keyReleased(KeyEvent e) { - if (e.getKeyCode() == KeyEvent.VK_ENTER || - e.getKeyCode() == KeyEvent.VK_SPACE) { - e.consume(); - startEdit(); - } + protected AbstractTuttiBeanUIModel getBean() { + return editRow; } - }); - component.addMouseListener(new MouseAdapter() { @Override - public void mouseClicked(MouseEvent e) { - e.consume(); - startEdit(); + protected String getProperty() { + return columnIdentifier.getPropertyName(); } - }); - } - protected void startEdit() { - if (frame == null) { - frame = SwingUtil.getParentContainer(ui, Frame.class); - } + @Override + public void startEdit() { + super.startEdit(); + int r = rowIndex; + int c = columnIndex; - ui.setBorder(BorderFactory.createTitledBorder(_(columnIdentifier.getHeaderI18nKey()))); - ui.setBean(editRow); - ui.setProperty(columnIdentifier.getPropertyName()); + // stop edition + stopCellEditing(); - JDialog editor = new JDialog(frame, true); - editor.setUndecorated(true); - editor.add(ui); - editor.setResizable(true); - editor.pack(); - - ComponentResizer cr = new ComponentResizer(); - cr.registerComponent(editor); - ComponentMover cm = new ComponentMover(); - cm.setDragInsets(cr.getDragInsets()); - cm.registerComponent(editor); - - editor.addWindowListener(new WindowAdapter() { - - @Override - public void windowClosed(WindowEvent e) { - Component ui = (Component) e.getSource(); - if (log.isInfoEnabled()) { - log.info("Destroy ui " + ui); - } - JAXXUtil.destroy(ui); + // reselect this cell + AbstractSelectTableAction.doSelectCell(table, r, c); + table.requestFocus(); } - }); + }; + } - // Computes the location of bottom left corner of the cell - Component comp = component; - int x = 0; - int y = component.getHeight(); - while (comp != null) { - x += comp.getX(); - y += comp.getY(); - comp = comp.getParent(); - } - // if the editor is too big on the right, - // then align its right side to the right side of the cell - if (x + editor.getWidth() > frame.getX() + frame.getWidth()) { - x = x - editor.getWidth() + component.getWidth(); - } - editor.setLocation(x, y); - editor.setVisible(true); +// public AttachmentCellEditor(AttachmentEditorUI ui) { +// this.ui = ui; +// +// this.attachmentEditor = new AttachmentEditor(SwingUtil.getParentContainer(ui, Frame.class)); +// +// component = new AttachmentCellComponent(); +// component.setBorder(new LineBorder(Color.BLACK)); +// component.addKeyListener(new KeyAdapter() { +// @Override +// public void keyReleased(KeyEvent e) { +// if (e.getKeyCode() == KeyEvent.VK_ENTER || +// e.getKeyCode() == KeyEvent.VK_SPACE) { +// e.consume(); +// startEdit(); +// } +// } +// }); +// +// component.addMouseListener(new MouseAdapter() { +// @Override +// public void mouseClicked(MouseEvent e) { +// e.consume(); +// startEdit(); +// } +// }); +// } +// +// protected void startEdit() { +// if (frame == null) { +// frame = SwingUtil.getParentContainer(ui, Frame.class); +// } +// +// ui.setBorder(BorderFactory.createTitledBorder(_(columnIdentifier.getHeaderI18nKey()))); +// ui.setBean(editRow); +// ui.setProperty(columnIdentifier.getPropertyName()); +// +// JDialog editor = new JDialog(frame, true); +// editor.setUndecorated(true); +// editor.add(ui); +// editor.setResizable(true); +// editor.pack(); +// +// ComponentResizer cr = new ComponentResizer(); +// cr.registerComponent(editor); +// ComponentMover cm = new ComponentMover(); +// cm.setDragInsets(cr.getDragInsets()); +// cm.registerComponent(editor); +// +// editor.addWindowListener(new WindowAdapter() { +// +// @Override +// public void windowClosed(WindowEvent e) { +// Component ui = (Component) e.getSource(); +// if (log.isInfoEnabled()) { +// log.info("Destroy ui " + ui); +// } +// JAXXUtil.destroy(ui); +// } +// }); +// +// // Computes the location of bottom left corner of the cell +// Component comp = component; +// int x = 0; +// int y = component.getHeight(); +// while (comp != null) { +// x += comp.getX(); +// y += comp.getY(); +// comp = comp.getParent(); +// } +// // if the editor is too big on the right, +// // then align its right side to the right side of the cell +// if (x + editor.getWidth() > frame.getX() + frame.getWidth()) { +// x = x - editor.getWidth() + component.getWidth(); +// } +// editor.setLocation(x, y); +// editor.setVisible(true); +// +// int r = rowIndex; +// int c = columnIndex; +// +// // stop edition +// stopCellEditing(); +// +// // reselect this cell +// AbstractSelectTableAction.doSelectCell(table, r, c); +// table.requestFocus(); +// } - int r = rowIndex; - int c = columnIndex; - - // stop edition - stopCellEditing(); - - // reselect this cell - AbstractSelectTableAction.doSelectCell(table, r, c); - table.requestFocus(); - } - @Override public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) { - if (tableModel == null) { - tableModel = (AbstractTuttiTableModel<AbstractTuttiBeanUIModel>) table.getModel(); - this.table = table; - columnIdentifier = tableModel.getPropertyName(column); - } + this.table = table; + this.tableModel = (AbstractTuttiTableModel<AbstractTuttiBeanUIModel>) table.getModel(); + columnIdentifier = tableModel.getPropertyName(column); rowIndex = row; columnIndex = column; Added: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/editor/AttachmentEditor.java =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/editor/AttachmentEditor.java (rev 0) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/editor/AttachmentEditor.java 2013-03-04 17:05:50 UTC (rev 530) @@ -0,0 +1,146 @@ +package fr.ifremer.tutti.ui.swing.util.editor; + +/* + * #%L + * Tutti :: UI + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2012 - 2013 Ifremer + * %% + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public + * License along with this program. If not, see + * <http://www.gnu.org/licenses/gpl-3.0.html>. + * #L% + */ + +import fr.ifremer.tutti.persistence.entities.data.AttachementObjectTypeEnum; +import fr.ifremer.tutti.ui.swing.util.AbstractTuttiBeanUIModel; +import jaxx.runtime.JAXXUtil; +import jaxx.runtime.swing.ComponentMover; +import jaxx.runtime.swing.ComponentResizer; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; + +import javax.swing.BorderFactory; +import javax.swing.JComponent; +import javax.swing.JDialog; +import java.awt.Component; +import java.awt.Frame; +import java.awt.event.KeyAdapter; +import java.awt.event.KeyEvent; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; +import java.awt.event.WindowAdapter; +import java.awt.event.WindowEvent; + +/** + * Editor of attachment. + * + * @author tchemit <chemit@codelutin.com> + * @since 1.0.2 + */ +public abstract class AttachmentEditor extends JDialog { + + private static final long serialVersionUID = 1L; + + /** Logger. */ + private static final Log log = LogFactory.getLog(AttachmentEditor.class); + + protected AttachmentEditorUI editor; + + protected JComponent component; + + public AttachmentEditor(Frame owner, + JComponent component, + AttachementObjectTypeEnum objectType, + String objectIdProperty, + String title) { + super(owner, true); + + this.component = component; + editor = new AttachmentEditorUI(); + editor.setBorder(BorderFactory.createTitledBorder(title)); + editor.setObjectType(objectType); + editor.setObjectIdProperty(objectIdProperty); + + setUndecorated(true); + add(editor); + setResizable(true); + + ComponentResizer cr = new ComponentResizer(); + cr.registerComponent(this); + ComponentMover cm = new ComponentMover(); + cm.setDragInsets(cr.getDragInsets()); + cm.registerComponent(this); + + addWindowListener(new WindowAdapter() { + + @Override + public void windowClosed(WindowEvent e) { + Component ui = (Component) e.getSource(); + if (log.isInfoEnabled()) { + log.info("Destroy ui " + ui); + } + JAXXUtil.destroy(ui); + } + }); + + component.addKeyListener(new KeyAdapter() { + @Override + public void keyReleased(KeyEvent e) { + if (e.getKeyCode() == KeyEvent.VK_ENTER || + e.getKeyCode() == KeyEvent.VK_SPACE) { + e.consume(); + startEdit(); + } + } + }); + + component.addMouseListener(new MouseAdapter() { + @Override + public void mouseClicked(MouseEvent e) { + e.consume(); + startEdit(); + } + }); + } + + protected abstract AbstractTuttiBeanUIModel getBean(); + + protected abstract String getProperty(); + + public void startEdit() { + + editor.setBean(getBean()); + editor.setProperty(getProperty()); + + // Computes the location of bottom left corner of the cell + Component comp = component; + int x = 0; + int y = component.getHeight(); + while (comp != null) { + x += comp.getX(); + y += comp.getY(); + comp = comp.getParent(); + } + // if the editor is too big on the right, + // then align its right side to the right side of the cell + if (x + getWidth() > getOwner().getX() + getOwner().getWidth()) { + x = x - getWidth() + component.getWidth(); + } + setLocation(x, y); + setVisible(true); + } + +} Property changes on: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/editor/AttachmentEditor.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: svn:eol-style + native Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/editor/AttachmentEditorUI.jaxx =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/editor/AttachmentEditorUI.jaxx 2013-03-04 16:57:44 UTC (rev 529) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/editor/AttachmentEditorUI.jaxx 2013-03-04 17:05:50 UTC (rev 530) @@ -26,9 +26,16 @@ <import> fr.ifremer.tutti.ui.swing.util.AbstractTuttiBeanUIModel fr.ifremer.tutti.persistence.entities.data.Attachment + fr.ifremer.tutti.persistence.entities.data.AttachementObjectTypeEnum jaxx.runtime.swing.editor.FileEditor </import> + <!-- bean property where to find the objectId to attach to Attachment (see Attachment#objectId) --> + <String id='objectIdProperty' javaBean='""'/> + + <!-- object type of attachments (see Attachment#objectType) --> + <AttachementObjectTypeEnum id='objectType' javaBean='null'/> + <!-- bean property linked state --> <String id='property' javaBean='""'/> Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/editor/AttachmentEditorUIHandler.java =================================================================== --- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/editor/AttachmentEditorUIHandler.java 2013-03-04 16:57:44 UTC (rev 529) +++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/editor/AttachmentEditorUIHandler.java 2013-03-04 17:05:50 UTC (rev 530) @@ -24,8 +24,11 @@ * #L% */ +import com.ezware.oxbow.swingbits.util.Preconditions; import com.google.common.collect.Lists; import fr.ifremer.tutti.persistence.entities.data.Attachment; +import fr.ifremer.tutti.service.PersistenceService; +import fr.ifremer.tutti.ui.swing.TuttiUIContext; import fr.ifremer.tutti.ui.swing.util.AbstractTuttiBeanUIModel; import fr.ifremer.tutti.ui.swing.util.TuttiUIUtil; import jaxx.runtime.SwingUtil; @@ -50,22 +53,28 @@ import java.util.List; /** - * Handler of the LongTextEditorUI - * - * @author kmorin + * @author kmorin <morin@codelutin.com> + * @author tchemit <chemit@codelutin.com> * @since 0.2 */ public class AttachmentEditorUIHandler { - private static final Log log = LogFactory.getLog(AttachmentEditorUIHandler.class); + /** Logger. */ + private static final Log log = + LogFactory.getLog(AttachmentEditorUIHandler.class); private final AttachmentEditorUI ui; - public AttachmentEditorUIHandler(AttachmentEditorUI attachmentEditorUI) { - ui = attachmentEditorUI; + private final PersistenceService persistenceService; - ui.addPropertyChangeListener(new PropertyChangeListener() { + public AttachmentEditorUIHandler(AttachmentEditorUI ui) { + this.ui = ui; + persistenceService = + TuttiUIContext.getApplicationContext().getPersistenceService(); + + this.ui.addPropertyChangeListener(new PropertyChangeListener() { + @Override public void propertyChange(PropertyChangeEvent evt) { init(); @@ -98,13 +107,16 @@ @Override public void actionPerformed(ActionEvent e) { AbstractTuttiBeanUIModel bean = ui.getBean(); + + persistenceService.deleteAttachment(attachment.getId()); + String property = ui.getProperty(); List<Attachment> list = (List<Attachment>) TuttiUIUtil.getProperty(bean, property); - if (list != null) { - list.remove(attachment); - TuttiUIUtil.setProperty(bean, property, list); - } + Preconditions.checkNotNull(list); + list.remove(attachment); + TuttiUIUtil.setProperty(bean, property, list); + ui.getAttachments().remove(hbox); JDialog parent = SwingUtil.getParentContainer(ui, JDialog.class); @@ -120,7 +132,8 @@ @Override public void mouseClicked(MouseEvent e) { - SwingUtil.openLink("file://" + attachment.getFile().getAbsolutePath()); + File file = persistenceService.getAttachmentFile(attachment.getId()); + SwingUtil.openLink("file://" + file.getAbsolutePath()); } @Override @@ -147,33 +160,30 @@ SwingUtil.getParentContainer(ui, Window.class).dispose(); } -// public void chooseFile() { -// if (fileChooser.showOpenDialog(ui) == JFileChooser.APPROVE_OPTION) { -// File file = fileChooser.getSelectedFile(); -// getModel().setFile(file); -// ui.getFile().setText(file.getAbsolutePath()); -// } -// } - public void addAttachment() { AbstractTuttiBeanUIModel bean = ui.getBean(); String property = ui.getProperty(); List<Attachment> list = (List<Attachment>) TuttiUIUtil.getProperty(bean, property); if (list == null) { list = Lists.newArrayList(); + TuttiUIUtil.setProperty(bean, property, list); } Attachment attachment = new Attachment(); + File file = ui.getFile().getSelectedFile(); if (file != null) { - attachment.setFile(file); String name = ui.getFileName().getText(); if (StringUtils.isEmpty(name)) { name = file.getName(); } + attachment.setObjectType(ui.getObjectType()); + attachment.setObjectId(Integer.valueOf(String.valueOf(TuttiUIUtil.getProperty(bean, ui.getObjectIdProperty())))); attachment.setName(name); attachment.setComment(ui.getFileComment().getText()); + + attachment = persistenceService.createAttachment(attachment, file); + list.add(attachment); - TuttiUIUtil.setProperty(bean, property, list); resetFields(); addAttachment(attachment);