Work at SourceForge, help us to make it a better place! We have an immediate need for a Support Technician in our San Francisco or Denver office.

Close

Commit [f65d45] Maximize Restore History

Bug fix: CtagsInterface unable to remove old tags

http://sourceforge.net/tracker/?func=detail&atid=565475&aid=3525480&group_id=588

- Add option pane to add/remove individual source files from the tag index
- Pane uses origin >>MISC:temp so includes source files referenced in tags
added using the "Add tag file..." action
- Add methods to replicate add/deleteTagsOfOrigin() for individual files
with >>MISC:temp as origin, use file path as proxy for origin ID
- Remove "Add tag file..." action
- Add "Update current file" and "Remove current file" actions
- Fix TagBrowser dockable refresh bug

Tom Power Tom Power 2012-05-11

changed docs/CHANGES.txt
changed docs/users-guide.xml
changed src/ctagsinterface/dockables/TagBrowser.java
changed src/ctagsinterface/index/TagIndex.java
changed src/ctagsinterface/main/CtagsInterfacePlugin.java
changed src/ctagsinterface/main/VFSHelper.java
changed src/ctagsinterface/options/DirsOptionPane.java
changed src/ctagsinterface/projects/ProjectDependencies.java
changed src/ctagsinterface/projects/ProjectRemoveAction.java
changed CtagsInterface.props
changed actions.xml
changed description.html
copied src/ctagsinterface/options/TagFilesOptionPane.java -> src/ctagsinterface/options/FilesOptionPane.java
docs/CHANGES.txt Diff Switch to side-by-side view
Loading...
docs/users-guide.xml Diff Switch to side-by-side view
Loading...
src/ctagsinterface/dockables/TagBrowser.java Diff Switch to side-by-side view
Loading...
src/ctagsinterface/index/TagIndex.java Diff Switch to side-by-side view
Loading...
src/ctagsinterface/main/CtagsInterfacePlugin.java Diff Switch to side-by-side view
Loading...
src/ctagsinterface/main/VFSHelper.java Diff Switch to side-by-side view
Loading...
src/ctagsinterface/options/DirsOptionPane.java Diff Switch to side-by-side view
Loading...
src/ctagsinterface/projects/ProjectDependencies.java Diff Switch to side-by-side view
Loading...
src/ctagsinterface/projects/ProjectRemoveAction.java Diff Switch to side-by-side view
Loading...
CtagsInterface.props Diff Switch to side-by-side view
Loading...
actions.xml Diff Switch to side-by-side view
Loading...
description.html Diff Switch to side-by-side view
Loading...
src/ctagsinterface/options/TagFilesOptionPane.java to src/ctagsinterface/options/FilesOptionPane.java
--- a/src/ctagsinterface/options/TagFilesOptionPane.java
+++ b/src/ctagsinterface/options/FilesOptionPane.java
@@ -15,7 +15,6 @@
 
 import org.gjt.sp.jedit.AbstractOptionPane;
 import org.gjt.sp.jedit.GUIUtilities;
-import org.gjt.sp.jedit.MiscUtilities;
 import org.gjt.sp.jedit.jEdit;
 import org.gjt.sp.jedit.Macros;
 import org.gjt.sp.jedit.browser.VFSBrowser;
@@ -27,40 +26,99 @@
 import ctagsinterface.main.VFSHelper;
 
 @SuppressWarnings("serial")
-public class TagFilesOptionPane extends AbstractOptionPane
+
+/**
+ * Pane for adding and removing tag files and individual source files
+ */
+public class FilesOptionPane extends AbstractOptionPane
 {
 
 	static public final String OPTION = CtagsInterfacePlugin.OPTION;
 	static public final String MESSAGE = CtagsInterfacePlugin.MESSAGE;
 	static public final String TagFiles = OPTION + "TagFiles.";
+	static public final String SourceFiles = OPTION + "SourceFiles.";
 	private JList tagFiles;
 	private DefaultListModel tagFilesModel;
-
-	public TagFilesOptionPane()
-	{
-		super("CtagsInterface-TagFiles");
+	private JList sourceFiles;
+	private DefaultListModel sourceFilesModel;
+
+	public FilesOptionPane()
+	{
+		super("CtagsInterface-Files");
+		setBorder(new EmptyBorder(5, 5, 5, 5));
+		sourceFilesModel = new DefaultListModel();
+		Vector<String> SourceFileList = getSourceFiles();
+		for (int i = 0; i < SourceFileList.size(); i++)
+			sourceFilesModel.addElement(SourceFileList.get(i));
+		sourceFiles = new JList(sourceFilesModel);
+		JScrollPane sourceScroller = new JScrollPane(sourceFiles);
+		sourceScroller.setBorder(BorderFactory.createTitledBorder(
+				jEdit.getProperty(MESSAGE + "sourceFiles")));
+		addComponent(sourceScroller, GridBagConstraints.HORIZONTAL);
+		JPanel sourceButtons = new JPanel();
+		JButton addSourceFile = new RolloverButton(GUIUtilities.loadIcon("Plus.png"));
+		sourceButtons.add(addSourceFile);
+		JButton removeSourceFile = new RolloverButton(GUIUtilities.loadIcon("Minus.png"));
+		sourceButtons.add(removeSourceFile);
+		JButton tagSourceFile = new JButton("Tag");
+		sourceButtons.add(tagSourceFile);
+		addComponent(sourceButtons);
+		addSourceFile.addActionListener(new ActionListener() {
+			public void actionPerformed(ActionEvent ae) {
+				VFSFileChooserDialog chooser = new VFSFileChooserDialog(
+					GUIUtilities.getParentDialog(FilesOptionPane.this),
+					jEdit.getActiveView(), System.getProperty("user.home"),
+					VFSBrowser.OPEN_DIALOG, false, false);
+				chooser.setTitle("Select tag file");
+				chooser.setVisible(true);
+				if (chooser.getSelectedFiles() == null)
+					return;
+				String SourceFilePath = chooser.getSelectedFiles()[0];
+				if (!sourceFilesModel.contains(SourceFilePath))
+					sourceFilesModel.addElement(SourceFilePath);
+			}
+		});
+
+		removeSourceFile.addActionListener(new ActionListener() {
+			public void actionPerformed(ActionEvent ae) {
+				int i = sourceFiles.getSelectedIndex();
+				if (i >= 0)
+					sourceFilesModel.removeElementAt(i);
+			}
+		});
+
+		tagSourceFile.addActionListener(new ActionListener() {
+			public void actionPerformed(ActionEvent ae) {
+				int i = sourceFiles.getSelectedIndex();
+				if (i >= 0) {
+					String sourceFilePath = (String) sourceFilesModel.getElementAt(i);
+					CtagsInterfacePlugin.addFile(jEdit.getActiveView(), sourceFilePath);
+				}
+			}
+		});
+
 		setBorder(new EmptyBorder(5, 5, 5, 5));
 		tagFilesModel = new DefaultListModel();
 		Vector<String> tagFileList = getTagFiles();
 		for (int i = 0; i < tagFileList.size(); i++)
 			tagFilesModel.addElement(tagFileList.get(i));
 		tagFiles = new JList(tagFilesModel);
-		JScrollPane scroller = new JScrollPane(tagFiles);
-		scroller.setBorder(BorderFactory.createTitledBorder(
+		JScrollPane tagFileScroller = new JScrollPane(tagFiles);
+		tagFileScroller.setBorder(BorderFactory.createTitledBorder(
 				jEdit.getProperty(MESSAGE + "tagFiles")));
-		addComponent(scroller, GridBagConstraints.HORIZONTAL);
-		JPanel buttons = new JPanel();
-		JButton add = new RolloverButton(GUIUtilities.loadIcon("Plus.png"));
-		buttons.add(add);
-		JButton remove = new RolloverButton(GUIUtilities.loadIcon("Minus.png"));
-		buttons.add(remove);
-		JButton tag = new JButton("Tag");
-		buttons.add(tag);
-		addComponent(buttons);
-		add.addActionListener(new ActionListener() {
+		addComponent(tagFileScroller, GridBagConstraints.HORIZONTAL);
+		JPanel tagFileButtons = new JPanel();
+		JButton addTagFile = new RolloverButton(GUIUtilities.loadIcon("Plus.png"));
+		tagFileButtons.add(addTagFile);
+		JButton removeTagFile = new RolloverButton(GUIUtilities.loadIcon("Minus.png"));
+		tagFileButtons.add(removeTagFile);
+		JButton tagTagFile = new JButton("Tag");
+		tagFileButtons.add(tagTagFile);
+		addComponent(tagFileButtons);
+		addTagFile.addActionListener(new ActionListener() {
 			public void actionPerformed(ActionEvent ae) {
 				VFSFileChooserDialog chooser = new VFSFileChooserDialog(
-					GUIUtilities.getParentDialog(TagFilesOptionPane.this),
+					GUIUtilities.getParentDialog(FilesOptionPane.this),
 					jEdit.getActiveView(), System.getProperty("user.home"),
 					VFSBrowser.OPEN_DIALOG, false, false);
 				chooser.setTitle("Select tag file");
@@ -68,7 +126,7 @@
 				if (chooser.getSelectedFiles() == null)
 					return;
 				String tagFilePath = chooser.getSelectedFiles()[0];
-				if (!VFSHelper.checkTagFileVFS(tagFilePath)) {
+				if (!VFSHelper.checkFileExtension(tagFilePath, "tag")) {
 					Macros.message(jEdit.getActiveView(), "File name needs to end with \".tag\"");
 					return;
 				}
@@ -77,7 +135,7 @@
 			}
 		});
 
-		remove.addActionListener(new ActionListener() {
+		removeTagFile.addActionListener(new ActionListener() {
 			public void actionPerformed(ActionEvent ae) {
 				int i = tagFiles.getSelectedIndex();
 				if (i >= 0)
@@ -85,7 +143,7 @@
 			}
 		});
 
-		tag.addActionListener(new ActionListener() {
+		tagTagFile.addActionListener(new ActionListener() {
 			public void actionPerformed(ActionEvent ae) {
 				int i = tagFiles.getSelectedIndex();
 				if (i >= 0) {
@@ -94,6 +152,7 @@
 				}
 			}
 		});
+
 	}
 
 	public void saveOrigins(OriginType origin, DefaultListModel model)
@@ -105,16 +164,38 @@
 		CtagsInterfacePlugin.updateOrigins(origin, names);
 	}
 
+	public void saveSourceFiles(DefaultListModel model)
+	{
+		Vector<String> sourceFiles = getSourceFiles();
+		// Remove obsolete files
+		for (String sf : sourceFiles) {
+			if (!sourceFilesModel.contains(sf)) {
+				CtagsInterfacePlugin.deleteFile(jEdit.getActiveView(), sf);
+			}
+		}
+		// Add new files
+		for (int i = 0; i < sourceFilesModel.size(); i++) {
+			String sf = sourceFilesModel.getElementAt(i).toString();
+			if (!sourceFiles.contains(sf)) {
+				CtagsInterfacePlugin.addFile(jEdit.getActiveView(), sf);
+			}
+		}
+	}
+
 	@Override
 	protected void _save()
 	{
 		saveOrigins(OriginType.TAGFILE, tagFilesModel);
+		saveSourceFiles(sourceFilesModel);
 	}
 
 	static public Vector<String> getTagFiles()
 	{
-		Vector<String> tagFiles = new Vector<String>();
-		CtagsInterfacePlugin.getIndex().getOrigins(OriginType.TAGFILE, tagFiles);
-		return tagFiles;
+		return CtagsInterfacePlugin.getIndex().getOrigins(OriginType.TAGFILE);
+	}
+
+	static public Vector<String> getSourceFiles()
+	{
+		return CtagsInterfacePlugin.getIndex().getFilesOfOrigin(OriginType.MISC);
 	}
 }