Coser-commits
Threads by month
- ----- 2026 -----
- June
- May
- April
- March
- February
- January
- ----- 2025 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- 1258 discussions
r895 - in trunk: coser-business/src/main/java/fr/ifremer/coser/control coser-business/src/main/java/fr/ifremer/coser/services coser-business/src/main/java/fr/ifremer/coser/storage coser-ui/src/main/java/fr/ifremer/coser/ui/control
by echatellier@users.forge.codelutin.com 17 Nov '11
by echatellier@users.forge.codelutin.com 17 Nov '11
17 Nov '11
Author: echatellier
Date: 2011-11-17 11:30:18 +0100 (Thu, 17 Nov 2011)
New Revision: 895
Url: http://forge.codelutin.com/repositories/revision/coser/895
Log:
#313 : Afficher les lignes en doublon cote ?\195?\160 cote dans la table
Added:
trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/control/ControlDuplicatedLineTableModel.java
trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/control/ControlTableModel.java
Modified:
trunk/coser-business/src/main/java/fr/ifremer/coser/control/ControlError.java
trunk/coser-business/src/main/java/fr/ifremer/coser/control/ControlErrorGroup.java
trunk/coser-business/src/main/java/fr/ifremer/coser/control/DiffCatchLengthControlError.java
trunk/coser-business/src/main/java/fr/ifremer/coser/services/ControlService.java
trunk/coser-business/src/main/java/fr/ifremer/coser/services/PublicationService.java
trunk/coser-business/src/main/java/fr/ifremer/coser/storage/MemoryDataStorage.java
trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/control/ControlDataTableModel.java
trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/control/ControlHandler.java
trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/control/ControlView.jaxx
Modified: trunk/coser-business/src/main/java/fr/ifremer/coser/control/ControlError.java
===================================================================
--- trunk/coser-business/src/main/java/fr/ifremer/coser/control/ControlError.java 2011-11-16 08:28:34 UTC (rev 894)
+++ trunk/coser-business/src/main/java/fr/ifremer/coser/control/ControlError.java 2011-11-17 10:30:18 UTC (rev 895)
@@ -5,7 +5,7 @@
* $Id$
* $HeadURL$
* %%
- * Copyright (C) 2010 Ifremer, Codelutin, Chatellier Eric
+ * Copyright (C) 2010,2011 Ifremer, Codelutin, Chatellier Eric
* %%
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as
@@ -26,8 +26,9 @@
package fr.ifremer.coser.control;
import java.io.Serializable;
+import java.util.ArrayList;
import java.util.Collection;
-import java.util.HashSet;
+import java.util.List;
import java.util.Set;
import fr.ifremer.coser.CoserConstants.Category;
@@ -69,12 +70,11 @@
*
* Peut être vide si l'erreur n'est pas associé à une ligne specifiques.
*/
- protected Set<String> lineNumbers;
+ protected List<String> lineNumbers;
public ControlError() {
- super();
-
- lineNumbers = new HashSet<String>();
+ // set TreeSet, must be sorted for swing ui to change order in model
+ lineNumbers = new ArrayList<String>();
}
/**
@@ -176,13 +176,13 @@
}
/**
- * Numero des lignes dans le fichier CSV.
+ * Numero des lignes dans le fichier CSV (sorted by implementation).
*
* Peut être vide si l'erreur n'est pas associé a une ligne specifiques.
*
* @return line number
*/
- public Set<String> getLineNumbers() {
+ public List<String> getLineNumbers() {
return lineNumbers;
}
Modified: trunk/coser-business/src/main/java/fr/ifremer/coser/control/ControlErrorGroup.java
===================================================================
--- trunk/coser-business/src/main/java/fr/ifremer/coser/control/ControlErrorGroup.java 2011-11-16 08:28:34 UTC (rev 894)
+++ trunk/coser-business/src/main/java/fr/ifremer/coser/control/ControlErrorGroup.java 2011-11-17 10:30:18 UTC (rev 895)
@@ -3,7 +3,7 @@
* $Id$
* $HeadURL$
* %%
- * Copyright (C) 2010 Ifremer, Codelutin, Chatellier Eric
+ * Copyright (C) 2010,2011 Ifremer, Codelutin, Chatellier Eric
* %%
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as
@@ -49,7 +49,6 @@
* @param message
*/
public ControlErrorGroup(Category category, ValidationLevel validationLevel, String message) {
- super();
this.category = category;
this.validationLevel = validationLevel;
this.message = message;
Modified: trunk/coser-business/src/main/java/fr/ifremer/coser/control/DiffCatchLengthControlError.java
===================================================================
--- trunk/coser-business/src/main/java/fr/ifremer/coser/control/DiffCatchLengthControlError.java 2011-11-16 08:28:34 UTC (rev 894)
+++ trunk/coser-business/src/main/java/fr/ifremer/coser/control/DiffCatchLengthControlError.java 2011-11-17 10:30:18 UTC (rev 895)
@@ -5,7 +5,7 @@
* $Id$
* $HeadURL$
* %%
- * Copyright (C) 2010 Ifremer, Codelutin, Chatellier Eric
+ * Copyright (C) 2010,2011 Ifremer, Codelutin, Chatellier Eric
* %%
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as
@@ -25,7 +25,6 @@
package fr.ifremer.coser.control;
-
/**
* Erreur de controle specifique pour les différences des nombres entre
* les captures et les tailles pour utilisation typée de cette erreur
Modified: trunk/coser-business/src/main/java/fr/ifremer/coser/services/ControlService.java
===================================================================
--- trunk/coser-business/src/main/java/fr/ifremer/coser/services/ControlService.java 2011-11-16 08:28:34 UTC (rev 894)
+++ trunk/coser-business/src/main/java/fr/ifremer/coser/services/ControlService.java 2011-11-17 10:30:18 UTC (rev 895)
@@ -315,6 +315,7 @@
}
Map<String, String> uniqueDataKeys = new HashMap<String, String>();
+ Map<String, ControlError> uniqueDataErrors = new HashMap<String, ControlError>();
List<ControlError> validationErrors = new ArrayList<ControlError>();
Iterator<String[]> itDataToCheck = dataToCheck.iterator(true);
int lineIndex = 1; // 1 = skip header
@@ -357,14 +358,25 @@
String lineNumber = line[AbstractDataEntity.INDEX_LINE];
String uniqueDataKey = getSignificantData(category, line);
if (uniqueDataKeys.containsKey(uniqueDataKey)) {
- ControlError error = new ControlError();
- error.setCategory(category);
- error.setLevel(ValidationLevel.ERROR);
- error.addLineNumber(uniqueDataKeys.get(uniqueDataKey));
+
+ // make a single ControlError instance pour the same
+ // duplicated even for more than 2 lines
+ ControlError error = null;
+ if (uniqueDataErrors.containsKey(uniqueDataKey)) {
+ error = uniqueDataErrors.get(uniqueDataKey);
+ } else {
+ error = new ControlError();
+ error.setCategory(category);
+ error.setLevel(ValidationLevel.ERROR);
+ // warning, line number must stay sorted
+ error.addLineNumber(uniqueDataKeys.get(uniqueDataKey));
+ error.setMessage(_("coser.business.control.error.duplicatedLine", uniqueDataKey));
+ error.setDetailMessage(_("coser.business.control.error.duplicatedLineDetails", uniqueDataKey));
+ validationErrors.add(error);
+ uniqueDataErrors.put(uniqueDataKey, error);
+ }
+ // add current line to error
error.addLineNumber(lineNumber);
- error.setMessage(_("coser.business.control.error.duplicatedLine", uniqueDataKey));
- error.setDetailMessage(_("coser.business.control.error.duplicatedLineDetails", uniqueDataKey));
- validationErrors.add(error);
}
else {
uniqueDataKeys.put(uniqueDataKey, lineNumber);
Modified: trunk/coser-business/src/main/java/fr/ifremer/coser/services/PublicationService.java
===================================================================
--- trunk/coser-business/src/main/java/fr/ifremer/coser/services/PublicationService.java 2011-11-16 08:28:34 UTC (rev 894)
+++ trunk/coser-business/src/main/java/fr/ifremer/coser/services/PublicationService.java 2011-11-17 10:30:18 UTC (rev 895)
@@ -378,7 +378,7 @@
for (ControlError error : validationErrorsChilds.get(group)) {
out.println("<li type='circle'>");
out.print(_(error.getDetailMessage()));
- Set<String> lineNumbers = error.getLineNumbers();
+ List<String> lineNumbers = error.getLineNumbers();
if (CollectionUtils.isNotEmpty(lineNumbers)) {
out.print(" (" + _("coser.business.publication.errorexportlines") + " : ");
Iterator<String> itLineNumbers = lineNumbers.iterator();
Modified: trunk/coser-business/src/main/java/fr/ifremer/coser/storage/MemoryDataStorage.java
===================================================================
--- trunk/coser-business/src/main/java/fr/ifremer/coser/storage/MemoryDataStorage.java 2011-11-16 08:28:34 UTC (rev 894)
+++ trunk/coser-business/src/main/java/fr/ifremer/coser/storage/MemoryDataStorage.java 2011-11-17 10:30:18 UTC (rev 895)
@@ -26,8 +26,10 @@
package fr.ifremer.coser.storage;
import java.util.ArrayList;
+import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
+import java.util.Map;
/**
* Stockage mémoire des String[] sous forme de String simple.
@@ -52,10 +54,13 @@
/** Stockage des numero de ligne (String) pour une recherche indexOf plus rapide. */
protected List<String> lineIndexStorage;
-
+ /** Cache pour les indexOf encore plus rapide (invalidé lors d'un delete). */
+ protected Map<String, Integer> lineIndexStorageCache;
+
public MemoryDataStorage() {
listStorage = new ArrayList<String>();
lineIndexStorage = new ArrayList<String>();
+ lineIndexStorageCache = new HashMap<String, Integer>();
}
/**
@@ -163,7 +168,12 @@
}
public int indexOf(String lineNumber) {
- return lineIndexStorage.indexOf(lineNumber);
+ Integer indexOf = lineIndexStorageCache.get(lineNumber);
+ if (indexOf == null) {
+ indexOf = lineIndexStorage.indexOf(lineNumber);
+ lineIndexStorageCache.put(lineNumber, indexOf);
+ }
+ return indexOf;
}
public int size() {
@@ -182,6 +192,7 @@
String old = listStorage.remove(index);
String[] oldArray = stringToArray(old);
lineIndexStorage.remove(index);
+ lineIndexStorageCache.clear(); // invalidate cache on remove
return oldArray;
}
Modified: trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/control/ControlDataTableModel.java
===================================================================
--- trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/control/ControlDataTableModel.java 2011-11-16 08:28:34 UTC (rev 894)
+++ trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/control/ControlDataTableModel.java 2011-11-17 10:30:18 UTC (rev 895)
@@ -3,7 +3,7 @@
* $Id$
* $HeadURL$
* %%
- * Copyright (C) 2010 Ifremer, Codelutin, Chatellier Eric
+ * Copyright (C) 2010-2011 Ifremer, Codelutin, Chatellier Eric
* %%
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as
@@ -25,14 +25,13 @@
import static org.nuiton.i18n.I18n._;
-import javax.swing.table.AbstractTableModel;
-
import fr.ifremer.coser.CoserConstants.Category;
import fr.ifremer.coser.bean.Project;
import fr.ifremer.coser.storage.DataStorage;
/**
- * Species and comments check boxed table model.
+ * Table model that display csv content loaded into memory and stored in
+ * project storage.
*
* @author chatellier
* @version $Revision$
@@ -40,7 +39,7 @@
* Last update : $Date$
* By : $Author$
*/
-public class ControlDataTableModel extends AbstractTableModel {
+public class ControlDataTableModel extends ControlTableModel {
/** serialVersionUID. */
private static final long serialVersionUID = -1192463259386773117L;
@@ -56,6 +55,11 @@
updateData(controlView);
}
+ @Override
+ public Category getCategory() {
+ return category;
+ }
+
protected void updateData(ControlView controlView) {
Project project = controlView.getContextValue(Project.class);
@@ -117,6 +121,7 @@
* @param rowIndex
* @return String[]
*/
+ @Override
public String[] getDataAt(int rowIndex) {
return data.get(rowIndex + 1);
}
@@ -128,6 +133,7 @@
* @param lineNumber le numero de données
* @return l'index
*/
+ @Override
public int getRealIndexOfLine(String lineNumber) {
// -1 because header is table header
int result = data.indexOf(lineNumber) - 1;
Added: trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/control/ControlDuplicatedLineTableModel.java
===================================================================
--- trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/control/ControlDuplicatedLineTableModel.java (rev 0)
+++ trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/control/ControlDuplicatedLineTableModel.java 2011-11-17 10:30:18 UTC (rev 895)
@@ -0,0 +1,319 @@
+/*
+ * #%L
+ *
+ *
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2011 Ifremer, Codelutin, Chatellier Eric
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 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 Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ * #L%
+ */
+
+package fr.ifremer.coser.ui.control;
+
+import java.util.EventListener;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import javax.swing.event.TableModelEvent;
+import javax.swing.event.TableModelListener;
+
+import org.apache.commons.collections.CollectionUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import fr.ifremer.coser.CoserConstants.Category;
+import fr.ifremer.coser.control.ControlError;
+
+/**
+ * Table model that change line order to display duplicated line side by side.
+ *
+ * L'implementation reside sur la construction d'un tableau associatif qui
+ * associe les numeros demandé par la vue à d'autre numero différents qui
+ * correspondent au données du modèle réel.
+ * La précédente implémentation utilisait des ArrayList, mais n'était pas
+ * performante vis à vis de la construction de la liste.
+ *
+ * @author chatellier
+ * @version $Revision$
+ *
+ * Last update : $Date$
+ * By : $Author$
+ */
+public class ControlDuplicatedLineTableModel extends ControlTableModel {
+
+ /** serialVersionUID. */
+ private static final long serialVersionUID = 8138379018849263395L;
+
+ private static final Log log = LogFactory.getLog(ControlDuplicatedLineTableModel.class);
+
+ protected ControlTableModel dataTableModel;
+
+ /** List des erreurs de validation (non null seulement apres validation). */
+ protected List<ControlError> controlErrors;
+
+ protected int[] linesIndex = null;
+ protected int[] reverseLinesIndex = null;
+
+ @Override
+ public Category getCategory() {
+ return dataTableModel.getCategory();
+ }
+
+ public ControlDuplicatedLineTableModel(ControlTableModel dataTableModel) {
+ this.dataTableModel = dataTableModel;
+ }
+
+ public void setControlErrors(List<ControlError> controlErrors) {
+ this.controlErrors = controlErrors;
+ computeLineIndices();
+ fireTableDataChanged();
+ }
+
+ /**
+ * Compute line indices.
+ */
+ protected void computeLineIndices() {
+
+ long timeBefore = System.currentTimeMillis();
+ int dataCount = getRowCount();
+ Category category = getCategory();
+
+ // build indexed array
+ linesIndex = new int[dataCount];
+ int i = 0;
+ int j = 0;
+ Set<Integer> alreadyDone = new HashSet<Integer>();
+ while (i<dataCount) {
+ while (alreadyDone.contains(j)) {
+ j++;
+ }
+ linesIndex[i++] = j;
+ for (ControlError controlError : controlErrors) {
+ if (CollectionUtils.size(controlError.getLineNumbers()) >= 2 && category.equals(controlError.getCategory())) {
+ // can return -1 here, after control can contains deleted lines
+ int errorFirstLine = dataTableModel.getRealIndexOfLine(controlError.getLineNumbers().get(0));
+ if (j == errorFirstLine) {
+ for (int errorIndex = 1; errorIndex < controlError.getLineNumbers().size(); ++errorIndex) {
+ // can return -1 here, after control can contains deleted lines
+ int delegateIndex = dataTableModel.getRealIndexOfLine(controlError.getLineNumbers().get(errorIndex));
+ linesIndex[i++] = delegateIndex;
+ alreadyDone.add(delegateIndex);
+ }
+ }
+ }
+ }
+ j++;
+ }
+
+ // build reverse array (for method getRealIndexOfLine)
+ reverseLinesIndex = new int[dataCount];
+ for (int reversei = 0 ; reversei < dataCount ; ++reversei) {
+ reverseLinesIndex[linesIndex[reversei]] = reversei;
+ }
+
+ if (log.isDebugEnabled()) {
+ long timeAfter = System.currentTimeMillis();
+ log.debug("Build new order array took " + (timeAfter - timeBefore) + " ms");
+ }
+ }
+
+ /*
+ * @see javax.swing.table.TableModel#getRowCount()
+ */
+ @Override
+ public int getRowCount() {
+ return dataTableModel.getRowCount();
+ }
+
+ /*
+ * @see javax.swing.table.TableModel#getColumnCount()
+ */
+ @Override
+ public int getColumnCount() {
+ return dataTableModel.getColumnCount();
+ }
+
+ /*
+ * @see javax.swing.table.AbstractTableModel#getColumnName(int)
+ */
+ @Override
+ public String getColumnName(int column) {
+ return dataTableModel.getColumnName(column);
+ }
+
+ /**
+ * Look for modified order row index.
+ *
+ * @param rowIndex initial row index
+ * @return modified row index
+ */
+ protected int getModifiedRowIndex(int rowIndex) {
+ int dupliRowIndex = rowIndex;
+ if (linesIndex != null) {
+ dupliRowIndex = linesIndex[rowIndex];
+ }
+ return dupliRowIndex;
+ }
+
+ /*
+ * @see javax.swing.table.TableModel#getValueAt(int, int)
+ */
+ @Override
+ public Object getValueAt(int rowIndex, int columnIndex) {
+ return dataTableModel.getValueAt(getModifiedRowIndex(rowIndex), columnIndex);
+ }
+
+ /*
+ * @see fr.ifremer.coser.ui.control.ControlTableModel#getDataAt(int)
+ */
+ @Override
+ public String[] getDataAt(int rowIndex) {
+ return dataTableModel.getDataAt(getModifiedRowIndex(rowIndex));
+ }
+
+ /**
+ * Retourne l'index réel de la ligne dans la vue.
+ *
+ * Ne doit être utilisé que pour manipuler le modele de selection
+ * et non appeler derriere getValueAt ou getDataAt (pas de sens).
+ */
+ @Override
+ public int getRealIndexOfLine(String lineNumber) {
+ int rowIndex = dataTableModel.getRealIndexOfLine(lineNumber);
+ // can return -2 if line has been deleted
+ if (rowIndex >= 0 && reverseLinesIndex != null) {
+ rowIndex = reverseLinesIndex[rowIndex];
+ }
+ return rowIndex;
+ }
+
+ /**
+ * Update linesIndex array to remove an index of a line.
+ * This method WONT work for addition, just deletion.
+ *
+ * @param lineIndex index of line to delete
+ */
+ protected void deleteLine(int lineIndex) {
+ int dataCount = getRowCount();
+ int currentVal = linesIndex[lineIndex];
+
+ // before index
+ for (int bIndex = 0; bIndex < lineIndex; ++bIndex) {
+ if (linesIndex[bIndex] > currentVal) {
+ linesIndex[bIndex] = linesIndex[bIndex] - 1;
+ }
+ }
+ // after index
+ // attention, il faut bien le <= ici, pour aller au dela
+ // du tableau et que l'element soit bien déplacé
+ // via aIndex - 1 dans le bon tableau
+ for (int aIndex = lineIndex + 1; aIndex <= dataCount; ++aIndex) {
+ if (linesIndex[aIndex] > currentVal) {
+ linesIndex[aIndex - 1] = linesIndex[aIndex] - 1;
+ } else {
+ linesIndex[aIndex - 1] = linesIndex[aIndex];
+ }
+ }
+
+ // update reverse array indices
+ for (int reversei = 0 ; reversei < dataCount ; ++reversei) {
+ reverseLinesIndex[linesIndex[reversei]] = reversei;
+ }
+ }
+
+ @Override
+ public int findColumn(String columnName) {
+ return dataTableModel.findColumn(columnName);
+ }
+
+ @Override
+ public Class<?> getColumnClass(int columnIndex) {
+ return dataTableModel.getColumnClass(columnIndex);
+ }
+
+ @Override
+ public boolean isCellEditable(int rowIndex, int columnIndex) {
+ return dataTableModel.isCellEditable(getModifiedRowIndex(rowIndex), columnIndex);
+ }
+
+ @Override
+ public void setValueAt(Object aValue, int rowIndex, int columnIndex) {
+ dataTableModel.setValueAt(aValue, getModifiedRowIndex(rowIndex), columnIndex);
+ }
+
+ @Override
+ public void fireTableDataChanged() {
+ dataTableModel.fireTableDataChanged();
+ }
+
+ @Override
+ public void fireTableStructureChanged() {
+ dataTableModel.fireTableStructureChanged();
+ }
+
+ @Override
+ public void fireTableRowsInserted(int firstRow, int lastRow) {
+ dataTableModel.fireTableRowsUpdated(firstRow, lastRow);
+ }
+
+ @Override
+ public void fireTableRowsUpdated(int firstRow, int lastRow) {
+ dataTableModel.fireTableRowsUpdated(firstRow, lastRow);
+ }
+
+ @Override
+ public void fireTableRowsDeleted(int firstRow, int lastRow) {
+ // fire before to get row count return correct value
+ dataTableModel.fireTableRowsDeleted(firstRow, lastRow);
+ // then delete line
+ for (int lineIndex = firstRow; lineIndex <= lastRow; ++lineIndex) {
+ deleteLine(lineIndex);
+ }
+ }
+
+ @Override
+ public void fireTableCellUpdated(int row, int column) {
+ dataTableModel.fireTableCellUpdated(row, column);
+ }
+
+ @Override
+ public void fireTableChanged(TableModelEvent e) {
+ dataTableModel.fireTableChanged(e);
+ }
+
+ @Override
+ public void addTableModelListener(TableModelListener l) {
+ dataTableModel.addTableModelListener(l);
+ }
+
+ @Override
+ public void removeTableModelListener(TableModelListener l) {
+ dataTableModel.removeTableModelListener(l);
+ }
+
+ @Override
+ public TableModelListener[] getTableModelListeners() {
+ return dataTableModel.getTableModelListeners();
+ }
+
+ @Override
+ public <T extends EventListener> T[] getListeners(Class<T> listenerType) {
+ return dataTableModel.getListeners(listenerType);
+ }
+}
Property changes on: trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/control/ControlDuplicatedLineTableModel.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Modified: trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/control/ControlHandler.java
===================================================================
--- trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/control/ControlHandler.java 2011-11-16 08:28:34 UTC (rev 894)
+++ trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/control/ControlHandler.java 2011-11-17 10:30:18 UTC (rev 895)
@@ -39,7 +39,6 @@
import java.util.Iterator;
import java.util.List;
import java.util.Map;
-import java.util.Set;
import java.util.UUID;
import javax.swing.JFrame;
@@ -177,7 +176,7 @@
// plusieurs lignes selectionnées et pas la premiere colonne (Line index)
if (dataSelectedRows.length > 0 && columnIndex > 0) {
- ControlDataTableModel controlDataModel = (ControlDataTableModel)displayedTable.getModel();
+ ControlTableModel controlDataModel = (ControlTableModel)displayedTable.getModel();
final String columnName = displayedTable.getColumnName(columnIndex);
final String firstValue = (String)controlDataModel.getValueAt(dataSelectedRows[0], columnIndex);
@@ -258,7 +257,7 @@
ProjectService projectService = controlView.getContextValue(ProjectService.class);
Category category = (Category)controlView.getCategoryComboBox().getSelectedItem();
- ControlDataTableModel model = (ControlDataTableModel)controlDataTable.getModel();
+ ControlTableModel model = (ControlTableModel)controlDataTable.getModel();
String commandUUID = UUID.randomUUID().toString();
// il faut le faire à l'envers, sinon, les index de
@@ -288,7 +287,7 @@
ControlView controlView = replaceView.getContextValue(ControlView.class, JAXXUtil.PARENT);
Category category = (Category)controlView.getCategoryComboBox().getSelectedItem();
JTable displayedTable = getControlDataTable(controlView);
- ControlDataTableModel controlDataModel = (ControlDataTableModel)displayedTable.getModel();
+ ControlTableModel controlDataModel = (ControlTableModel)displayedTable.getModel();
ProjectService projectService = replaceView.getContextValue(ProjectService.class);
Project project = replaceView.getContextValue(Project.class);
@@ -414,6 +413,16 @@
List<ControlError> errors = get();
view.getGlobalControlErrorModel().setControlErrors(errors);
+ // set errors list in each table model
+ ControlDuplicatedLineTableModel catchModel = (ControlDuplicatedLineTableModel)view.getControlDataTableCatch().getModel();
+ catchModel.setControlErrors(errors);
+ catchModel = (ControlDuplicatedLineTableModel)view.getControlDataTableStrata().getModel();
+ catchModel.setControlErrors(errors);
+ catchModel = (ControlDuplicatedLineTableModel)view.getControlDataTableHaul().getModel();
+ catchModel.setControlErrors(errors);
+ catchModel = (ControlDuplicatedLineTableModel)view.getControlDataTableLength().getModel();
+ catchModel.setControlErrors(errors);
+
// active le bouton de sauvegarde si la liste d'erreur
// ne contient pas de message d'erreur
// warning, c'est ok
@@ -443,6 +452,7 @@
public void controlDataTableSelectionChanged(ControlView view) {
JTable table = getControlDataTable(view);
+ ControlTableModel model = (ControlTableModel)table.getModel();
int[] selectedRows = table.getSelectedRows();
if (selectedRows.length == 1) {
int selectedRow = selectedRows[0];
@@ -454,22 +464,25 @@
case CATCH:
// warning, skip header
header = project.getControl().getCatch().get(0);
- line = project.getControl().getCatch().get(selectedRow + 1);
+ //project.getControl().getCatch().get(selectedRow + 1);
break;
case HAUL:
header = project.getControl().getHaul().get(0);
- line = project.getControl().getHaul().get(selectedRow + 1);
+ //line = project.getControl().getHaul().get(selectedRow + 1);
break;
case LENGTH:
header = project.getControl().getLength().get(0);
- line = project.getControl().getLength().get(selectedRow + 1);
+ //line = project.getControl().getLength().get(selectedRow + 1);
break;
case STRATA:
header = project.getControl().getStrata().get(0);
- line = project.getControl().getStrata().get(selectedRow + 1);
+ //line = project.getControl().getStrata().get(selectedRow + 1);
break;
}
+ // get data from model (because of line order modification)
+ line = model.getDataAt(selectedRow);
+
// convertion
updateEditionPanel(view, category, header, line);
}
@@ -500,11 +513,11 @@
view.getCategoryComboBoxModel().setSelectedItem(category);
ControlError error = (ControlError)pathWay[3];
- Set<String> errorLineNumbers = error.getLineNumbers();
+ List<String> errorLineNumbers = error.getLineNumbers();
// peut être vide, si l'erreur ne porte pas sur un bean en particulier
if (errorLineNumbers != null) {
JTable displayedTable = getControlDataTable(view);
- ControlDataTableModel tableModel = (ControlDataTableModel)displayedTable.getModel();
+ ControlTableModel tableModel = (ControlTableModel)displayedTable.getModel();
ListSelectionModel selectionModel = displayedTable.getSelectionModel();
selectionModel.clearSelection();
@@ -615,14 +628,14 @@
// select all lines
GlobalControlErrorModel model = controlView.getGlobalControlErrorModel();
JTable displayedTable = getControlDataTable(controlView);
- ControlDataTableModel tableModel = (ControlDataTableModel)displayedTable.getModel();
+ ControlTableModel tableModel = (ControlTableModel)displayedTable.getModel();
ListSelectionModel selectionModel = displayedTable.getSelectionModel();
selectionModel.clearSelection();
boolean first = true;
int childCount = model.getChildCount(validationGroup);
for (int indexChild = 0 ; indexChild < childCount ; ++indexChild) {
ControlError validationError = (ControlError)model.getChild(validationGroup, indexChild);
- Set<String> errorLineNumbers = validationError.getLineNumbers();
+ List<String> errorLineNumbers = validationError.getLineNumbers();
for (String errorLineNumber : errorLineNumbers) {
int errorLineIndex = tableModel.getRealIndexOfLine(errorLineNumber);
@@ -946,7 +959,7 @@
Project project = view.getContextValue(Project.class);
ProjectService projectService = view.getContextValue(ProjectService.class);
JTable controlDataTable = getControlDataTable(view);
- ControlDataTableModel model = (ControlDataTableModel)controlDataTable.getModel();
+ ControlTableModel model = (ControlTableModel)controlDataTable.getModel();
int selectedLine = controlDataTable.getSelectedRow();
Category category = (Category)view.getCategoryComboBox().getSelectedItem();
@@ -1009,7 +1022,7 @@
// get selected row, and selected csv line index
JTable controlDataTable = getControlDataTable(view);
- ControlDataTableModel model = (ControlDataTableModel)controlDataTable.getModel();
+ ControlTableModel model = (ControlTableModel)controlDataTable.getModel();
int selectedLine = controlDataTable.getSelectedRow();
Category category = (Category)view.getCategoryComboBox().getSelectedItem();
String[] data = model.getDataAt(selectedLine);
Added: trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/control/ControlTableModel.java
===================================================================
--- trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/control/ControlTableModel.java (rev 0)
+++ trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/control/ControlTableModel.java 2011-11-17 10:30:18 UTC (rev 895)
@@ -0,0 +1,69 @@
+/*
+ * #%L
+ *
+ *
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2011 Ifremer, Codelutin, Chatellier Eric
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 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 Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ * #L%
+ */
+
+package fr.ifremer.coser.ui.control;
+
+import javax.swing.table.AbstractTableModel;
+
+import fr.ifremer.coser.CoserConstants.Category;
+
+/**
+ * Common interface for all data table model used in control view.
+ *
+ * @author chatellier
+ * @version $Revision$
+ *
+ * Last update : $Date$
+ * By : $Author$
+ */
+public abstract class ControlTableModel extends AbstractTableModel {
+
+ /** serialVersionUID. */
+ private static final long serialVersionUID = -2010447483214407634L;
+
+ /**
+ * Return category managed by model.
+ *
+ * @return model category
+ */
+ public abstract Category getCategory();
+
+ /**
+ * Retourne la donnée (toutes le String[]) à la ligne demandée.
+ *
+ * @param rowIndex
+ * @return String[]
+ */
+ public abstract String[] getDataAt(int rowIndex);
+
+ /**
+ * Retourne l'index dans la liste des données du numero de ligne
+ * demandé.
+ *
+ * @param lineNumber le numero de données
+ * @return l'index
+ */
+ public abstract int getRealIndexOfLine(String lineNumber);
+}
Property changes on: trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/control/ControlTableModel.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Modified: trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/control/ControlView.jaxx
===================================================================
--- trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/control/ControlView.jaxx 2011-11-16 08:28:34 UTC (rev 894)
+++ trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/control/ControlView.jaxx 2011-11-17 10:30:18 UTC (rev 895)
@@ -79,25 +79,25 @@
<CardLayout id="controlTablesLayout" />
<JPanel id="controlTablesPanel" layout="{controlTablesLayout}">
<JScrollPane constraints="Category.CATCH.toString()">
- <JTable id='controlDataTableCatch' model="{new fr.ifremer.coser.ui.control.ControlDataTableModel(this, Category.CATCH)}"
+ <JTable id='controlDataTableCatch' model="{new ControlDuplicatedLineTableModel(new ControlDataTableModel(this, Category.CATCH))}"
onMouseClicked="getHandler().showDataTableContextMenu(this, event)" />
<ListSelectionModel id="controlDataTableSelectionModelCatch" javaBean="controlDataTableCatch.getSelectionModel()"
onValueChanged="getHandler().controlDataTableSelectionChanged(this)" />
</JScrollPane>
<JScrollPane constraints="Category.STRATA.toString()">
- <JTable id='controlDataTableStrata' model="{new fr.ifremer.coser.ui.control.ControlDataTableModel(this, Category.STRATA)}"
+ <JTable id='controlDataTableStrata' model="{new ControlDuplicatedLineTableModel(new ControlDataTableModel(this, Category.STRATA))}"
onMouseClicked="getHandler().showDataTableContextMenu(this, event)" />
<ListSelectionModel id="controlDataTableSelectionModelStrata" javaBean="controlDataTableStrata.getSelectionModel()"
onValueChanged="getHandler().controlDataTableSelectionChanged(this)" />
</JScrollPane>
<JScrollPane constraints="Category.HAUL.toString()">
- <JTable id='controlDataTableHaul' model="{new fr.ifremer.coser.ui.control.ControlDataTableModel(this, Category.HAUL)}"
+ <JTable id='controlDataTableHaul' model="{new ControlDuplicatedLineTableModel(new ControlDataTableModel(this, Category.HAUL))}"
onMouseClicked="getHandler().showDataTableContextMenu(this, event)" />
<ListSelectionModel id="controlDataTableSelectionModelHaul" javaBean="controlDataTableHaul.getSelectionModel()"
onValueChanged="getHandler().controlDataTableSelectionChanged(this)" />
</JScrollPane>
<JScrollPane constraints="Category.LENGTH.toString()">
- <JTable id='controlDataTableLength' model="{new fr.ifremer.coser.ui.control.ControlDataTableModel(this, Category.LENGTH)}"
+ <JTable id='controlDataTableLength' model="{new ControlDuplicatedLineTableModel(new ControlDataTableModel(this, Category.LENGTH))}"
onMouseClicked="getHandler().showDataTableContextMenu(this, event)" />
<ListSelectionModel id="controlDataTableSelectionModelLength" javaBean="controlDataTableLength.getSelectionModel()"
onValueChanged="getHandler().controlDataTableSelectionChanged(this)" />
1
0
Author: echatellier
Date: 2011-11-16 09:28:34 +0100 (Wed, 16 Nov 2011)
New Revision: 894
Url: http://forge.codelutin.com/repositories/revision/coser/894
Log:
Update to jfreechart 1.0.13
Modified:
trunk/pom.xml
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2011-11-16 08:22:40 UTC (rev 893)
+++ trunk/pom.xml 2011-11-16 08:28:34 UTC (rev 894)
@@ -186,14 +186,14 @@
<dependency>
<groupId>jfree</groupId>
<artifactId>jfreechart</artifactId>
- <version>1.0.12</version>
+ <version>1.0.13</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>jfree</groupId>
<artifactId>jcommon</artifactId>
- <version>1.0.15</version>
+ <version>1.0.16</version>
<scope>compile</scope>
</dependency>
1
0
Author: echatellier
Date: 2011-11-16 09:22:40 +0100 (Wed, 16 Nov 2011)
New Revision: 893
Url: http://forge.codelutin.com/repositories/revision/coser/893
Log:
Update to nuiton-utils 2.3.1
Modified:
trunk/pom.xml
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2011-11-16 08:21:57 UTC (rev 892)
+++ trunk/pom.xml 2011-11-16 08:22:40 UTC (rev 893)
@@ -117,13 +117,13 @@
<dependency>
<groupId>org.nuiton</groupId>
<artifactId>nuiton-utils</artifactId>
- <version>2.3</version>
+ <version>2.3.1</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.nuiton</groupId>
<artifactId>nuiton-validator</artifactId>
- <version>2.3</version>
+ <version>2.3.1</version>
<scope>compile</scope>
</dependency>
1
0
Author: echatellier
Date: 2011-11-16 09:21:57 +0100 (Wed, 16 Nov 2011)
New Revision: 892
Url: http://forge.codelutin.com/repositories/revision/coser/892
Log:
Update to commons-lang 3.1
Modified:
trunk/pom.xml
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2011-11-15 18:18:06 UTC (rev 891)
+++ trunk/pom.xml 2011-11-16 08:21:57 UTC (rev 892)
@@ -54,7 +54,7 @@
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
- <version>3.0.1</version>
+ <version>3.1</version>
<scope>compile</scope>
</dependency>
1
0
r891 - in trunk: . coser-business/src/main/java/fr/ifremer/coser coser-ui/src/main/java/fr/ifremer/coser coser-ui/src/main/java/fr/ifremer/coser/ui coser-ui/src/main/java/fr/ifremer/coser/ui/option coser-ui/src/main/resources/i18n
by echatellier@users.forge.codelutin.com 15 Nov '11
by echatellier@users.forge.codelutin.com 15 Nov '11
15 Nov '11
Author: echatellier
Date: 2011-11-15 19:18:06 +0100 (Tue, 15 Nov 2011)
New Revision: 891
Url: http://forge.codelutin.com/repositories/revision/coser/891
Log:
Add new specific configuration dialog.
Add support to change swing font size.
Added:
trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/option/ConfigurationHandler.java
trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/option/ConfigurationView.jaxx
Modified:
trunk/coser-business/src/main/java/fr/ifremer/coser/CoserBusinessConfig.java
trunk/coser-ui/src/main/java/fr/ifremer/coser/Coser.java
trunk/coser-ui/src/main/java/fr/ifremer/coser/CoserConfig.java
trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/CoserFrameHandler.java
trunk/coser-ui/src/main/resources/i18n/coser-ui_en_GB.properties
trunk/coser-ui/src/main/resources/i18n/coser-ui_fr_FR.properties
trunk/pom.xml
Modified: trunk/coser-business/src/main/java/fr/ifremer/coser/CoserBusinessConfig.java
===================================================================
--- trunk/coser-business/src/main/java/fr/ifremer/coser/CoserBusinessConfig.java 2011-11-07 10:31:24 UTC (rev 890)
+++ trunk/coser-business/src/main/java/fr/ifremer/coser/CoserBusinessConfig.java 2011-11-15 18:18:06 UTC (rev 891)
@@ -45,8 +45,6 @@
public class CoserBusinessConfig extends ApplicationConfig {
public CoserBusinessConfig() {
- super();
-
// init configuration with default options
for (CoserBusinessOption o : CoserBusinessOption.values()) {
if (o.defaultValue != null) {
@@ -55,6 +53,21 @@
}
}
+ /**
+ * Overridden to not store value when equals to default value.
+ */
+ @Override
+ public void setOption(String key, String value) {
+ String defaultValue = line.getProperty(key);
+ // replace ${xxx}
+ defaultValue = replaceRecursiveOptions(defaultValue);
+ if (defaultValue != null && defaultValue.equals(value)) {
+ options.remove(key);
+ } else {
+ super.setOption(key, value);
+ }
+ }
+
public void setDatabaseDirectory(String value) {
setOption(CoserBusinessOption.DATABASE_DIRECTORY.key, value);
}
@@ -69,10 +82,18 @@
return result;
}
+ public void setProjectsDirectory(String projectDirectory) {
+ setOption(CoserBusinessOption.PROJECTS_DIRECTORY.key, projectDirectory);
+ }
+
public File getValidatorsDirectory() {
File result = getOptionAsFile(CoserBusinessOption.VALIDATOR_DIRECTORY.key);
return result;
}
+
+ public void setValidatorsDirectory(String validatorDirectory) {
+ setOption(CoserBusinessOption.VALIDATOR_DIRECTORY.key, validatorDirectory);
+ }
public void setSmtpHost(String smtpHost) {
setOption(CoserBusinessOption.SMTP_HOST.key, smtpHost);
@@ -96,42 +117,74 @@
String result = getOption(CoserBusinessOption.REFERENCE_SPECIES.key);
return result;
}
+
+ public void setReferenceSpeciesPath(String referenceSpeciesPath) {
+ setOption(CoserBusinessOption.REFERENCE_SPECIES.key, referenceSpeciesPath);
+ }
public String getReferenceTypeEspecesPath() {
String result = getOption(CoserBusinessOption.REFERENCE_TYPE_ESPECES.key);
return result;
}
+
+ public void setReferenceTypeEspecesPath(String referenceTypeEspecesPath) {
+ setOption(CoserBusinessOption.REFERENCE_TYPE_ESPECES.key, referenceTypeEspecesPath);
+ }
public double getControlNobsmin() {
double result = getOptionAsDouble(CoserBusinessOption.CONTROL_NOBSMIN.key);
return result;
}
+
+ public void setControlNobsmin(double controlNobsmin) {
+ setOption(CoserBusinessOption.CONTROL_NOBSMIN.key, String.valueOf(controlNobsmin));
+ }
public double getControlDiffCatchLength() {
double result = getOptionAsDouble(CoserBusinessOption.CONTROL_DIFF_CATCH_LENGTH.key);
return result;
}
+
+ public void setControlDiffCatchLength(double controlDiffCatchLength) {
+ setOption(CoserBusinessOption.CONTROL_DIFF_CATCH_LENGTH.key, String.valueOf(controlDiffCatchLength));
+ }
public String getControlTypeFish() {
String result = getOption(CoserBusinessOption.CONTROL_TYPE_FISH.key);
return result;
}
+
+ public void setControlTypeFish(String controlTypeFish) {
+ setOption(CoserBusinessOption.CONTROL_TYPE_FISH.key, controlTypeFish);
+ }
public double getSelectionOccurrenceFilter() {
double result = getOptionAsDouble(CoserBusinessOption.SELECTION_FILTER_OCCURRENCE.key);
return result;
}
+
+ public void setSelectionOccurrenceFilter(double selectionOccurrenceFilter) {
+ setOption(CoserBusinessOption.SELECTION_FILTER_OCCURRENCE.key, String.valueOf(selectionOccurrenceFilter));
+ }
public double getSelectionDensityFilter() {
double result = getOptionAsDouble(CoserBusinessOption.SELECTION_FILTER_DENSITY.key);
return result;
}
+
+ public void setSelectionDensityFilter(double selectionDensityFilter) {
+ setOption(CoserBusinessOption.SELECTION_FILTER_DENSITY.key, String.valueOf(selectionDensityFilter));
+ }
public String getWebFrontEnd() {
String result = getOption(CoserBusinessOption.WEB_FRONT_END.key);
return result;
}
+ public void setWebFrontEnd(String webFrontEnd) {
+ setOption(CoserBusinessOption.WEB_FRONT_END.key, webFrontEnd);
+ }
+
public String getWebUploadURL() {
String result = getOption(CoserBusinessOption.WEB_UPLOAD_URL.key);
return result;
Modified: trunk/coser-ui/src/main/java/fr/ifremer/coser/Coser.java
===================================================================
--- trunk/coser-ui/src/main/java/fr/ifremer/coser/Coser.java 2011-11-07 10:31:24 UTC (rev 890)
+++ trunk/coser-ui/src/main/java/fr/ifremer/coser/Coser.java 2011-11-15 18:18:06 UTC (rev 891)
@@ -24,6 +24,8 @@
*/
package fr.ifremer.coser;
+import java.awt.Frame;
+import java.awt.Window;
import java.io.File;
import javax.swing.SwingUtilities;
@@ -109,7 +111,7 @@
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
-
+
// ne to be done in Swing EDT (otherwize, don't work on javawebstart)
// declare new classloader
ClassLoader currentClassLoader = Thread.currentThread().getContextClassLoader();
@@ -117,7 +119,7 @@
Thread.currentThread().setContextClassLoader(coserClassLoader);
// set coser xwork validation file directory in classloader
coserClassLoader.setValidatorsDirectory(coserConfig.getValidatorsDirectory());
-
+
// init LAF (from configuration)
try {
String lafClassName = coserConfig.getLookAndFeel();
@@ -132,6 +134,9 @@
}
}
+ // update font size (after laf)
+ coserConfig.updateSwingFont();
+
File coserConfigDirectory = new File(coserConfig.getUserConfigDirectory(), "coser");
coserConfigDirectory.mkdirs();
File mainFrameFile = new File(coserConfigDirectory, "session.xml");
@@ -151,6 +156,7 @@
CoserFrame frame = new CoserFrame(context);
frame.setLocationRelativeTo(null);
session.add(frame);
+
frame.setVisible(true);
}
});
Modified: trunk/coser-ui/src/main/java/fr/ifremer/coser/CoserConfig.java
===================================================================
--- trunk/coser-ui/src/main/java/fr/ifremer/coser/CoserConfig.java 2011-11-07 10:31:24 UTC (rev 890)
+++ trunk/coser-ui/src/main/java/fr/ifremer/coser/CoserConfig.java 2011-11-15 18:18:06 UTC (rev 891)
@@ -27,6 +27,19 @@
import static org.nuiton.i18n.I18n._;
+import java.awt.Font;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.Enumeration;
+import java.util.List;
+
+import javax.swing.UIManager;
+import javax.swing.plaf.FontUIResource;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
/**
* Coser application configuration.
*
@@ -38,8 +51,9 @@
*/
public class CoserConfig extends CoserBusinessConfig {
+ private static final Log log = LogFactory.getLog(CoserConfig.class);
+
public CoserConfig() {
-
// init configuration with default options
for (CoserOption o : CoserOption.values()) {
if (o.defaultValue != null) {
@@ -76,13 +90,27 @@
return result;
}
+ public int getSwingFontSize() {
+ int result = getOptionAsInt(CoserOption.SWING_FONT_SIZE.key);
+ return result;
+ }
+
+ public void setSwingFontSize(int swingFontSize) {
+ int old = getSwingFontSize();
+ if (old != swingFontSize) {
+ setOption(CoserOption.SWING_FONT_SIZE.key, String.valueOf(swingFontSize));
+ updateSwingFont(swingFontSize);
+ }
+ }
+
public static enum CoserOption implements OptionDef {
CONFIG_FILE(CONFIG_FILE_NAME, _("coser.config.config.file.description"), "coser.properties", String.class, true, true),
LOOKANDFEEL("coser.lookandfeel", _("coser.config.lookandfeel.description"), null, String.class, false, false),
APPLICATION_VERSION("coser.application.version", _("coser.config.application.version.description"), null, String.class, false, false),
SUPPORT_EMAIL("coser.support.email", _("coser.config.support.email.description"), "support(a)codelutin.com", String.class, false, false),
- WEBSITE_URL("coser.website", _("coser.config.website.description"), "http://maven-site.forge.codelutin.com/coser/", String.class, false, false);
+ WEBSITE_URL("coser.website", _("coser.config.website.description"), "http://maven-site.forge.codelutin.com/coser/", String.class, false, false),
+ SWING_FONT_SIZE("coser.swingfontsize", _("coser.config.swingfontsize.description"), "12", Integer.class, false, false);
protected String key;
protected String description;
@@ -145,4 +173,32 @@
this.isFinal = isFinal;
}
}
+
+ /**
+ * Update swing fonts properties.
+ */
+ public void updateSwingFont() {
+ updateSwingFont(getSwingFontSize());
+ }
+
+ /**
+ * Update swing fonts properties.
+ *
+ * @param newIncrease increase gap to apply to font
+ */
+ protected void updateSwingFont(int newIncrease) {
+ // update all font properties
+ Enumeration<Object> keys = UIManager.getDefaults().keys();
+ while (keys.hasMoreElements()) {
+ Object key = keys.nextElement();
+ if (key.toString().contains("Font") || key.toString().contains(".font")) {
+ Font font = (Font)UIManager.getFont(key);
+ font = font.deriveFont((float)newIncrease);
+ if (log.isDebugEnabled()) {
+ log.debug("Update " + key + " to size " + font.getSize());
+ }
+ UIManager.put(key, new FontUIResource(font));
+ }
+ }
+ }
}
Modified: trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/CoserFrameHandler.java
===================================================================
--- trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/CoserFrameHandler.java 2011-11-07 10:31:24 UTC (rev 890)
+++ trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/CoserFrameHandler.java 2011-11-15 18:18:06 UTC (rev 891)
@@ -36,7 +36,6 @@
import java.net.URI;
import java.util.Locale;
-import javax.swing.JDialog;
import javax.swing.JFileChooser;
import javax.swing.JOptionPane;
import javax.swing.JScrollPane;
@@ -44,8 +43,6 @@
import javax.swing.filechooser.FileFilter;
import jaxx.runtime.JAXXContext;
-import jaxx.runtime.swing.editor.config.ConfigUI;
-import jaxx.runtime.swing.editor.config.ConfigUIHelper;
import org.apache.commons.io.IOUtils;
import org.apache.commons.logging.Log;
@@ -54,7 +51,6 @@
import org.nuiton.widget.AboutFrame;
import org.nuiton.widget.SwingSession;
-import fr.ifremer.coser.CoserBusinessConfig;
import fr.ifremer.coser.CoserBusinessException;
import fr.ifremer.coser.CoserConfig;
import fr.ifremer.coser.CoserException;
@@ -64,6 +60,7 @@
import fr.ifremer.coser.ui.common.CommonHandler;
import fr.ifremer.coser.ui.control.ControlHandler;
import fr.ifremer.coser.ui.control.ControlView;
+import fr.ifremer.coser.ui.option.ConfigurationView;
import fr.ifremer.coser.ui.option.NoCopiedLayerUI;
import fr.ifremer.coser.ui.option.OptionHandler;
import fr.ifremer.coser.ui.option.ValidatorDialog;
@@ -177,44 +174,9 @@
* Show coser configuration.
*/
public void showCoserConfiguration() {
- CoserConfig config = view.getContextValue(CoserConfig.class);
- ConfigUIHelper modelBuilder = new ConfigUIHelper(config);
-
- // category main
- modelBuilder.addCategory(_("coser.config.category.path"), _("coser.config.category.path.description"));
- // chatellier 20110126 option genante
- //modelBuilder.addOption(CoserBusinessConfig.CoserBusinessOption.DATABASE_DIRECTORY);
- modelBuilder.addOption(CoserBusinessConfig.CoserBusinessOption.PROJECTS_DIRECTORY);
- modelBuilder.addOption(CoserBusinessConfig.CoserBusinessOption.VALIDATOR_DIRECTORY);
- modelBuilder.addOption(CoserBusinessConfig.CoserBusinessOption.REFERENCE_SPECIES);
- modelBuilder.addOption(CoserBusinessConfig.CoserBusinessOption.REFERENCE_TYPE_ESPECES);
- modelBuilder.addOption(CoserBusinessConfig.CoserBusinessOption.WEB_ZONES);
- modelBuilder.addOption(CoserBusinessConfig.CoserBusinessOption.WEB_FRONT_END);
-
- // category control
- modelBuilder.addCategory(_("coser.config.category.configuration"), _("coser.config.category.configuration.description"));
- modelBuilder.addOption(CoserBusinessConfig.CoserBusinessOption.CONTROL_NOBSMIN);
- modelBuilder.addOption(CoserBusinessConfig.CoserBusinessOption.CONTROL_DIFF_CATCH_LENGTH);
- modelBuilder.addOption(CoserBusinessConfig.CoserBusinessOption.CONTROL_TYPE_FISH);
- modelBuilder.addOption(CoserBusinessConfig.CoserBusinessOption.SELECTION_FILTER_OCCURRENCE);
- modelBuilder.addOption(CoserBusinessConfig.CoserBusinessOption.SELECTION_FILTER_DENSITY);
-
- // category misc
- modelBuilder.addCategory(_("coser.config.category.misc"), _("coser.config.category.misc.description"));
- modelBuilder.addOption(CoserBusinessConfig.CoserBusinessOption.SMTP_HOST);
- modelBuilder.addOption(CoserConfig.CoserOption.SUPPORT_EMAIL);
-
- ConfigUI configUI = modelBuilder.buildUI(view, _("coser.config.category.path"));
- JDialog dialogUI = new JDialog(view, _("coser.ui.config.title"));
- dialogUI.add(configUI);
- dialogUI.pack();
- dialogUI.setLocationRelativeTo(view);
-
- // restore session size
- SwingSession session = (SwingSession)view.getContextValue(SwingSession.class);
- session.add(dialogUI);
-
- dialogUI.setVisible(true);
+ ConfigurationView configView = new ConfigurationView((JAXXContext)view);
+ configView.setLocationRelativeTo(view);
+ configView.setVisible(true);
}
/**
Added: trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/option/ConfigurationHandler.java
===================================================================
--- trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/option/ConfigurationHandler.java (rev 0)
+++ trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/option/ConfigurationHandler.java 2011-11-15 18:18:06 UTC (rev 891)
@@ -0,0 +1,163 @@
+/*
+ * #%L
+ *
+ *
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2011 Codelutin, Chatellier Eric
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 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 Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ * #L%
+ */
+
+package fr.ifremer.coser.ui.option;
+
+import java.awt.Frame;
+import java.awt.Window;
+import java.io.File;
+
+import javax.swing.JFileChooser;
+import javax.swing.JTextField;
+import javax.swing.SwingUtilities;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import fr.ifremer.coser.CoserConfig;
+import fr.ifremer.coser.ui.common.CommonHandler;
+
+/**
+ * Handler for {@link ConfigurationView}.
+ *
+ * @author chatellier
+ * @version $Revision$
+ *
+ * Last update : $Date$
+ * By : $Author$
+ */
+public class ConfigurationHandler extends CommonHandler {
+
+ private static final Log log = LogFactory.getLog(ConfigurationHandler.class);
+
+ /**
+ * Display user directory selection dialog and fill given text component
+ * with given file.
+ *
+ * @param configurationView config view
+ * @param textComponent text component to fill
+ */
+ public void selectInputDirectory(ConfigurationView configurationView, JTextField textComponent) {
+ CoserConfig config = configurationView.getContextValue(CoserConfig.class);
+ JFileChooser selectFileChooser = getFileChooserInstance(config.getDatabaseDirectory());
+ selectFileChooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
+
+ int result = selectFileChooser.showOpenDialog(configurationView);
+ if (result == JFileChooser.APPROVE_OPTION) {
+ File selectedFile = selectFileChooser.getSelectedFile();
+ textComponent.setText(selectedFile.getAbsolutePath());
+ }
+ }
+
+ /**
+ * Display user file selection dialog and fill given text component
+ * with given file.
+ *
+ * @param configurationView config view
+ * @param textComponent text component to fill
+ */
+ public void selectInputFile(ConfigurationView configurationView, JTextField textComponent) {
+ CoserConfig config = configurationView.getContextValue(CoserConfig.class);
+ JFileChooser selectFileChooser = getFileChooserInstance(config.getDatabaseDirectory());
+ selectFileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
+
+ int result = selectFileChooser.showOpenDialog(configurationView);
+ if (result == JFileChooser.APPROVE_OPTION) {
+ File selectedFile = selectFileChooser.getSelectedFile();
+ textComponent.setText(selectedFile.getAbsolutePath());
+ }
+ }
+
+ /**
+ * Save configuration.
+ *
+ * @param configurationView
+ */
+ public void saveConfiguration(ConfigurationView configurationView) {
+ CoserConfig config = configurationView.getContextValue(CoserConfig.class);
+
+ // path
+ config.setProjectsDirectory(configurationView.getProjectDirectoryField().getText());
+ config.setValidatorsDirectory(configurationView.getValidatorDirectoryField().getText());
+ config.setReferenceSpeciesPath(configurationView.getReferenceSpeciesField().getText());
+ config.setReferenceTypeEspecesPath(configurationView.getReferenceTypeEspecesField().getText());
+ config.setWebZonesFile(configurationView.getWebZonesField().getText());
+ config.setWebFrontEnd(configurationView.getWebFrontEndField().getText());
+
+ // control / selection
+ try {
+ config.setControlNobsmin(Double.parseDouble(configurationView.getControlNobsMinField().getText()));
+ } catch (NumberFormatException ex) {
+ if (log.isWarnEnabled()) {
+ log.warn("Can't parse number", ex);
+ }
+ }
+ try {
+ config.setControlDiffCatchLength(Double.parseDouble(configurationView.getControlDiffCatchLengthField().getText()));
+ } catch (NumberFormatException ex) {
+ if (log.isWarnEnabled()) {
+ log.warn("Can't parse number", ex);
+ }
+ }
+ config.setControlTypeFish(configurationView.getControlTypeFishField().getText());
+ try {
+ config.setSelectionDensityFilter(Double.parseDouble(configurationView.getSelectionFilterDensityField().getText()));
+ } catch (NumberFormatException ex) {
+ if (log.isWarnEnabled()) {
+ log.warn("Can't parse number", ex);
+ }
+ }
+ try {
+ config.setSelectionOccurrenceFilter(Double.parseDouble(configurationView.getSelectionFilterOccurrenceField().getText()));
+ } catch (NumberFormatException ex) {
+ if (log.isWarnEnabled()) {
+ log.warn("Can't parse number", ex);
+ }
+ }
+
+ // misc
+ config.setSmtpHost(configurationView.getSmtpHostField().getText());
+ config.setSupportEmail(configurationView.getSupportEmailField().getText());
+ try {
+ config.setSwingFontSize(Integer.parseInt((String)configurationView.getSwingFontSizeField().getSelectedItem()));
+ } catch (NumberFormatException ex) {
+ if (log.isWarnEnabled()) {
+ log.warn("Can't parse number", ex);
+ }
+ }
+
+ // save
+ config.saveForUser();
+
+ // close
+ configurationView.dispose();
+
+ // update font size (font size)
+ Window windows[] = Frame.getWindows();
+ for(Window window : windows) {
+ SwingUtilities.updateComponentTreeUI(window);
+ }
+ }
+}
Property changes on: trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/option/ConfigurationHandler.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/option/ConfigurationView.jaxx
===================================================================
--- trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/option/ConfigurationView.jaxx (rev 0)
+++ trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/option/ConfigurationView.jaxx 2011-11-15 18:18:06 UTC (rev 891)
@@ -0,0 +1,198 @@
+<!--
+ #%L
+ Coser :: UI
+
+ $Id$
+ $HeadURL$
+ %%
+ Copyright (C) 2011 Ifremer, Codelutin, Chatellier Eric
+ %%
+ 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 3 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, see
+ <http://www.gnu.org/licenses/gpl-3.0.html>.
+ #L%
+ -->
+<JDialog title="coser.ui.configuration.title">
+ <import>
+ static fr.ifremer.coser.CoserBusinessConfig.CoserBusinessOption
+ static fr.ifremer.coser.CoserConfig.CoserOption
+ fr.ifremer.coser.CoserConfig
+ </import>
+
+ <ConfigurationHandler id="handler" />
+ <CoserConfig id="config" initializer="getContextValue(CoserConfig.class)" />
+
+ <Table>
+ <row>
+ <cell fill="both" columns="2">
+ <Table border='{BorderFactory.createTitledBorder(_("coser.ui.configuration.category.path"))}'>
+ <row>
+ <cell fill="horizontal">
+ <JLabel text="{CoserBusinessOption.PROJECTS_DIRECTORY.getDescription()}" />
+ </cell>
+ <cell weightx="1" fill="horizontal">
+ <JTextField id="projectDirectoryField" text="{config.getProjectsDirectory().getAbsolutePath()}"/>
+ </cell>
+ <cell fill="horizontal">
+ <JButton text="coser.ui.common.selectFile"
+ onActionPerformed="getHandler().selectInputDirectory(this, projectDirectoryField)"/>
+ </cell>
+ </row>
+ <row>
+ <cell fill="horizontal">
+ <JLabel text="{CoserBusinessOption.VALIDATOR_DIRECTORY.getDescription()}" />
+ </cell>
+ <cell fill="horizontal">
+ <JTextField id="validatorDirectoryField" text="{config.getValidatorsDirectory().getAbsolutePath()}"/>
+ </cell>
+ <cell fill="horizontal">
+ <JButton text="coser.ui.common.selectFile"
+ onActionPerformed="getHandler().selectInputDirectory(this, validatorDirectoryField)"/>
+ </cell>
+ </row>
+ <row>
+ <cell fill="horizontal">
+ <JLabel text="{CoserBusinessOption.REFERENCE_SPECIES.getDescription()}" />
+ </cell>
+ <cell fill="horizontal">
+ <JTextField id="referenceSpeciesField" text="{config.getReferenceSpeciesPath()}"/>
+ </cell>
+ <cell fill="horizontal">
+ <JButton text="coser.ui.common.selectFile"
+ onActionPerformed="getHandler().selectInputFile(this, referenceSpeciesField)"/>
+ </cell>
+ </row>
+ <row>
+ <cell fill="horizontal">
+ <JLabel text="{CoserBusinessOption.REFERENCE_TYPE_ESPECES.getDescription()}" />
+ </cell>
+ <cell fill="horizontal">
+ <JTextField id="referenceTypeEspecesField" text="{config.getReferenceTypeEspecesPath()}"/>
+ </cell>
+ <cell fill="horizontal">
+ <JButton text="coser.ui.common.selectFile"
+ onActionPerformed="getHandler().selectInputFile(this, referenceTypeEspecesField)"/>
+ </cell>
+ </row>
+ <row>
+ <cell fill="horizontal">
+ <JLabel text="{CoserBusinessOption.WEB_ZONES.getDescription()}" />
+ </cell>
+ <cell fill="horizontal">
+ <JTextField id="webZonesField" text="{config.getWebZonesFile().getAbsolutePath()}"/>
+ </cell>
+ <cell fill="horizontal">
+ <JButton text="coser.ui.common.selectFile"
+ onActionPerformed="getHandler().selectInputFile(this, webZonesField)"/>
+ </cell>
+ </row>
+ <row>
+ <cell fill="horizontal">
+ <JLabel text="{CoserBusinessOption.WEB_FRONT_END.getDescription()}" />
+ </cell>
+ <cell columns="2" fill="horizontal">
+ <JTextField id="webFrontEndField" text="{config.getWebFrontEnd()}"/>
+ </cell>
+ </row>
+ </Table>
+ </cell>
+ </row>
+ <row>
+ <cell fill="both" columns="2">
+ <Table border='{BorderFactory.createTitledBorder(_("coser.ui.configuration.category.controlselection"))}'>
+ <row>
+ <cell fill="horizontal">
+ <JLabel text="{CoserBusinessOption.CONTROL_NOBSMIN.getDescription()}" />
+ </cell>
+ <cell weightx="1" fill="horizontal">
+ <JTextField id="controlNobsMinField" text="{String.valueOf(config.getControlNobsmin())}"/>
+ </cell>
+ </row>
+ <row>
+ <cell fill="horizontal">
+ <JLabel text="{CoserBusinessOption.CONTROL_DIFF_CATCH_LENGTH.getDescription()}" />
+ </cell>
+ <cell fill="horizontal">
+ <JTextField id="controlDiffCatchLengthField" text="{String.valueOf(config.getControlDiffCatchLength())}" />
+ </cell>
+ </row>
+ <row>
+ <cell fill="horizontal">
+ <JLabel text="{CoserBusinessOption.CONTROL_TYPE_FISH.getDescription()}" />
+ </cell>
+ <cell fill="horizontal">
+ <JTextField id="controlTypeFishField" text="{config.getControlTypeFish()}" />
+ </cell>
+ </row>
+ <row>
+ <cell fill="horizontal">
+ <JLabel text="{CoserBusinessOption.SELECTION_FILTER_OCCURRENCE.getDescription()}" />
+ </cell>
+ <cell fill="horizontal">
+ <JTextField id="selectionFilterOccurrenceField" text="{String.valueOf(config.getSelectionOccurrenceFilter())}" />
+ </cell>
+ </row>
+ <row>
+ <cell fill="horizontal">
+ <JLabel text="{CoserBusinessOption.SELECTION_FILTER_DENSITY.getDescription()}" />
+ </cell>
+ <cell fill="horizontal">
+ <JTextField id="selectionFilterDensityField" text="{String.valueOf(config.getSelectionDensityFilter())}" />
+ </cell>
+ </row>
+ </Table>
+ </cell>
+ </row>
+ <row>
+ <cell fill="both" columns="2">
+ <Table border='{BorderFactory.createTitledBorder(_("coser.ui.configuration.category.misc"))}'>
+ <row>
+ <cell fill="horizontal">
+ <JLabel text="{CoserBusinessOption.SMTP_HOST.getDescription()}" />
+ </cell>
+ <cell weightx="1" fill="horizontal">
+ <JTextField id="smtpHostField" text="{config.getSmtpHost()}" />
+ </cell>
+ </row>
+ <row>
+ <cell fill="horizontal">
+ <JLabel text="{CoserOption.SUPPORT_EMAIL.getDescription()}" />
+ </cell>
+ <cell fill="horizontal">
+ <JTextField id="supportEmailField" text="{config.getSupportEmail()}" />
+ </cell>
+ </row>
+ <row>
+ <cell fill="horizontal">
+ <JLabel text="{CoserOption.SWING_FONT_SIZE.getDescription()}" />
+ </cell>
+ <cell fill="horizontal">
+ <JComboBox id="swingFontSizeField" constructorParams='new Object[]{"12", "14", "16", "18", "20"}'
+ selectedItem="{String.valueOf(config.getSwingFontSize())}" />
+ </cell>
+ </row>
+ </Table>
+ </cell>
+ </row>
+ <row>
+ <cell anchor="east" weightx="1">
+ <JButton text="coser.ui.common.valid"
+ onActionPerformed="getHandler().saveConfiguration(this)"/>
+ </cell>
+ <cell anchor="west" weightx="1">
+ <JButton text="coser.ui.common.cancel"
+ onActionPerformed="dispose()"/>
+ </cell>
+ </row>
+ </Table>
+</JDialog>
\ No newline at end of file
Modified: trunk/coser-ui/src/main/resources/i18n/coser-ui_en_GB.properties
===================================================================
--- trunk/coser-ui/src/main/resources/i18n/coser-ui_en_GB.properties 2011-11-07 10:31:24 UTC (rev 890)
+++ trunk/coser-ui/src/main/resources/i18n/coser-ui_en_GB.properties 2011-11-15 18:18:06 UTC (rev 891)
@@ -1,13 +1,8 @@
coser.config.application.version.description=Application's version
-coser.config.category.configuration=Configuration
-coser.config.category.configuration.description=Configuration (numerics data)
-coser.config.category.misc=Misc
-coser.config.category.misc.description=Misc
-coser.config.category.path=Path
-coser.config.category.path.description=File and directory configuration
coser.config.config.file.description=Coser configuration file
coser.config.lookandfeel.description=Application's swing theme
coser.config.support.email.description=Support email address
+coser.config.swingfontsize.description=Application fonts size
coser.config.website.description=Coser website
coser.ui.about.about=<html><b>Coser</b><br /><br />Version %s<br /><br />Usefull links \:<ul><li><a href\="http\://maven-site.forge.codelutin.com/coser/">Documentation</a></li><li><a href\="http\://forge.codelutin.com/projects/coser/issues">Bug report</a></li></ul><br /><br />Copyright 2010 - 2011 <a href\="http\://www.ifremer.fr">Ifremer</a>, <a href\="http\://www.codelutin.com">Code Lutin</a><html>
coser.ui.about.title=About Coser
@@ -20,7 +15,10 @@
coser.ui.common.unselectAll.short=None
coser.ui.common.valid=Valid
coser.ui.common.yes=Yes
-coser.ui.config.title=Configuration
+coser.ui.configuration.category.controlselection=Control and selection
+coser.ui.configuration.category.misc=Misc
+coser.ui.configuration.category.path=Paths
+coser.ui.configuration.title=Configuration
coser.ui.control.categorylabel=Displayed data \:
coser.ui.control.checkData=Check data
coser.ui.control.comment=Comment \:
Modified: trunk/coser-ui/src/main/resources/i18n/coser-ui_fr_FR.properties
===================================================================
--- trunk/coser-ui/src/main/resources/i18n/coser-ui_fr_FR.properties 2011-11-07 10:31:24 UTC (rev 890)
+++ trunk/coser-ui/src/main/resources/i18n/coser-ui_fr_FR.properties 2011-11-15 18:18:06 UTC (rev 891)
@@ -1,13 +1,8 @@
coser.config.application.version.description=Version de l'application
-coser.config.category.configuration=Configuration
-coser.config.category.configuration.description=Configuration (données numériques)
-coser.config.category.misc=Divers
-coser.config.category.misc.description=Divers
-coser.config.category.path=Chemins
-coser.config.category.path.description=Configuration des fichiers et répertoires
coser.config.config.file.description=Fichier de configuration de Coser
coser.config.lookandfeel.description=Themes graphique Swing de l'application
coser.config.support.email.description=Adresse de support pour l'envoi des erreurs
+coser.config.swingfontsize.description=Taille de la police
coser.config.website.description=Site internet de Coser
coser.ui.about.about=<html><b>Coser</b><br /><br />Version %s<br /><br />Liens utiles \:<ul><li><a href\="http\://maven-site.forge.codelutin.com/coser/">Documentation</a></li><li><a href\="http\://forge.codelutin.com/projects/coser/issues">Rapport de bug</a></li></ul><br /><br />Copyright 2010 - 2011 <a href\="http\://www.ifremer.fr">Ifremer</a>, <a href\="http\://www.codelutin.com">Code Lutin</a><html>
coser.ui.about.title=À propos de Coser
@@ -20,7 +15,10 @@
coser.ui.common.unselectAll.short=Aucun
coser.ui.common.valid=Valider
coser.ui.common.yes=Oui
-coser.ui.config.title=Configuration
+coser.ui.configuration.category.controlselection=Contrôle et sélection
+coser.ui.configuration.category.misc=Divers
+coser.ui.configuration.category.path=Chemins
+coser.ui.configuration.title=Configuration
coser.ui.control.categorylabel=Données affichées \:
coser.ui.control.checkData=Vérifier les données
coser.ui.control.comment=Commentaire \:
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2011-11-07 10:31:24 UTC (rev 890)
+++ trunk/pom.xml 2011-11-15 18:18:06 UTC (rev 891)
@@ -20,7 +20,6 @@
<module>coser-web</module>
</modules>
-
<distributionManagement>
<site>
<id>${platform}</id>
@@ -34,7 +33,7 @@
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
- <version>4.9</version>
+ <version>4.10</version>
<scope>test</scope>
</dependency>
@@ -215,7 +214,7 @@
<dependency>
<groupId>com.bbn</groupId>
<artifactId>openmap</artifactId>
- <version>4.6.5</version>
+ <version>5.0.0-20111028</version>
<scope>compile</scope>
</dependency>
1
0
r890 - in trunk: coser-business/src/main/java/fr/ifremer/coser/services coser-business/src/main/resources/i18n coser-ui/src/main/java/fr/ifremer/coser/ui/maps
by echatellier@users.forge.codelutin.com 07 Nov '11
by echatellier@users.forge.codelutin.com 07 Nov '11
07 Nov '11
Author: echatellier
Date: 2011-11-07 11:31:24 +0100 (Mon, 07 Nov 2011)
New Revision: 890
Url: http://forge.codelutin.com/repositories/revision/coser/890
Log:
Improve haul tooltip on map.
Modified:
trunk/coser-business/src/main/java/fr/ifremer/coser/services/ProjectService.java
trunk/coser-business/src/main/resources/i18n/coser-business_en_GB.properties
trunk/coser-business/src/main/resources/i18n/coser-business_fr_FR.properties
trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/maps/CoserMap.java
trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/maps/HaulLocationHandler.java
trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/maps/HaulLocationLayer.java
Modified: trunk/coser-business/src/main/java/fr/ifremer/coser/services/ProjectService.java
===================================================================
--- trunk/coser-business/src/main/java/fr/ifremer/coser/services/ProjectService.java 2011-11-05 12:41:37 UTC (rev 889)
+++ trunk/coser-business/src/main/java/fr/ifremer/coser/services/ProjectService.java 2011-11-07 10:31:24 UTC (rev 890)
@@ -2884,7 +2884,7 @@
* @throws CoserBusinessException
*/
public List<Coordinate> getStrataHaulCoordinate(Selection selection, Collection<String> strataCollection) throws CoserBusinessException {
-
+
List<Coordinate> hauls = new ArrayList<Coordinate>();
Iterator<String[]> itData = selection.getHaul().iterator(true);
@@ -2893,14 +2893,18 @@
String strata = tuple[Haul.INDEX_STRATUM];
if (strataCollection.contains(strata)) {
+ String stratum = tuple[Haul.INDEX_STRATUM];
+ String year = tuple[Haul.INDEX_YEAR];
String haul = tuple[Haul.INDEX_HAUL];
+
String lat = tuple[Haul.INDEX_LAT];
String longi = tuple[Haul.INDEX_LONG];
-
+
double dlat = Double.parseDouble(lat);
double dlong = Double.parseDouble(longi);
-
- Coordinate coordinate = new Coordinate(haul, dlat, dlong);
+
+ String name = _("coser.business.map.haulname", stratum, year, haul);
+ Coordinate coordinate = new Coordinate(name, dlat, dlong);
hauls.add(coordinate);
}
}
Modified: trunk/coser-business/src/main/resources/i18n/coser-business_en_GB.properties
===================================================================
--- trunk/coser-business/src/main/resources/i18n/coser-business_en_GB.properties 2011-11-05 12:41:37 UTC (rev 889)
+++ trunk/coser-business/src/main/resources/i18n/coser-business_en_GB.properties 2011-11-07 10:31:24 UTC (rev 890)
@@ -96,6 +96,7 @@
coser.business.extract.projectName=Project name \:
coser.business.extract.selectionName=Selection name \:
coser.business.line=Line
+coser.business.map.haulname=Strata \: %s, Year \: %s, Haul \: %s
coser.business.matrix.density=Density
coser.business.matrix.lengthstructure=Length structures
coser.business.matrix.occurrence=Occurrence
Modified: trunk/coser-business/src/main/resources/i18n/coser-business_fr_FR.properties
===================================================================
--- trunk/coser-business/src/main/resources/i18n/coser-business_fr_FR.properties 2011-11-05 12:41:37 UTC (rev 889)
+++ trunk/coser-business/src/main/resources/i18n/coser-business_fr_FR.properties 2011-11-07 10:31:24 UTC (rev 890)
@@ -96,6 +96,7 @@
coser.business.extract.projectName=Nom du project \:
coser.business.extract.selectionName=Nom de la sélection \:
coser.business.line=Ligne
+coser.business.map.haulname=Strate \: %s, Année \: %s, Trait \: %s
coser.business.matrix.density=Densité
coser.business.matrix.lengthstructure=Structures en taille
coser.business.matrix.occurrence=Occurrence
Modified: trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/maps/CoserMap.java
===================================================================
--- trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/maps/CoserMap.java 2011-11-05 12:41:37 UTC (rev 889)
+++ trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/maps/CoserMap.java 2011-11-07 10:31:24 UTC (rev 890)
@@ -37,10 +37,6 @@
import com.bbn.openmap.MapBean;
import com.bbn.openmap.MouseDelegator;
import com.bbn.openmap.PropertyHandler;
-import com.bbn.openmap.event.CoordMouseMode;
-import com.bbn.openmap.event.MapMouseMode;
-import com.bbn.openmap.event.NavMouseMode;
-import com.bbn.openmap.event.NavMouseMode2;
import com.bbn.openmap.event.OMMouseMode;
import com.bbn.openmap.gui.OverlayMapPanel;
import com.bbn.openmap.layer.GraticuleLayer;
@@ -48,7 +44,6 @@
import com.bbn.openmap.layer.location.LocationLayer;
import com.bbn.openmap.layer.shape.ShapeLayer;
import com.bbn.openmap.omGraphics.DrawingAttributes;
-import com.bbn.openmap.tools.drawing.OMDrawingToolMouseMode;
import fr.ifremer.coser.bean.Project;
import fr.ifremer.coser.util.Coordinate;
@@ -130,7 +125,7 @@
}
else {
// les autres rouge (contour noir)
- addLayer(map.getAbsolutePath(), map.getAbsolutePath(), "ff000000", "ffE55B3C");
+ addLayer(map.getAbsolutePath(), map.getAbsolutePath(), "ff000000", "ffFDA908");
}
}
}
@@ -177,13 +172,14 @@
log.debug("Adding strata haul layer (" + hauls.size() + " coordinates)");
}
+ if (haulLocationLayer != null) {
+ removeMapComponent(haulLocationLayer);
+ }
HaulLocationHandler locationHandler = new HaulLocationHandler(hauls);
haulLocationLayer = new HaulLocationLayer();
haulLocationLayer.setLocationHandlers(new LocationHandler[]{locationHandler});
haulLocationLayer.addInfoDisplayListener(informationDelegator);
- //haulLocationLayer.set
addMapComponent(haulLocationLayer);
-
}
/**
Modified: trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/maps/HaulLocationHandler.java
===================================================================
--- trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/maps/HaulLocationHandler.java 2011-11-05 12:41:37 UTC (rev 889)
+++ trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/maps/HaulLocationHandler.java 2011-11-07 10:31:24 UTC (rev 890)
@@ -53,6 +53,7 @@
public HaulLocationHandler(List<Coordinate> coordinates) {
this.coordinates = coordinates;
setLocationColor(Color.RED);
+ setShowLocations(true);
}
/*
@@ -64,9 +65,9 @@
for (Coordinate coordinate : coordinates) {
Location location = new BasicLocation(coordinate.getLatitude(), coordinate.getLongitude(), coordinate.getName(), null);
location.setLocationHandler(this);
- location.getLabel().setLinePaint(Color.BLACK);
- location.getLabel().setMatted(true);
- location.setLinePaint(Color.BLUE);
+ //location.getLabel().setLinePaint(Color.BLACK);
+ //location.getLabel().setMatted(true);
+ //location.setLinePaint(Color.BLUE);
location.setShowName(true);
location.setShowLocation(true);
Modified: trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/maps/HaulLocationLayer.java
===================================================================
--- trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/maps/HaulLocationLayer.java 2011-11-05 12:41:37 UTC (rev 889)
+++ trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/maps/HaulLocationLayer.java 2011-11-07 10:31:24 UTC (rev 890)
@@ -25,9 +25,7 @@
package fr.ifremer.coser.ui.maps;
-import com.bbn.openmap.layer.DeclutterMatrix;
import com.bbn.openmap.layer.location.LocationLayer;
-import com.bbn.openmap.omGraphics.OMGraphic;
/**
* Haul location layer.
@@ -50,26 +48,4 @@
//setUseDeclutterMatrix(true);
//setDeclutterMatrix(new DeclutterMatrix());
}
-
- @Override
- public String getToolTipTextFor(OMGraphic omg) {
- return super.getToolTipTextFor(omg);
- }
-
- @Override
- public boolean isHighlightable(OMGraphic omg) {
- return super.isHighlightable(omg);
- }
-
- @Override
- public void highlight(OMGraphic omg) {
- super.highlight(omg);
- }
-
- @Override
- public String getInfoText(OMGraphic omg) {
- return super.getInfoText(omg);
- }
-
-
}
1
0
Author: tchemit
Date: 2011-11-05 13:41:37 +0100 (Sat, 05 Nov 2011)
New Revision: 889
Url: http://forge.codelutin.com/repositories/revision/coser/889
Log:
use license-m-p and webstart-m-p from codehaus, our are obsolete
Modified:
trunk/coser-ui/pom.xml
Modified: trunk/coser-ui/pom.xml
===================================================================
--- trunk/coser-ui/pom.xml 2011-11-04 18:18:44 UTC (rev 888)
+++ trunk/coser-ui/pom.xml 2011-11-05 12:41:37 UTC (rev 889)
@@ -143,8 +143,8 @@
<plugins>
<plugin>
- <groupId>org.nuiton</groupId>
- <artifactId>maven-license-plugin</artifactId>
+ <groupId>org.codehaus.mojo</groupId>
+ <artifactId>license-maven-plugin</artifactId>
<configuration>
<generateBundle>true</generateBundle>
</configuration>
@@ -305,7 +305,7 @@
</executions>
</plugin>
<plugin>
- <groupId>org.nuiton.thirdparty</groupId>
+ <groupId>org.codehaus.mojo.webstart</groupId>
<artifactId>webstart-maven-plugin</artifactId>
<configuration>
<libPath>lib</libPath>
@@ -361,9 +361,9 @@
<reporting>
<plugins>
<plugin>
- <groupId>org.nuiton.thirdparty</groupId>
+ <groupId>org.codehaus.mojo.webstart</groupId>
<artifactId>webstart-maven-plugin</artifactId>
- <version>1.0-alpha-2-cl_20100511</version>
+ <version>${webstartPluginVersion}</version>
</plugin>
</plugins>
</reporting>
1
0
r888 - in trunk: coser-business/src/main/java/fr/ifremer/coser/services coser-business/src/main/java/fr/ifremer/coser/util coser-ui/src/main/java/fr/ifremer/coser coser-ui/src/main/java/fr/ifremer/coser/ui/maps coser-ui/src/main/java/fr/ifremer/coser/ui/selection
by echatellier@users.forge.codelutin.com 04 Nov '11
by echatellier@users.forge.codelutin.com 04 Nov '11
04 Nov '11
Author: echatellier
Date: 2011-11-04 19:18:44 +0100 (Fri, 04 Nov 2011)
New Revision: 888
Url: http://forge.codelutin.com/repositories/revision/coser/888
Log:
#312 : V?\195?\169rifier la coh?\195?\169rence entre le code de strate dans le fichier Traits et l'appartenance des coordonn?\195?\169es g?\195?\169ographiques du trait au polygone de la strate
Added:
trunk/coser-business/src/main/java/fr/ifremer/coser/util/Coordinate.java
trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/maps/HaulLocationHandler.java
trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/maps/HaulLocationLayer.java
Modified:
trunk/coser-business/src/main/java/fr/ifremer/coser/services/ProjectService.java
trunk/coser-ui/src/main/java/fr/ifremer/coser/Coser.java
trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/maps/CoserMap.java
trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/SelectionDetailsView.jaxx
trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/SelectionHandler.java
Modified: trunk/coser-business/src/main/java/fr/ifremer/coser/services/ProjectService.java
===================================================================
--- trunk/coser-business/src/main/java/fr/ifremer/coser/services/ProjectService.java 2011-10-28 21:27:27 UTC (rev 887)
+++ trunk/coser-business/src/main/java/fr/ifremer/coser/services/ProjectService.java 2011-11-04 18:18:44 UTC (rev 888)
@@ -90,6 +90,7 @@
import fr.ifremer.coser.data.Length;
import fr.ifremer.coser.data.Strata;
import fr.ifremer.coser.storage.DataStorage;
+import fr.ifremer.coser.util.Coordinate;
import fr.ifremer.coser.util.ProgressMonitor;
/**
@@ -2873,4 +2874,37 @@
return result;
}
+
+ /**
+ * Get all strata's haul coordinates of given strata.
+ *
+ * @param selection project's selection
+ * @param strataCollection starta collection to get haul
+ * @return haul collection
+ * @throws CoserBusinessException
+ */
+ public List<Coordinate> getStrataHaulCoordinate(Selection selection, Collection<String> strataCollection) throws CoserBusinessException {
+
+ List<Coordinate> hauls = new ArrayList<Coordinate>();
+
+ Iterator<String[]> itData = selection.getHaul().iterator(true);
+ while (itData.hasNext()) {
+ String[] tuple = itData.next();
+
+ String strata = tuple[Haul.INDEX_STRATUM];
+ if (strataCollection.contains(strata)) {
+ String haul = tuple[Haul.INDEX_HAUL];
+ String lat = tuple[Haul.INDEX_LAT];
+ String longi = tuple[Haul.INDEX_LONG];
+
+ double dlat = Double.parseDouble(lat);
+ double dlong = Double.parseDouble(longi);
+
+ Coordinate coordinate = new Coordinate(haul, dlat, dlong);
+ hauls.add(coordinate);
+ }
+ }
+
+ return hauls;
+ }
}
Added: trunk/coser-business/src/main/java/fr/ifremer/coser/util/Coordinate.java
===================================================================
--- trunk/coser-business/src/main/java/fr/ifremer/coser/util/Coordinate.java (rev 0)
+++ trunk/coser-business/src/main/java/fr/ifremer/coser/util/Coordinate.java 2011-11-04 18:18:44 UTC (rev 888)
@@ -0,0 +1,84 @@
+/*
+ * #%L
+ *
+ *
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2011 Ifremer, Codelutin, Chatellier Eric
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 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 Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ * #L%
+ */
+
+package fr.ifremer.coser.util;
+
+import java.io.Serializable;
+
+/**
+ * Coordinate used to manipulate haul in map.
+ *
+ * @author chatellier
+ * @version $Revision$
+ *
+ * Last update : $Date$
+ * By : $Author$
+ */
+public class Coordinate implements Serializable {
+
+ /** serialVersionUID. */
+ private static final long serialVersionUID = -5111417883474394223L;
+
+ protected String name;
+
+ protected double latitude;
+
+ protected double longitude;
+
+ public Coordinate() {
+
+ }
+
+ public Coordinate(String name, double latitude, double longitude) {
+ this();
+ this.name = name;
+ this.latitude = latitude;
+ this.longitude = longitude;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ public double getLatitude() {
+ return latitude;
+ }
+
+ public void setLatitude(double latitude) {
+ this.latitude = latitude;
+ }
+
+ public double getLongitude() {
+ return longitude;
+ }
+
+ public void setLongitude(double longitude) {
+ this.longitude = longitude;
+ }
+}
Property changes on: trunk/coser-business/src/main/java/fr/ifremer/coser/util/Coordinate.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Modified: trunk/coser-ui/src/main/java/fr/ifremer/coser/Coser.java
===================================================================
--- trunk/coser-ui/src/main/java/fr/ifremer/coser/Coser.java 2011-10-28 21:27:27 UTC (rev 887)
+++ trunk/coser-ui/src/main/java/fr/ifremer/coser/Coser.java 2011-11-04 18:18:44 UTC (rev 888)
@@ -38,6 +38,8 @@
import org.nuiton.util.ArgumentsParserException;
import org.nuiton.widget.SwingSession;
+import com.bbn.openmap.MapBean;
+
import fr.ifremer.coser.services.ControlService;
import fr.ifremer.coser.services.ImportService;
import fr.ifremer.coser.services.ProjectService;
@@ -76,6 +78,9 @@
}
}
+ // OpenMap sysout
+ MapBean.suppressCopyright = true;
+
// catch wall application exception
launch(coserConfig);
Modified: trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/maps/CoserMap.java
===================================================================
--- trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/maps/CoserMap.java 2011-10-28 21:27:27 UTC (rev 887)
+++ trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/maps/CoserMap.java 2011-11-04 18:18:44 UTC (rev 888)
@@ -23,23 +23,35 @@
package fr.ifremer.coser.ui.maps;
+import java.awt.Color;
import java.io.File;
+import java.util.List;
import java.util.Properties;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import com.bbn.openmap.BufferedMapBean;
+import com.bbn.openmap.InformationDelegator;
import com.bbn.openmap.Layer;
import com.bbn.openmap.LayerHandler;
+import com.bbn.openmap.MapBean;
import com.bbn.openmap.MouseDelegator;
+import com.bbn.openmap.PropertyHandler;
+import com.bbn.openmap.event.CoordMouseMode;
import com.bbn.openmap.event.MapMouseMode;
import com.bbn.openmap.event.NavMouseMode;
+import com.bbn.openmap.event.NavMouseMode2;
+import com.bbn.openmap.event.OMMouseMode;
+import com.bbn.openmap.gui.OverlayMapPanel;
import com.bbn.openmap.layer.GraticuleLayer;
+import com.bbn.openmap.layer.location.LocationHandler;
+import com.bbn.openmap.layer.location.LocationLayer;
import com.bbn.openmap.layer.shape.ShapeLayer;
import com.bbn.openmap.omGraphics.DrawingAttributes;
+import com.bbn.openmap.tools.drawing.OMDrawingToolMouseMode;
import fr.ifremer.coser.bean.Project;
+import fr.ifremer.coser.util.Coordinate;
/**
* Coser map based open openmap.
@@ -50,44 +62,44 @@
* Last update : $Date$
* By : $Author$
*/
-public class CoserMap extends BufferedMapBean {
+public class CoserMap extends OverlayMapPanel {
/** serialVersionUID. */
private static final long serialVersionUID = 3134624721243512358L;
private static final Log log = LogFactory.getLog(CoserMap.class);
-
- protected LayerHandler layerHandler = new LayerHandler();
- protected MapMouseMode currentMouseMode;
+ protected InformationDelegator informationDelegator;
- protected MouseDelegator md;
+ protected LocationLayer haulLocationLayer;
protected static final float SCALE = 9500000f;
-
+
public CoserMap() {
- setScale(SCALE);
- md = new MouseDelegator(this);
- md.setDefaultMouseModes();
- setActiveMouseMode(new NavMouseMode());
- layerHandler.addLayerListener(this);
- //initMap();
- }
+ super(new PropertyHandler(new Properties()), true);
+ create();
- public void setActiveMouseMode(MapMouseMode mode) {
- md.setActiveMouseMode(mode);
- currentMouseMode = mode;
- // il faut remettre les listeners
- /*for (MapMouseListener l : orderedListener) {
- currentMouseMode.addMapMouseListener(l);
- }*/
+ MapBean mapBean = getMapBean();
+ mapBean.setScale(SCALE);
+
+ addMapComponent(new LayerHandler());
+ addMapComponent(new MouseDelegator(mapBean));
+
+ getMapBean().setBackgroundColor(new Color(0x99b3cc));
}
-
- public void initMap(Project project) {
+ public void initMap(Project project, InformationDelegator informationDelegator) {
+
+ this.informationDelegator = informationDelegator;
+ OMMouseMode mouseMode = new OMMouseMode();
+ mouseMode.setInfoDelegator(informationDelegator);
+ addMapComponent(mouseMode);
+
+ MapBean mapBean = getMapBean();
+
// centrée sur la france
- setCenter(50f, 0f);
- setScale(16000000f);
+ mapBean.setCenter(50f, 0f);
+ mapBean.setScale(16000000f);
// graticule layer
addGraticuleLayer();
@@ -151,10 +163,30 @@
p.setProperty("." + GraticuleLayer.TextColorProperty, "FF000000");
layer.setProperties("", p);
- layerHandler.addLayer(layer);
+ addMapComponent(layer);
}
-
+
/**
+ * Display stata's haul position in an openmap layer
+ *
+ * @param hauls coordinate to display on map
+ */
+ public void addStataHaulLayer(List<Coordinate> hauls) {
+
+ if (log.isDebugEnabled()) {
+ log.debug("Adding strata haul layer (" + hauls.size() + " coordinates)");
+ }
+
+ HaulLocationHandler locationHandler = new HaulLocationHandler(hauls);
+ haulLocationLayer = new HaulLocationLayer();
+ haulLocationLayer.setLocationHandlers(new LocationHandler[]{locationHandler});
+ haulLocationLayer.addInfoDisplayListener(informationDelegator);
+ //haulLocationLayer.set
+ addMapComponent(haulLocationLayer);
+
+ }
+
+ /**
* Add a new layer to the map depending on mapFile extension.
*
* @param layerId layer id
@@ -181,10 +213,10 @@
if (log.isDebugEnabled()) {
log.debug("Add layer " + layer);
}
- layerHandler.addLayer(layer);
+ addMapComponent(layer);
}
}
-
+
/**
* Manage shp layer display.
*
Added: trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/maps/HaulLocationHandler.java
===================================================================
--- trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/maps/HaulLocationHandler.java (rev 0)
+++ trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/maps/HaulLocationHandler.java 2011-11-04 18:18:44 UTC (rev 888)
@@ -0,0 +1,94 @@
+/*
+ * #%L
+ *
+ *
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2011 Codelutin, Chatellier Eric
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 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 Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ * #L%
+ */
+
+package fr.ifremer.coser.ui.maps;
+
+import java.awt.Color;
+import java.awt.Component;
+import java.util.List;
+
+import com.bbn.openmap.layer.location.AbstractLocationHandler;
+import com.bbn.openmap.layer.location.BasicLocation;
+import com.bbn.openmap.layer.location.Location;
+import com.bbn.openmap.layer.location.LocationLayer;
+import com.bbn.openmap.omGraphics.OMGraphicList;
+
+import fr.ifremer.coser.util.Coordinate;
+
+/**
+ * Handler used by {@link LocationLayer} to provide haul's locations.
+ *
+ * @author chatellier
+ * @version $Revision$
+ *
+ * Last update : $Date$
+ * By : $Author$
+ */
+public class HaulLocationHandler extends AbstractLocationHandler {
+
+ protected List<Coordinate> coordinates;
+
+ public HaulLocationHandler(List<Coordinate> coordinates) {
+ this.coordinates = coordinates;
+ setLocationColor(Color.RED);
+ }
+
+ /*
+ * @see com.bbn.openmap.layer.location.LocationHandler#get(float, float, float, float, com.bbn.openmap.omGraphics.OMGraphicList)
+ */
+ @Override
+ public OMGraphicList get(float nwLat, float nwLon, float seLat, float seLon, OMGraphicList graphicList) {
+
+ for (Coordinate coordinate : coordinates) {
+ Location location = new BasicLocation(coordinate.getLatitude(), coordinate.getLongitude(), coordinate.getName(), null);
+ location.setLocationHandler(this);
+ location.getLabel().setLinePaint(Color.BLACK);
+ location.getLabel().setMatted(true);
+ location.setLinePaint(Color.BLUE);
+ location.setShowName(true);
+ location.setShowLocation(true);
+
+ graphicList.add(location);
+ }
+
+ return graphicList;
+ }
+
+ /*
+ * @see com.bbn.openmap.layer.location.LocationHandler#getItemsForPopupMenu(com.bbn.openmap.layer.location.Location)
+ */
+ @Override
+ public List<Component> getItemsForPopupMenu(Location arg0) {
+ return null;
+ }
+
+ /*
+ * @see com.bbn.openmap.layer.location.LocationHandler#reloadData()
+ */
+ @Override
+ public void reloadData() {
+
+ }
+}
Property changes on: trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/maps/HaulLocationHandler.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Added: trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/maps/HaulLocationLayer.java
===================================================================
--- trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/maps/HaulLocationLayer.java (rev 0)
+++ trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/maps/HaulLocationLayer.java 2011-11-04 18:18:44 UTC (rev 888)
@@ -0,0 +1,75 @@
+/*
+ * #%L
+ *
+ *
+ * $Id$
+ * $HeadURL$
+ * %%
+ * Copyright (C) 2011 Codelutin, Chatellier Eric
+ * %%
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation, either version 3 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 Lesser Public License for more details.
+ *
+ * You should have received a copy of the GNU General Lesser Public
+ * License along with this program. If not, see
+ * <http://www.gnu.org/licenses/lgpl-3.0.html>.
+ * #L%
+ */
+
+package fr.ifremer.coser.ui.maps;
+
+import com.bbn.openmap.layer.DeclutterMatrix;
+import com.bbn.openmap.layer.location.LocationLayer;
+import com.bbn.openmap.omGraphics.OMGraphic;
+
+/**
+ * Haul location layer.
+ *
+ * See http://openmap.bbn.com/mailArchives/openmap-users/2004-06/2869.html
+ * for tooltip details.
+ *
+ * @author chatellier
+ * @version $Revision$
+ *
+ * Last update : $Date$
+ * By : $Author$
+ */
+public class HaulLocationLayer extends LocationLayer {
+
+ /** serialVersionUID. */
+ private static final long serialVersionUID = -4011021347597993208L;
+
+ public HaulLocationLayer() {
+ //setUseDeclutterMatrix(true);
+ //setDeclutterMatrix(new DeclutterMatrix());
+ }
+
+ @Override
+ public String getToolTipTextFor(OMGraphic omg) {
+ return super.getToolTipTextFor(omg);
+ }
+
+ @Override
+ public boolean isHighlightable(OMGraphic omg) {
+ return super.isHighlightable(omg);
+ }
+
+ @Override
+ public void highlight(OMGraphic omg) {
+ super.highlight(omg);
+ }
+
+ @Override
+ public String getInfoText(OMGraphic omg) {
+ return super.getInfoText(omg);
+ }
+
+
+}
Property changes on: trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/maps/HaulLocationLayer.java
___________________________________________________________________
Added: svn:keywords
+ Author Date Id Revision HeadURL
Modified: trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/SelectionDetailsView.jaxx
===================================================================
--- trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/SelectionDetailsView.jaxx 2011-10-28 21:27:27 UTC (rev 887)
+++ trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/SelectionDetailsView.jaxx 2011-11-04 18:18:44 UTC (rev 888)
@@ -167,7 +167,7 @@
</cell>
<cell anchor="northeast">
<JButton icon="map.png" toolTipText="coser.ui.selection.details.showMapTip"
- onActionPerformed='getDetailDecisionPanelLayout().show(getDetailDecisionPanel(), "ZONEMAP");' />
+ onActionPerformed='getDetailDecisionPanelLayout().show(getDetailDecisionPanel(), "ZONEMAP");getHandler().showStataOnMap(this);' />
</cell>
<cell anchor="northeast">
<JButton icon="table.png" toolTipText="coser.ui.selection.details.showSpreciesTip"
@@ -301,8 +301,8 @@
</Table>
</JScrollPane>
<JPanel layout="{new BorderLayout()}" constraints='"ZONEMAP"'>
- <com.bbn.openmap.gui.ToolPanel id='strataMapToolBar' javaBean='new com.bbn.openmap.gui.ToolPanel()' constraints='BorderLayout.NORTH' />
<fr.ifremer.coser.ui.maps.CoserMap id="strataMap" constraints='BorderLayout.CENTER' />
+ <com.bbn.openmap.InformationDelegator id="stataMapInfo" constraints='BorderLayout.SOUTH' />
</JPanel>
<JScrollPane constraints='"SPECIESGRAPH"'>
<JPanel id="speciesGraphPanel" layout="{new GridBagLayout()}"/>
Modified: trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/SelectionHandler.java
===================================================================
--- trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/SelectionHandler.java 2011-10-28 21:27:27 UTC (rev 887)
+++ trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/selection/SelectionHandler.java 2011-11-04 18:18:44 UTC (rev 888)
@@ -28,6 +28,7 @@
import java.awt.Component;
import java.awt.GridBagConstraints;
import java.awt.Insets;
+import java.awt.Point;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseEvent;
@@ -80,6 +81,7 @@
import fr.ifremer.coser.ui.result.SelectionEditResultDialog;
import fr.ifremer.coser.ui.selection.model.OccurrenceDensitySpeciesListModel;
import fr.ifremer.coser.ui.util.CoserListSelectionModel;
+import fr.ifremer.coser.util.Coordinate;
/**
* Selection handler.
@@ -382,12 +384,11 @@
// add layers
Project project = view.getContextValue(Project.class);
- view.getStrataMap().initMap(project);
+ view.getStrataMap().initMap(project, view.getStataMapInfo());
+ view.getStataMapInfo().setMap(view.getStrataMap().getMapBean());
+ view.getStataMapInfo().setShowCoordsInfoLine(true);
+ view.getStataMapInfo().setShowInfoLine(true);
- // link toolbar with map
- OMToolSet toolSet = new OMToolSet();
- toolSet.setupListeners(view.getStrataMap());
- view.getStrataMapToolBar().add((Tool)toolSet);
}
/**
@@ -1041,7 +1042,32 @@
view.getMatrixPanelEditor().getTable().setDefaultRenderer(String.class,
new SamplingEffortRenderer((MatrixTableModelND)view.getMatrixPanelEditor().getTable().getModel()));
}
+
+ /**
+ * Display selected strata haul position in map.
+ *
+ * @param view view
+ */
+ public void showStataOnMap(SelectionDetailsView view) {
+ Selection selection = view.getContextValue(Selection.class);
+ ProjectService projectService = view.getContextValue(ProjectService.class);
+
+ // get selected stata
+ Object[] selectedStrataArray = view.getStrataList().getSelectedValues();
+ Set<String> selectedStata = new HashSet<String>();
+ for (Object selectedStrataItem : selectedStrataArray) {
+ selectedStata.add((String)selectedStrataItem);
+ }
+ // display on map
+ try {
+ List<Coordinate> hauls = projectService.getStrataHaulCoordinate(selection, selectedStata);
+ view.getStrataMap().addStataHaulLayer(hauls);
+ } catch (CoserBusinessException ex) {
+ throw new CoserException("Can't display stata's hauls on map", ex);
+ }
+ }
+
/**
* Display data graph, initialized with graph for selected specy
* selected.
1
0
Author: maven-release
Date: 2011-10-28 23:27:27 +0200 (Fri, 28 Oct 2011)
New Revision: 887
Url: http://forge.codelutin.com/repositories/revision/coser/887
Log:
Update mavenpom4redmine to 3.0.5.
Modified:
trunk/pom.xml
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2011-10-28 13:33:10 UTC (rev 886)
+++ trunk/pom.xml 2011-10-28 21:27:27 UTC (rev 887)
@@ -6,7 +6,7 @@
<parent>
<groupId>org.nuiton</groupId>
<artifactId>mavenpom4redmine</artifactId>
- <version>3.0.4</version>
+ <version>3.0.5</version>
</parent>
<groupId>fr.ifremer</groupId>
1
0
r886 - in trunk: . coser-ui coser-ui/src/main/java/fr/ifremer/coser/ui/option
by echatellier@users.forge.codelutin.com 28 Oct '11
by echatellier@users.forge.codelutin.com 28 Oct '11
28 Oct '11
Author: echatellier
Date: 2011-10-28 15:33:10 +0200 (Fri, 28 Oct 2011)
New Revision: 886
Url: http://forge.codelutin.com/repositories/revision/coser/886
Log:
Remove spring
Modified:
trunk/coser-ui/pom.xml
trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/option/OptionHandler.java
trunk/pom.xml
Modified: trunk/coser-ui/pom.xml
===================================================================
--- trunk/coser-ui/pom.xml 2011-10-27 15:15:16 UTC (rev 885)
+++ trunk/coser-ui/pom.xml 2011-10-28 13:33:10 UTC (rev 886)
@@ -108,10 +108,6 @@
<groupId>com.bbn</groupId>
<artifactId>openmap</artifactId>
</dependency>
- <dependency>
- <groupId>org.springframework</groupId>
- <artifactId>spring-core</artifactId>
- </dependency>
</dependencies>
<name>Coser :: UI</name>
Modified: trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/option/OptionHandler.java
===================================================================
--- trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/option/OptionHandler.java 2011-10-27 15:15:16 UTC (rev 885)
+++ trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/option/OptionHandler.java 2011-10-28 13:33:10 UTC (rev 886)
@@ -28,6 +28,7 @@
import java.io.File;
import java.io.IOException;
import java.net.URL;
+import java.util.List;
import javax.swing.JOptionPane;
import javax.swing.tree.TreePath;
@@ -38,8 +39,7 @@
import org.apache.commons.lang.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
-import org.springframework.core.io.Resource;
-import org.springframework.core.io.support.PathMatchingResourcePatternResolver;
+import org.nuiton.util.Resource;
import fr.ifremer.coser.CoserConfig;
import fr.ifremer.coser.CoserConstants.Category;
@@ -109,14 +109,13 @@
// ne match que dans coser
try {
- PathMatchingResourcePatternResolver resolver = new PathMatchingResourcePatternResolver(Thread.currentThread().getContextClassLoader());
- Resource[] resources = resolver.getResources("classpath:/validators/fr/ifremer/coser/data/*.xml");
+ List<URL> resources = Resource.getResources("validators/fr/ifremer/coser/data/.*\\.xml",
+ Thread.currentThread().getContextClassLoader());
if (log.isDebugEnabled()) {
- log.debug("XML resources found : " + resources.length + " files");
+ log.debug("XML resources found : " + resources.size() + " files");
}
- for (Resource resource : resources) {
- URL url = resource.getURL();
- String path = url.getPath();
+ for (URL resource : resources) {
+ String path = resource.getPath();
String lastPath = path.substring(path.indexOf("/validators/") + "/validators/".length());
String folderPath = lastPath.substring(0, lastPath.lastIndexOf('/'));
String name = lastPath.substring(lastPath.lastIndexOf('/') + 1);
@@ -126,10 +125,10 @@
File validatorFile = new File(validatorDirectory, name);
if (log.isDebugEnabled()) {
- log.debug("Coping resources " + url + " to " + validatorFile.getAbsolutePath());
+ log.debug("Coping resources " + resource + " to " + validatorFile.getAbsolutePath());
}
- FileUtils.copyURLToFile(url, validatorFile);
+ FileUtils.copyURLToFile(resource, validatorFile);
}
} catch (IOException ex) {
if (log.isErrorEnabled()) {
Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml 2011-10-27 15:15:16 UTC (rev 885)
+++ trunk/pom.xml 2011-10-28 13:33:10 UTC (rev 886)
@@ -288,13 +288,6 @@
<version>2.3.18</version>
<scope>compile</scope>
</dependency>
-
- <dependency>
- <groupId>org.springframework</groupId>
- <artifactId>spring-core</artifactId>
- <version>3.0.5.RELEASE</version>
- <scope>compile</scope>
- </dependency>
</dependencies>
</dependencyManagement>
1
0