r2089 - in isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui: . script
Author: chatellier Date: 2009-04-08 12:43:46 +0000 (Wed, 08 Apr 2009) New Revision: 2089 Removed: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/UIHelper.java Modified: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/script/ExportDialogUI.jaxx Log: Remove unused code (swixat specific) Deleted: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/UIHelper.java =================================================================== --- isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/UIHelper.java 2009-04-08 10:24:31 UTC (rev 2088) +++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/UIHelper.java 2009-04-08 12:43:46 UTC (rev 2089) @@ -1,228 +0,0 @@ -/* *##% - * Copyright (C) 2006 - 2009 - * Ifremer, Code Lutin, Cédric Pineau, Benjamin Poussin - * - * 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. - *##%*/ - -/* * - * UIHelper.java - * - * Created: 10 août 2006 12:08:13 - * - * @author poussin - * @version $Revision$ - * - * Last update: $Date$ - * by : $Author$ - */ - -package fr.ifremer.isisfish.ui; - -import fr.ifremer.isisfish.ui.util.IDialog; - - -import org.codelutin.topia.TopiaContext; -import org.codelutin.util.FileUtil; - -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; - -import javax.swing.AbstractAction; -import javax.swing.JButton; -import javax.swing.JDialog; -import javax.swing.JTable; -import javax.swing.JTextField; -import static javax.swing.Action.NAME; -import javax.swing.table.TableColumn; -import java.io.File; - - -/** - * Set of usefull method for all swixat UI - * - * @author poussin - */ -public class UIHelper { - - /** - * to use log facility, just put in your code: log.info(\"...\"); - */ - static private Log log = LogFactory.getLog(UIHelper.class); - - /** - * only used to debug action in XML - * - * @param o object - */ - static public void print(Object o) { - System.out.println("++++++++++ print: '" + o + "'(" + (o != null ? o.getClass().getName() : "null") + ")"); - } - - static public void closeContext(TopiaContext context) { - try { - log.debug("clause TopiaContext: " + context); - if (context != null) { - context.closeContext(); - } - } catch (Exception eee) { - log.warn("Can't close context: " + context, eee); - } - } - -// /** -// * Permet de modifier l'element selection dans l'arbre -// * -// * @param tree l'arbre ou doit se faire la selection -// * @param jmodel le JTreeModel de l'arbre -// * @param o l'objet a selectionner dans l'arbre -// */ -// static public void setTreeSelection(JTree tree, JTreeModel jmodel, Object o) { -// try { -// log.debug("try to select objet in tree: " + o); -// DefaultMutableTreeNode node = jmodel.getNode(o); -// TreeNode[] path = node.getPath(); -// if (log.isDebugEnabled()) { -// log.debug("chemin du prochain noeud selectionnée: " + Arrays.toString(path)); -// } -// TreePath newSelectionPath = new TreePath(path); -// tree.setSelectionPath(newSelectionPath); -// tree.scrollPathToVisible(newSelectionPath); -// tree.revalidate(); -// tree.repaint(); -// } catch (Exception eee) { -// log.warn("Can't select object in tree: " + o, eee); -// } -// } - -// static public void setTreeSelectionFirstChild(JTree tree, JTreeModel jmodel, Object o) { -// try { -// log.debug("try to select first child of objet in tree: " + o); -// DefaultMutableTreeNode node = jmodel.getNode(o); -// TreeNode[] path = ((DefaultMutableTreeNode) node.getFirstChild()).getPath(); -// if (log.isDebugEnabled()) { -// log.debug("chemin du prochain noeud selectionnée: " + Arrays.toString(path)); -// } -// TreePath newSelectionPath = new TreePath(path); -// tree.setSelectionPath(newSelectionPath); -// tree.scrollPathToVisible(newSelectionPath); -// tree.revalidate(); -// tree.repaint(); -// } catch (Exception eee) { -// log.warn("Can't select child of object in tree: " + o, eee); -// } -// } - - - public static void setColumnsWidth(JTable table, int... widths) { - for (int i = 0; i < widths.length; i++) { - String colName; - colName = table.getColumnName(i); - TableColumn column; - column = table.getColumn(colName); - column.setPreferredWidth(widths[i]); - } - table.repaint(); - } - - /** - * Init a dialog - * - * @param dial the dialog to prepare - * @param okAction action to be process by {@link fr.ifremer.isisfish.ui.util.IDialog#getOk()} button - * @param cancelAction action to be process by {@link fr.ifremer.isisfish.ui.util.IDialog#getCancel()}} button - * @param show flag to set visible dialog after init - * @param maxWidth maximum width authorized - * @param minHeight minimum height - * @param maxHeight maximum height authorized - */ - public static void prepareDialog(JDialog dial, AbstractAction okAction, - AbstractAction cancelAction, boolean show, - int maxWidth, int minHeight, int maxHeight) { - if (!IDialog.class.isAssignableFrom(dial.getClass())) { - return; - } - - IDialog dialog = (IDialog) dial; - //dialog.frame = frame; - if (okAction != null) { - okAction.putValue(NAME, dialog.getOk().getText()); - dialog.setOkAction(okAction); - dialog.getOk().setAction(okAction); - } - if (cancelAction != null) { - cancelAction.putValue(NAME, dialog.getCancel().getText()); - dialog.setCancelAction(cancelAction); - dialog.getCancel().setAction(cancelAction); - } - - dialog.setMaxWidth(maxWidth); - dialog.setMinHeight(minHeight); - dialog.setMaxHeight(maxHeight); - dialog.setMaximumSize(new java.awt.Dimension(maxWidth, maxHeight)); - - int width = dialog.computeWidth(); - int height = dialog.computeHeight(); - - if (width > maxWidth) { - width = maxWidth; - } - if (height > maxHeight) { - height = maxHeight; - } - dialog.setSize(width, height); - dialog.doRefresh(); - if (show) { - dialog.setVisible(true); - } - } - - /** - * Open a directory and push it back in the field given. - * it field given was previously containing the absolute path of a file - * then it will use the same file name for push back. - * - * @param field the JTextField containing the path where to put new dir - * @param ok the ok button to activate if everything is allwright - */ - public static void openDirChooser(JTextField field, JButton ok) { - // assumer field contain path to a filename - File dir = new File(field.getText()); - String name = ""; - File oldDir = dir; - if (dir.isFile() || !dir.exists()) { - name = dir.getName(); - oldDir = dir.getParentFile(); - } - - String newDir = FileUtil.getDirectory(); - - if (newDir != null) { - File newFile = new File(newDir); - String path; - - path = newFile.getAbsolutePath(); - if (!"".equals(name)) { - path += File.separator + name; - } - - field.setText(path); - } - ok.setEnabled(newDir != null || oldDir.exists()); - } - -} - - Modified: isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/script/ExportDialogUI.jaxx =================================================================== --- isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/script/ExportDialogUI.jaxx 2009-04-08 10:24:31 UTC (rev 2088) +++ isis-fish/trunk/src/main/java/fr/ifremer/isisfish/ui/script/ExportDialogUI.jaxx 2009-04-08 12:43:46 UTC (rev 2089) @@ -41,7 +41,8 @@ text='isisfish.script.export.chooseDir' toolTipText='isisfish.script.export.tooltip.chooseDir' enabled='{!isEmpty()}' - onActionPerformed="fr.ifremer.isisfish.ui.UIHelper.openDirChooser(archivePath,ok)"/> + /> + <!-- onActionPerformed="fr.ifremer.isisfish.ui.UIHelper.openDirChooser(archivePath,ok)" --> </cell> </row> <row fill='horizontal'>
participants (1)
-
chatellier@users.labs.libre-entreprise.org