|
From: <de...@us...> - 2012-07-17 14:37:38
|
Revision: 7502
http://fudaa.svn.sourceforge.net/fudaa/?rev=7502&view=rev
Author: deniger
Date: 2012-07-17 14:37:26 +0000 (Tue, 17 Jul 2012)
Log Message:
-----------
Support edition branche et changement de type
Modified Paths:
--------------
trunk/soft/fudaa-crue/crue-server/src/main/java/org/fudaa/dodico/crue/metier/emh/DonCalcSansPrtBranchePdc.java
trunk/soft/fudaa-crue/ui-common/src/main/java/org/fudaa/fudaa/crue/common/view/DefaultOutlineViewEditor.java
trunk/soft/fudaa-crue/ui-modelling/src/main/java/org/fudaa/fudaa/crue/modelling/emh/ElemSeuilAduNode.java
trunk/soft/fudaa-crue/ui-modelling/src/main/java/org/fudaa/fudaa/crue/modelling/emh/ModellingEMHBrancheBarrageFilEauPanel.java
trunk/soft/fudaa-crue/ui-modelling/src/main/java/org/fudaa/fudaa/crue/modelling/emh/ModellingEMHBrancheBarrageGeneriquePanel.java
trunk/soft/fudaa-crue/ui-modelling/src/main/java/org/fudaa/fudaa/crue/modelling/emh/ModellingEMHBrancheSeuilTransversalPanel.java
Modified: trunk/soft/fudaa-crue/crue-server/src/main/java/org/fudaa/dodico/crue/metier/emh/DonCalcSansPrtBranchePdc.java
===================================================================
--- trunk/soft/fudaa-crue/crue-server/src/main/java/org/fudaa/dodico/crue/metier/emh/DonCalcSansPrtBranchePdc.java 2012-07-16 21:57:21 UTC (rev 7501)
+++ trunk/soft/fudaa-crue/crue-server/src/main/java/org/fudaa/dodico/crue/metier/emh/DonCalcSansPrtBranchePdc.java 2012-07-17 14:37:26 UTC (rev 7502)
@@ -1,28 +1,38 @@
-/***********************************************************************
- * Module: DonCalcSansPrtBranchePdc.java
- * Author: deniger
- * Purpose: Defines the Class DonCalcSansPrtBranchePdc
- ***********************************************************************/
-
+/**
+ * *********************************************************************
+ * Module: DonCalcSansPrtBranchePdc.java Author: deniger Purpose: Defines the Class DonCalcSansPrtBranchePdc
+ **********************************************************************
+ */
package org.fudaa.dodico.crue.metier.emh;
+import java.util.Collection;
+
/**
* Pour les branches type 1 Crue9
- *
+ *
* @pdOid d52cbe5d-73d9-423c-990f-e6ab61d710cc
*/
public class DonCalcSansPrtBranchePdc extends DonCalcSansPrt {
- /** @pdOid d2caaf75-5d42-421e-ad3a-ba495b6d3daa */
+
+ /**
+ * @pdOid d2caaf75-5d42-421e-ad3a-ba495b6d3daa
+ */
private LoiFF pdc;
- /** @pdOid 2043fea9-8823-4e85-a3d7-6570a09f74cb */
+ /**
+ * @pdOid 2043fea9-8823-4e85-a3d7-6570a09f74cb
+ */
public LoiFF getPdc() {
return pdc;
}
+ @Override
+ public void fillWithLoi(Collection<Loi> target) {
+ target.add(pdc);
+ }
+
/**
- * @param newPdc
- * @pdOid c5c4c95f-d374-44e7-8e65-cbaa5ebcfa1c
+ * @param newPdc @pdOid c5c4c95f-d374-44e7-8e65-cbaa5ebcfa1c
*/
public void setPdc(final LoiFF newPdc) {
if (this.pdc != null) {
@@ -32,5 +42,4 @@
pdc = newPdc;
this.pdc.register(this);
}
-
}
\ No newline at end of file
Modified: trunk/soft/fudaa-crue/ui-common/src/main/java/org/fudaa/fudaa/crue/common/view/DefaultOutlineViewEditor.java
===================================================================
--- trunk/soft/fudaa-crue/ui-common/src/main/java/org/fudaa/fudaa/crue/common/view/DefaultOutlineViewEditor.java 2012-07-16 21:57:21 UTC (rev 7501)
+++ trunk/soft/fudaa-crue/ui-common/src/main/java/org/fudaa/fudaa/crue/common/view/DefaultOutlineViewEditor.java 2012-07-17 14:37:26 UTC (rev 7502)
@@ -9,10 +9,13 @@
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyEvent;
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
import javax.swing.*;
import org.openide.explorer.ExplorerManager;
import org.openide.explorer.ExplorerUtils;
import org.openide.explorer.view.OutlineView;
+import org.openide.nodes.*;
import org.openide.util.Lookup;
import org.openide.util.NbBundle;
@@ -21,30 +24,122 @@
* @author Frédéric Deniger
*/
public abstract class DefaultOutlineViewEditor extends JPanel implements ExplorerManager.Provider, Lookup.Provider {
-
+
protected OutlineView view;
private ExplorerManager em = new ExplorerManager();
JButton btAdd;
JButton btPaste;
private Lookup lookup;
-
+ ExplorerManagerChangeListener explorerManagerChangeListener = new ExplorerManagerChangeListener();
+ CustomNodeListener customNodeListener = new CustomNodeListener();
+ CustomPropertyChangeListener customPropertyChangeListener = new CustomPropertyChangeListener();
+
+ public DefaultOutlineViewEditor() {
+ super(new BorderLayout(5, 5));
+ initView();
+ em.addPropertyChangeListener(explorerManagerChangeListener);
+ }
+
+ private class ExplorerManagerChangeListener implements PropertyChangeListener {
+
+ @Override
+ public void propertyChange(PropertyChangeEvent evt) {
+ if (ExplorerManager.PROP_ROOT_CONTEXT.equals(evt.getPropertyName())) {
+ explorerChanged((Node) evt.getOldValue());
+ }
+ }
+ }
+
+ private class CustomPropertyChangeListener implements PropertyChangeListener {
+
+ @Override
+ public void propertyChange(PropertyChangeEvent evt) {
+ changeInNode();
+ }
+ }
+
+ private class CustomNodeListener implements NodeListener {
+
+ @Override
+ public void childrenAdded(NodeMemberEvent nme) {
+ Node[] delta = nme.getDelta();
+ for (Node node : delta) {
+ removeListener(node);
+ installListener(node);
+ }
+ changeInNode();
+ }
+
+ @Override
+ public void childrenRemoved(NodeMemberEvent nme) {
+ Node[] delta = nme.getDelta();
+ for (Node node : delta) {
+ removeListener(node);
+ }
+ changeInNode();
+ }
+
+ @Override
+ public void childrenReordered(NodeReorderEvent nre) {
+ changeInNode();
+ }
+
+ @Override
+ public void nodeDestroyed(NodeEvent ne) {
+ changeInNode();
+ removeListener(ne.getNode());
+ }
+
+ @Override
+ public void propertyChange(PropertyChangeEvent evt) {
+ changeInNode();
+ }
+ }
+
+ protected void explorerChanged(Node old) {
+ if (old != null) {
+ removeListener(old);
+ }
+ changeInNode();
+ em.getRootContext().addNodeListener(customNodeListener);
+ installListener(em.getRootContext());
+ }
+
+ protected void installListener(Node parentNode) {
+ parentNode.removePropertyChangeListener(customPropertyChangeListener);
+ parentNode.removeNodeListener(customNodeListener);
+ parentNode.addPropertyChangeListener(customPropertyChangeListener);
+ parentNode.addNodeListener(customNodeListener);
+ Node[] nodes = parentNode.getChildren().getNodes();
+ for (Node node : nodes) {
+ installListener(node);
+ }
+ }
+
+ protected void removeListener(Node parentNode) {
+ parentNode.removePropertyChangeListener(customPropertyChangeListener);
+ parentNode.removeNodeListener(customNodeListener);
+ Node[] nodes = parentNode.getChildren().getNodes();
+ for (Node node : nodes) {
+ removeListener(node);
+ }
+ }
+
+ protected void changeInNode() {
+ }
+
@Override
public Lookup getLookup() {
return lookup;
}
-
+
@Override
public ExplorerManager getExplorerManager() {
return em;
}
-
- public DefaultOutlineViewEditor() {
- super(new BorderLayout(5, 5));
- initView();
- }
-
+
protected abstract void addElement();
-
+
protected void initActions() {
ActionMap map = this.getActionMap();
final Action actionDelete = ExplorerUtils.actionDelete(em, false);
@@ -55,11 +150,11 @@
addRemove.setBorder(BorderFactory.createEmptyBorder(0, 3, 0, 3));
btAdd = new JButton(NbBundle.getMessage(DefaultOutlineViewEditor.class, "Add.Name"));
btAdd.addActionListener(new ActionListener() {
-
+
@Override
public void actionPerformed(ActionEvent e) {
addElement();
-
+
}
});
addRemove.add(btAdd);
@@ -76,20 +171,20 @@
ExplorerUtils.activateActions(em, true);
view.setNodePopupFactory(new CustomNodePopupFactory());
}
-
+
protected JButton createPastComponent() {
return null;
}
-
+
protected abstract void createOutlineView();
-
+
private void initView() {
createOutlineView();
add(view);
initActions();
}
protected boolean editable;
-
+
public void setEditable(boolean editable) {
this.editable = editable;
btAdd.setEnabled(editable);
Modified: trunk/soft/fudaa-crue/ui-modelling/src/main/java/org/fudaa/fudaa/crue/modelling/emh/ElemSeuilAduNode.java
===================================================================
--- trunk/soft/fudaa-crue/ui-modelling/src/main/java/org/fudaa/fudaa/crue/modelling/emh/ElemSeuilAduNode.java 2012-07-16 21:57:21 UTC (rev 7501)
+++ trunk/soft/fudaa-crue/ui-modelling/src/main/java/org/fudaa/fudaa/crue/modelling/emh/ElemSeuilAduNode.java 2012-07-17 14:37:26 UTC (rev 7502)
@@ -7,6 +7,7 @@
import java.util.MissingResourceException;
import org.fudaa.dodico.crue.config.CrueConfigMetier;
import org.fudaa.dodico.crue.metier.emh.ElemSeuil;
+import org.fudaa.fudaa.crue.common.property.PropertyCrueUtils;
import org.fudaa.fudaa.crue.common.property.PropertyStringReadOnly;
import org.fudaa.fudaa.crue.modelling.perspective.PerspectiveServiceModelling;
import org.openide.nodes.Sheet;
@@ -30,6 +31,7 @@
Sheet res = super.createSheet();
Set set = res.get(Sheet.PROPERTIES);
PropertyStringReadOnly readOnly = new PropertyStringReadOnly("1", PROP_ADU, getAduDisplayName(), null);
+ PropertyCrueUtils.configureNoCustomEditor(readOnly);
set.put(readOnly);
return res;
Modified: trunk/soft/fudaa-crue/ui-modelling/src/main/java/org/fudaa/fudaa/crue/modelling/emh/ModellingEMHBrancheBarrageFilEauPanel.java
===================================================================
--- trunk/soft/fudaa-crue/ui-modelling/src/main/java/org/fudaa/fudaa/crue/modelling/emh/ModellingEMHBrancheBarrageFilEauPanel.java 2012-07-16 21:57:21 UTC (rev 7501)
+++ trunk/soft/fudaa-crue/ui-modelling/src/main/java/org/fudaa/fudaa/crue/modelling/emh/ModellingEMHBrancheBarrageFilEauPanel.java 2012-07-17 14:37:26 UTC (rev 7502)
@@ -30,6 +30,7 @@
import org.fudaa.fudaa.crue.common.view.NodeEditionHelper;
import org.fudaa.fudaa.crue.common.view.PropertyEditorPanel;
import org.fudaa.fudaa.crue.modelling.perspective.PerspectiveServiceModelling;
+import org.openide.explorer.ExplorerManager;
import org.openide.explorer.view.OutlineView;
import org.openide.nodes.Children;
import org.openide.nodes.Node;
@@ -42,7 +43,7 @@
* @author fred
*/
public class ModellingEMHBrancheBarrageFilEauPanel extends JPanel implements ModellingEMHBrancheSpecificEditor, Observer {
-
+
ModellingScenarioService modellingScenarioService = Lookup.getDefault().lookup(
ModellingScenarioService.class);
PerspectiveServiceModelling perspectiveServiceModelling = Lookup.getDefault().lookup(PerspectiveServiceModelling.class);
@@ -50,7 +51,7 @@
List<PropertyEditorPanel> properties;
JComboBox cbSectionPilote;
SeuilView seuilView;
-
+
ModellingEMHBrancheBarrageFilEauPanel(CatEMHBranche branche, ModellingEMHBrancheTopComponent parent) {
super(new BorderLayout(5, 15));
this.parent = parent;
@@ -63,16 +64,21 @@
createTopPanel(branche, dcsp);
add(seuilView);
}
-
+
+ @Override
+ public ExplorerManager getExplorerManager() {
+ return null;
+ }
+
private void createTopPanel(CatEMHBranche branche, DonCalcSansPrtBrancheBarrageFilEau dcsp) throws MissingResourceException {
JPanel top = new JPanel(new BuGridLayout(4, 10, 10));
add(top, BorderLayout.NORTH);
-
+
properties = PropertyEditorPanel.create(dcsp, getCcm(), DonCalcSansPrtBrancheNiveauxAssocies.PROP_QLIMINF,
DonCalcSansPrtBrancheNiveauxAssocies.PROP_QLIMSUP);
for (PropertyEditorPanel propertyEditorPanel : properties) {
propertyEditorPanel.addObserver(this);
-
+
}
PropertyEditorPanel first = properties.get(0);
top.add(new JLabel(first.getLabelName()));
@@ -81,36 +87,36 @@
cbSectionPilote = ModellingEMHBrancheBarrageGeneriquePanel.createSectionPilote(branche);
cbSectionPilote.addActionListener(parent.modifiedActionListener);
top.add(cbSectionPilote);
-
+
PropertyEditorPanel second = properties.get(1);
top.add(new JLabel(second.getLabelName()));
top.add(second.getComponent());
top.add(new JLabel(NbBundle.getMessage(ModellingEMHBrancheBarrageFilEauPanel.class, "LoiQpilZam.Label.DisplayName")));
JButton bt = new JButton(NbBundle.getMessage(ModellingEMHBrancheBarrageFilEauPanel.class, "LoiQpilZam.Button.DisplayName"));
bt.addActionListener(new ActionListener() {
-
+
@Override
public void actionPerformed(ActionEvent e) {
openLoiQpilZam();
}
});
-
+
top.add(bt);
}
-
+
public void openLoiQpilZam() {
DialogHelper.showInfo(" LoiQpilZam", "doit ouvrir l'éditeur de lois");
}
-
+
@Override
public void update(Observable o, Object arg) {
parent.setModified(true);
}
-
+
private CrueConfigMetier getCcm() {
return modellingScenarioService.getSelectedProjet().getPropDefinition();
}
-
+
@Override
public void setEditable(boolean editable) {
for (PropertyEditorPanel object : properties) {
@@ -119,7 +125,7 @@
cbSectionPilote.setEnabled(editable);
seuilView.setEditable(editable);
}
-
+
@Override
public void fillWithData(BrancheEditionContent content) {
DonCalcSansPrtBrancheBarrageFilEau dcsp = new DonCalcSansPrtBrancheBarrageFilEau(getCcm());
@@ -128,14 +134,14 @@
content.setSectionPilote((CatEMHSection) cbSectionPilote.getSelectedItem());
content.setDcsp(dcsp);
}
-
+
@Override
public JComponent getComponent() {
return this;
}
-
+
private class SeuilView extends DefaultOutlineViewEditor {
-
+
protected void initWith(DonCalcSansPrtBrancheBarrageFilEau dcsp) {
List<ElemSeuilAduNode> nodes = new ArrayList<ElemSeuilAduNode>();
if (dcsp != null) {
@@ -145,9 +151,16 @@
nodes.add(new ElemSeuilAduNode(elemSeuilAvecPdcNode, ccm, perspectiveServiceModelling));
}
}
+
getExplorerManager().setRootContext(NodeHelper.createNode(nodes, "ElemSeuilAvecPdc", false));
+ DefaultNodePasteType.updateIndexedDisplayName(getExplorerManager().getRootContext());
}
-
+
+ @Override
+ protected void changeInNode() {
+ parent.setModified(true);
+ }
+
List<ElemSeuil> getElemSeuil() {
List<ElemSeuil> res = new ArrayList<ElemSeuil>();
Node[] nodes = getExplorerManager().getRootContext().getChildren().getNodes();
@@ -157,12 +170,12 @@
}
return res;
}
-
+
@Override
protected JButton createPastComponent() {
JButton button = new JButton(NbBundle.getMessage(ModellingEMHBrancheSeuilTransversalPanel.class, "Paste.DisplayName"));
button.addActionListener(new ActionListener() {
-
+
@Override
public void actionPerformed(ActionEvent e) {
paste();
@@ -170,14 +183,14 @@
});
return button;
}
-
+
protected void paste() {
List<ElemSeuilAduNode> pastData = getPastData(getCcm(), perspectiveServiceModelling);
if (!pastData.isEmpty()) {
NodeEditionHelper.addNodesFromClipboard(getExplorerManager(), pastData);
}
}
-
+
@Override
protected void addElement() {
ElemSeuil elem = new ElemSeuil(getCcm());
@@ -186,11 +199,11 @@
children.add(new Node[]{elemPdtNode});
DefaultNodePasteType.updateIndexedDisplayName(getExplorerManager().getRootContext());
}
-
+
private CrueConfigMetier getCcm() {
return modellingScenarioService.getSelectedProjet().getPropDefinition();
}
-
+
@Override
protected void createOutlineView() {
view = new OutlineView(StringUtils.EMPTY);
@@ -208,7 +221,7 @@
view.setDropTarget(true);
}
}
-
+
public static List<ElemSeuilAduNode> getPastData(CrueConfigMetier ccm, PerspectiveServiceModelling perspective) {
try {
String toCopy = (String) Toolkit.getDefaultToolkit().getSystemClipboard().getData(DataFlavor.stringFlavor);
@@ -232,10 +245,10 @@
newContent.setCoefD(Double.parseDouble(strings[2]));
} catch (NumberFormatException numberFormatException) {
}
-
+
}
}
-
+
}
}
return contents;
Modified: trunk/soft/fudaa-crue/ui-modelling/src/main/java/org/fudaa/fudaa/crue/modelling/emh/ModellingEMHBrancheBarrageGeneriquePanel.java
===================================================================
--- trunk/soft/fudaa-crue/ui-modelling/src/main/java/org/fudaa/fudaa/crue/modelling/emh/ModellingEMHBrancheBarrageGeneriquePanel.java 2012-07-16 21:57:21 UTC (rev 7501)
+++ trunk/soft/fudaa-crue/ui-modelling/src/main/java/org/fudaa/fudaa/crue/modelling/emh/ModellingEMHBrancheBarrageGeneriquePanel.java 2012-07-17 14:37:26 UTC (rev 7502)
@@ -24,6 +24,7 @@
import org.fudaa.fudaa.crue.common.services.ModellingScenarioService;
import org.fudaa.fudaa.crue.common.view.PropertyEditorPanel;
import org.fudaa.fudaa.crue.modelling.perspective.PerspectiveServiceModelling;
+import org.openide.explorer.ExplorerManager;
import org.openide.util.Lookup;
import org.openide.util.NbBundle;
@@ -81,6 +82,11 @@
add(bt);
}
+ @Override
+ public ExplorerManager getExplorerManager() {
+ return null;
+ }
+
public static JComboBox createSectionPilote(CatEMHBranche branche) {
List<CatEMHSection> sections = branche.getParent().getSections();
CatEMHSection sectionPilote = EMHHelper.getSectionPilote(branche);
Modified: trunk/soft/fudaa-crue/ui-modelling/src/main/java/org/fudaa/fudaa/crue/modelling/emh/ModellingEMHBrancheSeuilTransversalPanel.java
===================================================================
--- trunk/soft/fudaa-crue/ui-modelling/src/main/java/org/fudaa/fudaa/crue/modelling/emh/ModellingEMHBrancheSeuilTransversalPanel.java 2012-07-16 21:57:21 UTC (rev 7501)
+++ trunk/soft/fudaa-crue/ui-modelling/src/main/java/org/fudaa/fudaa/crue/modelling/emh/ModellingEMHBrancheSeuilTransversalPanel.java 2012-07-17 14:37:26 UTC (rev 7502)
@@ -16,8 +16,6 @@
import java.util.List;
import javax.swing.*;
import org.apache.commons.lang.StringUtils;
-import org.fudaa.ctulu.CtuluLog;
-import org.fudaa.dodico.crue.common.BusinessMessages;
import org.fudaa.dodico.crue.config.CrueConfigMetier;
import org.fudaa.dodico.crue.edition.bean.BrancheEditionContent;
import org.fudaa.dodico.crue.metier.emh.*;
@@ -29,6 +27,7 @@
import org.fudaa.fudaa.crue.common.view.DefaultOutlineViewEditor;
import org.fudaa.fudaa.crue.common.view.NodeEditionHelper;
import org.fudaa.fudaa.crue.modelling.perspective.PerspectiveServiceModelling;
+import org.openide.explorer.ExplorerManager;
import org.openide.explorer.view.OutlineView;
import org.openide.nodes.Children;
import org.openide.nodes.Node;
@@ -67,13 +66,18 @@
}
@Override
+ public ExplorerManager getExplorerManager() {
+ return null;
+ }
+
+ @Override
public void setEditable(boolean editable) {
seuilView.setEditable(editable);
}
@Override
public void fillWithData(BrancheEditionContent content) {
- DonCalcSansPrtBrancheSeuilLateral dcsp = new DonCalcSansPrtBrancheSeuilLateral();
+ DonCalcSansPrtBrancheSeuilTransversal dcsp = new DonCalcSansPrtBrancheSeuilTransversal();
dcsp.setFormulePdc((EnumFormulePdc) cbFormule.getSelectedItem());
dcsp.setElemSeuilAvecPdc(seuilView.getElemSeuilAvecPdc());
content.setDcsp(dcsp);
@@ -97,9 +101,15 @@
}
}
getExplorerManager().setRootContext(NodeHelper.createNode(nodes, "ElemSeuilAvecPdc", false));
+ DefaultNodePasteType.updateIndexedDisplayName(getExplorerManager().getRootContext());
}
@Override
+ protected void changeInNode() {
+ parent.setModified(true);
+ }
+
+ @Override
protected JButton createPastComponent() {
JButton button = new JButton(NbBundle.getMessage(ModellingEMHBrancheSeuilTransversalPanel.class, "Paste.DisplayName"));
button.addActionListener(new ActionListener() {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|