# This patch file was generated by NetBeans IDE
# Following Index: paths are relative to: /data/work/src/netbeans-cm
# This patch can be applied using context Tools: Patch action on respective folder.
# It uses platform neutral UTF-8 encoding and \n newlines.
# Above lines and this line are ignored by the patching process.
Index: versioning.core/nbproject/project.xml
--- versioning.core/nbproject/project.xml Base (BASE)
+++ versioning.core/nbproject/project.xml Locally Modified (Based On LOCAL)
@@ -220,6 +220,11 @@
+ org.netbeans.modules.versioning.ui
+
+
+
+
org.openide.filesystems
Index: versioning.core/src/org/netbeans/modules/versioning/core/SPIAccessor.java
--- versioning.core/src/org/netbeans/modules/versioning/core/SPIAccessor.java Base (BASE)
+++ versioning.core/src/org/netbeans/modules/versioning/core/SPIAccessor.java Locally Modified (Based On LOCAL)
@@ -47,6 +47,8 @@
import java.util.*;
import org.netbeans.modules.versioning.core.api.VCSFileProxy;
+import org.netbeans.modules.versioning.core.spi.VCSHistoryProvider;
+import org.netbeans.modules.versioning.core.spi.VCSHistoryProvider.HistoryEntry;
import org.openide.filesystems.FileObject;
/**
@@ -71,4 +73,8 @@
public abstract VCSContext createContextForFiles(Set files, Set extends FileObject> originalFiles);
+ public abstract Object[] getDelegateEntry(VCSHistoryProvider.HistoryEntry entry);
+
+ public abstract void setDelegateEntry(HistoryEntry entry, Object[] lookupObjects);
+
}
Index: versioning.core/src/org/netbeans/modules/versioning/core/spi/SPIAccessorImpl.java
--- versioning.core/src/org/netbeans/modules/versioning/core/spi/SPIAccessorImpl.java Base (BASE)
+++ versioning.core/src/org/netbeans/modules/versioning/core/spi/SPIAccessorImpl.java Locally Modified (Based On LOCAL)
@@ -46,6 +46,7 @@
import java.util.*;
import org.netbeans.modules.versioning.core.SPIAccessor;
import org.netbeans.modules.versioning.core.api.VCSFileProxy;
+import org.netbeans.modules.versioning.core.spi.VCSHistoryProvider.HistoryEntry;
import org.openide.filesystems.FileObject;
/**
@@ -55,8 +56,19 @@
*/
final class SPIAccessorImpl extends SPIAccessor {
+
@Override
public VCSContext createContextForFiles(Set files, Set extends FileObject> originalFiles) {
return VCSContext.forFiles(files, originalFiles);
}
+
+ @Override
+ public void setDelegateEntry(HistoryEntry entry, Object[] lookupObjects) {
+ entry.setLookupObjects(lookupObjects);
}
+
+ @Override
+ public Object[] getDelegateEntry(HistoryEntry entry) {
+ return entry.getLookupObjects();
+ }
+}
Index: versioning.core/src/org/netbeans/modules/versioning/core/spi/VCSHistoryProvider.java
--- versioning.core/src/org/netbeans/modules/versioning/core/spi/VCSHistoryProvider.java Base (BASE)
+++ versioning.core/src/org/netbeans/modules/versioning/core/spi/VCSHistoryProvider.java Locally Modified (Based On LOCAL)
@@ -278,7 +278,12 @@
}
/**
- * Returns actions which might be called for this HistoryEntry.
+ * Returns actions which might be called for this HistoryEntry as it is presented
+ * in the history view.
+ * It is ensured that if the returned actions are a {@link ContextAwareAction}, they
+ * will be provided with a context containing the nodes selected in the history view.
+ * The lookup of those nodes will again contain the relevant {@link HistoryEntry}
+ * and {@link java.io.File}-s for which the action should be invoked.
*
* @return a field of actions
*/
@@ -298,8 +303,17 @@
revisionProvider.getRevisionFile(originalFile, revisionFile);
}
}
+
+ private Object[] lookupObjects;
+ void setLookupObjects(Object[] lookupObjects) {
+ this.lookupObjects = lookupObjects;
}
+ Object[] getLookupObjects() {
+ return lookupObjects;
+ }
+ }
+
/**
* Adds a listener for history change events.
*
Index: versioning.core/src/org/netbeans/modules/versioning/core/util/Utils.java
--- versioning.core/src/org/netbeans/modules/versioning/core/util/Utils.java Base (BASE)
+++ versioning.core/src/org/netbeans/modules/versioning/core/util/Utils.java Locally Modified (Based On LOCAL)
@@ -43,12 +43,15 @@
import java.beans.PropertyChangeListener;
import java.io.File;
+import java.util.Date;
import java.util.prefs.Preferences;
-import org.netbeans.modules.versioning.core.FlatFolder;
-import org.netbeans.modules.versioning.core.VcsVisibilityQueryImplementation;
-import org.netbeans.modules.versioning.core.VersioningConfig;
-import org.netbeans.modules.versioning.core.VersioningManager;
+import javax.swing.Action;
+import org.netbeans.modules.versioning.core.*;
import org.netbeans.modules.versioning.core.api.VCSFileProxy;
+import org.netbeans.modules.versioning.core.spi.VCSHistoryProvider;
+import org.netbeans.modules.versioning.core.spi.VCSHistoryProvider.HistoryEntry;
+import org.netbeans.modules.versioning.core.spi.VCSHistoryProvider.MessageEditProvider;
+import org.netbeans.modules.versioning.core.spi.VCSHistoryProvider.RevisionProvider;
import org.netbeans.modules.versioning.core.util.VCSSystemProvider.VersioningSystem;
/**
@@ -190,5 +193,14 @@
VersioningManager.getInstance().removePropertyChangeListener(l);
}
+ public static Object[] getDelegateEntry(VCSHistoryProvider.HistoryEntry entry) {
+ return SPIAccessor.IMPL.getDelegateEntry(entry);
+ }
+ public static HistoryEntry createHistoryEntry(VCSFileProxy[] proxies, Date dateTime, String message, String username, String usernameShort, String revision, String revisionShort, Action[] actions, RevisionProvider rp, MessageEditProvider mep, Object[] lookupObjects) {
+ HistoryEntry entry = new HistoryEntry(proxies, dateTime, message, username, usernameShort, revision, revisionShort, actions, rp, mep);
+ SPIAccessor.IMPL.setDelegateEntry(entry, lookupObjects);
+ return entry;
}
+
+}
Index: versioning.core/test/unit/src/org/netbeans/modules/versioning/core/spi/VCSHistoryTest.java
--- versioning.core/test/unit/src/org/netbeans/modules/versioning/core/spi/VCSHistoryTest.java Base (BASE)
+++ versioning.core/test/unit/src/org/netbeans/modules/versioning/core/spi/VCSHistoryTest.java Locally Modified (Based On LOCAL)
@@ -46,6 +46,7 @@
import java.io.File;
import java.io.IOException;
+import java.util.Collection;
import java.util.Date;
import javax.swing.Action;
import org.netbeans.junit.NbTestCase;
@@ -56,6 +57,8 @@
import org.netbeans.modules.versioning.core.util.VCSSystemProvider;
import org.netbeans.modules.versioning.spi.testvcs.TestVCS;
import org.netbeans.modules.versioning.spi.testvcs.TestVCSHistoryProvider;
+import org.netbeans.modules.versioning.ui.history.HistoryTestKit;
+import org.openide.nodes.Node;
import org.openide.util.Lookup;
import org.openide.util.test.MockLookup;
@@ -202,6 +205,32 @@
assertTrue(TestVCSHistoryProvider.instance.revisionProvided);
}
+ public void testHistoryNodesProperlySetup() throws IOException {
+ File f1 = new File(dataRootDir, "workdir/root-test-versioned/file1" + TestVCSHistoryProvider.FILE_PROVIDES_REVISIONS_SUFFIX);
+ f1.createNewFile();
+ VCSFileProxy proxy1 = VCSFileProxy.createFileProxy(f1);
+ File f2 = new File(dataRootDir, "workdir/root-test-versioned/file2" + TestVCSHistoryProvider.FILE_PROVIDES_REVISIONS_SUFFIX);
+ f2.createNewFile();
+ VCSFileProxy proxy2 = VCSFileProxy.createFileProxy(f2);
+ VCSSystemProvider.VersioningSystem pvs = Utils.getOwner(proxy1);
+ assertNotNull(pvs);
+ org.netbeans.modules.versioning.core.spi.VCSHistoryProvider php = pvs.getVCSHistoryProvider();
+ assertNotNull(php);
+
+ org.netbeans.modules.versioning.core.spi.VCSHistoryProvider.HistoryEntry[] phistory = php.getHistory(new VCSFileProxy[] {proxy1, proxy2}, null);
+ assertNotNull(phistory);
+ assertTrue(phistory.length > 0);
+
+ Node node = HistoryTestKit.createHistoryNode(phistory[0]);
+ assertNotNull(node.getLookup().lookup(HistoryEntry.class));
+
+ Collection extends VCSFileProxy> proxies = node.getLookup().lookupAll(VCSFileProxy.class);
+ assertNotNull(proxies);
+ assertTrue(proxies.size() >= 2);
+ assertTrue(proxies.contains(proxy1));
+ assertTrue(proxies.contains(proxy2));
+ }
+
private void deleteRecursively(File f) {
if(f.isFile()) {
f.delete();
Index: versioning.core/test/unit/src/org/netbeans/modules/versioning/spi/testvcs/TestVCSHistoryProvider.java
--- versioning.core/test/unit/src/org/netbeans/modules/versioning/spi/testvcs/TestVCSHistoryProvider.java Base (BASE)
+++ versioning.core/test/unit/src/org/netbeans/modules/versioning/spi/testvcs/TestVCSHistoryProvider.java Locally Modified (Based On LOCAL)
@@ -71,11 +71,10 @@
@Override
public HistoryEntry[] getHistory(VCSFileProxy[] files, Date fromDate) {
- for (VCSFileProxy file : files) {
- if(file.getName().endsWith(FILE_PROVIDES_REVISIONS_SUFFIX)) {
+ if(files[0].getName().endsWith(FILE_PROVIDES_REVISIONS_SUFFIX)) {
return new VCSHistoryProvider.HistoryEntry[] {
new VCSHistoryProvider.HistoryEntry(
- new VCSFileProxy[] {file},
+ files,
new Date(System.currentTimeMillis()),
"msg",
"user",
@@ -84,9 +83,7 @@
"1234567890",
new Action[0],
this)};
-
}
- }
return history;
}
Index: versioning/apichanges.xml
--- versioning/apichanges.xml Base (BASE)
+++ versioning/apichanges.xml Locally Modified (Based On LOCAL)
@@ -111,6 +111,21 @@
+ Support ContextAwareActions
+
+
+
+
+
+ Ensure that ContextAwareAction
-s provided via VCSHistoryProvider.HistoryEntry.getActions()
+ are created with a context containing the selected nodes in a files editor history tab. Those nodes than will have
+ the relevant HistoryEntry
and files in their lookup.
+
+
+
+
+
+
Added VCSHistoryProvider
Index: versioning/nbproject/project.xml
--- versioning/nbproject/project.xml Base (BASE)
+++ versioning/nbproject/project.xml Locally Modified (Based On LOCAL)
@@ -148,13 +148,18 @@
+ org.netbeans.modules.nbjunit
+
+
+
org.netbeans.modules.versioning.masterfs
- org.netbeans.modules.nbjunit
+ org.netbeans.modules.versioning.ui
+
org.netbeans.modules.versioning.util
Index: versioning/src/org/netbeans/modules/versioning/DelegatingVCS.java
--- versioning/src/org/netbeans/modules/versioning/DelegatingVCS.java Base (BASE)
+++ versioning/src/org/netbeans/modules/versioning/DelegatingVCS.java Locally Modified (Based On LOCAL)
@@ -635,7 +635,7 @@
};
}
proxyHistory[i] =
- new HistoryEntry(
+ Utils.createHistoryEntry(
proxies,
he.getDateTime(),
he.getMessage(),
@@ -645,7 +645,8 @@
he.getRevisionShort(),
he.getActions(),
rp,
- mep);
+ mep,
+ new Object[] {he});
}
return proxyHistory;
}
Index: versioning/src/org/netbeans/modules/versioning/spi/VCSHistoryProvider.java
--- versioning/src/org/netbeans/modules/versioning/spi/VCSHistoryProvider.java Base (BASE)
+++ versioning/src/org/netbeans/modules/versioning/spi/VCSHistoryProvider.java Locally Modified (Based On LOCAL)
@@ -45,6 +45,7 @@
import java.io.IOException;
import java.util.Date;
import javax.swing.Action;
+import org.openide.util.ContextAwareAction;
/**
@@ -306,11 +307,16 @@
}
/**
- * Returns actions which might be called for this HistoryEntry.
+ * Returns actions which might be called for this HistoryEntry as it is presented
+ * in the history view.
+ * It is ensured that if the returned actions are a {@link ContextAwareAction}, they
+ * will be provided with a context containing the nodes selected in the history view.
+ * The lookup of those nodes will again contain the relevant {@link HistoryEntry}
+ * and {@link java.io.File}-s for which the action should be invoked.
*
* @return a field of actions
*
- * @since 1.29
+ * @since 1.31
*/
public Action[] getActions() {
return actions;
Index: versioning/test/unit/src/org/netbeans/modules/versioning/spi/VCSHistoryTest.java
--- versioning/test/unit/src/org/netbeans/modules/versioning/spi/VCSHistoryTest.java Base (BASE)
+++ versioning/test/unit/src/org/netbeans/modules/versioning/spi/VCSHistoryTest.java Locally Modified (Based On LOCAL)
@@ -44,9 +44,12 @@
package org.netbeans.modules.versioning.spi;
+import java.awt.event.ActionEvent;
import java.io.File;
import java.io.IOException;
+import java.util.Collection;
import java.util.Date;
+import javax.swing.AbstractAction;
import javax.swing.Action;
import org.netbeans.junit.NbTestCase;
import org.netbeans.modules.versioning.core.api.VCSFileProxy;
@@ -54,9 +57,13 @@
import org.netbeans.modules.versioning.core.util.VCSSystemProvider;
import org.netbeans.modules.versioning.spi.VCSHistoryProvider.HistoryEntry;
import org.netbeans.modules.versioning.spi.testvcs.TestVCSHistoryProvider;
+import org.netbeans.modules.versioning.ui.history.HistoryTestKit;
import org.openide.util.Lookup;
-import org.netbeans.modules.versioning.spi.testvcs.TestVCSInterceptor;
+import org.openide.filesystems.FileObject;
+import org.openide.filesystems.FileUtil;
+import org.openide.nodes.Node;
+import org.openide.util.ContextAwareAction;
/**
* Versioning SPI unit tests of VCSInterceptor.
@@ -207,6 +214,32 @@
fail("exception should be raised on readonly entry");
}
+ public void testHistoryNodesProperlySetup() throws IOException {
+ File f1 = new File(dataRootDir, "workdir/root-test-versioned/file1" + TestVCSHistoryProvider.FILE_PROVIDES_REVISIONS_SUFFIX);
+ f1.createNewFile();
+ VCSFileProxy proxy1 = VCSFileProxy.createFileProxy(f1);
+ File f2 = new File(dataRootDir, "workdir/root-test-versioned/file2" + TestVCSHistoryProvider.FILE_PROVIDES_REVISIONS_SUFFIX);
+ f2.createNewFile();
+ VCSFileProxy proxy2 = VCSFileProxy.createFileProxy(f2);
+ VCSSystemProvider.VersioningSystem pvs = Utils.getOwner(proxy1);
+ assertNotNull(pvs);
+ org.netbeans.modules.versioning.core.spi.VCSHistoryProvider php = pvs.getVCSHistoryProvider();
+ assertNotNull(php);
+
+ org.netbeans.modules.versioning.core.spi.VCSHistoryProvider.HistoryEntry[] phistory = php.getHistory(new VCSFileProxy[] {proxy1, proxy2}, null);
+ assertNotNull(phistory);
+ assertTrue(phistory.length > 0);
+
+ Node node = HistoryTestKit.createHistoryNode(phistory[0]);
+ assertNotNull(node.getLookup().lookup(HistoryEntry.class));
+
+ Collection extends File> fos = node.getLookup().lookupAll(File.class);
+ assertNotNull(fos);
+ assertTrue(fos.size() >= 2);
+ assertTrue(fos.contains(f1));
+ assertTrue(fos.contains(f2));
+ }
+
private void deleteRecursively(File f) {
if(f.isFile()) {
f.delete();
@@ -236,4 +269,21 @@
this.message = message;
}
}
+
+ private class HistoryAwareAction extends AbstractAction implements ContextAwareAction {
+ private Lookup context;
+
+ @Override
+ public void actionPerformed(ActionEvent e) {
+
}
+
+ @Override
+ public Action createContextAwareInstance(Lookup actionContext) {
+ this.context = actionContext;
+ return this;
+ }
+
+ }
+
+}
Index: versioning/test/unit/src/org/netbeans/modules/versioning/spi/testvcs/TestVCSHistoryProvider.java
--- versioning/test/unit/src/org/netbeans/modules/versioning/spi/testvcs/TestVCSHistoryProvider.java Base (BASE)
+++ versioning/test/unit/src/org/netbeans/modules/versioning/spi/testvcs/TestVCSHistoryProvider.java Locally Modified (Based On LOCAL)
@@ -47,6 +47,8 @@
import javax.swing.AbstractAction;
import javax.swing.Action;
import org.netbeans.modules.versioning.spi.VCSHistoryProvider;
+import org.openide.util.ContextAwareAction;
+import org.openide.util.Lookup;
/**
*
@@ -71,22 +73,19 @@
@Override
public HistoryEntry[] getHistory(File[] files, Date fromDate) {
- for (File file : files) {
- if(file.getName().endsWith(FILE_PROVIDES_REVISIONS_SUFFIX)) {
+ if(files[0].getName().endsWith(FILE_PROVIDES_REVISIONS_SUFFIX)) {
return new VCSHistoryProvider.HistoryEntry[] {
new VCSHistoryProvider.HistoryEntry(
- new File[] {file},
+ files,
new Date(System.currentTimeMillis()),
"msg",
"user",
"username",
"12345",
"1234567890",
- new Action[0],
+ new Action[] {new HistoryAwareAction()},
this)};
-
}
- }
return history;
}
@@ -114,4 +113,20 @@
public void getRevisionFile(File originalFile, File revisionFile) {
revisionProvided = true;
}
+
+ public class HistoryAwareAction extends AbstractAction implements ContextAwareAction {
+ public Lookup context;
+
+ @Override
+ public void actionPerformed(ActionEvent e) {
+
}
+
+ @Override
+ public Action createContextAwareInstance(Lookup actionContext) {
+ this.context = actionContext;
+ return this;
+ }
+
+ }
+}