Author: tchemit Date: 2008-02-16 15:18:36 +0000 (Sat, 16 Feb 2008) New Revision: 1025 Added: trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/model/DetailTableModel.java Modified: trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/DetailTabRefreshHelper.java trunk/simexplorer-is/simexplorer-is-swing/src/uimodel/fr/cemagref/simexplorer/is/ui/swing/JDetailTab.jaxx Log: renommage model Modified: trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/DetailTabRefreshHelper.java =================================================================== --- trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/DetailTabRefreshHelper.java 2008-02-16 15:16:09 UTC (rev 1024) +++ trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/DetailTabRefreshHelper.java 2008-02-16 15:18:36 UTC (rev 1025) @@ -26,7 +26,7 @@ import fr.cemagref.simexplorer.is.ui.SimExplorer; import fr.cemagref.simexplorer.is.ui.swing.model.DetailTabModel; import fr.cemagref.simexplorer.is.ui.swing.model.HistoryModel; -import fr.cemagref.simexplorer.is.ui.swing.model.JDetailTableModel; +import fr.cemagref.simexplorer.is.ui.swing.model.DetailTableModel; import fr.cemagref.simexplorer.is.ui.swing.model.LoggableElementTreeNode; import static org.codelutin.i18n.I18n._; @@ -175,7 +175,7 @@ listModel.setSize(0); listModel.trimToSize(); ui.getDetail().setVisible(false); - ((JDetailTableModel) ui.getDetailTable().getModel()).setData(null); + ((DetailTableModel) ui.getDetailTable().getModel()).setData(null); } public static void updateDetailNavigationTree(JDetailTab ui, HistoryModel<LoggableElementTreeNode> model) { @@ -210,7 +210,7 @@ ui.getDetailCreationDate().setText(DATE_FORMAT.format(detail.getCreationDate())); ui.getDetail().setVisible(true); JTable table = ui.getDetailTable(); - ((JDetailTableModel) table.getModel()).setData(detail); + ((DetailTableModel) table.getModel()).setData(detail); int nbDescriptorRows = table.getRowCount(); List<Attachment> attachments = detail.getAttachments(); Copied: trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/model/DetailTableModel.java (from rev 1023, trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/model/JDetailTableModel.java) =================================================================== --- trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/model/DetailTableModel.java (rev 0) +++ trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/model/DetailTableModel.java 2008-02-16 15:18:36 UTC (rev 1025) @@ -0,0 +1,94 @@ +/* +* ##% Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008 Code Lutin, +* Tony Chemit +* +* This program is free software; you can redistribute it and/or +* modify it under the terms of the GNU General Public License +* as published by the Free Software Foundation; either version 2 +* of the License, or (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software +* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +* ##% */ +package fr.cemagref.simexplorer.is.ui.swing.model; + +import fr.cemagref.simexplorer.is.entities.metadata.MetaData; +import static org.codelutin.i18n.I18n._; +import static org.codelutin.i18n.I18n.n_; + +import javax.swing.table.AbstractTableModel; +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +/** + * Table model to contains a MetaData details + * + * @author chemit + */ +public class DetailTableModel extends AbstractTableModel { + + protected MetaData data; + protected List<String> descriptors; + private static final long serialVersionUID = -2377632046940030206L; + + protected final String[] columnNames = { + n_("simexplorer.common.key"), + n_("simexplorer.common.value") + }; + + public DetailTableModel() { + } + + public int getRowCount() { + return getDescriptors().size(); + } + + public int getColumnCount() { + return columnNames.length; + } + + public Object getValueAt(int rowIndex, int columnIndex) { + Object result = null; + if (data == null) { + return null; + } + if (columnIndex == 0) { + // key + result = getDescriptors().get(rowIndex); + } else if (columnIndex == 1) { + // value + String propertyDescriptor = getDescriptors().get(rowIndex); + result = data.getDescriptors().get(propertyDescriptor); + } + return result; + } + + @Override + public String getColumnName(int column) { + return _(columnNames[column]); + } + + public List<String> getDescriptors() { + if (descriptors == null) { + descriptors = new ArrayList<String>(); + } + return descriptors; + } + + public void setData(MetaData data) { + this.data = data; + getDescriptors().clear(); + if (data != null) { + getDescriptors().addAll(data.getDescriptors().keySet()); + Collections.sort(getDescriptors()); + } + } + +} \ No newline at end of file Modified: trunk/simexplorer-is/simexplorer-is-swing/src/uimodel/fr/cemagref/simexplorer/is/ui/swing/JDetailTab.jaxx =================================================================== --- trunk/simexplorer-is/simexplorer-is-swing/src/uimodel/fr/cemagref/simexplorer/is/ui/swing/JDetailTab.jaxx 2008-02-16 15:16:09 UTC (rev 1024) +++ trunk/simexplorer-is/simexplorer-is-swing/src/uimodel/fr/cemagref/simexplorer/is/ui/swing/JDetailTab.jaxx 2008-02-16 15:18:36 UTC (rev 1025) @@ -96,7 +96,7 @@ <row> <cell fill='horizontal' columns="2" insets='0,0,0,0'> <JScrollPane id='scrollTable' border='{null}' horizontalScrollBarPolicy='horizontal_scrollbar_as_needed' verticalScrollBarPolicy='vertical_scrollbar_as_needed'> - <JTable id="detailTable" border='{null}' model='{new fr.cemagref.simexplorer.is.ui.swing.model.JDetailTableModel()}' focusable='false' enabled='false' /> + <JTable id="detailTable" border='{null}' model='{new fr.cemagref.simexplorer.is.ui.swing.model.DetailTableModel()}' focusable='false' enabled='false' /> </JScrollPane> </cell> </row>