r518 - in trunk/lutinvcs: core/src/main/java/org/codelutin/vcs core/src/main/java/org/codelutin/vcs/util provider/mock/src/main/java/org/codelutin/vcs/provider/mock ui/common/src/main/java/org/codelutin/vcs/ui ui/common/src/main/java/org/codelutin/vcs/ui/action ui/common/src/main/java/org/codelutin/vcs/ui/handler ui/common/src/main/java/org/codelutin/vcs/ui/model ui/common/src/main/java/org/codelutin/vcs/ui/util ui/jaxx/src/main/uimodel/org/codelutin/vcs/ui
Author: tchemit Date: 2008-04-13 19:29:47 +0000 (Sun, 13 Apr 2008) New Revision: 518 Added: 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/util/AbstractTabOneFileUI.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/AbstractTabOneFileUIModel.java Modified: trunk/lutinvcs/core/src/main/java/org/codelutin/vcs/VCSEntry.java trunk/lutinvcs/core/src/main/java/org/codelutin/vcs/util/VCSEntryImpl.java trunk/lutinvcs/provider/mock/src/main/java/org/codelutin/vcs/provider/mock/MockHandler.java trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/ChangelogUI.java trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/DiffUI.java trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/SynchUI.java trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/handler/ChangelogUIHandler.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/model/ChangelogUIModel.java trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/model/DiffUIModel.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/AbstractTabUIHandler.java trunk/lutinvcs/ui/jaxx/src/main/uimodel/org/codelutin/vcs/ui/common.css Log: next - prev file actions + diff and changelog Modified: trunk/lutinvcs/core/src/main/java/org/codelutin/vcs/VCSEntry.java =================================================================== --- trunk/lutinvcs/core/src/main/java/org/codelutin/vcs/VCSEntry.java 2008-04-13 19:14:00 UTC (rev 517) +++ trunk/lutinvcs/core/src/main/java/org/codelutin/vcs/VCSEntry.java 2008-04-13 19:29:47 UTC (rev 518) @@ -59,7 +59,7 @@ * * @throws VCSException if any pb with vcs io * @throws IllegalStateException if entry was never populated - * @throws java.io.IOException if io pb + * @throws IOException if io pb */ void populateDiff() throws IllegalStateException, VCSException, IOException; @@ -137,16 +137,19 @@ String getRev() throws IllegalStateException; /** - * @return the changelog of entry from local aginst remote + * @return the changelog of entry from local against remote (compute it if necessary) * @throws IllegalStateException if entry was never populated + * @throws VCSException if vcs io pb while computing changelog */ - BufferedReader getChangeLog() throws IllegalStateException; + BufferedReader getChangeLog() throws IllegalStateException, VCSException; /** - * @return the diff of entry from local aginst remote + * @return the diff of entry from local against remote (compute it if necessary) * @throws IllegalStateException if entry was never populated + * @throws VCSException if vcs io pb while computing diff + * @throws IOException if io pb while computing diff */ - BufferedReader getDiff() throws IllegalStateException; + BufferedReader getDiff() throws IllegalStateException, IOException, VCSException; /** * @return the local entry content Modified: trunk/lutinvcs/core/src/main/java/org/codelutin/vcs/util/VCSEntryImpl.java =================================================================== --- trunk/lutinvcs/core/src/main/java/org/codelutin/vcs/util/VCSEntryImpl.java 2008-04-13 19:14:00 UTC (rev 517) +++ trunk/lutinvcs/core/src/main/java/org/codelutin/vcs/util/VCSEntryImpl.java 2008-04-13 19:29:47 UTC (rev 518) @@ -127,13 +127,19 @@ return rev; } - public BufferedReader getChangeLog() throws IllegalStateException { + public BufferedReader getChangeLog() throws IllegalStateException, VCSException { checkPopulated(); + if (changelog == null) { + populateChangeLog(); + } return new BufferedReader(new StringReader(changelog)); } - public BufferedReader getDiff() throws IllegalStateException { + public BufferedReader getDiff() throws IllegalStateException, IOException, VCSException { checkPopulated(); + if (diff== null) { + populateDiff(); + } return new BufferedReader(new StringReader(diff)); } Modified: trunk/lutinvcs/provider/mock/src/main/java/org/codelutin/vcs/provider/mock/MockHandler.java =================================================================== --- trunk/lutinvcs/provider/mock/src/main/java/org/codelutin/vcs/provider/mock/MockHandler.java 2008-04-13 19:14:00 UTC (rev 517) +++ trunk/lutinvcs/provider/mock/src/main/java/org/codelutin/vcs/provider/mock/MockHandler.java 2008-04-13 19:29:47 UTC (rev 518) @@ -110,15 +110,15 @@ } public String getChangeLog(File file) throws VCSException { - return null; + return this+" changelog for : \n"+file+"... mock"; } public String getDiff(File file) throws VCSException, IOException { - return null; + return this+" diff for : \n"+file+"... mock"; } public String getDiff(File file, Object againstRevision) throws VCSException, IOException { - return null; + return this+" diff for : \n"+file+"... mock"; } public boolean hasProtocoleChanged() throws VCSException { Modified: trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/ChangelogUI.java =================================================================== --- trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/ChangelogUI.java 2008-04-13 19:14:00 UTC (rev 517) +++ trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/ChangelogUI.java 2008-04-13 19:29:47 UTC (rev 518) @@ -14,23 +14,9 @@ */ package org.codelutin.vcs.ui; -import javax.swing.AbstractButton; - /** @author chemit */ -public abstract class ChangelogUI extends org.codelutin.vcs.ui.util.AbstractTabUI<org.codelutin.vcs.ui.handler.ChangelogUIHandler> { +public abstract class ChangelogUI extends org.codelutin.vcs.ui.util.AbstractTabOneFileUI<org.codelutin.vcs.ui.handler.ChangelogUIHandler> { - @Override - public void setVisible(boolean b) { - if (b) { - AbstractButton button = getButton(getHandler().getLocation()); - if (button == null) { - button = getAllTab(); - } - button.doClick(); - if (getContentTable().getRowCount() > 0) - getHandler().getSelectionModel().setSelectionInterval(0, 0); - } - super.setVisible(b); - } + public abstract javax.swing.JTextArea getChangelogContent(); } \ No newline at end of file Modified: trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/DiffUI.java =================================================================== --- trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/DiffUI.java 2008-04-13 19:14:00 UTC (rev 517) +++ trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/DiffUI.java 2008-04-13 19:29:47 UTC (rev 518) @@ -16,9 +16,11 @@ import javax.swing.AbstractAction; import javax.swing.AbstractButton; +import javax.swing.JScrollPane; +import javax.swing.JTextArea; /** @author chemit */ -public abstract class DiffUI extends org.codelutin.vcs.ui.util.AbstractTabUI<org.codelutin.vcs.ui.handler.DiffUIHandler> { +public abstract class DiffUI extends org.codelutin.vcs.ui.util.AbstractTabOneFileUI<org.codelutin.vcs.ui.handler.DiffUIHandler> { public abstract AbstractButton getNextDiff(); @@ -26,20 +28,14 @@ public abstract AbstractButton getCommit(); - @Override - public void setVisible(boolean b) { - if (b) { - AbstractButton button = getButton(getHandler().getLocation()); - if (button == null) { - button = getAllTab(); - } - button.doClick(); - if (getContentTable().getRowCount() > 0) - getHandler().getSelectionModel().setSelectionInterval(0, 0); - } - super.setVisible(b); - } + public abstract JScrollPane getRemoteEditorScroll(); + public abstract JTextArea getRemoteEditorContent(); + + public abstract JScrollPane getLocalEditorScroll(); + + public abstract JTextArea getLocalEditorContent(); + protected AbstractAction createDiffAction(boolean goUp) { return org.codelutin.vcs.ui.action.DiffAction.createAction(goUp, this); } Modified: trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/SynchUI.java =================================================================== --- trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/SynchUI.java 2008-04-13 19:14:00 UTC (rev 517) +++ trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/SynchUI.java 2008-04-13 19:29:47 UTC (rev 518) @@ -48,16 +48,4 @@ public abstract JPopupMenu getPopup(); - @Override - public void setVisible(boolean b) { - if (b) { - AbstractButton button = getButton(getHandler().getLocation()); - if (button == null) { - button = getAllTab(); - } - button.doClick(); - } - super.setVisible(b); - } - } \ No newline at end of file Copied: trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/action/ChangeFileAction.java (from rev 511, 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/ChangeFileAction.java (rev 0) +++ trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/action/ChangeFileAction.java 2008-04-13 19:29:47 UTC (rev 518) @@ -0,0 +1,58 @@ +/** + * # #% 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.vcs.ui.util.AbstractTabOneFileUI; +import org.codelutin.vcs.ui.util.AbstractTabOneFileUIHandler; +import static org.codelutin.vcs.ui.util.UIHelper.createActionIcon; + +import javax.swing.AbstractAction; +import java.awt.event.ActionEvent; + +/** @author chemit */ +public class ChangeFileAction extends org.codelutin.vcs.ui.util.AbstractUIAction<AbstractTabOneFileUIHandler<?, ?>> { + + protected boolean goPrevious; + + private static final long serialVersionUID = 1L; + + public static AbstractAction createAction(boolean location, AbstractTabOneFileUI<?> ui) { + ChangeFileAction action = new ChangeFileAction(location); + action.setUi(ui); + return action; + } + + public void actionPerformed(ActionEvent e) { + checkInit(); + if (goPrevious) { + getHandler().gotoPreviousFile(); + } else { + getHandler().gotoNextFile(); + } + } + + public boolean isGoPrevious() { + return goPrevious; + } + + protected ChangeFileAction(boolean location) { + super(null, createActionIcon("file-" + (location ? "prev" : "next"))); + this.goPrevious = location; + //putValue(SHORT_DESCRIPTION, location.getTip()); + //putValue(DISPLAYED_MNEMONIC_INDEX_KEY, 0); + //putValue(MNEMONIC_KEY, (int) ((String) getValue(NAME)).charAt(0)); + } + +} \ No newline at end of file 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-13 19:14:00 UTC (rev 517) +++ trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/handler/ChangelogUIHandler.java 2008-04-13 19:29:47 UTC (rev 518) @@ -14,82 +14,43 @@ */ package org.codelutin.vcs.ui.handler; -import static org.codelutin.i18n.I18n._; import org.codelutin.vcs.VCSEntry; import org.codelutin.vcs.type.VCSAction; import org.codelutin.vcs.ui.ChangelogUI; import org.codelutin.vcs.ui.model.ChangelogUIModel; -import org.codelutin.vcs.ui.model.DiffUIModel; -import org.codelutin.vcs.ui.util.AbstractTabUIHandler; +import org.codelutin.vcs.ui.util.AbstractTabOneFileUIHandler; -import javax.swing.AbstractButton; -import javax.swing.ListSelectionModel; -import javax.swing.event.ListSelectionEvent; -import java.beans.PropertyChangeEvent; import java.util.Collections; import java.util.EnumMap; /** @author chemit */ -public class ChangelogUIHandler extends AbstractTabUIHandler<ChangelogUIModel, ChangelogUI> { +public class ChangelogUIHandler extends AbstractTabOneFileUIHandler<ChangelogUIModel, ChangelogUI> { public ChangelogUIHandler(ChangelogUI ui) { super(ui, new ChangelogUIModel()); ui.setHandler(this); } - @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()) { - // update model selected file ? TODO Is this really necessary, - ListSelectionModel selectionModel = (ListSelectionModel) e.getSource(); - VCSEntry vcsEntry = null; - if (!selectionModel.isSelectionEmpty()) { - vcsEntry = getModel().getEntriesModel().getDisplayedEntry(selectionModel.getMinSelectionIndex()); - } - getModel().setFileModel(vcsEntry); - } - } - - public void afterLocationChanged() { - if (getModel().getEntriesModel().getRowCount() > 0) { - // select first row - getSelectionModel().addSelectionInterval(0, 0); - } - } - protected void afterSelectionChanged() { - + super.afterSelectionChanged(); VCSEntry vcsEntry = getModel().getFileModel(); EnumMap<VCSAction, Integer> actions = vcsEntry == null ? null : getModel().getEntriesModel().countActions(Collections.singletonList(vcsEntry)); boolean hasActions = actions != null && !actions.isEmpty(); ChangelogUI ui = getUi(); updateAction(actions, hasActions, ui.getUpdate(), VCSAction.UPDATE, vcsEntry); - updateAction(actions, hasActions, ui.getRevert(), VCSAction.REVERT, vcsEntry); + updateAction(actions, hasActions, ui.getRevert(), VCSAction.REVERT, vcsEntry); updateAction(actions, hasActions, ui.getRefresh(), VCSAction.REFRESH, vcsEntry); - //TODO init changelog handler - log.info("//TODO: show changleog for "+vcsEntry); - - } - - 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()); + if (vcsEntry == null) { + ui.getChangelogContent().setText(""); + return; } - ui.setToolTipText(tip); + try { + ui.getChangelogContent().read(vcsEntry.getChangeLog(), "test"); + } catch (Exception e) { + String message = "could not obtain changelog for file " + vcsEntry.getFile() + " for reason:\n" + e.getMessage(); + log.warn(message); + ui.getChangelogContent().setText(message); + } } + } \ No newline at end of file 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-13 19:14:00 UTC (rev 517) +++ trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/handler/DiffUIHandler.java 2008-04-13 19:29:47 UTC (rev 518) @@ -15,21 +15,19 @@ package org.codelutin.vcs.ui.handler; import static org.codelutin.i18n.I18n._; +import org.codelutin.util.FileUtil; import org.codelutin.vcs.VCSEntry; import org.codelutin.vcs.type.VCSAction; import org.codelutin.vcs.ui.DiffUI; import org.codelutin.vcs.ui.model.DiffUIModel; -import org.codelutin.vcs.ui.util.AbstractTabUIHandler; +import org.codelutin.vcs.ui.util.AbstractTabOneFileUIHandler; -import javax.swing.AbstractButton; -import javax.swing.ListSelectionModel; -import javax.swing.event.ListSelectionEvent; import java.beans.PropertyChangeEvent; import java.util.Collections; import java.util.EnumMap; /** @author chemit */ -public class DiffUIHandler extends AbstractTabUIHandler<DiffUIModel, DiffUI> { +public class DiffUIHandler extends AbstractTabOneFileUIHandler<DiffUIModel, DiffUI> { public DiffUIHandler(DiffUI ui) { super(ui, new DiffUIModel()); @@ -41,10 +39,6 @@ if (log.isDebugEnabled()) { log.debug(evt.getPropertyName() + " old:" + evt.getOldValue() + ", new:" + evt.getNewValue()); } - if (DiffUIModel.FILE_PROPERTY_CHANGED.equals(evt.getPropertyName())) { - afterSelectionChanged(); - return; - } if (DiffUIModel.DIFF_PROPERTY_CHANGED.equals(evt.getPropertyName())) { afterDiffAction(); return; @@ -53,27 +47,8 @@ } @Override - public void valueChanged(ListSelectionEvent e) { - if (!e.getValueIsAdjusting()) { - // update model selected file ? TODO Is this really necessary, - ListSelectionModel selectionModel = (ListSelectionModel) e.getSource(); - VCSEntry vcsEntry = null; - if (!selectionModel.isSelectionEmpty()) { - vcsEntry = getModel().getEntriesModel().getDisplayedEntry(selectionModel.getMinSelectionIndex()); - } - getModel().setFileModel(vcsEntry); - } - } - - public void afterLocationChanged() { - if (getModel().getEntriesModel().getRowCount() > 0) { - // select first row - getSelectionModel().addSelectionInterval(0, 0); - } - } - protected void afterSelectionChanged() { - + super.afterSelectionChanged(); VCSEntry vcsEntry = getModel().getFileModel(); EnumMap<VCSAction, Integer> actions = vcsEntry == null ? null : getModel().getEntriesModel().countActions(Collections.singletonList(vcsEntry)); boolean hasActions = actions != null && !actions.isEmpty(); @@ -82,7 +57,21 @@ updateAction(actions, hasActions, ui.getRevert(), VCSAction.REVERT, vcsEntry); updateAction(actions, hasActions, ui.getCommit(), VCSAction.COMMIT, vcsEntry); updateAction(actions, hasActions, ui.getRefresh(), VCSAction.REFRESH, vcsEntry); - //TODO init diff handler + if (vcsEntry == null) { + ui.getLocalEditorContent().setText(""); + ui.getRemoteEditorContent().setText(""); + return; + } + //TODO for the moment, just display local file content at right + //TODO abd diff at right + try { + ui.getRemoteEditorContent().read(vcsEntry.getDiff(), "diff-content " + vcsEntry.getFile()); + ui.getLocalEditorContent().read(FileUtil.getReader(vcsEntry.getFile()), "local-content " + vcsEntry.getFile()); + } catch (Exception e) { + String message = "could not obtain changelog for file " + vcsEntry.getFile() + " for reason:\n" + e.getMessage(); + log.warn(message); + ui.getRemoteEditorContent().setText(message); + } } protected void afterDiffAction() { @@ -107,14 +96,4 @@ getModel().setDiff(getModel().getDiff() - 1); log.info("//TODO :" + this); } - - 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); - } } Modified: 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/ChangelogUIModel.java 2008-04-13 19:14:00 UTC (rev 517) +++ trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/model/ChangelogUIModel.java 2008-04-13 19:29:47 UTC (rev 518) @@ -16,30 +16,15 @@ import org.codelutin.vcs.VCSEntry; import org.codelutin.vcs.type.VCSEntryLocation; -import org.codelutin.vcs.ui.util.AbstractTabUIModel; +import org.codelutin.vcs.ui.util.AbstractTabOneFileUIModel; /** * Model of a repository * * @author chemit */ -public class ChangelogUIModel extends AbstractTabUIModel { +public class ChangelogUIModel extends AbstractTabOneFileUIModel { - public static final String FILE_PROPERTY_CHANGED = "file"; - - /** current file displayed */ - protected VCSEntry fileModel; - - public VCSEntry getFileModel() { - return fileModel; - } - - public void setFileModel(VCSEntry fileModel) { - VCSEntry oldFileModel = this.fileModel; - this.fileModel = fileModel; - firePropertyChange(FILE_PROPERTY_CHANGED, oldFileModel, fileModel); - } - public void init(VCSEntryLocation location, VCSEntry[] states) { getEntriesModel().clear(); getEntriesModel().populate(VCSEntryLocation.ALL, states); Modified: trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/model/DiffUIModel.java =================================================================== --- trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/model/DiffUIModel.java 2008-04-13 19:14:00 UTC (rev 517) +++ trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/model/DiffUIModel.java 2008-04-13 19:29:47 UTC (rev 518) @@ -16,29 +16,21 @@ import org.codelutin.vcs.VCSEntry; import org.codelutin.vcs.type.VCSEntryLocation; -import org.codelutin.vcs.ui.util.AbstractTabUIModel; +import org.codelutin.vcs.ui.util.AbstractTabOneFileUIModel; /** * Model of a repository * * @author chemit */ -public class DiffUIModel extends AbstractTabUIModel { +public class DiffUIModel extends AbstractTabOneFileUIModel { - public static final String FILE_PROPERTY_CHANGED = "file"; public static final String DIFF_PROPERTY_CHANGED = "diff"; - /** current file displayed */ - protected VCSEntry fileModel; - protected int nbDiffs; protected Integer diff; - public VCSEntry getFileModel() { - return fileModel; - } - public int getNbDiffs() { return nbDiffs; } @@ -69,10 +61,9 @@ return diff != null && diff > 0; } - public void setFileModel(VCSEntry fileModel) { - VCSEntry oldFileModel = this.fileModel; - this.fileModel = fileModel; - firePropertyChange(FILE_PROPERTY_CHANGED, oldFileModel, fileModel); + @Override + public void setFileModel(Integer fileModel) { + super.setFileModel(fileModel); // TODO acquire diff and prepare DiffModel... setNbDiffs(0); } Copied: trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/util/AbstractTabOneFileUI.java (from rev 514, 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/AbstractTabOneFileUI.java (rev 0) +++ trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/util/AbstractTabOneFileUI.java 2008-04-13 19:29:47 UTC (rev 518) @@ -0,0 +1,40 @@ +/** + * ##% 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.ui.action.ChangeFileAction; + +import javax.swing.AbstractAction; +import javax.swing.AbstractButton; + +/** @author chemit */ +public abstract class AbstractTabOneFileUI<H extends AbstractTabOneFileUIHandler<?, ?>> extends AbstractTabUI<H> { + + public abstract AbstractButton getNextFile(); + + public abstract AbstractButton getPreviousFile(); + + @Override + public void setVisible(boolean b) { + super.setVisible(b); + getContentTable().setAutoscrolls(true); + //TODO selected first file ? + } + + protected AbstractAction createFileAction(boolean goPrevious) { + return ChangeFileAction.createAction(goPrevious, this); + } + +} \ No newline at end of file Copied: trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/util/AbstractTabOneFileUIHandler.java (from rev 514, 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/AbstractTabOneFileUIHandler.java (rev 0) +++ trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/util/AbstractTabOneFileUIHandler.java 2008-04-13 19:29:47 UTC (rev 518) @@ -0,0 +1,110 @@ +/** + * ##% 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.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) { + super(ui, model); + } + + @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); + } + //super.valueChanged(e); + } + + protected void afterSelectionChanged() { + + U ui = getUi(); + boolean hasNext = getModel().hasNextFile(); + boolean hasPrevious = getModel().hasPreviousFile(); + log.info("//TODO :" + this + " next:" + hasNext + ", prev:" + hasPrevious); + 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 (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/AbstractTabOneFileUIModel.java (from rev 511, trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/util/AbstractTabUIModel.java) =================================================================== --- trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/util/AbstractTabOneFileUIModel.java (rev 0) +++ trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/util/AbstractTabOneFileUIModel.java 2008-04-13 19:29:47 UTC (rev 518) @@ -0,0 +1,76 @@ +/** + * ##% 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; + +/** + * Abstract for a dialog with location information (says one tab by location type (except UNKNOW type of course...) + * + * @author chemit + */ +public class AbstractTabOneFileUIModel extends AbstractTabUIModel { + + public static final String FILE_PROPERTY_CHANGED = "file"; + + /** current file displayed */ + protected VCSEntry fileModel; + + protected boolean hasNextFile; + protected boolean hasPreviousFile; + + protected Integer fileIndex; + + public VCSEntry getFileModel() { + if (fileIndex == null) { + return null; + } + return getEntriesModel().getDisplayedEntry(fileIndex); + } + + public void setFileModel(Integer fileIndex) { + VCSEntry oldFileModel = this.fileModel; + this.fileIndex = fileIndex; + + int size = getEntriesModel().getRowCount(); + if (fileIndex == null || size < 2) { + hasNextFile = hasPreviousFile = false; + } else { + hasNextFile = hasPreviousFile = true; + if (fileIndex == 0) { + // first row : no previous file + hasPreviousFile = false; + } else { + if (fileIndex == size - 1) { + // last row : no next file + hasNextFile = false; + } + } + } + firePropertyChange(FILE_PROPERTY_CHANGED, oldFileModel, fileIndex); + } + + public boolean hasPreviousFile() { + return hasPreviousFile; + } + + public boolean hasNextFile() { + return hasNextFile; + } + + public Integer getFileIndex() { + return fileIndex; + } +} \ 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-13 19:14:00 UTC (rev 517) +++ trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/util/AbstractTabUI.java 2008-04-13 19:29:47 UTC (rev 518) @@ -36,9 +36,23 @@ public abstract AbstractButton getUpdate(); - public abstract AbstractButton getRevert(); + @Override + public void setVisible(boolean b) { + if (b) { + + VCSEntryLocation vcsEntryLocation = getHandler().getLocation(); + AbstractButton button = getButton(vcsEntryLocation); + if (button == null) { + button = getAllTab(); + } + getHandler().getModel().setLocation(VCSEntryLocation.UNKNOW); + button.doClick(); + } + super.setVisible(b); + } + public AbstractButton getButton(VCSEntryLocation modelName) { switch (modelName) { case ALL: @@ -50,7 +64,7 @@ case UNKNOW: return null; } - throw new IllegalStateException("no popup found for " + modelName); + throw new IllegalStateException("no button found for " + modelName); } protected AbstractAction createLocationAction(VCSEntryLocation location) { Modified: 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-13 19:14:00 UTC (rev 517) +++ trunk/lutinvcs/ui/common/src/main/java/org/codelutin/vcs/ui/util/AbstractTabUIHandler.java 2008-04-13 19:29:47 UTC (rev 518) @@ -16,6 +16,7 @@ import org.codelutin.vcs.VCSEntry; import org.codelutin.vcs.type.VCSAction; +import org.codelutin.vcs.type.VCSEntryLocation; import org.codelutin.vcs.ui.ConfirmUI; import org.codelutin.vcs.ui.DiffUI; import org.codelutin.vcs.ui.VCSUIFactory; @@ -66,6 +67,7 @@ entries = model.filter(VCSAction.DIFF, model.getEntries()); } log.info("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); @@ -78,7 +80,7 @@ entries = model.filter(VCSAction.CHANGELOG, model.getEntries()); } log.info("nb entries:" + entries.size()); - ui.getHandler().getModel().init(model.getLocation(), entries.toArray(new VCSEntry[entries.size()])); + ui.getHandler().getModel().init(VCSEntryLocation.REMOTE, entries.toArray(new VCSEntry[entries.size()])); ui.getContentScroll().setEnabled(entries.size() > 1); ui.setVisible(true); } @@ -90,6 +92,5 @@ // do refresh of all states model.refresh(System.nanoTime(), entries); } - - + } \ No newline at end of file Modified: trunk/lutinvcs/ui/jaxx/src/main/uimodel/org/codelutin/vcs/ui/common.css =================================================================== --- trunk/lutinvcs/ui/jaxx/src/main/uimodel/org/codelutin/vcs/ui/common.css 2008-04-13 19:14:00 UTC (rev 517) +++ trunk/lutinvcs/ui/jaxx/src/main/uimodel/org/codelutin/vcs/ui/common.css 2008-04-13 19:29:47 UTC (rev 518) @@ -46,7 +46,9 @@ rowSelectionAllowed: true; rowMargin: 0; } - +#localEditorScroll,#remoteEditorScroll{ + font-size:10; +} .updateTable, .confirmTable { selectionMode: 2; }
participants (1)
-
tchemit@users.labs.libre-entreprise.org