From: <de...@us...> - 2016-11-24 09:21:04
|
Revision: 9461 http://sourceforge.net/p/fudaa/svn/9461 Author: deniger Date: 2016-11-24 09:21:02 +0000 (Thu, 24 Nov 2016) Log Message: ----------- CRUE-706 Modified Paths: -------------- trunk/soft/fudaa-crue/ui-otfa/src/main/java/org/fudaa/fudaa/crue/otfa/service/OtfaService.java Modified: trunk/soft/fudaa-crue/ui-otfa/src/main/java/org/fudaa/fudaa/crue/otfa/service/OtfaService.java =================================================================== --- trunk/soft/fudaa-crue/ui-otfa/src/main/java/org/fudaa/fudaa/crue/otfa/service/OtfaService.java 2016-11-22 11:20:28 UTC (rev 9460) +++ trunk/soft/fudaa-crue/ui-otfa/src/main/java/org/fudaa/fudaa/crue/otfa/service/OtfaService.java 2016-11-24 09:21:02 UTC (rev 9461) @@ -1,7 +1,9 @@ package org.fudaa.fudaa.crue.otfa.service; +import java.awt.EventQueue; import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeListener; +import java.beans.PropertyVetoException; import java.io.File; import java.util.ArrayList; import java.util.List; @@ -21,6 +23,7 @@ import org.fudaa.fudaa.crue.options.services.ConfigurationManagerService; import org.fudaa.fudaa.crue.options.services.InstallationService; import org.fudaa.fudaa.crue.otfa.filter.OtfaFileFilter; +import org.fudaa.fudaa.crue.otfa.node.OtfaCampagneLineNode; import org.fudaa.fudaa.crue.otfa.node.OtfaCampagneNode; import org.fudaa.fudaa.crue.otfa.process.OpenOtfaCampagneProcess; import org.fudaa.fudaa.crue.otfa.process.OtfaCampagneContainer; @@ -28,8 +31,10 @@ import org.netbeans.swing.etable.ETableColumn; import org.netbeans.swing.etable.ETableColumnModel; import org.openide.NotifyDescriptor; +import org.openide.explorer.ExplorerManager; import org.openide.explorer.view.OutlineView; import org.openide.filesystems.FileChooserBuilder; +import org.openide.nodes.Node; import org.openide.util.Lookup; import org.openide.util.NbBundle; import org.openide.util.lookup.AbstractLookup; @@ -43,6 +48,30 @@ @ServiceProvider(service = OtfaService.class) public class OtfaService implements Lookup.Provider, PropertyChangeListener { + private static OtfaCampagneContainer createBlankCampagne() { + final OtfaCampagne campagne = new OtfaCampagne(); + final OtfaCampagne.OtfaRunOptions ref = new OtfaCampagne.OtfaRunOptions(); + + ref.setEffacerRunAvant(false); + ref.setEffacerRunApres(true); + + final OtfaCampagne.OtfaRunOptions cible = new OtfaCampagne.OtfaRunOptions(); + + cible.setEffacerRunAvant(true); + cible.setEffacerRunApres(false); + + campagne.setCommentaire(NbBundle.getMessage(OtfaService.class, "newCampaignComment")); + campagne.setAuteurCreation(null); + campagne.setDateCreation(null); + campagne.setAuteurModification(null); + campagne.setDateModification(null); + campagne.setReferenceOptions(ref); + campagne.setCibleOptions(cible); + campagne.setLines(new ArrayList<OtfaCampagneLine>()); + + return new OtfaCampagneContainer(campagne); + } + private InstanceContent dynamicContent = new InstanceContent(); private Lookup otfatLookup = new AbstractLookup(dynamicContent); ConfigurationManagerService configurationManagerService = Lookup.getDefault().lookup(ConfigurationManagerService.class); @@ -50,6 +79,7 @@ InstallationService installationService = Lookup.getDefault().lookup(InstallationService.class); private OutlineView view; + ExplorerManager explorerManager; public OutlineView getView() { return view; @@ -177,30 +207,6 @@ } } - private static OtfaCampagneContainer createBlankCampagne() { - final OtfaCampagne campagne = new OtfaCampagne(); - final OtfaCampagne.OtfaRunOptions ref = new OtfaCampagne.OtfaRunOptions(); - - ref.setEffacerRunAvant(false); - ref.setEffacerRunApres(true); - - final OtfaCampagne.OtfaRunOptions cible = new OtfaCampagne.OtfaRunOptions(); - - cible.setEffacerRunAvant(true); - cible.setEffacerRunApres(false); - - campagne.setCommentaire(NbBundle.getMessage(OtfaService.class, "newCampaignComment")); - campagne.setAuteurCreation(null); - campagne.setDateCreation(null); - campagne.setAuteurModification(null); - campagne.setDateModification(null); - campagne.setReferenceOptions(ref); - campagne.setCibleOptions(cible); - campagne.setLines(new ArrayList<OtfaCampagneLine>()); - - return new OtfaCampagneContainer(campagne); - } - private boolean needCrue9() { OtfaCampagne otfaCampagne = getCurrentOTFA().getOtfaCampagne(); List<OtfaCampagneLine> lines = otfaCampagne.getLines(); @@ -391,6 +397,21 @@ public void propertyChange(PropertyChangeEvent evt) { setModified(true); validate(false); + //pour maintenir la selection si on modifie une ligne de campagne. + //normalement les editeurs "inline" le font mais dans le cas des combobox, cette sélection est perdue. + if (evt.getSource() instanceof OtfaCampagneLineNode && explorerManager != null) { + final OtfaCampagneLineNode node = (OtfaCampagneLineNode) evt.getSource(); + EventQueue.invokeLater(new Runnable() { + @Override + public void run() { + try { + explorerManager.setSelectedNodes(new Node[]{node}); + } catch (PropertyVetoException propertyVetoException) { + //rien a faire ici. On ignore l'exception + } + } + }); + } } public void linesStructureChanged() { @@ -416,4 +437,13 @@ } return false; } + + /** + * Utiliser pour mettre à jour la selection après l'edition d'une ligne + * + * @param mgr + */ + public void setExplorerManager(ExplorerManager mgr) { + this.explorerManager = mgr; + } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |