Tutti-commits
Threads by month
- ----- 2026 -----
- June
- May
- April
- March
- February
- January
- ----- 2025 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
March 2013
- 5 participants
- 242 discussions
05 Mar '13
Author: tchemit
Date: 2013-03-05 11:45:23 +0100 (Tue, 05 Mar 2013)
New Revision: 534
Url: http://forge.codelutin.com/projects/tutti/repository/revisions/534
Log:
fixes #1860: [CAMPAGNE] - Fonctionnalit?\195?\169s de pi?\195?\168ces jointes
fixes #1963: [CAPTURE] - Global - Ajouter pi?\195?\168ce jointe sur tous les onglets
Added:
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/attachment/
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/attachment/AttachmentCellEditor.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/attachment/AttachmentCellRenderer.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/attachment/AttachmentEditor.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/attachment/AttachmentEditorUI.css
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/attachment/AttachmentEditorUI.jaxx
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/attachment/AttachmentEditorUIHandler.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/attachment/AttachmentModelAware.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/attachment/ButtonAttachmentEditor.java
Removed:
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/AttachmentEditor.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/editor/AttachmentEditorUI.css
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/cruise/EditCruiseUI.css
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/cruise/EditCruiseUI.jaxx
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/cruise/EditCruiseUIHandler.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/cruise/EditCruiseUIModel.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/EditFishingOperationAction.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/EditFishingOperationUI.css
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/EditFishingOperationUI.jaxx
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/EditFishingOperationUIHandler.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/EditFishingOperationUIModel.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/ComputeWeightsAction.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/EditCatchesUI.css
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/EditCatchesUI.jaxx
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/EditCatchesUIHandler.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/EditCatchesUIModel.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/accidental/AccidentalBatchUI.jaxx
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/accidental/AccidentalBatchUIHandler.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchRowModel.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchTableModel.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchUI.jaxx
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchUIHandler.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/macrowaste/MacroWasteBatchUI.jaxx
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/macrowaste/MacroWasteBatchUIHandler.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/plankton/PlanktonBatchUI.jaxx
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/plankton/PlanktonBatchUIHandler.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchRowModel.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchTableModel.java
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/content/operation/catches/species/frequency/SpeciesFrequencyUIHandler.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSpeciesBatchUIHandler.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/AbstractTuttiBeanUIModel.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/AbstractTuttiUIHandler.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/TuttiComputedOrNotData.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/table/AbstractTuttiTableModel.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/table/AbstractTuttiTableUIHandler.java
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/cruise/EditCruiseUI.css
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/cruise/EditCruiseUI.css 2013-03-04 20:23:40 UTC (rev 533)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/cruise/EditCruiseUI.css 2013-03-05 10:45:23 UTC (rev 534)
@@ -209,4 +209,8 @@
actionIcon: generate;
text: "tutti.action.generateCampaignName";
enabled: {model.isCanGenerateName()};
+}
+
+#attachmentsButton {
+ enabled: {model.getObjectId() != null};
}
\ No newline at end of file
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/cruise/EditCruiseUI.jaxx
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/cruise/EditCruiseUI.jaxx 2013-03-04 20:23:40 UTC (rev 533)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/cruise/EditCruiseUI.jaxx 2013-03-05 10:45:23 UTC (rev 534)
@@ -30,8 +30,10 @@
fr.ifremer.tutti.persistence.entities.referential.Gear
fr.ifremer.tutti.persistence.entities.referential.Person
fr.ifremer.tutti.persistence.entities.referential.Vessel
+
+ fr.ifremer.tutti.ui.swing.TuttiUIContext
fr.ifremer.tutti.ui.swing.util.TuttiUI
- fr.ifremer.tutti.ui.swing.TuttiUIContext
+ fr.ifremer.tutti.ui.swing.util.attachment.ButtonAttachmentEditor
jaxx.runtime.swing.editor.NumberEditor
jaxx.runtime.swing.editor.bean.BeanComboBox
@@ -93,7 +95,6 @@
<field name='comment' component='commentPane'/>
</BeanValidator>
-
<Table fill='both'>
<!-- cruise program / year / program part / name -->
@@ -218,12 +219,18 @@
<!-- Form Actions -->
<row>
<cell columns='6'>
- <JPanel layout='{new GridLayout(1, 0)}'>
- <JButton id='cancelButton'/>
- <JButton id='saveButton'/>
+ <JPanel layout='{new GridLayout(0,1)}'>
+ <JButton id='attachmentsButton'/>
+ <JPanel layout='{new GridLayout(1, 0)}'>
+ <JButton id='cancelButton'/>
+ <JButton id='saveButton'/>
+ </JPanel>
</JPanel>
</cell>
</row>
</Table>
+ <ButtonAttachmentEditor id='attachmentEditor'
+ initializer='ButtonAttachmentEditor.newEditor(this, attachmentsButton)'/>
+
</JPanel>
\ No newline at end of file
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/cruise/EditCruiseUIHandler.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/cruise/EditCruiseUIHandler.java 2013-03-04 20:23:40 UTC (rev 533)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/cruise/EditCruiseUIHandler.java 2013-03-05 10:45:23 UTC (rev 534)
@@ -26,6 +26,7 @@
import com.google.common.base.Predicate;
import com.google.common.collect.Lists;
+import fr.ifremer.tutti.persistence.entities.data.Attachment;
import fr.ifremer.tutti.persistence.entities.data.Cruise;
import fr.ifremer.tutti.persistence.entities.data.Program;
import fr.ifremer.tutti.persistence.entities.referential.Gear;
@@ -75,27 +76,31 @@
EditCruiseUIModel model = new EditCruiseUIModel();
- // get vessels
+ if (context.isCruiseFilled()) {
- if (!context.isCruiseFilled()) {
+ // load existing cruise
+ Cruise cruise = getDataContext().getCruise();
+ model.fromBean(cruise);
+
+ // load attachments
+ List<Attachment> attachments = persistenceService.getAllAttachments(Integer.valueOf(model.getObjectId()));
+ model.addAllAttachment(attachments);
+
+ if (log.isDebugEnabled()) {
+ log.debug("Will edit cruise: " + cruise.getId());
+ }
+ } else {
+
// create new cruise
Program program = getDataContext().getProgram();
model.setProgram(program);
model.setMultirigNumber(1);
+
if (log.isDebugEnabled()) {
log.debug("Will create a new cruise from program: " + program);
}
- } else {
-
- // load existing program
- Cruise cruise = getDataContext().getCruise();
-
- model.fromBean(cruise);
- if (log.isDebugEnabled()) {
- log.debug("Will edit cruise: " + cruise.getId());
- }
}
listModelIsModify(model);
ui.setContextValue(model);
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/cruise/EditCruiseUIModel.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/cruise/EditCruiseUIModel.java 2013-03-04 20:23:40 UTC (rev 533)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/cruise/EditCruiseUIModel.java 2013-03-05 10:45:23 UTC (rev 534)
@@ -24,6 +24,9 @@
* #L%
*/
+import com.google.common.collect.Lists;
+import fr.ifremer.tutti.persistence.entities.data.AttachementObjectTypeEnum;
+import fr.ifremer.tutti.persistence.entities.data.Attachment;
import fr.ifremer.tutti.persistence.entities.data.Cruise;
import fr.ifremer.tutti.persistence.entities.data.Program;
import fr.ifremer.tutti.persistence.entities.referential.Country;
@@ -31,10 +34,12 @@
import fr.ifremer.tutti.persistence.entities.referential.Person;
import fr.ifremer.tutti.persistence.entities.referential.Vessel;
import fr.ifremer.tutti.ui.swing.util.AbstractTuttiBeanUIModel;
+import fr.ifremer.tutti.ui.swing.util.attachment.AttachmentModelAware;
import org.apache.commons.lang3.StringUtils;
import org.nuiton.util.beans.Binder;
import org.nuiton.util.beans.BinderFactory;
+import java.util.Collection;
import java.util.Date;
import java.util.List;
@@ -44,7 +49,7 @@
* @author tchemit <chemit(a)codelutin.com>
* @since 0.1
*/
-public class EditCruiseUIModel extends AbstractTuttiBeanUIModel<Cruise, EditCruiseUIModel> {
+public class EditCruiseUIModel extends AbstractTuttiBeanUIModel<Cruise, EditCruiseUIModel> implements AttachmentModelAware {
private static final long serialVersionUID = 1L;
@@ -112,6 +117,8 @@
protected VesselTypeEnum vesselType;
+ protected final List<Attachment> attachment = Lists.newArrayList();
+
protected static Binder<EditCruiseUIModel, Cruise> toBeanBinder =
BinderFactory.newBinder(EditCruiseUIModel.class,
Cruise.class);
@@ -284,13 +291,52 @@
return program != null && year != null;
}
- public static final String cruiseNameFormat = "%1$s_%2$s";
+ public static final String CRUISE_NAME_FORMAT = "%1$s_%2$s";
public String getGeneratedCampaignName() {
- String name = String.format(cruiseNameFormat, program.getName(), year);
+ String result = String.format(CRUISE_NAME_FORMAT, program.getName(), year);
if (StringUtils.isNotEmpty(surveyPart)) {
- name += "_" + surveyPart;
+ result += "_" + surveyPart;
}
- return name;
+ return result;
}
+
+ @Override
+ public AttachementObjectTypeEnum getObjectType() {
+ return AttachementObjectTypeEnum.SCIENTIFIC_CRUISE;
+ }
+
+ @Override
+ public String getObjectId() {
+ return getId();
+ }
+
+ @Override
+ public List<Attachment> getAttachment() {
+ return attachment;
+ }
+
+ @Override
+ public void addAllAttachment(Collection<Attachment> attachments) {
+ this.attachment.addAll(attachments);
+ firePropertyChange(PROPERTY_ATTACHMENT, null, getAttachment());
+ }
+
+ @Override
+ public void addAttachment(Attachment attachment) {
+ this.attachment.add(attachment);
+ firePropertyChange(PROPERTY_ATTACHMENT, null, getAttachment());
+ }
+
+ @Override
+ public void removeAllAttachment(Collection<Attachment> attachments) {
+ this.attachment.removeAll(attachments);
+ firePropertyChange(PROPERTY_ATTACHMENT, null, getAttachment());
+ }
+
+ @Override
+ public void removeAttachment(Attachment attachment) {
+ this.attachment.remove(attachment);
+ firePropertyChange(PROPERTY_ATTACHMENT, null, getAttachment());
+ }
}
\ No newline at end of file
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/EditFishingOperationAction.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/EditFishingOperationAction.java 2013-03-04 20:23:40 UTC (rev 533)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/EditFishingOperationAction.java 2013-03-05 10:45:23 UTC (rev 534)
@@ -26,6 +26,7 @@
import com.google.common.collect.Lists;
import fr.ifremer.tutti.persistence.entities.TuttiEntities;
+import fr.ifremer.tutti.persistence.entities.data.Attachment;
import fr.ifremer.tutti.persistence.entities.data.CatchBatch;
import fr.ifremer.tutti.persistence.entities.data.Cruise;
import fr.ifremer.tutti.persistence.entities.data.FishingOperation;
@@ -52,6 +53,7 @@
import java.awt.BorderLayout;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
+import java.util.Collections;
import java.util.List;
import static org.nuiton.i18n.I18n._;
@@ -381,6 +383,8 @@
EditFishingOperationUIModel editFishingOperationUIModel = ui.getModel();
+ editFishingOperationUIModel.removeAllAttachment(editFishingOperationUIModel.getAttachment());
+
handler.uninstallStartDateListener();
handler.uninstallCoordinatesListener();
@@ -450,9 +454,15 @@
HydrologyTabUI hydrologyTab = ui.getHydrologyTabContent();
hydrologyTab.getHandler().reset(bean);
+ Integer objectId = Integer.valueOf(editFishingOperationUIModel.getObjectId());
+
+ List<Attachment> attachments =
+ getContext().getPersistenceService().getAllAttachments(objectId);
+
+ editFishingOperationUIModel.addAllAttachment(attachments);
+
editFishingOperationUIModel.setModify(false);
handler.getFishingOperationMonitor().clearModified();
-
handler.registerValidator();
}
@@ -473,6 +483,8 @@
CatchBatch batch;
+ List<Attachment> attachments;
+
if (empty) {
// create a new CatchBatch
@@ -482,6 +494,8 @@
batch = new CatchBatch();
batch.setFishingOperation(bean);
+ attachments = Collections.emptyList();
+
} else {
String operationId = bean.getId();
@@ -497,6 +511,11 @@
batch = persistenceService.getCatchBatchFromFishingOperation(
operationId, true);
batch.setFishingOperation(bean);
+
+ Integer objectId = Integer.valueOf(batch.getId());
+
+
+ attachments = persistenceService.getAllAttachments(objectId);
}
catchesUIModel.setCatchBatch(batch);
@@ -504,6 +523,8 @@
catchesUIModel.fromBean(batch);
+ catchesUIModel.addAllAttachment(attachments);
+
catchesUIModel.setModify(false);
catchBatchMonitor.clearModified();
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/EditFishingOperationUI.css
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/EditFishingOperationUI.css 2013-03-04 20:23:40 UTC (rev 533)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/EditFishingOperationUI.css 2013-03-05 10:45:23 UTC (rev 534)
@@ -466,8 +466,7 @@
}
#durationField {
- text: {TuttiUIUtil.getDuration(
- model.getGearShootingStartDate(), model.getGearShootingEndDate())};
+ text: {TuttiUIUtil.getDuration(model.getGearShootingStartDate(), model.getGearShootingEndDate())};
enabled: false;
_validatorLabel : {_("tutti.label.fishingOperation.duration")};
}
@@ -500,5 +499,5 @@
}
#attachmentsButton {
- _tuttiAction: {AttachmentsAction.class};
+ enabled: {model.getId() !=null}
}
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/EditFishingOperationUI.jaxx
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/EditFishingOperationUI.jaxx 2013-03-04 20:23:40 UTC (rev 533)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/EditFishingOperationUI.jaxx 2013-03-05 10:45:23 UTC (rev 534)
@@ -34,6 +34,7 @@
fr.ifremer.tutti.ui.swing.content.operation.fishing.environment.EnvironmentTabUI
fr.ifremer.tutti.ui.swing.content.operation.fishing.gearshooting.GearShootingTabUI
fr.ifremer.tutti.ui.swing.content.operation.fishing.hydrology.HydrologyTabUI
+ fr.ifremer.tutti.ui.swing.util.attachment.ButtonAttachmentEditor
fr.ifremer.tutti.ui.swing.util.editor.CoordinateEditorType
fr.ifremer.tutti.ui.swing.util.editor.SimpleTimeEditor
fr.ifremer.tutti.ui.swing.util.TuttiUIUtil
@@ -158,6 +159,7 @@
<CardLayout2Ext id='gearShootingEndLatitudeLayout'
constructorParams='this, "gearShootingEndLatitudePanel"'/>
+
<JPanel id='fishingOperationPane' constraints='BorderLayout.CENTER'
layout='{new BorderLayout()}'>
@@ -540,4 +542,7 @@
</JPanel>
+ <ButtonAttachmentEditor id='attachmentEditor'
+ initializer='ButtonAttachmentEditor.newEditor(this, attachmentsButton)'/>
+
</JPanel>
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/EditFishingOperationUIHandler.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/EditFishingOperationUIHandler.java 2013-03-04 20:23:40 UTC (rev 533)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/EditFishingOperationUIHandler.java 2013-03-05 10:45:23 UTC (rev 534)
@@ -27,7 +27,9 @@
import com.google.common.base.Preconditions;
import com.google.common.collect.Lists;
import fr.ifremer.tutti.persistence.entities.TuttiEntities;
+import fr.ifremer.tutti.persistence.entities.data.Attachment;
import fr.ifremer.tutti.persistence.entities.data.Cruise;
+import fr.ifremer.tutti.persistence.entities.data.FishingOperation;
import fr.ifremer.tutti.persistence.entities.data.Program;
import fr.ifremer.tutti.persistence.entities.referential.FishingOperationLocation;
import fr.ifremer.tutti.persistence.entities.referential.Gear;
@@ -98,7 +100,6 @@
getModel().setGearShootingEndDate(newDate);
}
}
-
};
private final PropertyChangeListener coordinatePropertiesListener = new PropertyChangeListener() {
@@ -595,4 +596,14 @@
getModel().setModify(false);
}
+ public void reset(FishingOperation bean) {
+
+ Integer objectId = Integer.valueOf(bean.getId());
+
+ List<Attachment> attachments =
+ getContext().getPersistenceService().getAllAttachments(objectId);
+
+ getModel().removeAllAttachment(getModel().getAttachment());
+ getModel().addAllAttachment(attachments);
+ }
}
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/EditFishingOperationUIModel.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/EditFishingOperationUIModel.java 2013-03-04 20:23:40 UTC (rev 533)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/EditFishingOperationUIModel.java 2013-03-05 10:45:23 UTC (rev 534)
@@ -26,6 +26,8 @@
import com.google.common.collect.Lists;
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.Cruise;
import fr.ifremer.tutti.persistence.entities.data.FishingOperation;
import fr.ifremer.tutti.persistence.entities.referential.FishingOperationLocation;
@@ -35,12 +37,14 @@
import fr.ifremer.tutti.persistence.spatial.SexagecimalPosition;
import fr.ifremer.tutti.ui.swing.util.AbstractTuttiBeanUIModel;
import fr.ifremer.tutti.ui.swing.util.TuttiUIUtil;
+import fr.ifremer.tutti.ui.swing.util.attachment.AttachmentModelAware;
import fr.ifremer.tutti.ui.swing.util.editor.CoordinateEditorType;
import org.nuiton.util.DateUtil;
import org.nuiton.util.beans.Binder;
import org.nuiton.util.beans.BinderFactory;
import java.util.Calendar;
+import java.util.Collection;
import java.util.Date;
import java.util.List;
@@ -52,7 +56,7 @@
* @author tchemit <chemit(a)codelutin.com>
* @since 0.1
*/
-public class EditFishingOperationUIModel extends AbstractTuttiBeanUIModel<FishingOperation, EditFishingOperationUIModel> {
+public class EditFishingOperationUIModel extends AbstractTuttiBeanUIModel<FishingOperation, EditFishingOperationUIModel> implements AttachmentModelAware {
private static final long serialVersionUID = 1L;
@@ -132,6 +136,8 @@
public static final String PROPERTY_GEAR = "gear";
+// public static final String PROPERTY_ATTACHMENT = "attachment";
+
public static final String PROPERTY_VALIDATION_CONTEXT = "validationContext";
/**
@@ -183,6 +189,8 @@
protected List<Person> saisisseur = Lists.newArrayList();
+ protected final List<Attachment> attachment = Lists.newArrayList();
+
protected FishingOperation fishingOperation;
protected String validationContext;
@@ -248,6 +256,45 @@
this.cruise = cruise;
}
+ @Override
+ public AttachementObjectTypeEnum getObjectType() {
+ return AttachementObjectTypeEnum.OPERATION;
+ }
+
+ @Override
+ public String getObjectId() {
+ return getId();
+ }
+
+ @Override
+ public List<Attachment> getAttachment() {
+ return attachment;
+ }
+
+ @Override
+ public void addAllAttachment(Collection<Attachment> attachments) {
+ this.attachment.addAll(attachments);
+ firePropertyChange(PROPERTY_ATTACHMENT, null, getAttachment());
+ }
+
+ @Override
+ public void addAttachment(Attachment attachment) {
+ this.attachment.add(attachment);
+ firePropertyChange(PROPERTY_ATTACHMENT, null, getAttachment());
+ }
+
+ @Override
+ public void removeAllAttachment(Collection<Attachment> attachments) {
+ this.attachment.removeAll(attachments);
+ firePropertyChange(PROPERTY_ATTACHMENT, null, getAttachment());
+ }
+
+ @Override
+ public void removeAttachment(Attachment attachment) {
+ this.attachment.remove(attachment);
+ firePropertyChange(PROPERTY_ATTACHMENT, null, getAttachment());
+ }
+
public String getStationNumber() {
return stationNumber;
}
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/ComputeWeightsAction.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/ComputeWeightsAction.java 2013-03-04 20:23:40 UTC (rev 533)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/ComputeWeightsAction.java 2013-03-05 10:45:23 UTC (rev 534)
@@ -11,15 +11,15 @@
* %%
* 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
+ * 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
+ *
+ * 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%
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/EditCatchesUI.css
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/EditCatchesUI.css 2013-03-04 20:23:40 UTC (rev 533)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/EditCatchesUI.css 2013-03-05 10:45:23 UTC (rev 534)
@@ -224,6 +224,12 @@
_tuttiAction: {ImportPupitriAction.class};
}
+#attachmentsButton {
+ actionIcon: edit-attachment;
+ toolTipText: "tutti.action.attachments.tip";
+ text: {ButtonAttachmentEditor.getButtonText(model.getAttachment())};
+}
+
#benthosTab {
enabled: {false};
}
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/EditCatchesUI.jaxx
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/EditCatchesUI.jaxx 2013-03-04 20:23:40 UTC (rev 533)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/EditCatchesUI.jaxx 2013-03-05 10:45:23 UTC (rev 534)
@@ -36,6 +36,7 @@
fr.ifremer.tutti.ui.swing.content.operation.catches.species.split.SplitSpeciesBatchUI
fr.ifremer.tutti.ui.swing.content.operation.catches.EditCatchesUI
+ fr.ifremer.tutti.ui.swing.util.attachment.ButtonAttachmentEditor
fr.ifremer.tutti.ui.swing.util.editor.TuttiComputedOrNotDataEditor
org.jdesktop.swingx.JXTitledPanel
@@ -281,6 +282,7 @@
<cell columns='2'>
<JPanel layout='{new GridLayout(1,0)}'>
<JButton id='importPupitriButton'/>
+ <JButton id='attachmentsButton'/>
</JPanel>
</cell>
</row>
@@ -350,4 +352,7 @@
</JPanel>
</JPanel>
+ <ButtonAttachmentEditor id='attachmentEditor'
+ initializer='ButtonAttachmentEditor.newEditor(this, attachmentsButton)'/>
+
</JPanel>
\ No newline at end of file
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/EditCatchesUIHandler.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/EditCatchesUIHandler.java 2013-03-04 20:23:40 UTC (rev 533)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/EditCatchesUIHandler.java 2013-03-05 10:45:23 UTC (rev 534)
@@ -65,13 +65,6 @@
private static final Log log =
LogFactory.getLog(EditCatchesUIHandler.class);
-// /**
-// * Persistence service.
-// *
-// * @since 0.3
-// */
-// private final PersistenceService persistenceService;
-
/**
* To monitor changes on the incoming fishing operation.
*
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/EditCatchesUIModel.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/EditCatchesUIModel.java 2013-03-04 20:23:40 UTC (rev 533)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/EditCatchesUIModel.java 2013-03-05 10:45:23 UTC (rev 534)
@@ -24,15 +24,21 @@
* #L%
*/
+import com.google.common.collect.Lists;
+import fr.ifremer.tutti.persistence.entities.data.AttachementObjectTypeEnum;
+import fr.ifremer.tutti.persistence.entities.data.Attachment;
import fr.ifremer.tutti.persistence.entities.data.CatchBatch;
import fr.ifremer.tutti.persistence.entities.data.FishingOperation;
import fr.ifremer.tutti.ui.swing.util.AbstractTuttiBeanUIModel;
import fr.ifremer.tutti.ui.swing.util.TuttiComputedOrNotData;
+import fr.ifremer.tutti.ui.swing.util.attachment.AttachmentModelAware;
import org.nuiton.util.beans.Binder;
import org.nuiton.util.beans.BinderFactory;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
+import java.util.Collection;
+import java.util.List;
import static org.nuiton.i18n.I18n._;
@@ -40,7 +46,7 @@
* @author tchemit <chemit(a)codelutin.com>
* @since 0.3
*/
-public class EditCatchesUIModel extends AbstractTuttiBeanUIModel<CatchBatch, EditCatchesUIModel> {
+public class EditCatchesUIModel extends AbstractTuttiBeanUIModel<CatchBatch, EditCatchesUIModel> implements AttachmentModelAware {
private static final long serialVersionUID = 1L;
@@ -92,41 +98,6 @@
public static final String PROPERTY_CATCH_BATCH = "catchBatch";
- /*protected static final Binder<CatchBatch, EditCatchesUIModel> fromBeanBinder = BinderModelBuilder.newEmptyBuilder(CatchBatch.class, EditCatchesUIModel.class)
- .addSimpleProperties(
- PROPERTY_CATCH_TOTAL_WEIGHT,
- PROPERTY_SPECIES_TOTAL_WEIGHT,
- PROPERTY_SPECIES_TOTAL_SORTED_WEIGHT,
- PROPERTY_SPECIES_TOTAL_UNSORTED_WEIGHT,
- PROPERTY_SPECIES_TOTAL_SAMPLE_SORTED_WEIGHT,
- PROPERTY_SPECIES_TOTAL_INERT_WEIGHT,
- PROPERTY_SPECIES_TOTAL_LIVING_NOT_ITEMIZED_WEIGHT,
- PROPERTY_BENTHOS_TOTAL_WEIGHT,
- PROPERTY_BENTHOS_TOTAL_SORTED_WEIGHT,
- PROPERTY_BENTHOS_TOTAL_UNSORTED_WEIGHT,
- PROPERTY_BENTHOS_TOTAL_SAMPLE_SORTED_WEIGHT,
- PROPERTY_PLANKTON_TOTAL_WEIGHT,
- PROPERTY_PLANKTON_TOTAL_SAMPLE_WEIGHT,
- PROPERTY_MACRO_WASTE_TOTAL_WEIGHT
- ).toBinder();
-
- protected static final Binder<EditCatchesUIModel, CatchBatch> toBeanBinder = BinderModelBuilder.newEmptyBuilder(EditCatchesUIModel.class, CatchBatch.class)
- .addSimpleProperties(
- PROPERTY_SPECIES_TOTAL_WEIGHT,
- PROPERTY_SPECIES_TOTAL_SORTED_WEIGHT,
- PROPERTY_SPECIES_TOTAL_UNSORTED_WEIGHT,
- PROPERTY_SPECIES_TOTAL_SAMPLE_SORTED_WEIGHT,
- PROPERTY_SPECIES_TOTAL_INERT_WEIGHT,
- PROPERTY_SPECIES_TOTAL_LIVING_NOT_ITEMIZED_WEIGHT,
- PROPERTY_BENTHOS_TOTAL_WEIGHT,
- PROPERTY_BENTHOS_TOTAL_SORTED_WEIGHT,
- PROPERTY_BENTHOS_TOTAL_UNSORTED_WEIGHT,
- PROPERTY_BENTHOS_TOTAL_SAMPLE_SORTED_WEIGHT,
- PROPERTY_PLANKTON_TOTAL_WEIGHT,
- PROPERTY_PLANKTON_TOTAL_SAMPLE_WEIGHT,
- PROPERTY_MACRO_WASTE_TOTAL_WEIGHT
- ).toBinder();*/
-
protected static final Binder<CatchBatch, EditCatchesUIModel> fromBeanBinder = BinderFactory.newBinder(CatchBatch.class, EditCatchesUIModel.class);
protected static final Binder<EditCatchesUIModel, CatchBatch> toBeanBinder = BinderFactory.newBinder(EditCatchesUIModel.class, CatchBatch.class);
@@ -175,6 +146,8 @@
protected CatchBatch catchBatch;
+ protected final List<Attachment> attachment = Lists.newArrayList();
+
public EditCatchesUIModel() {
super(CatchBatch.class, fromBeanBinder, toBeanBinder);
speciesTotalSortedComputedOrNotWeight.addPropertyChangeListener(
@@ -463,6 +436,45 @@
firePropertyChange(PROPERTY_MACRO_WASTE_TOTAL_WEIGHT, oldValue, macroWasteTotalWeight);
}
+ @Override
+ public AttachementObjectTypeEnum getObjectType() {
+ return AttachementObjectTypeEnum.CATCH_BATCH;
+ }
+
+ @Override
+ public String getObjectId() {
+ return catchBatch == null ? null : catchBatch.getId();
+ }
+
+ @Override
+ public List<Attachment> getAttachment() {
+ return attachment;
+ }
+
+ @Override
+ public void addAllAttachment(Collection<Attachment> attachments) {
+ this.attachment.addAll(attachments);
+ firePropertyChange(PROPERTY_ATTACHMENT, null, getAttachment());
+ }
+
+ @Override
+ public void addAttachment(Attachment attachment) {
+ this.attachment.add(attachment);
+ firePropertyChange(PROPERTY_ATTACHMENT, null, getAttachment());
+ }
+
+ @Override
+ public void removeAllAttachment(Collection<Attachment> attachments) {
+ this.attachment.removeAll(attachments);
+ firePropertyChange(PROPERTY_ATTACHMENT, null, getAttachment());
+ }
+
+ @Override
+ public void removeAttachment(Attachment attachment) {
+ this.attachment.remove(attachment);
+ firePropertyChange(PROPERTY_ATTACHMENT, null, getAttachment());
+ }
+
public void reset() {
setSpeciesTotalSampleSortedComputedWeight(null);
setSpeciesTotalSortedComputedWeight(null);
@@ -472,6 +484,7 @@
setCatchTotalSortedComputedWeight(null);
setCatchTotalUnsortedComputedWeight(null);
setCatchTotalComputedWeight(null);
+ removeAllAttachment(getAttachment());
}
@Override
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/accidental/AccidentalBatchUI.jaxx
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/accidental/AccidentalBatchUI.jaxx 2013-03-04 20:23:40 UTC (rev 533)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/accidental/AccidentalBatchUI.jaxx 2013-03-05 10:45:23 UTC (rev 534)
@@ -29,7 +29,6 @@
fr.ifremer.tutti.ui.swing.TuttiUIContext
fr.ifremer.tutti.ui.swing.util.editor.LongTextEditorUI
- fr.ifremer.tutti.ui.swing.util.editor.AttachmentEditorUI
jaxx.runtime.swing.editor.NumberEditor
@@ -62,8 +61,6 @@
<LongTextEditorUI id='longTextEditor'/>
- <AttachmentEditorUI id='attachmentEditor'/>
-
<JScrollPane id='tableScrollPane' constraints='BorderLayout.CENTER'>
<JXTable id='table' onFocusLost='handler.saveSelectedRowIfRequired(event)'/>
</JScrollPane>
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/accidental/AccidentalBatchUIHandler.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/accidental/AccidentalBatchUIHandler.java 2013-03-04 20:23:40 UTC (rev 533)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/accidental/AccidentalBatchUIHandler.java 2013-03-05 10:45:23 UTC (rev 534)
@@ -27,6 +27,7 @@
import com.google.common.collect.Lists;
import fr.ifremer.tutti.persistence.entities.TuttiEntities;
import fr.ifremer.tutti.persistence.entities.data.AccidentalBatch;
+import fr.ifremer.tutti.persistence.entities.data.AttachementObjectTypeEnum;
import fr.ifremer.tutti.persistence.entities.data.Attachment;
import fr.ifremer.tutti.persistence.entities.data.FishingOperation;
import fr.ifremer.tutti.persistence.entities.referential.Species;
@@ -35,7 +36,8 @@
import fr.ifremer.tutti.ui.swing.content.operation.catches.EditCatchesUIModel;
import fr.ifremer.tutti.ui.swing.util.TuttiBeanMonitor;
import fr.ifremer.tutti.ui.swing.util.TuttiUI;
-import fr.ifremer.tutti.ui.swing.util.editor.AttachmentCellComponent;
+import fr.ifremer.tutti.ui.swing.util.attachment.AttachmentCellEditor;
+import fr.ifremer.tutti.ui.swing.util.attachment.AttachmentCellRenderer;
import fr.ifremer.tutti.ui.swing.util.editor.LongTextCellComponent;
import jaxx.runtime.validator.swing.SwingValidator;
import org.apache.commons.logging.Log;
@@ -202,7 +204,7 @@
DefaultTableColumnModelExt columnModel =
new DefaultTableColumnModelExt();
- List<Species> allSpecies = persistenceService.getAllSpecies();
+ List<Species> allSpecies = getDataContext().getSpecies();
{
// Species (by code) column
@@ -244,11 +246,15 @@
{ // File column
+ AttachmentCellRenderer renderer = AttachmentCellRenderer.newRender(
+ getDecorator(Attachment.class, null),
+ n_("tutti.tooltip.attachment.none"));
addColumnToModel(columnModel,
- AttachmentCellComponent.newEditor(ui.getAttachmentEditor()),
- AttachmentCellComponent.newRender(
- getDecorator(Attachment.class, null),
- n_("tutti.tooltip.attachment.none")),
+ AttachmentCellEditor.newEditor(ui,
+ renderer,
+ AttachementObjectTypeEnum.SAMPLE
+ ),
+ renderer,
AccidentalBatchTableModel.ATTACHMENTS);
}
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchRowModel.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchRowModel.java 2013-03-04 20:23:40 UTC (rev 533)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchRowModel.java 2013-03-05 10:45:23 UTC (rev 534)
@@ -24,14 +24,18 @@
* #L%
*/
+import com.google.common.collect.Lists;
+import fr.ifremer.tutti.persistence.entities.data.AttachementObjectTypeEnum;
import fr.ifremer.tutti.persistence.entities.data.Attachment;
import fr.ifremer.tutti.persistence.entities.data.SpeciesBatch;
import fr.ifremer.tutti.persistence.entities.referential.Species;
import fr.ifremer.tutti.ui.swing.util.AbstractTuttiBeanUIModel;
+import fr.ifremer.tutti.ui.swing.util.attachment.AttachmentModelAware;
import org.apache.commons.collections.CollectionUtils;
import org.nuiton.util.beans.Binder;
import org.nuiton.util.beans.BinderFactory;
+import java.util.Collection;
import java.util.List;
/**
@@ -40,7 +44,7 @@
* @author tchemit <chemit(a)codelutin.com>
* @since 0.2
*/
-public class BenthosBatchRowModel extends AbstractTuttiBeanUIModel<SpeciesBatch, BenthosBatchRowModel> {
+public class BenthosBatchRowModel extends AbstractTuttiBeanUIModel<SpeciesBatch, BenthosBatchRowModel> implements AttachmentModelAware {
private static final long serialVersionUID = 1L;
@@ -111,11 +115,11 @@
protected String comment;
/**
- * Attachments
+ * Attachments (should never be null).
*
* @since 0.2
*/
- protected List<Attachment> attachments;
+ protected final List<Attachment> attachment = Lists.newArrayList();
/**
* Parent of this batch (can be null if batch is root).
@@ -244,15 +248,47 @@
firePropertyChange(PROPERTY_COMMENT, oldValue, comment);
}
- public List<Attachment> getAttachments() {
- return attachments;
+ //------------------------------------------------------------------------//
+ //-- AttachmentModelAware --//
+ //------------------------------------------------------------------------//
+
+ @Override
+ public AttachementObjectTypeEnum getObjectType() {
+ return AttachementObjectTypeEnum.SAMPLE;
}
- public void setAttachments(List<Attachment> attachments) {
- Object oldValue = getAttachments();
- this.attachments = attachments;
- firePropertyChange(PROPERTY_ATTACHMENTS, oldValue, attachments);
+ @Override
+ public String getObjectId() {
+ return getId();
}
+ @Override
+ public List<Attachment> getAttachment() {
+ return attachment;
+ }
+ @Override
+ public void addAllAttachment(Collection<Attachment> attachments) {
+ this.attachment.addAll(attachments);
+ firePropertyChange(PROPERTY_ATTACHMENT, null, getAttachment());
+ }
+
+ @Override
+ public void addAttachment(Attachment attachment) {
+ this.attachment.add(attachment);
+ firePropertyChange(PROPERTY_ATTACHMENT, null, getAttachment());
+ }
+
+ @Override
+ public void removeAllAttachment(Collection<Attachment> attachments) {
+ this.attachment.removeAll(attachments);
+ firePropertyChange(PROPERTY_ATTACHMENT, null, getAttachment());
+ }
+
+ @Override
+ public void removeAttachment(Attachment attachment) {
+ this.attachment.remove(attachment);
+ firePropertyChange(PROPERTY_ATTACHMENT, null, getAttachment());
+ }
+
}
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchTableModel.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchTableModel.java 2013-03-04 20:23:40 UTC (rev 533)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchTableModel.java 2013-03-05 10:45:23 UTC (rev 534)
@@ -70,8 +70,8 @@
n_("tutti.table.benthos.batch.header.comment"),
n_("tutti.table.benthos.batch.header.comment"));
- public static final ColumnIdentifier<BenthosBatchRowModel> ATTACHMENTS = ColumnIdentifier.newId(
- SpeciesBatchRowModel.PROPERTY_ATTACHMENTS,
+ public static final ColumnIdentifier<BenthosBatchRowModel> ATTACHMENT = ColumnIdentifier.newId(
+ BenthosBatchRowModel.PROPERTY_ATTACHMENT,
n_("tutti.table.benthos.batch.header.file"),
n_("tutti.table.benthos.batch.header.file"));
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchUI.jaxx
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchUI.jaxx 2013-03-04 20:23:40 UTC (rev 533)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchUI.jaxx 2013-03-05 10:45:23 UTC (rev 534)
@@ -28,8 +28,8 @@
fr.ifremer.tutti.ui.swing.util.TuttiUI
fr.ifremer.tutti.ui.swing.TuttiUIContext
+ fr.ifremer.tutti.ui.swing.util.attachment.ButtonAttachmentEditor
fr.ifremer.tutti.ui.swing.util.editor.LongTextEditorUI
- fr.ifremer.tutti.ui.swing.util.editor.AttachmentEditorUI
jaxx.runtime.swing.editor.NumberEditor
@@ -79,7 +79,7 @@
<LongTextEditorUI id='longTextEditor'/>
- <AttachmentEditorUI id='attachmentEditor'/>
+ <!--<AttachmentEditorUI id='attachmentEditor'/>-->
<Table id='form' fill='both' constraints='BorderLayout.NORTH'>
@@ -116,6 +116,27 @@
<JTextField id='benthosTotalUnsortedWeightField'/>
</cell>
</row>
+
+ <!-- Toolbar / Filter -->
+ <row>
+ <cell columns="4">
+ <JPanel id='tableToolbar' layout='{new BorderLayout()}'>
+ <JPanel layout='{new GridLayout(1,0)}' constraints='BorderLayout.WEST'>
+ <!--<JButton id='createSpeciesBatchButton' onActionPerformed='handler.createSpeciesBatch()'/>-->
+ <JButton id='attachmentsButton'/>
+ </JPanel>
+ <!--JPanel id='filterTablePane' constraints='BorderLayout.CENTER'>
+ <JLabel id='filterSpeciesBatchLabel'/>
+ <JRadioButton id='filterSpeciesBatchAllButton'
+ onActionPerformed='model.setTableViewMode(TableViewMode.ALL)'/>
+ <JRadioButton id='filterSpeciesBatchLeafButton'
+ onActionPerformed='model.setTableViewMode(TableViewMode.LEAF)'/>
+ <JRadioButton id='filterSpeciesBatchRootButton'
+ onActionPerformed='model.setTableViewMode(TableViewMode.ROOT)'/>
+ </JPanel-->
+ </JPanel>
+ </cell>
+ </row>
</Table>
<JScrollPane id='tableScrollPane' constraints='BorderLayout.CENTER'>
@@ -123,4 +144,7 @@
onFocusLost='handler.saveSelectedRowIfRequired(event)'/>
</JScrollPane>
+ <ButtonAttachmentEditor id='attachmentEditor'
+ initializer='ButtonAttachmentEditor.newEditor(this, attachmentsButton)'/>
+
</JPanel>
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchUIHandler.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchUIHandler.java 2013-03-04 20:23:40 UTC (rev 533)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/benthos/BenthosBatchUIHandler.java 2013-03-05 10:45:23 UTC (rev 534)
@@ -26,6 +26,7 @@
import com.google.common.collect.Lists;
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.FishingOperation;
import fr.ifremer.tutti.persistence.entities.data.SpeciesBatch;
@@ -35,7 +36,8 @@
import fr.ifremer.tutti.ui.swing.content.operation.catches.EditCatchesUIModel;
import fr.ifremer.tutti.ui.swing.util.TuttiBeanMonitor;
import fr.ifremer.tutti.ui.swing.util.TuttiUI;
-import fr.ifremer.tutti.ui.swing.util.editor.AttachmentCellComponent;
+import fr.ifremer.tutti.ui.swing.util.attachment.AttachmentCellEditor;
+import fr.ifremer.tutti.ui.swing.util.attachment.AttachmentCellRenderer;
import fr.ifremer.tutti.ui.swing.util.editor.LongTextCellComponent;
import jaxx.runtime.validator.swing.SwingValidator;
import org.apache.commons.logging.Log;
@@ -262,12 +264,15 @@
{ // File column
+ AttachmentCellRenderer renderer = AttachmentCellRenderer.newRender(
+ getDecorator(Attachment.class, null),
+ n_("tutti.tooltip.attachment.none"));
addColumnToModel(columnModel,
- AttachmentCellComponent.newEditor(ui.getAttachmentEditor()),
- AttachmentCellComponent.newRender(
- getDecorator(Attachment.class, null),
- n_("tutti.tooltip.attachment.none")),
- BenthosBatchTableModel.ATTACHMENTS);
+ AttachmentCellEditor.newEditor(ui,
+ renderer,
+ AttachementObjectTypeEnum.SAMPLE),
+ renderer,
+ BenthosBatchTableModel.ATTACHMENT);
}
{ // Species to confirm column
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/macrowaste/MacroWasteBatchUI.jaxx
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/macrowaste/MacroWasteBatchUI.jaxx 2013-03-04 20:23:40 UTC (rev 533)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/macrowaste/MacroWasteBatchUI.jaxx 2013-03-05 10:45:23 UTC (rev 534)
@@ -29,7 +29,6 @@
fr.ifremer.tutti.ui.swing.TuttiUIContext
fr.ifremer.tutti.ui.swing.util.editor.LongTextEditorUI
- fr.ifremer.tutti.ui.swing.util.editor.AttachmentEditorUI
jaxx.runtime.swing.editor.NumberEditor
@@ -72,8 +71,6 @@
<LongTextEditorUI id='longTextEditor'/>
- <AttachmentEditorUI id='attachmentEditor'/>
-
<Table id='form' fill='both' constraints='BorderLayout.NORTH'>
<!-- Poids total -->
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/macrowaste/MacroWasteBatchUIHandler.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/macrowaste/MacroWasteBatchUIHandler.java 2013-03-04 20:23:40 UTC (rev 533)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/macrowaste/MacroWasteBatchUIHandler.java 2013-03-05 10:45:23 UTC (rev 534)
@@ -26,6 +26,7 @@
import com.google.common.collect.Lists;
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.FishingOperation;
import fr.ifremer.tutti.persistence.entities.data.MacroWasteBatch;
@@ -34,7 +35,8 @@
import fr.ifremer.tutti.ui.swing.content.operation.catches.EditCatchesUIModel;
import fr.ifremer.tutti.ui.swing.util.TuttiBeanMonitor;
import fr.ifremer.tutti.ui.swing.util.TuttiUI;
-import fr.ifremer.tutti.ui.swing.util.editor.AttachmentCellComponent;
+import fr.ifremer.tutti.ui.swing.util.attachment.AttachmentCellEditor;
+import fr.ifremer.tutti.ui.swing.util.attachment.AttachmentCellRenderer;
import fr.ifremer.tutti.ui.swing.util.editor.LongTextCellComponent;
import jaxx.runtime.validator.swing.SwingValidator;
import org.apache.commons.logging.Log;
@@ -45,6 +47,7 @@
import java.util.List;
+import static org.nuiton.i18n.I18n._;
import static org.nuiton.i18n.I18n.n_;
/**
@@ -253,11 +256,14 @@
{ // File column
+ AttachmentCellRenderer renderer = AttachmentCellRenderer.newRender(
+ getDecorator(Attachment.class, null),
+ n_("tutti.tooltip.attachment.none"));
addColumnToModel(columnModel,
- AttachmentCellComponent.newEditor(ui.getAttachmentEditor()),
- AttachmentCellComponent.newRender(
- getDecorator(Attachment.class, null),
- n_("tutti.tooltip.attachment.none")),
+ AttachmentCellEditor.newEditor(ui,
+ renderer,
+ AttachementObjectTypeEnum.SAMPLE),
+ renderer,
MacroWasteBatchTableModel.ATTACHMENTS);
}
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/plankton/PlanktonBatchUI.jaxx
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/plankton/PlanktonBatchUI.jaxx 2013-03-04 20:23:40 UTC (rev 533)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/plankton/PlanktonBatchUI.jaxx 2013-03-05 10:45:23 UTC (rev 534)
@@ -28,7 +28,6 @@
fr.ifremer.tutti.ui.swing.util.TuttiUI
fr.ifremer.tutti.ui.swing.TuttiUIContext
fr.ifremer.tutti.ui.swing.util.editor.LongTextEditorUI
- fr.ifremer.tutti.ui.swing.util.editor.AttachmentEditorUI
jaxx.runtime.swing.editor.NumberEditor
@@ -73,8 +72,6 @@
<LongTextEditorUI id='longTextEditor'/>
- <AttachmentEditorUI id='attachmentEditor'/>
-
<Table id='form' fill='both' constraints='BorderLayout.NORTH'>
<!-- Poids total -->
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/plankton/PlanktonBatchUIHandler.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/plankton/PlanktonBatchUIHandler.java 2013-03-04 20:23:40 UTC (rev 533)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/plankton/PlanktonBatchUIHandler.java 2013-03-05 10:45:23 UTC (rev 534)
@@ -26,6 +26,7 @@
import com.google.common.collect.Lists;
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.FishingOperation;
import fr.ifremer.tutti.persistence.entities.data.PlanktonBatch;
@@ -35,7 +36,8 @@
import fr.ifremer.tutti.ui.swing.content.operation.catches.EditCatchesUIModel;
import fr.ifremer.tutti.ui.swing.util.TuttiBeanMonitor;
import fr.ifremer.tutti.ui.swing.util.TuttiUI;
-import fr.ifremer.tutti.ui.swing.util.editor.AttachmentCellComponent;
+import fr.ifremer.tutti.ui.swing.util.attachment.AttachmentCellEditor;
+import fr.ifremer.tutti.ui.swing.util.attachment.AttachmentCellRenderer;
import fr.ifremer.tutti.ui.swing.util.editor.LongTextCellComponent;
import jaxx.runtime.validator.swing.SwingValidator;
import org.apache.commons.logging.Log;
@@ -46,6 +48,7 @@
import java.util.List;
+import static org.nuiton.i18n.I18n._;
import static org.nuiton.i18n.I18n.n_;
/**
@@ -249,11 +252,14 @@
{ // File column
+ AttachmentCellRenderer renderer = AttachmentCellRenderer.newRender(
+ getDecorator(Attachment.class, null),
+ n_("tutti.tooltip.attachment.none"));
addColumnToModel(columnModel,
- AttachmentCellComponent.newEditor(ui.getAttachmentEditor()),
- AttachmentCellComponent.newRender(
- getDecorator(Attachment.class, null),
- n_("tutti.tooltip.attachment.none")),
+ AttachmentCellEditor.newEditor(ui,
+ renderer,
+ AttachementObjectTypeEnum.SAMPLE),
+ renderer,
PlanktonBatchTableModel.ATTACHMENTS);
}
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchRowModel.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchRowModel.java 2013-03-04 20:23:40 UTC (rev 533)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchRowModel.java 2013-03-05 10:45:23 UTC (rev 534)
@@ -25,6 +25,7 @@
*/
import com.google.common.collect.Lists;
+import fr.ifremer.tutti.persistence.entities.data.AttachementObjectTypeEnum;
import fr.ifremer.tutti.persistence.entities.data.Attachment;
import fr.ifremer.tutti.persistence.entities.data.SampleCategoryEnum;
import fr.ifremer.tutti.persistence.entities.data.SpeciesBatch;
@@ -34,12 +35,14 @@
import fr.ifremer.tutti.ui.swing.content.operation.catches.species.frequency.SpeciesFrequencyRowModel;
import fr.ifremer.tutti.ui.swing.util.AbstractTuttiBeanUIModel;
import fr.ifremer.tutti.ui.swing.util.TuttiComputedOrNotData;
+import fr.ifremer.tutti.ui.swing.util.attachment.AttachmentModelAware;
import org.apache.commons.collections.CollectionUtils;
import org.nuiton.util.beans.Binder;
import org.nuiton.util.beans.BinderFactory;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
+import java.util.Collection;
import java.util.Collections;
import java.util.List;
@@ -49,7 +52,7 @@
* @author tchemit <chemit(a)codelutin.com>
* @since 0.2
*/
-public class SpeciesBatchRowModel extends AbstractTuttiBeanUIModel<SpeciesBatch, SpeciesBatchRowModel> {
+public class SpeciesBatchRowModel extends AbstractTuttiBeanUIModel<SpeciesBatch, SpeciesBatchRowModel> implements AttachmentModelAware {
private static final long serialVersionUID = 1L;
@@ -101,8 +104,6 @@
public static final String PROPERTY_COMPUTED_WEIGHT = "computedOrNotWeight";
- public static final String PROPERTY_ATTACHMENTS = "attachments";
-
public static final String PROPERTY_PARENT_BATCH = "parentBatch";
public static final String PROPERTY_CHILD_BATCH = "childBatch";
@@ -200,14 +201,14 @@
*
* @since 0.2
*/
- protected final List<Attachment> attachments;
+ protected final List<Attachment> attachment = Lists.newArrayList();
/**
* List of frequencies observed for this batch.
*
* @since 0.2
*/
- protected List<SpeciesFrequencyRowModel> frequency;
+ protected List<SpeciesFrequencyRowModel> frequency = Lists.newArrayList();
/**
* Parent of this batch (can be null if batch is root).
@@ -235,8 +236,6 @@
public SpeciesBatchRowModel() {
super(SpeciesBatch.class, fromBeanBinder, toBeanBinder);
- frequency = Lists.newArrayList();
- attachments = Lists.newArrayList();
sortedUnsortedCategory = SampleCategory.newSample(SampleCategoryType.sortedUnsorted);
sizeCategory = SampleCategory.newSample(SampleCategoryType.size);
sexCategory = SampleCategory.newSample(SampleCategoryType.sex);
@@ -286,7 +285,7 @@
List<SpeciesFrequencyRowModel> frequencyRows =
SpeciesFrequencyRowModel.fromBeans(frequencies);
frequency.addAll(frequencyRows);
- this.attachments.addAll(attachments);
+ this.attachment.addAll(attachments);
Collections.sort(frequency);
}
@@ -556,6 +555,49 @@
}
//------------------------------------------------------------------------//
+ //-- AttachmentModelAware --//
+ //------------------------------------------------------------------------//
+
+ @Override
+ public AttachementObjectTypeEnum getObjectType() {
+ return AttachementObjectTypeEnum.SAMPLE;
+ }
+
+ @Override
+ public String getObjectId() {
+ return getId();
+ }
+
+ @Override
+ public List<Attachment> getAttachment() {
+ return attachment;
+ }
+
+ @Override
+ public void addAllAttachment(Collection<Attachment> attachments) {
+ this.attachment.addAll(attachments);
+ firePropertyChange(PROPERTY_ATTACHMENT, null, getAttachment());
+ }
+
+ @Override
+ public void addAttachment(Attachment attachment) {
+ this.attachment.add(attachment);
+ firePropertyChange(PROPERTY_ATTACHMENT, null, getAttachment());
+ }
+
+ @Override
+ public void removeAllAttachment(Collection<Attachment> attachments) {
+ this.attachment.removeAll(attachments);
+ firePropertyChange(PROPERTY_ATTACHMENT, null, getAttachment());
+ }
+
+ @Override
+ public void removeAttachment(Attachment attachment) {
+ this.attachment.remove(attachment);
+ firePropertyChange(PROPERTY_ATTACHMENT, null, getAttachment());
+ }
+
+ //------------------------------------------------------------------------//
//-- Other properties --//
//------------------------------------------------------------------------//
@@ -596,15 +638,9 @@
}
public List<Attachment> getAttachments() {
- return attachments;
+ return attachment;
}
-// public void setAttachments(List<Attachment> attachments) {
-// Object oldValue = getAttachments();
-// this.attachments = attachments;
-// firePropertyChange(PROPERTY_ATTACHMENTS, oldValue, attachments);
-// }
-
public List<SpeciesFrequencyRowModel> getFrequency() {
return frequency;
}
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchTableModel.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchTableModel.java 2013-03-04 20:23:40 UTC (rev 533)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchTableModel.java 2013-03-05 10:45:23 UTC (rev 534)
@@ -139,8 +139,8 @@
n_("tutti.table.species.batch.header.comment"),
n_("tutti.table.species.batch.header.comment"));
- public static final ColumnIdentifier<SpeciesBatchRowModel> ATTACHMENTS = ColumnIdentifier.newReadOnlyId(
- SpeciesBatchRowModel.PROPERTY_ATTACHMENTS,
+ public static final ColumnIdentifier<SpeciesBatchRowModel> ATTACHMENT = ColumnIdentifier.newReadOnlyId(
+ SpeciesBatchRowModel.PROPERTY_ATTACHMENT,
n_("tutti.table.species.batch.header.file"),
n_("tutti.table.species.batch.header.file"));
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 20:23:40 UTC (rev 533)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUI.jaxx 2013-03-05 10:45:23 UTC (rev 534)
@@ -27,8 +27,8 @@
<import>
fr.ifremer.tutti.ui.swing.util.TuttiUI
+ fr.ifremer.tutti.ui.swing.util.attachment.ButtonAttachmentEditor
fr.ifremer.tutti.ui.swing.util.editor.LongTextEditorUI
- fr.ifremer.tutti.ui.swing.util.editor.AttachmentEditorUI
fr.ifremer.tutti.ui.swing.util.editor.TuttiComputedOrNotDataEditor
org.jdesktop.swingx.JXTable
@@ -75,8 +75,6 @@
<LongTextEditorUI id='longTextEditor'/>
- <!--<AttachmentEditorUI id='attachmentEditor'/>-->
-
<JPopupMenu id='tablePopup'>
<!--onPopupMenuWillBecomeVisible='handler.updateTablePopup()'>-->
<JMenuItem id='splitSpeciesBatchMenu'
@@ -143,8 +141,11 @@
<row>
<cell columns="4">
<JPanel id='tableToolbar' layout='{new BorderLayout()}'>
- <JButton id='createSpeciesBatchButton' constraints='BorderLayout.WEST'
- onActionPerformed='handler.createSpeciesBatch()'/>
+ <JPanel layout='{new GridLayout(1,0)}' constraints='BorderLayout.WEST'>
+ <JButton id='createSpeciesBatchButton'
+ onActionPerformed='handler.createSpeciesBatch()'/>
+ <JButton id='attachmentsButton'/>
+ </JPanel>
<JPanel id='filterTablePane' constraints='BorderLayout.CENTER'>
<JLabel id='filterSpeciesBatchLabel'/>
<JRadioButton id='filterSpeciesBatchAllButton'
@@ -165,4 +166,7 @@
onMouseClicked='handler.autoSelectRowInTable(event, tablePopup)'/>
</JScrollPane>
+ <ButtonAttachmentEditor id='attachmentEditor'
+ initializer='ButtonAttachmentEditor.newEditor(this, attachmentsButton)'/>
+
</JPanel>
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 20:23:40 UTC (rev 533)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUIHandler.java 2013-03-05 10:45:23 UTC (rev 534)
@@ -10,15 +10,15 @@
* %%
* 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
+ * 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
+ *
+ * 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%
@@ -57,7 +57,8 @@
import fr.ifremer.tutti.ui.swing.util.TuttiBeanMonitor;
import fr.ifremer.tutti.ui.swing.util.TuttiUI;
import fr.ifremer.tutti.ui.swing.util.TuttiUIUtil;
-import fr.ifremer.tutti.ui.swing.util.editor.AttachmentCellComponent;
+import fr.ifremer.tutti.ui.swing.util.attachment.AttachmentCellEditor;
+import fr.ifremer.tutti.ui.swing.util.attachment.AttachmentCellRenderer;
import fr.ifremer.tutti.ui.swing.util.editor.LongTextCellComponent;
import fr.ifremer.tutti.ui.swing.util.editor.TuttiComputedOrNotDataTableCell;
import fr.ifremer.tutti.ui.swing.util.table.AbstractSelectTableAction;
@@ -145,7 +146,7 @@
SpeciesBatchRowModel.PROPERTY_WEIGHT,
SpeciesBatchRowModel.PROPERTY_NUMBER,
SpeciesBatchRowModel.PROPERTY_COMMENT,
- SpeciesBatchRowModel.PROPERTY_ATTACHMENTS,
+ SpeciesBatchRowModel.PROPERTY_ATTACHMENT,
SpeciesBatchRowModel.PROPERTY_FREQUENCY,
SpeciesBatchRowModel.PROPERTY_SPECIES_TO_CONFIRM);
tableFilters = new EnumMap<TableViewMode, RowFilter<SpeciesBatchTableModel, Integer>>(TableViewMode.class);
@@ -209,6 +210,8 @@
}
rows = Lists.newArrayList();
+ model.removeAllAttachment(model.getAttachment());
+
if (!TuttiEntities.isNew(bean)) {
// get all batch species root (says the one with only a species sample category)
@@ -217,15 +220,16 @@
model.setRootBatchId(rootSpeciesBatch.getId());
+ List<Attachment> attachments =
+ persistenceService.getAllAttachments(Integer.valueOf(model.getObjectId()));
+ model.addAllAttachment(attachments);
+
if (log.isInfoEnabled()) {
log.info("species root batch id: " + model.getRootBatchId());
}
List<SpeciesBatch> catches = rootSpeciesBatch.getChildren();
-// List<SpeciesBatch> catches =
-// persistenceService.getAllRootSpeciesBatch(bean.getId());
-//
for (SpeciesBatch aBatch : catches) {
// root batch sample categroy is species
@@ -622,15 +626,15 @@
{ // File column
+ AttachmentCellRenderer renderer = AttachmentCellRenderer.newRender(
+ getDecorator(Attachment.class, null),
+ n_("tutti.tooltip.attachment.none"));
addColumnToModel(columnModel,
- AttachmentCellComponent.newEditor(ui,
- AttachementObjectTypeEnum.SAMPLE,
- "id",
- _(SpeciesBatchTableModel.ATTACHMENTS.getHeaderI18nKey())),
- AttachmentCellComponent.newRender(
- getDecorator(Attachment.class, null),
- n_("tutti.tooltip.attachment.none")),
- SpeciesBatchTableModel.ATTACHMENTS);
+ AttachmentCellEditor.newEditor(ui,
+ renderer,
+ AttachementObjectTypeEnum.SAMPLE),
+ renderer,
+ SpeciesBatchTableModel.ATTACHMENT);
}
{ // Species to confirm column
@@ -938,7 +942,7 @@
}
public String getFilterSpeciesBatchRootButtonText(int rootNumber) {
- return _("tutti.label.filterSpeciesBatchMode.mode.root", getModel().getRootNumber());
+ return _("tutti.label.filterSpeciesBatchMode.mode.root", rootNumber);
}
protected void recomputeBatchActionEnable() {
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 20:23:40 UTC (rev 533)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUIModel.java 2013-03-05 10:45:23 UTC (rev 534)
@@ -25,20 +25,25 @@
*/
import com.google.common.collect.ArrayListMultimap;
+import com.google.common.collect.Lists;
import com.google.common.collect.Multimap;
+import fr.ifremer.tutti.persistence.entities.data.AttachementObjectTypeEnum;
+import fr.ifremer.tutti.persistence.entities.data.Attachment;
import fr.ifremer.tutti.persistence.entities.referential.CaracteristicQualitativeValue;
import fr.ifremer.tutti.persistence.entities.referential.Species;
import fr.ifremer.tutti.ui.swing.content.operation.AbstractTuttiBatchUIModel;
import fr.ifremer.tutti.ui.swing.content.operation.catches.EditCatchesUIModel;
import fr.ifremer.tutti.ui.swing.util.TuttiComputedOrNotData;
+import fr.ifremer.tutti.ui.swing.util.attachment.AttachmentModelAware;
+import java.util.Collection;
import java.util.List;
/**
* @author tchemit <chemit(a)codelutin.com>
* @since 0.1
*/
-public class SpeciesBatchUIModel extends AbstractTuttiBatchUIModel<SpeciesBatchRowModel, SpeciesBatchUIModel> {
+public class SpeciesBatchUIModel extends AbstractTuttiBatchUIModel<SpeciesBatchRowModel, SpeciesBatchUIModel> implements AttachmentModelAware {
private static final long serialVersionUID = 1L;
@@ -138,6 +143,8 @@
/** @since 1.0 */
protected int leafNumber;
+ protected final List<Attachment> attachment = Lists.newArrayList();
+
private boolean renameSpeciesBatchEnabled;
private String rootBatchId;
@@ -346,4 +353,44 @@
public String getRootBatchId() {
return rootBatchId;
}
+
+ @Override
+ public AttachementObjectTypeEnum getObjectType() {
+ return AttachementObjectTypeEnum.CATCH_BATCH;
+ }
+
+ @Override
+ public String getObjectId() {
+ return rootBatchId;
+ }
+
+ @Override
+ public List<Attachment> getAttachment() {
+ return attachment;
+ }
+
+ @Override
+ public void addAllAttachment(Collection<Attachment> attachments) {
+ this.attachment.addAll(attachments);
+ firePropertyChange(PROPERTY_ATTACHMENT, null, getAttachment());
+ }
+
+ @Override
+ public void addAttachment(Attachment attachment) {
+ this.attachment.add(attachment);
+ firePropertyChange(PROPERTY_ATTACHMENT, null, getAttachment());
+ }
+
+ @Override
+ public void removeAllAttachment(Collection<Attachment> attachments) {
+ this.attachment.removeAll(attachments);
+ firePropertyChange(PROPERTY_ATTACHMENT, null, getAttachment());
+ }
+
+ @Override
+ public void removeAttachment(Attachment attachment) {
+ this.attachment.remove(attachment);
+ firePropertyChange(PROPERTY_ATTACHMENT, null, getAttachment());
+ }
+
}
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SpeciesFrequencyUIHandler.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SpeciesFrequencyUIHandler.java 2013-03-04 20:23:40 UTC (rev 533)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SpeciesFrequencyUIHandler.java 2013-03-05 10:45:23 UTC (rev 534)
@@ -10,15 +10,15 @@
* %%
* 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
+ * 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
+ *
+ * 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%
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSpeciesBatchUIHandler.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSpeciesBatchUIHandler.java 2013-03-04 20:23:40 UTC (rev 533)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSpeciesBatchUIHandler.java 2013-03-05 10:45:23 UTC (rev 534)
@@ -10,15 +10,15 @@
* %%
* 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
+ * 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
+ *
+ * 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%
@@ -434,4 +434,4 @@
getModel().setRows(rows);
}
-}
\ No newline at end of file
+}
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/AbstractTuttiBeanUIModel.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/AbstractTuttiBeanUIModel.java 2013-03-04 20:23:40 UTC (rev 533)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/AbstractTuttiBeanUIModel.java 2013-03-05 10:45:23 UTC (rev 534)
@@ -24,8 +24,8 @@
* #L%
*/
+import fr.ifremer.tutti.TuttiTechnicalException;
import fr.ifremer.tutti.persistence.entities.IdAware;
-import fr.ifremer.tutti.TuttiTechnicalException;
import org.jdesktop.beans.AbstractSerializableBean;
import org.nuiton.util.beans.Binder;
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/AbstractTuttiUIHandler.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/AbstractTuttiUIHandler.java 2013-03-04 20:23:40 UTC (rev 533)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/AbstractTuttiUIHandler.java 2013-03-05 10:45:23 UTC (rev 534)
@@ -38,6 +38,7 @@
import fr.ifremer.tutti.ui.swing.content.MainUIHandler;
import fr.ifremer.tutti.ui.swing.util.action.AbstractTuttiAction;
import fr.ifremer.tutti.ui.swing.util.action.TuttiUIAction;
+import fr.ifremer.tutti.ui.swing.util.attachment.ButtonAttachmentEditor;
import fr.ifremer.tutti.ui.swing.util.editor.SimpleTimeEditor;
import jaxx.runtime.JAXXUtil;
import jaxx.runtime.SwingUtil;
@@ -309,6 +310,9 @@
} else if (component instanceof SimpleTimeEditor) {
initTimeEditor((SimpleTimeEditor) component);
+ } else if (component instanceof ButtonAttachmentEditor) {
+ initButtonAttachmentEditor((ButtonAttachmentEditor) component);
+
} else if (component instanceof JLabel) {
JLabel jLabel = (JLabel) component;
Boolean strongStyle = (Boolean) jLabel.getClientProperty("strongStyle");
@@ -346,6 +350,11 @@
}
}
+ protected void initButtonAttachmentEditor(ButtonAttachmentEditor component) {
+
+ component.init();
+ }
+
protected <A extends AbstractTuttiAction> void initAction(AbstractButton abstractButton,
Class<A> actionName) {
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/TuttiComputedOrNotData.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/TuttiComputedOrNotData.java 2013-03-04 20:23:40 UTC (rev 533)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/TuttiComputedOrNotData.java 2013-03-05 10:45:23 UTC (rev 534)
@@ -1,7 +1,7 @@
package fr.ifremer.tutti.ui.swing.util;
-import org.jdesktop.beans.AbstractBean;
+import org.jdesktop.beans.AbstractSerializableBean;
/*
* #%L
@@ -28,12 +28,14 @@
*/
/** @author kmorin <kmorin(a)codelutin.com> */
-public class TuttiComputedOrNotData<N extends Number> extends AbstractBean {
+public class TuttiComputedOrNotData<N extends Number> extends AbstractSerializableBean {
public static final String PROPERTY_DATA = "data";
public static final String PROPERTY_COMPUTED_DATA = "computedData";
+ private static final long serialVersionUID = 1L;
+
protected N data;
protected N computedData;
Added: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/attachment/AttachmentCellEditor.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/attachment/AttachmentCellEditor.java (rev 0)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/attachment/AttachmentCellEditor.java 2013-03-05 10:45:23 UTC (rev 534)
@@ -0,0 +1,201 @@
+package fr.ifremer.tutti.ui.swing.util.attachment;
+
+/*
+ * #%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 com.google.common.base.Preconditions;
+import fr.ifremer.tutti.persistence.entities.data.AttachementObjectTypeEnum;
+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.SwingUtil;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import javax.swing.AbstractCellEditor;
+import javax.swing.JTable;
+import javax.swing.border.LineBorder;
+import javax.swing.table.TableCellEditor;
+import java.awt.Color;
+import java.awt.Component;
+import java.awt.Frame;
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+
+import static org.nuiton.i18n.I18n._;
+
+/**
+ * To edit attachments from a table cell.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @author kmorin <morin(a)codelutin.com>
+ * @since 1.0.2
+ */
+public class AttachmentCellEditor extends AbstractCellEditor implements TableCellEditor {
+
+ private static final long serialVersionUID = 1L;
+
+ /** Logger. */
+ private static final Log log = LogFactory.getLog(AttachmentCellEditor.class);
+
+ public static TableCellEditor newEditor(TuttiUI ui,
+ AttachmentCellRenderer renderer,
+ AttachementObjectTypeEnum objectType) {
+
+ Frame frame = SwingUtil.getParentContainer(ui, Frame.class);
+
+ renderer.setBorder(new LineBorder(Color.BLACK));
+
+ return new AttachmentCellEditor(frame, renderer, objectType);
+ }
+
+ protected final AttachmentCellRenderer component;
+
+ protected AttachmentEditor attachmentEditor;
+
+ protected JTable table;
+
+ protected AbstractTuttiTableModel<AbstractTuttiBeanUIModel> tableModel;
+
+ protected ColumnIdentifier<AbstractTuttiBeanUIModel> columnIdentifier;
+
+ protected AttachmentModelAware editRow;
+
+ protected Integer rowIndex;
+
+ protected Integer columnIndex;
+
+ protected PropertyChangeListener reloadAttachmentEditorTextListener;
+
+ public AttachmentCellEditor(Frame frame,
+ AttachmentCellRenderer component,
+ AttachementObjectTypeEnum objectTypeProperty) {
+
+ this.component = component;
+
+ reloadAttachmentEditorTextListener = new PropertyChangeListener() {
+ @Override
+ public void propertyChange(PropertyChangeEvent evt) {
+
+ tableModel.fireTableCellUpdated(rowIndex, columnIndex);
+// List<Attachment> attachment = (List<Attachment>) evt.getNewValue();
+// AttachmentCellEditor.this.component.setText(ButtonAttachmentEditor.getButtonText(attachment));
+ }
+ };
+
+ this.attachmentEditor = new AttachmentEditor(frame,
+ component,
+ objectTypeProperty,
+ _("tutti.table.accidental.batch.header.file")) {
+
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ protected AttachmentModelAware getBean() {
+ return editRow;
+ }
+
+ @Override
+ public void startEdit() {
+
+ ((AbstractTuttiBeanUIModel) getBean()).addPropertyChangeListener(AttachmentModelAware.PROPERTY_ATTACHMENT, reloadAttachmentEditorTextListener);
+
+ try {
+ super.startEdit();
+ int r = rowIndex;
+ int c = columnIndex;
+
+ // stop edition
+ stopCellEditing();
+
+ // refresh cell
+ tableModel.fireTableCellUpdated(r, c);
+
+ // reselect this cell
+ AbstractSelectTableAction.doSelectCell(table, r, c);
+
+ // focus on table
+ table.requestFocus();
+ } finally {
+
+ ((AbstractTuttiBeanUIModel) getBean()).removePropertyChangeListener(AttachmentModelAware.PROPERTY_ATTACHMENT, reloadAttachmentEditorTextListener);
+ }
+ }
+ };
+ }
+
+ @Override
+ public Component getTableCellEditorComponent(JTable table,
+ Object value,
+ boolean isSelected,
+ int row,
+ int column) {
+ this.table = table;
+ this.tableModel = (AbstractTuttiTableModel<AbstractTuttiBeanUIModel>) table.getModel();
+ columnIdentifier = tableModel.getPropertyName(column);
+
+ rowIndex = row;
+ columnIndex = column;
+
+ editRow = (AttachmentModelAware) tableModel.getEntry(row);
+
+ return component;
+ }
+
+ @Override
+ public Object getCellEditorValue() {
+
+ Preconditions.checkNotNull(editRow, "No editRow found in editor.");
+
+ String propertyName = columnIdentifier.getPropertyName();
+ Object result = TuttiUIUtil.getProperty(editRow, propertyName);
+ if (log.isInfoEnabled()) {
+ log.info("editor value (" + propertyName + "): " + result);
+ }
+
+ return result;
+ }
+
+ @Override
+ public boolean stopCellEditing() {
+ boolean b = super.stopCellEditing();
+ if (b) {
+ rowIndex = null;
+ editRow = null;
+ columnIndex = null;
+ }
+ return b;
+ }
+
+ @Override
+ public void cancelCellEditing() {
+ super.cancelCellEditing();
+ rowIndex = null;
+ columnIndex = null;
+ editRow = null;
+ }
+}
Property changes on: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/attachment/AttachmentCellEditor.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/attachment/AttachmentCellRenderer.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/attachment/AttachmentCellRenderer.java (rev 0)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/attachment/AttachmentCellRenderer.java 2013-03-05 10:45:23 UTC (rev 534)
@@ -0,0 +1,115 @@
+package fr.ifremer.tutti.ui.swing.util.attachment;
+
+/*
+ * #%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.Attachment;
+import jaxx.runtime.SwingUtil;
+import org.apache.commons.collections.CollectionUtils;
+import org.nuiton.util.decorator.Decorator;
+
+import javax.swing.JTable;
+import javax.swing.table.DefaultTableCellRenderer;
+import java.awt.Component;
+import java.util.Collection;
+
+import static org.nuiton.i18n.I18n._;
+
+/**
+ * Renderer of a attachement editor in a table cell.
+ *
+ * @author kmorin <morin(a)codelutin.com>
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 1.0.2
+ */
+public class AttachmentCellRenderer extends DefaultTableCellRenderer {
+
+
+ public static final String TEXT_PATTERN = "<html><body>%s</body></html>";
+
+ private static final long serialVersionUID = 1L;
+
+ private final String noneText;
+
+ private final Decorator<Attachment> decorator;
+
+ public static AttachmentCellRenderer newRender(Decorator<Attachment> decorator,
+ String noneText) {
+ return new AttachmentCellRenderer(decorator, noneText);
+ }
+
+ protected AttachmentCellRenderer(Decorator<Attachment> decorator,
+ String noneText) {
+ setHorizontalAlignment(CENTER);
+ setIcon(SwingUtil.createActionIcon("edit-attachment"));
+ this.noneText = noneText;
+ this.decorator = decorator;
+ }
+
+ @Override
+ protected void setValue(Object value) {
+ // do nothing
+ }
+
+ @Override
+ public Component getTableCellRendererComponent(JTable table,
+ Object value,
+ boolean isSelected,
+ boolean hasFocus,
+ int row,
+ int column) {
+
+// if (table != null) {
+
+ Collection<Attachment> attachments = (Collection<Attachment>) value;
+
+ String textValue;
+ String toolTipTextValue;
+
+ if (CollectionUtils.isEmpty(attachments)) {
+
+ // use HTML to show the tooltip in italic
+ toolTipTextValue = "<i>" + _(noneText) + "</i>";
+
+ textValue = null;
+ } else {
+
+ StringBuilder sb = new StringBuilder();
+ for (Attachment attachment : attachments) {
+ sb.append("<br/>").append(decorator.toString(attachment));
+ }
+ // use html to display the tooltip on several lines
+ toolTipTextValue = sb.substring(5);
+ textValue = "(" + attachments.size() + ")";
+ }
+ boolean editable = table.isCellEditable(row, column);
+ toolTipTextValue = String.format(TEXT_PATTERN, toolTipTextValue);
+ setEnabled(editable);
+ setText(textValue);
+ setToolTipText(toolTipTextValue);
+// }
+
+ return this;
+ }
+}
Property changes on: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/attachment/AttachmentCellRenderer.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Copied: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/attachment/AttachmentEditor.java (from rev 531, 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/attachment/AttachmentEditor.java (rev 0)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/attachment/AttachmentEditor.java 2013-03-05 10:45:23 UTC (rev 534)
@@ -0,0 +1,155 @@
+package fr.ifremer.tutti.ui.swing.util.attachment;
+
+/*
+ * #%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 com.ezware.oxbow.swingbits.util.Preconditions;
+import fr.ifremer.tutti.persistence.entities.data.AttachementObjectTypeEnum;
+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(a)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 title) {
+ super(owner, true);
+
+ Preconditions.checkNotNull(
+ component,
+ "AttachmentEditor.component can not be null");
+ this.component = component;
+ this.editor = new AttachmentEditorUI();
+ editor.setBorder(BorderFactory.createTitledBorder(title));
+ editor.setObjectType(objectType);
+ editor.setObjectIdProperty(AttachmentModelAware.PROPERTY_OBJECT_ID);
+
+ setUndecorated(true);
+ add(editor);
+ setResizable(true);
+ pack();
+
+ 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();
+ if (((JComponent) e.getSource()).isEnabled()) {
+ startEdit();
+ }
+ }
+ }
+ });
+
+ component.addMouseListener(new MouseAdapter() {
+ @Override
+ public void mouseClicked(MouseEvent e) {
+ e.consume();
+ if (((JComponent) e.getSource()).isEnabled()) {
+ startEdit();
+ }
+ }
+ });
+ }
+
+ protected abstract AttachmentModelAware getBean();
+
+ public void startEdit() {
+
+ editor.setBean(getBean());
+
+ // 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();
+ }
+
+ pack();
+ // 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);
+ }
+
+ protected JComponent getComponent() {
+ return component;
+ }
+}
Copied: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/attachment/AttachmentEditorUI.css (from rev 529, trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/editor/AttachmentEditorUI.css)
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/attachment/AttachmentEditorUI.css (rev 0)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/attachment/AttachmentEditorUI.css 2013-03-05 10:45:23 UTC (rev 534)
@@ -0,0 +1,47 @@
+/*
+ * #%L
+ * Tutti :: UI
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2012 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%
+ */
+#fileLabel {
+ text: "tutti.label.attachmentEditor.file";
+ labelFor: {file};
+}
+
+#fileNameLabel {
+ text: "tutti.label.attachmentEditor.fileName";
+ labelFor: {fileName};
+}
+
+#fileCommentLabel {
+ text: "tutti.label.attachmentEditor.fileComment";
+ labelFor: {fileComment};
+}
+
+#addButton {
+ actionIcon: add;
+}
+
+#closeButton {
+ actionIcon: close;
+ text: "tutti.action.close";
+ mnemonic: F;
+}
Copied: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/attachment/AttachmentEditorUI.jaxx (from rev 530, 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/attachment/AttachmentEditorUI.jaxx (rev 0)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/attachment/AttachmentEditorUI.jaxx 2013-03-05 10:45:23 UTC (rev 534)
@@ -0,0 +1,92 @@
+<!--
+ #%L
+ Tutti :: UI
+ $Id$
+ $HeadURL$
+ %%
+ Copyright (C) 2012 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%
+ -->
+<Table id='mainPanel'>
+
+ <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='""'/>
+
+ <!-- if true, display the form to add attachments
+ and the button to remove existing attachments -->
+ <Boolean id='editable' javaBean='true'/>
+
+ <!-- bean property -->
+ <AttachmentModelAware id='bean' javaBean='null'/>
+
+ <AttachmentEditorUIHandler id='handler' constructorParams='this'/>
+
+ <row fill='both'>
+ <cell fill='both' weightx='1' columns='3'>
+ <VBox id='attachments'></VBox>
+ </cell>
+ </row>
+ <row fill='both'>
+ <cell fill='both' weightx='1'>
+ <JLabel id='fileLabel'/>
+ </cell>
+ <cell fill='both' weightx='1'>
+ <FileEditor id='file'/>
+ </cell>
+ <cell fill='both' rows='3'>
+ <JButton id='addButton'
+ onActionPerformed='handler.addAttachment()'/>
+ </cell>
+ </row>
+ <row fill='both'>
+ <cell fill='both' weightx='1'>
+ <JLabel id='fileNameLabel'/>
+ </cell>
+ <cell fill='both' weightx='1'>
+ <JTextField id='fileName'/>
+ </cell>
+ </row>
+ <row fill='both' weighty='1'>
+ <cell fill='both' weightx='1'>
+ <JLabel id='fileCommentLabel'/>
+ </cell>
+ <cell fill='both' weightx='1'>
+ <JScrollPane>
+ <JTextArea id='fileComment' rows='3'/>
+ </JScrollPane>
+ </cell>
+ </row>
+ <row fill='both'>
+ <!-- actions -->
+ <cell fill='both' weightx='1' columns='3'>
+ <JButton id='closeButton' onActionPerformed='handler.close()'/>
+ </cell>
+ </row>
+</Table>
\ No newline at end of file
Copied: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/attachment/AttachmentEditorUIHandler.java (from rev 531, 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/attachment/AttachmentEditorUIHandler.java (rev 0)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/attachment/AttachmentEditorUIHandler.java 2013-03-05 10:45:23 UTC (rev 534)
@@ -0,0 +1,186 @@
+package fr.ifremer.tutti.ui.swing.util.attachment;
+
+/*
+ * #%L
+ * Tutti :: UI
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2012 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.Attachment;
+import fr.ifremer.tutti.service.PersistenceService;
+import fr.ifremer.tutti.ui.swing.TuttiUIContext;
+import fr.ifremer.tutti.ui.swing.util.TuttiUIUtil;
+import jaxx.runtime.SwingUtil;
+import jaxx.runtime.swing.HBox;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import javax.swing.JButton;
+import javax.swing.JDialog;
+import javax.swing.JLabel;
+import javax.swing.SwingConstants;
+import java.awt.Cursor;
+import java.awt.Window;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.awt.event.MouseAdapter;
+import java.awt.event.MouseEvent;
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+import java.io.File;
+import java.util.List;
+
+/**
+ * @author kmorin <morin(a)codelutin.com>
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 0.2
+ */
+public class AttachmentEditorUIHandler {
+
+ /** Logger. */
+ private static final Log log =
+ LogFactory.getLog(AttachmentEditorUIHandler.class);
+
+ private final AttachmentEditorUI ui;
+
+ private final PersistenceService persistenceService;
+
+ public AttachmentEditorUIHandler(AttachmentEditorUI ui) {
+ this.ui = ui;
+ persistenceService =
+ TuttiUIContext.getApplicationContext().getPersistenceService();
+
+
+ this.ui.addPropertyChangeListener(new PropertyChangeListener() {
+
+ @Override
+ public void propertyChange(PropertyChangeEvent evt) {
+ init();
+ }
+ });
+ }
+
+ public void init() {
+ resetFields();
+ ui.getAttachments().removeAll();
+ AttachmentModelAware bean = ui.getBean();
+ if (bean != null) {
+ List<Attachment> list = bean.getAttachment();
+ if (list != null) {
+ for (Attachment attachment : list) {
+ addAttachment(attachment);
+ }
+ }
+ }
+ }
+
+ protected void addAttachment(final Attachment attachment) {
+ final HBox hbox = new HBox();
+ hbox.setVerticalAlignment(SwingConstants.CENTER);
+
+ JButton deleteButton = new JButton(SwingUtil.createActionIcon("delete"));
+ deleteButton.addActionListener(new ActionListener() {
+
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ AttachmentModelAware bean = ui.getBean();
+
+ persistenceService.deleteAttachment(attachment.getId());
+
+ bean.removeAttachment(attachment);
+
+ ui.getAttachments().remove(hbox);
+
+ JDialog parent = SwingUtil.getParentContainer(ui, JDialog.class);
+ parent.pack();
+ }
+ });
+ hbox.add(deleteButton);
+
+ final JLabel label = new JLabel("<html><body><a href=''>"
+ + attachment.getName() + "</a></body></html>");
+ label.setToolTipText(attachment.getComment());
+ label.addMouseListener(new MouseAdapter() {
+
+ @Override
+ public void mouseClicked(MouseEvent e) {
+ File file = persistenceService.getAttachmentFile(attachment.getId());
+ SwingUtil.openLink("file://" + file.getAbsolutePath());
+ }
+
+ @Override
+ public void mouseEntered(MouseEvent e) {
+ label.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
+ }
+
+ @Override
+ public void mouseExited(MouseEvent e) {
+ label.setCursor(Cursor.getDefaultCursor());
+ }
+
+ });
+ hbox.add(label);
+
+ ui.getAttachments().add(hbox);
+ }
+
+ /** closes the editor */
+ public void close() {
+ if (log.isInfoEnabled()) {
+ log.info("Will close UI " + ui);
+ }
+ SwingUtil.getParentContainer(ui, Window.class).dispose();
+ }
+
+ public void addAttachment() {
+ AttachmentModelAware bean = ui.getBean();
+ Attachment attachment = new Attachment();
+
+ File file = ui.getFile().getSelectedFile();
+ if (file != null) {
+ 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);
+ bean.addAttachment(attachment);
+
+ resetFields();
+ addAttachment(attachment);
+
+ JDialog parent = SwingUtil.getParentContainer(ui, JDialog.class);
+ parent.pack();
+ }
+ }
+
+ protected void resetFields() {
+ ui.getFile().setSelectedFile((File) null);
+ ui.getFileName().setText("");
+ ui.getFileComment().setText("");
+ }
+
+}
Added: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/attachment/AttachmentModelAware.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/attachment/AttachmentModelAware.java (rev 0)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/attachment/AttachmentModelAware.java 2013-03-05 10:45:23 UTC (rev 534)
@@ -0,0 +1,60 @@
+package fr.ifremer.tutti.ui.swing.util.attachment;
+
+/*
+ * #%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.persistence.entities.data.Attachment;
+
+import java.io.Serializable;
+import java.util.Collection;
+import java.util.List;
+
+/**
+ * To place on model wich supports attachments.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 1.0.2
+ */
+public interface AttachmentModelAware extends Serializable {
+
+ String PROPERTY_ATTACHMENT = "attachment";
+
+ String PROPERTY_OBJECT_ID = "objectId";
+
+ AttachementObjectTypeEnum getObjectType();
+
+ String getObjectId();
+
+ List<Attachment> getAttachment();
+
+ void addAllAttachment(Collection<Attachment> attachments);
+
+ void addAttachment(Attachment attachment);
+
+ void removeAllAttachment(Collection<Attachment> attachments);
+
+ void removeAttachment(Attachment attachment);
+
+}
Property changes on: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/attachment/AttachmentModelAware.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Added: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/attachment/ButtonAttachmentEditor.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/attachment/ButtonAttachmentEditor.java (rev 0)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/attachment/ButtonAttachmentEditor.java 2013-03-05 10:45:23 UTC (rev 534)
@@ -0,0 +1,103 @@
+package fr.ifremer.tutti.ui.swing.util.attachment;
+
+/*
+ * #%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.Attachment;
+import fr.ifremer.tutti.ui.swing.util.TuttiUI;
+import jaxx.runtime.SwingUtil;
+import org.jdesktop.beans.AbstractSerializableBean;
+
+import javax.swing.JButton;
+import java.awt.Frame;
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+import java.util.Collections;
+import java.util.List;
+
+import static org.nuiton.i18n.I18n._;
+
+/**
+ * To show attachment editor on a button.
+ *
+ * @author tchemit <chemit(a)codelutin.com>
+ * @since 1.0.2
+ */
+public class ButtonAttachmentEditor extends AttachmentEditor {
+
+ private static final long serialVersionUID = 1L;
+
+ public static String getButtonText(List<Attachment> attachment) {
+ return _("tutti.action.attachments", attachment.size());
+ }
+
+ public static ButtonAttachmentEditor newEditor(TuttiUI ui,
+ JButton button) {
+
+ Frame frame = SwingUtil.getParentContainer(ui, Frame.class);
+
+ return new ButtonAttachmentEditor(frame,
+ button,
+ (AttachmentModelAware) ui.getModel()
+ );
+ }
+
+ protected final AttachmentModelAware model;
+
+ protected ButtonAttachmentEditor(Frame owner,
+ JButton component,
+ AttachmentModelAware model) {
+ super(owner,
+ component,
+ model.getObjectType(),
+ null);
+ this.model = model;
+ }
+
+ @Override
+ protected AttachmentModelAware getBean() {
+ return model;
+ }
+
+ protected JButton getComponent() {
+ return (JButton) component;
+ }
+
+ public void init() {
+
+ JButton button = getComponent();
+ button.setIcon(SwingUtil.createActionIcon("edit-attachment"));
+ button.setToolTipText(_("tutti.action.attachments.tip"));
+ ((AbstractSerializableBean) model).addPropertyChangeListener(AttachmentModelAware.PROPERTY_ATTACHMENT, new PropertyChangeListener() {
+ @Override
+ public void propertyChange(PropertyChangeEvent evt) {
+ List<Attachment> attachment = (List<Attachment>) evt.getNewValue();
+ getComponent().setText(ButtonAttachmentEditor.getButtonText(attachment));
+ }
+ });
+ AttachmentModelAware bean = getBean();
+ List<Attachment> attachment = bean == null ? Collections.<Attachment>emptyList() : bean.getAttachment();
+ button.setText(ButtonAttachmentEditor.getButtonText(attachment));
+ }
+}
Property changes on: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/attachment/ButtonAttachmentEditor.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: svn:eol-style
+ native
Deleted: 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 20:23:40 UTC (rev 533)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/editor/AttachmentCellComponent.java 2013-03-05 10:45:23 UTC (rev 534)
@@ -1,368 +0,0 @@
-package fr.ifremer.tutti.ui.swing.util.editor;
-
-/*
- * #%L
- * Tutti :: UI
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2012 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 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.SwingUtil;
-import org.apache.commons.collections.CollectionUtils;
-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.JTable;
-import javax.swing.border.LineBorder;
-import javax.swing.table.DefaultTableCellRenderer;
-import javax.swing.table.TableCellEditor;
-import javax.swing.table.TableCellRenderer;
-import java.awt.Color;
-import java.awt.Component;
-import java.awt.Frame;
-import java.util.Collection;
-
-import static org.nuiton.i18n.I18n._;
-
-/**
- * Component to edit a cell containing attachments.
- *
- * @author kmorin
- * @since 0.2
- */
-public class AttachmentCellComponent extends DefaultTableCellRenderer {
-
- /** Logger. */
- private static final Log log = LogFactory.getLog(AttachmentCellComponent.class);
-
- private static final long serialVersionUID = 1L;
-
- public AttachmentCellComponent() {
- setHorizontalAlignment(CENTER);
- setIcon(SwingUtil.createActionIcon("edit-attachment"));
- }
-
- @Override
- protected void setValue(Object value) {
- // do nothing
- }
-
- public static TableCellRenderer newRender(Decorator<Attachment> decorator, String noneText) {
- return new AttachmentCellRenderer(decorator, noneText);
- }
-
- //FIXME remove this
- public static TableCellEditor newEditor(AttachmentEditorUI 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 AttachmentEditor attachmentEditor;
-
- protected Frame frame;
-
- protected JTable table;
-
- protected AbstractTuttiTableModel<AbstractTuttiBeanUIModel> tableModel;
-
- protected ColumnIdentifier<AbstractTuttiBeanUIModel> columnIdentifier;
-
- protected AbstractTuttiBeanUIModel editRow;
-
- protected Integer rowIndex;
-
- protected Integer columnIndex;
-
- public AttachmentCellEditor(Frame frame,
- AttachmentCellComponent component,
- AttachementObjectTypeEnum objectTypeProperty,
- String objectIdProperty,
- String title) {
-
- this.component = component;
- this.attachmentEditor = new AttachmentEditor(frame,
- component,
- objectTypeProperty,
- objectIdProperty,
- title) {
-
- private static final long serialVersionUID = 1L;
-
- @Override
- protected AbstractTuttiBeanUIModel getBean() {
- return editRow;
- }
-
- @Override
- protected String getProperty() {
- return columnIdentifier.getPropertyName();
- }
-
- @Override
- public void startEdit() {
- super.startEdit();
- int r = rowIndex;
- int c = columnIndex;
-
- // stop edition
- stopCellEditing();
-
- // refresh cell
- tableModel.fireTableCellUpdated(r, c);
-
- // reselect this cell
- AbstractSelectTableAction.doSelectCell(table, r, c);
-
- // focus on table
- table.requestFocus();
- }
- };
- }
-
-// 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();
-// }
-
- @Override
- public Component getTableCellEditorComponent(JTable table,
- Object value,
- boolean isSelected,
- int row,
- int column) {
- this.table = table;
- this.tableModel = (AbstractTuttiTableModel<AbstractTuttiBeanUIModel>) table.getModel();
- columnIdentifier = tableModel.getPropertyName(column);
-
- rowIndex = row;
- columnIndex = column;
-
- editRow = tableModel.getEntry(row);
-
- return component;
- }
-
- @Override
- public Object getCellEditorValue() {
-
- Preconditions.checkNotNull(editRow, "No editRow found in editor.");
-
- String propertyName = columnIdentifier.getPropertyName();
- Object result = TuttiUIUtil.getProperty(editRow, propertyName);
- if (log.isInfoEnabled()) {
- log.info("editor value (" + propertyName + "): " + result);
- }
-
- return result;
- }
-
- @Override
- public boolean stopCellEditing() {
- boolean b = super.stopCellEditing();
- if (b) {
- rowIndex = null;
- editRow = null;
- columnIndex = null;
- }
- return b;
- }
-
- @Override
- public void cancelCellEditing() {
- super.cancelCellEditing();
- rowIndex = null;
- columnIndex = null;
- editRow = null;
- }
- }
-
- public static class AttachmentCellRenderer implements TableCellRenderer {
-
- protected final AttachmentCellComponent component;
-
- public static final String TEXT_PATTERN = "<html><body>%s</body></html>";
-
- private final String noneText;
-
- private final Decorator<Attachment> decorator;
-
- public AttachmentCellRenderer(Decorator<Attachment> decorator,
- String noneText) {
- component = new AttachmentCellComponent();
- this.noneText = noneText;
- this.decorator = decorator;
- }
-
- @Override
- public Component getTableCellRendererComponent(JTable table,
- Object value,
- boolean isSelected,
- boolean hasFocus,
- int row,
- int column) {
- AttachmentCellComponent result =
- (AttachmentCellComponent) component.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
-
- if (table != null) {
-
- Collection<Attachment> attachments = (Collection<Attachment>) value;
-
- String textValue;
-
- if (CollectionUtils.isEmpty(attachments)) {
-
- // use HTML to show the tooltip in italic
- textValue = "<i>" + _(noneText) + "</i>";
-
- } else {
-
- StringBuilder sb = new StringBuilder();
- for (Attachment attachment : attachments) {
- sb.append("<br/>").append(decorator.toString(attachment));
- }
- // use html to display the tooltip on several lines
- textValue = sb.substring(5);
- }
- String text = String.format(TEXT_PATTERN, textValue);
- boolean editable = table.isCellEditable(row, column);
- result.setEnabled(editable);
- result.setToolTipText(text);
- }
-
- return result;
- }
- }
-}
Deleted: 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 2013-03-04 20:23:40 UTC (rev 533)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/editor/AttachmentEditor.java 2013-03-05 10:45:23 UTC (rev 534)
@@ -1,147 +0,0 @@
-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(a)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);
- pack();
-
- 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);
- }
-
-}
Deleted: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/editor/AttachmentEditorUI.css
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/editor/AttachmentEditorUI.css 2013-03-04 20:23:40 UTC (rev 533)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/editor/AttachmentEditorUI.css 2013-03-05 10:45:23 UTC (rev 534)
@@ -1,47 +0,0 @@
-/*
- * #%L
- * Tutti :: UI
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2012 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%
- */
-#fileLabel {
- text: "tutti.label.attachmentEditor.file";
- labelFor: {file};
-}
-
-#fileNameLabel {
- text: "tutti.label.attachmentEditor.fileName";
- labelFor: {fileName};
-}
-
-#fileCommentLabel {
- text: "tutti.label.attachmentEditor.fileComment";
- labelFor: {fileComment};
-}
-
-#addButton {
- actionIcon: add;
-}
-
-#closeButton {
- actionIcon: close;
- text: "tutti.action.close";
- mnemonic: F;
-}
Deleted: 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 20:23:40 UTC (rev 533)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/editor/AttachmentEditorUI.jaxx 2013-03-05 10:45:23 UTC (rev 534)
@@ -1,92 +0,0 @@
-<!--
- #%L
- Tutti :: UI
- $Id$
- $HeadURL$
- %%
- Copyright (C) 2012 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%
- -->
-<Table id='mainPanel'>
-
- <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='""'/>
-
- <!-- if true, display the form to add attachments
- and the button to remove existing attachments -->
- <Boolean id='editable' javaBean='true'/>
-
- <!-- bean property -->
- <AbstractTuttiBeanUIModel id='bean' javaBean='null'/>
-
- <AttachmentEditorUIHandler id='handler' constructorParams='this'/>
-
- <row fill='both'>
- <cell fill='both' weightx='1' columns='3'>
- <VBox id='attachments'></VBox>
- </cell>
- </row>
- <row fill='both'>
- <cell fill='both' weightx='1'>
- <JLabel id='fileLabel'/>
- </cell>
- <cell fill='both' weightx='1'>
- <FileEditor id='file'/>
- </cell>
- <cell fill='both' rows='3'>
- <JButton id='addButton'
- onActionPerformed='handler.addAttachment()'/>
- </cell>
- </row>
- <row fill='both'>
- <cell fill='both' weightx='1'>
- <JLabel id='fileNameLabel'/>
- </cell>
- <cell fill='both' weightx='1'>
- <JTextField id='fileName'/>
- </cell>
- </row>
- <row fill='both' weighty='1'>
- <cell fill='both' weightx='1'>
- <JLabel id='fileCommentLabel'/>
- </cell>
- <cell fill='both' weightx='1'>
- <JScrollPane>
- <JTextArea id='fileComment' rows='3'/>
- </JScrollPane>
- </cell>
- </row>
- <row fill='both'>
- <!-- actions -->
- <cell fill='both' weightx='1' columns='3'>
- <JButton id='closeButton' onActionPerformed='handler.close()'/>
- </cell>
- </row>
-</Table>
\ No newline at end of file
Deleted: 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 20:23:40 UTC (rev 533)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/editor/AttachmentEditorUIHandler.java 2013-03-05 10:45:23 UTC (rev 534)
@@ -1,197 +0,0 @@
-package fr.ifremer.tutti.ui.swing.util.editor;
-
-/*
- * #%L
- * Tutti :: UI
- * $Id$
- * $HeadURL$
- * %%
- * Copyright (C) 2012 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 com.ezware.oxbow.swingbits.util.Preconditions;
-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;
-import jaxx.runtime.swing.HBox;
-import org.apache.commons.lang3.StringUtils;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-
-import javax.swing.JButton;
-import javax.swing.JDialog;
-import javax.swing.JLabel;
-import javax.swing.SwingConstants;
-import java.awt.Cursor;
-import java.awt.Window;
-import java.awt.event.ActionEvent;
-import java.awt.event.ActionListener;
-import java.awt.event.MouseAdapter;
-import java.awt.event.MouseEvent;
-import java.beans.PropertyChangeEvent;
-import java.beans.PropertyChangeListener;
-import java.io.File;
-import java.util.List;
-
-/**
- * @author kmorin <morin(a)codelutin.com>
- * @author tchemit <chemit(a)codelutin.com>
- * @since 0.2
- */
-public class AttachmentEditorUIHandler {
-
- /** Logger. */
- private static final Log log =
- LogFactory.getLog(AttachmentEditorUIHandler.class);
-
- private final AttachmentEditorUI ui;
-
- private final PersistenceService persistenceService;
-
- public AttachmentEditorUIHandler(AttachmentEditorUI ui) {
- this.ui = ui;
- persistenceService =
- TuttiUIContext.getApplicationContext().getPersistenceService();
-
-
- this.ui.addPropertyChangeListener(new PropertyChangeListener() {
-
- @Override
- public void propertyChange(PropertyChangeEvent evt) {
- init();
- }
- });
- }
-
- public void init() {
- resetFields();
- ui.getAttachments().removeAll();
- AbstractTuttiBeanUIModel bean = ui.getBean();
- String property = ui.getProperty();
- if (bean != null && !StringUtils.isEmpty(property)) {
- List<Attachment> list = (List<Attachment>) TuttiUIUtil.getProperty(bean, property);
- if (list != null) {
- for (Attachment attachment : list) {
- addAttachment(attachment);
- }
- }
- }
- }
-
- protected void addAttachment(final Attachment attachment) {
- final HBox hbox = new HBox();
- hbox.setVerticalAlignment(SwingConstants.CENTER);
-
- JButton deleteButton = new JButton(SwingUtil.createActionIcon("delete"));
- deleteButton.addActionListener(new ActionListener() {
-
- @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);
- Preconditions.checkNotNull(list);
-
- list.remove(attachment);
-
- ui.getAttachments().remove(hbox);
-
- JDialog parent = SwingUtil.getParentContainer(ui, JDialog.class);
- parent.pack();
- }
- });
- hbox.add(deleteButton);
-
- final JLabel label = new JLabel("<html><body><a href=''>"
- + attachment.getName() + "</a></body></html>");
- label.setToolTipText(attachment.getComment());
- label.addMouseListener(new MouseAdapter() {
-
- @Override
- public void mouseClicked(MouseEvent e) {
- File file = persistenceService.getAttachmentFile(attachment.getId());
- SwingUtil.openLink("file://" + file.getAbsolutePath());
- }
-
- @Override
- public void mouseEntered(MouseEvent e) {
- label.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
- }
-
- @Override
- public void mouseExited(MouseEvent e) {
- label.setCursor(Cursor.getDefaultCursor());
- }
-
- });
- hbox.add(label);
-
- ui.getAttachments().add(hbox);
- }
-
- /** closes the editor */
- public void close() {
- if (log.isInfoEnabled()) {
- log.info("Will close UI " + ui);
- }
- SwingUtil.getParentContainer(ui, Window.class).dispose();
- }
-
- public void addAttachment() {
- AbstractTuttiBeanUIModel bean = ui.getBean();
- String property = ui.getProperty();
- List<Attachment> list = (List<Attachment>) TuttiUIUtil.getProperty(bean, property);
- Preconditions.checkNotNull(list, "Attachments list can not be null");
- Attachment attachment = new Attachment();
-
- File file = ui.getFile().getSelectedFile();
- if (file != null) {
- 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);
-
- resetFields();
- addAttachment(attachment);
-
- JDialog parent = SwingUtil.getParentContainer(ui, JDialog.class);
- parent.pack();
- }
- }
-
- protected void resetFields() {
- ui.getFile().setSelectedFile((File) null);
- ui.getFileName().setText("");
- ui.getFileComment().setText("");
- }
-
-}
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/table/AbstractTuttiTableModel.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/table/AbstractTuttiTableModel.java 2013-03-04 20:23:40 UTC (rev 533)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/table/AbstractTuttiTableModel.java 2013-03-05 10:45:23 UTC (rev 534)
@@ -10,15 +10,15 @@
* %%
* 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
+ * 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
+ *
+ * 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%
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/table/AbstractTuttiTableUIHandler.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/table/AbstractTuttiTableUIHandler.java 2013-03-04 20:23:40 UTC (rev 533)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/table/AbstractTuttiTableUIHandler.java 2013-03-05 10:45:23 UTC (rev 534)
@@ -315,7 +315,7 @@
// paint in a special color for attachment cell (when some attachments)
Highlighter attachmentHighlighter = TuttiUIUtil.newBackgroundColorHighlighter(
new HighlightPredicate.AndHighlightPredicate(
- new MyIdentifierHighlightPredicate(SpeciesBatchTableModel.ATTACHMENTS),
+ new MyIdentifierHighlightPredicate(SpeciesBatchTableModel.ATTACHMENT),
// for not null value
new HighlightPredicate() {
@Override
1
0
See <http://ci.nuiton.org/jenkins/job/tutti/435/changes>
Changes:
[Tony Chemit] refs #1963: [CAPTURE] - Global - Ajouter pièce jointe sur tous les onglets (obtenir depuis le service le sur lot)
------------------------------------------
Started by an SCM change
Building on master in workspace <http://ci.nuiton.org/jenkins/job/tutti/ws/>
Updating http://svn.forge.codelutin.com/svn/tutti/trunk to revision '2013-03-04T16:32:03.926 +0100'
U tutti-service/src/main/java/fr/ifremer/tutti/service/PersistenceService.java
U tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUIHandler.java
U tutti-persistence/src/test/java/fr/ifremer/tutti/persistence/service/AttachmentPersistenceServiceWriteTest.java
U tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/TuttiPersistenceImpl.java
U tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/batch/ScientificCruiseCatchBatchValidator.java
U tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/BatchPersistenceService.java
U tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/BatchPersistenceServiceImpl.java
U tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/TuttiPersistenceNoDbImpl.java
AU tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/entities/data/BatchContainer.java
U tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/TuttiPersistence.java
At revision 526
Parsing POMs
[trunk] $ /opt/jdk/bin/java -Xmx256m -XX:-UseGCOverheadLimit -cp /var/local/jenkins/data/plugins/maven-plugin/WEB-INF/lib/maven3-agent-1.2.jar:/opt/maven3/boot/plexus-classworlds-2.4.jar org.jvnet.hudson.maven3.agent.Maven3Main /opt/maven3 /opt/repo/apache-tomcat-7.0.34/webapps/jenkins/WEB-INF/lib/remoting-2.20.jar /var/local/jenkins/data/plugins/maven-plugin/WEB-INF/lib/maven3-interceptor-1.2.jar 58890
<===[JENKINS REMOTING CAPACITY]===> channel started
log4j:WARN No appenders could be found for logger (org.apache.commons.beanutils.converters.BooleanConverter).
log4j:WARN Please initialize the log4j system properly.
Executing Maven: -B -f <http://ci.nuiton.org/jenkins/job/tutti/ws/trunk/pom.xml> -U -e clean install
[INFO] Error stacktraces are turned on.
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Build Order:
[INFO]
[INFO] Tutti
[INFO] Tutti :: Persistence
[INFO] Tutti :: Service
[INFO] Tutti :: UI
Projects to build: [MavenProject: fr.ifremer:tutti:1.0.2-SNAPSHOT @ <http://ci.nuiton.org/jenkins/job/tutti/ws/trunk/pom.xml,> MavenProject: fr.ifremer.tutti:tutti-persistence:1.0.2-SNAPSHOT @ <http://ci.nuiton.org/jenkins/job/tutti/ws/trunk/tutti-persistence/pom.xml,> MavenProject: fr.ifremer.tutti:tutti-service:1.0.2-SNAPSHOT @ <http://ci.nuiton.org/jenkins/job/tutti/ws/trunk/tutti-service/pom.xml,> MavenProject: fr.ifremer.tutti:tutti-ui-swing:1.0.2-SNAPSHOT @ <http://ci.nuiton.org/jenkins/job/tutti/ws/trunk/tutti-ui-swing/pom.xml]>
projectStarted fr.ifremer:tutti:1.0.2-SNAPSHOT
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building Tutti 1.0.2-SNAPSHOT
[INFO] ------------------------------------------------------------------------
mojoStarted org.apache.maven.plugins:maven-clean-plugin:2.5(default-clean)
[INFO]
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ tutti ---
mojoSucceeded org.apache.maven.plugins:maven-clean-plugin:2.5(default-clean)
[INFO] Deleting <http://ci.nuiton.org/jenkins/job/tutti/ws/trunk/target>
mojoStarted org.apache.maven.plugins:maven-enforcer-plugin:1.2(check-project-files)
[INFO]
[INFO] --- maven-enforcer-plugin:1.2:enforce (check-project-files) @ tutti ---
mojoSucceeded org.apache.maven.plugins:maven-enforcer-plugin:1.2(check-project-files)
mojoStarted org.apache.maven.plugins:maven-antrun-plugin:1.7(generate-surefire-workdir)
[INFO]
[INFO] --- maven-antrun-plugin:1.7:run (generate-surefire-workdir) @ tutti ---
[INFO] Executing tasks
main:
[mkdir] Created dir: <http://ci.nuiton.org/jenkins/job/tutti/ws/trunk/target/surefire-workdir>
[INFO] Executed tasks
mojoSucceeded org.apache.maven.plugins:maven-antrun-plugin:1.7(generate-surefire-workdir)
mojoStarted org.apache.maven.plugins:maven-site-plugin:3.2(attach-descriptor)
[INFO]
[INFO] --- maven-site-plugin:3.2:attach-descriptor (attach-descriptor) @ tutti ---
mojoSucceeded org.apache.maven.plugins:maven-site-plugin:3.2(attach-descriptor)
mojoStarted org.apache.maven.plugins:maven-install-plugin:2.4(default-install)
[INFO]
[INFO] --- maven-install-plugin:2.4:install (default-install) @ tutti ---
[INFO] Installing <http://ci.nuiton.org/jenkins/job/tutti/ws/trunk/pom.xml> to /var/local/maven/data/repository/fr/ifremer/tutti/1.0.2-SNAPSHOT/tutti-1.0.2-SNAPSHOT.pom
[INFO] Installing <http://ci.nuiton.org/jenkins/job/tutti/ws/trunk/target/tutti-1.0.2-SNAPSHOT…> to /var/local/maven/data/repository/fr/ifremer/tutti/1.0.2-SNAPSHOT/tutti-1.0.2-SNAPSHOT-site_fr.xml
mojoSucceeded org.apache.maven.plugins:maven-install-plugin:2.4(default-install)
projectSucceeded fr.ifremer:tutti:1.0.2-SNAPSHOT
projectStarted fr.ifremer.tutti:tutti-persistence:1.0.2-SNAPSHOT
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building Tutti :: Persistence 1.0.2-SNAPSHOT
[INFO] ------------------------------------------------------------------------
Downloading: http://nexus.nuiton.org/nexus/content/groups/tutti-group/fr/ifremer/adagio/…
Downloading: http://nexus.nuiton.org/nexus/content/groups/public/fr/ifremer/adagio/adagi…
Downloaded: http://nexus.nuiton.org/nexus/content/groups/tutti-group/fr/ifremer/adagio/… (2 KB at 5.6 KB/sec)
Downloading: http://nexus.nuiton.org/nexus/content/groups/tutti-group/fr/ifremer/adagio/…
Downloading: http://nexus.nuiton.org/nexus/content/groups/public/fr/ifremer/adagio/adagi…
Downloaded: http://nexus.nuiton.org/nexus/content/groups/tutti-group/fr/ifremer/adagio/… (600 B at 14.0 KB/sec)
Downloading: http://nexus.nuiton.org/nexus/content/groups/public/org/nuiton/nuiton-utils…
Downloading: http://nexus.nuiton.org/nexus/content/groups/tutti-group/org/nuiton/nuiton-…
Downloaded: http://nexus.nuiton.org/nexus/content/groups/tutti-group/org/nuiton/nuiton-… (2 KB at 30.4 KB/sec)
Downloaded: http://nexus.nuiton.org/nexus/content/groups/public/org/nuiton/nuiton-utils… (2 KB at 25.9 KB/sec)
Downloading: http://nexus.nuiton.org/nexus/content/groups/public/org/nuiton/nuiton-utils…
Downloading: http://nexus.nuiton.org/nexus/content/groups/tutti-group/org/nuiton/nuiton-…
Downloaded: http://nexus.nuiton.org/nexus/content/groups/tutti-group/org/nuiton/nuiton-… (823 B at 23.6 KB/sec)
Downloaded: http://nexus.nuiton.org/nexus/content/groups/public/org/nuiton/nuiton-utils… (823 B at 11.6 KB/sec)
Downloading: http://nexus.nuiton.org/nexus/content/groups/tutti-group/org/nuiton/nuiton-…
Downloading: http://nexus.nuiton.org/nexus/content/groups/public/org/nuiton/nuiton-confi…
Downloaded: http://nexus.nuiton.org/nexus/content/groups/tutti-group/org/nuiton/nuiton-… (2 KB at 16.6 KB/sec)
Downloaded: http://nexus.nuiton.org/nexus/content/groups/public/org/nuiton/nuiton-confi… (2 KB at 16.8 KB/sec)
mojoStarted org.apache.maven.plugins:maven-clean-plugin:2.5(default-clean)
[INFO]
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ tutti-persistence ---
[INFO] Deleting <http://ci.nuiton.org/jenkins/job/tutti/ws/trunk/tutti-persistence/target>
mojoSucceeded org.apache.maven.plugins:maven-clean-plugin:2.5(default-clean)
mojoStarted org.apache.maven.plugins:maven-enforcer-plugin:1.2(check-project-files)
[INFO]
[INFO] --- maven-enforcer-plugin:1.2:enforce (check-project-files) @ tutti-persistence ---
mojoSucceeded org.apache.maven.plugins:maven-enforcer-plugin:1.2(check-project-files)
mojoStarted org.nuiton.eugene:eugene-maven-plugin:2.6.1(default)
[INFO]
[INFO] --- eugene-maven-plugin:2.6.1:generate (default) @ tutti-persistence ---
[INFO] Process phase [zargo] for one entry.
[INFO] Expanding 1 xmi file(s) from <http://ci.nuiton.org/jenkins/job/tutti/ws/trunk/tutti-persistence/src/main/…>
[INFO] Will generate <http://ci.nuiton.org/jenkins/job/tutti/ws/trunk/tutti-persistence/target/ge…>
[INFO] Copy file <http://ci.nuiton.org/jenkins/job/tutti/ws/trunk/tutti-persistence/src/main/…> to <http://ci.nuiton.org/jenkins/job/tutti/ws/trunk/tutti-persistence/target/ge…>
[INFO] Generate one file in 51.042ms.
[INFO] Process phase [xmi] for one entry.
[INFO] Processing XSL tranformation on <http://ci.nuiton.org/jenkins/job/tutti/ws/trunk/tutti-persistence/target/ge…> for 1 file(s).
[INFO] Will generate <http://ci.nuiton.org/jenkins/job/tutti/ws/trunk/tutti-persistence/target/ge…>
[INFO] Copy file <http://ci.nuiton.org/jenkins/job/tutti/ws/trunk/tutti-persistence/target/ge…> to <http://ci.nuiton.org/jenkins/job/tutti/ws/trunk/tutti-persistence/target/ge…>
[INFO] Generate one file in 2.364s.
[INFO] Process phase [model] for one entry.
INFO [pool-1-thread-1] (ObjectModelReader.java:273) loadModelProperties - 19 tag values were succesfull imported from <http://ci.nuiton.org/jenkins/job/tutti/ws/trunk/tutti-persistence/target/ge…>
[INFO] Apply generator JavaInterfaceTransformer
[INFO] Apply generator SimpleJavaBeanTransformer
INFO [pool-1-thread-1] (ObjectModelTransformerToJava.java:911) isInClassPath - Will not generate [fr.ifremer.tutti.persistence.entities.data.Program], already found in class-path.
[INFO] Apply generator JavaEnumerationTransformer
INFO [pool-1-thread-1] (ObjectModelTransformerToJava.java:911) isInClassPath - Will not generate [fr.ifremer.tutti.persistence.entities.data.AttachementObjectTypeEnum], already found in class-path.
[INFO] No file generated.
[INFO] Add compile source root : <http://ci.nuiton.org/jenkins/job/tutti/ws/trunk/tutti-persistence/target/ge…>
[INFO] Add resource root :Resource {targetPath: null, filtering: false, FileSet {directory: <http://ci.nuiton.org/jenkins/job/tutti/ws/trunk/tutti-persistence/target/ge…,> PatternSet [includes: {}, excludes: {**/*.java}]}}
mojoSucceeded org.nuiton.eugene:eugene-maven-plugin:2.6.1(default)
mojoStarted org.nuiton.i18n:i18n-maven-plugin:2.5(scan-sources)
[INFO]
[INFO] --- i18n-maven-plugin:2.5:parserJava (scan-sources) @ tutti-persistence ---
mojoSucceeded org.nuiton.i18n:i18n-maven-plugin:2.5(scan-sources)
forkedProjectStarted fr.ifremer.tutti:tutti-persistence:1.0.2-SNAPSHOT
mojoStarted org.nuiton.i18n:i18n-maven-plugin:2.5(get)
[INFO]
[INFO] --- i18n-maven-plugin:2.5:get (get) @ tutti-persistence ---
[INFO] Copying tutti-persistence.properties to <http://ci.nuiton.org/jenkins/job/tutti/ws/trunk/tutti-persistence/target/ge…>
mojoSucceeded org.nuiton.i18n:i18n-maven-plugin:2.5(get)
forkedProjectSucceeded fr.ifremer.tutti:tutti-persistence:1.0.2-SNAPSHOT
mojoStarted org.nuiton.i18n:i18n-maven-plugin:2.5(scan-sources)
[INFO]
[INFO] --- i18n-maven-plugin:2.5:gen (scan-sources) @ tutti-persistence ---
mojoSucceeded org.nuiton.i18n:i18n-maven-plugin:2.5(scan-sources)
mojoStarted org.apache.maven.plugins:maven-resources-plugin:2.6(default-resources)
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ tutti-persistence ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 7 resources
[INFO] Copying 0 resource
mojoSucceeded org.apache.maven.plugins:maven-resources-plugin:2.6(default-resources)
mojoStarted org.apache.maven.plugins:maven-compiler-plugin:2.5.1(default-compile)
[INFO]
[INFO] --- maven-compiler-plugin:2.5.1:compile (default-compile) @ tutti-persistence ---
[INFO] Compiling 88 source files to <http://ci.nuiton.org/jenkins/job/tutti/ws/trunk/tutti-persistence/target/cl…>
mojoSucceeded org.apache.maven.plugins:maven-compiler-plugin:2.5.1(default-compile)
mojoStarted org.apache.maven.plugins:maven-antrun-plugin:1.7(generate-surefire-workdir)
[INFO]
[INFO] --- maven-antrun-plugin:1.7:run (generate-surefire-workdir) @ tutti-persistence ---
[INFO] Executing tasks
main:
[mkdir] Created dir: <http://ci.nuiton.org/jenkins/job/tutti/ws/trunk/tutti-persistence/target/su…>
[INFO] Executed tasks
mojoSucceeded org.apache.maven.plugins:maven-antrun-plugin:1.7(generate-surefire-workdir)
mojoStarted org.apache.maven.plugins:maven-resources-plugin:2.6(default-testResources)
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ tutti-persistence ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 5 resources
mojoSucceeded org.apache.maven.plugins:maven-resources-plugin:2.6(default-testResources)
mojoStarted org.apache.maven.plugins:maven-compiler-plugin:2.5.1(default-testCompile)
[INFO]
[INFO] --- maven-compiler-plugin:2.5.1:testCompile (default-testCompile) @ tutti-persistence ---
[INFO] Compiling 30 source files to <http://ci.nuiton.org/jenkins/job/tutti/ws/trunk/tutti-persistence/target/te…>
mojoFailed org.apache.maven.plugins:maven-compiler-plugin:2.5.1(default-testCompile)[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] bootstrap class path not set in conjunction with -source 1.6
<http://ci.nuiton.org/jenkins/job/tutti/ws/trunk/tutti-persistence/src/test/…>:[179,106] error: cannot find symbol
[ERROR] symbol: method getAllRootSpeciesBatch(String)
location: interface BatchPersistenceService
<http://ci.nuiton.org/jenkins/job/tutti/ws/trunk/tutti-persistence/src/test/…>:[377,53] error: cannot find symbol
[ERROR] symbol: method getAllRootSpeciesBatch(String)
location: variable service of type BatchPersistenceService
<http://ci.nuiton.org/jenkins/job/tutti/ws/trunk/tutti-persistence/src/test/…>:[585,53] error: cannot find symbol
[ERROR] symbol: method getAllRootSpeciesBatch(String)
location: variable service of type BatchPersistenceService
<http://ci.nuiton.org/jenkins/job/tutti/ws/trunk/tutti-persistence/src/test/…>:[846,54] error: cannot find symbol
[INFO] 4 errors
[INFO] -------------------------------------------------------------
projectFailed fr.ifremer.tutti:tutti-persistence:1.0.2-SNAPSHOT
sessionEnded
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary:
[INFO]
[INFO] Tutti ............................................. SUCCESS [6.756s]
[INFO] Tutti :: Persistence .............................. FAILURE [18.352s]
[INFO] Tutti :: Service .................................. SKIPPED
[INFO] Tutti :: UI ....................................... SKIPPED
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 26.650s
[INFO] Finished at: Mon Mar 04 16:32:38 CET 2013
[INFO] Final Memory: 30M/120M
[INFO] ------------------------------------------------------------------------
Projects to build: [MavenProject: fr.ifremer:tutti:1.0.2-SNAPSHOT @ <http://ci.nuiton.org/jenkins/job/tutti/ws/trunk/pom.xml,> MavenProject: fr.ifremer.tutti:tutti-persistence:1.0.2-SNAPSHOT @ <http://ci.nuiton.org/jenkins/job/tutti/ws/trunk/tutti-persistence/pom.xml,> MavenProject: fr.ifremer.tutti:tutti-service:1.0.2-SNAPSHOT @ <http://ci.nuiton.org/jenkins/job/tutti/ws/trunk/tutti-service/pom.xml,> MavenProject: fr.ifremer.tutti:tutti-ui-swing:1.0.2-SNAPSHOT @ <http://ci.nuiton.org/jenkins/job/tutti/ws/trunk/tutti-ui-swing/pom.xml]>
[JENKINS] Archiving <http://ci.nuiton.org/jenkins/job/tutti/ws/trunk/tutti-service/pom.xml> to /var/local/jenkins/data/jobs/tutti/modules/fr.ifremer.tutti$tutti-service/builds/2013-03-04_16-32-06/archive/fr.ifremer.tutti/tutti-service/1.0.2-SNAPSHOT/tutti-service-1.0.2-SNAPSHOT.pom
[JENKINS] Archiving <http://ci.nuiton.org/jenkins/job/tutti/ws/trunk/tutti-ui-swing/pom.xml> to /var/local/jenkins/data/jobs/tutti/modules/fr.ifremer.tutti$tutti-ui-swing/builds/2013-03-04_16-32-06/archive/fr.ifremer.tutti/tutti-ui-swing/1.0.2-SNAPSHOT/tutti-ui-swing-1.0.2-SNAPSHOT.pom
[JENKINS] Archiving <http://ci.nuiton.org/jenkins/job/tutti/ws/trunk/pom.xml> to /var/local/jenkins/data/jobs/tutti/modules/fr.ifremer$tutti/builds/2013-03-04_16-32-06/archive/fr.ifremer/tutti/1.0.2-SNAPSHOT/tutti-1.0.2-SNAPSHOT.pom
[JENKINS] Archiving <http://ci.nuiton.org/jenkins/job/tutti/ws/trunk/target/tutti-1.0.2-SNAPSHOT…> to /var/local/jenkins/data/jobs/tutti/modules/fr.ifremer$tutti/builds/2013-03-04_16-32-06/archive/fr.ifremer/tutti/1.0.2-SNAPSHOT/tutti-1.0.2-SNAPSHOT-site_fr.xml
[JENKINS] Archiving <http://ci.nuiton.org/jenkins/job/tutti/ws/trunk/tutti-persistence/pom.xml> to /var/local/jenkins/data/jobs/tutti/modules/fr.ifremer.tutti$tutti-persistence/builds/2013-03-04_16-32-06/archive/fr.ifremer.tutti/tutti-persistence/1.0.2-SNAPSHOT/tutti-persistence-1.0.2-SNAPSHOT.pom
Waiting for Jenkins to finish collecting data
mavenExecutionResult exceptions not empty
message : Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.5.1:testCompile (default-testCompile) on project tutti-persistence: Compilation failure
cause : Compilation failure
Stack trace :
org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.5.1:testCompile (default-testCompile) on project tutti-persistence: Compilation failure
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:213)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:153)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:145)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:84)
at org.apache.maven.lifecycle.internal.LifecycleModuleBuilder.buildProject(LifecycleModuleBuilder.java:59)
at org.apache.maven.lifecycle.internal.LifecycleStarter.singleThreadedBuild(LifecycleStarter.java:183)
at org.apache.maven.lifecycle.internal.LifecycleStarter.execute(LifecycleStarter.java:161)
at org.apache.maven.DefaultMaven.doExecute(DefaultMaven.java:320)
at org.apache.maven.DefaultMaven.execute(DefaultMaven.java:156)
at org.jvnet.hudson.maven3.launcher.Maven3Launcher.main(Maven3Launcher.java:79)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:601)
at org.codehaus.plexus.classworlds.launcher.Launcher.launchStandard(Launcher.java:329)
at org.codehaus.plexus.classworlds.launcher.Launcher.launch(Launcher.java:239)
at org.jvnet.hudson.maven3.agent.Maven3Main.launch(Maven3Main.java:158)
at hudson.maven.Maven3Builder.call(Maven3Builder.java:100)
at hudson.maven.Maven3Builder.call(Maven3Builder.java:66)
at hudson.remoting.UserRequest.perform(UserRequest.java:118)
at hudson.remoting.UserRequest.perform(UserRequest.java:48)
at hudson.remoting.Request$2.run(Request.java:326)
at hudson.remoting.InterceptingExecutorService$1.call(InterceptingExecutorService.java:72)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:334)
at java.util.concurrent.FutureTask.run(FutureTask.java:166)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603)
at java.lang.Thread.run(Thread.java:722)
Caused by: org.apache.maven.plugin.CompilationFailureException: Compilation failure
at org.apache.maven.plugin.AbstractCompilerMojo.execute(AbstractCompilerMojo.java:729)
at org.apache.maven.plugin.TestCompilerMojo.execute(TestCompilerMojo.java:161)
at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo(DefaultBuildPluginManager.java:101)
at org.apache.maven.lifecycle.internal.MojoExecutor.execute(MojoExecutor.java:209)
... 27 more
Sending e-mails to: tutti-commits(a)list.forge.codelutin.com chemit(a)codelutin.com
channel stopped
1
6
04 Mar '13
See <http://ci.nuiton.org/jenkins/job/tutti/fr.ifremer.tutti$tutti-persistence/4…>
Changes:
[Tony Chemit] refs #1963: [CAPTURE] - Global - Ajouter pièce jointe sur tous les onglets (obtenir depuis le service le sur lot)
------------------------------------------
projectStarted fr.ifremer.tutti:tutti-persistence:1.0.2-SNAPSHOT
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building Tutti :: Persistence 1.0.2-SNAPSHOT
[INFO] ------------------------------------------------------------------------
Downloading: http://nexus.nuiton.org/nexus/content/groups/tutti-group/fr/ifremer/adagio/…
Downloading: http://nexus.nuiton.org/nexus/content/groups/public/fr/ifremer/adagio/adagi…
Downloaded: http://nexus.nuiton.org/nexus/content/groups/tutti-group/fr/ifremer/adagio/… (2 KB at 5.6 KB/sec)
Downloading: http://nexus.nuiton.org/nexus/content/groups/tutti-group/fr/ifremer/adagio/…
Downloading: http://nexus.nuiton.org/nexus/content/groups/public/fr/ifremer/adagio/adagi…
Downloaded: http://nexus.nuiton.org/nexus/content/groups/tutti-group/fr/ifremer/adagio/… (600 B at 14.0 KB/sec)
Downloading: http://nexus.nuiton.org/nexus/content/groups/public/org/nuiton/nuiton-utils…
Downloading: http://nexus.nuiton.org/nexus/content/groups/tutti-group/org/nuiton/nuiton-…
Downloaded: http://nexus.nuiton.org/nexus/content/groups/tutti-group/org/nuiton/nuiton-… (2 KB at 30.4 KB/sec)
Downloaded: http://nexus.nuiton.org/nexus/content/groups/public/org/nuiton/nuiton-utils… (2 KB at 25.9 KB/sec)
Downloading: http://nexus.nuiton.org/nexus/content/groups/public/org/nuiton/nuiton-utils…
Downloading: http://nexus.nuiton.org/nexus/content/groups/tutti-group/org/nuiton/nuiton-…
Downloaded: http://nexus.nuiton.org/nexus/content/groups/tutti-group/org/nuiton/nuiton-… (823 B at 23.6 KB/sec)
Downloaded: http://nexus.nuiton.org/nexus/content/groups/public/org/nuiton/nuiton-utils… (823 B at 11.6 KB/sec)
Downloading: http://nexus.nuiton.org/nexus/content/groups/tutti-group/org/nuiton/nuiton-…
Downloading: http://nexus.nuiton.org/nexus/content/groups/public/org/nuiton/nuiton-confi…
Downloaded: http://nexus.nuiton.org/nexus/content/groups/tutti-group/org/nuiton/nuiton-… (2 KB at 16.6 KB/sec)
Downloaded: http://nexus.nuiton.org/nexus/content/groups/public/org/nuiton/nuiton-confi… (2 KB at 16.8 KB/sec)
mojoStarted org.apache.maven.plugins:maven-clean-plugin:2.5(default-clean)
[INFO]
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ tutti-persistence ---
[INFO] Deleting <http://ci.nuiton.org/jenkins/job/tutti/fr.ifremer.tutti$tutti-persistence/w…>
mojoSucceeded org.apache.maven.plugins:maven-clean-plugin:2.5(default-clean)
mojoStarted org.apache.maven.plugins:maven-enforcer-plugin:1.2(check-project-files)
[INFO]
[INFO] --- maven-enforcer-plugin:1.2:enforce (check-project-files) @ tutti-persistence ---
mojoSucceeded org.apache.maven.plugins:maven-enforcer-plugin:1.2(check-project-files)
mojoStarted org.nuiton.eugene:eugene-maven-plugin:2.6.1(default)
[INFO]
[INFO] --- eugene-maven-plugin:2.6.1:generate (default) @ tutti-persistence ---
[INFO] Process phase [zargo] for one entry.
[INFO] Expanding 1 xmi file(s) from <http://ci.nuiton.org/jenkins/job/tutti/fr.ifremer.tutti$tutti-persistence/w…>
[INFO] Will generate <http://ci.nuiton.org/jenkins/job/tutti/fr.ifremer.tutti$tutti-persistence/w…>
[INFO] Copy file <http://ci.nuiton.org/jenkins/job/tutti/fr.ifremer.tutti$tutti-persistence/w…> to <http://ci.nuiton.org/jenkins/job/tutti/fr.ifremer.tutti$tutti-persistence/w…>
[INFO] Generate one file in 51.042ms.
[INFO] Process phase [xmi] for one entry.
[INFO] Processing XSL tranformation on <http://ci.nuiton.org/jenkins/job/tutti/fr.ifremer.tutti$tutti-persistence/w…> for 1 file(s).
[INFO] Will generate <http://ci.nuiton.org/jenkins/job/tutti/fr.ifremer.tutti$tutti-persistence/w…>
[INFO] Copy file <http://ci.nuiton.org/jenkins/job/tutti/fr.ifremer.tutti$tutti-persistence/w…> to <http://ci.nuiton.org/jenkins/job/tutti/fr.ifremer.tutti$tutti-persistence/w…>
[INFO] Generate one file in 2.364s.
[INFO] Process phase [model] for one entry.
INFO [pool-1-thread-1] (ObjectModelReader.java:273) loadModelProperties - 19 tag values were succesfull imported from <http://ci.nuiton.org/jenkins/job/tutti/fr.ifremer.tutti$tutti-persistence/w…>
[INFO] Apply generator JavaInterfaceTransformer
[INFO] Apply generator SimpleJavaBeanTransformer
INFO [pool-1-thread-1] (ObjectModelTransformerToJava.java:911) isInClassPath - Will not generate [fr.ifremer.tutti.persistence.entities.data.Program], already found in class-path.
[INFO] Apply generator JavaEnumerationTransformer
INFO [pool-1-thread-1] (ObjectModelTransformerToJava.java:911) isInClassPath - Will not generate [fr.ifremer.tutti.persistence.entities.data.AttachementObjectTypeEnum], already found in class-path.
[INFO] No file generated.
[INFO] Add compile source root : <http://ci.nuiton.org/jenkins/job/tutti/fr.ifremer.tutti$tutti-persistence/w…>
[INFO] Add resource root :Resource {targetPath: null, filtering: false, FileSet {directory: <http://ci.nuiton.org/jenkins/job/tutti/fr.ifremer.tutti$tutti-persistence/w…,> PatternSet [includes: {}, excludes: {**/*.java}]}}
mojoSucceeded org.nuiton.eugene:eugene-maven-plugin:2.6.1(default)
mojoStarted org.nuiton.i18n:i18n-maven-plugin:2.5(scan-sources)
[INFO]
[INFO] --- i18n-maven-plugin:2.5:parserJava (scan-sources) @ tutti-persistence ---
mojoSucceeded org.nuiton.i18n:i18n-maven-plugin:2.5(scan-sources)
forkedProjectStarted fr.ifremer.tutti:tutti-persistence:1.0.2-SNAPSHOT
mojoStarted org.nuiton.i18n:i18n-maven-plugin:2.5(get)
[INFO]
[INFO] --- i18n-maven-plugin:2.5:get (get) @ tutti-persistence ---
[INFO] Copying tutti-persistence.properties to <http://ci.nuiton.org/jenkins/job/tutti/fr.ifremer.tutti$tutti-persistence/w…>
mojoSucceeded org.nuiton.i18n:i18n-maven-plugin:2.5(get)
forkedProjectSucceeded fr.ifremer.tutti:tutti-persistence:1.0.2-SNAPSHOT
mojoStarted org.nuiton.i18n:i18n-maven-plugin:2.5(scan-sources)
[INFO]
[INFO] --- i18n-maven-plugin:2.5:gen (scan-sources) @ tutti-persistence ---
mojoSucceeded org.nuiton.i18n:i18n-maven-plugin:2.5(scan-sources)
mojoStarted org.apache.maven.plugins:maven-resources-plugin:2.6(default-resources)
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ tutti-persistence ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 7 resources
[INFO] Copying 0 resource
mojoSucceeded org.apache.maven.plugins:maven-resources-plugin:2.6(default-resources)
mojoStarted org.apache.maven.plugins:maven-compiler-plugin:2.5.1(default-compile)
[INFO]
[INFO] --- maven-compiler-plugin:2.5.1:compile (default-compile) @ tutti-persistence ---
[INFO] Compiling 88 source files to <http://ci.nuiton.org/jenkins/job/tutti/fr.ifremer.tutti$tutti-persistence/w…>
mojoSucceeded org.apache.maven.plugins:maven-compiler-plugin:2.5.1(default-compile)
mojoStarted org.apache.maven.plugins:maven-antrun-plugin:1.7(generate-surefire-workdir)
[INFO]
[INFO] --- maven-antrun-plugin:1.7:run (generate-surefire-workdir) @ tutti-persistence ---
[INFO] Executing tasks
main:
[mkdir] Created dir: <http://ci.nuiton.org/jenkins/job/tutti/fr.ifremer.tutti$tutti-persistence/w…>
[INFO] Executed tasks
mojoSucceeded org.apache.maven.plugins:maven-antrun-plugin:1.7(generate-surefire-workdir)
mojoStarted org.apache.maven.plugins:maven-resources-plugin:2.6(default-testResources)
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ tutti-persistence ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 5 resources
mojoSucceeded org.apache.maven.plugins:maven-resources-plugin:2.6(default-testResources)
mojoStarted org.apache.maven.plugins:maven-compiler-plugin:2.5.1(default-testCompile)
[INFO]
[INFO] --- maven-compiler-plugin:2.5.1:testCompile (default-testCompile) @ tutti-persistence ---
[INFO] Compiling 30 source files to <http://ci.nuiton.org/jenkins/job/tutti/fr.ifremer.tutti$tutti-persistence/w…>
mojoFailed org.apache.maven.plugins:maven-compiler-plugin:2.5.1(default-testCompile)[INFO] -------------------------------------------------------------
[ERROR] COMPILATION ERROR :
[INFO] -------------------------------------------------------------
[ERROR] bootstrap class path not set in conjunction with -source 1.6
<http://ci.nuiton.org/jenkins/job/tutti/fr.ifremer.tutti$tutti-persistence/w…>:[179,106] error: cannot find symbol
[ERROR] symbol: method getAllRootSpeciesBatch(String)
location: interface BatchPersistenceService
<http://ci.nuiton.org/jenkins/job/tutti/fr.ifremer.tutti$tutti-persistence/w…>:[377,53] error: cannot find symbol
[ERROR] symbol: method getAllRootSpeciesBatch(String)
location: variable service of type BatchPersistenceService
<http://ci.nuiton.org/jenkins/job/tutti/fr.ifremer.tutti$tutti-persistence/w…>:[585,53] error: cannot find symbol
[ERROR] symbol: method getAllRootSpeciesBatch(String)
location: variable service of type BatchPersistenceService
<http://ci.nuiton.org/jenkins/job/tutti/fr.ifremer.tutti$tutti-persistence/w…>:[846,54] error: cannot find symbol
[INFO] 4 errors
[INFO] -------------------------------------------------------------
projectFailed fr.ifremer.tutti:tutti-persistence:1.0.2-SNAPSHOT
1
6
r533 - in trunk/tutti-persistence/src: main/java/fr/ifremer/tutti/persistence/service test/java/fr/ifremer/tutti/persistence/service test/java/fr/ifremer/tutti/persistence/service/batch
by tchemit@users.forge.codelutin.com 04 Mar '13
by tchemit@users.forge.codelutin.com 04 Mar '13
04 Mar '13
Author: tchemit
Date: 2013-03-04 21:23:40 +0100 (Mon, 04 Mar 2013)
New Revision: 533
Url: http://forge.codelutin.com/projects/tutti/repository/revisions/533
Log:
fix tests
Modified:
trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/BatchPersistenceService.java
trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/BatchPersistenceServiceImpl.java
trunk/tutti-persistence/src/test/java/fr/ifremer/tutti/persistence/service/BatchPersistenceServiceReadTest.java
trunk/tutti-persistence/src/test/java/fr/ifremer/tutti/persistence/service/BatchPersistenceServiceWriteTest.java
trunk/tutti-persistence/src/test/java/fr/ifremer/tutti/persistence/service/batch/CatchBatchValidatorReadTest.java
Modified: trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/BatchPersistenceService.java
===================================================================
--- trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/BatchPersistenceService.java 2013-03-04 18:40:32 UTC (rev 532)
+++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/BatchPersistenceService.java 2013-03-04 20:23:40 UTC (rev 533)
@@ -68,15 +68,6 @@
* @return found catchbatch
* @throws CatchBatchValidationException
*/
- CatchBatch getCatchBatchFromFishingOperation(String fishingOperationId) throws CatchBatchValidationException;
-
- /**
- * Get the catchBatch from the fishing Operation id.
- *
- * @param fishingOperationId id of the fihsing operation
- * @return found catchbatch
- * @throws CatchBatchValidationException
- */
@Transactional(readOnly = false)
CatchBatch getCatchBatchFromFishingOperation(String fishingOperationId,
boolean tryToRepair) throws CatchBatchValidationException;
Modified: trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/BatchPersistenceServiceImpl.java
===================================================================
--- trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/BatchPersistenceServiceImpl.java 2013-03-04 18:40:32 UTC (rev 532)
+++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/BatchPersistenceServiceImpl.java 2013-03-04 20:23:40 UTC (rev 533)
@@ -104,12 +104,8 @@
//------------------------------------------------------------------------//
@Override
- public CatchBatch getCatchBatchFromFishingOperation(String fishingOperationId) throws CatchBatchValidationException {
- return getCatchBatchFromFishingOperation(fishingOperationId, false);
- }
-
- @Override
- public CatchBatch getCatchBatchFromFishingOperation(String fishingOperationId, boolean tryToRepair) throws CatchBatchValidationException {
+ public CatchBatch getCatchBatchFromFishingOperation(String fishingOperationId,
+ boolean tryToRepair) throws CatchBatchValidationException {
Preconditions.checkNotNull(fishingOperationId);
Integer catchBatchId = catchBatchDao.getIdByFishingOperationId(Integer.valueOf(fishingOperationId));
@@ -180,7 +176,6 @@
result.setBenthosTotalUnsortedWeight(benthosBatch.getWeight());
}
-
// TODO : Plancton...
}
}
Modified: trunk/tutti-persistence/src/test/java/fr/ifremer/tutti/persistence/service/BatchPersistenceServiceReadTest.java
===================================================================
--- trunk/tutti-persistence/src/test/java/fr/ifremer/tutti/persistence/service/BatchPersistenceServiceReadTest.java 2013-03-04 18:40:32 UTC (rev 532)
+++ trunk/tutti-persistence/src/test/java/fr/ifremer/tutti/persistence/service/BatchPersistenceServiceReadTest.java 2013-03-04 20:23:40 UTC (rev 533)
@@ -25,17 +25,20 @@
*/
import com.google.common.collect.Maps;
+import fr.ifremer.adagio.core.dao.data.batch.validator.CatchBatchValidationException;
import fr.ifremer.tutti.persistence.DatabaseResource;
+import fr.ifremer.tutti.persistence.entities.data.BatchContainer;
import fr.ifremer.tutti.persistence.entities.data.CatchBatch;
import fr.ifremer.tutti.persistence.entities.data.FishingOperation;
import fr.ifremer.tutti.persistence.entities.data.SampleCategoryEnum;
import fr.ifremer.tutti.persistence.entities.data.SpeciesBatch;
import fr.ifremer.tutti.persistence.entities.data.SpeciesBatchFrequency;
import fr.ifremer.tutti.persistence.entities.referential.CaracteristicQualitativeValue;
+import org.junit.Assert;
import org.junit.Before;
import org.junit.ClassRule;
+import org.junit.Ignore;
import org.junit.Test;
-import org.springframework.dao.DataRetrievalFailureException;
import java.util.List;
import java.util.Map;
@@ -44,7 +47,6 @@
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
/**
* To test {@link BatchPersistenceService} for read operation.
@@ -55,7 +57,7 @@
public class BatchPersistenceServiceReadTest {
@ClassRule
- public static final DatabaseResource dbResource = DatabaseResource.readDb();
+ public static final DatabaseResource dbResource = DatabaseResource.writeDb();
protected BatchPersistenceService service;
@@ -76,37 +78,41 @@
assertNotNull(fishingOperation.getId());
}
- @Test
+ @Test(expected = CatchBatchValidationException.class)
public void getCatchBatchFromFishingOperation() throws Exception {
- try {
- CatchBatch catchBatch = service.getCatchBatchFromFishingOperation(fishingOperation.getId());
- fail("batch tree must be invalid (old CGFS tree structure), for fishing operation id=" + fishingOperation.getId());
- } catch (DataRetrievalFailureException drfe) {
- // success
- }
+ // old CGFS tree structure is still not valid
+ service.getCatchBatchFromFishingOperation(fishingOperation.getId(), false);
}
@Test
- public void getAllRootSpeciesBatch(/*String fishingOperationId*/) {
- //TODO Do me!
+ public void getCatchBatchFromFishingOperationAndRepair() throws Exception {
+
+ // old CGFS tree structure is still not valid, but can be repair
+ CatchBatch catchBatch = service.getCatchBatchFromFishingOperation(fishingOperation.getId(), true);
+ Assert.assertNotNull(catchBatch);
}
+ @Ignore
@Test
- public void getAllSpeciesBatchFrequency(/*String speciesBatchId*/) {
+ public void getRootSpeciesBatch(/*String fishingOperationId*/) {
//TODO Do me!
+ service.getRootSpeciesBatch(fishingOperation.getId());
}
+ @Ignore
@Test
- public void getAllRootBenthosBatch(/*String fishingOperationId*/) {
+ public void getAllSpeciesBatchFrequency(/*String speciesBatchId*/) {
//TODO Do me!
}
+ @Ignore
@Test
- public void getAllBenthosBatchFrequency(/*String benthosBatchId*/) {
+ public void getRootBenthosBatch(/*String fishingOperationId*/) {
//TODO Do me!
}
+
public static void assertSpeciesBatch(SpeciesBatch expectedBatch, SpeciesBatch actualBatch, boolean assertIdEquals) {
assertNotNull(actualBatch);
assertNotNull(actualBatch.getId());
@@ -176,7 +182,8 @@
public static SpeciesBatch getSpeciesBatch(String fishingOperationId,
String speciesBatchId) {
- return getSpeciesBatch(speciesBatchId, TuttiPersistenceServiceLocator.getBatchPersistenceService().getAllRootSpeciesBatch(fishingOperationId));
+ BatchContainer<SpeciesBatch> rootSpeciesBatch = TuttiPersistenceServiceLocator.getBatchPersistenceService().getRootSpeciesBatch(fishingOperationId);
+ return getSpeciesBatch(speciesBatchId, rootSpeciesBatch.getChildren());
}
public static SpeciesBatch getSpeciesBatch(String speciesBatchId,
Modified: trunk/tutti-persistence/src/test/java/fr/ifremer/tutti/persistence/service/BatchPersistenceServiceWriteTest.java
===================================================================
--- trunk/tutti-persistence/src/test/java/fr/ifremer/tutti/persistence/service/BatchPersistenceServiceWriteTest.java 2013-03-04 18:40:32 UTC (rev 532)
+++ trunk/tutti-persistence/src/test/java/fr/ifremer/tutti/persistence/service/BatchPersistenceServiceWriteTest.java 2013-03-04 20:23:40 UTC (rev 533)
@@ -28,6 +28,7 @@
import com.google.common.collect.Maps;
import fr.ifremer.adagio.core.dao.data.batch.validator.CatchBatchValidationException;
import fr.ifremer.tutti.persistence.DatabaseResource;
+import fr.ifremer.tutti.persistence.entities.data.BatchContainer;
import fr.ifremer.tutti.persistence.entities.data.CatchBatch;
import fr.ifremer.tutti.persistence.entities.data.Cruise;
import fr.ifremer.tutti.persistence.entities.data.FishingOperation;
@@ -41,6 +42,7 @@
import org.junit.Assert;
import org.junit.Before;
import org.junit.ClassRule;
+import org.junit.Ignore;
import org.junit.Test;
import org.springframework.dao.DataRetrievalFailureException;
@@ -374,7 +376,8 @@
// -----------------------------------------------------------------------------
// 7. Test get all root species
// -----------------------------------------------------------------------------
- List<SpeciesBatch> rootSpeciesBatch = service.getAllRootSpeciesBatch(fishingOperationWithEmptyBatch.getId());
+ BatchContainer<SpeciesBatch> rootSpeciesBatc = service.getRootSpeciesBatch(fishingOperationWithEmptyBatch.getId());
+ List<SpeciesBatch> rootSpeciesBatch = rootSpeciesBatc.getChildren();
assertNotNull(rootSpeciesBatch);
assertEquals(2, rootSpeciesBatch.size());
assertNotNull(rootSpeciesBatch.get(0).getChildBatchs());
@@ -413,7 +416,7 @@
}
// And remove the last item (should be deleted in DB)
createdFrequencies.remove(createdFrequencies.size() - 1);
- List<SpeciesBatchFrequency> savedFrequencies = service.saveSpeciesBatchFrequency(frequenciesParentBatch.getId(), frequencies);
+ List<SpeciesBatchFrequency> savedFrequencies = service.saveSpeciesBatchFrequency(frequenciesParentBatch.getId(), createdFrequencies);
assertBatchFrequencies(createdFrequencies, savedFrequencies, true);
}
@@ -460,6 +463,7 @@
}
+ @Ignore
@Test
public void createAndSaveBenthosBatchAndFrequencies() {
SpeciesBatch esp1Batch;
@@ -582,7 +586,7 @@
// -----------------------------------------------------------------------------
// 7. Test get all root species
// -----------------------------------------------------------------------------
- List<SpeciesBatch> rootSpeciesBatch = service.getAllRootSpeciesBatch(fishingOperationWithEmptyBatch.getId());
+ List<SpeciesBatch> rootSpeciesBatch = service.getRootSpeciesBatch(fishingOperationWithEmptyBatch.getId()).getChildren();
assertNotNull(rootSpeciesBatch);
assertEquals(2, rootSpeciesBatch.size());
assertNotNull(rootSpeciesBatch.get(0).getChildBatchs());
@@ -625,6 +629,7 @@
assertBatchFrequencies(createdFrequencies, savedFrequencies, true);
}
+ @Ignore
@Test
public void deleteBenthosBatch(/* String id */) {
SpeciesBatch esp1Batch;
@@ -715,7 +720,7 @@
CatchBatch reloadedCatchBatch = null;
try {
- reloadedCatchBatch = service.getCatchBatchFromFishingOperation(fishingOperationId);
+ reloadedCatchBatch = service.getCatchBatchFromFishingOperation(fishingOperationId, false);
} catch (CatchBatchValidationException e) {
Assert.fail(e.getMessage());
}
@@ -732,7 +737,7 @@
CatchBatch reloadedCatchBatch = null;
try {
- reloadedCatchBatch = service.getCatchBatchFromFishingOperation(fishingOperationId);
+ reloadedCatchBatch = service.getCatchBatchFromFishingOperation(fishingOperationId, false);
} catch (CatchBatchValidationException e) {
Assert.fail(e.getMessage());
}
@@ -843,7 +848,7 @@
}
protected SpeciesBatch getSpeciesBatch(String fishingOperationId, String speciesBatchId) {
- return getSpeciesBatch(speciesBatchId, service.getAllRootSpeciesBatch(fishingOperationId));
+ return getSpeciesBatch(speciesBatchId, service.getRootSpeciesBatch(fishingOperationId).getChildren());
}
protected SpeciesBatch getBenthosBatch(String fishingOperationId, String speciesBatchId) {
Modified: trunk/tutti-persistence/src/test/java/fr/ifremer/tutti/persistence/service/batch/CatchBatchValidatorReadTest.java
===================================================================
--- trunk/tutti-persistence/src/test/java/fr/ifremer/tutti/persistence/service/batch/CatchBatchValidatorReadTest.java 2013-03-04 18:40:32 UTC (rev 532)
+++ trunk/tutti-persistence/src/test/java/fr/ifremer/tutti/persistence/service/batch/CatchBatchValidatorReadTest.java 2013-03-04 20:23:40 UTC (rev 533)
@@ -90,17 +90,10 @@
fishingOperationId = fishingOperations.get(0).getId();
}
- @Test
- @Ignore
- public void getInvalidCatchBatch() {
+ @Test(expected = CatchBatchValidationException.class)
+ public void getInvalidCatchBatch() throws CatchBatchValidationException {
- // Full load operation
- try {
- CatchBatch catchBatch = service.getCatchBatchFromFishingOperation(fishingOperationId);
- Assert.fail("Historical batch tree must not be valid");
- } catch (CatchBatchValidationException e) {
- assertNotNull(e);
- }
+ service.getCatchBatchFromFishingOperation(fishingOperationId, false);
}
@Test
1
0
r532 - trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/table
by tchemit@users.forge.codelutin.com 04 Mar '13
by tchemit@users.forge.codelutin.com 04 Mar '13
04 Mar '13
Author: tchemit
Date: 2013-03-04 19:40:32 +0100 (Mon, 04 Mar 2013)
New Revision: 532
Url: http://forge.codelutin.com/projects/tutti/repository/revisions/532
Log:
improve comment highlight
Modified:
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/table/AbstractTuttiTableUIHandler.java
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/table/AbstractTuttiTableUIHandler.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/table/AbstractTuttiTableUIHandler.java 2013-03-04 18:03:49 UTC (rev 531)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/table/AbstractTuttiTableUIHandler.java 2013-03-04 18:40:32 UTC (rev 532)
@@ -42,6 +42,7 @@
import jaxx.runtime.swing.renderer.DecoratorTableCellRenderer;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.ArrayUtils;
+import org.apache.commons.lang3.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.jdesktop.swingx.JXTable;
@@ -303,12 +304,15 @@
new HighlightPredicate.AndHighlightPredicate(
new MyIdentifierHighlightPredicate(SpeciesBatchTableModel.COMMENT),
// for not null value
- new HighlightPredicate.NotHighlightPredicate(new HighlightPredicate.EqualsHighlightPredicate()),
- new HighlightPredicate.NotHighlightPredicate(new HighlightPredicate.EqualsHighlightPredicate(""))
- ), cellWithValueColor);
+ new HighlightPredicate() {
+ @Override
+ public boolean isHighlighted(Component renderer, ComponentAdapter adapter) {
+ return StringUtils.isNotBlank((String) adapter.getValue());
+ }
+ }), cellWithValueColor);
table.addHighlighter(commentHighlighter);
- // paint in a special color for attachment cell (with not null value)
+ // paint in a special color for attachment cell (when some attachments)
Highlighter attachmentHighlighter = TuttiUIUtil.newBackgroundColorHighlighter(
new HighlightPredicate.AndHighlightPredicate(
new MyIdentifierHighlightPredicate(SpeciesBatchTableModel.ATTACHMENTS),
1
0
r531 - in trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing: content/operation/catches/species util/editor util/table
by tchemit@users.forge.codelutin.com 04 Mar '13
by tchemit@users.forge.codelutin.com 04 Mar '13
04 Mar '13
Author: tchemit
Date: 2013-03-04 19:03:49 +0100 (Mon, 04 Mar 2013)
New Revision: 531
Url: http://forge.codelutin.com/projects/tutti/repository/revisions/531
Log:
fixes #1861: [CAPTURE] - Fonctionnalit?\195?\169s de pi?\195?\168ces jointes
Modified:
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchRowModel.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchTableModel.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUI.css
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/util/editor/AttachmentCellComponent.java
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/AttachmentEditorUIHandler.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/table/AbstractTuttiTableUIHandler.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/table/ColumnIdentifier.java
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchRowModel.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchRowModel.java 2013-03-04 17:05:50 UTC (rev 530)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchRowModel.java 2013-03-04 18:03:49 UTC (rev 531)
@@ -196,11 +196,11 @@
protected String comment;
/**
- * Attachments
+ * Attachments (should never be null).
*
* @since 0.2
*/
- protected List<Attachment> attachments;
+ protected final List<Attachment> attachments;
/**
* List of frequencies observed for this batch.
@@ -236,6 +236,7 @@
public SpeciesBatchRowModel() {
super(SpeciesBatch.class, fromBeanBinder, toBeanBinder);
frequency = Lists.newArrayList();
+ attachments = Lists.newArrayList();
sortedUnsortedCategory = SampleCategory.newSample(SampleCategoryType.sortedUnsorted);
sizeCategory = SampleCategory.newSample(SampleCategoryType.size);
sexCategory = SampleCategory.newSample(SampleCategoryType.sex);
@@ -278,12 +279,14 @@
}
public SpeciesBatchRowModel(SpeciesBatch aBatch,
- List<SpeciesBatchFrequency> frequencies) {
+ List<SpeciesBatchFrequency> frequencies,
+ List<Attachment> attachments) {
this();
fromBean(aBatch);
List<SpeciesFrequencyRowModel> frequencyRows =
SpeciesFrequencyRowModel.fromBeans(frequencies);
frequency.addAll(frequencyRows);
+ this.attachments.addAll(attachments);
Collections.sort(frequency);
}
@@ -596,11 +599,11 @@
return attachments;
}
- public void setAttachments(List<Attachment> attachments) {
- Object oldValue = getAttachments();
- this.attachments = attachments;
- firePropertyChange(PROPERTY_ATTACHMENTS, oldValue, attachments);
- }
+// public void setAttachments(List<Attachment> attachments) {
+// Object oldValue = getAttachments();
+// this.attachments = attachments;
+// firePropertyChange(PROPERTY_ATTACHMENTS, oldValue, attachments);
+// }
public List<SpeciesFrequencyRowModel> getFrequency() {
return frequency;
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchTableModel.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchTableModel.java 2013-03-04 17:05:50 UTC (rev 530)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchTableModel.java 2013-03-04 18:03:49 UTC (rev 531)
@@ -139,7 +139,7 @@
n_("tutti.table.species.batch.header.comment"),
n_("tutti.table.species.batch.header.comment"));
- public static final ColumnIdentifier<SpeciesBatchRowModel> ATTACHMENTS = ColumnIdentifier.newId(
+ public static final ColumnIdentifier<SpeciesBatchRowModel> ATTACHMENTS = ColumnIdentifier.newReadOnlyId(
SpeciesBatchRowModel.PROPERTY_ATTACHMENTS,
n_("tutti.table.species.batch.header.file"),
n_("tutti.table.species.batch.header.file"));
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUI.css
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUI.css 2013-03-04 17:05:50 UTC (rev 530)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUI.css 2013-03-04 18:03:49 UTC (rev 531)
@@ -178,7 +178,7 @@
}
#filterSpeciesBatchRootButton {
- text: {_("tutti.label.filterSpeciesBatchMode.mode.root", model.getRootNumber())};
+ text: {handler.getFilterSpeciesBatchRootButtonText(model.getRootNumber())};
toolTipText: "tutti.label.filterSpeciesBatchMode.mode.root.tip";
value: "root";
selected: {model.isTableViewModeRoot()};
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 17:05:50 UTC (rev 530)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/SpeciesBatchUIHandler.java 2013-03-04 18:03:49 UTC (rev 531)
@@ -937,6 +937,10 @@
row.setFrequency(frequencyRows);
}
+ public String getFilterSpeciesBatchRootButtonText(int rootNumber) {
+ return _("tutti.label.filterSpeciesBatchMode.mode.root", getModel().getRootNumber());
+ }
+
protected void recomputeBatchActionEnable() {
int rowIndex = getTable().getSelectedRow();
@@ -1051,11 +1055,16 @@
SpeciesBatchRowModel parentRow,
List<SpeciesBatchRowModel> rows) {
+ String id = aBatch.getId();
+
List<SpeciesBatchFrequency> frequencies =
- persistenceService.getAllSpeciesBatchFrequency(aBatch.getId());
+ persistenceService.getAllSpeciesBatchFrequency(id);
+ List<Attachment> attachments =
+ persistenceService.getAllAttachments(Integer.valueOf(id));
+
SpeciesBatchRowModel newRow =
- new SpeciesBatchRowModel(aBatch, frequencies);
+ new SpeciesBatchRowModel(aBatch, frequencies, attachments);
SampleCategoryEnum sampleCategoryEnum =
aBatch.getSampleCategoryType();
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 17:05:50 UTC (rev 530)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/editor/AttachmentCellComponent.java 2013-03-04 18:03:49 UTC (rev 531)
@@ -34,6 +34,7 @@
import fr.ifremer.tutti.ui.swing.util.table.AbstractTuttiTableModel;
import fr.ifremer.tutti.ui.swing.util.table.ColumnIdentifier;
import jaxx.runtime.SwingUtil;
+import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.nuiton.util.decorator.Decorator;
@@ -106,8 +107,6 @@
protected final AttachmentCellComponent component;
-// protected final AttachmentEditorUI ui;
-
protected AttachmentEditor attachmentEditor;
protected Frame frame;
@@ -158,8 +157,13 @@
// stop edition
stopCellEditing();
+ // refresh cell
+ tableModel.fireTableCellUpdated(r, c);
+
// reselect this cell
AbstractSelectTableAction.doSelectCell(table, r, c);
+
+ // focus on table
table.requestFocus();
}
};
@@ -315,8 +319,6 @@
private final Decorator<Attachment> decorator;
- protected String propertyName;
-
public AttachmentCellRenderer(Decorator<Attachment> decorator,
String noneText) {
component = new AttachmentCellComponent();
@@ -336,19 +338,17 @@
if (table != null) {
+ Collection<Attachment> attachments = (Collection<Attachment>) value;
+
String textValue;
- if (value == null) {
- if (propertyName == null) {
- AbstractTuttiTableModel tableModel =
- (AbstractTuttiTableModel) table.getModel();
- ColumnIdentifier columnIdentifier = tableModel.getPropertyName(column);
- propertyName = columnIdentifier.getPropertyName();
- }
+
+ if (CollectionUtils.isEmpty(attachments)) {
+
// use HTML to show the tooltip in italic
textValue = "<i>" + _(noneText) + "</i>";
} else {
- Collection<Attachment> attachments = (Collection<Attachment>) value;
+
StringBuilder sb = new StringBuilder();
for (Attachment attachment : attachments) {
sb.append("<br/>").append(decorator.toString(attachment));
Modified: 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 2013-03-04 17:05:50 UTC (rev 530)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/editor/AttachmentEditor.java 2013-03-04 18:03:49 UTC (rev 531)
@@ -77,6 +77,7 @@
setUndecorated(true);
add(editor);
setResizable(true);
+ pack();
ComponentResizer cr = new ComponentResizer();
cr.registerComponent(this);
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 17:05:50 UTC (rev 530)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/editor/AttachmentEditorUIHandler.java 2013-03-04 18:03:49 UTC (rev 531)
@@ -25,7 +25,6 @@
*/
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;
@@ -115,7 +114,6 @@
Preconditions.checkNotNull(list);
list.remove(attachment);
- TuttiUIUtil.setProperty(bean, property, list);
ui.getAttachments().remove(hbox);
@@ -164,10 +162,7 @@
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);
- }
+ Preconditions.checkNotNull(list, "Attachments list can not be null");
Attachment attachment = new Attachment();
File file = ui.getFile().getSelectedFile();
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/table/AbstractTuttiTableUIHandler.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/table/AbstractTuttiTableUIHandler.java 2013-03-04 17:05:50 UTC (rev 530)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/table/AbstractTuttiTableUIHandler.java 2013-03-04 18:03:49 UTC (rev 531)
@@ -73,6 +73,7 @@
import java.awt.event.MouseEvent;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
+import java.util.Collection;
import java.util.Enumeration;
import java.util.List;
import java.util.Set;
@@ -312,7 +313,12 @@
new HighlightPredicate.AndHighlightPredicate(
new MyIdentifierHighlightPredicate(SpeciesBatchTableModel.ATTACHMENTS),
// for not null value
- new HighlightPredicate.NotHighlightPredicate(new HighlightPredicate.EqualsHighlightPredicate())
+ new HighlightPredicate() {
+ @Override
+ public boolean isHighlighted(Component renderer, ComponentAdapter adapter) {
+ return CollectionUtils.isNotEmpty((Collection) adapter.getValue());
+ }
+ }
), cellWithValueColor);
table.addHighlighter(attachmentHighlighter);
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/table/ColumnIdentifier.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/table/ColumnIdentifier.java 2013-03-04 17:05:50 UTC (rev 530)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/table/ColumnIdentifier.java 2013-03-04 18:03:49 UTC (rev 531)
@@ -50,6 +50,22 @@
headerTipI18nKey);
}
+ public static <R> ColumnIdentifier<R> newReadOnlyId(String propertyName,
+ String headerI18nKey,
+ String headerTipI18nKey) {
+ return new ColumnIdentifier<R>(propertyName,
+ headerI18nKey,
+ headerTipI18nKey) {
+
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void setValue(R entry, Object value) {
+ // no set
+ }
+ };
+ }
+
protected ColumnIdentifier(String propertyName,
String headerI18nKey,
String headerTipI18nKey) {
1
0
r530 - in trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing: content/operation/catches/species util/editor
by tchemit@users.forge.codelutin.com 04 Mar '13
by tchemit@users.forge.codelutin.com 04 Mar '13
04 Mar '13
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(a)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(a)codelutin.com>
+ * @author tchemit <chemit(a)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);
1
0
r529 - in trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing: content/operation/catches content/operation/catches/species content/operation/catches/species/frequency content/operation/catches/species/split util/table
by kmorin@users.forge.codelutin.com 04 Mar '13
by kmorin@users.forge.codelutin.com 04 Mar '13
04 Mar '13
Author: kmorin
Date: 2013-03-04 17:57:44 +0100 (Mon, 04 Mar 2013)
New Revision: 529
Url: http://forge.codelutin.com/projects/tutti/repository/revisions/529
Log:
- do not hide screen when computing weights
- select last create batch in species catches
- reset simple count when leaving frequency screen
- reset the selected category when leaving the split screen, otherwise, the selected data are not reset
- clear the rows before creating the new rows in setRows
Modified:
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/ComputeWeightsAction.java
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/frequency/SpeciesFrequencyUIHandler.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSpeciesBatchUIHandler.java
trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/table/AbstractTuttiTableModel.java
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/ComputeWeightsAction.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/ComputeWeightsAction.java 2013-03-04 16:44:45 UTC (rev 528)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/ComputeWeightsAction.java 2013-03-04 16:57:44 UTC (rev 529)
@@ -11,15 +11,15 @@
* %%
* 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
+ * 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
+ *
+ * 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%
@@ -60,7 +60,7 @@
"generate",
_("tutti.action.computeWeights"),
_("tutti.action.computeWeights.tip"),
- true);
+ false);
}
@Override
@@ -176,10 +176,10 @@
errorComponent = ui.getSpeciesTotalSortedWeightField();
} else if (speciesTotalSortedWeight < 1.05 * totalSortedWeight) {
- // TODO Si le "Poids total VRAC" est saisi est que sa valeur
- // est supérieure de moins de x% (x en configuration)
- // du "Poids total Vrac trié", demander confirmation que
- // le "Poids total VRAC" est bien une valeur observée
+ // TODO Si le "Poids total VRAC" est saisi est que sa valeur
+ // est supérieure de moins de x% (x en configuration)
+ // du "Poids total Vrac trié", demander confirmation que
+ // le "Poids total VRAC" est bien une valeur observée
// sinon la remplacer par le "Poids total Vrac trié"
}
@@ -262,7 +262,7 @@
errorComponent = null;
} else if (categoryWeight == null && frequencyWeight != null) {
- // if the category weight is null and the frequencies have a weight,
+ // if the category weight is null and the frequencies have a weight,
// then this weight is the result
finestCategory.setComputedWeight(frequencyWeight);
result = frequencyWeight;
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:44:45 UTC (rev 528)
+++ 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)
@@ -10,15 +10,15 @@
* %%
* 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
+ * 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
+ *
+ * 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%
@@ -59,6 +59,7 @@
import fr.ifremer.tutti.ui.swing.util.editor.AttachmentCellComponent;
import fr.ifremer.tutti.ui.swing.util.editor.LongTextCellComponent;
import fr.ifremer.tutti.ui.swing.util.editor.TuttiComputedOrNotDataTableCell;
+import fr.ifremer.tutti.ui.swing.util.table.AbstractSelectTableAction;
import fr.ifremer.tutti.ui.swing.util.table.ColumnIdentifier;
import jaxx.runtime.JAXXUtil;
import jaxx.runtime.SwingUtil;
@@ -735,6 +736,7 @@
recomputeRowValidState(newRow);
tableModel.addNewRow(newRow);
+ AbstractSelectTableAction.doSelectCell(getTable(), tableModel.getRowCount() - 1, 0);
saveRow(newRow);
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SpeciesFrequencyUIHandler.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SpeciesFrequencyUIHandler.java 2013-03-04 16:44:45 UTC (rev 528)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/frequency/SpeciesFrequencyUIHandler.java 2013-03-04 16:57:44 UTC (rev 529)
@@ -10,15 +10,15 @@
* %%
* 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
+ * 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
+ *
+ * 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%
@@ -295,6 +295,8 @@
// when canceling always invalid model (in that way)
getModel().setValid(false);
+ getModel().setSimpleCount(null);
+
EditCatchesUI parent = SwingUtil.getParentContainer(ui, EditCatchesUI.class);
parent.getHandler().setSpeciesSelectedCard(EditCatchesUIHandler.MAIN_CARD);
}
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSpeciesBatchUIHandler.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSpeciesBatchUIHandler.java 2013-03-04 16:44:45 UTC (rev 528)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/content/operation/catches/species/split/SplitSpeciesBatchUIHandler.java 2013-03-04 16:57:44 UTC (rev 529)
@@ -10,15 +10,15 @@
* %%
* 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
+ * 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
+ *
+ * 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%
@@ -216,6 +216,7 @@
// when canceling always invalid model
getModel().setValid(false);
+ getModel().setSelectedCategory(null);
EditCatchesUI parent = SwingUtil.getParentContainer(ui, EditCatchesUI.class);
parent.getHandler().setSpeciesSelectedCard(EditCatchesUIHandler.MAIN_CARD);
Modified: trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/table/AbstractTuttiTableModel.java
===================================================================
--- trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/table/AbstractTuttiTableModel.java 2013-03-04 16:44:45 UTC (rev 528)
+++ trunk/tutti-ui-swing/src/main/java/fr/ifremer/tutti/ui/swing/util/table/AbstractTuttiTableModel.java 2013-03-04 16:57:44 UTC (rev 529)
@@ -10,15 +10,15 @@
* %%
* 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
+ * 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
+ *
+ * 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%
@@ -145,6 +145,7 @@
// can't accept a empty data list
Preconditions.checkNotNull(data, "Data list can not be null.");
+ this.rows = null;
if (createEmptyRowIsEmpty && data.isEmpty()) {
if (log.isInfoEnabled()) {
1
0
04 Mar '13
Author: tchemit
Date: 2013-03-04 17:44:45 +0100 (Mon, 04 Mar 2013)
New Revision: 528
Url: http://forge.codelutin.com/projects/tutti/repository/revisions/528
Log:
refs #2073: [TECH] Mise en place de la persistence des pi?\195?\168ces-jointes (remove Attachment#file)
Modified:
trunk/tutti-persistence/src/main/xmi/tutti-persistence.zargo
Modified: trunk/tutti-persistence/src/main/xmi/tutti-persistence.zargo
===================================================================
(Binary files differ)
1
0
r527 - trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/batch
by tchemit@users.forge.codelutin.com 04 Mar '13
by tchemit@users.forge.codelutin.com 04 Mar '13
04 Mar '13
Author: tchemit
Date: 2013-03-04 17:44:15 +0100 (Mon, 04 Mar 2013)
New Revision: 527
Url: http://forge.codelutin.com/projects/tutti/repository/revisions/527
Log:
benthos as warning in tree validation (for now)
Modified:
trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/batch/ScientificCruiseCatchBatchValidator.java
Modified: trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/batch/ScientificCruiseCatchBatchValidator.java
===================================================================
--- trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/batch/ScientificCruiseCatchBatchValidator.java 2013-03-04 15:26:13 UTC (rev 526)
+++ trunk/tutti-persistence/src/main/java/fr/ifremer/tutti/persistence/service/batch/ScientificCruiseCatchBatchValidator.java 2013-03-04 16:44:15 UTC (rev 527)
@@ -127,7 +127,7 @@
"pmfmId", enumeration.PMFM_ID_SORTING_TYPE,
enumeration.QUALITATIVE_ID_SORTING_TYPE_BENTHOS);
if (benthosBatch == null) {
- addError(errors, n_("tutti.persistence.batch.validation.vracBenthosNotFound"), null);
+ addWarning(errors, n_("tutti.persistence.batch.validation.vracBenthosNotFound"));
} else {
// Vrac > Benthos > Inert
SortingBatch inertBatch = catchBatchDao.getSortingBatch(benthosBatch.getChildBatchs(),
1
0