Author: kmorin Date: 2014-05-08 12:22:45 +0200 (Thu, 08 May 2014) New Revision: 59 Url: http://forge.codelutin.com/projects/faxtomail/repository/revisions/59 Log: refs #4655 [ECRAN] D?\195?\169tail d'un mail / fax - affichage des demandes d'un m?\195?\170me groupe dans des onglets Added: trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/demande/DemandesUIModel.java Modified: trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/actions/SaveDemandeAndExitAction.java trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/MainUIHandler.java trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/attachment/AttachmentEditorUIHandler.java trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/demande/DemandeUI.css trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/demande/DemandeUI.jaxx trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/demande/DemandeUIHandler.java trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/demande/DemandeUIModel.java trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/demande/DemandesUI.css trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/demande/DemandesUI.jaxx trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/demande/DemandesUIHandler.java trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/demande/demandgroup/DemandGroupUI.css trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/demande/demandgroup/DemandGroupUI.jaxx trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/demande/demandgroup/DemandGroupUIHandler.java Modified: trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/actions/SaveDemandeAndExitAction.java =================================================================== --- trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/actions/SaveDemandeAndExitAction.java 2014-05-06 16:55:34 UTC (rev 58) +++ trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/actions/SaveDemandeAndExitAction.java 2014-05-08 10:22:45 UTC (rev 59) @@ -37,9 +37,15 @@ } @Override + public void doAction() throws Exception { + super.doAction(); + } + + @Override public void postSuccessAction() { super.postSuccessAction(); - getContext().setScreen(AbstractChangeScreenAction.PREVIOUS_SCREEN.getContextValue(handler.getUI())); + GoToPreviousScreenAction action = getContext().getActionFactory().createLogicAction(getContext().getMainUI().getHandler(), GoToPreviousScreenAction.class); + getActionEngine().runAction(action); } } Modified: trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/MainUIHandler.java =================================================================== --- trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/MainUIHandler.java 2014-05-06 16:55:34 UTC (rev 58) +++ trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/MainUIHandler.java 2014-05-08 10:22:45 UTC (rev 59) @@ -445,4 +445,8 @@ public void setBodyTitle(String title) { ui.getBody().setTitle(title); } + + public JComponent getCurrentBody() { + return currentBody; + } } Modified: trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/attachment/AttachmentEditorUIHandler.java =================================================================== --- trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/attachment/AttachmentEditorUIHandler.java 2014-05-06 16:55:34 UTC (rev 58) +++ trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/attachment/AttachmentEditorUIHandler.java 2014-05-08 10:22:45 UTC (rev 59) @@ -200,7 +200,7 @@ dialogContent.getModel().toEntity(attachment); } else { - Desktop desktop = FaxToMailUIUtil.getDesktopForBrowse(); + Desktop desktop = FaxToMailUIUtil.getDesktopForOpen(); try { // desktop.browse(file.toURI()); desktop.open(file); Modified: trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/demande/DemandeUI.css =================================================================== --- trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/demande/DemandeUI.css 2014-05-06 16:55:34 UTC (rev 58) +++ trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/demande/DemandeUI.css 2014-05-08 10:22:45 UTC (rev 59) @@ -315,47 +315,4 @@ #toolbarContainer { rightDecoration: { topToolBar }; -} - -#backButton { - text: "faxtomail.demande.back.button.label"; - actionIcon: cancel; - _applicationAction: { com.franciaflex.faxtomail.ui.swing.actions.GoToPreviousScreenAction.class }; -} - -#saveButton { - text: "faxtomail.demande.save.button.label"; - actionIcon: save; - enabled: { model.isEditable() }; - _applicationAction: { com.franciaflex.faxtomail.ui.swing.actions.SaveDemandeAndExitAction.class }; -} - -#transmitButton { - text: "faxtomail.demande.transmit.button.label"; - actionIcon: transmit; - enabled: { model.isValid() && model.isEditable() }; -} - -#printButton { - text: "faxtomail.demande.print.button.label"; - actionIcon: print; - enabled: { model.isValid() && model.isEditable() }; -} - -#archiveButton { - text: "faxtomail.demande.archive.button.label"; - enabled: { model.isEditable() }; - _applicationAction: { com.franciaflex.faxtomail.ui.swing.actions.ArchiveAction.class }; -} - -#replyButton { - text: "faxtomail.demande.reply.button.label"; - actionIcon: reply; - enabled: { model.isEditable() }; -} - -#groupButton { - text: "faxtomail.demande.group.button.label"; - actionIcon: group; - enabled: { model.isEditable() }; } \ No newline at end of file Modified: trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/demande/DemandeUI.jaxx =================================================================== --- trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/demande/DemandeUI.jaxx 2014-05-06 16:55:34 UTC (rev 58) +++ trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/demande/DemandeUI.jaxx 2014-05-08 10:22:45 UTC (rev 59) @@ -55,8 +55,9 @@ <script><![CDATA[ - public DemandeUI(FaxToMailUI parentUI) { + public DemandeUI(FaxToMailUI parentUI, DemandeUIModel demand) { FaxToMailUIUtil.setParentUI(this, parentUI); + setContextValue(demand); } ]]></script> @@ -325,15 +326,4 @@ </JSplitPane> - <JPanel layout='{new GridLayout(1,0)}' - constraints='BorderLayout.SOUTH'> - <JButton id="backButton"/> - <JButton id="saveButton"/> - <JButton id="transmitButton" onActionPerformed="handler.transmitDemande()"/> - <JButton id="printButton" onActionPerformed="handler.print()"/> - <JButton id="archiveButton"/> - <JButton id="replyButton" onActionPerformed="handler.reply()"/> - <JButton id="groupButton" onActionPerformed="handler.group()"/> - </JPanel> - </JPanel> Modified: trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/demande/DemandeUIHandler.java =================================================================== --- trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/demande/DemandeUIHandler.java 2014-05-06 16:55:34 UTC (rev 58) +++ trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/demande/DemandeUIHandler.java 2014-05-08 10:22:45 UTC (rev 59) @@ -45,6 +45,7 @@ import com.franciaflex.faxtomail.ui.swing.util.FaxToMailUIUtil; import com.franciaflex.faxtomail.ui.swing.content.attachment.AttachmentEditorUIModel; import jaxx.runtime.validator.swing.SwingValidator; +import org.apache.commons.beanutils.BeanUtils; import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -54,6 +55,7 @@ import org.jdesktop.swingx.decorator.HighlightPredicate; import org.jdesktop.swingx.table.DefaultTableColumnModelExt; import org.jdesktop.swingx.table.TableColumnModelExt; +import org.nuiton.jaxx.application.swing.tab.TabHandler; import org.nuiton.jaxx.application.swing.table.AbstractApplicationTableModel; import org.nuiton.jaxx.application.swing.table.MoveToNextEditableCellAction; import org.nuiton.jaxx.application.swing.table.MoveToNextEditableRowAction; @@ -71,6 +73,7 @@ import java.awt.event.KeyEvent; import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeListener; +import java.lang.reflect.InvocationTargetException; import java.util.ArrayList; import java.util.Collection; import java.util.Date; @@ -87,7 +90,7 @@ * @author tchemit <chemit@codelutin.com> * @since 0.1 */ -public class DemandeUIHandler extends AbstractFaxToMailUIHandler<DemandeUIModel, DemandeUI> implements CloseableUI { +public class DemandeUIHandler extends AbstractFaxToMailUIHandler<DemandeUIModel, DemandeUI> implements CloseableUI, TabHandler { /** Logger. */ private static final Log log = LogFactory.getLog(DemandeUIHandler.class); @@ -102,18 +105,15 @@ // private final PersistenceService persistenceService; @Override - public void beforeInit(DemandeUI ui) { + public void afterInit(DemandeUI ui) { - super.beforeInit(ui); + initUI(ui); - DemandeUIModel model = getContext().getCurrentEmail(); -// listModelIsModify(model); + DemandeUIModel model = getModel(); Set<String> propertiesToIgnore = getPropertiesToIgnore(); monitor = new BeanMonitor(true, propertiesToIgnore.toArray(new String[propertiesToIgnore.size()])); monitor.setBean(model); - this.ui.setContextValue(model); - model.addPropertyChangeListener(Email.PROPERTY_DEMAND_TYPE, new PropertyChangeListener() { private int dividerLocation = -1; @@ -124,7 +124,7 @@ DemandType oldType = (DemandType) evt.getOldValue(); if (newType != null && (oldType == null - || !Objects.equals(oldType.getRangeNeeded(), newType.getRangeNeeded()))) { + || !Objects.equals(oldType.getRangeNeeded(), newType.getRangeNeeded()))) { JSplitPane leftVerticalSplitPanel = getUI().getLeftVerticalSplitPanel(); if (Boolean.TRUE.equals(newType.getRangeNeeded())) { @@ -139,14 +139,7 @@ } } }); - } - @Override - public void afterInit(DemandeUI ui) { - - initUI(ui); - - DemandeUIModel model = getModel(); MailFolder folder = model.getMailFolder(); ReferentielService referentielService = getContext().getReferentielService(); @@ -367,6 +360,7 @@ } ); + listModelIsModify(getModel()); } @Override @@ -393,17 +387,18 @@ closeButtonPopups(); } - protected void closeButtonPopups() { + public void closeButtonPopups() { ui.getAttachmentsButton().setSelected(false); ui.getHistoryButton().setSelected(false); - ui.getGroupButton().setSelected(false); + ui.getDemandRepliesButton().setSelected(false); } @Override public boolean quitUI() { + BeanMonitor monitor = getMonitor(); boolean result = quitScreen( true, - getMonitor().wasModified(), + monitor.wasModified(), t("faxtomail.demande.askCancelEditBeforeLeaving.cancelSave"), t("faxtomail.demande.askSaveBeforeLeaving.save"), getContext().getActionFactory().createUIAction(this, SaveDemandeAction.class) @@ -433,74 +428,18 @@ return rangeRow.getRange() != null; } - public void transmitDemande() { + @Override + public boolean onHideTab(int currentIndex, int newIndex) { closeButtonPopups(); - - MailFolderChooserUI dialogContent = new MailFolderChooserUI(ui, getModel()); - SaveAndOpenDialogAction action = new SaveAndOpenDialogAction(this, - true, - dialogContent, - t("faxtomail.chooseMailFolder.title"), - new Dimension(350, 500)); - - getContext().getActionFactory().createUIAction(null, action).actionPerformed(null); + return true; } - public void print() { - closeButtonPopups(); - -// for (Attachment attachment : getModel().getAttachment()) { -//// try { -// File editedFile = attachment.getEditedFile(); -// if (editedFile == null) { -// editedFile = attachment.getOriginalFile(); -// } -// log.info("print " + editedFile.getAbsolutePath()); -//// Desktop.getDesktop().print(editedFile); -// -// -//// } catch (IOException e) { -//// if (log.isErrorEnabled()) { -//// log.error("", e); -//// } -//// } -// } - AttachmentToPrintChooserUI dialogContent = new AttachmentToPrintChooserUI(ui, getModel()); - SaveAndOpenDialogAction action = new SaveAndOpenDialogAction(this, - true, - dialogContent, - t("faxtomail.chooseAttachmentToPrint.title"), - new Dimension(350, 500)); - - getContext().getActionFactory().createUIAction(null, action).actionPerformed(null); + @Override + public void onShowTab(int currentIndex, int newIndex) { } - public void reply() { - closeButtonPopups(); - - ReplyFormUI dialogContent = new ReplyFormUI(ui); - ReplyFormUIModel model = dialogContent.getModel(); - model.setTo(getModel().getSender()); - SaveAndOpenDialogAction action = new SaveAndOpenDialogAction(this, - false, - dialogContent, - t("faxtomail.reply.title", getModel().getObject()), - new Dimension(800, 600)); - - getContext().getActionFactory().createUIAction(null, action).actionPerformed(null); + @Override + public boolean onRemoveTab() { + return quitUI(); } - - public void group() { - closeButtonPopups(); - - SearchToGroupUI dialogContent = new SearchToGroupUI(ui); - SaveAndOpenDialogAction action = new SaveAndOpenDialogAction(this, - false, - dialogContent, - t("faxtomail.searchToGroup.title", getModel().getObject()), - getContext().getMainUI().getSize()); - - getContext().getActionFactory().createUIAction(null, action).actionPerformed(null); - } - } Modified: trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/demande/DemandeUIModel.java =================================================================== --- trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/demande/DemandeUIModel.java 2014-05-06 16:55:34 UTC (rev 58) +++ trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/demande/DemandeUIModel.java 2014-05-08 10:22:45 UTC (rev 59) @@ -126,7 +126,7 @@ protected List<String> ccRecipients; -// protected List<String> sender; + protected boolean closeable; protected static Binder<DemandeUIModel, Email> toBeanBinder = BinderFactory.newBinder(DemandeUIModel.class, @@ -643,7 +643,7 @@ public void setComment(String comment) { Object oldValue = getComment(); editObject.setComment(comment); - firePropertyChange(Email.PROPERTY_COMMENT, oldValue, editable); + firePropertyChange(Email.PROPERTY_COMMENT, oldValue, comment); } public String getComment() { @@ -813,4 +813,13 @@ public String getIcon() { return "email"; } + + @Override + public boolean isCloseable() { + return closeable; + } + + public void setCloseable(boolean closeable) { + this.closeable = closeable; + } } Modified: trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/demande/DemandesUI.css =================================================================== --- trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/demande/DemandesUI.css 2014-05-06 16:55:34 UTC (rev 58) +++ trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/demande/DemandesUI.css 2014-05-08 10:22:45 UTC (rev 59) @@ -2,4 +2,45 @@ floatable: false; opaque: false; borderPainted: false; +} + +#backButton { + text: "faxtomail.demande.back.button.label"; + actionIcon: cancel; + _applicationAction: { com.franciaflex.faxtomail.ui.swing.actions.GoToPreviousScreenAction.class }; +} + +#saveButton { + text: "faxtomail.demande.save.button.label"; + actionIcon: save; + enabled: { model.getCurrentDemand().isEditable() }; +} + +#transmitButton { + text: "faxtomail.demande.transmit.button.label"; + actionIcon: transmit; + enabled: { model.getCurrentDemand().isValid() && model.getCurrentDemand().isEditable() }; +} + +#printButton { + text: "faxtomail.demande.print.button.label"; + actionIcon: print; + enabled: { model.getCurrentDemand().isValid() && model.getCurrentDemand().isEditable() }; +} + +#archiveButton { + text: "faxtomail.demande.archive.button.label"; + enabled: { model.getCurrentDemand().isEditable() }; +} + +#replyButton { + text: "faxtomail.demande.reply.button.label"; + actionIcon: reply; + enabled: { model.getCurrentDemand().isEditable() }; +} + +#groupButton { + text: "faxtomail.demande.group.button.label"; + actionIcon: group; + enabled: { model.getCurrentDemand().isEditable() }; } \ No newline at end of file Modified: trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/demande/DemandesUI.jaxx =================================================================== --- trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/demande/DemandesUI.jaxx 2014-05-06 16:55:34 UTC (rev 58) +++ trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/demande/DemandesUI.jaxx 2014-05-08 10:22:45 UTC (rev 59) @@ -1,5 +1,5 @@ <JPanel id='demandsPanel' layout="{ new BorderLayout() }" - implements='com.franciaflex.faxtomail.ui.swing.util.FaxToMailUI<DemandeUIModel, DemandesUIHandler>'> + implements='com.franciaflex.faxtomail.ui.swing.util.FaxToMailUI<DemandesUIModel, DemandesUIHandler>'> <import> com.franciaflex.faxtomail.ui.swing.FaxToMailUIContext @@ -16,19 +16,28 @@ ]]></script> + <DemandesUIModel id='model' + initializer='getContextValue(DemandesUIModel.class)'/> - <DemandeUIModel id='model' - initializer='getContextValue(DemandeUIModel.class)'/> - - <JToolBar id='topToolBar'> <ButtonEmailGroup id="demandGroupButton"/> </JToolBar> <JTabbedPane id="demandsTabPane" constraints="BorderLayout.CENTER"> - <tab id="mainDemandTab"> - <DemandeUI id="mainDemand" constructorParams="this"/> - </tab> + <!--<tab id="mainDemandTab">--> + <!--<DemandeUI id="mainDemand" constructorParams="this"/>--> + <!--</tab>--> </JTabbedPane> + <JPanel layout='{new GridLayout(1,0)}' + constraints='BorderLayout.SOUTH'> + <JButton id="backButton"/> + <JButton id="saveButton" onActionPerformed="handler.save()"/> + <JButton id="transmitButton" onActionPerformed="handler.transmitDemande()"/> + <JButton id="printButton" onActionPerformed="handler.print()"/> + <JButton id="archiveButton" onActionPerformed="handler.archive()"/> + <JButton id="replyButton" onActionPerformed="handler.reply()"/> + <JButton id="groupButton" onActionPerformed="handler.group()"/> + </JPanel> + </JPanel> \ No newline at end of file Modified: trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/demande/DemandesUIHandler.java =================================================================== --- trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/demande/DemandesUIHandler.java 2014-05-06 16:55:34 UTC (rev 58) +++ trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/demande/DemandesUIHandler.java 2014-05-08 10:22:45 UTC (rev 59) @@ -2,7 +2,17 @@ import com.franciaflex.faxtomail.persistence.entities.DemandType; import com.franciaflex.faxtomail.persistence.entities.Email; +import com.franciaflex.faxtomail.ui.swing.actions.ArchiveAction; +import com.franciaflex.faxtomail.ui.swing.actions.GoToPreviousScreenAction; +import com.franciaflex.faxtomail.ui.swing.actions.SaveAndOpenDialogAction; +import com.franciaflex.faxtomail.ui.swing.actions.SaveDemandeAndExitAction; +import com.franciaflex.faxtomail.ui.swing.content.print.AttachmentToPrintChooserUI; +import com.franciaflex.faxtomail.ui.swing.content.reply.ReplyFormUI; +import com.franciaflex.faxtomail.ui.swing.content.reply.ReplyFormUIModel; +import com.franciaflex.faxtomail.ui.swing.content.search.SearchToGroupUI; +import com.franciaflex.faxtomail.ui.swing.content.transmit.MailFolderChooserUI; import com.franciaflex.faxtomail.ui.swing.util.AbstractFaxToMailUIHandler; +import com.franciaflex.faxtomail.ui.swing.util.CloseableUI; import jaxx.runtime.validator.swing.SwingValidator; import org.nuiton.jaxx.application.swing.tab.DelegateTabContainerHandler; import org.nuiton.jaxx.application.swing.tab.TabContainerHandler; @@ -11,16 +21,19 @@ import org.nuiton.util.beans.BeanMonitor; import javax.swing.*; +import java.awt.*; import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeListener; import java.util.Objects; import java.util.Set; +import static org.nuiton.i18n.I18n.t; + /** * @author Kevin Morin (Code Lutin) * @since x.x */ -public class DemandesUIHandler extends AbstractFaxToMailUIHandler<DemandeUIModel, DemandesUI> implements TabContainerHandler { +public class DemandesUIHandler extends AbstractFaxToMailUIHandler<DemandesUIModel, DemandesUI> implements TabContainerHandler, CloseableUI { protected DelegateTabContainerHandler delegateTabHandler; @@ -29,7 +42,12 @@ super.beforeInit(ui); - DemandeUIModel model = getContext().getCurrentEmail(); + DemandeUIModel currentEmail = getContext().getCurrentEmail(); + currentEmail.setCloseable(false); + + DemandesUIModel model = new DemandesUIModel(); +// model.addDemand(currentEmail); + this.ui.setContextValue(model); } @@ -37,15 +55,58 @@ public void afterInit(DemandesUI demandesUI) { initUI(ui); - setCustomTab(0, getModel()); + DemandesUIModel model = getModel(); +// setCustomTab(0, getModel().getDemands().get(0)); + model.addDemandsListener(new DemandesUIModel.DemandsListener() { + @Override + public void onDemandAdded(DemandeUIModel demand, int index, boolean added) { + + JTabbedPane tabPanel = getTabPanel(); + if (added) { + DemandeUI demandeUI = new DemandeUI(getUI(), demand); + tabPanel.add(demandeUI); + setCustomTab(index, demand); + } + + tabPanel.setSelectedIndex(index); + } + + @Override + public void onDemandRemoved(DemandeUIModel demand, int index) { + } + }); + + DemandeUIModel currentEmail = getContext().getCurrentEmail(); + model.addDemand(currentEmail); } @Override + public boolean quitUI() { + closeButtonPopups(); + JTabbedPane tabPanel = getTabPanel(); + int tabCount = tabPanel.getTabCount(); + boolean quit = true; + int i = 0; + while (quit && i < tabCount) { + tabPanel.setSelectedIndex(i); + DemandeUIHandler tabHandler = (DemandeUIHandler) getTabHandler(i++); + quit = tabHandler.quitUI(); + } + return quit; + } + + @Override public void onCloseUI() { + closeButtonPopups(); + int tabCount = getTabPanel().getTabCount(); + for (int i = 0 ; i < tabCount ; i++) { + DemandeUIHandler tabHandler = (DemandeUIHandler) getTabHandler(i); + tabHandler.onCloseUI(); + } } @Override - public SwingValidator<DemandeUIModel> getValidator() { + public SwingValidator<DemandesUIModel> getValidator() { return null; } @@ -74,10 +135,20 @@ } @Override + public boolean removeTab(int i) { + boolean remove = delegateTabHandler.removeTab(i); + if (remove) { + getModel().removeDemand(i); + } + return remove; + } + + @Override protected void initUI(DemandesUI ui) { super.initUI(ui); - delegateTabHandler = new DelegateTabContainerHandler(getTabPanel()); + JTabbedPane tabPanel = getTabPanel(); + delegateTabHandler = new DelegateTabContainerHandler(tabPanel, this); delegateTabHandler.init(); } @@ -93,7 +164,107 @@ @Override public boolean onTabChanged(int currentIndex, int newIndex) { - return delegateTabHandler.onTabChanged(currentIndex, newIndex); + boolean change = delegateTabHandler.onTabChanged(currentIndex, newIndex); + if (change) { + getModel().setCurrentIndex(newIndex); + } + return change; } + protected void closeButtonPopups() { + DemandeUI demandeUI = (DemandeUI) getTabPanel().getSelectedComponent(); + demandeUI.getHandler().closeButtonPopups(); + ui.getDemandGroupButton().setSelected(false); + } + + public void save() { + closeButtonPopups(); + DemandeUI demandeUI = (DemandeUI) getTabPanel().getSelectedComponent(); + SaveDemandeAndExitAction action = new SaveDemandeAndExitAction(demandeUI.getHandler()); + getContext().getActionFactory().createUIAction(null, action).actionPerformed(null); + } + + public void transmitDemande() { + closeButtonPopups(); + + DemandeUI demandeUI = (DemandeUI) getTabPanel().getSelectedComponent(); + MailFolderChooserUI dialogContent = new MailFolderChooserUI(ui, demandeUI.getModel()); + SaveAndOpenDialogAction action = new SaveAndOpenDialogAction(demandeUI.getHandler(), + true, + dialogContent, + t("faxtomail.chooseMailFolder.title"), + new Dimension(350, 500)); + + getContext().getActionFactory().createUIAction(null, action).actionPerformed(null); + } + + public void print() { + closeButtonPopups(); + +// for (Attachment attachment : getModel().getAttachment()) { +//// try { +// File editedFile = attachment.getEditedFile(); +// if (editedFile == null) { +// editedFile = attachment.getOriginalFile(); +// } +// log.info("print " + editedFile.getAbsolutePath()); +//// Desktop.getDesktop().print(editedFile); +// +// +//// } catch (IOException e) { +//// if (log.isErrorEnabled()) { +//// log.error("", e); +//// } +//// } +// } + + DemandeUI demandeUI = (DemandeUI) getTabPanel().getSelectedComponent(); + AttachmentToPrintChooserUI dialogContent = new AttachmentToPrintChooserUI(ui, demandeUI.getModel()); + SaveAndOpenDialogAction action = new SaveAndOpenDialogAction(demandeUI.getHandler(), + true, + dialogContent, + t("faxtomail.chooseAttachmentToPrint.title"), + new Dimension(350, 500)); + + getContext().getActionFactory().createUIAction(null, action).actionPerformed(null); + } + + public void archive() { + closeButtonPopups(); + DemandeUI demandeUI = (DemandeUI) getTabPanel().getSelectedComponent(); + ArchiveAction action = new ArchiveAction(demandeUI.getHandler()); + getContext().getActionFactory().createUIAction(null, action).actionPerformed(null); + } + + public void reply() { + closeButtonPopups(); + + ReplyFormUI dialogContent = new ReplyFormUI(ui); + ReplyFormUIModel model = dialogContent.getModel(); + + DemandeUI demandeUI = (DemandeUI) getTabPanel().getSelectedComponent(); + model.setTo(demandeUI.getModel().getSender()); + SaveAndOpenDialogAction action = new SaveAndOpenDialogAction(demandeUI.getHandler(), + false, + dialogContent, + t("faxtomail.reply.title", demandeUI.getModel().getObject()), + new Dimension(800, 600)); + + getContext().getActionFactory().createUIAction(null, action).actionPerformed(null); + } + + public void group() { + closeButtonPopups(); + + SearchToGroupUI dialogContent = new SearchToGroupUI(ui); + DemandeUI demandeUI = (DemandeUI) getTabPanel().getSelectedComponent(); + SaveAndOpenDialogAction action = new SaveAndOpenDialogAction(demandeUI.getHandler(), + false, + dialogContent, + t("faxtomail.searchToGroup.title", demandeUI.getModel().getObject()), + getContext().getMainUI().getSize()); + + getContext().getActionFactory().createUIAction(null, action).actionPerformed(null); + } + } Added: trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/demande/DemandesUIModel.java =================================================================== --- trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/demande/DemandesUIModel.java (rev 0) +++ trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/demande/DemandesUIModel.java 2014-05-08 10:22:45 UTC (rev 59) @@ -0,0 +1,94 @@ +package com.franciaflex.faxtomail.ui.swing.content.demande; + +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.jdesktop.beans.AbstractBean; + +import java.util.ArrayList; +import java.util.HashSet; +import java.util.LinkedHashSet; +import java.util.List; +import java.util.Set; + +/** + * @author Kevin Morin (Code Lutin) + * @since x.x + */ +public class DemandesUIModel extends AbstractBean { + + private static final Log log = LogFactory.getLog(DemandesUIModel.class); + + public static final String PROPERTY_CURRENT_DEMAND = "currentDemand"; + + protected List<DemandeUIModel> demands = new ArrayList<DemandeUIModel>(); + + protected List<DemandsListener> listeners = new ArrayList<DemandsListener>(); + + protected List<DemandeUIModel> getDemands() { + return demands; + } + + protected int currentIndex = -1; + + public void addDemand(DemandeUIModel demand) { + boolean added = !demands.contains(demand); + if (added) { + demands.add(demand); + } + int index = demands.indexOf(demand); + fireDemandAdded(demand, index, added); + } + + public void removeDemand(int i) { + DemandeUIModel demand = demands.get(i); + demands.remove(i); + fireDemandRemoved(demand, i); + } + + public void addDemandsListener(DemandsListener listener) { + listeners.add(listener); + } + + public void removeDemandsListener(DemandsListener listener) { + listeners.remove(listener); + } + + protected void fireDemandAdded(DemandeUIModel demand, int index, boolean added) { + for (DemandsListener listener : listeners) { + listener.onDemandAdded(demand, index, added); + } + } + + protected void fireDemandRemoved(DemandeUIModel demand, int index) { + for (DemandsListener listener : listeners) { + listener.onDemandRemoved(demand, index); + } + } + + public static interface DemandsListener { + + void onDemandAdded(DemandeUIModel demand, int index, boolean added); + + void onDemandRemoved(DemandeUIModel demand, int index); + + } + + public DemandeUIModel getCurrentDemand() { + int currentIndex = getCurrentIndex(); + if (currentIndex < 0 || currentIndex >= demands.size()) { + return null; + } + return demands.get(currentIndex); + } + + public int getCurrentIndex() { + return currentIndex; + } + + public void setCurrentIndex(int currentIndex) { + Object oldValue = getCurrentDemand(); + this.currentIndex = currentIndex; + Object newValue = getCurrentDemand(); + firePropertyChange(PROPERTY_CURRENT_DEMAND, oldValue, newValue); + } +} Modified: trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/demande/demandgroup/DemandGroupUI.css =================================================================== --- trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/demande/demandgroup/DemandGroupUI.css 2014-05-06 16:55:34 UTC (rev 58) +++ trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/demande/demandgroup/DemandGroupUI.css 2014-05-08 10:22:45 UTC (rev 59) @@ -29,14 +29,6 @@ title: "faxtomail.demandGroup.title"; } -#noGroupedDemandLabel { - text: "faxtomail.demandGroup.empty"; - visible: { model.getGroupedDemandes().isEmpty() }; - border: { javax.swing.BorderFactory.createEmptyBorder(3, 3, 3, 3) }; - font-style: italic; -} - #demandGroup { editable: true; - visible: { !model.getGroupedDemandes().isEmpty() }; } Modified: trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/demande/demandgroup/DemandGroupUI.jaxx =================================================================== --- trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/demande/demandgroup/DemandGroupUI.jaxx 2014-05-06 16:55:34 UTC (rev 58) +++ trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/demande/demandgroup/DemandGroupUI.jaxx 2014-05-08 10:22:45 UTC (rev 59) @@ -38,7 +38,6 @@ <JXTitledPanel id='body'> <JScrollPane id='demandGroupBodyScrollPane'> <JPanel id='mainPanel' layout="{new BorderLayout()}"> - <JLabel id='noGroupedDemandLabel' constraints="BorderLayout.NORTH"/> <JXTable id='demandGroup' constraints="BorderLayout.CENTER"/> </JPanel> </JScrollPane> Modified: trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/demande/demandgroup/DemandGroupUIHandler.java =================================================================== --- trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/demande/demandgroup/DemandGroupUIHandler.java 2014-05-06 16:55:34 UTC (rev 58) +++ trunk/faxtomail-ui-swing/src/main/java/com/franciaflex/faxtomail/ui/swing/content/demande/demandgroup/DemandGroupUIHandler.java 2014-05-08 10:22:45 UTC (rev 59) @@ -26,7 +26,10 @@ import com.franciaflex.faxtomail.ui.swing.FaxToMailUIContext; import com.franciaflex.faxtomail.ui.swing.actions.ShowDemandeAction; +import com.franciaflex.faxtomail.ui.swing.content.MainUI; +import com.franciaflex.faxtomail.ui.swing.content.MainUIHandler; import com.franciaflex.faxtomail.ui.swing.content.demande.DemandeUIModel; +import com.franciaflex.faxtomail.ui.swing.content.demande.DemandesUI; import com.franciaflex.faxtomail.ui.swing.util.AbstractToolbarPopupHandler; import com.google.common.collect.Iterables; import jaxx.runtime.validator.swing.SwingValidator; @@ -143,8 +146,12 @@ closeEditor(); FaxToMailUIContext context = getContext(); - context.setCurrentEmail(demande); - context.getActionEngine().runAction(new ShowDemandeAction(context.getMainUI().getHandler())); + demande.setCloseable(true); +// context.setCurrentEmail(demande); +// context.getActionEngine().runAction(new ShowDemandeAction(context.getMainUI().getHandler())); + MainUIHandler mainUIHandler = context.getMainUI().getHandler(); + DemandesUI parentContainer = (DemandesUI) mainUIHandler.getCurrentBody(); + parentContainer.getModel().addDemand(demande); } protected class DemandGroupItemRenderer extends DemandGroupItem