|
From: <de...@us...> - 2012-07-13 15:27:49
|
Revision: 7495
http://fudaa.svn.sourceforge.net/fudaa/?rev=7495&view=rev
Author: deniger
Date: 2012-07-13 15:27:43 +0000 (Fri, 13 Jul 2012)
Log Message:
-----------
Modified Paths:
--------------
trunk/soft/fudaa-crue/ui-modelling/src/main/java/org/fudaa/fudaa/crue/modelling/emh/AbstractModellingEMHTopComponent.java
trunk/soft/fudaa-crue/ui-modelling/src/main/java/org/fudaa/fudaa/crue/modelling/emh/ModellingEMHBrancheTopComponent.java
trunk/soft/fudaa-crue/ui-modelling/src/main/resources/org/fudaa/fudaa/crue/modelling/emh/Bundle.properties
Added Paths:
-----------
trunk/soft/fudaa-crue/ui-modelling/src/main/java/org/fudaa/fudaa/crue/modelling/emh/ModellingEMHBrancheSpecificEditorFactory.java
Modified: trunk/soft/fudaa-crue/ui-modelling/src/main/java/org/fudaa/fudaa/crue/modelling/emh/AbstractModellingEMHTopComponent.java
===================================================================
--- trunk/soft/fudaa-crue/ui-modelling/src/main/java/org/fudaa/fudaa/crue/modelling/emh/AbstractModellingEMHTopComponent.java 2012-07-13 14:53:54 UTC (rev 7494)
+++ trunk/soft/fudaa-crue/ui-modelling/src/main/java/org/fudaa/fudaa/crue/modelling/emh/AbstractModellingEMHTopComponent.java 2012-07-13 15:27:43 UTC (rev 7495)
@@ -8,6 +8,8 @@
import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
+import java.net.MalformedURLException;
+import java.net.URL;
import java.util.MissingResourceException;
import javax.swing.*;
import javax.swing.event.DocumentEvent;
@@ -24,6 +26,8 @@
import org.fudaa.fudaa.crue.modelling.AbstractModellingTopComponent;
import org.fudaa.fudaa.crue.modelling.services.EnumModification;
import org.fudaa.fudaa.crue.modelling.services.ScenarioModificationEvent;
+import org.openide.awt.HtmlBrowser;
+import org.openide.util.Exceptions;
import org.openide.util.NbBundle;
/**
@@ -36,6 +40,7 @@
JTextField jEMHName;
JTextField jCommentaire;
+ JButton btHelp;
JLabel jEMHNameError;
Long emhUid;
protected final ActionListener modifiedActionListener = new ActionListener() {
@@ -107,18 +112,25 @@
}
});
jEMHNameError = new JLabel();
+ btHelp = ModellingEMHBrancheSpecificEditorFactory.createButtonHelp();
+ btHelp.addActionListener(new ActionListener() {
+
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ showCommonHelp();
+ }
+ });
JPanel pn = new JPanel(new BuGridLayout(2, 5, 6));
pn.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
pn.add(new JLabel(NbBundle.getMessage(AbstractModellingEMHTopComponent.class, "ListTopComponent.EMHName.Label")));
+ JPanel pnName = new JPanel(new FlowLayout(FlowLayout.LEFT, 10, 0));
+ pnName.add(jEMHName);
if (northEastCmp != null) {
- JPanel pnName = new JPanel(new FlowLayout(FlowLayout.LEFT, 0, 0));
- pnName.add(jEMHName);
pnName.add(northEastCmp);
- pn.add(pnName);
- } else {
- pn.add(jEMHName);
}
+ pnName.add(btHelp);
+ pn.add(pnName);
pn.add(new JLabel());
pn.add(jEMHNameError);
return pn;
@@ -128,6 +140,14 @@
return super.modellingScenarioModificationService.getModellingScenarioService().getScenarioLoaded();
}
+ protected void showCommonHelp() {
+ try {
+ HtmlBrowser.URLDisplayer.getDefault().showURLExternal(new URL("http://fr.wikipedia.org/wiki/Hydraulique_fluviale"));
+ } catch (MalformedURLException ex) {
+ Exceptions.printStackTrace(ex);
+ }
+ }
+
@Override
public void cancelModification() {
scenarioReloaded();
Added: trunk/soft/fudaa-crue/ui-modelling/src/main/java/org/fudaa/fudaa/crue/modelling/emh/ModellingEMHBrancheSpecificEditorFactory.java
===================================================================
--- trunk/soft/fudaa-crue/ui-modelling/src/main/java/org/fudaa/fudaa/crue/modelling/emh/ModellingEMHBrancheSpecificEditorFactory.java (rev 0)
+++ trunk/soft/fudaa-crue/ui-modelling/src/main/java/org/fudaa/fudaa/crue/modelling/emh/ModellingEMHBrancheSpecificEditorFactory.java 2012-07-13 15:27:43 UTC (rev 7495)
@@ -0,0 +1,75 @@
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+package org.fudaa.fudaa.crue.modelling.emh;
+
+import com.memoire.bu.BuResource;
+import java.awt.BorderLayout;
+import java.awt.event.ActionEvent;
+import java.awt.event.ActionListener;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.MissingResourceException;
+import javax.swing.BorderFactory;
+import javax.swing.JButton;
+import javax.swing.JPanel;
+import javax.swing.JTextField;
+import org.fudaa.dodico.crue.metier.emh.CatEMHBranche;
+import org.fudaa.dodico.crue.metier.emh.EnumBrancheType;
+import org.openide.awt.HtmlBrowser;
+import org.openide.util.Exceptions;
+import org.openide.util.NbBundle;
+
+/**
+ *
+ * @author Frédéric Deniger
+ */
+public class ModellingEMHBrancheSpecificEditorFactory {
+
+ JPanel create(final CatEMHBranche branche, final EnumBrancheType type) {
+ JPanel res = createMainPanel(type);
+ JPanel center = createCenterPanel(branche, type);
+ res.add(center);
+ return res;
+ }
+
+ protected JPanel createMainPanel(final EnumBrancheType type) throws MissingResourceException {
+ JPanel res = new JPanel(new BorderLayout());
+ res.setBorder(BorderFactory.createTitledBorder(NbBundle.getMessage(ModellingEMHBrancheSpecificEditorFactory.class, "BrancheDescription", type.geti18n())));
+ JTextField txt = new JTextField(50);
+ txt.setText("Aide pour le type " + type.geti18n());
+ txt.setEditable(false);
+ JPanel pn = new JPanel(new BorderLayout(10, 0));
+ pn.add(txt);
+ JButton bt = createButtonHelp();
+ bt.addActionListener(new ActionListener() {
+
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ showHelp(type);
+ }
+ });
+ pn.add(bt, BorderLayout.EAST);
+ res.add(pn, BorderLayout.NORTH);
+ return res;
+ }
+
+ public void showHelp(EnumBrancheType brancheType) {
+ try {
+ HtmlBrowser.URLDisplayer.getDefault().showURLExternal(new URL("http://fr.wikipedia.org/wiki/Hydraulique_fluviale"));
+ } catch (MalformedURLException ex) {
+ Exceptions.printStackTrace(ex);
+ }
+ }
+
+ protected static JButton createButtonHelp() {
+ JButton bt = new JButton();
+ bt.setIcon(BuResource.BU.getIcon("aide"));
+ return bt;
+ }
+
+ private JPanel createCenterPanel(CatEMHBranche branche, EnumBrancheType type) {
+ return new JPanel();
+ }
+}
Modified: trunk/soft/fudaa-crue/ui-modelling/src/main/java/org/fudaa/fudaa/crue/modelling/emh/ModellingEMHBrancheTopComponent.java
===================================================================
--- trunk/soft/fudaa-crue/ui-modelling/src/main/java/org/fudaa/fudaa/crue/modelling/emh/ModellingEMHBrancheTopComponent.java 2012-07-13 14:53:54 UTC (rev 7494)
+++ trunk/soft/fudaa-crue/ui-modelling/src/main/java/org/fudaa/fudaa/crue/modelling/emh/ModellingEMHBrancheTopComponent.java 2012-07-13 15:27:43 UTC (rev 7495)
@@ -6,8 +6,11 @@
import com.memoire.bu.BuGridLayout;
import java.awt.BorderLayout;
+import java.awt.Container;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
+import java.awt.event.ItemEvent;
+import java.awt.event.ItemListener;
import java.util.List;
import javax.swing.*;
import org.fudaa.ctulu.CtuluLog;
@@ -45,7 +48,6 @@
JButton btSectionAval;
JButton btListSection;
JComboBox cbType;
-
public ModellingEMHBrancheTopComponent() {
setName(NbBundle.getMessage(ModellingEMHBrancheTopComponent.class, TOPCOMPONENT_ACTION));
@@ -59,6 +61,15 @@
pn.add(new JLabel(NbBundle.getMessage(ModellingEMHBrancheTopComponent.class, "BrancheType.DisplayName")));
cbType = new JComboBox(EnumBrancheType.getAvailablesBrancheType().toArray(new EnumBrancheType[0]));
cbType.addActionListener(modifiedActionListener);
+ cbType.addItemListener(new ItemListener() {
+
+ @Override
+ public void itemStateChanged(ItemEvent e) {
+ if (e.getStateChange() == ItemEvent.SELECTED) {
+ udpdateSpecificCenter();
+ }
+ }
+ });
cbType.setRenderer(new ToStringInternationalizableCellRenderer());
pn.add(cbType);
cbActive.addActionListener(modifiedActionListener);
@@ -165,6 +176,7 @@
LogsDisplayer.displayError(log, getName());
}
}
+ ModellingEMHBrancheSpecificEditorFactory factory = new ModellingEMHBrancheSpecificEditorFactory();
@Override
protected void updateOtherComponents() {
@@ -182,7 +194,27 @@
btSectionAmont.setText(branche.getSectionAmont().getEmhNom());
btSectionAval.setText(branche.getSectionAval().getEmhNom());
}
+ JPanel currentCenter;
+ protected void udpdateSpecificCenter() {
+ final EnumBrancheType type = (EnumBrancheType) cbType.getSelectedItem();
+ if (type == null) {
+ return;
+ }
+ if (currentCenter != null) {
+ remove(currentCenter);
+ }
+ CatEMHBranche branche = getEMH();
+ currentCenter = factory.create(branche, type);
+ add(currentCenter);
+ repaint();
+ revalidate();
+ JDialog dialog = (JDialog) SwingUtilities.getAncestorOfClass(JDialog.class, this);
+ if (dialog != null) {
+ dialog.pack();
+ }
+ }
+
@Override
protected void setEditable(boolean b) {
super.setEditable(b);
@@ -194,7 +226,8 @@
@Override
protected void createComponents() {
- add(buildNorthPanel(), BorderLayout.CENTER);
+ add(buildNorthPanel(), BorderLayout.NORTH);
+
add(createCancelSaveButtons(), BorderLayout.SOUTH);
}
Modified: trunk/soft/fudaa-crue/ui-modelling/src/main/resources/org/fudaa/fudaa/crue/modelling/emh/Bundle.properties
===================================================================
--- trunk/soft/fudaa-crue/ui-modelling/src/main/resources/org/fudaa/fudaa/crue/modelling/emh/Bundle.properties 2012-07-13 14:53:54 UTC (rev 7494)
+++ trunk/soft/fudaa-crue/ui-modelling/src/main/resources/org/fudaa/fudaa/crue/modelling/emh/Bundle.properties 2012-07-13 15:27:43 UTC (rev 7495)
@@ -19,3 +19,4 @@
OpenListSection.DisplayName=Liste des sections
SectionButton.Tooltip=Ouvrir l'\u00e9diteur de la section
ListSectionButton.Tooltip=Ouvrir la liste des sections
+BrancheDescription=Branche {0}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|