Improved code snippet selection.
git-svn-id: https://pmd.svn.sourceforge.net/svnroot/pmd/trunk@1920 51baf565-9d33-0410-a72c-fc3788e3496d
This commit is contained in:
@ -17,6 +17,7 @@ import javax.swing.tree.DefaultTreeModel;
|
||||
import javax.swing.tree.TreeSelectionModel;
|
||||
import java.awt.BorderLayout;
|
||||
import java.util.Vector;
|
||||
import org.gjt.sp.util.Log;
|
||||
//End of Imports
|
||||
|
||||
/**
|
||||
@ -47,16 +48,16 @@ public class CPDDuplicateCodeViewer extends JPanel
|
||||
DefaultMutableTreeNode node = (DefaultMutableTreeNode)tree.getLastSelectedPathComponent();
|
||||
if (node == null) return;
|
||||
|
||||
System.out.println("Node is " + node +" class "+ node.getClass());
|
||||
//System.out.println("Node is " + node +" class "+ node.getClass());
|
||||
if (node.isLeaf() && node instanceof Duplicate)
|
||||
{
|
||||
Duplicate duplicate = (Duplicate)node;
|
||||
gotoDuplicate(duplicate);
|
||||
System.out.println("Got!! " + duplicate);
|
||||
//System.out.println("Got!! " + duplicate);
|
||||
}
|
||||
else
|
||||
{
|
||||
System.out.println("Iila something else. Please check ");
|
||||
//System.out.println("Something else. Please check ");
|
||||
}
|
||||
}
|
||||
});
|
||||
@ -86,9 +87,12 @@ public class CPDDuplicateCodeViewer extends JPanel
|
||||
public void run()
|
||||
{
|
||||
view.setBuffer(buffer);
|
||||
int start = buffer.getLineStartOffset(duplicate.getBeginLine()-1);
|
||||
int end = buffer.getLineEndOffset(duplicate.getEndLine()-1);
|
||||
view.getTextArea().setSelection(new Selection.Range(start,end));
|
||||
|
||||
int start = buffer.getLineStartOffset(duplicate.getBeginLine());
|
||||
int end = buffer.getLineEndOffset(duplicate.getEndLine()-2);
|
||||
//Log.log(Log.DEBUG, this.getClass(), "Start Line "+ duplicate.getBeginLine() + " End Line "+ duplicate.getEndLine() + " Start " + start + " End "+ end);
|
||||
//Since an AIOOB Exception is thrown if the end is the end of file. we do a -1 from end to fix it.
|
||||
view.getTextArea().setSelection(new Selection.Range(start,end -1));
|
||||
view.getTextArea().moveCaretPosition(start);
|
||||
}
|
||||
});
|
||||
@ -103,7 +107,7 @@ public class CPDDuplicateCodeViewer extends JPanel
|
||||
|
||||
public void addDuplicates(Duplicates duplicates)
|
||||
{
|
||||
System.out.println("Inside addDuplicates " + duplicates +" Root child count "+ treeModel.getChildCount(treeModel.getRoot()));
|
||||
//System.out.println("Inside addDuplicates " + duplicates +" Root child count "+ treeModel.getChildCount(treeModel.getRoot()));
|
||||
getRoot().add(duplicates);
|
||||
//vecDuplicates.addElement(duplicates);
|
||||
}
|
||||
|
Reference in New Issue
Block a user