[Buix-commits] r440 - in trunk/lutinvcs: lutinvcs-all/src/test/java/org/codelutin/vcs/ui lutinvcs-core/src/main/java/org/codelutin/vcs lutinvcs-core/src/main/java/org/codelutin/vcs/event lutinvcs-core/src/main/java/org/codelutin/vcs/util lutinvcs-ui-common/src/main/java/org/codelutin/vcs/ui lutinvcs-ui-common/src/main/java/org/codelutin/vcs/ui/handler lutinvcs-ui-jaxx/src/main/uimodel/org/codelutin/vcs/ui
Author: tchemit Date: 2008-04-06 23:12:13 +0000 (Sun, 06 Apr 2008) New Revision: 440 Added: trunk/lutinvcs/lutinvcs-core/src/main/java/org/codelutin/vcs/event/VCSEntryStateChangedEvent.java trunk/lutinvcs/lutinvcs-core/src/main/java/org/codelutin/vcs/event/VCSEntryStateChangedEventListener.java Removed: trunk/lutinvcs/lutinvcs-ui-jaxx/src/main/uimodel/org/codelutin/vcs/ui/JDiffPanelUI.jaxx Modified: trunk/lutinvcs/lutinvcs-all/src/test/java/org/codelutin/vcs/ui/UITest.java trunk/lutinvcs/lutinvcs-core/src/main/java/org/codelutin/vcs/VCSEntry.java trunk/lutinvcs/lutinvcs-core/src/main/java/org/codelutin/vcs/util/VCSEntryImpl.java trunk/lutinvcs/lutinvcs-ui-common/src/main/java/org/codelutin/vcs/ui/AbstractTabUI.java trunk/lutinvcs/lutinvcs-ui-common/src/main/java/org/codelutin/vcs/ui/handler/DiffUIHandler.java trunk/lutinvcs/lutinvcs-ui-jaxx/src/main/uimodel/org/codelutin/vcs/ui/JDiffUI.jaxx trunk/lutinvcs/lutinvcs-ui-jaxx/src/main/uimodel/org/codelutin/vcs/ui/common.css Log: begin of diff ui + add listener to listen about change of state on VCSEntry Modified: trunk/lutinvcs/lutinvcs-all/src/test/java/org/codelutin/vcs/ui/UITest.java =================================================================== --- trunk/lutinvcs/lutinvcs-all/src/test/java/org/codelutin/vcs/ui/UITest.java 2008-04-06 21:47:39 UTC (rev 439) +++ trunk/lutinvcs/lutinvcs-all/src/test/java/org/codelutin/vcs/ui/UITest.java 2008-04-06 23:12:13 UTC (rev 440) @@ -25,6 +25,8 @@ import org.codelutin.vcs.util.VCSConnexionConfigImpl; import org.codelutin.vcs.util.VCSEntryImpl; +import java.awt.event.WindowAdapter; +import java.awt.event.WindowEvent; import java.io.File; import java.util.ArrayList; import java.util.List; @@ -39,20 +41,22 @@ I18n.init(); - VCSConnexion connexion = initVCS(new File(new File("").getAbsolutePath())); + final VCSConnexion connexion = initVCS(new File(new File("").getAbsolutePath())); - try { - connexion.open(); + connexion.open(); - AbstractSynchUI ui = VCSUIFactory.newSynchUI(); + AbstractSynchUI ui = VCSUIFactory.newSynchUI(); - fillSynchModel(connexion, ui.getModel(), 20, "trunk", "local/", "remote/"); + fillSynchModel(connexion, ui.getModel(), 20, "trunk", "local/", "remote/"); - ui.setVisible(true); + ui.setVisible(true); + ui.addWindowListener(new WindowAdapter() { + @Override + public void windowClosed(WindowEvent e) { + connexion.close(); + } + }); - } finally { - connexion.close(); - } } public static VCSConnexion initVCS(File root) { Modified: trunk/lutinvcs/lutinvcs-core/src/main/java/org/codelutin/vcs/VCSEntry.java =================================================================== --- trunk/lutinvcs/lutinvcs-core/src/main/java/org/codelutin/vcs/VCSEntry.java 2008-04-06 21:47:39 UTC (rev 439) +++ trunk/lutinvcs/lutinvcs-core/src/main/java/org/codelutin/vcs/VCSEntry.java 2008-04-06 23:12:13 UTC (rev 440) @@ -14,6 +14,7 @@ */ package org.codelutin.vcs; +import org.codelutin.vcs.event.VCSEntryStateChangedEventListener; import org.codelutin.vcs.type.VCSEntryLocation; import org.codelutin.vcs.type.VCSState; @@ -125,4 +126,11 @@ BufferedReader getRemoteContent() throws IllegalStateException; void setState(VCSState state); + + /** @param l the listener to add */ + void addVCSEntryStateChangedEventListener(VCSEntryStateChangedEventListener l); + + /** @param l the listener to remove */ + void removeVCSEntryStateChangedEventListener(VCSEntryStateChangedEventListener l); + } \ No newline at end of file Copied: trunk/lutinvcs/lutinvcs-core/src/main/java/org/codelutin/vcs/event/VCSEntryStateChangedEvent.java (from rev 436, trunk/lutinvcs/lutinvcs-core/src/main/java/org/codelutin/vcs/event/VCSConnexionEvent.java) =================================================================== --- trunk/lutinvcs/lutinvcs-core/src/main/java/org/codelutin/vcs/event/VCSEntryStateChangedEvent.java (rev 0) +++ trunk/lutinvcs/lutinvcs-core/src/main/java/org/codelutin/vcs/event/VCSEntryStateChangedEvent.java 2008-04-06 23:12:13 UTC (rev 440) @@ -0,0 +1,53 @@ +/** + * # #% 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.event; + +import org.codelutin.vcs.VCSEntry; +import org.codelutin.vcs.type.VCSState; + +import java.util.EventObject; + +/** + * Events to be used when the state of a {@link org.codelutin.vcs.VCSEntry} has changed. + * + * @author chemit + */ +public class VCSEntryStateChangedEvent extends EventObject { + + private static final long serialVersionUID = 1L; + + protected VCSState state; + + /** + * Constructs a prototypical Event. + * + * @param source The object on which the Event initially occurred. + * @param type type of event + * @throws IllegalArgumentException if source is null. + */ + public VCSEntryStateChangedEvent(VCSEntry source, VCSState type) { + super(source); + this.state = type; + } + + @Override + public VCSEntry getSource() { + return (VCSEntry) super.getSource(); + } + + public VCSState getState() { + return state; + } +} \ No newline at end of file Copied: trunk/lutinvcs/lutinvcs-core/src/main/java/org/codelutin/vcs/event/VCSEntryStateChangedEventListener.java (from rev 436, trunk/lutinvcs/lutinvcs-core/src/main/java/org/codelutin/vcs/event/VCSConnexionEventListener.java) =================================================================== --- trunk/lutinvcs/lutinvcs-core/src/main/java/org/codelutin/vcs/event/VCSEntryStateChangedEventListener.java (rev 0) +++ trunk/lutinvcs/lutinvcs-core/src/main/java/org/codelutin/vcs/event/VCSEntryStateChangedEventListener.java 2008-04-06 23:12:13 UTC (rev 440) @@ -0,0 +1,62 @@ +/** + * # #% Copyright (C) 2008 Code Lutin, Tony Chemit + * This program is free software; you + * can redistribute it and/or modify it under the terms of the GNU General + * Public License as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. This program is + * distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; + * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A + * PARTICULAR PURPOSE. See the GNU General Public License for more details. You + * should have received a copy of the GNU General Public License along with this + * program; if not, write to the Free Software Foundation, Inc., 59 Temple Place + * - Suite 330, Boston, MA 02111-1307, USA. + * # #% + */ +package org.codelutin.vcs.event; + +import org.codelutin.vcs.type.VCSState; + +/** + * A listener on state of a {@link org.codelutin.vcs.VCSEntry}. + * + * @author chemit + */ +public interface VCSEntryStateChangedEventListener extends java.util.EventListener { + + /** + * call when entry was added on local repository (correspond to {@link VCSState#UNVERSIONNED} + * + * @param event current event + */ + public void onAdded(VCSEntryStateChangedEvent event); + + /** + * call when entry was modified on local repository (correspond to {@link VCSState#MODIFIED} + * + * @param event current event + */ + public void onModified(VCSEntryStateChangedEvent event); + + /** + * call when entry is obsolete on local repository (correspond to + * {@link VCSState#OUT_OF_DATE_AND_MODIFIED} or {@link VCSState#OUT_OF_DATE} + * + * @param event current event + */ + public void onObseleted(VCSEntryStateChangedEvent event); + + /** + * call when entry was deleted on local repository (corresponds to {@link VCSState#MISSING} + * + * @param event current event + */ + public void onDeleted(VCSEntryStateChangedEvent event); + + /** + * call when entry was updated, commit, revert,...(corresponds to {@link VCSState#UP_TO_DATE} + * + * @param event current event + */ + public void onUpdated(VCSEntryStateChangedEvent event); + +} \ No newline at end of file Modified: trunk/lutinvcs/lutinvcs-core/src/main/java/org/codelutin/vcs/util/VCSEntryImpl.java =================================================================== --- trunk/lutinvcs/lutinvcs-core/src/main/java/org/codelutin/vcs/util/VCSEntryImpl.java 2008-04-06 21:47:39 UTC (rev 439) +++ trunk/lutinvcs/lutinvcs-core/src/main/java/org/codelutin/vcs/util/VCSEntryImpl.java 2008-04-06 23:12:13 UTC (rev 440) @@ -14,11 +14,14 @@ */ package org.codelutin.vcs.util; +import org.codelutin.util.ListenerSet; import org.codelutin.vcs.VCSConnexion; import org.codelutin.vcs.VCSEntry; +import org.codelutin.vcs.VCSException; +import org.codelutin.vcs.event.VCSEntryStateChangedEvent; +import org.codelutin.vcs.event.VCSEntryStateChangedEventListener; import org.codelutin.vcs.type.VCSEntryLocation; import org.codelutin.vcs.type.VCSState; -import org.codelutin.vcs.VCSException; import java.io.BufferedReader; import java.io.File; @@ -39,6 +42,9 @@ protected long timestamp; protected String rev; + + protected transient ListenerSet<VCSEntryStateChangedEventListener> listeners = new ListenerSet<VCSEntryStateChangedEventListener>(); + private static final long serialVersionUID = -6628119456256629555L; public VCSEntryImpl(VCSConnexion connexion, String relativeLocalPath) { @@ -50,9 +56,68 @@ public void populate(long timestamp) throws VCSException { this.timestamp = timestamp; + VCSState oldState = this.state; this.state = connexion.getState(new File(connexion.getWorkingCopy(), relativeLocalPath), null); + if (oldState != state) { + fireStateChanged(oldState); + } } + protected void fireStateChanged(VCSState oldState) { + VCSEntryStateChangedEvent event = new VCSEntryStateChangedEvent(this, state); + switch (state) { + case MISSING: + for (VCSEntryStateChangedEventListener listener : listeners) { + listener.onDeleted(event); + } + break; + case MODIFIED: + for (VCSEntryStateChangedEventListener listener : listeners) { + listener.onModified(event); + } + break; + case OUT_OF_DATE: + for (VCSEntryStateChangedEventListener listener : listeners) { + listener.onObseleted(event); + } + break; + case OUT_OF_DATE_AND_MODIFIED: + if (oldState == VCSState.OUT_OF_DATE) { + for (VCSEntryStateChangedEventListener listener : listeners) { + listener.onModified(event); + } + } else { + for (VCSEntryStateChangedEventListener listener : listeners) { + listener.onObseleted(event); + } + } + break; + case REMOVED: + for (VCSEntryStateChangedEventListener listener : listeners) { + listener.onDeleted(event); + } + break; + case UNKNOWN: + // ? + break; + case UNVERSIONNED: + for (VCSEntryStateChangedEventListener listener : listeners) { + listener.onAdded(event); + } + break; + case UNVERSIONNED_OR_MISSING: + for (VCSEntryStateChangedEventListener listener : listeners) { + listener.onAdded(event); + } + break; + case UP_TO_DATE: + for (VCSEntryStateChangedEventListener listener : listeners) { + listener.onUpdated(event); + } + break; + } + } + public void refresh(long timestamp) throws IllegalStateException, VCSException { checkPopulated(); populate(timestamp); @@ -115,9 +180,19 @@ } public void setState(VCSState state) { + //TODO Remove this method, we should not be able to change state + //TODO is used by VCSUITest (should prefer to implements popuplatemethod in MockConnexion) this.state = state; + } + public void addVCSEntryStateChangedEventListener(VCSEntryStateChangedEventListener l) { + listeners.add(l); + } + + public void removeVCSEntryStateChangedEventListener(VCSEntryStateChangedEventListener l) { + } + protected void checkPopulated() throws IllegalStateException { if (timestamp == -1) { throw new IllegalStateException(this + " was not populated"); Modified: trunk/lutinvcs/lutinvcs-ui-common/src/main/java/org/codelutin/vcs/ui/AbstractTabUI.java =================================================================== --- trunk/lutinvcs/lutinvcs-ui-common/src/main/java/org/codelutin/vcs/ui/AbstractTabUI.java 2008-04-06 21:47:39 UTC (rev 439) +++ trunk/lutinvcs/lutinvcs-ui-common/src/main/java/org/codelutin/vcs/ui/AbstractTabUI.java 2008-04-06 23:12:13 UTC (rev 440) @@ -60,34 +60,16 @@ super(handler, model); } + @Override public AbstractTabUIModel getModel() { return (AbstractTabUIModel) model; } + @Override protected AbstractTabUIHandler getHandler() { return (AbstractTabUIHandler) handler; } - /*@Override - public void setVisible(boolean b) { - if (b) { - switch (handler.getLocation()) { - - case LOCAL: - getLocalTab().doClick(); - break; - case REMOTE: - getRemoteTab().doClick(); - break; - case ALL: - case UNKNOW: - getAllTab().doClick(); - break; - } - } - super.setVisible(b); - }*/ - public JTable getTable(VCSEntryLocation modelName) { switch (modelName) { case ALL: @@ -111,7 +93,7 @@ case REMOTE: return getRemoteTab(); case UNKNOW: - break; + return null; } throw new IllegalStateException("no popup found for " + modelName); } Modified: trunk/lutinvcs/lutinvcs-ui-common/src/main/java/org/codelutin/vcs/ui/handler/DiffUIHandler.java =================================================================== --- trunk/lutinvcs/lutinvcs-ui-common/src/main/java/org/codelutin/vcs/ui/handler/DiffUIHandler.java 2008-04-06 21:47:39 UTC (rev 439) +++ trunk/lutinvcs/lutinvcs-ui-common/src/main/java/org/codelutin/vcs/ui/handler/DiffUIHandler.java 2008-04-06 23:12:13 UTC (rev 440) @@ -18,10 +18,13 @@ import org.codelutin.vcs.type.VCSAction; import org.codelutin.vcs.type.VCSEntryLocation; import org.codelutin.vcs.ui.AbstractDiffUI; +import org.codelutin.vcs.ui.VCSUIFactory; +import org.codelutin.vcs.ui.AbstractConfirmUI; import org.codelutin.vcs.ui.model.AbstractVCSEntriesTableModel; import org.codelutin.vcs.ui.model.DiffUIModel; import javax.swing.JTable; +import javax.swing.ListSelectionModel; import javax.swing.event.ListSelectionEvent; import javax.swing.event.ListSelectionListener; import java.beans.PropertyChangeEvent; @@ -99,8 +102,29 @@ getUi().getRefresh().setEnabled(hasActions); } - public void doAction(VCSAction action, VCSEntry model) { + public void doAction(VCSAction action, VCSEntry file) { + AbstractVCSEntriesTableModel model = getModel().getEntriesModel(); + List<VCSEntry> entries = new ArrayList<VCSEntry>(1); + entries.add(file); log.info(action + " : " + model); + ListSelectionModel selectionModel = getSelectionModel(); + if (action == VCSAction.REFRESH) { + selectionModel.clearSelection(); + // do refresh of all states + log.info("refresh :" + model.getRowCount()); + model.refresh(entries, System.nanoTime()); + } else { + + log.info("files to treate :" + entries.size()); + + AbstractConfirmUI confirmUI = VCSUIFactory.newConfirmUI(); + + confirmUI.getModel().init(action, model.getLocation(), entries.toArray(new VCSEntry[entries.size()])); + + confirmUI.setVisible(true); + //TODO SynchModel should listener for modification on ActionManagerQueue thread + log.info("TODO refresh states for files..."); + } } public void gotoNextDiff() { Deleted: trunk/lutinvcs/lutinvcs-ui-jaxx/src/main/uimodel/org/codelutin/vcs/ui/JDiffPanelUI.jaxx =================================================================== --- trunk/lutinvcs/lutinvcs-ui-jaxx/src/main/uimodel/org/codelutin/vcs/ui/JDiffPanelUI.jaxx 2008-04-06 21:47:39 UTC (rev 439) +++ trunk/lutinvcs/lutinvcs-ui-jaxx/src/main/uimodel/org/codelutin/vcs/ui/JDiffPanelUI.jaxx 2008-04-06 23:12:13 UTC (rev 440) @@ -1,15 +0,0 @@ -<!--Table> - <style source="common.css"/> - <row fill='both'> - <cell fill='both' weightx='1'--> -<JSplitPane id='splitPane2' orientation='horizontal' oneTouchExpandable='true'> - <JScrollPane id='remoteScroll' styleClass='updateScroll'> - <JTextArea id="remoteContent"/> - </JScrollPane> - <JScrollPane id='localScroll' styleClass='updateScroll'> - <JTextArea id="localContent"/> - </JScrollPane> -</JSplitPane> - <!--/cell> - </row> -</Table--> \ No newline at end of file Modified: trunk/lutinvcs/lutinvcs-ui-jaxx/src/main/uimodel/org/codelutin/vcs/ui/JDiffUI.jaxx =================================================================== --- trunk/lutinvcs/lutinvcs-ui-jaxx/src/main/uimodel/org/codelutin/vcs/ui/JDiffUI.jaxx 2008-04-06 21:47:39 UTC (rev 439) +++ trunk/lutinvcs/lutinvcs-ui-jaxx/src/main/uimodel/org/codelutin/vcs/ui/JDiffUI.jaxx 2008-04-06 23:12:13 UTC (rev 440) @@ -65,18 +65,33 @@ </JPanel> </cell> </row> - <row> - <cell fill='both' weighty='1' weightx='2'> - <!--JDiffPanelUI id="diffPanel"/--> - <JSplitPane id='splitPane2' orientation='horizontal' oneTouchExpandable='true'> - <JScrollPane id='remoteScroll' styleClass='updateScroll'> - <JTextArea id="remoteEditorContent"/> + <row fill='both'> + <cell fill='both' weighty='1' weightx='1'> + <JSplitPane id='splitPane2' orientation='horizontal' resizeWeight="0.5" dividerLocation="{0.5}"> + <JScrollPane id='remoteEditorScroll' styleClass='diffScroll'> + <JTextArea id="remoteEditorContent" editable='false'/> </JScrollPane> - <JScrollPane id='localScroll' styleClass='updateScroll'> + <JScrollPane id='localEditorScroll' styleClass='diffScroll'> <JTextArea id="localEditorContent"/> </JScrollPane> </JSplitPane> + + <!--Table fill='both'> + <row> + <cell fill='both' weighty='1' weightx='1'> + <JScrollPane id='remoteScroll' styleClass='diffScroll'> + <JTextArea id="remoteEditorContent" editable='false' constructorParams="20,80"/> + </JScrollPane> + </cell> + <cell fill='both' weighty='1' weightx='1'> + <JScrollPane id='localScroll' styleClass='diffScroll'> + <JTextArea id="localEditorContent" constructorParams="20,80"/> + </JScrollPane> + </cell> + </row> + </Table--> </cell> + </row> </Table> </AbstractDiffUI> Modified: trunk/lutinvcs/lutinvcs-ui-jaxx/src/main/uimodel/org/codelutin/vcs/ui/common.css =================================================================== --- trunk/lutinvcs/lutinvcs-ui-jaxx/src/main/uimodel/org/codelutin/vcs/ui/common.css 2008-04-06 21:47:39 UTC (rev 439) +++ trunk/lutinvcs/lutinvcs-ui-jaxx/src/main/uimodel/org/codelutin/vcs/ui/common.css 2008-04-06 23:12:13 UTC (rev 440) @@ -48,4 +48,9 @@ verticalScrollBarPolicy: 20; horizontalScrollBarPolicy: 31; visible: false; +} + +.diffScroll { + verticalScrollBarPolicy: 20; + horizontalScrollBarPolicy: 31; } \ No newline at end of file
participants (1)
-
tchemit@users.labs.libre-entreprise.org