Author: tchemit Date: 2008-04-06 17:14:57 +0000 (Sun, 06 Apr 2008) New Revision: 410 Modified: trunk/lutinvcs/lutinvcs-ui-pre-jaxx/src/main/java/org/codelutin/vcs/ui/AbstractConfirmUI.java trunk/lutinvcs/lutinvcs-ui-pre-jaxx/src/main/java/org/codelutin/vcs/ui/AbstractDiffUI.java trunk/lutinvcs/lutinvcs-ui-pre-jaxx/src/main/java/org/codelutin/vcs/ui/AbstractSynchUI.java trunk/lutinvcs/lutinvcs-ui-pre-jaxx/src/main/java/org/codelutin/vcs/ui/AbstractUI.java trunk/lutinvcs/lutinvcs-ui-pre-jaxx/src/main/java/org/codelutin/vcs/ui/AbstractVCSPopup.java trunk/lutinvcs/lutinvcs-ui-pre-jaxx/src/main/java/org/codelutin/vcs/ui/handler/AbstractConfirmUIHandler.java trunk/lutinvcs/lutinvcs-ui-pre-jaxx/src/main/java/org/codelutin/vcs/ui/handler/AbstractUIHandler.java trunk/lutinvcs/lutinvcs-ui/src/main/java/org/codelutin/vcs/ui/ConfirmUIHandler.java trunk/lutinvcs/lutinvcs-ui/src/main/java/org/codelutin/vcs/ui/DiffUIHandler.java trunk/lutinvcs/lutinvcs-ui/src/main/java/org/codelutin/vcs/ui/SynchUIHandler.java trunk/lutinvcs/lutinvcs-ui/src/main/java/org/codelutin/vcs/ui/VCSUIFactory.java Log: use default constructor for ui since we use ServiceLoader Modified: trunk/lutinvcs/lutinvcs-ui/src/main/java/org/codelutin/vcs/ui/ConfirmUIHandler.java =================================================================== --- trunk/lutinvcs/lutinvcs-ui/src/main/java/org/codelutin/vcs/ui/ConfirmUIHandler.java 2008-04-06 17:14:47 UTC (rev 409) +++ trunk/lutinvcs/lutinvcs-ui/src/main/java/org/codelutin/vcs/ui/ConfirmUIHandler.java 2008-04-06 17:14:57 UTC (rev 410) @@ -14,43 +14,99 @@ */ package org.codelutin.vcs.ui; +import org.codelutin.vcs.VCSEntry; import org.codelutin.vcs.type.VCSAction; -import org.codelutin.vcs.ui.handler.AbstractConfirmUIHandler; +import org.codelutin.vcs.ui.model.AbstractVCSEntriesTableModel; import org.codelutin.vcs.ui.model.ConfirmUIModel; import javax.swing.ListSelectionModel; +import java.beans.PropertyChangeEvent; +import java.util.List; /** @author chemit */ -public class ConfirmUIHandler extends AbstractConfirmUIHandler { +public class ConfirmUIHandler extends org.codelutin.vcs.ui.handler.AbstractUIHandler<ConfirmUIModel, AbstractConfirmUI> { - protected final AbstractConfirmUI ui; public ConfirmUIHandler() { - this.ui = new JConfirmUI(this); + super(); + //this.ui = new JConfirmUI(this); } - public ConfirmUIModel getModel() { - return ui.getModel(); + /*public void setUi(AbstractConfirmUI ui) { + this.ui = ui; + }*/ + + /*public ConfirmUIModel getModel() { + return getUi().getModel(); + }*/ + + + public Class<AbstractConfirmUI> getUiClass() { + return AbstractConfirmUI.class; } - public AbstractConfirmUI getUi() { - return ui; + public Class<? super ConfirmUIModel> getModelClass() { + return ConfirmUIModel.class; } public ListSelectionModel getSelectionModel() { - return ui.getContentTable().getSelectionModel(); + return getUi().getContentTable().getSelectionModel(); } + public void propertyChange(PropertyChangeEvent evt) { + if (log.isDebugEnabled()) { + log.debug(evt.getPropertyName() + " old:" + evt.getOldValue() + ", new:" + evt.getNewValue()); + } + String action = evt.getPropertyName(); + + if (ConfirmUIModel.ACCEPT_PROPERTY_CHANGED.equals(action)) { + updateUI(); + return; + } + + if (ConfirmUIModel.MESSAGE_HISTORY_PROPERTY_CHANGED.equals(action)) { + updateMessageUI(); + return; + } + + throw new IllegalStateException("unimplemented property changed : " + evt); + } + protected void updateUI() { - VCSAction action = ui.getModel().getAction(); - ui.getAccept().setText(action.getLibelle()); - ui.getToolbar().setVisible(action.isCommit()); - ui.getHandler().getSelectionModel().setSelectionInterval(0, getModel().getEntriesModel().getRowCount() - 1); + VCSAction action = getModel().getAction(); + getUi().getAccept().setText(action.getLibelle()); + getUi().getToolbar().setVisible(action.isCommit()); + getUi().getHandler().getSelectionModel().setSelectionInterval(0, getModel().getEntriesModel().getRowCount() - 1); } protected void updateMessageUI() { // update message history combo box ? - ui.getLastMessages().setEnabled(!getModel().getCommitMessages().isEmpty()); + getUi().getLastMessages().setEnabled(!getModel().getCommitMessages().isEmpty()); } + public void doAction(String commitMessage, AbstractVCSEntriesTableModel model) { + + VCSAction action = getModel().getAction(); + + List<VCSEntry> entries = model.filter(action, model.getDisplayedEntries(getSelectionModel())); + + if (action.isCommit()) { + getModel().addCommitMessage(commitMessage); + + } else { + commitMessage = null; + } + + if (log.isDebugEnabled()) { + log.debug("action:" + action + ", message:" + commitMessage + ", nb files:" + entries.size()); + } + + getActionManager().add(action, entries.toArray(new VCSEntry[entries.size()]), commitMessage); + + // dispose ui + getUi().dispose(); + + } + + } Modified: trunk/lutinvcs/lutinvcs-ui/src/main/java/org/codelutin/vcs/ui/DiffUIHandler.java =================================================================== --- trunk/lutinvcs/lutinvcs-ui/src/main/java/org/codelutin/vcs/ui/DiffUIHandler.java 2008-04-06 17:14:47 UTC (rev 409) +++ trunk/lutinvcs/lutinvcs-ui/src/main/java/org/codelutin/vcs/ui/DiffUIHandler.java 2008-04-06 17:14:57 UTC (rev 410) @@ -17,26 +17,59 @@ import org.codelutin.vcs.VCSEntry; import org.codelutin.vcs.type.VCSAction; import org.codelutin.vcs.type.VCSEntryLocation; -import org.codelutin.vcs.ui.handler.AbstractDiffUIHandler; import org.codelutin.vcs.ui.model.DiffUIModel; +import java.beans.PropertyChangeEvent; + /** @author chemit */ -public class DiffUIHandler extends AbstractDiffUIHandler<JDiffUI> { +public class DiffUIHandler extends org.codelutin.vcs.ui.handler.AbstractTabUIHandler<DiffUIModel, AbstractDiffUI> { - protected final AbstractDiffUI ui; + //protected AbstractDiffUI ui; public DiffUIHandler() { - this.ui = new JDiffUI(this); + //this.ui = new JDiffUI(this); } - public JDiffUI getUi() { - return (JDiffUI) ui; + /*public AbstractDiffUI getUi() { + return ui; + }*/ + + /*public void setUi(AbstractDiffUI ui) { + this.ui = ui; } public DiffUIModel getModel() { return ui.getModel(); + }*/ + + public Class<AbstractDiffUI> getUiClass() { + return AbstractDiffUI.class; } + public Class<? super DiffUIModel> getModelClass() { + return DiffUIModel.class; + } + + @Override + public void propertyChange(PropertyChangeEvent evt) { + //if (log.isDebugEnabled()) { + log.info(evt.getPropertyName() + " old:" + evt.getOldValue() + ", new:" + evt.getNewValue()); + //} + + String action = evt.getPropertyName(); + if (DiffUIModel.FILE_PROPERTY_CHANGED.equals(action)) { + doSelectFile((VCSEntry) evt.getNewValue()); + } else { + super.propertyChange(evt); + } + } + + @Override + public void doSelectLocation(VCSEntryLocation location) { + super.doSelectLocation(location); + + } + protected void initTab(VCSEntryLocation location) { //TODO } Modified: trunk/lutinvcs/lutinvcs-ui/src/main/java/org/codelutin/vcs/ui/SynchUIHandler.java =================================================================== --- trunk/lutinvcs/lutinvcs-ui/src/main/java/org/codelutin/vcs/ui/SynchUIHandler.java 2008-04-06 17:14:47 UTC (rev 409) +++ trunk/lutinvcs/lutinvcs-ui/src/main/java/org/codelutin/vcs/ui/SynchUIHandler.java 2008-04-06 17:14:57 UTC (rev 410) @@ -3,7 +3,6 @@ import org.codelutin.vcs.VCSEntry; import org.codelutin.vcs.type.VCSAction; import org.codelutin.vcs.type.VCSEntryLocation; -import org.codelutin.vcs.ui.handler.AbstractSynchUIHandler; import org.codelutin.vcs.ui.handler.VCSAbsractAction; import org.codelutin.vcs.ui.model.AbstractVCSEntriesTableModel; import org.codelutin.vcs.ui.model.SynchUIModel; @@ -17,28 +16,59 @@ import java.util.List; /** @author chemit */ -public class SynchUIHandler extends AbstractSynchUIHandler<JSynchUI> { +public class SynchUIHandler extends org.codelutin.vcs.ui.handler.AbstractTabUIHandler<SynchUIModel, AbstractSynchUI> { - protected final JSynchUI ui; + //protected AbstractSynchUI ui; public SynchUIHandler() { - this.ui = new JSynchUI(this); + //this.ui = new JSynchUI(this); } - public JSynchUI getUi() { - return ui; + public Class<AbstractSynchUI> getUiClass() { + return AbstractSynchUI.class; } - public SynchUIModel getModel() { - return ui.getModel(); + public Class<? super SynchUIModel> getModelClass() { + return SynchUIModel.class; } - public void doAllAction(VCSAction action) { + /*public void setUi(AbstractSynchUI ui) { + this.ui = ui; + } + + public AbstractSynchUI getUi() { + return ui; + }*/ + + /*public SynchUIModel getModel() { + return ui.getModel(); + }*/ + + /*public void doAllAction(VCSAction action) { doAction(action, false); } public void doSelectAction(VCSAction action) { doAction(action, true); + }*/ + + @Override + public void doSelectLocation(VCSEntryLocation location) { + + super.doSelectLocation(location); + + VCSAction[] actions = getModel().getEntriesModel().getActions((ListSelectionModel) null); + List<String> acts = new ArrayList<String>(); + for (VCSAction action : actions) { + acts.add(action.name().toLowerCase()); + } + boolean hasActions = actions.length > 0; + getUi().getDiffAll().setEnabled(hasActions && acts.contains("diff")); + getUi().getUpdateAll().setEnabled(hasActions && acts.contains("update")); + getUi().getCommitAll().setEnabled(hasActions && acts.contains("commit")); + getUi().getRevertAll().setEnabled(hasActions && acts.contains("revert")); + getUi().getDeleteAll().setEnabled(hasActions && acts.contains("delete")); + getUi().getRefreshAll().setEnabled(hasActions); } public void doAction(VCSAction action, boolean useSelection) { @@ -61,6 +91,7 @@ return; } log.info("files to treate :" + entries.size()); + AbstractConfirmUI confirmUI = VCSUIFactory.newConfirmUI(); confirmUI.getModel().init(action, model.getLocation(), entries.toArray(new VCSEntry[entries.size()])); @@ -75,14 +106,14 @@ JTable table = getUi().getTable(location); AbstractVCSEntriesTableModel fileStatesModel = getModel().getEntriesModel(); table.setModel(fileStatesModel); - table.addMouseListener(new ListMouseListener(ui, fileStatesModel, location)); - AbstractVCSPopup jvcsPopup = getUi().getPopup(location); - //jvcsPopup.setDispatchAction(new VCSPopupAction(this, location)); - jvcsPopup.setDispatchAction(new VCSAbsractAction() { + table.addMouseListener(new ListMouseListener(getUi(), fileStatesModel, location)); + AbstractVCSPopup popup = getUi().getPopup(location); + + popup.setDispatchAction(new VCSAbsractAction() { private static final long serialVersionUID = 8622118724992019898L; public void actionPerformed(ActionEvent e) { - doSelectAction(action); + doAction(action, false); } }); } Modified: trunk/lutinvcs/lutinvcs-ui/src/main/java/org/codelutin/vcs/ui/VCSUIFactory.java =================================================================== --- trunk/lutinvcs/lutinvcs-ui/src/main/java/org/codelutin/vcs/ui/VCSUIFactory.java 2008-04-06 17:14:47 UTC (rev 409) +++ trunk/lutinvcs/lutinvcs-ui/src/main/java/org/codelutin/vcs/ui/VCSUIFactory.java 2008-04-06 17:14:57 UTC (rev 410) @@ -14,10 +14,16 @@ */ package org.codelutin.vcs.ui; +import org.apache.commons.logging.Log; +import org.apache.commons.logging.LogFactory; +import org.codelutin.util.StringUtil; +import org.codelutin.vcs.VCSFactory; import org.codelutin.vcs.ui.handler.AbstractUIHandler; +import org.codelutin.vcs.ui.model.AbstractUIModel; import java.util.HashMap; import java.util.Map; +import java.util.ServiceLoader; /** * Factory if VCS UI, using a cache. @@ -26,59 +32,125 @@ */ public class VCSUIFactory { - protected static Map<Class<? extends AbstractUIHandler>, AbstractUIHandler> cache; + static protected final Log log = LogFactory.getLog(VCSFactory.class); - protected static AbstractTabUI synchUI; - protected static AbstractDiffUI diffUI; - protected static AbstractConfirmUI confirmUI; + protected static VCSUIFactory instance; + protected Map<Class<? extends AbstractUIHandler>, AbstractUIHandler> cache; + protected ServiceLoader<AbstractUI> loader; + + public static AbstractSynchUI newSynchUI() { - SynchUIHandler result = newHandler(SynchUIHandler.class); + SynchUIHandler result = getInstance().newHandler(SynchUIHandler.class); return result.getUi(); } - public static AbstractDiffUI newDiffUI() { - DiffUIHandler result = newHandler(DiffUIHandler.class); + public static AbstractConfirmUI newConfirmUI() { + ConfirmUIHandler result = getInstance().newHandler(ConfirmUIHandler.class); return result.getUi(); } - public static AbstractConfirmUI newConfirmUI() { - ConfirmUIHandler result = newHandler(ConfirmUIHandler.class); + public static AbstractDiffUI newDiffUI() { + DiffUIHandler result = getInstance().newHandler(DiffUIHandler.class); return result.getUi(); } - public static void close() { + public void close() { if (cache != null) { cache.clear(); + cache = null; } - cache = null; + if (loader != null) { + loader.reload(); + loader = null; + } } - protected static Map<Class<? extends AbstractUIHandler>, AbstractUIHandler> getCache() { + protected static VCSUIFactory getInstance() { + if (instance == null) { + instance = new VCSUIFactory(); + } + return instance; + } + + @Override + protected void finalize() throws Throwable { + super.finalize(); + close(); + } + + protected synchronized Map<Class<? extends AbstractUIHandler>, AbstractUIHandler> getCache() { if (cache == null) { cache = new HashMap<Class<? extends AbstractUIHandler>, AbstractUIHandler>(); } return cache; } + protected synchronized ServiceLoader<AbstractUI> getLoader() { + if (loader == null) { + long t0 = System.nanoTime(); + + loader = ServiceLoader.load(AbstractUI.class); + int nb = 0; + for (AbstractUI provider : loader) { + log.info(provider.getName() + " [" + provider + ']'); + nb++; + } + log.info("found " + nb + " ui(s) in " + StringUtil.convertTime(t0, System.nanoTime())); + } + return loader; + } + @SuppressWarnings({"unchecked"}) - protected static <H extends AbstractUIHandler> H newHandler(Class<H> klass) { + protected <H extends AbstractUIHandler> H newHandler(Class<H> klass) { H result; - result = (H) getCache().get(klass); + + result = (H) getInstance().getCache().get(klass); + if (result == null) { + try { - result = klass.newInstance(); + // instance of handler + result = klass.getConstructor().newInstance(); + + // instance of model + AbstractUIModel model = (AbstractUIModel) result.getModelClass().newInstance(); + + // obtain intance of ui + AbstractUI ui = getUI(result.getUiClass()); + + // attach model to ui + ui.setModel(model); + + // attach handler to ui + ui.setHandler(result); + + // attach ui to handler + result.setUi(ui); + + // init handler result.init(); + getCache().put(klass, result); - } catch (InstantiationException e) { + } catch (Exception e) { throw new IllegalStateException("could not instanciate ui handler " + klass + " for reason : " + e.getMessage()); - } catch (IllegalAccessException e) { - throw new IllegalStateException("could not instanciate ui handler " + klass + " for reason : " + e.getMessage()); } } return result; } + @SuppressWarnings({"unchecked"}) + protected <U extends AbstractUI> U getUI(Class<U> klass) { + + for (AbstractUI ui : getLoader()) { + if (klass.isAssignableFrom(ui.getClass())) { + return (U) ui; + } + } + throw new IllegalStateException("could not find ui " + klass); + } + protected VCSUIFactory() { } + } Modified: trunk/lutinvcs/lutinvcs-ui-pre-jaxx/src/main/java/org/codelutin/vcs/ui/AbstractConfirmUI.java =================================================================== --- trunk/lutinvcs/lutinvcs-ui-pre-jaxx/src/main/java/org/codelutin/vcs/ui/AbstractConfirmUI.java 2008-04-06 17:14:47 UTC (rev 409) +++ trunk/lutinvcs/lutinvcs-ui-pre-jaxx/src/main/java/org/codelutin/vcs/ui/AbstractConfirmUI.java 2008-04-06 17:14:57 UTC (rev 410) @@ -17,6 +17,7 @@ import jaxx.runtime.swing.Table; import org.codelutin.vcs.ui.handler.AbstractConfirmUIHandler; import org.codelutin.vcs.ui.model.ConfirmUIModel; +import org.codelutin.vcs.ui.model.AbstractUIModel; import javax.swing.JButton; import javax.swing.JLabel; @@ -48,13 +49,7 @@ public abstract JButton getAccept(); - public AbstractConfirmUI() { - } - public AbstractConfirmUI(AbstractConfirmUIHandler handler) { - super(handler, new ConfirmUIModel()); - } - @Override protected AbstractConfirmUIHandler getHandler() { return (AbstractConfirmUIHandler) super.getHandler(); @@ -65,14 +60,16 @@ return (ConfirmUIModel) super.getModel(); } + @Override + public void setModel(AbstractUIModel model) { + super.setModel(model); + getContentTable().setModel(model.getEntriesModel()); + } + public void doAccept() { getHandler().doAction(getCommitMessage().getText(), getModel().getEntriesModel()); } - protected void showLastMessages() { - - } - @Override public void setVisible(boolean b) { if (b) { @@ -80,4 +77,8 @@ } super.setVisible(b); } + + protected void showLastMessages() { + //TODO + } } Modified: trunk/lutinvcs/lutinvcs-ui-pre-jaxx/src/main/java/org/codelutin/vcs/ui/AbstractDiffUI.java =================================================================== --- trunk/lutinvcs/lutinvcs-ui-pre-jaxx/src/main/java/org/codelutin/vcs/ui/AbstractDiffUI.java 2008-04-06 17:14:47 UTC (rev 409) +++ trunk/lutinvcs/lutinvcs-ui-pre-jaxx/src/main/java/org/codelutin/vcs/ui/AbstractDiffUI.java 2008-04-06 17:14:57 UTC (rev 410) @@ -28,14 +28,6 @@ public abstract JButton getPreviousDiff(); - public AbstractDiffUI() { - super(); - } - - public AbstractDiffUI(AbstractTabUIHandler handler) { - super(handler, new DiffUIModel()); - } - @Override public DiffUIModel getModel() { return (DiffUIModel) model; Modified: trunk/lutinvcs/lutinvcs-ui-pre-jaxx/src/main/java/org/codelutin/vcs/ui/AbstractSynchUI.java =================================================================== --- trunk/lutinvcs/lutinvcs-ui-pre-jaxx/src/main/java/org/codelutin/vcs/ui/AbstractSynchUI.java 2008-04-06 17:14:47 UTC (rev 409) +++ trunk/lutinvcs/lutinvcs-ui-pre-jaxx/src/main/java/org/codelutin/vcs/ui/AbstractSynchUI.java 2008-04-06 17:14:57 UTC (rev 410) @@ -43,14 +43,6 @@ public abstract AbstractVCSPopup getRemotePopup(); - public AbstractSynchUI() { - super(); - } - - public AbstractSynchUI(AbstractSynchUIHandler handler) { - super(handler, new SynchUIModel()); - } - @Override public SynchUIModel getModel() { return (SynchUIModel) model; Modified: trunk/lutinvcs/lutinvcs-ui-pre-jaxx/src/main/java/org/codelutin/vcs/ui/AbstractUI.java =================================================================== --- trunk/lutinvcs/lutinvcs-ui-pre-jaxx/src/main/java/org/codelutin/vcs/ui/AbstractUI.java 2008-04-06 17:14:47 UTC (rev 409) +++ trunk/lutinvcs/lutinvcs-ui-pre-jaxx/src/main/java/org/codelutin/vcs/ui/AbstractUI.java 2008-04-06 17:14:57 UTC (rev 410) @@ -20,13 +20,14 @@ /** @author chemit */ public class AbstractUI extends javax.swing.JDialog { - protected final AbstractUIModel model; + protected AbstractUIModel model; - protected final AbstractUIHandler handler; + protected AbstractUIHandler handler; public AbstractUI() { // Jaxx always generate the default constructor, so need it, but DO NOT USE IT! - throw new IllegalStateException("the default constructor can NOT be used!"); + //throw new IllegalStateException("the default constructor can NOT be used!"); + UIHelper.setQuitAction(this); } public AbstractUI(AbstractUIHandler handler, AbstractUIModel model) { @@ -43,5 +44,12 @@ return handler; } + public void setModel(AbstractUIModel model) { + this.model = model; + } + public void setHandler(AbstractUIHandler handler) { + this.handler = handler; + } + } Modified: trunk/lutinvcs/lutinvcs-ui-pre-jaxx/src/main/java/org/codelutin/vcs/ui/AbstractVCSPopup.java =================================================================== --- trunk/lutinvcs/lutinvcs-ui-pre-jaxx/src/main/java/org/codelutin/vcs/ui/AbstractVCSPopup.java 2008-04-06 17:14:47 UTC (rev 409) +++ trunk/lutinvcs/lutinvcs-ui-pre-jaxx/src/main/java/org/codelutin/vcs/ui/AbstractVCSPopup.java 2008-04-06 17:14:57 UTC (rev 410) @@ -21,7 +21,7 @@ import java.awt.event.ActionEvent; /** @author chemit */ -public abstract class AbstractVCSPopup extends javax.swing.JPopupMenu {/* begin raw body code */ +public abstract class AbstractVCSPopup extends javax.swing.JPopupMenu { protected VCSAbsractAction dispatchAction; Modified: trunk/lutinvcs/lutinvcs-ui-pre-jaxx/src/main/java/org/codelutin/vcs/ui/handler/AbstractConfirmUIHandler.java =================================================================== --- trunk/lutinvcs/lutinvcs-ui-pre-jaxx/src/main/java/org/codelutin/vcs/ui/handler/AbstractConfirmUIHandler.java 2008-04-06 17:14:47 UTC (rev 409) +++ trunk/lutinvcs/lutinvcs-ui-pre-jaxx/src/main/java/org/codelutin/vcs/ui/handler/AbstractConfirmUIHandler.java 2008-04-06 17:14:57 UTC (rev 410) @@ -16,7 +16,7 @@ import org.codelutin.vcs.VCSEntry; import org.codelutin.vcs.type.VCSAction; -import org.codelutin.vcs.ui.AbstractUI; +import org.codelutin.vcs.ui.AbstractConfirmUI; import org.codelutin.vcs.ui.model.AbstractVCSEntriesTableModel; import org.codelutin.vcs.ui.model.ConfirmUIModel; @@ -28,7 +28,7 @@ * * @author chemit */ -public abstract class AbstractConfirmUIHandler extends AbstractUIHandler<ConfirmUIModel, AbstractUI> { +public abstract class AbstractConfirmUIHandler extends AbstractUIHandler<ConfirmUIModel, AbstractConfirmUI> { protected abstract void updateUI(); Modified: trunk/lutinvcs/lutinvcs-ui-pre-jaxx/src/main/java/org/codelutin/vcs/ui/handler/AbstractUIHandler.java =================================================================== --- trunk/lutinvcs/lutinvcs-ui-pre-jaxx/src/main/java/org/codelutin/vcs/ui/handler/AbstractUIHandler.java 2008-04-06 17:14:47 UTC (rev 409) +++ trunk/lutinvcs/lutinvcs-ui-pre-jaxx/src/main/java/org/codelutin/vcs/ui/handler/AbstractUIHandler.java 2008-04-06 17:14:57 UTC (rev 410) @@ -30,12 +30,28 @@ protected static Log log = LogFactory.getLog(AbstractUIHandler.class); - public abstract M getModel(); + private U ui; - public abstract U getUi(); + public abstract Class<? super U> getUiClass(); + public abstract Class<? super M> getModelClass(); + public abstract ListSelectionModel getSelectionModel(); + @SuppressWarnings({"unchecked"}) + public M getModel() { + return (M) getUi().getModel(); + } + + public U getUi() { + return ui; + } + + public void setUi(U ui) { + this.ui = ui; + } + + public void init() { if (getModel() == null) { throw new IllegalStateException("no model was defined for " + this);