Author: tchemit Date: 2008-02-12 23:19:01 +0000 (Tue, 12 Feb 2008) New Revision: 880 Added: trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/DetailToTreeAction.java Modified: trunk/simexplorer-is/simexplorer-is-swing/src/resources/actions.properties trunk/simexplorer-is/simexplorer-is-swing/src/uimodel/fr/cemagref/simexplorer/is/ui/swing/JDetailTab.jaxx Log: ajout action detail to tree Added: trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/DetailToTreeAction.java =================================================================== --- trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/DetailToTreeAction.java (rev 0) +++ trunk/simexplorer-is/simexplorer-is-swing/src/java/fr/cemagref/simexplorer/is/ui/swing/actions/DetailToTreeAction.java 2008-02-12 23:19:01 UTC (rev 880) @@ -0,0 +1,88 @@ +/* +* ##% Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008 Code Lutin, +* Tony Chemit, Gabriel Landais +* +* This program is free software; you can redistribute it and/or +* modify it under the terms of the GNU General Public License +* as published by the Free Software Foundation; either version 2 +* of the License, or (at your option) any later version. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with this program; if not, write to the Free Software +* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +* ##% */ +package fr.cemagref.simexplorer.is.ui.swing.actions; + +import fr.cemagref.simexplorer.is.entities.data.LoggableElement; +import fr.cemagref.simexplorer.is.entities.metadata.Version; +import fr.cemagref.simexplorer.is.ui.StorageServiceHelper; +import fr.cemagref.simexplorer.is.ui.swing.JDetailTab; +import fr.cemagref.simexplorer.is.ui.swing.SimExplorerUIRefreshHelper; +import fr.cemagref.simexplorer.is.ui.swing.actions.util.SimExplorerAbstractTabAction; +import fr.cemagref.simexplorer.is.ui.swing.model.DetailTabModel; +import fr.cemagref.simexplorer.is.ui.swing.model.LoggableElementTreeNode; + +import java.awt.event.ActionEvent; + +/** + * Action pour positionner un element comme root de l'arbre de navigation à + * partir de son detail + * + * @author chemit + */ + at jaxx.runtime.builder.ActionConfig( + actionCommand = "detailToTreeApplication", + name = "simexplorer.action.detailToTree", + shortDescription = "simexplorer.action.detailToTree.tooltip", + longDescription = "simexplorer.action.detailToTree.help", + smallIcon = "action/detail-to-tree.png", + mnemonic = 'd', + hideActionText = true +) +public class DetailToTreeAction extends SimExplorerAbstractTabAction { + + LoggableElementTreeNode node; + LoggableElement element; + String uuid; + Version version; + DetailTabModel model; + + private static final long serialVersionUID = 2165684159831076054L; + + public DetailToTreeAction(String name) { + super(name); + } + + @Override + protected boolean beforeAction(ActionEvent e) throws Exception { + if (!super.beforeAction(e)) { + return false; + } + model = (DetailTabModel) getModel(); + uuid = model.getDetail().getUuid(); + version = model.getSelectedVersion(); + element = StorageServiceHelper.getElement(getContext(), model.isRemote(), uuid, version.toString()); + return element != null; + } + + @Override + protected void doAction(ActionEvent e) throws Exception { + model.setRootNode(element); + SimExplorerUIRefreshHelper.updateDetailNavigationTree((JDetailTab) getUI(), model); + } + + @Override + protected void clear() { + super.clear(); + node = null; + element = null; + version = null; + uuid = null; + model = null; + } +} \ No newline at end of file Modified: trunk/simexplorer-is/simexplorer-is-swing/src/resources/actions.properties =================================================================== --- trunk/simexplorer-is/simexplorer-is-swing/src/resources/actions.properties 2008-02-12 21:55:59 UTC (rev 879) +++ trunk/simexplorer-is/simexplorer-is-swing/src/resources/actions.properties 2008-02-12 23:19:01 UTC (rev 880) @@ -58,6 +58,9 @@ # delete action action.deleteElement=fr.cemagref.simexplorer.is.ui.swing.actions.DeleteElementAction +# detail to tree action +action.detailToTree=fr.cemagref.simexplorer.is.ui.swing.actions.DetailToTreeAction + # import- export actions action.exportElement=fr.cemagref.simexplorer.is.ui.swing.actions.ExportAction action.exportElementToLocal=fr.cemagref.simexplorer.is.ui.swing.actions.ExportToLocalAction Modified: trunk/simexplorer-is/simexplorer-is-swing/src/uimodel/fr/cemagref/simexplorer/is/ui/swing/JDetailTab.jaxx =================================================================== --- trunk/simexplorer-is/simexplorer-is-swing/src/uimodel/fr/cemagref/simexplorer/is/ui/swing/JDetailTab.jaxx 2008-02-12 21:55:59 UTC (rev 879) +++ trunk/simexplorer-is/simexplorer-is-swing/src/uimodel/fr/cemagref/simexplorer/is/ui/swing/JDetailTab.jaxx 2008-02-12 23:19:01 UTC (rev 880) @@ -12,6 +12,7 @@ <cell anchor="east"> <JToolBar> <JButton id='collapseAllDetail'/> + <JButton id='collapseAllDetail'/> <JButton id='expandAllDetail'/> </JToolBar> </cell> @@ -68,8 +69,23 @@ <cell anchor='west'> <JLabel text='simexplorer.common.version'/> </cell> - <cell weightx="1" anchor='west'> - <JComboBox id='detailVersions' model='{new DefaultComboBoxModel()}'/> + <cell weightx="1" anchor='west' fill="both"> + <Table> + <row fill="both"> + <cell anchor="west"> + <JComboBox id='detailVersions' model='{new DefaultComboBoxModel()}'/> + </cell> + <cell fill="horizontal" weightx="2"> + <JLabel text=""/> + </cell> + <cell anchor="east"> + <JToolBar> + <JButton id='detailToTree'/> + </JToolBar> + </cell> + </row> + </Table> + </cell> </row> <row fill='vertical'>