[Buix-commits] r615 - in trunk/lutinvcs/ui/common/src/main: java/org/codelutin/vcs/ui java/org/codelutin/vcs/ui/action java/org/codelutin/vcs/ui/handler java/org/codelutin/vcs/ui/model java/org/codelutin/vcs/ui/util java/org/codelutin/vcs/ui/util/handler java/org/codelutin/vcs/ui/util/ui resources/i18n
Author: tchemit Date: 2008-04-25 23:42:54 +0000 (Fri, 25 Apr 2008) New Revision: 615 Added: trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/UIActionHelper.java trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/action/TestConnexionAction.java trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/util/AbstractShowUIAction.java trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/util/ui/AbstractFormUI.java Removed: trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/VCSUI.java trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/VCSUIProvider.java Modified: trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/ConfigUI.java trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/GenerateSshKeyUI.java trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/SynchUI.java trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/VCSInitializer.java trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/VCSUIFactory.java trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/handler/ConfigUIHandler.java trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/model/ConfigUIModel.java trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/util/handler/AbstractTabUIHandler.java trunk/lutinvcs/ui/common/src/main/resources/i18n/common-en_GB.properties trunk/lutinvcs/ui/common/src/main/resources/i18n/common-fr_FR.properties Log: add generic show ui action Modified: trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/ConfigUI.java =================================================================== --- trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/ConfigUI.java 2008-04-25 23:42:47 UTC (rev 614) +++ trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/ConfigUI.java 2008-04-25 23:42:54 UTC (rev 615) @@ -15,6 +15,7 @@ package org.codelutin.vcs.ui; import static org.codelutin.i18n.I18n._; +import org.codelutin.ui.FormElement; import org.codelutin.util.FileUtil; import org.codelutin.vcs.type.VCSConnexionMode; import org.codelutin.vcs.ui.handler.ConfigUIHandler; @@ -30,11 +31,12 @@ import javax.swing.JRadioButton; import javax.swing.JTextField; import java.io.File; +import java.util.Arrays; /** @author chemit */ public abstract class ConfigUI extends AbstractUI<ConfigUIHandler> { - public enum Element { + public enum Element implements FormElement<ConfigUI> { firstname, lastname, email, @@ -44,15 +46,62 @@ password, passphrase, nopassphrase, - privateKeyFile + privateKeyFile; + + public Object getValue(ConfigUI ui) { + return ui.getElementValue(this); + } + + public void setValue(ConfigUI ui, String value) { + //TODO + JComponent component = ui.getElement(this); + } + + public JLabel getLabel(ConfigUI ui) { + return ui.getElementLabel(this); + } } - public abstract String getElementValue(Element element); + public abstract ButtonGroup getConnexionMode(); - public abstract JLabel getElementLabel(Element element); + public abstract AbstractButton getChangePrivateKeyFile(); - public abstract JComponent getElement(Element element); + public abstract AbstractButton getGenerateKey(); + public abstract AbstractButton getOk(); + + public abstract AbstractButton getReset(); + + public abstract AbstractButton getCancel(); + + public abstract AbstractButton getTestConnection(); + + public String getElementValue(Element element) { + JComponent o = getElement(element); + if (o instanceof JPasswordField) { + return Arrays.toString(((JPasswordField) o).getPassword()); + } + if (o instanceof JTextField) { + return ((JTextField) o).getText(); + } + if (o instanceof JRadioButton) { + return String.valueOf(((JRadioButton) o).isSelected()); + } + if (o instanceof JCheckBox) { + return String.valueOf(((JCheckBox) o).isSelected()); + } + return ""; + } + + public JLabel getElementLabel(Element element) { + return (JLabel) getObjectById(element.name() + "Label"); + } + + public JComponent getElement(Element element) { + return (JComponent) getObjectById(element.name()); + } + + public abstract JEditorPane getDoc(); public abstract JTextField getFirstname(); @@ -79,20 +128,6 @@ public abstract JTextField getPrivateKeyFile(); - public abstract ButtonGroup getConnexionMode(); - - public abstract AbstractButton getChangePrivateKeyFile(); - - public abstract AbstractButton getGenerateKey(); - - public abstract AbstractButton getOk(); - - public abstract AbstractButton getReset(); - - public abstract AbstractButton getCancel(); - - public abstract AbstractButton getTestConnection(); - public abstract JLabel getFirstnameLabel(); public abstract JLabel getLastnameLabel(); @@ -158,8 +193,4 @@ //TODO } - protected void testConnexion() { - //TODO - } - } Modified: trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/GenerateSshKeyUI.java =================================================================== --- trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/GenerateSshKeyUI.java 2008-04-25 23:42:47 UTC (rev 614) +++ trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/GenerateSshKeyUI.java 2008-04-25 23:42:54 UTC (rev 615) @@ -24,7 +24,9 @@ import javax.swing.JComponent; import javax.swing.JLabel; import javax.swing.JPasswordField; +import javax.swing.JRadioButton; import javax.swing.JTextField; +import java.util.Arrays; /** @author chemit */ public abstract class GenerateSshKeyUI extends AbstractUI<GenerateSshKeyUIHandler> { @@ -37,11 +39,30 @@ keyName } - public abstract String getElementValue(Element element); + public String getElementValue(Element element) { + JComponent o = getElement(element); + if (o instanceof JPasswordField) { + return Arrays.toString(((JPasswordField) o).getPassword()); + } + if (o instanceof JTextField) { + return ((JTextField) o).getText(); + } + if (o instanceof JRadioButton) { + return String.valueOf(((JRadioButton) o).isSelected()); + } + if (o instanceof JCheckBox) { + return String.valueOf(((JCheckBox) o).isSelected()); + } + return ""; + } - public abstract JLabel getElementLabel(Element element); + public JLabel getElementLabel(Element element) { + return (JLabel) getObjectById(element.name() + "Label"); + } - public abstract JComponent getElement(Element element); + public JComponent getElement(Element element) { + return (JComponent) getObjectById(element.name()); + } public abstract JTextField getLogin(); Modified: trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/SynchUI.java =================================================================== --- trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/SynchUI.java 2008-04-25 23:42:47 UTC (rev 614) +++ trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/SynchUI.java 2008-04-25 23:42:54 UTC (rev 615) @@ -24,6 +24,8 @@ /** @author chemit */ public abstract class SynchUI extends AbstractTabUI<SynchUIHandler> { + public abstract AbstractButton getConfig() ; + public abstract AbstractButton getRefreshAll(); public abstract AbstractButton getDiffAll(); Added: trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/UIActionHelper.java =================================================================== --- trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/UIActionHelper.java (rev 0) +++ trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/UIActionHelper.java 2008-04-25 23:42:54 UTC (rev 615) @@ -0,0 +1,74 @@ +/** + * # #% Copyright (C) 2008 Code Lutin, Tony Chemit + * This program is free software; you + * can redistribute it and/or modify it under the terms of the GNU General + * Public License as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. This program is + * distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A + * PARTICULAR PURPOSE. See the GNU General Public License for more details. You + * should have received a copy of the GNU General Public License along with this + * program; if not, write to the Free Software Foundation, Inc., 59 Temple Place + * - Suite 330, Boston, MA 02111-1307, USA. + * # #% + */ +package org.codelutin.vcs.ui; + +import org.codelutin.ui.DialogUI; +import org.codelutin.vcs.VCSConnexionConfig; +import org.codelutin.vcs.VCSEntry; +import org.codelutin.vcs.type.VCSAction; +import org.codelutin.vcs.type.VCSEntryLocation; +import org.codelutin.vcs.ui.action.ShowChangelogUIAction; +import org.codelutin.vcs.ui.action.ShowConfigAction; +import org.codelutin.vcs.ui.action.ShowConfirmUIAction; +import org.codelutin.vcs.ui.action.ShowDiffUIAction; +import org.codelutin.vcs.ui.action.ShowSynchUIAction; + +import java.awt.event.ActionEvent; + +/** @author chemit */ +public class UIActionHelper { + + public static void showSynchUI(VCSConnexionConfig config, DialogUI ui, VCSEntryLocation location, VCSEntry[] entries) { + ShowSynchUIAction action = new ShowSynchUIAction(ui, false); + action.setConfig(config); + action.setLocation(location); + action.setEntries(entries); + action.actionPerformed(new ActionEvent(ui == null ? action : ui, 0, "" + action.getValue(javax.swing.AbstractAction.NAME))); + } + + public static void showConfigUI(VCSConnexionConfig config, DialogUI<?> ui) { + ShowConfigAction action = new ShowConfigAction(ui, false); + action.setConfig(config); + action.actionPerformed(new ActionEvent(ui == null ? action : ui, 0, "" + action.getValue(javax.swing.AbstractAction.NAME))); + } + + public static void showConfirmUI(VCSConnexionConfig config, DialogUI ui, VCSEntryLocation location, VCSAction vcsAction, VCSEntry[] entries) { + ShowConfirmUIAction action = new ShowConfirmUIAction(ui, false); + action.setAction(vcsAction); + action.setLocation(location); + action.setEntries(entries); + action.setConfig(config); + action.actionPerformed(new ActionEvent(ui == null ? action : ui, 0, "" + action.getValue(javax.swing.AbstractAction.NAME))); + } + + public static void showDiffUI(VCSConnexionConfig config, DialogUI ui, VCSEntryLocation location, VCSEntry[] entries) { + ShowDiffUIAction action = new ShowDiffUIAction(ui, false); + action.setLocation(location); + action.setEntries(entries); + action.setConfig(config); + action.actionPerformed(new ActionEvent(ui == null ? action : ui, 0, "" + action.getValue(javax.swing.AbstractAction.NAME))); + } + + public static void showChangelogUI(VCSConnexionConfig config, DialogUI ui, VCSEntryLocation location, VCSEntry[] entries) { + ShowChangelogUIAction action = new ShowChangelogUIAction(ui, false); + action.setLocation(location); + action.setEntries(entries); + action.setConfig(config); + action.actionPerformed(new ActionEvent(ui == null ? action : ui, 0, "" + action.getValue(javax.swing.AbstractAction.NAME))); + } + + protected UIActionHelper() { + } +} Modified: trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/VCSInitializer.java =================================================================== --- trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/VCSInitializer.java 2008-04-25 23:42:47 UTC (rev 614) +++ trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/VCSInitializer.java 2008-04-25 23:42:54 UTC (rev 615) @@ -22,8 +22,8 @@ public void initialize() { registerBean(getClassDescriptor(javax.swing.JMenuItem.class), jaxx.tags.swing.JRadioButtonHandler.class); - for (VCSUI vcsui : VCSUI.values()) { - Class<?> uiClass = vcsui.getUiClass(); + for (org.codelutin.ui.DialogUIDef def : VCSUIFactory.defs()) { + Class<?> uiClass = def.getUiClass(); registerBean(getClassDescriptor(uiClass), jaxx.tags.swing.JWindowHandler.class); registerDefaultNamespace(uiClass.getSimpleName(), "org.codelutin.vcs.ui.*"); } Deleted: trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/VCSUI.java =================================================================== --- trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/VCSUI.java 2008-04-25 23:42:47 UTC (rev 614) +++ trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/VCSUI.java 2008-04-25 23:42:54 UTC (rev 615) @@ -1,61 +0,0 @@ -/** - * # #% Copyright (C) 2008 Code Lutin, Tony Chemit - * This program is free software; you - * can redistribute it and/or modify it under the terms of the GNU General - * Public License as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. This program is - * distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A - * PARTICULAR PURPOSE. See the GNU General Public License for more details. You - * should have received a copy of the GNU General Public License along with this - * program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - * - Suite 330, Boston, MA 02111-1307, USA. - * # #% - */ -package org.codelutin.vcs.ui; - -import org.codelutin.vcs.ui.util.handler.AbstractUIHandler; -import org.codelutin.vcs.ui.util.model.AbstractUIModel; -import org.codelutin.vcs.ui.util.ui.AbstractUI; - -/** - * @author chemit - * @see org.codelutin.vcs.ui.util.ui.AbstractUI - * @see AbstractUIModel - * @see org.codelutin.vcs.ui.util.handler.AbstractUIHandler - */ -public enum VCSUI { - - synch(SynchUI.class, org.codelutin.vcs.ui.handler.SynchUIHandler.class), - diff(DiffUI.class, org.codelutin.vcs.ui.handler.DiffUIHandler.class), - changelog(ChangelogUI.class, org.codelutin.vcs.ui.handler.ChangelogUIHandler.class), - confirm(ConfirmUI.class, org.codelutin.vcs.ui.handler.ConfirmUIHandler.class), - config(ConfigUI.class, org.codelutin.vcs.ui.handler.ConfigUIHandler.class), - generateSshKey(GenerateSshKeyUI.class, org.codelutin.vcs.ui.handler.GenerateSshKeyUIHandler.class); - - private final Class<? extends AbstractUI> uiClass; - private final Class<? extends AbstractUIHandler> handlerClass; - - private VCSUI(Class<? extends AbstractUI> uiClass, Class<? extends AbstractUIHandler> handlerClass) { - this.uiClass = uiClass; - this.handlerClass = handlerClass; - } - - public Class<? extends AbstractUIHandler> getHandlerClass() { - return handlerClass; - } - - public Class<? extends AbstractUI> getUiClass() { - return uiClass; - } - - public static VCSUI valueOf(Class<AbstractUI> uiClass) { - for (VCSUI vcsui : values()) { - if (vcsui.getUiClass() == uiClass) { - return vcsui; - } - } - throw new IllegalStateException("could not find a UI for " + uiClass + ", availables : " + java.util.Arrays.toString(values())); - } - -} Modified: trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/VCSUIFactory.java =================================================================== --- trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/VCSUIFactory.java 2008-04-25 23:42:47 UTC (rev 614) +++ trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/VCSUIFactory.java 2008-04-25 23:42:54 UTC (rev 615) @@ -14,8 +14,10 @@ */ package org.codelutin.vcs.ui; +import static org.codelutin.i18n.I18n.n_; import org.codelutin.ui.DialogUI; import org.codelutin.ui.DialogUIDef; +import static org.codelutin.ui.DialogUIDef.newDef; import org.codelutin.ui.DialogUIHandler; import org.codelutin.ui.DialogUIModel; import org.codelutin.ui.FactoryWindowListener; @@ -49,15 +51,21 @@ */ public class VCSUIFactory extends UIFactory { - public static final DialogUIDef<SynchUIModel, SynchUI, SynchUIHandler> SYNCH_UI = new DialogUIDef<SynchUIModel, SynchUI, SynchUIHandler>(SynchUIHandler.class, SynchUI.class, SynchUIModel.class); - public static final DialogUIDef<DiffUIModel, DiffUI, DiffUIHandler> DIFF_UI = new DialogUIDef<DiffUIModel, DiffUI, DiffUIHandler>(DiffUIHandler.class, DiffUI.class, DiffUIModel.class); - public static final DialogUIDef<ChangelogUIModel, ChangelogUI, ChangelogUIHandler> CHANGELOG_UI = new DialogUIDef<ChangelogUIModel, ChangelogUI, ChangelogUIHandler>(ChangelogUIHandler.class, ChangelogUI.class, ChangelogUIModel.class); - public static final DialogUIDef<ConfirmUIModel, ConfirmUI, ConfirmUIHandler> CONFIRM_UI = new DialogUIDef<ConfirmUIModel, ConfirmUI, ConfirmUIHandler>(ConfirmUIHandler.class, ConfirmUI.class, ConfirmUIModel.class); - public static final DialogUIDef<ConfigUIModel, ConfigUI, ConfigUIHandler> CONFIG_UI = new DialogUIDef<ConfigUIModel, ConfigUI, ConfigUIHandler>(ConfigUIHandler.class, ConfigUI.class, ConfigUIModel.class); - public static final DialogUIDef<GenerateSshKeyUIModel, GenerateSshKeyUI, GenerateSshKeyUIHandler> GENERATE_SHH_KEY_UI = new DialogUIDef<GenerateSshKeyUIModel, GenerateSshKeyUI, GenerateSshKeyUIHandler>(GenerateSshKeyUIHandler.class, GenerateSshKeyUI.class, GenerateSshKeyUIModel.class); + public static final DialogUIDef<SynchUIModel, SynchUI, SynchUIHandler> SYNCH_UI; + public static final DialogUIDef<DiffUIModel, DiffUI, DiffUIHandler> DIFF_UI; + public static final DialogUIDef<ChangelogUIModel, ChangelogUI, ChangelogUIHandler> CHANGELOG_UI; + public static final DialogUIDef<ConfirmUIModel, ConfirmUI, ConfirmUIHandler> CONFIRM_UI; + public static final DialogUIDef<ConfigUIModel, ConfigUI, ConfigUIHandler> CONFIG_UI; + public static final DialogUIDef<GenerateSshKeyUIModel, GenerateSshKeyUI, GenerateSshKeyUIHandler> GENERATE_SHH_KEY_UI; + public static DialogUIDef[] defs() { + return new DialogUIDef[]{SYNCH_UI,DIFF_UI,CHANGELOG_UI,CONFIG_UI,CONFIRM_UI,GENERATE_SHH_KEY_UI}; + } + protected static VCSUIFactory instance; + protected VCSConnexionConfig config; + protected static FactoryWindowListener closeConnextionsListener; public static void initFactory(VCSConnexionConfig config, FactoryWindowListener myWindowAdapter) { @@ -71,18 +79,18 @@ return getInstance().getUI(uiType, getInstance().config); } - protected VCSUIFactory(String applicationName, VCSConnexionConfig config, FactoryWindowListener... listeners) { - super(applicationName, new DialogUIDef[]{SYNCH_UI, DIFF_UI, CHANGELOG_UI, CONFIRM_UI, CONFIG_UI, GENERATE_SHH_KEY_UI}, listeners); - this.config = config; - } - - protected static VCSUIFactory getInstance() throws IllegalStateException { + public static VCSUIFactory getInstance() throws IllegalStateException { if (instance == null) { throw new IllegalStateException("factory " + VCSUIFactory.class + " was not init"); - } + } return instance; } + protected VCSUIFactory(String applicationName, VCSConnexionConfig config, FactoryWindowListener... listeners) { + super(applicationName, defs(), listeners); + this.config = config; + } + protected static FactoryWindowListener getCloseConnextionsListener() { if (closeConnextionsListener == null) { closeConnextionsListener = new FactoryWindowListener() { @@ -100,4 +108,31 @@ } return closeConnextionsListener; } + + static { + SYNCH_UI = newDef(SynchUIHandler.class, SynchUI.class, SynchUIModel.class, + n_("lutinvcs.action.show.synchui"), + n_("lutinvcs.action.show.synchui.tip"), + n_("lutinvcs.synchui.title")); + DIFF_UI = newDef(DiffUIHandler.class, DiffUI.class, DiffUIModel.class, + n_("lutinvcs.action.showui.diffui"), + n_("lutinvcs.action.showui.diffui.tip"), + n_("lutinvcs.diffui.title")); + CHANGELOG_UI = newDef(ChangelogUIHandler.class, ChangelogUI.class, ChangelogUIModel.class, + n_("lutinvcs.action.show.changelogui"), + n_("lutinvcs.action.show.changelogui.tip"), + n_("lutinvcs.changelogui.title")); + CONFIRM_UI = newDef(ConfirmUIHandler.class, ConfirmUI.class, ConfirmUIModel.class, + n_("lutinvcs.action.show.confirmui"), + n_("lutinvcs.action.show.confirmui.tip"), + n_("lutinvcs.confirmui.title")); + CONFIG_UI = newDef(ConfigUIHandler.class, ConfigUI.class, ConfigUIModel.class, + n_("lutinvcs.action.show.configui"), + n_("lutinvcs.action.show.configui.tip"), + n_("lutinvcs.configui.title")); + GENERATE_SHH_KEY_UI = newDef(GenerateSshKeyUIHandler.class, GenerateSshKeyUI.class, GenerateSshKeyUIModel.class, + n_("lutinvcs.action.show.generatesshkeyui"), + n_("lutinvcs.action.show.generatesshkeyui.tip"), + n_("lutinvcs.generatesshkeyui.title")); + } } \ No newline at end of file Deleted: trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/VCSUIProvider.java =================================================================== --- trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/VCSUIProvider.java 2008-04-25 23:42:47 UTC (rev 614) +++ trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/VCSUIProvider.java 2008-04-25 23:42:54 UTC (rev 615) @@ -1,41 +0,0 @@ -/** - * # #% Copyright (C) 2008 Code Lutin, Tony Chemit - * This program is free software; you - * can redistribute it and/or modify it under the terms of the GNU General - * Public License as published by the Free Software Foundation; either version 2 - * of the License, or (at your option) any later version. This program is - * distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; - * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A - * PARTICULAR PURPOSE. See the GNU General Public License for more details. You - * should have received a copy of the GNU General Public License along with this - * program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - * - Suite 330, Boston, MA 02111-1307, USA. - * # #% - */ -package org.codelutin.vcs.ui; - -import org.codelutin.vcs.ui.util.ui.AbstractUI; - -/** @author chemit */ -public abstract class VCSUIProvider { - - private Class<?>[] klasses; - - protected String name; - - protected VCSUIProvider(String name, Class<?>... klasses) { - this.name = name; - this.klasses = klasses; - } - - /** @return the identifier of the vcs ui provider (eg jaxx, swing, ...) */ - public String getName() { - return name; - } - - public AbstractUI newUI(VCSUI uiType) throws InstantiationException, IllegalAccessException { - Class<?> uiImpl = klasses[uiType.ordinal()]; - return (AbstractUI) (uiImpl != null ? uiImpl.newInstance() : null); - } - -} Copied: trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/action/TestConnexionAction.java (from rev 608, trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/action/ConfirmAction.java) =================================================================== --- trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/action/TestConnexionAction.java (rev 0) +++ trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/action/TestConnexionAction.java 2008-04-25 23:42:54 UTC (rev 615) @@ -0,0 +1,63 @@ +/** + * # #% Copyright (C) 2008 Code Lutin, Tony Chemit + * This program is free software; you + * can redistribute it and/or modify it under the terms of the GNU General + * Public License as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. This program is + * distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A + * PARTICULAR PURPOSE. See the GNU General Public License for more details. You + * should have received a copy of the GNU General Public License along with this + * program; if not, write to the Free Software Foundation, Inc., 59 Temple Place + * - Suite 330, Boston, MA 02111-1307, USA. + * # #% + */ +package org.codelutin.vcs.ui.action; + +import static org.codelutin.i18n.I18n._; +import org.codelutin.vcs.VCSConnexion; +import org.codelutin.vcs.VCSConnexionConfig; +import org.codelutin.vcs.VCSException; +import org.codelutin.vcs.VCSFactory; +import org.codelutin.vcs.ui.ConfigUI; +import org.codelutin.vcs.ui.handler.ConfigUIHandler; + +import javax.swing.JOptionPane; +import static javax.swing.JOptionPane.ERROR_MESSAGE; +import static javax.swing.JOptionPane.INFORMATION_MESSAGE; + +/** @author chemit */ +public class TestConnexionAction extends org.codelutin.ui.AbstractUIAction<org.codelutin.vcs.ui.handler.ConfigUIHandler> { + + + private static final long serialVersionUID = 1L; + + public TestConnexionAction(org.codelutin.vcs.ui.ConfigUI ui) { + super(null, org.codelutin.ui.UIHelper.createActionIcon("test"), ui); + putValue(SHORT_DESCRIPTION, org.codelutin.i18n.I18n._("lutinvcs.config.test.tip")); + //putValue(DISPLAYED_MNEMONIC_INDEX_KEY, 0); + //putValue(MNEMONIC_KEY, (int) (action.getLibelle()).charAt(0)); + } + + public void actionPerformed(java.awt.event.ActionEvent e) { + checkInit(); + ConfigUIHandler uiHandler = getHandler(); + VCSConnexionConfig config = uiHandler.getConfig(); + VCSConnexion connexion = VCSFactory.newConnexion(config); + ConfigUI ui = uiHandler.getUi(); + boolean result = false; + try { + connexion.testConnection(); + //TODO should notify ConfigModel, connexion is safe, need a testConnexion state (reset as soon as model modified) + JOptionPane.showMessageDialog(ui, _("lutinvcs.success.test"), _("lutinvcs.test.result"), INFORMATION_MESSAGE); + result = true; + } catch (VCSException e1) { + String message = _("lutinvcs.error.test", e1.getMessage()); + log.warn(message); + JOptionPane.showMessageDialog(ui, message, _("lutinvcs.test.result"), ERROR_MESSAGE); + } finally { + uiHandler.getModel().setConnexionState(result); + } + } + +} \ No newline at end of file Modified: trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/handler/ConfigUIHandler.java =================================================================== --- trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/handler/ConfigUIHandler.java 2008-04-25 23:42:47 UTC (rev 614) +++ trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/handler/ConfigUIHandler.java 2008-04-25 23:42:54 UTC (rev 615) @@ -39,8 +39,8 @@ protected List<Element> errors; - public ConfigUIHandler(ConfigUI ui,VCSConnexionConfig config) { - super(ui, new ConfigUIModel(),config); + public ConfigUIHandler(ConfigUI ui, VCSConnexionConfig config) { + super(ui, new ConfigUIModel(), config); ui.setHandler(this); errors = new ArrayList<Element>(); } @@ -75,9 +75,19 @@ if (ConfigUIModel.MODIFIED_PROPERTY_CHANGED.equals(action)) { Boolean newValue = (Boolean) evt.getNewValue(); - getUi().getReset().setEnabled(newValue != null && newValue); + boolean modified = newValue != null && newValue; + getUi().getReset().setEnabled(modified); + getUi().getTestConnection().setEnabled(modified && isConfigValid()); return; } + + if (ConfigUIModel.CONNEXION_STATE_PROPERTY_CHANGED.equals(action)) { + Boolean newValue = (Boolean) evt.getNewValue(); + boolean validConnexion = newValue != null && newValue; + getUi().getOk().setEnabled(validConnexion); + getUi().getTestConnection().setEnabled(!validConnexion); + return; + } throw new IllegalStateException("unimplemented property changed : " + evt + " for " + this); } @@ -176,8 +186,12 @@ } if (modify) { model.addModified(element); + // reset connexion state + model.setConnexionState(null); } else if (model.getModifieds().contains(element)) { model.removeModified(element); + // reset connexion state + model.setConnexionState(null); } } @@ -187,7 +201,7 @@ } public boolean isConfigValid() { - return errors.isEmpty(); + return errors.isEmpty() && getModel().isConnexionState(); } public void reset() { @@ -218,6 +232,7 @@ getUi().getLastname().setText(model.getLasttname()); getUi().getEmail().setText(model.getEmail()); } + ui.getTestConnection().setEnabled(true); } protected void updateUI(final VCSConnexionMode mode) { @@ -252,7 +267,7 @@ ConfigUI ui = getUi(); boolean valid = isConfigValid(); ui.getOk().setEnabled(valid && getModel().isModified()); - ui.getTestConnection().setEnabled(valid); + //ui.getTestConnection().setEnabled(valid); ui.getGenerateKey().setEnabled(getModel().getMode() == VCSConnexionMode.SSH && !errors.contains(sshLogin) && !errors.contains(passphrase)); for (Element element : values()) { setLabelColor(errors, element); Modified: trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/model/ConfigUIModel.java =================================================================== --- trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/model/ConfigUIModel.java 2008-04-25 23:42:47 UTC (rev 614) +++ trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/model/ConfigUIModel.java 2008-04-25 23:42:54 UTC (rev 615) @@ -39,6 +39,8 @@ public static final String CONFIG_PROPERTY_CHANGED = "config"; + public static final String CONNEXION_STATE_PROPERTY_CHANGED = "connexionState"; + public static final String MODE_PROPERTY_CHANGED = "mode"; public static final String IDENTITY_PROPERTY_CHANGED = "identity"; @@ -55,6 +57,8 @@ protected List<Element> modifieds; protected VCSConnexionConfig config; + protected Boolean connexionState; + public ConfigUIModel() { modifieds = new ArrayList<Element>(); } @@ -101,6 +105,7 @@ addModified(connexion); } firePropertyChange(MODE_PROPERTY_CHANGED, oldMode, mode); + setConnexionState(null); } public String getEmail() { @@ -127,6 +132,10 @@ return modifieds; } + public Boolean isConnexionState() { + return connexionState != null && connexionState; + } + public VCSConnexionConfig getConfig() throws IllegalStateException { checkConnexionInit(); return config; @@ -140,8 +149,7 @@ public void addModified(Element elementname) { if (!modifieds.contains(elementname)) { modifieds.add(elementname); - - } + } setModified(!modifieds.isEmpty()); } @@ -207,4 +215,10 @@ throw new IllegalStateException("no config found in model " + this); } } + + public void setConnexionState(Boolean connexionState) { + Boolean oldConnexionState = this.connexionState; + this.connexionState = connexionState; + firePropertyChange(CONNEXION_STATE_PROPERTY_CHANGED, oldConnexionState, connexionState); + } } \ No newline at end of file Copied: trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/util/AbstractShowUIAction.java (from rev 608, trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/action/ShowConfigAction.java) =================================================================== --- trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/util/AbstractShowUIAction.java (rev 0) +++ trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/util/AbstractShowUIAction.java 2008-04-25 23:42:54 UTC (rev 615) @@ -0,0 +1,57 @@ +/** + * # #% Copyright (C) 2008 Code Lutin, Tony Chemit + * This program is free software; you + * can redistribute it and/or modify it under the terms of the GNU General + * Public License as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. This program is + * distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A + * PARTICULAR PURPOSE. See the GNU General Public License for more details. You + * should have received a copy of the GNU General Public License along with this + * program; if not, write to the Free Software Foundation, Inc., 59 Temple Place + * - Suite 330, Boston, MA 02111-1307, USA. + * # #% + */ +package org.codelutin.vcs.ui.util; + +import org.codelutin.ui.DialogUI; +import org.codelutin.ui.DialogUIDef; +import org.codelutin.ui.DialogUIHandler; +import org.codelutin.ui.DialogUIModel; +import org.codelutin.ui.ShowUIAction; +import org.codelutin.vcs.VCSConnexionConfig; +import org.codelutin.vcs.ui.VCSUIFactory; + +import java.awt.event.ActionEvent; + +/** @author chemit */ +public abstract class AbstractShowUIAction<M extends DialogUIModel, U extends DialogUI<H>, H extends DialogUIHandler<M, U>, HH extends DialogUIHandler<?, ?>> extends ShowUIAction<M, U, H, HH> { + + protected transient VCSConnexionConfig config; + + private static final long serialVersionUID = 1L; + + public <UU extends DialogUI<HH>> AbstractShowUIAction(UU ui, DialogUIDef<M, U, H> uiDef, boolean showText) { + super(ui, uiDef, VCSUIFactory.getInstance(), showText); + } + + public VCSConnexionConfig getConfig() { + return config; + } + + public void setConfig(VCSConnexionConfig config) { + this.config = config; + } + + protected U initUI(ActionEvent e) { + return getFactory().getUI(uiDef, config); + } + + @Override + protected void checkInit() throws IllegalStateException { + super.checkInit(); + if (config == null) { + throw new IllegalStateException("no config found in " + this); + } + } +} \ No newline at end of file Modified: trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/util/handler/AbstractTabUIHandler.java =================================================================== --- trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/util/handler/AbstractTabUIHandler.java 2008-04-25 23:42:47 UTC (rev 614) +++ trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/util/handler/AbstractTabUIHandler.java 2008-04-25 23:42:54 UTC (rev 615) @@ -18,10 +18,6 @@ import org.codelutin.vcs.VCSEntry; import org.codelutin.vcs.VCSException; import org.codelutin.vcs.type.VCSAction; -import org.codelutin.vcs.ui.ChangelogUI; -import org.codelutin.vcs.ui.ConfirmUI; -import org.codelutin.vcs.ui.DiffUI; -import org.codelutin.vcs.ui.VCSUIFactory; import org.codelutin.vcs.ui.util.AbstractVCSEntriesTableModel; import org.codelutin.vcs.ui.util.model.AbstractTabUIModel; import org.codelutin.vcs.ui.util.ui.AbstractTabUI; @@ -62,45 +58,6 @@ ui.setEnabled(hasActions && actions.containsKey(action) && actions.get(action) > 0); } - public void showConfirmUI(VCSAction action, AbstractVCSEntriesTableModel model, List<VCSEntry> entries) { - ConfirmUI ui = VCSUIFactory.getUI(VCSUIFactory.CONFIRM_UI); - if (log.isDebugEnabled()) { - log.debug("nb entries:" + entries.size()); - } - ui.getHandler().getModel().init(action, model.getLocation(), entries.toArray(new VCSEntry[entries.size()])); - ui.getContentScroll().setEnabled(entries.size() > 1); - ui.setVisible(true); - } - - public void showDiffUI(boolean useSelection, AbstractVCSEntriesTableModel model, List<VCSEntry> entries) { - DiffUI ui = VCSUIFactory.getUI(VCSUIFactory.DIFF_UI); - if (!useSelection) { - // take all entries - entries = model.filter(VCSAction.DIFF, model.getEntries()); - } - if (log.isDebugEnabled()) { - log.debug("nb entries:" + entries.size()); - } - ui.getButton(model.getLocation()).setSelected(false); - ui.getHandler().getModel().init(model.getLocation(), entries.toArray(new VCSEntry[entries.size()])); - ui.getContentScroll().setEnabled(entries.size() > 1); - ui.setVisible(true); - } - - public void showChangelogUI(boolean useSelection, AbstractVCSEntriesTableModel model, List<VCSEntry> entries) { - ChangelogUI ui = VCSUIFactory.getUI(VCSUIFactory.CHANGELOG_UI); - if (!useSelection) { - // take all entries - entries = model.filter(VCSAction.CHANGELOG, model.getEntries()); - } - if (log.isDebugEnabled()) { - log.debug("nb entries:" + entries.size()); - } - ui.getHandler().getModel().init(model.getLocation(), entries.toArray(new VCSEntry[entries.size()])); - ui.getContentScroll().setEnabled(entries.size() > 1); - ui.setVisible(true); - } - public void doRefresh(AbstractVCSEntriesTableModel model, List<VCSEntry> entries, ListSelectionModel selectionModel) { log.info(selectionModel); selectionModel.clearSelection(); Copied: trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/util/ui/AbstractFormUI.java (from rev 601, trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/util/ui/AbstractUI.java) =================================================================== --- trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/util/ui/AbstractFormUI.java (rev 0) +++ trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/util/ui/AbstractFormUI.java 2008-04-25 23:42:54 UTC (rev 615) @@ -0,0 +1,30 @@ +/** + * ##% Copyright (C) 2008 Code Lutin, Tony Chemit + * This program is free software; you + * can redistribute it and/or modify it under the terms of the GNU General + * Public License as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. This program is + * distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A + * PARTICULAR PURPOSE. See the GNU General Public License for more details. You + * should have received a copy of the GNU General Public License along with this + * program; if not, write to the Free Software Foundation, Inc., 59 Temple Place + * - Suite 330, Boston, MA 02111-1307, USA. + * ##% + */ +package org.codelutin.vcs.ui.util.ui; + +import org.codelutin.vcs.ui.util.handler.AbstractUIHandler; + +/** + * The base dialog to be used in vcs project + * + * @author chemit + */ +public abstract class AbstractFormUI<H extends AbstractUIHandler> extends org.codelutin.ui.DialogUI<H> { + + /*protected javax.swing.AbstractAction createHelpAction() { + return org.codelutin.vcs.ui.action.HelpAction.createAction(this); + }*/ + +} \ No newline at end of file Modified: trunk/lutinvcs/ui/common/src/main/resources/i18n/common-en_GB.properties =================================================================== --- trunk/lutinvcs/ui/common/src/main/resources/i18n/common-en_GB.properties 2008-04-25 23:42:47 UTC (rev 614) +++ trunk/lutinvcs/ui/common/src/main/resources/i18n/common-en_GB.properties 2008-04-25 23:42:54 UTC (rev 615) @@ -13,13 +13,33 @@ lutinvcs.action.nextfile.tip=select newt file lutinvcs.action.previousdiff.tip=goto previous diff lutinvcs.action.previousfile.tip=select previous file -lutinvcs.action.showconfig.libelle= -lutinvcs.action.showconfig.tip= +lutinvcs.action.show.changelogui= +lutinvcs.action.show.changelogui.tip= +lutinvcs.action.show.configui= +lutinvcs.action.show.configui.tip= +lutinvcs.action.show.confirmui= +lutinvcs.action.show.confirmui.tip= +lutinvcs.action.show.generatesshkeyui= +lutinvcs.action.show.generatesshkeyui.tip= +lutinvcs.action.show.synchui= +lutinvcs.action.show.synchui.tip= lutinvcs.action.showmessages.tip=show previous commit messages +lutinvcs.action.showui.diffui= +lutinvcs.action.showui.diffui.tip= lutinvcs.action.single.tip=Launch action ''{0}'' on selected file ''{1}'' +lutinvcs.changelogui.title= lutinvcs.config.accept=Accept lutinvcs.config.find.public.key=Public ssh key (*.pub) associated with the required private key lutinvcs.config.find.ssh.dir=Change container dir of shh keys +lutinvcs.config.test.tip=Test connexion +lutinvcs.configui.title= +lutinvcs.confirmui.title= +lutinvcs.diffui.title= +lutinvcs.error.test=Connexion failed fro reason {0} lutinvcs.file=File +lutinvcs.generatesshkeyui.title= lutinvcs.module=Module lutinvcs.status=Status +lutinvcs.success.test=Connexion was successfull established +lutinvcs.synchui.title= +lutinvcs.test.result=Connexion Result UI Modified: trunk/lutinvcs/ui/common/src/main/resources/i18n/common-fr_FR.properties =================================================================== --- trunk/lutinvcs/ui/common/src/main/resources/i18n/common-fr_FR.properties 2008-04-25 23:42:47 UTC (rev 614) +++ trunk/lutinvcs/ui/common/src/main/resources/i18n/common-fr_FR.properties 2008-04-25 23:42:54 UTC (rev 615) @@ -13,13 +13,33 @@ lutinvcs.action.nextfile.tip=S\u00E9lectionner le prochain fichier lutinvcs.action.previousdiff.tip=voir la diff\u00E9rence pr\u00E9c\u00E9dente lutinvcs.action.previousfile.tip=S\u00E9lectionner le pr\u00E9c\u00E9dent fichier -lutinvcs.action.showconfig.libelle=Modifier la configuration -lutinvcs.action.showconfig.tip=Modifier la configuration vcs +lutinvcs.action.show.changelogui=Voir le journal des changements +lutinvcs.action.show.changelogui.tip=Cliquer ici pour ouvrir le journal des changements +lutinvcs.action.show.configui=Configuration +lutinvcs.action.show.configui.tip=Modifier la configuration vcs +lutinvcs.action.show.confirmui=Confirmer +lutinvcs.action.show.confirmui.tip=Cliquer ic pour ouvrir la fen\u00EAtre de confirmation +lutinvcs.action.show.generatesshkeyui=G\u00E9n\u00E9rer la clef +lutinvcs.action.show.generatesshkeyui.tip=G\u00E9n\u00E9rer la paire de clefs ssh +lutinvcs.action.show.synchui=Synchroniser +lutinvcs.action.show.synchui.tip=Voir la fen\u00EAtre de synchronisation lutinvcs.action.showmessages.tip=voir les messages de publication pr\u00E9c\u00E9dents +lutinvcs.action.showui.diffui=Voir les diff\u00E9rences +lutinvcs.action.showui.diffui.tip=Voir les diff\u00E9rences lutinvcs.action.single.tip=ex\u00E9cuter l''action ''{0}'' sur le fichier s\u00E9l\u00E9ctionn\u00E9 ''{1}'' +lutinvcs.changelogui.title=Voir le journal des changements lutinvcs.config.accept=Accepter lutinvcs.config.find.public.key=Clef publique ssh (*.pub) associ\u00E9e \u00E0 la clef priv\u00E9e lutinvcs.config.find.ssh.dir=Changer le r\u00E9pertoire contenant la paire de clef ssh g\u00E9n\u00E9r\u00E9 +lutinvcs.config.test.tip=Tester la connexion +lutinvcs.configui.title=Config UI +lutinvcs.confirmui.title=Confirm UI +lutinvcs.diffui.title=Diff UI +lutinvcs.error.test=La connexion n''a pas pu \u00EAtre \u00E9tablie pour la raison suivante \: {0} lutinvcs.file=Fichier +lutinvcs.generatesshkeyui.title=GenerateSshKey UI lutinvcs.module=Module lutinvcs.status=Status +lutinvcs.success.test=Connexion \u00E9tablie avec succ\u00E8s +lutinvcs.synchui.title=Synch UI +lutinvcs.test.result=Config Result UI
participants (1)
-
tchemit@users.labs.libre-entreprise.org