r450 - in trunk/coser-ui/src/main: java/fr/ifremer/coser/ui java/fr/ifremer/coser/ui/maps java/fr/ifremer/coser/ui/option resources/i18n
Author: chatellier Date: 2010-12-24 16:29:46 +0000 (Fri, 24 Dec 2010) New Revision: 450 Log: Ajout d'une interface d'edition des fichiers de validation Added: trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/option/ trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/option/NoCopiedLayerUI.java trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/option/OptionHandler.java trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/option/ValidatorDialog.jaxx trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/option/ValidatorsTreeModel.java trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/option/ValidatorsTreeRenderer.java Removed: trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/ValidatorDialog.jaxx Modified: trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/CoserFrameHandler.java trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/maps/CoserMap.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 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 2010-12-24 16:28:42 UTC (rev 449) +++ trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/CoserFrameHandler.java 2010-12-24 16:29:46 UTC (rev 450) @@ -45,6 +45,7 @@ import jaxx.runtime.swing.editor.config.ConfigUI; import jaxx.runtime.swing.editor.config.ConfigUIHelper; +import org.apache.commons.lang.StringUtils; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.nuiton.widget.SwingSession; @@ -60,6 +61,9 @@ 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.NoCopiedLayerUI; +import fr.ifremer.coser.ui.option.OptionHandler; +import fr.ifremer.coser.ui.option.ValidatorDialog; import fr.ifremer.coser.ui.project.ProjectCreationView; import fr.ifremer.coser.ui.project.ProjectEditView; import fr.ifremer.coser.ui.project.ProjectHandler; @@ -213,11 +217,16 @@ * l'utilisateur. */ public void showValidatorsConfiguration() { + CoserConfig config = view.getContextValue(CoserConfig.class); ValidatorDialog validatorDialog = new ValidatorDialog(view); - URL sample = Catch.class.getResource("Catch-error-validation.xml"); - File sampleFile = new File(sample.getFile()); - validatorDialog.getValidationEditor().open(sampleFile); - validatorDialog.setLocationRelativeTo(null); + validatorDialog.setHandler(new OptionHandler()); + + // layer si non copié + if (!config.getValidatorsDirectory().isDirectory()) { + validatorDialog.getNoCopiedToDiskLayer().setUI(new NoCopiedLayerUI(validatorDialog)); + } + + validatorDialog.setLocationRelativeTo(view); validatorDialog.setVisible(true); } Deleted: trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/ValidatorDialog.jaxx =================================================================== --- trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/ValidatorDialog.jaxx 2010-12-24 16:28:42 UTC (rev 449) +++ trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/ValidatorDialog.jaxx 2010-12-24 16:29:46 UTC (rev 450) @@ -1,70 +0,0 @@ -<!-- - #%L - Coser :: UI - - $Id$ - $HeadURL$ - %% - Copyright (C) 2010 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.validators.title"> - <Table> - <row> - <cell columns="4" fill="horizontal"> - <JLabel font-style="italic" text="coser.ui.validators.description" /> - </cell> - </row> - <row> - <cell fill="horizontal"> - <JLabel text="coser.ui.validators.validators" /> - </cell> - <cell> - <JLabel text="coser.ui.validators.entity" /> - </cell> - <cell weightx="1" fill="horizontal" columns="2"> - <JComboBox /> - </cell> - </row> - <row> - <cell fill="both" weightx="1" weighty="1"> - <JScrollPane> - <JList /> - </JScrollPane> - </cell> - <cell weightx="2" weighty="1" fill="both" columns="3"> - <org.nuiton.widget.editor.Editor id="validationEditor" /> - </cell> - </row> - <row> - <cell fill="horizontal"> - <JButton text="coser.ui.validators.newValidator" /> - </cell> - <cell fill="horizontal"> - <JButton text="coser.ui.validators.deleteValidator" /> - </cell> - </row> - <row> - <cell columns="4" anchor="east" insets="0"> - <JPanel> - <JButton text="coser.ui.validators.cancel" onActionPerformed="dispose()"/> - <JButton text="coser.ui.validators.valid" onActionPerformed="dispose()"/> - </JPanel> - </cell> - </row> - </Table> -</JDialog> 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 2010-12-24 16:28:42 UTC (rev 449) +++ trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/maps/CoserMap.java 2010-12-24 16:29:46 UTC (rev 450) @@ -38,7 +38,6 @@ import com.bbn.openmap.layer.GraticuleLayer; import com.bbn.openmap.layer.shape.ShapeLayer; import com.bbn.openmap.omGraphics.DrawingAttributes; -import com.bbn.openmap.plugin.esri.EsriLayer; import fr.ifremer.coser.bean.Project; @@ -56,7 +55,7 @@ /** serialVersionUID. */ private static final long serialVersionUID = 3134624721243512358L; - private static Log log = LogFactory.getLog(CoserMap.class); + private static final Log log = LogFactory.getLog(CoserMap.class); protected LayerHandler layerHandler = new LayerHandler(); Added: trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/option/NoCopiedLayerUI.java =================================================================== --- trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/option/NoCopiedLayerUI.java (rev 0) +++ trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/option/NoCopiedLayerUI.java 2010-12-24 16:29:46 UTC (rev 450) @@ -0,0 +1,93 @@ +/* + * #%L + * + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2010 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.Color; +import java.awt.FlowLayout; +import java.awt.Graphics2D; +import java.awt.GridBagLayout; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; + +import javax.swing.JButton; +import javax.swing.JComponent; + +import org.jdesktop.jxlayer.JXLayer; +import org.jdesktop.jxlayer.plaf.ext.LockableUI; + +/** + * Layer transparent. + * + * @author chatellier + * @version $Revision$ + * + * Last update : $Date$ + * By : $Author$ + */ +public class NoCopiedLayerUI extends LockableUI implements ActionListener { + + protected ValidatorDialog view; + protected JButton copyToDiskButton; + + public NoCopiedLayerUI(ValidatorDialog view) { + this.view = view; + setLocked(true); + copyToDiskButton = new JButton("Copy to disk"); + copyToDiskButton.addActionListener(this); + } + + /* + * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent) + */ + @Override + public void actionPerformed(ActionEvent e) { + view.getHandler().copyDefaultValidators(view); + } + + @Override + protected void paintLayer(Graphics2D g2, JXLayer<JComponent> l) { + super.paintLayer(g2, l); + g2.setColor(new Color(150, 150, 150, 128)); + g2.fillRect(0, 0, l.getWidth(), l.getHeight()); + } + + @Override + public void installUI(JComponent c) { + super.installUI(c); + JXLayer<JComponent> l = (JXLayer<JComponent>) c; + l.getGlassPane().setLayout(new GridBagLayout()); + l.getGlassPane().add(copyToDiskButton); + //copyToDiskButton.setCursor(Cursor.getDefaultCursor()); + } + + @Override + public void uninstallUI(JComponent c) { + super.uninstallUI(c); + JXLayer<JComponent> l = (JXLayer<JComponent>) c; + l.getGlassPane().setLayout(new FlowLayout()); + l.getGlassPane().remove(copyToDiskButton); + } +} \ No newline at end of file Property changes on: trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/option/NoCopiedLayerUI.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: 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 (rev 0) +++ trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/option/OptionHandler.java 2010-12-24 16:29:46 UTC (rev 450) @@ -0,0 +1,160 @@ +/* + * #%L + * + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2010 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.io.File; +import java.io.IOException; +import java.net.URL; +import java.util.List; + +import javax.swing.JComponent; +import javax.swing.JPanel; +import javax.swing.plaf.PanelUI; +import javax.swing.tree.TreePath; + +import org.apache.commons.io.FileUtils; +import org.apache.commons.lang.StringUtils; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.jdesktop.jxlayer.plaf.BufferedLayerUI; +import org.nuiton.util.Resource; + +import fr.ifremer.coser.CoserConfig; +import fr.ifremer.coser.CoserConstants.Category; +import fr.ifremer.coser.CoserConstants.ValidationLevel; +import fr.ifremer.coser.data.Catch; +import fr.ifremer.coser.ui.common.CommonHandler; + +/** + * Handler for options. + * + * @author chatellier + * @version $Revision$ + * + * Last update : $Date$ + * By : $Author$ + */ +public class OptionHandler extends CommonHandler { + + private static final Log log = LogFactory.getLog(OptionHandler.class); + + /** + * Appelé par le layer pour copier les validateurs par defaut sur + * le disque de l'utilisateur. Les copies depuis le classpath (dossier + * "validators" vers le dossier défini par l'utilisateur. + * + * @param view view + */ + public void copyDefaultValidators(ValidatorDialog view) { + CoserConfig config = view.getContextValue(CoserConfig.class); + File validatorsDir = config.getValidatorsDirectory(); + validatorsDir.mkdirs(); + + // ne match que dans coser + List<URL> urls = Resource.getURLs(".*/validators/fr/ifremer/coser/.+\\.xml"); + for (URL url : urls) { + String path = url.getPath(); + String lastPath = path.substring(path.indexOf("/validators/") + "/validators/".length()); + String folderPath = lastPath.substring(0, lastPath.lastIndexOf('/')); + String name = lastPath.substring(lastPath.lastIndexOf('/') + 1); + + File validatorDirectory = new File(validatorsDir, folderPath); + validatorDirectory.mkdirs(); + File validatorFile = new File(validatorDirectory, name); + + if (log.isDebugEnabled()) { + log.debug("Coping resources " + url + " to " + validatorFile.getAbsolutePath()); + } + try { + FileUtils.copyURLToFile(url, validatorFile); + } catch (IOException e) { + e.printStackTrace(); + } + } + + // remove bloking layer + //view.getNoCopiedToDiskLayer().setUI(null); + // FIXME gros hack, j'arrive pas a enlever le layer + view.dispose(); + ValidatorDialog newView = new ValidatorDialog(view); + newView.setHandler(this); + newView.setLocationRelativeTo(view); + newView.setVisible(true); + } + + /** + * Control selected in tree. + * + * Dans ce cas, les fichiers sur disque existent, et on ne doit + * editer que ceux là, sinon enregistrer un fichier dans le classpath + * ca risque pas de fonctionner. + * + * @param view view + */ + public void selectValidator(ValidatorDialog view) { + + TreePath selectedPath = view.getValidatorsTree().getSelectionPath(); + if (selectedPath != null) { + Object[] path = selectedPath.getPath(); + + CoserConfig config = view.getContextValue(CoserConfig.class); + File validatorsDir = config.getValidatorsDirectory(); + + // si la selection est un sous context d'une categorie + if (path.length == 3) { + Category category = (Category)path[1]; + ValidationLevel level = (ValidationLevel)path[2]; + + String sPackage = Catch.class.getPackage().getName(); + + String validatorResource = sPackage.replace('.', '/') + "/"; + // c'est le meme nom actuellement + // au lower case et capitalize pret ;) + // CATCH = Catch + validatorResource += StringUtils.capitalize(category.toString().toLowerCase()); + validatorResource += "-" + level.getXWorkContext() + "-validation.xml"; + + File validatorFile = new File(validatorsDir, validatorResource); + + // look for resources in class path + if (log.isDebugEnabled()) { + log.debug("Looking for validator : " + validatorFile.getAbsoluteFile()); + } + + if (validatorFile.isFile()) { + view.getValidationEditor().open(validatorFile); + } + else { + view.getValidationEditor().close(); + } + view.getValidationEditor().validate(); + view.getValidationEditor().repaint(); + } + } + } + + +} Property changes on: trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/option/OptionHandler.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Copied: trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/option/ValidatorDialog.jaxx (from rev 300, trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/ValidatorDialog.jaxx) =================================================================== --- trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/option/ValidatorDialog.jaxx (rev 0) +++ trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/option/ValidatorDialog.jaxx 2010-12-24 16:29:46 UTC (rev 450) @@ -0,0 +1,64 @@ +<!-- + #%L + Coser :: UI + + $Id$ + $HeadURL$ + %% + Copyright (C) 2010 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.validators.title"> + <OptionHandler id="handler" javaBean="null" /> + <org.jdesktop.jxlayer.JXLayer id="noCopiedToDiskLayer"> + <Table> + <row> + <cell columns="2" fill="horizontal"> + <JLabel font-style="italic" text="coser.ui.validators.description" /> + </cell> + </row> + <row> + <cell fill="horizontal"> + <JLabel text="coser.ui.validators.validators" /> + </cell> + <cell fill="horizontal"> + <JLabel text="coser.ui.validators.content" /> + </cell> + </row> + <row> + <cell fill="both" weightx="1" weighty="1"> + <JScrollPane> + <ValidatorsTreeModel id="validatorsTreeModel" /> + <JTree id="validatorsTree" model="{validatorsTreeModel}" cellRenderer="{new ValidatorsTreeRenderer()}" + showsRootHandles="true" rootVisible="false" + onValueChanged="getHandler().selectValidator(this)" /> + </JScrollPane> + </cell> + <cell weightx="2" weighty="1" fill="both"> + <org.nuiton.widget.editor.Editor id="validationEditor" /> + </cell> + </row> + <row> + <cell columns="2" anchor="east" insets="0"> + <JPanel> + <JButton text="coser.ui.validators.valid" onActionPerformed="dispose()"/> + </JPanel> + </cell> + </row> + </Table> + </org.jdesktop.jxlayer.JXLayer> +</JDialog> Added: trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/option/ValidatorsTreeModel.java =================================================================== --- trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/option/ValidatorsTreeModel.java (rev 0) +++ trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/option/ValidatorsTreeModel.java 2010-12-24 16:29:46 UTC (rev 450) @@ -0,0 +1,161 @@ +/* + * #%L + * + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2010 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.util.ArrayList; +import java.util.List; + +import javax.swing.event.TreeModelListener; +import javax.swing.tree.TreeModel; +import javax.swing.tree.TreePath; + +import org.apache.commons.lang.ArrayUtils; +import org.jdesktop.swingx.tree.TreeModelSupport; + +import fr.ifremer.coser.CoserConstants.Category; +import fr.ifremer.coser.CoserConstants.ValidationLevel; + +/** + * Validators tree model. + * + * @author chatellier + * @version $Revision$ + * + * Last update : $Date$ + * By : $Author$ + */ +public class ValidatorsTreeModel implements TreeModel { + + protected TreeModelSupport support; + + protected Category[] dataCategory; + + public ValidatorsTreeModel() { + support = new TreeModelSupport(this); + + // les categories contiennent des données non liés aux données + List<Category> dataCategories = new ArrayList<Category>(); + for (Category category : Category.values()) { + if (category.isDataCategory()) { + dataCategories.add(category); + } + } + dataCategory = dataCategories.toArray(new Category[dataCategories.size()]); + } + + /* + * @see javax.swing.tree.TreeModel#getRoot() + */ + @Override + public Object getRoot() { + return 1L; + } + + /* + * @see javax.swing.tree.TreeModel#getChild(java.lang.Object, int) + */ + @Override + public Object getChild(Object parent, int index) { + + Object child = null; + + if (parent == getRoot()) { + child = dataCategory[index]; + } + else if (parent instanceof Category) { + child = ValidationLevel.values()[index]; + } + + return child; + } + + /* + * @see javax.swing.tree.TreeModel#getChildCount(java.lang.Object) + */ + @Override + public int getChildCount(Object parent) { + + int result = 0; + + if (parent == getRoot()) { + result = dataCategory.length; + } + else if (parent instanceof Category) { + result = ValidationLevel.values().length; + } + + return result; + } + + /* + * @see javax.swing.tree.TreeModel#isLeaf(java.lang.Object) + */ + @Override + public boolean isLeaf(Object node) { + return getChildCount(node) == 0; + } + + /* + * @see javax.swing.tree.TreeModel#valueForPathChanged(javax.swing.tree.TreePath, java.lang.Object) + */ + @Override + public void valueForPathChanged(TreePath path, Object newValue) { + + } + + /* + * @see javax.swing.tree.TreeModel#getIndexOfChild(java.lang.Object, java.lang.Object) + */ + @Override + public int getIndexOfChild(Object parent, Object child) { + int result = -1; + + if (parent == getRoot()) { + result = ArrayUtils.indexOf(dataCategory, child); + } + else if (parent instanceof Category) { + result = ArrayUtils.indexOf(ValidationLevel.values(), child); + } + + return result; + } + + /* + * @see javax.swing.tree.TreeModel#addTreeModelListener(javax.swing.event.TreeModelListener) + */ + @Override + public void addTreeModelListener(TreeModelListener l) { + support.addTreeModelListener(l); + } + + /* + * @see javax.swing.tree.TreeModel#removeTreeModelListener(javax.swing.event.TreeModelListener) + */ + @Override + public void removeTreeModelListener(TreeModelListener l) { + support.addTreeModelListener(l); + } +} Property changes on: trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/option/ValidatorsTreeModel.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL Added: trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/option/ValidatorsTreeRenderer.java =================================================================== --- trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/option/ValidatorsTreeRenderer.java (rev 0) +++ trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/option/ValidatorsTreeRenderer.java 2010-12-24 16:29:46 UTC (rev 450) @@ -0,0 +1,73 @@ +/* + * #%L + * + * + * $Id$ + * $HeadURL$ + * %% + * Copyright (C) 2010 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 static org.nuiton.i18n.I18n._; + +import java.awt.Component; + +import javax.swing.JTree; +import javax.swing.tree.DefaultTreeCellRenderer; + +import fr.ifremer.coser.CoserConstants.Category; +import fr.ifremer.coser.CoserConstants.ValidationLevel; + +/** + * Renderer pour l'arbre des navigateurs. + * + * Affiche les noms explicites à la place des Category et ValidationLevel. + * + * @author chatellier + * @version $Revision$ + * + * Last update : $Date$ + * By : $Author$ + */ +public class ValidatorsTreeRenderer extends DefaultTreeCellRenderer { + + /** serialVersionUID. */ + private static final long serialVersionUID = -2211918491839391988L; + + @Override + public Component getTreeCellRendererComponent(JTree tree, Object value, + boolean sel, boolean expanded, boolean leaf, int row, + boolean hasFocus) { + + Object stringValue = value; + + if (value instanceof Category) { + stringValue = _(((Category)value).getTranslationKey()); + } + else if (value instanceof ValidationLevel) { + // en attendant mieux + stringValue = _(((ValidationLevel)value).getXWorkContext()); + } + return super.getTreeCellRendererComponent(tree, stringValue, sel, expanded, leaf, + row, hasFocus); + } + + +} Property changes on: trunk/coser-ui/src/main/java/fr/ifremer/coser/ui/option/ValidatorsTreeRenderer.java ___________________________________________________________________ Added: svn:keywords + Author Date Id Revision HeadURL 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 2010-12-24 16:28:42 UTC (rev 449) +++ trunk/coser-ui/src/main/resources/i18n/coser-ui_en_GB.properties 2010-12-24 16:29:46 UTC (rev 450) @@ -219,11 +219,8 @@ coser.ui.uploadresult.selected=\u2026 coser.ui.uploadresult.title=Results publication coser.ui.uploadresult.upload=Send results -coser.ui.validators.cancel=Cancel -coser.ui.validators.deleteValidator=Delete +coser.ui.validators.content=Content \: coser.ui.validators.description=Application must be restarted after validators modification. -coser.ui.validators.entity=Entity -coser.ui.validators.newValidator=New Validator -coser.ui.validators.title=Validators +coser.ui.validators.title=Controls coser.ui.validators.valid=Valid coser.ui.validators.validators=Validators \: 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 2010-12-24 16:28:42 UTC (rev 449) +++ trunk/coser-ui/src/main/resources/i18n/coser-ui_fr_FR.properties 2010-12-24 16:29:46 UTC (rev 450) @@ -219,11 +219,8 @@ coser.ui.uploadresult.selected=\u2026 coser.ui.uploadresult.title=Publication des r\u00E9sultats coser.ui.uploadresult.upload=Envoyer les r\u00E9sultats -coser.ui.validators.cancel=Annuler -coser.ui.validators.deleteValidator=Supprimer +coser.ui.validators.content=Contenu \: coser.ui.validators.description=L'application doit \u00EAtre red\u00E9marr\u00E9e apr\u00E8s la modification des validateurs. -coser.ui.validators.entity=Entit\u00E9 -coser.ui.validators.newValidator=Nouveau validateur -coser.ui.validators.title=Validateurs +coser.ui.validators.title=Contr\u00F4les coser.ui.validators.valid=Valider coser.ui.validators.validators=Validateurs \:
participants (1)
-
chatellier@users.labs.libre-entreprise.org