Author: tchemit Date: 2008-04-27 08:28:06 +0000 (Sun, 27 Apr 2008) New Revision: 627 Added: trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/IdentityUI.java trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/TestUI.java trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/action/ShowIdentityUIAction.java trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/action/ShowTestUIAction.java trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/handler/IdentityUIHandler.java trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/handler/TestUIHandler.java trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/model/IdentityUIModel.java trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/model/TestUIModel.java trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/util/AbstractVCSShowUIAction.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/UIActionHelper.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/action/ShowChangelogUIAction.java 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/action/ShowConfirmUIAction.java trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/action/ShowDiffUIAction.java trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/action/ShowSynchUIAction.java trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/action/TabUIAction.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/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/AbstractShowUIAction.java Log: introduction ui Identity (pour les param?\195?\168tre perso de l'utilisateur (nom prenom email) suppression de l'ui de config debut de l'ui de configuration des VCSRoots introduction ui de test 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-27 08:27:31 UTC (rev 626) +++ trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/ConfigUI.java 2008-04-27 08:28:06 UTC (rev 627) @@ -37,9 +37,6 @@ public abstract class ConfigUI extends AbstractUI<ConfigUIHandler> { public enum Element implements FormElement<ConfigUI> { - firstname, - lastname, - email, connexion, login, sshLogin, @@ -76,6 +73,12 @@ public abstract AbstractButton getTestConnection(); + public abstract AbstractButton getAddRoot(); + + public abstract AbstractButton getDeleteRoot(); + + public abstract AbstractButton getEditRoot(); + public String getElementValue(Element element) { JComponent o = getElement(element); if (o instanceof JPasswordField) { @@ -104,12 +107,6 @@ public abstract JEditorPane getDoc(); - public abstract JTextField getFirstname(); - - public abstract JTextField getLastname(); - - public abstract JTextField getEmail(); - public abstract JRadioButton getConnexionModeAnonymous(); public abstract JRadioButton getConnexionModePassword(); @@ -128,12 +125,6 @@ public abstract JTextField getPrivateKeyFile(); - public abstract JLabel getFirstnameLabel(); - - public abstract JLabel getLastnameLabel(); - - public abstract JLabel getEmailLabel(); - public abstract JLabel getLoginLabel(); public abstract JLabel getSshLoginLabel(); @@ -154,8 +145,9 @@ public abstract javax.swing.JPanel getSshPanel(); - public abstract javax.swing.JScrollPane getIdentityScroll(); + public abstract javax.swing.JComboBox getRootsList(); + public boolean isConfigValid() { return getHandler().isConfigValid(); } @@ -176,7 +168,6 @@ protected void changeAutheticationMode(VCSConnexionMode mode) { getHandler().getModel().setConnexionMode(mode); doCheck(Element.connexion); - //doCheck(Element.connexion); } protected void changePrivateKeyFile() { @@ -193,4 +184,16 @@ //TODO } + protected void editRoot() { + //TODO + } + + protected void addRoot() { + //TODO + } + + protected void deleteRoot() { + //TODO + } + } Copied: trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/IdentityUI.java (from rev 615, trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/ConfigUI.java) =================================================================== --- trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/IdentityUI.java (rev 0) +++ trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/IdentityUI.java 2008-04-27 08:28:06 UTC (rev 627) @@ -0,0 +1,112 @@ +/** + * # #% 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.ui.FormElement; +import org.codelutin.vcs.ui.handler.IdentityUIHandler; + +import javax.swing.AbstractButton; +import javax.swing.JCheckBox; +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 IdentityUI extends DialogUI<IdentityUIHandler> { + + public enum Element implements FormElement<IdentityUI> { + firstname, + lastname, + email; + + public Object getValue(IdentityUI ui) { + return ui.getElementValue(this); + } + + public void setValue(IdentityUI ui, String value) { + //TODO + JComponent component = ui.getElement(this); + } + + public JLabel getLabel(IdentityUI ui) { + return ui.getElementLabel(this); + } + } + + public abstract AbstractButton getOk(); + + public abstract AbstractButton getReset(); + + public abstract AbstractButton getCancel(); + + 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 JTextField getFirstname(); + + public abstract JTextField getLastname(); + + public abstract JTextField getEmail(); + + public abstract JLabel getFirstnameLabel(); + + public abstract JLabel getLastnameLabel(); + + public abstract JLabel getEmailLabel(); + + public boolean isConfigValid() { + return getHandler().isConfigValid(); + } + + protected void reset() { + getHandler().reset(); + } + + protected void save() { + getHandler().save(); + dispose(); + } + + protected void doCheck(Element element) { + getHandler().doCheck(element); + } + +} \ No newline at end of file Added: trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/TestUI.java =================================================================== --- trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/TestUI.java (rev 0) +++ trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/TestUI.java 2008-04-27 08:28:06 UTC (rev 627) @@ -0,0 +1,33 @@ +/** + * # #% 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.DialogUIDef; + +/** @author chemit */ +public abstract class TestUI extends org.codelutin.ui.DialogUI<org.codelutin.vcs.ui.handler.TestUIHandler> { + + public abstract javax.swing.AbstractButton getShowFirstLaunch(); + + public abstract javax.swing.AbstractButton getShowConfig(); + + public abstract javax.swing.AbstractButton getShowSynch(); + + public void showUI(DialogUIDef uiDef) { + getHandler().getModel().setUIDef(uiDef); + } + + +} \ No newline at end of file Modified: 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 2008-04-27 08:27:31 UTC (rev 626) +++ trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/UIActionHelper.java 2008-04-27 08:28:06 UTC (rev 627) @@ -15,6 +15,7 @@ package org.codelutin.vcs.ui; import org.codelutin.ui.DialogUI; +import org.codelutin.ui.ShowUIAction; import org.codelutin.vcs.VCSConnexionConfig; import org.codelutin.vcs.VCSEntry; import org.codelutin.vcs.type.VCSAction; @@ -23,49 +24,74 @@ 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.ShowIdentityUIAction; import org.codelutin.vcs.ui.action.ShowSynchUIAction; +import org.codelutin.vcs.ui.action.ShowTestUIAction; +import org.codelutin.vcs.ui.model.TestUIModel; import java.awt.event.ActionEvent; /** @author chemit */ public class UIActionHelper { - public static void showSynchUI(VCSConnexionConfig config, DialogUI ui, VCSEntryLocation location, VCSEntry[] entries) { + public static void showSynchUI(VCSConnexionConfig config, DialogUI ui, VCSEntryLocation location, VCSEntry[] entries, String position) { 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))); + action.setPosition(position); + fireAction(ui, action); } - public static void showConfigUI(VCSConnexionConfig config, DialogUI<?> ui) { + public static void showConfigUI(VCSConnexionConfig config, DialogUI<?> ui, String position) { ShowConfigAction action = new ShowConfigAction(ui, false); action.setConfig(config); - action.actionPerformed(new ActionEvent(ui == null ? action : ui, 0, "" + action.getValue(javax.swing.AbstractAction.NAME))); + action.setPosition(position); + fireAction(ui, action); } - public static void showConfirmUI(VCSConnexionConfig config, DialogUI ui, VCSEntryLocation location, VCSAction vcsAction, VCSEntry[] entries) { + public static void showConfirmUI(VCSConnexionConfig config, DialogUI ui, VCSEntryLocation location, VCSAction vcsAction, VCSEntry[] entries, String position) { ShowConfirmUIAction action = new ShowConfirmUIAction(ui, false); + action.setPosition(position); 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))); + fireAction(ui, action); } - public static void showDiffUI(VCSConnexionConfig config, DialogUI ui, VCSEntryLocation location, VCSEntry[] entries) { + public static void showDiffUI(VCSConnexionConfig config, DialogUI ui, VCSEntryLocation location, VCSEntry[] entries, String position) { ShowDiffUIAction action = new ShowDiffUIAction(ui, false); + action.setPosition(position); action.setLocation(location); action.setEntries(entries); action.setConfig(config); - action.actionPerformed(new ActionEvent(ui == null ? action : ui, 0, "" + action.getValue(javax.swing.AbstractAction.NAME))); + fireAction(ui, action); } - public static void showChangelogUI(VCSConnexionConfig config, DialogUI ui, VCSEntryLocation location, VCSEntry[] entries) { + public static void showChangelogUI(VCSConnexionConfig config, DialogUI ui, VCSEntryLocation location, VCSEntry[] entries, String position) { ShowChangelogUIAction action = new ShowChangelogUIAction(ui, false); + action.setPosition(position); action.setLocation(location); action.setEntries(entries); action.setConfig(config); + fireAction(ui, action); + } + + public static void showIdentityUI(java.io.Serializable src, DialogUI<?> ui, String position) { + ShowIdentityUIAction action = new ShowIdentityUIAction(ui, false); + action.setSrc(src); + action.setPosition(position); + fireAction(ui, action); + } + + public static void showTestUI(TestUIModel model, DialogUI<?> ui) { + ShowTestUIAction action = new ShowTestUIAction(ui, false); + action.setModel(model, true); + fireAction(ui, action); + } + + protected static void fireAction(DialogUI<?> ui, ShowUIAction action) { action.actionPerformed(new ActionEvent(ui == null ? action : ui, 0, "" + action.getValue(javax.swing.AbstractAction.NAME))); } 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-27 08:27:31 UTC (rev 626) +++ trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/VCSUIFactory.java 2008-04-27 08:28:06 UTC (rev 627) @@ -29,14 +29,18 @@ import org.codelutin.vcs.ui.handler.ConfigUIHandler; import org.codelutin.vcs.ui.handler.ConfirmUIHandler; import org.codelutin.vcs.ui.handler.DiffUIHandler; +import org.codelutin.vcs.ui.handler.IdentityUIHandler; import org.codelutin.vcs.ui.handler.GenerateSshKeyUIHandler; import org.codelutin.vcs.ui.handler.SynchUIHandler; +import org.codelutin.vcs.ui.handler.TestUIHandler; import org.codelutin.vcs.ui.model.ChangelogUIModel; import org.codelutin.vcs.ui.model.ConfigUIModel; import org.codelutin.vcs.ui.model.ConfirmUIModel; import org.codelutin.vcs.ui.model.DiffUIModel; +import org.codelutin.vcs.ui.model.IdentityUIModel; import org.codelutin.vcs.ui.model.GenerateSshKeyUIModel; import org.codelutin.vcs.ui.model.SynchUIModel; +import org.codelutin.vcs.ui.model.TestUIModel; import java.awt.event.WindowEvent; @@ -57,9 +61,11 @@ 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 final DialogUIDef<IdentityUIModel, IdentityUI, IdentityUIHandler> IDENTITY_UI; + public static final DialogUIDef<TestUIModel, TestUI, TestUIHandler> TEST_UI; public static DialogUIDef[] defs() { - return new DialogUIDef[]{SYNCH_UI,DIFF_UI,CHANGELOG_UI,CONFIG_UI,CONFIRM_UI,GENERATE_SHH_KEY_UI}; + return new DialogUIDef[]{SYNCH_UI, DIFF_UI, CHANGELOG_UI, CONFIG_UI, CONFIRM_UI, GENERATE_SHH_KEY_UI, IDENTITY_UI,TEST_UI}; } protected static VCSUIFactory instance; @@ -134,5 +140,13 @@ n_("lutinvcs.action.show.generatesshkeyui"), n_("lutinvcs.action.show.generatesshkeyui.tip"), n_("lutinvcs.generatesshkeyui.title")); + IDENTITY_UI = newDef(IdentityUIHandler.class, IdentityUI.class, IdentityUIModel.class, + n_("lutinvcs.action.show.identityui"), + n_("lutinvcs.action.show.identityui.tip"), + n_("lutinvcs.firstlaunch.title")); + TEST_UI = newDef(TestUIHandler.class, TestUI.class, TestUIModel.class, + n_("lutinvcs.action.show.testui"), + n_("lutinvcs.action.show.testui.tip"), + n_("lutinvcs.testui.title")); } } \ No newline at end of file Modified: trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/action/ShowChangelogUIAction.java =================================================================== --- trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/action/ShowChangelogUIAction.java 2008-04-27 08:27:31 UTC (rev 626) +++ trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/action/ShowChangelogUIAction.java 2008-04-27 08:28:06 UTC (rev 627) @@ -22,12 +22,12 @@ import org.codelutin.vcs.ui.VCSUIFactory; import org.codelutin.vcs.ui.handler.ChangelogUIHandler; import org.codelutin.vcs.ui.model.ChangelogUIModel; -import org.codelutin.vcs.ui.util.AbstractShowUIAction; +import org.codelutin.vcs.ui.util.AbstractVCSShowUIAction; import java.awt.event.ActionEvent; /** @author chemit */ -public class ShowChangelogUIAction extends AbstractShowUIAction<ChangelogUIModel, ChangelogUI, ChangelogUIHandler, DialogUIHandler<?, ?>> { +public class ShowChangelogUIAction extends AbstractVCSShowUIAction<ChangelogUIModel, ChangelogUI, ChangelogUIHandler, DialogUIHandler<?, ?>> { private static final long serialVersionUID = 1L; Modified: 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/action/ShowConfigAction.java 2008-04-27 08:27:31 UTC (rev 626) +++ trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/action/ShowConfigAction.java 2008-04-27 08:28:06 UTC (rev 627) @@ -19,12 +19,12 @@ import org.codelutin.vcs.ui.VCSUIFactory; import org.codelutin.vcs.ui.handler.ConfigUIHandler; import org.codelutin.vcs.ui.model.ConfigUIModel; -import org.codelutin.vcs.ui.util.AbstractShowUIAction; +import org.codelutin.vcs.ui.util.AbstractVCSShowUIAction; import java.awt.event.ActionEvent; /** @author chemit */ -public class ShowConfigAction extends AbstractShowUIAction<ConfigUIModel, ConfigUI, ConfigUIHandler, DialogUIHandler<?, ?>> { +public class ShowConfigAction extends AbstractVCSShowUIAction<ConfigUIModel, ConfigUI, ConfigUIHandler, DialogUIHandler<?, ?>> { private static final long serialVersionUID = 1L; @@ -36,7 +36,7 @@ protected ConfigUI initUI(ActionEvent e) { ConfigUI ui = super.initUI(e); ui.getHandler().getModel().populate(getConfig()); + ui.pack(); return ui; } - } \ No newline at end of file Modified: trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/action/ShowConfirmUIAction.java =================================================================== --- trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/action/ShowConfirmUIAction.java 2008-04-27 08:27:31 UTC (rev 626) +++ trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/action/ShowConfirmUIAction.java 2008-04-27 08:28:06 UTC (rev 627) @@ -23,12 +23,12 @@ import org.codelutin.vcs.ui.VCSUIFactory; import org.codelutin.vcs.ui.handler.ConfirmUIHandler; import org.codelutin.vcs.ui.model.ConfirmUIModel; -import org.codelutin.vcs.ui.util.AbstractShowUIAction; +import org.codelutin.vcs.ui.util.AbstractVCSShowUIAction; import java.awt.event.ActionEvent; /** @author chemit */ -public class ShowConfirmUIAction extends AbstractShowUIAction<ConfirmUIModel, ConfirmUI, ConfirmUIHandler, DialogUIHandler<?, ?>> { +public class ShowConfirmUIAction extends AbstractVCSShowUIAction<ConfirmUIModel, ConfirmUI, ConfirmUIHandler, DialogUIHandler<?, ?>> { private static final long serialVersionUID = 1L; Modified: trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/action/ShowDiffUIAction.java =================================================================== --- trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/action/ShowDiffUIAction.java 2008-04-27 08:27:31 UTC (rev 626) +++ trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/action/ShowDiffUIAction.java 2008-04-27 08:28:06 UTC (rev 627) @@ -22,12 +22,12 @@ import org.codelutin.vcs.ui.VCSUIFactory; import org.codelutin.vcs.ui.handler.DiffUIHandler; import org.codelutin.vcs.ui.model.DiffUIModel; -import org.codelutin.vcs.ui.util.AbstractShowUIAction; +import org.codelutin.vcs.ui.util.AbstractVCSShowUIAction; import java.awt.event.ActionEvent; /** @author chemit */ -public class ShowDiffUIAction extends AbstractShowUIAction<DiffUIModel, DiffUI, DiffUIHandler, DialogUIHandler<?, ?>> { +public class ShowDiffUIAction extends AbstractVCSShowUIAction<DiffUIModel, DiffUI, DiffUIHandler, DialogUIHandler<?, ?>> { private static final long serialVersionUID = 1L; Copied: trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/action/ShowIdentityUIAction.java (from rev 613, 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/action/ShowIdentityUIAction.java (rev 0) +++ trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/action/ShowIdentityUIAction.java 2008-04-27 08:28:06 UTC (rev 627) @@ -0,0 +1,62 @@ +/** + * # #% 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 org.codelutin.ui.DialogUIHandler; +import org.codelutin.ui.ShowUIAction; +import org.codelutin.vcs.ui.IdentityUI; +import org.codelutin.vcs.ui.VCSUIFactory; +import org.codelutin.vcs.ui.handler.IdentityUIHandler; +import org.codelutin.vcs.ui.model.IdentityUIModel; + +import java.awt.event.ActionEvent; +import java.io.Serializable; + +/** @author chemit */ +public class ShowIdentityUIAction extends ShowUIAction<IdentityUIModel, IdentityUI, IdentityUIHandler, DialogUIHandler<?, ?>> { + + private static final long serialVersionUID = 1L; + + protected Serializable src; + + public Serializable getSrc() { + return src; + } + + public void setSrc(Serializable src) { + this.src = src; + } + + public ShowIdentityUIAction(org.codelutin.ui.DialogUI ui, boolean showText) { + super(ui, VCSUIFactory.IDENTITY_UI, VCSUIFactory.getInstance(), showText); + } + + @Override + protected IdentityUI initUI(ActionEvent e) { + IdentityUI ui = getFactory().getUI(uiDef); + ui.getHandler().getModel().populate(src); + ui.pack(); + return ui; + } + + + @Override + protected void checkInit() throws IllegalStateException { + super.checkInit(); + if (src == null) { + throw new IllegalStateException("no src object found for action " + this); + } + } +} \ No newline at end of file Modified: trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/action/ShowSynchUIAction.java =================================================================== --- trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/action/ShowSynchUIAction.java 2008-04-27 08:27:31 UTC (rev 626) +++ trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/action/ShowSynchUIAction.java 2008-04-27 08:28:06 UTC (rev 627) @@ -22,12 +22,12 @@ import org.codelutin.vcs.ui.VCSUIFactory; import org.codelutin.vcs.ui.handler.SynchUIHandler; import org.codelutin.vcs.ui.model.SynchUIModel; -import org.codelutin.vcs.ui.util.AbstractShowUIAction; +import org.codelutin.vcs.ui.util.AbstractVCSShowUIAction; import java.awt.event.ActionEvent; /** @author chemit */ -public class ShowSynchUIAction extends AbstractShowUIAction<SynchUIModel, SynchUI, SynchUIHandler, DialogUIHandler<?,?>> { +public class ShowSynchUIAction extends AbstractVCSShowUIAction<SynchUIModel, SynchUI, SynchUIHandler, DialogUIHandler<?, ?>> { private static final long serialVersionUID = 1L; @@ -62,7 +62,7 @@ SynchUI ui = super.initUI(e); ui.getHandler().getModel().populate(getLocation(), entries); ui.getContentScroll().setEnabled(entries.length > 1); - ((AbstractShowUIAction) ui.getConfig().getAction()).setConfig(ui.getHandler().getConfig()); + ((AbstractVCSShowUIAction) ui.getConfig().getAction()).setConfig(ui.getHandler().getConfig()); return ui; } } \ No newline at end of file Added: trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/action/ShowTestUIAction.java =================================================================== --- trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/action/ShowTestUIAction.java (rev 0) +++ trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/action/ShowTestUIAction.java 2008-04-27 08:28:06 UTC (rev 627) @@ -0,0 +1,59 @@ +/** + * # #% 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 org.codelutin.ui.DialogUIHandler; +import org.codelutin.vcs.ui.TestUI; +import org.codelutin.vcs.ui.VCSUIFactory; +import org.codelutin.vcs.ui.handler.TestUIHandler; +import org.codelutin.vcs.ui.model.TestUIModel; +import org.codelutin.vcs.ui.util.AbstractShowUIAction; + +import java.awt.event.ActionEvent; + +/** @author chemit */ +public class ShowTestUIAction extends AbstractShowUIAction<TestUIModel, TestUI, TestUIHandler, DialogUIHandler<?, ?>> { + + private static final long serialVersionUID = 1L; + + protected transient TestUIModel model; + + protected boolean firstTime; + + public ShowTestUIAction(org.codelutin.ui.DialogUI ui, boolean showText) { + super(ui, VCSUIFactory.TEST_UI, showText); + } + + public void setModel(TestUIModel model, boolean firstTime) { + this.model = model; + this.firstTime = firstTime; + } + + @Override + protected TestUI initUI(ActionEvent e) { + TestUI ui = super.initUI(e); + ui.getHandler().getModel().init(model, firstTime); + ui.pack(); + return ui; + } + + @Override + protected void checkInit() throws IllegalStateException { + super.checkInit(); + if (model == null) { + throw new IllegalStateException("no model object found for action " + this); + } + } +} \ No newline at end of file Modified: trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/action/TabUIAction.java =================================================================== --- trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/action/TabUIAction.java 2008-04-27 08:27:31 UTC (rev 626) +++ trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/action/TabUIAction.java 2008-04-27 08:28:06 UTC (rev 627) @@ -60,14 +60,14 @@ // take all entries entries = model.filter(VCSAction.CHANGELOG, model.getEntries()); } - UIActionHelper.showChangelogUI(config, ui, location, entries.toArray(new VCSEntry[entries.size()])); + UIActionHelper.showChangelogUI(config, ui, location, entries.toArray(new VCSEntry[entries.size()]),null); return; case DIFF: if (!useSelection) { // take all entries entries = model.filter(VCSAction.DIFF, model.getEntries()); } - UIActionHelper.showDiffUI(config, ui, location, entries.toArray(new VCSEntry[entries.size()])); + UIActionHelper.showDiffUI(config, ui, location, entries.toArray(new VCSEntry[entries.size()]),null); return; case REFRESH: handler.doRefresh(model, entries, handler.getSelectionModel()); @@ -79,7 +79,7 @@ case DELETE: case REVERT: case UPDATE: - UIActionHelper.showConfirmUI(config, ui, location, action, entries.toArray(new VCSEntry[entries.size()])); + UIActionHelper.showConfirmUI(config, ui, location, action, entries.toArray(new VCSEntry[entries.size()]),null); return; } throw new IllegalStateException("could not perform action for action " + action + " (" + this + ')'); Modified: 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/action/TestConnexionAction.java 2008-04-27 08:27:31 UTC (rev 626) +++ trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/action/TestConnexionAction.java 2008-04-27 08:28:06 UTC (rev 627) @@ -33,7 +33,7 @@ private static final long serialVersionUID = 1L; public TestConnexionAction(org.codelutin.vcs.ui.ConfigUI ui) { - super(null, org.codelutin.ui.UIHelper.createActionIcon("test"), ui); + super(null, org.codelutin.ui.UIHelper.createActionIcon("testconnexion"), 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)); 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-27 08:27:31 UTC (rev 626) +++ trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/handler/ConfigUIHandler.java 2008-04-27 08:28:06 UTC (rev 627) @@ -18,7 +18,13 @@ import org.codelutin.vcs.type.VCSConnexionMode; import org.codelutin.vcs.ui.ConfigUI; import org.codelutin.vcs.ui.ConfigUI.Element; -import static org.codelutin.vcs.ui.ConfigUI.Element.*; +import static org.codelutin.vcs.ui.ConfigUI.Element.login; +import static org.codelutin.vcs.ui.ConfigUI.Element.nopassphrase; +import static org.codelutin.vcs.ui.ConfigUI.Element.passphrase; +import static org.codelutin.vcs.ui.ConfigUI.Element.password; +import static org.codelutin.vcs.ui.ConfigUI.Element.privateKeyFile; +import static org.codelutin.vcs.ui.ConfigUI.Element.sshLogin; +import static org.codelutin.vcs.ui.ConfigUI.Element.values; import org.codelutin.vcs.ui.model.ConfigUIModel; import org.codelutin.vcs.ui.util.handler.AbstractUIHandler; @@ -51,8 +57,7 @@ JPanel connexionPanel = ui.getConnexionPanel(); connexionPanel.add(ui.getAnonymousPanel(), VCSConnexionMode.ANONYMOUS.name()); connexionPanel.add(ui.getPasswordPanel(), VCSConnexionMode.PASSWORD.name()); - connexionPanel.add(ui.getSshPanel(), VCSConnexionMode.SSH.name()); - //getUi().pack(); + connexionPanel.add(ui.getSshPanel(), VCSConnexionMode.SSH.name()); } public void propertyChange(PropertyChangeEvent evt) { @@ -98,13 +103,6 @@ // compute modifed setModified(element, ui); } - // validate firstname + lastname + email (only if required) - if (getModel().isShowIdentity()) { - checkData(ui.getFirstname(), firstname); - checkData(ui.getLastname(), lastname); - checkData(ui.getEmail(), email); - } - switch (getModel().getMode()) { case ANONYMOUS: // nothing to validate @@ -141,15 +139,6 @@ case connexion: modify = model.getMode() != model.getConfig().getMode(); break; - case email: - modify = !model.getEmail().equals(value); - break; - case firstname: - modify = !model.getFirstname().equals(value); - break; - case lastname: - modify = !model.getLasttname().equals(value); - break; case login: modify = !model.getConfig().getUserName().equals(value); break; @@ -225,13 +214,6 @@ ui.getPassphrase().setText(config.getPassphrase() == null ? "" : config.getPassphrase()); break; } - boolean showIdenty = model.isShowIdentity(); - ui.getIdentityScroll().setVisible(showIdenty); - if (showIdenty) { - getUi().getFirstname().setText(model.getFirstname()); - getUi().getLastname().setText(model.getLasttname()); - getUi().getEmail().setText(model.getEmail()); - } ui.getTestConnection().setEnabled(true); } Copied: trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/handler/IdentityUIHandler.java (from rev 615, 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/IdentityUIHandler.java (rev 0) +++ trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/handler/IdentityUIHandler.java 2008-04-27 08:28:06 UTC (rev 627) @@ -0,0 +1,163 @@ +/** + * ##% 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.handler; + +import org.codelutin.ui.DialogUIHandler; +import org.codelutin.vcs.ui.IdentityUI; +import static org.codelutin.vcs.ui.IdentityUI.Element; +import static org.codelutin.vcs.ui.IdentityUI.Element.email; +import static org.codelutin.vcs.ui.IdentityUI.Element.firstname; +import static org.codelutin.vcs.ui.IdentityUI.Element.lastname; +import static org.codelutin.vcs.ui.IdentityUI.Element.values; +import org.codelutin.vcs.ui.model.IdentityUIModel; + +import javax.swing.JComponent; +import javax.swing.text.JTextComponent; +import java.awt.Color; +import java.beans.PropertyChangeEvent; +import java.util.ArrayList; +import java.util.List; + +/** @author chemit */ +public class IdentityUIHandler extends DialogUIHandler<IdentityUIModel, IdentityUI> { + + protected List<Element> errors; + + + public IdentityUIHandler(IdentityUI ui) { + super(ui, new IdentityUIModel()); + ui.setHandler(this); + errors = new ArrayList<Element>(); + } + + public void propertyChange(PropertyChangeEvent evt) { + if (log.isDebugEnabled()) { + log.debug(evt.getPropertyName() + " old:" + evt.getOldValue() + ", new:" + evt.getNewValue()); + } + String action = evt.getPropertyName(); + + if (IdentityUIModel.CONFIG_PROPERTY_CHANGED.equals(action)) { + // update ui with model values, + populateUI((IdentityUIModel) evt.getNewValue()); + doCheck(null); + return; + } + + if (IdentityUIModel.MODIFIED_PROPERTY_CHANGED.equals(action)) { + Boolean newValue = (Boolean) evt.getNewValue(); + boolean modified = newValue != null && newValue; + getUi().getReset().setEnabled(modified); + return; + } + throw new IllegalStateException("unimplemented property changed : " + evt + " for " + this); + } + + public synchronized List<Element> validateModel(Element element) { + errors.clear(); + IdentityUI ui = getUi(); + if (element != null) { + // compute modifed + setModified(element, ui); + } + checkData(ui.getFirstname(), firstname); + checkData(ui.getLastname(), lastname); + checkData(ui.getEmail(), email); + + return errors; + } + + public void setModified(Element element, IdentityUI ui) { + boolean modify = false; + IdentityUIModel model = getModel(); + + String value = ui.getElementValue(element); + + switch (element) { + case email: + modify = !model.getEmail().equals(value); + break; + case firstname: + modify = !model.getFirstname().equals(value); + break; + case lastname: + modify = !model.getLastname().equals(value); + break; + } + if (modify) { + model.addModified(element); + } else if (model.getModifieds().contains(element)) { + model.removeModified(element); + } + } + + public void doCheck(Element element) { + List<Element> errors = validateModel(element); + updateUI(errors); + } + + public boolean isConfigValid() { + return errors.isEmpty(); + } + + public void reset() { + getModel().reset(); + } + + protected void populateUI(IdentityUIModel model) { + IdentityUI ui = getUi(); + ui.getFirstname().setText(model.getFirstname()); + ui.getLastname().setText(model.getLastname()); + ui.getEmail().setText(model.getEmail()); + } + + protected void updateUI(List<Element> errors) { + IdentityUI ui = getUi(); + boolean valid = isConfigValid(); + ui.getOk().setEnabled(valid && getModel().isModified()); + for (Element element : values()) { + setLabelColor(errors, element); + } + } + + protected void checkData(JTextComponent component, Element errorName) { + if (component.getText().isEmpty()) { + errors.add(errorName); + } + } + + protected void checkData(boolean notValid, Element errorName) { + if (notValid) { + errors.add(errorName); + } + } + + protected void setLabelColor(List<Element> errors, Element element) { + JComponent component = getUi().getElementLabel(element); + if (component != null && component.isVisible()) { + component.setForeground(errors.contains(element) ? Color.red : Color.black); + } + } + + public void save() { + if (!getModel().isModified()) { + log.warn("nothing to save"); + } + for (Element element : getModel().getModifieds()) { + String value = getUi().getElementValue(element); + getModel().save(element, value); + log.info("save " + element); + } + } +} \ No newline at end of file Added: trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/handler/TestUIHandler.java =================================================================== --- trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/handler/TestUIHandler.java (rev 0) +++ trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/handler/TestUIHandler.java 2008-04-27 08:28:06 UTC (rev 627) @@ -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.handler; + +import org.codelutin.ui.DialogUIDef; +import org.codelutin.vcs.type.VCSEntryLocation; +import org.codelutin.vcs.ui.TestUI; +import org.codelutin.vcs.ui.UIActionHelper; +import org.codelutin.vcs.ui.VCSUIFactory; +import org.codelutin.vcs.ui.model.TestUIModel; + +import javax.swing.AbstractButton; +import java.beans.PropertyChangeEvent; + +/** @author chemit */ +public class TestUIHandler extends org.codelutin.ui.DialogUIHandler<TestUIModel, TestUI> { + + public TestUIHandler(TestUI ui) { + super(ui, new TestUIModel()); + ui.setHandler(this); + } + + @Override + public void init() { + super.init(); + // push icon and text in actions + initAction(VCSUIFactory.IDENTITY_UI, getUi().getShowFirstLaunch()); + initAction(VCSUIFactory.CONFIG_UI, getUi().getShowConfig()); + initAction(VCSUIFactory.SYNCH_UI, getUi().getShowSynch()); + } + + protected void initAction(DialogUIDef uiDef, AbstractButton button) { + button.setText(uiDef.getShowActionLibelle()); + button.setToolTipText(uiDef.getShowActionTip()); + button.setIcon(uiDef.getShowUIActionIcon()); + } + + public void propertyChange(PropertyChangeEvent evt) { + if (evt.getPropertyName().equals(TestUIModel.PREPARE_UI_PROPERTY_CHANGED)) { + return; + } + if (evt.getPropertyName().equals(TestUIModel.SHOW_UI_PROPERTY_CHANGED)) { + DialogUIDef uiDef = (DialogUIDef) evt.getNewValue(); + // show ui + if (uiDef == VCSUIFactory.IDENTITY_UI) { + UIActionHelper.showIdentityUI(getModel().getIdentity(), getUi(), "bottom-left"); + return; + } + if (uiDef == VCSUIFactory.CONFIG_UI) { + UIActionHelper.showConfigUI(getModel().getConnexion().getConfig(), getUi(), "bottom-left"); + return; + } + if (uiDef == VCSUIFactory.SYNCH_UI) { + UIActionHelper.showSynchUI(getModel().getConnexion().getConfig(), getUi(), VCSEntryLocation.ALL, getModel().getEntries(), "bottom-left"); + return; + } + return; + } + + throw new IllegalStateException("unknown property changed " + evt); + } +} \ No newline at end of file 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-27 08:27:31 UTC (rev 626) +++ trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/model/ConfigUIModel.java 2008-04-27 08:28:06 UTC (rev 627) @@ -38,49 +38,29 @@ public class ConfigUIModel extends AbstractUIModel { 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"; - public static final String MODIFIED_PROPERTY_CHANGED = "modify"; - private boolean showIdentity; - - private String firstname; - private String lasttname; - private String email; - private VCSConnexionMode mode; - + protected VCSConnexionMode mode; protected List<Element> modifieds; protected VCSConnexionConfig config; - protected Boolean connexionState; public ConfigUIModel() { modifieds = new ArrayList<Element>(); } - public void populate(VCSConnexionConfig config, boolean showIdentify, String firstname, String lastname, String email) { + public void populate(VCSConnexionConfig config) { this.config = config; - this.firstname = firstname; - this.lasttname = lastname; - this.email = email; - this.showIdentity = showIdentify; setConnexionMode(config.getMode()); setModified(false); firePropertyChange(CONFIG_PROPERTY_CHANGED, null, this); } - public void populate(VCSConnexionConfig config) { - populate(config, false, null, null, null); - } - public void reset() { checkConnexionInit(); - populate(config, showIdentity, firstname, lasttname, email); + populate(config); } public void setConnexionMode(VCSConnexionMode mode) { @@ -108,22 +88,6 @@ setConnexionState(null); } - public String getEmail() { - return email; - } - - public String getFirstname() { - return firstname; - } - - public String getLasttname() { - return lasttname; - } - - public boolean isShowIdentity() { - return showIdentity; - } - public boolean isModified() { return !modifieds.isEmpty(); } @@ -149,7 +113,7 @@ public void addModified(Element elementname) { if (!modifieds.contains(elementname)) { modifieds.add(elementname); - } + } setModified(!modifieds.isEmpty()); } @@ -176,12 +140,6 @@ case connexion: config.setConnexionMode(mode); break; - case email: - break; - case firstname: - break; - case lastname: - break; case login: if (mode != VCSConnexionMode.ANONYMOUS) { config.setUserName(value); @@ -218,7 +176,7 @@ public void setConnexionState(Boolean connexionState) { Boolean oldConnexionState = this.connexionState; - this.connexionState = 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/model/IdentityUIModel.java (from rev 615, 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/IdentityUIModel.java (rev 0) +++ trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/model/IdentityUIModel.java 2008-04-27 08:28:06 UTC (rev 627) @@ -0,0 +1,142 @@ +/** + * ##% 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.model; + + +import org.apache.commons.beanutils.BeanUtils; +import org.codelutin.ui.DialogUIModel; +import org.codelutin.vcs.ui.IdentityUI.Element; + +import java.lang.reflect.InvocationTargetException; +import java.util.ArrayList; +import java.util.List; + +/** + * Model of a a confirmation of action on entries (single type of action possible) + * + * @author chemit + */ +public class IdentityUIModel extends DialogUIModel { + + public static final String CONFIG_PROPERTY_CHANGED = "config"; + public static final String MODIFIED_PROPERTY_CHANGED = "modify"; + + protected Object src; + protected String firstname; + protected String lastname; + protected String email; + + protected List<Element> modifieds; + + public IdentityUIModel() { + modifieds = new ArrayList<Element>(); + } + + public void populate(Object src) { + this.src = src; + + for (Element o : Element.values()) { + try { + String value = BeanUtils.getProperty(src, o.name()); + BeanUtils.setProperty(this, o.name(), value); + } catch (IllegalAccessException e) { + throw new IllegalStateException(e); + } catch (InvocationTargetException e) { + throw new IllegalStateException(e); + } catch (NoSuchMethodException e) { + throw new IllegalStateException(e); + } + } + setModified(false); + firePropertyChange(CONFIG_PROPERTY_CHANGED, null, this); + } + + public void reset() { + populate(src); + } + + public String getEmail() { + return email; + } + + public String getFirstname() { + return firstname; + } + + public String getLastname() { + return lastname; + } + + public void setEmail(String email) { + this.email = email; + } + + public void setFirstname(String firstname) { + this.firstname = firstname; + } + + public void setLastname(String lastname) { + this.lastname = lastname; + } + + public boolean isModified() { + return !modifieds.isEmpty(); + } + + public List<Element> getModifieds() { + return modifieds; + } + + public void addModified(Element elementname) { + if (!modifieds.contains(elementname)) { + modifieds.add(elementname); + } + setModified(!modifieds.isEmpty()); + } + + public void removeModified(Element... elementnames) { + for (Element elementname : elementnames) { + if (modifieds.contains(elementname)) { + modifieds.remove(elementname); + } + setModified(!modifieds.isEmpty()); + } + + } + + public void setModified(boolean modified) { + if (!modified) { + modifieds.clear(); + } + firePropertyChange(MODIFIED_PROPERTY_CHANGED, null, modified); + } + + public void save(Element element, String value) { + switch (element) { + case email: + case firstname: + case lastname: + try { + BeanUtils.setProperty(src, element.name(), value); + } catch (IllegalAccessException e) { + throw new IllegalStateException(e); + } catch (InvocationTargetException e) { + throw new IllegalStateException(e); + } + break; + } + } + +} \ No newline at end of file Copied: trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/model/TestUIModel.java (from rev 609, trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/model/ChangelogUIModel.java) =================================================================== --- trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/model/TestUIModel.java (rev 0) +++ trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/model/TestUIModel.java 2008-04-27 08:28:06 UTC (rev 627) @@ -0,0 +1,81 @@ +/** + * ##% 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.model; + +import org.codelutin.ui.DialogUIDef; +import org.codelutin.vcs.VCSConnexion; +import org.codelutin.vcs.VCSEntry; + +import java.beans.PropertyChangeListener; +import java.io.Serializable; + +/** + * Model of a repository + * + * @author chemit + */ +public class TestUIModel extends org.codelutin.ui.DialogUIModel { + + public static final String PREPARE_UI_PROPERTY_CHANGED = "prepareui"; + public static final String SHOW_UI_PROPERTY_CHANGED = "showui"; + + protected VCSConnexion connexion; + protected Serializable identity; + private VCSEntry[] entries; + + public void setUIDef(DialogUIDef uiDef) { + // prepare model + firePropertyChange(PREPARE_UI_PROPERTY_CHANGED, this, uiDef); + + // display model + firePropertyChange(SHOW_UI_PROPERTY_CHANGED, this, uiDef); + } + + public VCSConnexion getConnexion() { + return connexion; + } + + public Serializable getIdentity() { + return identity; + } + + public VCSEntry[] getEntries() { + return entries; + } + + public void setConnexion(VCSConnexion connexion) { + this.connexion = connexion; + } + + public void setEntries(VCSEntry[] entries) { + this.entries = entries; + } + + public void setIdentity(Serializable identity) { + this.identity = identity; + } + + public void init(TestUIModel model, boolean firstTime) { + connexion = model.getConnexion(); + entries = model.getEntries(); + identity = model.getIdentity(); + if (firstTime) { + // propagate incoming model listeners to ui model + for (PropertyChangeListener listener : model.getPropertyChangeListeners()) { + addPropertyChangeListener(listener); + } + } + } +} \ No newline at end of file Modified: 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/AbstractShowUIAction.java 2008-04-27 08:27:31 UTC (rev 626) +++ trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/util/AbstractShowUIAction.java 2008-04-27 08:28:06 UTC (rev 627) @@ -19,7 +19,6 @@ 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; @@ -27,31 +26,14 @@ /** @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); + return getFactory().getUI(uiDef); } - @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 Copied: trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/util/AbstractVCSShowUIAction.java (from rev 615, 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/AbstractVCSShowUIAction.java (rev 0) +++ trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/util/AbstractVCSShowUIAction.java 2008-04-27 08:28:06 UTC (rev 627) @@ -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 AbstractVCSShowUIAction<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>> AbstractVCSShowUIAction(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