|
From: <de...@us...> - 2016-11-22 11:20:30
|
Revision: 9460
http://sourceforge.net/p/fudaa/svn/9460
Author: deniger
Date: 2016-11-22 11:20:28 +0000 (Tue, 22 Nov 2016)
Log Message:
-----------
CRUE-706
Modified Paths:
--------------
trunk/soft/fudaa-crue/ui-modelling/src/main/java/org/fudaa/fudaa/crue/modelling/list/ModellingListFrottementTopComponent.java
trunk/soft/fudaa-crue/ui-modelling/src/main/resources/org/fudaa/fudaa/crue/modelling/list/Bundle.properties
trunk/soft/fudaa-crue/ui-views/src/main/java/org/fudaa/fudaa/crue/views/export/OutlineViewExportTableModel.java
Added Paths:
-----------
trunk/soft/fudaa-crue/ui-modelling/src/main/java/org/fudaa/fudaa/crue/modelling/list/ModellingListFrottementExportTableModel.java
Added: trunk/soft/fudaa-crue/ui-modelling/src/main/java/org/fudaa/fudaa/crue/modelling/list/ModellingListFrottementExportTableModel.java
===================================================================
--- trunk/soft/fudaa-crue/ui-modelling/src/main/java/org/fudaa/fudaa/crue/modelling/list/ModellingListFrottementExportTableModel.java (rev 0)
+++ trunk/soft/fudaa-crue/ui-modelling/src/main/java/org/fudaa/fudaa/crue/modelling/list/ModellingListFrottementExportTableModel.java 2016-11-22 11:20:28 UTC (rev 9460)
@@ -0,0 +1,108 @@
+/*
+GPL 2
+ */
+package org.fudaa.fudaa.crue.modelling.list;
+
+import java.lang.reflect.InvocationTargetException;
+import java.util.Collections;
+import java.util.List;
+import javax.swing.JTable;
+import jxl.write.Label;
+import jxl.write.WritableCell;
+import org.fudaa.ctulu.CtuluLibString;
+import org.fudaa.ctulu.table.CtuluTableModelInterface;
+import org.openide.nodes.Node;
+import org.openide.util.Exceptions;
+
+/**
+ * Un modèle pour adapter l'export cvs/Excel de la liste des frottement
+ *
+ * @author Frederic Deniger
+ */
+public class ModellingListFrottementExportTableModel implements CtuluTableModelInterface {
+
+ //l'indice de la premiere colonne
+ int idxColumnBrancheName = 0;
+ //l'offset impliqué par la première colonne
+ int offsetToApply = 1;
+ JTable listFrtTable;
+ List<String> rowNames;
+
+ public ModellingListFrottementExportTableModel(JTable listFrtTable) {
+ this.listFrtTable = listFrtTable;
+ //le noms des lignes.
+ rowNames = (List<String>) listFrtTable.getClientProperty(ModellingListFrottementTopComponent.PROPERTY_FOR_ROW_NAMES);
+ }
+
+ @Override
+ public int[] getSelectedRows() {
+ return null;
+ }
+
+ /**
+ *
+ * @param rowIndex
+ * @param columnIndex
+ * @return la valeur a utliser en (rowIndex,columnIndex). Pour la première colonne on utilise le nom de la ligne
+ */
+ @Override
+ public Object getValue(int rowIndex, int columnIndex) {
+ //on utilise le noms des lignes
+ if (columnIndex == idxColumnBrancheName) {
+ if (rowNames == null || rowNames.size() < rowIndex) {
+ return CtuluLibString.EMPTY_STRING;
+ }
+ return rowNames.get(rowIndex);
+ }
+ Object val = listFrtTable.getValueAt(rowIndex, columnIndex - offsetToApply);
+ if (val instanceof Node.Property) {
+ try {
+ return ((Node.Property) val).getValue();
+ } catch (IllegalAccessException | InvocationTargetException ex) {
+ Exceptions.printStackTrace(ex);
+ }
+ }
+ return val;
+ }
+
+ @Override
+ public String getColumnName(int colIdx) {
+ if (colIdx == idxColumnBrancheName) {
+ return org.openide.util.NbBundle.getMessage(ModellingListFrottementExportTableModel.class, "listFrottementExport.first.column.name");
+ }
+ return listFrtTable.getColumnName(colIdx - offsetToApply);
+ }
+
+ @Override
+ public WritableCell getExcelWritable(int _rowInModel, int _colInModel, int _rowInXls, int _colInXls) {
+ final Object o = getValue(_rowInModel, _colInModel);
+ if (o == null) {
+ return null;
+ }
+ String s = o.toString();
+ if (s == null) {
+ return null;
+ }
+ s = s.trim();
+ if (s.length() == 0) {
+ return null;
+ }
+ return new Label(_colInXls, _rowInXls, s);
+ }
+
+ @Override
+ public int getMaxCol() {
+ return offsetToApply + listFrtTable.getColumnCount();
+ }
+
+ @Override
+ public int getMaxRow() {
+ return listFrtTable.getRowCount();
+ }
+
+ @Override
+ public List<String> getComments() {
+ return Collections.emptyList();
+ }
+
+}
Modified: trunk/soft/fudaa-crue/ui-modelling/src/main/java/org/fudaa/fudaa/crue/modelling/list/ModellingListFrottementTopComponent.java
===================================================================
--- trunk/soft/fudaa-crue/ui-modelling/src/main/java/org/fudaa/fudaa/crue/modelling/list/ModellingListFrottementTopComponent.java 2016-11-22 09:48:54 UTC (rev 9459)
+++ trunk/soft/fudaa-crue/ui-modelling/src/main/java/org/fudaa/fudaa/crue/modelling/list/ModellingListFrottementTopComponent.java 2016-11-22 11:20:28 UTC (rev 9460)
@@ -26,7 +26,7 @@
import org.apache.commons.lang.StringUtils;
import org.fudaa.ctulu.gui.CtuluFileChooser;
import org.fudaa.ctulu.gui.CtuluTableSimpleExporter;
-import org.fudaa.ctulu.table.CtuluTableModelDefault;
+import org.fudaa.ctulu.table.CtuluTableModelInterface;
import org.fudaa.dodico.crue.common.BusinessMessages;
import org.fudaa.dodico.crue.config.lit.LitNomme;
import org.fudaa.dodico.crue.metier.emh.CatEMHBranche;
@@ -48,7 +48,6 @@
import org.fudaa.fudaa.crue.modelling.loi.ModellingOpenDFRTNodeAction;
import org.fudaa.fudaa.crue.modelling.services.EnumModification;
import org.fudaa.fudaa.crue.modelling.services.ScenarioModificationEvent;
-import org.fudaa.fudaa.crue.views.export.OutlineViewExportTableModel;
import org.openide.util.NbBundle;
import org.openide.windows.TopComponent;
@@ -68,6 +67,7 @@
public static final String TOPCOMPONENT_ACTION = "CTL_" + TOPCOMPONENT_ID;
public static final String PROP_LIT_NUMEROTE = "LitNumerote";
public static final String PROPERTY_BRANCHE = "BRANCHE";
+ protected static final String PROPERTY_FOR_ROW_NAMES = "rowNames";
Long sousModeleUid;
private JScrollPane scrollPane;
private JTable table;
@@ -77,6 +77,17 @@
// menu d'import des fichiers XLS/CSV
JMenuItem importItem;
+ protected final ActionListener modifiedActionListener = new ActionListener() {
+ @Override
+ public void actionPerformed(ActionEvent e) {
+ setModified(true);
+ }
+ };
+ boolean isUpdating;
+ CatEMHBranche brancheToSelect = null;
+ // GridBuilder gridBuilder;
+ private boolean editable;
+
public ModellingListFrottementTopComponent() {
setName(NbBundle.getMessage(ModellingListFrottementTopComponent.class, TOPCOMPONENT_ACTION));
setToolTipText(NbBundle.getMessage(ModellingListFrottementTopComponent.class, "HINT_" + TOPCOMPONENT_ID));
@@ -84,13 +95,6 @@
setBorder(BorderFactory.createCompoundBorder(getBorder(), BuBorders.EMPTY3333));
}
- protected final ActionListener modifiedActionListener = new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent e) {
- setModified(true);
- }
- };
-
@Override
protected String getViewHelpCtxId() {
return "vueListeFrottements";
@@ -127,7 +131,6 @@
protected void scenarioReloaded() {
scenarioLoaded();
}
- boolean isUpdating;
@Override
public void setModified(boolean modified) {
@@ -202,6 +205,7 @@
table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF);
table.setCellSelectionEnabled(false);
table.setRowSelectionAllowed(true);
+ table.putClientProperty(PROPERTY_FOR_ROW_NAMES, rows);
table.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
@@ -278,7 +282,7 @@
* Export csv/xlsx du tableau
*/
protected void exportTable() {
- CtuluTableModelDefault defaultModel = new OutlineViewExportTableModel(table, null, null);
+ CtuluTableModelInterface defaultModel = new ModellingListFrottementExportTableModel(table);
CtuluTableSimpleExporter.doExport(';', defaultModel, CtuluUIForNetbeans.DEFAULT);
}
@@ -328,7 +332,6 @@
scenarioReloaded();
}
}
- CatEMHBranche brancheToSelect = null;
public void setBrancheUid(Long uid) {
CatEMHBranche branche = (CatEMHBranche) getScenario().getIdRegistry().getEmh(uid);
@@ -348,8 +351,6 @@
void readProperties(java.util.Properties p) {
}
-// GridBuilder gridBuilder;
- private boolean editable;
@Override
protected void setEditable(boolean b) {
Modified: trunk/soft/fudaa-crue/ui-modelling/src/main/resources/org/fudaa/fudaa/crue/modelling/list/Bundle.properties
===================================================================
--- trunk/soft/fudaa-crue/ui-modelling/src/main/resources/org/fudaa/fudaa/crue/modelling/list/Bundle.properties 2016-11-22 09:48:54 UTC (rev 9459)
+++ trunk/soft/fudaa-crue/ui-modelling/src/main/resources/org/fudaa/fudaa/crue/modelling/list/Bundle.properties 2016-11-22 11:20:28 UTC (rev 9460)
@@ -58,4 +58,5 @@
Filtre.Label=Branche :
button.export.name=Exporter
-button.import.name=Importer
\ No newline at end of file
+button.import.name=Importer
+listFrottementExport.first.column.name=Branche / Section
Modified: trunk/soft/fudaa-crue/ui-views/src/main/java/org/fudaa/fudaa/crue/views/export/OutlineViewExportTableModel.java
===================================================================
--- trunk/soft/fudaa-crue/ui-views/src/main/java/org/fudaa/fudaa/crue/views/export/OutlineViewExportTableModel.java 2016-11-22 09:48:54 UTC (rev 9459)
+++ trunk/soft/fudaa-crue/ui-views/src/main/java/org/fudaa/fudaa/crue/views/export/OutlineViewExportTableModel.java 2016-11-22 11:20:28 UTC (rev 9460)
@@ -10,6 +10,7 @@
import org.openide.util.Exceptions;
/**
+ * Le modele pour adapater une table netbeans a un export excel/csv utilisé par ctulu
*
* @author Frederic Deniger
*/
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|