Author: tchemit Date: 2008-04-16 21:09:36 +0000 (Wed, 16 Apr 2008) New Revision: 531 Added: trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/util/handler/ trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/util/handler/AbstractBasicUIHandler.java trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/util/handler/AbstractTabOneFileUIHandler.java trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/util/handler/AbstractTabUIHandler.java trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/util/handler/AbstractUIHandler.java Removed: trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/util/AbstractBasicUIHandler.java trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/util/AbstractTabOneFileUIHandler.java trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/util/AbstractTabUIHandler.java trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/util/AbstractUIHandler.java Modified: trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/VCSUI.java trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/action/ChangeFileAction.java trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/action/ChangeLocationAction.java trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/action/HelpAction.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/TabUIAction.java trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/handler/ChangelogUIHandler.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/handler/ConfirmUIHandler.java trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/handler/DiffUIHandler.java trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/handler/SynchUIHandler.java trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/util/AbstractBasicUI.java trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/util/AbstractTabOneFileUI.java trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/util/AbstractTabUI.java trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/util/AbstractUI.java trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/util/AbstractUIAction.java Log: refactor util package Modified: trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/VCSUI.java =================================================================== --- trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/VCSUI.java 2008-04-16 21:07:57 UTC (rev 530) +++ trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/VCSUI.java 2008-04-16 21:09:36 UTC (rev 531) @@ -15,14 +15,14 @@ package org.codelutin.vcs.ui; import org.codelutin.vcs.ui.util.AbstractUI; -import org.codelutin.vcs.ui.util.AbstractUIHandler; +import org.codelutin.vcs.ui.util.handler.AbstractUIHandler; import org.codelutin.vcs.ui.util.AbstractUIModel; /** * @author chemit * @see AbstractUI * @see AbstractUIModel - * @see AbstractUIHandler + * @see org.codelutin.vcs.ui.util.handler.AbstractUIHandler */ public enum VCSUI { Modified: trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/action/ChangeFileAction.java =================================================================== --- trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/action/ChangeFileAction.java 2008-04-16 21:07:57 UTC (rev 530) +++ trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/action/ChangeFileAction.java 2008-04-16 21:09:36 UTC (rev 531) @@ -15,7 +15,7 @@ package org.codelutin.vcs.ui.action; import org.codelutin.vcs.ui.util.AbstractTabOneFileUI; -import org.codelutin.vcs.ui.util.AbstractTabOneFileUIHandler; +import org.codelutin.vcs.ui.util.handler.AbstractTabOneFileUIHandler; import static org.codelutin.vcs.ui.util.UIHelper.createActionIcon; import javax.swing.AbstractAction; Modified: trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/action/ChangeLocationAction.java =================================================================== --- trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/action/ChangeLocationAction.java 2008-04-16 21:07:57 UTC (rev 530) +++ trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/action/ChangeLocationAction.java 2008-04-16 21:09:36 UTC (rev 531) @@ -16,7 +16,7 @@ import org.codelutin.vcs.type.VCSEntryLocation; import org.codelutin.vcs.ui.util.AbstractTabUI; -import org.codelutin.vcs.ui.util.AbstractTabUIHandler; +import org.codelutin.vcs.ui.util.handler.AbstractTabUIHandler; import org.codelutin.vcs.ui.util.UIHelper; import javax.swing.AbstractAction; Modified: trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/action/HelpAction.java =================================================================== --- trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/action/HelpAction.java 2008-04-16 21:07:57 UTC (rev 530) +++ trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/action/HelpAction.java 2008-04-16 21:09:36 UTC (rev 531) @@ -16,7 +16,7 @@ import static org.codelutin.i18n.I18n._; import org.codelutin.vcs.ui.util.AbstractUI; -import org.codelutin.vcs.ui.util.AbstractUIHandler; +import org.codelutin.vcs.ui.util.handler.AbstractUIHandler; import static org.codelutin.vcs.ui.util.UIHelper.createActionIcon; import javax.swing.AbstractAction; 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-16 21:07:57 UTC (rev 530) +++ trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/action/ShowConfigAction.java 2008-04-16 21:09:36 UTC (rev 531) @@ -16,7 +16,7 @@ import static org.codelutin.i18n.I18n._; import org.codelutin.vcs.ui.util.AbstractUI; -import org.codelutin.vcs.ui.util.AbstractUIHandler; +import org.codelutin.vcs.ui.util.handler.AbstractUIHandler; import static org.codelutin.vcs.ui.util.UIHelper.createActionIcon; import org.codelutin.vcs.ui.VCSUIFactory; 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-16 21:07:57 UTC (rev 530) +++ trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/action/TabUIAction.java 2008-04-16 21:09:36 UTC (rev 531) @@ -17,7 +17,7 @@ import org.codelutin.vcs.VCSEntry; import org.codelutin.vcs.type.VCSAction; import org.codelutin.vcs.ui.util.AbstractTabUI; -import org.codelutin.vcs.ui.util.AbstractTabUIHandler; +import org.codelutin.vcs.ui.util.handler.AbstractTabUIHandler; import org.codelutin.vcs.ui.util.AbstractVCSEntriesTableModel; import org.codelutin.vcs.ui.util.UIHelper; Modified: trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/handler/ChangelogUIHandler.java =================================================================== --- trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/handler/ChangelogUIHandler.java 2008-04-16 21:07:57 UTC (rev 530) +++ trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/handler/ChangelogUIHandler.java 2008-04-16 21:09:36 UTC (rev 531) @@ -20,7 +20,7 @@ import org.codelutin.vcs.type.VCSState; import org.codelutin.vcs.ui.ChangelogUI; import org.codelutin.vcs.ui.model.ChangelogUIModel; -import org.codelutin.vcs.ui.util.AbstractTabOneFileUIHandler; +import org.codelutin.vcs.ui.util.handler.AbstractTabOneFileUIHandler; import org.codelutin.vcs.ui.util.AbstractVCSEntriesTableModel; import javax.swing.SwingUtilities; 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-16 21:07:57 UTC (rev 530) +++ trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/handler/ConfigUIHandler.java 2008-04-16 21:09:36 UTC (rev 531) @@ -20,7 +20,7 @@ import org.codelutin.vcs.ui.ConfigUI.Element; import static org.codelutin.vcs.ui.ConfigUI.Element.*; import org.codelutin.vcs.ui.model.ConfigUIModel; -import org.codelutin.vcs.ui.util.AbstractUIHandler; +import org.codelutin.vcs.ui.util.handler.AbstractUIHandler; import javax.swing.JComponent; import javax.swing.JPanel; Modified: trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/handler/ConfirmUIHandler.java =================================================================== --- trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/handler/ConfirmUIHandler.java 2008-04-16 21:07:57 UTC (rev 530) +++ trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/handler/ConfirmUIHandler.java 2008-04-16 21:09:36 UTC (rev 531) @@ -20,7 +20,7 @@ import org.codelutin.vcs.type.VCSAction; import org.codelutin.vcs.ui.ConfirmUI; import org.codelutin.vcs.ui.model.ConfirmUIModel; -import org.codelutin.vcs.ui.util.AbstractBasicUIHandler; +import org.codelutin.vcs.ui.util.handler.AbstractBasicUIHandler; import org.codelutin.vcs.ui.util.AbstractVCSEntriesTableModel; import org.codelutin.vcs.ui.util.UIHelper; Modified: trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/handler/DiffUIHandler.java =================================================================== --- trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/handler/DiffUIHandler.java 2008-04-16 21:07:57 UTC (rev 530) +++ trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/handler/DiffUIHandler.java 2008-04-16 21:09:36 UTC (rev 531) @@ -22,7 +22,7 @@ import org.codelutin.vcs.type.VCSState; import org.codelutin.vcs.ui.DiffUI; import org.codelutin.vcs.ui.model.DiffUIModel; -import org.codelutin.vcs.ui.util.AbstractTabOneFileUIHandler; +import org.codelutin.vcs.ui.util.handler.AbstractTabOneFileUIHandler; import org.codelutin.vcs.ui.util.AbstractVCSEntriesTableModel; import javax.swing.SwingUtilities; Modified: trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/handler/SynchUIHandler.java =================================================================== --- trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/handler/SynchUIHandler.java 2008-04-16 21:07:57 UTC (rev 530) +++ trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/handler/SynchUIHandler.java 2008-04-16 21:09:36 UTC (rev 531) @@ -7,7 +7,7 @@ import org.codelutin.vcs.type.VCSState; import org.codelutin.vcs.ui.SynchUI; import org.codelutin.vcs.ui.model.SynchUIModel; -import org.codelutin.vcs.ui.util.AbstractTabUIHandler; +import org.codelutin.vcs.ui.util.handler.AbstractTabUIHandler; import org.codelutin.vcs.ui.util.AbstractVCSEntriesTableModel; import javax.swing.AbstractButton; Modified: trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/util/AbstractBasicUI.java =================================================================== --- trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/util/AbstractBasicUI.java 2008-04-16 21:07:57 UTC (rev 530) +++ trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/util/AbstractBasicUI.java 2008-04-16 21:09:36 UTC (rev 531) @@ -14,6 +14,8 @@ */ package org.codelutin.vcs.ui.util; +import org.codelutin.vcs.ui.util.handler.AbstractUIHandler; + import javax.swing.JScrollPane; import javax.swing.JTable; Deleted: trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/util/AbstractBasicUIHandler.java =================================================================== --- trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/util/AbstractBasicUIHandler.java 2008-04-16 21:07:57 UTC (rev 530) +++ trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/util/AbstractBasicUIHandler.java 2008-04-16 21:09:36 UTC (rev 531) @@ -1,72 +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.util; - -import org.codelutin.vcs.VCSFactory; -import org.codelutin.vcs.event.VCSActionThreadEventListener; -import org.codelutin.vcs.runner.VCSActionManager; -import org.codelutin.vcs.type.VCSEntryLocation; - -import javax.swing.JTable; -import javax.swing.ListSelectionModel; -import javax.swing.event.ListSelectionEvent; -import javax.swing.event.ListSelectionListener; - -/** @author chemit */ -public abstract class AbstractBasicUIHandler<M extends AbstractBasicUIModel, U extends AbstractBasicUI<? extends AbstractBasicUIHandler>> extends AbstractUIHandler<M, U> implements ListSelectionListener, VCSActionThreadEventListener { - - private final boolean useThreadListener; - - protected abstract void afterSelectionChanged(); - - protected AbstractBasicUIHandler(U ui, M model, boolean useThreadListener) { - super(ui, model); - this.useThreadListener = useThreadListener; - } - - public final ListSelectionModel getSelectionModel() { - return getUi().getContentTable().getSelectionModel(); - } - - public boolean isUseThreadListener() { - return useThreadListener; - } - - public void valueChanged(ListSelectionEvent e) { - if (!e.getValueIsAdjusting()) { - // update popup states - afterSelectionChanged(); - } - } - - @Override - public void init() { - super.init(); - getUi().getContentTable().getSelectionModel().addListSelectionListener(this); - JTable table = getUi().getContentTable(); - table.setModel(getModel().getEntriesModel()); - // init table renderer - UIHelper.installVCSTableUI(table); - } - - public VCSEntryLocation getLocation() { - return getModel().getEntriesModel().getLocation(); - } - - public VCSActionManager getActionManager() { - return VCSFactory.getActionManager(); - } - -} \ No newline at end of file Modified: trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/util/AbstractTabOneFileUI.java =================================================================== --- trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/util/AbstractTabOneFileUI.java 2008-04-16 21:07:57 UTC (rev 530) +++ trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/util/AbstractTabOneFileUI.java 2008-04-16 21:09:36 UTC (rev 531) @@ -15,6 +15,7 @@ package org.codelutin.vcs.ui.util; import org.codelutin.vcs.ui.action.ChangeFileAction; +import org.codelutin.vcs.ui.util.handler.AbstractTabOneFileUIHandler; import javax.swing.AbstractAction; import javax.swing.AbstractButton; Deleted: trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/util/AbstractTabOneFileUIHandler.java =================================================================== --- trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/util/AbstractTabOneFileUIHandler.java 2008-04-16 21:07:57 UTC (rev 530) +++ trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/util/AbstractTabOneFileUIHandler.java 2008-04-16 21:09:36 UTC (rev 531) @@ -1,111 +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.util; - -import static org.codelutin.i18n.I18n._; -import org.codelutin.vcs.VCSEntry; -import org.codelutin.vcs.type.VCSAction; -import org.codelutin.vcs.type.VCSEntryLocation; -import org.codelutin.vcs.ui.model.DiffUIModel; - -import javax.swing.AbstractButton; -import javax.swing.ListSelectionModel; -import javax.swing.event.ListSelectionEvent; -import java.beans.PropertyChangeEvent; -import java.util.EnumMap; - -/** @author chemit */ -public abstract class AbstractTabOneFileUIHandler<M extends AbstractTabOneFileUIModel, U extends AbstractTabOneFileUI<? extends AbstractTabUIHandler>> extends AbstractTabUIHandler<M, U> { - - protected AbstractTabOneFileUIHandler(U ui, M model,boolean useThreadListener) { - super(ui, model,useThreadListener); - } - - @Override - public void propertyChange(PropertyChangeEvent evt) { - if (log.isDebugEnabled()) { - log.debug(evt.getPropertyName() + " old:" + evt.getOldValue() + ", new:" + evt.getNewValue()); - } - if (DiffUIModel.FILE_PROPERTY_CHANGED.equals(evt.getPropertyName())) { - afterSelectionChanged(); - return; - } - super.propertyChange(evt); - } - - @Override - public void valueChanged(ListSelectionEvent e) { - if (!e.getValueIsAdjusting()) { - - ListSelectionModel selectionModel = (ListSelectionModel) e.getSource(); - - Integer selectionIndex = selectionModel.isSelectionEmpty() ? null : selectionModel.getMinSelectionIndex(); - - getModel().setFileModel(selectionIndex); - } - } - - protected void afterSelectionChanged() { - U ui = getUi(); - boolean hasNext = getModel().hasNextFile(); - boolean hasPrevious = getModel().hasPreviousFile(); - ui.getNextFile().setEnabled(hasNext); - ui.getPreviousFile().setEnabled(hasPrevious); - ui.getNextFile().setToolTipText(hasNext ? _("lutinvcs.action.nextfile.tip") : null); - ui.getPreviousFile().setToolTipText(hasPrevious ? _("lutinvcs.action.previousfile.tip") : null); - // always scroll to selected - Integer selectedRow = getModel().getFileIndex(); - if (selectedRow != null) { - ui.getContentTable().scrollRectToVisible(ui.getContentTable().getCellRect(selectedRow, 0, true)); - } - } - - public void afterLocationChanged() { - if (getLocation() == VCSEntryLocation.UNKNOW) { - return; - } - if (getModel().getEntriesModel().getRowCount() > 0) { - // select first row - getSelectionModel().setSelectionInterval(0, 0); - } else { - // disable all actions - afterSelectionChanged(); - } - } - - public void gotoPreviousFile() { - Integer index = getModel().getFileIndex(); - if (index != null && getModel().hasPreviousFile) { - getSelectionModel().setSelectionInterval(index - 1, index - 1); - } - } - - public void gotoNextFile() { - Integer index = getModel().getFileIndex(); - if (index != null && getModel().hasNextFile) { - getSelectionModel().setSelectionInterval(index + 1, index + 1); - } - } - - protected void updateAction(EnumMap<VCSAction, Integer> actions, boolean hasActions, AbstractButton ui, VCSAction action, VCSEntry vcsEntry) { - super.updateAction(actions, hasActions, ui, action); - boolean useAction = hasActions && actions.containsKey(action) && actions.get(action) > 0; - String tip = null; - if (useAction) { - tip = _("lutinvcs.action.single.tip", action.getLibelle(), vcsEntry.getFile().getName()); - } - ui.setToolTipText(tip); - } -} \ No newline at end of file Modified: trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/util/AbstractTabUI.java =================================================================== --- trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/util/AbstractTabUI.java 2008-04-16 21:07:57 UTC (rev 530) +++ trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/util/AbstractTabUI.java 2008-04-16 21:09:36 UTC (rev 531) @@ -16,6 +16,7 @@ import org.codelutin.vcs.type.VCSAction; import org.codelutin.vcs.type.VCSEntryLocation; +import org.codelutin.vcs.ui.util.handler.AbstractTabUIHandler; import javax.swing.AbstractAction; import javax.swing.AbstractButton; Deleted: trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/util/AbstractTabUIHandler.java =================================================================== --- trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/util/AbstractTabUIHandler.java 2008-04-16 21:07:57 UTC (rev 530) +++ trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/util/AbstractTabUIHandler.java 2008-04-16 21:09:36 UTC (rev 531) @@ -1,115 +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.util; - -import org.codelutin.vcs.VCSEntry; -import org.codelutin.vcs.VCSException; -import org.codelutin.vcs.type.VCSAction; -import org.codelutin.vcs.ui.ChangelogUI; -import org.codelutin.vcs.ui.ConfirmUI; -import org.codelutin.vcs.ui.DiffUI; -import org.codelutin.vcs.ui.VCSUIFactory; - -import javax.swing.AbstractButton; -import javax.swing.ListSelectionModel; -import javax.swing.event.TableModelListener; -import java.beans.PropertyChangeEvent; -import java.util.EnumMap; -import java.util.List; - -/** @author chemit */ -public abstract class AbstractTabUIHandler<M extends AbstractTabUIModel, U extends AbstractTabUI<? extends AbstractTabUIHandler>> extends AbstractBasicUIHandler<M, U> implements TableModelListener { - - protected AbstractTabUIHandler(U ui, M model,boolean useThreadListener) { - super(ui, model,useThreadListener); - } - - public void propertyChange(PropertyChangeEvent evt) { - if (log.isDebugEnabled()) { - log.debug(evt.getPropertyName() + " old:" + evt.getOldValue() + ", new:" + evt.getNewValue()); - } - String action = evt.getPropertyName(); - if (AbstractTabUIModel.LOCATION_PROPERTY_CHANGED.equals(action)) { - afterLocationChanged(); - } - } - - @Override - public void init() { - super.init(); - getUi().getContentTable().getModel().addTableModelListener(this); - } - - protected abstract void afterLocationChanged(); - - - protected void updateAction(EnumMap<VCSAction, Integer> actions, boolean hasActions, AbstractButton ui, VCSAction action) { - ui.setEnabled(hasActions && actions.containsKey(action) && actions.get(action) > 0); - } - - public void showConfirmUI(VCSAction action, AbstractVCSEntriesTableModel model, List<VCSEntry> entries) { - ConfirmUI ui = VCSUIFactory.newConfirmUI(); - if (log.isDebugEnabled()) { - log.debug("nb entries:" + entries.size()); - } - ui.getHandler().getModel().init(action, model.getLocation(), entries.toArray(new VCSEntry[entries.size()])); - ui.getContentScroll().setEnabled(entries.size() > 1); - ui.setVisible(true); - } - - public void showDiffUI(boolean useSelection, AbstractVCSEntriesTableModel model, List<VCSEntry> entries) { - DiffUI ui = VCSUIFactory.newDiffUI(); - if (!useSelection) { - // take all entries - entries = model.filter(VCSAction.DIFF, model.getEntries()); - } - if (log.isDebugEnabled()) { - log.debug("nb entries:" + entries.size()); - } - ui.getButton(model.getLocation()).setSelected(false); - ui.getHandler().getModel().init(model.getLocation(), entries.toArray(new VCSEntry[entries.size()])); - ui.getContentScroll().setEnabled(entries.size() > 1); - ui.setVisible(true); - } - - public void showChangelogUI(boolean useSelection, AbstractVCSEntriesTableModel model, List<VCSEntry> entries) { - ChangelogUI ui = VCSUIFactory.newChangelogUI(); - if (!useSelection) { - // take all entries - entries = model.filter(VCSAction.CHANGELOG, model.getEntries()); - } - if (log.isDebugEnabled()) { - log.debug("nb entries:" + entries.size()); - } - ui.getHandler().getModel().init(model.getLocation(), entries.toArray(new VCSEntry[entries.size()])); - ui.getContentScroll().setEnabled(entries.size() > 1); - ui.setVisible(true); - } - - public void doRefresh(AbstractVCSEntriesTableModel model, List<VCSEntry> entries, ListSelectionModel selectionModel) { - log.info(selectionModel); - selectionModel.clearSelection(); - if (log.isDebugEnabled()) { - log.debug("nb entries:" + entries.size()); - } - // do refresh of all states - try { - model.refresh(System.nanoTime(), entries); - } catch (VCSException e) { - log.error(e); - } - } - -} \ No newline at end of file Modified: trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/util/AbstractUI.java =================================================================== --- trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/util/AbstractUI.java 2008-04-16 21:07:57 UTC (rev 530) +++ trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/util/AbstractUI.java 2008-04-16 21:09:36 UTC (rev 531) @@ -14,6 +14,8 @@ */ package org.codelutin.vcs.ui.util; +import org.codelutin.vcs.ui.util.handler.AbstractUIHandler; + /** * A abstract dialog contract to be realised by a dialog * <p/> Modified: trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/util/AbstractUIAction.java =================================================================== --- trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/util/AbstractUIAction.java 2008-04-16 21:07:57 UTC (rev 530) +++ trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/util/AbstractUIAction.java 2008-04-16 21:09:36 UTC (rev 531) @@ -16,6 +16,7 @@ import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; +import org.codelutin.vcs.ui.util.handler.AbstractUIHandler; /** @author chemit */ public abstract class AbstractUIAction<H extends AbstractUIHandler<?, ?>> extends javax.swing.AbstractAction { Deleted: trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/util/AbstractUIHandler.java =================================================================== --- trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/util/AbstractUIHandler.java 2008-04-16 21:07:57 UTC (rev 530) +++ trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/util/AbstractUIHandler.java 2008-04-16 21:09:36 UTC (rev 531) @@ -1,27 +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.util; - -/** - * TODO Move this classe in jaxx - * - * @author chemit - */ -public abstract class AbstractUIHandler<M extends AbstractUIModel, U extends AbstractUI<? extends AbstractUIHandler>> extends jaxx.DialogUIHandler<M, U> { - - protected AbstractUIHandler(U ui, M model) { - super(ui, model); - } -} Copied: trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/util/handler/AbstractBasicUIHandler.java (from rev 524, trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/util/AbstractBasicUIHandler.java) =================================================================== --- trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/util/handler/AbstractBasicUIHandler.java (rev 0) +++ trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/util/handler/AbstractBasicUIHandler.java 2008-04-16 21:09:36 UTC (rev 531) @@ -0,0 +1,75 @@ +/** + * ##% 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.handler; + +import org.codelutin.vcs.VCSFactory; +import org.codelutin.vcs.ui.util.AbstractBasicUIModel; +import org.codelutin.vcs.ui.util.AbstractBasicUI; +import org.codelutin.vcs.ui.util.UIHelper; +import org.codelutin.vcs.event.VCSActionThreadEventListener; +import org.codelutin.vcs.runner.VCSActionManager; +import org.codelutin.vcs.type.VCSEntryLocation; + +import javax.swing.JTable; +import javax.swing.ListSelectionModel; +import javax.swing.event.ListSelectionEvent; +import javax.swing.event.ListSelectionListener; + +/** @author chemit */ +public abstract class AbstractBasicUIHandler<M extends AbstractBasicUIModel, U extends AbstractBasicUI<? extends AbstractBasicUIHandler>> extends AbstractUIHandler<M, U> implements ListSelectionListener, VCSActionThreadEventListener { + + private final boolean useThreadListener; + + protected abstract void afterSelectionChanged(); + + protected AbstractBasicUIHandler(U ui, M model, boolean useThreadListener) { + super(ui, model); + this.useThreadListener = useThreadListener; + } + + public final ListSelectionModel getSelectionModel() { + return getUi().getContentTable().getSelectionModel(); + } + + public boolean isUseThreadListener() { + return useThreadListener; + } + + public void valueChanged(ListSelectionEvent e) { + if (!e.getValueIsAdjusting()) { + // update popup states + afterSelectionChanged(); + } + } + + @Override + public void init() { + super.init(); + getUi().getContentTable().getSelectionModel().addListSelectionListener(this); + JTable table = getUi().getContentTable(); + table.setModel(getModel().getEntriesModel()); + // init table renderer + UIHelper.installVCSTableUI(table); + } + + public VCSEntryLocation getLocation() { + return getModel().getEntriesModel().getLocation(); + } + + public VCSActionManager getActionManager() { + return VCSFactory.getActionManager(); + } + +} \ No newline at end of file Copied: trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/util/handler/AbstractTabOneFileUIHandler.java (from rev 524, trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/util/AbstractTabOneFileUIHandler.java) =================================================================== --- trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/util/handler/AbstractTabOneFileUIHandler.java (rev 0) +++ trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/util/handler/AbstractTabOneFileUIHandler.java 2008-04-16 21:09:36 UTC (rev 531) @@ -0,0 +1,113 @@ +/** + * ##% 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.handler; + +import static org.codelutin.i18n.I18n._; +import org.codelutin.vcs.VCSEntry; +import org.codelutin.vcs.type.VCSAction; +import org.codelutin.vcs.type.VCSEntryLocation; +import org.codelutin.vcs.ui.model.DiffUIModel; +import org.codelutin.vcs.ui.util.AbstractTabOneFileUIModel; +import org.codelutin.vcs.ui.util.AbstractTabOneFileUI; + +import javax.swing.AbstractButton; +import javax.swing.ListSelectionModel; +import javax.swing.event.ListSelectionEvent; +import java.beans.PropertyChangeEvent; +import java.util.EnumMap; + +/** @author chemit */ +public abstract class AbstractTabOneFileUIHandler<M extends AbstractTabOneFileUIModel, U extends AbstractTabOneFileUI<? extends AbstractTabUIHandler>> extends AbstractTabUIHandler<M, U> { + + protected AbstractTabOneFileUIHandler(U ui, M model,boolean useThreadListener) { + super(ui, model,useThreadListener); + } + + @Override + public void propertyChange(PropertyChangeEvent evt) { + if (log.isDebugEnabled()) { + log.debug(evt.getPropertyName() + " old:" + evt.getOldValue() + ", new:" + evt.getNewValue()); + } + if (DiffUIModel.FILE_PROPERTY_CHANGED.equals(evt.getPropertyName())) { + afterSelectionChanged(); + return; + } + super.propertyChange(evt); + } + + @Override + public void valueChanged(ListSelectionEvent e) { + if (!e.getValueIsAdjusting()) { + + ListSelectionModel selectionModel = (ListSelectionModel) e.getSource(); + + Integer selectionIndex = selectionModel.isSelectionEmpty() ? null : selectionModel.getMinSelectionIndex(); + + getModel().setFileModel(selectionIndex); + } + } + + protected void afterSelectionChanged() { + U ui = getUi(); + boolean hasNext = getModel().hasNextFile(); + boolean hasPrevious = getModel().hasPreviousFile(); + ui.getNextFile().setEnabled(hasNext); + ui.getPreviousFile().setEnabled(hasPrevious); + ui.getNextFile().setToolTipText(hasNext ? _("lutinvcs.action.nextfile.tip") : null); + ui.getPreviousFile().setToolTipText(hasPrevious ? _("lutinvcs.action.previousfile.tip") : null); + // always scroll to selected + Integer selectedRow = getModel().getFileIndex(); + if (selectedRow != null) { + ui.getContentTable().scrollRectToVisible(ui.getContentTable().getCellRect(selectedRow, 0, true)); + } + } + + public void afterLocationChanged() { + if (getLocation() == VCSEntryLocation.UNKNOW) { + return; + } + if (getModel().getEntriesModel().getRowCount() > 0) { + // select first row + getSelectionModel().setSelectionInterval(0, 0); + } else { + // disable all actions + afterSelectionChanged(); + } + } + + public void gotoPreviousFile() { + Integer index = getModel().getFileIndex(); + if (index != null && getModel().hasPreviousFile) { + getSelectionModel().setSelectionInterval(index - 1, index - 1); + } + } + + public void gotoNextFile() { + Integer index = getModel().getFileIndex(); + if (index != null && getModel().hasNextFile) { + getSelectionModel().setSelectionInterval(index + 1, index + 1); + } + } + + protected void updateAction(EnumMap<VCSAction, Integer> actions, boolean hasActions, AbstractButton ui, VCSAction action, VCSEntry vcsEntry) { + super.updateAction(actions, hasActions, ui, action); + boolean useAction = hasActions && actions.containsKey(action) && actions.get(action) > 0; + String tip = null; + if (useAction) { + tip = _("lutinvcs.action.single.tip", action.getLibelle(), vcsEntry.getFile().getName()); + } + ui.setToolTipText(tip); + } +} \ No newline at end of file Copied: trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/util/handler/AbstractTabUIHandler.java (from rev 524, trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/util/AbstractTabUIHandler.java) =================================================================== --- trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/util/handler/AbstractTabUIHandler.java (rev 0) +++ trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/util/handler/AbstractTabUIHandler.java 2008-04-16 21:09:36 UTC (rev 531) @@ -0,0 +1,118 @@ +/** + * ##% 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.handler; + +import org.codelutin.vcs.VCSEntry; +import org.codelutin.vcs.VCSException; +import org.codelutin.vcs.type.VCSAction; +import org.codelutin.vcs.ui.ChangelogUI; +import org.codelutin.vcs.ui.ConfirmUI; +import org.codelutin.vcs.ui.DiffUI; +import org.codelutin.vcs.ui.VCSUIFactory; +import org.codelutin.vcs.ui.util.AbstractTabUIModel; +import org.codelutin.vcs.ui.util.AbstractTabUI; +import org.codelutin.vcs.ui.util.AbstractVCSEntriesTableModel; + +import javax.swing.AbstractButton; +import javax.swing.ListSelectionModel; +import javax.swing.event.TableModelListener; +import java.beans.PropertyChangeEvent; +import java.util.EnumMap; +import java.util.List; + +/** @author chemit */ +public abstract class AbstractTabUIHandler<M extends AbstractTabUIModel, U extends AbstractTabUI<? extends AbstractTabUIHandler>> extends AbstractBasicUIHandler<M, U> implements TableModelListener { + + protected AbstractTabUIHandler(U ui, M model,boolean useThreadListener) { + super(ui, model,useThreadListener); + } + + public void propertyChange(PropertyChangeEvent evt) { + if (log.isDebugEnabled()) { + log.debug(evt.getPropertyName() + " old:" + evt.getOldValue() + ", new:" + evt.getNewValue()); + } + String action = evt.getPropertyName(); + if (AbstractTabUIModel.LOCATION_PROPERTY_CHANGED.equals(action)) { + afterLocationChanged(); + } + } + + @Override + public void init() { + super.init(); + getUi().getContentTable().getModel().addTableModelListener(this); + } + + protected abstract void afterLocationChanged(); + + + protected void updateAction(EnumMap<VCSAction, Integer> actions, boolean hasActions, AbstractButton ui, VCSAction action) { + ui.setEnabled(hasActions && actions.containsKey(action) && actions.get(action) > 0); + } + + public void showConfirmUI(VCSAction action, AbstractVCSEntriesTableModel model, List<VCSEntry> entries) { + ConfirmUI ui = VCSUIFactory.newConfirmUI(); + if (log.isDebugEnabled()) { + log.debug("nb entries:" + entries.size()); + } + ui.getHandler().getModel().init(action, model.getLocation(), entries.toArray(new VCSEntry[entries.size()])); + ui.getContentScroll().setEnabled(entries.size() > 1); + ui.setVisible(true); + } + + public void showDiffUI(boolean useSelection, AbstractVCSEntriesTableModel model, List<VCSEntry> entries) { + DiffUI ui = VCSUIFactory.newDiffUI(); + if (!useSelection) { + // take all entries + entries = model.filter(VCSAction.DIFF, model.getEntries()); + } + if (log.isDebugEnabled()) { + log.debug("nb entries:" + entries.size()); + } + ui.getButton(model.getLocation()).setSelected(false); + ui.getHandler().getModel().init(model.getLocation(), entries.toArray(new VCSEntry[entries.size()])); + ui.getContentScroll().setEnabled(entries.size() > 1); + ui.setVisible(true); + } + + public void showChangelogUI(boolean useSelection, AbstractVCSEntriesTableModel model, List<VCSEntry> entries) { + ChangelogUI ui = VCSUIFactory.newChangelogUI(); + if (!useSelection) { + // take all entries + entries = model.filter(VCSAction.CHANGELOG, model.getEntries()); + } + if (log.isDebugEnabled()) { + log.debug("nb entries:" + entries.size()); + } + ui.getHandler().getModel().init(model.getLocation(), entries.toArray(new VCSEntry[entries.size()])); + ui.getContentScroll().setEnabled(entries.size() > 1); + ui.setVisible(true); + } + + public void doRefresh(AbstractVCSEntriesTableModel model, List<VCSEntry> entries, ListSelectionModel selectionModel) { + log.info(selectionModel); + selectionModel.clearSelection(); + if (log.isDebugEnabled()) { + log.debug("nb entries:" + entries.size()); + } + // do refresh of all states + try { + model.refresh(System.nanoTime(), entries); + } catch (VCSException e) { + log.error(e); + } + } + +} \ No newline at end of file Copied: trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/util/handler/AbstractUIHandler.java (from rev 530, trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/util/AbstractUIHandler.java) =================================================================== --- trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/util/handler/AbstractUIHandler.java (rev 0) +++ trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/util/handler/AbstractUIHandler.java 2008-04-16 21:09:36 UTC (rev 531) @@ -0,0 +1,30 @@ +/** + * ##% Copyright (C) 2008 Code Lutin, Tony Chemit + * This program is free software; you + * can redistribute it and/or modify it under the terms of the GNU General + * Public License as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. This program is + * distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A + * PARTICULAR PURPOSE. See the GNU General Public License for more details. You + * should have received a copy of the GNU General Public License along with this + * program; if not, write to the Free Software Foundation, Inc., 59 Temple Place + * - Suite 330, Boston, MA 02111-1307, USA. + * ##% + */ +package org.codelutin.vcs.ui.util.handler; + +import org.codelutin.vcs.ui.util.AbstractUIModel; +import org.codelutin.vcs.ui.util.AbstractUI; + +/** + * TODO Move this classe in jaxx + * + * @author chemit + */ +public abstract class AbstractUIHandler<M extends AbstractUIModel, U extends AbstractUI<? extends AbstractUIHandler>> extends jaxx.DialogUIHandler<M, U> { + + protected AbstractUIHandler(U ui, M model) { + super(ui, model); + } +}