[Buix-commits] r633 - in trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui: . handler model
Author: tchemit Date: 2008-04-27 08:38:28 +0000 (Sun, 27 Apr 2008) New Revision: 633 Added: trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/model/ConnexionConfigUIModel.java Removed: trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/model/ConfigUIModel.java 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/handler/ConfigUIHandler.java Log: renommage ConfigUI en ConnexionConfigUI 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:38:00 UTC (rev 632) +++ trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/VCSUIFactory.java 2008-04-27 08:38:28 UTC (rev 633) @@ -34,7 +34,7 @@ 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.ConnexionConfigUIModel; import org.codelutin.vcs.ui.model.ConfirmUIModel; import org.codelutin.vcs.ui.model.DiffUIModel; import org.codelutin.vcs.ui.model.IdentityUIModel; @@ -59,7 +59,7 @@ 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, ConnexionConfigUI, ConfigUIHandler> CONFIG_UI; + public static final DialogUIDef<ConnexionConfigUIModel, ConnexionConfigUI, 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; @@ -132,7 +132,7 @@ n_("lutinvcs.action.show.confirmui"), n_("lutinvcs.action.show.confirmui.tip"), n_("lutinvcs.confirmui.title")); - CONFIG_UI = newDef(ConfigUIHandler.class, ConnexionConfigUI.class, ConfigUIModel.class, + CONFIG_UI = newDef(ConfigUIHandler.class, ConnexionConfigUI.class, ConnexionConfigUIModel.class, n_("lutinvcs.action.show.configui"), n_("lutinvcs.action.show.configui.tip"), n_("lutinvcs.configui.title")); 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:38:00 UTC (rev 632) +++ trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/handler/ConfigUIHandler.java 2008-04-27 08:38:28 UTC (rev 633) @@ -25,7 +25,7 @@ import static org.codelutin.vcs.ui.ConnexionConfigUI.Element.privateKeyFile; import static org.codelutin.vcs.ui.ConnexionConfigUI.Element.sshLogin; import static org.codelutin.vcs.ui.ConnexionConfigUI.Element.values; -import org.codelutin.vcs.ui.model.ConfigUIModel; +import org.codelutin.vcs.ui.model.ConnexionConfigUIModel; import org.codelutin.vcs.ui.util.handler.AbstractUIHandler; import javax.swing.JComponent; @@ -40,13 +40,13 @@ import java.util.List; /** @author chemit */ -public class ConfigUIHandler extends AbstractUIHandler<ConfigUIModel, ConnexionConfigUI> { +public class ConfigUIHandler extends AbstractUIHandler<ConnexionConfigUIModel, ConnexionConfigUI> { protected List<Element> errors; public ConfigUIHandler(ConnexionConfigUI ui, VCSConnexionConfig config) { - super(ui, new ConfigUIModel(), config); + super(ui, new ConnexionConfigUIModel(), config); ui.setHandler(this); errors = new ArrayList<Element>(); } @@ -66,19 +66,19 @@ } String action = evt.getPropertyName(); - if (ConfigUIModel.CONFIG_PROPERTY_CHANGED.equals(action)) { + if (ConnexionConfigUIModel.CONFIG_PROPERTY_CHANGED.equals(action)) { // update ui with model values, - populateUI((ConfigUIModel) evt.getNewValue()); + populateUI((ConnexionConfigUIModel) evt.getNewValue()); doCheck(null); return; } - if (ConfigUIModel.MODE_PROPERTY_CHANGED.equals(action)) { + if (ConnexionConfigUIModel.MODE_PROPERTY_CHANGED.equals(action)) { updateUI((VCSConnexionMode) evt.getNewValue()); doCheck(null); return; } - if (ConfigUIModel.MODIFIED_PROPERTY_CHANGED.equals(action)) { + if (ConnexionConfigUIModel.MODIFIED_PROPERTY_CHANGED.equals(action)) { Boolean newValue = (Boolean) evt.getNewValue(); boolean modified = newValue != null && newValue; getUi().getReset().setEnabled(modified); @@ -86,7 +86,7 @@ return; } - if (ConfigUIModel.CONNEXION_STATE_PROPERTY_CHANGED.equals(action)) { + if (ConnexionConfigUIModel.CONNEXION_STATE_PROPERTY_CHANGED.equals(action)) { Boolean newValue = (Boolean) evt.getNewValue(); boolean validConnexion = newValue != null && newValue; getUi().getOk().setEnabled(validConnexion); @@ -131,7 +131,7 @@ public void setModified(Element element, ConnexionConfigUI ui) { boolean modify = false; - ConfigUIModel model = getModel(); + ConnexionConfigUIModel model = getModel(); String value = ui.getElementValue(element); @@ -197,7 +197,7 @@ getModel().reset(); } - protected void populateUI(ConfigUIModel model) { + protected void populateUI(ConnexionConfigUIModel model) { ConnexionConfigUI ui = getUi(); VCSConnexionConfig config = model.getConfig(); switch (config.getMode()) { Deleted: 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:38:00 UTC (rev 632) +++ trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/model/ConfigUIModel.java 2008-04-27 08:38:28 UTC (rev 633) @@ -1,182 +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.model; - -import org.codelutin.vcs.VCSConnexionConfig; -import org.codelutin.vcs.type.VCSConnexionMode; -import org.codelutin.vcs.ui.ConnexionConfigUI.Element; -import static org.codelutin.vcs.ui.ConnexionConfigUI.Element.connexion; -import static org.codelutin.vcs.ui.ConnexionConfigUI.Element.login; -import static org.codelutin.vcs.ui.ConnexionConfigUI.Element.nopassphrase; -import static org.codelutin.vcs.ui.ConnexionConfigUI.Element.passphrase; -import static org.codelutin.vcs.ui.ConnexionConfigUI.Element.password; -import static org.codelutin.vcs.ui.ConnexionConfigUI.Element.privateKeyFile; -import static org.codelutin.vcs.ui.ConnexionConfigUI.Element.sshLogin; -import org.codelutin.vcs.ui.util.model.AbstractUIModel; - -import java.io.File; -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 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 MODIFIED_PROPERTY_CHANGED = "modify"; - - protected VCSConnexionMode mode; - protected List<Element> modifieds; - protected VCSConnexionConfig config; - protected Boolean connexionState; - - public ConfigUIModel() { - modifieds = new ArrayList<Element>(); - } - - public void populate(VCSConnexionConfig config) { - this.config = config; - setConnexionMode(config.getMode()); - setModified(false); - firePropertyChange(CONFIG_PROPERTY_CHANGED, null, this); - } - - public void reset() { - checkConnexionInit(); - populate(config); - } - - public void setConnexionMode(VCSConnexionMode mode) { - VCSConnexionMode oldMode = this.mode; - this.mode = mode; - if (oldMode != null) { - switch (oldMode) { - case ANONYMOUS: - // nothing to clean - break; - case PASSWORD: - removeModified(login, password); - break; - case SSH: - removeModified(sshLogin, passphrase, nopassphrase, privateKeyFile); - break; - } - } - if (mode == getConfig().getMode()) { - removeModified(connexion); - } else { - addModified(connexion); - } - firePropertyChange(MODE_PROPERTY_CHANGED, oldMode, mode); - setConnexionState(null); - } - - public boolean isModified() { - return !modifieds.isEmpty(); - } - - public List<Element> getModifieds() { - return modifieds; - } - - public Boolean isConnexionState() { - return connexionState != null && connexionState; - } - - public VCSConnexionConfig getConfig() throws IllegalStateException { - checkConnexionInit(); - return config; - } - - public VCSConnexionMode getMode() throws IllegalStateException { - checkConnexionInit(); - return mode; - } - - 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) { - checkConnexionInit(); - switch (element) { - case connexion: - config.setConnexionMode(mode); - break; - case login: - if (mode != VCSConnexionMode.ANONYMOUS) { - config.setUserName(value); - } - break; - case nopassphrase: - if (mode == VCSConnexionMode.SSH) { - config.setNoPassPhrase(Boolean.valueOf(value)); - } - break; - case password: - if (mode == VCSConnexionMode.PASSWORD) { - config.setPassPhrase(value); - } - case passphrase: - if (mode == VCSConnexionMode.SSH) { - config.setPassPhrase(value); - } - break; - case privateKeyFile: - if (mode == VCSConnexionMode.SSH) { - config.setKeyFile(new File(value)); - } - break; - } - } - - - protected void checkConnexionInit() throws IllegalStateException { - if (config == null) { - 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/model/ConnexionConfigUIModel.java (from rev 632, 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/ConnexionConfigUIModel.java (rev 0) +++ trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/model/ConnexionConfigUIModel.java 2008-04-27 08:38:28 UTC (rev 633) @@ -0,0 +1,182 @@ +/** + * ##% 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.vcs.VCSConnexionConfig; +import org.codelutin.vcs.type.VCSConnexionMode; +import org.codelutin.vcs.ui.ConnexionConfigUI.Element; +import static org.codelutin.vcs.ui.ConnexionConfigUI.Element.connexion; +import static org.codelutin.vcs.ui.ConnexionConfigUI.Element.login; +import static org.codelutin.vcs.ui.ConnexionConfigUI.Element.nopassphrase; +import static org.codelutin.vcs.ui.ConnexionConfigUI.Element.passphrase; +import static org.codelutin.vcs.ui.ConnexionConfigUI.Element.password; +import static org.codelutin.vcs.ui.ConnexionConfigUI.Element.privateKeyFile; +import static org.codelutin.vcs.ui.ConnexionConfigUI.Element.sshLogin; +import org.codelutin.vcs.ui.util.model.AbstractUIModel; + +import java.io.File; +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 ConnexionConfigUIModel 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 MODIFIED_PROPERTY_CHANGED = "modify"; + + protected VCSConnexionMode mode; + protected List<Element> modifieds; + protected VCSConnexionConfig config; + protected Boolean connexionState; + + public ConnexionConfigUIModel() { + modifieds = new ArrayList<Element>(); + } + + public void populate(VCSConnexionConfig config) { + this.config = config; + setConnexionMode(config.getMode()); + setModified(false); + firePropertyChange(CONFIG_PROPERTY_CHANGED, null, this); + } + + public void reset() { + checkConnexionInit(); + populate(config); + } + + public void setConnexionMode(VCSConnexionMode mode) { + VCSConnexionMode oldMode = this.mode; + this.mode = mode; + if (oldMode != null) { + switch (oldMode) { + case ANONYMOUS: + // nothing to clean + break; + case PASSWORD: + removeModified(login, password); + break; + case SSH: + removeModified(sshLogin, passphrase, nopassphrase, privateKeyFile); + break; + } + } + if (mode == getConfig().getMode()) { + removeModified(connexion); + } else { + addModified(connexion); + } + firePropertyChange(MODE_PROPERTY_CHANGED, oldMode, mode); + setConnexionState(null); + } + + public boolean isModified() { + return !modifieds.isEmpty(); + } + + public List<Element> getModifieds() { + return modifieds; + } + + public Boolean isConnexionState() { + return connexionState != null && connexionState; + } + + public VCSConnexionConfig getConfig() throws IllegalStateException { + checkConnexionInit(); + return config; + } + + public VCSConnexionMode getMode() throws IllegalStateException { + checkConnexionInit(); + return mode; + } + + 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) { + checkConnexionInit(); + switch (element) { + case connexion: + config.setConnexionMode(mode); + break; + case login: + if (mode != VCSConnexionMode.ANONYMOUS) { + config.setUserName(value); + } + break; + case nopassphrase: + if (mode == VCSConnexionMode.SSH) { + config.setNoPassPhrase(Boolean.valueOf(value)); + } + break; + case password: + if (mode == VCSConnexionMode.PASSWORD) { + config.setPassPhrase(value); + } + case passphrase: + if (mode == VCSConnexionMode.SSH) { + config.setPassPhrase(value); + } + break; + case privateKeyFile: + if (mode == VCSConnexionMode.SSH) { + config.setKeyFile(new File(value)); + } + break; + } + } + + + protected void checkConnexionInit() throws IllegalStateException { + if (config == null) { + 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
participants (1)
-
tchemit@users.labs.libre-entreprise.org